Skip to content

Commit 4c5a941

Browse files
committed
refactor(cli): reuse npmDistTagForCliVersion in SPA patchers
The react/vue/angular/nuxt patchers each carried a copy of the CLI-version to dist-tag helper. Replace all four with the shared npmDistTagForCliVersion from public-cli, which also falls back to "latest" instead of "alpha" for a stable CLI release. Next keeps its own helper: its fallback is the renderer's pinned dependency version (workspace:* for the lit renderer), not a dist tag.
1 parent 7521246 commit 4c5a941

4 files changed

Lines changed: 8 additions & 29 deletions

File tree

apps/cli/src/lib/orca/patchers/rule/angular/index.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { npmDistTagForCliVersion } from "../../../../public-cli";
12
import type { FileOp } from "../file-writer/types";
23
import type { PatchContext, PatchView } from "../../types";
34
import { AbstractRulePatcher } from "../base";
@@ -40,7 +41,7 @@ export class AngularPatcher extends AbstractRulePatcher {
4041
{
4142
kind: "add-dep",
4243
name: SDK_DEPENDENCY,
43-
version: dependencyVersionForCli(ctx.cliVersion, "alpha"),
44+
version: npmDistTagForCliVersion(ctx.cliVersion),
4445
},
4546
];
4647
}
@@ -61,8 +62,3 @@ export class AngularPatcher extends AbstractRulePatcher {
6162
};
6263
}
6364
}
64-
65-
function dependencyVersionForCli(cliVersion: string, fallback: string): string {
66-
const prerelease = cliVersion.match(/^\d+\.\d+\.\d+-([0-9A-Za-z]+)(?:[.-]|$)/)?.[1];
67-
return prerelease ?? fallback;
68-
}

apps/cli/src/lib/orca/patchers/rule/nuxt/index.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { npmDistTagForCliVersion } from "../../../../public-cli";
12
import { configCandidates } from "../config-paths";
23
import type { FileOp } from "../file-writer/types";
34
import type { PatchContext, PatchView } from "../../types";
@@ -54,7 +55,7 @@ export class NuxtPatcher extends AbstractRulePatcher {
5455
{
5556
kind: "add-dep",
5657
name: SDK_DEPENDENCY,
57-
version: dependencyVersionForCli(ctx.cliVersion, "alpha"),
58+
version: npmDistTagForCliVersion(ctx.cliVersion),
5859
},
5960
];
6061
}
@@ -82,8 +83,3 @@ export class NuxtPatcher extends AbstractRulePatcher {
8283
};
8384
}
8485
}
85-
86-
function dependencyVersionForCli(cliVersion: string, fallback: string): string {
87-
const prerelease = cliVersion.match(/^\d+\.\d+\.\d+-([0-9A-Za-z]+)(?:[.-]|$)/)?.[1];
88-
return prerelease ?? fallback;
89-
}

apps/cli/src/lib/orca/patchers/rule/react/index.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { npmDistTagForCliVersion } from "../../../../public-cli";
12
import type { FileOp } from "../file-writer/types";
23
import type { PatchContext, PatchView } from "../../types";
34
import { AbstractRulePatcher } from "../base";
@@ -36,7 +37,7 @@ export class ReactPatcher extends AbstractRulePatcher implements ViteSupport {
3637
{
3738
kind: "add-dep",
3839
name: SDK_DEPENDENCY,
39-
version: dependencyVersionForCli(ctx.cliVersion, "alpha"),
40+
version: npmDistTagForCliVersion(ctx.cliVersion),
4041
},
4142
];
4243
}
@@ -57,13 +58,3 @@ export class ReactPatcher extends AbstractRulePatcher implements ViteSupport {
5758
};
5859
}
5960
}
60-
61-
/**
62-
* Pins the SDK to the CLI's own prerelease tag (e.g. a `0.1.0-alpha.N` CLI
63-
* installs `@zitadel/sdk-react@alpha`), falling back to a stable range. Mirrors
64-
* the Next patcher so the two cannot drift.
65-
*/
66-
function dependencyVersionForCli(cliVersion: string, fallback: string): string {
67-
const prerelease = cliVersion.match(/^\d+\.\d+\.\d+-([0-9A-Za-z]+)(?:[.-]|$)/)?.[1];
68-
return prerelease ?? fallback;
69-
}

apps/cli/src/lib/orca/patchers/rule/vue/index.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { npmDistTagForCliVersion } from "../../../../public-cli";
12
import type { FileOp } from "../file-writer/types";
23
import type { PatchContext, PatchView } from "../../types";
34
import { AbstractRulePatcher } from "../base";
@@ -31,7 +32,7 @@ export class VuePatcher extends AbstractRulePatcher implements ViteSupport {
3132
{
3233
kind: "add-dep",
3334
name: SDK_DEPENDENCY,
34-
version: dependencyVersionForCli(ctx.cliVersion, "alpha"),
35+
version: npmDistTagForCliVersion(ctx.cliVersion),
3536
},
3637
];
3738
}
@@ -51,8 +52,3 @@ export class VuePatcher extends AbstractRulePatcher implements ViteSupport {
5152
};
5253
}
5354
}
54-
55-
function dependencyVersionForCli(cliVersion: string, fallback: string): string {
56-
const prerelease = cliVersion.match(/^\d+\.\d+\.\d+-([0-9A-Za-z]+)(?:[.-]|$)/)?.[1];
57-
return prerelease ?? fallback;
58-
}

0 commit comments

Comments
 (0)