From ad26a77a46e291d2d0b8a5a362963b9b339dc588 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=99=E5=87=A1?= Date: Mon, 2 Feb 2026 15:34:42 +0800 Subject: [PATCH 1/4] feat: add organization ID handling in plugin commands and update environment variable names --- src/commands/plugin/init.ts | 5 +++++ src/commands/plugin/refresh-key.ts | 25 ++++++++++++----------- src/templates/common/.env | 2 -- src/templates/common/.env.eta | 3 +++ src/templates/typescript/src/index.ts.eta | 1 + 5 files changed, 22 insertions(+), 14 deletions(-) delete mode 100644 src/templates/common/.env create mode 100644 src/templates/common/.env.eta diff --git a/src/commands/plugin/init.ts b/src/commands/plugin/init.ts index ff4e060..f5ee06d 100644 --- a/src/commands/plugin/init.ts +++ b/src/commands/plugin/init.ts @@ -92,10 +92,12 @@ export default class PluginInit extends Command { // Fetch user session to get author and email let author = "" let email = "" + let organizationId = "" try { const session = await this.fetchSession() author = session.user.name email = session.user.email + organizationId = session.user.inherentOrganizationId } catch (error) { const message = error instanceof Error ? error.message : "Unknown error" this.log( @@ -116,6 +118,7 @@ export default class PluginInit extends Command { ...flags, author, email, + organizationId, createdAt: new Date().toISOString(), date: new Date().toISOString().slice(0, 10), year: new Date().getFullYear().toString(), @@ -288,6 +291,7 @@ export default class PluginInit extends Command { user: { name: string email: string + inherentOrganizationId: string } session: { updatedAt: string @@ -328,6 +332,7 @@ export default class PluginInit extends Command { user: { name: string email: string + inherentOrganizationId: string } session: { updatedAt: string diff --git a/src/commands/plugin/refresh-key.ts b/src/commands/plugin/refresh-key.ts index 0927630..e5db8a8 100644 --- a/src/commands/plugin/refresh-key.ts +++ b/src/commands/plugin/refresh-key.ts @@ -46,12 +46,13 @@ export default class PluginRefreshKey extends Command { const apiKey = await this.fetchDebugApiKey(config.auth.access_token) // Step 5: Manage .env file + assert(config.hub?.endpoint, "Hub endpoint is required") await this.updateEnvFile(apiKey, session.user.inherentOrganizationId) // Display success message this.log(colorize("green", "✓ Debug API Key refreshed successfully")) - this.log(colorize("green", "✓ DEBUG_API_KEY updated in .env file")) - this.log(colorize("green", "✓ ORGANIZATION_ID updated in .env file")) + this.log(colorize("green", "✓ HUB_DEBUG_API_KEY updated in .env file")) + this.log(colorize("green", "✓ HUB_ORGANIZATION_ID updated in .env file")) this.log("") this.log("Your debug API Key has been saved to .env file.") this.log(`Key preview: ${this.maskApiKey(apiKey)}`) @@ -145,34 +146,34 @@ export default class PluginRefreshKey extends Command { try { envContent = await fs.readFile(envPath, "utf-8") - existingApiKey = envContent.includes("DEBUG_API_KEY=") - existingOrgId = envContent.includes("ORGANIZATION_ID=") + existingApiKey = envContent.includes("HUB_DEBUG_API_KEY=") + existingOrgId = envContent.includes("HUB_ORGANIZATION_ID=") } catch (_error) { // File doesn't exist, will create new file } let newContent: string = envContent - // Update or add DEBUG_API_KEY + // Update or add HUB_DEBUG_API_KEY if (existingApiKey) { newContent = newContent.replace( - /^DEBUG_API_KEY=.*$/m, - `DEBUG_API_KEY=${apiKey}`, + /^HUB_DEBUG_API_KEY=.*$/m, + `HUB_DEBUG_API_KEY=${apiKey}`, ) } else { const separator = newContent && !newContent.endsWith("\n") ? "\n" : "" - newContent = `${newContent + separator}DEBUG_API_KEY=${apiKey}\n` + newContent = `${newContent + separator}HUB_DEBUG_API_KEY=${apiKey}\n` } - // Update or add ORGANIZATION_ID + // Update or add HUB_ORGANIZATION_ID if (existingOrgId) { newContent = newContent.replace( - /^ORGANIZATION_ID=.*$/m, - `ORGANIZATION_ID=${organizationId}`, + /^HUB_ORGANIZATION_ID=.*$/m, + `HUB_ORGANIZATION_ID=${organizationId}`, ) } else { const separator = newContent && !newContent.endsWith("\n") ? "\n" : "" - newContent = `${newContent + separator}ORGANIZATION_ID=${organizationId}\n` + newContent = `${newContent + separator}HUB_ORGANIZATION_ID=${organizationId}\n` } await fs.writeFile(envPath, newContent, "utf-8") diff --git a/src/templates/common/.env b/src/templates/common/.env deleted file mode 100644 index 9eb6416..0000000 --- a/src/templates/common/.env +++ /dev/null @@ -1,2 +0,0 @@ -DEBUG_API_KEY= -HUB_SERVER_WS_URL=wss://automation-plugin-api.choiceform.io/debug_socket diff --git a/src/templates/common/.env.eta b/src/templates/common/.env.eta new file mode 100644 index 0000000..c33c883 --- /dev/null +++ b/src/templates/common/.env.eta @@ -0,0 +1,3 @@ +HUB_ORGANIZATION_ID=<%= props.organizationId %> +HUB_WS_URL=wss://automation-plugin-api.choiceform.io +HUB_DEBUG_API_KEY= diff --git a/src/templates/typescript/src/index.ts.eta b/src/templates/typescript/src/index.ts.eta index 641220a..67d3e28 100644 --- a/src/templates/typescript/src/index.ts.eta +++ b/src/templates/typescript/src/index.ts.eta @@ -12,6 +12,7 @@ const plugin = await createPlugin({ display_name: t("PLUGIN_DISPLAY_NAME"), description: t("PLUGIN_DESCRIPTION"), icon: "🎛️", + lang: "<%= props.language %>", version: packageJSON.version, repo: "<%= props.url %>", locales, From 369b1d15911d85ccab65c9a93162e5f0c5c20b81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=99=E5=87=A1?= Date: Mon, 2 Feb 2026 15:34:59 +0800 Subject: [PATCH 2/4] chore(release): v0.5.8 :tada: --- README.md | 16 ++++++++-------- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 6d03858..0d314fc 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ EXAMPLES $ atomemo auth login ``` -_See code: [src/commands/auth/login.ts](https://github.com/choice-open/atomemo-plugin-cli/blob/v0.5.7/src/commands/auth/login.ts)_ +_See code: [src/commands/auth/login.ts](https://github.com/choice-open/atomemo-plugin-cli/blob/v0.5.8/src/commands/auth/login.ts)_ ## `atomemo auth status` @@ -120,7 +120,7 @@ EXAMPLES $ atomemo auth status ``` -_See code: [src/commands/auth/status.ts](https://github.com/choice-open/atomemo-plugin-cli/blob/v0.5.7/src/commands/auth/status.ts)_ +_See code: [src/commands/auth/status.ts](https://github.com/choice-open/atomemo-plugin-cli/blob/v0.5.8/src/commands/auth/status.ts)_ ## `atomemo autocomplete [SHELL]` @@ -195,7 +195,7 @@ EXAMPLES $ atomemo plugin checksum ``` -_See code: [src/commands/plugin/checksum.ts](https://github.com/choice-open/atomemo-plugin-cli/blob/v0.5.7/src/commands/plugin/checksum.ts)_ +_See code: [src/commands/plugin/checksum.ts](https://github.com/choice-open/atomemo-plugin-cli/blob/v0.5.8/src/commands/plugin/checksum.ts)_ ## `atomemo plugin init` @@ -225,7 +225,7 @@ EXAMPLES $ atomemo plugin init ``` -_See code: [src/commands/plugin/init.ts](https://github.com/choice-open/atomemo-plugin-cli/blob/v0.5.7/src/commands/plugin/init.ts)_ +_See code: [src/commands/plugin/init.ts](https://github.com/choice-open/atomemo-plugin-cli/blob/v0.5.8/src/commands/plugin/init.ts)_ ## `atomemo plugin pack [FILE]` @@ -249,7 +249,7 @@ EXAMPLES $ atomemo plugin pack ``` -_See code: [src/commands/plugin/pack.ts](https://github.com/choice-open/atomemo-plugin-cli/blob/v0.5.7/src/commands/plugin/pack.ts)_ +_See code: [src/commands/plugin/pack.ts](https://github.com/choice-open/atomemo-plugin-cli/blob/v0.5.8/src/commands/plugin/pack.ts)_ ## `atomemo plugin permission [FILE]` @@ -273,7 +273,7 @@ EXAMPLES $ atomemo plugin permission ``` -_See code: [src/commands/plugin/permission.ts](https://github.com/choice-open/atomemo-plugin-cli/blob/v0.5.7/src/commands/plugin/permission.ts)_ +_See code: [src/commands/plugin/permission.ts](https://github.com/choice-open/atomemo-plugin-cli/blob/v0.5.8/src/commands/plugin/permission.ts)_ ## `atomemo plugin refresh-key` @@ -290,7 +290,7 @@ EXAMPLES $ atomemo plugin refresh-key ``` -_See code: [src/commands/plugin/refresh-key.ts](https://github.com/choice-open/atomemo-plugin-cli/blob/v0.5.7/src/commands/plugin/refresh-key.ts)_ +_See code: [src/commands/plugin/refresh-key.ts](https://github.com/choice-open/atomemo-plugin-cli/blob/v0.5.8/src/commands/plugin/refresh-key.ts)_ ## `atomemo plugin run [FILE]` @@ -314,7 +314,7 @@ EXAMPLES $ atomemo plugin run ``` -_See code: [src/commands/plugin/run.ts](https://github.com/choice-open/atomemo-plugin-cli/blob/v0.5.7/src/commands/plugin/run.ts)_ +_See code: [src/commands/plugin/run.ts](https://github.com/choice-open/atomemo-plugin-cli/blob/v0.5.8/src/commands/plugin/run.ts)_ ## `atomemo version` diff --git a/package-lock.json b/package-lock.json index dd965e1..3cfde74 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@choiceopen/atomemo-plugin-cli", - "version": "0.5.7", + "version": "0.5.8", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@choiceopen/atomemo-plugin-cli", - "version": "0.5.7", + "version": "0.5.8", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 4864508..71c0db7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@choiceopen/atomemo-plugin-cli", - "version": "0.5.7", + "version": "0.5.8", "description": "A command-line utility for building and publishing Choiceform Atomemo Plugin.", "keywords": [ "oclif" From e849c63016325ac5f7663ec2ff6c62998a3058ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=99=E5=87=A1?= Date: Mon, 2 Feb 2026 15:38:05 +0800 Subject: [PATCH 3/4] docs: update changelog for 0.5.8 release with new features and breaking changes --- CHANGELOG.md | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e9d4b5..b97b30e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/). ## [Unreleased] +## [0.5.8] - 2026-02-02 + +### Added + +- `plugin init` 命令现在会自动从用户会话中获取 `organizationId` 并写入 `.env` 文件 +- 插件模板新增 `lang` 属性配置 +- 新增 `.env.eta` 模板,包含 `HUB_WS_URL` 默认值 + +### Changed + +- 环境变量重命名: + - `DEBUG_API_KEY` → `HUB_DEBUG_API_KEY` + - `ORGANIZATION_ID` → `HUB_ORGANIZATION_ID` + +### Breaking Changes + +- 环境变量名称已更改,使用旧版本创建的插件需要手动更新 `.env` 文件中的变量名 + ## [0.5.7] - 2026-01-21 ### Added @@ -193,7 +211,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/). - Code quality checks with Biome. - Automated release workflow via GitHub Actions. -[Unreleased]: https://github.com/choice-open/atomemo-plugin-cli/compare/v0.5.7...HEAD +[Unreleased]: https://github.com/choice-open/atomemo-plugin-cli/compare/v0.5.8...HEAD +[0.5.8]: https://github.com/choice-open/atomemo-plugin-cli/compare/v0.5.7...v0.5.8 [0.5.7]: https://github.com/choice-open/atomemo-plugin-cli/compare/v0.5.6...v0.5.7 [0.5.6]: https://github.com/choice-open/atomemo-plugin-cli/compare/v0.5.5...v0.5.6 [0.5.5]: https://github.com/choice-open/atomemo-plugin-cli/compare/v0.5.4...v0.5.5 From f9c47cd9ff6718b759479071ff8523225cf3a3c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=99=E5=87=A1?= Date: Mon, 2 Feb 2026 15:41:52 +0800 Subject: [PATCH 4/4] test: update refresh-key tests to reflect new environment variable naming conventions --- test/commands/plugin/refresh-key.test.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/test/commands/plugin/refresh-key.test.ts b/test/commands/plugin/refresh-key.test.ts index adf06ca..2c577a0 100644 --- a/test/commands/plugin/refresh-key.test.ts +++ b/test/commands/plugin/refresh-key.test.ts @@ -138,13 +138,13 @@ describe("plugin refresh-key", () => { const { stdout } = await runCommand("plugin refresh-key") expect(stdout).to.contain("Debug API Key refreshed successfully") - expect(stdout).to.contain("DEBUG_API_KEY updated in .env file") - expect(stdout).to.contain("ORGANIZATION_ID updated in .env file") + expect(stdout).to.contain("HUB_DEBUG_API_KEY updated in .env file") + expect(stdout).to.contain("HUB_ORGANIZATION_ID updated in .env file") const envPath = join(testDir, ".env") const content = await fs.readFile(envPath, "utf-8") - expect(content).to.contain("DEBUG_API_KEY=test_api_key_12345678") - expect(content).to.contain("ORGANIZATION_ID=org_123456") + expect(content).to.contain("HUB_DEBUG_API_KEY=test_api_key_12345678") + expect(content).to.contain("HUB_ORGANIZATION_ID=org_123456") }) it("更新现有的 .env 文件中的 DEBUG_API_KEY", async () => { @@ -181,15 +181,15 @@ describe("plugin refresh-key", () => { const envPath = join(testDir, ".env") await fs.writeFile( envPath, - `EXISTING_KEY=value\nDEBUG_API_KEY=old_key_123\nANOTHER_KEY=value2`, + `EXISTING_KEY=value\nHUB_DEBUG_API_KEY=old_key_123\nANOTHER_KEY=value2`, ) const { stdout } = await runCommand("plugin refresh-key") expect(stdout).to.contain("Debug API Key refreshed successfully") const content = await fs.readFile(envPath, "utf-8") - expect(content).to.contain("DEBUG_API_KEY=new_api_key_87654321") - expect(content).to.contain("ORGANIZATION_ID=org_789012") + expect(content).to.contain("HUB_DEBUG_API_KEY=new_api_key_87654321") + expect(content).to.contain("HUB_ORGANIZATION_ID=org_789012") expect(content).to.contain("EXISTING_KEY=value") expect(content).to.contain("ANOTHER_KEY=value2") expect(content).to.not.contain("old_key_123") @@ -233,8 +233,8 @@ describe("plugin refresh-key", () => { expect(stdout).to.contain("Debug API Key refreshed successfully") const content = await fs.readFile(envPath, "utf-8") - expect(content).to.contain("DEBUG_API_KEY=appended_key_999") - expect(content).to.contain("ORGANIZATION_ID=org_345678") + expect(content).to.contain("HUB_DEBUG_API_KEY=appended_key_999") + expect(content).to.contain("HUB_ORGANIZATION_ID=org_345678") expect(content).to.contain("EXISTING_KEY=value") expect(content).to.contain("ANOTHER_KEY=value2") }) @@ -273,15 +273,15 @@ describe("plugin refresh-key", () => { const envPath = join(testDir, ".env") await fs.writeFile( envPath, - `DEBUG_API_KEY=old_key\nORGANIZATION_ID=org_old_456\nOTHER_KEY=value`, + `HUB_DEBUG_API_KEY=old_key\nHUB_ORGANIZATION_ID=org_old_456\nOTHER_KEY=value`, ) const { stdout } = await runCommand("plugin refresh-key") expect(stdout).to.contain("Debug API Key refreshed successfully") const content = await fs.readFile(envPath, "utf-8") - expect(content).to.contain("DEBUG_API_KEY=test_key_456") - expect(content).to.contain("ORGANIZATION_ID=org_new_123") + expect(content).to.contain("HUB_DEBUG_API_KEY=test_key_456") + expect(content).to.contain("HUB_ORGANIZATION_ID=org_new_123") expect(content).to.contain("OTHER_KEY=value") expect(content).to.not.contain("org_old_456") })