create-astro 2.0.2 → 3.0.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-astro",
3
- "version": "2.0.2",
3
+ "version": "3.0.0",
4
4
  "type": "module",
5
5
  "author": "withastro",
6
6
  "license": "MIT",
@@ -14,46 +14,38 @@
14
14
  "exports": {
15
15
  ".": "./create-astro.mjs"
16
16
  },
17
+ "main": "./create-astro.mjs",
17
18
  "bin": {
18
19
  "create-astro": "./create-astro.mjs"
19
20
  },
20
21
  "files": [
21
22
  "dist",
22
- "create-astro.js",
23
- "tsconfigs"
23
+ "create-astro.js"
24
24
  ],
25
+ "//a": "MOST PACKAGES SHOULD GO IN DEV_DEPENDENCIES! THEY WILL BE BUNDLED.",
26
+ "//b": "DEPENDENCIES IS FOR UNBUNDLED PACKAGES",
25
27
  "dependencies": {
26
- "@astrojs/cli-kit": "^0.1.6",
27
- "chalk": "^5.0.1",
28
- "comment-json": "^4.2.3",
28
+ "@astrojs/cli-kit": "^0.2.2",
29
+ "chai": "^4.3.6",
29
30
  "execa": "^6.1.0",
30
31
  "giget": "^1.0.0",
31
- "kleur": "^4.1.4",
32
- "ora": "^6.1.0",
33
- "prompts": "^2.4.2",
34
- "strip-ansi": "^7.0.1",
35
- "which-pm-runs": "^1.1.0",
36
- "yargs-parser": "^21.0.1"
32
+ "mocha": "^9.2.2"
37
33
  },
38
34
  "devDependencies": {
39
- "@types/chai": "^4.3.1",
40
- "@types/degit": "^2.8.3",
41
- "@types/mocha": "^9.1.1",
42
- "@types/prompts": "^2.0.14",
43
35
  "@types/which-pm-runs": "^1.0.0",
44
- "@types/yargs-parser": "^21.0.0",
36
+ "arg": "^5.0.2",
45
37
  "astro-scripts": "0.0.10",
46
- "chai": "^4.3.6",
47
- "mocha": "^9.2.2",
48
- "uvu": "^0.5.3"
38
+ "strip-ansi": "^7.0.1",
39
+ "strip-json-comments": "^5.0.0",
40
+ "which-pm-runs": "^1.1.0"
49
41
  },
50
42
  "engines": {
51
43
  "node": ">=16.12.0"
52
44
  },
53
45
  "scripts": {
54
- "build": "astro-scripts build \"src/**/*.ts\" && tsc",
55
- "build:ci": "astro-scripts build \"src/**/*.ts\"",
46
+ "build": "astro-scripts build \"src/index.ts\" --bundle && tsc",
47
+ "build:ci": "astro-scripts build \"src/index.ts\" --bundle",
56
48
  "dev": "astro-scripts dev \"src/**/*.ts\"",
57
- "test": "mocha --exit --timeout 20000"
49
+ "test": "mocha --exit --timeout 20000 --parallel"
58
50
  }
59
51
  }
package/dist/gradient.js DELETED
@@ -1,70 +0,0 @@
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(
29
- referenceGradient.slice(start, end).map((g) => chalk.bgHex(g)(" ")).join("")
30
- );
31
- }
32
- return frames;
33
- }
34
- function getIntroAnimFrames() {
35
- const frames = [];
36
- for (let end = 1; end <= gradientColors.length; end++) {
37
- const leadingSpacesArr = Array.from(
38
- new Array(Math.abs(gradientColors.length - end - 1)),
39
- () => " "
40
- );
41
- const gradientArr = gradientColors.slice(0, end).map((g) => chalk.bgHex(g)(" "));
42
- frames.push([...leadingSpacesArr, ...gradientArr].join(""));
43
- }
44
- return frames;
45
- }
46
- async function loadWithRocketGradient(text) {
47
- const frames = getIntroAnimFrames();
48
- const intro = ora({
49
- spinner: {
50
- interval: 30,
51
- frames
52
- },
53
- text: `${rocketAscii} ${text}`
54
- });
55
- intro.start();
56
- await sleep((frames.length - 1) * intro.interval);
57
- intro.stop();
58
- const spinner = ora({
59
- spinner: {
60
- interval: 80,
61
- frames: getGradientAnimFrames()
62
- },
63
- text: `${rocketAscii} ${text}`
64
- }).start();
65
- return spinner;
66
- }
67
- export {
68
- loadWithRocketGradient,
69
- rocketAscii
70
- };
package/dist/logger.js DELETED
@@ -1,98 +0,0 @@
1
- import { blue, bold, dim, red, yellow } from "kleur/colors";
2
- import { Writable } from "stream";
3
- import { format as utilFormat } from "util";
4
- const dt = new Intl.DateTimeFormat([], {
5
- hour: "2-digit",
6
- minute: "2-digit",
7
- second: "2-digit"
8
- });
9
- const defaultLogDestination = new Writable({
10
- objectMode: true,
11
- write(event, _, callback) {
12
- let dest = process.stderr;
13
- if (levels[event.level] < levels["error"])
14
- dest = process.stdout;
15
- dest.write(dim(dt.format(new Date()) + " "));
16
- let type = event.type;
17
- if (type) {
18
- switch (event.level) {
19
- case "info":
20
- type = bold(blue(type));
21
- break;
22
- case "warn":
23
- type = bold(yellow(type));
24
- break;
25
- case "error":
26
- type = bold(red(type));
27
- break;
28
- }
29
- dest.write(`[${type}] `);
30
- }
31
- dest.write(utilFormat(...event.args));
32
- dest.write("\n");
33
- callback();
34
- }
35
- });
36
- let defaultLogLevel;
37
- if (process.argv.includes("--verbose")) {
38
- defaultLogLevel = "debug";
39
- } else if (process.argv.includes("--silent")) {
40
- defaultLogLevel = "silent";
41
- } else {
42
- defaultLogLevel = "info";
43
- }
44
- const defaultLogOptions = {
45
- dest: defaultLogDestination,
46
- level: defaultLogLevel
47
- };
48
- const levels = {
49
- debug: 20,
50
- info: 30,
51
- warn: 40,
52
- error: 50,
53
- silent: 90
54
- };
55
- function log(opts = {}, level, type, ...args) {
56
- const logLevel = opts.level ?? defaultLogOptions.level;
57
- const dest = opts.dest ?? defaultLogOptions.dest;
58
- const event = {
59
- type,
60
- level,
61
- args,
62
- message: ""
63
- };
64
- if (levels[logLevel] > levels[level]) {
65
- return;
66
- }
67
- dest.write(event);
68
- }
69
- function debug(opts, type, ...messages) {
70
- return log(opts, "debug", type, ...messages);
71
- }
72
- function info(opts, type, ...messages) {
73
- return log(opts, "info", type, ...messages);
74
- }
75
- function warn(opts, type, ...messages) {
76
- return log(opts, "warn", type, ...messages);
77
- }
78
- function error(opts, type, ...messages) {
79
- return log(opts, "error", type, ...messages);
80
- }
81
- const logger = {
82
- debug: debug.bind(null, defaultLogOptions, "debug"),
83
- info: info.bind(null, defaultLogOptions, "info"),
84
- warn: warn.bind(null, defaultLogOptions, "warn"),
85
- error: error.bind(null, defaultLogOptions, "error")
86
- };
87
- export {
88
- debug,
89
- defaultLogDestination,
90
- defaultLogLevel,
91
- defaultLogOptions,
92
- error,
93
- info,
94
- levels,
95
- log,
96
- logger,
97
- warn
98
- };
package/dist/messages.js DELETED
@@ -1,134 +0,0 @@
1
- import { color, label } from "@astrojs/cli-kit";
2
- import { sleep } from "@astrojs/cli-kit/utils";
3
- import { exec } from "node:child_process";
4
- import { get } from "node:https";
5
- import stripAnsi from "strip-ansi";
6
- const welcome = [
7
- `Let's claim your corner of the internet.`,
8
- `I'll be your assistant today.`,
9
- `Let's build something awesome!`,
10
- `Let's build something great!`,
11
- `Let's build something fast!`,
12
- `Let's make the web weird!`,
13
- `Let's make the web a better place!`,
14
- `Let's create a new project!`,
15
- `Let's create something unique!`,
16
- `Time to build a new website.`,
17
- `Time to build a faster website.`,
18
- `Time to build a sweet new website.`,
19
- `We're glad to have you on board.`,
20
- `Keeping the internet weird since 2021.`,
21
- `Initiating launch sequence...`,
22
- `Initiating launch sequence... right... now!`,
23
- `Awaiting further instructions.`
24
- ];
25
- function getName() {
26
- return new Promise((resolve) => {
27
- exec("git config user.name", { encoding: "utf-8" }, (_1, gitName, _2) => {
28
- if (gitName.trim()) {
29
- return resolve(gitName.split(" ")[0].trim());
30
- }
31
- exec("whoami", { encoding: "utf-8" }, (_3, whoami, _4) => {
32
- if (whoami.trim()) {
33
- return resolve(whoami.split(" ")[0].trim());
34
- }
35
- return resolve("astronaut");
36
- });
37
- });
38
- });
39
- }
40
- let v;
41
- function getVersion() {
42
- return new Promise((resolve) => {
43
- if (v)
44
- return resolve(v);
45
- get("https://registry.npmjs.org/astro/latest", (res) => {
46
- let body = "";
47
- res.on("data", (chunk) => body += chunk);
48
- res.on("end", () => {
49
- const { version } = JSON.parse(body);
50
- v = version;
51
- resolve(version);
52
- });
53
- });
54
- });
55
- }
56
- async function banner(version) {
57
- return console.log(
58
- `
59
- ${label("astro", color.bgGreen, color.black)} ${color.green(
60
- color.bold(`v${version}`)
61
- )} ${color.bold("Launch sequence initiated.")}
62
- `
63
- );
64
- }
65
- async function info(prefix, text) {
66
- await sleep(100);
67
- if (process.stdout.columns < 80) {
68
- console.log(`${color.cyan("\u25FC")} ${color.cyan(prefix)}`);
69
- console.log(`${" ".repeat(3)}${color.dim(text)}
70
- `);
71
- } else {
72
- console.log(`${color.cyan("\u25FC")} ${color.cyan(prefix)} ${color.dim(text)}
73
- `);
74
- }
75
- }
76
- async function error(prefix, text) {
77
- if (process.stdout.columns < 80) {
78
- console.log(`${" ".repeat(5)} ${color.red("\u25B2")} ${color.red(prefix)}`);
79
- console.log(`${" ".repeat(9)}${color.dim(text)}`);
80
- } else {
81
- console.log(`${" ".repeat(5)} ${color.red("\u25B2")} ${color.red(prefix)} ${color.dim(text)}`);
82
- }
83
- }
84
- async function typescriptByDefault() {
85
- await info(`Cool!`, "Astro comes with TypeScript support enabled by default.");
86
- console.log(
87
- `${" ".repeat(3)}${color.dim(`We'll default to the most relaxed settings for you.`)}`
88
- );
89
- await sleep(300);
90
- }
91
- async function nextSteps({ projectDir, devCmd }) {
92
- const max = process.stdout.columns;
93
- const prefix = max < 80 ? " " : " ".repeat(9);
94
- await sleep(200);
95
- console.log(
96
- `
97
- ${color.bgCyan(` ${color.black("next")} `)} ${color.bold(
98
- "Liftoff confirmed. Explore your project!"
99
- )}`
100
- );
101
- await sleep(100);
102
- if (projectDir !== "") {
103
- const enter = [
104
- `
105
- ${prefix}Enter your project directory using`,
106
- color.cyan(`cd ./${projectDir}`, "")
107
- ];
108
- const len = enter[0].length + stripAnsi(enter[1]).length;
109
- console.log(enter.join(len > max ? "\n" + prefix : " "));
110
- }
111
- console.log(
112
- `${prefix}Run ${color.cyan(devCmd)} to start the dev server. ${color.cyan("CTRL+C")} to stop.`
113
- );
114
- await sleep(100);
115
- console.log(
116
- `${prefix}Add frameworks like ${color.cyan(`react`)} or ${color.cyan(
117
- "tailwind"
118
- )} using ${color.cyan("astro add")}.`
119
- );
120
- await sleep(100);
121
- console.log(`
122
- ${prefix}Stuck? Join us at ${color.cyan(`https://astro.build/chat`)}`);
123
- await sleep(200);
124
- }
125
- export {
126
- banner,
127
- error,
128
- getName,
129
- getVersion,
130
- info,
131
- nextSteps,
132
- typescriptByDefault,
133
- welcome
134
- };
package/dist/templates.js DELETED
@@ -1,8 +0,0 @@
1
- const TEMPLATES = [
2
- { value: "basics", title: "a few best practices (recommended)" },
3
- { value: "blog", title: "a personal website starter kit" },
4
- { value: "minimal", title: "an empty project" }
5
- ];
6
- export {
7
- TEMPLATES
8
- };
@@ -1,8 +0,0 @@
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>;
@@ -1,2 +0,0 @@
1
- export declare function mkdirp(dir: string): void;
2
- export declare function main(): Promise<void>;
@@ -1,38 +0,0 @@
1
- /// <reference types="node" />
2
- import { Writable } from 'stream';
3
- export declare const defaultLogDestination: Writable;
4
- interface LogWritable<T> extends Writable {
5
- write: (chunk: T) => boolean;
6
- }
7
- export declare type LoggerLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent';
8
- export declare type LoggerEvent = 'debug' | 'info' | 'warn' | 'error';
9
- export declare let defaultLogLevel: LoggerLevel;
10
- export interface LogOptions {
11
- dest?: LogWritable<LogMessage>;
12
- level?: LoggerLevel;
13
- }
14
- export declare const defaultLogOptions: Required<LogOptions>;
15
- export interface LogMessage {
16
- type: string | null;
17
- level: LoggerLevel;
18
- message: string;
19
- args: Array<any>;
20
- }
21
- export declare const levels: Record<LoggerLevel, number>;
22
- /** Full logging API */
23
- export declare function log(opts: LogOptions | undefined, level: LoggerLevel, type: string | null, ...args: Array<any>): void;
24
- /** Emit a message only shown in debug mode */
25
- export declare function debug(opts: LogOptions, type: string | null, ...messages: Array<any>): void;
26
- /** Emit a general info message (be careful using this too much!) */
27
- export declare function info(opts: LogOptions, type: string | null, ...messages: Array<any>): void;
28
- /** Emit a warning a user should be aware of */
29
- export declare function warn(opts: LogOptions, type: string | null, ...messages: Array<any>): void;
30
- /** Emit a fatal error message the user should address. */
31
- export declare function error(opts: LogOptions, type: string | null, ...messages: Array<any>): void;
32
- export declare const logger: {
33
- debug: (...args: any[]) => void;
34
- info: (...args: any[]) => void;
35
- warn: (...args: any[]) => void;
36
- error: (...args: any[]) => void;
37
- };
38
- export {};
@@ -1,11 +0,0 @@
1
- export declare const welcome: string[];
2
- export declare function getName(): Promise<unknown>;
3
- export declare function getVersion(): Promise<string>;
4
- export declare function banner(version: string): Promise<void>;
5
- export declare function info(prefix: string, text: string): Promise<void>;
6
- export declare function error(prefix: string, text: string): Promise<void>;
7
- export declare function typescriptByDefault(): Promise<void>;
8
- export declare function nextSteps({ projectDir, devCmd }: {
9
- projectDir: string;
10
- devCmd: string;
11
- }): Promise<void>;
@@ -1,4 +0,0 @@
1
- export declare const TEMPLATES: {
2
- value: string;
3
- title: string;
4
- }[];