@homeflare/config 0.4.0 → 0.5.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/README.md +38 -0
- package/dist/changeset-workspace.d.ts +5 -0
- package/dist/changeset-workspace.d.ts.map +1 -0
- package/dist/release.d.ts +54 -0
- package/dist/release.d.ts.map +1 -0
- package/dist/release.js +66 -0
- package/dist/release.js.map +10 -0
- package/dist/require-release-config.d.ts +11 -0
- package/dist/require-release-config.d.ts.map +1 -0
- package/dist/require-release-config.js +127 -0
- package/dist/require-release-config.js.map +11 -0
- package/package.json +10 -2
- package/src/changeset-workspace.ts +95 -0
- package/src/release.ts +107 -0
- package/src/require-release-config.ts +100 -0
package/README.md
CHANGED
|
@@ -104,6 +104,44 @@ if (problems.length > 0) throw new Error(problems.join('\n'));
|
|
|
104
104
|
presets, that `.oxfmtrc.json` keeps house style plus at least the house ignores, and that
|
|
105
105
|
`bunfig.toml` still matches.
|
|
106
106
|
|
|
107
|
+
## App releases (no npm)
|
|
108
|
+
|
|
109
|
+
A HomeFlare app that does **not** publish a tarball still versions itself with Changesets
|
|
110
|
+
and cuts a GitHub Release. It does not call `npm publish`.
|
|
111
|
+
|
|
112
|
+
```ts
|
|
113
|
+
import { runAppRelease } from '@homeflare/config/release';
|
|
114
|
+
|
|
115
|
+
await runAppRelease(process.cwd());
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
`shouldRelease` proceeds only when `CHANGELOG.md` has `## <version>` (proof
|
|
119
|
+
`changeset version` ran) AND no git tag `<name>@<version>` exists yet. A custom
|
|
120
|
+
`publish-script` on changesets/action otherwise tags every changeset-less push to `main`
|
|
121
|
+
(measured 2026-09-16/17; changesets/action#9).
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
import { runRequireReleaseConfig } from '@homeflare/config/require-release-config';
|
|
125
|
+
|
|
126
|
+
await runRequireReleaseConfig();
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
⛔ A private `package.json` without `privatePackages.version: true` makes
|
|
130
|
+
`changeset version` silently no-op. The guard fails that combination before the version
|
|
131
|
+
command consumes the changeset file.
|
|
132
|
+
|
|
133
|
+
⛔ A leftover `pnpm-workspace.yaml` that lists only nested packages hides the root.
|
|
134
|
+
Measured 2026-09-17 on `homeflare-secrets`: `changeset version` exited 1 ("package
|
|
135
|
+
homeflare-secrets which is not in the workspace") and no Version Packages PR opened.
|
|
136
|
+
The workspace file must include `.` if it exists at all.
|
|
137
|
+
|
|
138
|
+
⛔ Both helpers take the **app** cwd / paths. Defaulting from `import.meta.url` after
|
|
139
|
+
publish would inspect `@homeflare/config` itself.
|
|
140
|
+
|
|
141
|
+
Alchemy still owns `GitHub.Repository` (visibility, `deleteBranchOnMerge`, `hasWiki`) and
|
|
142
|
+
`Cloudflare.state()`. The kit `main` ruleset is `scripts/apply-main-ruleset.ts`, not an
|
|
143
|
+
Alchemy resource — see `docs/github-hygiene.md`.
|
|
144
|
+
|
|
107
145
|
## License
|
|
108
146
|
|
|
109
147
|
MIT © Timothy Schneider
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function workspacePackageNames(cwd: string): Promise<readonly string[]>;
|
|
2
|
+
/** Package names in a changeset file's YAML frontmatter. */
|
|
3
|
+
export declare function packagesNamedInChangeset(text: string): readonly string[];
|
|
4
|
+
export declare function problemsFromPendingChangesets(cwd: string): Promise<readonly string[]>;
|
|
5
|
+
//# sourceMappingURL=changeset-workspace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"changeset-workspace.d.ts","sourceRoot":"","sources":["../src/changeset-workspace.ts"],"names":[],"mappings":"AA0BA,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,MAAM,EAAE,CAAC,CAcnF;AAkBD,4DAA4D;AAC5D,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAMxE;AAED,wBAAsB,6BAA6B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,MAAM,EAAE,CAAC,CA2B3F"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* No npm publish. Tag a GitHub Release — but ONLY when this version genuinely just
|
|
3
|
+
* came out of `changeset version`, never on an arbitrary changeset-less push to main.
|
|
4
|
+
*
|
|
5
|
+
* 🔴 MEASURED 2026-09-16/17 on homeflare-openbao, and documented upstream
|
|
6
|
+
* (changesets/action's own README, changesets/action#9): a custom publish-script runs
|
|
7
|
+
* on EVERY push to `main` that has zero pending changesets — not just the one push
|
|
8
|
+
* right after a Version Packages PR merges. The README says so directly: "a commit
|
|
9
|
+
* without any new changesets can always land on your base branch after a successful
|
|
10
|
+
* publish... you need to figure out on your own how to skip." Unguarded, this would
|
|
11
|
+
* tag `<name>@<version>` on every unrelated push to main once CHANGELOG.md exists.
|
|
12
|
+
*
|
|
13
|
+
* ★ THE CONDITION: proceed only if `CHANGELOG.md` has an entry for the current version
|
|
14
|
+
* (proof `changeset version` really ran and wrote it) AND no git tag `<name>@<version>`
|
|
15
|
+
* exists yet (proof this exact release was not already cut). Both checks are local —
|
|
16
|
+
* no network, no GitHub API — and both work from the checkout `release.yml` already
|
|
17
|
+
* has (`fetch-depth: 0`).
|
|
18
|
+
*
|
|
19
|
+
* ⛔ TELL changesets/action WHAT TO TAG. With a custom publish-script it learns what
|
|
20
|
+
* shipped only from `CHANGESETS_OUTPUT`. Without it, the action warns "GitHub releases
|
|
21
|
+
* and git tags cannot be created without this output" and creates neither.
|
|
22
|
+
*/
|
|
23
|
+
type Pkg = {
|
|
24
|
+
readonly name: string;
|
|
25
|
+
readonly version: string;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Does CHANGELOG.md have a heading for this exact version?
|
|
29
|
+
* @changesets/changelog-github writes `## <version>` for a single, non-monorepo package.
|
|
30
|
+
*/
|
|
31
|
+
export declare function changelogHasEntry(cwd: string, version: string): Promise<boolean>;
|
|
32
|
+
/** Does this exact tag already exist? Local `git tag -l`, no network. */
|
|
33
|
+
export declare function tagExists(cwd: string, tag: string): boolean;
|
|
34
|
+
export type ReleaseDecision = {
|
|
35
|
+
readonly ok: boolean;
|
|
36
|
+
readonly reason: string;
|
|
37
|
+
};
|
|
38
|
+
export declare function shouldRelease(cwd: string, pkg: Pkg): Promise<ReleaseDecision>;
|
|
39
|
+
/** One ndjson line changesets/action turns into a git tag and a GitHub Release. */
|
|
40
|
+
export declare function tagEvent(pkg: Pkg): {
|
|
41
|
+
type: 'git-tag';
|
|
42
|
+
tag: string;
|
|
43
|
+
packageName: string;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* App-repo publish-script. Reads `package.json` at `cwd`, gates on `shouldRelease`,
|
|
47
|
+
* and writes the tag event to `$CHANGESETS_OUTPUT` when this version is new.
|
|
48
|
+
*
|
|
49
|
+
* ⛔ `cwd` is the APP, never this package. Defaulting from `import.meta.url` after
|
|
50
|
+
* publish would inspect `@homeflare/config` itself.
|
|
51
|
+
*/
|
|
52
|
+
export declare function runAppRelease(cwd: string): Promise<ReleaseDecision>;
|
|
53
|
+
export {};
|
|
54
|
+
//# sourceMappingURL=release.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"release.d.ts","sourceRoot":"","sources":["../src/release.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,KAAK,GAAG,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/D;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAMtF;AAgBD,yEAAyE;AACzE,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAG3D;AAED,MAAM,MAAM,eAAe,GAAG;IAAE,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhF,wBAAsB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,eAAe,CAAC,CAanF;AAED,mFAAmF;AACnF,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAExF;AAED;;;;;;GAMG;AACH,wBAAsB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAiBzE"}
|
package/dist/release.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/release.ts
|
|
3
|
+
async function changelogHasEntry(cwd, version) {
|
|
4
|
+
const file = Bun.file(`${cwd}/CHANGELOG.md`);
|
|
5
|
+
if (!await file.exists())
|
|
6
|
+
return false;
|
|
7
|
+
const escaped = version.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
8
|
+
return new RegExp(`^## ${escaped}$`, "m").test(await file.text());
|
|
9
|
+
}
|
|
10
|
+
var gitEnv = () => {
|
|
11
|
+
const env = { ...process.env };
|
|
12
|
+
delete env.GIT_DIR;
|
|
13
|
+
delete env.GIT_WORK_TREE;
|
|
14
|
+
delete env.GIT_INDEX_FILE;
|
|
15
|
+
return env;
|
|
16
|
+
};
|
|
17
|
+
function tagExists(cwd, tag) {
|
|
18
|
+
const result = Bun.spawnSync(["git", "tag", "-l", tag], { cwd, env: gitEnv() });
|
|
19
|
+
return result.stdout.toString().trim() === tag;
|
|
20
|
+
}
|
|
21
|
+
async function shouldRelease(cwd, pkg) {
|
|
22
|
+
const tag = `${pkg.name}@${pkg.version}`;
|
|
23
|
+
if (!await changelogHasEntry(cwd, pkg.version)) {
|
|
24
|
+
return {
|
|
25
|
+
ok: false,
|
|
26
|
+
reason: `CHANGELOG.md has no "## ${pkg.version}" entry \u2014 changeset version has not run for this version`
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
if (tagExists(cwd, tag)) {
|
|
30
|
+
return { ok: false, reason: `${tag} already exists \u2014 this version was already released` };
|
|
31
|
+
}
|
|
32
|
+
return { ok: true, reason: `CHANGELOG.md has the entry and ${tag} does not exist yet` };
|
|
33
|
+
}
|
|
34
|
+
function tagEvent(pkg) {
|
|
35
|
+
return { type: "git-tag", tag: `${pkg.name}@${pkg.version}`, packageName: pkg.name };
|
|
36
|
+
}
|
|
37
|
+
async function runAppRelease(cwd) {
|
|
38
|
+
const pkg = await Bun.file(`${cwd}/package.json`).json();
|
|
39
|
+
const decision = await shouldRelease(cwd, pkg);
|
|
40
|
+
if (!decision.ok) {
|
|
41
|
+
process.stdout.write(`skip: ${decision.reason}
|
|
42
|
+
`);
|
|
43
|
+
return decision;
|
|
44
|
+
}
|
|
45
|
+
const outputFile = process.env["CHANGESETS_OUTPUT"];
|
|
46
|
+
if (outputFile !== undefined) {
|
|
47
|
+
await Bun.write(outputFile, `${JSON.stringify(tagEvent(pkg))}
|
|
48
|
+
`);
|
|
49
|
+
}
|
|
50
|
+
process.stdout.write(`${pkg.name}@${pkg.version} \u2014 no npm publish; tagged (${decision.reason}).
|
|
51
|
+
`);
|
|
52
|
+
return decision;
|
|
53
|
+
}
|
|
54
|
+
if (import.meta.main) {
|
|
55
|
+
await runAppRelease(process.cwd());
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
changelogHasEntry,
|
|
59
|
+
runAppRelease,
|
|
60
|
+
shouldRelease,
|
|
61
|
+
tagEvent,
|
|
62
|
+
tagExists
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
//# debugId=6C6369E02082921C64756E2164756E21
|
|
66
|
+
//# sourceMappingURL=release.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/release.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * No npm publish. Tag a GitHub Release — but ONLY when this version genuinely just\n * came out of `changeset version`, never on an arbitrary changeset-less push to main.\n *\n * 🔴 MEASURED 2026-09-16/17 on homeflare-openbao, and documented upstream\n * (changesets/action's own README, changesets/action#9): a custom publish-script runs\n * on EVERY push to `main` that has zero pending changesets — not just the one push\n * right after a Version Packages PR merges. The README says so directly: \"a commit\n * without any new changesets can always land on your base branch after a successful\n * publish... you need to figure out on your own how to skip.\" Unguarded, this would\n * tag `<name>@<version>` on every unrelated push to main once CHANGELOG.md exists.\n *\n * ★ THE CONDITION: proceed only if `CHANGELOG.md` has an entry for the current version\n * (proof `changeset version` really ran and wrote it) AND no git tag `<name>@<version>`\n * exists yet (proof this exact release was not already cut). Both checks are local —\n * no network, no GitHub API — and both work from the checkout `release.yml` already\n * has (`fetch-depth: 0`).\n *\n * ⛔ TELL changesets/action WHAT TO TAG. With a custom publish-script it learns what\n * shipped only from `CHANGESETS_OUTPUT`. Without it, the action warns \"GitHub releases\n * and git tags cannot be created without this output\" and creates neither.\n */\ntype Pkg = { readonly name: string; readonly version: string };\n\n/**\n * Does CHANGELOG.md have a heading for this exact version?\n * @changesets/changelog-github writes `## <version>` for a single, non-monorepo package.\n */\nexport async function changelogHasEntry(cwd: string, version: string): Promise<boolean> {\n const file = Bun.file(`${cwd}/CHANGELOG.md`);\n if (!(await file.exists())) return false;\n\n const escaped = version.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n return new RegExp(`^## ${escaped}$`, 'm').test(await file.text());\n}\n\n/**\n * ⛔ DROP HUSKY GIT_DIR. `cwd` is not enough — pre-push exports GIT_DIR\n * and `git tag -l` then reads this checkout, not the throwaway repo.\n * Symptom: shouldRelease is false during verify and a test commits `init`\n * onto the branch being pushed.\n */\nconst gitEnv = (): NodeJS.ProcessEnv => {\n const env = { ...process.env };\n delete env.GIT_DIR;\n delete env.GIT_WORK_TREE;\n delete env.GIT_INDEX_FILE;\n return env;\n};\n\n/** Does this exact tag already exist? Local `git tag -l`, no network. */\nexport function tagExists(cwd: string, tag: string): boolean {\n const result = Bun.spawnSync(['git', 'tag', '-l', tag], { cwd, env: gitEnv() });\n return result.stdout.toString().trim() === tag;\n}\n\nexport type ReleaseDecision = { readonly ok: boolean; readonly reason: string };\n\nexport async function shouldRelease(cwd: string, pkg: Pkg): Promise<ReleaseDecision> {\n const tag = `${pkg.name}@${pkg.version}`;\n\n if (!(await changelogHasEntry(cwd, pkg.version))) {\n return {\n ok: false,\n reason: `CHANGELOG.md has no \"## ${pkg.version}\" entry — changeset version has not run for this version`,\n };\n }\n if (tagExists(cwd, tag)) {\n return { ok: false, reason: `${tag} already exists — this version was already released` };\n }\n return { ok: true, reason: `CHANGELOG.md has the entry and ${tag} does not exist yet` };\n}\n\n/** One ndjson line changesets/action turns into a git tag and a GitHub Release. */\nexport function tagEvent(pkg: Pkg): { type: 'git-tag'; tag: string; packageName: string } {\n return { type: 'git-tag', tag: `${pkg.name}@${pkg.version}`, packageName: pkg.name };\n}\n\n/**\n * App-repo publish-script. Reads `package.json` at `cwd`, gates on `shouldRelease`,\n * and writes the tag event to `$CHANGESETS_OUTPUT` when this version is new.\n *\n * ⛔ `cwd` is the APP, never this package. Defaulting from `import.meta.url` after\n * publish would inspect `@homeflare/config` itself.\n */\nexport async function runAppRelease(cwd: string): Promise<ReleaseDecision> {\n const pkg = (await Bun.file(`${cwd}/package.json`).json()) as Pkg;\n const decision = await shouldRelease(cwd, pkg);\n\n if (!decision.ok) {\n process.stdout.write(`skip: ${decision.reason}\\n`);\n return decision;\n }\n\n const outputFile = process.env['CHANGESETS_OUTPUT'];\n if (outputFile !== undefined) {\n await Bun.write(outputFile, `${JSON.stringify(tagEvent(pkg))}\\n`);\n }\n process.stdout.write(\n `${pkg.name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,SAAS,QAAQ,CAAC,KAAiE;AAAA,EACxF,OAAO,EAAE,MAAM,WAAW,KAAK,GAAG,IAAI,QAAQ,IAAI,WAAW,aAAa,IAAI,KAAK;AAAA;AAUrF,eAAsB,aAAa,CAAC,KAAuC;AAAA,EACzE,MAAM,MAAO,MAAM,IAAI,KAAK,GAAG,kBAAkB,EAAE,KAAK;AAAA,EACxD,MAAM,WAAW,MAAM,cAAc,KAAK,GAAG;AAAA,EAE7C,IAAI,CAAC,SAAS,IAAI;AAAA,IAChB,QAAQ,OAAO,MAAM,SAAS,SAAS;AAAA,CAAU;AAAA,IACjD,OAAO;AAAA,EACT;AAAA,EAEA,MAAM,aAAa,QAAQ,IAAI;AAAA,EAC/B,IAAI,eAAe,WAAW;AAAA,IAC5B,MAAM,IAAI,MAAM,YAAY,GAAG,KAAK,UAAU,SAAS,GAAG,CAAC;AAAA,CAAK;AAAA,EAClE;AAAA,EACA,QAAQ,OAAO,MACb,GAAG,IAAI,QAAQ,IAAI,0CAAqC,SAAS;AAAA,CACnE;AAAA,EACA,OAAO;AAAA;AAGT,IAAI,kBAAkB;AAAA,EACpB,MAAM,cAAc,QAAQ,IAAI,CAAC;AACnC;",
|
|
8
|
+
"debugId": "6C6369E02082921C64756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type ReleaseConfigPaths = {
|
|
2
|
+
readonly pkgPath: string;
|
|
3
|
+
readonly changesetConfigPath: string;
|
|
4
|
+
};
|
|
5
|
+
/** Resolve the two files a version command must see. Override in tests. */
|
|
6
|
+
export declare function releaseConfigPaths(cwd?: string): ReleaseConfigPaths;
|
|
7
|
+
/** One thing a project should fix, in the imperative. */
|
|
8
|
+
export declare function problemsInReleaseConfig(paths: ReleaseConfigPaths): Promise<string[]>;
|
|
9
|
+
/** Print and exit. App `version` scripts call this before `changeset version`. */
|
|
10
|
+
export declare function runRequireReleaseConfig(paths?: Partial<ReleaseConfigPaths>): Promise<void>;
|
|
11
|
+
//# sourceMappingURL=require-release-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"require-release-config.d.ts","sourceRoot":"","sources":["../src/require-release-config.ts"],"names":[],"mappings":"AA8BA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;CACtC,CAAC;AAEF,2EAA2E;AAC3E,wBAAgB,kBAAkB,CAAC,GAAG,GAAE,MAAsB,GAAG,kBAAkB,CAKlF;AAED,yDAAyD;AACzD,wBAAsB,uBAAuB,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAsB1F;AAED,kFAAkF;AAClF,wBAAsB,uBAAuB,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAqBhG"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/changeset-workspace.ts
|
|
3
|
+
import { readdir } from "fs/promises";
|
|
4
|
+
function rootName(pkg) {
|
|
5
|
+
return typeof pkg.name === "string" ? [pkg.name] : [];
|
|
6
|
+
}
|
|
7
|
+
async function workspacePackageNames(cwd) {
|
|
8
|
+
const pnpm = Bun.file(`${cwd}/pnpm-workspace.yaml`);
|
|
9
|
+
if (await pnpm.exists()) {
|
|
10
|
+
const parsed = Bun.YAML.parse(await pnpm.text());
|
|
11
|
+
return namesFromPatterns(cwd, parsed.packages ?? []);
|
|
12
|
+
}
|
|
13
|
+
const pkg = await Bun.file(`${cwd}/package.json`).json();
|
|
14
|
+
if (pkg.workspaces !== undefined && pkg.workspaces.length > 0) {
|
|
15
|
+
return namesFromPatterns(cwd, pkg.workspaces);
|
|
16
|
+
}
|
|
17
|
+
return rootName(pkg);
|
|
18
|
+
}
|
|
19
|
+
async function namesFromPatterns(cwd, patterns) {
|
|
20
|
+
const names = [];
|
|
21
|
+
for (const pattern of patterns) {
|
|
22
|
+
if (pattern.includes("*"))
|
|
23
|
+
continue;
|
|
24
|
+
const pkgPath = pattern === "." ? `${cwd}/package.json` : `${cwd}/${pattern}/package.json`;
|
|
25
|
+
const file = Bun.file(pkgPath);
|
|
26
|
+
if (!await file.exists())
|
|
27
|
+
continue;
|
|
28
|
+
const name = (await file.json()).name;
|
|
29
|
+
if (typeof name === "string")
|
|
30
|
+
names.push(name);
|
|
31
|
+
}
|
|
32
|
+
return names;
|
|
33
|
+
}
|
|
34
|
+
function packagesNamedInChangeset(text) {
|
|
35
|
+
const match = /^---\n([\s\S]*?)\n---/m.exec(text);
|
|
36
|
+
if (match?.[1] === undefined)
|
|
37
|
+
return [];
|
|
38
|
+
const parsed = Bun.YAML.parse(match[1]);
|
|
39
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed))
|
|
40
|
+
return [];
|
|
41
|
+
return Object.keys(parsed);
|
|
42
|
+
}
|
|
43
|
+
async function problemsFromPendingChangesets(cwd) {
|
|
44
|
+
let files;
|
|
45
|
+
try {
|
|
46
|
+
files = (await readdir(`${cwd}/.changeset`)).filter((name) => name.endsWith(".md") && name !== "README.md");
|
|
47
|
+
} catch {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
if (files.length === 0)
|
|
51
|
+
return [];
|
|
52
|
+
const workspace = new Set(await workspacePackageNames(cwd));
|
|
53
|
+
const problems = [];
|
|
54
|
+
for (const name of files) {
|
|
55
|
+
const rel = `.changeset/${name}`;
|
|
56
|
+
for (const pkg of packagesNamedInChangeset(await Bun.file(`${cwd}/${rel}`).text())) {
|
|
57
|
+
if (!workspace.has(pkg)) {
|
|
58
|
+
problems.push(`${rel} names "${pkg}" which is not in the workspace \u2014 changeset version ` + "exits 1 (measured 2026-09-17: leftover pnpm-workspace.yaml listed nested " + "packages and hid the root)");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return problems;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// src/require-release-config.ts
|
|
66
|
+
function releaseConfigPaths(cwd = process.cwd()) {
|
|
67
|
+
return {
|
|
68
|
+
pkgPath: `${cwd}/package.json`,
|
|
69
|
+
changesetConfigPath: `${cwd}/.changeset/config.json`
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
async function problemsInReleaseConfig(paths) {
|
|
73
|
+
const pkg = await Bun.file(paths.pkgPath).json();
|
|
74
|
+
const problems = [];
|
|
75
|
+
if (typeof pkg.version !== "string" || pkg.version.length === 0) {
|
|
76
|
+
problems.push(`${paths.pkgPath} has no "version" \u2014 changeset version would silently no-op`);
|
|
77
|
+
}
|
|
78
|
+
if (pkg.private === true) {
|
|
79
|
+
const changesetConfig = await Bun.file(paths.changesetConfigPath).json();
|
|
80
|
+
if (changesetConfig.privatePackages?.version !== true) {
|
|
81
|
+
problems.push(`${paths.changesetConfigPath} has no privatePackages.version: true \u2014 a private package ` + 'is excluded from versioning entirely, which reads as "nothing to release"');
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const cwd = paths.pkgPath.replace(/\/package\.json$/, "");
|
|
85
|
+
problems.push(...await problemsFromPendingChangesets(cwd));
|
|
86
|
+
return problems;
|
|
87
|
+
}
|
|
88
|
+
async function runRequireReleaseConfig(paths) {
|
|
89
|
+
const defaults = releaseConfigPaths();
|
|
90
|
+
const resolved = {
|
|
91
|
+
pkgPath: paths?.pkgPath ?? defaults.pkgPath,
|
|
92
|
+
changesetConfigPath: paths?.changesetConfigPath ?? defaults.changesetConfigPath
|
|
93
|
+
};
|
|
94
|
+
const problems = await problemsInReleaseConfig(resolved);
|
|
95
|
+
if (problems.length > 0) {
|
|
96
|
+
process.stderr.write(`
|
|
97
|
+
\u2717 changeset version would silently no-op:
|
|
98
|
+
`);
|
|
99
|
+
for (const problem of problems)
|
|
100
|
+
process.stderr.write(` - ${problem}
|
|
101
|
+
`);
|
|
102
|
+
process.stderr.write(`
|
|
103
|
+
Fix the file(s) above in a reviewed commit, then re-run this.
|
|
104
|
+
|
|
105
|
+
`);
|
|
106
|
+
process.exit(1);
|
|
107
|
+
}
|
|
108
|
+
const pkg = await Bun.file(resolved.pkgPath).json();
|
|
109
|
+
process.stdout.write(`ok: ${resolved.pkgPath} version is ${pkg.version}, privatePackages.version is set
|
|
110
|
+
`);
|
|
111
|
+
}
|
|
112
|
+
if (import.meta.main) {
|
|
113
|
+
const pkgPath = process.argv[2];
|
|
114
|
+
const changesetConfigPath = process.argv[3];
|
|
115
|
+
await runRequireReleaseConfig({
|
|
116
|
+
...pkgPath === undefined ? {} : { pkgPath },
|
|
117
|
+
...changesetConfigPath === undefined ? {} : { changesetConfigPath }
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
export {
|
|
121
|
+
problemsInReleaseConfig,
|
|
122
|
+
releaseConfigPaths,
|
|
123
|
+
runRequireReleaseConfig
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
//# debugId=5B77C8600B7D3E7B64756E2164756E21
|
|
127
|
+
//# sourceMappingURL=require-release-config.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/changeset-workspace.ts", "../src/require-release-config.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * Pending changesets must name a package Changesets actually considers a workspace\n * member. Otherwise `changeset version` exits 1 and no Version Packages PR opens.\n *\n * 🔴 MEASURED 2026-09-17 on homeflare-secrets. A leftover `pnpm-workspace.yaml`\n * listed only `hfs` and `secret-vault`. `@changesets/cli` treats that file as the\n * workspace, so the root package (`homeflare-secrets` — the GitHub Release) was\n * \"not in the workspace\". The hygiene changeset named the root. Release on main\n * failed; no Version PR, no tag.\n *\n * ★ Root is a member only when the workspace file says so (`.` or a package.json\n * `workspaces` entry). Nested leftover packages keep their own package.json for\n * their own tools; they are not this repo's release.\n */\nimport { readdir } from 'node:fs/promises';\n\ntype WorkspaceFile = { readonly packages?: readonly string[] };\ntype RootPkg = {\n readonly name?: unknown;\n readonly workspaces?: readonly string[];\n};\n\nfunction rootName(pkg: RootPkg): readonly string[] {\n return typeof pkg.name === 'string' ? [pkg.name] : [];\n}\n\nexport async function workspacePackageNames(cwd: string): Promise<readonly string[]> {\n const pnpm = Bun.file(`${cwd}/pnpm-workspace.yaml`);\n if (await pnpm.exists()) {\n const parsed = Bun.YAML.parse(await pnpm.text()) as WorkspaceFile;\n return namesFromPatterns(cwd, parsed.packages ?? []);\n }\n\n const pkg = (await Bun.file(`${cwd}/package.json`).json()) as RootPkg;\n // ★ Array form only. The yarn `{ packages: [] }` object is unused in this estate,\n // and `Array.isArray` does not narrow that union under exactOptionalPropertyTypes.\n if (pkg.workspaces !== undefined && pkg.workspaces.length > 0) {\n return namesFromPatterns(cwd, pkg.workspaces);\n }\n return rootName(pkg);\n}\n\nasync function namesFromPatterns(cwd: string, patterns: readonly string[]): Promise<string[]> {\n const names: string[] = [];\n for (const pattern of patterns) {\n // ⛔ Full glob support is not the job. Changesets already expands globs; this\n // guard only needs `.` and literal directory members — the case that hid\n // the root. A `*` pattern is skipped rather than half-parsed.\n if (pattern.includes('*')) continue;\n const pkgPath = pattern === '.' ? `${cwd}/package.json` : `${cwd}/${pattern}/package.json`;\n const file = Bun.file(pkgPath);\n if (!(await file.exists())) continue;\n const name = ((await file.json()) as { readonly name?: unknown }).name;\n if (typeof name === 'string') names.push(name);\n }\n return names;\n}\n\n/** Package names in a changeset file's YAML frontmatter. */\nexport function packagesNamedInChangeset(text: string): readonly string[] {\n const match = /^---\\n([\\s\\S]*?)\\n---/m.exec(text);\n if (match?.[1] === undefined) return [];\n const parsed = Bun.YAML.parse(match[1]);\n if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) return [];\n return Object.keys(parsed);\n}\n\nexport async function problemsFromPendingChangesets(cwd: string): Promise<readonly string[]> {\n let files: string[];\n try {\n files = (await readdir(`${cwd}/.changeset`)).filter(\n (name) => name.endsWith('.md') && name !== 'README.md',\n );\n } catch {\n // Missing `.changeset` is not a fault — nothing pending.\n return [];\n }\n if (files.length === 0) return [];\n\n const workspace = new Set(await workspacePackageNames(cwd));\n const problems: string[] = [];\n for (const name of files) {\n const rel = `.changeset/${name}`;\n for (const pkg of packagesNamedInChangeset(await Bun.file(`${cwd}/${rel}`).text())) {\n if (!workspace.has(pkg)) {\n problems.push(\n `${rel} names \"${pkg}\" which is not in the workspace — changeset version ` +\n 'exits 1 (measured 2026-09-17: leftover pnpm-workspace.yaml listed nested ' +\n 'packages and hid the root)',\n );\n }\n }\n }\n return problems;\n}\n",
|
|
6
|
+
"/**\n * Refuse to let `changeset version` run against a config that would silently no-op.\n *\n * 🔴 MEASURED 2026-09-16 on homeflare-openbao, TWO INDEPENDENT WAYS TO GET THE SAME\n * SILENT FAILURE. `@changesets/cli` 3.0.3 does neither of these things loudly:\n * 1. `package.json` with no \"version\" — `changeset version` consumes the pending\n * changeset file, writes no `CHANGELOG.md`, leaves `package.json` untouched.\n * 2. `\"private\": true` with no `privatePackages.version: true` in\n * `.changeset/config.json` — the package is excluded from versioning entirely;\n * `changeset status` reports zero packages to bump even with a real version and a\n * pending changeset file.\n * Either gap alone reproduces the same no-op. Both are required together.\n *\n * ★ This is regression protection against either field being dropped — a bad merge, a\n * hand-edit, a generator overwriting either file — not a bootstrap blocker.\n *\n * 🔴 A leftover `pnpm-workspace.yaml` that lists only nested packages hides the\n * root. `changeset version` then exits 1 (\"package X is not in the workspace\") —\n * measured 2026-09-17 on homeflare-secrets. `problemsFromPendingChangesets`\n * fails that before the version command consumes the file.\n *\n * ⛔ Path defaults are `process.cwd()`, NEVER `import.meta.url`. After publish this\n * file lives in `node_modules/@homeflare/config`; resolving next to it would check\n * the published package, not the app that invoked it.\n */\nimport { problemsFromPendingChangesets } from './changeset-workspace.ts';\n\ntype Pkg = { readonly version?: unknown; readonly private?: unknown };\ntype ChangesetConfig = { readonly privatePackages?: { readonly version?: unknown } };\n\nexport type ReleaseConfigPaths = {\n readonly pkgPath: string;\n readonly changesetConfigPath: string;\n};\n\n/** Resolve the two files a version command must see. Override in tests. */\nexport function releaseConfigPaths(cwd: string = process.cwd()): ReleaseConfigPaths {\n return {\n pkgPath: `${cwd}/package.json`,\n changesetConfigPath: `${cwd}/.changeset/config.json`,\n };\n}\n\n/** One thing a project should fix, in the imperative. */\nexport async function problemsInReleaseConfig(paths: ReleaseConfigPaths): Promise<string[]> {\n const pkg = (await Bun.file(paths.pkgPath).json()) as Pkg;\n const problems: string[] = [];\n\n if (typeof pkg.version !== 'string' || pkg.version.length === 0) {\n problems.push(`${paths.pkgPath} has no \"version\" — changeset version would silently no-op`);\n }\n\n if (pkg.private === true) {\n const changesetConfig = (await Bun.file(paths.changesetConfigPath).json()) as ChangesetConfig;\n if (changesetConfig.privatePackages?.version !== true) {\n problems.push(\n `${paths.changesetConfigPath} has no privatePackages.version: true — a private package ` +\n 'is excluded from versioning entirely, which reads as \"nothing to release\"',\n );\n }\n }\n\n const cwd = paths.pkgPath.replace(/\\/package\\.json$/, '');\n problems.push(...(await problemsFromPendingChangesets(cwd)));\n\n return problems;\n}\n\n/** Print and exit. App `version` scripts call this before `changeset version`. */\nexport async function runRequireReleaseConfig(paths?: Partial<ReleaseConfigPaths>): Promise<void> {\n // ⚠️ A spread of `{ pkgPath: undefined }` from `process.argv[2]` would overwrite the\n // cwd default. Only copy keys that are actually present.\n const defaults = releaseConfigPaths();\n const resolved: ReleaseConfigPaths = {\n pkgPath: paths?.pkgPath ?? defaults.pkgPath,\n changesetConfigPath: paths?.changesetConfigPath ?? defaults.changesetConfigPath,\n };\n const problems = await problemsInReleaseConfig(resolved);\n\n if (problems.length > 0) {\n process.stderr.write('\\n✗ changeset version would silently no-op:\\n');\n for (const problem of problems) process.stderr.write(` - ${problem}\\n`);\n process.stderr.write('\\n Fix the file(s) above in a reviewed commit, then re-run this.\\n\\n');\n process.exit(1);\n }\n\n const pkg = (await Bun.file(resolved.pkgPath).json()) as Pkg;\n process.stdout.write(\n `ok: ${resolved.pkgPath} version is ${pkg.version}, privatePackages.version is set\\n`,\n );\n}\n\nif (import.meta.main) {\n const pkgPath = process.argv[2];\n const changesetConfigPath = process.argv[3];\n await runRequireReleaseConfig({\n ...(pkgPath === undefined ? {} : { pkgPath }),\n ...(changesetConfigPath === undefined ? {} : { changesetConfigPath }),\n });\n}\n"
|
|
7
|
+
],
|
|
8
|
+
"mappings": ";;AAcA;AAQA,SAAS,QAAQ,CAAC,KAAiC;AAAA,EACjD,OAAO,OAAO,IAAI,SAAS,WAAW,CAAC,IAAI,IAAI,IAAI,CAAC;AAAA;AAGtD,eAAsB,qBAAqB,CAAC,KAAyC;AAAA,EACnF,MAAM,OAAO,IAAI,KAAK,GAAG,yBAAyB;AAAA,EAClD,IAAI,MAAM,KAAK,OAAO,GAAG;AAAA,IACvB,MAAM,SAAS,IAAI,KAAK,MAAM,MAAM,KAAK,KAAK,CAAC;AAAA,IAC/C,OAAO,kBAAkB,KAAK,OAAO,YAAY,CAAC,CAAC;AAAA,EACrD;AAAA,EAEA,MAAM,MAAO,MAAM,IAAI,KAAK,GAAG,kBAAkB,EAAE,KAAK;AAAA,EAGxD,IAAI,IAAI,eAAe,aAAa,IAAI,WAAW,SAAS,GAAG;AAAA,IAC7D,OAAO,kBAAkB,KAAK,IAAI,UAAU;AAAA,EAC9C;AAAA,EACA,OAAO,SAAS,GAAG;AAAA;AAGrB,eAAe,iBAAiB,CAAC,KAAa,UAAgD;AAAA,EAC5F,MAAM,QAAkB,CAAC;AAAA,EACzB,WAAW,WAAW,UAAU;AAAA,IAI9B,IAAI,QAAQ,SAAS,GAAG;AAAA,MAAG;AAAA,IAC3B,MAAM,UAAU,YAAY,MAAM,GAAG,qBAAqB,GAAG,OAAO;AAAA,IACpE,MAAM,OAAO,IAAI,KAAK,OAAO;AAAA,IAC7B,IAAI,CAAE,MAAM,KAAK,OAAO;AAAA,MAAI;AAAA,IAC5B,MAAM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KAAK;AAAA,EACnD,QAAQ,OAAO,MACb,OAAO,SAAS,sBAAsB,IAAI;AAAA,CAC5C;AAAA;AAGF,IAAI,kBAAkB;AAAA,EACpB,MAAM,UAAU,QAAQ,KAAK;AAAA,EAC7B,MAAM,sBAAsB,QAAQ,KAAK;AAAA,EACzC,MAAM,wBAAwB;AAAA,OACxB,YAAY,YAAY,CAAC,IAAI,EAAE,QAAQ;AAAA,OACvC,wBAAwB,YAAY,CAAC,IAAI,EAAE,oBAAoB;AAAA,EACrE,CAAC;AACH;",
|
|
9
|
+
"debugId": "5B77C8600B7D3E7B64756E2164756E21",
|
|
10
|
+
"names": []
|
|
11
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@homeflare/config",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Shared tsconfig, oxlint and
|
|
3
|
+
"version": "0.5.1",
|
|
4
|
+
"description": "Shared tsconfig, oxlint, oxfmt, and non-npm release helpers for HomeFlare projects.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Timothy Schneider",
|
|
7
7
|
"repository": {
|
|
@@ -35,6 +35,14 @@
|
|
|
35
35
|
"types": "./dist/check.d.ts",
|
|
36
36
|
"default": "./dist/check.js"
|
|
37
37
|
},
|
|
38
|
+
"./release": {
|
|
39
|
+
"types": "./dist/release.d.ts",
|
|
40
|
+
"default": "./dist/release.js"
|
|
41
|
+
},
|
|
42
|
+
"./require-release-config": {
|
|
43
|
+
"types": "./dist/require-release-config.d.ts",
|
|
44
|
+
"default": "./dist/require-release-config.js"
|
|
45
|
+
},
|
|
38
46
|
"./package.json": "./package.json"
|
|
39
47
|
},
|
|
40
48
|
"publishConfig": {
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pending changesets must name a package Changesets actually considers a workspace
|
|
3
|
+
* member. Otherwise `changeset version` exits 1 and no Version Packages PR opens.
|
|
4
|
+
*
|
|
5
|
+
* 🔴 MEASURED 2026-09-17 on homeflare-secrets. A leftover `pnpm-workspace.yaml`
|
|
6
|
+
* listed only `hfs` and `secret-vault`. `@changesets/cli` treats that file as the
|
|
7
|
+
* workspace, so the root package (`homeflare-secrets` — the GitHub Release) was
|
|
8
|
+
* "not in the workspace". The hygiene changeset named the root. Release on main
|
|
9
|
+
* failed; no Version PR, no tag.
|
|
10
|
+
*
|
|
11
|
+
* ★ Root is a member only when the workspace file says so (`.` or a package.json
|
|
12
|
+
* `workspaces` entry). Nested leftover packages keep their own package.json for
|
|
13
|
+
* their own tools; they are not this repo's release.
|
|
14
|
+
*/
|
|
15
|
+
import { readdir } from 'node:fs/promises';
|
|
16
|
+
|
|
17
|
+
type WorkspaceFile = { readonly packages?: readonly string[] };
|
|
18
|
+
type RootPkg = {
|
|
19
|
+
readonly name?: unknown;
|
|
20
|
+
readonly workspaces?: readonly string[];
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
function rootName(pkg: RootPkg): readonly string[] {
|
|
24
|
+
return typeof pkg.name === 'string' ? [pkg.name] : [];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export async function workspacePackageNames(cwd: string): Promise<readonly string[]> {
|
|
28
|
+
const pnpm = Bun.file(`${cwd}/pnpm-workspace.yaml`);
|
|
29
|
+
if (await pnpm.exists()) {
|
|
30
|
+
const parsed = Bun.YAML.parse(await pnpm.text()) as WorkspaceFile;
|
|
31
|
+
return namesFromPatterns(cwd, parsed.packages ?? []);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const pkg = (await Bun.file(`${cwd}/package.json`).json()) as RootPkg;
|
|
35
|
+
// ★ Array form only. The yarn `{ packages: [] }` object is unused in this estate,
|
|
36
|
+
// and `Array.isArray` does not narrow that union under exactOptionalPropertyTypes.
|
|
37
|
+
if (pkg.workspaces !== undefined && pkg.workspaces.length > 0) {
|
|
38
|
+
return namesFromPatterns(cwd, pkg.workspaces);
|
|
39
|
+
}
|
|
40
|
+
return rootName(pkg);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async function namesFromPatterns(cwd: string, patterns: readonly string[]): Promise<string[]> {
|
|
44
|
+
const names: string[] = [];
|
|
45
|
+
for (const pattern of patterns) {
|
|
46
|
+
// ⛔ Full glob support is not the job. Changesets already expands globs; this
|
|
47
|
+
// guard only needs `.` and literal directory members — the case that hid
|
|
48
|
+
// the root. A `*` pattern is skipped rather than half-parsed.
|
|
49
|
+
if (pattern.includes('*')) continue;
|
|
50
|
+
const pkgPath = pattern === '.' ? `${cwd}/package.json` : `${cwd}/${pattern}/package.json`;
|
|
51
|
+
const file = Bun.file(pkgPath);
|
|
52
|
+
if (!(await file.exists())) continue;
|
|
53
|
+
const name = ((await file.json()) as { readonly name?: unknown }).name;
|
|
54
|
+
if (typeof name === 'string') names.push(name);
|
|
55
|
+
}
|
|
56
|
+
return names;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Package names in a changeset file's YAML frontmatter. */
|
|
60
|
+
export function packagesNamedInChangeset(text: string): readonly string[] {
|
|
61
|
+
const match = /^---\n([\s\S]*?)\n---/m.exec(text);
|
|
62
|
+
if (match?.[1] === undefined) return [];
|
|
63
|
+
const parsed = Bun.YAML.parse(match[1]);
|
|
64
|
+
if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) return [];
|
|
65
|
+
return Object.keys(parsed);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export async function problemsFromPendingChangesets(cwd: string): Promise<readonly string[]> {
|
|
69
|
+
let files: string[];
|
|
70
|
+
try {
|
|
71
|
+
files = (await readdir(`${cwd}/.changeset`)).filter(
|
|
72
|
+
(name) => name.endsWith('.md') && name !== 'README.md',
|
|
73
|
+
);
|
|
74
|
+
} catch {
|
|
75
|
+
// Missing `.changeset` is not a fault — nothing pending.
|
|
76
|
+
return [];
|
|
77
|
+
}
|
|
78
|
+
if (files.length === 0) return [];
|
|
79
|
+
|
|
80
|
+
const workspace = new Set(await workspacePackageNames(cwd));
|
|
81
|
+
const problems: string[] = [];
|
|
82
|
+
for (const name of files) {
|
|
83
|
+
const rel = `.changeset/${name}`;
|
|
84
|
+
for (const pkg of packagesNamedInChangeset(await Bun.file(`${cwd}/${rel}`).text())) {
|
|
85
|
+
if (!workspace.has(pkg)) {
|
|
86
|
+
problems.push(
|
|
87
|
+
`${rel} names "${pkg}" which is not in the workspace — changeset version ` +
|
|
88
|
+
'exits 1 (measured 2026-09-17: leftover pnpm-workspace.yaml listed nested ' +
|
|
89
|
+
'packages and hid the root)',
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return problems;
|
|
95
|
+
}
|
package/src/release.ts
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* No npm publish. Tag a GitHub Release — but ONLY when this version genuinely just
|
|
3
|
+
* came out of `changeset version`, never on an arbitrary changeset-less push to main.
|
|
4
|
+
*
|
|
5
|
+
* 🔴 MEASURED 2026-09-16/17 on homeflare-openbao, and documented upstream
|
|
6
|
+
* (changesets/action's own README, changesets/action#9): a custom publish-script runs
|
|
7
|
+
* on EVERY push to `main` that has zero pending changesets — not just the one push
|
|
8
|
+
* right after a Version Packages PR merges. The README says so directly: "a commit
|
|
9
|
+
* without any new changesets can always land on your base branch after a successful
|
|
10
|
+
* publish... you need to figure out on your own how to skip." Unguarded, this would
|
|
11
|
+
* tag `<name>@<version>` on every unrelated push to main once CHANGELOG.md exists.
|
|
12
|
+
*
|
|
13
|
+
* ★ THE CONDITION: proceed only if `CHANGELOG.md` has an entry for the current version
|
|
14
|
+
* (proof `changeset version` really ran and wrote it) AND no git tag `<name>@<version>`
|
|
15
|
+
* exists yet (proof this exact release was not already cut). Both checks are local —
|
|
16
|
+
* no network, no GitHub API — and both work from the checkout `release.yml` already
|
|
17
|
+
* has (`fetch-depth: 0`).
|
|
18
|
+
*
|
|
19
|
+
* ⛔ TELL changesets/action WHAT TO TAG. With a custom publish-script it learns what
|
|
20
|
+
* shipped only from `CHANGESETS_OUTPUT`. Without it, the action warns "GitHub releases
|
|
21
|
+
* and git tags cannot be created without this output" and creates neither.
|
|
22
|
+
*/
|
|
23
|
+
type Pkg = { readonly name: string; readonly version: string };
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Does CHANGELOG.md have a heading for this exact version?
|
|
27
|
+
* @changesets/changelog-github writes `## <version>` for a single, non-monorepo package.
|
|
28
|
+
*/
|
|
29
|
+
export async function changelogHasEntry(cwd: string, version: string): Promise<boolean> {
|
|
30
|
+
const file = Bun.file(`${cwd}/CHANGELOG.md`);
|
|
31
|
+
if (!(await file.exists())) return false;
|
|
32
|
+
|
|
33
|
+
const escaped = version.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
34
|
+
return new RegExp(`^## ${escaped}$`, 'm').test(await file.text());
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* ⛔ DROP HUSKY GIT_DIR. `cwd` is not enough — pre-push exports GIT_DIR
|
|
39
|
+
* and `git tag -l` then reads this checkout, not the throwaway repo.
|
|
40
|
+
* Symptom: shouldRelease is false during verify and a test commits `init`
|
|
41
|
+
* onto the branch being pushed.
|
|
42
|
+
*/
|
|
43
|
+
const gitEnv = (): NodeJS.ProcessEnv => {
|
|
44
|
+
const env = { ...process.env };
|
|
45
|
+
delete env.GIT_DIR;
|
|
46
|
+
delete env.GIT_WORK_TREE;
|
|
47
|
+
delete env.GIT_INDEX_FILE;
|
|
48
|
+
return env;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/** Does this exact tag already exist? Local `git tag -l`, no network. */
|
|
52
|
+
export function tagExists(cwd: string, tag: string): boolean {
|
|
53
|
+
const result = Bun.spawnSync(['git', 'tag', '-l', tag], { cwd, env: gitEnv() });
|
|
54
|
+
return result.stdout.toString().trim() === tag;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export type ReleaseDecision = { readonly ok: boolean; readonly reason: string };
|
|
58
|
+
|
|
59
|
+
export async function shouldRelease(cwd: string, pkg: Pkg): Promise<ReleaseDecision> {
|
|
60
|
+
const tag = `${pkg.name}@${pkg.version}`;
|
|
61
|
+
|
|
62
|
+
if (!(await changelogHasEntry(cwd, pkg.version))) {
|
|
63
|
+
return {
|
|
64
|
+
ok: false,
|
|
65
|
+
reason: `CHANGELOG.md has no "## ${pkg.version}" entry — changeset version has not run for this version`,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
if (tagExists(cwd, tag)) {
|
|
69
|
+
return { ok: false, reason: `${tag} already exists — this version was already released` };
|
|
70
|
+
}
|
|
71
|
+
return { ok: true, reason: `CHANGELOG.md has the entry and ${tag} does not exist yet` };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** One ndjson line changesets/action turns into a git tag and a GitHub Release. */
|
|
75
|
+
export function tagEvent(pkg: Pkg): { type: 'git-tag'; tag: string; packageName: string } {
|
|
76
|
+
return { type: 'git-tag', tag: `${pkg.name}@${pkg.version}`, packageName: pkg.name };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* App-repo publish-script. Reads `package.json` at `cwd`, gates on `shouldRelease`,
|
|
81
|
+
* and writes the tag event to `$CHANGESETS_OUTPUT` when this version is new.
|
|
82
|
+
*
|
|
83
|
+
* ⛔ `cwd` is the APP, never this package. Defaulting from `import.meta.url` after
|
|
84
|
+
* publish would inspect `@homeflare/config` itself.
|
|
85
|
+
*/
|
|
86
|
+
export async function runAppRelease(cwd: string): Promise<ReleaseDecision> {
|
|
87
|
+
const pkg = (await Bun.file(`${cwd}/package.json`).json()) as Pkg;
|
|
88
|
+
const decision = await shouldRelease(cwd, pkg);
|
|
89
|
+
|
|
90
|
+
if (!decision.ok) {
|
|
91
|
+
process.stdout.write(`skip: ${decision.reason}\n`);
|
|
92
|
+
return decision;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const outputFile = process.env['CHANGESETS_OUTPUT'];
|
|
96
|
+
if (outputFile !== undefined) {
|
|
97
|
+
await Bun.write(outputFile, `${JSON.stringify(tagEvent(pkg))}\n`);
|
|
98
|
+
}
|
|
99
|
+
process.stdout.write(
|
|
100
|
+
`${pkg.name}@${pkg.version} — no npm publish; tagged (${decision.reason}).\n`,
|
|
101
|
+
);
|
|
102
|
+
return decision;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (import.meta.main) {
|
|
106
|
+
await runAppRelease(process.cwd());
|
|
107
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Refuse to let `changeset version` run against a config that would silently no-op.
|
|
3
|
+
*
|
|
4
|
+
* 🔴 MEASURED 2026-09-16 on homeflare-openbao, TWO INDEPENDENT WAYS TO GET THE SAME
|
|
5
|
+
* SILENT FAILURE. `@changesets/cli` 3.0.3 does neither of these things loudly:
|
|
6
|
+
* 1. `package.json` with no "version" — `changeset version` consumes the pending
|
|
7
|
+
* changeset file, writes no `CHANGELOG.md`, leaves `package.json` untouched.
|
|
8
|
+
* 2. `"private": true` with no `privatePackages.version: true` in
|
|
9
|
+
* `.changeset/config.json` — the package is excluded from versioning entirely;
|
|
10
|
+
* `changeset status` reports zero packages to bump even with a real version and a
|
|
11
|
+
* pending changeset file.
|
|
12
|
+
* Either gap alone reproduces the same no-op. Both are required together.
|
|
13
|
+
*
|
|
14
|
+
* ★ This is regression protection against either field being dropped — a bad merge, a
|
|
15
|
+
* hand-edit, a generator overwriting either file — not a bootstrap blocker.
|
|
16
|
+
*
|
|
17
|
+
* 🔴 A leftover `pnpm-workspace.yaml` that lists only nested packages hides the
|
|
18
|
+
* root. `changeset version` then exits 1 ("package X is not in the workspace") —
|
|
19
|
+
* measured 2026-09-17 on homeflare-secrets. `problemsFromPendingChangesets`
|
|
20
|
+
* fails that before the version command consumes the file.
|
|
21
|
+
*
|
|
22
|
+
* ⛔ Path defaults are `process.cwd()`, NEVER `import.meta.url`. After publish this
|
|
23
|
+
* file lives in `node_modules/@homeflare/config`; resolving next to it would check
|
|
24
|
+
* the published package, not the app that invoked it.
|
|
25
|
+
*/
|
|
26
|
+
import { problemsFromPendingChangesets } from './changeset-workspace.ts';
|
|
27
|
+
|
|
28
|
+
type Pkg = { readonly version?: unknown; readonly private?: unknown };
|
|
29
|
+
type ChangesetConfig = { readonly privatePackages?: { readonly version?: unknown } };
|
|
30
|
+
|
|
31
|
+
export type ReleaseConfigPaths = {
|
|
32
|
+
readonly pkgPath: string;
|
|
33
|
+
readonly changesetConfigPath: string;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/** Resolve the two files a version command must see. Override in tests. */
|
|
37
|
+
export function releaseConfigPaths(cwd: string = process.cwd()): ReleaseConfigPaths {
|
|
38
|
+
return {
|
|
39
|
+
pkgPath: `${cwd}/package.json`,
|
|
40
|
+
changesetConfigPath: `${cwd}/.changeset/config.json`,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** One thing a project should fix, in the imperative. */
|
|
45
|
+
export async function problemsInReleaseConfig(paths: ReleaseConfigPaths): Promise<string[]> {
|
|
46
|
+
const pkg = (await Bun.file(paths.pkgPath).json()) as Pkg;
|
|
47
|
+
const problems: string[] = [];
|
|
48
|
+
|
|
49
|
+
if (typeof pkg.version !== 'string' || pkg.version.length === 0) {
|
|
50
|
+
problems.push(`${paths.pkgPath} has no "version" — changeset version would silently no-op`);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (pkg.private === true) {
|
|
54
|
+
const changesetConfig = (await Bun.file(paths.changesetConfigPath).json()) as ChangesetConfig;
|
|
55
|
+
if (changesetConfig.privatePackages?.version !== true) {
|
|
56
|
+
problems.push(
|
|
57
|
+
`${paths.changesetConfigPath} has no privatePackages.version: true — a private package ` +
|
|
58
|
+
'is excluded from versioning entirely, which reads as "nothing to release"',
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const cwd = paths.pkgPath.replace(/\/package\.json$/, '');
|
|
64
|
+
problems.push(...(await problemsFromPendingChangesets(cwd)));
|
|
65
|
+
|
|
66
|
+
return problems;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Print and exit. App `version` scripts call this before `changeset version`. */
|
|
70
|
+
export async function runRequireReleaseConfig(paths?: Partial<ReleaseConfigPaths>): Promise<void> {
|
|
71
|
+
// ⚠️ A spread of `{ pkgPath: undefined }` from `process.argv[2]` would overwrite the
|
|
72
|
+
// cwd default. Only copy keys that are actually present.
|
|
73
|
+
const defaults = releaseConfigPaths();
|
|
74
|
+
const resolved: ReleaseConfigPaths = {
|
|
75
|
+
pkgPath: paths?.pkgPath ?? defaults.pkgPath,
|
|
76
|
+
changesetConfigPath: paths?.changesetConfigPath ?? defaults.changesetConfigPath,
|
|
77
|
+
};
|
|
78
|
+
const problems = await problemsInReleaseConfig(resolved);
|
|
79
|
+
|
|
80
|
+
if (problems.length > 0) {
|
|
81
|
+
process.stderr.write('\n✗ changeset version would silently no-op:\n');
|
|
82
|
+
for (const problem of problems) process.stderr.write(` - ${problem}\n`);
|
|
83
|
+
process.stderr.write('\n Fix the file(s) above in a reviewed commit, then re-run this.\n\n');
|
|
84
|
+
process.exit(1);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const pkg = (await Bun.file(resolved.pkgPath).json()) as Pkg;
|
|
88
|
+
process.stdout.write(
|
|
89
|
+
`ok: ${resolved.pkgPath} version is ${pkg.version}, privatePackages.version is set\n`,
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (import.meta.main) {
|
|
94
|
+
const pkgPath = process.argv[2];
|
|
95
|
+
const changesetConfigPath = process.argv[3];
|
|
96
|
+
await runRequireReleaseConfig({
|
|
97
|
+
...(pkgPath === undefined ? {} : { pkgPath }),
|
|
98
|
+
...(changesetConfigPath === undefined ? {} : { changesetConfigPath }),
|
|
99
|
+
});
|
|
100
|
+
}
|