From 238468ddaa1dfc52c9b97bad7f777b14a45d66f5 Mon Sep 17 00:00:00 2001 From: Henry Heino <46334387+personalizedrefrigerator@users.noreply.github.com> Date: Mon, 11 Mar 2024 03:11:07 -0700 Subject: [PATCH] Chore: Joplin generator: Remove `@joplin/lib` dev dependency from generated projects (#10075) --- .eslintignore | 1 + .gitignore | 1 + .../app/templates/package_TEMPLATE.json | 3 +-- .../app/templates/webpack.config.js | 5 ++++- packages/generator-joplin/package.json | 8 ++++++-- .../tools/updateCategories.ts | 20 +++++++++++++++++++ packages/generator-joplin/updateTypes.sh | 2 ++ yarn.lock | 3 +++ 8 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 packages/generator-joplin/tools/updateCategories.ts diff --git a/.eslintignore b/.eslintignore index 6ba5f5e91..dc7e22cd7 100644 --- a/.eslintignore +++ b/.eslintignore @@ -677,6 +677,7 @@ packages/generator-joplin/generators/app/templates/api/noteListType.js packages/generator-joplin/generators/app/templates/api/types.js packages/generator-joplin/generators/app/templates/api_index.js packages/generator-joplin/generators/app/templates/src/index.js +packages/generator-joplin/tools/updateCategories.js packages/htmlpack/src/index.js packages/lib/ArrayUtils.js packages/lib/AsyncActionQueue.js diff --git a/.gitignore b/.gitignore index 530ee075d..999d8b9c8 100644 --- a/.gitignore +++ b/.gitignore @@ -657,6 +657,7 @@ packages/generator-joplin/generators/app/templates/api/noteListType.js packages/generator-joplin/generators/app/templates/api/types.js packages/generator-joplin/generators/app/templates/api_index.js packages/generator-joplin/generators/app/templates/src/index.js +packages/generator-joplin/tools/updateCategories.js packages/htmlpack/src/index.js packages/lib/ArrayUtils.js packages/lib/AsyncActionQueue.js diff --git a/packages/generator-joplin/generators/app/templates/package_TEMPLATE.json b/packages/generator-joplin/generators/app/templates/package_TEMPLATE.json index 9eae02a18..92fad8d15 100644 --- a/packages/generator-joplin/generators/app/templates/package_TEMPLATE.json +++ b/packages/generator-joplin/generators/app/templates/package_TEMPLATE.json @@ -24,7 +24,6 @@ "ts-loader": "^9.3.1", "typescript": "^4.8.2", "webpack": "^5.74.0", - "webpack-cli": "^4.10.0", - "@joplin/lib": "~2.9" + "webpack-cli": "^4.10.0" } } diff --git a/packages/generator-joplin/generators/app/templates/webpack.config.js b/packages/generator-joplin/generators/app/templates/webpack.config.js index cfd773b81..cc5308b1a 100644 --- a/packages/generator-joplin/generators/app/templates/webpack.config.js +++ b/packages/generator-joplin/generators/app/templates/webpack.config.js @@ -16,7 +16,10 @@ const CopyPlugin = require('copy-webpack-plugin'); const tar = require('tar'); const glob = require('glob'); const execSync = require('child_process').execSync; -const allPossibleCategories = require('@joplin/lib/pluginCategories.json'); + +// AUTO-GENERATED by updateCategories +const allPossibleCategories = [{ 'name': 'appearance' }, { 'name': 'developer tools' }, { 'name': 'productivity' }, { 'name': 'themes' }, { 'name': 'integrations' }, { 'name': 'viewer' }, { 'name': 'search' }, { 'name': 'tags' }, { 'name': 'editor' }, { 'name': 'files' }, { 'name': 'personal knowledge management' }]; +// AUTO-GENERATED by updateCategories const rootDir = path.resolve(__dirname); const userConfigFilename = './plugin.config.json'; diff --git a/packages/generator-joplin/package.json b/packages/generator-joplin/package.json index 8a6328a66..0bda6734c 100644 --- a/packages/generator-joplin/package.json +++ b/packages/generator-joplin/package.json @@ -9,7 +9,8 @@ }, "scripts": { "test": "jest", - "test-ci": "yarn test" + "test-ci": "yarn test", + "updateCategories": "ts-node tools/updateCategories.ts" }, "files": [ "generators" @@ -29,7 +30,10 @@ "yosay": "2.0.2" }, "devDependencies": { - "jest": "29.7.0" + "@joplin/lib": "~3.0", + "@joplin/tools": "~3.0", + "jest": "29.7.0", + "ts-node": "10.9.2" }, "repository": "https://github.com/laurent22/generator-joplin", "license": "AGPL-3.0-or-later", diff --git a/packages/generator-joplin/tools/updateCategories.ts b/packages/generator-joplin/tools/updateCategories.ts new file mode 100644 index 000000000..c3fc00256 --- /dev/null +++ b/packages/generator-joplin/tools/updateCategories.ts @@ -0,0 +1,20 @@ + +import { dirname } from 'path'; +import { insertContentIntoFile } from '@joplin/tools/tool-utils'; +const allCategories = require('@joplin/lib/pluginCategories.json'); + +const updateCategories = async () => { + const buildScriptPath = `${dirname(__dirname)}/generators/app/templates/webpack.config.js`; + + const possibleCategoriesJson = JSON.stringify(allCategories).replace(/["]/g, '\''); + const possibleCategoriesLine = `const allPossibleCategories = ${possibleCategoriesJson};`; + + await insertContentIntoFile( + buildScriptPath, + '// AUTO-GENERATED by updateCategories\n', + '\n// AUTO-GENERATED by updateCategories', + possibleCategoriesLine, + ); +}; + +void updateCategories(); diff --git a/packages/generator-joplin/updateTypes.sh b/packages/generator-joplin/updateTypes.sh index 5362c384d..16d4c56fc 100755 --- a/packages/generator-joplin/updateTypes.sh +++ b/packages/generator-joplin/updateTypes.sh @@ -13,3 +13,5 @@ cp "$LIB_DIR/services/plugins/api/types.ts" "$SCRIPT_DIR/generators/app/template cp "$LIB_DIR/services/plugins/api/noteListType.ts" "$SCRIPT_DIR/generators/app/templates/api/" cp "$SCRIPT_DIR/generators/app/templates/api_index.ts" "$SCRIPT_DIR/generators/app/templates/api/index.ts" rm -f "$SCRIPT_DIR/generators/app/templates/api/types.d.ts" + +yarn updateCategories \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 0e7b36762..7a662d7f0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -22406,9 +22406,12 @@ __metadata: version: 0.0.0-use.local resolution: "generator-joplin@workspace:packages/generator-joplin" dependencies: + "@joplin/lib": ~3.0 + "@joplin/tools": ~3.0 chalk: 2.4.2 jest: 29.7.0 slugify: 1.6.6 + ts-node: 10.9.2 yeoman-generator: 5.10.0 yosay: 2.0.2 languageName: unknown