create-ts-monorepo-starter 0.2.0 → 0.2.1
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 +35 -44
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -298,6 +298,15 @@ class ToolchainError extends Error {
|
|
|
298
298
|
}
|
|
299
299
|
}
|
|
300
300
|
const PNPM_HELP = 'https://github.com/prosdevlab/create-ts-monorepo-starter#pnpm';
|
|
301
|
+
/** The stop for a pnpm older than 10.26, which can't switch itself to the template's pnpm. */
|
|
302
|
+
function tooOld(found, spec) {
|
|
303
|
+
const version = spec.slice('pnpm@'.length);
|
|
304
|
+
return new ToolchainError(`pnpm ${found} is too old for this project`, [
|
|
305
|
+
`This project needs pnpm 10.26 or newer, which switches itself to pnpm ${version}.`,
|
|
306
|
+
'Upgrade pnpm: npm install -g pnpm (or https://pnpm.io/installation)',
|
|
307
|
+
'Then run this command again. Nothing was created.',
|
|
308
|
+
]);
|
|
309
|
+
}
|
|
301
310
|
const fileExists = (path) => access(path).then(() => true, () => false);
|
|
302
311
|
/**
|
|
303
312
|
* Runs `pnpm --version` in an empty folder pinned to `spec` (`pnpm@12.15.0`), where pnpm switches
|
|
@@ -351,8 +360,6 @@ function installCommand(status, dir, lockfileOnly) {
|
|
|
351
360
|
const extra = ['--no-frozen-lockfile', ...(lockfileOnly ? ['--lockfile-only'] : [])];
|
|
352
361
|
if (status.kind === 'ok')
|
|
353
362
|
return { cmd: 'pnpm', args: ['install', ...extra], cwd: dir };
|
|
354
|
-
if (status.kind === 'old')
|
|
355
|
-
return null;
|
|
356
363
|
return {
|
|
357
364
|
cmd: 'npm',
|
|
358
365
|
args: [
|
|
@@ -3630,19 +3637,14 @@ function closing(result, plan) {
|
|
|
3630
3637
|
let title = 'Ready.';
|
|
3631
3638
|
let commands = [];
|
|
3632
3639
|
let notes = [];
|
|
3633
|
-
if (result.pnpm.kind === '
|
|
3634
|
-
title = 'Upgrade pnpm, then install:';
|
|
3635
|
-
commands = ['npm install -g pnpm'];
|
|
3636
|
-
notes = [`Any pnpm from 10.26 on switches itself to ${pin} for this project.`];
|
|
3637
|
-
}
|
|
3638
|
-
else if (result.pnpm.kind === 'none') {
|
|
3640
|
+
if (result.pnpm.kind === 'none') {
|
|
3639
3641
|
title = 'One step left before your first commit:';
|
|
3640
3642
|
commands = ['npm install -g pnpm'];
|
|
3641
3643
|
notes = [
|
|
3642
3644
|
`The git hooks run pnpm. Any pnpm from 10.26 on switches itself to ${pin.split('.')[0]}.`,
|
|
3643
3645
|
];
|
|
3644
3646
|
}
|
|
3645
|
-
const extra = !result.installed
|
|
3647
|
+
const extra = !result.installed
|
|
3646
3648
|
? ["Dependencies aren't installed: the first pnpm install installs them and the git hooks."]
|
|
3647
3649
|
: [];
|
|
3648
3650
|
const dir = cdPath(plan.target, result.backup !== undefined);
|
|
@@ -4110,6 +4112,8 @@ async function run(plan, ui, deps = {}) {
|
|
|
4110
4112
|
const spec = pnpmSpec(await readFile(join(from, 'package.json'), 'utf8'));
|
|
4111
4113
|
const pin = spec.slice('pnpm@'.length);
|
|
4112
4114
|
const pnpm = await detectPnpm(exec);
|
|
4115
|
+
if (pnpm.kind === 'old')
|
|
4116
|
+
throw tooOld(pnpm.version, spec);
|
|
4113
4117
|
if (pnpm.kind === 'ok')
|
|
4114
4118
|
await checkSwitch(spec, pnpm.version, exec);
|
|
4115
4119
|
await (deps.generate ?? generate)({
|
|
@@ -4148,40 +4152,29 @@ async function run(plan, ui, deps = {}) {
|
|
|
4148
4152
|
}
|
|
4149
4153
|
}
|
|
4150
4154
|
const command = installCommand(pnpm, temp, !plan.install);
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
'It would install with the wrong pnpm and Node, and skip the',
|
|
4157
|
-
'3-day release rule. Install skipped.',
|
|
4155
|
+
const what = plan.install ? 'install dependencies' : 'update the lockfile';
|
|
4156
|
+
if (pnpm.kind === 'none') {
|
|
4157
|
+
const doing = plan.install ? 'Installing' : 'Updating the lockfile';
|
|
4158
|
+
ui.warn("pnpm isn't installed", [
|
|
4159
|
+
`${doing} with a temporary pnpm ${pin} instead (npm exec).`,
|
|
4158
4160
|
]);
|
|
4159
4161
|
}
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
]);
|
|
4167
|
-
}
|
|
4168
|
-
const using = pnpm.kind === 'ok' ? ` with pnpm ${pin}` : '';
|
|
4169
|
-
const started = performance.now();
|
|
4170
|
-
ui.start(plan.install ? `Installing dependencies${using}` : 'Updating the lockfile');
|
|
4171
|
-
let output;
|
|
4172
|
-
try {
|
|
4173
|
-
output = await exec(command.cmd, command.args, { cwd: command.cwd });
|
|
4174
|
-
}
|
|
4175
|
-
finally {
|
|
4176
|
-
ui.stop();
|
|
4177
|
-
}
|
|
4178
|
-
seconds = Math.round((performance.now() - started) / 1000);
|
|
4179
|
-
if (output.code !== 0) {
|
|
4180
|
-
throw new RunError(`Couldn't ${what} (pnpm exited with ${output.code})`, lastLines(output));
|
|
4181
|
-
}
|
|
4182
|
-
installed = plan.install;
|
|
4183
|
-
ui.step(plan.install ? `Installed dependencies${using} (${seconds}s)` : 'Updated the lockfile');
|
|
4162
|
+
const using = pnpm.kind === 'ok' ? ` with pnpm ${pin}` : '';
|
|
4163
|
+
const started = performance.now();
|
|
4164
|
+
ui.start(plan.install ? `Installing dependencies${using}` : 'Updating the lockfile');
|
|
4165
|
+
let output;
|
|
4166
|
+
try {
|
|
4167
|
+
output = await exec(command.cmd, command.args, { cwd: command.cwd });
|
|
4184
4168
|
}
|
|
4169
|
+
finally {
|
|
4170
|
+
ui.stop();
|
|
4171
|
+
}
|
|
4172
|
+
const seconds = Math.round((performance.now() - started) / 1000);
|
|
4173
|
+
if (output.code !== 0) {
|
|
4174
|
+
throw new RunError(`Couldn't ${what} (pnpm exited with ${output.code})`, lastLines(output));
|
|
4175
|
+
}
|
|
4176
|
+
const installed = plan.install;
|
|
4177
|
+
ui.step(plan.install ? `Installed dependencies${using} (${seconds}s)` : 'Updated the lockfile');
|
|
4185
4178
|
assertLockfileSubset(await readFile(join(from, 'pnpm-lock.yaml'), 'utf8'), await readFile(join(temp, 'pnpm-lock.yaml'), 'utf8'));
|
|
4186
4179
|
let outcome = git === 'ready' ? 'failed' : git;
|
|
4187
4180
|
if (git === 'ready') {
|
|
@@ -4335,10 +4328,8 @@ async function check(ui, exec) {
|
|
|
4335
4328
|
return 0;
|
|
4336
4329
|
}
|
|
4337
4330
|
if (pnpm.kind === 'old') {
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
'Upgrade pnpm (https://pnpm.io/installation), then run --check again.',
|
|
4341
|
-
]);
|
|
4331
|
+
const error = tooOld(pnpm.version, spec);
|
|
4332
|
+
ui.fail(error.message, error.lines);
|
|
4342
4333
|
return TOOLCHAIN;
|
|
4343
4334
|
}
|
|
4344
4335
|
try {
|