@astryxdesign/cli 0.6.3-canary.98a2e4e → 0.6.3-canary.a860a50
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 +32 -18
- package/api/build/build.doc.mjs +3 -3
- package/api/build/build.test.mjs +14 -3
- package/api/build/build.type.d.mts +36 -2
- package/api/build/build.type.mjs +25 -4
- package/api/build/help/help.d.mts +8 -5
- package/api/build/help/help.mjs +56 -6
- package/api/component/component.doc.mjs +11 -2
- package/api/component/component.mjs +29 -0
- package/api/component/component.test.mjs +38 -0
- package/api/component/component.type.d.mts +17 -7
- package/api/component/component.type.mjs +27 -20
- package/api/discover/discover.doc.mjs +1 -1
- package/api/discover/discover.type.d.mts +4 -4
- package/api/discover/discover.type.mjs +10 -10
- package/api/docs/_adapter.d.mts +30 -27
- package/api/docs/_adapter.mjs +154 -124
- package/api/docs/compiled-topics.test.mjs +78 -0
- package/api/docs/detail/detail.d.mts +0 -15
- package/api/docs/detail/detail.mjs +14 -78
- package/api/docs/detail/section/section.mjs +22 -18
- package/api/docs/detail/section/section.test.mjs +4 -3
- package/api/docs/docs.type.d.mts +4 -4
- package/api/docs/docs.type.mjs +10 -10
- package/api/docs/index/index.mjs +6 -5
- package/api/doctor/doctor.mjs +3 -7
- package/api/gap-report/gap-report.doc.mjs +7 -4
- package/api/hook/hook.type.d.mts +3 -3
- package/api/hook/hook.type.mjs +11 -11
- package/api/init/init.doc.mjs +4 -0
- package/api/init/init.test.mjs +41 -1
- package/api/init/remove/remove.mjs +1 -1
- package/api/init/run/run.mjs +20 -10
- package/api/integration/add-contribution.component-names.test.mjs +120 -0
- package/api/integration/add-contribution.mjs +16 -3
- package/api/integration/add-contribution.test.mjs +84 -4
- package/api/integration/integrationAdd.doc.mjs +7 -4
- package/api/integration/integrationAddComponent.doc.mjs +1 -1
- package/api/integration/pack-check.mjs +49 -7
- package/api/integration/pack-check.test.mjs +249 -0
- package/api/integration/validate-integration.mjs +2 -0
- package/api/integration/validate-integration.test.mjs +91 -0
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/json/envelope-types.test.mjs +76 -0
- package/api/json/parseResponse.doc.mjs +2 -2
- package/api/layout/expand/expand.mjs +7 -5
- package/api/layout/expand/expand.path-safety.test.mjs +53 -0
- package/api/layout/grammar/grammar.mjs +2 -1
- package/api/layout/layoutExpand.doc.mjs +1 -1
- package/api/search/search-return-type.test.mjs +54 -0
- package/api/search/search.d.mts +2 -9
- package/api/search/search.doc.mjs +5 -1
- package/api/search/search.mjs +15 -8
- package/api/search/search.test.mjs +34 -0
- package/api/search/search.type.d.mts +1 -1
- package/api/search/search.type.mjs +1 -1
- package/api/swizzle/copy/copy.mjs +28 -11
- package/api/swizzle/swizzle.doc.mjs +1 -1
- package/api/swizzle/swizzle.type.d.mts +2 -2
- package/api/swizzle/swizzle.type.mjs +2 -2
- package/api/template/copy/copy.mjs +17 -23
- package/api/template/copy/copy.test.mjs +17 -0
- package/api/template/template.doc.mjs +2 -1
- package/api/template/template.type.d.mts +5 -5
- package/api/template/template.type.mjs +12 -12
- package/api/theme/add/add.binary.test.mjs +91 -0
- package/api/theme/add/add.mjs +15 -2
- package/api/theme/build/build.mjs +133 -42
- package/api/theme/build/build.public-component-vars.test.mjs +1 -1
- package/api/theme/build/build.receipt-doc.test.mjs +111 -0
- package/api/theme/build/build.test.mjs +127 -0
- package/api/theme/build/font-warning.mjs +3 -3
- package/api/theme/build/font-warning.test.mjs +5 -2
- package/api/theme/palette/generate/generate.mjs +8 -3
- package/api/theme/palette/generate/generate.test.mjs +96 -0
- package/api/theme/palette/generate/generator.d.mts +10 -13
- package/api/theme/palette/generate/generator.mjs +15 -4
- package/api/theme/palette/generate/generator.test.mjs +10 -0
- package/api/theme/template/template.mjs +11 -2
- package/api/theme/template/template.test.mjs +15 -0
- package/api/theme/theme.type.d.mts +170 -11
- package/api/theme/theme.type.mjs +94 -27
- package/api/theme/themeBuild.doc.mjs +7 -4
- package/api/theme/themeTemplate.doc.mjs +4 -1
- package/api/upgrade/_adapter.mjs +27 -4
- package/api/upgrade/list/list.mjs +2 -1
- package/api/upgrade/list/list.test.mjs +73 -0
- package/api/upgrade/status/status.mjs +2 -2
- package/api/upgrade/upgrade.doc.mjs +2 -1
- package/api/upgrade/upgrade.type.d.mts +8 -4
- package/api/upgrade/upgrade.type.mjs +11 -10
- package/assets/codemods/integration-discovery.mjs +40 -2
- package/assets/codemods/integration-discovery.test.mjs +58 -0
- package/assets/codemods/term-log.mjs +32 -8
- package/assets/codemods/term-log.test.mjs +19 -1
- package/assets/codemods/transforms/v0.3.0/__tests__/unwrap-authoring-factories.test.mjs +27 -5
- package/assets/codemods/transforms/v0.3.0/unwrap-authoring-factories.mjs +20 -5
- package/assets/codemods/transforms/v0.6.0/__tests__/next-codemods.test.mjs +47 -0
- package/assets/codemods/transforms/v0.6.0/rename-resizable-pixel-bounds.mjs +57 -10
- package/assets/docs/cli-integrations.doc.mjs +9 -0
- package/assets/docs/styling-libraries.doc.mjs +1 -1
- package/assets/docs/working-with-ai.doc.mjs +1 -1
- package/assets/templates/pages/table-tree/page.tsx +1704 -0
- package/assets/templates/pages/table-tree/template.doc.mjs +12 -0
- package/authoring/_shared/contract.ts +22 -0
- package/authoring/codemod/codemod.doc.mjs +6 -1
- package/authoring/codemod/parse.d.mts +8 -8
- package/authoring/codemod/parse.mjs +8 -6
- package/authoring/config/config.doc.mjs +1 -1
- package/authoring/config/debug-composition.test.mjs +92 -0
- package/authoring/config/parse.d.mts +13 -13
- package/authoring/config/parse.mjs +8 -8
- package/authoring/config/type.ts +18 -6
- package/authoring/debug/parse.d.mts +4 -4
- package/authoring/debug/parse.mjs +3 -3
- package/authoring/doctypes/_schema.d.mts +121 -11
- package/authoring/doctypes/_schema.mjs +144 -13
- package/authoring/doctypes/base/graph-fields.doc.mjs +11 -4
- package/authoring/doctypes/base/type.ts +8 -4
- package/authoring/doctypes/command/command.doc.mjs +3 -2
- package/authoring/doctypes/command/parse.d.mts +2 -2
- package/authoring/doctypes/command/parse.mjs +1 -1
- package/authoring/doctypes/command/type.ts +2 -2
- package/authoring/doctypes/component/component.doc.mjs +5 -2
- package/authoring/doctypes/component/parse.d.mts +2 -2
- package/authoring/doctypes/component/parse.mjs +1 -1
- package/authoring/doctypes/component/type.ts +1 -1
- package/authoring/doctypes/enum/parse.d.mts +2 -2
- package/authoring/doctypes/enum/parse.mjs +1 -1
- package/authoring/doctypes/enum/type.ts +1 -1
- package/authoring/doctypes/function/function.doc.mjs +4 -0
- package/authoring/doctypes/function/parse.d.mts +2 -2
- package/authoring/doctypes/function/parse.mjs +1 -1
- package/authoring/doctypes/function/type.ts +1 -1
- package/authoring/doctypes/hook/hook.doc.mjs +4 -0
- package/authoring/doctypes/hook/parse.d.mts +2 -2
- package/authoring/doctypes/hook/parse.mjs +1 -1
- package/authoring/doctypes/hook/type.ts +1 -1
- package/authoring/doctypes/legacy.d.mts +6 -6
- package/authoring/doctypes/legacy.mjs +3 -3
- package/authoring/doctypes/load-contract.test.mjs +207 -0
- package/authoring/doctypes/namespace/namespace.doc.mjs +7 -3
- package/authoring/doctypes/namespace/parse.d.mts +2 -2
- package/authoring/doctypes/namespace/parse.mjs +1 -1
- package/authoring/doctypes/namespace/type.ts +2 -2
- package/authoring/doctypes/parse.d.mts +18 -18
- package/authoring/doctypes/parse.mjs +9 -9
- package/authoring/doctypes/reference/parse.d.mts +2 -2
- package/authoring/doctypes/reference/parse.mjs +1 -1
- package/authoring/doctypes/reference/reference.doc.mjs +6 -2
- package/authoring/doctypes/reference/type.ts +1 -1
- package/authoring/doctypes/schema/parse.d.mts +2 -2
- package/authoring/doctypes/schema/parse.mjs +1 -1
- package/authoring/doctypes/schema/type.ts +2 -2
- package/authoring/doctypes/template/parse.d.mts +92 -1
- package/authoring/doctypes/template/parse.mjs +33 -1
- package/authoring/doctypes/template/template.doc.mjs +4 -0
- package/authoring/doctypes/template/type.ts +4 -1
- package/authoring/doctypes/types.ts +10 -10
- package/authoring/gap-report/parse.d.mts +9 -9
- package/authoring/gap-report/parse.mjs +6 -6
- package/authoring/gap-report/type.ts +1 -1
- package/authoring/identity/identity.doc.mjs +3 -2
- package/authoring/identity/type.ts +10 -10
- package/authoring/index.d.ts +19 -19
- package/authoring/integration/parse.d.mts +2 -2
- package/authoring/integration/parse.mjs +1 -1
- package/authoring/integration/schema.d.mts +4 -4
- package/authoring/integration/schema.mjs +3 -3
- package/authoring/integration/type.ts +1 -1
- package/clients/cli/command-load-failure.test.mjs +83 -0
- package/clients/cli/commands/blog.mjs +23 -8
- package/clients/cli/commands/blog.test.mjs +42 -1
- package/clients/cli/commands/build-theme.ascii-output.test.mjs +161 -0
- package/clients/cli/commands/build-theme.flag-docs.test.mjs +110 -0
- package/clients/cli/commands/build-theme.mjs +5 -5
- package/clients/cli/commands/build-theme.path-safety.test.mjs +86 -1
- package/clients/cli/commands/build-theme.variants.test.mjs +76 -0
- package/clients/cli/commands/build.doc.mjs +4 -1
- package/clients/cli/commands/build.exit-codes-doc.test.mjs +50 -0
- package/clients/cli/commands/build.mjs +32 -47
- package/clients/cli/commands/build.playbook.test.mjs +75 -0
- package/clients/cli/commands/build.text-fields.test.mjs +40 -0
- package/clients/cli/commands/component/index.mjs +2 -7
- package/clients/cli/commands/component-package.test.mjs +18 -0
- package/clients/cli/commands/component-resolution.test.mjs +21 -0
- package/clients/cli/commands/component.test.mjs +19 -0
- package/clients/cli/commands/detail-levels.test.mjs +2 -2
- package/clients/cli/commands/discover.broken-integration.test.mjs +48 -0
- package/clients/cli/commands/discover.components-flag.test.mjs +97 -0
- package/clients/cli/commands/discover.doc.mjs +4 -2
- package/clients/cli/commands/discover.mjs +3 -3
- package/clients/cli/commands/discover.text-projection.test.mjs +103 -0
- package/clients/cli/commands/doctor-integration.package-json.test.mjs +53 -0
- package/clients/cli/commands/doctor.mjs +6 -16
- package/clients/cli/commands/doctor.test.mjs +42 -0
- package/clients/cli/commands/gap-report.doc.mjs +16 -5
- package/clients/cli/commands/gap-report.test.mjs +72 -0
- package/clients/cli/commands/hook/index.mjs +7 -17
- package/clients/cli/commands/hook.text-projection.test.mjs +45 -0
- package/clients/cli/commands/init.doc.mjs +19 -8
- package/clients/cli/commands/init.flag-help.test.mjs +153 -0
- package/clients/cli/commands/integration-add.controls.test.mjs +132 -0
- package/clients/cli/commands/integration-add.doc.mjs +21 -5
- package/clients/cli/commands/integration-authoring.test.mjs +13 -9
- package/clients/cli/commands/interactive-guard.test.mjs +101 -24
- package/clients/cli/commands/json-contract.test.mjs +33 -0
- package/clients/cli/commands/layout-check.doc.mjs +14 -3
- package/clients/cli/commands/layout-expand.doc.mjs +21 -4
- package/clients/cli/commands/layout.doc.mjs +2 -2
- package/clients/cli/commands/layout.mjs +21 -9
- package/clients/cli/commands/layout.path-help.test.mjs +33 -0
- package/clients/cli/commands/layout.stdin-cap.test.mjs +47 -0
- package/clients/cli/commands/layout.text-fields.test.mjs +39 -0
- package/clients/cli/commands/no-prompt-wording.test.mjs +94 -0
- package/clients/cli/commands/search.doc.mjs +5 -2
- package/clients/cli/commands/search.mjs +13 -2
- package/clients/cli/commands/search.test.mjs +61 -0
- package/clients/cli/commands/swizzle.doc.mjs +2 -1
- package/clients/cli/commands/swizzle.path-safety.test.mjs +42 -0
- package/clients/cli/commands/template.doc.mjs +28 -6
- package/clients/cli/commands/template.flag-help.test.mjs +117 -0
- package/clients/cli/commands/template.path-help.test.mjs +40 -0
- package/clients/cli/commands/theme-add.doc.mjs +2 -1
- package/clients/cli/commands/theme-build.doc.mjs +7 -6
- package/clients/cli/commands/theme-palette-generate.test.mjs +19 -0
- package/clients/cli/commands/theme-template.behavior.test.mjs +12 -0
- package/clients/cli/commands/theme-template.doc.mjs +1 -1
- package/clients/cli/commands/upgrade.ascii-output.test.mjs +87 -0
- package/clients/cli/commands/upgrade.doc.mjs +17 -6
- package/clients/cli/commands/upgrade.flag-help.test.mjs +188 -0
- package/clients/cli/commands/upgrade.hook-output.test.mjs +88 -0
- package/clients/cli/index.mjs +13 -30
- package/clients/cli/latest-version-env.test.mjs +50 -0
- package/clients/cli/lib/cli-error.test.mjs +7 -0
- package/clients/cli/lib/component-format.mjs +9 -9
- package/clients/cli/lib/component-format.test.mjs +1 -1
- package/clients/cli/lib/define-command.mjs +32 -6
- package/clients/cli/lib/doc-text-ascii.test.mjs +82 -0
- package/clients/cli/lib/exit-codes.test.mjs +97 -0
- package/clients/cli/lib/hook-format.mjs +5 -5
- package/clients/cli/lib/json-shim.mjs +38 -2
- package/clients/cli/lib/json-shim.test.mjs +83 -0
- package/clients/cli/lib/manifest.d.ts +2 -0
- package/clients/cli/lib/manifest.mjs +22 -0
- package/clients/cli/lib/manifest.test.mjs +17 -0
- package/foundation/agent-docs/agent-docs.d.mts +4 -0
- package/foundation/agent-docs/agent-docs.mjs +69 -3
- package/foundation/agent-docs/agent-docs.path-safety.test.mjs +266 -4
- package/foundation/config/integration-debug.test.mjs +28 -3
- package/foundation/config/project.mjs +123 -9
- package/foundation/config/project.test.mjs +126 -0
- package/foundation/discovery/authoring-self-docs.test.mjs +71 -12
- package/foundation/discovery/docs-discovery.d.mts +4 -0
- package/foundation/discovery/docs-discovery.mjs +16 -2
- package/foundation/discovery/docs-discovery.test.mjs +47 -11
- package/foundation/discovery/template-adapter.d.mts +14 -5
- package/foundation/discovery/template-adapter.fixture-refs.test.mjs +248 -0
- package/foundation/discovery/template-adapter.integration-isolation.test.mjs +94 -0
- package/foundation/discovery/template-adapter.mjs +292 -25
- package/foundation/discovery/theming-targets.test.mjs +4 -0
- package/foundation/doc-compiler/compile.d.mts +162 -0
- package/foundation/doc-compiler/compile.mjs +262 -0
- package/foundation/doc-compiler/doc-compiler.test.mjs +687 -0
- package/foundation/doc-compiler/ir.d.mts +9 -0
- package/foundation/doc-compiler/ir.mjs +287 -0
- package/foundation/doc-compiler/lenses.d.mts +33 -0
- package/foundation/doc-compiler/lenses.mjs +127 -0
- package/foundation/fs/module-loader.d.mts +1 -0
- package/foundation/fs/module-loader.mjs +50 -1
- package/foundation/fs/module-loader.stdout.test.mjs +332 -0
- package/foundation/fs/path-safety.d.mts +3 -2
- package/foundation/fs/path-safety.mjs +49 -19
- package/foundation/fs/path-safety.test.mjs +50 -0
- package/foundation/fs/publish-file-hardlink-unavailable.test.mjs +129 -94
- package/foundation/integrations/autolink.mjs +6 -1
- package/foundation/response/base.d.ts +8 -4
- package/foundation/response/error-codes.doc.mjs +1 -2
- package/foundation/response/error-codes.mjs +1 -1
- package/foundation/response/error-codes.test.mjs +83 -0
- package/foundation/response/json-contract.test.mjs +11 -0
- package/foundation/response/json.d.mts +4 -2
- package/foundation/response/json.mjs +8 -10
- package/foundation/response/response-types.doc.mjs +3 -3
- package/foundation/xle/expand.d.mts +2 -0
- package/foundation/xle/expand.mjs +3 -2
- package/foundation/xle/expand.test.mjs +54 -0
- package/package.json +9 -11
- package/clients/cli/lib/update-check.mjs +0 -83
- package/clients/cli/lib/update-check.test.mjs +0 -137
- package/clients/cli/update-hint-commands.test.mjs +0 -54
package/api/theme/theme.type.mjs
CHANGED
|
@@ -6,23 +6,23 @@
|
|
|
6
6
|
* directly (functions own their types); the public `@astryxdesign/cli/api`
|
|
7
7
|
* surface re-exports them via types/theme.d.ts, so consumers see the same names.
|
|
8
8
|
*
|
|
9
|
-
* Invocation
|
|
9
|
+
* Invocation -> type discriminator
|
|
10
10
|
* ------------------------------------------------------------------
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* (file not found / parse error)
|
|
11
|
+
* astryx --json theme build <file> -> theme.build
|
|
12
|
+
* astryx --json theme build <file> --check -> theme.build.check
|
|
13
|
+
* astryx --json theme build <a> <b> … -> theme.build.batch
|
|
14
|
+
* astryx --json theme list -> theme.list
|
|
15
|
+
* astryx --json theme add <slug> -> theme.add
|
|
16
|
+
* astryx --json theme template -> theme.template
|
|
17
|
+
* astryx --json theme targets [filter] -> theme.targets
|
|
18
|
+
* astryx --json theme palette generate <file> -> theme.palette.generate
|
|
19
|
+
* (file not found / parse error) -> CLIError
|
|
20
20
|
*
|
|
21
21
|
* @position api — colocated typedefs for api/theme/{theme,build,add,list,template,targets,_adapter}
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
25
|
+
* astryx --json theme build <file>
|
|
26
26
|
* @typedef {object} ThemeBuildResponse
|
|
27
27
|
* @property {'theme.build'} type
|
|
28
28
|
* `warnings` are defects the theme author should fix. `notices` are advisories
|
|
@@ -32,14 +32,14 @@
|
|
|
32
32
|
*/
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
35
|
+
* astryx --json theme build <file> --check
|
|
36
36
|
* @typedef {object} ThemeBuildCheckResponse
|
|
37
37
|
* @property {'theme.build.check'} type
|
|
38
38
|
* @property {{name: string, upToDate: boolean, stale: Array<{path: string, reason: 'missing' | 'outdated'}>, checked: string[]}} data
|
|
39
39
|
*/
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
42
|
+
* astryx --json theme build <a> <b> … — several themes in one invocation. Each
|
|
43
43
|
* result carries the file as it was passed and the receipt a single-file build
|
|
44
44
|
* would have returned (null when that theme produced no CSS). One file still
|
|
45
45
|
* returns the bare theme.build / theme.build.check envelope.
|
|
@@ -59,21 +59,21 @@
|
|
|
59
59
|
*/
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
|
-
*
|
|
62
|
+
* astryx --json theme list
|
|
63
63
|
* @typedef {object} ThemeListResponse
|
|
64
64
|
* @property {'theme.list'} type
|
|
65
65
|
* @property {ThemeListEntry[]} data
|
|
66
66
|
*/
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
|
-
*
|
|
69
|
+
* astryx --json theme add <slug>
|
|
70
70
|
* @typedef {object} ThemeAddResponse
|
|
71
71
|
* @property {'theme.add'} type
|
|
72
72
|
* @property {{slug: string, displayName: string, maintained: boolean, package: string, outputDir: string, entry: string, exportName: string, files: string[]}} data
|
|
73
73
|
*/
|
|
74
74
|
|
|
75
75
|
/**
|
|
76
|
-
*
|
|
76
|
+
* astryx --json theme template
|
|
77
77
|
* `written: false` with `reason: 'exists'` is a success: the command is safe to
|
|
78
78
|
* re-run, and an edited template is the consumer's file to keep.
|
|
79
79
|
* @typedef {object} ThemeTemplateResponse
|
|
@@ -95,19 +95,19 @@
|
|
|
95
95
|
*/
|
|
96
96
|
|
|
97
97
|
/**
|
|
98
|
-
*
|
|
98
|
+
* astryx --json theme targets [filter]
|
|
99
99
|
* @typedef {object} ThemeTargetsResponse
|
|
100
100
|
* @property {'theme.targets'} type
|
|
101
101
|
* @property {{filter: string | null, componentCount: number, targets: ThemeTargetEntry[]}} data
|
|
102
102
|
*/
|
|
103
103
|
|
|
104
104
|
/**
|
|
105
|
-
* A
|
|
106
|
-
* and is not connected to runtime theme values.
|
|
105
|
+
* A color an author pins at one stop of one mode, constraining generation.
|
|
107
106
|
* @typedef {object} TonalPaletteAnchor
|
|
108
107
|
* @property {'light' | 'dark'} mode Mode containing the anchored stop.
|
|
109
108
|
* @property {number} stop Existing requested stop where the anchor applies.
|
|
110
|
-
* @property {string} color
|
|
109
|
+
* @property {string} color sRGB hex the stop is pulled toward: three or six
|
|
110
|
+
* digits, with or without `#`; the generator normalizes it.
|
|
111
111
|
* @property {'exact' | 'bounded' | 'flexible'} policy `exact` preserves the
|
|
112
112
|
* chosen color at that stop; `bounded` permits adjustment within `maxDeltaE`;
|
|
113
113
|
* `flexible` treats the color as guidance and blends toward it.
|
|
@@ -116,12 +116,16 @@
|
|
|
116
116
|
*/
|
|
117
117
|
|
|
118
118
|
/**
|
|
119
|
+
* One requested family: a seed color and the constraints applied to its ramp.
|
|
119
120
|
* @typedef {object} TonalPaletteFamilyInput
|
|
120
|
-
* @property {string} id
|
|
121
|
-
*
|
|
122
|
-
* @property {string}
|
|
123
|
-
*
|
|
124
|
-
* @property {
|
|
121
|
+
* @property {string} id Lower-kebab-case key for the family in the generated
|
|
122
|
+
* palette. `black` and `white` are reserved for the standalone values.
|
|
123
|
+
* @property {string} seed sRGB hex the ramp is generated from: three or six
|
|
124
|
+
* digits, with or without `#`; the generator normalizes it.
|
|
125
|
+
* @property {string} [name] Display name for review artifacts; defaults to `id`.
|
|
126
|
+
* @property {'chromatic' | 'neutral'} [kind] `neutral` derives the ramp from
|
|
127
|
+
* `neutralProfile` instead of the seed hue; defaults to `chromatic`.
|
|
128
|
+
* @property {TonalPaletteAnchor[]} [anchors] Colors pinned at specific stops.
|
|
125
129
|
*/
|
|
126
130
|
|
|
127
131
|
/**
|
|
@@ -130,6 +134,9 @@
|
|
|
130
134
|
* @property {number} [vibrancy] Chroma control from 0 (most muted) through 50
|
|
131
135
|
* (default) to 100 (most vivid).
|
|
132
136
|
* @property {'neutral-v1' | 'warm-v1' | 'cool-v1' | 'custom'} [neutralProfile]
|
|
137
|
+
* Hue treatment for `neutral` families: `neutral-v1` is fully achromatic,
|
|
138
|
+
* `warm-v1` and `cool-v1` add a slight tint, and `custom` derives the hue from
|
|
139
|
+
* the family's own seed. Defaults to `neutral-v1`.
|
|
133
140
|
* @property {'light-only' | 'dark-only' | 'light-and-dark'} [modeStrategy]
|
|
134
141
|
* @property {number[]} [stops] Ordered stops shared by every requested family;
|
|
135
142
|
* defaults to 0 through 100 in increments of 5. Decimal stops are supported,
|
|
@@ -137,6 +144,8 @@
|
|
|
137
144
|
*/
|
|
138
145
|
|
|
139
146
|
/**
|
|
147
|
+
* A generated palette candidate. The palette is still subject to author review
|
|
148
|
+
* and is not connected to runtime theme values.
|
|
140
149
|
* @typedef {object} TonalPaletteCandidate
|
|
141
150
|
* @property {1} schemaVersion
|
|
142
151
|
* @property {'candidate'} status
|
|
@@ -148,10 +157,68 @@
|
|
|
148
157
|
*/
|
|
149
158
|
|
|
150
159
|
/**
|
|
151
|
-
*
|
|
160
|
+
* Per-ramp evidence recorded for one family in one mode.
|
|
161
|
+
* @typedef {object} TonalPaletteRampDiagnostics
|
|
162
|
+
* @property {boolean} monotonic Whether luminance rises across every stop.
|
|
163
|
+
* @property {number} minimumAdjacentDeltaE Smallest perceptual gap between
|
|
164
|
+
* neighboring stops; a small value means two stops read as one color.
|
|
165
|
+
* @property {number} maximumAdjacentDeltaE Largest gap between neighboring stops.
|
|
166
|
+
* @property {number} maximumHueDrift Largest hue distance, in degrees, between
|
|
167
|
+
* a stop and the family's reference hue.
|
|
168
|
+
* @property {'blue-to-purple' | 'yellow-to-brown' | null} hueIdentityRisk Named
|
|
169
|
+
* drift the ramp is at risk of, or `null`.
|
|
170
|
+
* @property {number[]} gamutMappedStops Stops whose ideal color fell outside
|
|
171
|
+
* sRGB and was mapped back into it.
|
|
172
|
+
* @property {Array<TonalPaletteAnchor & {generatedColor: string, deltaE: number}>} anchors
|
|
173
|
+
* Each anchor with the color the stop received after its policy was applied
|
|
174
|
+
* and the perceptual distance that color still has from the requested target.
|
|
175
|
+
*/
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Cross-family evidence for one mode, sampled at the stop nearest 50.
|
|
179
|
+
* @typedef {object} TonalPaletteCoordinationDiagnostics
|
|
180
|
+
* @property {'light' | 'dark'} mode Mode these samples come from.
|
|
181
|
+
* @property {number} stop Sampled stop.
|
|
182
|
+
* @property {[string, string] | null} closestFamilies The two chromatic
|
|
183
|
+
* families hardest to tell apart, or `null` with fewer than two.
|
|
184
|
+
* @property {number | null} minimumFamilyDeltaE Perceptual distance between them.
|
|
185
|
+
* @property {string | null} strongestFamily Most saturated family at this stop.
|
|
186
|
+
* @property {string | null} weakestFamily Least saturated family at this stop.
|
|
187
|
+
* @property {number | null} chromaRatio Strongest chroma over weakest; a large
|
|
188
|
+
* ratio means the families are unbalanced.
|
|
189
|
+
*/
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* The request as the generator resolved it, with every default filled in.
|
|
193
|
+
* @typedef {object} TonalPaletteNormalizedRequest
|
|
194
|
+
* @property {'astryx-oklch-v1'} recipe
|
|
195
|
+
* @property {number} vibrancy
|
|
196
|
+
* @property {'neutral-v1' | 'warm-v1' | 'cool-v1' | 'custom'} neutralProfile
|
|
197
|
+
* @property {'light-only' | 'dark-only' | 'light-and-dark'} modeStrategy
|
|
198
|
+
* @property {number[]} stops
|
|
199
|
+
* @property {Array<{id: string, name: string, seed: string, kind: 'chromatic' | 'neutral', anchors: TonalPaletteAnchor[]}>} families
|
|
200
|
+
*/
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* The detached receipt written beside a candidate. It records what was asked
|
|
204
|
+
* for and what the generator observed, so a candidate can be traced back to
|
|
205
|
+
* its request without rerunning generation.
|
|
206
|
+
* @typedef {object} TonalPaletteGenerationReceipt
|
|
207
|
+
* @property {1} schemaVersion
|
|
208
|
+
* @property {'astryx-oklch-v1'} recipe Recipe that produced the candidate.
|
|
209
|
+
* @property {string} candidateSha256 SHA-256 over the candidate bytes as written.
|
|
210
|
+
* @property {{version: string, sha256: string}} [preview] Present when preview
|
|
211
|
+
* content was generated for the request, even if no file was written because
|
|
212
|
+
* the target already exists.
|
|
213
|
+
* @property {TonalPaletteNormalizedRequest} request
|
|
214
|
+
* @property {{families: Record<string, {light?: TonalPaletteRampDiagnostics, dark?: TonalPaletteRampDiagnostics}>, coordination: TonalPaletteCoordinationDiagnostics[]}} diagnostics
|
|
215
|
+
*/
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* astryx --json theme palette generate <config>
|
|
152
219
|
* @typedef {object} ThemePaletteGenerateResponse
|
|
153
220
|
* @property {'theme.palette.generate'} type
|
|
154
|
-
* @property {{recipe: 'astryx-oklch-v1', status: 'candidate', familyCount: number, stopCount: number, modes: string[], output: string | null, receipt: string | null, preview: string | null, written: boolean, reason: 'exists' | null, candidate: TonalPaletteCandidate, generationReceipt:
|
|
221
|
+
* @property {{recipe: 'astryx-oklch-v1', status: 'candidate', familyCount: number, stopCount: number, modes: string[], output: string | null, receipt: string | null, preview: string | null, written: boolean, reason: 'exists' | null, candidate: TonalPaletteCandidate, generationReceipt: TonalPaletteGenerationReceipt}} data
|
|
155
222
|
*/
|
|
156
223
|
|
|
157
224
|
// Make this a module so the @typedefs above are importable as types via
|
|
@@ -73,7 +73,7 @@ export const doc = {
|
|
|
73
73
|
{
|
|
74
74
|
type: 'theme.build',
|
|
75
75
|
description:
|
|
76
|
-
'Build receipt: theme name
|
|
76
|
+
'Build receipt {name, tokenCount, componentCount, sizeKB, outputs, warnings, notices}: the theme name; how many tokens (portable plus theme-local) and component targets it overrides; the CSS size in KB; the written outputs {css, js, dts, and variantsDts when custom prop values were augmented}; warnings, the defects the author should fix, including exact canonical replacements for deprecated component target keys and declarations the generator dropped; and notices, advisories about a correct theme, such as a font it names but does not load. Resolves to null instead when the theme produced no CSS (nothing to build).',
|
|
77
77
|
},
|
|
78
78
|
{
|
|
79
79
|
type: 'theme.build.check',
|
|
@@ -87,10 +87,13 @@ export const doc = {
|
|
|
87
87
|
code: 'ERR_THEME_LOAD',
|
|
88
88
|
when: 'the file cannot be loaded or parsed into a defineTheme() result',
|
|
89
89
|
},
|
|
90
|
-
{
|
|
90
|
+
{
|
|
91
|
+
code: 'ERR_THEME_INVALID',
|
|
92
|
+
when: 'the resolved theme is invalid, for example it has no name, or a custom Heading type has no standalone rule with a declaration the compiler can emit',
|
|
93
|
+
},
|
|
91
94
|
{
|
|
92
95
|
code: 'ERR_PATH_TRAVERSAL',
|
|
93
|
-
when: 'the theme name contains a path separator or traversal marker',
|
|
96
|
+
when: 'the theme name contains a path separator or traversal marker, or a relative `out` path resolves outside cwd (including through a symlink)',
|
|
94
97
|
},
|
|
95
98
|
{
|
|
96
99
|
code: 'ERR_CORE_NOT_FOUND',
|
|
@@ -102,7 +105,7 @@ export const doc = {
|
|
|
102
105
|
},
|
|
103
106
|
{
|
|
104
107
|
code: 'ERR_WRITE_FAILED',
|
|
105
|
-
when: 'writing the outputs fails (staged temp files are rolled back)',
|
|
108
|
+
when: 'creating the output directory or writing the outputs fails (staged temp files are rolled back)',
|
|
106
109
|
},
|
|
107
110
|
],
|
|
108
111
|
examples: [
|
|
@@ -51,7 +51,10 @@ export const doc = {
|
|
|
51
51
|
'Receipt: the path (relative to cwd), whether it was written, and the reason it was not. `exists` when a file was already there, which is a success, not a failure.',
|
|
52
52
|
},
|
|
53
53
|
],
|
|
54
|
-
throws: [
|
|
54
|
+
throws: [
|
|
55
|
+
{code: 'ERR_PATH_TRAVERSAL', when: 'the target path escapes cwd'},
|
|
56
|
+
{code: 'ERR_WRITE_FAILED', when: 'the template file cannot be written'},
|
|
57
|
+
],
|
|
55
58
|
examples: [
|
|
56
59
|
{label: 'Write it at the project root', code: 'themeTemplate();'},
|
|
57
60
|
{
|
package/api/upgrade/_adapter.mjs
CHANGED
|
@@ -104,6 +104,27 @@ export function uniqueFiles(files) {
|
|
|
104
104
|
];
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
+
/**
|
|
108
|
+
* Run app code with its stdout writes sent to stderr. Stdout carries only the
|
|
109
|
+
* command's own output, so a hook that prints cannot corrupt `--json`.
|
|
110
|
+
* @template T
|
|
111
|
+
* @param {() => T | Promise<T>} fn
|
|
112
|
+
* @returns {Promise<T>}
|
|
113
|
+
*/
|
|
114
|
+
async function withStdoutOnStderr(fn) {
|
|
115
|
+
const realWrite = process.stdout.write;
|
|
116
|
+
process.stdout.write = /** @type {any} */ (
|
|
117
|
+
function (/** @type {any} */ chunk, /** @type {any[]} */ ...rest) {
|
|
118
|
+
return process.stderr.write(chunk, ...rest);
|
|
119
|
+
}
|
|
120
|
+
);
|
|
121
|
+
try {
|
|
122
|
+
return await fn();
|
|
123
|
+
} finally {
|
|
124
|
+
process.stdout.write = realWrite;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
107
128
|
/**
|
|
108
129
|
* Run the app config's post-codemod hooks (config.hooks.postCodemod).
|
|
109
130
|
* Dry-run PREVIEWS (buildCommand still called, so a throw fails); apply executes.
|
|
@@ -123,7 +144,9 @@ export async function runPostCodemodHooks(hooks, context) {
|
|
|
123
144
|
);
|
|
124
145
|
}
|
|
125
146
|
|
|
126
|
-
const cmd = await
|
|
147
|
+
const cmd = await withStdoutOnStderr(() =>
|
|
148
|
+
hook.buildCommand({packageDir, files}),
|
|
149
|
+
);
|
|
127
150
|
if (!cmd) {
|
|
128
151
|
logger.log(`Post-codemod hook ${label} produced no command; skipping.`);
|
|
129
152
|
continue;
|
|
@@ -147,7 +170,7 @@ export async function runPostCodemodHooks(hooks, context) {
|
|
|
147
170
|
env: {...process.env, ...(cmd.options?.env ?? {})},
|
|
148
171
|
}),
|
|
149
172
|
);
|
|
150
|
-
logger.log(
|
|
173
|
+
logger.log(`[ok] Post-codemod hook ${label} completed.`);
|
|
151
174
|
}
|
|
152
175
|
}
|
|
153
176
|
|
|
@@ -186,7 +209,7 @@ export async function prepareAgentDocsRefresh({
|
|
|
186
209
|
if (initial.status === 'missing') {
|
|
187
210
|
summary.action = 'nudge-init';
|
|
188
211
|
logger.warn(
|
|
189
|
-
`No Astryx agent-docs block found
|
|
212
|
+
`No Astryx agent-docs block found - AI agents have no component index. Run \`${formatCliCommand('astryx init --features agents')}\` to install it.`,
|
|
190
213
|
);
|
|
191
214
|
return {cwd, renderedBlock: null, summary};
|
|
192
215
|
}
|
|
@@ -240,7 +263,7 @@ export function applyAgentDocsRefresh(plan) {
|
|
|
240
263
|
summary.files = written;
|
|
241
264
|
summary.action = summary.refreshed ? 'refreshed' : 'error';
|
|
242
265
|
if (summary.refreshed) {
|
|
243
|
-
logger.log(
|
|
266
|
+
logger.log(`[ok] Agent docs refreshed -> ${written.join(', ')}`);
|
|
244
267
|
} else {
|
|
245
268
|
logger.warn(
|
|
246
269
|
`Agent docs look stale but couldn't be refreshed. Run \`${formatCliCommand('astryx init --features agents')}\` to reinstall the block.`,
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
import {collectAllCodemods} from '../_adapter.mjs';
|
|
12
12
|
import {logger} from '../../logger.mjs';
|
|
13
|
+
import {toAscii} from '../../../assets/codemods/term-log.mjs';
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* List every available codemod (oldest→newest).
|
|
@@ -19,7 +20,7 @@ export async function list() {
|
|
|
19
20
|
const codemods = await collectAllCodemods();
|
|
20
21
|
logger.log('Available codemods:');
|
|
21
22
|
for (const {name, title, pr, optional} of codemods) {
|
|
22
|
-
logger.log(` ${name}
|
|
23
|
+
logger.log(` ${name} - ${toAscii(title)}${optional ? ' (optional)' : ''} (${pr})`);
|
|
23
24
|
}
|
|
24
25
|
logger.log('Done\n');
|
|
25
26
|
return {
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Colocated tests for the upgrade.list leaf: every field an entry
|
|
5
|
+
* carries is declared on the canonical `UpgradeListEntry` type, and every
|
|
6
|
+
* declared field is present on every entry.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {describe, it, expect} from 'vitest';
|
|
10
|
+
import * as fs from 'node:fs';
|
|
11
|
+
import {fileURLToPath} from 'node:url';
|
|
12
|
+
import ts from 'typescript';
|
|
13
|
+
import {list} from './list.mjs';
|
|
14
|
+
|
|
15
|
+
const TYPE_FILE = fileURLToPath(
|
|
16
|
+
new URL('../upgrade.type.mjs', import.meta.url),
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Property names a JSDoc `@typedef {object}` declares, parsed from the file.
|
|
21
|
+
* @param {string} typedefName
|
|
22
|
+
* @returns {string[]}
|
|
23
|
+
*/
|
|
24
|
+
function declaredProperties(typedefName) {
|
|
25
|
+
const source = ts.createSourceFile(
|
|
26
|
+
TYPE_FILE,
|
|
27
|
+
fs.readFileSync(TYPE_FILE, 'utf8'),
|
|
28
|
+
ts.ScriptTarget.Latest,
|
|
29
|
+
true,
|
|
30
|
+
ts.ScriptKind.JS,
|
|
31
|
+
);
|
|
32
|
+
/** @type {string[]} */
|
|
33
|
+
const names = [];
|
|
34
|
+
for (const statement of source.statements) {
|
|
35
|
+
for (const doc of /** @type {any} */ (statement).jsDoc ?? []) {
|
|
36
|
+
for (const tag of doc.tags ?? []) {
|
|
37
|
+
if (
|
|
38
|
+
!ts.isJSDocTypedefTag(tag) ||
|
|
39
|
+
tag.name?.getText(source) !== typedefName
|
|
40
|
+
) {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
const literal = tag.typeExpression;
|
|
44
|
+
if (literal && ts.isJSDocTypeLiteral(literal)) {
|
|
45
|
+
for (const property of literal.jsDocPropertyTags ?? []) {
|
|
46
|
+
names.push(property.name.getText(source));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return names.sort();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
describe('upgrade.list entries', () => {
|
|
56
|
+
it('carry exactly the fields UpgradeListEntry declares', async () => {
|
|
57
|
+
const declared = declaredProperties('UpgradeListEntry');
|
|
58
|
+
expect(declared.length).toBeGreaterThan(0);
|
|
59
|
+
|
|
60
|
+
const {type, data} = await list();
|
|
61
|
+
expect(type).toBe('upgrade.list');
|
|
62
|
+
expect(data.length).toBeGreaterThan(0);
|
|
63
|
+
for (const entry of data) {
|
|
64
|
+
expect(Object.keys(entry).sort()).toEqual(declared);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('marks optional codemods with a boolean', async () => {
|
|
69
|
+
const {data} = await list();
|
|
70
|
+
for (const entry of data) expect(typeof entry.optional).toBe('boolean');
|
|
71
|
+
expect(data.some(entry => entry.optional)).toBe(true);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
@@ -24,7 +24,7 @@ import {logger} from '../../logger.mjs';
|
|
|
24
24
|
* @returns {import('../upgrade.type.mjs').UpgradeStatusResponse}
|
|
25
25
|
*/
|
|
26
26
|
export function statusUpToDate({from, to, agentDocs, registryCompositions}) {
|
|
27
|
-
logger.log('
|
|
27
|
+
logger.log('[ok] Already up to date - no codemods to run.');
|
|
28
28
|
logger.log('Use --force to run codemods anyway.');
|
|
29
29
|
logger.log(registryCompositions?.ok === false ? 'Finished with unresolved registry items\n' : 'Done\n');
|
|
30
30
|
return {
|
|
@@ -45,7 +45,7 @@ export function statusUpToDate({from, to, agentDocs, registryCompositions}) {
|
|
|
45
45
|
* @returns {import('../upgrade.type.mjs').UpgradeStatusResponse}
|
|
46
46
|
*/
|
|
47
47
|
export function statusNoCodemods({from, to, agentDocs, registryCompositions}) {
|
|
48
|
-
logger.log('
|
|
48
|
+
logger.log('[ok] No codemods available for this version range.');
|
|
49
49
|
logger.log(registryCompositions?.ok === false ? 'Finished with unresolved registry items\n' : 'Done\n');
|
|
50
50
|
return {
|
|
51
51
|
type: 'upgrade.status',
|
|
@@ -80,7 +80,8 @@ export const doc = {
|
|
|
80
80
|
{
|
|
81
81
|
name: 'options.installDeps',
|
|
82
82
|
type: 'boolean',
|
|
83
|
-
description:
|
|
83
|
+
description:
|
|
84
|
+
'Install jscodeshift when it is missing; otherwise a missing jscodeshift throws ERR_DEP_MISSING.',
|
|
84
85
|
},
|
|
85
86
|
{
|
|
86
87
|
name: 'options.registry',
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* astryx --json upgrade --list
|
|
6
6
|
*/
|
|
7
7
|
export type UpgradeListResponse = {
|
|
8
8
|
type: "upgrade.list";
|
|
@@ -12,6 +12,10 @@ export type UpgradeListEntry = {
|
|
|
12
12
|
name: string;
|
|
13
13
|
title: string;
|
|
14
14
|
version: string;
|
|
15
|
+
/**
|
|
16
|
+
* True when the codemod runs only if named with `--codemod`.
|
|
17
|
+
*/
|
|
18
|
+
optional: boolean;
|
|
15
19
|
};
|
|
16
20
|
/**
|
|
17
21
|
* State of the managed agent-docs block (`<!-- ASTRYX:START --> … END -->`)
|
|
@@ -121,14 +125,14 @@ export type RegistryCompositionSummary = {
|
|
|
121
125
|
items: RegistryCompositionItemSummary[];
|
|
122
126
|
};
|
|
123
127
|
/**
|
|
124
|
-
*
|
|
128
|
+
* astryx --json upgrade --registry [--apply]
|
|
125
129
|
*/
|
|
126
130
|
export type UpgradeRegistryResponse = {
|
|
127
131
|
type: "upgrade.registry";
|
|
128
132
|
data: RegistryCompositionSummary;
|
|
129
133
|
};
|
|
130
134
|
/**
|
|
131
|
-
*
|
|
135
|
+
* astryx --json upgrade [--apply]
|
|
132
136
|
*/
|
|
133
137
|
export type UpgradeRunResponse = {
|
|
134
138
|
type: "upgrade.run";
|
|
@@ -150,7 +154,7 @@ export type UpgradeRunResponse = {
|
|
|
150
154
|
};
|
|
151
155
|
};
|
|
152
156
|
/**
|
|
153
|
-
*
|
|
157
|
+
* astryx --json upgrade — short-circuit status results.
|
|
154
158
|
*
|
|
155
159
|
* - `up_to_date`: `--from` is >= installed target and `--force` was not passed.
|
|
156
160
|
* - `no_codemods`: no codemods (core or integration) apply to the range.
|
|
@@ -4,17 +4,17 @@
|
|
|
4
4
|
* @file Colocated types for the `upgrade` command — source of truth for the
|
|
5
5
|
* upgrade command JSON responses. Re-exported by `types/upgrade.d.ts`.
|
|
6
6
|
*
|
|
7
|
-
* Invocation
|
|
7
|
+
* Invocation -> type discriminator
|
|
8
8
|
* ------------------------------------------------------------------
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* (version detection failure)
|
|
9
|
+
* astryx --json upgrade --list -> upgrade.list
|
|
10
|
+
* astryx --json upgrade [--apply] -> upgrade.run
|
|
11
|
+
* astryx --json upgrade --registry [--apply] -> upgrade.registry
|
|
12
|
+
* astryx --json upgrade (status short-circuit) -> upgrade.status
|
|
13
|
+
* (version detection failure) -> CLIError
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* astryx --json upgrade --list
|
|
18
18
|
* @typedef {object} UpgradeListResponse
|
|
19
19
|
* @property {'upgrade.list'} type
|
|
20
20
|
* @property {UpgradeListEntry[]} data
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
* @property {string} name
|
|
26
26
|
* @property {string} title
|
|
27
27
|
* @property {string} version
|
|
28
|
+
* @property {boolean} optional True when the codemod runs only if named with `--codemod`.
|
|
28
29
|
*/
|
|
29
30
|
|
|
30
31
|
/**
|
|
@@ -88,14 +89,14 @@
|
|
|
88
89
|
*/
|
|
89
90
|
|
|
90
91
|
/**
|
|
91
|
-
*
|
|
92
|
+
* astryx --json upgrade --registry [--apply]
|
|
92
93
|
* @typedef {object} UpgradeRegistryResponse
|
|
93
94
|
* @property {'upgrade.registry'} type
|
|
94
95
|
* @property {RegistryCompositionSummary} data
|
|
95
96
|
*/
|
|
96
97
|
|
|
97
98
|
/**
|
|
98
|
-
*
|
|
99
|
+
* astryx --json upgrade [--apply]
|
|
99
100
|
* @typedef {object} UpgradeRunResponse
|
|
100
101
|
* @property {'upgrade.run'} type
|
|
101
102
|
* @property {object} data
|
|
@@ -112,7 +113,7 @@
|
|
|
112
113
|
*/
|
|
113
114
|
|
|
114
115
|
/**
|
|
115
|
-
*
|
|
116
|
+
* astryx --json upgrade — short-circuit status results.
|
|
116
117
|
*
|
|
117
118
|
* - `up_to_date`: `--from` is >= installed target and `--force` was not passed.
|
|
118
119
|
* - `no_codemods`: no codemods (core or integration) apply to the range.
|
|
@@ -32,6 +32,40 @@ import {semverCompare} from '../../foundation/env/semver.mjs';
|
|
|
32
32
|
/** File extensions recognized as codemod modules. */
|
|
33
33
|
const CODEMOD_EXTENSIONS = ['.ts', '.mjs', '.js'];
|
|
34
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Directories never walked for codemods: a test directory beside a transform is
|
|
37
|
+
* the natural place to put its test, and every file found here is loaded and
|
|
38
|
+
* validated as a codemod.
|
|
39
|
+
*/
|
|
40
|
+
const SKIP_DIRS = new Set([
|
|
41
|
+
'node_modules',
|
|
42
|
+
'.git',
|
|
43
|
+
'__tests__',
|
|
44
|
+
'__fixtures__',
|
|
45
|
+
]);
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Whether a file name is a test or fixture rather than a codemod.
|
|
49
|
+
*
|
|
50
|
+
* The trap this closes: EVERY `.ts`/`.mjs`/`.js` under a version folder used to
|
|
51
|
+
* be loaded as a codemod, so a test file colocated with its transform failed
|
|
52
|
+
* validation and — because a definition error is a hard error — took every
|
|
53
|
+
* codemod in that package's version with it. `astryx upgrade` then applied no
|
|
54
|
+
* transforms and reported success, which is the worst shape a failure can take.
|
|
55
|
+
*
|
|
56
|
+
* Core's own codemods never hit this: they are enumerated in a registry, and
|
|
57
|
+
* their colocated tests are simply not in it. Only integrations are discovered
|
|
58
|
+
* by walking a directory, so only integrations carry the landmine — which is why
|
|
59
|
+
* this is a loader fix and not a documentation one. It protects the integrations
|
|
60
|
+
* that already exist, which no authoring tool can reach.
|
|
61
|
+
*
|
|
62
|
+
* @param {string} name a file's base name
|
|
63
|
+
* @returns {boolean}
|
|
64
|
+
*/
|
|
65
|
+
function isTestFile(name) {
|
|
66
|
+
return /\.(test|spec)\.[^.]+$/.test(name) || /\.fixture\.[^.]+$/.test(name);
|
|
67
|
+
}
|
|
68
|
+
|
|
35
69
|
/**
|
|
36
70
|
* Recursively collect codemod module files under a version folder. Returns
|
|
37
71
|
* entries of {id, file} where id is the extension-less relative path
|
|
@@ -49,14 +83,18 @@ function collectCodemodFiles(versionDir) {
|
|
|
49
83
|
for (const entry of entries) {
|
|
50
84
|
const full = path.join(dir, entry.name);
|
|
51
85
|
if (entry.isDirectory()) {
|
|
52
|
-
if (
|
|
86
|
+
if (SKIP_DIRS.has(entry.name)) continue;
|
|
53
87
|
walk(full);
|
|
54
88
|
continue;
|
|
55
89
|
}
|
|
56
90
|
const ext = path.extname(entry.name);
|
|
57
91
|
if (!CODEMOD_EXTENSIONS.includes(ext)) continue;
|
|
92
|
+
if (isTestFile(entry.name)) continue;
|
|
58
93
|
const rel = path.relative(versionDir, full);
|
|
59
|
-
const id = rel
|
|
94
|
+
const id = rel
|
|
95
|
+
.slice(0, rel.length - ext.length)
|
|
96
|
+
.split(path.sep)
|
|
97
|
+
.join('/');
|
|
60
98
|
out.push({id, file: full});
|
|
61
99
|
}
|
|
62
100
|
}
|