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