betterstart-cli 0.0.64 → 0.0.67
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/cli.js +110 -25
- package/dist/cli.js.map +1 -1
- package/package.json +3 -2
package/dist/cli.js
CHANGED
|
@@ -279,7 +279,7 @@ function runCommand(pm, script) {
|
|
|
279
279
|
function createNextAppCommand(pm) {
|
|
280
280
|
switch (pm) {
|
|
281
281
|
case "pnpm":
|
|
282
|
-
return { bin: "pnpm", prefix: ["
|
|
282
|
+
return { bin: "pnpm", prefix: ["dlx", "create-next-app@latest"] };
|
|
283
283
|
case "yarn":
|
|
284
284
|
return { bin: "yarn", prefix: ["create", "next-app@latest"] };
|
|
285
285
|
case "bun":
|
|
@@ -1078,8 +1078,11 @@ var REACT_ADMIN_DEPS = [
|
|
|
1078
1078
|
var REACT_ADMIN_DEV_DEPS = ["@tailwindcss/typography"];
|
|
1079
1079
|
|
|
1080
1080
|
// adapters/next/init/scaffolders/dependencies.ts
|
|
1081
|
+
import { parseDocument } from "yaml";
|
|
1081
1082
|
var CLI_PACKAGE_NAME = "betterstart-cli";
|
|
1082
1083
|
var LOCAL_PACKAGE_PREFIXES = ["workspace:", "link:", "file:", "portal:"];
|
|
1084
|
+
var MIN_SUPPORTED_PNPM_MAJOR = 9;
|
|
1085
|
+
var PINNED_PNPM_PACKAGE_MANAGER = "pnpm@11.9.0";
|
|
1083
1086
|
var TIPTAP_PACKAGE_PREFIX = "@tiptap/";
|
|
1084
1087
|
var TIPTAP_PACKAGE_VERSION_SPEC = "^3.26.0";
|
|
1085
1088
|
var CODEMIRROR_PACKAGE_SPECS = {
|
|
@@ -1121,6 +1124,46 @@ function readProjectPackageJson(cwd) {
|
|
|
1121
1124
|
return null;
|
|
1122
1125
|
}
|
|
1123
1126
|
}
|
|
1127
|
+
function findPnpmWorkspacePath(cwd) {
|
|
1128
|
+
let currentDir = path8.resolve(cwd);
|
|
1129
|
+
const filesystemRoot = path8.parse(currentDir).root;
|
|
1130
|
+
while (true) {
|
|
1131
|
+
const workspacePath = path8.join(currentDir, "pnpm-workspace.yaml");
|
|
1132
|
+
if (fs7.existsSync(workspacePath)) {
|
|
1133
|
+
return workspacePath;
|
|
1134
|
+
}
|
|
1135
|
+
if (currentDir === filesystemRoot) {
|
|
1136
|
+
return path8.join(path8.resolve(cwd), "pnpm-workspace.yaml");
|
|
1137
|
+
}
|
|
1138
|
+
currentDir = path8.dirname(currentDir);
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
function isSupportedPnpmPackageManager(packageManager) {
|
|
1142
|
+
const pnpmVersionMatch = /^pnpm@(\d+)\.\d+\.\d+(?:[-+].+)?$/.exec(packageManager);
|
|
1143
|
+
return Boolean(pnpmVersionMatch && Number(pnpmVersionMatch[1]) >= MIN_SUPPORTED_PNPM_MAJOR);
|
|
1144
|
+
}
|
|
1145
|
+
function hasSupportedAncestorPnpmPackageManager(cwd) {
|
|
1146
|
+
let currentDir = path8.dirname(path8.resolve(cwd));
|
|
1147
|
+
const filesystemRoot = path8.parse(currentDir).root;
|
|
1148
|
+
while (true) {
|
|
1149
|
+
const packageJsonPath = path8.join(currentDir, "package.json");
|
|
1150
|
+
if (fs7.existsSync(packageJsonPath)) {
|
|
1151
|
+
try {
|
|
1152
|
+
const packageJson = JSON.parse(
|
|
1153
|
+
fs7.readFileSync(packageJsonPath, "utf-8")
|
|
1154
|
+
);
|
|
1155
|
+
if (packageJson.packageManager) {
|
|
1156
|
+
return isSupportedPnpmPackageManager(packageJson.packageManager);
|
|
1157
|
+
}
|
|
1158
|
+
} catch {
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
if (currentDir === filesystemRoot) {
|
|
1162
|
+
return false;
|
|
1163
|
+
}
|
|
1164
|
+
currentDir = path8.dirname(currentDir);
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1124
1167
|
function dependencySpecMatches(spec, name) {
|
|
1125
1168
|
return spec === name || spec.startsWith(`${name}@`);
|
|
1126
1169
|
}
|
|
@@ -1146,6 +1189,7 @@ function getPnpmPackageExtensionsToEnsure(pkg, dependencies) {
|
|
|
1146
1189
|
}
|
|
1147
1190
|
function ensurePnpmPackageExtensions(cwd, dependencies) {
|
|
1148
1191
|
const pkgPath = path8.join(cwd, "package.json");
|
|
1192
|
+
const workspacePath = findPnpmWorkspacePath(cwd);
|
|
1149
1193
|
const pkg = readProjectPackageJson(cwd);
|
|
1150
1194
|
if (!pkg) {
|
|
1151
1195
|
return;
|
|
@@ -1154,31 +1198,66 @@ function ensurePnpmPackageExtensions(cwd, dependencies) {
|
|
|
1154
1198
|
if (Object.keys(extensionsToEnsure).length === 0) {
|
|
1155
1199
|
return;
|
|
1156
1200
|
}
|
|
1157
|
-
|
|
1158
|
-
const
|
|
1159
|
-
|
|
1201
|
+
const workspaceContent = fs7.existsSync(workspacePath) ? fs7.readFileSync(workspacePath, "utf-8") : "{}\n";
|
|
1202
|
+
const workspaceDocument = parseDocument(workspaceContent);
|
|
1203
|
+
if (workspaceDocument.errors.length > 0) {
|
|
1204
|
+
throw new Error(
|
|
1205
|
+
`Could not update pnpm-workspace.yaml: ${workspaceDocument.errors[0]?.message ?? "invalid YAML"}`
|
|
1206
|
+
);
|
|
1207
|
+
}
|
|
1208
|
+
let workspaceChanged = false;
|
|
1209
|
+
let packageJsonChanged = false;
|
|
1160
1210
|
for (const [selector, extension] of Object.entries(extensionsToEnsure)) {
|
|
1161
|
-
const
|
|
1162
|
-
const
|
|
1163
|
-
|
|
1211
|
+
const legacyExtension = pkg.pnpm?.packageExtensions?.[selector];
|
|
1212
|
+
for (const section of ["dependencies", "peerDependencies"]) {
|
|
1213
|
+
for (const [name, version2] of Object.entries(legacyExtension?.[section] ?? {})) {
|
|
1214
|
+
const valuePath = ["packageExtensions", selector, section, name];
|
|
1215
|
+
if (workspaceDocument.getIn(valuePath) === void 0) {
|
|
1216
|
+
workspaceDocument.setIn(valuePath, version2);
|
|
1217
|
+
workspaceChanged = true;
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1164
1221
|
for (const [name, version2] of Object.entries(extension.dependencies ?? {})) {
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1222
|
+
const valuePath = ["packageExtensions", selector, "dependencies", name];
|
|
1223
|
+
if (workspaceDocument.getIn(valuePath) !== version2) {
|
|
1224
|
+
workspaceDocument.setIn(valuePath, version2);
|
|
1225
|
+
workspaceChanged = true;
|
|
1168
1226
|
}
|
|
1169
1227
|
}
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1228
|
+
const legacyPackageExtensions = pkg.pnpm?.packageExtensions;
|
|
1229
|
+
if (legacyPackageExtensions && Object.hasOwn(legacyPackageExtensions, selector)) {
|
|
1230
|
+
delete legacyPackageExtensions[selector];
|
|
1231
|
+
packageJsonChanged = true;
|
|
1232
|
+
if (Object.keys(legacyPackageExtensions).length === 0 && pkg.pnpm) {
|
|
1233
|
+
const { packageExtensions: _packageExtensions, ...remainingPnpmConfig } = pkg.pnpm;
|
|
1234
|
+
pkg.pnpm = Object.keys(remainingPnpmConfig).length > 0 ? remainingPnpmConfig : void 0;
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
if (workspaceChanged) {
|
|
1239
|
+
fs7.writeFileSync(workspacePath, workspaceDocument.toString({ lineWidth: 0 }), "utf-8");
|
|
1174
1240
|
}
|
|
1175
|
-
if (
|
|
1241
|
+
if (packageJsonChanged) {
|
|
1242
|
+
fs7.writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}
|
|
1243
|
+
`, "utf-8");
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
function ensurePnpmPackageManager(cwd) {
|
|
1247
|
+
const pkgPath = path8.join(cwd, "package.json");
|
|
1248
|
+
const pkg = readProjectPackageJson(cwd);
|
|
1249
|
+
if (!pkg) {
|
|
1176
1250
|
return;
|
|
1177
1251
|
}
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1252
|
+
const currentPackageManager = pkg.packageManager;
|
|
1253
|
+
if (currentPackageManager) {
|
|
1254
|
+
if (isSupportedPnpmPackageManager(currentPackageManager)) {
|
|
1255
|
+
return;
|
|
1256
|
+
}
|
|
1257
|
+
} else if (hasSupportedAncestorPnpmPackageManager(cwd)) {
|
|
1258
|
+
return;
|
|
1259
|
+
}
|
|
1260
|
+
pkg.packageManager = PINNED_PNPM_PACKAGE_MANAGER;
|
|
1182
1261
|
fs7.writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}
|
|
1183
1262
|
`, "utf-8");
|
|
1184
1263
|
}
|
|
@@ -1346,13 +1425,20 @@ function buildRemoveArgs(pm, deps, dev) {
|
|
|
1346
1425
|
function spawnAsync(cmd, args, cwd) {
|
|
1347
1426
|
return new Promise((resolve, reject) => {
|
|
1348
1427
|
const child = spawn(cmd, args, { cwd, stdio: "pipe" });
|
|
1428
|
+
let stdout = "";
|
|
1349
1429
|
let stderr = "";
|
|
1430
|
+
child.stdout?.on("data", (chunk) => {
|
|
1431
|
+
stdout += chunk.toString();
|
|
1432
|
+
});
|
|
1350
1433
|
child.stderr?.on("data", (chunk) => {
|
|
1351
1434
|
stderr += chunk.toString();
|
|
1352
1435
|
});
|
|
1353
1436
|
child.on("close", (code) => {
|
|
1354
1437
|
if (code === 0) resolve();
|
|
1355
|
-
else
|
|
1438
|
+
else {
|
|
1439
|
+
const output = [stdout.trim(), stderr.trim()].filter(Boolean).join("\n");
|
|
1440
|
+
reject(new Error(output || `${cmd} exited with code ${code}`));
|
|
1441
|
+
}
|
|
1356
1442
|
});
|
|
1357
1443
|
child.on("error", reject);
|
|
1358
1444
|
});
|
|
@@ -1392,6 +1478,7 @@ async function installDependenciesAsync({
|
|
|
1392
1478
|
const installPlan = resolveDependencyInstallPlan({ cwd, pm, dependencies, devDependencies });
|
|
1393
1479
|
try {
|
|
1394
1480
|
if (pm === "pnpm") {
|
|
1481
|
+
ensurePnpmPackageManager(cwd);
|
|
1395
1482
|
ensurePnpmPackageExtensions(cwd, installPlan.dependencies);
|
|
1396
1483
|
}
|
|
1397
1484
|
if (installPlan.dependencies.length > 0) {
|
|
@@ -27367,10 +27454,8 @@ async function runInitCommand(name, options) {
|
|
|
27367
27454
|
])
|
|
27368
27455
|
)
|
|
27369
27456
|
});
|
|
27370
|
-
let depsInstalled = false;
|
|
27371
27457
|
if (depsResult.success) {
|
|
27372
27458
|
s.stop("");
|
|
27373
|
-
depsInstalled = true;
|
|
27374
27459
|
} else {
|
|
27375
27460
|
s.stop("Failed to install dependencies");
|
|
27376
27461
|
p22.log.warning(depsResult.error ?? "Unknown error");
|
|
@@ -27379,10 +27464,10 @@ async function runInitCommand(name, options) {
|
|
|
27379
27464
|
${pc9.cyan(`${pm} add ${depsResult.dependencies.join(" ")}`)}
|
|
27380
27465
|
${pc9.cyan(`${pm} add -D ${depsResult.devDeps.join(" ")}`)}`
|
|
27381
27466
|
);
|
|
27467
|
+
disposeCancelGuard();
|
|
27468
|
+
process.exit(1);
|
|
27382
27469
|
}
|
|
27383
|
-
|
|
27384
|
-
process.stdout.write("\x1B[2A\x1B[J");
|
|
27385
|
-
}
|
|
27470
|
+
process.stdout.write("\x1B[2A\x1B[J");
|
|
27386
27471
|
s.start("Generating core schemas");
|
|
27387
27472
|
const coreSchemasResult = scaffoldCoreSchemas({ cwd, config });
|
|
27388
27473
|
s.stop("");
|