@plexus-ms/lib 0.130.0 → 0.132.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.
Files changed (109) hide show
  1. package/dist/apply.d.ts +25 -0
  2. package/dist/apply.d.ts.map +1 -0
  3. package/dist/apply.js +204 -0
  4. package/dist/apply.js.map +1 -0
  5. package/dist/bookkeeping.js +3 -3
  6. package/dist/bookkeeping.js.map +1 -1
  7. package/dist/bundled.d.ts +15 -0
  8. package/dist/bundled.d.ts.map +1 -0
  9. package/dist/bundled.js +42 -0
  10. package/dist/bundled.js.map +1 -0
  11. package/dist/changeset.js +3 -3
  12. package/dist/changeset.js.map +1 -1
  13. package/dist/consumers.d.ts +6 -35
  14. package/dist/consumers.d.ts.map +1 -1
  15. package/dist/consumers.js +45 -83
  16. package/dist/consumers.js.map +1 -1
  17. package/dist/doctor.d.ts +17 -1
  18. package/dist/doctor.d.ts.map +1 -1
  19. package/dist/doctor.js +167 -11
  20. package/dist/doctor.js.map +1 -1
  21. package/dist/engine.d.ts +2 -0
  22. package/dist/engine.d.ts.map +1 -0
  23. package/dist/engine.js +9 -0
  24. package/dist/engine.js.map +1 -0
  25. package/dist/frontmatter.d.ts.map +1 -1
  26. package/dist/frontmatter.js +6 -5
  27. package/dist/frontmatter.js.map +1 -1
  28. package/dist/index.d.ts +13 -8
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +14 -9
  31. package/dist/index.js.map +1 -1
  32. package/dist/io.d.ts +1 -1
  33. package/dist/marker.d.ts +38 -0
  34. package/dist/marker.d.ts.map +1 -1
  35. package/dist/marker.js +269 -16
  36. package/dist/marker.js.map +1 -1
  37. package/dist/model.d.ts +15 -17
  38. package/dist/model.d.ts.map +1 -1
  39. package/dist/model.js +19 -21
  40. package/dist/model.js.map +1 -1
  41. package/dist/need.d.ts +1 -1
  42. package/dist/need.d.ts.map +1 -1
  43. package/dist/need.js +2 -2
  44. package/dist/need.js.map +1 -1
  45. package/dist/newSite.d.ts +31 -0
  46. package/dist/newSite.d.ts.map +1 -0
  47. package/dist/newSite.js +184 -0
  48. package/dist/newSite.js.map +1 -0
  49. package/dist/overview.d.ts +5 -9
  50. package/dist/overview.d.ts.map +1 -1
  51. package/dist/overview.js +26 -51
  52. package/dist/overview.js.map +1 -1
  53. package/dist/pull.d.ts +48 -21
  54. package/dist/pull.d.ts.map +1 -1
  55. package/dist/pull.js +183 -67
  56. package/dist/pull.js.map +1 -1
  57. package/dist/recursive.d.ts.map +1 -1
  58. package/dist/recursive.js +7 -5
  59. package/dist/recursive.js.map +1 -1
  60. package/dist/requirements.d.ts +1 -1
  61. package/dist/requirements.d.ts.map +1 -1
  62. package/dist/requirements.js +11 -13
  63. package/dist/requirements.js.map +1 -1
  64. package/dist/siteTemplates.d.ts +14 -0
  65. package/dist/siteTemplates.d.ts.map +1 -0
  66. package/dist/siteTemplates.js +107 -0
  67. package/dist/siteTemplates.js.map +1 -0
  68. package/dist/sites.d.ts +24 -0
  69. package/dist/sites.d.ts.map +1 -0
  70. package/dist/sites.js +89 -0
  71. package/dist/sites.js.map +1 -0
  72. package/dist/standard-index.json +1 -1
  73. package/dist/summary.d.ts +1 -1
  74. package/dist/summary.d.ts.map +1 -1
  75. package/dist/summary.js +6 -1
  76. package/dist/summary.js.map +1 -1
  77. package/dist/sync.d.ts +86 -0
  78. package/dist/sync.d.ts.map +1 -0
  79. package/dist/sync.js +227 -0
  80. package/dist/sync.js.map +1 -0
  81. package/dist/take.d.ts +20 -25
  82. package/dist/take.d.ts.map +1 -1
  83. package/dist/take.js +48 -142
  84. package/dist/take.js.map +1 -1
  85. package/dist/templatesRoot.d.ts +5 -0
  86. package/dist/templatesRoot.d.ts.map +1 -0
  87. package/dist/templatesRoot.js +37 -0
  88. package/dist/templatesRoot.js.map +1 -0
  89. package/dist/update.d.ts +48 -10
  90. package/dist/update.d.ts.map +1 -1
  91. package/dist/update.js +173 -78
  92. package/dist/update.js.map +1 -1
  93. package/dist/version.d.ts +2 -2
  94. package/dist/version.d.ts.map +1 -1
  95. package/dist/version.js +2 -8
  96. package/dist/version.js.map +1 -1
  97. package/dist/versionTemplates.d.ts +24 -0
  98. package/dist/versionTemplates.d.ts.map +1 -0
  99. package/dist/versionTemplates.js +168 -0
  100. package/dist/versionTemplates.js.map +1 -0
  101. package/package.json +2 -1
  102. package/dist/copier.d.ts +0 -17
  103. package/dist/copier.d.ts.map +0 -1
  104. package/dist/copier.js +0 -35
  105. package/dist/copier.js.map +0 -1
  106. package/dist/templates.d.ts +0 -21
  107. package/dist/templates.d.ts.map +0 -1
  108. package/dist/templates.js +0 -55
  109. package/dist/templates.js.map +0 -1
@@ -0,0 +1,168 @@
1
+ // The templates of a Plexus version, and the engine that renders them: one side
2
+ // of `plx update` (update.ts), which renders the tree a repo's sites were last
3
+ // brought to with the templates of the version it is on, and the tree it is
4
+ // brought to with those of the version it takes (Decisions § 6 of the template
5
+ // composition). A version's templates are only ever rendered by that version's
6
+ // own plx-template, so that an engine change can never pass for a template
7
+ // change. A render of no template at all, which a marker without templates
8
+ // asks for, is the one exception: it is empty for every engine, and the
9
+ // command refuses it, so this plx's engine gives it.
10
+ //
11
+ // The running version is the plx that runs: its templates are the ones it
12
+ // bundles (`templatesRoot()`), rendered by its own engine in this process, and
13
+ // nothing is fetched. Any other version is fetched from the npm registry: its
14
+ // `@plexus-ms/cli`, installed into a scratch directory with npm (`npm install
15
+ // --prefix <dir> @plexus-ms/cli@<version>`), brings the templates it bundles
16
+ // (`dist/templates`) and, as its dependency at the same version,
17
+ // `@plexus-ms/cli-template`, whose `plx-template` is run with the node that
18
+ // runs plx: `plx-template render --answers - <out> <template-dir>...`. Its
19
+ // render is read back with the policies file beside it (`readRender` of this
20
+ // plx's engine), and its resolved answers from what it prints. npm runs in the
21
+ // scratch directory, so the repo's own npm settings do not apply and the
22
+ // user's and the machine's do (a mirror, a proxy); install scripts are not run.
23
+ // A version is fetched once per run of a repo and rendered once per site and
24
+ // side. A failed install is reported with npm's error lines, which name the
25
+ // cause (a version the registry lacks, no network), not with its last line,
26
+ // which only points to npm's log.
27
+ //
28
+ // Every failure is loud: a version that cannot be fetched, a package that
29
+ // bundles no templates (a version before the engine), a plx-template that
30
+ // cannot run, is an error naming the version, never a render that changed
31
+ // nothing. A render that the version's plx-template refuses (an answer
32
+ // missing, a template error) is no failure of the run's own: its errors are
33
+ // returned, as this plx's engine returns its own, for the caller to list with
34
+ // the site and the side.
35
+ import { join } from 'node:path';
36
+ import { CROSSOVER_RUNBOOK } from "./apply.js";
37
+ import { run } from "./effects.js";
38
+ import { engine } from "./engine.js";
39
+ import { detailOf, ExecError } from "./io.js";
40
+ import { RESERVED_KEYS } from "./marker.js";
41
+ import { isDirectory, templatesRoot } from "./templatesRoot.js";
42
+ /** The package that bundles the templates and depends on the engine at the same version. */
43
+ const CLI = '@plexus-ms/cli';
44
+ const ENGINE = '@plexus-ms/cli-template';
45
+ /** The templates of `version`, and how they are rendered, as the header says. */
46
+ export async function templatesOf(ctx, version, options) {
47
+ if (version === options.plxVersion)
48
+ return { root: options.bundled ?? templatesRoot() };
49
+ const into = join(options.scratch, version);
50
+ let fetched;
51
+ try {
52
+ fetched = await (options.fetch ?? fromRegistry)(ctx, version, into);
53
+ }
54
+ catch (error) {
55
+ throw new Error(`cannot take the templates of ${version}: ${error.message}`);
56
+ }
57
+ return {
58
+ root: fetched.templates,
59
+ render: renderBy(ctx, version, fetched, join(options.scratch, `${version}-renders`)),
60
+ };
61
+ }
62
+ /** The render of another version's plx-template, each into a directory of its own below `renders`. */
63
+ function renderBy(ctx, version, fetched, renders) {
64
+ let count = 0;
65
+ return async (names, answers) => {
66
+ // Nothing to render (a marker without templates gives its answers only): any engine renders it alike, and the
67
+ // command wants a template, so this plx's engine does it.
68
+ if (names.length === 0) {
69
+ const { render } = await engine();
70
+ const empty = render([], answers);
71
+ return { rendered: { tree: empty.tree, policies: empty.files, answers: empty.answers }, errors: [] };
72
+ }
73
+ const out = join(renders, String(count++));
74
+ const args = [
75
+ fetched.plxTemplate,
76
+ 'render',
77
+ '--answers',
78
+ '-',
79
+ out,
80
+ ...names.map((n) => join(fetched.templates, n)),
81
+ ];
82
+ let printed;
83
+ try {
84
+ printed = (await ctx.stage(run(process.execPath, args, { input: JSON.stringify(answers) }))) ?? '';
85
+ }
86
+ catch (error) {
87
+ // 3: the inputs are wrong, and each error is a line on standard error.
88
+ if (error instanceof ExecError && error.code === 3)
89
+ return { errors: renderErrors(error.stderr) };
90
+ throw new Error(`the plx-template of ${version} failed: ${detailOf(error) || error.message}`);
91
+ }
92
+ let resolved;
93
+ try {
94
+ resolved = JSON.parse(printed).answers;
95
+ }
96
+ catch {
97
+ throw new Error(`the plx-template of ${version} printed no JSON`);
98
+ }
99
+ const reserved = RESERVED_KEYS.filter((key) => key in resolved);
100
+ if (reserved.length > 0)
101
+ return {
102
+ errors: reserved.map((key) => `a template of ${version} declares \`${key}\`, a key of the marker`),
103
+ };
104
+ const { readRender } = await engine();
105
+ return { rendered: { ...(await readRender(out)), answers: resolved }, errors: [] };
106
+ };
107
+ }
108
+ /** The errors a refused render repeats on standard error, one a line. */
109
+ function renderErrors(stderr) {
110
+ const prefix = 'plx-template: error: ';
111
+ const lines = stderr.split('\n').filter((l) => l.startsWith(prefix));
112
+ return lines.length > 0 ? lines.map((l) => l.slice(prefix.length)) : [stderr.trim() || 'refused'];
113
+ }
114
+ /** The version's `@plexus-ms/cli` from the npm registry, installed below `into`, as the header says. */
115
+ export const fromRegistry = async (ctx, version, into) => {
116
+ const spec = `${CLI}@${version}`;
117
+ try {
118
+ await ctx.stage(run('npm', [
119
+ 'install',
120
+ '--prefix',
121
+ into,
122
+ '--no-save',
123
+ '--no-package-lock',
124
+ '--ignore-scripts',
125
+ '--no-audit',
126
+ '--no-fund',
127
+ '--loglevel=error',
128
+ spec,
129
+ ], { cwd: await made(ctx, into) }));
130
+ }
131
+ catch (error) {
132
+ const why = (error instanceof ExecError && npmCause(error.stderr)) || detailOf(error) || error.message;
133
+ throw new Error(`cannot fetch ${spec} from the registry: ${why}`);
134
+ }
135
+ const modules = join(into, 'node_modules');
136
+ const templates = join(modules, CLI, 'dist', 'templates');
137
+ if (!isDirectory(templates))
138
+ throw new Error(`${spec} bundles no templates: ${version} predates plx-template, and this plx renders only versions that bundle them; a repo on a version before the engine gets onto one by ${CROSSOVER_RUNBOOK}`);
139
+ let bin;
140
+ try {
141
+ bin = JSON.parse(await ctx.readFile(join(modules, ENGINE, 'package.json')))
142
+ .bin?.['plx-template'];
143
+ }
144
+ catch (error) {
145
+ throw new Error(`${spec} came without ${ENGINE}: ${error.message}`);
146
+ }
147
+ if (typeof bin !== 'string')
148
+ throw new Error(`${ENGINE} of ${version} names no plx-template`);
149
+ return { plxTemplate: join(modules, ENGINE, bin), templates };
150
+ };
151
+ /**
152
+ * What npm says went wrong: its error lines, in order, without its pointer to
153
+ * the log of the run, which ends every failure and names no cause; empty
154
+ * where it printed none.
155
+ */
156
+ function npmCause(stderr) {
157
+ return stderr
158
+ .split('\n')
159
+ .map((l) => l.trimEnd())
160
+ .filter((l) => /^npm (error|ERR!) /.test(l) && !/A complete log of this run/.test(l))
161
+ .join('\n');
162
+ }
163
+ /** The directory `dir`, made where it is missing. */
164
+ async function made(ctx, dir) {
165
+ await ctx.stage(run('mkdir', ['-p', dir]));
166
+ return dir;
167
+ }
168
+ //# sourceMappingURL=versionTemplates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"versionTemplates.js","sourceRoot":"","sources":["../src/versionTemplates.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,+EAA+E;AAC/E,4EAA4E;AAC5E,+EAA+E;AAC/E,+EAA+E;AAC/E,2EAA2E;AAC3E,2EAA2E;AAC3E,wEAAwE;AACxE,qDAAqD;AACrD,EAAE;AACF,0EAA0E;AAC1E,+EAA+E;AAC/E,8EAA8E;AAC9E,8EAA8E;AAC9E,6EAA6E;AAC7E,iEAAiE;AACjE,4EAA4E;AAC5E,2EAA2E;AAC3E,6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I,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAED,qDAAqD;AACrD,KAAK,UAAU,IAAI,CAAC,GAAY,EAAE,GAAW;IAC3C,MAAM,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;IAC3C,OAAO,GAAG,CAAC;AACb,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plexus-ms/lib",
3
- "version": "0.130.0",
3
+ "version": "0.132.0",
4
4
  "description": "The Plexus verbs as a library: the plan-then-apply core behind plx, and the one parser of Plexus's own file shapes",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "type": "module",
@@ -27,6 +27,7 @@
27
27
  "node": ">=24.22.1"
28
28
  },
29
29
  "dependencies": {
30
+ "@plexus-ms/cli-template": "0.132.0",
30
31
  "semver": "^7.8.6",
31
32
  "yaml": "^2.9.1"
32
33
  },
package/dist/copier.d.ts DELETED
@@ -1,17 +0,0 @@
1
- export declare const ANSWERS_FILE = ".copier-answers.yml";
2
- export declare const TEMPLATE_FILES: string[];
3
- export declare const COPIER_VERSION = "9.19.1";
4
- /** `copier <args>` at the pinned version, as arguments to `mise`. */
5
- export declare const copierVia: (args: string[]) => string[];
6
- export interface Answers {
7
- /** The template's ref the project was last updated to, if recorded. */
8
- commit?: string;
9
- /** Where the template comes from, e.g. `gh:plexus-ms/template-repo-turbo`. */
10
- src?: string;
11
- /** Every other answer, by question name. */
12
- answers: Record<string, unknown>;
13
- }
14
- export declare function parseAnswers(text: string): Answers;
15
- /** The answers file with one top-level key set, everything else (comments, order, the other answers) kept. */
16
- export declare function setAnswer(text: string, key: string, value: string): string;
17
- //# sourceMappingURL=copier.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"copier.d.ts","sourceRoot":"","sources":["../src/copier.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,YAAY,wBAAwB,CAAC;AAClD,eAAO,MAAM,cAAc,UAAgC,CAAC;AAO5D,eAAO,MAAM,cAAc,WAAW,CAAC;AAEvC,qEAAqE;AACrE,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,EAAE,KAAG,MAAM,EAAmE,CAAC;AAErH,MAAM,WAAW,OAAO;IACtB,uEAAuE;IACvE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8EAA8E;IAC9E,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,4CAA4C;IAC5C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAUlD;AAED,8GAA8G;AAC9G,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAK1E"}
package/dist/copier.js DELETED
@@ -1,35 +0,0 @@
1
- // Copier's bookkeeping in a generated project (§ 3 PLX-Updates): the answers
2
- // file records the template (`_src_path`) and the version it was last synced
3
- // to (`_commit`), plus the answers given. A template is a directory carrying a
4
- // `copier.yml`. The file is read and written as YAML, never as lines of text.
5
- import { parse, parseDocument } from 'yaml';
6
- export const ANSWERS_FILE = '.copier-answers.yml';
7
- export const TEMPLATE_FILES = ['copier.yml', 'copier.yaml'];
8
- // The copier every propagation runs, pinned here so that it travels with plx:
9
- // a consumer's update never depends on whichever copier the operator's machine
10
- // has on its PATH. mise installs it on first use. The update bot moves the pin
11
- // (the regex manager in renovate.json); the next version ships it.
12
- // renovate: datasource=pypi depName=copier
13
- export const COPIER_VERSION = '9.19.1';
14
- /** `copier <args>` at the pinned version, as arguments to `mise`. */
15
- export const copierVia = (args) => ['exec', `copier@${COPIER_VERSION}`, '--', 'copier', ...args];
16
- export function parseAnswers(text) {
17
- const data = parse(text);
18
- if (data === null || typeof data !== 'object' || Array.isArray(data))
19
- throw new Error('answers file is not a mapping');
20
- const { _commit, _src_path, ...answers } = data;
21
- return {
22
- commit: _commit === undefined ? undefined : String(_commit),
23
- src: _src_path === undefined ? undefined : String(_src_path),
24
- answers,
25
- };
26
- }
27
- /** The answers file with one top-level key set, everything else (comments, order, the other answers) kept. */
28
- export function setAnswer(text, key, value) {
29
- const doc = parseDocument(text);
30
- if (doc.errors.length > 0)
31
- throw new Error(`answers file is not YAML: ${doc.errors[0]?.message}`);
32
- doc.set(key, value);
33
- return doc.toString();
34
- }
35
- //# sourceMappingURL=copier.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"copier.js","sourceRoot":"","sources":["../src/copier.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,6EAA6E;AAC7E,+EAA+E;AAC/E,8EAA8E;AAC9E,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAE5C,MAAM,CAAC,MAAM,YAAY,GAAG,qBAAqB,CAAC;AAClD,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC;AAE5D,8EAA8E;AAC9E,+EAA+E;AAC/E,+EAA+E;AAC/E,mEAAmE;AACnE,2CAA2C;AAC3C,MAAM,CAAC,MAAM,cAAc,GAAG,QAAQ,CAAC;AAEvC,qEAAqE;AACrE,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,IAAc,EAAY,EAAE,CAAC,CAAC,MAAM,EAAE,UAAU,cAAc,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,CAAC;AAWrH,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,MAAM,IAAI,GAAY,KAAK,CAAC,IAAI,CAAC,CAAC;IAClC,IAAI,IAAI,KAAK,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QAClE,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACnD,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,OAAO,EAAE,GAAG,IAA+B,CAAC;IAC3E,OAAO;QACL,MAAM,EAAE,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;QAC3D,GAAG,EAAE,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC;QAC5D,OAAO;KACR,CAAC;AACJ,CAAC;AAED,8GAA8G;AAC9G,MAAM,UAAU,SAAS,CAAC,IAAY,EAAE,GAAW,EAAE,KAAa;IAChE,MAAM,GAAG,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;IAChC,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,6BAA6B,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IAClG,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACpB,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;AACxB,CAAC"}
@@ -1,21 +0,0 @@
1
- /** The versioned repos that are templates: what a repo can be generated from. */
2
- export declare const TEMPLATES: readonly string[];
3
- /** The template source copier records for a template of the upstream organisation. */
4
- export declare const templateSource: (template: string) => string;
5
- /**
6
- * Templates renamed on a version, old name → current (0.114.0: the web template
7
- * became the Turborepo template, the platform repo the operations repo; 0.120.0:
8
- * the repos' `preset-` prefix became `template-`, copier's own word). A
9
- * consumer whose answers still name the old one is a consumer of the current
10
- * one, and its next update points the answers at the new name.
11
- */
12
- export declare const RENAMED_TEMPLATES: Readonly<Record<string, string>>;
13
- /**
14
- * The current template a recorded template source stands for, under its
15
- * current or an earlier name, or undefined when it is none of the given
16
- * templates. Owner and repo name are compared, not the spelling.
17
- */
18
- export declare function templateOf(src: string, templates: readonly string[]): string | undefined;
19
- /** Whether a recorded source names a template by a name it had before a rename, in any spelling. */
20
- export declare function namesOldTemplate(src: string): boolean;
21
- //# sourceMappingURL=templates.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../src/templates.ts"],"names":[],"mappings":"AAMA,iFAAiF;AACjF,eAAO,MAAM,SAAS,EAAE,SAAS,MAAM,EAA6D,CAAC;AAErG,sFAAsF;AACtF,eAAO,MAAM,cAAc,GAAI,UAAU,MAAM,KAAG,MAAoC,CAAC;AAEvF;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAM9D,CAAC;AAmBF;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAMxF;AAED,oGAAoG;AACpG,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAGrD"}
package/dist/templates.js DELETED
@@ -1,55 +0,0 @@
1
- // The templates (§ 1.6 PLX) by name, and what a copier answers file's recorded
2
- // source says about which one a site is generated from. Both the model (which
3
- // repo is the operations repo) and the consumers (which sites an update
4
- // takes) read a source through `templateOf`.
5
- import { VERSIONED_REPOS } from "./version.js";
6
- /** The versioned repos that are templates: what a repo can be generated from. */
7
- export const TEMPLATES = VERSIONED_REPOS.filter((r) => r.startsWith('template-'));
8
- /** The template source copier records for a template of the upstream organisation. */
9
- export const templateSource = (template) => `gh:plexus-ms/${template}`;
10
- /**
11
- * Templates renamed on a version, old name → current (0.114.0: the web template
12
- * became the Turborepo template, the platform repo the operations repo; 0.120.0:
13
- * the repos' `preset-` prefix became `template-`, copier's own word). A
14
- * consumer whose answers still name the old one is a consumer of the current
15
- * one, and its next update points the answers at the new name.
16
- */
17
- export const RENAMED_TEMPLATES = {
18
- 'preset-repo-web': 'template-repo-turbo',
19
- 'preset-repo-platform': 'template-repo-operations',
20
- 'preset-repo-turbo': 'template-repo-turbo',
21
- 'preset-app-nextjs': 'template-app-nextjs',
22
- 'preset-repo-operations': 'template-repo-operations',
23
- };
24
- /** The organisation the templates are published under. */
25
- const UPSTREAM = 'plexus-ms';
26
- /**
27
- * A recorded source as owner and repo name, whichever way it spells a GitHub
28
- * repo: copier's `gh:owner/repo`, `https://github.com/owner/repo`,
29
- * `git@github.com:owner/repo` or `ssh://git@github.com/owner/repo`, each with
30
- * or without `.git`. Undefined for anything else, a local path among them.
31
- */
32
- function githubRepoOf(src) {
33
- const m = /^(?:gh:|https?:\/\/(?:www\.)?github\.com\/|git@github\.com:|ssh:\/\/git@github\.com\/)([^/\s]+)\/([^/\s]+?)(?:\.git)?\/?$/i.exec(src.trim());
34
- return m?.[1] && m[2] ? { owner: m[1].toLowerCase(), name: m[2].toLowerCase() } : undefined;
35
- }
36
- /**
37
- * The current template a recorded template source stands for, under its
38
- * current or an earlier name, or undefined when it is none of the given
39
- * templates. Owner and repo name are compared, not the spelling.
40
- */
41
- export function templateOf(src, templates) {
42
- const repo = githubRepoOf(src);
43
- if (repo?.owner !== UPSTREAM)
44
- return undefined;
45
- if (templates.includes(repo.name))
46
- return repo.name;
47
- const current = Object.hasOwn(RENAMED_TEMPLATES, repo.name) ? RENAMED_TEMPLATES[repo.name] : undefined;
48
- return current && templates.includes(current) ? current : undefined;
49
- }
50
- /** Whether a recorded source names a template by a name it had before a rename, in any spelling. */
51
- export function namesOldTemplate(src) {
52
- const repo = githubRepoOf(src);
53
- return repo?.owner === UPSTREAM && Object.hasOwn(RENAMED_TEMPLATES, repo.name);
54
- }
55
- //# sourceMappingURL=templates.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"templates.js","sourceRoot":"","sources":["../src/templates.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,8EAA8E;AAC9E,wEAAwE;AACxE,6CAA6C;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,iFAAiF;AACjF,MAAM,CAAC,MAAM,SAAS,GAAs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