@smoothbricks/cli 0.10.3 → 0.10.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -13
- package/dist/bun/preload.d.ts +13 -0
- package/dist/bun/preload.d.ts.map +1 -0
- package/dist/bun/preload.js +12 -0
- package/dist/cli.js +12 -4
- package/dist/generate/index.d.ts.map +1 -1
- package/dist/generate/index.js +0 -6
- package/dist/github-ci/index.d.ts.map +1 -1
- package/dist/github-ci/index.js +52 -16
- package/dist/github-ci/outputs.d.ts.map +1 -1
- package/dist/github-ci/outputs.js +1 -2
- package/dist/lib/cli-package.js +2 -2
- package/dist/lib/json.d.ts +118 -11
- package/dist/lib/json.d.ts.map +1 -1
- package/dist/lib/json.js +317 -29
- package/dist/lib/workspace.d.ts +7 -14
- package/dist/lib/workspace.d.ts.map +1 -1
- package/dist/lib/workspace.js +76 -82
- package/dist/monorepo/ci-workflow.d.ts +2 -0
- package/dist/monorepo/ci-workflow.d.ts.map +1 -1
- package/dist/monorepo/ci-workflow.js +27 -1
- package/dist/monorepo/git-config.js +2 -2
- package/dist/monorepo/index.d.ts +3 -1
- package/dist/monorepo/index.d.ts.map +1 -1
- package/dist/monorepo/index.js +6 -2
- package/dist/monorepo/lockfile.d.ts +13 -1
- package/dist/monorepo/lockfile.d.ts.map +1 -1
- package/dist/monorepo/lockfile.js +33 -21
- package/dist/monorepo/managed-files.d.ts +11 -0
- package/dist/monorepo/managed-files.d.ts.map +1 -1
- package/dist/monorepo/managed-files.js +52 -32
- package/dist/monorepo/package-policy.d.ts.map +1 -1
- package/dist/monorepo/package-policy.js +52 -45
- package/dist/monorepo/packed-manifest.d.ts +5 -2
- package/dist/monorepo/packed-manifest.d.ts.map +1 -1
- package/dist/monorepo/packed-manifest.js +16 -47
- package/dist/monorepo/packed-package.d.ts.map +1 -1
- package/dist/monorepo/packed-package.js +28 -16
- package/dist/monorepo/packs/index.d.ts.map +1 -1
- package/dist/monorepo/packs/index.js +13 -4
- package/dist/monorepo/publish-workflow.js +3 -1
- package/dist/monorepo/runtime.d.ts +15 -0
- package/dist/monorepo/runtime.d.ts.map +1 -1
- package/dist/monorepo/runtime.js +66 -12
- package/dist/monorepo/tool-validation.d.ts.map +1 -1
- package/dist/monorepo/tool-validation.js +32 -23
- package/dist/monorepo/wrangler.d.ts.map +1 -1
- package/dist/monorepo/wrangler.js +13 -13
- package/dist/nx/index.d.ts +9 -7
- package/dist/nx/index.d.ts.map +1 -1
- package/dist/nx/index.js +48 -31
- package/dist/pr/index.d.ts.map +1 -1
- package/dist/pr/index.js +28 -32
- package/dist/release/candidates.d.ts +3 -2
- package/dist/release/candidates.d.ts.map +1 -1
- package/dist/release/candidates.js +4 -5
- package/dist/release/index.d.ts +1 -0
- package/dist/release/index.d.ts.map +1 -1
- package/dist/release/index.js +82 -59
- package/dist/wrangler/prepare-env.d.ts +0 -1
- package/dist/wrangler/prepare-env.d.ts.map +1 -1
- package/dist/wrangler/prepare-env.js +100 -51
- package/dist/wrangler/scaffold.d.ts.map +1 -1
- package/dist/wrangler/scaffold.js +12 -12
- package/managed/raw/git-format-staged.yml +19 -1
- package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +2 -1
- package/managed/raw/tooling/direnv/merge-newer-pins.sh +3 -3
- package/managed/raw/tooling/direnv/setup-environment.ts +150 -19
- package/managed/raw/tooling/git-hooks/pre-commit.sh +0 -6
- package/managed/templates/github/actions/cache-node-modules/action.yml +5 -2
- package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +19 -0
- package/managed/templates/github/actions/setup-devenv/action.yml +5 -0
- package/managed/templates/github/workflows/managed-files.yml +80 -0
- package/package.json +15 -4
- package/src/bun/preload.ts +12 -0
- package/src/cli.ts +19 -7
- package/src/generate/index.ts +0 -6
- package/src/github-ci/index.ts +49 -18
- package/src/github-ci/outputs.ts +1 -2
- package/src/lib/cli-package.ts +2 -2
- package/src/lib/json.ts +291 -32
- package/src/lib/workspace.ts +88 -100
- package/src/monorepo/__tests__/ci-workflow.test.ts +3 -3
- package/src/monorepo/ci-workflow.ts +27 -1
- package/src/monorepo/git-config.ts +2 -2
- package/src/monorepo/index.ts +6 -2
- package/src/monorepo/lockfile.test.ts +35 -36
- package/src/monorepo/lockfile.ts +48 -24
- package/src/monorepo/managed-files.test.ts +1 -0
- package/src/monorepo/managed-files.ts +57 -38
- package/src/monorepo/package-policy.test.ts +20 -50
- package/src/monorepo/package-policy.ts +76 -59
- package/src/monorepo/packed-manifest.ts +18 -52
- package/src/monorepo/packed-package.ts +43 -22
- package/src/monorepo/packs/index.ts +13 -4
- package/src/monorepo/publish-workflow.ts +3 -1
- package/src/monorepo/runtime.test.ts +42 -3
- package/src/monorepo/runtime.ts +90 -12
- package/src/monorepo/tool-validation.ts +35 -25
- package/src/monorepo/wrangler.test.ts +11 -15
- package/src/monorepo/wrangler.ts +15 -15
- package/src/nx/index.test.ts +9 -5
- package/src/nx/index.ts +69 -42
- package/src/pr/index.ts +42 -36
- package/src/release/__tests__/candidates.test.ts +5 -4
- package/src/release/__tests__/trust-publisher.test.ts +7 -0
- package/src/release/candidates.ts +10 -17
- package/src/release/index.ts +104 -73
- package/src/wrangler/prepare-env.ts +75 -54
- package/src/wrangler/scaffold.test.ts +9 -12
- package/src/wrangler/scaffold.ts +13 -13
package/dist/nx/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { existsSync } from 'node:fs';
|
|
|
2
2
|
import { lstat, rm } from 'node:fs/promises';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
4
|
import { $ } from 'bun';
|
|
5
|
-
import {
|
|
5
|
+
import { parseNxProjectJsonText, parseStringArrayText, } from '../lib/json.js';
|
|
6
6
|
import { decode, run } from '../lib/run.js';
|
|
7
7
|
export function nxResetCommand() {
|
|
8
8
|
return { command: 'nx', args: ['reset'] };
|
|
@@ -14,51 +14,66 @@ export function nxCacheDirectories(root) {
|
|
|
14
14
|
return [join(root, '.nx/cache'), join(root, '.nx/workspace-data'), join(root, 'node_modules/.cache/nx')];
|
|
15
15
|
}
|
|
16
16
|
export function targetNamesFromNxProjectJson(value) {
|
|
17
|
-
const targets =
|
|
17
|
+
const targets = value?.targets;
|
|
18
18
|
return targets ? Object.keys(targets).sort((a, b) => a.localeCompare(b)) : [];
|
|
19
19
|
}
|
|
20
20
|
export function projectRootFromNxProjectJson(value) {
|
|
21
|
-
return
|
|
21
|
+
return typeof value?.root === 'string' ? value.root : undefined;
|
|
22
22
|
}
|
|
23
23
|
export function buildDependsOnFromNxProjectJson(value) {
|
|
24
24
|
return targetDependenciesFromNxProjectJson(value).get('build');
|
|
25
25
|
}
|
|
26
26
|
export function targetDependenciesFromNxProjectJson(value) {
|
|
27
|
-
const targets =
|
|
27
|
+
const targets = value?.targets;
|
|
28
28
|
const dependencies = new Map();
|
|
29
29
|
if (!targets) {
|
|
30
30
|
return dependencies;
|
|
31
31
|
}
|
|
32
32
|
for (const [targetName, target] of Object.entries(targets)) {
|
|
33
|
-
if (!
|
|
33
|
+
if (!target.dependsOn) {
|
|
34
34
|
continue;
|
|
35
35
|
}
|
|
36
36
|
const entries = [];
|
|
37
37
|
for (const dependency of target.dependsOn) {
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
const local = localDependsOnTarget(dependency);
|
|
39
|
+
if (local === undefined) {
|
|
40
|
+
if (isInvalidDependsOn(dependency)) {
|
|
41
|
+
throw new Error(`Nx target ${targetName} has an invalid dependsOn entry.`);
|
|
42
|
+
}
|
|
40
43
|
continue;
|
|
41
44
|
}
|
|
42
|
-
|
|
43
|
-
throw new Error(`Nx target ${targetName} has an invalid dependsOn entry.`);
|
|
44
|
-
}
|
|
45
|
-
if (dependency.projects !== undefined && dependency.projects !== 'self') {
|
|
46
|
-
throw new Error(`Nx target ${targetName} uses unsupported cross-project dependsOn for ${dependency.target}.`);
|
|
47
|
-
}
|
|
48
|
-
entries.push(dependency.target);
|
|
45
|
+
entries.push(local);
|
|
49
46
|
}
|
|
50
47
|
dependencies.set(targetName, entries);
|
|
51
48
|
}
|
|
52
49
|
return dependencies;
|
|
53
50
|
}
|
|
51
|
+
function localDependsOnTarget(dependency) {
|
|
52
|
+
if (typeof dependency === 'string') {
|
|
53
|
+
return dependency;
|
|
54
|
+
}
|
|
55
|
+
if (typeof dependency.target !== 'string') {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
if (dependency.projects !== undefined && dependency.projects !== 'self') {
|
|
59
|
+
// Target closures are intentionally project-local. Nx schedules explicit
|
|
60
|
+
// cross-project prerequisites itself; treating them as local targets
|
|
61
|
+
// would collect or verify outputs from the wrong project.
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
return dependency.target;
|
|
65
|
+
}
|
|
66
|
+
function isInvalidDependsOn(dependency) {
|
|
67
|
+
return typeof dependency !== 'string' && typeof dependency.target !== 'string';
|
|
68
|
+
}
|
|
54
69
|
export function targetExecutorsFromNxProjectJson(value) {
|
|
55
|
-
const targets =
|
|
70
|
+
const targets = value?.targets;
|
|
56
71
|
const executors = new Map();
|
|
57
72
|
if (!targets) {
|
|
58
73
|
return executors;
|
|
59
74
|
}
|
|
60
75
|
for (const [targetName, target] of Object.entries(targets)) {
|
|
61
|
-
if (
|
|
76
|
+
if (typeof target.executor === 'string') {
|
|
62
77
|
executors.set(targetName, target.executor);
|
|
63
78
|
}
|
|
64
79
|
}
|
|
@@ -68,35 +83,34 @@ export function targetOutputsFromNxProjectJson(value) {
|
|
|
68
83
|
return targetStringArraysFromNxProjectJson(value, 'outputs');
|
|
69
84
|
}
|
|
70
85
|
export function targetScriptsFromNxProjectJson(value) {
|
|
71
|
-
const targets =
|
|
86
|
+
const targets = value?.targets;
|
|
72
87
|
const scripts = new Map();
|
|
73
88
|
if (!targets) {
|
|
74
89
|
return scripts;
|
|
75
90
|
}
|
|
76
91
|
for (const [targetName, target] of Object.entries(targets)) {
|
|
77
|
-
if (
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
const options = recordProperty(target, 'options');
|
|
81
|
-
if (typeof options?.script === 'string') {
|
|
82
|
-
scripts.set(targetName, options.script);
|
|
92
|
+
if (typeof target.options?.script === 'string') {
|
|
93
|
+
scripts.set(targetName, target.options.script);
|
|
83
94
|
}
|
|
84
95
|
}
|
|
85
96
|
return scripts;
|
|
86
97
|
}
|
|
87
98
|
function targetStringArraysFromNxProjectJson(value, property) {
|
|
88
|
-
const targets =
|
|
99
|
+
const targets = value?.targets;
|
|
89
100
|
const values = new Map();
|
|
90
101
|
if (!targets) {
|
|
91
102
|
return values;
|
|
92
103
|
}
|
|
93
104
|
for (const [targetName, target] of Object.entries(targets)) {
|
|
94
|
-
if (!isRecord(target)) {
|
|
95
|
-
continue;
|
|
96
|
-
}
|
|
97
105
|
const entries = target[property];
|
|
98
106
|
if (Array.isArray(entries)) {
|
|
99
|
-
|
|
107
|
+
const strings = [];
|
|
108
|
+
for (const entry of entries) {
|
|
109
|
+
if (typeof entry === 'string') {
|
|
110
|
+
strings.push(entry);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
values.set(targetName, strings);
|
|
100
114
|
}
|
|
101
115
|
}
|
|
102
116
|
return values;
|
|
@@ -120,8 +134,8 @@ export function projectNamesFromNxShowProjectsOutput(output) {
|
|
|
120
134
|
}
|
|
121
135
|
if (trimmed.startsWith('[')) {
|
|
122
136
|
try {
|
|
123
|
-
const parsed =
|
|
124
|
-
if (
|
|
137
|
+
const parsed = parseStringArrayText(trimmed);
|
|
138
|
+
if (parsed) {
|
|
125
139
|
return parsed.sort((a, b) => a.localeCompare(b));
|
|
126
140
|
}
|
|
127
141
|
}
|
|
@@ -179,7 +193,10 @@ async function readNxProjectNames(root) {
|
|
|
179
193
|
async function readProjectTarget(root, project) {
|
|
180
194
|
const command = nxShowProjectCommand(project);
|
|
181
195
|
const result = await $ `${command.command} ${command.args}`.cwd(root).quiet();
|
|
182
|
-
const parsed =
|
|
196
|
+
const parsed = parseNxProjectJsonText(decode(result.stdout));
|
|
197
|
+
if (!parsed) {
|
|
198
|
+
throw new Error(`Unable to inspect Nx project ${project}.`);
|
|
199
|
+
}
|
|
183
200
|
const targetDependencies = targetDependenciesFromNxProjectJson(parsed);
|
|
184
201
|
return {
|
|
185
202
|
project,
|
package/dist/pr/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pr/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pr/index.ts"],"names":[],"mappings":"AAOA,mFAAmF;AACnF,MAAM,MAAM,aAAa,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAEtC,MAAM,WAAW,gBAAgB;IAC/B,qFAAqF;IACrF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gFAAgF;IAChF,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,SAAS,CACP,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,GAAG,EAAE,MAAM,GACV,OAAO,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACjE,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAClE;AAoDD;;;;;;;;GAQG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,OAAO,EAAE,gBAAgB,EACzB,KAAK,GAAE,cAA6B,GACnC,OAAO,CAAC,aAAa,CAAC,CAWxB"}
|
package/dist/pr/index.js
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
import { mkdirSync, rmSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { dirname, join } from 'node:path';
|
|
3
|
+
import typia from 'typia';
|
|
3
4
|
import { formatMarkerHits, scanRefChangedForMarkers } from '../lib/conflict-markers.js';
|
|
4
|
-
import {
|
|
5
|
+
import { readJson } from '../lib/json.js';
|
|
5
6
|
import { run, runResult } from '../lib/run.js';
|
|
6
7
|
const defaultShell = {
|
|
7
8
|
runResult: (command, args, cwd) => runResult(command, args, cwd),
|
|
8
9
|
run: (command, args, cwd) => run(command, args, cwd),
|
|
9
10
|
};
|
|
11
|
+
const parseGhPrViewJson = (() => {
|
|
12
|
+
const _io0 = input => "number" === typeof input.number && "string" === typeof input.url && "string" === typeof input.headRefName && "string" === typeof input.baseRefName && (undefined === input.isCrossRepository || "boolean" === typeof input.isCrossRepository);
|
|
13
|
+
const __is = input => "object" === typeof input && null !== input && _io0(input);
|
|
14
|
+
return input => { input = JSON.parse(input); return __is(input) ? input : null; };
|
|
15
|
+
})();
|
|
16
|
+
const isPrResolveStateJson = (() => {
|
|
17
|
+
const _io0 = input => "number" === typeof input.pr && (undefined === input.url || "string" === typeof input.url) && "string" === typeof input.headBranch && "string" === typeof input.baseBranch && "string" === typeof input.remote && (undefined === input.crossRepo || "boolean" === typeof input.crossRepo) && (undefined === input.originalBranch || "string" === typeof input.originalBranch) && (undefined === input.originalSha || "string" === typeof input.originalSha) && (undefined === input.startedAt || "string" === typeof input.startedAt);
|
|
18
|
+
return input => "object" === typeof input && null !== input && _io0(input);
|
|
19
|
+
})();
|
|
10
20
|
/**
|
|
11
21
|
* Agent-first conflict resolution for a GitHub PR.
|
|
12
22
|
*
|
|
@@ -122,23 +132,16 @@ async function prMeta(shell, root, prArg) {
|
|
|
122
132
|
if (result.exitCode !== 0) {
|
|
123
133
|
throw new Error(`Could not resolve PR '${prArg}' via gh: ${result.stderr.trim() || `exit ${result.exitCode}`}`);
|
|
124
134
|
}
|
|
125
|
-
const raw =
|
|
126
|
-
if (!
|
|
135
|
+
const raw = parseGhPrViewJson(result.stdout);
|
|
136
|
+
if (!raw) {
|
|
127
137
|
throw new Error(`gh pr view returned unexpected JSON for '${prArg}'.`);
|
|
128
138
|
}
|
|
129
|
-
const
|
|
130
|
-
if (typeof number !== 'number' ||
|
|
131
|
-
typeof url !== 'string' ||
|
|
132
|
-
typeof headRefName !== 'string' ||
|
|
133
|
-
typeof baseRefName !== 'string') {
|
|
134
|
-
throw new Error(`gh pr view JSON for '${prArg}' is missing expected fields.`);
|
|
135
|
-
}
|
|
136
|
-
const match = /github\.com\/([^/]+\/[^/]+)\/pull\//.exec(url);
|
|
139
|
+
const match = /github\.com\/([^/]+\/[^/]+)\/pull\//.exec(raw.url);
|
|
137
140
|
return {
|
|
138
|
-
number,
|
|
139
|
-
url,
|
|
140
|
-
headBranch: headRefName,
|
|
141
|
-
baseBranch: baseRefName,
|
|
141
|
+
number: raw.number,
|
|
142
|
+
url: raw.url,
|
|
143
|
+
headBranch: raw.headRefName,
|
|
144
|
+
baseBranch: raw.baseRefName,
|
|
142
145
|
crossRepo: raw.isCrossRepository === true,
|
|
143
146
|
nameWithOwner: match ? match[1] : '',
|
|
144
147
|
};
|
|
@@ -225,26 +228,19 @@ function readState(statePath) {
|
|
|
225
228
|
catch {
|
|
226
229
|
return null;
|
|
227
230
|
}
|
|
228
|
-
if (!
|
|
229
|
-
return null;
|
|
230
|
-
}
|
|
231
|
-
const { pr, url, headBranch, baseBranch, remote, crossRepo, originalBranch, originalSha, startedAt } = raw;
|
|
232
|
-
if (typeof pr !== 'number' ||
|
|
233
|
-
typeof headBranch !== 'string' ||
|
|
234
|
-
typeof baseBranch !== 'string' ||
|
|
235
|
-
typeof remote !== 'string') {
|
|
231
|
+
if (!isPrResolveStateJson(raw)) {
|
|
236
232
|
return null;
|
|
237
233
|
}
|
|
238
234
|
return {
|
|
239
|
-
pr,
|
|
240
|
-
url:
|
|
241
|
-
headBranch,
|
|
242
|
-
baseBranch,
|
|
243
|
-
remote,
|
|
244
|
-
crossRepo: crossRepo === true,
|
|
245
|
-
originalBranch:
|
|
246
|
-
originalSha:
|
|
247
|
-
startedAt:
|
|
235
|
+
pr: raw.pr,
|
|
236
|
+
url: raw.url ?? '',
|
|
237
|
+
headBranch: raw.headBranch,
|
|
238
|
+
baseBranch: raw.baseBranch,
|
|
239
|
+
remote: raw.remote,
|
|
240
|
+
crossRepo: raw.crossRepo === true,
|
|
241
|
+
originalBranch: raw.originalBranch ?? '',
|
|
242
|
+
originalSha: raw.originalSha ?? '',
|
|
243
|
+
startedAt: raw.startedAt ?? '',
|
|
248
244
|
};
|
|
249
245
|
}
|
|
250
246
|
function writeState(statePath, state) {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import type { PackageJson } from '../lib/json.js';
|
|
1
2
|
import type { ReleasePackageInfo } from './core.js';
|
|
2
3
|
export interface AutoReleaseCandidateShell {
|
|
3
4
|
gitRefExists(ref: string): Promise<boolean>;
|
|
4
5
|
latestStableReleaseRef(projectName: string): Promise<string | null>;
|
|
5
6
|
packageChangedFilesSince(ref: string, packagePath: string): Promise<string[]>;
|
|
6
|
-
packageJsonAtRef(ref: string, packagePath: string): Promise<
|
|
7
|
-
currentPackageJson(packagePath: string): Promise<
|
|
7
|
+
packageJsonAtRef(ref: string, packagePath: string): Promise<PackageJson | null>;
|
|
8
|
+
currentPackageJson(packagePath: string): Promise<PackageJson | null>;
|
|
8
9
|
packageBuildInputPatterns(projectName: string, packagePath: string): Promise<string[]>;
|
|
9
10
|
packageHasHistory(packagePath: string): Promise<boolean>;
|
|
10
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"candidates.d.ts","sourceRoot":"","sources":["../../src/release/candidates.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"candidates.d.ts","sourceRoot":"","sources":["../../src/release/candidates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAGpD,MAAM,WAAW,yBAAyB;IACxC,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5C,sBAAsB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACpE,wBAAwB,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC9E,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAChF,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IACrE,yBAAyB,CAAC,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACvF,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC1D;AAgCD,wBAAsB,4BAA4B,CAAC,OAAO,SAAS,kBAAkB,EACnF,KAAK,EAAE,yBAAyB,EAChC,QAAQ,EAAE,OAAO,EAAE,GAClB,OAAO,CAAC,OAAO,EAAE,CAAC,CAQpB"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { isRecord } from '../lib/json.js';
|
|
2
1
|
import { releaseTag } from './core.js';
|
|
3
2
|
const releasableManifestKeys = [
|
|
4
3
|
'author',
|
|
@@ -80,7 +79,7 @@ async function packageHasReleasableChangesSince(shell, ref, pkg) {
|
|
|
80
79
|
}
|
|
81
80
|
function releasableManifestChanged(previousManifest, currentManifest) {
|
|
82
81
|
for (const key of releasableManifestKeys) {
|
|
83
|
-
if (!stableJsonEqual(previousManifest
|
|
82
|
+
if (!stableJsonEqual(Reflect.get(previousManifest, key), Reflect.get(currentManifest, key))) {
|
|
84
83
|
return true;
|
|
85
84
|
}
|
|
86
85
|
}
|
|
@@ -159,7 +158,7 @@ function isManifestFilesPath(path, manifest) {
|
|
|
159
158
|
return false;
|
|
160
159
|
}
|
|
161
160
|
for (const entry of files) {
|
|
162
|
-
if (
|
|
161
|
+
if (entry.length === 0 || entry.startsWith('!')) {
|
|
163
162
|
continue;
|
|
164
163
|
}
|
|
165
164
|
if (matchesManifestFilesEntry(path, entry)) {
|
|
@@ -182,10 +181,10 @@ function stableJson(value) {
|
|
|
182
181
|
if (Array.isArray(value)) {
|
|
183
182
|
return value.map(stableJson);
|
|
184
183
|
}
|
|
185
|
-
if (
|
|
184
|
+
if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
|
|
186
185
|
const normalized = {};
|
|
187
186
|
for (const key of Object.keys(value).sort()) {
|
|
188
|
-
normalized[key] = stableJson(value
|
|
187
|
+
normalized[key] = stableJson(Reflect.get(value, key));
|
|
189
188
|
}
|
|
190
189
|
return normalized;
|
|
191
190
|
}
|
package/dist/release/index.d.ts
CHANGED
|
@@ -77,6 +77,7 @@ export declare function configureTrustedPublishers<Package extends ReleasePackag
|
|
|
77
77
|
export declare function releaseBootstrapNpmPackages(root: string, options: ReleaseBootstrapNpmPackagesOptions): Promise<void>;
|
|
78
78
|
export declare function releaseRetagUnpublished(root: string, options: ReleaseRetagUnpublishedOptions): Promise<void>;
|
|
79
79
|
export declare function printReleaseState(root: string): Promise<void>;
|
|
80
|
+
/** npm trust list/setup requires an authenticated package owner. */
|
|
80
81
|
export declare function npmTrustListAccessDenied(stdout: string, stderr: string): boolean;
|
|
81
82
|
export declare function parseTrustedPublishers(stdout: string, packageName: string): TrustedPublisher[];
|
|
82
83
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/release/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/release/index.ts"],"names":[],"mappings":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AwB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAShF;AA8CD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAkB9F"}
|
package/dist/release/index.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
1
2
|
import { appendFile, mkdtemp, rm, writeFile } from 'node:fs/promises';
|
|
2
3
|
import { tmpdir } from 'node:os';
|
|
3
4
|
import { join, resolve } from 'node:path';
|
|
4
5
|
import { createInterface } from 'node:readline/promises';
|
|
5
6
|
import { Writable } from 'node:stream';
|
|
6
7
|
import { $ } from 'bun';
|
|
8
|
+
import typia from 'typia';
|
|
7
9
|
import { githubCiApplyOutputs, githubCiNxRunMany } from '../github-ci/index.js';
|
|
8
10
|
import { assertNoConflictMarkers } from '../lib/conflict-markers.js';
|
|
9
11
|
import { withDevenvEnv } from '../lib/devenv.js';
|
|
10
|
-
import {
|
|
12
|
+
import { parseNxJsonText, parseNxProjectJsonText, parsePackageJsonText, } from '../lib/json.js';
|
|
11
13
|
import { decode, run, runInteractiveStatus, runResult } from '../lib/run.js';
|
|
12
14
|
import { listReleasePackages, readPackageJson, repositoryInfo } from '../lib/workspace.js';
|
|
13
15
|
import { readPackedPackageJson, validatePackedWorkspaceDependencies } from '../monorepo/packed-manifest.js';
|
|
@@ -340,7 +342,7 @@ async function publishPlaceholderPackage(root, pkg, env) {
|
|
|
340
342
|
name: pkg.name,
|
|
341
343
|
version: NPM_BOOTSTRAP_VERSION,
|
|
342
344
|
description: `Bootstrap placeholder for ${pkg.name}. Real releases are published by SmoothBricks CI.`,
|
|
343
|
-
license:
|
|
345
|
+
license: pkg.json.license ?? 'UNLICENSED',
|
|
344
346
|
repository: pkg.json.repository,
|
|
345
347
|
publishConfig: { access: 'public' },
|
|
346
348
|
}, null, 2)}\n`);
|
|
@@ -356,7 +358,7 @@ function safeTarballPrefix(name) {
|
|
|
356
358
|
}
|
|
357
359
|
async function assertPackedWorkspaceDependencies(root, tarball, pkg) {
|
|
358
360
|
const manifest = await readPackedPackageJson(root, tarball, pkg.name);
|
|
359
|
-
const failures = validatePackedWorkspaceDependencies(root, pkg, manifest);
|
|
361
|
+
const failures = validatePackedWorkspaceDependencies(root, pkg, manifest, { mode: 'publish' });
|
|
360
362
|
if (failures.length > 0) {
|
|
361
363
|
throw new Error(failures.join('\n'));
|
|
362
364
|
}
|
|
@@ -499,8 +501,7 @@ async function packageVersionAtRef(root, packagePath, ref) {
|
|
|
499
501
|
return null;
|
|
500
502
|
}
|
|
501
503
|
try {
|
|
502
|
-
|
|
503
|
-
return isRecord(parsed) ? stringProperty(parsed, 'version') : null;
|
|
504
|
+
return parsePackageJsonText(decode(result.stdout))?.version ?? null;
|
|
504
505
|
}
|
|
505
506
|
catch {
|
|
506
507
|
return null;
|
|
@@ -927,8 +928,7 @@ async function packageJsonAtRef(root, ref, packagePath) {
|
|
|
927
928
|
return null;
|
|
928
929
|
}
|
|
929
930
|
try {
|
|
930
|
-
|
|
931
|
-
return isRecord(parsed) ? parsed : null;
|
|
931
|
+
return parsePackageJsonText(decode(result.stdout));
|
|
932
932
|
}
|
|
933
933
|
catch {
|
|
934
934
|
return null;
|
|
@@ -939,46 +939,59 @@ async function currentPackageJson(root, packagePath) {
|
|
|
939
939
|
}
|
|
940
940
|
async function packageBuildInputPatterns(root, projectName, _packagePath) {
|
|
941
941
|
const project = await nxProjectJson(root, projectName);
|
|
942
|
-
|
|
943
|
-
return resolveBuildInputPatterns(project, nxJson);
|
|
942
|
+
return resolveBuildInputPatterns(project, readNxJson(join(root, 'nx.json')));
|
|
944
943
|
}
|
|
945
944
|
async function nxProjectJson(root, projectName) {
|
|
946
945
|
const result = await $ `nx show project ${projectName} --json`.cwd(root).quiet();
|
|
947
|
-
const parsed =
|
|
948
|
-
if (!
|
|
946
|
+
const parsed = parseNxProjectJsonText(decode(result.stdout));
|
|
947
|
+
if (!parsed) {
|
|
949
948
|
throw new Error(`Unable to inspect Nx project ${projectName}.`);
|
|
950
949
|
}
|
|
951
950
|
return parsed;
|
|
952
951
|
}
|
|
952
|
+
function readNxJson(path) {
|
|
953
|
+
if (!existsSync(path)) {
|
|
954
|
+
return {};
|
|
955
|
+
}
|
|
956
|
+
try {
|
|
957
|
+
return parseNxJsonText(readFileSync(path, 'utf8')) ?? {};
|
|
958
|
+
}
|
|
959
|
+
catch {
|
|
960
|
+
return {};
|
|
961
|
+
}
|
|
962
|
+
}
|
|
953
963
|
function resolveBuildInputPatterns(project, nxJson) {
|
|
954
|
-
const targets =
|
|
964
|
+
const targets = project.targets;
|
|
955
965
|
if (!targets) {
|
|
956
966
|
return [];
|
|
957
967
|
}
|
|
958
968
|
return normalizeInputPatterns(collectBuildInputs(targets), nxJson);
|
|
959
969
|
}
|
|
960
970
|
function collectBuildInputs(targets) {
|
|
961
|
-
const build =
|
|
971
|
+
const build = targets.build;
|
|
962
972
|
if (!build) {
|
|
963
973
|
return ['production'];
|
|
964
974
|
}
|
|
965
|
-
const directInputs =
|
|
975
|
+
const directInputs = stringInputs(build.inputs);
|
|
966
976
|
if (directInputs.length > 0) {
|
|
967
977
|
return directInputs;
|
|
968
978
|
}
|
|
969
979
|
const inputs = [];
|
|
970
|
-
for (const dependency of
|
|
971
|
-
if (dependency.startsWith('^')) {
|
|
980
|
+
for (const dependency of build.dependsOn ?? []) {
|
|
981
|
+
if (typeof dependency !== 'string' || dependency.startsWith('^')) {
|
|
972
982
|
continue;
|
|
973
983
|
}
|
|
974
984
|
const targetName = dependency.includes(':') ? dependency.split(':')[1] : dependency;
|
|
975
985
|
if (!targetName) {
|
|
976
986
|
continue;
|
|
977
987
|
}
|
|
978
|
-
inputs.push(...
|
|
988
|
+
inputs.push(...stringInputs(targets[targetName]?.inputs));
|
|
979
989
|
}
|
|
980
990
|
return inputs.length > 0 ? inputs : ['production'];
|
|
981
991
|
}
|
|
992
|
+
function stringInputs(inputs) {
|
|
993
|
+
return Array.isArray(inputs) ? inputs.filter((entry) => typeof entry === 'string') : [];
|
|
994
|
+
}
|
|
982
995
|
function normalizeInputPatterns(inputs, nxJson) {
|
|
983
996
|
const patterns = [];
|
|
984
997
|
const seen = new Set();
|
|
@@ -995,8 +1008,7 @@ function expandInputPattern(input, nxJson, seen) {
|
|
|
995
1008
|
}
|
|
996
1009
|
seen.add(input);
|
|
997
1010
|
if (!input.includes('{')) {
|
|
998
|
-
const
|
|
999
|
-
const namedInput = namedInputs?.[input];
|
|
1011
|
+
const namedInput = nxJson.namedInputs?.[input];
|
|
1000
1012
|
if (Array.isArray(namedInput)) {
|
|
1001
1013
|
return namedInput.flatMap((entry) => (typeof entry === 'string' ? expandInputPattern(entry, nxJson, seen) : []));
|
|
1002
1014
|
}
|
|
@@ -1010,17 +1022,6 @@ function expandInputPattern(input, nxJson, seen) {
|
|
|
1010
1022
|
const packageRelative = rawInput.slice('{projectRoot}/'.length);
|
|
1011
1023
|
return [`${excluded ? '!' : ''}${packageRelative}`];
|
|
1012
1024
|
}
|
|
1013
|
-
function recordProperty(record, key) {
|
|
1014
|
-
if (!record) {
|
|
1015
|
-
return null;
|
|
1016
|
-
}
|
|
1017
|
-
const value = record[key];
|
|
1018
|
-
return isRecord(value) ? value : null;
|
|
1019
|
-
}
|
|
1020
|
-
function stringArrayProperty(record, key) {
|
|
1021
|
-
const value = record?.[key];
|
|
1022
|
-
return Array.isArray(value) ? value.filter((entry) => typeof entry === 'string') : [];
|
|
1023
|
-
}
|
|
1024
1025
|
async function packageHasHistory(root, packagePath) {
|
|
1025
1026
|
const result = await $ `git log --format=%H -- ${packagePath}`.cwd(root).quiet().nothrow();
|
|
1026
1027
|
if (result.exitCode !== 0) {
|
|
@@ -1219,7 +1220,7 @@ async function runLatestNpmTrust(root, npmArgs, env) {
|
|
|
1219
1220
|
if (status === 0) {
|
|
1220
1221
|
return 'configured';
|
|
1221
1222
|
}
|
|
1222
|
-
throw new Error(
|
|
1223
|
+
throw new Error(npmCommandFailedMessage(npmArgs, status));
|
|
1223
1224
|
}
|
|
1224
1225
|
async function listTrustedPublishers(root, pkg) {
|
|
1225
1226
|
const args = ['trust', 'list', pkg.name, '--json'];
|
|
@@ -1227,7 +1228,7 @@ async function listTrustedPublishers(root, pkg) {
|
|
|
1227
1228
|
if (result.exitCode !== 0 && /\bEOTP\b/.test(`${result.stdout}\n${result.stderr}`)) {
|
|
1228
1229
|
const status = await runInteractiveStatus('nix', ['shell', 'nixpkgs#nodejs_latest', '-c', 'npm', ...args], root);
|
|
1229
1230
|
if (status !== 0) {
|
|
1230
|
-
throw new Error(
|
|
1231
|
+
throw new Error(npmCommandFailedMessage(args, status));
|
|
1231
1232
|
}
|
|
1232
1233
|
result = await runResult('nix', ['shell', 'nixpkgs#nodejs_latest', '-c', 'npm', ...args], root);
|
|
1233
1234
|
}
|
|
@@ -1235,12 +1236,42 @@ async function listTrustedPublishers(root, pkg) {
|
|
|
1235
1236
|
return npmTrustAccessDetails(root, pkg.name);
|
|
1236
1237
|
}
|
|
1237
1238
|
if (result.exitCode !== 0) {
|
|
1238
|
-
throw new Error(
|
|
1239
|
+
throw new Error(npmCommandFailedMessage(args, result.exitCode, result.stdout, result.stderr));
|
|
1239
1240
|
}
|
|
1240
1241
|
return parseTrustedPublishers(result.stdout, pkg.name);
|
|
1241
1242
|
}
|
|
1243
|
+
/** npm trust list/setup requires an authenticated package owner. */
|
|
1242
1244
|
export function npmTrustListAccessDenied(stdout, stderr) {
|
|
1243
|
-
|
|
1245
|
+
const output = `${stdout}\n${stderr}`;
|
|
1246
|
+
// E403: authenticated but not an owner. E401 / login-required: no usable session.
|
|
1247
|
+
return (/\bE403\b/.test(output) ||
|
|
1248
|
+
/\bE401\b/.test(output) ||
|
|
1249
|
+
/You must be logged in to publish packages/i.test(output) ||
|
|
1250
|
+
/npm error 401 Unauthorized/i.test(output));
|
|
1251
|
+
}
|
|
1252
|
+
function npmCommandFailedMessage(npmArgs, exitCode, stdout = '', stderr = '') {
|
|
1253
|
+
const command = `nix shell nixpkgs#nodejs_latest -c npm ${npmArgs.join(' ')}`;
|
|
1254
|
+
const detail = npmFailureDetail(stdout, stderr);
|
|
1255
|
+
return detail.length > 0
|
|
1256
|
+
? `${command} failed with exit code ${exitCode}\n${detail}`
|
|
1257
|
+
: `${command} failed with exit code ${exitCode}`;
|
|
1258
|
+
}
|
|
1259
|
+
function npmFailureDetail(stdout, stderr) {
|
|
1260
|
+
const chunks = [stderr.trim(), stdout.trim()].filter((chunk) => chunk.length > 0);
|
|
1261
|
+
if (chunks.length === 0) {
|
|
1262
|
+
return '';
|
|
1263
|
+
}
|
|
1264
|
+
// Prefer the actionable npm error line over notice spam when present.
|
|
1265
|
+
const joined = chunks.join('\n');
|
|
1266
|
+
const errorLines = joined
|
|
1267
|
+
.split('\n')
|
|
1268
|
+
.map((line) => line.trimEnd())
|
|
1269
|
+
.filter((line) => /npm error|error code|401 Unauthorized|403 Forbidden|E401|E403|logged in/i.test(line));
|
|
1270
|
+
if (errorLines.length > 0) {
|
|
1271
|
+
return errorLines.slice(0, 8).join('\n');
|
|
1272
|
+
}
|
|
1273
|
+
// Fall back to a short tail of combined output.
|
|
1274
|
+
return joined.split('\n').slice(-12).join('\n');
|
|
1244
1275
|
}
|
|
1245
1276
|
async function npmTrustAccessDetails(root, packageName) {
|
|
1246
1277
|
const [identityResult, ownersResult] = await Promise.all([
|
|
@@ -1261,34 +1292,26 @@ export function parseTrustedPublishers(stdout, packageName) {
|
|
|
1261
1292
|
if (stdout.trim().length === 0) {
|
|
1262
1293
|
return [];
|
|
1263
1294
|
}
|
|
1264
|
-
|
|
1295
|
+
// createIsParse returns null for non-matching shapes and bare `null`.
|
|
1296
|
+
const parsed = parseTrustedPublisherJson(stdout);
|
|
1265
1297
|
if (parsed === null) {
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
}
|
|
1271
|
-
if (isRecord(parsed)) {
|
|
1272
|
-
return [parseTrustedPublisher(parsed, packageName)];
|
|
1273
|
-
}
|
|
1274
|
-
throw new Error(`${packageName}: npm trust list returned invalid JSON.`);
|
|
1275
|
-
}
|
|
1276
|
-
function parseTrustedPublisher(value, packageName) {
|
|
1277
|
-
if (!isRecord(value)) {
|
|
1278
|
-
throw new Error(`${packageName}: npm trust list returned invalid trusted publisher entry.`);
|
|
1279
|
-
}
|
|
1280
|
-
const id = stringProperty(value, 'id');
|
|
1281
|
-
const type = stringProperty(value, 'type');
|
|
1282
|
-
if (!id || !type) {
|
|
1283
|
-
throw new Error(`${packageName}: npm trust list returned a trusted publisher without id or type.`);
|
|
1298
|
+
if (stdout.trim() === 'null') {
|
|
1299
|
+
return [];
|
|
1300
|
+
}
|
|
1301
|
+
throw new Error(`${packageName}: npm trust list returned invalid trusted publisher JSON.`);
|
|
1284
1302
|
}
|
|
1285
|
-
return {
|
|
1286
|
-
id,
|
|
1287
|
-
type,
|
|
1288
|
-
file:
|
|
1289
|
-
repository:
|
|
1290
|
-
};
|
|
1303
|
+
return (Array.isArray(parsed) ? parsed : [parsed]).map((value) => ({
|
|
1304
|
+
id: value.id,
|
|
1305
|
+
type: value.type,
|
|
1306
|
+
file: value.file,
|
|
1307
|
+
repository: value.repository,
|
|
1308
|
+
}));
|
|
1291
1309
|
}
|
|
1310
|
+
const parseTrustedPublisherJson = (() => {
|
|
1311
|
+
const _io0 = input => "string" === typeof input.id && "string" === typeof input.type && (undefined === input.file || "string" === typeof input.file) && (undefined === input.repository || "string" === typeof input.repository);
|
|
1312
|
+
const __is = input => null !== input && undefined !== input && (Array.isArray(input) && input.every(elem => "object" === typeof elem && null !== elem && _io0(elem)) || "object" === typeof input && null !== input && _io0(input));
|
|
1313
|
+
return input => { input = JSON.parse(input); return __is(input) ? input : null; };
|
|
1314
|
+
})();
|
|
1292
1315
|
async function runLatestNpmPublish(root, npmArgs) {
|
|
1293
1316
|
await runLatestNpm(root, npmArgs, { NODE_AUTH_TOKEN: '', NPM_TOKEN: '' });
|
|
1294
1317
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export declare function isRecord(v: unknown): v is Record<string, unknown>;
|
|
2
1
|
/** First `[env.<name>]` (source order; also derived from a nested `[env.<name>.*]`), or null when no env declared. */
|
|
3
2
|
export declare function firstWranglerEnv(toml: string): string | null;
|
|
4
3
|
/** True if the toml declares `[env.<env>]` (or any `[env.<env>.*]` sub-table). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepare-env.d.ts","sourceRoot":"","sources":["../../src/wrangler/prepare-env.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prepare-env.d.ts","sourceRoot":"","sources":["../../src/wrangler/prepare-env.ts"],"names":[],"mappings":"AAgIA,sHAAsH;AACtH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAK5D;AAED,kFAAkF;AAClF,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAG9D;AAED,yFAAyF;AACzF,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAG7E;AAED,oIAAoI;AACpI,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAKrF;AAED,yFAAyF;AACzF,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAKjF;AAED,iIAAiI;AACjI,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE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