create-angular-lynx 22.2.1 → 22.2.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +24 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-angular-lynx",
3
- "version": "22.2.1",
3
+ "version": "22.2.2",
4
4
  "description": "Create a new AngularLynx project",
5
5
  "homepage": "https://github.com/Blotch-Smart-Frames/AngularLynx#readme",
6
6
  "bugs": {
package/src/index.js CHANGED
@@ -2,8 +2,19 @@
2
2
 
3
3
  import { execSync } from 'node:child_process';
4
4
  import { existsSync } from 'node:fs';
5
+ import { createRequire } from 'node:module';
5
6
  import path from 'node:path';
6
7
 
8
+ // The publish workflow releases this scaffolder in lockstep with
9
+ // @blotch/angular-lynx under one version, whose major mirrors the Angular major
10
+ // the renderer supports. Pinning the Angular CLI and the renderer to it keeps
11
+ // `npm create angular-lynx` working after a newer Angular ships:
12
+ // `@angular/cli@latest` would generate a project that the renderer's peer
13
+ // range rejects, failing `ng add`. A bare major (rather than a `^` range) also
14
+ // sidesteps cmd.exe treating `^` as an escape character on Windows.
15
+ const { version } = createRequire(import.meta.url)('../package.json');
16
+ const angularMajor = version.split('.')[0];
17
+
7
18
  const name = process.argv[2];
8
19
 
9
20
  if (!name) {
@@ -18,15 +29,24 @@ if (existsSync(dest)) {
18
29
  process.exit(1);
19
30
  }
20
31
 
21
- const run = (cmd) => {
32
+ const run = (cmd, cwd) => {
22
33
  console.log(`\n> ${cmd}\n`);
23
- execSync(cmd, { stdio: 'inherit' });
34
+ execSync(cmd, { stdio: 'inherit', cwd });
24
35
  };
25
36
 
26
37
  run(
27
- `npx -y @angular/cli@latest new ${name} --skip-install --skip-git --style css --ssr false`,
38
+ `npx -y @angular/cli@${angularMajor} new ${name} --skip-install --skip-git --style css --ssr false`,
39
+ );
40
+ // `ng add` must run inside the new project so it finds its angular.json and
41
+ // package.json. (`npx -w <dir>` doesn't do this: it treats the current
42
+ // directory as an npm workspace root and fails when it has no package.json.)
43
+ // The CLI is fetched by package name rather than via `npx ng`, because
44
+ // `--skip-install` leaves no local `ng` binary and `npx ng` would download the
45
+ // unrelated `ng` package from npm instead.
46
+ run(
47
+ `npx -y @angular/cli@${angularMajor} add @blotch/angular-lynx@${version} --skip-confirmation`,
48
+ dest,
28
49
  );
29
- run(`npx -y -w ${dest} ng add @blotch/angular-lynx --skip-confirmation`);
30
50
  run(`npm install --prefix ${dest}`);
31
51
 
32
52
  console.log(`