create-astro 0.6.10 → 0.8.0-next.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/LICENSE ADDED
@@ -0,0 +1,34 @@
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
+ """
package/README.md CHANGED
@@ -43,4 +43,19 @@ May be provided in place of prompts
43
43
  | `--template` | Specify the template name ([list][examples]) |
44
44
  | `--commit` | Specify a specific Git commit or branch to use from this repo (by default, `main` branch of this repo will be used) |
45
45
 
46
+ ### Debugging
47
+
48
+ To debug `create-astro`, you can use the `--verbose` flag which will log the output of degit and some more information about the command, this can be useful when you encounter an error and want to report it.
49
+
50
+ ```bash
51
+ # npm 6.x
52
+ npm init astro my-astro-project --verbose
53
+
54
+ # npm 7+, extra double-dash is needed:
55
+ npm init astro my-astro-project -- --verbose
56
+
57
+ # yarn
58
+ yarn create astro my-astro-project --verbose
59
+ ```
60
+
46
61
  [examples]: https://github.com/withastro/astro/tree/main/examples
package/create-astro.mjs CHANGED
@@ -6,9 +6,9 @@ const requiredMajorVersion = parseInt(currentVersion.split('.')[0], 10);
6
6
  const minimumMajorVersion = 12;
7
7
 
8
8
  if (requiredMajorVersion < minimumMajorVersion) {
9
- console.error(`Node.js v${currentVersion} is out of date and unsupported!`);
10
- console.error(`Please use Node.js v${minimumMajorVersion} or higher.`);
11
- process.exit(1);
9
+ console.error(`Node.js v${currentVersion} is out of date and unsupported!`);
10
+ console.error(`Please use Node.js v${minimumMajorVersion} or higher.`);
11
+ process.exit(1);
12
12
  }
13
13
 
14
14
  import('./dist/index.js').then(({ main }) => main());
package/dist/config.js CHANGED
@@ -1,24 +1,23 @@
1
- const createConfig = ({ renderers }) => {
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}(),`);
2
10
  return [
3
- `export default {
4
- // projectRoot: '.', // Where to resolve all URLs relative to. Useful if you have a monorepo project.
5
- // pages: './src/pages', // Path to Astro components, pages, and data
6
- // dist: './dist', // When running \`astro build\`, path to final static output
7
- // public: './public', // A folder of static files Astro will copy to the root. Useful for favicons, images, and other files that don\u2019t need processing.
8
- buildOptions: {
9
- // site: 'http://example.com', // Your public domain, e.g.: https://my-site.dev/. Used to generate sitemaps and canonical URLs.
10
- sitemap: true, // Generate sitemap (set to "false" to disable)
11
- },
12
- devOptions: {
13
- // hostname: 'localhost', // The hostname to run the dev server on.
14
- // port: 3000, // The port to run the dev server on.
15
- },`,
16
- ` renderers: ${JSON.stringify(renderers, void 0, 2).split("\n").map((ln, i) => i !== 0 ? ` ${ln}` : ln).join("\n")},`,
17
- `};
18
- `
11
+ `import { defineConfig } from 'astro/config';`,
12
+ ...rendererImports,
13
+ `// https://astro.build/config`,
14
+ `export default defineConfig({`,
15
+ ` integrations: [`,
16
+ ...rendererIntegrations,
17
+ ` ]`,
18
+ `});`
19
19
  ].join("\n");
20
20
  };
21
21
  export {
22
22
  createConfig
23
23
  };
24
- //# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vc3JjL2NvbmZpZy50cyJdLAogICJtYXBwaW5ncyI6ICJBQUFPLE1BQU0sZUFBZSxDQUFDLEVBQUUsZ0JBQXlDO0FBQ3RFLFNBQU87QUFBQSxJQUNMO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUEsSUFhQSxnQkFBZ0IsS0FBSyxVQUFVLFdBQVcsUUFBVyxHQUNsRCxNQUFNLE1BQ04sSUFBSSxDQUFDLElBQUksTUFBTyxNQUFNLElBQUksS0FBSyxPQUFPLElBQ3RDLEtBQUs7QUFBQSxJQUNSO0FBQUE7QUFBQSxJQUVBLEtBQUs7QUFBQTsiLAogICJuYW1lcyI6IFtdCn0K
@@ -1,5 +1,5 @@
1
1
  const COUNTER_COMPONENTS = {
2
- "@astrojs/renderer-preact": {
2
+ preact: {
3
3
  filename: `src/components/PreactCounter.jsx`,
4
4
  content: `import { useState } from 'preact/hooks';
5
5
 
@@ -18,7 +18,7 @@ export default function PreactCounter() {
18
18
  }
19
19
  `
20
20
  },
21
- "@astrojs/renderer-react": {
21
+ react: {
22
22
  filename: `src/components/ReactCounter.jsx`,
23
23
  content: `import { useState } from 'react';
24
24
 
@@ -37,7 +37,7 @@ export default function ReactCounter() {
37
37
  }
38
38
  `
39
39
  },
40
- "@astrojs/renderer-solid": {
40
+ solid: {
41
41
  filename: `src/components/SolidCounter.jsx`,
42
42
  content: `import { createSignal } from "solid-js";
43
43
 
@@ -56,7 +56,7 @@ export default function SolidCounter() {
56
56
  }
57
57
  `
58
58
  },
59
- "@astrojs/renderer-svelte": {
59
+ svelte: {
60
60
  filename: `src/components/SvelteCounter.svelte`,
61
61
  content: `<script>
62
62
  let count = 0;
@@ -77,7 +77,7 @@ export default function SolidCounter() {
77
77
  </div>
78
78
  `
79
79
  },
80
- "@astrojs/renderer-vue": {
80
+ vue: {
81
81
  filename: `src/components/VueCounter.vue`,
82
82
  content: `<template>
83
83
  <div id="vue" class="counter">
@@ -109,27 +109,26 @@ export default {
109
109
  const FRAMEWORKS = [
110
110
  {
111
111
  title: "Preact",
112
- value: "@astrojs/renderer-preact"
112
+ value: { id: "preact", packageName: "@astrojs/preact" }
113
113
  },
114
114
  {
115
115
  title: "React",
116
- value: "@astrojs/renderer-react"
116
+ value: { id: "react", packageName: "@astrojs/react" }
117
117
  },
118
118
  {
119
- title: "Solid",
120
- value: "@astrojs/renderer-solid"
119
+ title: "Solid.js",
120
+ value: { id: "solid", packageName: "@astrojs/solid-js" }
121
121
  },
122
122
  {
123
123
  title: "Svelte",
124
- value: "@astrojs/renderer-svelte"
124
+ value: { id: "svelte", packageName: "@astrojs/svelte" }
125
125
  },
126
126
  {
127
127
  title: "Vue",
128
- value: "@astrojs/renderer-vue"
128
+ value: { id: "vue", packageName: "@astrojs/vue" }
129
129
  }
130
130
  ];
131
131
  export {
132
132
  COUNTER_COMPONENTS,
133
133
  FRAMEWORKS
134
134
  };
135
- //# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vc3JjL2ZyYW1ld29ya3MudHMiXSwKICAibWFwcGluZ3MiOiAiQUFBTyxNQUFNLHFCQUFxQjtBQUFBLEVBQ2hDLDRCQUE0QjtBQUFBLElBQzFCLFVBQVU7QUFBQSxJQUNWLFNBQVM7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBLEVBaUJYLDJCQUEyQjtBQUFBLElBQ3pCLFVBQVU7QUFBQSxJQUNWLFNBQVM7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBLEVBaUJYLDJCQUEyQjtBQUFBLElBQ3pCLFVBQVU7QUFBQSxJQUNWLFNBQVM7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBLEVBaUJYLDRCQUE0QjtBQUFBLElBQzFCLFVBQVU7QUFBQSxJQUNWLFNBQVM7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQSxFQW1CWCx5QkFBeUI7QUFBQSxJQUN2QixVQUFVO0FBQUEsSUFDVixTQUFTO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQTRCTixNQUFNLGFBQWE7QUFBQSxFQUN4QjtBQUFBLElBQ0UsT0FBTztBQUFBLElBQ1AsT0FBTztBQUFBO0FBQUEsRUFFVDtBQUFBLElBQ0UsT0FBTztBQUFBLElBQ1AsT0FBTztBQUFBO0FBQUEsRUFFVDtBQUFBLElBQ0UsT0FBTztBQUFBLElBQ1AsT0FBTztBQUFBO0FBQUEsRUFFVDtBQUFBLElBQ0UsT0FBTztBQUFBLElBQ1AsT0FBTztBQUFBO0FBQUEsRUFFVDtBQUFBLElBQ0UsT0FBTztBQUFBLElBQ1AsT0FBTztBQUFBO0FBQUE7IiwKICAibmFtZXMiOiBbXQp9Cg==
package/dist/index.js CHANGED
@@ -21,11 +21,13 @@ import fetch from "node-fetch";
21
21
  import prompts from "prompts";
22
22
  import degit from "degit";
23
23
  import yargs from "yargs-parser";
24
+ import ora from "ora";
24
25
  import { FRAMEWORKS, COUNTER_COMPONENTS } from "./frameworks.js";
25
26
  import { TEMPLATES } from "./templates.js";
26
27
  import { createConfig } from "./config.js";
28
+ import { logger, defaultLogLevel } from "./logger.js";
27
29
  const cleanArgv = process.argv.filter((arg) => arg !== "--");
28
- const args = yargs(cleanArgv, { array: ["renderers"] });
30
+ const args = yargs(cleanArgv);
29
31
  prompts.override(args);
30
32
  function mkdirp(dir) {
31
33
  try {
@@ -39,12 +41,13 @@ function mkdirp(dir) {
39
41
  const { version } = JSON.parse(fs.readFileSync(new URL("../package.json", import.meta.url), "utf-8"));
40
42
  const POSTPROCESS_FILES = ["package.json", "astro.config.mjs", "CHANGELOG.md"];
41
43
  async function main() {
44
+ logger.debug("Verbose logging turned on");
42
45
  console.log(`
43
46
  ${bold("Welcome to Astro!")} ${gray(`(create-astro v${version})`)}`);
44
47
  console.log(`If you encounter a problem, visit ${cyan("https://github.com/withastro/astro/issues")} to search or file a new issue.
45
48
  `);
46
- console.log(`${green(`>`)} ${gray(`Prepare for liftoff.`)}`);
47
- console.log(`${green(`>`)} ${gray(`Gathering mission details...`)}`);
49
+ let spinner = ora({ color: "green", text: "Prepare for liftoff." });
50
+ spinner.succeed();
48
51
  const cwd = args["_"][2] || ".";
49
52
  if (fs.existsSync(cwd)) {
50
53
  if (fs.readdirSync(cwd).length > 0) {
@@ -78,45 +81,47 @@ ${bold("Welcome to Astro!")} ${gray(`(create-astro v${version})`)}`);
78
81
  const emitter = degit(`${templateTarget}${hash}`, {
79
82
  cache: false,
80
83
  force: true,
81
- verbose: false
84
+ verbose: defaultLogLevel === "debug" ? true : false
85
+ });
86
+ logger.debug("Initialized degit with following config:", `${templateTarget}${hash}`, {
87
+ cache: false,
88
+ force: true,
89
+ verbose: defaultLogLevel === "debug" ? true : false
82
90
  });
83
91
  const selectedTemplate = TEMPLATES.find((template) => template.value === options.template);
84
- let renderers = [];
85
- if ((selectedTemplate == null ? void 0 : selectedTemplate.renderers) === true) {
92
+ let integrations = [];
93
+ if ((selectedTemplate == null ? void 0 : selectedTemplate.integrations) === true) {
86
94
  const result = await prompts([
87
95
  {
88
96
  type: "multiselect",
89
- name: "renderers",
97
+ name: "integrations",
90
98
  message: "Which frameworks would you like to use?",
91
99
  choices: FRAMEWORKS
92
100
  }
93
101
  ]);
94
- renderers = result.renderers;
95
- } else if ((selectedTemplate == null ? void 0 : selectedTemplate.renderers) && Array.isArray(selectedTemplate.renderers) && selectedTemplate.renderers.length) {
96
- renderers = selectedTemplate.renderers;
97
- const titles = renderers.map((renderer) => {
98
- var _a;
99
- return (_a = FRAMEWORKS.find((item) => item.value === renderer)) == null ? void 0 : _a.title;
100
- }).join(", ");
101
- console.log(`${green(`\u2714`)} ${bold(`Using template's default renderers`)} ${gray("\u203A")} ${titles}`);
102
+ integrations = result.integrations;
102
103
  }
104
+ spinner = ora({ color: "green", text: "Copying project files..." }).start();
103
105
  try {
104
- console.log(`${green(`>`)} ${gray(`Copying project files...`)}`);
106
+ emitter.on("info", (info) => {
107
+ logger.debug(info.message);
108
+ });
105
109
  await emitter.clone(cwd);
106
110
  } catch (err) {
111
+ logger.debug(err);
107
112
  console.error(red(err.message));
108
113
  if (err.message === "zlib: unexpected end of file") {
109
- console.log(yellow("This seems to be a cache related problem. Remove the folder '~/.degit/github/snowpackjs' to fix this error."));
114
+ console.log(yellow("This seems to be a cache related problem. Remove the folder '~/.degit/github/withastro' to fix this error."));
110
115
  console.log(yellow("For more information check out this issue: https://github.com/withastro/astro/issues/655"));
111
116
  }
112
117
  if (err.code === "MISSING_REF") {
113
118
  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)."));
114
- console.log(yellow("If you do have 'git' installed, please file a new issue here: https://github.com/withastro/astro/issues"));
119
+ 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"));
115
120
  }
121
+ spinner.fail();
116
122
  process.exit(1);
117
123
  }
118
124
  await Promise.all(POSTPROCESS_FILES.map(async (file) => {
119
- var _a;
120
125
  const fileLoc = path.resolve(path.join(cwd, file));
121
126
  switch (file) {
122
127
  case "CHANGELOG.md": {
@@ -126,17 +131,26 @@ ${bold("Welcome to Astro!")} ${gray(`(create-astro v${version})`)}`);
126
131
  break;
127
132
  }
128
133
  case "astro.config.mjs": {
129
- if ((selectedTemplate == null ? void 0 : selectedTemplate.renderers) !== true) {
134
+ if ((selectedTemplate == null ? void 0 : selectedTemplate.integrations) !== true) {
130
135
  break;
131
136
  }
132
- await fs.promises.writeFile(fileLoc, createConfig({ renderers }));
137
+ await fs.promises.writeFile(fileLoc, createConfig({ integrations }));
133
138
  break;
134
139
  }
135
140
  case "package.json": {
136
141
  const packageJSON = JSON.parse(await fs.promises.readFile(fileLoc, "utf8"));
137
142
  delete packageJSON.snowpack;
138
- const rendererEntries = await Promise.all(["astro", ...renderers].map((renderer) => fetch(`https://registry.npmjs.org/${renderer}/latest`).then((res) => res.json()).then((res) => [renderer, `^${res["version"]}`])));
139
- packageJSON.devDependencies = __spreadValues(__spreadValues({}, (_a = packageJSON.devDependencies) != null ? _a : {}), Object.fromEntries(rendererEntries));
143
+ const integrationEntries = (await Promise.all(integrations.map((integration) => fetch(`https://registry.npmjs.org/${integration.packageName}/latest`).then((res) => res.json()).then((res) => {
144
+ let dependencies = [[res["name"], `^${res["version"]}`]];
145
+ if (res["peerDependencies"]) {
146
+ for (const peer in res["peerDependencies"]) {
147
+ dependencies.push([peer, res["peerDependencies"][peer]]);
148
+ }
149
+ }
150
+ return dependencies;
151
+ })))).flat(1);
152
+ packageJSON.devDependencies = __spreadValues(__spreadValues({}, packageJSON.devDependencies ?? {}), Object.fromEntries(integrationEntries));
153
+ packageJSON.devDependencies = Object.fromEntries(Object.entries(packageJSON.devDependencies).sort((a, b) => a[0].localeCompare(b[0])));
140
154
  await fs.promises.writeFile(fileLoc, JSON.stringify(packageJSON, void 0, 2));
141
155
  break;
142
156
  }
@@ -145,8 +159,8 @@ ${bold("Welcome to Astro!")} ${gray(`(create-astro v${version})`)}`);
145
159
  if ((selectedTemplate == null ? void 0 : selectedTemplate.value) === "starter") {
146
160
  let importStatements = [];
147
161
  let components = [];
148
- await Promise.all(renderers.map(async (renderer) => {
149
- const component = COUNTER_COMPONENTS[renderer];
162
+ await Promise.all(integrations.map(async (integration) => {
163
+ const component = COUNTER_COMPONENTS[integration.id];
150
164
  const componentName = path.basename(component.filename, path.extname(component.filename));
151
165
  const absFileLoc = path.resolve(cwd, component.filename);
152
166
  importStatements.push(`import ${componentName} from '${component.filename.replace(/^src/, "..")}';`);
@@ -162,6 +176,7 @@ ${bold("Welcome to Astro!")} ${gray(`(create-astro v${version})`)}`);
162
176
  });
163
177
  await fs.promises.writeFile(pageFileLoc, newContent);
164
178
  }
179
+ spinner.succeed();
165
180
  console.log(bold(green("\u2714") + " Done!"));
166
181
  console.log("\nNext steps:");
167
182
  let i = 1;
@@ -182,4 +197,3 @@ export {
182
197
  main,
183
198
  mkdirp
184
199
  };
185
- //# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vc3JjL2luZGV4LnRzIl0sCiAgIm1hcHBpbmdzIjogIjs7Ozs7Ozs7Ozs7Ozs7OztBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBTUEsTUFBTSxZQUFZLFFBQVEsS0FBSyxPQUFPLENBQUMsUUFBUSxRQUFRO0FBQ3ZELE1BQU0sT0FBTyxNQUFNLFdBQVcsRUFBRSxPQUFPLENBQUM7QUFDeEMsUUFBUSxTQUFTO0FBRVYsZ0JBQWdCLEtBQWE7QUFDbEMsTUFBSTtBQUNGLE9BQUcsVUFBVSxLQUFLLEVBQUUsV0FBVztBQUFBLFdBQ3hCLEdBQVA7QUFDQSxRQUFJLEVBQUUsU0FBUztBQUFVO0FBQ3pCLFVBQU07QUFBQTtBQUFBO0FBSVYsTUFBTSxFQUFFLFlBQVksS0FBSyxNQUFNLEdBQUcsYUFBYSxJQUFJLElBQUksbUJBQW1CLFlBQVksTUFBTTtBQUU1RixNQUFNLG9CQUFvQixDQUFDLGdCQUFnQixvQkFBb0I7QUFFL0Qsc0JBQTZCO0FBQzNCLFVBQVEsSUFBSTtBQUFBLEVBQUssS0FBSyx3QkFBd0IsS0FBSyxrQ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@@
1
+ import { bold, blue, dim, red, yellow } from "kleur/colors";
2
+ import { Writable } from "stream";
3
+ import { format as utilFormat } from "util";
4
+ function getLoggerLocale() {
5
+ const defaultLocale = "en-US";
6
+ if (process.env.LANG) {
7
+ const extractedLocale = process.env.LANG.split(".")[0].replace(/_/g, "-");
8
+ if (extractedLocale.length < 2)
9
+ return defaultLocale;
10
+ else
11
+ return extractedLocale;
12
+ } else
13
+ return defaultLocale;
14
+ }
15
+ const dt = new Intl.DateTimeFormat(getLoggerLocale(), {
16
+ hour: "2-digit",
17
+ minute: "2-digit"
18
+ });
19
+ const defaultLogDestination = new Writable({
20
+ objectMode: true,
21
+ write(event, _, callback) {
22
+ let dest = process.stderr;
23
+ if (levels[event.level] < levels["error"])
24
+ dest = process.stdout;
25
+ dest.write(dim(dt.format(new Date()) + " "));
26
+ let type = event.type;
27
+ if (type) {
28
+ switch (event.level) {
29
+ case "info":
30
+ type = bold(blue(type));
31
+ break;
32
+ case "warn":
33
+ type = bold(yellow(type));
34
+ break;
35
+ case "error":
36
+ type = bold(red(type));
37
+ break;
38
+ }
39
+ dest.write(`[${type}] `);
40
+ }
41
+ dest.write(utilFormat(...event.args));
42
+ dest.write("\n");
43
+ callback();
44
+ }
45
+ });
46
+ let defaultLogLevel;
47
+ if (process.argv.includes("--verbose")) {
48
+ defaultLogLevel = "debug";
49
+ } else if (process.argv.includes("--silent")) {
50
+ defaultLogLevel = "silent";
51
+ } else {
52
+ defaultLogLevel = "info";
53
+ }
54
+ const defaultLogOptions = {
55
+ dest: defaultLogDestination,
56
+ level: defaultLogLevel
57
+ };
58
+ const levels = {
59
+ debug: 20,
60
+ info: 30,
61
+ warn: 40,
62
+ error: 50,
63
+ silent: 90
64
+ };
65
+ function log(opts = {}, level, type, ...args) {
66
+ const logLevel = opts.level ?? defaultLogOptions.level;
67
+ const dest = opts.dest ?? defaultLogOptions.dest;
68
+ const event = {
69
+ type,
70
+ level,
71
+ args,
72
+ message: ""
73
+ };
74
+ if (levels[logLevel] > levels[level]) {
75
+ return;
76
+ }
77
+ dest.write(event);
78
+ }
79
+ function debug(opts, type, ...messages) {
80
+ return log(opts, "debug", type, ...messages);
81
+ }
82
+ function info(opts, type, ...messages) {
83
+ return log(opts, "info", type, ...messages);
84
+ }
85
+ function warn(opts, type, ...messages) {
86
+ return log(opts, "warn", type, ...messages);
87
+ }
88
+ function error(opts, type, ...messages) {
89
+ return log(opts, "error", type, ...messages);
90
+ }
91
+ const logger = {
92
+ debug: debug.bind(null, defaultLogOptions, "debug"),
93
+ info: info.bind(null, defaultLogOptions, "info"),
94
+ warn: warn.bind(null, defaultLogOptions, "warn"),
95
+ error: error.bind(null, defaultLogOptions, "error")
96
+ };
97
+ export {
98
+ debug,
99
+ defaultLogDestination,
100
+ defaultLogLevel,
101
+ defaultLogOptions,
102
+ error,
103
+ info,
104
+ levels,
105
+ log,
106
+ logger,
107
+ warn
108
+ };
package/dist/templates.js CHANGED
@@ -2,35 +2,25 @@ const TEMPLATES = [
2
2
  {
3
3
  title: "Starter Kit (Generic)",
4
4
  value: "starter",
5
- renderers: true
5
+ integrations: true
6
6
  },
7
7
  {
8
8
  title: "Blog",
9
- value: "blog",
10
- renderers: ["@astrojs/renderer-preact"]
9
+ value: "blog"
11
10
  },
12
11
  {
13
12
  title: "Documentation",
14
- value: "docs",
15
- renderers: ["@astrojs/renderer-preact"]
13
+ value: "docs"
16
14
  },
17
15
  {
18
16
  title: "Portfolio",
19
- value: "portfolio",
20
- renderers: ["@astrojs/renderer-preact"]
21
- },
22
- {
23
- title: "Portfolio Svelte",
24
- value: "portfolio-svelte",
25
- renderers: ["@astrojs/renderer-svelte"]
17
+ value: "portfolio"
26
18
  },
27
19
  {
28
20
  title: "Minimal",
29
- value: "minimal",
30
- renderers: []
21
+ value: "minimal"
31
22
  }
32
23
  ];
33
24
  export {
34
25
  TEMPLATES
35
26
  };
36
- //# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vc3JjL3RlbXBsYXRlcy50cyJdLAogICJtYXBwaW5ncyI6ICJBQUFPLE1BQU0sWUFBWTtBQUFBLEVBQ3ZCO0FBQUEsSUFDRSxPQUFPO0FBQUEsSUFDUCxPQUFPO0FBQUEsSUFDUCxXQUFXO0FBQUE7QUFBQSxFQUViO0FBQUEsSUFDRSxPQUFPO0FBQUEsSUFDUCxPQUFPO0FBQUEsSUFDUCxXQUFXLENBQUM7QUFBQTtBQUFBLEVBRWQ7QUFBQSxJQUNFLE9BQU87QUFBQSxJQUNQLE9BQU87QUFBQSxJQUNQLFdBQVcsQ0FBQztBQUFBO0FBQUEsRUFFZDtBQUFBLElBQ0UsT0FBTztBQUFBLElBQ1AsT0FBTztBQUFBLElBQ1AsV0FBVyxDQUFDO0FBQUE7QUFBQSxFQUVkO0FBQUEsSUFDRSxPQUFPO0FBQUEsSUFDUCxPQUFPO0FBQUEsSUFDUCxXQUFXLENBQUM7QUFBQTtBQUFBLEVBRWQ7QUFBQSxJQUNFLE9BQU87QUFBQSxJQUNQLE9BQU87QUFBQSxJQUNQLFdBQVc7QUFBQTtBQUFBOyIsCiAgIm5hbWVzIjogW10KfQo=
@@ -1,3 +1,4 @@
1
- export declare const createConfig: ({ renderers }: {
2
- renderers: string[];
1
+ import type { Integration } from './frameworks';
2
+ export declare const createConfig: ({ integrations }: {
3
+ integrations: Integration[];
3
4
  }) => string;
@@ -1,26 +1,30 @@
1
1
  export declare const COUNTER_COMPONENTS: {
2
- '@astrojs/renderer-preact': {
2
+ preact: {
3
3
  filename: string;
4
4
  content: string;
5
5
  };
6
- '@astrojs/renderer-react': {
6
+ react: {
7
7
  filename: string;
8
8
  content: string;
9
9
  };
10
- '@astrojs/renderer-solid': {
10
+ solid: {
11
11
  filename: string;
12
12
  content: string;
13
13
  };
14
- '@astrojs/renderer-svelte': {
14
+ svelte: {
15
15
  filename: string;
16
16
  content: string;
17
17
  };
18
- '@astrojs/renderer-vue': {
18
+ vue: {
19
19
  filename: string;
20
20
  content: string;
21
21
  };
22
22
  };
23
+ export interface Integration {
24
+ id: string;
25
+ packageName: string;
26
+ }
23
27
  export declare const FRAMEWORKS: {
24
28
  title: string;
25
- value: string;
29
+ value: Integration;
26
30
  }[];
@@ -0,0 +1,38 @@
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,9 +1,9 @@
1
1
  export declare const TEMPLATES: ({
2
2
  title: string;
3
3
  value: string;
4
- renderers: boolean;
4
+ integrations: boolean;
5
5
  } | {
6
6
  title: string;
7
7
  value: string;
8
- renderers: string[];
8
+ integrations?: undefined;
9
9
  })[];
package/package.json CHANGED
@@ -1,42 +1,48 @@
1
1
  {
2
2
  "name": "create-astro",
3
- "version": "0.6.10",
3
+ "version": "0.8.0-next.0",
4
4
  "type": "module",
5
+ "author": "withastro",
6
+ "license": "MIT",
5
7
  "repository": {
6
8
  "type": "git",
7
9
  "url": "https://github.com/withastro/astro.git",
8
10
  "directory": "packages/create-astro"
9
11
  },
12
+ "bugs": "https://github.com/withastro/astro/issues",
13
+ "homepage": "https://astro.build",
10
14
  "exports": {
11
15
  ".": "./create-astro.mjs"
12
16
  },
13
17
  "bin": {
14
18
  "create-astro": "./create-astro.mjs"
15
19
  },
16
- "scripts": {
17
- "build": "astro-scripts build \"src/**/*.ts\" && tsc",
18
- "dev": "astro-scripts dev \"src/**/*.ts\"",
19
- "prepare": "yarn build",
20
- "test": "rm -rf test/fixtures && mkdir test/fixtures && node --unhandled-rejections=strict test/create-astro.test.js"
21
- },
22
20
  "files": [
23
21
  "dist",
24
22
  "create-astro.js"
25
23
  ],
26
24
  "dependencies": {
27
- "@types/degit": "^2.8.2",
28
- "@types/node-fetch": "^3.0.0",
29
- "@types/prompts": "^2.0.12",
25
+ "@types/degit": "^2.8.3",
26
+ "@types/prompts": "^2.0.14",
30
27
  "degit": "^2.8.4",
31
- "kleur": "^4.1.1",
32
- "node-fetch": "^3.0.0",
33
- "prompts": "^2.4.1",
34
- "yargs-parser": "^20.2.7"
28
+ "kleur": "^4.1.4",
29
+ "node-fetch": "^3.2.3",
30
+ "ora": "^6.1.0",
31
+ "prompts": "^2.4.2",
32
+ "yargs-parser": "^21.0.1"
35
33
  },
36
34
  "devDependencies": {
37
- "uvu": "^0.5.1"
35
+ "@types/yargs-parser": "^21.0.0",
36
+ "astro-scripts": "0.0.2",
37
+ "uvu": "^0.5.3"
38
38
  },
39
39
  "engines": {
40
- "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
41
- }
42
- }
40
+ "node": "^14.15.0 || >=16.0.0"
41
+ },
42
+ "scripts": {
43
+ "build": "astro-scripts build \"src/**/*.ts\" && tsc",
44
+ "dev": "astro-scripts dev \"src/**/*.ts\"",
45
+ "test": "rm -rf test/fixtures && mkdir test/fixtures && node --unhandled-rejections=strict test/create-astro.test.js"
46
+ },
47
+ "readme": "# create-astro\n\n## Scaffolding for Astro projects\n\n**With NPM:**\n\n```bash\nnpm init astro\n```\n\n**With Yarn:**\n\n```bash\nyarn create astro\n```\n\n`create-astro` automatically runs in _interactive_ mode, but you can also specify your project name and template with command line arguments.\n\n```bash\n# npm 6.x\nnpm init astro my-astro-project --template starter\n\n# npm 7+, extra double-dash is needed:\nnpm init astro my-astro-project -- --template starter\n\n# yarn\nyarn create astro my-astro-project --template starter\n```\n[Check out the full list][examples] of example starter templates, available on GitHub.\n\nYou can also use any GitHub repo as a template:\n\n```bash\nnpm init astro my-astro-project -- --template cassidoo/shopify-react-astro\n```\n\n### CLI Flags\n\nMay be provided in place of prompts\n\n| Name | Description |\n|:-------------|:----------------------------------------------------|\n| `--template` | Specify the template name ([list][examples]) |\n| `--commit` | Specify a specific Git commit or branch to use from this repo (by default, `main` branch of this repo will be used) |\n\n### Debugging\n\nTo debug `create-astro`, you can use the `--verbose` flag which will log the output of degit and some more information about the command, this can be useful when you encounter an error and want to report it.\n\n```bash\n# npm 6.x\nnpm init astro my-astro-project --verbose\n\n# npm 7+, extra double-dash is needed:\nnpm init astro my-astro-project -- --verbose\n\n# yarn\nyarn create astro my-astro-project --verbose\n```\n\n[examples]: https://github.com/withastro/astro/tree/main/examples\n"
48
+ }