enablement-build-monorepo-version 2.0.6 → 2.0.7
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 +4 -4
- package/package.json +1 -1
- package/src/lib.mjs +4 -4
- package/tests/lib.test.mjs +5 -5
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@ npx enablement-build-monorepo-version@latest [flags]
|
|
|
27
27
|
| `--hash` | off | Compute and **save** current hashes to the hash state file. Must be run before `--changed` / `--version` to establish a baseline. |
|
|
28
28
|
| `--changed` | off | Print the list of changed packages and emit a `changed` pipeline variable. |
|
|
29
29
|
| `--version` | off | Emit a pipeline variable per changed package containing its next version. |
|
|
30
|
-
| `--save` | off | Write the bumped version back into each changed package's version manifests (`
|
|
30
|
+
| `--save` | off | Write the bumped version back into each changed package's version manifests (`package.json`, `version.json`, and/or `pyproject.toml`). Requires `--version`. |
|
|
31
31
|
| `--tag` | off | Create a git tag (`<short-name>/<version>`) for each changed package, where `short-name` is the npm package name with its scope prefix removed (e.g. `@scope/lib-foo` → `lib-foo/1.2.3`). |
|
|
32
32
|
| `--retag` | off | Convert existing tags that use the old folder-name format to the new short-package-name format. Non-destructive: old tags are left in place. |
|
|
33
33
|
| `--init` | off | Inject `release:*` scripts into the root `package.json` of the target project. Adds scripts that are missing; strips `--children` from any that already exist. Combine with `--try` to preview changes. |
|
|
@@ -54,8 +54,8 @@ Each package directory is scanned for a version manifest in this priority order:
|
|
|
54
54
|
|
|
55
55
|
| File | Format | Version field |
|
|
56
56
|
| ---------------- | ----------------------------------- | -------------------------------------------------------- |
|
|
57
|
-
| `
|
|
58
|
-
| `version.json` | JSON (same shape as `
|
|
57
|
+
| `package.json` | JSON | `"version": "1.2.3"` |
|
|
58
|
+
| `version.json` | JSON (same shape as `package.json`) | `"version": "1.2.3"` |
|
|
59
59
|
| `pyproject.toml` | TOML | `version = "1.2.3"` under `[project]` or `[tool.poetry]` |
|
|
60
60
|
|
|
61
61
|
The first file found is used to determine the current version. When `--save` is enabled, all existing manifests in this set are updated. If none exists the package is treated as version `0.0.0`.
|
|
@@ -161,7 +161,7 @@ If the file is missing or the `--dependencies` path doesn't exist, change propag
|
|
|
161
161
|
- script: echo "$(versions.mypackagename)"
|
|
162
162
|
```
|
|
163
163
|
|
|
164
|
-
To bump and persist the new versions back to the package version manifests (`
|
|
164
|
+
To bump and persist the new versions back to the package version manifests (`package.json`, `version.json`, and `pyproject.toml` when present):
|
|
165
165
|
|
|
166
166
|
```bash
|
|
167
167
|
npx enablement-build-monorepo-version --changed --version --save
|
package/package.json
CHANGED
package/src/lib.mjs
CHANGED
|
@@ -224,19 +224,19 @@ export function dependencyMap(outputFile) {
|
|
|
224
224
|
return parseDependencyMap(JSON.parse(data).graph.dependencies);
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
-
const VERSION_MANIFESTS = ["
|
|
227
|
+
const VERSION_MANIFESTS = ["package.json", "version.json", "pyproject.toml"];
|
|
228
228
|
|
|
229
229
|
function getVersionManifestPaths(basePath) {
|
|
230
230
|
return VERSION_MANIFESTS.map((filename) => path.join(basePath, filename));
|
|
231
231
|
}
|
|
232
232
|
|
|
233
233
|
// Finds the version manifest for a package directory.
|
|
234
|
-
// Priority:
|
|
234
|
+
// Priority: package.json → version.json → pyproject.toml → package.json (fallback path)
|
|
235
235
|
function findVersionFile(basePath) {
|
|
236
236
|
const found = getVersionManifestPaths(basePath).find((filePath) =>
|
|
237
237
|
existsSync(filePath),
|
|
238
238
|
);
|
|
239
|
-
return found || path.join(basePath, "
|
|
239
|
+
return found || path.join(basePath, "package.json");
|
|
240
240
|
}
|
|
241
241
|
|
|
242
242
|
export function buildResult(
|
|
@@ -316,7 +316,7 @@ export async function updateVersion(packageFolder, name, version, options) {
|
|
|
316
316
|
if (manifestFiles.length === 0) {
|
|
317
317
|
console.log(
|
|
318
318
|
"\x1b[36m%s\x1b[0m",
|
|
319
|
-
`[try] Would update ${path.join(basePath, "
|
|
319
|
+
`[try] Would update ${path.join(basePath, "package.json")} → version ${version}`,
|
|
320
320
|
);
|
|
321
321
|
} else {
|
|
322
322
|
manifestFiles.forEach((projectFile) => {
|
package/tests/lib.test.mjs
CHANGED
|
@@ -315,13 +315,13 @@ describe("compare", () => {
|
|
|
315
315
|
});
|
|
316
316
|
|
|
317
317
|
describe("version manifest precedence and updates", () => {
|
|
318
|
-
it("reads current version from
|
|
318
|
+
it("reads current version from package.json before version.json and pyproject.toml", () => {
|
|
319
319
|
const root = mkdtempSync(path.join(os.tmpdir(), "monorepo-version-"));
|
|
320
320
|
const pkgDir = path.join(root, "packages", "alpha");
|
|
321
321
|
mkdirSync(pkgDir, { recursive: true });
|
|
322
322
|
|
|
323
323
|
writeFileSync(
|
|
324
|
-
path.join(pkgDir, "
|
|
324
|
+
path.join(pkgDir, "package.json"),
|
|
325
325
|
JSON.stringify({ name: "@s/alpha-project", version: "1.0.0" }, null, 2),
|
|
326
326
|
"utf8",
|
|
327
327
|
);
|
|
@@ -343,13 +343,13 @@ describe("version manifest precedence and updates", () => {
|
|
|
343
343
|
rmSync(root, { recursive: true, force: true });
|
|
344
344
|
});
|
|
345
345
|
|
|
346
|
-
it("updates all version manifests when
|
|
346
|
+
it("updates all version manifests when package.json, version.json, and pyproject.toml exist", async () => {
|
|
347
347
|
const root = mkdtempSync(path.join(os.tmpdir(), "monorepo-version-"));
|
|
348
348
|
const pkgDir = path.join(root, "packages", "beta");
|
|
349
349
|
mkdirSync(pkgDir, { recursive: true });
|
|
350
350
|
|
|
351
351
|
writeFileSync(
|
|
352
|
-
path.join(pkgDir, "
|
|
352
|
+
path.join(pkgDir, "package.json"),
|
|
353
353
|
JSON.stringify({ name: "@s/beta", version: "1.1.0" }, null, 2),
|
|
354
354
|
"utf8",
|
|
355
355
|
);
|
|
@@ -371,7 +371,7 @@ describe("version manifest precedence and updates", () => {
|
|
|
371
371
|
expect(result).toBe("OK");
|
|
372
372
|
|
|
373
373
|
expect(
|
|
374
|
-
JSON.parse(readFileSync(path.join(pkgDir, "
|
|
374
|
+
JSON.parse(readFileSync(path.join(pkgDir, "package.json"), "utf8"))
|
|
375
375
|
.version,
|
|
376
376
|
).toBe("1.2.0");
|
|
377
377
|
expect(
|