@amaster.ai/cli 1.1.40 → 1.1.42
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 +73 -1
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +73 -1
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -788,6 +788,12 @@ function validateRequirementItem(item, kind) {
|
|
|
788
788
|
if (requirement.required !== void 0 && typeof requirement.required !== "boolean") {
|
|
789
789
|
throw new Error(`addon.json install.requirements.${kind}s item required must be boolean`);
|
|
790
790
|
}
|
|
791
|
+
if (requirement.category !== void 0 && typeof requirement.category !== "string") {
|
|
792
|
+
throw new Error(`addon.json install.requirements.${kind}s item category must be string`);
|
|
793
|
+
}
|
|
794
|
+
if (requirement.label !== void 0 && typeof requirement.label !== "string") {
|
|
795
|
+
throw new Error(`addon.json install.requirements.${kind}s item label must be string`);
|
|
796
|
+
}
|
|
791
797
|
if (requirement.description !== void 0 && typeof requirement.description !== "string") {
|
|
792
798
|
throw new Error(`addon.json install.requirements.${kind}s item description must be string`);
|
|
793
799
|
}
|
|
@@ -1086,6 +1092,52 @@ function resolveInstallNpm(manifest) {
|
|
|
1086
1092
|
dependencies: npm.dependencies ? { ...npm.dependencies } : void 0
|
|
1087
1093
|
};
|
|
1088
1094
|
}
|
|
1095
|
+
function hasPlannedEnvMetadata(settings, key) {
|
|
1096
|
+
return settings.some(
|
|
1097
|
+
(setting) => setting.paths.some((path) => path.segments[0] === "envMetadata" && path.segments[1] === key)
|
|
1098
|
+
);
|
|
1099
|
+
}
|
|
1100
|
+
function buildRequirementEnvMetadata(manifest, requirement, kind) {
|
|
1101
|
+
const metadata = {
|
|
1102
|
+
category: requirement.category || manifest.display.title,
|
|
1103
|
+
label: requirement.label || requirement.key,
|
|
1104
|
+
type: kind === "secret" ? "password" : "input",
|
|
1105
|
+
envVar: requirement.key,
|
|
1106
|
+
storage: kind === "secret" ? "secret" : "env"
|
|
1107
|
+
};
|
|
1108
|
+
if (kind === "secret") {
|
|
1109
|
+
metadata.sensitive = true;
|
|
1110
|
+
}
|
|
1111
|
+
if (requirement.description !== void 0) {
|
|
1112
|
+
metadata.description = requirement.description;
|
|
1113
|
+
}
|
|
1114
|
+
if (requirement.required !== void 0) {
|
|
1115
|
+
metadata.required = requirement.required;
|
|
1116
|
+
}
|
|
1117
|
+
if (requirement.defaultValue !== void 0) {
|
|
1118
|
+
metadata.default = requirement.defaultValue;
|
|
1119
|
+
}
|
|
1120
|
+
return metadata;
|
|
1121
|
+
}
|
|
1122
|
+
function buildInstallRequirementsSettingsPatch(manifest, settings) {
|
|
1123
|
+
const envMetadata = {};
|
|
1124
|
+
for (const requirement of resolveInstallRequirements(manifest).envs ?? []) {
|
|
1125
|
+
if (hasPlannedEnvMetadata(settings, requirement.key)) {
|
|
1126
|
+
continue;
|
|
1127
|
+
}
|
|
1128
|
+
envMetadata[requirement.key] = buildRequirementEnvMetadata(manifest, requirement, "env");
|
|
1129
|
+
}
|
|
1130
|
+
for (const requirement of resolveInstallRequirements(manifest).secrets ?? []) {
|
|
1131
|
+
if (hasPlannedEnvMetadata(settings, requirement.key)) {
|
|
1132
|
+
continue;
|
|
1133
|
+
}
|
|
1134
|
+
envMetadata[requirement.key] = buildRequirementEnvMetadata(manifest, requirement, "secret");
|
|
1135
|
+
}
|
|
1136
|
+
if (!Object.keys(envMetadata).length) {
|
|
1137
|
+
return null;
|
|
1138
|
+
}
|
|
1139
|
+
return { envMetadata };
|
|
1140
|
+
}
|
|
1089
1141
|
function listNpmDependencies(npm) {
|
|
1090
1142
|
return Object.entries(npm.dependencies ?? {}).map(([packageName, version]) => ({
|
|
1091
1143
|
packageName,
|
|
@@ -1162,7 +1214,9 @@ function buildAddonLlmGuidance(input) {
|
|
|
1162
1214
|
instructions.push("Use installed function members by invoking their function names from the host application.");
|
|
1163
1215
|
}
|
|
1164
1216
|
if (hasInstallRequirements(input.requirements)) {
|
|
1165
|
-
instructions.push(
|
|
1217
|
+
instructions.push(
|
|
1218
|
+
"Configure the declared env/secret requirements before running or deploying the application. Use the app_secret_env tool instead of writing secret values into source files or .env examples."
|
|
1219
|
+
);
|
|
1166
1220
|
}
|
|
1167
1221
|
if (hasNpmDependencies(input.npm)) {
|
|
1168
1222
|
instructions.push("NPM dependencies have been written to package.json; avoid adding duplicate dependency entries.");
|
|
@@ -1447,6 +1501,24 @@ async function buildInstallPlan(options) {
|
|
|
1447
1501
|
}
|
|
1448
1502
|
members.push(installedMember);
|
|
1449
1503
|
}
|
|
1504
|
+
const requirementsSettingsPatch = buildInstallRequirementsSettingsPatch(manifest, settings);
|
|
1505
|
+
if (requirementsSettingsPatch) {
|
|
1506
|
+
settings.push({
|
|
1507
|
+
sourcePath: join(options.extractedDir, "addon.json"),
|
|
1508
|
+
sourceRelativePath: "addon.json#install.requirements",
|
|
1509
|
+
targetPath: "app.settings.yml",
|
|
1510
|
+
memberName: "install-requirements",
|
|
1511
|
+
memberType: "settings",
|
|
1512
|
+
patch: requirementsSettingsPatch,
|
|
1513
|
+
paths: flattenSettingsPatch(requirementsSettingsPatch)
|
|
1514
|
+
});
|
|
1515
|
+
members.push({
|
|
1516
|
+
name: "install-requirements",
|
|
1517
|
+
type: "settings",
|
|
1518
|
+
sourcePath: "addon.json#install.requirements",
|
|
1519
|
+
targetPaths: ["app.settings.yml"]
|
|
1520
|
+
});
|
|
1521
|
+
}
|
|
1450
1522
|
return {
|
|
1451
1523
|
files,
|
|
1452
1524
|
settings,
|