@amaster.ai/cli 1.1.39 → 1.1.40
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 +33 -4
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +33 -4
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -626,6 +626,9 @@ function validateMembers(manifest) {
|
|
|
626
626
|
if (!resolveMemberSourcePath(member)) {
|
|
627
627
|
throw new Error(`addon.json member ${member.name} missing source.path`);
|
|
628
628
|
}
|
|
629
|
+
if (member.type === "settings" && resolveMemberTargetPath(member)) {
|
|
630
|
+
throw new Error(`Settings member ${member.name} does not support target.path`);
|
|
631
|
+
}
|
|
629
632
|
}
|
|
630
633
|
}
|
|
631
634
|
function validateDisplayAssets(manifest) {
|
|
@@ -857,6 +860,13 @@ function resolveMemberSourcePath(member) {
|
|
|
857
860
|
}
|
|
858
861
|
return null;
|
|
859
862
|
}
|
|
863
|
+
function resolveMemberTargetPath(member) {
|
|
864
|
+
const targetPath = member.target?.path;
|
|
865
|
+
if (typeof targetPath === "string" && targetPath.trim()) {
|
|
866
|
+
return normalizeRelativePath(targetPath, "member target path");
|
|
867
|
+
}
|
|
868
|
+
return null;
|
|
869
|
+
}
|
|
860
870
|
function normalizeRelativePath(value, fieldName = "path") {
|
|
861
871
|
if (path.isAbsolute(value)) {
|
|
862
872
|
throw new Error(`Invalid addon.json ${fieldName}: ${value}`);
|
|
@@ -1290,6 +1300,11 @@ function isExistingNpmDependencyCompatible(existingVersion, requestedVersion) {
|
|
|
1290
1300
|
}
|
|
1291
1301
|
return semver.gte(existingMinimum, requestedMinimum);
|
|
1292
1302
|
}
|
|
1303
|
+
function isSameOrInsidePath(path$1, parentPath) {
|
|
1304
|
+
const normalizedPath = path.resolve("/", path$1);
|
|
1305
|
+
const normalizedParent = path.resolve("/", parentPath);
|
|
1306
|
+
return normalizedPath === normalizedParent || normalizedPath.startsWith(`${normalizedParent}/`);
|
|
1307
|
+
}
|
|
1293
1308
|
async function collectDirectoryFiles(sourceDir) {
|
|
1294
1309
|
const entries = await promises$1.readdir(sourceDir, { withFileTypes: true });
|
|
1295
1310
|
const files = [];
|
|
@@ -1303,16 +1318,18 @@ async function collectDirectoryFiles(sourceDir) {
|
|
|
1303
1318
|
}
|
|
1304
1319
|
return files.sort();
|
|
1305
1320
|
}
|
|
1306
|
-
async function planCopyMember(sourceRoot, sourceRelativePath, targetBaseRelativeDir, member) {
|
|
1321
|
+
async function planCopyMember(sourceRoot, sourceRelativePath, targetBaseRelativeDir, member, targetRelativePath) {
|
|
1307
1322
|
const sourceAbsolutePath = path.join(sourceRoot, sourceRelativePath);
|
|
1308
1323
|
const sourceStat = await promises$1.stat(sourceAbsolutePath);
|
|
1309
1324
|
const plannedFiles = [];
|
|
1310
1325
|
const targetPaths = [];
|
|
1326
|
+
const defaultTargetPath = path.join(targetBaseRelativeDir, path.basename(sourceRelativePath)).replace(/\\/g, "/");
|
|
1327
|
+
const memberTargetPath = targetRelativePath ?? defaultTargetPath;
|
|
1311
1328
|
if (sourceStat.isDirectory()) {
|
|
1312
1329
|
const sourceFiles = await collectDirectoryFiles(sourceAbsolutePath);
|
|
1313
1330
|
for (const sourceFile of sourceFiles) {
|
|
1314
1331
|
const nestedRelativePath = path.relative(sourceAbsolutePath, sourceFile);
|
|
1315
|
-
const targetPath = path.join(
|
|
1332
|
+
const targetPath = path.join(memberTargetPath, nestedRelativePath).replace(/\\/g, "/");
|
|
1316
1333
|
const sourcePackagePath = path.join(sourceRelativePath, nestedRelativePath).replace(/\\/g, "/");
|
|
1317
1334
|
plannedFiles.push({
|
|
1318
1335
|
sourcePath: sourceFile,
|
|
@@ -1324,7 +1341,7 @@ async function planCopyMember(sourceRoot, sourceRelativePath, targetBaseRelative
|
|
|
1324
1341
|
targetPaths.push(targetPath);
|
|
1325
1342
|
}
|
|
1326
1343
|
} else {
|
|
1327
|
-
const targetPath =
|
|
1344
|
+
const targetPath = memberTargetPath;
|
|
1328
1345
|
plannedFiles.push({
|
|
1329
1346
|
sourcePath: sourceAbsolutePath,
|
|
1330
1347
|
sourceRelativePath,
|
|
@@ -1408,7 +1425,19 @@ async function buildInstallPlan(options) {
|
|
|
1408
1425
|
default:
|
|
1409
1426
|
throw new Error(`Unsupported addon member type: ${member.type}`);
|
|
1410
1427
|
}
|
|
1411
|
-
const
|
|
1428
|
+
const targetRelativePath = resolveMemberTargetPath(member);
|
|
1429
|
+
if (targetRelativePath && !isSameOrInsidePath(targetRelativePath, targetBaseRelativeDir)) {
|
|
1430
|
+
throw new Error(
|
|
1431
|
+
`Member ${member.name} target.path must stay inside ${targetBaseRelativeDir}: ${targetRelativePath}`
|
|
1432
|
+
);
|
|
1433
|
+
}
|
|
1434
|
+
const planned = await planCopyMember(
|
|
1435
|
+
options.extractedDir,
|
|
1436
|
+
sourceRelativePath,
|
|
1437
|
+
targetBaseRelativeDir,
|
|
1438
|
+
member,
|
|
1439
|
+
targetRelativePath
|
|
1440
|
+
);
|
|
1412
1441
|
files.push(...planned.files);
|
|
1413
1442
|
const installedMember = {
|
|
1414
1443
|
name: member.name,
|