create-astro 0.12.0 → 0.12.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/LICENSE +61 -0
- package/dist/gradient.js +65 -0
- package/dist/index.js +16 -20
- package/dist/types/gradient.d.ts +8 -0
- package/package.json +10 -9
package/LICENSE
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Fred K. Schott
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
"""
|
|
25
|
+
This license applies to parts of the `packages/create-astro` and `packages/astro` subdirectories originating from the https://github.com/sveltejs/kit repository:
|
|
26
|
+
|
|
27
|
+
Copyright (c) 2020 [these people](https://github.com/sveltejs/kit/graphs/contributors)
|
|
28
|
+
|
|
29
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
30
|
+
|
|
31
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
32
|
+
|
|
33
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
"""
|
|
38
|
+
This license applies to parts of the `packages/create-astro` and `packages/astro` subdirectories originating from the https://github.com/vitejs/vite repository:
|
|
39
|
+
|
|
40
|
+
MIT License
|
|
41
|
+
|
|
42
|
+
Copyright (c) 2019-present, Yuxi (Evan) You and Vite contributors
|
|
43
|
+
|
|
44
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
45
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
46
|
+
in the Software without restriction, including without limitation the rights
|
|
47
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
48
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
49
|
+
furnished to do so, subject to the following conditions:
|
|
50
|
+
|
|
51
|
+
The above copyright notice and this permission notice shall be included in all
|
|
52
|
+
copies or substantial portions of the Software.
|
|
53
|
+
|
|
54
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
55
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
56
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
57
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
58
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
59
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
60
|
+
SOFTWARE.
|
|
61
|
+
"""
|
package/dist/gradient.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import ora from "ora";
|
|
3
|
+
const gradientColors = [
|
|
4
|
+
`#ff5e00`,
|
|
5
|
+
`#ff4c29`,
|
|
6
|
+
`#ff383f`,
|
|
7
|
+
`#ff2453`,
|
|
8
|
+
`#ff0565`,
|
|
9
|
+
`#ff007b`,
|
|
10
|
+
`#f5008b`,
|
|
11
|
+
`#e6149c`,
|
|
12
|
+
`#d629ae`,
|
|
13
|
+
`#c238bd`
|
|
14
|
+
];
|
|
15
|
+
const rocketAscii = "\u25A0\u25A0\u25B6";
|
|
16
|
+
const referenceGradient = [
|
|
17
|
+
...gradientColors,
|
|
18
|
+
...[...gradientColors].reverse(),
|
|
19
|
+
...gradientColors
|
|
20
|
+
];
|
|
21
|
+
const sleep = (time) => new Promise((resolve) => {
|
|
22
|
+
setTimeout(resolve, time);
|
|
23
|
+
});
|
|
24
|
+
function getGradientAnimFrames() {
|
|
25
|
+
const frames = [];
|
|
26
|
+
for (let start = 0; start < gradientColors.length * 2; start++) {
|
|
27
|
+
const end = start + gradientColors.length - 1;
|
|
28
|
+
frames.push(referenceGradient.slice(start, end).map((g) => chalk.bgHex(g)(" ")).join(""));
|
|
29
|
+
}
|
|
30
|
+
return frames;
|
|
31
|
+
}
|
|
32
|
+
function getIntroAnimFrames() {
|
|
33
|
+
const frames = [];
|
|
34
|
+
for (let end = 1; end <= gradientColors.length; end++) {
|
|
35
|
+
const leadingSpacesArr = Array.from(new Array(Math.abs(gradientColors.length - end - 1)), () => " ");
|
|
36
|
+
const gradientArr = gradientColors.slice(0, end).map((g) => chalk.bgHex(g)(" "));
|
|
37
|
+
frames.push([...leadingSpacesArr, ...gradientArr].join(""));
|
|
38
|
+
}
|
|
39
|
+
return frames;
|
|
40
|
+
}
|
|
41
|
+
async function loadWithRocketGradient(text) {
|
|
42
|
+
const frames = getIntroAnimFrames();
|
|
43
|
+
const intro = ora({
|
|
44
|
+
spinner: {
|
|
45
|
+
interval: 30,
|
|
46
|
+
frames
|
|
47
|
+
},
|
|
48
|
+
text: `${rocketAscii} ${text}`
|
|
49
|
+
});
|
|
50
|
+
intro.start();
|
|
51
|
+
await sleep((frames.length - 1) * intro.interval);
|
|
52
|
+
intro.stop();
|
|
53
|
+
const spinner = ora({
|
|
54
|
+
spinner: {
|
|
55
|
+
interval: 80,
|
|
56
|
+
frames: getGradientAnimFrames()
|
|
57
|
+
},
|
|
58
|
+
text: `${rocketAscii} ${text}`
|
|
59
|
+
}).start();
|
|
60
|
+
return spinner;
|
|
61
|
+
}
|
|
62
|
+
export {
|
|
63
|
+
loadWithRocketGradient,
|
|
64
|
+
rocketAscii
|
|
65
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import ora from "ora";
|
|
|
8
8
|
import { TEMPLATES } from "./templates.js";
|
|
9
9
|
import { logger, defaultLogLevel } from "./logger.js";
|
|
10
10
|
import { execa, execaCommand } from "execa";
|
|
11
|
+
import { loadWithRocketGradient, rocketAscii } from "./gradient.js";
|
|
11
12
|
const cleanArgv = process.argv.filter((arg) => arg !== "--");
|
|
12
13
|
const args = yargs(cleanArgv);
|
|
13
14
|
prompts.override(args);
|
|
@@ -30,8 +31,6 @@ async function main() {
|
|
|
30
31
|
logger.debug("Verbose logging turned on");
|
|
31
32
|
console.log(`
|
|
32
33
|
${bold("Welcome to Astro!")} ${gray(`(create-astro v${version})`)}`);
|
|
33
|
-
let spinner = ora({ color: "green", text: "Prepare for liftoff." });
|
|
34
|
-
spinner.succeed();
|
|
35
34
|
let cwd = args["_"][2];
|
|
36
35
|
if (cwd && isEmpty(cwd)) {
|
|
37
36
|
let acknowledgeProjectDir = ora({
|
|
@@ -74,6 +73,7 @@ ${bold("Welcome to Astro!")} ${gray(`(create-astro v${version})`)}`);
|
|
|
74
73
|
if (!options.template) {
|
|
75
74
|
process.exit(1);
|
|
76
75
|
}
|
|
76
|
+
const templateSpinner = await loadWithRocketGradient("Copying project files...");
|
|
77
77
|
const hash = args.commit ? `#${args.commit}` : "";
|
|
78
78
|
const templateTarget = `withastro/astro/examples/${options.template}#latest`;
|
|
79
79
|
const emitter = degit(`${templateTarget}${hash}`, {
|
|
@@ -86,7 +86,6 @@ ${bold("Welcome to Astro!")} ${gray(`(create-astro v${version})`)}`);
|
|
|
86
86
|
force: true,
|
|
87
87
|
verbose: defaultLogLevel === "debug" ? true : false
|
|
88
88
|
});
|
|
89
|
-
spinner = ora({ color: "green", text: "Copying project files..." }).start();
|
|
90
89
|
if (!args.dryrun) {
|
|
91
90
|
try {
|
|
92
91
|
emitter.on("info", (info) => {
|
|
@@ -104,7 +103,7 @@ ${bold("Welcome to Astro!")} ${gray(`(create-astro v${version})`)}`);
|
|
|
104
103
|
console.log(yellow("This seems to be an issue with degit. Please check if you have 'git' installed on your system, and install it if you don't have (https://git-scm.com)."));
|
|
105
104
|
console.log(yellow("If you do have 'git' installed, please run this command with the --verbose flag and file a new issue with the command output here: https://github.com/withastro/astro/issues"));
|
|
106
105
|
}
|
|
107
|
-
|
|
106
|
+
templateSpinner.fail();
|
|
108
107
|
process.exit(1);
|
|
109
108
|
}
|
|
110
109
|
await Promise.all(FILES_TO_REMOVE.map(async (file) => {
|
|
@@ -114,8 +113,8 @@ ${bold("Welcome to Astro!")} ${gray(`(create-astro v${version})`)}`);
|
|
|
114
113
|
}
|
|
115
114
|
}));
|
|
116
115
|
}
|
|
117
|
-
|
|
118
|
-
|
|
116
|
+
templateSpinner.text = green("Template copied!");
|
|
117
|
+
templateSpinner.succeed();
|
|
119
118
|
const installResponse = await prompts({
|
|
120
119
|
type: "confirm",
|
|
121
120
|
name: "install",
|
|
@@ -128,17 +127,18 @@ ${bold("Welcome to Astro!")} ${gray(`(create-astro v${version})`)}`);
|
|
|
128
127
|
if (installResponse.install && !args.dryrun) {
|
|
129
128
|
const installExec = execa(pkgManager, ["install"], { cwd });
|
|
130
129
|
const installingPackagesMsg = `Installing packages${emojiWithFallback(" \u{1F4E6}", "...")}`;
|
|
131
|
-
|
|
130
|
+
const installSpinner = await loadWithRocketGradient(installingPackagesMsg);
|
|
132
131
|
await new Promise((resolve, reject) => {
|
|
133
132
|
var _a;
|
|
134
133
|
(_a = installExec.stdout) == null ? void 0 : _a.on("data", function(data) {
|
|
135
|
-
|
|
134
|
+
installSpinner.text = `${rocketAscii} ${installingPackagesMsg}
|
|
136
135
|
${bold(`[${pkgManager}]`)} ${data}`;
|
|
137
136
|
});
|
|
138
137
|
installExec.on("error", (error) => reject(error));
|
|
139
138
|
installExec.on("close", () => resolve());
|
|
140
139
|
});
|
|
141
|
-
|
|
140
|
+
installSpinner.text = green("Packages installed!");
|
|
141
|
+
installSpinner.succeed();
|
|
142
142
|
}
|
|
143
143
|
const astroAddCommand = installResponse.install ? "astro add --yes" : `${pkgManagerExecCommand(pkgManager)} astro@latest add --yes`;
|
|
144
144
|
const astroAddResponse = await prompts({
|
|
@@ -168,23 +168,19 @@ ${bold(`[${pkgManager}]`)} ${data}`;
|
|
|
168
168
|
if (gitResponse.git && !args.dryrun) {
|
|
169
169
|
await execaCommand("git init", { cwd });
|
|
170
170
|
}
|
|
171
|
+
ora({ text: green("Done. Ready for liftoff!") }).succeed();
|
|
171
172
|
console.log(`
|
|
172
173
|
${bgCyan(black(" Next steps "))}
|
|
173
174
|
`);
|
|
174
|
-
const
|
|
175
|
-
const
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}
|
|
175
|
+
const projectDir = path.relative(process.cwd(), cwd);
|
|
176
|
+
const devCmd = pkgManager === "npm" ? "npm run dev" : `${pkgManager} dev`;
|
|
177
|
+
console.log(`You can now ${bold(cyan("cd"))} into the ${bold(cyan(projectDir))} project directory.`);
|
|
178
|
+
console.log(`Run ${bold(cyan(devCmd))} to start the Astro dev server. ${bold(cyan("CTRL-C"))} to close.`);
|
|
179
179
|
if (!installResponse.install) {
|
|
180
|
-
|
|
180
|
+
console.log(yellow(`Remember to install dependencies first!`));
|
|
181
181
|
}
|
|
182
|
-
startCommand.push(bold(cyan(pkgManager === "npm" ? "npm run dev" : `${pkgManager} dev`)));
|
|
183
|
-
console.log(startCommand.join(" && "));
|
|
184
182
|
console.log(`
|
|
185
|
-
|
|
186
|
-
console.log(`Stuck? Visit us at ${cyan("https://astro.build/chat")}
|
|
187
|
-
`);
|
|
183
|
+
Stuck? Come join us at ${bold(cyan("https://astro.build/chat"))}`);
|
|
188
184
|
}
|
|
189
185
|
function emojiWithFallback(char, fallback) {
|
|
190
186
|
return process.platform !== "win32" ? char : fallback;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Ora } from 'ora';
|
|
2
|
+
export declare const rocketAscii = "\u25A0\u25A0\u25B6";
|
|
3
|
+
/**
|
|
4
|
+
* Generate loading spinner with rocket flames!
|
|
5
|
+
* @param text display text next to rocket
|
|
6
|
+
* @returns Ora spinner for running .stop()
|
|
7
|
+
*/
|
|
8
|
+
export declare function loadWithRocketGradient(text: string): Promise<Ora>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-astro",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "withastro",
|
|
6
6
|
"license": "MIT",
|
|
@@ -17,12 +17,6 @@
|
|
|
17
17
|
"bin": {
|
|
18
18
|
"create-astro": "./create-astro.mjs"
|
|
19
19
|
},
|
|
20
|
-
"scripts": {
|
|
21
|
-
"build": "astro-scripts build \"src/**/*.ts\" && tsc",
|
|
22
|
-
"build:ci": "astro-scripts build \"src/**/*.ts\"",
|
|
23
|
-
"dev": "astro-scripts dev \"src/**/*.ts\"",
|
|
24
|
-
"test": "mocha --exit --timeout 20000"
|
|
25
|
-
},
|
|
26
20
|
"files": [
|
|
27
21
|
"dist",
|
|
28
22
|
"create-astro.js"
|
|
@@ -30,6 +24,7 @@
|
|
|
30
24
|
"dependencies": {
|
|
31
25
|
"@types/degit": "^2.8.3",
|
|
32
26
|
"@types/prompts": "^2.0.14",
|
|
27
|
+
"chalk": "^5.0.1",
|
|
33
28
|
"degit": "^2.8.4",
|
|
34
29
|
"execa": "^6.1.0",
|
|
35
30
|
"kleur": "^4.1.4",
|
|
@@ -41,12 +36,18 @@
|
|
|
41
36
|
"@types/chai": "^4.3.1",
|
|
42
37
|
"@types/mocha": "^9.1.1",
|
|
43
38
|
"@types/yargs-parser": "^21.0.0",
|
|
44
|
-
"astro-scripts": "
|
|
39
|
+
"astro-scripts": "0.0.3",
|
|
45
40
|
"chai": "^4.3.6",
|
|
46
41
|
"mocha": "^9.2.2",
|
|
47
42
|
"uvu": "^0.5.3"
|
|
48
43
|
},
|
|
49
44
|
"engines": {
|
|
50
45
|
"node": "^14.15.0 || >=16.0.0"
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"build": "astro-scripts build \"src/**/*.ts\" && tsc",
|
|
49
|
+
"build:ci": "astro-scripts build \"src/**/*.ts\"",
|
|
50
|
+
"dev": "astro-scripts dev \"src/**/*.ts\"",
|
|
51
|
+
"test": "mocha --exit --timeout 20000"
|
|
51
52
|
}
|
|
52
|
-
}
|
|
53
|
+
}
|