@amaster.ai/cli 1.1.41 → 1.1.43-beta.0
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.
- package/README.md +3 -1
- package/dist/cli.cjs +70 -0
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +70 -0
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -121,6 +121,8 @@ Addon 可在 `addon.json` 中声明安装后的运行配置要求:
|
|
|
121
121
|
{
|
|
122
122
|
"key": "OAUTH_CLIENT_ID",
|
|
123
123
|
"required": true,
|
|
124
|
+
"category": "OAuth",
|
|
125
|
+
"label": "OAuth Client ID",
|
|
124
126
|
"description": "OAuth client id",
|
|
125
127
|
"defaultValue": "demo-client"
|
|
126
128
|
}
|
|
@@ -140,7 +142,7 @@ Addon 可在 `addon.json` 中声明安装后的运行配置要求:
|
|
|
140
142
|
`install.npm` 会写入应用根目录 `package.json`。如果目标应用已声明同名包,CLI 会按 semver 判断是否可保留现有版本:版本范围相交,或现有版本下限高于 Addon 请求下限时,保留应用现有版本;旧版本或无法按 semver 判断的差异会停止并返回 `package_dependency_conflict`。
|
|
141
143
|
通过 registry 执行 `addon install` / `addon upgrade` 时,如果 `package.json` 有变更,CLI 会按当前应用自动执行 `bun install`、`pnpm install`、`npm install` 或 `yarn install`。
|
|
142
144
|
|
|
143
|
-
`install.requirements` 会写入 `meta.json`,并在安装/升级结果中返回 `requirements` 和 `missingRequirements`。`secrets`
|
|
145
|
+
`install.requirements` 会写入 `meta.json`,并在安装/升级结果中返回 `requirements` 和 `missingRequirements`。`requirements.envs` 和 `requirements.secrets` 会合并到应用根目录 `app.settings.yml` 的 `envMetadata`;env 字段生成 `type: input` / `storage: env`,secret 字段生成 `type: password` / `storage: secret` / `sensitive: true`。`defaultValue` 仅支持 env,会写为 `default`;secret 不保存密钥值。
|
|
144
146
|
|
|
145
147
|
页面接入方式:
|
|
146
148
|
|
package/dist/cli.cjs
CHANGED
|
@@ -815,6 +815,12 @@ function validateRequirementItem(item, kind) {
|
|
|
815
815
|
if (requirement.required !== void 0 && typeof requirement.required !== "boolean") {
|
|
816
816
|
throw new Error(`addon.json install.requirements.${kind}s item required must be boolean`);
|
|
817
817
|
}
|
|
818
|
+
if (requirement.category !== void 0 && typeof requirement.category !== "string") {
|
|
819
|
+
throw new Error(`addon.json install.requirements.${kind}s item category must be string`);
|
|
820
|
+
}
|
|
821
|
+
if (requirement.label !== void 0 && typeof requirement.label !== "string") {
|
|
822
|
+
throw new Error(`addon.json install.requirements.${kind}s item label must be string`);
|
|
823
|
+
}
|
|
818
824
|
if (requirement.description !== void 0 && typeof requirement.description !== "string") {
|
|
819
825
|
throw new Error(`addon.json install.requirements.${kind}s item description must be string`);
|
|
820
826
|
}
|
|
@@ -1113,6 +1119,52 @@ function resolveInstallNpm(manifest) {
|
|
|
1113
1119
|
dependencies: npm.dependencies ? { ...npm.dependencies } : void 0
|
|
1114
1120
|
};
|
|
1115
1121
|
}
|
|
1122
|
+
function hasPlannedEnvMetadata(settings, key) {
|
|
1123
|
+
return settings.some(
|
|
1124
|
+
(setting) => setting.paths.some((path) => path.segments[0] === "envMetadata" && path.segments[1] === key)
|
|
1125
|
+
);
|
|
1126
|
+
}
|
|
1127
|
+
function buildRequirementEnvMetadata(manifest, requirement, kind) {
|
|
1128
|
+
const metadata = {
|
|
1129
|
+
category: requirement.category || manifest.display.title,
|
|
1130
|
+
label: requirement.label || requirement.key,
|
|
1131
|
+
type: kind === "secret" ? "password" : "input",
|
|
1132
|
+
envVar: requirement.key,
|
|
1133
|
+
storage: kind === "secret" ? "secret" : "env"
|
|
1134
|
+
};
|
|
1135
|
+
if (kind === "secret") {
|
|
1136
|
+
metadata.sensitive = true;
|
|
1137
|
+
}
|
|
1138
|
+
if (requirement.description !== void 0) {
|
|
1139
|
+
metadata.description = requirement.description;
|
|
1140
|
+
}
|
|
1141
|
+
if (requirement.required !== void 0) {
|
|
1142
|
+
metadata.required = requirement.required;
|
|
1143
|
+
}
|
|
1144
|
+
if (requirement.defaultValue !== void 0) {
|
|
1145
|
+
metadata.default = requirement.defaultValue;
|
|
1146
|
+
}
|
|
1147
|
+
return metadata;
|
|
1148
|
+
}
|
|
1149
|
+
function buildInstallRequirementsSettingsPatch(manifest, settings) {
|
|
1150
|
+
const envMetadata = {};
|
|
1151
|
+
for (const requirement of resolveInstallRequirements(manifest).envs ?? []) {
|
|
1152
|
+
if (hasPlannedEnvMetadata(settings, requirement.key)) {
|
|
1153
|
+
continue;
|
|
1154
|
+
}
|
|
1155
|
+
envMetadata[requirement.key] = buildRequirementEnvMetadata(manifest, requirement, "env");
|
|
1156
|
+
}
|
|
1157
|
+
for (const requirement of resolveInstallRequirements(manifest).secrets ?? []) {
|
|
1158
|
+
if (hasPlannedEnvMetadata(settings, requirement.key)) {
|
|
1159
|
+
continue;
|
|
1160
|
+
}
|
|
1161
|
+
envMetadata[requirement.key] = buildRequirementEnvMetadata(manifest, requirement, "secret");
|
|
1162
|
+
}
|
|
1163
|
+
if (!Object.keys(envMetadata).length) {
|
|
1164
|
+
return null;
|
|
1165
|
+
}
|
|
1166
|
+
return { envMetadata };
|
|
1167
|
+
}
|
|
1116
1168
|
function listNpmDependencies(npm) {
|
|
1117
1169
|
return Object.entries(npm.dependencies ?? {}).map(([packageName, version]) => ({
|
|
1118
1170
|
packageName,
|
|
@@ -1476,6 +1528,24 @@ async function buildInstallPlan(options) {
|
|
|
1476
1528
|
}
|
|
1477
1529
|
members.push(installedMember);
|
|
1478
1530
|
}
|
|
1531
|
+
const requirementsSettingsPatch = buildInstallRequirementsSettingsPatch(manifest, settings);
|
|
1532
|
+
if (requirementsSettingsPatch) {
|
|
1533
|
+
settings.push({
|
|
1534
|
+
sourcePath: path.join(options.extractedDir, "addon.json"),
|
|
1535
|
+
sourceRelativePath: "addon.json#install.requirements",
|
|
1536
|
+
targetPath: "app.settings.yml",
|
|
1537
|
+
memberName: "install-requirements",
|
|
1538
|
+
memberType: "settings",
|
|
1539
|
+
patch: requirementsSettingsPatch,
|
|
1540
|
+
paths: flattenSettingsPatch(requirementsSettingsPatch)
|
|
1541
|
+
});
|
|
1542
|
+
members.push({
|
|
1543
|
+
name: "install-requirements",
|
|
1544
|
+
type: "settings",
|
|
1545
|
+
sourcePath: "addon.json#install.requirements",
|
|
1546
|
+
targetPaths: ["app.settings.yml"]
|
|
1547
|
+
});
|
|
1548
|
+
}
|
|
1479
1549
|
return {
|
|
1480
1550
|
files,
|
|
1481
1551
|
settings,
|