diff --git a/.vscode/PackageJsonMapping.sillot.jsonc b/.vscode/PackageJsonMapping.sillot.jsonc new file mode 100644 index 0000000000..0b233cc89e --- /dev/null +++ b/.vscode/PackageJsonMapping.sillot.jsonc @@ -0,0 +1,7 @@ +{ + "Sillot (工作区)": [ + "a:\\Github\\Hi-Windom\\Sillot\\.vscode\\extensions\\Sillot\\package.json", + "a:\\Github\\Hi-Windom\\Sillot\\app\\package.json", + "a:\\Github\\Hi-Windom\\Sillot\\docs\\starlight\\package.json", + ], +} \ No newline at end of file diff --git a/.vscode/extensions/Sillot/package.json b/.vscode/extensions/Sillot/package.json index 6525288ae0..1a636b7ba0 100644 --- a/.vscode/extensions/Sillot/package.json +++ b/.vscode/extensions/Sillot/package.json @@ -1,411 +1,428 @@ { - "name": "sillot", - "displayName": "汐洛 Sillot", - "description": "汐洛(Sillot)孵化自思源笔记(siyuan-note),致力于服务智慧新彖乄。此插件为汐洛官方插件,提供多功能一体化集成。", - "version": "0.1.2000", - "preview": true, - "repository": "https://github.com/Hi-Windom/Sillot", - "publisher": "Hi-Windom", - "icon": "media/icon.png", - "galleryBanner": { - "color": "#131824", - "theme": "dark" - }, - "keywords": [ - "ms-ceintl.vscode-language-pack-zh-hans" + "name": "sillot", + "displayName": "汐洛 Sillot", + "description": "汐洛(Sillot)孵化自思源笔记(siyuan-note),致力于服务智慧新彖乄。此插件为汐洛官方插件,提供多功能一体化集成。", + "version": "0.32.2000", + "preview": true, + "repository": "https://github.com/Hi-Windom/Sillot", + "publisher": "Hi-Windom", + "icon": "media/icon.png", + "galleryBanner": { + "color": "#131824", + "theme": "dark" + }, + "keywords": [ + "ms-ceintl.vscode-language-pack-zh-hans" + ], + "extensionDependencies": [], + "markdown": "github", + "engines": { + "vscode": "^1.88.0" + }, + "categories": [ + "Programming Languages", + "Snippets", + "Extension Packs" + ], + "activationEvents": [ + "onDidChangeTextDocument", + "onDidChangeActiveTextEditor", + "onLanguage:plaintext", + "onLanguage:json", + "onLanguage:jsonc", + "onLanguage:go", + "onLanguage:javascript", + "onLanguage:typescript", + "onLanguage:yaml", + "onLanguage:markdown", + "onLanguage:astro", + "onLanguage:csharp", + "onLanguage:kotlin", + "onLanguage:css", + "onLanguage:less", + "onLanguage:scss", + "onLanguage:python", + "onLanguage:xml", + "workspaceContains:**/.editorconfig" + ], + "main": "./dist/extension.js", + "contributes": { + "themes": [ + { + "label": "Sample Light", + "uiTheme": "vs", + "path": "./theme/Sample_Light.tmTheme" + }, + { + "label": "Sample Dark", + "uiTheme": "vs-dark", + "path": "./theme/Sample_Dark.tmTheme" + } ], - "extensionDependencies": [], - "markdown": "github", - "engines": { - "vscode": "^1.88.0" + "configuration": { + "type": "object", + "title": "汐洛插件配置", + "properties": { + "codelens-sample.enableCodeLens": { + "type": "boolean", + "default": true + }, + "typescript.useCodeSnippetsOnMethodSuggest": { + "type": "boolean", + "default": false, + "description": "Complete functions with their parameter signature." + }, + "sillot.typescript.tsdk": { + "type": [ + "string", + "null" + ], + "default": null, + "markdownDescription": "Specifies the folder path containing the tsserver and `lib*.d.ts` files to use." + } + } }, - "categories": [ - "Programming Languages", - "Snippets", - "Extension Packs" + "commands": [ + { + "command": "extension.getGitHubUser", + "title": "Get GitHub User", + "category": "GitHub 认证 (共享)" + }, + { + "command": "sillot.getGitHubUser", + "title": "Get GitHub User", + "category": "GitHub 认证 (独占)" + }, + { + "command": "sillot.helloWorld", + "title": "Hello World", + "category": "Sillot" + }, + { + "command": "sillot.openPackageOnNpm", + "title": "Open Package on NPM", + "category": "Sillot" + }, + { + "command": "sillot.测试序列化字典", + "title": "测试序列化字典", + "category": "Sillot" + }, + { + "command": "sillot.测试反序列化字典", + "title": "测试反序列化字典", + "category": "Sillot" + }, + { + "command": "sillot.pickEXE", + "title": "pickEXE", + "category": "Sillot" + }, + { + "title": "Enable CodeLens", + "command": "codelens-sample.enableCodeLens", + "category": "CodeLens Sample" + }, + { + "title": "Disable Codelens", + "command": "codelens-sample.disableCodeLens", + "category": "CodeLens Sample" + }, + { + "command": "汐洛.花字.样式_反转大小写", + "title": "♻️ 应用样式_反转大小写 abcABC... ⚠️ 恢复默认字体", + "category": "Sillot" + }, + { + "command": "汐洛.花字.样式_转大写", + "title": "♻️ 应用样式_转大写 ABCABC... ⚠️ 恢复默认字体", + "category": "Sillot" + }, + { + "command": "汐洛.花字.样式_转小写", + "title": "♻️ 应用样式_转小写 abcabc... ⚠️ 恢复默认字体", + "category": "Sillot" + }, + { + "command": "汐洛.花字.字体_默认", + "title": "♻️ 应用字体_默认 ABCabc...", + "category": "Sillot" + }, + { + "command": "汐洛.花字.字体_手写体", + "title": "♻️ 应用字体_手写体 𝓐𝓑𝓒𝒶𝒷𝒸...", + "category": "Sillot" + }, + { + "command": "汐洛.花字.字体_粗体", + "title": "♻️ 应用字体_粗体 𝗔𝗕𝗖𝗮𝗯𝗰...", + "category": "Sillot" + }, + { + "command": "汐洛.花字.字体_德文尖角", + "title": "♻️ 应用字体_德文尖角 𝕬𝕭𝕮𝔞𝔟𝔠...", + "category": "Sillot" + }, + { + "command": "汐洛.花字.字体_斜体", + "title": "♻️ 应用字体_斜体 𝘈𝘉𝘊𝘢𝘣𝘤...", + "category": "Sillot" + }, + { + "command": "汐洛.花字.字体_等宽", + "title": "♻️ 应用字体_等宽 𝙰𝙱𝙲𝚊𝚋𝚌...", + "category": "Sillot" + }, + { + "command": "汐洛.花字.字体_删除线", + "title": "♻️ 应用字体_删除线 𝙰𝙱𝙲𝚊𝚋𝚌...", + "category": "Sillot" + }, + { + "command": "汐洛.同步更新版本", + "title": "汐洛 🤍 同步更新版本", + "category": "Sillot" + }, + { + "command": "汐洛.addPackageJsonMapping", + "title": "汐洛 🤍 添加包JSON映射", + "category": "Sillot" + } ], - "activationEvents": [ - "onDidChangeTextDocument", - "onDidChangeActiveTextEditor", - "onLanguage:plaintext", - "onLanguage:json", - "onLanguage:jsonc", - "onLanguage:go", - "onLanguage:javascript", - "onLanguage:typescript", - "onLanguage:yaml", - "onLanguage:markdown", - "onLanguage:astro", - "onLanguage:csharp", - "onLanguage:kotlin", - "onLanguage:css", - "onLanguage:less", - "onLanguage:scss", - "onLanguage:python", - "onLanguage:xml", - "workspaceContains:**/.editorconfig" + "submenus": [ + { + "id": "汐洛.花字", + "label": "🦢 汐洛花字菜单 - Sillot 🌸 Menu" + } ], - "main": "./dist/extension.js", - "contributes": { - "themes": [ - { - "label": "Sample Light", - "uiTheme": "vs", - "path": "./theme/Sample_Light.tmTheme" - }, - { - "label": "Sample Dark", - "uiTheme": "vs-dark", - "path": "./theme/Sample_Dark.tmTheme" - } - ], - "configuration": { - "type": "object", - "title": "汐洛插件配置", - "properties": { - "codelens-sample.enableCodeLens": { - "type": "boolean", - "default": true - }, - "typescript.useCodeSnippetsOnMethodSuggest": { - "type": "boolean", - "default": false, - "description": "Complete functions with their parameter signature." - }, - "sillot.typescript.tsdk": { - "type": [ - "string", - "null" - ], - "default": null, - "markdownDescription": "Specifies the folder path containing the tsserver and `lib*.d.ts` files to use." - } - } + "menus": { + "汐洛.花字": [ + { + "command": "汐洛.花字.样式_反转大小写" }, - "commands": [ - { - "command": "extension.getGitHubUser", - "title": "Get GitHub User", - "category": "GitHub 认证 (共享)" - }, - { - "command": "sillot.getGitHubUser", - "title": "Get GitHub User", - "category": "GitHub 认证 (独占)" - }, - { - "command": "sillot.helloWorld", - "title": "Hello World", - "category": "Sillot" - }, - { - "command": "sillot.openPackageOnNpm", - "title": "Open Package on NPM", - "category": "Sillot" - }, - { - "command": "sillot.测试序列化字典", - "title": "测试序列化字典", - "category": "Sillot" - }, - { - "command": "sillot.测试反序列化字典", - "title": "测试反序列化字典", - "category": "Sillot" - }, - { - "command": "sillot.pickEXE", - "title": "pickEXE", - "category": "Sillot" - }, - { - "title": "Enable CodeLens", - "command": "codelens-sample.enableCodeLens", - "category": "CodeLens Sample" - }, - { - "title": "Disable Codelens", - "command": "codelens-sample.disableCodeLens", - "category": "CodeLens Sample" - }, - { - "command": "汐洛.花字.样式_反转大小写", - "title": "♻️ 应用样式_反转大小写 abcABC... ⚠️ 恢复默认字体", - "category": "Sillot" - }, - { - "command": "汐洛.花字.样式_转大写", - "title": "♻️ 应用样式_转大写 ABCABC... ⚠️ 恢复默认字体", - "category": "Sillot" - }, - { - "command": "汐洛.花字.样式_转小写", - "title": "♻️ 应用样式_转小写 abcabc... ⚠️ 恢复默认字体", - "category": "Sillot" - }, - { - "command": "汐洛.花字.字体_默认", - "title": "♻️ 应用字体_默认 ABCabc...", - "category": "Sillot" - }, - { - "command": "汐洛.花字.字体_手写体", - "title": "♻️ 应用字体_手写体 𝓐𝓑𝓒𝒶𝒷𝒸...", - "category": "Sillot" - }, - { - "command": "汐洛.花字.字体_粗体", - "title": "♻️ 应用字体_粗体 𝗔𝗕𝗖𝗮𝗯𝗰...", - "category": "Sillot" - }, - { - "command": "汐洛.花字.字体_德文尖角", - "title": "♻️ 应用字体_德文尖角 𝕬𝕭𝕮𝔞𝔟𝔠...", - "category": "Sillot" - }, - { - "command": "汐洛.花字.字体_斜体", - "title": "♻️ 应用字体_斜体 𝘈𝘉𝘊𝘢𝘣𝘤...", - "category": "Sillot" - }, - { - "command": "汐洛.花字.字体_等宽", - "title": "♻️ 应用字体_等宽 𝙰𝙱𝙲𝚊𝚋𝚌...", - "category": "Sillot" - }, - { - "command": "汐洛.花字.字体_删除线", - "title": "♻️ 应用字体_删除线 𝙰𝙱𝙲𝚊𝚋𝚌...", - "category": "Sillot" - } - ], - "submenus": [ - { - "id": "汐洛.花字", - "label": "🦢 汐洛花字菜单 - Sillot 🌸 Menu" - } - ], - "menus": { - "汐洛.花字": [ - { - "command": "汐洛.花字.样式_反转大小写" - }, - { - "command": "汐洛.花字.样式_转大写" - }, - { - "command": "汐洛.花字.样式_转小写" - }, - { - "command": "汐洛.花字.字体_默认" - }, - { - "command": "汐洛.花字.字体_手写体" - }, - { - "command": "汐洛.花字.字体_粗体" - }, - { - "command": "汐洛.花字.字体_德文尖角" - }, - { - "command": "汐洛.花字.字体_斜体" - }, - { - "command": "汐洛.花字.字体_等宽" - }, - { - "command": "汐洛.花字.字体_删除线" - } - ], - "editor/context": [ - { - "when": "editorHasSelection && resourceLangId == typescript", - "command": "sillot.openPackageOnNpm", - "group": "navigation" - }, - { - "when": "editorHasSelection", - "submenu": "汐洛.花字", - "group": "navigation" - } - ] + { + "command": "汐洛.花字.样式_转大写" }, - "viewsContainers": { - "activitybar": [ - { - "id": "package-explorer", - "title": "汐洛插件面板", - "icon": "media/dep.svg" - } - ] + { + "command": "汐洛.花字.样式_转小写" }, - "views": { - "package-explorer": [ - { - "id": "nodeDependencies", - "name": "Node Dependencies", - "icon": "media/dep.svg", - "contextualTitle": "Package Explorer" - } - ], - "explorer": [ - { - "id": "jsonOutline", - "name": "Json Outline", - "when": "jsonOutlineEnabled" - }, - { - "id": "ftpExplorer", - "name": "FTP Explorer" - }, - { - "id": "fileExplorer", - "name": "File Explorer" - }, - { - "id": "testView", - "name": "Test View" - }, - { - "id": "testViewDragAndDrop", - "name": "Test View Drag and Drop" - } - ] + { + "command": "汐洛.花字.字体_默认" }, - "languages": [ - { - "id": "dosc", - "aliases": [ - "csod", - "ds" - ], - "extensions": [ - ".dosc" - ], - "configuration": "./languages/_dosc.language-configuration.json" - }, - { - "id": "sy", - "aliases": [ - "SY", - "sy" - ], - "extensions": [ - ".sy" - ], - "configuration": "./languages/_sy.language-configuration.json" - } + { + "command": "汐洛.花字.字体_手写体" + }, + { + "command": "汐洛.花字.字体_粗体" + }, + { + "command": "汐洛.花字.字体_德文尖角" + }, + { + "command": "汐洛.花字.字体_斜体" + }, + { + "command": "汐洛.花字.字体_等宽" + }, + { + "command": "汐洛.花字.字体_删除线" + } + ], + "editor/context": [ + { + "when": "editorHasSelection && resourceLangId == typescript", + "command": "sillot.openPackageOnNpm", + "group": "navigation" + }, + { + "when": "editorHasSelection", + "submenu": "汐洛.花字", + "group": "navigation" + } + ], + "explorer/context": [ + { + "when": "resourceLangId == json && resourceFilename == package.json", + "command": "汐洛.addPackageJsonMapping", + "group": "navigation" + } + ] + }, + "viewsContainers": { + "activitybar": [ + { + "id": "package-explorer", + "title": "汐洛插件面板", + "icon": "media/dep.svg" + } + ] + }, + "views": { + "package-explorer": [ + { + "id": "nodeDependencies", + "name": "Node Dependencies", + "icon": "media/dep.svg", + "contextualTitle": "Package Explorer" + } + ], + "explorer": [ + { + "id": "jsonOutline", + "name": "Json Outline", + "when": "jsonOutlineEnabled" + }, + { + "id": "ftpExplorer", + "name": "FTP Explorer" + }, + { + "id": "fileExplorer", + "name": "File Explorer" + }, + { + "id": "testView", + "name": "Test View" + }, + { + "id": "testViewDragAndDrop", + "name": "Test View Drag and Drop" + } + ] + }, + "languages": [ + { + "id": "dosc", + "aliases": [ + "csod", + "ds" ], - "codeActions": [ - { - "languages": [ - "sy" - ], - "provider": "SyCodeActionProvider", - "providedCodeActionKinds": [ - "quickfix", - "refactor", - "source", - "organizeImports" - ], - "actions": { - "kind": "quickfix", - "title": "Fix sy error", - "description": "Fixes a JSON error in the current file" - } - } + "extensions": [ + ".dosc" ], - "semanticTokenTypes": [ - { - "id": "type", - "description": "Type names", - "defaultLegend": { - "tokenType": "type" - } - }, - { - "id": "trailingComma", - "description": "Trailing commas in JSON", - "defaultLegend": { - "tokenType": "trailingComma" - } - } + "configuration": "./languages/_dosc.language-configuration.json" + }, + { + "id": "sy", + "aliases": [ + "SY", + "sy" ], - "semanticTokenModifiers": [ - { - "id": "error", - "description": "Indicates an error" - } + "extensions": [ + ".sy" ], - "grammars": [ - { - "language": "sy", - "scopeName": "source.sy", - "path": "./grammars/sy.tmLanguage.json" - } + "configuration": "./languages/_sy.language-configuration.json" + } + ], + "codeActions": [ + { + "languages": [ + "sy" ], - "snippets": [ - { - "language": "javascript", - "path": "./snippets/sofill.json" - }, - { - "language": "typescript", - "path": "./snippets/sofill.json" - }, - { - "language": "markdown", - "path": "./snippets/md.json" - }, - { - "language": "mdx", - "path": "./snippets/md.json" - } - ] - }, - "vsce": { - "baseImagesUrl": "https://raw.githubusercontent.com/Hi-Windom/Sillot/master/app/stage/icon.png", - "dependencies": false, - "yarn": false - }, - "scripts": { - "vscode:prepublish": "pnpm run package", - "compile": "webpack", - "watch": "webpack --watch", - "package": "webpack --mode production --devtool hidden-source-map", - "vsce:package": "pnpm vsce package", - "vsce:login": "pnpm vsce login Hi-Windom", - "compile-tests": "tsc -p . --outDir out", - "watch-tests": "tsc -p . -w --outDir out", - "pretest": "pnpm run compile-tests && pnpm run compile && pnpm run lint", - "lint": "eslint src --ext ts --fix", - "test": "vscode-test", - "b:lint": "biome lint ./src --config-path ../../ --diagnostic-level error --apply && echo 'ref https://biomejs.dev/reference/cli/#biome-lint'", - "b:check": "biome check ./src --config-path ../../ --diagnostic-level error --apply && echo 'ref https://biomejs.dev/reference/cli/#biome-check'" - }, - "devDependencies": { - "@types/fs-extra": "^11.0.4", - "@types/mocha": "^10.0.6", - "@types/node": "18.x", - "@types/vscode": "^1.88.0", - "@typescript-eslint/eslint-plugin": "^7.4.0", - "@typescript-eslint/parser": "^7.4.0", - "@vscode/test-cli": "^0.0.8", - "@vscode/test-electron": "^2.3.9", - "@vscode/vsce": "^2.26.0", - "eslint": "^8.57.0", - "jsonc-parser": "^3.2.1", - "mkdirp": "^3.0.1", - "rimraf": "^5.0.5", - "ts-loader": "^9.5.1", - "typescript": "^5.3.3", - "webpack": "^5.91.0", - "webpack-cli": "^5.1.4" - }, - "dependencies": { - "@octokit/rest": "^20.1.0", - "fs-extra": "^11.2.0", - "json5": "^2.2.3" - } -} + "provider": "SyCodeActionProvider", + "providedCodeActionKinds": [ + "quickfix", + "refactor", + "source", + "organizeImports" + ], + "actions": { + "kind": "quickfix", + "title": "Fix sy error", + "description": "Fixes a JSON error in the current file" + } + } + ], + "semanticTokenTypes": [ + { + "id": "type", + "description": "Type names", + "defaultLegend": { + "tokenType": "type" + } + }, + { + "id": "trailingComma", + "description": "Trailing commas in JSON", + "defaultLegend": { + "tokenType": "trailingComma" + } + } + ], + "semanticTokenModifiers": [ + { + "id": "error", + "description": "Indicates an error" + } + ], + "grammars": [ + { + "language": "sy", + "scopeName": "source.sy", + "path": "./grammars/sy.tmLanguage.json" + } + ], + "snippets": [ + { + "language": "javascript", + "path": "./snippets/sofill.json" + }, + { + "language": "typescript", + "path": "./snippets/sofill.json" + }, + { + "language": "markdown", + "path": "./snippets/md.json" + }, + { + "language": "mdx", + "path": "./snippets/md.json" + } + ] + }, + "vsce": { + "baseImagesUrl": "https://raw.githubusercontent.com/Hi-Windom/Sillot/master/app/stage/icon.png", + "dependencies": false, + "yarn": false + }, + "scripts": { + "vscode:prepublish": "pnpm run package", + "compile": "webpack", + "watch": "webpack --watch", + "package": "webpack --mode production --devtool hidden-source-map", + "vsce:package": "pnpm vsce package", + "vsce:login": "pnpm vsce login Hi-Windom", + "compile-tests": "tsc -p . --outDir out", + "watch-tests": "tsc -p . -w --outDir out", + "pretest": "pnpm run compile-tests && pnpm run compile && pnpm run lint", + "lint": "eslint src --ext ts --fix", + "test": "vscode-test", + "b:lint": "biome lint ./src --config-path ../../ --diagnostic-level error --apply && echo 'ref https://biomejs.dev/reference/cli/#biome-lint'", + "b:check": "biome check ./src --config-path ../../ --diagnostic-level error --apply && echo 'ref https://biomejs.dev/reference/cli/#biome-check'" + }, + "devDependencies": { + "@types/fs-extra": "^11.0.4", + "@types/mocha": "^10.0.6", + "@types/node": "18.x", + "@types/vscode": "^1.88.0", + "@typescript-eslint/eslint-plugin": "^7.4.0", + "@typescript-eslint/parser": "^7.4.0", + "@vscode/test-cli": "^0.0.8", + "@vscode/test-electron": "^2.3.9", + "@vscode/vsce": "^2.26.0", + "eslint": "^8.57.0", + "jsonc-parser": "^3.2.1", + "mkdirp": "^3.0.1", + "rimraf": "^5.0.5", + "ts-loader": "^9.5.1", + "typescript": "^5.3.3", + "webpack": "^5.91.0", + "webpack-cli": "^5.1.4" + }, + "dependencies": { + "@octokit/rest": "^20.1.0", + "fs-extra": "^11.2.0", + "json5": "^2.2.3" + } +} \ No newline at end of file diff --git a/.vscode/extensions/Sillot/src/extension.const.ts b/.vscode/extensions/Sillot/src/extension.const.ts index 93d836778f..f5d651f41d 100644 --- a/.vscode/extensions/Sillot/src/extension.const.ts +++ b/.vscode/extensions/Sillot/src/extension.const.ts @@ -1,4 +1,5 @@ export const C = { extensionId: "Hi-Windom.sillot", - npmjs: "https://www.npmjs.com" + npmjs: "https://www.npmjs.com", + PackageJsonMapping: "PackageJsonMapping.sillot.jsonc", } diff --git a/.vscode/extensions/Sillot/src/extension.ts b/.vscode/extensions/Sillot/src/extension.ts index 415c9ca19a..f9b797d415 100644 --- a/.vscode/extensions/Sillot/src/extension.ts +++ b/.vscode/extensions/Sillot/src/extension.ts @@ -24,7 +24,7 @@ import { SnippetCompletionItems } from "./provider/db/Snippet"; import { StructCompletionItems } from "./provider/db/Struct"; import { TypeParameterCompletionItems } from "./provider/db/TypeParameter"; import { VariableCompletionItems } from "./provider/db/Variable"; -import path from "path"; +import path, { resolve } from "path"; import { DepNodeProvider } from "./nodeDependencies"; import { FileExplorer } from "./fileExplorer"; import { TestView } from "./testView"; @@ -59,27 +59,124 @@ class fileCompletionItemProvider implements vscode.CompletionItemProvider { } } // 序列化并保存到文件 -async function saveCompletionItemsToFile(filePath: string, items: Array) { +async function saveCompletionItemsToFile(filePath: string, items: Array | { [key: string]: any }) { // 使用 json5.stringify 格式化 JSON,使其更易读 - const serializedItems = json5.stringify(items, null, 2); + const serializedItems = json5.stringify(items, { + space: 2, + quote: '"', + }); // 使用 fs-extra 写入文件 await fs.writeFile(filePath, serializedItems, "utf-8"); } // 从文件反序列化 -async function loadCompletionItemsFromFile(filePath: string): Promise> { +async function loadCompletionItemsFromFile(filePath: string): Promise { // 使用 fs-extra 读取文件 const serializedItems = await fs.readFile(filePath, "utf-8"); // 使用 json5.parse 反序列化 JSON - const items: Array = json5.parse(serializedItems); + const items = json5.parse(serializedItems); // 返回反序列化后的数组 return items; } export async function activate(context: vscode.ExtensionContext) { + const disposable555 = vscode.commands.registerCommand("汐洛.同步更新版本", () => { + vscode.window.showInputBox({ prompt: "Enter new version" }).then(async version => { + if (version) { + const wname = vscode.workspace.name; + if (wname && vscode.workspace.workspaceFile) { + const pkgMapFile = `${path.dirname(vscode.workspace.workspaceFile.fsPath)}/${C.PackageJsonMapping}`; + Log.d(wname, pkgMapFile); + if (!(await fs.exists(pkgMapFile))) { + vscode.window.showWarningMessage("package.json 映射不存在,请先添加"); + return; + } + + const pkgMap: { [key: string]: any } = await loadCompletionItemsFromFile(pkgMapFile); + const paths: string[] = pkgMap[wname]; + // 创建快速选择框 + const quickPick = vscode.window.createQuickPick(); + quickPick.title = "选择要更新版本的文件"; + // quickPick.items = [{ label: "Option 1" }, { label: "Option 2" }, { label: "Option 3" }]; + quickPick.items = paths.map(path => ({ label: path })); + quickPick.canSelectMany = true; // 允许多选 + + // 显示快速选择框并等待用户选择 + const selectedOptions: string[] = await new Promise(resolve => { + quickPick.onDidAccept(() => { + resolve(quickPick.selectedItems.map(item => item.label)); + quickPick.dispose(); + }); + quickPick.onDidHide(() => { + resolve([]); + quickPick.dispose(); + }); + quickPick.show(); + }); + + if (selectedOptions.length > 0) { + Log.d(`Version: ${version}, Selected options:${selectedOptions.join(", ")}`); + } else { + resolve(); + } + // 遍历映射并更新版本号 + selectedOptions.forEach(async (value: string, index: number) => { + Log.d("汐洛.同步更新版本", value); + if (await fs.exists(value)) { + const pkgContent = fs.readJSONSync(value); + pkgContent.version = version; + fs.writeFileSync(value, JSON.stringify(pkgContent, null, 2)); + Log.d(`${version} -> ${value}`); + } else { + vscode.window.showWarningMessage(`已跳过无效映射 ${value}`); + } + }); + vscode.window.showInformationMessage("Version updated in all package.json files."); + } else { + vscode.window.showWarningMessage("当前不在工作区环境"); + } + } + }); + }); + + context.subscriptions.push(disposable555); + + const addMappingDisposable = vscode.commands.registerCommand("汐洛.addPackageJsonMapping", async (uri: vscode.Uri) => { + if (uri?.fsPath.endsWith("package.json")) { + const wname = vscode.workspace.name; + if (wname && vscode.workspace.workspaceFile) { + Log.d(wname, uri.fsPath); + let pkgMap: { [key: string]: any } = {}; + const pkgMapFile = `${path.dirname(vscode.workspace.workspaceFile.fsPath)}/${C.PackageJsonMapping}`; + if (await fs.exists(pkgMapFile)) { + pkgMap = await loadCompletionItemsFromFile(pkgMapFile); + } + if (!pkgMap[wname]) { + pkgMap[wname] = []; + } + if (pkgMap[wname].includes(uri.fsPath)) { + vscode.window.showInformationMessage("当前 package.json 映射已存在"); + } else { + pkgMap[wname].push(uri.fsPath); + saveCompletionItemsToFile(pkgMapFile, pkgMap); + vscode.window.showInformationMessage(`已映射到工作区 ${wname}`); + vscode.window.showWarningMessage( + `注意:目前使用绝对路径,因此移动项目后请手动修改工作区配置文件同目录下的 ${C.PackageJsonMapping} 文件` + ); + } + } else { + vscode.window.showWarningMessage("当前不在工作区环境"); + } + } else { + vscode.window.showErrorMessage("Right-click command must be executed on a package.json file."); + } + }); + + context.subscriptions.push(addMappingDisposable); + const rootPath = vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0 ? vscode.workspace.workspaceFolders[0].uri.fsPath @@ -302,7 +399,7 @@ export async function activate(context: vscode.ExtensionContext) { apply花字Transformation(c); }) ); - }) + }); const disposable5 = vscode.commands.registerCommand("sillot.pickEXE", () => { vscode.window diff --git a/app/package.json b/app/package.json index 3e7ffb6e32..f02dc6fea3 100644 --- a/app/package.json +++ b/app/package.json @@ -1,6 +1,6 @@ { "name": "sillot", - "version": "0.32.1500", + "version": "0.32.2000", "syv": "3.0.13", "sypv": "[]", "description": "Build Your Eternal Digital Garden", @@ -163,4 +163,4 @@ "resolutions": { "lodash": "4.17.21" } -} +} \ No newline at end of file diff --git a/docs/starlight/package.json b/docs/starlight/package.json index 4badd64fb6..4310a02918 100644 --- a/docs/starlight/package.json +++ b/docs/starlight/package.json @@ -1,28 +1,28 @@ { - "name": "starlight", - "type": "module", - "version": "0.0.1", - "scripts": { - "test": "echo 'Test your sister day by day'", - "dev": "astro dev", - "start": "astro dev", - "build": "astro check && astro build", - "preview": "astro preview", - "astro": "astro", - "pcl:aahbf": "node addAllHeadByFilename.cjs" - }, - "dependencies": { - "@astrojs/check": "^0.5.10", - "@astrojs/starlight": "^0.21.5", - "@vercel/speed-insights": "^1.0.10", - "astro": "^4.6.4", - "astro-feelback": "^0.3.4", - "sharp": "^0.33.3", - "starlight-links-validator": "^0.8.0", - "typescript": "^5.4.5" - }, - "devDependencies": { - "@types/node": "^20.12.7", - "sass": "^1.75.0" - } -} + "name": "starlight", + "type": "module", + "version": "0.32.2000", + "scripts": { + "test": "echo 'Test your sister day by day'", + "dev": "astro dev", + "start": "astro dev", + "build": "astro check && astro build", + "preview": "astro preview", + "astro": "astro", + "pcl:aahbf": "node addAllHeadByFilename.cjs" + }, + "dependencies": { + "@astrojs/check": "^0.5.10", + "@astrojs/starlight": "^0.21.5", + "@vercel/speed-insights": "^1.0.10", + "astro": "^4.6.4", + "astro-feelback": "^0.3.4", + "sharp": "^0.33.3", + "starlight-links-validator": "^0.8.0", + "typescript": "^5.4.5" + }, + "devDependencies": { + "@types/node": "^20.12.7", + "sass": "^1.75.0" + } +} \ No newline at end of file