@choiceopen/automation-plugin-cli 0.2.0 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +65 -65
  2. package/dist/commands/auth/login.js +5 -5
  3. package/dist/commands/auth/status.js +2 -2
  4. package/dist/commands/plugin/init.js +7 -2
  5. package/dist/commands/plugin/refresh-key.js +2 -2
  6. package/dist/templates/OVERVIEW.md +58 -0
  7. package/dist/templates/common/.claude/commands/commit.md +13 -0
  8. package/dist/templates/common/.env +2 -0
  9. package/dist/templates/common/.gitignore.eta +6 -0
  10. package/dist/templates/common/.spec/ARCHITECTURE.md +193 -0
  11. package/dist/templates/common/LICENSE.md.eta +21 -0
  12. package/dist/templates/common/PRIVACY.md.eta +47 -0
  13. package/dist/templates/typescript/.editorconfig +15 -0
  14. package/dist/templates/typescript/.typesafe-i18n.json +8 -0
  15. package/dist/templates/typescript/README.md.eta +21 -0
  16. package/dist/templates/typescript/biome.json.eta +32 -0
  17. package/dist/templates/typescript/package.json.eta +57 -0
  18. package/dist/templates/typescript/src/README.md.eta +24 -0
  19. package/dist/templates/typescript/src/i18n/README.md +29 -0
  20. package/dist/templates/typescript/src/i18n/en-US/README.md +12 -0
  21. package/dist/templates/typescript/src/i18n/en-US/index.ts.eta +13 -0
  22. package/dist/templates/typescript/src/i18n/formatters.ts.eta +12 -0
  23. package/dist/templates/typescript/src/i18n/i18n-node.ts.eta +31 -0
  24. package/dist/templates/typescript/src/i18n/i18n-types.ts.eta +79 -0
  25. package/dist/templates/typescript/src/i18n/i18n-util.async.ts.eta +33 -0
  26. package/dist/templates/typescript/src/i18n/i18n-util.sync.ts.eta +26 -0
  27. package/dist/templates/typescript/src/i18n/i18n-util.ts.eta +63 -0
  28. package/dist/templates/typescript/src/i18n/zh-Hans/README.md +12 -0
  29. package/dist/templates/typescript/src/i18n/zh-Hans/index.ts.eta +13 -0
  30. package/dist/templates/typescript/src/index.ts.eta +25 -0
  31. package/dist/templates/typescript/src/tools/README.md +18 -0
  32. package/dist/templates/typescript/src/tools/demo.ts.eta +29 -0
  33. package/dist/templates/typescript/test/README.md +15 -0
  34. package/dist/templates/typescript/test/index.test.ts.eta +65 -0
  35. package/dist/templates/typescript/tsconfig.json.eta +20 -0
  36. package/dist/templates/typescript/tsdown.config.ts.eta +11 -0
  37. package/oclif.manifest.json +1 -1
  38. package/package.json +13 -14
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) <%= props.year %> <%= props.author %>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,47 @@
1
+ # Privacy Policy
2
+
3
+ **Last Updated: <%= props.date %>**
4
+
5
+ ## Overview
6
+
7
+ <%= props.name %> ("the Plugin") is committed to protecting your privacy. This policy explains how data is handled when you use the Plugin within the Choiceform Atomemo Platform.
8
+
9
+ ## Data Collection
10
+
11
+ The Plugin may collect and process the following types of data:
12
+
13
+ - **Usage Data**: Information about how you interact with the Plugin
14
+ - **Configuration Data**: Settings and preferences you configure within the Plugin
15
+ - **Input Data**: Data you provide to the Plugin for processing
16
+
17
+ ## Data Usage
18
+
19
+ Collected data is used solely for:
20
+
21
+ - Providing and improving Plugin functionality
22
+ - Debugging and error resolution
23
+ - Analytics and performance optimization
24
+
25
+ ## Data Storage
26
+
27
+ - All data is processed in accordance with the Choiceform Atomemo Platform's data handling policies
28
+ - No personal data is stored beyond what is necessary for Plugin operation
29
+ - Data is not shared with third parties unless required by law
30
+
31
+ ## Your Rights
32
+
33
+ You have the right to:
34
+
35
+ - Access your data
36
+ - Request data deletion
37
+ - Opt out of non-essential data collection
38
+
39
+ ## Contact
40
+
41
+ For privacy-related inquiries, please contact:
42
+
43
+ <%= props.author %><% if (props.email) { %> (<%= props.email %>)<% } %>
44
+
45
+ ## Changes to This Policy
46
+
47
+ We may update this privacy policy from time to time. Any changes will be reflected by updating the "Last Updated" date above.
@@ -0,0 +1,15 @@
1
+ # EditorConfig is awesome: https://EditorConfig.org
2
+
3
+ # top-most EditorConfig file
4
+ root = true
5
+
6
+ [*]
7
+ end_of_line = lf
8
+ charset = utf-8
9
+ indent_size = 2
10
+ indent_style = space
11
+ insert_final_newline = true
12
+ trim_trailing_whitespace = true
13
+
14
+ [*.md]
15
+ trim_trailing_whitespace = false
@@ -0,0 +1,8 @@
1
+ {
2
+ "$schema": "https://unpkg.com/typesafe-i18n@5.26.2/schema/typesafe-i18n.json",
3
+ "adapter": "node",
4
+ "baseLocale": "en-US",
5
+ "esmImports": true,
6
+ "generateOnlyTypes": true,
7
+ "runAfterGenerator": "bun biome format ./src/i18n --write"
8
+ }
@@ -0,0 +1,21 @@
1
+ # Atomemo Plugin - <%= props.name %>
2
+
3
+ ## Development
4
+
5
+ - Install dependencies:
6
+
7
+ ```bash
8
+ bun install
9
+ ```
10
+
11
+ - Run the unit tests:
12
+
13
+ ```bash
14
+ bun run test
15
+ ```
16
+
17
+ - Build the library:
18
+
19
+ ```bash
20
+ bun run build
21
+ ```
@@ -0,0 +1,32 @@
1
+ {
2
+ "$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
3
+ "vcs": {
4
+ "enabled": true,
5
+ "clientKind": "git",
6
+ "useIgnoreFile": true
7
+ },
8
+ "assist": {
9
+ "enabled": true,
10
+ "actions": {
11
+ "recommended": true
12
+ },
13
+ "includes": ["**", "!src/i18n"]
14
+ },
15
+ "formatter": {
16
+ "enabled": true,
17
+ "includes": ["**"],
18
+ "indentStyle": "space"
19
+ },
20
+ "linter": {
21
+ "enabled": true,
22
+ "includes": ["**", "!src/i18n"],
23
+ "rules": {
24
+ "recommended": true
25
+ }
26
+ },
27
+ "javascript": {
28
+ "formatter": {
29
+ "semicolons": "asNeeded"
30
+ }
31
+ }
32
+ }
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "<%= props.name %>",
3
+ "type": "module",
4
+ "version": "<%= props.version %>",
5
+ "description": "<%= props.description %>",
6
+ "author": "<%= props.author %> <<%= props.email %>>",
7
+ "license": "MIT",
8
+ "homepage": "https://github.com/<%= props.author %>/<%= props.name %>#readme",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/<%= props.author %>/<%= props.name %>.git"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/<%= props.author %>/<%= props.name %>/issues"
15
+ },
16
+ "exports": {
17
+ ".": {
18
+ "development": "./src/index.ts",
19
+ "default": "./dist/index.js"
20
+ },
21
+ "./package.json": "./package.json"
22
+ },
23
+ "main": "./dist/index.js",
24
+ "module": "./dist/index.js",
25
+ "types": "./dist/index.d.ts",
26
+ "files": [
27
+ "dist"
28
+ ],
29
+ "scripts": {
30
+ "build": "tsdown",
31
+ "dev": "concurrently -c=cyan.bold,blue.bold --names=DEV,I18N --pad-prefix \"tsdown --watch\" \"typesafe-i18n\"",
32
+ "test": "vitest",
33
+ "typecheck": "tsc --noEmit",
34
+ "prepublishOnly": "bun run build"
35
+ },
36
+ "dependencies": {
37
+ "@choiceopen/automation-plugin-sdk-js": "@choiceopen/automation-plugin-sdk-js",
38
+ "dotenv": "^17.2.3",
39
+ "zod": "^4.3.5"
40
+ },
41
+ "devDependencies": {
42
+ "@biomejs/biome": "^2.3.11",
43
+ "@types/bun": "^1.3.6",
44
+ "bumpp": "^10.4.0",
45
+ "concurrently": "9.2.1",
46
+ "tsdown": "^0.19.0",
47
+ "typesafe-i18n": "^5.26.2",
48
+ "typescript": "^5.9.3",
49
+ "vitest": "^4.0.17"
50
+ },
51
+ "publishConfig": {
52
+ "exports": {
53
+ ".": "./dist/index.js",
54
+ "./package.json": "./package.json"
55
+ }
56
+ }
57
+ }
@@ -0,0 +1,24 @@
1
+ # src
2
+
3
+ 源代码主目录,包含插件的所有核心模块。
4
+
5
+ ## 目录结构
6
+
7
+ - `tools/` - [工具定义模块](./tools/README.md)
8
+ - `i18n/` - [国际化模块](./i18n/README.md)
9
+ - `index.ts` - 插件入口文件
10
+
11
+ ## 入口文件
12
+
13
+ `index.ts` 是插件的入口点,负责:
14
+ 1. 加载所有国际化语言包
15
+ 2. 创建插件实例
16
+ 3. 注册工具
17
+ 4. 启动插件
18
+
19
+ ## 架构
20
+
21
+ 插件基于 `@choiceopen/automation-plugin-sdk-js` SDK 构建,采用模块化设计:
22
+ - 工具独立定义
23
+ - 通过统一的国际化系统提供多语言支持
24
+ - 所有组件通过插件实例统一注册和管理
@@ -0,0 +1,29 @@
1
+ # i18n
2
+
3
+ 国际化模块,基于 typesafe-i18n 实现类型安全的国际化支持。
4
+
5
+ ## 目录结构
6
+
7
+ - `en-US/` - 英文翻译
8
+ - `zh-Hans/` - 简体中文翻译
9
+
10
+ ## 核心文件
11
+
12
+ - `i18n-node.ts` - 国际化入口,提供 `t()` 函数用于获取翻译文本
13
+ - `i18n-util.ts` - 国际化工具函数和类型定义(基础配置)
14
+ - `i18n-util.sync.ts` - 同步加载所有语言包
15
+ - `i18n-util.async.ts` - 异步加载语言包(用于动态导入)
16
+ - `i18n-types.ts` - 自动生成的类型定义(包含所有翻译键的类型)
17
+ - `formatters.ts` - 格式化函数配置(当前为空)
18
+
19
+ ## 功能
20
+
21
+ - 支持英文(en-US)和简体中文(zh-Hans)两种语言
22
+ - 类型安全的翻译键,编译时检查
23
+ - 同步和异步两种加载方式
24
+ - 自动生成类型定义
25
+
26
+ ## 关系
27
+
28
+ - 被所有需要国际化的模块导入(tools、index)
29
+ - 在 `src/index.ts` 中通过 `loadAllLocalesAsync()` 异步加载所有语言包
@@ -0,0 +1,12 @@
1
+ # en-US
2
+
3
+ 英文翻译文件目录。
4
+
5
+ ## 文件
6
+
7
+ - `index.ts` - 英文翻译内容,包含插件、工具等所有 UI 文本的英文版本
8
+
9
+ ## 关系
10
+
11
+ - 被 `src/i18n/i18n-util.sync.ts` 和 `src/i18n/i18n-util.async.ts` 导入
12
+ - 与 `src/i18n/zh-Hans/` 目录对应,提供多语言支持
@@ -0,0 +1,13 @@
1
+ import type { BaseTranslation } from "../i18n-types"
2
+
3
+ const en_US = {
4
+ PLUGIN_DISPLAY_NAME: "Testing Plugin",
5
+ PLUGIN_DESCRIPTION: "A plugin for testing the plugin",
6
+ DEMO_TOOL_DISPLAY_NAME: "Demo Tool",
7
+ DEMO_TOOL_DESCRIPTION: "A tool for testing the plugin",
8
+ LOCATION_DISPLAY_NAME: "Location",
9
+ LOCATION_HINT: "The location to test",
10
+ LOCATION_PLACEHOLDER: "Enter the location to test",
11
+ } satisfies BaseTranslation
12
+
13
+ export default en_US
@@ -0,0 +1,12 @@
1
+ import type { FormattersInitializer } from "typesafe-i18n"
2
+ import type { Locales, Formatters } from "./i18n-types.js"
3
+
4
+ export const initFormatters: FormattersInitializer<Locales, Formatters> = (
5
+ locale: Locales,
6
+ ) => {
7
+ const formatters: Formatters = {
8
+ // add your formatter functions here
9
+ }
10
+
11
+ return formatters
12
+ }
@@ -0,0 +1,31 @@
1
+ // This file was auto-generated by 'typesafe-i18n'. Any manual changes will be overwritten.
2
+ /* eslint-disable */
3
+
4
+ import { i18n, locales } from "./i18n-util.js"
5
+ import { loadAllLocales } from "./i18n-util.sync.js"
6
+ import type { LocaleTranslationFunctions } from "typesafe-i18n"
7
+ import type {
8
+ Locales,
9
+ Translations,
10
+ TranslationFunctions,
11
+ } from "./i18n-types.js"
12
+
13
+ loadAllLocales()
14
+
15
+ export const L: LocaleTranslationFunctions<
16
+ Locales,
17
+ Translations,
18
+ TranslationFunctions
19
+ > = i18n()
20
+
21
+ export const t = (entry: keyof Translations) => {
22
+ return locales.reduce<{ en_US: string; [key: string]: string }>(
23
+ (entries, locale) => {
24
+ const underscoreLocale = locale.replace("-", "_")
25
+ return Object.assign(entries, { [underscoreLocale]: L[locale][entry]() })
26
+ },
27
+ { en_US: "" },
28
+ )
29
+ }
30
+
31
+ export default L
@@ -0,0 +1,79 @@
1
+ // This file was auto-generated by 'typesafe-i18n'. Any manual changes will be overwritten.
2
+ /* eslint-disable */
3
+ import type {
4
+ BaseTranslation as BaseTranslationType,
5
+ LocalizedString,
6
+ } from "typesafe-i18n"
7
+
8
+ export type BaseTranslation = BaseTranslationType
9
+ export type BaseLocale = "en-US"
10
+
11
+ export type Locales = "en-US" | "zh-Hans"
12
+
13
+ export type Translation = RootTranslation
14
+
15
+ export type Translations = RootTranslation
16
+
17
+ type RootTranslation = {
18
+ /**
19
+ * T​e​s​t​i​n​g​ ​P​l​u​g​i​n
20
+ */
21
+ PLUGIN_DISPLAY_NAME: string
22
+ /**
23
+ * A​ ​p​l​u​g​i​n​ ​f​o​r​ ​t​e​s​t​i​n​g​ ​t​h​e​ ​p​l​u​g​i​n
24
+ */
25
+ PLUGIN_DESCRIPTION: string
26
+ /**
27
+ * D​e​m​o​ ​T​o​o​l
28
+ */
29
+ DEMO_TOOL_DISPLAY_NAME: string
30
+ /**
31
+ * A​ ​t​o​o​l​ ​f​o​r​ ​t​e​s​t​i​n​g​ ​t​h​e​ ​p​l​u​g​i​n
32
+ */
33
+ DEMO_TOOL_DESCRIPTION: string
34
+ /**
35
+ * L​o​c​a​t​i​o​n
36
+ */
37
+ LOCATION_DISPLAY_NAME: string
38
+ /**
39
+ * T​h​e​ ​l​o​c​a​t​i​o​n​ ​t​o​ ​t​e​s​t
40
+ */
41
+ LOCATION_HINT: string
42
+ /**
43
+ * E​n​t​e​r​ ​t​h​e​ ​l​o​c​a​t​i​o​n​ ​t​o​ ​t​e​s​t
44
+ */
45
+ LOCATION_PLACEHOLDER: string
46
+ }
47
+
48
+ export type TranslationFunctions = {
49
+ /**
50
+ * Testing Plugin
51
+ */
52
+ PLUGIN_DISPLAY_NAME: () => LocalizedString
53
+ /**
54
+ * A plugin for testing the plugin
55
+ */
56
+ PLUGIN_DESCRIPTION: () => LocalizedString
57
+ /**
58
+ * Demo Tool
59
+ */
60
+ DEMO_TOOL_DISPLAY_NAME: () => LocalizedString
61
+ /**
62
+ * A tool for testing the plugin
63
+ */
64
+ DEMO_TOOL_DESCRIPTION: () => LocalizedString
65
+ /**
66
+ * Location
67
+ */
68
+ LOCATION_DISPLAY_NAME: () => LocalizedString
69
+ /**
70
+ * The location to test
71
+ */
72
+ LOCATION_HINT: () => LocalizedString
73
+ /**
74
+ * Enter the location to test
75
+ */
76
+ LOCATION_PLACEHOLDER: () => LocalizedString
77
+ }
78
+
79
+ export type Formatters = {}
@@ -0,0 +1,33 @@
1
+ // This file was auto-generated by 'typesafe-i18n'. Any manual changes will be overwritten.
2
+ /* eslint-disable */
3
+
4
+ import { initFormatters } from "./formatters.js"
5
+ import type { Locales, Translations } from "./i18n-types.js"
6
+ import { loadedFormatters, loadedLocales, locales } from "./i18n-util.js"
7
+
8
+ const localeTranslationLoaders = {
9
+ "en-US": () => import("./en-US/index.js"),
10
+ "zh-Hans": () => import("./zh-Hans/index.js"),
11
+ }
12
+
13
+ const updateDictionary = (
14
+ locale: Locales,
15
+ dictionary: Partial<Translations>,
16
+ ): Translations =>
17
+ (loadedLocales[locale] = { ...loadedLocales[locale], ...dictionary })
18
+
19
+ export const importLocaleAsync = async (
20
+ locale: Locales,
21
+ ): Promise<Translations> =>
22
+ (await localeTranslationLoaders[locale]()).default as unknown as Translations
23
+
24
+ export const loadLocaleAsync = async (locale: Locales): Promise<void> => {
25
+ updateDictionary(locale, await importLocaleAsync(locale))
26
+ loadFormatters(locale)
27
+ }
28
+
29
+ export const loadAllLocalesAsync = (): Promise<void[]> =>
30
+ Promise.all(locales.map(loadLocaleAsync))
31
+
32
+ export const loadFormatters = (locale: Locales): void =>
33
+ void (loadedFormatters[locale] = initFormatters(locale))
@@ -0,0 +1,26 @@
1
+ // This file was auto-generated by 'typesafe-i18n'. Any manual changes will be overwritten.
2
+ /* eslint-disable */
3
+
4
+ import { initFormatters } from "./formatters.js"
5
+ import type { Locales, Translations } from "./i18n-types.js"
6
+ import { loadedFormatters, loadedLocales, locales } from "./i18n-util.js"
7
+
8
+ import en_US from "./en-US/index.js"
9
+ import zh_Hans from "./zh-Hans/index.js"
10
+
11
+ const localeTranslations = {
12
+ "en-US": en_US,
13
+ "zh-Hans": zh_Hans,
14
+ }
15
+
16
+ export const loadLocale = (locale: Locales): void => {
17
+ if (loadedLocales[locale]) return
18
+
19
+ loadedLocales[locale] = localeTranslations[locale] as unknown as Translations
20
+ loadFormatters(locale)
21
+ }
22
+
23
+ export const loadAllLocales = (): void => locales.forEach(loadLocale)
24
+
25
+ export const loadFormatters = (locale: Locales): void =>
26
+ void (loadedFormatters[locale] = initFormatters(locale))
@@ -0,0 +1,63 @@
1
+ // This file was auto-generated by 'typesafe-i18n'. Any manual changes will be overwritten.
2
+ /* eslint-disable */
3
+
4
+ import {
5
+ i18n as initI18n,
6
+ i18nObject as initI18nObject,
7
+ i18nString as initI18nString,
8
+ } from "typesafe-i18n"
9
+ import type { LocaleDetector } from "typesafe-i18n/detectors"
10
+ import type {
11
+ LocaleTranslationFunctions,
12
+ TranslateByString,
13
+ } from "typesafe-i18n"
14
+ import { detectLocale as detectLocaleFn } from "typesafe-i18n/detectors"
15
+ import { initExtendDictionary } from "typesafe-i18n/utils"
16
+ import type {
17
+ Formatters,
18
+ Locales,
19
+ Translations,
20
+ TranslationFunctions,
21
+ } from "./i18n-types.js"
22
+
23
+ export const baseLocale: Locales = "en-US"
24
+
25
+ export const locales: Locales[] = ["en-US", "zh-Hans"]
26
+
27
+ export const isLocale = (locale: string): locale is Locales =>
28
+ locales.includes(locale as Locales)
29
+
30
+ export const loadedLocales: Record<Locales, Translations> = {} as Record<
31
+ Locales,
32
+ Translations
33
+ >
34
+
35
+ export const loadedFormatters: Record<Locales, Formatters> = {} as Record<
36
+ Locales,
37
+ Formatters
38
+ >
39
+
40
+ export const extendDictionary = initExtendDictionary<Translations>()
41
+
42
+ export const i18nString = (locale: Locales): TranslateByString =>
43
+ initI18nString<Locales, Formatters>(locale, loadedFormatters[locale])
44
+
45
+ export const i18nObject = (locale: Locales): TranslationFunctions =>
46
+ initI18nObject<Locales, Translations, TranslationFunctions, Formatters>(
47
+ locale,
48
+ loadedLocales[locale],
49
+ loadedFormatters[locale],
50
+ )
51
+
52
+ export const i18n = (): LocaleTranslationFunctions<
53
+ Locales,
54
+ Translations,
55
+ TranslationFunctions
56
+ > =>
57
+ initI18n<Locales, Translations, TranslationFunctions, Formatters>(
58
+ loadedLocales,
59
+ loadedFormatters,
60
+ )
61
+
62
+ export const detectLocale = (...detectors: LocaleDetector[]): Locales =>
63
+ detectLocaleFn<Locales>(baseLocale, locales, ...detectors)
@@ -0,0 +1,12 @@
1
+ # zh-Hans
2
+
3
+ 简体中文翻译文件目录。
4
+
5
+ ## 文件
6
+
7
+ - `index.ts` - 简体中文翻译内容,包含插件、工具等所有 UI 文本的中文版本
8
+
9
+ ## 关系
10
+
11
+ - 被 `src/i18n/i18n-util.sync.ts` 和 `src/i18n/i18n-util.async.ts` 导入
12
+ - 与 `src/i18n/en-US/` 目录对应,提供多语言支持
@@ -0,0 +1,13 @@
1
+ import type { Translation } from "../i18n-types"
2
+
3
+ const zh_Hans = {
4
+ PLUGIN_DISPLAY_NAME: "测试插件",
5
+ PLUGIN_DESCRIPTION: "一个用于测试插件的插件",
6
+ DEMO_TOOL_DISPLAY_NAME: "演示工具",
7
+ DEMO_TOOL_DESCRIPTION: "一个用于测试插件的工具",
8
+ LOCATION_DISPLAY_NAME: "位置",
9
+ LOCATION_HINT: "要测试的位置",
10
+ LOCATION_PLACEHOLDER: "输入要测试的位置",
11
+ } satisfies Translation
12
+
13
+ export default zh_Hans
@@ -0,0 +1,25 @@
1
+ import { createPlugin } from "@choiceopen/automation-plugin-sdk-js"
2
+ import packageJSON from "../package.json"
3
+ import { t } from "./i18n/i18n-node"
4
+ import { locales } from "./i18n/i18n-util"
5
+ import { loadAllLocalesAsync } from "./i18n/i18n-util.async"
6
+ import { demoTool } from "./tools/demo"
7
+
8
+ await loadAllLocalesAsync()
9
+
10
+ const plugin = createPlugin({
11
+ name: packageJSON.name,
12
+ display_name: t("PLUGIN_DISPLAY_NAME"),
13
+ description: t("PLUGIN_DESCRIPTION"),
14
+ icon: "🎛️",
15
+ author: "Choiceform",
16
+ email: "support@choiceform.com",
17
+ version: packageJSON.version,
18
+ repo: "https://github.com/choice-open/automation-official-plugins/plugins/testing-plugin",
19
+ locales,
20
+ transporterOptions: {},
21
+ })
22
+
23
+ plugin.addTool(demoTool)
24
+
25
+ plugin.run()
@@ -0,0 +1,18 @@
1
+ # tools
2
+
3
+ 工具定义模块,用于定义插件提供的可执行工具。
4
+
5
+ ## 文件
6
+
7
+ - `demo.ts` - 演示工具定义,包含工具参数和执行逻辑
8
+
9
+ ## 功能
10
+
11
+ 定义 `demo-tool` 工具,包含:
12
+ - 参数定义(location 字符串)
13
+ - 执行逻辑(invoke 函数,返回测试消息)
14
+
15
+ ## 关系
16
+
17
+ - 被 `src/index.ts` 导入并注册到插件
18
+ - 使用 `src/i18n/i18n-node.ts` 获取国际化文本
@@ -0,0 +1,29 @@
1
+ import type { ToolDefinition } from "@choiceopen/automation-plugin-sdk-js/types"
2
+ import { t } from "../i18n/i18n-node"
3
+
4
+ export const demoTool = {
5
+ name: "demo-tool",
6
+ display_name: t("DEMO_TOOL_DISPLAY_NAME"),
7
+ description: t("DEMO_TOOL_DESCRIPTION"),
8
+ icon: "🧰",
9
+ parameters: [
10
+ {
11
+ name: "location",
12
+ type: "string",
13
+ required: true,
14
+ display_name: t("LOCATION_DISPLAY_NAME"),
15
+ ui: {
16
+ component: "input",
17
+ hint: t("LOCATION_HINT"),
18
+ placeholder: t("LOCATION_PLACEHOLDER"),
19
+ support_expression: true,
20
+ width: "full",
21
+ },
22
+ },
23
+ ],
24
+ async invoke({ args }: { args: { location: string } }) {
25
+ return {
26
+ message: `Testing the plugin with location: ${args.location}`,
27
+ }
28
+ },
29
+ } satisfies ToolDefinition
@@ -0,0 +1,15 @@
1
+ # tests
2
+
3
+ 测试文件目录。
4
+
5
+ ## 文件
6
+
7
+ - `index.test.ts` - 主测试文件
8
+
9
+ ## 测试框架
10
+
11
+ 使用 Vitest 作为测试框架,配置在 `package.json` 中。
12
+
13
+ ## 关系
14
+
15
+ - 测试 `src/` 目录下的所有模块