@plexus-ms/lib 0.129.1 → 0.131.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/apply.d.ts +25 -0
- package/dist/apply.d.ts.map +1 -0
- package/dist/apply.js +205 -0
- package/dist/apply.js.map +1 -0
- package/dist/bundled.d.ts +15 -0
- package/dist/bundled.d.ts.map +1 -0
- package/dist/bundled.js +42 -0
- package/dist/bundled.js.map +1 -0
- package/dist/consumers.d.ts +8 -21
- package/dist/consumers.d.ts.map +1 -1
- package/dist/consumers.js +62 -58
- package/dist/consumers.js.map +1 -1
- package/dist/doctor.d.ts +17 -1
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +173 -15
- package/dist/doctor.js.map +1 -1
- package/dist/engine.d.ts +2 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +9 -0
- package/dist/engine.js.map +1 -0
- package/dist/frontmatter.d.ts.map +1 -1
- package/dist/frontmatter.js +6 -5
- package/dist/frontmatter.js.map +1 -1
- package/dist/index.d.ts +11 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -4
- package/dist/index.js.map +1 -1
- package/dist/marker.d.ts +38 -0
- package/dist/marker.d.ts.map +1 -1
- package/dist/marker.js +269 -16
- package/dist/marker.js.map +1 -1
- package/dist/model.d.ts +5 -2
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +8 -4
- package/dist/model.js.map +1 -1
- package/dist/need.d.ts +1 -1
- package/dist/need.d.ts.map +1 -1
- package/dist/need.js +2 -2
- package/dist/need.js.map +1 -1
- package/dist/newSite.d.ts +31 -0
- package/dist/newSite.d.ts.map +1 -0
- package/dist/newSite.js +185 -0
- package/dist/newSite.js.map +1 -0
- package/dist/overview.d.ts +4 -8
- package/dist/overview.d.ts.map +1 -1
- package/dist/overview.js +9 -32
- package/dist/overview.js.map +1 -1
- package/dist/pull.d.ts +48 -21
- package/dist/pull.d.ts.map +1 -1
- package/dist/pull.js +183 -67
- package/dist/pull.js.map +1 -1
- package/dist/recursive.d.ts.map +1 -1
- package/dist/recursive.js +7 -5
- package/dist/recursive.js.map +1 -1
- package/dist/siteTemplates.d.ts +14 -0
- package/dist/siteTemplates.d.ts.map +1 -0
- package/dist/siteTemplates.js +107 -0
- package/dist/siteTemplates.js.map +1 -0
- package/dist/sites.d.ts +24 -0
- package/dist/sites.d.ts.map +1 -0
- package/dist/sites.js +89 -0
- package/dist/sites.js.map +1 -0
- package/dist/standard-index.json +1 -1
- package/dist/summary.d.ts +1 -1
- package/dist/summary.d.ts.map +1 -1
- package/dist/summary.js +6 -1
- package/dist/summary.js.map +1 -1
- package/dist/sync.d.ts +86 -0
- package/dist/sync.d.ts.map +1 -0
- package/dist/sync.js +227 -0
- package/dist/sync.js.map +1 -0
- package/dist/take.d.ts +20 -25
- package/dist/take.d.ts.map +1 -1
- package/dist/take.js +48 -142
- package/dist/take.js.map +1 -1
- package/dist/templates.d.ts +1 -3
- package/dist/templates.d.ts.map +1 -1
- package/dist/templates.js +5 -9
- package/dist/templates.js.map +1 -1
- package/dist/templatesRoot.d.ts +5 -0
- package/dist/templatesRoot.d.ts.map +1 -0
- package/dist/templatesRoot.js +37 -0
- package/dist/templatesRoot.js.map +1 -0
- package/dist/update.d.ts +18 -9
- package/dist/update.d.ts.map +1 -1
- package/dist/update.js +166 -78
- package/dist/update.js.map +1 -1
- package/dist/versionTemplates.d.ts +24 -0
- package/dist/versionTemplates.d.ts.map +1 -0
- package/dist/versionTemplates.js +168 -0
- package/dist/versionTemplates.js.map +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// The markers against the templates this plx bundles: what `plx doctor` checks
|
|
2
|
+
// of a repo that has crossed over (doctor.ts) once it has the templates. Each
|
|
3
|
+
// finding is a line naming the marker it concerns.
|
|
4
|
+
//
|
|
5
|
+
// `templates` names only templates the bundle holds. A name it lacks is a
|
|
6
|
+
// finding and the name is left out of the rest.
|
|
7
|
+
//
|
|
8
|
+
// Every key of a marker is reserved (`version`, `templates`, `deviations`) or
|
|
9
|
+
// a question or read of a template, found by handing the marker's answers to
|
|
10
|
+
// the engine's `render` and taking the answers it lists as unused: no template
|
|
11
|
+
// of the render owns or reads them. Which templates form the render decides
|
|
12
|
+
// which keys a marker may hold, by the composition rules (a nested site's
|
|
13
|
+
// answers are the root marker's, defaults of its templates included, plus its
|
|
14
|
+
// own, and a given answer no template owns may satisfy a read):
|
|
15
|
+
//
|
|
16
|
+
// a nested marker the templates it lists itself; a key that only a template
|
|
17
|
+
// of the root marker owns belongs in the root marker, and
|
|
18
|
+
// is a finding here
|
|
19
|
+
// the root marker the templates of every marker of the repo, since the root
|
|
20
|
+
// holds the answers that nested sites' templates own or
|
|
21
|
+
// read, and shares them with every site; so a root key that
|
|
22
|
+
// no template of the repo owns or reads is a finding even
|
|
23
|
+
// where the root lists no template itself
|
|
24
|
+
// no templates a marker that lists none is not checked, unless it is the
|
|
25
|
+
// root and another marker lists some: a third-party app's
|
|
26
|
+
// marker states its `profile`, and nothing renders from it
|
|
27
|
+
//
|
|
28
|
+
// A repo none of whose markers lists a template checks no key.
|
|
29
|
+
//
|
|
30
|
+
// Every answer is valid for its question: type, choices and validator are the
|
|
31
|
+
// engine's own question resolution, which `render` runs for the templates a
|
|
32
|
+
// marker lists on that site's answers (the root's, resolved, plus its own). Its
|
|
33
|
+
// errors that concern a question or a read, among them an answer missing, are
|
|
34
|
+
// findings, named at the marker that holds the key, once however many sites
|
|
35
|
+
// render with it: a root answer to a nested template's question is judged at
|
|
36
|
+
// the root marker. An error that concerns no question (a template's files or
|
|
37
|
+
// manifest, two templates of one marker that write one path) is not reported
|
|
38
|
+
// here; `plx apply` refuses it. A question nothing answers, or a read nothing
|
|
39
|
+
// supplies, is named at the marker that lists the template.
|
|
40
|
+
//
|
|
41
|
+
// Each site is rendered once for both, and the root a second time over the
|
|
42
|
+
// union of templates only where that differs from its own.
|
|
43
|
+
import { join } from 'node:path';
|
|
44
|
+
import { MARKER_FILE } from "./marker.js";
|
|
45
|
+
import { siteAnswers } from "./sites.js";
|
|
46
|
+
/** The findings of the markers among `sites` against `bundled`. */
|
|
47
|
+
export function templateFindings(sites, bundled, rootAnswers) {
|
|
48
|
+
const { keys, answers } = judge(sites, bundled, rootAnswers);
|
|
49
|
+
return [...unknownNames(sites, bundled), ...keys, ...answers];
|
|
50
|
+
}
|
|
51
|
+
function unknownNames(sites, bundled) {
|
|
52
|
+
const held = [...bundled.trees.keys()].sort().map((name) => `\`${name}\``);
|
|
53
|
+
return sites.flatMap(({ dir, config }) => (config?.templates ?? [])
|
|
54
|
+
.filter((name) => !bundled.trees.has(name))
|
|
55
|
+
.map((name) => `${join(dir, MARKER_FILE)}: \`templates\` names \`${name}\`, which this plx does not bundle (it bundles ${held.join(', ')})`));
|
|
56
|
+
}
|
|
57
|
+
/** The keys that no template of a marker's scope owns or reads, and the invalid answers, of every site. */
|
|
58
|
+
function judge(sites, bundled, rootAnswers) {
|
|
59
|
+
const listed = (site) => site.config?.templates ?? [];
|
|
60
|
+
const trees = (names) => [...names].flatMap((name) => bundled.trees.get(name) ?? []);
|
|
61
|
+
const rootConfig = sites.find((s) => s.dir === '.')?.config;
|
|
62
|
+
const everywhere = [...new Set(sites.flatMap(listed))];
|
|
63
|
+
const keys = [];
|
|
64
|
+
const answers = new Set();
|
|
65
|
+
for (const site of sites) {
|
|
66
|
+
const { dir, config } = site;
|
|
67
|
+
const root = dir === '.';
|
|
68
|
+
const mine = [...new Set(listed(site))];
|
|
69
|
+
if (!config || (root ? everywhere.length === 0 : mine.length === 0))
|
|
70
|
+
continue;
|
|
71
|
+
const given = answersOf(sites, dir, rootAnswers);
|
|
72
|
+
if (!given)
|
|
73
|
+
continue;
|
|
74
|
+
const own = mine.length > 0 ? bundled.render(trees(mine), given) : undefined;
|
|
75
|
+
for (const { question, template, message } of own?.errors ?? []) {
|
|
76
|
+
if (question === undefined)
|
|
77
|
+
continue;
|
|
78
|
+
// The marker that holds the key is at fault, not each site that renders with it.
|
|
79
|
+
const holder = !Object.hasOwn(config.answers, question) && Object.hasOwn(rootConfig?.answers ?? {}, question) ? '.' : dir;
|
|
80
|
+
answers.add(`${join(holder, MARKER_FILE)}: \`${question}\` of ${template}: ${message}`);
|
|
81
|
+
}
|
|
82
|
+
const scope = root ? everywhere : mine;
|
|
83
|
+
const { unused } = own && scope.length === mine.length ? own : bundled.render(trees(scope), given);
|
|
84
|
+
const where = root ? 'a template that a marker of the repo lists' : 'a template it lists';
|
|
85
|
+
for (const key of unused)
|
|
86
|
+
if (Object.hasOwn(config.answers, key))
|
|
87
|
+
keys.push(`${join(dir, MARKER_FILE)}: \`${key}\` is neither reserved nor a question or read of ${where}`);
|
|
88
|
+
}
|
|
89
|
+
return { keys, answers: [...answers] };
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* The site's answers, or undefined where they cannot be told: a doubled key is
|
|
93
|
+
* named by doctor already. A nested site's are the root's resolved answers
|
|
94
|
+
* (given where doctor could resolve them) under its own, as `plx apply` renders it.
|
|
95
|
+
*/
|
|
96
|
+
function answersOf(sites, dir, rootAnswers) {
|
|
97
|
+
try {
|
|
98
|
+
const joined = siteAnswers(sites, dir);
|
|
99
|
+
if (dir === '.' || !rootAnswers)
|
|
100
|
+
return joined;
|
|
101
|
+
return { ...rootAnswers, ...sites.find((s) => s.dir === dir)?.config?.answers };
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=siteTemplates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"siteTemplates.js","sourceRoot":"","sources":["../src/siteTemplates.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,8EAA8E;AAC9E,mDAAmD;AACnD,EAAE;AACF,0EAA0E;AAC1E,gDAAgD;AAChD,EAAE;AACF,8EAA8E;AAC9E,6EAA6E;AAC7E,+EAA+E;AAC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C,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC;QACnG,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,4CAA4C,CAAC,CAAC,CAAC,qBAAqB,CAAC;QAC1F,KAAK,MAAM,GAAG,IAAI,MAAM;YACtB,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC;gBACpC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,OAAO,GAAG,oDAAoD,KAAK,EAAE,CAAC,CAAC;IAChH,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,EAAE,CAAC;AACzC,CAAC;AAED;;;;GAIG;AACH,SAAS,SAAS,CAChB,KAA4B,EAC5B,GAAW,EACX,WAAgD;IAEhD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,WAAW,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QACvC,IAAI,GAAG,KAAK,GAAG,IAAI,CAAC,WAAW;YAAE,OAAO,MAAM,CAAC;QAC/C,OAAO,EAAE,GAAG,WAAW,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;IAClF,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
package/dist/sites.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Context } from './context.ts';
|
|
2
|
+
import { type MarkerConfig } from './marker.ts';
|
|
3
|
+
export interface MarkerSite {
|
|
4
|
+
/** The site's directory relative to the repo, `.` for the root. */
|
|
5
|
+
dir: string;
|
|
6
|
+
/** The marker's configuration; undefined when the marker has a problem. */
|
|
7
|
+
config?: MarkerConfig;
|
|
8
|
+
/** Why the marker cannot serve as configuration. */
|
|
9
|
+
problem?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The sites of the repo at `repo`, the root first and the others in path
|
|
13
|
+
* order: as the working tree has them, or, given a `ref`, as that commit has
|
|
14
|
+
* them, which needs no checkout of it. Rejects when git cannot list the
|
|
15
|
+
* repo or the ref.
|
|
16
|
+
*/
|
|
17
|
+
export declare function findSites(ctx: Context, repo: string, ref?: string): Promise<MarkerSite[]>;
|
|
18
|
+
/**
|
|
19
|
+
* The answers of the site at `dir` among `sites`: the root marker's and the
|
|
20
|
+
* site's own; the root's alone for the root. Throws when either marker has a
|
|
21
|
+
* problem, when both answer a key, or when no site is at `dir`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function siteAnswers(sites: readonly MarkerSite[], dir: string): Record<string, unknown>;
|
|
24
|
+
//# sourceMappingURL=sites.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sites.d.ts","sourceRoot":"","sources":["../src/sites.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAe,KAAK,YAAY,EAAqB,MAAM,aAAa,CAAC;AAGhF,MAAM,WAAW,UAAU;IACzB,mEAAmE;IACnE,GAAG,EAAE,MAAM,CAAC;IACZ,2EAA2E;IAC3E,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,oDAAoD;IACpD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;GAKG;AACH,wBAAsB,SAAS,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAqB/F;AAaD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,UAAU,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAc9F"}
|
package/dist/sites.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// The sites of a repo: every directory that holds a tracked marker
|
|
2
|
+
// (PLEXUS.md, marker.ts), at any depth, with the marker's frontmatter read as
|
|
3
|
+
// configuration. A site whose marker lists `templates` is rendered from them;
|
|
4
|
+
// one without renders nothing, and the root marker's answers count for every
|
|
5
|
+
// site all the same.
|
|
6
|
+
//
|
|
7
|
+
// The markers are read from the working tree, as a verb that works on the
|
|
8
|
+
// checkout sees it, or from a git ref, as a verb that compares with a base
|
|
9
|
+
// branch needs it. Tracked is what git lists (`git ls-files`, `git ls-tree`
|
|
10
|
+
// at a ref): an untracked marker is no site yet, and a tracked one deleted
|
|
11
|
+
// from the working tree is none any more there.
|
|
12
|
+
//
|
|
13
|
+
// A marker that cannot be read, or that carries `version` below the root,
|
|
14
|
+
// where it does not belong, gives its site a problem instead of a
|
|
15
|
+
// configuration, so that a check can name every such site at once.
|
|
16
|
+
//
|
|
17
|
+
// A site's answers, which a render is given, are the root marker's answers
|
|
18
|
+
// and the site's own: a nested site shares the root's answers and adds its
|
|
19
|
+
// own, and a key answered in both markers is an error, never an override.
|
|
20
|
+
import { dirname, join } from 'node:path';
|
|
21
|
+
import { MARKER_FILE, parseMarkerConfig } from "./marker.js";
|
|
22
|
+
import { isMissing } from "./overview.js";
|
|
23
|
+
/**
|
|
24
|
+
* The sites of the repo at `repo`, the root first and the others in path
|
|
25
|
+
* order: as the working tree has them, or, given a `ref`, as that commit has
|
|
26
|
+
* them, which needs no checkout of it. Rejects when git cannot list the
|
|
27
|
+
* repo or the ref.
|
|
28
|
+
*/
|
|
29
|
+
export async function findSites(ctx, repo, ref) {
|
|
30
|
+
// --end-of-options: a ref that starts with `-` is a name git rejects, never an option it runs (git 2.24).
|
|
31
|
+
const listing = ref === undefined ? ['ls-files', '-z'] : ['ls-tree', '-r', '-z', '--name-only', '--end-of-options', ref];
|
|
32
|
+
const markers = (await ctx.read('git', listing, { cwd: repo }))
|
|
33
|
+
.split('\0')
|
|
34
|
+
.filter((path) => path === MARKER_FILE || path.endsWith(`/${MARKER_FILE}`));
|
|
35
|
+
const sites = [];
|
|
36
|
+
for (const path of markers) {
|
|
37
|
+
const text = ref === undefined
|
|
38
|
+
? await ctx.readFile(join(repo, path)).catch((error) => {
|
|
39
|
+
if (isMissing(error))
|
|
40
|
+
return undefined;
|
|
41
|
+
throw error;
|
|
42
|
+
})
|
|
43
|
+
: await ctx.read('git', ['cat-file', 'blob', '--end-of-options', `${ref}:${path}`], { cwd: repo });
|
|
44
|
+
if (text === undefined)
|
|
45
|
+
continue;
|
|
46
|
+
const dir = dirname(path);
|
|
47
|
+
sites.push({ dir, ...configOf(text, dir) });
|
|
48
|
+
}
|
|
49
|
+
return sites.sort((a, b) => Number(b.dir === '.') - Number(a.dir === '.') || (a.dir < b.dir ? -1 : 1));
|
|
50
|
+
}
|
|
51
|
+
function configOf(text, dir) {
|
|
52
|
+
try {
|
|
53
|
+
const config = parseMarkerConfig(text);
|
|
54
|
+
if (dir !== '.' && config.version !== undefined)
|
|
55
|
+
return { problem: "`version` belongs in the repo's root marker only; remove it" };
|
|
56
|
+
return { config };
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
return { problem: error instanceof Error ? error.message : String(error) };
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The answers of the site at `dir` among `sites`: the root marker's and the
|
|
64
|
+
* site's own; the root's alone for the root. Throws when either marker has a
|
|
65
|
+
* problem, when both answer a key, or when no site is at `dir`.
|
|
66
|
+
*/
|
|
67
|
+
export function siteAnswers(sites, dir) {
|
|
68
|
+
const own = answersAt(sites, dir);
|
|
69
|
+
if (!own)
|
|
70
|
+
throw new Error(`no marker in ${dir}`);
|
|
71
|
+
const root = dir === '.' ? undefined : answersAt(sites, '.');
|
|
72
|
+
if (!root)
|
|
73
|
+
return { ...own };
|
|
74
|
+
const both = Object.keys(own).filter((key) => Object.hasOwn(root, key));
|
|
75
|
+
if (both.length > 0) {
|
|
76
|
+
const keys = both.map((key) => `\`${key}\``).join(', ');
|
|
77
|
+
const [is, remove] = both.length === 1 ? ['is', 'it'] : ['are', 'each'];
|
|
78
|
+
throw new Error(`${join(dir, MARKER_FILE)}: ${keys} ${is} answered in the root marker as well; remove ${remove} from one of the two`);
|
|
79
|
+
}
|
|
80
|
+
return { ...root, ...own };
|
|
81
|
+
}
|
|
82
|
+
/** The answers of the marker in `dir`, or undefined when there is none; throws on its problem. */
|
|
83
|
+
function answersAt(sites, dir) {
|
|
84
|
+
const site = sites.find((s) => s.dir === dir);
|
|
85
|
+
if (site?.problem !== undefined)
|
|
86
|
+
throw new Error(`${join(dir, MARKER_FILE)}: ${site.problem}`);
|
|
87
|
+
return site?.config?.answers;
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=sites.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sites.js","sourceRoot":"","sources":["../src/sites.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,8EAA8E;AAC9E,8EAA8E;AAC9E,6EAA6E;AAC7E,qBAAqB;AACrB,EAAE;AACF,0EAA0E;AAC1E,2EAA2E;AAC3E,4EAA4E;AAC5E,2EAA2E;AAC3E,gDAAgD;AAChD,EAAE;AACF,0EAA0E;AAC1E,kEAAkE;AAClE,mEAAmE;AACnE,EAAE;AACF,2EAA2E;AAC3E,2EAA2E;AAC3E,0EAA0E;AAC1E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAqB,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChF,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAW1C;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,GAAY,EAAE,IAAY,EAAE,GAAY;IACtE,0GAA0G;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
|
|
|
7
7
|
clean: string[];
|
|
8
8
|
/** Sites left with conflicts, and files that hold conflict markers outside them: in a pull request opened, or on a version branch found on origin. */
|
|
9
9
|
conflicted: string[];
|
|
10
|
-
/** Sites whose
|
|
10
|
+
/** Sites whose step failed or, on a version branch found on origin, not at the version; consumers that could not be worked on, cloned or pushed, lockfiles that failed to refresh, and review requests the forge refused. */
|
|
11
11
|
failed: string[];
|
|
12
12
|
/** Consumers left untouched, with the reason. */
|
|
13
13
|
skipped: {
|
package/dist/summary.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summary.d.ts","sourceRoot":"","sources":["../src/summary.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,4DAA4D;IAC5D,OAAO,EAAE,OAAO,CAAC;IACjB,wCAAwC;IACxC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,sJAAsJ;IACtJ,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,
|
|
1
|
+
{"version":3,"file":"summary.d.ts","sourceRoot":"","sources":["../src/summary.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,4DAA4D;IAC5D,OAAO,EAAE,OAAO,CAAC;IACjB,wCAAwC;IACxC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,sJAAsJ;IACtJ,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,6NAA6N;IAC7N,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,iDAAiD;IACjD,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC5C,4GAA4G;IAC5G,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC5C,wEAAwE;IACxE,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,kGAAkG;IAClG,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,4FAA4F;IAC5F,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAKD,4EAA4E;AAC5E,eAAO,MAAM,OAAO,GAAI,GAAG,OAAO,KAAG,OACyC,CAAC;AAE/E;;;GAGG;AACH,wBAAgB,SAAS,CACvB,QAAQ,EAAE,SAAS,OAAO,EAAE,EAC5B,OAAO,EAAE,OAAO,EAChB,OAAO,SAAiD,GACvD,OAAO,CA+DT;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAMhD;AAED,2EAA2E;AAC3E,wBAAgB,aAAa,CAAC,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,SAAW,GAAG,MAAM,CAsBtF"}
|
package/dist/summary.js
CHANGED
|
@@ -45,9 +45,12 @@ export function summarize(outcomes, preview, version = outcomes.find((o) => o.ve
|
|
|
45
45
|
// Files that still hold markers need a human, like a conflicted site.
|
|
46
46
|
for (const file of o.marked)
|
|
47
47
|
s.conflicted.push(inRun(o.repo, file));
|
|
48
|
-
// A
|
|
48
|
+
// A branch not at the version needs a human to bring it there.
|
|
49
49
|
for (const site of o.behind)
|
|
50
50
|
s.failed.push(`${site === '.' ? o.repo : inRun(o.repo, site)} (not at ${o.version})`);
|
|
51
|
+
// A pin the version did not move needs a human to move it.
|
|
52
|
+
if (o.pin)
|
|
53
|
+
s.failed.push(`${o.repo} (plx pin not at ${o.version})`);
|
|
51
54
|
if (o.failed !== undefined)
|
|
52
55
|
s.failed.push(o.repo);
|
|
53
56
|
if (o.pull)
|
|
@@ -73,6 +76,8 @@ export function summarize(outcomes, preview, version = outcomes.find((o) => o.ve
|
|
|
73
76
|
}
|
|
74
77
|
if (t.lockfile === 'failed')
|
|
75
78
|
s.failed.push(`${t.rel}/pnpm-lock.yaml`);
|
|
79
|
+
if (t.pin)
|
|
80
|
+
s.failed.push(`${t.rel} (plx pin not at ${o.version})`);
|
|
76
81
|
if (t.failed !== undefined)
|
|
77
82
|
s.failed.push(t.rel);
|
|
78
83
|
if (t.pull)
|
package/dist/summary.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summary.js","sourceRoot":"","sources":["../src/summary.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,8EAA8E;AAC9E,uEAAuE;AACvE,yEAAyE;AACzE,wEAAwE;AACxE,2EAA2E;AAC3E,YAAY;AACZ,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAyBtC,gGAAgG;AAChG,MAAM,KAAK,GAAG,CAAC,IAAY,EAAE,IAAY,EAAU,EAAE,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC;AAEhG,4EAA4E;AAC5E,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,CAAU,EAAW,EAAE,CAC7C,CAAC,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC;AAE/E;;;GAGG;AACH,MAAM,UAAU,SAAS,CACvB,QAA4B,EAC5B,OAAgB,EAChB,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,OAAO,IAAI,EAAE;IAExD,MAAM,CAAC,GAAY;QACjB,OAAO;QACP,OAAO;QACP,KAAK,EAAE,EAAE;QACT,UAAU,EAAE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C;IAC1F,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IACzB,6HAA6H;IAC7H,MAAM,IAAI,GAAG,KAAK,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC;IACrE,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;QACvB,KAAK,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC;QACrD,IAAI,KAAK;YAAE,KAAK,CAAC,IAAI,CAAC,sCAAsC,WAAW,EAAE,CAAC,CAAC;IAC7E,CAAC;SAAM,IAAI,KAAK,EAAE,CAAC;QACjB,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,6CAA6C,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC;IAC9G,CAAC;IACD,IAAI,CAAC,KAAK;QAAE,KAAK,CAAC,IAAI,CAAC,4DAA4D,IAAI,EAAE,CAAC,CAAC;IAC3F,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
package/dist/sync.d.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { Answers, MergeEntry, RenderError, RenderedSide } from '@plexus-ms/cli-template';
|
|
2
|
+
import type { Context } from './context.ts';
|
|
3
|
+
/** Templates, by name below a root, and the answers to render them with. */
|
|
4
|
+
export interface Source {
|
|
5
|
+
readonly templates: readonly string[];
|
|
6
|
+
readonly answers: Answers;
|
|
7
|
+
}
|
|
8
|
+
/** A render that arrived as a tree: its policies, and the answers it resolved. */
|
|
9
|
+
export interface Rendered extends RenderedSide {
|
|
10
|
+
readonly answers: Answers;
|
|
11
|
+
}
|
|
12
|
+
/** A render of templates by name with answers, by another engine than this plx's: the render, or why there is none. */
|
|
13
|
+
export type RenderTemplates = (names: readonly string[], answers: Answers) => Promise<{
|
|
14
|
+
rendered?: Rendered;
|
|
15
|
+
errors: readonly string[];
|
|
16
|
+
}>;
|
|
17
|
+
/** Where one side's sources are rendered from: a root of templates, and the render of another engine where it is not this plx's. */
|
|
18
|
+
export interface Templates {
|
|
19
|
+
/** The directory that holds one directory per template. */
|
|
20
|
+
readonly root: string;
|
|
21
|
+
/** Renders the templates below the root; default: this plx's engine. */
|
|
22
|
+
readonly render?: RenderTemplates;
|
|
23
|
+
}
|
|
24
|
+
/** The templates of each side. */
|
|
25
|
+
export interface TemplateSides {
|
|
26
|
+
readonly old: Templates;
|
|
27
|
+
readonly new: Templates;
|
|
28
|
+
}
|
|
29
|
+
export interface SiteSides {
|
|
30
|
+
/** The site's directory relative to the repo, `.` for the root. */
|
|
31
|
+
readonly dir: string;
|
|
32
|
+
readonly old: Source | Rendered;
|
|
33
|
+
readonly new: Source;
|
|
34
|
+
/** Render the site for what it gives the nested sites, and merge nothing into it. */
|
|
35
|
+
readonly contextOnly?: boolean;
|
|
36
|
+
}
|
|
37
|
+
export interface SyncOptions {
|
|
38
|
+
/** What the old and the new side are called in an error. */
|
|
39
|
+
labels?: {
|
|
40
|
+
old: string;
|
|
41
|
+
new: string;
|
|
42
|
+
};
|
|
43
|
+
/** Every nested site of the repo, the ones not planned included: its templates and its marker's own answers. */
|
|
44
|
+
siblings?: readonly {
|
|
45
|
+
dir: string;
|
|
46
|
+
templates: readonly string[];
|
|
47
|
+
answers: Answers;
|
|
48
|
+
}[];
|
|
49
|
+
/** The version to write into the root marker, which must be among the sites; none: the version is left as it is. */
|
|
50
|
+
version?: string;
|
|
51
|
+
}
|
|
52
|
+
/** What planning decided for one site. */
|
|
53
|
+
export interface SiteMerge {
|
|
54
|
+
dir: string;
|
|
55
|
+
report: readonly MergeEntry[];
|
|
56
|
+
/** The answers to write into the site's marker. */
|
|
57
|
+
defaults: Record<string, unknown>;
|
|
58
|
+
}
|
|
59
|
+
export interface SyncPlan {
|
|
60
|
+
sites: SiteMerge[];
|
|
61
|
+
/** The paths reported `conflicted`, over all sites. */
|
|
62
|
+
conflicted: number;
|
|
63
|
+
/**
|
|
64
|
+
* By site, the paths reported `conflicted` that the new render does not
|
|
65
|
+
* hold: files the version drops that the user edited, kept as they are, with
|
|
66
|
+
* no marker in them.
|
|
67
|
+
*/
|
|
68
|
+
dropped: Readonly<Record<string, readonly string[]>>;
|
|
69
|
+
/** Writes the merges and the markers; narrated, and skipped under --dry-run. */
|
|
70
|
+
perform(): Promise<void>;
|
|
71
|
+
}
|
|
72
|
+
/** An error as a line naming the site and what it concerns. */
|
|
73
|
+
export declare const describeError: (dir: string, e: RenderError) => string;
|
|
74
|
+
/**
|
|
75
|
+
* The merge of each of `sites` into the repo at `repo`, as the header says;
|
|
76
|
+
* `templates` is the root of templates both sides are rendered from, or each
|
|
77
|
+
* side's own.
|
|
78
|
+
*/
|
|
79
|
+
export declare function planSync(ctx: Context, repo: string, templates: string | TemplateSides, sites: readonly SiteSides[], options?: SyncOptions): Promise<SyncPlan>;
|
|
80
|
+
/**
|
|
81
|
+
* The answers a site's templates resolve to, with the given answers under
|
|
82
|
+
* them: what a nested site reads of the root. A render that fails gives the
|
|
83
|
+
* given answers alone; the error is the plan's to report.
|
|
84
|
+
*/
|
|
85
|
+
export declare function resolvedAnswers(root: string, source: Source): Promise<Answers>;
|
|
86
|
+
//# sourceMappingURL=sync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../src/sync.ts"],"names":[],"mappings":"AA2DA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAa,WAAW,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEzG,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAK5C,4EAA4E;AAC5E,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,OAAO,EAAE,OA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