@within-7/jetr 0.5.0 → 0.5.2
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.js +36 -22
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -465,14 +465,11 @@ program.argument("[paths...]", "Files or directory to deploy").action(async (pat
|
|
|
465
465
|
const rcDir = dir;
|
|
466
466
|
let siteName = await resolveSiteName(rcDir, explicitName);
|
|
467
467
|
if (!siteName) {
|
|
468
|
-
|
|
469
|
-
|
|
468
|
+
siteName = generateName();
|
|
469
|
+
console.log(chalk2.dim(`Site name: ${siteName}`));
|
|
470
470
|
}
|
|
471
471
|
siteName = sanitizeName(siteName);
|
|
472
|
-
if (!siteName)
|
|
473
|
-
console.error(chalk2.red("Invalid site name"));
|
|
474
|
-
process.exit(1);
|
|
475
|
-
}
|
|
472
|
+
if (!siteName) siteName = generateName();
|
|
476
473
|
const spinner = ora("").start();
|
|
477
474
|
try {
|
|
478
475
|
await ensureSiteExists(spinner, siteName);
|
|
@@ -490,14 +487,11 @@ program.argument("[paths...]", "Files or directory to deploy").action(async (pat
|
|
|
490
487
|
console.log(chalk2.dim(`File mode: ${files.map((f) => basename2(f)).join(", ")}`));
|
|
491
488
|
let siteName = explicitName;
|
|
492
489
|
if (!siteName) {
|
|
493
|
-
|
|
494
|
-
|
|
490
|
+
siteName = generateName();
|
|
491
|
+
console.log(chalk2.dim(`Site name: ${siteName}`));
|
|
495
492
|
}
|
|
496
493
|
siteName = sanitizeName(siteName);
|
|
497
|
-
if (!siteName)
|
|
498
|
-
console.error(chalk2.red("Invalid site name"));
|
|
499
|
-
process.exit(1);
|
|
500
|
-
}
|
|
494
|
+
if (!siteName) siteName = generateName();
|
|
501
495
|
const spinner = ora("").start();
|
|
502
496
|
try {
|
|
503
497
|
await ensureSiteExists(spinner, siteName);
|
|
@@ -730,19 +724,39 @@ function parseDeployArgs(paths) {
|
|
|
730
724
|
}
|
|
731
725
|
return { mode: "files", files, explicitName };
|
|
732
726
|
}
|
|
727
|
+
function generateName() {
|
|
728
|
+
const adjectives = [
|
|
729
|
+
"swift",
|
|
730
|
+
"cool",
|
|
731
|
+
"fast",
|
|
732
|
+
"neat",
|
|
733
|
+
"bold",
|
|
734
|
+
"calm",
|
|
735
|
+
"warm",
|
|
736
|
+
"keen",
|
|
737
|
+
"fair",
|
|
738
|
+
"wise"
|
|
739
|
+
];
|
|
740
|
+
const nouns = [
|
|
741
|
+
"page",
|
|
742
|
+
"site",
|
|
743
|
+
"note",
|
|
744
|
+
"docs",
|
|
745
|
+
"view",
|
|
746
|
+
"deck",
|
|
747
|
+
"leaf",
|
|
748
|
+
"post",
|
|
749
|
+
"blog",
|
|
750
|
+
"demo"
|
|
751
|
+
];
|
|
752
|
+
const adj = adjectives[Math.floor(Math.random() * adjectives.length)];
|
|
753
|
+
const noun = nouns[Math.floor(Math.random() * nouns.length)];
|
|
754
|
+
const hex = Math.floor(Math.random() * 65535).toString(16).padStart(4, "0");
|
|
755
|
+
return `${adj}-${noun}-${hex}`;
|
|
756
|
+
}
|
|
733
757
|
function sanitizeName(name) {
|
|
734
758
|
return name.toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/^-+|-+$/g, "").replace(/-+/g, "-");
|
|
735
759
|
}
|
|
736
|
-
async function promptLine(prompt) {
|
|
737
|
-
const { createInterface: createInterface2 } = await import("readline");
|
|
738
|
-
const rl = createInterface2({ input: process.stdin, output: process.stdout });
|
|
739
|
-
return new Promise((res) => {
|
|
740
|
-
rl.question(chalk2.bold(prompt), (a) => {
|
|
741
|
-
rl.close();
|
|
742
|
-
res(a.trim());
|
|
743
|
-
});
|
|
744
|
-
});
|
|
745
|
-
}
|
|
746
760
|
async function ensureSiteExists(spinner, siteName) {
|
|
747
761
|
spinner.text = "Checking site...";
|
|
748
762
|
try {
|