create-astro 4.7.1 → 4.7.2
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/dist/index.js +25 -21
- package/dist/messages.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -162,7 +162,7 @@ var require_arg = __commonJS({
|
|
|
162
162
|
fn[flagSymbol] = true;
|
|
163
163
|
return fn;
|
|
164
164
|
};
|
|
165
|
-
arg2.COUNT = arg2.flag((
|
|
165
|
+
arg2.COUNT = arg2.flag((v, name, existingCount) => (existingCount || 0) + 1);
|
|
166
166
|
arg2.ArgError = ArgError;
|
|
167
167
|
module.exports = arg2;
|
|
168
168
|
}
|
|
@@ -229,13 +229,17 @@ async function shell(command, flags, opts = {}) {
|
|
|
229
229
|
}
|
|
230
230
|
|
|
231
231
|
// src/messages.ts
|
|
232
|
+
var _registry;
|
|
232
233
|
async function getRegistry(packageManager) {
|
|
234
|
+
if (_registry)
|
|
235
|
+
return _registry;
|
|
233
236
|
try {
|
|
234
237
|
const { stdout: stdout2 } = await shell(packageManager, ["config", "get", "registry"]);
|
|
235
|
-
|
|
238
|
+
_registry = stdout2?.trim()?.replace(/\/$/, "") || "https://registry.npmjs.org";
|
|
236
239
|
} catch (e) {
|
|
237
|
-
|
|
240
|
+
_registry = "https://registry.npmjs.org";
|
|
238
241
|
}
|
|
242
|
+
return _registry;
|
|
239
243
|
}
|
|
240
244
|
var stdout = process.stdout;
|
|
241
245
|
function setStdout(writable) {
|
|
@@ -258,17 +262,15 @@ var getName = () => new Promise((resolve) => {
|
|
|
258
262
|
});
|
|
259
263
|
});
|
|
260
264
|
});
|
|
261
|
-
var
|
|
262
|
-
var getVersion = (packageManager) => new Promise(async (resolve) => {
|
|
263
|
-
if (v)
|
|
264
|
-
return resolve(v);
|
|
265
|
+
var getVersion = (packageManager, packageName, fallback = "") => new Promise(async (resolve) => {
|
|
265
266
|
let registry = await getRegistry(packageManager);
|
|
266
|
-
const { version } = await fetch(`${registry}/
|
|
267
|
+
const { version } = await fetch(`${registry}/${packageName}/latest`, {
|
|
268
|
+
redirect: "follow"
|
|
269
|
+
}).then(
|
|
267
270
|
(res) => res.json(),
|
|
268
|
-
() => ({ version:
|
|
271
|
+
() => ({ version: fallback })
|
|
269
272
|
);
|
|
270
|
-
|
|
271
|
-
resolve(version);
|
|
273
|
+
return resolve(version);
|
|
272
274
|
});
|
|
273
275
|
var log = (message) => stdout.write(message + "\n");
|
|
274
276
|
var banner = () => {
|
|
@@ -361,7 +363,7 @@ function printHelp({
|
|
|
361
363
|
if (headline) {
|
|
362
364
|
message.push(
|
|
363
365
|
linebreak(),
|
|
364
|
-
`${title(commandName)} ${color.green(`v${"4.7.
|
|
366
|
+
`${title(commandName)} ${color.green(`v${"4.7.2"}`)} ${headline}`
|
|
365
367
|
);
|
|
366
368
|
}
|
|
367
369
|
if (usage) {
|
|
@@ -538,14 +540,14 @@ async function getContext(argv) {
|
|
|
538
540
|
if (typescript2 == void 0)
|
|
539
541
|
typescript2 = "strict";
|
|
540
542
|
}
|
|
541
|
-
skipHouston = (os.platform() === "win32" && !fancy || skipHouston) ?? [yes, no, install2, git2, typescript2].some((
|
|
543
|
+
skipHouston = (os.platform() === "win32" && !fancy || skipHouston) ?? [yes, no, install2, git2, typescript2].some((v) => v !== void 0);
|
|
542
544
|
const { messages, hats, ties } = getSeasonalHouston({ fancy });
|
|
543
545
|
const context = {
|
|
544
546
|
help: help2,
|
|
545
547
|
prompt,
|
|
546
548
|
packageManager,
|
|
547
549
|
username: getName(),
|
|
548
|
-
version: getVersion(packageManager),
|
|
550
|
+
version: getVersion(packageManager, "astro"),
|
|
549
551
|
skipHouston,
|
|
550
552
|
fancy,
|
|
551
553
|
dryRun,
|
|
@@ -1129,19 +1131,21 @@ async function typescript(ctx) {
|
|
|
1129
1131
|
var FILES_TO_UPDATE2 = {
|
|
1130
1132
|
"package.json": async (file, options) => {
|
|
1131
1133
|
try {
|
|
1132
|
-
if (options.ctx.install)
|
|
1133
|
-
await shell(options.ctx.packageManager, ["add", "@astrojs/check", "typescript"], {
|
|
1134
|
-
cwd: path6.dirname(file),
|
|
1135
|
-
stdio: "ignore"
|
|
1136
|
-
});
|
|
1137
1134
|
const data = await readFile(file, { encoding: "utf-8" });
|
|
1138
1135
|
const indent = /(^\s+)/m.exec(data)?.[1] ?? " ";
|
|
1139
1136
|
const parsedPackageJson = JSON.parse(data);
|
|
1140
1137
|
const buildScript = parsedPackageJson.scripts?.build;
|
|
1141
1138
|
if (typeof buildScript === "string" && !buildScript.includes("astro check")) {
|
|
1142
1139
|
parsedPackageJson.scripts.build = `astro check && ${buildScript}`;
|
|
1143
|
-
await writeFile(file, JSON.stringify(parsedPackageJson, null, indent), "utf-8");
|
|
1144
1140
|
}
|
|
1141
|
+
const [astroCheckVersion, typescriptVersion] = await Promise.all([
|
|
1142
|
+
getVersion(options.ctx.packageManager, "@astrojs/check"),
|
|
1143
|
+
getVersion(options.ctx.packageManager, "typescript")
|
|
1144
|
+
]);
|
|
1145
|
+
parsedPackageJson.dependencies ??= {};
|
|
1146
|
+
parsedPackageJson.dependencies["@astrojs/check"] = `^${astroCheckVersion}`;
|
|
1147
|
+
parsedPackageJson.dependencies.typescript = `^${typescriptVersion}`;
|
|
1148
|
+
await writeFile(file, JSON.stringify(parsedPackageJson, null, indent), "utf-8");
|
|
1145
1149
|
} catch (err) {
|
|
1146
1150
|
if (err && err.code === "ENOENT")
|
|
1147
1151
|
return;
|
|
@@ -1256,8 +1260,8 @@ async function main() {
|
|
|
1256
1260
|
intro,
|
|
1257
1261
|
projectName,
|
|
1258
1262
|
template,
|
|
1259
|
-
dependencies,
|
|
1260
1263
|
typescript,
|
|
1264
|
+
dependencies,
|
|
1261
1265
|
// Steps which write to files need to go above git
|
|
1262
1266
|
git
|
|
1263
1267
|
];
|
package/dist/messages.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export declare function spinner(args: {
|
|
|
11
11
|
}): Promise<void>;
|
|
12
12
|
export declare const title: (text: string) => string;
|
|
13
13
|
export declare const getName: () => Promise<string>;
|
|
14
|
-
export declare const getVersion: (packageManager: string) => Promise<string>;
|
|
14
|
+
export declare const getVersion: (packageManager: string, packageName: string, fallback?: string) => Promise<string>;
|
|
15
15
|
export declare const log: (message: string) => boolean;
|
|
16
16
|
export declare const banner: () => void;
|
|
17
17
|
export declare const bannerAbort: () => boolean;
|