@plexus-ms/lib 0.122.1 → 0.124.0
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/bookkeeping.d.ts +0 -8
- package/dist/bookkeeping.d.ts.map +1 -1
- package/dist/bookkeeping.js +5 -16
- package/dist/bookkeeping.js.map +1 -1
- package/dist/compose.d.ts +41 -0
- package/dist/compose.d.ts.map +1 -0
- package/dist/compose.js +169 -0
- package/dist/compose.js.map +1 -0
- package/dist/consumers.d.ts +3 -18
- package/dist/consumers.d.ts.map +1 -1
- package/dist/consumers.js +13 -42
- package/dist/consumers.js.map +1 -1
- package/dist/context.d.ts +6 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +14 -5
- package/dist/context.js.map +1 -1
- package/dist/deploy.d.ts +11 -3
- package/dist/deploy.d.ts.map +1 -1
- package/dist/deploy.js +185 -120
- package/dist/deploy.js.map +1 -1
- package/dist/deployTargets.d.ts.map +1 -1
- package/dist/deployTargets.js +8 -7
- package/dist/deployTargets.js.map +1 -1
- package/dist/doctor.d.ts +121 -15
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +512 -71
- package/dist/doctor.js.map +1 -1
- package/dist/effects.d.ts +3 -0
- package/dist/effects.d.ts.map +1 -1
- package/dist/effects.js.map +1 -1
- package/dist/frontmatter.js +1 -1
- package/dist/frontmatter.js.map +1 -1
- package/dist/index.d.ts +10 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -10
- package/dist/index.js.map +1 -1
- package/dist/io.d.ts +28 -0
- package/dist/io.d.ts.map +1 -1
- package/dist/io.js +86 -4
- package/dist/io.js.map +1 -1
- package/dist/marker.d.ts +22 -5
- package/dist/marker.d.ts.map +1 -1
- package/dist/marker.js +100 -13
- package/dist/marker.js.map +1 -1
- package/dist/model.d.ts +48 -4
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +59 -11
- package/dist/model.js.map +1 -1
- package/dist/need.d.ts +11 -34
- package/dist/need.d.ts.map +1 -1
- package/dist/need.js +92 -54
- package/dist/need.js.map +1 -1
- package/dist/overview.d.ts +25 -0
- package/dist/overview.d.ts.map +1 -1
- package/dist/overview.js +106 -14
- package/dist/overview.js.map +1 -1
- package/dist/propagate.d.ts +3 -3
- package/dist/propagate.d.ts.map +1 -1
- package/dist/propagate.js +8 -6
- package/dist/propagate.js.map +1 -1
- package/dist/requirements.d.ts +1 -1
- package/dist/requirements.d.ts.map +1 -1
- package/dist/requirements.js +6 -5
- package/dist/requirements.js.map +1 -1
- package/dist/standard-index.json +90 -6
- package/dist/take.d.ts +1 -1
- package/dist/take.d.ts.map +1 -1
- package/dist/take.js +6 -25
- package/dist/take.js.map +1 -1
- package/dist/templates.d.ts +21 -0
- package/dist/templates.d.ts.map +1 -0
- package/dist/templates.js +55 -0
- package/dist/templates.js.map +1 -0
- package/dist/update.d.ts +3 -3
- package/dist/update.d.ts.map +1 -1
- package/dist/update.js +58 -71
- package/dist/update.js.map +1 -1
- package/dist/version.d.ts +7 -2
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +17 -2
- package/dist/version.js.map +1 -1
- package/package.json +1 -1
- package/dist/catalog.d.ts +0 -23
- package/dist/catalog.d.ts.map +0 -1
- package/dist/catalog.js +0 -38
- package/dist/catalog.js.map +0 -1
- package/dist/manifest.d.ts +0 -20
- package/dist/manifest.d.ts.map +0 -1
- package/dist/manifest.js +0 -59
- package/dist/manifest.js.map +0 -1
package/dist/marker.js
CHANGED
|
@@ -1,26 +1,113 @@
|
|
|
1
|
-
// The
|
|
2
|
-
//
|
|
3
|
-
// one reader of that shape; every verb
|
|
1
|
+
// The marker, PLEXUS.md (§ 1.4 PLX): YAML frontmatter with an app's
|
|
2
|
+
// `profile` and the unit's `deviations`, then free-form prose that gives a
|
|
3
|
+
// reason for each deviation. This is the one reader of that shape; every verb
|
|
4
|
+
// that needs a marker parses it here. Neither what a unit follows nor the
|
|
5
|
+
// Plexus version is in a marker: a unit is bound by the contracts by being a
|
|
6
|
+
// repo or an app, and a repo is on the version its `plx` pin names (§ 1.5 PLX).
|
|
7
|
+
// Keys a marker of an earlier version still carries (`plexus`, `modules`) are
|
|
8
|
+
// not read; the declaration names them, so that a verb can say they can go.
|
|
4
9
|
import { parse } from 'yaml';
|
|
10
|
+
/** What markers carried before the unit's kind followed from where it sits and the version from the plx pin. */
|
|
11
|
+
const OBSOLETE_KEYS = ['plexus', 'modules'];
|
|
5
12
|
export const MARKER_FILE = 'PLEXUS.md';
|
|
13
|
+
/**
|
|
14
|
+
* A marker from its text; throws when its frontmatter does not parse,
|
|
15
|
+
* `profile` is not a string, or `deviations` is not a list of names. An empty
|
|
16
|
+
* `deviations:` is an empty list.
|
|
17
|
+
*/
|
|
6
18
|
export function parseMarker(text) {
|
|
7
19
|
const { data, body } = splitFrontmatter(text);
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (!Array.isArray(
|
|
13
|
-
throw new Error('marker: `
|
|
14
|
-
|
|
20
|
+
const { profile, deviations = [] } = data;
|
|
21
|
+
if (profile != null && typeof profile !== 'string')
|
|
22
|
+
throw new Error('marker: `profile` must be a string');
|
|
23
|
+
const listed = deviations ?? [];
|
|
24
|
+
if (!Array.isArray(listed) || !listed.every((d) => typeof d === 'string'))
|
|
25
|
+
throw new Error('marker: `deviations` must be a list of requirement names');
|
|
26
|
+
const obsolete = OBSOLETE_KEYS.filter((k) => k in data);
|
|
27
|
+
return {
|
|
28
|
+
...(profile == null ? {} : { profile }),
|
|
29
|
+
deviations: listed,
|
|
30
|
+
body,
|
|
31
|
+
...(obsolete.length > 0 ? { obsolete } : {}),
|
|
32
|
+
};
|
|
15
33
|
}
|
|
16
34
|
/** The YAML between the leading `---` lines, as a plain object, and the rest. */
|
|
17
35
|
export function splitFrontmatter(text) {
|
|
18
|
-
|
|
36
|
+
// A UTF-8 byte order mark, which some editors write, comes before the `---`.
|
|
37
|
+
const match = /^\uFEFF?---\r?\n(?:([\s\S]*?)\r?\n)?---(?:\r?\n|$)([\s\S]*)$/.exec(text);
|
|
19
38
|
if (!match)
|
|
20
39
|
throw new Error('no frontmatter: expected a `---` block at the top');
|
|
21
|
-
const data = parse(match[1] ?? '');
|
|
22
|
-
if (
|
|
40
|
+
const data = parse(match[1] ?? '') ?? {};
|
|
41
|
+
if (typeof data !== 'object' || Array.isArray(data))
|
|
23
42
|
throw new Error('frontmatter is not a mapping');
|
|
24
43
|
return { data: data, body: match[2] ?? '' };
|
|
25
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Whether the body gives a reason for a deviation (§ 1.4 PLX): a list item
|
|
47
|
+
* that opens with the requirement's name, in backticks or bare, optionally
|
|
48
|
+
* followed by a colon, and says something besides, on its first line or the
|
|
49
|
+
* lines that continue it, as in
|
|
50
|
+
* `` - `PLX-App/Stateful/MigrateService`: the image migrates on startup. ``
|
|
51
|
+
* A longer name (`<name>-x`, `<name>/Sub`) is not the name; a name mentioned
|
|
52
|
+
* further into an item, or inside fenced code, gives no reason for it.
|
|
53
|
+
*/
|
|
54
|
+
export function reasonGiven(body, name) {
|
|
55
|
+
const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
56
|
+
const opens = new RegExp(`^(\`?)${escaped}\\1(?![\\w/-])\\s*:?(.*)$`, 's');
|
|
57
|
+
return listItems(body).some((item) => {
|
|
58
|
+
const rest = opens.exec(item)?.[2];
|
|
59
|
+
return rest !== undefined && /\w/.test(rest.replace(/`/g, ''));
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/** A list item's first line: its marker (`-`, `*`, `+`, `1.` or `1)`) and the text after it. */
|
|
63
|
+
const ITEM = /^(\s*)(?:[-*+]|\d{1,9}[.)])(\s+)(.*)$/;
|
|
64
|
+
const FENCE = /^\s*(```|~~~)/;
|
|
65
|
+
/**
|
|
66
|
+
* The text of each Markdown list item of a body, its continuation lines
|
|
67
|
+
* joined to its first, in order: a line indented to the item's text, or a
|
|
68
|
+
* line straight after it without a blank line between, continues it; a new
|
|
69
|
+
* item, a blank line followed by a line indented less, or a fence ends it.
|
|
70
|
+
* Fenced code is no item and continues none.
|
|
71
|
+
*/
|
|
72
|
+
function listItems(body) {
|
|
73
|
+
const items = [];
|
|
74
|
+
let current;
|
|
75
|
+
let blank = false;
|
|
76
|
+
let fence;
|
|
77
|
+
const close = () => {
|
|
78
|
+
if (current)
|
|
79
|
+
items.push(current.text.join(' '));
|
|
80
|
+
current = undefined;
|
|
81
|
+
};
|
|
82
|
+
for (const line of body.split(/\r?\n/)) {
|
|
83
|
+
const fenced = FENCE.exec(line)?.[1];
|
|
84
|
+
if (fence) {
|
|
85
|
+
if (fenced === fence)
|
|
86
|
+
fence = undefined;
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
if (fenced) {
|
|
90
|
+
close();
|
|
91
|
+
fence = fenced;
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
const item = ITEM.exec(line);
|
|
95
|
+
if (item) {
|
|
96
|
+
close();
|
|
97
|
+
const [, lead = '', gap = '', text = ''] = item;
|
|
98
|
+
current = { text: [text.trim()], indent: lead.length + line.slice(lead.length).indexOf(gap) + gap.length };
|
|
99
|
+
blank = false;
|
|
100
|
+
}
|
|
101
|
+
else if (line.trim() === '')
|
|
102
|
+
blank = true;
|
|
103
|
+
else if (current && (!blank || line.length - line.trimStart().length >= current.indent)) {
|
|
104
|
+
current.text.push(line.trim());
|
|
105
|
+
blank = false;
|
|
106
|
+
}
|
|
107
|
+
else
|
|
108
|
+
close();
|
|
109
|
+
}
|
|
110
|
+
close();
|
|
111
|
+
return items;
|
|
112
|
+
}
|
|
26
113
|
//# sourceMappingURL=marker.js.map
|
package/dist/marker.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marker.js","sourceRoot":"","sources":["../src/marker.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,6EAA6E;AAC7E,
|
|
1
|
+
{"version":3,"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GAAG,GAAG,CAAC,MAAM,EAAE,CAAC;YAC3G,KAAK,GAAG,KAAK,CAAC;QAChB,CAAC;aAAM,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE;YAAE,KAAK,GAAG,IAAI,CAAC;aACvC,IAAI,OAAO,IAAI,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YACxF,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;YAC/B,KAAK,GAAG,KAAK,CAAC;QAChB,CAAC;;YAAM,KAAK,EAAE,CAAC;IACjB,CAAC;IACD,KAAK,EAAE,CAAC;IACR,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/model.d.ts
CHANGED
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
import type { Answers } from './copier.ts';
|
|
2
|
-
import type
|
|
2
|
+
import { type Declaration } from './marker.ts';
|
|
3
3
|
export interface Directory {
|
|
4
4
|
name: string;
|
|
5
5
|
path: string;
|
|
6
|
+
/** `.git` is here: a directory for a checkout, a file for a linked worktree or a submodule. Read even when the git facet is not. */
|
|
7
|
+
gitRoot?: true;
|
|
6
8
|
git?: GitFacet;
|
|
7
9
|
template?: TemplateFacet;
|
|
8
10
|
copier?: Answers;
|
|
9
11
|
declaration?: Declaration;
|
|
12
|
+
/** The `plx` pin of the directory's `mise.toml`: the Plexus version a repo is on (§ 1.5 PLX). */
|
|
13
|
+
pin?: string;
|
|
10
14
|
/** Marker files that could not be read; shown, never fatal. */
|
|
11
15
|
problems?: string[];
|
|
16
|
+
/** A git root's apps (§ 2 PLX-App), by path, as `appsOf` (overview.ts) finds them; set by the walk on every git root. */
|
|
17
|
+
apps?: string[];
|
|
18
|
+
/** Why the directory's entries could not be read (an errno code such as EACCES); nothing beneath it is known. */
|
|
19
|
+
unreadable?: string;
|
|
20
|
+
/** A symbolic link to a directory, not followed: one in a repo's `apps/`, or one to a git repo. */
|
|
21
|
+
symlink?: true;
|
|
12
22
|
children: Directory[];
|
|
13
23
|
}
|
|
14
24
|
export interface GitFacet {
|
|
@@ -29,9 +39,43 @@ export interface TemplateFacet {
|
|
|
29
39
|
/** The template repo's most recent tag, if any. */
|
|
30
40
|
tag?: string;
|
|
31
41
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
42
|
+
/** What a unit is: an app, the operations repo, or any other repo (§ 1.2 PLX). */
|
|
43
|
+
export type Kind = 'app' | 'operations' | 'repo';
|
|
44
|
+
/** A repo or an app, and what it is. */
|
|
45
|
+
export interface Unit {
|
|
46
|
+
dir: Directory;
|
|
47
|
+
kind: Kind;
|
|
48
|
+
/** An app's source repo, the repo whose `apps/` holds it. */
|
|
49
|
+
repo?: Directory;
|
|
50
|
+
}
|
|
51
|
+
/** Whether the directory carries a marker, readable or not. */
|
|
52
|
+
export declare const hasMarker: (dir: Directory) => boolean;
|
|
53
|
+
/** The directory that holds a repo's apps, one directory each (§ 2 PLX-App). */
|
|
54
|
+
export declare const APPS_DIR = "apps";
|
|
55
|
+
/**
|
|
56
|
+
* Whether a directory's entries make it an app, once it sits directly in its
|
|
57
|
+
* repo's `apps/`: anything but dotfiles (an empty directory, or one holding
|
|
58
|
+
* only a `.gitkeep`, is none), and no `.git` (a checkout of its own is a repo
|
|
59
|
+
* of its own, not this repo's app).
|
|
60
|
+
*/
|
|
61
|
+
export declare const holdsApp: (entries: readonly {
|
|
62
|
+
name: string;
|
|
63
|
+
}[]) => boolean;
|
|
64
|
+
/**
|
|
65
|
+
* The operations repo is the one rendered from the operations template: its
|
|
66
|
+
* root answers file names it, under its current or an earlier name.
|
|
67
|
+
*/
|
|
68
|
+
export declare const isOperations: (dir: Directory) => boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Every unit of a scanned tree, in tree order, as overview labels them. What
|
|
71
|
+
* a unit is follows from where it is (§ 1.3 PLX), never from what its marker
|
|
72
|
+
* says: a repo is a git root, the operations repo when its answers file says
|
|
73
|
+
* so; an app is one of the apps the walk found for its nearest enclosing git
|
|
74
|
+
* root (`apps`, read by `appsOf`, which doctor reads them by too), with a
|
|
75
|
+
* marker or without. A git root is a Plexus repo when it carries a marker or
|
|
76
|
+
* has an app.
|
|
77
|
+
*/
|
|
78
|
+
export declare function unitsOf(root: Directory): Unit[];
|
|
35
79
|
/** A git remote URL as a short handle: `gh:org/repo` for GitHub, the URL otherwise. */
|
|
36
80
|
export declare function shortRemote(url: string): string;
|
|
37
81
|
/** Whether a directory, or anything below it, carries a facet worth showing. */
|
package/dist/model.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,KAAK,WAAW,EAAe,MAAM,aAAa,CAAC;AAG5D,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,oIAAoI;IACpI,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,GAAG,CAAC,EAAE,QAAQ,CAAC;IACf,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,iGAAiG;IACjG,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,yHAAyH;IACzH,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,iHAAiH;IACj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AG,MAAM,CAI/C;AAED,gFAAgF;AAChF,wBAAgB,SAAS,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CAWjD"}
|
package/dist/model.js
CHANGED
|
@@ -1,13 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { MARKER_FILE } from "./marker.js";
|
|
2
|
+
import { templateOf } from "./templates.js";
|
|
3
|
+
/** The template the operations repo is rendered from (§ 1.6 PLX). */
|
|
4
|
+
const OPERATIONS_TEMPLATE = 'template-repo-operations';
|
|
5
|
+
/** Whether the directory carries a marker, readable or not. */
|
|
6
|
+
export const hasMarker = (dir) => Boolean(dir.declaration || dir.problems?.some((p) => p.startsWith(MARKER_FILE)));
|
|
7
|
+
/** The directory that holds a repo's apps, one directory each (§ 2 PLX-App). */
|
|
8
|
+
export const APPS_DIR = 'apps';
|
|
9
|
+
/**
|
|
10
|
+
* Whether a directory's entries make it an app, once it sits directly in its
|
|
11
|
+
* repo's `apps/`: anything but dotfiles (an empty directory, or one holding
|
|
12
|
+
* only a `.gitkeep`, is none), and no `.git` (a checkout of its own is a repo
|
|
13
|
+
* of its own, not this repo's app).
|
|
14
|
+
*/
|
|
15
|
+
export const holdsApp = (entries) => entries.some((e) => !e.name.startsWith('.')) && !entries.some((e) => e.name === '.git');
|
|
16
|
+
/**
|
|
17
|
+
* The operations repo is the one rendered from the operations template: its
|
|
18
|
+
* root answers file names it, under its current or an earlier name.
|
|
19
|
+
*/
|
|
20
|
+
export const isOperations = (dir) => dir.copier?.src !== undefined && templateOf(dir.copier.src, [OPERATIONS_TEMPLATE]) !== undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Every unit of a scanned tree, in tree order, as overview labels them. What
|
|
23
|
+
* a unit is follows from where it is (§ 1.3 PLX), never from what its marker
|
|
24
|
+
* says: a repo is a git root, the operations repo when its answers file says
|
|
25
|
+
* so; an app is one of the apps the walk found for its nearest enclosing git
|
|
26
|
+
* root (`apps`, read by `appsOf`, which doctor reads them by too), with a
|
|
27
|
+
* marker or without. A git root is a Plexus repo when it carries a marker or
|
|
28
|
+
* has an app.
|
|
29
|
+
*/
|
|
30
|
+
export function unitsOf(root) {
|
|
31
|
+
const units = [];
|
|
32
|
+
/** `repo` is the nearest enclosing git root; `inApps`, that `dir` sits directly in its `apps/`. */
|
|
33
|
+
const visit = (dir, repo, inApps) => {
|
|
34
|
+
let here = repo;
|
|
35
|
+
if (dir.gitRoot) {
|
|
36
|
+
here = dir;
|
|
37
|
+
if (hasMarker(dir) || (dir.apps?.length ?? 0) > 0)
|
|
38
|
+
units.push({ dir, kind: isOperations(dir) ? 'operations' : 'repo' });
|
|
39
|
+
}
|
|
40
|
+
else if (inApps && repo?.apps?.includes(dir.path))
|
|
41
|
+
units.push({ dir, kind: 'app', repo });
|
|
42
|
+
for (const child of dir.children) {
|
|
43
|
+
if (child.name === APPS_DIR && here === dir)
|
|
44
|
+
for (const app of child.children)
|
|
45
|
+
visit(app, here, true);
|
|
46
|
+
else
|
|
47
|
+
visit(child, here, false);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
visit(root, undefined, false);
|
|
51
|
+
return units;
|
|
11
52
|
}
|
|
12
53
|
/** A git remote URL as a short handle: `gh:org/repo` for GitHub, the URL otherwise. */
|
|
13
54
|
export function shortRemote(url) {
|
|
@@ -17,6 +58,13 @@ export function shortRemote(url) {
|
|
|
17
58
|
}
|
|
18
59
|
/** Whether a directory, or anything below it, carries a facet worth showing. */
|
|
19
60
|
export function isNotable(dir) {
|
|
20
|
-
return Boolean(dir.
|
|
61
|
+
return Boolean(dir.gitRoot ||
|
|
62
|
+
dir.git ||
|
|
63
|
+
dir.template ||
|
|
64
|
+
dir.copier ||
|
|
65
|
+
dir.declaration ||
|
|
66
|
+
dir.problems?.length ||
|
|
67
|
+
dir.unreadable ||
|
|
68
|
+
dir.symlink);
|
|
21
69
|
}
|
|
22
70
|
//# sourceMappingURL=model.js.map
|
package/dist/model.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAKA,OAAO,EAAoB,WAAW,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAuD5C,qEAAqE;AACrE,MAAM,mBAAmB,GAAG,0BAA0B,CAAC;AAEvD,+DAA+D;AAC/D,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAc,EAAW,EAAE,CACnD,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;AAEnF,gFAAgF;AAChF,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC;AAE/B;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,OAAoC,EAAW,EAAE,CACxE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC;AAE1F;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,GAAc,EAAW,EAAE,CACtD,GAAG,CAAC,MAAM,EAAE,GAAG,KAAK,SAAS,IAAI,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,mBAAmB,CAAC,CAAC,KAAK,SAAS,CAAC;AAEnG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,GAAG,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC1D,MAAM,CAAC,GAAG,4FAA4F,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClH,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACjC,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,SAAS,CAAC,GAAc;IACtC,OAAO,OAAO,CACZ,GAAG,CAAC,OAAO;QACT,GAAG,CAAC,GAAG;QACP,GAAG,CAAC,QAAQ;QACZ,GAAG,CAAC,MAAM;QACV,GAAG,CAAC,WAAW;QACf,GAAG,CAAC,QAAQ,EAAE,MAAM;QACpB,GAAG,CAAC,UAAU;QACd,GAAG,CAAC,OAAO,CACd,CAAC;AACJ,CAAC"}
|
package/dist/need.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
/** The answer of the repo templates that sets the backstop age, in days. */
|
|
1
|
+
/** The interval, in days, of a repo whose answers do not set one. */
|
|
2
|
+
export declare const DEFAULT_MAX_AGE = 7;
|
|
3
|
+
/** The answer of the repo templates that sets the interval, in days. */
|
|
5
4
|
export declare const MAX_AGE_ANSWER = "update_max_age";
|
|
6
5
|
/** A version as the forge knows it: its number and when its release was published. */
|
|
7
6
|
export interface Release {
|
|
@@ -9,54 +8,32 @@ export interface Release {
|
|
|
9
8
|
/** ISO 8601, as the forge gives it. */
|
|
10
9
|
published: string;
|
|
11
10
|
}
|
|
12
|
-
|
|
13
|
-
/** A marker as the decision needs it: where it is, the version it was brought up to, the modules it declares. */
|
|
14
|
-
export interface Marked {
|
|
15
|
-
where: string;
|
|
16
|
-
plexus: string;
|
|
17
|
-
modules: string[];
|
|
18
|
-
}
|
|
19
|
-
/** A declared module whose requirements changed after the marker that declares it was brought up. */
|
|
20
|
-
export interface Stale {
|
|
21
|
-
code: string;
|
|
22
|
-
changed: string;
|
|
23
|
-
where: string;
|
|
24
|
-
declared: string;
|
|
25
|
-
}
|
|
11
|
+
/** `held`, when set, names a version of a newer major that waits to be asked for. */
|
|
26
12
|
export type Need =
|
|
27
|
-
/** Take
|
|
13
|
+
/** Take `version`; `why` is a clause for the narration and the pull request. */
|
|
28
14
|
{
|
|
29
15
|
take: true;
|
|
30
|
-
|
|
16
|
+
version: string;
|
|
31
17
|
why: string;
|
|
18
|
+
held?: string;
|
|
32
19
|
}
|
|
33
20
|
/** Rest on the version the repo has; `why` says what would end the rest. */
|
|
34
21
|
| {
|
|
35
22
|
take: false;
|
|
36
23
|
why: string;
|
|
24
|
+
held?: string;
|
|
37
25
|
};
|
|
38
26
|
export interface NeedInput {
|
|
39
27
|
/** What each site of the repo records as its version (the answers' `_commit`). */
|
|
40
28
|
recorded: (string | undefined)[];
|
|
41
29
|
/** The template's releases, in any order. */
|
|
42
30
|
releases: Release[];
|
|
43
|
-
/**
|
|
44
|
-
asked?: string;
|
|
45
|
-
/** The declared modules that changed since their markers (`staleModules`); empty when none, or when no manifest was read. */
|
|
46
|
-
stale?: Stale[];
|
|
47
|
-
/** The backstop age in days. */
|
|
31
|
+
/** The interval in days. */
|
|
48
32
|
maxAge: number;
|
|
49
33
|
now: Date;
|
|
50
34
|
}
|
|
51
|
-
export declare function needOf({ recorded, releases,
|
|
52
|
-
/**
|
|
53
|
-
* The modules the markers declare whose `changed` in the catalogue is newer
|
|
54
|
-
* than the marker's `plexus`: the staleness of § 1.4 PLX, per module. A module
|
|
55
|
-
* the catalogue does not carry, or one without a `changed` (below standard
|
|
56
|
-
* maturity), is never stale here; `doctor` is what reports the first.
|
|
57
|
-
*/
|
|
58
|
-
export declare function staleModules(markers: Marked[], catalog: Catalog): Stale[];
|
|
59
|
-
/** The backstop age a repo's answers set, or the default; a value that is not a whole number of days is refused. */
|
|
35
|
+
export declare function needOf({ recorded, releases, maxAge, now }: NeedInput): Need;
|
|
36
|
+
/** The interval a repo's answers set, or the default; a value that is not a whole number of days is refused. */
|
|
60
37
|
export declare function maxAgeOf(answers: Record<string, unknown>): number;
|
|
61
38
|
export declare function parseMaxAge(value: string, what: string): number;
|
|
62
39
|
//# sourceMappingURL=need.d.ts.map
|
package/dist/need.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"need.d.ts","sourceRoot":"","sources":["../src/need.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"need.d.ts","sourceRoot":"","sources":["../src/need.ts"],"names":[],"mappings":"AAsBA,qEAAqE;AACrE,eAAO,MAAM,eAAe,IAAI,CAAC;AACjC,wEAAwE;AACxE,eAAO,MAAM,cAAc,mBAAmB,CAAC;AAE/C,sFAAsF;AACtF,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,uCAAuC;IACvC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,qFAAqF;AACrF,MAAM,MAAM,IAAI;AACd,gFAAgF;AAC9E;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE;AAC7D,4EAA4E;GAC1E;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhD,MAAM,WAAW,SAAS;IACxB,kFAAkF;IAClF,QAAQ,EAAE,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,CAAC;IACjC,6CAA6C;IAC7C,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,4BAA4B;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,IAAI,CAAC;CACX;AAUD,wBAAgB,MAAM,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,SAAS,GAAG,IAAI,CA2E3E;AAED,gHAAgH;AAChH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAIjE;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAG/D"}
|
package/dist/need.js
CHANGED
|
@@ -1,73 +1,111 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
// need: which version, if any, a repo takes now (§ 3 PLX-Updates). Cutting a
|
|
2
|
+
// version and a repo taking it are separate events. The step of the version
|
|
3
|
+
// number says how urgent it is:
|
|
4
|
+
//
|
|
5
|
+
// patch a hotfix: taken at once
|
|
6
|
+
// minor routine: taken once the oldest version the repo has not taken is as
|
|
7
|
+
// old as its interval (7 days unless its answers say otherwise; zero
|
|
8
|
+
// takes every version)
|
|
9
|
+
// major a contract changed: taken only when asked, with the migration note
|
|
10
|
+
//
|
|
11
|
+
// Within the repo's major, any pending patch release is a hotfix: the newest
|
|
12
|
+
// one is taken at once, and since ship tags main it carries every version
|
|
13
|
+
// before it. The newest of the major is taken only once the interval is due.
|
|
14
|
+
// A newer major is named in one line and never taken unasked. Asking (`--now`,
|
|
15
|
+
// `--to`, a manual run of the workflow) takes the newest version whatever its
|
|
16
|
+
// step, and is decided by the caller; this file decides an unasked run.
|
|
17
|
+
//
|
|
18
|
+
// While nothing is taken the repo rests on the version it has, which its
|
|
19
|
+
// immutable pins make safe (§ 1.6 PLX). Pure: the caller reads the releases,
|
|
20
|
+
// the answers and the clock.
|
|
21
|
+
import { compareVersions, isPlexusVersion } from "./version.js";
|
|
22
|
+
/** The interval, in days, of a repo whose answers do not set one. */
|
|
23
|
+
export const DEFAULT_MAX_AGE = 7;
|
|
24
|
+
/** The answer of the repo templates that sets the interval, in days. */
|
|
6
25
|
export const MAX_AGE_ANSWER = 'update_max_age';
|
|
7
26
|
const DAY = 24 * 60 * 60 * 1000;
|
|
8
27
|
const days = (n) => `${n} day${n === 1 ? '' : 's'}`;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
28
|
+
const parts = (v) => {
|
|
29
|
+
const [major = 0, minor = 0, patch = 0] = v.split('.').map(Number);
|
|
30
|
+
return [major, minor, patch];
|
|
31
|
+
};
|
|
32
|
+
const newest = (versions) => versions.reduce((a, b) => (compareVersions(a, b) >= 0 ? a : b));
|
|
33
|
+
export function needOf({ recorded, releases, maxAge, now }) {
|
|
34
|
+
const versions = releases.map((r) => r.version).filter(isPlexusVersion);
|
|
35
|
+
const known = recorded.filter((r) => !!r && isPlexusVersion(r));
|
|
36
|
+
const majorOf = (v) => parts(v)[0];
|
|
37
|
+
const heldBeyond = (major) => {
|
|
38
|
+
const beyond = versions.filter((v) => majorOf(v) > major);
|
|
39
|
+
return beyond.length > 0 ? `${newest(beyond)} is a new major, taken only when asked` : undefined;
|
|
40
|
+
};
|
|
19
41
|
// A site that records no version (a commit, a branch) cannot be placed among
|
|
20
|
-
// the releases
|
|
42
|
+
// the releases: it is brought onto the newest version of the major the other
|
|
43
|
+
// sites record, at once; with no site to say which major, nothing is taken.
|
|
21
44
|
const odd = recorded.findIndex((r) => !r || !isPlexusVersion(r));
|
|
22
|
-
if (recorded.length === 0 || odd >= 0)
|
|
45
|
+
if (recorded.length === 0 || odd >= 0) {
|
|
46
|
+
const what = `a site records ${recorded[odd] ? `'${recorded[odd]}'` : 'no version'}, not a version`;
|
|
47
|
+
if (known.length === 0)
|
|
48
|
+
return { take: false, why: `${what}, and no site records one` };
|
|
49
|
+
const major = majorOf(newest(known));
|
|
50
|
+
const within = versions.filter((v) => majorOf(v) === major);
|
|
51
|
+
const held = heldBeyond(major);
|
|
52
|
+
if (within.length === 0)
|
|
53
|
+
return { take: false, why: held ?? `${what}, and no version of its major is released` };
|
|
54
|
+
return { take: true, version: newest(within), why: what, ...(held ? { held } : {}) };
|
|
55
|
+
}
|
|
56
|
+
// The repo is measured by the site furthest behind.
|
|
57
|
+
const on = known.reduce((a, b) => (compareVersions(a, b) <= 0 ? a : b));
|
|
58
|
+
const major = majorOf(on);
|
|
59
|
+
const held = heldBeyond(major);
|
|
60
|
+
// A date the forge gives that does not parse counts as old enough.
|
|
61
|
+
const time = (r) => {
|
|
62
|
+
const t = Date.parse(r.published);
|
|
63
|
+
return Number.isNaN(t) ? Number.NEGATIVE_INFINITY : t;
|
|
64
|
+
};
|
|
65
|
+
const within = releases
|
|
66
|
+
.filter((r) => isPlexusVersion(r.version) && majorOf(r.version) === major && compareVersions(r.version, on) > 0)
|
|
67
|
+
.sort((a, b) => time(a) - time(b));
|
|
68
|
+
const oldest = within[0];
|
|
69
|
+
// When the major is the only thing pending, it is the reason, said once.
|
|
70
|
+
if (!oldest)
|
|
71
|
+
return { take: false, why: held ?? `no version newer than ${on}` };
|
|
72
|
+
const pending = within.map((r) => r.version);
|
|
73
|
+
const target = newest(pending);
|
|
74
|
+
const count = (upTo) => {
|
|
75
|
+
const n = pending.filter((v) => compareVersions(v, upTo) <= 0).length;
|
|
76
|
+
return `${n} newer version${n === 1 ? '' : 's'}`;
|
|
77
|
+
};
|
|
78
|
+
const also = held ? { held } : {};
|
|
79
|
+
const age = Math.max(0, Math.floor((now.getTime() - time(oldest)) / DAY));
|
|
80
|
+
if (maxAge === 0)
|
|
81
|
+
return { take: true, version: target, why: `an interval of zero takes every version (${count(target)})`, ...also };
|
|
82
|
+
if (time(oldest) === Number.NEGATIVE_INFINITY)
|
|
23
83
|
return {
|
|
24
84
|
take: true,
|
|
25
|
-
|
|
26
|
-
why:
|
|
85
|
+
version: target,
|
|
86
|
+
why: `${oldest.version} has no readable release date ('${oldest.published}'), so it counts as old enough (${count(target)})`,
|
|
87
|
+
...also,
|
|
27
88
|
};
|
|
28
|
-
const versions = recorded;
|
|
29
|
-
const oldest = versions.reduce((a, b) => (compareVersions(a, b) <= 0 ? a : b));
|
|
30
|
-
const untaken = releases
|
|
31
|
-
.filter((r) => isPlexusVersion(r.version) && compareVersions(r.version, oldest) > 0)
|
|
32
|
-
.sort((a, b) => Date.parse(a.published) - Date.parse(b.published));
|
|
33
|
-
const oldestUntaken = untaken[0];
|
|
34
|
-
if (!oldestUntaken)
|
|
35
|
-
return { take: false, why: `no version newer than ${oldest}` };
|
|
36
|
-
const age = Math.max(0, Math.floor((now.getTime() - Date.parse(oldestUntaken.published)) / DAY));
|
|
37
|
-
const count = `${untaken.length} newer version${untaken.length === 1 ? '' : 's'}`;
|
|
38
|
-
if (maxAge === 0)
|
|
39
|
-
return { take: true, trigger: 'backstop', why: `a backstop age of zero takes every version (${count})` };
|
|
40
89
|
if (age >= maxAge)
|
|
41
90
|
return {
|
|
42
91
|
take: true,
|
|
43
|
-
|
|
44
|
-
why: `${
|
|
92
|
+
version: target,
|
|
93
|
+
why: `${oldest.version}, the oldest version not taken, was cut ${days(age)} ago (interval: ${days(maxAge)}; ${count(target)})`,
|
|
94
|
+
...also,
|
|
45
95
|
};
|
|
96
|
+
const hotfixes = pending.filter((v) => parts(v)[2] > 0);
|
|
97
|
+
if (hotfixes.length > 0) {
|
|
98
|
+
const fix = newest(hotfixes);
|
|
99
|
+
const rest = fix === target ? '' : `; ${target} waits for the interval`;
|
|
100
|
+
return { take: true, version: fix, why: `${fix} is a hotfix, taken at once (${count(fix)})${rest}`, ...also };
|
|
101
|
+
}
|
|
46
102
|
return {
|
|
47
103
|
take: false,
|
|
48
|
-
why: `${count}, the oldest (${
|
|
104
|
+
why: `${count(target)}, the oldest (${oldest.version}) cut ${days(age)} ago; the interval is ${days(maxAge)}`,
|
|
105
|
+
...also,
|
|
49
106
|
};
|
|
50
107
|
}
|
|
51
|
-
/**
|
|
52
|
-
* The modules the markers declare whose `changed` in the catalogue is newer
|
|
53
|
-
* than the marker's `plexus`: the staleness of § 1.4 PLX, per module. A module
|
|
54
|
-
* the catalogue does not carry, or one without a `changed` (below standard
|
|
55
|
-
* maturity), is never stale here; `doctor` is what reports the first.
|
|
56
|
-
*/
|
|
57
|
-
export function staleModules(markers, catalog) {
|
|
58
|
-
const stale = [];
|
|
59
|
-
for (const { where, plexus, modules } of markers) {
|
|
60
|
-
if (!isPlexusVersion(plexus))
|
|
61
|
-
continue;
|
|
62
|
-
for (const code of modules) {
|
|
63
|
-
const changed = catalog.get(code)?.changed;
|
|
64
|
-
if (changed && isPlexusVersion(changed) && compareVersions(changed, plexus) > 0)
|
|
65
|
-
stale.push({ code, changed, where, declared: plexus });
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return stale;
|
|
69
|
-
}
|
|
70
|
-
/** The backstop age a repo's answers set, or the default; a value that is not a whole number of days is refused. */
|
|
108
|
+
/** The interval a repo's answers set, or the default; a value that is not a whole number of days is refused. */
|
|
71
109
|
export function maxAgeOf(answers) {
|
|
72
110
|
const value = answers[MAX_AGE_ANSWER];
|
|
73
111
|
if (value === undefined || value === null || value === '')
|
package/dist/need.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"need.js","sourceRoot":"","sources":["../src/need.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"need.js","sourceRoot":"","sources":["../src/need.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,4EAA4E;AAC5E,gCAAgC;AAChC,EAAE;AACF,mCAAmC;AACnC,+EAA+E;AAC/E,8EAA8E;AAC9E,gCAAgC;AAChC,8EAA8E;AAC9E,EAAE;AACF,6EAA6E;AAC7E,0EAA0E;AAC1E,6EAA6E;AAC7E,+EAA+E;AAC/E,8EAA8E;AAC9E,wEAAwE;AACxE,EAAE;AACF,yEAAyE;AACzE,6EAA6E;AAC7E,6BAA6B;AAC7B,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEhE,qE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