@astryxdesign/cli 0.7.5-canary.04434e7 → 0.7.5-canary.06ff669
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/CHANGELOG.md +3 -3
- package/README.md +1 -1
- package/api/hook/detail/detail.test.mjs +11 -0
- package/api/swizzle/copy/copy.mjs +1 -1
- package/api/template/tokenizer-showcase.test.mjs +47 -0
- package/api/theme/build/build.adaptation-enrollment.test.mjs +4 -0
- package/api/theme/build/build.icon-entry-variants.test.mjs +134 -0
- package/api/theme/build/build.icon-function-entries.test.mjs +499 -0
- package/api/theme/build/build.icon-variants.test.mjs +105 -0
- package/api/theme/build/build.mjs +371 -113
- package/api/theme/build/build.project-core.test.mjs +63 -8
- package/api/theme/build/build.test.mjs +77 -0
- package/api/theme/build/icon-imports.d.mts +12 -2
- package/api/theme/build/icon-imports.mjs +36 -11
- package/api/upgrade/_adapter.d.mts +47 -2
- package/api/upgrade/_adapter.mjs +58 -2
- package/api/upgrade/run/failure-receipt.test.mjs +57 -0
- package/api/upgrade/run/outcomes.test.mjs +646 -0
- package/api/upgrade/run/run.d.mts +36 -0
- package/api/upgrade/run/run.mjs +509 -45
- package/api/upgrade/upgrade.doc.mjs +2 -2
- package/api/upgrade/upgrade.type.d.mts +24 -0
- package/api/upgrade/upgrade.type.mjs +15 -3
- package/assets/codemods/__tests__/runner.unparseable.test.mjs +457 -0
- package/assets/codemods/integration-runner.mjs +7 -1
- package/assets/codemods/integration-runner.protection.test.mjs +53 -0
- package/assets/codemods/outcome.mjs +79 -0
- package/assets/codemods/outcome.test.mjs +40 -0
- package/assets/codemods/parse.mjs +94 -0
- package/assets/codemods/run-codemod.mjs +92 -2
- package/assets/codemods/runner.mjs +38 -5
- package/assets/codemods/transforms/next/__tests__/migrate-codeblock-tokenizer-to-language.test.mjs +130 -0
- package/assets/codemods/transforms/next/index.mjs +11 -1
- package/assets/codemods/transforms/next/migrate-codeblock-tokenizer-to-language.mjs +315 -0
- package/assets/codemods/transforms/v0.1.2/rename-text-color-active-to-accent.mjs +1 -1
- package/assets/codemods/transforms/v0.1.3/__tests__/migrate-layout-components-to-experimental.test.mjs +216 -2
- package/assets/codemods/transforms/v0.1.3/migrate-layout-components-to-experimental.mjs +88 -6
- package/assets/codemods/transforms/v0.1.5/rename-switch-label-spacing-default-to-hug.mjs +1 -1
- package/assets/codemods/transforms/v0.1.7/migrate-table-tableprops-to-direct-props.mjs +1 -1
- package/assets/codemods/transforms/v0.1.8/rename-avatar-size-scale.mjs +1 -1
- package/assets/codemods/transforms/v0.2.0/remove-tablist-orientation.mjs +1 -1
- package/assets/codemods/transforms/v0.2.1/migrate-dialog-position-to-logical.mjs +1 -1
- package/assets/codemods/transforms/v0.6.0/migrate-astryx-theme-selectors-to-data-attrs.mjs +4 -3
- package/assets/codemods/transforms/v0.7.0/__tests__/validate-data-token-ownership.test.mjs +24 -4
- package/assets/codemods/transforms/v0.7.0/migrate-deprecated-theme-surface.mjs +44 -10
- package/assets/codemods/transforms/v0.7.0/validate-data-token-ownership.mjs +6 -3
- package/assets/docs/README.md +13 -13
- package/assets/docs/author-a-theme.doc.mjs +5 -1
- package/assets/docs/getting-started.doc.mjs +5 -5
- package/assets/docs/icons.doc.mjs +82 -1
- package/assets/docs/motion.doc.mjs +1 -1
- package/assets/docs/theme.doc.dense.mjs +8 -0
- package/assets/docs/theme.doc.mjs +16 -0
- package/assets/docs/theme.doc.zh.mjs +11 -0
- package/assets/docs/tree/i18n-library-integration.doc.mjs +1 -1
- package/assets/docs/tree/template-styles.doc.mjs +1 -1
- package/assets/docs/tree/tokens-color.doc.mjs +145 -1
- package/assets/docs/tree/tokens-ease.doc.mjs +4 -0
- package/assets/docs/tree/tokens.doc.mjs +1 -1
- package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherReviewFlow.doc.mjs +6 -4
- package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherReviewFlow.tsx +61 -55
- package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherShowcase.doc.mjs +6 -4
- package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherShowcase.tsx +68 -37
- package/assets/templates/blocks/components/CodeBlock/CodeBlockBashCommand.doc.mjs +1 -1
- package/assets/templates/blocks/components/CodeBlock/CodeBlockBashCommand.tsx +10 -2
- package/assets/templates/blocks/components/Thumbnail/ThumbnailDisabled.doc.mjs +1 -1
- package/assets/templates/blocks/components/Tokenizer/TokenizerShowcase.tsx +13 -6
- package/assets/templates/pages/dashboard-alert-rail/page.tsx +3 -3
- package/assets/templates/pages/library/page.tsx +1 -2
- package/assets/templates/pages/table-comparison/page.tsx +12 -3
- package/assets/templates/themes/butter/butterPaletteRefs.generated.ts +3 -2
- package/assets/templates/themes/butter/butterTheme.ts +47 -44
- package/assets/templates/themes/chocolate/chocolateTheme.ts +15 -2
- package/assets/templates/themes/gothic/gothicTheme.ts +21 -16
- package/assets/templates/themes/matcha/matchaPaletteRefs.generated.ts +1 -1
- package/assets/templates/themes/matcha/matchaTheme.ts +15 -2
- package/assets/templates/themes/neutral/neutralPaletteRefs.generated.ts +4 -4
- package/assets/templates/themes/neutral/neutralTheme.ts +24 -119
- package/assets/templates/themes/stone/stoneTheme.ts +46 -21
- package/assets/templates/themes/y2k/y2kTheme.ts +20 -16
- package/assets/theme.template.ts +19 -6
- package/authoring/codemod/type.ts +10 -0
- package/authoring/config/config.doc.mjs +1 -1
- package/clients/cli/commands/build-theme.adaptations.test.mjs +110 -0
- package/clients/cli/commands/build-theme.outside-project.test.mjs +140 -0
- package/clients/cli/commands/swizzle.routing.test.mjs +1 -1
- package/clients/cli/commands/upgrade.doc.mjs +30 -2
- package/clients/cli/commands/upgrade.file-protection.test.mjs +146 -0
- package/clients/cli/commands/upgrade.outcomes.test.mjs +350 -0
- package/foundation/agent-docs/agent-docs.mjs +1 -0
- package/foundation/agent-docs/agent-docs.test.mjs +5 -0
- package/foundation/config/project.d.mts +1 -1
- package/foundation/config/project.mjs +1 -1
- package/foundation/debug/redact.test.mjs +1 -1
- package/foundation/doc-compiler/doc-loads.test.mjs +2 -6
- package/foundation/env/package-manager.test.mjs +14 -1
- package/foundation/response/response-types.doc.mjs +1 -1
- package/package.json +13 -12
package/api/upgrade/run/run.mjs
CHANGED
|
@@ -39,6 +39,7 @@ import {
|
|
|
39
39
|
warnIntegrationIssues,
|
|
40
40
|
selectIntegrationCodemodsFor,
|
|
41
41
|
runIntegrationCodemodsStep,
|
|
42
|
+
withCodemodOutcomes,
|
|
42
43
|
} from '../_adapter.mjs';
|
|
43
44
|
import {
|
|
44
45
|
logRegistryCompositionSummary,
|
|
@@ -61,6 +62,7 @@ import {
|
|
|
61
62
|
PathSafetyError,
|
|
62
63
|
} from '../../../foundation/fs/path-safety.mjs';
|
|
63
64
|
import {createFileProtectionResolver} from '../../../foundation/fs/file-protection.mjs';
|
|
65
|
+
import {withoutProtected} from '../../../assets/codemods/runner.mjs';
|
|
64
66
|
|
|
65
67
|
/**
|
|
66
68
|
* Collapse per-codemod protection hits into one stable row per file.
|
|
@@ -93,6 +95,235 @@ function summarizeProtectedFiles(rows) {
|
|
|
93
95
|
.sort((a, b) => a.file.localeCompare(b.file));
|
|
94
96
|
}
|
|
95
97
|
|
|
98
|
+
/** Every declined finding for a manual migration starts with this. */
|
|
99
|
+
const MANUAL_MIGRATION_REASON = 'manual migration needed';
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Where one declined finding ends and the next begins inside a folded
|
|
103
|
+
* `reason`: `; ` before a finding's own prefix.
|
|
104
|
+
*/
|
|
105
|
+
const NEXT_FINDING =
|
|
106
|
+
/; (?=(?:unparseable protected file|manual migration needed) \()/;
|
|
107
|
+
|
|
108
|
+
/** The suffix of a folded finding that has no location of its own. */
|
|
109
|
+
const LOCATION_UNKNOWN = '(location unknown)';
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Collapse per-codemod declined candidates into one row per file, in the
|
|
113
|
+
* receipt's `{file, location?, reason}` shape. A file the receipt lists under
|
|
114
|
+
* `protectedFiles` is left out: a codemod still requires a change to it, and
|
|
115
|
+
* that already makes the run incomplete.
|
|
116
|
+
*
|
|
117
|
+
* Every distinct finding for a file is kept, whatever its kind: a single
|
|
118
|
+
* finding is the row as it arrived; several are folded into the one row,
|
|
119
|
+
* each keeping its own prefix (`unparseable protected file (<category>): ...`
|
|
120
|
+
* or `manual migration needed (<codemod>): ...`), joined by `; ` in arrival
|
|
121
|
+
* order. `location` is the first finding's own location (absent when it has
|
|
122
|
+
* none). A later finding whose own location differs from the row's says so at
|
|
123
|
+
* its end: ` (at <location>)` when known, ` (location unknown)` when not; a
|
|
124
|
+
* later finding without a suffix is at the row's location. So no finding is
|
|
125
|
+
* ever read at another finding's location.
|
|
126
|
+
*
|
|
127
|
+
* Rows are grouped by their `/`-separated path, which is also the spelling
|
|
128
|
+
* the row carries: a runner's row keeps the platform separator (backslashes on
|
|
129
|
+
* Windows), while a manual row already uses `/`.
|
|
130
|
+
* @param {Array<{file: string, codemod: string, location?: string, reason: string}>} rows
|
|
131
|
+
* @param {Array<{file: string}>} [protectedRows]
|
|
132
|
+
* @param {string} [sep] The platform path separator (a parameter for tests).
|
|
133
|
+
* @returns {Array<{file: string, location?: string, reason: string}>}
|
|
134
|
+
*/
|
|
135
|
+
export function summarizeDeclinedCandidates(
|
|
136
|
+
rows,
|
|
137
|
+
protectedRows = [],
|
|
138
|
+
sep = path.sep,
|
|
139
|
+
) {
|
|
140
|
+
/** @type {Map<string, Array<{location?: string, reason: string}>>} */
|
|
141
|
+
const byFile = new Map();
|
|
142
|
+
for (const {file: raw, location, reason} of withoutProtected(
|
|
143
|
+
rows,
|
|
144
|
+
protectedRows,
|
|
145
|
+
)) {
|
|
146
|
+
const file = raw.split(sep).join('/');
|
|
147
|
+
const findings = byFile.get(file) ?? [];
|
|
148
|
+
if (!findings.some(f => f.reason === reason && f.location === location)) {
|
|
149
|
+
findings.push({...(location ? {location} : {}), reason});
|
|
150
|
+
}
|
|
151
|
+
byFile.set(file, findings);
|
|
152
|
+
}
|
|
153
|
+
return [...byFile.entries()]
|
|
154
|
+
.map(([file, findings]) => {
|
|
155
|
+
const location = findings[0].location;
|
|
156
|
+
return {
|
|
157
|
+
file,
|
|
158
|
+
...(location ? {location} : {}),
|
|
159
|
+
reason: findings
|
|
160
|
+
.map((f, index) =>
|
|
161
|
+
index === 0 || f.location === location
|
|
162
|
+
? f.reason
|
|
163
|
+
: f.location
|
|
164
|
+
? `${f.reason} (at ${f.location})`
|
|
165
|
+
: `${f.reason} ${LOCATION_UNKNOWN}`,
|
|
166
|
+
)
|
|
167
|
+
.join('; '),
|
|
168
|
+
};
|
|
169
|
+
})
|
|
170
|
+
.sort((a, b) => a.file.localeCompare(b.file));
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* The findings a folded declined row carries, each with its own location.
|
|
175
|
+
* @param {{location?: string, reason: string}} row
|
|
176
|
+
* @returns {Array<{location?: string, text: string}>}
|
|
177
|
+
*/
|
|
178
|
+
function declinedFindings(row) {
|
|
179
|
+
return row.reason.split(NEXT_FINDING).map((text, index) => {
|
|
180
|
+
if (index === 0) {
|
|
181
|
+
return {...(row.location ? {location: row.location} : {}), text};
|
|
182
|
+
}
|
|
183
|
+
if (text.endsWith(` ${LOCATION_UNKNOWN}`)) {
|
|
184
|
+
return {text: text.slice(0, -LOCATION_UNKNOWN.length - 1)};
|
|
185
|
+
}
|
|
186
|
+
const at = / \(at ([^)]+)\)$/.exec(text);
|
|
187
|
+
return at
|
|
188
|
+
? {location: at[1], text: text.slice(0, at.index)}
|
|
189
|
+
: {...(row.location ? {location: row.location} : {}), text};
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Declined candidates for code a codemod identified but cannot migrate safely
|
|
195
|
+
* (`ManualMigrationRequired`): one row per finding, in the per-codemod row
|
|
196
|
+
* shape the runners use, for `summarizeDeclinedCandidates` to fold with the
|
|
197
|
+
* file's other declined findings. A person makes the change; like every
|
|
198
|
+
* declined candidate, it never fails the run or makes it incomplete
|
|
199
|
+
* (spec:AST-040 FR7).
|
|
200
|
+
* @param {import('../_adapter.mjs').CodemodOutcomeRecord[]} outcomes
|
|
201
|
+
* @returns {Array<{file: string, codemod: string, location?: string, reason: string}>}
|
|
202
|
+
*/
|
|
203
|
+
function manualDeclinedRows(outcomes) {
|
|
204
|
+
/** @type {Array<{file: string, codemod: string, location?: string, reason: string}>} */
|
|
205
|
+
const rows = [];
|
|
206
|
+
for (const outcome of outcomes) {
|
|
207
|
+
if (outcome.kind !== 'manual') continue;
|
|
208
|
+
rows.push({
|
|
209
|
+
file: outcome.file,
|
|
210
|
+
codemod: outcome.codemod,
|
|
211
|
+
...(typeof outcome.line === 'number'
|
|
212
|
+
? {location: String(outcome.line)}
|
|
213
|
+
: {}),
|
|
214
|
+
reason: `${MANUAL_MIGRATION_REASON} (${outcome.codemod}): ${outcome.message}`,
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
return rows;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* How many manual migrations the declined rows carry: every finding, not every
|
|
222
|
+
* file (a folded row lists several).
|
|
223
|
+
* @param {Array<{location?: string, reason: string}>} declined
|
|
224
|
+
*/
|
|
225
|
+
function countManualMigrations(declined) {
|
|
226
|
+
return declined
|
|
227
|
+
.flatMap(declinedFindings)
|
|
228
|
+
.filter(f => f.text.startsWith(MANUAL_MIGRATION_REASON)).length;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Print the final declined list (files it reports as protected are already
|
|
233
|
+
* left out), so the text output carries what the receipt lists: protected
|
|
234
|
+
* files the run skipped because a codemod could not parse them, and code a
|
|
235
|
+
* codemod could not migrate. Each finding of a folded row is printed under
|
|
236
|
+
* its own kind.
|
|
237
|
+
* @param {Array<{file: string, location?: string, reason: string}>} declined
|
|
238
|
+
*/
|
|
239
|
+
function logDeclined(declined) {
|
|
240
|
+
/** @type {Array<{file: string, location?: string, text: string}>} */
|
|
241
|
+
const manual = [];
|
|
242
|
+
/** @type {Array<{file: string, location?: string, text: string}>} */
|
|
243
|
+
const unparseable = [];
|
|
244
|
+
for (const row of declined) {
|
|
245
|
+
for (const finding of declinedFindings(row)) {
|
|
246
|
+
(finding.text.startsWith(MANUAL_MIGRATION_REASON)
|
|
247
|
+
? manual
|
|
248
|
+
: unparseable
|
|
249
|
+
).push({file: row.file, ...finding});
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
/** @param {Array<{file: string, location?: string, text: string}>} rows */
|
|
253
|
+
const lines = rows => {
|
|
254
|
+
for (const {file, location, text} of rows) {
|
|
255
|
+
logger.warn(` ${file}${location ? `:${location}` : ''} - ${text}`);
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
/** @param {Array<{file: string}>} rows */
|
|
259
|
+
const files = rows => new Set(rows.map(row => row.file)).size;
|
|
260
|
+
if (unparseable.length > 0) {
|
|
261
|
+
const n = files(unparseable);
|
|
262
|
+
logger.warn(
|
|
263
|
+
`${n} protected file${n === 1 ? ' was' : 's were'} skipped because ${n === 1 ? 'it does' : 'they do'} not parse; review manually:`,
|
|
264
|
+
);
|
|
265
|
+
lines(unparseable);
|
|
266
|
+
}
|
|
267
|
+
if (manual.length > 0) {
|
|
268
|
+
const n = files(manual);
|
|
269
|
+
logger.warn(
|
|
270
|
+
`${n} file${n === 1 ? ' needs' : 's need'} a manual migration that upgrade cannot make; review manually:`,
|
|
271
|
+
);
|
|
272
|
+
lines(manual);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Print protected files that still require a codemod change, each with the
|
|
278
|
+
* declarations that protect it and the commands that rebuild it.
|
|
279
|
+
* @param {string} header
|
|
280
|
+
* @param {import('../upgrade.type.mjs').ProtectedCodemodFile[]} protectedFiles
|
|
281
|
+
*/
|
|
282
|
+
function logProtectedFiles(header, protectedFiles) {
|
|
283
|
+
if (protectedFiles.length === 0) return;
|
|
284
|
+
logger.error(header);
|
|
285
|
+
for (const item of protectedFiles) {
|
|
286
|
+
logger.error(` ${item.file} — ${item.declarations.join('; ')}`);
|
|
287
|
+
for (const command of item.commands) {
|
|
288
|
+
logger.log(` Regenerate with: ${command}`);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Print the generated files to rebuild, each with why and the commands that
|
|
295
|
+
* rebuild it, so the text output carries what `regenerate` lists. Files
|
|
296
|
+
* already printed with their commands (protected files) are skipped.
|
|
297
|
+
* @param {import('../upgrade.type.mjs').RegenerateFile[]} regenerate
|
|
298
|
+
* @param {Array<{file: string}>} [printed]
|
|
299
|
+
*/
|
|
300
|
+
function logRegenerate(regenerate, printed = []) {
|
|
301
|
+
const skip = new Set(printed.map(item => item.file));
|
|
302
|
+
const rows = regenerate.filter(item => !skip.has(item.file));
|
|
303
|
+
if (rows.length === 0) return;
|
|
304
|
+
logger.error(
|
|
305
|
+
`${rows.length} generated file${rows.length === 1 ? '' : 's'} must be regenerated:`,
|
|
306
|
+
);
|
|
307
|
+
for (const item of rows) {
|
|
308
|
+
logger.error(
|
|
309
|
+
` ${item.file}${item.messages.length > 0 ? ` — ${item.messages.join(' ')}` : ''}`,
|
|
310
|
+
);
|
|
311
|
+
for (const command of item.commands) {
|
|
312
|
+
logger.log(` Regenerate with: ${command}`);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* @template {Array<{file: string, location?: string, reason: string}>} T
|
|
319
|
+
* @param {T} declined
|
|
320
|
+
* @returns {T}
|
|
321
|
+
*/
|
|
322
|
+
function logged(declined) {
|
|
323
|
+
logDeclined(declined);
|
|
324
|
+
return declined;
|
|
325
|
+
}
|
|
326
|
+
|
|
96
327
|
/** @param {string} cwd */
|
|
97
328
|
function loadFileProtection(cwd) {
|
|
98
329
|
try {
|
|
@@ -109,6 +340,118 @@ function loadFileProtection(cwd) {
|
|
|
109
340
|
}
|
|
110
341
|
}
|
|
111
342
|
|
|
343
|
+
/**
|
|
344
|
+
* Generated files that must be rebuilt before the upgrade is complete, one row
|
|
345
|
+
* per file: protected generated files a codemod still needs to change, and
|
|
346
|
+
* generated outputs a codemod reported out of date. `commands` are the exact
|
|
347
|
+
* rebuild commands known for the file (its header's `Command:` line, or the
|
|
348
|
+
* command the codemod names).
|
|
349
|
+
* @param {Array<{file: string, codemods: string[], reasons: string[], commands: string[]}>} protectedFiles
|
|
350
|
+
* @param {import('../_adapter.mjs').CodemodOutcomeRecord[]} outcomes
|
|
351
|
+
* @returns {import('../upgrade.type.mjs').RegenerateFile[]}
|
|
352
|
+
*/
|
|
353
|
+
function summarizeRegenerate(protectedFiles, outcomes) {
|
|
354
|
+
/** @type {Map<string, {codemods: Set<string>, commands: Set<string>, messages: Set<string>}>} */
|
|
355
|
+
const byFile = new Map();
|
|
356
|
+
/** @param {string} file */
|
|
357
|
+
const row = file => {
|
|
358
|
+
const current = byFile.get(file) ?? {
|
|
359
|
+
codemods: new Set(),
|
|
360
|
+
commands: new Set(),
|
|
361
|
+
messages: new Set(),
|
|
362
|
+
};
|
|
363
|
+
byFile.set(file, current);
|
|
364
|
+
return current;
|
|
365
|
+
};
|
|
366
|
+
for (const item of protectedFiles) {
|
|
367
|
+
if (!item.reasons.includes('generated')) continue;
|
|
368
|
+
const current = row(item.file);
|
|
369
|
+
for (const codemod of item.codemods) current.codemods.add(codemod);
|
|
370
|
+
for (const command of item.commands) current.commands.add(command);
|
|
371
|
+
}
|
|
372
|
+
for (const outcome of outcomes) {
|
|
373
|
+
if (outcome.kind !== 'regenerate') continue;
|
|
374
|
+
const current = row(outcome.file);
|
|
375
|
+
current.codemods.add(outcome.codemod);
|
|
376
|
+
for (const command of outcome.commands) current.commands.add(command);
|
|
377
|
+
current.messages.add(outcome.message);
|
|
378
|
+
}
|
|
379
|
+
return [...byFile.entries()]
|
|
380
|
+
.map(([file, item]) => ({
|
|
381
|
+
file,
|
|
382
|
+
codemods: [...item.codemods].sort(),
|
|
383
|
+
commands: [...item.commands].sort(),
|
|
384
|
+
messages: [...item.messages].sort(),
|
|
385
|
+
}))
|
|
386
|
+
.sort((a, b) => a.file.localeCompare(b.file));
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Protection rows for generated outputs a codemod reported out of date, from
|
|
391
|
+
* the run's protection resolver, in the shape the runners report blocked
|
|
392
|
+
* protected candidates. A reported file the project protects (an `@generated`
|
|
393
|
+
* header, `linguist-generated`, ...) is a protected file that still requires a
|
|
394
|
+
* change, so it is listed in `protectedFiles` with the declaration that
|
|
395
|
+
* protects it (spec:AST-040 FR6), and the command the codemod names is one of
|
|
396
|
+
* its `commands`. A reported file nothing protects gets no row here: it is a
|
|
397
|
+
* codemod error (`regenerationErrors`) and stays in `regenerate`.
|
|
398
|
+
* @param {import('../_adapter.mjs').CodemodOutcomeRecord[]} outcomes
|
|
399
|
+
* @param {{classify: (file: string) => import('../../../foundation/fs/file-protection.mjs').FileProtection[]}} protection
|
|
400
|
+
* @param {string} cwd
|
|
401
|
+
* @returns {Array<{file: string, codemod: string, reason: string, declaration: string, generated: boolean, command?: string}>}
|
|
402
|
+
*/
|
|
403
|
+
function regenerationProtectionRows(outcomes, protection, cwd) {
|
|
404
|
+
/** @type {Array<{file: string, codemod: string, reason: string, declaration: string, generated: boolean, command?: string}>} */
|
|
405
|
+
const rows = [];
|
|
406
|
+
for (const outcome of outcomes) {
|
|
407
|
+
if (outcome.kind !== 'regenerate') continue;
|
|
408
|
+
for (const item of protection.classify(path.resolve(cwd, outcome.file))) {
|
|
409
|
+
const base = {
|
|
410
|
+
file: item.file,
|
|
411
|
+
codemod: outcome.codemod,
|
|
412
|
+
reason: item.reason,
|
|
413
|
+
declaration: item.declaration,
|
|
414
|
+
generated: item.reason === 'generated',
|
|
415
|
+
};
|
|
416
|
+
const commands = [
|
|
417
|
+
...(item.command ? [item.command] : []),
|
|
418
|
+
...outcome.commands,
|
|
419
|
+
];
|
|
420
|
+
if (commands.length === 0) rows.push(base);
|
|
421
|
+
for (const command of commands) rows.push({...base, command});
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
return rows;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Error rows for generated outputs a codemod reported out of date that nothing
|
|
429
|
+
* protects. No protected consumer file blocks such a change, so it is not an
|
|
430
|
+
* ERR_CODEMOD_PROTECTED outcome: the codemod required a change it could not
|
|
431
|
+
* make, which is a codemod failure (ERR_CODEMOD_FAILED), as it was before the
|
|
432
|
+
* outcome was typed. The file stays in `regenerate` with its command.
|
|
433
|
+
* @param {import('../_adapter.mjs').CodemodOutcomeRecord[]} outcomes
|
|
434
|
+
* @param {{classify: (file: string) => import('../../../foundation/fs/file-protection.mjs').FileProtection[]}} protection
|
|
435
|
+
* @param {string} cwd
|
|
436
|
+
* @returns {Array<{file: string, codemod: string, error: string}>}
|
|
437
|
+
*/
|
|
438
|
+
function regenerationErrors(outcomes, protection, cwd) {
|
|
439
|
+
/** @type {Array<{file: string, codemod: string, error: string}>} */
|
|
440
|
+
const rows = [];
|
|
441
|
+
for (const outcome of outcomes) {
|
|
442
|
+
if (outcome.kind !== 'regenerate') continue;
|
|
443
|
+
if (protection.classify(path.resolve(cwd, outcome.file)).length > 0) {
|
|
444
|
+
continue;
|
|
445
|
+
}
|
|
446
|
+
rows.push({
|
|
447
|
+
file: outcome.file,
|
|
448
|
+
codemod: outcome.codemod,
|
|
449
|
+
error: outcome.message,
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
return rows;
|
|
453
|
+
}
|
|
454
|
+
|
|
112
455
|
/**
|
|
113
456
|
* The receipt of a run that stopped after codemods ran. Whatever the codemods
|
|
114
457
|
* already wrote stays on disk, so the error the run throws carries this
|
|
@@ -116,7 +459,7 @@ function loadFileProtection(cwd) {
|
|
|
116
459
|
* report nothing changed while the files it lists remain modified
|
|
117
460
|
* (spec:AST-040 FR7).
|
|
118
461
|
*
|
|
119
|
-
* @param {{from: string, to: string, codemods: number, integrations: string[], sourcePathFound: boolean, cwd: string, changedFiles: string[], transformsApplied: number, protectedRows: Array<{file: string, codemod: string, reason: string, declaration: string, generated: boolean, command?: string}>, errors: Array<{file: string, codemod: string, error: string}>, errorCode: string, cliBehindCore?: import('../upgrade.type.mjs').CliBehindCore | null, registryCompositions?: import('../upgrade.type.mjs').RegistryCompositionSummary}} facts
|
|
462
|
+
* @param {{from: string, to: string, codemods: number, integrations: string[], sourcePathFound: boolean, cwd: string, changedFiles: string[], transformsApplied: number, protectedRows: Array<{file: string, codemod: string, reason: string, declaration: string, generated: boolean, command?: string}>, outcomes?: import('../_adapter.mjs').CodemodOutcomeRecord[], errors: Array<{file: string, codemod: string, error: string}>, declinedRows?: Array<{file: string, codemod: string, location?: string, reason: string}>, errorCode: string, cliBehindCore?: import('../upgrade.type.mjs').CliBehindCore | null, registryCompositions?: import('../upgrade.type.mjs').RegistryCompositionSummary}} facts
|
|
120
463
|
* @returns {import('../upgrade.type.mjs').UpgradeRunResponse['data']}
|
|
121
464
|
*/
|
|
122
465
|
function stoppedReceipt({
|
|
@@ -129,14 +472,20 @@ function stoppedReceipt({
|
|
|
129
472
|
changedFiles,
|
|
130
473
|
transformsApplied,
|
|
131
474
|
protectedRows,
|
|
475
|
+
outcomes = [],
|
|
132
476
|
errors,
|
|
477
|
+
declinedRows = [],
|
|
133
478
|
errorCode,
|
|
134
479
|
cliBehindCore,
|
|
135
480
|
registryCompositions,
|
|
136
481
|
}) {
|
|
482
|
+
const protectedFiles = summarizeProtectedFiles(protectedRows);
|
|
137
483
|
const modifiedFiles = uniqueFiles(changedFiles).map(file =>
|
|
138
484
|
path.relative(cwd, file).split(path.sep).join('/'),
|
|
139
485
|
);
|
|
486
|
+
const regenerate = summarizeRegenerate(protectedFiles, outcomes);
|
|
487
|
+
// The run stopped early; the text still names every file to rebuild.
|
|
488
|
+
logRegenerate(regenerate);
|
|
140
489
|
return /** @type {import('../upgrade.type.mjs').UpgradeRunResponse['data']} */ ({
|
|
141
490
|
from,
|
|
142
491
|
to,
|
|
@@ -155,8 +504,14 @@ function stoppedReceipt({
|
|
|
155
504
|
filesChanged: modifiedFiles.length,
|
|
156
505
|
transformsApplied,
|
|
157
506
|
modifiedFiles,
|
|
158
|
-
protectedFiles
|
|
159
|
-
declinedCandidates:
|
|
507
|
+
protectedFiles,
|
|
508
|
+
declinedCandidates: logged(
|
|
509
|
+
summarizeDeclinedCandidates(
|
|
510
|
+
[...declinedRows, ...manualDeclinedRows(outcomes)],
|
|
511
|
+
protectedRows,
|
|
512
|
+
),
|
|
513
|
+
),
|
|
514
|
+
regenerate,
|
|
160
515
|
complete: false,
|
|
161
516
|
errorCode,
|
|
162
517
|
errors,
|
|
@@ -340,16 +695,22 @@ export async function run(options = {}, {cwd = process.cwd(), origin} = {}) {
|
|
|
340
695
|
}
|
|
341
696
|
|
|
342
697
|
// CORE codemods run FIRST (before loading config) so a core CONFIG codemod can
|
|
343
|
-
// repair a config the strict loader would otherwise reject.
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
698
|
+
// repair a config the strict loader would otherwise reject. Manual-migration
|
|
699
|
+
// and regeneration outcomes they report are collected, not counted as errors.
|
|
700
|
+
const initialOutcomes = withCodemodOutcomes(versionManifests, cwd);
|
|
701
|
+
const codemodResult = await runCoreCodemods(
|
|
702
|
+
initialOutcomes.versionManifests,
|
|
703
|
+
{
|
|
704
|
+
apply,
|
|
705
|
+
path: path_,
|
|
706
|
+
codemod: options.codemod,
|
|
707
|
+
skipCodemods,
|
|
708
|
+
root: cwd,
|
|
709
|
+
protection,
|
|
710
|
+
coversTarget: !cliBehindCore,
|
|
711
|
+
outcomes: initialOutcomes.outcomes,
|
|
712
|
+
},
|
|
713
|
+
);
|
|
353
714
|
const coreResult =
|
|
354
715
|
codemodResult && 'totalFilesChanged' in codemodResult
|
|
355
716
|
? codemodResult
|
|
@@ -371,15 +732,30 @@ export async function run(options = {}, {cwd = process.cwd(), origin} = {}) {
|
|
|
371
732
|
iconSets = projectContext.iconSets;
|
|
372
733
|
} catch (err) {
|
|
373
734
|
const configErr = /** @type {Error} */ (err);
|
|
374
|
-
const allProtected =
|
|
735
|
+
const allProtected = [
|
|
736
|
+
...(coreResult?.protectedFiles ?? []),
|
|
737
|
+
...regenerationProtectionRows(initialOutcomes.outcomes, protection, cwd),
|
|
738
|
+
];
|
|
739
|
+
const staleErrors = regenerationErrors(
|
|
740
|
+
initialOutcomes.outcomes,
|
|
741
|
+
protection,
|
|
742
|
+
cwd,
|
|
743
|
+
);
|
|
744
|
+
// A protected file to regenerate blocks the run like any protected file,
|
|
745
|
+
// so it keeps this incomplete result rather than the config error.
|
|
375
746
|
if (allProtected.length > 0) {
|
|
376
747
|
const protectedFiles = summarizeProtectedFiles(allProtected);
|
|
377
|
-
|
|
748
|
+
const regenerate = summarizeRegenerate(
|
|
749
|
+
protectedFiles,
|
|
750
|
+
initialOutcomes.outcomes,
|
|
751
|
+
);
|
|
752
|
+
// The protected result wins, but the config error stays visible.
|
|
753
|
+
logger.error(configErr.message);
|
|
754
|
+
logProtectedFiles(
|
|
378
755
|
`${ERROR_CODES.ERR_CODEMOD_PROTECTED}: protected codemod changes remain while loading the Astryx config.`,
|
|
756
|
+
protectedFiles,
|
|
379
757
|
);
|
|
380
|
-
|
|
381
|
-
logger.error(` ${item.file} — ${item.declarations.join('; ')}`);
|
|
382
|
-
}
|
|
758
|
+
logRegenerate(regenerate, protectedFiles);
|
|
383
759
|
if (cliBehindCore) logCliBehindCore(cliBehindCore, targetVersion);
|
|
384
760
|
logger.log('Upgrade incomplete: protected changes remain\n');
|
|
385
761
|
return {
|
|
@@ -405,10 +781,23 @@ export async function run(options = {}, {cwd = process.cwd(), origin} = {}) {
|
|
|
405
781
|
path.relative(cwd, file).split(path.sep).join('/'),
|
|
406
782
|
),
|
|
407
783
|
protectedFiles,
|
|
408
|
-
declinedCandidates:
|
|
784
|
+
declinedCandidates: logged(
|
|
785
|
+
summarizeDeclinedCandidates(
|
|
786
|
+
[
|
|
787
|
+
...(coreResult?.declinedCandidates ?? []),
|
|
788
|
+
...manualDeclinedRows(initialOutcomes.outcomes),
|
|
789
|
+
],
|
|
790
|
+
allProtected,
|
|
791
|
+
),
|
|
792
|
+
),
|
|
793
|
+
regenerate,
|
|
409
794
|
complete: false,
|
|
410
795
|
errorCode: 'ERR_CODEMOD_PROTECTED',
|
|
411
|
-
errors:
|
|
796
|
+
errors: [
|
|
797
|
+
...(coreResult?.errors ?? []),
|
|
798
|
+
...staleErrors,
|
|
799
|
+
{file: '.', codemod: 'config', error: configErr.message},
|
|
800
|
+
],
|
|
412
801
|
...(cliBehindCore ? {cliBehindCore} : {}),
|
|
413
802
|
},
|
|
414
803
|
};
|
|
@@ -442,8 +831,12 @@ export async function run(options = {}, {cwd = process.cwd(), origin} = {}) {
|
|
|
442
831
|
// Genuine config error: abort.
|
|
443
832
|
logger.error(configErr.message);
|
|
444
833
|
logger.log('Aborted\n');
|
|
445
|
-
if (
|
|
446
|
-
|
|
834
|
+
if (
|
|
835
|
+
(coreResult?.writtenFiles.length ?? 0) > 0 ||
|
|
836
|
+
initialOutcomes.outcomes.length > 0
|
|
837
|
+
) {
|
|
838
|
+
// Core codemods already wrote, or reported files to regenerate or
|
|
839
|
+
// migrate by hand: the error carries what they changed and found.
|
|
447
840
|
if (cliBehindCore) logCliBehindCore(cliBehindCore, targetVersion);
|
|
448
841
|
const stopped = stoppedReceipt({
|
|
449
842
|
from: currentVersion,
|
|
@@ -455,10 +848,13 @@ export async function run(options = {}, {cwd = process.cwd(), origin} = {}) {
|
|
|
455
848
|
changedFiles: coreResult?.changedFiles ?? [],
|
|
456
849
|
transformsApplied: coreResult?.totalTransformsApplied ?? 0,
|
|
457
850
|
protectedRows: [],
|
|
851
|
+
outcomes: initialOutcomes.outcomes,
|
|
458
852
|
errors: [
|
|
459
853
|
...(coreResult?.errors ?? []),
|
|
854
|
+
...staleErrors,
|
|
460
855
|
{file: '.', codemod: 'config', error: configErr.message},
|
|
461
856
|
],
|
|
857
|
+
declinedRows: coreResult?.declinedCandidates ?? [],
|
|
462
858
|
errorCode: ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
463
859
|
cliBehindCore,
|
|
464
860
|
});
|
|
@@ -616,15 +1012,21 @@ export async function run(options = {}, {cwd = process.cwd(), origin} = {}) {
|
|
|
616
1012
|
];
|
|
617
1013
|
const registryFilesChanged = registryResult?.writtenFiles.length ?? 0;
|
|
618
1014
|
const generatedChangeBlocked = initialProtected.some(item => item.generated);
|
|
1015
|
+
// Generated outputs a codemod reported out of date: the project's declared
|
|
1016
|
+
// regeneration may rebuild them, exactly like a blocked generated change.
|
|
1017
|
+
const reportedRegeneration = initialOutcomes.outcomes.filter(
|
|
1018
|
+
outcome => outcome.kind === 'regenerate',
|
|
1019
|
+
);
|
|
619
1020
|
const shouldRunHooks =
|
|
620
1021
|
postCodemodHooks.length > 0 &&
|
|
621
1022
|
(mergedFilesChanged > 0 ||
|
|
622
1023
|
registryFilesChanged > 0 ||
|
|
623
|
-
generatedChangeBlocked
|
|
1024
|
+
generatedChangeBlocked ||
|
|
1025
|
+
reportedRegeneration.length > 0);
|
|
624
1026
|
/** @type {Map<string, Buffer>} */
|
|
625
1027
|
const protectedBeforeHooks = new Map();
|
|
626
1028
|
if (apply && shouldRunHooks) {
|
|
627
|
-
for (const item of initialProtected) {
|
|
1029
|
+
for (const item of [...initialProtected, ...reportedRegeneration]) {
|
|
628
1030
|
const absolute = path.resolve(cwd, item.file);
|
|
629
1031
|
const relative = path.relative(cwd, absolute);
|
|
630
1032
|
if (
|
|
@@ -659,7 +1061,12 @@ export async function run(options = {}, {cwd = process.cwd(), origin} = {}) {
|
|
|
659
1061
|
const hookErr = /** @type {Error} */ (err);
|
|
660
1062
|
const msg = `Post-codemod hook failed: ${hookErr.message}`;
|
|
661
1063
|
logger.error(msg);
|
|
662
|
-
|
|
1064
|
+
const protectedRegeneration = regenerationProtectionRows(
|
|
1065
|
+
initialOutcomes.outcomes,
|
|
1066
|
+
protection,
|
|
1067
|
+
cwd,
|
|
1068
|
+
);
|
|
1069
|
+
if (initialProtected.length === 0 && protectedRegeneration.length === 0) {
|
|
663
1070
|
logger.log('Upgrade failed\n');
|
|
664
1071
|
throw failWithReceipt(
|
|
665
1072
|
msg,
|
|
@@ -674,10 +1081,16 @@ export async function run(options = {}, {cwd = process.cwd(), origin} = {}) {
|
|
|
674
1081
|
changedFiles: mergedChangedFiles,
|
|
675
1082
|
transformsApplied: mergedTransformsApplied,
|
|
676
1083
|
protectedRows: [],
|
|
1084
|
+
outcomes: initialOutcomes.outcomes,
|
|
677
1085
|
errors: [
|
|
678
1086
|
...mergedErrors,
|
|
1087
|
+
...regenerationErrors(initialOutcomes.outcomes, protection, cwd),
|
|
679
1088
|
{file: '.', codemod: 'post-codemod-hook', error: msg},
|
|
680
1089
|
],
|
|
1090
|
+
declinedRows: [
|
|
1091
|
+
...(coreResult?.declinedCandidates ?? []),
|
|
1092
|
+
...(integrationResult?.declinedCandidates ?? []),
|
|
1093
|
+
],
|
|
681
1094
|
errorCode: ERROR_CODES.ERR_CODEMOD_FAILED,
|
|
682
1095
|
cliBehindCore,
|
|
683
1096
|
...(registryResult
|
|
@@ -709,6 +1122,12 @@ export async function run(options = {}, {cwd = process.cwd(), origin} = {}) {
|
|
|
709
1122
|
// selected codemods in preview mode against fresh bytes and fresh declarations
|
|
710
1123
|
// to distinguish resolved outputs from changes that remain blocked.
|
|
711
1124
|
let remainingProtected = initialProtected;
|
|
1125
|
+
let remainingDeclined = [
|
|
1126
|
+
...(coreResult?.declinedCandidates ?? []),
|
|
1127
|
+
...(integrationResult?.declinedCandidates ?? []),
|
|
1128
|
+
];
|
|
1129
|
+
let finalOutcomes = initialOutcomes.outcomes;
|
|
1130
|
+
let finalProtection = protection;
|
|
712
1131
|
if (apply && shouldRunHooks && !hookFailure) {
|
|
713
1132
|
let refreshedProtection;
|
|
714
1133
|
try {
|
|
@@ -726,11 +1145,24 @@ export async function run(options = {}, {cwd = process.cwd(), origin} = {}) {
|
|
|
726
1145
|
cwd,
|
|
727
1146
|
changedFiles: [...mergedChangedFiles, ...hookModifiedFiles],
|
|
728
1147
|
transformsApplied: mergedTransformsApplied,
|
|
729
|
-
protectedRows:
|
|
1148
|
+
protectedRows: [
|
|
1149
|
+
...initialProtected,
|
|
1150
|
+
...regenerationProtectionRows(
|
|
1151
|
+
initialOutcomes.outcomes,
|
|
1152
|
+
protection,
|
|
1153
|
+
cwd,
|
|
1154
|
+
),
|
|
1155
|
+
],
|
|
1156
|
+
outcomes: initialOutcomes.outcomes,
|
|
730
1157
|
errors: [
|
|
731
1158
|
...mergedErrors,
|
|
1159
|
+
...regenerationErrors(initialOutcomes.outcomes, protection, cwd),
|
|
732
1160
|
{file: '.', codemod: 'file-protection', error: err.message},
|
|
733
1161
|
],
|
|
1162
|
+
declinedRows: [
|
|
1163
|
+
...(coreResult?.declinedCandidates ?? []),
|
|
1164
|
+
...(integrationResult?.declinedCandidates ?? []),
|
|
1165
|
+
],
|
|
734
1166
|
errorCode: err.code,
|
|
735
1167
|
cliBehindCore,
|
|
736
1168
|
...(registryResult
|
|
@@ -739,7 +1171,8 @@ export async function run(options = {}, {cwd = process.cwd(), origin} = {}) {
|
|
|
739
1171
|
});
|
|
740
1172
|
throw failWithReceipt(err.message, err.code, stopped);
|
|
741
1173
|
}
|
|
742
|
-
const
|
|
1174
|
+
const recheckOutcomes = withCodemodOutcomes(versionManifests, cwd);
|
|
1175
|
+
const coreCheck = await runCoreCodemods(recheckOutcomes.versionManifests, {
|
|
743
1176
|
apply: false,
|
|
744
1177
|
path: path_,
|
|
745
1178
|
codemod: options.codemod,
|
|
@@ -789,6 +1222,14 @@ export async function run(options = {}, {cwd = process.cwd(), origin} = {}) {
|
|
|
789
1222
|
recheckedProtected.push(...(initialByFile.get(file) ?? []));
|
|
790
1223
|
}
|
|
791
1224
|
remainingProtected = recheckedProtected;
|
|
1225
|
+
// Regenerated bytes decide what a codemod could not parse, as they decide
|
|
1226
|
+
// what is still protected.
|
|
1227
|
+
remainingDeclined = [
|
|
1228
|
+
...(checkedCore?.declinedCandidates ?? []),
|
|
1229
|
+
...(integrationCheck?.declinedCandidates ?? []),
|
|
1230
|
+
];
|
|
1231
|
+
finalOutcomes = recheckOutcomes.outcomes;
|
|
1232
|
+
finalProtection = refreshedProtection;
|
|
792
1233
|
finalErrors = [
|
|
793
1234
|
...mergedErrors,
|
|
794
1235
|
...(checkedCore?.errors ?? []),
|
|
@@ -796,7 +1237,10 @@ export async function run(options = {}, {cwd = process.cwd(), origin} = {}) {
|
|
|
796
1237
|
];
|
|
797
1238
|
}
|
|
798
1239
|
|
|
799
|
-
const protectedFiles = summarizeProtectedFiles(
|
|
1240
|
+
const protectedFiles = summarizeProtectedFiles([
|
|
1241
|
+
...remainingProtected,
|
|
1242
|
+
...regenerationProtectionRows(finalOutcomes, finalProtection, cwd),
|
|
1243
|
+
]);
|
|
800
1244
|
receipt.filesChanged = mergedFilesChanged;
|
|
801
1245
|
receipt.transformsApplied = mergedTransformsApplied;
|
|
802
1246
|
receipt.modifiedFiles = uniqueFiles([
|
|
@@ -804,9 +1248,28 @@ export async function run(options = {}, {cwd = process.cwd(), origin} = {}) {
|
|
|
804
1248
|
...hookModifiedFiles,
|
|
805
1249
|
]).map(file => path.relative(cwd, file).split(path.sep).join('/'));
|
|
806
1250
|
receipt.protectedFiles = protectedFiles;
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
1251
|
+
const declinedCandidates = logged(
|
|
1252
|
+
summarizeDeclinedCandidates(
|
|
1253
|
+
[...remainingDeclined, ...manualDeclinedRows(finalOutcomes)],
|
|
1254
|
+
// The complete final set, regeneration rows included: a file listed
|
|
1255
|
+
// under protectedFiles is never also declined.
|
|
1256
|
+
protectedFiles,
|
|
1257
|
+
),
|
|
1258
|
+
);
|
|
1259
|
+
receipt.declinedCandidates = declinedCandidates;
|
|
1260
|
+
const regenerate = summarizeRegenerate(protectedFiles, finalOutcomes);
|
|
1261
|
+
receipt.regenerate = regenerate;
|
|
1262
|
+
// A protected file to rebuild blocks the run like any protected file
|
|
1263
|
+
// (spec:AST-040 FR6). An unprotected one is a required change the codemod
|
|
1264
|
+
// could not make: a codemod error. A declined candidate, a manual
|
|
1265
|
+
// migration included, never blocks (FR7).
|
|
1266
|
+
finalErrors = [
|
|
1267
|
+
...finalErrors,
|
|
1268
|
+
...regenerationErrors(finalOutcomes, finalProtection, cwd),
|
|
1269
|
+
];
|
|
1270
|
+
const blocked = protectedFiles.length > 0;
|
|
1271
|
+
receipt.complete = !blocked && finalErrors.length === 0;
|
|
1272
|
+
if (blocked) {
|
|
810
1273
|
receipt.errorCode = 'ERR_CODEMOD_PROTECTED';
|
|
811
1274
|
} else if (finalErrors.length > 0) {
|
|
812
1275
|
// Only on the receipt the thrown error carries (below).
|
|
@@ -816,19 +1279,15 @@ export async function run(options = {}, {cwd = process.cwd(), origin} = {}) {
|
|
|
816
1279
|
if (registryResult) receipt.registryCompositions = registryResult.summary;
|
|
817
1280
|
if (cliBehindCore) receipt.cliBehindCore = cliBehindCore;
|
|
818
1281
|
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
logger.log(` Regenerate with: ${command}`);
|
|
827
|
-
}
|
|
828
|
-
}
|
|
829
|
-
}
|
|
1282
|
+
logProtectedFiles(
|
|
1283
|
+
`${ERROR_CODES.ERR_CODEMOD_PROTECTED}: ${protectedFiles.length} protected file${protectedFiles.length === 1 ? '' : 's'} still require${protectedFiles.length === 1 ? 's' : ''} a codemod change:`,
|
|
1284
|
+
protectedFiles,
|
|
1285
|
+
);
|
|
1286
|
+
// Generated outputs a codemod reported out of date, beyond the protected
|
|
1287
|
+
// files already listed above.
|
|
1288
|
+
logRegenerate(regenerate, protectedFiles);
|
|
830
1289
|
|
|
831
|
-
if (finalErrors.length > 0 &&
|
|
1290
|
+
if (finalErrors.length > 0 && !blocked) {
|
|
832
1291
|
const msg = `Upgrade completed with ${finalErrors.length} codemod error${finalErrors.length === 1 ? '' : 's'}.`;
|
|
833
1292
|
logger.log('Upgrade failed\n');
|
|
834
1293
|
// The error carries the receipt: every file the codemods wrote before the
|
|
@@ -865,14 +1324,19 @@ export async function run(options = {}, {cwd = process.cwd(), origin} = {}) {
|
|
|
865
1324
|
: apply
|
|
866
1325
|
? 'Upgrade complete'
|
|
867
1326
|
: 'Dry run complete';
|
|
1327
|
+
const manualCount = countManualMigrations(declinedCandidates);
|
|
1328
|
+
const manualNote =
|
|
1329
|
+
manualCount > 0
|
|
1330
|
+
? `; ${manualCount} manual migration${manualCount === 1 ? '' : 's'} listed above`
|
|
1331
|
+
: '';
|
|
868
1332
|
logger.log(
|
|
869
1333
|
protectedFiles.length > 0
|
|
870
1334
|
? 'Upgrade incomplete: protected changes remain\n'
|
|
871
1335
|
: !registryOk
|
|
872
1336
|
? 'Upgrade finished with unresolved registry items\n'
|
|
873
1337
|
: sourcePathFound
|
|
874
|
-
? done + '\n'
|
|
875
|
-
: `${done}, but ${path.relative(cwd, path_) || '.'} does not exist, so no source files were scanned. ` +
|
|
1338
|
+
? done + manualNote + '\n'
|
|
1339
|
+
: `${done}${manualNote}, but ${path.relative(cwd, path_) || '.'} does not exist, so no source files were scanned. ` +
|
|
876
1340
|
`Pass --path <your source directory> if your code does not live in ./src.\n`,
|
|
877
1341
|
);
|
|
878
1342
|
return {
|