@amaster.ai/cli 1.1.39 → 1.1.41
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/dist/cli.cjs +36 -5
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +36 -5
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -599,6 +599,9 @@ function validateMembers(manifest) {
|
|
|
599
599
|
if (!resolveMemberSourcePath(member)) {
|
|
600
600
|
throw new Error(`addon.json member ${member.name} missing source.path`);
|
|
601
601
|
}
|
|
602
|
+
if (member.type === "settings" && resolveMemberTargetPath(member)) {
|
|
603
|
+
throw new Error(`Settings member ${member.name} does not support target.path`);
|
|
604
|
+
}
|
|
602
605
|
}
|
|
603
606
|
}
|
|
604
607
|
function validateDisplayAssets(manifest) {
|
|
@@ -830,6 +833,13 @@ function resolveMemberSourcePath(member) {
|
|
|
830
833
|
}
|
|
831
834
|
return null;
|
|
832
835
|
}
|
|
836
|
+
function resolveMemberTargetPath(member) {
|
|
837
|
+
const targetPath = member.target?.path;
|
|
838
|
+
if (typeof targetPath === "string" && targetPath.trim()) {
|
|
839
|
+
return normalizeRelativePath(targetPath, "member target path");
|
|
840
|
+
}
|
|
841
|
+
return null;
|
|
842
|
+
}
|
|
833
843
|
function normalizeRelativePath(value, fieldName = "path") {
|
|
834
844
|
if (isAbsolute(value)) {
|
|
835
845
|
throw new Error(`Invalid addon.json ${fieldName}: ${value}`);
|
|
@@ -1152,7 +1162,9 @@ function buildAddonLlmGuidance(input) {
|
|
|
1152
1162
|
instructions.push("Use installed function members by invoking their function names from the host application.");
|
|
1153
1163
|
}
|
|
1154
1164
|
if (hasInstallRequirements(input.requirements)) {
|
|
1155
|
-
instructions.push(
|
|
1165
|
+
instructions.push(
|
|
1166
|
+
"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."
|
|
1167
|
+
);
|
|
1156
1168
|
}
|
|
1157
1169
|
if (hasNpmDependencies(input.npm)) {
|
|
1158
1170
|
instructions.push("NPM dependencies have been written to package.json; avoid adding duplicate dependency entries.");
|
|
@@ -1263,6 +1275,11 @@ function isExistingNpmDependencyCompatible(existingVersion, requestedVersion) {
|
|
|
1263
1275
|
}
|
|
1264
1276
|
return gte(existingMinimum, requestedMinimum);
|
|
1265
1277
|
}
|
|
1278
|
+
function isSameOrInsidePath(path, parentPath) {
|
|
1279
|
+
const normalizedPath = resolve("/", path);
|
|
1280
|
+
const normalizedParent = resolve("/", parentPath);
|
|
1281
|
+
return normalizedPath === normalizedParent || normalizedPath.startsWith(`${normalizedParent}/`);
|
|
1282
|
+
}
|
|
1266
1283
|
async function collectDirectoryFiles(sourceDir) {
|
|
1267
1284
|
const entries = await readdir(sourceDir, { withFileTypes: true });
|
|
1268
1285
|
const files = [];
|
|
@@ -1276,16 +1293,18 @@ async function collectDirectoryFiles(sourceDir) {
|
|
|
1276
1293
|
}
|
|
1277
1294
|
return files.sort();
|
|
1278
1295
|
}
|
|
1279
|
-
async function planCopyMember(sourceRoot, sourceRelativePath, targetBaseRelativeDir, member) {
|
|
1296
|
+
async function planCopyMember(sourceRoot, sourceRelativePath, targetBaseRelativeDir, member, targetRelativePath) {
|
|
1280
1297
|
const sourceAbsolutePath = join(sourceRoot, sourceRelativePath);
|
|
1281
1298
|
const sourceStat = await stat(sourceAbsolutePath);
|
|
1282
1299
|
const plannedFiles = [];
|
|
1283
1300
|
const targetPaths = [];
|
|
1301
|
+
const defaultTargetPath = join(targetBaseRelativeDir, basename(sourceRelativePath)).replace(/\\/g, "/");
|
|
1302
|
+
const memberTargetPath = targetRelativePath ?? defaultTargetPath;
|
|
1284
1303
|
if (sourceStat.isDirectory()) {
|
|
1285
1304
|
const sourceFiles = await collectDirectoryFiles(sourceAbsolutePath);
|
|
1286
1305
|
for (const sourceFile of sourceFiles) {
|
|
1287
1306
|
const nestedRelativePath = relative(sourceAbsolutePath, sourceFile);
|
|
1288
|
-
const targetPath = join(
|
|
1307
|
+
const targetPath = join(memberTargetPath, nestedRelativePath).replace(/\\/g, "/");
|
|
1289
1308
|
const sourcePackagePath = join(sourceRelativePath, nestedRelativePath).replace(/\\/g, "/");
|
|
1290
1309
|
plannedFiles.push({
|
|
1291
1310
|
sourcePath: sourceFile,
|
|
@@ -1297,7 +1316,7 @@ async function planCopyMember(sourceRoot, sourceRelativePath, targetBaseRelative
|
|
|
1297
1316
|
targetPaths.push(targetPath);
|
|
1298
1317
|
}
|
|
1299
1318
|
} else {
|
|
1300
|
-
const targetPath =
|
|
1319
|
+
const targetPath = memberTargetPath;
|
|
1301
1320
|
plannedFiles.push({
|
|
1302
1321
|
sourcePath: sourceAbsolutePath,
|
|
1303
1322
|
sourceRelativePath,
|
|
@@ -1381,7 +1400,19 @@ async function buildInstallPlan(options) {
|
|
|
1381
1400
|
default:
|
|
1382
1401
|
throw new Error(`Unsupported addon member type: ${member.type}`);
|
|
1383
1402
|
}
|
|
1384
|
-
const
|
|
1403
|
+
const targetRelativePath = resolveMemberTargetPath(member);
|
|
1404
|
+
if (targetRelativePath && !isSameOrInsidePath(targetRelativePath, targetBaseRelativeDir)) {
|
|
1405
|
+
throw new Error(
|
|
1406
|
+
`Member ${member.name} target.path must stay inside ${targetBaseRelativeDir}: ${targetRelativePath}`
|
|
1407
|
+
);
|
|
1408
|
+
}
|
|
1409
|
+
const planned = await planCopyMember(
|
|
1410
|
+
options.extractedDir,
|
|
1411
|
+
sourceRelativePath,
|
|
1412
|
+
targetBaseRelativeDir,
|
|
1413
|
+
member,
|
|
1414
|
+
targetRelativePath
|
|
1415
|
+
);
|
|
1385
1416
|
files.push(...planned.files);
|
|
1386
1417
|
const installedMember = {
|
|
1387
1418
|
name: member.name,
|