From bf41b7c12ec7e37690b462850de584cad0243c33 Mon Sep 17 00:00:00 2001 From: suhaotian Date: Fri, 15 Nov 2024 13:50:42 +1100 Subject: [PATCH] Fix --- .github/workflows/release-deno.yml | 4 ++++ package.json | 3 ++- pnpm-lock.yaml | 25 ++++++++++++++----------- scripts/replace-files-for-deno.mjs | 23 +++++++++++++++++++++++ 4 files changed, 43 insertions(+), 12 deletions(-) create mode 100644 scripts/replace-files-for-deno.mjs diff --git a/.github/workflows/release-deno.yml b/.github/workflows/release-deno.yml index f35bad9..4ba1630 100644 --- a/.github/workflows/release-deno.yml +++ b/.github/workflows/release-deno.yml @@ -26,6 +26,10 @@ jobs: node-version: ${{ matrix.node-version }} registry-url: 'https://registry.npmjs.org' + + - name: Install and Update ./src/*.ts for deno + run: npm install && node scripts/replace-files-for-deno.mjs + - name: Move files to ./deno folder run: cp ./deno/deno.json README.md Mock-plugin.md CHANGELOG.md ./src/ && rm -f package.json diff --git a/package.json b/package.json index 50e98d1..9b20318 100644 --- a/package.json +++ b/package.json @@ -112,7 +112,8 @@ "promise-polyfill": "^8.3.0", "webpack": "^5.93.0", "webpack-cli": "^5.1.4", - "change-case": "^5.4.4" + "change-case": "^5.4.4", + "fast-glob": "^3.3.2" }, "prettier": { "printWidth": 100, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index af1679a..c2783f3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -57,6 +57,9 @@ importers: express: specifier: ^4.19.2 version: 4.19.2 + fast-glob: + specifier: ^3.3.2 + version: 3.3.2 husky: specifier: ^9.1.1 version: 9.1.1 @@ -5802,17 +5805,17 @@ snapshots: '@webassemblyjs/ast': 1.12.1 '@xtuc/long': 4.2.2 - '@webpack-cli/configtest@2.1.1(webpack-cli@5.1.4(webpack@5.93.0))(webpack@5.93.0(@swc/core@1.6.7(@swc/helpers@0.5.11))(webpack-cli@5.1.4))': + '@webpack-cli/configtest@2.1.1(webpack-cli@5.1.4)(webpack@5.93.0)': dependencies: webpack: 5.93.0(@swc/core@1.6.7(@swc/helpers@0.5.11))(webpack-cli@5.1.4) webpack-cli: 5.1.4(webpack@5.93.0) - '@webpack-cli/info@2.0.2(webpack-cli@5.1.4(webpack@5.93.0))(webpack@5.93.0(@swc/core@1.6.7(@swc/helpers@0.5.11))(webpack-cli@5.1.4))': + '@webpack-cli/info@2.0.2(webpack-cli@5.1.4)(webpack@5.93.0)': dependencies: webpack: 5.93.0(@swc/core@1.6.7(@swc/helpers@0.5.11))(webpack-cli@5.1.4) webpack-cli: 5.1.4(webpack@5.93.0) - '@webpack-cli/serve@2.0.5(webpack-cli@5.1.4(webpack@5.93.0))(webpack@5.93.0(@swc/core@1.6.7(@swc/helpers@0.5.11))(webpack-cli@5.1.4))': + '@webpack-cli/serve@2.0.5(webpack-cli@5.1.4)(webpack@5.93.0)': dependencies: webpack: 5.93.0(@swc/core@1.6.7(@swc/helpers@0.5.11))(webpack-cli@5.1.4) webpack-cli: 5.1.4(webpack@5.93.0) @@ -6749,7 +6752,7 @@ snapshots: debug: 4.3.4 enhanced-resolve: 5.16.0 eslint: 8.56.0 - eslint-module-utils: 2.8.0(@typescript-eslint/parser@6.20.0(eslint@8.56.0)(typescript@5.3.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@6.20.0(eslint@8.56.0)(typescript@5.3.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1)(eslint@8.56.0))(eslint@8.56.0) + eslint-module-utils: 2.8.0(@typescript-eslint/parser@6.20.0(eslint@8.56.0)(typescript@5.3.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1)(eslint@8.56.0) eslint-plugin-import: 2.29.1(@typescript-eslint/parser@7.8.0(eslint@8.56.0)(typescript@5.3.3))(eslint@8.56.0) fast-glob: 3.3.2 get-tsconfig: 4.7.2 @@ -6761,7 +6764,7 @@ snapshots: - eslint-import-resolver-webpack - supports-color - eslint-module-utils@2.8.0(@typescript-eslint/parser@6.20.0(eslint@8.56.0)(typescript@5.3.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@6.20.0(eslint@8.56.0)(typescript@5.3.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1)(eslint@8.56.0))(eslint@8.56.0): + eslint-module-utils@2.8.0(@typescript-eslint/parser@6.20.0(eslint@8.56.0)(typescript@5.3.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1)(eslint@8.56.0): dependencies: debug: 3.2.7 optionalDependencies: @@ -7097,7 +7100,7 @@ snapshots: '@nodelib/fs.walk': 1.2.8 glob-parent: 5.1.2 merge2: 1.4.1 - micromatch: 4.0.5 + micromatch: 4.0.7 fast-json-stable-stringify@2.1.0: {} @@ -8845,7 +8848,7 @@ snapshots: tapable@2.2.1: {} - terser-webpack-plugin@5.3.10(@swc/core@1.6.7(@swc/helpers@0.5.11))(webpack@5.93.0(@swc/core@1.6.7(@swc/helpers@0.5.11))(webpack-cli@5.1.4)): + terser-webpack-plugin@5.3.10(@swc/core@1.6.7(@swc/helpers@0.5.11))(webpack@5.93.0): dependencies: '@jridgewell/trace-mapping': 0.3.25 jest-worker: 27.5.1 @@ -9128,9 +9131,9 @@ snapshots: webpack-cli@5.1.4(webpack@5.93.0): dependencies: '@discoveryjs/json-ext': 0.5.7 - '@webpack-cli/configtest': 2.1.1(webpack-cli@5.1.4(webpack@5.93.0))(webpack@5.93.0(@swc/core@1.6.7(@swc/helpers@0.5.11))(webpack-cli@5.1.4)) - '@webpack-cli/info': 2.0.2(webpack-cli@5.1.4(webpack@5.93.0))(webpack@5.93.0(@swc/core@1.6.7(@swc/helpers@0.5.11))(webpack-cli@5.1.4)) - '@webpack-cli/serve': 2.0.5(webpack-cli@5.1.4(webpack@5.93.0))(webpack@5.93.0(@swc/core@1.6.7(@swc/helpers@0.5.11))(webpack-cli@5.1.4)) + '@webpack-cli/configtest': 2.1.1(webpack-cli@5.1.4)(webpack@5.93.0) + '@webpack-cli/info': 2.0.2(webpack-cli@5.1.4)(webpack@5.93.0) + '@webpack-cli/serve': 2.0.5(webpack-cli@5.1.4)(webpack@5.93.0) colorette: 2.0.20 commander: 10.0.1 cross-spawn: 7.0.3 @@ -9173,7 +9176,7 @@ snapshots: neo-async: 2.6.2 schema-utils: 3.3.0 tapable: 2.2.1 - terser-webpack-plugin: 5.3.10(@swc/core@1.6.7(@swc/helpers@0.5.11))(webpack@5.93.0(@swc/core@1.6.7(@swc/helpers@0.5.11))(webpack-cli@5.1.4)) + terser-webpack-plugin: 5.3.10(@swc/core@1.6.7(@swc/helpers@0.5.11))(webpack@5.93.0) watchpack: 2.4.1 webpack-sources: 3.2.3 optionalDependencies: diff --git a/scripts/replace-files-for-deno.mjs b/scripts/replace-files-for-deno.mjs new file mode 100644 index 0000000..cecd953 --- /dev/null +++ b/scripts/replace-files-for-deno.mjs @@ -0,0 +1,23 @@ +import glob from 'fast-glob'; +import fs from 'fs/promises'; + +async function start() { + const files = await glob(['./src/*.ts']); + const pluginFiles = await glob(['./src/plugins/*.ts']); + + await Promise.all( + files.map((item) => { + const content = fs.readFile(item, 'utf8'); + return fs.writeFile(item, content.replace(/'xior\/utils'/g, "'./utils'")); + }) + ); + + await Promise.all( + pluginFiles.map((item) => { + const content = fs.readFile(item, 'utf8'); + return fs.writeFile(item, content.replace(/'xior\/utils'/g, "'../utils'")); + }) + ); +} + +start();