From 12106a9d0c3cfaca70272e0d91df6c9042a50ca7 Mon Sep 17 00:00:00 2001 From: pacoyang Date: Mon, 13 Nov 2023 01:11:42 +0800 Subject: [PATCH 1/9] refactor: specify the build tsconfig json file --- package.json | 3 ++- src/lib/runWebpack.ts | 8 ++------ tsconfig.build.json | 12 ++++++++++++ 3 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 tsconfig.build.json diff --git a/package.json b/package.json index c620403..a7d6849 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,8 @@ }, "files": [ "/bin", - "/dist" + "/dist", + "/tsconfig.build.json" ], "dependencies": { "@oclif/core": "^2", diff --git a/src/lib/runWebpack.ts b/src/lib/runWebpack.ts index c07966f..16d0bae 100644 --- a/src/lib/runWebpack.ts +++ b/src/lib/runWebpack.ts @@ -47,13 +47,9 @@ const getBaseConfig = ( exclude: /node_modules/, loader: require.resolve('ts-loader'), options: { - compilerOptions: { - declaration: false, - moduleResolution: 'node', - module: 'es6', - }, + configFile: require.resolve('../../tsconfig.build.json'), onlyCompileBundledFiles: true, - }, + } }, ], }, diff --git a/tsconfig.build.json b/tsconfig.build.json new file mode 100644 index 0000000..8bd55a8 --- /dev/null +++ b/tsconfig.build.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "module": "es6", + "target": "es2020", + "esModuleInterop": true, + "skipLibCheck": true, + "resolveJsonModule": true, + "declaration": false, + "moduleResolution": "node", + "allowJs": true + } +} From 927cd8b82afc33c24625a4e0ad35b396fc362aaf Mon Sep 17 00:00:00 2001 From: pacoyang Date: Mon, 13 Nov 2023 01:12:30 +0800 Subject: [PATCH 2/9] fix: check if package.json exists --- src/commands/build.ts | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/commands/build.ts b/src/commands/build.ts index cedb87e..e308b24 100644 --- a/src/commands/build.ts +++ b/src/commands/build.ts @@ -1,4 +1,4 @@ -import { lstatSync, readFileSync } from 'node:fs' +import { lstatSync, readFileSync, existsSync } from 'node:fs' import upath from 'upath' import { Args, Command, Flags, ux } from '@oclif/core' import chalk from 'chalk' @@ -48,15 +48,20 @@ export default class Build extends Command { let buildEntries: Record = { [upath.parse(script).name]: script, } - const pjson = JSON.parse(readFileSync(upath.join(directory, 'package.json')).toString()) - if (pjson.exports && typeof pjson.exports !== 'string') { - buildEntries = Object.entries(pjson.exports as Record).reduce( - (acc, [key, value]) => { - acc[key] = value - return acc - }, - { ...buildEntries }, - ) + + + const pjson_file_path = upath.join(directory, 'package.json') + if (existsSync(pjson_file_path)) { + const pjson = JSON.parse(readFileSync(pjson_file_path).toString()) + if (pjson.exports && typeof pjson.exports !== 'string') { + buildEntries = Object.entries(pjson.exports as Record).reduce( + (acc, [key, value]) => { + acc[key] = value + return acc + }, + { ...buildEntries }, + ) + } } for (const i in buildEntries) { From 528a982dd0f113adab535e1a5c2a6f49994a91d8 Mon Sep 17 00:00:00 2001 From: pacoyang Date: Mon, 13 Nov 2023 01:22:23 +0800 Subject: [PATCH 3/9] feat: add ci --- .github/workflows/main.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..942a8d3 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,28 @@ +name: CLI action +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Use Node.js + uses: actions/setup-node@v2 + with: + node-version: 16 + - name: Install dependencies + run: yarn install --frozen-lockfile + - name: Build + run: npm run build + - name: Run Commands + run: | + ./bin/run init --help + ./bin/run build --help + ./bin/run run --help + ./bin/run watch --help + ./bin/run upload --help + ./bin/run update --help From 9aa2425d2b18e8a65ddd271d430bf5aec7e8805e Mon Sep 17 00:00:00 2001 From: pacoyang Date: Mon, 13 Nov 2023 10:25:07 +0800 Subject: [PATCH 4/9] fix: regex --- src/lib/runWebpack.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/runWebpack.ts b/src/lib/runWebpack.ts index 16d0bae..6cf03b0 100644 --- a/src/lib/runWebpack.ts +++ b/src/lib/runWebpack.ts @@ -66,7 +66,7 @@ const getBaseConfig = ( function modifyFilePath(filePath: string) { - let newFilePath = filePath.replace(/\/([^/]+)$/, '/_$1') + let newFilePath = filePath.replace(/([^/]+)$/, '_$1') if (!newFilePath.endsWith('.ts')) { newFilePath += '.ts' } From 2e86250dbd0c8fb55f6b4ad8e509e3ce2d02e775 Mon Sep 17 00:00:00 2001 From: pacoyang Date: Mon, 13 Nov 2023 12:54:55 +0800 Subject: [PATCH 5/9] chore: update sdk version --- package.json | 2 +- yarn.lock | 293 +++++++++++++-------------------------------------- 2 files changed, 74 insertions(+), 221 deletions(-) diff --git a/package.json b/package.json index a7d6849..96ef6ea 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ ], "dependencies": { "@oclif/core": "^2", - "@phala/sdk": "^0.5.3-nightly-20231013", + "@phala/sdk": "0.5.5-nightly-20231111", "@types/node-fetch": "2", "chalk": "4", "dotenv": "^16.3.1", diff --git a/yarn.lock b/yarn.lock index 49c0bbd..159a600 100644 --- a/yarn.lock +++ b/yarn.lock @@ -600,28 +600,25 @@ dependencies: "@octokit/openapi-types" "^12.11.0" -"@phala/sdk@^0.5.3-nightly-20231013": - version "0.5.3-nightly-20231013" - resolved "https://registry.yarnpkg.com/@phala/sdk/-/sdk-0.5.3-nightly-20231013.tgz#6060a667b0d5b39cc230fa06378b83154366fa0d" - integrity sha512-J4KlTpk5kqzjrH/J0LKopUnexTR9yliDc0NXiZuimd7mdfT9L2D7tDOgeeXQ2H6TYA4WDQ6m6YaK5c8P90Ay6w== +"@phala/sdk@0.5.5-nightly-20231111": + version "0.5.5-nightly-20231111" + resolved "https://registry.yarnpkg.com/@phala/sdk/-/sdk-0.5.5-nightly-20231111.tgz#2441d38a511461c7a75b6aacef4402663cdb05e5" + integrity sha512-B6K4CK5M2AODtLrHsFvCWtHEnguQK+onQmawkIm8CQHpnUapxaJKA8MCwqavi3PubQt8AOIMxIUrR5xptXKHXg== dependencies: - "@phala/typedefs" "^0.2.33" "@polkadot/api" "^10.9.1" "@polkadot/api-contract" "^10.9.1" "@polkadot/keyring" "^12.3.2" "@polkadot/types" "^10.9.1" + "@polkadot/types-augment" "^10.9.1" "@polkadot/util" "^12.3.2" "@polkadot/util-crypto" "^12.3.2" - crypto-browserify "^3.12.0" + browserify-cipher "^1.0.1" + cross-fetch "^4.0.0" protobufjs "^7.2.4" - undici "^5.22.1" + randombytes "^2.1.0" + rxjs "^7.8.1" viem "^1.5.0" -"@phala/typedefs@^0.2.33": - version "0.2.33" - resolved "https://registry.yarnpkg.com/@phala/typedefs/-/typedefs-0.2.33.tgz#6f18d73b5104db6a594d08be571954385b3e509b" - integrity sha512-CaRzIGfU6CUIKLPswYtOw/xbtTttqmJZpr3fhkxLvkBQMXIH14iISD763OFXtWui7DrAMBKo/bHawvFNgWGKTg== - "@pkgjs/parseargs@^0.11.0": version "0.11.0" resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33" @@ -705,7 +702,7 @@ rxjs "^7.8.1" tslib "^2.5.3" -"@polkadot/keyring@^12.3.1", "@polkadot/keyring@^12.3.2": +"@polkadot/keyring@^12.3.1", "@polkadot/keyring@^12.3.2", "@polkadot/keyring@^12.5.1": version "12.5.1" resolved "https://registry.yarnpkg.com/@polkadot/keyring/-/keyring-12.5.1.tgz#2f38504aa915f54bbd265f3793a6be55010eb1f5" integrity sha512-u6b+Q7wI6WY/vwmJS9uUHy/5hKZ226nTlVNmxjkj9GvrRsQvUSwS94163yHPJwiZJiIv5xK5m0rwCMyoYu+wjA== @@ -766,6 +763,16 @@ optionalDependencies: "@substrate/connect" "0.7.26" +"@polkadot/types-augment@10.10.1", "@polkadot/types-augment@^10.9.1": + version "10.10.1" + resolved "https://registry.yarnpkg.com/@polkadot/types-augment/-/types-augment-10.10.1.tgz#178ce0b22681109396fc681a027f35da7d757cef" + integrity sha512-XRHE75IocXfFE6EADYov3pqXCyBk5SWbiHoZ0+4WYWP9SwMuzsBaAy84NlhLBlkG3+ehIqi0HpAd/qrljJGZbg== + dependencies: + "@polkadot/types" "10.10.1" + "@polkadot/types-codec" "10.10.1" + "@polkadot/util" "^12.5.1" + tslib "^2.6.2" + "@polkadot/types-augment@10.9.1": version "10.9.1" resolved "https://registry.yarnpkg.com/@polkadot/types-augment/-/types-augment-10.9.1.tgz#5f1c1225c04ffbfe243629a46087c9c9de25a6b3" @@ -776,6 +783,15 @@ "@polkadot/util" "^12.3.1" tslib "^2.5.3" +"@polkadot/types-codec@10.10.1": + version "10.10.1" + resolved "https://registry.yarnpkg.com/@polkadot/types-codec/-/types-codec-10.10.1.tgz#61d28a461493bfb72606b4399078460969a049c8" + integrity sha512-ETPG0wzWzt/bDKRQmYbO7CLe/0lUt8VrG6/bECdv+Kye+8Qedba2LZyTWm/9f2ngms8TZ82yI8mPv/mozdtfnw== + dependencies: + "@polkadot/util" "^12.5.1" + "@polkadot/x-bigint" "^12.5.1" + tslib "^2.6.2" + "@polkadot/types-codec@10.9.1": version "10.9.1" resolved "https://registry.yarnpkg.com/@polkadot/types-codec/-/types-codec-10.9.1.tgz#f30026d3dfeaa69c07c45fa66d1c39318fd232cc" @@ -785,6 +801,15 @@ "@polkadot/x-bigint" "^12.3.1" tslib "^2.5.3" +"@polkadot/types-create@10.10.1": + version "10.10.1" + resolved "https://registry.yarnpkg.com/@polkadot/types-create/-/types-create-10.10.1.tgz#76f1729ef3f4699d99e708801312e43825368827" + integrity sha512-7OiLzd+Ter5zrpjP7fDwA1m89kd38VvMVixfOSv8x7ld2pDT+yyyKl14TCwRSWrKWCMtIb6M3iasPhq5cUa7cw== + dependencies: + "@polkadot/types-codec" "10.10.1" + "@polkadot/util" "^12.5.1" + tslib "^2.6.2" + "@polkadot/types-create@10.9.1": version "10.9.1" resolved "https://registry.yarnpkg.com/@polkadot/types-create/-/types-create-10.9.1.tgz#087d7e2af51cce558b67e3859613b932a3bdc0a3" @@ -814,6 +839,20 @@ "@polkadot/util" "^12.3.1" tslib "^2.5.3" +"@polkadot/types@10.10.1": + version "10.10.1" + resolved "https://registry.yarnpkg.com/@polkadot/types/-/types-10.10.1.tgz#4a55909ff35b0b568c0b1539ae923a259b0dba6a" + integrity sha512-Ben62P1tjYEhKag34GBGcLX6NqcFR1VD5nNbWaxgr+t36Jl/tlHs6P9DlbFqQP7Tt9FmGrAYY0m3oTkhjG1NzA== + dependencies: + "@polkadot/keyring" "^12.5.1" + "@polkadot/types-augment" "10.10.1" + "@polkadot/types-codec" "10.10.1" + "@polkadot/types-create" "10.10.1" + "@polkadot/util" "^12.5.1" + "@polkadot/util-crypto" "^12.5.1" + rxjs "^7.8.1" + tslib "^2.6.2" + "@polkadot/types@10.9.1", "@polkadot/types@^10.9.1": version "10.9.1" resolved "https://registry.yarnpkg.com/@polkadot/types/-/types-10.9.1.tgz#f111d00f7278ad3be95deba3d701fafefe080cb2" @@ -828,7 +867,7 @@ rxjs "^7.8.1" tslib "^2.5.3" -"@polkadot/util-crypto@12.5.1", "@polkadot/util-crypto@^12.3.1", "@polkadot/util-crypto@^12.3.2": +"@polkadot/util-crypto@12.5.1", "@polkadot/util-crypto@^12.3.1", "@polkadot/util-crypto@^12.3.2", "@polkadot/util-crypto@^12.5.1": version "12.5.1" resolved "https://registry.yarnpkg.com/@polkadot/util-crypto/-/util-crypto-12.5.1.tgz#1753b23abfb9d72db950399ef65b0cbe5bef9f2f" integrity sha512-Y8ORbMcsM/VOqSG3DgqutRGQ8XXK+X9M3C8oOEI2Tji65ZsXbh9Yh+ryPLM0oBp/9vqOXjkLgZJbbVuQceOw0A== @@ -844,7 +883,7 @@ "@scure/base" "^1.1.3" tslib "^2.6.2" -"@polkadot/util@12.5.1", "@polkadot/util@^12.3.1", "@polkadot/util@^12.3.2": +"@polkadot/util@12.5.1", "@polkadot/util@^12.3.1", "@polkadot/util@^12.3.2", "@polkadot/util@^12.5.1": version "12.5.1" resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-12.5.1.tgz#f4e7415600b013d3b69527aa88904acf085be3f5" integrity sha512-fDBZL7D4/baMG09Qowseo884m3QBzErGkRWNBId1UjWR99kyex+cIY9fOSzmuQxo6nLdJlLHw1Nz2caN3+Bq0A== @@ -910,7 +949,7 @@ dependencies: tslib "^2.6.1" -"@polkadot/x-bigint@12.5.1", "@polkadot/x-bigint@^12.3.1": +"@polkadot/x-bigint@12.5.1", "@polkadot/x-bigint@^12.3.1", "@polkadot/x-bigint@^12.5.1": version "12.5.1" resolved "https://registry.yarnpkg.com/@polkadot/x-bigint/-/x-bigint-12.5.1.tgz#0a6a3a34fae51468e7b02b42e0ff0747fd88a80a" integrity sha512-Fw39eoN9v0sqxSzfSC5awaDVdzojIiE7d1hRSQgVSrES+8whWvtbYMR0qwbVhTuW7DvogHmye41P9xKMlXZysg== @@ -1751,16 +1790,6 @@ asap@^2.0.0: resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46" integrity sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA== -asn1.js@^5.2.0: - version "5.4.1" - resolved "https://registry.yarnpkg.com/asn1.js/-/asn1.js-5.4.1.tgz#11a980b84ebb91781ce35b0fdc2ee294e3783f07" - integrity sha512-+I//4cYPccV8LdmBLiX8CYvf9Sp3vQsrqu2QNXRcrbiWvcx/UdlFiqUJJzxRQxgsZmvhXhn4cSKeSmoFjVdupA== - dependencies: - bn.js "^4.0.0" - inherits "^2.0.1" - minimalistic-assert "^1.0.0" - safer-buffer "^2.1.0" - assertion-error@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b" @@ -1855,12 +1884,7 @@ bl@^4.1.0: inherits "^2.0.4" readable-stream "^3.4.0" -bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.11.9: - version "4.12.0" - resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.12.0.tgz#775b3f278efbb9718eec7361f483fb36fbbfea88" - integrity sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA== - -bn.js@^5.0.0, bn.js@^5.1.1, bn.js@^5.2.1: +bn.js@^5.2.1: version "5.2.1" resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.1.tgz#0bc527a6a0d18d0aa8d5b0538ce4a77dccfa7b70" integrity sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ== @@ -1887,17 +1911,12 @@ braces@^3.0.2, braces@~3.0.2: dependencies: fill-range "^7.0.1" -brorand@^1.0.1, brorand@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/brorand/-/brorand-1.1.0.tgz#12c25efe40a45e3c323eb8675a0a0ce57b22371f" - integrity sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w== - browser-stdout@1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.1.tgz#baa559ee14ced73452229bad7326467c61fabd60" integrity sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw== -browserify-aes@^1.0.0, browserify-aes@^1.0.4: +browserify-aes@^1.0.4: version "1.2.0" resolved "https://registry.yarnpkg.com/browserify-aes/-/browserify-aes-1.2.0.tgz#326734642f403dabc3003209853bb70ad428ef48" integrity sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA== @@ -1909,7 +1928,7 @@ browserify-aes@^1.0.0, browserify-aes@^1.0.4: inherits "^2.0.1" safe-buffer "^5.0.1" -browserify-cipher@^1.0.0: +browserify-cipher@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/browserify-cipher/-/browserify-cipher-1.0.1.tgz#8d6474c1b870bfdabcd3bcfcc1934a10e94f15f0" integrity sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w== @@ -1928,29 +1947,6 @@ browserify-des@^1.0.0: inherits "^2.0.1" safe-buffer "^5.1.2" -browserify-rsa@^4.0.0, browserify-rsa@^4.0.1: - version "4.1.0" - resolved "https://registry.yarnpkg.com/browserify-rsa/-/browserify-rsa-4.1.0.tgz#b2fd06b5b75ae297f7ce2dc651f918f5be158c8d" - integrity sha512-AdEER0Hkspgno2aR97SAf6vi0y0k8NuOpGnVH3O99rcA5Q6sh8QxcngtHuJ6uXwnfAXNM4Gn1Gb7/MV1+Ymbog== - dependencies: - bn.js "^5.0.0" - randombytes "^2.0.1" - -browserify-sign@^4.0.0: - version "4.2.1" - resolved "https://registry.yarnpkg.com/browserify-sign/-/browserify-sign-4.2.1.tgz#eaf4add46dd54be3bb3b36c0cf15abbeba7956c3" - integrity sha512-/vrA5fguVAKKAVTNJjgSm1tRQDHUU6DbwO9IROu/0WAzC8PKhucDSh18J0RMvVeHAn5puMd+QHC2erPRNf8lmg== - dependencies: - bn.js "^5.1.1" - browserify-rsa "^4.0.1" - create-hash "^1.2.0" - create-hmac "^1.1.7" - elliptic "^6.5.3" - inherits "^2.0.4" - parse-asn1 "^5.1.5" - readable-stream "^3.6.0" - safe-buffer "^5.2.0" - browserslist@^4.14.5: version "4.21.11" resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.21.11.tgz#35f74a3e51adc4d193dcd76ea13858de7b8fecb8" @@ -2008,13 +2004,6 @@ builtins@^5.0.0: dependencies: semver "^7.0.0" -busboy@^1.6.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/busboy/-/busboy-1.6.0.tgz#966ea36a9502e43cdb9146962523b92f531f6893" - integrity sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA== - dependencies: - streamsearch "^1.1.0" - cacache@^15.0.3, cacache@^15.0.5, cacache@^15.2.0: version "15.3.0" resolved "https://registry.yarnpkg.com/cacache/-/cacache-15.3.0.tgz#dc85380fb2f556fe3dda4c719bfa0ec875a7f1eb" @@ -2195,7 +2184,7 @@ chrome-trace-event@^1.0.2: resolved "https://registry.yarnpkg.com/chrome-trace-event/-/chrome-trace-event-1.0.3.tgz#1015eced4741e15d06664a957dbbf50d041e26ac" integrity sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg== -cipher-base@^1.0.0, cipher-base@^1.0.1, cipher-base@^1.0.3: +cipher-base@^1.0.0, cipher-base@^1.0.1: version "1.0.4" resolved "https://registry.yarnpkg.com/cipher-base/-/cipher-base-1.0.4.tgz#8760e4ecc272f4c363532f926d874aae2c1397de" integrity sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q== @@ -2412,15 +2401,7 @@ core-util-is@~1.0.0: resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.3.tgz#a6042d3634c2b27e9328f837b965fac83808db85" integrity sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ== -create-ecdh@^4.0.0: - version "4.0.4" - resolved "https://registry.yarnpkg.com/create-ecdh/-/create-ecdh-4.0.4.tgz#d6e7f4bffa66736085a0762fd3a632684dabcc4e" - integrity sha512-mf+TCx8wWc9VpuxfP2ht0iSISLZnt0JgWlrOKZiNqyUZWnjIaCIVNQArMHnCZKfEYRg6IM7A+NeJoN8gf/Ws0A== - dependencies: - bn.js "^4.1.0" - elliptic "^6.5.3" - -create-hash@^1.1.0, create-hash@^1.1.2, create-hash@^1.2.0: +create-hash@^1.1.0: version "1.2.0" resolved "https://registry.yarnpkg.com/create-hash/-/create-hash-1.2.0.tgz#889078af11a63756bcfb59bd221996be3a9ef196" integrity sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg== @@ -2431,23 +2412,18 @@ create-hash@^1.1.0, create-hash@^1.1.2, create-hash@^1.2.0: ripemd160 "^2.0.1" sha.js "^2.4.0" -create-hmac@^1.1.0, create-hmac@^1.1.4, create-hmac@^1.1.7: - version "1.1.7" - resolved "https://registry.yarnpkg.com/create-hmac/-/create-hmac-1.1.7.tgz#69170c78b3ab957147b2b8b04572e47ead2243ff" - integrity sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg== - dependencies: - cipher-base "^1.0.3" - create-hash "^1.1.0" - inherits "^2.0.1" - ripemd160 "^2.0.0" - safe-buffer "^5.0.1" - sha.js "^2.4.8" - create-require@^1.1.0: version "1.1.1" resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333" integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ== +cross-fetch@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-4.0.0.tgz#f037aef1580bb3a1a35164ea2a848ba81b445983" + integrity sha512-e4a5N8lVvuLgAWgnCrLr2PP0YyDOTHa9H/Rj54dirp61qXnNq46m82bRhNqIA5VccJtWBvPTFRV3TtvHUKPB1g== + dependencies: + node-fetch "^2.6.12" + cross-spawn@^7.0.0, cross-spawn@^7.0.2, cross-spawn@^7.0.3: version "7.0.3" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" @@ -2457,23 +2433,6 @@ cross-spawn@^7.0.0, cross-spawn@^7.0.2, cross-spawn@^7.0.3: shebang-command "^2.0.0" which "^2.0.1" -crypto-browserify@^3.12.0: - version "3.12.0" - resolved "https://registry.yarnpkg.com/crypto-browserify/-/crypto-browserify-3.12.0.tgz#396cf9f3137f03e4b8e532c58f698254e00f80ec" - integrity sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg== - dependencies: - browserify-cipher "^1.0.0" - browserify-sign "^4.0.0" - create-ecdh "^4.0.0" - create-hash "^1.1.0" - create-hmac "^1.1.0" - diffie-hellman "^5.0.0" - inherits "^2.0.1" - pbkdf2 "^3.0.3" - public-encrypt "^4.0.0" - randombytes "^2.0.0" - randomfill "^1.0.3" - dargs@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/dargs/-/dargs-7.0.0.tgz#04015c41de0bcb69ec84050f3d9be0caf8d6d5cc" @@ -2602,15 +2561,6 @@ diff@^5.0.0: resolved "https://registry.yarnpkg.com/diff/-/diff-5.1.0.tgz#bc52d298c5ea8df9194800224445ed43ffc87e40" integrity sha512-D+mk+qE8VC/PAUrlAU34N+VfXev0ghe5ywmpqrawphmVZc1bEfn56uo9qpyGp1p4xpzOHkSW4ztBd6L7Xx4ACw== -diffie-hellman@^5.0.0: - version "5.0.3" - resolved "https://registry.yarnpkg.com/diffie-hellman/-/diffie-hellman-5.0.3.tgz#40e8ee98f55a2149607146921c63e1ae5f3d2875" - integrity sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg== - dependencies: - bn.js "^4.1.0" - miller-rabin "^4.0.0" - randombytes "^2.0.0" - dir-glob@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/dir-glob/-/dir-glob-3.0.1.tgz#56dbf73d992a4a93ba1584f4534063fd2e41717f" @@ -2647,19 +2597,6 @@ electron-to-chromium@^1.4.526: resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.529.tgz#8c3377a05e5737f899770d14524dd8e2e4cb2351" integrity sha512-6uyPyXTo8lkv8SWAmjKFbG42U073TXlzD4R8rW3EzuznhFS2olCIAfjjQtV2dV2ar/vRF55KUd3zQYnCB0dd3A== -elliptic@^6.5.3: - version "6.5.4" - resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.4.tgz#da37cebd31e79a1367e941b592ed1fbebd58abbb" - integrity sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ== - dependencies: - bn.js "^4.11.9" - brorand "^1.1.0" - hash.js "^1.0.0" - hmac-drbg "^1.0.1" - inherits "^2.0.4" - minimalistic-assert "^1.0.1" - minimalistic-crypto-utils "^1.0.1" - emoji-regex@^8.0.0: version "8.0.0" resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" @@ -3419,28 +3356,11 @@ hash-base@^3.0.0: readable-stream "^3.6.0" safe-buffer "^5.2.0" -hash.js@^1.0.0, hash.js@^1.0.3: - version "1.1.7" - resolved "https://registry.yarnpkg.com/hash.js/-/hash.js-1.1.7.tgz#0babca538e8d4ee4a0f8988d68866537a003cf42" - integrity sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA== - dependencies: - inherits "^2.0.3" - minimalistic-assert "^1.0.1" - he@1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f" integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw== -hmac-drbg@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1" - integrity sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg== - dependencies: - hash.js "^1.0.3" - minimalistic-assert "^1.0.0" - minimalistic-crypto-utils "^1.0.1" - hosted-git-info@^2.1.4: version "2.8.9" resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.9.tgz#dffc0bf9a21c02209090f2aa69429e1414daf3f9" @@ -4181,14 +4101,6 @@ micromatch@^4.0.0, micromatch@^4.0.2, micromatch@^4.0.4: braces "^3.0.2" picomatch "^2.3.1" -miller-rabin@^4.0.0: - version "4.0.1" - resolved "https://registry.yarnpkg.com/miller-rabin/-/miller-rabin-4.0.1.tgz#f080351c865b0dc562a8462966daa53543c78a4d" - integrity sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA== - dependencies: - bn.js "^4.0.0" - brorand "^1.0.1" - mime-db@1.52.0: version "1.52.0" resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" @@ -4216,16 +4128,11 @@ mimic-response@^3.1.0: resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-3.1.0.tgz#2d1d59af9c1b129815accc2c46a022a5ce1fa3c9" integrity sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ== -minimalistic-assert@^1.0.0, minimalistic-assert@^1.0.1: +minimalistic-assert@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7" integrity sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A== -minimalistic-crypto-utils@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a" - integrity sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg== - minimatch@4.2.1: version "4.2.1" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-4.2.1.tgz#40d9d511a46bdc4e563c22c3080cde9c0d8299b4" @@ -4480,7 +4387,7 @@ node-domexception@^1.0.0: resolved "https://registry.yarnpkg.com/node-domexception/-/node-domexception-1.0.0.tgz#6888db46a1f71c0b76b3f7555016b63fe64766e5" integrity sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ== -node-fetch@^2.6.7: +node-fetch@^2.6.12, node-fetch@^2.6.7: version "2.7.0" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d" integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A== @@ -4954,17 +4861,6 @@ parent-module@^1.0.0: dependencies: callsites "^3.0.0" -parse-asn1@^5.0.0, parse-asn1@^5.1.5: - version "5.1.6" - resolved "https://registry.yarnpkg.com/parse-asn1/-/parse-asn1-5.1.6.tgz#385080a3ec13cb62a62d39409cb3e88844cdaed4" - integrity sha512-RnZRo1EPU6JBnra2vGHj0yhp6ebyjBZpmUCLHWiFhxlzvBCCpAuZ7elsBp1PVAbQN0/04VD/19rfzlBSwLstMw== - dependencies: - asn1.js "^5.2.0" - browserify-aes "^1.0.0" - evp_bytestokey "^1.0.0" - pbkdf2 "^3.0.3" - safe-buffer "^5.1.1" - parse-conflict-json@^2.0.1: version "2.0.2" resolved "https://registry.yarnpkg.com/parse-conflict-json/-/parse-conflict-json-2.0.2.tgz#3d05bc8ffe07d39600dc6436c6aefe382033d323" @@ -5038,17 +4934,6 @@ pathval@^1.1.1: resolved "https://registry.yarnpkg.com/pathval/-/pathval-1.1.1.tgz#8534e77a77ce7ac5a2512ea21e0fdb8fcf6c3d8d" integrity sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ== -pbkdf2@^3.0.3: - version "3.1.2" - resolved "https://registry.yarnpkg.com/pbkdf2/-/pbkdf2-3.1.2.tgz#dd822aa0887580e52f1a039dc3eda108efae3075" - integrity sha512-iuh7L6jA7JEGu2WxDwtQP1ddOpaJNC4KlDEFfdQajSGgGPNi4OyDc2R7QnbY2bR9QjBVGwgvTdNJZoE7RaxUMA== - dependencies: - create-hash "^1.1.2" - create-hmac "^1.1.4" - ripemd160 "^2.0.1" - safe-buffer "^5.0.1" - sha.js "^2.4.8" - picocolors@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c" @@ -5167,18 +5052,6 @@ protobufjs@^7.2.4: "@types/node" ">=13.7.0" long "^5.0.0" -public-encrypt@^4.0.0: - version "4.0.3" - resolved "https://registry.yarnpkg.com/public-encrypt/-/public-encrypt-4.0.3.tgz#4fcc9d77a07e48ba7527e7cbe0de33d0701331e0" - integrity sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q== - dependencies: - bn.js "^4.1.0" - browserify-rsa "^4.0.0" - create-hash "^1.1.0" - parse-asn1 "^5.0.0" - randombytes "^2.0.1" - safe-buffer "^5.1.2" - pump@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/pump/-/pump-3.0.0.tgz#b4a2116815bde2f4e1ea602354e8c75565107a64" @@ -5222,21 +5095,13 @@ quickjs-emscripten@^0.23.0: resolved "https://registry.yarnpkg.com/quickjs-emscripten/-/quickjs-emscripten-0.23.0.tgz#94f412d0ee5f3021fc12ddf6c0b00bd8ce0d28b9" integrity sha512-CIP+NDRYDDqbT3cTiN8Bon1wsZ7IgISVYCJHYsPc86oxszpepVMPXFfttyQgn1u1okg1HPnCnM7Xv1LrCO/VmQ== -randombytes@^2.0.0, randombytes@^2.0.1, randombytes@^2.0.5, randombytes@^2.1.0: +randombytes@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a" integrity sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ== dependencies: safe-buffer "^5.1.0" -randomfill@^1.0.3: - version "1.0.4" - resolved "https://registry.yarnpkg.com/randomfill/-/randomfill-1.0.4.tgz#c92196fc86ab42be983f1bf31778224931d61458" - integrity sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw== - dependencies: - randombytes "^2.0.5" - safe-buffer "^5.1.0" - read-cmd-shim@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/read-cmd-shim/-/read-cmd-shim-3.0.1.tgz#868c235ec59d1de2db69e11aec885bc095aea087" @@ -5437,7 +5302,7 @@ rimraf@^3.0.0, rimraf@^3.0.2: dependencies: glob "^7.1.3" -ripemd160@^2.0.0, ripemd160@^2.0.1: +ripemd160@^2.0.1: version "2.0.2" resolved "https://registry.yarnpkg.com/ripemd160/-/ripemd160-2.0.2.tgz#a1c1a6f624751577ba5d07914cbc92850585890c" integrity sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA== @@ -5474,7 +5339,7 @@ safe-buffer@~5.1.0, safe-buffer@~5.1.1: resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== -"safer-buffer@>= 2.1.2 < 3", "safer-buffer@>= 2.1.2 < 3.0.0", safer-buffer@^2.1.0: +"safer-buffer@>= 2.1.2 < 3", "safer-buffer@>= 2.1.2 < 3.0.0": version "2.1.2" resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== @@ -5534,7 +5399,7 @@ set-blocking@^2.0.0: resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" integrity sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw== -sha.js@^2.4.0, sha.js@^2.4.8: +sha.js@^2.4.0: version "2.4.11" resolved "https://registry.yarnpkg.com/sha.js/-/sha.js-2.4.11.tgz#37a5cf0b81ecbc6943de109ba2960d1b26584ae7" integrity sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ== @@ -5751,11 +5616,6 @@ stdout-stderr@^0.1.9: debug "^4.1.1" strip-ansi "^6.0.0" -streamsearch@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/streamsearch/-/streamsearch-1.1.0.tgz#404dd1e2247ca94af554e841a8ef0eaa238da764" - integrity sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg== - "string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" @@ -6070,13 +5930,6 @@ typescript@^5.2.2: resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.2.2.tgz#5ebb5e5a5b75f085f22bc3f8460fba308310fa78" integrity sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w== -undici@^5.22.1: - version "5.25.2" - resolved "https://registry.yarnpkg.com/undici/-/undici-5.25.2.tgz#17ddc3e8ab3c77e473ae1547f3f2917a05da2820" - integrity sha512-tch8RbCfn1UUH1PeVCXva4V8gDpGAud/w0WubD6sHC46vYQ3KDxL+xv1A2UxK0N6jrVedutuPHxe1XIoqerwMw== - dependencies: - busboy "^1.6.0" - undici@^5.27.0: version "5.27.0" resolved "https://registry.yarnpkg.com/undici/-/undici-5.27.0.tgz#789f2e40ce982b5507899abc2c2ddeb2712b4554" From f6c3ef4db2afa2cc16a9c8442a32424db28ef871 Mon Sep 17 00:00:00 2001 From: pacoyang Date: Mon, 13 Nov 2023 13:08:58 +0800 Subject: [PATCH 6/9] feat: add pruntimeUrl flag --- src/lib/PhatCommandBase.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib/PhatCommandBase.ts b/src/lib/PhatCommandBase.ts index 28f523f..faef328 100644 --- a/src/lib/PhatCommandBase.ts +++ b/src/lib/PhatCommandBase.ts @@ -39,6 +39,7 @@ export interface ParsedFlags { readonly accountFilePath: string readonly accountPassword: string readonly coreSettings: string + readonly pruntimeUrl: string } interface ParsedArgs { @@ -98,6 +99,10 @@ export default abstract class PhatCommandBase extends Command { description: 'Core settings', required: false, }), + pruntimeUrl: Flags.string({ + description: 'Pruntime URL', + required: false, + }), mode: Flags.custom({ options: ['production', 'prod', 'development', 'dev'], default: 'development', @@ -211,7 +216,9 @@ export default abstract class PhatCommandBase extends Command { noInitWarn: true, }) ) - const registry = await OnChainRegistry.create(apiPromise) + const registry = await OnChainRegistry.create(apiPromise, { + pruntimeURL: this.parsedFlags.pruntimeUrl + }) const cert = await signCertificate({ pair }) return [apiPromise, registry, cert] } From 0d05efa58547597284e6d7c78c9d4b2e61f13f25 Mon Sep 17 00:00:00 2001 From: pacoyang Date: Mon, 13 Nov 2023 23:19:19 +0800 Subject: [PATCH 7/9] refactor: use new getClient func replace OnChainRegistry.create --- src/lib/PhatCommandBase.ts | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/lib/PhatCommandBase.ts b/src/lib/PhatCommandBase.ts index faef328..e863d5f 100644 --- a/src/lib/PhatCommandBase.ts +++ b/src/lib/PhatCommandBase.ts @@ -6,14 +6,14 @@ import chalk from 'chalk' import { filesize } from 'filesize' import { Command, Args, Flags, ux } from '@oclif/core' import { - options, + getClient, OnChainRegistry, signCertificate, unsafeGetAbiFromGitHubRepoByCodeHash, PinkContractPromise, type CertificateData, } from '@phala/sdk' -import { ApiPromise, WsProvider } from '@polkadot/api' +import { ApiPromise } from '@polkadot/api' import { Abi } from '@polkadot/api-contract' import { waitReady } from '@polkadot/wasm-crypto' import { Keyring } from '@polkadot/keyring' @@ -210,17 +210,12 @@ export default abstract class PhatCommandBase extends Command { endpoint: string pair: KeyringPair }): Promise<[ApiPromise, OnChainRegistry, CertificateData]> { - const apiPromise = await ApiPromise.create( - options({ - provider: new WsProvider(endpoint), - noInitWarn: true, - }) - ) - const registry = await OnChainRegistry.create(apiPromise, { - pruntimeURL: this.parsedFlags.pruntimeUrl + const registry = await getClient({ + transport: endpoint, + pruntimeURL: this.parsedFlags.pruntimeUrl, }) const cert = await signCertificate({ pair }) - return [apiPromise, registry, cert] + return [registry.api, registry, cert] } async getRollupAbi() { From 0b67dcc00f35827135a3f4d9301d782ce4ded22f Mon Sep 17 00:00:00 2001 From: pacoyang Date: Mon, 13 Nov 2023 23:22:24 +0800 Subject: [PATCH 8/9] ci: use matrix --- .github/workflows/main.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 942a8d3..c45d848 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,12 +8,15 @@ on: jobs: build: runs-on: ubuntu-latest + strategy: + matrix: + node-version: [16, 18, 20] steps: - uses: actions/checkout@v2 - - name: Use Node.js + - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v2 with: - node-version: 16 + node-version: ${{ matrix.node-version }} - name: Install dependencies run: yarn install --frozen-lockfile - name: Build From 7b11aeaa60eb94f1c214d43b51cfa08a0c61325a Mon Sep 17 00:00:00 2001 From: pacoyang Date: Mon, 13 Nov 2023 23:25:37 +0800 Subject: [PATCH 9/9] fix: handle JSON.parse error --- src/commands/build.ts | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/commands/build.ts b/src/commands/build.ts index e308b24..d9ed303 100644 --- a/src/commands/build.ts +++ b/src/commands/build.ts @@ -52,15 +52,19 @@ export default class Build extends Command { const pjson_file_path = upath.join(directory, 'package.json') if (existsSync(pjson_file_path)) { - const pjson = JSON.parse(readFileSync(pjson_file_path).toString()) - if (pjson.exports && typeof pjson.exports !== 'string') { - buildEntries = Object.entries(pjson.exports as Record).reduce( - (acc, [key, value]) => { - acc[key] = value - return acc - }, - { ...buildEntries }, - ) + try { + const pjson = JSON.parse(readFileSync(pjson_file_path).toString()) + if (pjson.exports && typeof pjson.exports !== 'string') { + buildEntries = Object.entries(pjson.exports as Record).reduce( + (acc, [key, value]) => { + acc[key] = value + return acc + }, + { ...buildEntries }, + ) + } + } catch (error) { + this.error(`Error parsing package.json: ${error}`) } }