@astryxdesign/cli 0.7.5-canary.ce34b37 → 0.7.5-canary.d26cdf3
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 +1 -1
- package/api/upgrade/_adapter.d.mts +45 -2
- package/api/upgrade/_adapter.mjs +58 -2
- package/api/upgrade/run/outcomes.test.mjs +646 -0
- package/api/upgrade/run/run.d.mts +36 -0
- package/api/upgrade/run/run.mjs +446 -61
- 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/outcome.mjs +79 -0
- package/assets/codemods/outcome.test.mjs +40 -0
- package/assets/codemods/runner.mjs +11 -3
- package/assets/codemods/transforms/v0.7.0/__tests__/validate-data-token-ownership.test.mjs +24 -4
- package/assets/codemods/transforms/v0.7.0/validate-data-token-ownership.mjs +6 -3
- package/clients/cli/commands/upgrade.doc.mjs +20 -2
- package/clients/cli/commands/upgrade.outcomes.test.mjs +350 -0
- package/foundation/response/response-types.doc.mjs +1 -1
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -522,7 +522,7 @@ Every response has a `type` discriminant. The full set is below (generated from
|
|
|
522
522
|
| `upgrade.list` | Every available codemod, oldest→newest, as {name, package, title, version, optional}; returned for --list without running anything. |
|
|
523
523
|
| `upgrade.registry` | The copied-composition receipt for --registry: applied, ok, the counts (found, current, wouldUpdate, updated, wouldMerge, merged, wouldRefreshReceipt, receiptsRefreshed, conflicts, missing, invalid, failed), and items. |
|
|
524
524
|
| `upgrade.status` | A short-circuit outcome with no codemods run (up_to_date, no_codemods, or config_fixable), each carrying the agent-docs summary. no_codemods and config_fixable carry cliBehindCore ({cliVersion, command}) when the installed Core is newer than the CLI, which then has no codemods for the releases after its own version. |
|
|
525
|
-
| `upgrade.run` | The run receipt: from/to versions, codemod count, integrations processed, the agent-docs summary, sourcePathFound (false when the resolved source directory does not exist, so no source file was read), and (apply mode) filesChanged, transformsApplied, and per-codemod errors. When the installed Core is newer than the CLI, it also carries cliBehindCore ({cliVersion, command}): codemods for the releases after cliVersion did not run.
|
|
525
|
+
| `upgrade.run` | The run receipt: from/to versions, codemod count, integrations processed, the agent-docs summary, sourcePathFound (false when the resolved source directory does not exist, so no source file was read), and (apply mode) filesChanged, transformsApplied, and per-codemod errors. regenerate lists generated files to rebuild, each with its codemods, commands and messages. When the installed Core is newer than the CLI, it also carries cliBehindCore ({cliVersion, command}): codemods for the releases after cliVersion did not run. |
|
|
526
526
|
| `manifest` | The CLI capability manifest: name, version, apiVersion, description, globalOptions, commands (each name, description, arguments, options, json, aliases?, responseTypes?, examples?, exitCodes? as [{code, when}], outsideProject? (same, refuse, or own; absent on a group), subcommands?), jsonSupported, globalMode ({docs, summary}: what a run may do beyond its command, such as the hand-off to the project's own CLI, the daily update check, and the agent skill file, and the docs topic that explains it), and the flat responseTypes index. |
|
|
527
527
|
| `help` | Help, in one of two shapes. A bare `astryx --json` returns the root manifest: name, version, commands (the command names), jsonSupported, and manifest (the full payload `astryx manifest --json` returns). `--help --json` on any command, or `astryx help [command] --json`, returns that command's help: command, description, usage, options (each flags, description, and defaultValue and choices when set), and subcommands (each name and description). data.manifest marks the first shape; data.usage marks the second. |
|
|
528
528
|
| `version` | The CLI version, for `astryx --version --json`: {version}. |
|
|
@@ -180,13 +180,42 @@ export function getCoreVersionManifests(from: string, to: string): Promise<CoreV
|
|
|
180
180
|
export function ensureCodemodDeps({ installDeps }?: {
|
|
181
181
|
installDeps?: boolean;
|
|
182
182
|
}): Promise<boolean>;
|
|
183
|
+
/**
|
|
184
|
+
* @typedef {{kind: 'manual', file: string, codemod: string, message: string, line?: number} | {kind: 'regenerate', file: string, codemod: string, message: string, commands: string[]}} CodemodOutcomeRecord
|
|
185
|
+
*/
|
|
186
|
+
/**
|
|
187
|
+
* Wrap each core code and config transform so the non-failure outcomes it
|
|
188
|
+
* throws (`assets/codemods/outcome.mjs`) are recorded instead of reaching the
|
|
189
|
+
* runner as errors. The wrapped transform leaves that file unchanged, exactly
|
|
190
|
+
* as the throw did. Project codemods keep their own contract. One wrapper per
|
|
191
|
+
* pass: the regeneration re-check takes a fresh one, so an outcome a hook
|
|
192
|
+
* resolved does not linger.
|
|
193
|
+
*
|
|
194
|
+
* @template {{version: string, transforms: Array<{name: string, transform: any, meta?: {codemodType?: string}}>}} M
|
|
195
|
+
* @param {M[]} versionManifests
|
|
196
|
+
* @param {string} root project root; recorded files are relative to it
|
|
197
|
+
* @returns {{versionManifests: M[], outcomes: CodemodOutcomeRecord[]}}
|
|
198
|
+
*/
|
|
199
|
+
export function withCodemodOutcomes<M extends {
|
|
200
|
+
version: string;
|
|
201
|
+
transforms: Array<{
|
|
202
|
+
name: string;
|
|
203
|
+
transform: any;
|
|
204
|
+
meta?: {
|
|
205
|
+
codemodType?: string;
|
|
206
|
+
};
|
|
207
|
+
}>;
|
|
208
|
+
}>(versionManifests: M[], root: string): {
|
|
209
|
+
versionManifests: M[];
|
|
210
|
+
outcomes: CodemodOutcomeRecord[];
|
|
211
|
+
};
|
|
183
212
|
/**
|
|
184
213
|
* Run the CORE registry codemods. Runs BEFORE the config is loaded so a core
|
|
185
214
|
* CONFIG codemod can repair a config the strict loader would otherwise reject.
|
|
186
215
|
* @param {CoreVersionManifest[]} versionManifests
|
|
187
|
-
* @param {{apply: boolean, path: string, codemod?: string, skipCodemods: Set<string>, root?: string, protection?: {root: string, classify: (file: string) => import('../../foundation/fs/file-protection.mjs').FileProtection[]}, silent?: boolean, coversTarget?: boolean}} options
|
|
216
|
+
* @param {{apply: boolean, path: string, codemod?: string, skipCodemods: Set<string>, root?: string, protection?: {root: string, classify: (file: string) => import('../../foundation/fs/file-protection.mjs').FileProtection[]}, silent?: boolean, coversTarget?: boolean, outcomes?: CodemodOutcomeRecord[]}} options
|
|
188
217
|
*/
|
|
189
|
-
export function runCoreCodemods(versionManifests: CoreVersionManifest[], { apply, path: srcPath, codemod, skipCodemods, root, protection, silent, coversTarget, }: {
|
|
218
|
+
export function runCoreCodemods(versionManifests: CoreVersionManifest[], { apply, path: srcPath, codemod, skipCodemods, root, protection, silent, coversTarget, outcomes, }: {
|
|
190
219
|
apply: boolean;
|
|
191
220
|
path: string;
|
|
192
221
|
codemod?: string;
|
|
@@ -198,6 +227,7 @@ export function runCoreCodemods(versionManifests: CoreVersionManifest[], { apply
|
|
|
198
227
|
};
|
|
199
228
|
silent?: boolean;
|
|
200
229
|
coversTarget?: boolean;
|
|
230
|
+
outcomes?: CodemodOutcomeRecord[];
|
|
201
231
|
}): Promise<{
|
|
202
232
|
totalFilesChanged: number;
|
|
203
233
|
totalTransformsApplied: number;
|
|
@@ -349,4 +379,17 @@ export type AgentDocsRefreshPlan = {
|
|
|
349
379
|
renderedBlock: string | null;
|
|
350
380
|
summary: import("./upgrade.type.mjs").AgentDocsSummary;
|
|
351
381
|
};
|
|
382
|
+
export type CodemodOutcomeRecord = {
|
|
383
|
+
kind: "manual";
|
|
384
|
+
file: string;
|
|
385
|
+
codemod: string;
|
|
386
|
+
message: string;
|
|
387
|
+
line?: number;
|
|
388
|
+
} | {
|
|
389
|
+
kind: "regenerate";
|
|
390
|
+
file: string;
|
|
391
|
+
codemod: string;
|
|
392
|
+
message: string;
|
|
393
|
+
commands: string[];
|
|
394
|
+
};
|
|
352
395
|
import { inspectAgentDocs } from '../../foundation/agent-docs/agent-docs.mjs';
|
package/api/upgrade/_adapter.mjs
CHANGED
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
latestVersion,
|
|
25
25
|
} from '../../assets/codemods/registry.mjs';
|
|
26
26
|
import {runCodemods} from '../../assets/codemods/runner.mjs';
|
|
27
|
+
import {codemodOutcome} from '../../assets/codemods/outcome.mjs';
|
|
27
28
|
import {
|
|
28
29
|
discoverIntegrationCodemods,
|
|
29
30
|
selectIntegrationCodemods,
|
|
@@ -141,7 +142,12 @@ export function relativeToOrigin(result, {cwd: root, origin}) {
|
|
|
141
142
|
};
|
|
142
143
|
}
|
|
143
144
|
if (data.modifiedFiles) data.modifiedFiles = data.modifiedFiles.map(rebase);
|
|
144
|
-
for (const key of [
|
|
145
|
+
for (const key of [
|
|
146
|
+
'protectedFiles',
|
|
147
|
+
'declinedCandidates',
|
|
148
|
+
'errors',
|
|
149
|
+
'regenerate',
|
|
150
|
+
]) {
|
|
145
151
|
if (data[key]) {
|
|
146
152
|
data[key] = data[key].map(
|
|
147
153
|
(/** @type {{file: string, declarations?: string[]}} */ entry) => ({
|
|
@@ -599,11 +605,59 @@ export async function ensureCodemodDeps({installDeps} = {}) {
|
|
|
599
605
|
return ensureJscodeshift({installDeps, silent: logger.silent});
|
|
600
606
|
}
|
|
601
607
|
|
|
608
|
+
/**
|
|
609
|
+
* @typedef {{kind: 'manual', file: string, codemod: string, message: string, line?: number} | {kind: 'regenerate', file: string, codemod: string, message: string, commands: string[]}} CodemodOutcomeRecord
|
|
610
|
+
*/
|
|
611
|
+
|
|
612
|
+
/**
|
|
613
|
+
* Wrap each core code and config transform so the non-failure outcomes it
|
|
614
|
+
* throws (`assets/codemods/outcome.mjs`) are recorded instead of reaching the
|
|
615
|
+
* runner as errors. The wrapped transform leaves that file unchanged, exactly
|
|
616
|
+
* as the throw did. Project codemods keep their own contract. One wrapper per
|
|
617
|
+
* pass: the regeneration re-check takes a fresh one, so an outcome a hook
|
|
618
|
+
* resolved does not linger.
|
|
619
|
+
*
|
|
620
|
+
* @template {{version: string, transforms: Array<{name: string, transform: any, meta?: {codemodType?: string}}>}} M
|
|
621
|
+
* @param {M[]} versionManifests
|
|
622
|
+
* @param {string} root project root; recorded files are relative to it
|
|
623
|
+
* @returns {{versionManifests: M[], outcomes: CodemodOutcomeRecord[]}}
|
|
624
|
+
*/
|
|
625
|
+
export function withCodemodOutcomes(versionManifests, root) {
|
|
626
|
+
/** @type {CodemodOutcomeRecord[]} */
|
|
627
|
+
const outcomes = [];
|
|
628
|
+
const wrapped = versionManifests.map(manifest => ({
|
|
629
|
+
...manifest,
|
|
630
|
+
transforms: manifest.transforms.map(entry => {
|
|
631
|
+
if (entry.meta?.codemodType === 'project') return entry;
|
|
632
|
+
const {transform, name} = entry;
|
|
633
|
+
return {
|
|
634
|
+
...entry,
|
|
635
|
+
/** @param {{path: string, source: string}} file @param {unknown} api */
|
|
636
|
+
transform(file, api) {
|
|
637
|
+
try {
|
|
638
|
+
return transform(file, api);
|
|
639
|
+
} catch (err) {
|
|
640
|
+
const outcome = codemodOutcome(err);
|
|
641
|
+
if (!outcome) throw err;
|
|
642
|
+
outcomes.push({
|
|
643
|
+
...outcome,
|
|
644
|
+
file: path.relative(root, file.path).split(path.sep).join('/'),
|
|
645
|
+
codemod: `core:${name}`,
|
|
646
|
+
});
|
|
647
|
+
return undefined;
|
|
648
|
+
}
|
|
649
|
+
},
|
|
650
|
+
};
|
|
651
|
+
}),
|
|
652
|
+
}));
|
|
653
|
+
return {versionManifests: /** @type {M[]} */ (wrapped), outcomes};
|
|
654
|
+
}
|
|
655
|
+
|
|
602
656
|
/**
|
|
603
657
|
* Run the CORE registry codemods. Runs BEFORE the config is loaded so a core
|
|
604
658
|
* CONFIG codemod can repair a config the strict loader would otherwise reject.
|
|
605
659
|
* @param {CoreVersionManifest[]} versionManifests
|
|
606
|
-
* @param {{apply: boolean, path: string, codemod?: string, skipCodemods: Set<string>, root?: string, protection?: {root: string, classify: (file: string) => import('../../foundation/fs/file-protection.mjs').FileProtection[]}, silent?: boolean, coversTarget?: boolean}} options
|
|
660
|
+
* @param {{apply: boolean, path: string, codemod?: string, skipCodemods: Set<string>, root?: string, protection?: {root: string, classify: (file: string) => import('../../foundation/fs/file-protection.mjs').FileProtection[]}, silent?: boolean, coversTarget?: boolean, outcomes?: CodemodOutcomeRecord[]}} options
|
|
607
661
|
*/
|
|
608
662
|
export async function runCoreCodemods(
|
|
609
663
|
versionManifests,
|
|
@@ -616,6 +670,7 @@ export async function runCoreCodemods(
|
|
|
616
670
|
protection,
|
|
617
671
|
silent,
|
|
618
672
|
coversTarget,
|
|
673
|
+
outcomes,
|
|
619
674
|
},
|
|
620
675
|
) {
|
|
621
676
|
return runCodemods(versionManifests, {
|
|
@@ -627,6 +682,7 @@ export async function runCoreCodemods(
|
|
|
627
682
|
root,
|
|
628
683
|
protection,
|
|
629
684
|
coversTarget,
|
|
685
|
+
outcomes,
|
|
630
686
|
});
|
|
631
687
|
}
|
|
632
688
|
|