create-astro 3.1.6 → 3.1.8

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 (2) hide show
  1. package/dist/index.js +23 -35
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -168,37 +168,16 @@ 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";
180
+ import { execa } from "execa";
202
181
  import { exec } from "node:child_process";
203
182
  import { get } from "node:https";
204
183
 
@@ -211,15 +190,23 @@ function ansiRegex({ onlyFirst = false } = {}) {
211
190
  return new RegExp(pattern, onlyFirst ? void 0 : "g");
212
191
  }
213
192
 
214
- // ../../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();
215
195
  function stripAnsi(string) {
216
196
  if (typeof string !== "string") {
217
197
  throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
218
198
  }
219
- return string.replace(ansiRegex(), "");
199
+ return string.replace(regex, "");
220
200
  }
221
201
 
222
202
  // src/messages.ts
203
+ import detectPackageManager from "which-pm-runs";
204
+ async function getRegistry() {
205
+ var _a;
206
+ const packageManager = ((_a = detectPackageManager()) == null ? void 0 : _a.name) || "npm";
207
+ const { stdout: stdout2 } = await execa(packageManager, ["config", "get", "registry"]);
208
+ return stdout2 || "https://registry.npmjs.org";
209
+ }
223
210
  var stdout = process.stdout;
224
211
  function setStdout(writable) {
225
212
  stdout = writable;
@@ -265,10 +252,11 @@ var getName = () => new Promise((resolve) => {
265
252
  });
266
253
  });
267
254
  var v;
268
- var getVersion = () => new Promise((resolve) => {
255
+ var getVersion = () => new Promise(async (resolve) => {
269
256
  if (v)
270
257
  return resolve(v);
271
- get("https://registry.npmjs.org/astro/latest", (res) => {
258
+ const registry = await getRegistry();
259
+ get(`${registry}/astro/latest`, (res) => {
272
260
  let body = "";
273
261
  res.on("data", (chunk) => body += chunk);
274
262
  res.on("end", () => {
@@ -368,7 +356,7 @@ function printHelp({
368
356
  if (headline) {
369
357
  message.push(
370
358
  linebreak(),
371
- `${title(commandName)} ${color.green(`v${"3.1.6"}`)} ${headline}`
359
+ `${title(commandName)} ${color.green(`v${"3.1.8"}`)} ${headline}`
372
360
  );
373
361
  }
374
362
  if (usage) {
@@ -415,7 +403,7 @@ async function getContext(argv) {
415
403
  },
416
404
  { argv, permissive: true }
417
405
  );
418
- 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";
419
407
  const [username, version] = await Promise.all([getName(), getVersion()]);
420
408
  let cwd = flags["_"][0];
421
409
  let {
@@ -469,7 +457,7 @@ async function getContext(argv) {
469
457
 
470
458
  // src/actions/dependencies.ts
471
459
  import { color as color2 } from "@astrojs/cli-kit";
472
- import { execa } from "execa";
460
+ import { execa as execa2 } from "execa";
473
461
  async function dependencies(ctx) {
474
462
  let deps = ctx.install ?? ctx.yes;
475
463
  if (deps === void 0) {
@@ -509,7 +497,7 @@ async function dependencies(ctx) {
509
497
  }
510
498
  }
511
499
  async function install({ pkgManager, cwd }) {
512
- const installExec = execa(pkgManager, ["install"], { cwd });
500
+ const installExec = execa2(pkgManager, ["install"], { cwd });
513
501
  return new Promise((resolve, reject) => {
514
502
  setTimeout(() => reject(`Request timed out after one minute`), 6e4);
515
503
  installExec.on("error", (e) => reject(e));
@@ -521,7 +509,7 @@ async function install({ pkgManager, cwd }) {
521
509
  import fs from "node:fs";
522
510
  import path from "node:path";
523
511
  import { color as color3 } from "@astrojs/cli-kit";
524
- import { execa as execa2 } from "execa";
512
+ import { execa as execa3 } from "execa";
525
513
  async function git(ctx) {
526
514
  if (fs.existsSync(path.join(ctx.cwd, ".git"))) {
527
515
  await info("Nice!", `Git has already been initialized`);
@@ -558,9 +546,9 @@ async function git(ctx) {
558
546
  }
559
547
  async function init({ cwd }) {
560
548
  try {
561
- await execa2("git", ["init"], { cwd, stdio: "ignore" });
562
- await execa2("git", ["add", "-A"], { cwd, stdio: "ignore" });
563
- await execa2(
549
+ await execa3("git", ["init"], { cwd, stdio: "ignore" });
550
+ await execa3("git", ["add", "-A"], { cwd, stdio: "ignore" });
551
+ await execa3(
564
552
  "git",
565
553
  [
566
554
  "commit",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-astro",
3
- "version": "3.1.6",
3
+ "version": "3.1.8",
4
4
  "type": "module",
5
5
  "author": "withastro",
6
6
  "license": "MIT",
@@ -25,18 +25,18 @@
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
- "mocha": "^9.2.2"
32
+ "mocha": "^9.2.2",
33
+ "which-pm-runs": "^1.1.0"
33
34
  },
34
35
  "devDependencies": {
35
36
  "@types/which-pm-runs": "^1.0.0",
36
37
  "arg": "^5.0.2",
37
- "strip-ansi": "^7.0.1",
38
+ "strip-ansi": "^7.1.0",
38
39
  "strip-json-comments": "^5.0.0",
39
- "which-pm-runs": "^1.1.0",
40
40
  "astro-scripts": "0.0.14"
41
41
  },
42
42
  "engines": {