From c8e7c03bb9ae8ec5ff0791c8ee500c254010a2b1 Mon Sep 17 00:00:00 2001 From: liwei Date: Wed, 11 Oct 2023 10:04:28 +0800 Subject: [PATCH] fix: create-gopeed-ext eslint + prettier --- package.json | 2 +- packages/create-gopeed-ext/createGopeedExt.js | 3 ++- packages/create-gopeed-ext/package.json | 2 +- .../templates/pure/{.gitignore => gitignore} | 0 .../create-gopeed-ext/templates/pure/index.js | 8 ++++--- .../templates/webpack/.eslintrc | 22 +++++++++++++++++++ .../templates/webpack/.prettierrc | 8 +++++++ .../webpack/{.gitignore => gitignore} | 0 .../templates/webpack/package.json | 10 ++++++--- .../templates/webpack/src/index.js | 10 +++++---- packages/gopeed-rest/package.json | 2 +- packages/gopeed-types/package.json | 2 +- packages/gopeed/package.json | 2 +- 13 files changed, 55 insertions(+), 16 deletions(-) rename packages/create-gopeed-ext/templates/pure/{.gitignore => gitignore} (100%) create mode 100644 packages/create-gopeed-ext/templates/webpack/.eslintrc create mode 100644 packages/create-gopeed-ext/templates/webpack/.prettierrc rename packages/create-gopeed-ext/templates/webpack/{.gitignore => gitignore} (100%) diff --git a/package.json b/package.json index c54c0af..351104c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "private": true, - "version": "1.0.3", + "version": "1.0.4", "packageManager": "pnpm@8.6.1", "type": "module", "scripts": { diff --git a/packages/create-gopeed-ext/createGopeedExt.js b/packages/create-gopeed-ext/createGopeedExt.js index eb766d9..f195982 100644 --- a/packages/create-gopeed-ext/createGopeedExt.js +++ b/packages/create-gopeed-ext/createGopeedExt.js @@ -103,7 +103,8 @@ function copyDir(src, dest) { if (entry.isDirectory()) { copyDir(srcPath, destPath); } else { - fs.copyFileSync(srcPath, destPath); + const fileDestPath = entry.name === 'gitignore' ? path.join(dest, '.gitignore') : destPath; + fs.copyFileSync(srcPath, fileDestPath); } }); } diff --git a/packages/create-gopeed-ext/package.json b/packages/create-gopeed-ext/package.json index db0afcf..b59cd58 100644 --- a/packages/create-gopeed-ext/package.json +++ b/packages/create-gopeed-ext/package.json @@ -1,6 +1,6 @@ { "name": "create-gopeed-ext", - "version": "1.0.3", + "version": "1.0.4", "keywords": [ "gopeed" ], diff --git a/packages/create-gopeed-ext/templates/pure/.gitignore b/packages/create-gopeed-ext/templates/pure/gitignore similarity index 100% rename from packages/create-gopeed-ext/templates/pure/.gitignore rename to packages/create-gopeed-ext/templates/pure/gitignore diff --git a/packages/create-gopeed-ext/templates/pure/index.js b/packages/create-gopeed-ext/templates/pure/index.js index fc28224..fabaa32 100644 --- a/packages/create-gopeed-ext/templates/pure/index.js +++ b/packages/create-gopeed-ext/templates/pure/index.js @@ -1,10 +1,12 @@ gopeed.events.onResolve((ctx) => { ctx.res = { - name: "gopeed", + name: 'gopeed', files: [ { - name: "test.txt", - size: 1024, + name: 'test.txt', + req: { + url: 'https://example.com/test.txt', + }, }, ], }; diff --git a/packages/create-gopeed-ext/templates/webpack/.eslintrc b/packages/create-gopeed-ext/templates/webpack/.eslintrc new file mode 100644 index 0000000..a77f088 --- /dev/null +++ b/packages/create-gopeed-ext/templates/webpack/.eslintrc @@ -0,0 +1,22 @@ +{ + "ignorePatterns": [ + "node_modules/", + "dist/" + ], + "parserOptions": { + "ecmaVersion": 7, + "sourceType": "module" + }, + "extends": [ + "eslint:recommended" + ], + "plugins": [ + "prettier" + ], + "rules": { + "prettier/prettier": "error" + }, + "env": { + "browser": true + } +} \ No newline at end of file diff --git a/packages/create-gopeed-ext/templates/webpack/.prettierrc b/packages/create-gopeed-ext/templates/webpack/.prettierrc new file mode 100644 index 0000000..db014d2 --- /dev/null +++ b/packages/create-gopeed-ext/templates/webpack/.prettierrc @@ -0,0 +1,8 @@ +{ + "semi": true, + "trailingComma": "es5", + "singleQuote": true, + "printWidth": 120, + "tabWidth": 2, + "endOfLine": "auto" +} \ No newline at end of file diff --git a/packages/create-gopeed-ext/templates/webpack/.gitignore b/packages/create-gopeed-ext/templates/webpack/gitignore similarity index 100% rename from packages/create-gopeed-ext/templates/webpack/.gitignore rename to packages/create-gopeed-ext/templates/webpack/gitignore diff --git a/packages/create-gopeed-ext/templates/webpack/package.json b/packages/create-gopeed-ext/templates/webpack/package.json index a278b06..713a9ba 100644 --- a/packages/create-gopeed-ext/templates/webpack/package.json +++ b/packages/create-gopeed-ext/templates/webpack/package.json @@ -17,8 +17,12 @@ "@babel/core": "^7.22.20", "@babel/preset-env": "^7.22.20", "babel-loader": "^9.1.3", + "eslint": "^8.51.0", + "eslint-config-prettier": "^9.0.0", + "eslint-plugin-prettier": "^5.0.0", + "gopeed": "^1.0.4", + "prettier": "^3.0.3", "webpack": "^5.75.0", - "webpack-cli": "^5.0.1", - "gopeed": "^1.0.3" + "webpack-cli": "^5.0.1" } -} \ No newline at end of file +} diff --git a/packages/create-gopeed-ext/templates/webpack/src/index.js b/packages/create-gopeed-ext/templates/webpack/src/index.js index 5ea407a..62fbb1d 100644 --- a/packages/create-gopeed-ext/templates/webpack/src/index.js +++ b/packages/create-gopeed-ext/templates/webpack/src/index.js @@ -1,12 +1,14 @@ -import gopeed from "gopeed"; +import gopeed from 'gopeed'; gopeed.events.onResolve((ctx) => { ctx.res = { - name: "gopeed", + name: 'gopeed', files: [ { - name: "test.txt", - size: 1024, + name: 'test.txt', + req: { + url: 'https://example.com/test.txt', + }, }, ], }; diff --git a/packages/gopeed-rest/package.json b/packages/gopeed-rest/package.json index a7cb57b..94a60a1 100644 --- a/packages/gopeed-rest/package.json +++ b/packages/gopeed-rest/package.json @@ -1,6 +1,6 @@ { "name": "@gopeed/rest", - "version": "1.0.3", + "version": "1.0.4", "description": "", "main": "dist/index.js", "exports": { diff --git a/packages/gopeed-types/package.json b/packages/gopeed-types/package.json index 7a621d0..aec479a 100644 --- a/packages/gopeed-types/package.json +++ b/packages/gopeed-types/package.json @@ -1,6 +1,6 @@ { "name": "@gopeed/types", - "version": "1.0.3", + "version": "1.0.4", "description": "", "main": "dist/index.js", "exports": { diff --git a/packages/gopeed/package.json b/packages/gopeed/package.json index 2d43a85..ebecaff 100644 --- a/packages/gopeed/package.json +++ b/packages/gopeed/package.json @@ -1,6 +1,6 @@ { "name": "gopeed", - "version": "1.0.3", + "version": "1.0.4", "description": "", "main": "dist/index.js", "exports": {