@wayai/cli 0.3.60 → 0.3.61
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/index.js +49 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -16713,6 +16713,16 @@ function readDirToFileMap(rootDir) {
|
|
|
16713
16713
|
if (fs16.existsSync(rootDir)) walk(rootDir, "");
|
|
16714
16714
|
return out;
|
|
16715
16715
|
}
|
|
16716
|
+
function detectCollisions(targetDir, files) {
|
|
16717
|
+
const collisions = [];
|
|
16718
|
+
for (const rel of Object.keys(files)) {
|
|
16719
|
+
if (!isSafeTemplatePath2(rel)) {
|
|
16720
|
+
throw new Error(`Refusing to inspect unsafe template path: ${rel}`);
|
|
16721
|
+
}
|
|
16722
|
+
if (fs16.existsSync(path19.join(targetDir, rel))) collisions.push(rel);
|
|
16723
|
+
}
|
|
16724
|
+
return collisions.sort((a, b) => a.localeCompare(b));
|
|
16725
|
+
}
|
|
16716
16726
|
function writeFileMap(targetDir, files) {
|
|
16717
16727
|
const written = [];
|
|
16718
16728
|
for (const [rel, body] of Object.entries(files)) {
|
|
@@ -16791,7 +16801,17 @@ async function runTemplateList() {
|
|
|
16791
16801
|
async function runTemplatePull(rest) {
|
|
16792
16802
|
const positional = [];
|
|
16793
16803
|
let lang;
|
|
16804
|
+
let force = false;
|
|
16805
|
+
let dryRun = false;
|
|
16794
16806
|
for (let i = 0; i < rest.length; i++) {
|
|
16807
|
+
if (rest[i] === "--force") {
|
|
16808
|
+
force = true;
|
|
16809
|
+
continue;
|
|
16810
|
+
}
|
|
16811
|
+
if (rest[i] === "--dry-run") {
|
|
16812
|
+
dryRun = true;
|
|
16813
|
+
continue;
|
|
16814
|
+
}
|
|
16795
16815
|
if (rest[i] === "--lang") {
|
|
16796
16816
|
const v = rest[++i];
|
|
16797
16817
|
if (!v) {
|
|
@@ -16843,8 +16863,31 @@ async function runTemplatePull(rest) {
|
|
|
16843
16863
|
return;
|
|
16844
16864
|
}
|
|
16845
16865
|
const targetDir = path20.join(resolveLayout(gitRoot).hubsDir, slug);
|
|
16866
|
+
const relTarget = path20.relative(gitRoot, targetDir);
|
|
16867
|
+
const collisions = detectCollisions(targetDir, detail.files);
|
|
16868
|
+
if (dryRun) {
|
|
16869
|
+
const planned = Object.keys(detail.files).sort((a, b) => a.localeCompare(b));
|
|
16870
|
+
const collisionSet = new Set(collisions);
|
|
16871
|
+
console.log(`Dry run \u2014 would write ${planned.length} file${planned.length === 1 ? "" : "s"} into ${relTarget}/:`);
|
|
16872
|
+
for (const rel of planned) {
|
|
16873
|
+
console.log(` ${collisionSet.has(rel) ? "overwrite" : "create"} ${rel}`);
|
|
16874
|
+
}
|
|
16875
|
+
if (collisions.length > 0) {
|
|
16876
|
+
console.log(`
|
|
16877
|
+
${collisions.length} existing file${collisions.length === 1 ? "" : "s"} would be overwritten \u2014 re-run with --force to proceed.`);
|
|
16878
|
+
}
|
|
16879
|
+
return;
|
|
16880
|
+
}
|
|
16881
|
+
if (collisions.length > 0 && !force) {
|
|
16882
|
+
console.error(`Refusing to overwrite ${collisions.length} existing file${collisions.length === 1 ? "" : "s"} in ${relTarget}/:`);
|
|
16883
|
+
for (const rel of collisions) console.error(` ${rel}`);
|
|
16884
|
+
console.error(`
|
|
16885
|
+
Commit or move your changes and re-run with --force to overwrite, or pull into a fresh slug dir.`);
|
|
16886
|
+
console.error(`Preview the full file map first with --dry-run.`);
|
|
16887
|
+
process.exit(1);
|
|
16888
|
+
}
|
|
16846
16889
|
const written = writeFileMap(targetDir, detail.files);
|
|
16847
|
-
console.log(`Pulled template "${slug}" \u2192 ${
|
|
16890
|
+
console.log(`Pulled template "${slug}" \u2192 ${relTarget}/ (${written.length} file${written.length === 1 ? "" : "s"}).`);
|
|
16848
16891
|
console.log(`Next: \`wayai push\` to deploy it into your own hub.`);
|
|
16849
16892
|
if (detail.includes.rekor) {
|
|
16850
16893
|
console.log(`
|
|
@@ -16858,11 +16901,14 @@ function printTemplateHelp() {
|
|
|
16858
16901
|
console.log(`wayai template \u2014 install ready-made hub templates
|
|
16859
16902
|
|
|
16860
16903
|
Usage:
|
|
16861
|
-
wayai template list
|
|
16862
|
-
wayai template pull <slug> [--lang <l>]
|
|
16904
|
+
wayai template list List available templates
|
|
16905
|
+
wayai template pull <slug> [--lang <l>] [--force] [--dry-run]
|
|
16906
|
+
Write a template's WayAI slice into wayai-ws/hubs/<slug>/
|
|
16863
16907
|
|
|
16864
16908
|
--lang selects a localized variant (${templateLocaleSchema2.options.join("|")}); omitted = the template's default
|
|
16865
16909
|
language. An untranslated language falls back to the default (with a note).
|
|
16910
|
+
--dry-run previews the file map (marking files that would be overwritten) without writing.
|
|
16911
|
+
A pull refuses to overwrite existing files in the target dir; pass --force to overwrite them.
|
|
16866
16912
|
|
|
16867
16913
|
After pulling, run \`wayai push\` to deploy the template into your own hub.`);
|
|
16868
16914
|
}
|