@astryxdesign/cli 0.6.3-canary.dea6813 → 0.6.3-canary.e7819e0
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 +18 -32
- package/api/build/build.doc.mjs +3 -3
- package/api/build/build.test.mjs +3 -14
- package/api/build/build.type.d.mts +1 -35
- package/api/build/build.type.mjs +3 -24
- package/api/build/help/help.d.mts +5 -8
- package/api/build/help/help.mjs +6 -56
- package/api/component/component.doc.mjs +2 -11
- package/api/component/component.mjs +0 -29
- package/api/component/component.test.mjs +0 -38
- package/api/component/component.type.d.mts +1 -11
- package/api/component/component.type.mjs +1 -8
- package/api/discover/discover.doc.mjs +1 -1
- package/api/gap-report/gap-report.doc.mjs +4 -7
- package/api/init/init.doc.mjs +0 -4
- package/api/init/init.test.mjs +1 -41
- package/api/init/remove/remove.mjs +1 -1
- package/api/init/run/run.mjs +10 -20
- package/api/integration/add-contribution.mjs +0 -11
- package/api/integration/add-contribution.test.mjs +0 -80
- package/api/integration/integrationAdd.doc.mjs +4 -7
- package/api/integration/integrationAddComponent.doc.mjs +1 -1
- package/api/integration/validate-integration.mjs +0 -2
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/json/parseResponse.doc.mjs +2 -2
- package/api/layout/expand/expand.mjs +5 -7
- package/api/layout/grammar/grammar.mjs +1 -2
- package/api/layout/layoutExpand.doc.mjs +1 -1
- package/api/search/search.d.mts +9 -2
- package/api/search/search.doc.mjs +1 -5
- package/api/search/search.mjs +3 -10
- package/api/search/search.test.mjs +0 -34
- package/api/swizzle/copy/copy.mjs +11 -28
- package/api/swizzle/swizzle.doc.mjs +1 -1
- package/api/template/copy/copy.mjs +23 -17
- package/api/template/copy/copy.test.mjs +0 -17
- package/api/template/template.doc.mjs +1 -2
- package/api/theme/add/add.mjs +3 -20
- package/api/theme/build/build.mjs +37 -114
- package/api/theme/build/build.public-component-vars.test.mjs +1 -1
- package/api/theme/build/font-warning.mjs +3 -3
- package/api/theme/build/font-warning.test.mjs +2 -5
- package/api/theme/palette/generate/generate.mjs +2 -7
- package/api/theme/palette/generate/generate.test.mjs +0 -96
- package/api/theme/palette/generate/generator.mjs +1 -8
- package/api/theme/palette/generate/generator.test.mjs +0 -10
- package/api/theme/template/template.mjs +2 -11
- package/api/theme/template/template.test.mjs +0 -15
- package/api/theme/themeBuild.doc.mjs +4 -7
- package/api/theme/themeTemplate.doc.mjs +1 -4
- package/api/upgrade/_adapter.mjs +4 -27
- package/api/upgrade/list/list.mjs +1 -2
- package/api/upgrade/status/status.mjs +2 -2
- package/api/upgrade/upgrade.doc.mjs +1 -2
- package/api/upgrade/upgrade.type.d.mts +0 -4
- package/api/upgrade/upgrade.type.mjs +0 -1
- package/assets/codemods/term-log.mjs +8 -32
- package/assets/codemods/term-log.test.mjs +1 -19
- package/assets/codemods/transforms/v0.6.0/__tests__/next-codemods.test.mjs +0 -47
- package/assets/codemods/transforms/v0.6.0/rename-resizable-pixel-bounds.mjs +10 -57
- package/authoring/config/config.doc.mjs +1 -1
- package/authoring/config/type.ts +3 -15
- package/clients/cli/commands/blog.mjs +8 -23
- package/clients/cli/commands/blog.test.mjs +1 -42
- package/clients/cli/commands/build-theme.mjs +5 -5
- package/clients/cli/commands/build-theme.path-safety.test.mjs +1 -86
- package/clients/cli/commands/build-theme.variants.test.mjs +0 -76
- package/clients/cli/commands/build.doc.mjs +1 -4
- package/clients/cli/commands/build.mjs +47 -32
- package/clients/cli/commands/component/index.mjs +7 -2
- package/clients/cli/commands/component-package.test.mjs +0 -18
- package/clients/cli/commands/component-resolution.test.mjs +0 -21
- package/clients/cli/commands/component.test.mjs +0 -19
- package/clients/cli/commands/detail-levels.test.mjs +2 -2
- package/clients/cli/commands/discover.broken-integration.test.mjs +0 -48
- package/clients/cli/commands/discover.doc.mjs +2 -4
- package/clients/cli/commands/discover.mjs +3 -3
- package/clients/cli/commands/doctor.mjs +16 -6
- package/clients/cli/commands/doctor.test.mjs +0 -42
- package/clients/cli/commands/gap-report.doc.mjs +5 -16
- package/clients/cli/commands/gap-report.test.mjs +0 -72
- package/clients/cli/commands/hook/index.mjs +17 -7
- package/clients/cli/commands/init.doc.mjs +8 -19
- package/clients/cli/commands/integration-add.doc.mjs +5 -21
- package/clients/cli/commands/interactive-guard.test.mjs +24 -101
- package/clients/cli/commands/json-contract.test.mjs +0 -33
- package/clients/cli/commands/layout-check.doc.mjs +3 -14
- package/clients/cli/commands/layout-expand.doc.mjs +4 -21
- package/clients/cli/commands/layout.doc.mjs +2 -2
- package/clients/cli/commands/layout.mjs +9 -21
- package/clients/cli/commands/search.doc.mjs +3 -6
- package/clients/cli/commands/search.mjs +7 -17
- package/clients/cli/commands/search.test.mjs +0 -75
- package/clients/cli/commands/swizzle.doc.mjs +1 -2
- package/clients/cli/commands/swizzle.path-safety.test.mjs +0 -42
- package/clients/cli/commands/template.doc.mjs +6 -28
- package/clients/cli/commands/theme-add.doc.mjs +1 -2
- package/clients/cli/commands/theme-build.doc.mjs +6 -7
- package/clients/cli/commands/theme-palette-generate.test.mjs +0 -19
- package/clients/cli/commands/theme-template.behavior.test.mjs +0 -12
- package/clients/cli/commands/theme-template.doc.mjs +1 -1
- package/clients/cli/commands/upgrade.doc.mjs +6 -17
- package/clients/cli/index.mjs +30 -13
- package/clients/cli/lib/cli-error.test.mjs +0 -7
- 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 +6 -32
- package/clients/cli/lib/hook-format.mjs +5 -5
- package/clients/cli/lib/json-shim.mjs +2 -38
- package/clients/cli/lib/json-shim.test.mjs +0 -83
- package/clients/cli/lib/manifest.d.ts +0 -2
- package/clients/cli/lib/manifest.mjs +0 -22
- package/clients/cli/lib/manifest.test.mjs +0 -17
- package/clients/cli/lib/update-check.mjs +83 -0
- package/clients/cli/lib/update-check.test.mjs +137 -0
- package/clients/cli/update-hint-commands.test.mjs +54 -0
- package/foundation/agent-docs/agent-docs.d.mts +0 -4
- package/foundation/agent-docs/agent-docs.mjs +3 -69
- package/foundation/agent-docs/agent-docs.path-safety.test.mjs +4 -266
- package/foundation/config/integration-debug.test.mjs +3 -28
- package/foundation/config/project.mjs +9 -123
- package/foundation/config/project.test.mjs +0 -126
- package/foundation/discovery/template-adapter.d.mts +5 -14
- package/foundation/discovery/template-adapter.mjs +25 -292
- package/foundation/fs/module-loader.d.mts +0 -1
- package/foundation/fs/module-loader.mjs +1 -50
- package/foundation/fs/publish-file-hardlink-unavailable.test.mjs +94 -129
- package/foundation/integrations/autolink.mjs +1 -6
- package/foundation/response/base.d.ts +4 -8
- package/foundation/response/error-codes.doc.mjs +2 -1
- package/foundation/response/error-codes.mjs +1 -1
- package/foundation/response/error-codes.test.mjs +0 -83
- package/foundation/response/json-contract.test.mjs +0 -11
- package/foundation/response/json.d.mts +2 -4
- package/foundation/response/json.mjs +10 -8
- package/foundation/response/response-types.doc.mjs +3 -3
- package/foundation/xle/expand.d.mts +0 -2
- package/foundation/xle/expand.mjs +2 -3
- package/package.json +9 -9
- package/api/integration/add-contribution.component-names.test.mjs +0 -120
- package/api/json/envelope-types.test.mjs +0 -76
- package/api/layout/expand/expand.path-safety.test.mjs +0 -53
- package/api/search/search-return-type.test.mjs +0 -54
- package/api/theme/add/add.binary.test.mjs +0 -91
- package/api/theme/add/add.staging.test.mjs +0 -66
- package/api/theme/build/build.receipt-doc.test.mjs +0 -111
- package/api/upgrade/list/list.test.mjs +0 -73
- package/authoring/config/debug-composition.test.mjs +0 -92
- package/clients/cli/command-load-failure.test.mjs +0 -83
- package/clients/cli/commands/build-theme.ascii-output.test.mjs +0 -161
- package/clients/cli/commands/build-theme.flag-docs.test.mjs +0 -110
- package/clients/cli/commands/build.exit-codes-doc.test.mjs +0 -50
- package/clients/cli/commands/build.playbook.test.mjs +0 -75
- package/clients/cli/commands/build.text-fields.test.mjs +0 -40
- package/clients/cli/commands/discover.components-flag.test.mjs +0 -97
- package/clients/cli/commands/discover.text-projection.test.mjs +0 -103
- package/clients/cli/commands/doctor-integration.package-json.test.mjs +0 -53
- package/clients/cli/commands/hook.text-projection.test.mjs +0 -45
- package/clients/cli/commands/init.flag-help.test.mjs +0 -153
- package/clients/cli/commands/integration-add.controls.test.mjs +0 -132
- package/clients/cli/commands/layout.path-help.test.mjs +0 -33
- package/clients/cli/commands/layout.stdin-cap.test.mjs +0 -47
- package/clients/cli/commands/layout.text-fields.test.mjs +0 -39
- package/clients/cli/commands/no-prompt-wording.test.mjs +0 -94
- package/clients/cli/commands/template.flag-help.test.mjs +0 -117
- package/clients/cli/commands/template.path-help.test.mjs +0 -40
- package/clients/cli/commands/upgrade.ascii-output.test.mjs +0 -87
- package/clients/cli/commands/upgrade.flag-help.test.mjs +0 -188
- package/clients/cli/commands/upgrade.hook-output.test.mjs +0 -88
- package/clients/cli/latest-version-env.test.mjs +0 -50
- package/clients/cli/lib/doc-text-ascii.test.mjs +0 -82
- package/clients/cli/lib/exit-codes.test.mjs +0 -97
- package/foundation/discovery/template-adapter.fixture-refs.test.mjs +0 -248
- package/foundation/discovery/template-adapter.integration-isolation.test.mjs +0 -94
- package/foundation/fs/module-loader.stdout.test.mjs +0 -332
- package/foundation/xle/expand.test.mjs +0 -54
|
@@ -51,10 +51,7 @@ 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: [
|
|
55
|
-
{code: 'ERR_PATH_TRAVERSAL', when: 'the target path escapes cwd'},
|
|
56
|
-
{code: 'ERR_WRITE_FAILED', when: 'the template file cannot be written'},
|
|
57
|
-
],
|
|
54
|
+
throws: [{code: 'ERR_PATH_TRAVERSAL', when: 'the target path escapes cwd'}],
|
|
58
55
|
examples: [
|
|
59
56
|
{label: 'Write it at the project root', code: 'themeTemplate();'},
|
|
60
57
|
{
|
package/api/upgrade/_adapter.mjs
CHANGED
|
@@ -104,27 +104,6 @@ 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
|
-
|
|
128
107
|
/**
|
|
129
108
|
* Run the app config's post-codemod hooks (config.hooks.postCodemod).
|
|
130
109
|
* Dry-run PREVIEWS (buildCommand still called, so a throw fails); apply executes.
|
|
@@ -144,9 +123,7 @@ export async function runPostCodemodHooks(hooks, context) {
|
|
|
144
123
|
);
|
|
145
124
|
}
|
|
146
125
|
|
|
147
|
-
const cmd = await
|
|
148
|
-
hook.buildCommand({packageDir, files}),
|
|
149
|
-
);
|
|
126
|
+
const cmd = await hook.buildCommand({packageDir, files});
|
|
150
127
|
if (!cmd) {
|
|
151
128
|
logger.log(`Post-codemod hook ${label} produced no command; skipping.`);
|
|
152
129
|
continue;
|
|
@@ -170,7 +147,7 @@ export async function runPostCodemodHooks(hooks, context) {
|
|
|
170
147
|
env: {...process.env, ...(cmd.options?.env ?? {})},
|
|
171
148
|
}),
|
|
172
149
|
);
|
|
173
|
-
logger.log(
|
|
150
|
+
logger.log(`✓ Post-codemod hook ${label} completed.`);
|
|
174
151
|
}
|
|
175
152
|
}
|
|
176
153
|
|
|
@@ -209,7 +186,7 @@ export async function prepareAgentDocsRefresh({
|
|
|
209
186
|
if (initial.status === 'missing') {
|
|
210
187
|
summary.action = 'nudge-init';
|
|
211
188
|
logger.warn(
|
|
212
|
-
`No Astryx agent-docs block found
|
|
189
|
+
`No Astryx agent-docs block found — AI agents have no component index. Run \`${formatCliCommand('astryx init --features agents')}\` to install it.`,
|
|
213
190
|
);
|
|
214
191
|
return {cwd, renderedBlock: null, summary};
|
|
215
192
|
}
|
|
@@ -263,7 +240,7 @@ export function applyAgentDocsRefresh(plan) {
|
|
|
263
240
|
summary.files = written;
|
|
264
241
|
summary.action = summary.refreshed ? 'refreshed' : 'error';
|
|
265
242
|
if (summary.refreshed) {
|
|
266
|
-
logger.log(
|
|
243
|
+
logger.log(`✓ Agent docs refreshed → ${written.join(', ')}`);
|
|
267
244
|
} else {
|
|
268
245
|
logger.warn(
|
|
269
246
|
`Agent docs look stale but couldn't be refreshed. Run \`${formatCliCommand('astryx init --features agents')}\` to reinstall the block.`,
|
|
@@ -10,7 +10,6 @@
|
|
|
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';
|
|
14
13
|
|
|
15
14
|
/**
|
|
16
15
|
* List every available codemod (oldest→newest).
|
|
@@ -20,7 +19,7 @@ export async function list() {
|
|
|
20
19
|
const codemods = await collectAllCodemods();
|
|
21
20
|
logger.log('Available codemods:');
|
|
22
21
|
for (const {name, title, pr, optional} of codemods) {
|
|
23
|
-
logger.log(` ${name}
|
|
22
|
+
logger.log(` ${name} — ${title}${optional ? ' (optional)' : ''} (${pr})`);
|
|
24
23
|
}
|
|
25
24
|
logger.log('Done\n');
|
|
26
25
|
return {
|
|
@@ -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('✓ 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('✓ 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,8 +80,7 @@ export const doc = {
|
|
|
80
80
|
{
|
|
81
81
|
name: 'options.installDeps',
|
|
82
82
|
type: 'boolean',
|
|
83
|
-
description:
|
|
84
|
-
'Install jscodeshift when it is missing; otherwise a missing jscodeshift throws ERR_DEP_MISSING.',
|
|
83
|
+
description: 'Auto-install jscodeshift without prompting.',
|
|
85
84
|
},
|
|
86
85
|
{
|
|
87
86
|
name: 'options.registry',
|
|
@@ -12,10 +12,6 @@ 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;
|
|
19
15
|
};
|
|
20
16
|
/**
|
|
21
17
|
* State of the managed agent-docs block (`<!-- ASTRYX:START --> … END -->`)
|
|
@@ -11,8 +11,6 @@
|
|
|
11
11
|
* `p.log.step(...)`, `p.log.success(...)`, etc. All output routes through
|
|
12
12
|
* `humanLog`, the CLI's stdout-discipline primitive, which is a no-op in
|
|
13
13
|
* `--json` mode — so these human logs can never corrupt a JSON envelope.
|
|
14
|
-
* Every line is plain ASCII: level prefixes are ASCII and typographic glyphs
|
|
15
|
-
* in a message are transliterated before it is printed.
|
|
16
14
|
*
|
|
17
15
|
* The side-effecting API commands (upgrade/init/themeBuild) do NOT use this;
|
|
18
16
|
* they write through the shared `logger` (api/logger.mjs).
|
|
@@ -20,30 +18,8 @@
|
|
|
20
18
|
|
|
21
19
|
import {humanLog} from '../../foundation/response/json.mjs';
|
|
22
20
|
|
|
23
|
-
/** @
|
|
24
|
-
const
|
|
25
|
-
[/[\u2014\u2013]/g, '-'],
|
|
26
|
-
[/\u2192/g, '->'],
|
|
27
|
-
[/\u2713/g, '[ok]'],
|
|
28
|
-
[/\u2717/g, '!!'],
|
|
29
|
-
[/\u26a0\ufe0f?/g, '!'],
|
|
30
|
-
[/\u2022/g, '-'],
|
|
31
|
-
[/\u2026/g, '...'],
|
|
32
|
-
[/[\u2018\u2019]/g, "'"],
|
|
33
|
-
[/[\u201c\u201d]/g, '"'],
|
|
34
|
-
[/\u00a0/g, ' '],
|
|
35
|
-
];
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* A message as plain ASCII: typographic glyphs become their ASCII spelling.
|
|
39
|
-
* @param {unknown} msg
|
|
40
|
-
* @returns {string}
|
|
41
|
-
*/
|
|
42
|
-
export function toAscii(msg) {
|
|
43
|
-
let text = msg === undefined || msg === null ? '' : String(msg);
|
|
44
|
-
for (const [glyph, ascii] of ASCII_GLYPHS) text = text.replace(glyph, ascii);
|
|
45
|
-
return text;
|
|
46
|
-
}
|
|
21
|
+
/** @param {unknown} msg */
|
|
22
|
+
const toStr = (msg) => (msg === undefined || msg === null ? '' : String(msg));
|
|
47
23
|
|
|
48
24
|
/**
|
|
49
25
|
* Human-facing log surface (the small `log` API codemods use). All lines go to
|
|
@@ -52,15 +28,15 @@ export function toAscii(msg) {
|
|
|
52
28
|
*/
|
|
53
29
|
export const log = {
|
|
54
30
|
/** @param {unknown} msg */
|
|
55
|
-
message: (msg) => humanLog(
|
|
31
|
+
message: (msg) => humanLog(toStr(msg)),
|
|
56
32
|
/** @param {unknown} msg */
|
|
57
|
-
info: (msg) => humanLog(
|
|
33
|
+
info: (msg) => humanLog(toStr(msg)),
|
|
58
34
|
/** @param {unknown} msg */
|
|
59
|
-
step: (msg) => humanLog(
|
|
35
|
+
step: (msg) => humanLog(toStr(msg)),
|
|
60
36
|
/** @param {unknown} msg */
|
|
61
|
-
success: (msg) => humanLog(
|
|
37
|
+
success: (msg) => humanLog(`✓ ${toStr(msg)}`),
|
|
62
38
|
/** @param {unknown} msg */
|
|
63
|
-
warn: (msg) => humanLog(
|
|
39
|
+
warn: (msg) => humanLog(`⚠ ${toStr(msg)}`),
|
|
64
40
|
/** @param {unknown} msg */
|
|
65
|
-
error: (msg) => humanLog(
|
|
41
|
+
error: (msg) => humanLog(`✗ ${toStr(msg)}`),
|
|
66
42
|
};
|
|
@@ -51,7 +51,7 @@ describe('sanity: helpers are live in human mode', () => {
|
|
|
51
51
|
setJsonMode(false);
|
|
52
52
|
p.log.success('done');
|
|
53
53
|
expect(logSpy).toHaveBeenCalledTimes(1);
|
|
54
|
-
expect(logSpy).toHaveBeenCalledWith('
|
|
54
|
+
expect(logSpy).toHaveBeenCalledWith('✓ done');
|
|
55
55
|
});
|
|
56
56
|
|
|
57
57
|
it('every log helper emits exactly one stdout line in human mode', () => {
|
|
@@ -60,21 +60,3 @@ describe('sanity: helpers are live in human mode', () => {
|
|
|
60
60
|
expect(logSpy).toHaveBeenCalledTimes(6);
|
|
61
61
|
});
|
|
62
62
|
});
|
|
63
|
-
|
|
64
|
-
describe('ASCII output', () => {
|
|
65
|
-
it('prints ASCII level prefixes and transliterates glyphs in messages', () => {
|
|
66
|
-
setJsonMode(false);
|
|
67
|
-
p.log.success('src/a.tsx');
|
|
68
|
-
p.log.warn('stale \u2014 refresh');
|
|
69
|
-
p.log.error(' \u2717 src/b.tsx \u2014 rename \u2192 failed');
|
|
70
|
-
p.log.info(' \u2022 name \u2014 title\u2026');
|
|
71
|
-
const lines = logSpy.mock.calls.map(call => call.join(' '));
|
|
72
|
-
expect(lines).toEqual([
|
|
73
|
-
'[ok] src/a.tsx',
|
|
74
|
-
'! stale - refresh',
|
|
75
|
-
'!! !! src/b.tsx - rename -> failed',
|
|
76
|
-
' - name - title...',
|
|
77
|
-
]);
|
|
78
|
-
for (const line of lines) expect(line).not.toMatch(/[\u0080-\uFFFF]/);
|
|
79
|
-
});
|
|
80
|
-
});
|
|
@@ -220,51 +220,4 @@ function wrapper(useResizable) {
|
|
|
220
220
|
const output = await apply('rename-resizable-pixel-bounds', input);
|
|
221
221
|
expect(output).toBe(input);
|
|
222
222
|
});
|
|
223
|
-
|
|
224
|
-
it('renames bounds when useResizable comes from a namespace import', async () => {
|
|
225
|
-
const input = `import * as Astryx from '@astryxdesign/core';
|
|
226
|
-
const region = Astryx.useResizable({defaultSize: 240, minSizePx: 120, maxSizePx: 480});`;
|
|
227
|
-
const output = await apply('rename-resizable-pixel-bounds', input);
|
|
228
|
-
expect(output).toContain('minSize: 120');
|
|
229
|
-
expect(output).toContain('maxSize: 480');
|
|
230
|
-
expect(output).not.toContain('minSizePx');
|
|
231
|
-
expect(output).not.toContain('maxSizePx');
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
it('leaves a namespace that does not come from Astryx alone', async () => {
|
|
235
|
-
const input = `import * as Other from 'other-resizable';
|
|
236
|
-
const region = Other.useResizable({minSizePx: 120});`;
|
|
237
|
-
const output = await apply('rename-resizable-pixel-bounds', input);
|
|
238
|
-
expect(output).toContain('minSizePx: 120');
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
it('does not rewrite a parameter that shadows the namespace import', async () => {
|
|
242
|
-
const input = `import * as Astryx from '@astryxdesign/core';
|
|
243
|
-
function build(Astryx) {
|
|
244
|
-
return Astryx.useResizable({minSizePx: 120});
|
|
245
|
-
}`;
|
|
246
|
-
const output = await apply('rename-resizable-pixel-bounds', input);
|
|
247
|
-
expect(output).toContain('minSizePx: 120');
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
it.each([
|
|
251
|
-
['as const', '{defaultSize: 240, minSizePx: 120} as const'],
|
|
252
|
-
['satisfies', '{defaultSize: 240, minSizePx: 120} satisfies object'],
|
|
253
|
-
])('renames a static configuration wrapped in %s', async (_label, config) => {
|
|
254
|
-
const input = `import {useResizable} from '@astryxdesign/core/Resizable';
|
|
255
|
-
const region = useResizable(${config});`;
|
|
256
|
-
const output = await apply('rename-resizable-pixel-bounds', input);
|
|
257
|
-
expect(output).toContain('minSize: 120');
|
|
258
|
-
expect(output).not.toContain('minSizePx');
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
it('renames wrapped multi-region configurations', async () => {
|
|
262
|
-
const input = `import {useResizable} from '@astryxdesign/core';
|
|
263
|
-
const regions = useResizable({regions: {
|
|
264
|
-
nav: {defaultSize: 240, minSizePx: 120} as const,
|
|
265
|
-
} as const});`;
|
|
266
|
-
const output = await apply('rename-resizable-pixel-bounds', input);
|
|
267
|
-
expect(output).toContain('minSize: 120');
|
|
268
|
-
expect(output).not.toContain('minSizePx');
|
|
269
|
-
});
|
|
270
223
|
});
|
|
@@ -8,9 +8,6 @@
|
|
|
8
8
|
* released conflict rule (the unified property wins when both are present).
|
|
9
9
|
* A spread or computed property can change precedence invisibly, so dynamic
|
|
10
10
|
* objects stay unchanged and receive a manual-migration TODO instead.
|
|
11
|
-
* Named and namespace imports both count, and a type-only wrapper (`as`,
|
|
12
|
-
* `satisfies`, a non-null assertion, parentheses) does not make a
|
|
13
|
-
* configuration dynamic.
|
|
14
11
|
*/
|
|
15
12
|
|
|
16
13
|
export const meta = {
|
|
@@ -36,26 +33,6 @@ const MANUAL_MIGRATION_COMMENT =
|
|
|
36
33
|
'or computed property. Rename minSizePx/maxSizePx to minSize/maxSize ' +
|
|
37
34
|
'manually without changing property precedence. ';
|
|
38
35
|
|
|
39
|
-
const TYPE_WRAPPERS = new Set([
|
|
40
|
-
'TSAsExpression',
|
|
41
|
-
'TSSatisfiesExpression',
|
|
42
|
-
'TSTypeAssertion',
|
|
43
|
-
'TSNonNullExpression',
|
|
44
|
-
'ParenthesizedExpression',
|
|
45
|
-
]);
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* The expression under type-only wrappers such as `{...} as const`.
|
|
49
|
-
* @param {any} node
|
|
50
|
-
*/
|
|
51
|
-
function unwrap(node) {
|
|
52
|
-
let current = node;
|
|
53
|
-
while (current && TYPE_WRAPPERS.has(current.type)) {
|
|
54
|
-
current = current.expression;
|
|
55
|
-
}
|
|
56
|
-
return current;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
36
|
/** @param {any} property */
|
|
60
37
|
function staticPropertyName(property) {
|
|
61
38
|
if (property.computed) return null;
|
|
@@ -151,8 +128,6 @@ export default function transformer(file, api) {
|
|
|
151
128
|
const root = j(file.source);
|
|
152
129
|
/** @type {Map<string, any>} */
|
|
153
130
|
const bindings = new Map();
|
|
154
|
-
/** @type {Map<string, any>} */
|
|
155
|
-
const namespaces = new Map();
|
|
156
131
|
|
|
157
132
|
root.find(j.ImportDeclaration).forEach((/** @type {any} */ path) => {
|
|
158
133
|
if (!IMPORT_SOURCES.has(path.node.source.value)) return;
|
|
@@ -163,40 +138,17 @@ export default function transformer(file, api) {
|
|
|
163
138
|
) {
|
|
164
139
|
const local = specifier.local?.name ?? 'useResizable';
|
|
165
140
|
bindings.set(local, path.scope.lookup(local) ?? path.scope);
|
|
166
|
-
} else if (specifier.type === 'ImportNamespaceSpecifier') {
|
|
167
|
-
const local = specifier.local.name;
|
|
168
|
-
namespaces.set(local, path.scope.lookup(local) ?? path.scope);
|
|
169
141
|
}
|
|
170
142
|
}
|
|
171
143
|
});
|
|
172
|
-
if (bindings.size === 0
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* @param {any} callee
|
|
176
|
-
* @param {any} scope
|
|
177
|
-
*/
|
|
178
|
-
const isUseResizable = (callee, scope) => {
|
|
179
|
-
if (callee.type === 'Identifier') {
|
|
180
|
-
return (
|
|
181
|
-
bindings.has(callee.name) &&
|
|
182
|
-
scope.lookup(callee.name) === bindings.get(callee.name)
|
|
183
|
-
);
|
|
184
|
-
}
|
|
185
|
-
return (
|
|
186
|
-
callee.type === 'MemberExpression' &&
|
|
187
|
-
!callee.computed &&
|
|
188
|
-
callee.object.type === 'Identifier' &&
|
|
189
|
-
callee.property.type === 'Identifier' &&
|
|
190
|
-
callee.property.name === 'useResizable' &&
|
|
191
|
-
namespaces.has(callee.object.name) &&
|
|
192
|
-
scope.lookup(callee.object.name) === namespaces.get(callee.object.name)
|
|
193
|
-
);
|
|
194
|
-
};
|
|
144
|
+
if (bindings.size === 0) return undefined;
|
|
195
145
|
|
|
196
146
|
let changed = false;
|
|
197
147
|
root.find(j.CallExpression).forEach((/** @type {any} */ path) => {
|
|
198
|
-
|
|
199
|
-
|
|
148
|
+
const callee = path.node.callee;
|
|
149
|
+
if (callee.type !== 'Identifier' || !bindings.has(callee.name)) return;
|
|
150
|
+
if (path.scope.lookup(callee.name) !== bindings.get(callee.name)) return;
|
|
151
|
+
const config = path.node.arguments[0];
|
|
200
152
|
if (config?.type !== 'ObjectExpression') return;
|
|
201
153
|
|
|
202
154
|
changed = migrateObject(j, config) || changed;
|
|
@@ -206,12 +158,13 @@ export default function transformer(file, api) {
|
|
|
206
158
|
staticPropertyName(property) === 'regions',
|
|
207
159
|
);
|
|
208
160
|
if (!regions || !('value' in regions)) return;
|
|
209
|
-
const regionsObject =
|
|
161
|
+
const regionsObject = regions.value;
|
|
210
162
|
if (regionsObject?.type !== 'ObjectExpression') return;
|
|
211
163
|
for (const region of regionsObject.properties) {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
164
|
+
if (!('value' in region) || region.value?.type !== 'ObjectExpression') {
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
changed = migrateObject(j, region.value) || changed;
|
|
215
168
|
}
|
|
216
169
|
});
|
|
217
170
|
|
|
@@ -48,7 +48,7 @@ export const doc = {
|
|
|
48
48
|
name: 'debug',
|
|
49
49
|
type: '(event: DebugEvent) => void',
|
|
50
50
|
description:
|
|
51
|
-
'Record every command run. The handler is synchronous; promises are not awaited and output goes to stderr. Declare `debug` directly in this file so early commands can discover it. An integration can supply one too, as a `debug` named export from its manifest
|
|
51
|
+
'Record every command run. The handler is synchronous; promises are not awaited and output goes to stderr. Declare `debug` directly in this file so early commands can discover it. An integration can supply one too, as a `debug` named export from its manifest — both run; set `{"astryx": {"inheritDebug": false}}` in package.json to take only your own.',
|
|
52
52
|
example:
|
|
53
53
|
"event => appendFileSync('runs.ndjson', JSON.stringify(event) + '\\n')",
|
|
54
54
|
},
|
package/authoring/config/type.ts
CHANGED
|
@@ -56,9 +56,8 @@ export interface XleComponent {
|
|
|
56
56
|
/**
|
|
57
57
|
* Record every astryx command run in this project.
|
|
58
58
|
*
|
|
59
|
-
* A function that receives each run.
|
|
60
|
-
*
|
|
61
|
-
* combine and how to refuse inherited handlers.
|
|
59
|
+
* A function that receives each run. Setting it is the whole opt-in; leave it
|
|
60
|
+
* out and nothing is recorded.
|
|
62
61
|
*
|
|
63
62
|
* ```
|
|
64
63
|
* export default {
|
|
@@ -81,18 +80,7 @@ export interface AstryxConfig {
|
|
|
81
80
|
hooks?: {
|
|
82
81
|
postCodemod?: PostCodemodHook[];
|
|
83
82
|
};
|
|
84
|
-
/**
|
|
85
|
-
* Record every astryx command run in this project. See {@link DebugConfig}.
|
|
86
|
-
*
|
|
87
|
-
* An integration can contribute a handler too, as a `debug` named export
|
|
88
|
-
* from its `astryx.integration.*` module. Every handler receives the run:
|
|
89
|
-
* this one first, then each integration's in load order (the ones
|
|
90
|
-
* `integrations` lists, in that order, then autolinked ones). A handler that
|
|
91
|
-
* throws is skipped; the others still run and the command's result does not
|
|
92
|
-
* change. To refuse inherited handlers, set
|
|
93
|
-
* `{"astryx": {"inheritDebug": false}}` in the project's package.json; this
|
|
94
|
-
* handler still runs.
|
|
95
|
-
*/
|
|
83
|
+
/** Record every astryx command run in this project. See {@link DebugConfig}. */
|
|
96
84
|
debug?: DebugConfig;
|
|
97
85
|
/** Route gap reports through a project-owned handler. See {@link GapReportHandler}. */
|
|
98
86
|
gapReport?: GapReportHandler;
|
|
@@ -24,18 +24,6 @@ import {resultSet} from '../../../foundation/debug/index.mjs';
|
|
|
24
24
|
import {doc as blogCommand} from './blog.doc.mjs';
|
|
25
25
|
import {doc as blogFn} from '../../../api/blog/blog.doc.mjs';
|
|
26
26
|
|
|
27
|
-
/** Every field of a post in the JSON, in order; record() skips empty ones. */
|
|
28
|
-
const POST_FIELDS = [
|
|
29
|
-
'slug',
|
|
30
|
-
'title',
|
|
31
|
-
'description',
|
|
32
|
-
'date',
|
|
33
|
-
'type',
|
|
34
|
-
'authors',
|
|
35
|
-
'link',
|
|
36
|
-
'textUrl',
|
|
37
|
-
];
|
|
38
|
-
|
|
39
27
|
/**
|
|
40
28
|
* @param {import('commander').Command} program
|
|
41
29
|
*/
|
|
@@ -74,25 +62,22 @@ export function registerBlog(program) {
|
|
|
74
62
|
const {feedUrl, posts} = result.data;
|
|
75
63
|
if (posts.length === 0) {
|
|
76
64
|
emit(
|
|
77
|
-
section('Astryx blog'),
|
|
78
|
-
record({feedUrl}),
|
|
65
|
+
section('Astryx blog', `feed: ${feedUrl}`),
|
|
79
66
|
text('No posts found in the feed.'),
|
|
80
67
|
);
|
|
81
68
|
return answered;
|
|
82
69
|
}
|
|
70
|
+
// One record per post — fields mirror the JSON post shape; empty
|
|
71
|
+
// fields (type/textUrl) are skipped by record().
|
|
83
72
|
emit(
|
|
84
|
-
section('Astryx blog'),
|
|
85
|
-
|
|
86
|
-
records(posts, {fields: POST_FIELDS}),
|
|
73
|
+
section('Astryx blog', `feed: ${feedUrl}`),
|
|
74
|
+
records(posts, {fields: ['slug', 'title', 'type', 'textUrl']}),
|
|
87
75
|
text(`Read one: ${run} astryx blog <slug>`),
|
|
88
76
|
);
|
|
89
77
|
} else {
|
|
90
|
-
// blog.detail — the
|
|
91
|
-
//
|
|
92
|
-
emit(
|
|
93
|
-
record(result.data, {fields: [...POST_FIELDS, 'feedUrl']}),
|
|
94
|
-
code(result.data.text),
|
|
95
|
-
);
|
|
78
|
+
// blog.detail — the feed URL, then the post body emitted verbatim
|
|
79
|
+
// (code() so article typography/spacing isn't ASCII-normalized).
|
|
80
|
+
emit(record({feed: result.data.feedUrl}), code(result.data.text));
|
|
96
81
|
}
|
|
97
82
|
return answered;
|
|
98
83
|
},
|
|
@@ -19,10 +19,7 @@ const FEED = `<?xml version="1.0" encoding="UTF-8"?>
|
|
|
19
19
|
<item>
|
|
20
20
|
<title>How Astryx works</title>
|
|
21
21
|
<link>${SITE_URL}/blog/how-astryx-works</link>
|
|
22
|
-
<description>Under the hood & more</description>
|
|
23
22
|
<category>engineering</category>
|
|
24
|
-
<author>Ada</author>
|
|
25
|
-
<author>Grace</author>
|
|
26
23
|
<pubDate>Mon, 29 Jun 2026 00:00:00 GMT</pubDate>
|
|
27
24
|
<atom:link rel="alternate" type="text/plain" href="${SITE_URL}/blog/how-astryx-works.txt" />
|
|
28
25
|
</item>
|
|
@@ -42,23 +39,6 @@ function stubFetch(routes) {
|
|
|
42
39
|
});
|
|
43
40
|
}
|
|
44
41
|
|
|
45
|
-
/**
|
|
46
|
-
* Every non-empty field prints as a `key: value` line under its JSON key.
|
|
47
|
-
* @param {string} stdout
|
|
48
|
-
* @param {Record<string, unknown>} fields
|
|
49
|
-
*/
|
|
50
|
-
function expectFields(stdout, fields) {
|
|
51
|
-
const lines = stdout.split('\n');
|
|
52
|
-
for (const [key, value] of Object.entries(fields)) {
|
|
53
|
-
if (value == null || value === '' || (Array.isArray(value) && !value.length)) continue;
|
|
54
|
-
const shown = Array.isArray(value) ? value.join(', ') : String(value);
|
|
55
|
-
expect(
|
|
56
|
-
lines.some(line => line.startsWith(`${key}:`) && line.trimEnd().endsWith(shown)),
|
|
57
|
-
`${key}: ${shown}`,
|
|
58
|
-
).toBe(true);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
42
|
beforeEach(() => {
|
|
63
43
|
vi.stubGlobal(
|
|
64
44
|
'fetch',
|
|
@@ -103,31 +83,10 @@ describe('blog CLI — json-enabled', () => {
|
|
|
103
83
|
const {status, stdout} = await runCli(['blog']);
|
|
104
84
|
expect(status).toBe(0);
|
|
105
85
|
expect(stdout).toMatch(/Astryx blog/);
|
|
106
|
-
expect(stdout).toMatch(
|
|
86
|
+
expect(stdout).toMatch(/feed:/);
|
|
107
87
|
expect(stdout).toMatch(/how-astryx-works/);
|
|
108
88
|
});
|
|
109
89
|
|
|
110
|
-
it('the text list projects every JSON field under its JSON key', async () => {
|
|
111
|
-
const env = JSON.parse((await runCli(['blog', '--json'])).stdout);
|
|
112
|
-
const {status, stdout} = await runCli(['blog']);
|
|
113
|
-
expect(status).toBe(0);
|
|
114
|
-
expectFields(stdout, {feedUrl: env.data.feedUrl});
|
|
115
|
-
for (const post of env.data.posts) expectFields(stdout, post);
|
|
116
|
-
expect(stdout).not.toMatch(/^feed:/m);
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it('the text detail projects every JSON field, then the post body', async () => {
|
|
120
|
-
const env = JSON.parse(
|
|
121
|
-
(await runCli(['blog', 'how-astryx-works', '--json'])).stdout,
|
|
122
|
-
);
|
|
123
|
-
const {status, stdout} = await runCli(['blog', 'how-astryx-works']);
|
|
124
|
-
expect(status).toBe(0);
|
|
125
|
-
const {text, ...fields} = env.data;
|
|
126
|
-
expectFields(stdout, fields);
|
|
127
|
-
expect(stdout).toContain(text);
|
|
128
|
-
expect(stdout).not.toMatch(/^feed:/m);
|
|
129
|
-
});
|
|
130
|
-
|
|
131
90
|
it('surfaces the API error code and exits non-zero for an unknown slug (--json)', async () => {
|
|
132
91
|
const {status, stdout} = await runCli(['blog', 'no-such-post', '--json']);
|
|
133
92
|
expect(status).not.toBe(0);
|
|
@@ -369,7 +369,7 @@ export function registerTheme(program) {
|
|
|
369
369
|
emit(
|
|
370
370
|
section(
|
|
371
371
|
'Palette candidate',
|
|
372
|
-
`${result.data.familyCount} families
|
|
372
|
+
`${result.data.familyCount} families · ${result.data.stopCount} stops · ${result.data.modes.join(', ')}`,
|
|
373
373
|
),
|
|
374
374
|
code(serializePaletteCandidate(result.data.candidate).trimEnd()),
|
|
375
375
|
);
|
|
@@ -426,7 +426,7 @@ export function registerTheme(program) {
|
|
|
426
426
|
{
|
|
427
427
|
name: `astryx theme build ${entry.file.replace(/['"]/g, '')}`,
|
|
428
428
|
reason:
|
|
429
|
-
'globs are expanded by your shell
|
|
429
|
+
'globs are expanded by your shell — pass the pattern unquoted, or list the files',
|
|
430
430
|
},
|
|
431
431
|
]
|
|
432
432
|
: undefined,
|
|
@@ -491,7 +491,7 @@ export function registerTheme(program) {
|
|
|
491
491
|
// Non-watch: delegate to the API compiler, once per theme, in argument
|
|
492
492
|
// order. Enable human output unless in --json mode (log → stdout via
|
|
493
493
|
// humanLog, warn/error → stderr). The "Building theme from" line, the
|
|
494
|
-
//
|
|
494
|
+
// ✓/warning lines, and the install instructions are all emitted from
|
|
495
495
|
// inside themeBuild via the shared logger.
|
|
496
496
|
logger.setSilent(json);
|
|
497
497
|
|
|
@@ -574,8 +574,8 @@ export function registerTheme(program) {
|
|
|
574
574
|
emit(
|
|
575
575
|
text(
|
|
576
576
|
options.check
|
|
577
|
-
? `\n${stale ? '
|
|
578
|
-
: `\n
|
|
577
|
+
? `\n${stale ? '✗' : '✓'} Checked ${entries.length} themes.`
|
|
578
|
+
: `\n✓ Built ${entries.length} themes.`,
|
|
579
579
|
),
|
|
580
580
|
);
|
|
581
581
|
}
|