create-astro 3.1.7 → 3.1.9

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.
Files changed (3) hide show
  1. package/README.md +11 -10
  2. package/dist/index.js +22 -43
  3. package/package.json +6 -6
package/README.md CHANGED
@@ -26,6 +26,7 @@ npm create astro@latest my-astro-project -- --template minimal
26
26
  # yarn
27
27
  yarn create astro my-astro-project --template minimal
28
28
  ```
29
+
29
30
  [Check out the full list][examples] of example templates, available on GitHub.
30
31
 
31
32
  You can also use any GitHub repo as a template:
@@ -38,16 +39,16 @@ npm create astro@latest my-astro-project -- --template cassidoo/shopify-react-as
38
39
 
39
40
  May be provided in place of prompts
40
41
 
41
- | Name | Description |
42
- |:-------------|:----------------------------------------------------|
43
- | `--template <name>` | Specify your template. |
44
- | `--install` / `--no-install` | Install dependencies (or not). |
45
- | `--git` / `--no-git` | Initialize git repo (or not). |
46
- | `--yes` (`-y`) | Skip all prompt by accepting defaults. |
47
- | `--no` (`-n`) | Skip all prompt by declining defaults. |
48
- | `--dry-run` | Walk through steps without executing. |
49
- | `--skip-houston` | Skip Houston animation. |
50
- | `--typescript <option>` | TypeScript option: `strict` / `strictest` / `relaxed`. |
42
+ | Name | Description |
43
+ | :--------------------------- | :----------------------------------------------------- |
44
+ | `--template <name>` | Specify your template. |
45
+ | `--install` / `--no-install` | Install dependencies (or not). |
46
+ | `--git` / `--no-git` | Initialize git repo (or not). |
47
+ | `--yes` (`-y`) | Skip all prompt by accepting defaults. |
48
+ | `--no` (`-n`) | Skip all prompt by declining defaults. |
49
+ | `--dry-run` | Walk through steps without executing. |
50
+ | `--skip-houston` | Skip Houston animation. |
51
+ | `--typescript <option>` | TypeScript option: `strict` / `strictest` / `relaxed`. |
51
52
 
52
53
  [examples]: https://github.com/withastro/astro/tree/main/examples
53
54
  [typescript]: https://github.com/withastro/astro/tree/main/packages/astro/tsconfigs
package/dist/index.js CHANGED
@@ -168,41 +168,18 @@ var require_arg = __commonJS({
168
168
  }
169
169
  });
170
170
 
171
- // ../../node_modules/.pnpm/which-pm-runs@1.1.0/node_modules/which-pm-runs/index.js
172
- var require_which_pm_runs = __commonJS({
173
- "../../node_modules/.pnpm/which-pm-runs@1.1.0/node_modules/which-pm-runs/index.js"(exports, module) {
174
- "use strict";
175
- module.exports = function() {
176
- if (!process.env.npm_config_user_agent) {
177
- return void 0;
178
- }
179
- return pmFromUserAgent(process.env.npm_config_user_agent);
180
- };
181
- function pmFromUserAgent(userAgent) {
182
- const pmSpec = userAgent.split(" ")[0];
183
- const separatorPos = pmSpec.lastIndexOf("/");
184
- const name = pmSpec.substring(0, separatorPos);
185
- return {
186
- name: name === "npminstall" ? "cnpm" : name,
187
- version: pmSpec.substring(separatorPos + 1)
188
- };
189
- }
190
- }
191
- });
192
-
193
171
  // src/actions/context.ts
194
172
  var import_arg = __toESM(require_arg(), 1);
195
- var import_which_pm_runs = __toESM(require_which_pm_runs(), 1);
196
173
  import { prompt } from "@astrojs/cli-kit";
197
174
  import os from "node:os";
175
+ import detectPackageManager2 from "which-pm-runs";
198
176
 
199
177
  // src/messages.ts
200
178
  import { color, label, say as houston, spinner as load } from "@astrojs/cli-kit";
201
179
  import { align, sleep } from "@astrojs/cli-kit/utils";
202
180
  import { execa } from "execa";
181
+ import fetch from "node-fetch-native";
203
182
  import { exec } from "node:child_process";
204
- import { get } from "node:https";
205
- import preferredPM from "preferred-pm";
206
183
 
207
184
  // ../../node_modules/.pnpm/ansi-regex@6.0.1/node_modules/ansi-regex/index.js
208
185
  function ansiRegex({ onlyFirst = false } = {}) {
@@ -213,20 +190,26 @@ function ansiRegex({ onlyFirst = false } = {}) {
213
190
  return new RegExp(pattern, onlyFirst ? void 0 : "g");
214
191
  }
215
192
 
216
- // ../../node_modules/.pnpm/strip-ansi@7.0.1/node_modules/strip-ansi/index.js
193
+ // ../../node_modules/.pnpm/strip-ansi@7.1.0/node_modules/strip-ansi/index.js
194
+ var regex = ansiRegex();
217
195
  function stripAnsi(string) {
218
196
  if (typeof string !== "string") {
219
197
  throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
220
198
  }
221
- return string.replace(ansiRegex(), "");
199
+ return string.replace(regex, "");
222
200
  }
223
201
 
224
202
  // src/messages.ts
203
+ import detectPackageManager from "which-pm-runs";
225
204
  async function getRegistry() {
226
- var _a;
227
- const packageManager = ((_a = await preferredPM(process.cwd())) == null ? void 0 : _a.name) || "npm";
228
- const { stdout: stdout2 } = await execa(packageManager, ["config", "get", "registry"]);
229
- return stdout2 || "https://registry.npmjs.org";
205
+ var _a, _b;
206
+ const packageManager = ((_a = detectPackageManager()) == null ? void 0 : _a.name) || "npm";
207
+ try {
208
+ const { stdout: stdout2 } = await execa(packageManager, ["config", "get", "registry"]);
209
+ return ((_b = stdout2 == null ? void 0 : stdout2.trim()) == null ? void 0 : _b.replace(/\/$/, "")) || "https://registry.npmjs.org";
210
+ } catch (e) {
211
+ return "https://registry.npmjs.org";
212
+ }
230
213
  }
231
214
  var stdout = process.stdout;
232
215
  function setStdout(writable) {
@@ -276,16 +259,12 @@ var v;
276
259
  var getVersion = () => new Promise(async (resolve) => {
277
260
  if (v)
278
261
  return resolve(v);
279
- const registry = await getRegistry();
280
- get(`${registry}/astro/latest`, (res) => {
281
- let body = "";
282
- res.on("data", (chunk) => body += chunk);
283
- res.on("end", () => {
284
- const { version } = JSON.parse(body);
285
- v = version;
286
- resolve(version);
287
- });
288
- });
262
+ let registry = await getRegistry();
263
+ const { version } = await fetch(`${registry}/astro/latest`, { redirect: "follow" }).then(
264
+ (res) => res.json()
265
+ );
266
+ v = version;
267
+ resolve(version);
289
268
  });
290
269
  var log = (message) => stdout.write(message + "\n");
291
270
  var banner = async (version) => log(
@@ -377,7 +356,7 @@ function printHelp({
377
356
  if (headline) {
378
357
  message.push(
379
358
  linebreak(),
380
- `${title(commandName)} ${color.green(`v${"3.1.7"}`)} ${headline}`
359
+ `${title(commandName)} ${color.green(`v${"3.1.9"}`)} ${headline}`
381
360
  );
382
361
  }
383
362
  if (usage) {
@@ -424,7 +403,7 @@ async function getContext(argv) {
424
403
  },
425
404
  { argv, permissive: true }
426
405
  );
427
- const pkgManager = ((_a = (0, import_which_pm_runs.default)()) == null ? void 0 : _a.name) ?? "npm";
406
+ const pkgManager = ((_a = detectPackageManager2()) == null ? void 0 : _a.name) ?? "npm";
428
407
  const [username, version] = await Promise.all([getName(), getVersion()]);
429
408
  let cwd = flags["_"][0];
430
409
  let {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-astro",
3
- "version": "3.1.7",
3
+ "version": "3.1.9",
4
4
  "type": "module",
5
5
  "author": "withastro",
6
6
  "license": "MIT",
@@ -25,19 +25,19 @@
25
25
  "//a": "MOST PACKAGES SHOULD GO IN DEV_DEPENDENCIES! THEY WILL BE BUNDLED.",
26
26
  "//b": "DEPENDENCIES IS FOR UNBUNDLED PACKAGES",
27
27
  "dependencies": {
28
- "@astrojs/cli-kit": "^0.2.2",
29
- "chai": "^4.3.6",
28
+ "@astrojs/cli-kit": "^0.2.3",
29
+ "chai": "^4.3.7",
30
30
  "execa": "^6.1.0",
31
31
  "giget": "1.0.0",
32
32
  "mocha": "^9.2.2",
33
- "preferred-pm": "^3.0.3"
33
+ "node-fetch-native": "^1.2.0",
34
+ "which-pm-runs": "^1.1.0"
34
35
  },
35
36
  "devDependencies": {
36
37
  "@types/which-pm-runs": "^1.0.0",
37
38
  "arg": "^5.0.2",
38
- "strip-ansi": "^7.0.1",
39
+ "strip-ansi": "^7.1.0",
39
40
  "strip-json-comments": "^5.0.0",
40
- "which-pm-runs": "^1.1.0",
41
41
  "astro-scripts": "0.0.14"
42
42
  },
43
43
  "engines": {