Skip to content

Commit

Permalink
chore: use github packages (#1323)
Browse files Browse the repository at this point in the history
  • Loading branch information
septs committed Jul 20, 2020
1 parent 1e3e643 commit 3e6c6c6
Show file tree
Hide file tree
Showing 15 changed files with 105 additions and 128 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ executors:
working_directory: ~/repo
commands:
restore_workspace:
description: 'Restore the workspace'
description: "Restore the workspace"
steps:
- attach_workspace:
at: ~/
Expand Down Expand Up @@ -74,7 +74,7 @@ jobs:
steps:
- restore_workspace
- run:
name: 'Publish Release on GitHub'
name: "Publish Release on GitHub"
command: |
set -o nounset
mkdir ~/repo/release
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/E2E.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ jobs:
image: differui/node-14.4.0-browsers:v1

# more: https://github.community/t5/GitHub-Actions/How-to-run-action-as-a-non-root-user/m-p/45733/highlight/true#M6330
options: '--user 1000
options: "--user 1000
-v /home/ubuntu/.cache/yarn/v6:/tmp/.yarn-cache-1000/v6
-v /home/ubuntu/.cache/alice_home:/tmp/alice_home
-v /home/ubuntu/.cache/bob_home:/tmp/bob_home
-v /home/ubuntu/.e2e/e2e-test:/tmp/e2e-test'
-v /home/ubuntu/.e2e/e2e-test:/tmp/e2e-test"

# more: https://stackoverflow.com/a/60202672/1986338
# volumes:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Install Dependencies
run: |
yarn config set cache-folder /tmp/.yarn-cache-1000/v6
yarn install --link-duplicates --frozen-lockfile --pure-lockfile
yarn install --link-duplicates --frozen-lockfile --pure-lockfile --verbose
linters:
needs: setup
runs-on: self-hosted
Expand Down
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@dimensiondev:registry=https://npm.pkg.github.com/
//npm.pkg.github.com/:_authToken=6c6372312c5169327ac9c3fb7793bf4ed971133b
28 changes: 13 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,27 @@
"build-storybook": "build-storybook -s public --quiet",
"build:base": "webpack --mode production",
"build:chromium": "webpack --mode production --chromium",
"build:e2e": "webpack --mode production --e2e",
"build:firefox": "webpack --mode production --firefox --reproducible-build",
"build:gecko": "webpack --mode production --firefox-gecko",
"build:e2e": "webpack --mode production --e2e",
"build:ios": "run-s build:ios:webpack build:ios:ext:prebuilt",
"build:ios:webpack": "webpack --mode production --wk-webview",
"build:ios:ext:prebuilt": "ts-node scripts/webextensiom-shim-prebuilt.ts",
"build:ios:webpack": "webpack --mode production --wk-webview",
"compile:contracts": "./scripts/contracts.sh",
"install": "ts-node scripts/postinstall.ts",
"lint": "eslint src/ --ext .ts,.tsx --fix",
"lint:report": "eslint src/ --ext .ts,.tsx --format junit -o reports/junit/eslint-results.xml",
"lint:typecoverage": "type-coverage --strict --ignore-catch --ignore-files src/plugins/Wallet/contracts/** --ignore-files **/__tests__/** --ignore-files **\\__tests__\\** --detail --at-least 98",
"start": "webpack-dev-server --mode development",
"start:android": "webpack-dev-server --firefox-android --mode development",
"start:chromium": "webpack-dev-server --chromium --mode development",
"start:e2e": "webpack-dev-server --e2e --mode development",
"start:firefox": "webpack-dev-server --firefox --mode development",
"start:gecko": "webpack-dev-server --firefox-gecko --mode development",
"start:ios": "webpack-dev-server --wk-webview --mode development",
"start:e2e": "webpack-dev-server --e2e --mode development",
"storybook": "start-storybook -p 9009 -s public --quiet",
"test": "jest --verbose --watch",
"test:ci": "jest --verbose --ci --collectCoverage=true --reporters=default --reporters=jest-junit -w 1 --forceExit",
"test:e2e": "jest --verbose --runInBand --config=jest-e2e.config.js",
"uninstall": "ts-node scripts/postinstall.ts"
"test:e2e": "jest --verbose --runInBand --config=jest-e2e.config.js"
},
"husky": {
"hooks": {
Expand All @@ -45,8 +43,9 @@
]
},
"dependencies": {
"@dimensiondev/stego-js": "^0.11.0",
"@holoflows/kit": "https://github.com/DimensionDev/holoflows-kit",
"@dimensiondev/matrix-js-sdk-type": "^1.0.0-3",
"@dimensiondev/stego-js": "^0.11.0-11",
"@holoflows/kit": "npm:@dimensiondev/holoflows-kit@0.7.0-7",
"@material-ui/core": "4.10.2",
"@material-ui/icons": "4.9.1",
"@material-ui/lab": "^4.0.0-alpha.56",
Expand Down Expand Up @@ -86,7 +85,6 @@
"jsqr": "^1.3.1",
"lodash-es": "^4.17.11",
"matrix-js-sdk": "^7.0.0",
"matrix-js-sdk-type": "https://github.com/Jack-Works/matrix-js-sdk-type",
"metamask-extension-provider": "^1.1.1",
"notistack": "^0.9.17",
"pvtsutils": "^1.0.10",
Expand Down Expand Up @@ -117,6 +115,9 @@
"devDependencies": {
"@commitlint/cli": "^9.0.1",
"@commitlint/config-conventional": "^9.0.1",
"@dimensiondev/webcrypto": "^0.1.0-11",
"@dimensiondev/webextension-shim": "^0.0.3-17",
"@dimensiondev/webpack-web-ext-plugin": "^0.0.3-6",
"@nice-labs/git-flow-init": "^1.0.1",
"@nice-labs/git-rev": "^3.4.2",
"@sinonjs/text-encoding": "^0.7.1",
Expand Down Expand Up @@ -182,23 +183,20 @@
"typechain-target-web3-v1": "^1.0.4",
"typescript": "^3.9.6",
"web-ext": "^4.3.0",
"webcrypto": "https://github.com/DimensionDev/webcrypto",
"webextension-shim": "https://github.com/DimensionDev/webextension-polyfill",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.12",
"webpack-dev-server": "^3.11.0",
"webpack-extension-manifest-plugin": "^0.5.0",
"webpack-manifest-plugin": "^2.2.0",
"webpack-notifier": "^1.8.0",
"webpack-web-ext-plugin": "github:DimensionDev/webpack-web-ext-plugin",
"yargs": "^15.3.1"
},
"engines": {
"node": ">=14.4.0"
},
"optionalDependencies": {
"expect-puppeteer": "^4.4.0",
"jest-puppeteer": "^4.4.0",
"puppeteer": "^3.1.0"
},
"engines": {
"node": ">=14.4.0"
}
}
30 changes: 6 additions & 24 deletions scripts/ci-build.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,18 @@
import { execFileSync, ExecFileSyncOptions } from 'child_process'
import path from 'path'
import os from 'os'
import git from '@nice-labs/git-rev'

const cwd = path.join(__dirname, '..')
const BUILD_PATH = path.join(cwd, 'build')
const stdio = [process.stdin, process.stdout, process.stderr]
const shell = os.platform() === 'win32'

const exec = (command: string, args: string[], options?: ExecFileSyncOptions) => {
console.log('$', command, args.join(' '), '# cwd:', options?.cwd ?? cwd)
return execFileSync(command, args, { cwd, stdio, shell, ...options })
}

function buildTypes(name: string): string[] {
// Always build full types
return ['base', 'chromium', 'firefox', 'gecko', 'iOS']
}
import { BUILD_PATH, ROOT_PATH, run } from './utils'

const branch = git.branchName()
const types = buildTypes(branch.toLowerCase())
const types = ['base', 'chromium', 'firefox', 'gecko', 'iOS']
console.log(`Branch: ${branch}`)
for (const type of types) {
console.log('#', 'Building for target:', type)
if (type === 'chromium' && types.includes('base')) {
// chromium doesn't have it's own changes yet.
// just copying base version is acceptable
exec('cp', ['-v', 'Maskbook.base.zip', 'Maskbook.chromium.zip'])
run(ROOT_PATH, 'cp', '-v', 'Maskbook.base.zip', 'Maskbook.chromium.zip')
} else {
exec('yarn', [`build:${type.toLowerCase()}`])
exec('zip', ['-FS', '-r', `../Maskbook.${type}.zip`, '.'], { cwd: BUILD_PATH })
exec('rm', ['-rfv', 'build'])
run(ROOT_PATH, 'yarn', `build:${type.toLowerCase()}`)
run(BUILD_PATH, 'zip', '-FS', '-r', `../Maskbook.${type}.zip`, '.')
run(ROOT_PATH, 'rm', '-rfv', 'build')
}
exec('free', ['-h'])
}
12 changes: 0 additions & 12 deletions scripts/postinstall.ts

This file was deleted.

16 changes: 16 additions & 0 deletions scripts/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { execFileSync } from 'child_process'
import os from 'os'
import path from 'path'

export const ROOT_PATH = path.resolve(__dirname, '..')
export const NODE_MODULES_PATH = path.resolve(ROOT_PATH, 'node_modules')
export const BUILD_PATH = path.resolve(ROOT_PATH, 'build')

export function run(cwd: string | undefined, cmd: string, ...args: string[]) {
console.log('$', cmd, args.join(' '), '# cwd:', cwd)
return execFileSync(cmd, args, {
cwd,
stdio: [process.stdin, process.stdout, process.stderr],
shell: os.platform() === 'win32',
})
}
33 changes: 13 additions & 20 deletions scripts/webextensiom-shim-prebuilt.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
import { execFileSync } from 'child_process'
import fs from 'fs'
import path from 'path'
import os from 'os'
import { BUILD_PATH, ROOT_PATH, NODE_MODULES_PATH, run } from './utils'

const stdio = [process.stdin, process.stdout, process.stderr]
const shell = os.platform() === 'win32'
const run = (cwd: string, cmd: string, ...args: string[]) => execFileSync(cmd, args, { cwd, stdio, shell })
run(ROOT_PATH, 'web-ext-prebuilts', 'eofkdgkhfoebecmamljfaepckoecjhib', 'build')

run(
path.join(__dirname, '../node_modules/webextension-shim'),
'node',
...'../ts-node/dist/bin.js -T ./src/bin/prebuilts.ts eofkdgkhfoebecmamljfaepckoecjhib ../../build/'.split(' '),
)
import fs from 'fs'
function readDir(x: string) {
const _ = path.join(__dirname, x)
return fs.readdirSync(_).map((x) => path.join(_, x))
}
readDir('../build/js').filter(unused).forEach(fs.unlinkSync)
// .forEach((x) => console.log(x))
function unused(x: string): boolean {
if (x.includes('prebuilt-0-module')) return true
if (x.includes('prebuilt') && !x.includes('content-script')) return true
// Since content script has it prebuilt version, we can remove the original version?
if (x.match(/content-script\.js$/)) return true
return false
}

readDir(path.resolve(BUILD_PATH, 'js'))
.filter(function unused(x: string): boolean {
if (x.includes('prebuilt-0-module')) return true
if (x.includes('prebuilt') && !x.includes('content-script')) return true
// Since content script has it prebuilt version, we can remove the original version?
if (x.match(/content-script\.js$/)) return true
return false
})
.forEach(fs.unlinkSync)
8 changes: 4 additions & 4 deletions src/extension/background-script/SteganographyService.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { encode, decode } from '@dimensiondev/stego-js/es/dom'
import { GrayscaleAlgorithm } from '@dimensiondev/stego-js/es/grayscale'
import { TransformAlgorithm } from '@dimensiondev/stego-js/es/transform'
import { encode, decode } from '@dimensiondev/stego-js/cjs/dom'
import { GrayscaleAlgorithm } from '@dimensiondev/stego-js/cjs/grayscale'
import { TransformAlgorithm } from '@dimensiondev/stego-js/cjs/transform'
import { OnlyRunInContext } from '@holoflows/kit/es'
import type { EncodeOptions, DecodeOptions } from '@dimensiondev/stego-js/es/stego'
import type { EncodeOptions, DecodeOptions } from '@dimensiondev/stego-js/cjs/stego'
import { getUrl, downloadUrl } from '../../utils/utils'
import { memoizePromise } from '../../utils/memoize'
import { getDimension } from '../../utils/image'
Expand Down
2 changes: 1 addition & 1 deletion src/network/matrix/matrix.type.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
declare module 'matrix-js-sdk' {
export * from 'matrix-js-sdk-type'
export * from '@dimensiondev/matrix-js-sdk-type'
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { untilDocumentReady } from '../../../utils/dom'
import { getUrl, downloadUrl, pasteImageToActiveElements } from '../../../utils/utils'
import Services from '../../../extension/service'
import { decodeArrayBuffer } from '../../../utils/type-transform/String-ArrayBuffer'
import { GrayscaleAlgorithm } from '@dimensiondev/stego-js/es/grayscale'
import { GrayscaleAlgorithm } from '@dimensiondev/stego-js/cjs/grayscale'

export async function uploadToPostBoxFacebook(
text: string,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/image.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-bitwise */
import { imgType } from '@dimensiondev/stego-js/es/helper'
import { imgType } from '@dimensiondev/stego-js/cjs/helper'

export function getDimension(buf: ArrayBuffer) {
const fallback = {
Expand Down
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const publicPolyfill = src('./public/polyfill')
process.env.BROWSER = 'none'

const SSRPlugin = require('./config-overrides/SSRPlugin')
const WebExtensionHotLoadPlugin = require('webpack-web-ext-plugin')
const WebExtensionHotLoadPlugin = require('@dimensiondev/webpack-web-ext-plugin')
const ManifestGeneratorPlugin = require('webpack-extension-manifest-plugin')

/**
Expand Down

0 comments on commit 3e6c6c6

Please sign in to comment.