create-astro 3.1.2 → 3.1.4
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 +39 -20
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -368,7 +368,7 @@ function printHelp({
|
|
|
368
368
|
if (headline) {
|
|
369
369
|
message.push(
|
|
370
370
|
linebreak(),
|
|
371
|
-
`${title(commandName)} ${color.green(`v${"3.1.
|
|
371
|
+
`${title(commandName)} ${color.green(`v${"3.1.4"}`)} ${headline}`
|
|
372
372
|
);
|
|
373
373
|
}
|
|
374
374
|
if (usage) {
|
|
@@ -468,6 +468,7 @@ async function getContext(argv) {
|
|
|
468
468
|
}
|
|
469
469
|
|
|
470
470
|
// src/actions/dependencies.ts
|
|
471
|
+
import { color as color2 } from "@astrojs/cli-kit";
|
|
471
472
|
import { execa } from "execa";
|
|
472
473
|
async function dependencies(ctx) {
|
|
473
474
|
let deps = ctx.install ?? ctx.yes;
|
|
@@ -488,10 +489,26 @@ async function dependencies(ctx) {
|
|
|
488
489
|
await spinner({
|
|
489
490
|
start: `Dependencies installing with ${ctx.pkgManager}...`,
|
|
490
491
|
end: "Dependencies installed",
|
|
491
|
-
while: () =>
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
492
|
+
while: () => {
|
|
493
|
+
return Promise.reject("Unknown error").catch((e) => {
|
|
494
|
+
error("error", e);
|
|
495
|
+
error(
|
|
496
|
+
"error",
|
|
497
|
+
`Dependencies failed to install, please run ${color2.bold(
|
|
498
|
+
ctx.pkgManager + " install"
|
|
499
|
+
)} to install them manually after setup.`
|
|
500
|
+
);
|
|
501
|
+
});
|
|
502
|
+
return install({ pkgManager: ctx.pkgManager, cwd: ctx.cwd }).catch((e) => {
|
|
503
|
+
error("error", e);
|
|
504
|
+
error(
|
|
505
|
+
"error",
|
|
506
|
+
`Dependencies failed to install, please run ${color2.bold(
|
|
507
|
+
ctx.pkgManager + " install"
|
|
508
|
+
)} to install them manually after setup.`
|
|
509
|
+
);
|
|
510
|
+
});
|
|
511
|
+
}
|
|
495
512
|
});
|
|
496
513
|
} else {
|
|
497
514
|
await info(
|
|
@@ -512,7 +529,7 @@ async function install({ pkgManager, cwd }) {
|
|
|
512
529
|
// src/actions/git.ts
|
|
513
530
|
import fs from "node:fs";
|
|
514
531
|
import path from "node:path";
|
|
515
|
-
import { color as
|
|
532
|
+
import { color as color3 } from "@astrojs/cli-kit";
|
|
516
533
|
import { execa as execa2 } from "execa";
|
|
517
534
|
async function git(ctx) {
|
|
518
535
|
if (fs.existsSync(path.join(ctx.cwd, ".git"))) {
|
|
@@ -544,7 +561,7 @@ async function git(ctx) {
|
|
|
544
561
|
} else {
|
|
545
562
|
await info(
|
|
546
563
|
ctx.yes === false ? "git [skip]" : "Sounds good!",
|
|
547
|
-
`You can always run ${
|
|
564
|
+
`You can always run ${color3.reset("git init")}${color3.dim(" manually.")}`
|
|
548
565
|
);
|
|
549
566
|
}
|
|
550
567
|
}
|
|
@@ -591,7 +608,7 @@ function help() {
|
|
|
591
608
|
}
|
|
592
609
|
|
|
593
610
|
// src/actions/intro.ts
|
|
594
|
-
import { color as
|
|
611
|
+
import { color as color4, label as label2 } from "@astrojs/cli-kit";
|
|
595
612
|
import { random } from "@astrojs/cli-kit/utils";
|
|
596
613
|
async function intro(ctx) {
|
|
597
614
|
if (!ctx.skipHouston) {
|
|
@@ -599,8 +616,8 @@ async function intro(ctx) {
|
|
|
599
616
|
[
|
|
600
617
|
"Welcome",
|
|
601
618
|
"to",
|
|
602
|
-
label2("astro",
|
|
603
|
-
|
|
619
|
+
label2("astro", color4.bgGreen, color4.black),
|
|
620
|
+
color4.green(`v${ctx.version}`) + ",",
|
|
604
621
|
`${ctx.username}!`
|
|
605
622
|
],
|
|
606
623
|
random(welcome)
|
|
@@ -624,7 +641,7 @@ async function next(ctx) {
|
|
|
624
641
|
}
|
|
625
642
|
|
|
626
643
|
// src/actions/project-name.ts
|
|
627
|
-
import { color as
|
|
644
|
+
import { color as color5, generateProjectName } from "@astrojs/cli-kit";
|
|
628
645
|
import path3 from "node:path";
|
|
629
646
|
|
|
630
647
|
// src/actions/shared.ts
|
|
@@ -678,7 +695,7 @@ async function projectName(ctx) {
|
|
|
678
695
|
await checkCwd(ctx.cwd);
|
|
679
696
|
if (!ctx.cwd || !isEmpty(ctx.cwd)) {
|
|
680
697
|
if (!isEmpty(ctx.cwd)) {
|
|
681
|
-
await info("Hmm...", `${
|
|
698
|
+
await info("Hmm...", `${color5.reset(`"${ctx.cwd}"`)}${color5.dim(` is not empty!`)}`);
|
|
682
699
|
}
|
|
683
700
|
const { name } = await ctx.prompt({
|
|
684
701
|
name: "name",
|
|
@@ -690,6 +707,8 @@ async function projectName(ctx) {
|
|
|
690
707
|
if (!isEmpty(value)) {
|
|
691
708
|
return `Directory is not empty!`;
|
|
692
709
|
}
|
|
710
|
+
if (value.match(/[^\x20-\x7E]/g) !== null)
|
|
711
|
+
return `Invalid non-printable character present!`;
|
|
693
712
|
return true;
|
|
694
713
|
}
|
|
695
714
|
});
|
|
@@ -714,13 +733,13 @@ async function checkCwd(cwd) {
|
|
|
714
733
|
const empty = cwd && isEmpty(cwd);
|
|
715
734
|
if (empty) {
|
|
716
735
|
log("");
|
|
717
|
-
await info("dir", `Using ${
|
|
736
|
+
await info("dir", `Using ${color5.reset(cwd)}${color5.dim(" as project directory")}`);
|
|
718
737
|
}
|
|
719
738
|
return empty;
|
|
720
739
|
}
|
|
721
740
|
|
|
722
741
|
// src/actions/template.ts
|
|
723
|
-
import { color as
|
|
742
|
+
import { color as color6 } from "@astrojs/cli-kit";
|
|
724
743
|
import { downloadTemplate } from "giget";
|
|
725
744
|
import fs3 from "node:fs";
|
|
726
745
|
import path4 from "node:path";
|
|
@@ -740,7 +759,7 @@ async function template(ctx) {
|
|
|
740
759
|
});
|
|
741
760
|
ctx.template = tmpl;
|
|
742
761
|
} else {
|
|
743
|
-
await info("tmpl", `Using ${
|
|
762
|
+
await info("tmpl", `Using ${color6.reset(ctx.template)}${color6.dim(" as project template")}`);
|
|
744
763
|
}
|
|
745
764
|
if (ctx.dryRun) {
|
|
746
765
|
await info("--dry-run", `Skipping template copying`);
|
|
@@ -793,13 +812,13 @@ async function copyTemplate(tmpl, ctx) {
|
|
|
793
812
|
} catch (err) {
|
|
794
813
|
fs3.rmdirSync(ctx.cwd);
|
|
795
814
|
if (err.message.includes("404")) {
|
|
796
|
-
throw new Error(`Template ${
|
|
815
|
+
throw new Error(`Template ${color6.reset(tmpl)} ${color6.dim("does not exist!")}`);
|
|
797
816
|
} else {
|
|
798
817
|
throw new Error(err.message);
|
|
799
818
|
}
|
|
800
819
|
}
|
|
801
820
|
if (fs3.readdirSync(ctx.cwd).length === 0) {
|
|
802
|
-
throw new Error(`Template ${
|
|
821
|
+
throw new Error(`Template ${color6.reset(tmpl)} ${color6.dim("is empty!")}`);
|
|
803
822
|
}
|
|
804
823
|
const removeFiles = FILES_TO_REMOVE.map(async (file) => {
|
|
805
824
|
const fileLoc = path4.resolve(path4.join(ctx.cwd, file));
|
|
@@ -818,7 +837,7 @@ async function copyTemplate(tmpl, ctx) {
|
|
|
818
837
|
}
|
|
819
838
|
|
|
820
839
|
// src/actions/typescript.ts
|
|
821
|
-
import { color as
|
|
840
|
+
import { color as color7 } from "@astrojs/cli-kit";
|
|
822
841
|
import fs4 from "node:fs";
|
|
823
842
|
import { readFile } from "node:fs/promises";
|
|
824
843
|
import path5 from "node:path";
|
|
@@ -945,13 +964,13 @@ async function typescript(ctx) {
|
|
|
945
964
|
}
|
|
946
965
|
error(
|
|
947
966
|
"Error",
|
|
948
|
-
`Unknown TypeScript option ${
|
|
967
|
+
`Unknown TypeScript option ${color7.reset(ts)}${color7.dim(
|
|
949
968
|
"! Expected strict | strictest | relaxed"
|
|
950
969
|
)}`
|
|
951
970
|
);
|
|
952
971
|
ctx.exit(1);
|
|
953
972
|
}
|
|
954
|
-
await info("ts", `Using ${
|
|
973
|
+
await info("ts", `Using ${color7.reset(ts)}${color7.dim(" TypeScript configuration")}`);
|
|
955
974
|
}
|
|
956
975
|
if (ctx.dryRun) {
|
|
957
976
|
await info("--dry-run", `Skipping TypeScript setup`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-astro",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "withastro",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/which-pm-runs": "^1.0.0",
|
|
36
36
|
"arg": "^5.0.2",
|
|
37
|
-
"astro-scripts": "0.0.14",
|
|
38
37
|
"strip-ansi": "^7.0.1",
|
|
39
38
|
"strip-json-comments": "^5.0.0",
|
|
40
|
-
"which-pm-runs": "^1.1.0"
|
|
39
|
+
"which-pm-runs": "^1.1.0",
|
|
40
|
+
"astro-scripts": "0.0.14"
|
|
41
41
|
},
|
|
42
42
|
"engines": {
|
|
43
43
|
"node": ">=16.12.0"
|