create-astro 0.10.1 → 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 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
+ """
@@ -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
@@ -1,32 +1,14 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
- var __hasOwnProp = Object.prototype.hasOwnProperty;
4
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __spreadValues = (a, b) => {
7
- for (var prop in b || (b = {}))
8
- if (__hasOwnProp.call(b, prop))
9
- __defNormalProp(a, prop, b[prop]);
10
- if (__getOwnPropSymbols)
11
- for (var prop of __getOwnPropSymbols(b)) {
12
- if (__propIsEnum.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- }
15
- return a;
16
- };
17
1
  import fs from "fs";
18
2
  import path from "path";
19
- import { bold, cyan, gray, green, red, yellow } from "kleur/colors";
20
- import fetch from "node-fetch";
3
+ import { bgCyan, black, bold, cyan, gray, green, red, yellow } from "kleur/colors";
21
4
  import prompts from "prompts";
22
5
  import degit from "degit";
23
6
  import yargs from "yargs-parser";
24
7
  import ora from "ora";
25
- import { FRAMEWORKS, COUNTER_COMPONENTS } from "./frameworks.js";
26
8
  import { TEMPLATES } from "./templates.js";
27
- import { createConfig } from "./config.js";
28
9
  import { logger, defaultLogLevel } from "./logger.js";
29
- import { execa } from "execa";
10
+ import { execa, execaCommand } from "execa";
11
+ import { loadWithRocketGradient, rocketAscii } from "./gradient.js";
30
12
  const cleanArgv = process.argv.filter((arg) => arg !== "--");
31
13
  const args = yargs(cleanArgv);
32
14
  prompts.override(args);
@@ -43,15 +25,12 @@ function isEmpty(dirPath) {
43
25
  return !fs.existsSync(dirPath) || fs.readdirSync(dirPath).length === 0;
44
26
  }
45
27
  const { version } = JSON.parse(fs.readFileSync(new URL("../package.json", import.meta.url), "utf-8"));
46
- const FILES_TO_REMOVE = [".stackblitzrc", "sandbox.config.json"];
47
- const POSTPROCESS_FILES = ["package.json", "astro.config.mjs", "CHANGELOG.md"];
28
+ const FILES_TO_REMOVE = [".stackblitzrc", "sandbox.config.json", "CHANGELOG.md"];
48
29
  async function main() {
49
30
  const pkgManager = pkgManagerFromUserAgent(process.env.npm_config_user_agent);
50
31
  logger.debug("Verbose logging turned on");
51
32
  console.log(`
52
33
  ${bold("Welcome to Astro!")} ${gray(`(create-astro v${version})`)}`);
53
- let spinner = ora({ color: "green", text: "Prepare for liftoff." });
54
- spinner.succeed();
55
34
  let cwd = args["_"][2];
56
35
  if (cwd && isEmpty(cwd)) {
57
36
  let acknowledgeProjectDir = ora({
@@ -94,8 +73,9 @@ ${bold("Welcome to Astro!")} ${gray(`(create-astro v${version})`)}`);
94
73
  if (!options.template) {
95
74
  process.exit(1);
96
75
  }
76
+ const templateSpinner = await loadWithRocketGradient("Copying project files...");
97
77
  const hash = args.commit ? `#${args.commit}` : "";
98
- const templateTarget = options.template.includes("/") ? options.template : `withastro/astro/examples/${options.template}#latest`;
78
+ const templateTarget = `withastro/astro/examples/${options.template}#latest`;
99
79
  const emitter = degit(`${templateTarget}${hash}`, {
100
80
  cache: false,
101
81
  force: true,
@@ -106,20 +86,6 @@ ${bold("Welcome to Astro!")} ${gray(`(create-astro v${version})`)}`);
106
86
  force: true,
107
87
  verbose: defaultLogLevel === "debug" ? true : false
108
88
  });
109
- const selectedTemplate = TEMPLATES.find((template) => template.value === options.template);
110
- let integrations = [];
111
- if ((selectedTemplate == null ? void 0 : selectedTemplate.integrations) === true) {
112
- const result = await prompts([
113
- {
114
- type: "multiselect",
115
- name: "integrations",
116
- message: "Which frameworks would you like to use?",
117
- choices: FRAMEWORKS
118
- }
119
- ]);
120
- integrations = result.integrations;
121
- }
122
- spinner = ora({ color: "green", text: "Copying project files..." }).start();
123
89
  if (!args.dryrun) {
124
90
  try {
125
91
  emitter.on("info", (info) => {
@@ -137,73 +103,18 @@ ${bold("Welcome to Astro!")} ${gray(`(create-astro v${version})`)}`);
137
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)."));
138
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"));
139
105
  }
140
- spinner.fail();
106
+ templateSpinner.fail();
141
107
  process.exit(1);
142
108
  }
143
- await Promise.all([
144
- ...FILES_TO_REMOVE.map(async (file) => {
145
- const fileLoc = path.resolve(path.join(cwd, file));
146
- return fs.promises.rm(fileLoc);
147
- }),
148
- ...POSTPROCESS_FILES.map(async (file) => {
149
- const fileLoc = path.resolve(path.join(cwd, file));
150
- switch (file) {
151
- case "CHANGELOG.md": {
152
- if (fs.existsSync(fileLoc)) {
153
- await fs.promises.unlink(fileLoc);
154
- }
155
- break;
156
- }
157
- case "astro.config.mjs": {
158
- if ((selectedTemplate == null ? void 0 : selectedTemplate.integrations) !== true) {
159
- break;
160
- }
161
- await fs.promises.writeFile(fileLoc, createConfig({ integrations }));
162
- break;
163
- }
164
- case "package.json": {
165
- const packageJSON = JSON.parse(await fs.promises.readFile(fileLoc, "utf8"));
166
- delete packageJSON.snowpack;
167
- const integrationEntries = (await Promise.all(integrations.map((integration) => fetch(`https://registry.npmjs.org/${integration.packageName}/latest`).then((res) => res.json()).then((res) => {
168
- let dependencies = [[res["name"], `^${res["version"]}`]];
169
- if (res["peerDependencies"]) {
170
- for (const peer in res["peerDependencies"]) {
171
- dependencies.push([peer, res["peerDependencies"][peer]]);
172
- }
173
- }
174
- return dependencies;
175
- })))).flat(1);
176
- packageJSON.devDependencies = __spreadValues(__spreadValues({}, packageJSON.devDependencies ?? {}), Object.fromEntries(integrationEntries));
177
- packageJSON.devDependencies = Object.fromEntries(Object.entries(packageJSON.devDependencies).sort((a, b) => a[0].localeCompare(b[0])));
178
- await fs.promises.writeFile(fileLoc, JSON.stringify(packageJSON, void 0, 2));
179
- break;
180
- }
181
- }
182
- })
183
- ]);
184
- if ((selectedTemplate == null ? void 0 : selectedTemplate.value) === "starter") {
185
- let importStatements = [];
186
- let components = [];
187
- await Promise.all(integrations.map(async (integration) => {
188
- const component = COUNTER_COMPONENTS[integration.id];
189
- const componentName = path.basename(component.filename, path.extname(component.filename));
190
- const absFileLoc = path.resolve(cwd, component.filename);
191
- importStatements.push(`import ${componentName} from '${component.filename.replace(/^src/, "..")}';`);
192
- components.push(`<${componentName} client:visible />`);
193
- await fs.promises.writeFile(absFileLoc, component.content);
194
- }));
195
- const pageFileLoc = path.resolve(path.join(cwd, "src", "pages", "index.astro"));
196
- const content = (await fs.promises.readFile(pageFileLoc)).toString();
197
- const newContent = content.replace(/^(\s*)\/\* ASTRO\:COMPONENT_IMPORTS \*\//gm, (_, indent) => {
198
- return indent + importStatements.join("\n");
199
- }).replace(/^(\s*)<!-- ASTRO:COMPONENT_MARKUP -->/gm, (_, indent) => {
200
- return components.map((ln) => indent + ln).join("\n");
201
- });
202
- await fs.promises.writeFile(pageFileLoc, newContent);
203
- }
109
+ await Promise.all(FILES_TO_REMOVE.map(async (file) => {
110
+ const fileLoc = path.resolve(path.join(cwd, file));
111
+ if (fs.existsSync(fileLoc)) {
112
+ return fs.promises.rm(fileLoc, {});
113
+ }
114
+ }));
204
115
  }
205
- spinner.succeed();
206
- console.log(bold(green("\u2714") + " Done!"));
116
+ templateSpinner.text = green("Template copied!");
117
+ templateSpinner.succeed();
207
118
  const installResponse = await prompts({
208
119
  type: "confirm",
209
120
  name: "install",
@@ -213,40 +124,63 @@ ${bold("Welcome to Astro!")} ${gray(`(create-astro v${version})`)}`);
213
124
  if (!installResponse) {
214
125
  process.exit(0);
215
126
  }
216
- if (installResponse.install) {
127
+ if (installResponse.install && !args.dryrun) {
217
128
  const installExec = execa(pkgManager, ["install"], { cwd });
218
129
  const installingPackagesMsg = `Installing packages${emojiWithFallback(" \u{1F4E6}", "...")}`;
219
- spinner = ora({ color: "green", text: installingPackagesMsg }).start();
220
- if (!args.dryrun) {
221
- await new Promise((resolve, reject) => {
222
- var _a;
223
- (_a = installExec.stdout) == null ? void 0 : _a.on("data", function(data) {
224
- spinner.text = `${installingPackagesMsg}
130
+ const installSpinner = await loadWithRocketGradient(installingPackagesMsg);
131
+ await new Promise((resolve, reject) => {
132
+ var _a;
133
+ (_a = installExec.stdout) == null ? void 0 : _a.on("data", function(data) {
134
+ installSpinner.text = `${rocketAscii} ${installingPackagesMsg}
225
135
  ${bold(`[${pkgManager}]`)} ${data}`;
226
- });
227
- installExec.on("error", (error) => reject(error));
228
- installExec.on("close", () => resolve());
229
136
  });
230
- }
231
- spinner.succeed();
137
+ installExec.on("error", (error) => reject(error));
138
+ installExec.on("close", () => resolve());
139
+ });
140
+ installSpinner.text = green("Packages installed!");
141
+ installSpinner.succeed();
142
+ }
143
+ const astroAddCommand = installResponse.install ? "astro add --yes" : `${pkgManagerExecCommand(pkgManager)} astro@latest add --yes`;
144
+ const astroAddResponse = await prompts({
145
+ type: "confirm",
146
+ name: "astroAdd",
147
+ message: `Run "${astroAddCommand}?" This lets you optionally add component frameworks (ex. React), CSS frameworks (ex. Tailwind), and more.`,
148
+ initial: true
149
+ });
150
+ if (!astroAddResponse) {
151
+ process.exit(0);
232
152
  }
233
- console.log("\nNext steps:");
234
- let i = 1;
235
- const relative = path.relative(process.cwd(), cwd);
236
- if (relative !== "") {
237
- console.log(` ${i++}: ${bold(cyan(`cd ${relative}`))}`);
153
+ if (!astroAddResponse.astroAdd) {
154
+ ora().info(`No problem. You can always run "${pkgManagerExecCommand(pkgManager)} astro add" later!`);
238
155
  }
239
- if (!installResponse.install) {
240
- console.log(` ${i++}: ${bold(cyan(`${pkgManager} install`))}`);
156
+ if (astroAddResponse.astroAdd && !args.dryrun) {
157
+ await execaCommand(astroAddCommand, astroAddCommand === "astro add --yes" ? { cwd, stdio: "inherit", localDir: cwd, preferLocal: true } : { cwd, stdio: "inherit" });
241
158
  }
242
- console.log(` ${i++}: ${bold(cyan('git init && git add -A && git commit -m "Initial commit"'))} (optional step)`);
243
- const runCommand = pkgManager === "npm" ? "npm run dev" : `${pkgManager} dev`;
244
- console.log(` ${i++}: ${bold(cyan(runCommand))}`);
245
- console.log(`
246
- To close the dev server, hit ${bold(cyan("Ctrl-C"))}`);
159
+ const gitResponse = await prompts({
160
+ type: "confirm",
161
+ name: "git",
162
+ message: "Initialize a git repository?",
163
+ initial: true
164
+ });
165
+ if (!gitResponse) {
166
+ process.exit(0);
167
+ }
168
+ if (gitResponse.git && !args.dryrun) {
169
+ await execaCommand("git init", { cwd });
170
+ }
171
+ ora({ text: green("Done. Ready for liftoff!") }).succeed();
247
172
  console.log(`
248
- Stuck? Visit us at ${cyan("https://astro.build/chat")}
173
+ ${bgCyan(black(" Next steps "))}
249
174
  `);
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
+ if (!installResponse.install) {
180
+ console.log(yellow(`Remember to install dependencies first!`));
181
+ }
182
+ console.log(`
183
+ Stuck? Come join us at ${bold(cyan("https://astro.build/chat"))}`);
250
184
  }
251
185
  function emojiWithFallback(char, fallback) {
252
186
  return process.platform !== "win32" ? char : fallback;
@@ -258,6 +192,13 @@ function pkgManagerFromUserAgent(userAgent) {
258
192
  const pkgSpecArr = pkgSpec.split("/");
259
193
  return pkgSpecArr[0];
260
194
  }
195
+ function pkgManagerExecCommand(pkgManager) {
196
+ if (pkgManager === "pnpm") {
197
+ return "pnpx";
198
+ } else {
199
+ return "npx";
200
+ }
201
+ }
261
202
  export {
262
203
  main,
263
204
  mkdirp
package/dist/templates.js CHANGED
@@ -1,8 +1,7 @@
1
1
  const TEMPLATES = [
2
2
  {
3
- title: "Starter Kit (Generic)",
4
- value: "starter",
5
- integrations: true
3
+ title: "Just the basics",
4
+ value: "basics"
6
5
  },
7
6
  {
8
7
  title: "Blog",
@@ -17,7 +16,7 @@ const TEMPLATES = [
17
16
  value: "portfolio"
18
17
  },
19
18
  {
20
- title: "Minimal",
19
+ title: "Completely empty",
21
20
  value: "minimal"
22
21
  }
23
22
  ];
@@ -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>;
@@ -1,9 +1,4 @@
1
- export declare const TEMPLATES: ({
1
+ export declare const TEMPLATES: {
2
2
  title: string;
3
3
  value: string;
4
- integrations: boolean;
5
- } | {
6
- title: string;
7
- value: string;
8
- integrations?: undefined;
9
- })[];
4
+ }[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-astro",
3
- "version": "0.10.1",
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,10 +24,10 @@
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",
36
- "node-fetch": "^3.2.3",
37
31
  "ora": "^6.1.0",
38
32
  "prompts": "^2.4.2",
39
33
  "yargs-parser": "^21.0.1"
@@ -42,12 +36,18 @@
42
36
  "@types/chai": "^4.3.1",
43
37
  "@types/mocha": "^9.1.1",
44
38
  "@types/yargs-parser": "^21.0.0",
45
- "astro-scripts": "workspace:*",
39
+ "astro-scripts": "0.0.3",
46
40
  "chai": "^4.3.6",
47
41
  "mocha": "^9.2.2",
48
42
  "uvu": "^0.5.3"
49
43
  },
50
44
  "engines": {
51
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"
52
52
  }
53
- }
53
+ }
package/dist/config.js DELETED
@@ -1,23 +0,0 @@
1
- const createConfig = ({ integrations }) => {
2
- if (integrations.length === 0) {
3
- return `import { defineConfig } from 'astro/config';
4
- // https://astro.build/config
5
- export default defineConfig({});
6
- `;
7
- }
8
- const rendererImports = integrations.map((r) => ` import ${r.id} from '${r.packageName}';`);
9
- const rendererIntegrations = integrations.map((r) => ` ${r.id}(),`);
10
- return [
11
- `import { defineConfig } from 'astro/config';`,
12
- ...rendererImports,
13
- `// https://astro.build/config`,
14
- `export default defineConfig({`,
15
- ` integrations: [`,
16
- ...rendererIntegrations,
17
- ` ]`,
18
- `});`
19
- ].join("\n");
20
- };
21
- export {
22
- createConfig
23
- };
@@ -1,134 +0,0 @@
1
- const COUNTER_COMPONENTS = {
2
- preact: {
3
- filename: `src/components/PreactCounter.jsx`,
4
- content: `import { useState } from 'preact/hooks';
5
-
6
- export default function PreactCounter() {
7
- const [count, setCount] = useState(0);
8
- const add = () => setCount((i) => i + 1);
9
- const subtract = () => setCount((i) => i - 1);
10
-
11
- return (
12
- <div id="preact" class="counter">
13
- <button onClick={subtract}>-</button>
14
- <pre>{count}</pre>
15
- <button onClick={add}>+</button>
16
- </div>
17
- );
18
- }
19
- `
20
- },
21
- react: {
22
- filename: `src/components/ReactCounter.jsx`,
23
- content: `import { useState } from 'react';
24
-
25
- export default function ReactCounter() {
26
- const [count, setCount] = useState(0);
27
- const add = () => setCount((i) => i + 1);
28
- const subtract = () => setCount((i) => i - 1);
29
-
30
- return (
31
- <div id="react" className="counter">
32
- <button onClick={subtract}>-</button>
33
- <pre>{count}</pre>
34
- <button onClick={add}>+</button>
35
- </div>
36
- );
37
- }
38
- `
39
- },
40
- solid: {
41
- filename: `src/components/SolidCounter.jsx`,
42
- content: `import { createSignal } from "solid-js";
43
-
44
- export default function SolidCounter() {
45
- const [count, setCount] = createSignal(0);
46
- const add = () => setCount(count() + 1);
47
- const subtract = () => setCount(count() - 1);
48
-
49
- return (
50
- <div id="solid" class="counter">
51
- <button onClick={subtract}>-</button>
52
- <pre>{count()}</pre>
53
- <button onClick={add}>+</button>
54
- </div>
55
- );
56
- }
57
- `
58
- },
59
- svelte: {
60
- filename: `src/components/SvelteCounter.svelte`,
61
- content: `<script>
62
- let count = 0;
63
-
64
- function add() {
65
- count += 1;
66
- }
67
-
68
- function subtract() {
69
- count -= 1;
70
- }
71
- <\/script>
72
-
73
- <div id="svelte" class="counter">
74
- <button on:click={subtract}>-</button>
75
- <pre>{ count }</pre>
76
- <button on:click={add}>+</button>
77
- </div>
78
- `
79
- },
80
- vue: {
81
- filename: `src/components/VueCounter.vue`,
82
- content: `<template>
83
- <div id="vue" class="counter">
84
- <button @click="subtract()">-</button>
85
- <pre>{{ count }}</pre>
86
- <button @click="add()">+</button>
87
- </div>
88
- </template>
89
-
90
- <script>
91
- import { ref } from 'vue';
92
- export default {
93
- setup() {
94
- const count = ref(0)
95
- const add = () => count.value = count.value + 1;
96
- const subtract = () => count.value = count.value - 1;
97
-
98
- return {
99
- count,
100
- add,
101
- subtract
102
- }
103
- }
104
- }
105
- <\/script>
106
- `
107
- }
108
- };
109
- const FRAMEWORKS = [
110
- {
111
- title: "Preact",
112
- value: { id: "preact", packageName: "@astrojs/preact" }
113
- },
114
- {
115
- title: "React",
116
- value: { id: "react", packageName: "@astrojs/react" }
117
- },
118
- {
119
- title: "Solid.js",
120
- value: { id: "solid", packageName: "@astrojs/solid-js" }
121
- },
122
- {
123
- title: "Svelte",
124
- value: { id: "svelte", packageName: "@astrojs/svelte" }
125
- },
126
- {
127
- title: "Vue",
128
- value: { id: "vue", packageName: "@astrojs/vue" }
129
- }
130
- ];
131
- export {
132
- COUNTER_COMPONENTS,
133
- FRAMEWORKS
134
- };
@@ -1,4 +0,0 @@
1
- import type { Integration } from './frameworks';
2
- export declare const createConfig: ({ integrations }: {
3
- integrations: Integration[];
4
- }) => string;
@@ -1,30 +0,0 @@
1
- export declare const COUNTER_COMPONENTS: {
2
- preact: {
3
- filename: string;
4
- content: string;
5
- };
6
- react: {
7
- filename: string;
8
- content: string;
9
- };
10
- solid: {
11
- filename: string;
12
- content: string;
13
- };
14
- svelte: {
15
- filename: string;
16
- content: string;
17
- };
18
- vue: {
19
- filename: string;
20
- content: string;
21
- };
22
- };
23
- export interface Integration {
24
- id: string;
25
- packageName: string;
26
- }
27
- export declare const FRAMEWORKS: {
28
- title: string;
29
- value: Integration;
30
- }[];