repokeeper 0.4.6 → 0.4.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/dist/model.js +4 -0
- package/dist/modules/release.js +7 -1
- package/dist/stacks/gradle.js +9 -2
- package/dist/sync/apply.js +4 -1
- package/dist/sync/decide.js +6 -2
- package/dist/sync/lock.js +2 -0
- package/dist/sync/marker.js +28 -0
- package/dist/sync/state.js +5 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/model.js
CHANGED
|
@@ -2,6 +2,8 @@ export const MANAGED_HEADER = "Managed by repokeeper (https://github.com/vannt-d
|
|
|
2
2
|
/** Header of YAML files repokeeper creates but owns only in part. */
|
|
3
3
|
export const YAML_HEADER = `${MANAGED_HEADER} Keys and jobs you add yourself are left alone.`;
|
|
4
4
|
export function outputId(output) {
|
|
5
|
+
if (output.kind === "marker")
|
|
6
|
+
return `marker:${output.path}`;
|
|
5
7
|
if (output.kind === "file")
|
|
6
8
|
return `file:${output.path}`;
|
|
7
9
|
if (output.kind === "seed")
|
|
@@ -13,6 +15,8 @@ export function outputId(output) {
|
|
|
13
15
|
return `json:${output.path}#${JSON.stringify(output.keyPath)}`;
|
|
14
16
|
}
|
|
15
17
|
export function describeOutput(output) {
|
|
18
|
+
if (output.kind === "marker")
|
|
19
|
+
return `${output.path} (release-please version markers)`;
|
|
16
20
|
if (output.kind === "file" || output.kind === "seed")
|
|
17
21
|
return output.path;
|
|
18
22
|
if (output.kind === "block")
|
package/dist/modules/release.js
CHANGED
|
@@ -6,5 +6,11 @@ export function pickRelease(stacks) {
|
|
|
6
6
|
export const releaseModule = {
|
|
7
7
|
id: "release",
|
|
8
8
|
enabled: (config) => config.modules.release,
|
|
9
|
-
outputs: (ctx) =>
|
|
9
|
+
outputs: (ctx) => {
|
|
10
|
+
const release = pickRelease(ctx.stacks);
|
|
11
|
+
const markers = release.versionLine
|
|
12
|
+
? [{ kind: "marker", module: "release", path: release.versionLine.path, line: release.versionLine.line }]
|
|
13
|
+
: [];
|
|
14
|
+
return [...ctx.platform.releaseAutomation(ctx, release), ...markers];
|
|
15
|
+
},
|
|
10
16
|
};
|
package/dist/stacks/gradle.js
CHANGED
|
@@ -10,7 +10,14 @@ export async function gradleBuild(root) {
|
|
|
10
10
|
return {
|
|
11
11
|
command: wrapper ? "./gradlew check" : "gradle check",
|
|
12
12
|
wrapper,
|
|
13
|
-
// release-please's generic updater
|
|
14
|
-
|
|
13
|
+
// release-please's generic updater only edits gradle.properties between x-release-please markers,
|
|
14
|
+
// which the release module adds around the version line
|
|
15
|
+
release: {
|
|
16
|
+
type: "simple",
|
|
17
|
+
version,
|
|
18
|
+
...(version !== null
|
|
19
|
+
? { extraFiles: ["gradle.properties"], versionLine: { path: "gradle.properties", line: "^version\\s*=" } }
|
|
20
|
+
: {}),
|
|
21
|
+
},
|
|
15
22
|
};
|
|
16
23
|
}
|
package/dist/sync/apply.js
CHANGED
|
@@ -5,6 +5,7 @@ import { removeBlock, upsertBlock } from "./block.js";
|
|
|
5
5
|
import { hashText } from "./hash.js";
|
|
6
6
|
import { deleteAtPath, formatJson, setAtPath } from "./json.js";
|
|
7
7
|
import { targetOf, writeLock } from "./lock.js";
|
|
8
|
+
import { addMarkers } from "./marker.js";
|
|
8
9
|
import { desiredText } from "./state.js";
|
|
9
10
|
import { deleteYamlKey, setYamlKey } from "./yaml.js";
|
|
10
11
|
async function readOrNull(path) {
|
|
@@ -26,6 +27,8 @@ async function write(root, output) {
|
|
|
26
27
|
if (output.kind === "file" || output.kind === "seed")
|
|
27
28
|
return put(path, output.content);
|
|
28
29
|
const existing = await readOrNull(path);
|
|
30
|
+
if (output.kind === "marker")
|
|
31
|
+
return existing === null ? undefined : put(path, addMarkers(existing, output.line));
|
|
29
32
|
if (output.kind === "block")
|
|
30
33
|
return put(path, upsertBlock(existing, output.id, output.body, output.comment));
|
|
31
34
|
if (output.kind === "yaml") {
|
|
@@ -37,7 +40,7 @@ async function write(root, output) {
|
|
|
37
40
|
}
|
|
38
41
|
async function remove(root, target) {
|
|
39
42
|
const path = join(root, target.path);
|
|
40
|
-
if (target.kind === "seed")
|
|
43
|
+
if (target.kind === "seed" || target.kind === "marker")
|
|
41
44
|
return;
|
|
42
45
|
if (target.kind === "file")
|
|
43
46
|
return rm(path, { force: true });
|
package/dist/sync/decide.js
CHANGED
|
@@ -7,6 +7,9 @@ export function decide(output, currentText, entry, adopt) {
|
|
|
7
7
|
const current = hashText(currentText);
|
|
8
8
|
if (current === hashText(desiredText(output)))
|
|
9
9
|
return "unchanged";
|
|
10
|
+
// adding the two marker lines is always safe, so they are written without --adopt or --accept
|
|
11
|
+
if (output.kind === "marker")
|
|
12
|
+
return "write";
|
|
10
13
|
if (entry)
|
|
11
14
|
return current === entry.hash ? "write" : "conflict";
|
|
12
15
|
return adopt ? "adopt" : "unmanaged";
|
|
@@ -15,7 +18,8 @@ export function decide(output, currentText, entry, adopt) {
|
|
|
15
18
|
export function decideRemoval(entry, currentText) {
|
|
16
19
|
if (currentText === null)
|
|
17
20
|
return "gone";
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
// other tools own a seed once it exists, and release-please uses the markers
|
|
22
|
+
if (entry.target.kind === "seed" || entry.target.kind === "marker")
|
|
23
|
+
return "left";
|
|
20
24
|
return hashText(currentText) === entry.hash ? "delete" : "orphan-edited";
|
|
21
25
|
}
|
package/dist/sync/lock.js
CHANGED
|
@@ -3,6 +3,8 @@ import { dirname, join } from "node:path";
|
|
|
3
3
|
import { LockError } from "../errors.js";
|
|
4
4
|
export const LOCK_FILE = ".repokeeper/lock.json";
|
|
5
5
|
export function targetOf(output) {
|
|
6
|
+
if (output.kind === "marker")
|
|
7
|
+
return { kind: "marker", path: output.path, line: output.line };
|
|
6
8
|
if (output.kind === "file")
|
|
7
9
|
return { kind: "file", path: output.path };
|
|
8
10
|
if (output.kind === "seed")
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** release-please's block markers for a version in a file its generic updater edits. */
|
|
2
|
+
export const MARKER_START = "# x-release-please-start-version";
|
|
3
|
+
export const MARKER_END = "# x-release-please-end";
|
|
4
|
+
const HAS_MARKERS = /x-release-please-(start-version|version)\b/;
|
|
5
|
+
const UNMARKED = "unmarked";
|
|
6
|
+
function eolOf(text) {
|
|
7
|
+
return text.includes("\r\n") ? "\r\n" : "\n";
|
|
8
|
+
}
|
|
9
|
+
function lineIndex(lines, line) {
|
|
10
|
+
const pattern = new RegExp(line);
|
|
11
|
+
return lines.findIndex((l) => pattern.test(l));
|
|
12
|
+
}
|
|
13
|
+
/** "" when there is nothing to add (no file, no matching line, or markers already present), else "unmarked". */
|
|
14
|
+
export function markerState(text, line) {
|
|
15
|
+
if (text === null || HAS_MARKERS.test(text))
|
|
16
|
+
return "";
|
|
17
|
+
return lineIndex(text.split(eolOf(text)), line) === -1 ? "" : UNMARKED;
|
|
18
|
+
}
|
|
19
|
+
/** The text with block markers around the first line matching `line`; unchanged when there is nothing to add. */
|
|
20
|
+
export function addMarkers(text, line) {
|
|
21
|
+
if (markerState(text, line) === "")
|
|
22
|
+
return text;
|
|
23
|
+
const eol = eolOf(text);
|
|
24
|
+
const lines = text.split(eol);
|
|
25
|
+
const index = lineIndex(lines, line);
|
|
26
|
+
lines.splice(index, 1, MARKER_START, lines[index], MARKER_END);
|
|
27
|
+
return lines.join(eol);
|
|
28
|
+
}
|
package/dist/sync/state.js
CHANGED
|
@@ -3,13 +3,14 @@ import { join } from "node:path";
|
|
|
3
3
|
import { UsageError } from "../errors.js";
|
|
4
4
|
import { readBlock } from "./block.js";
|
|
5
5
|
import { getAtPath } from "./json.js";
|
|
6
|
+
import { markerState } from "./marker.js";
|
|
6
7
|
import { readYamlKey } from "./yaml.js";
|
|
7
8
|
/** The text repokeeper compares and hashes for an output. */
|
|
8
9
|
export function desiredText(output) {
|
|
9
10
|
if (output.kind === "file")
|
|
10
11
|
return output.content;
|
|
11
12
|
// a seed only has to exist, so present content always compares equal
|
|
12
|
-
if (output.kind === "seed")
|
|
13
|
+
if (output.kind === "seed" || output.kind === "marker")
|
|
13
14
|
return "";
|
|
14
15
|
if (output.kind === "block")
|
|
15
16
|
return output.body;
|
|
@@ -28,6 +29,9 @@ async function readText(root, path) {
|
|
|
28
29
|
/** The same comparable text read from disk, or null when absent. */
|
|
29
30
|
export async function readCurrent(root, target) {
|
|
30
31
|
const text = await readText(root, target.path);
|
|
32
|
+
// markers are added to a file the user owns; a missing file or line means there is nothing to add
|
|
33
|
+
if (target.kind === "marker")
|
|
34
|
+
return markerState(text, target.line);
|
|
31
35
|
if (text === null)
|
|
32
36
|
return null;
|
|
33
37
|
if (target.kind === "file")
|
package/dist/version.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
export const PACKAGE_VERSION = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
|
|
3
3
|
/** The standard this build of repokeeper applies. Bump it whenever generated output changes. */
|
|
4
|
-
export const STANDARD_VERSION = "1.4.
|
|
4
|
+
export const STANDARD_VERSION = "1.4.3";
|
|
5
5
|
export const TOOL_VERSIONS = {
|
|
6
6
|
lefthook: "2.1.14",
|
|
7
7
|
commitlintCli: "21.2.3",
|
package/package.json
CHANGED