@astryxdesign/cli 0.7.0-canary.693da50 → 0.7.0-canary.81dc9bb
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 +21 -26
- package/api/build/build.mjs +9 -0
- package/api/component/_adapter.d.mts +2 -0
- package/api/component/_adapter.mjs +3 -1
- package/api/component/component.doc.mjs +5 -1
- package/api/docs/compiled-topics.test.mjs +16 -0
- package/api/doctor/doctor.doc.mjs +1 -1
- package/api/doctor/doctor.test.mjs +28 -0
- package/api/doctor/theme-checks.mjs +10 -10
- package/api/doctor/theme-checks.test.mjs +5 -4
- package/api/gap-report/gap-report.doc.mjs +1 -1
- package/api/gap-report/gap-report.mjs +15 -0
- package/api/gap-report/gap-report.test.mjs +1 -1
- package/api/index.d.mts +0 -2
- package/api/index.mjs +0 -2
- package/api/init/init.doc.mjs +5 -1
- package/api/init/init.mjs +22 -0
- package/api/init/init.type.d.mts +4 -1
- package/api/init/init.type.mjs +1 -1
- package/api/init/remove/remove.mjs +8 -3
- package/api/init/remove/remove.test.mjs +12 -0
- package/api/init/run/run.d.mts +1 -1
- package/api/init/run/run.mjs +3 -3
- package/api/integration/validate-integration.d.mts +4 -0
- package/api/integration/validate-integration.mjs +5 -2
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/json/index.ts +0 -1
- package/api/search/search.doc.mjs +1 -1
- package/api/search/search.mjs +1 -1
- package/api/search/search.test.mjs +1 -1
- package/api/search/search.type.d.mts +1 -1
- package/api/search/search.type.mjs +1 -1
- package/api/template/list/list.mjs +23 -2
- package/api/template/list/list.test.mjs +52 -0
- package/api/template/template-integration.test.mjs +37 -100
- package/api/template/template.doc.mjs +7 -2
- package/api/template/template.mjs +45 -0
- package/api/theme/_adapter.mjs +3 -3
- package/api/theme/add/add.d.mts +11 -5
- package/api/theme/add/add.mjs +19 -192
- package/api/theme/add/add.test.mjs +68 -258
- package/api/theme/add/add.types.test.mjs +0 -1
- package/api/theme/build/build.d.mts +3 -3
- package/api/theme/build/build.mjs +22 -36
- package/api/theme/build/build.test.mjs +11 -24
- package/api/theme/eject/eject.copy-compat.test.mjs +168 -0
- package/api/theme/integration-themes.test.mjs +3 -3
- package/api/theme/remove/remove.test.mjs +1 -1
- package/api/theme/targets/targets.test.mjs +0 -4
- package/api/theme/template/template.mjs +1 -1
- package/api/theme/theme.type.d.mts +1 -30
- package/api/theme/theme.type.mjs +3 -13
- package/api/theme/themeAdd.doc.mjs +19 -27
- package/api/theme/themeTargets.doc.mjs +3 -4
- package/api/theme/themeTemplate.doc.mjs +1 -1
- package/api/theme/use/use.test.mjs +1 -1
- package/api/upgrade/upgrade.doc.mjs +1 -1
- package/api/upgrade/upgrade.mjs +19 -0
- package/assets/codemods/transforms/next/__tests__/migrate-deprecated-theme-surface.test.mjs +322 -0
- package/assets/codemods/transforms/next/index.mjs +11 -1
- package/assets/codemods/transforms/next/migrate-deprecated-theme-surface-v0.6-data.mjs +229 -0
- package/assets/codemods/transforms/next/migrate-deprecated-theme-surface.mjs +624 -0
- package/assets/codemods/transforms/v0.6.0/migrate-astryx-theme-selectors-to-data-attrs.mjs +38 -18
- package/assets/docs/author-a-theme.doc.mjs +4 -4
- package/assets/docs/getting-started.doc.mjs +2 -2
- package/assets/docs/theme.doc.dense.mjs +1 -1
- package/assets/docs/theme.doc.mjs +2 -2
- package/assets/docs/tree/add-a-theme.doc.mjs +1 -1
- package/assets/docs/tree/document-the-theme.doc.mjs +2 -2
- package/assets/docs/tree/fonts-and-assets.doc.mjs +3 -3
- package/assets/docs/tree/styling-advanced.doc.mjs +21 -14
- package/assets/docs/tree/themes.doc.mjs +1 -1
- package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +2 -2
- package/assets/docs/tree/versioning.doc.mjs +1 -4
- package/assets/docs/use-a-theme.doc.mjs +16 -16
- package/authoring/debug/type.ts +2 -2
- package/authoring/doctypes/base/type.ts +0 -9
- package/authoring/integration/integration.doc.mjs +1 -1
- package/clients/cli/command-result-coverage.test.mjs +1 -1
- package/clients/cli/commands/build-theme.adaptations.test.mjs +4 -0
- package/clients/cli/commands/build-theme.ascii-output.test.mjs +35 -8
- package/clients/cli/commands/build-theme.mjs +31 -67
- package/clients/cli/commands/build-theme.registry.test.mjs +0 -10
- package/clients/cli/commands/build.doc.mjs +1 -1
- package/clients/cli/commands/build.mjs +1 -1
- package/clients/cli/commands/component-ownership.test.mjs +2 -2
- package/clients/cli/commands/debug-result-summary.test.mjs +0 -16
- package/clients/cli/commands/discover.mjs +2 -1
- package/clients/cli/commands/doctor.mjs +5 -2
- package/clients/cli/commands/empty-argument.test.mjs +16 -0
- package/clients/cli/commands/gap-report.doc.mjs +1 -1
- package/clients/cli/commands/gap-report.test.mjs +2 -2
- package/clients/cli/commands/init.doc.mjs +4 -4
- package/clients/cli/commands/init.flag-help.test.mjs +7 -10
- package/clients/cli/commands/init.next-steps.test.mjs +1 -1
- package/clients/cli/commands/integration.mjs +2 -1
- package/clients/cli/commands/option-pair-refusals.test.mjs +37 -0
- package/clients/cli/commands/search.test.mjs +1 -1
- package/clients/cli/commands/silent-success-refusals.test.mjs +15 -0
- package/clients/cli/commands/swizzle.mjs +4 -1
- package/clients/cli/commands/template.doc.mjs +4 -4
- package/clients/cli/commands/template.flag-help.test.mjs +18 -11
- package/clients/cli/commands/template.mjs +7 -1
- package/clients/cli/commands/text-json-parity.test.mjs +0 -17
- package/clients/cli/commands/theme-add-lifecycle.test.mjs +142 -49
- package/clients/cli/commands/theme-add.doc.mjs +10 -17
- package/clients/cli/commands/theme-list.behavior.test.mjs +2 -1
- package/clients/cli/commands/theme-targets.behavior.test.mjs +8 -6
- package/clients/cli/commands/theme-template.doc.mjs +1 -1
- package/clients/cli/commands/theme.doc.mjs +2 -2
- package/clients/cli/commands/upgrade.doc.mjs +1 -1
- package/clients/cli/commands/upgrade.flag-help.test.mjs +7 -11
- package/clients/cli/commands/validate-nothing-exits-nonzero.test.mjs +67 -0
- package/clients/cli/index.mjs +0 -4
- package/clients/cli/lib/cli-error.mjs +19 -0
- package/clients/cli/lib/component-format.mjs +111 -57
- package/clients/cli/lib/component-format.test.mjs +28 -39
- package/clients/cli/lib/doc-text-ascii.test.mjs +5 -2
- package/clients/cli/lib/exit-codes.test.mjs +0 -7
- package/clients/cli/lib/json-shim.test.mjs +0 -24
- package/foundation/agent-docs/agent-docs.d.mts +2 -1
- package/foundation/agent-docs/agent-docs.mjs +6 -1
- package/foundation/agent-docs/app-theme-workflow.test.mjs +3 -0
- package/foundation/config/theme-state.mjs +3 -3
- package/foundation/debug/debug-fields.test.mjs +13 -35
- package/foundation/debug/event.mjs +13 -78
- package/foundation/debug/privacy-contract.test.mjs +20 -12
- package/foundation/debug/redact.d.mts +2 -2
- package/foundation/debug/redact.mjs +2 -2
- package/foundation/discovery/theme-imports.mjs +1 -1
- package/foundation/discovery/theming-targets.d.mts +1 -20
- package/foundation/discovery/theming-targets.mjs +1 -38
- package/foundation/discovery/theming-targets.test.mjs +9 -175
- package/foundation/doc-compiler/doc-loads.test.mjs +0 -12
- package/foundation/response/error-codes.doc.mjs +1 -1
- package/foundation/response/response-types.doc.mjs +11 -30
- package/foundation/response/response-types.doc.test.mjs +36 -14
- package/foundation/response/response.doc.mjs +1 -1
- package/foundation/xle/browser.d.mts +2 -2
- package/foundation/xle/browser.mjs +2 -2
- package/foundation/xle/expand.mjs +1 -1
- package/foundation/xle/print.mjs +1 -1
- package/package.json +9 -9
- package/api/layout/_adapter.d.mts +0 -34
- package/api/layout/_adapter.mjs +0 -148
- package/api/layout/check/check.d.mts +0 -17
- package/api/layout/check/check.mjs +0 -41
- package/api/layout/expand/expand.d.mts +0 -23
- package/api/layout/expand/expand.mjs +0 -161
- package/api/layout/expand/expand.path-safety.test.mjs +0 -53
- package/api/layout/expand/expand.receipt.test.mjs +0 -74
- package/api/layout/grammar/grammar.d.mts +0 -14
- package/api/layout/grammar/grammar.mjs +0 -88
- package/api/layout/layout.d.mts +0 -6
- package/api/layout/layout.mjs +0 -17
- package/api/layout/layout.test.mjs +0 -297
- package/api/layout/layout.type.d.mts +0 -90
- package/api/layout/layout.type.mjs +0 -104
- package/api/layout/layoutCheck.doc.d.mts +0 -11
- package/api/layout/layoutCheck.doc.mjs +0 -85
- package/api/layout/layoutExpand.doc.d.mts +0 -11
- package/api/layout/layoutExpand.doc.mjs +0 -107
- package/api/layout/layoutGrammar.doc.d.mts +0 -11
- package/api/layout/layoutGrammar.doc.mjs +0 -57
- package/api/theme/add/add.binary.test.mjs +0 -157
- package/api/theme/add/add.rollback.test.mjs +0 -158
- package/api/theme/add/add.staging.test.mjs +0 -83
- package/clients/cli/commands/layout-check.doc.mjs +0 -67
- package/clients/cli/commands/layout-expand.doc.mjs +0 -87
- package/clients/cli/commands/layout-grammar.doc.mjs +0 -32
- package/clients/cli/commands/layout.deprecation-lifecycle.test.mjs +0 -140
- package/clients/cli/commands/layout.doc.mjs +0 -36
- package/clients/cli/commands/layout.error-codes.test.mjs +0 -66
- package/clients/cli/commands/layout.exit-parity.test.mjs +0 -41
- package/clients/cli/commands/layout.expand-receipt.test.mjs +0 -94
- package/clients/cli/commands/layout.mjs +0 -327
- 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/README.md
CHANGED
|
@@ -78,24 +78,23 @@ Options:
|
|
|
78
78
|
|
|
79
79
|
<!-- BEGIN GENERATED: commands -->
|
|
80
80
|
|
|
81
|
-
| Command | Description
|
|
82
|
-
| ------------- |
|
|
83
|
-
| `blog` | Read the Astryx blog from the published feed
|
|
84
|
-
| `build` | Build a page: the template to start from, or the workflow playbook (no query)
|
|
85
|
-
| `component` | List components or print component docs
|
|
86
|
-
| `discover` | Browse and search integrations: the ones you have and the ones you could add
|
|
87
|
-
| `docs` | Print reference docs
|
|
88
|
-
| `doctor` | Diagnose Astryx projects and integration packages
|
|
89
|
-
| `gap-report` | Report a missing component or feature to the package that owns it
|
|
90
|
-
| `hook` | List hooks or print hook docs
|
|
91
|
-
| `init` | Initialize the design system in your project
|
|
92
|
-
| `integration` | Author and verify an Astryx integration package
|
|
93
|
-
| `
|
|
94
|
-
| `
|
|
95
|
-
| `
|
|
96
|
-
| `
|
|
97
|
-
| `
|
|
98
|
-
| `upgrade` | Update your code after upgrading Astryx, and refresh ShadCN-copied components |
|
|
81
|
+
| Command | Description |
|
|
82
|
+
| ------------- | ----------------------------------------------------------------------------- |
|
|
83
|
+
| `blog` | Read the Astryx blog from the published feed |
|
|
84
|
+
| `build` | Build a page: the template to start from, or the workflow playbook (no query) |
|
|
85
|
+
| `component` | List components or print component docs |
|
|
86
|
+
| `discover` | Browse and search integrations: the ones you have and the ones you could add |
|
|
87
|
+
| `docs` | Print reference docs |
|
|
88
|
+
| `doctor` | Diagnose Astryx projects and integration packages |
|
|
89
|
+
| `gap-report` | Report a missing component or feature to the package that owns it |
|
|
90
|
+
| `hook` | List hooks or print hook docs |
|
|
91
|
+
| `init` | Initialize the design system in your project |
|
|
92
|
+
| `integration` | Author and verify an Astryx integration package |
|
|
93
|
+
| `search` | Search components, hooks, docs, templates, and themes in one ranked list |
|
|
94
|
+
| `swizzle` | Copy component source for customization |
|
|
95
|
+
| `template` | List, show, or scaffold page and block templates |
|
|
96
|
+
| `theme` | Add, switch, build, and author themes |
|
|
97
|
+
| `upgrade` | Update your code after upgrading Astryx, and refresh ShadCN-copied components |
|
|
99
98
|
|
|
100
99
|
<!-- END GENERATED: commands -->
|
|
101
100
|
<!-- Generated by scripts/generate-cli-readme.mjs from `astryx manifest`. Run `pnpm -F @astryxdesign/cli readme`. -->
|
|
@@ -165,7 +164,7 @@ if (isError(result)) {
|
|
|
165
164
|
| `ERR_UNKNOWN` | Fallback for any error without a more specific code. |
|
|
166
165
|
| `ERR_UNKNOWN_COMMAND` | A top-level command name was not recognized (e.g. `astryx bogus`). |
|
|
167
166
|
| `ERR_UNKNOWN_SUBCOMMAND` | A subcommand under a command group was not recognized (e.g. `astryx theme bogus`). |
|
|
168
|
-
| `ERR_INVALID_OPTION` | An unknown option was passed, --json was given to a command without JSON output
|
|
167
|
+
| `ERR_INVALID_OPTION` | An unknown option was passed, --json was given to a command without JSON output. |
|
|
169
168
|
| `ERR_INVALID_ARGUMENT` | An argument or option value is invalid: wrong type, out of range, an unknown choice, an extra argument, or a conflicting combination. |
|
|
170
169
|
| `ERR_MISSING_ARGUMENT` | A required argument or option value was omitted. |
|
|
171
170
|
| `ERR_INVALID_LANG` | `--lang` was given a value outside its choices (en, zh, dense). |
|
|
@@ -423,7 +422,7 @@ Every response has a `type` discriminant. The full set is below (generated from
|
|
|
423
422
|
| Type | What `data` carries |
|
|
424
423
|
| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
425
424
|
| `init.run` | The install receipt: the `mode` (`default` \| `features`), the features run, agent-doc files written, any soft `docsError`, whether theme guidance was emitted, the template outcome (`workflow` \| `created` \| `skipped`) plus its path, and whether the next-steps were emitted. |
|
|
426
|
-
| `init.remove` |
|
|
425
|
+
| `init.remove` | The removal receipt — returned when --remove-agents is set: `data.removed` is true when a managed agent-docs block was found and removed, and false when there was none to remove. |
|
|
427
426
|
| `component.list` | The component catalog grouped by component group (each component's group field): `detail` (the level: names \| compact \| full) and `components`, the grouped map of names entries ({name, package, and optional canonical import for integrations}), brief entries ({name, package, description, import}), or a full ComponentDoc per entry with its package. |
|
|
428
427
|
| `component.batch` | The component specialization of the shared `BatchResponse` and `BatchRow` types. An explicit programmatic selector array, or two or more CLI selectors, returns one ordered receipt: `count` plus `results`, one row per selector including duplicates. Every row carries `selector` and `status` (found \| not_found \| ambiguous \| error). A found row carries `result`, the same {type, data} response as one selector. An ambiguous row carries `code`, `error`, and `candidates` ({package, component, kind, installed}). Other failed rows carry `code`, `error`, and optional `suggestions` ({name, reason}). |
|
|
429
428
|
| `component.detail` | One component's authored ComponentDoc plus ownership fields (package, the owner; import, the specifier; sourceAvailable, whether source exists) and parentDoc (present when the component is documented inside another component's doc, naming that doc). The envelope's package names the same owner. |
|
|
@@ -462,11 +461,10 @@ Every response has a `type` discriminant. The full set is below (generated from
|
|
|
462
461
|
| `theme.build.check` | The --check receipt: theme name, an upToDate flag, the stale outputs (each {path, reason: missing \| outdated}), and the full list of checked paths. Writes nothing. |
|
|
463
462
|
| `theme.build.batch` | Several themes built in one invocation: `count` plus one {file, receipt} per theme in argument order, where receipt is that theme's theme.build (or theme.build.check) envelope, or null when it produced no CSS. |
|
|
464
463
|
| `theme.list` | Every bundled, installed package, and local theme as a ThemeListEntry[]. Each entry has slug, displayName, description, maintained, owner package or local root, source, added, and default fields. Optional meta.unmigratedCopies names earlier descriptor-less copies, their missing descriptor, and the upgrade command; those copies are not data entries. |
|
|
465
|
-
| `theme.add` | The released source-copy receipt: slug, displayName, maintained flag, owner package, outputDir, source entry, exportName, and files. Its additive meta.deprecations entry names DEP-0005 and the source-fork/import replacements. |
|
|
466
464
|
| `theme.app` | The app theme record after add, remove, or use. It includes every added theme and its built imports, the default slug, generated module path, and the command change. After add, the envelope package names the npm package that owns the added theme; a local theme has none. |
|
|
467
465
|
| `theme.eject` | A local source-fork receipt with the resolved slug, displayName, source theme maintained flag, source-selector package, outputDir, source entry, exportName, and every file written, including the descriptor. The written local descriptor always uses maintained: false. |
|
|
468
466
|
| `theme.template` | A write receipt for the annotated theme template: 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. |
|
|
469
|
-
| `theme.targets` | The whole themeable surface: the echoed filter, componentCount, and targets, one per theming target — {key, className, component, props, states
|
|
467
|
+
| `theme.targets` | The whole themeable surface: the echoed filter, componentCount, and targets, one per theming target — {key, className, component, props, states}, where props and states are its legal override keys. |
|
|
470
468
|
| `theme.palette.generate` | An author-reviewable OKLCH palette candidate, its reproducibility receipt, summary counts, and optional candidate/receipt file-write result. |
|
|
471
469
|
| `upgrade.list` | Every available codemod, oldest→newest, as {name, package, title, version, optional}; returned for --list without running anything. |
|
|
472
470
|
| `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. |
|
|
@@ -478,13 +476,10 @@ Every response has a `type` discriminant. The full set is below (generated from
|
|
|
478
476
|
| `doctor` | The health-check report: `checks` (each with id, label, status: pass \| warn \| fail \| info, a message, and an optional fix, always present on warn and fail) plus a `summary` of counts per status. |
|
|
479
477
|
| `integration.add` | A contribution-writer receipt: kind, name, optional root {path, created}, integration-manifest path, every affected project-relative path, written, and dryRun. |
|
|
480
478
|
| `integration.pack-check` | The packed-package check: name, version, packable, tarball {filename, fileCount, size, unpackedSize} or null, inventory {manifest, roots [{kind, path, expectedFiles, missingFiles, complete}], expectedFiles, packedFiles}, contributions {local, packed}, each null or {themes [{slug, exportName}], components, templates [{id, type, name}], codemods [{version, id}], docs, agentDocsAppend}, and issues [{code, severity, message}]. |
|
|
481
|
-
| `integration.validate` | The validation result: validated (false when no
|
|
479
|
+
| `integration.validate` | The validation result: validated (false when nothing was validated: with no package.json the issues list carries one no_package error so the command exits 1, and with a package.json but no integration manifest the issues list is empty and proves nothing), the package name and version (both null when validated is false) plus issues, an AstryxIntegrationIssue[] of {code, severity: warning \| error, message}. |
|
|
482
480
|
| `integration.template-conflicts` | validated (false when no integration manifest was found, so nothing was inspected), the integration identity, structural issues, and non-blocking Core template-id conflicts as {id, severity: warning, integrationPackage, integrationType, integrationName, coreMatches, message, command}. |
|
|
483
481
|
| `integration.component-conflicts` | validated (false when no integration manifest was found, so nothing was inspected), the integration identity, structural issues, and non-blocking conflicts where an integration component name is also owned by Core; each conflict includes the exact package-qualified command. |
|
|
484
482
|
| `integration.doc-conflicts` | validated (false when no integration manifest was found, so nothing was inspected), the integration identity, structural issues, and Core doc overlaps. Each finding includes `severity` (`info` \| `error`) and `relationship` (`replaces` \| `extends` \| `accidental`). |
|
|
485
|
-
| `layout.expand` | The expansion: parsed form, generated TSX code, componentsUsed, states (count of useState hooks scaffolded), todos, blocksReferenced (each {name, mode}), warnings, written (the output path, or null when nothing was written), and demoMediaReplaced (count of demo media placeholders). Carries `meta.deprecations` with DEP-0006 and its replacement commands. |
|
|
486
|
-
| `layout.check` | The validation result: a valid flag, the detected form, errors (each with line/col, message, formatted text, and suggestions), warnings, and the expression re-printed in both canonical surfaces (compact and outline). Carries `meta.deprecations` with DEP-0006 and its replacement commands. |
|
|
487
|
-
| `layout.grammar` | The XLE/XLO grammar cheatsheet: a text field with the full reference plus an aliases map (short name → canonical component) generated from this install's registry. Carries `meta.deprecations` with DEP-0006 and its replacement commands. |
|
|
488
483
|
|
|
489
484
|
<!-- END GENERATED: response-types -->
|
|
490
485
|
<!-- Generated by scripts/generate-cli-readme.mjs from the response-types EnumDoc. Run `pnpm -F @astryxdesign/cli readme`. -->
|
package/api/build/build.mjs
CHANGED
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
* a query → build.kit (api/build/kit/kit.mjs)
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
+
import {AstryxError} from '../error.mjs';
|
|
17
|
+
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
16
18
|
import {buildHelp} from './help/help.mjs';
|
|
17
19
|
import {buildKit} from './kit/kit.mjs';
|
|
18
20
|
|
|
@@ -31,5 +33,12 @@ export async function build(query, options = {}) {
|
|
|
31
33
|
if (!query || !String(query).trim()) {
|
|
32
34
|
return buildHelp();
|
|
33
35
|
}
|
|
36
|
+
if (options.limit != null && (!Number.isInteger(options.limit) || options.limit <= 0)) {
|
|
37
|
+
throw new AstryxError(
|
|
38
|
+
`Invalid limit "${options.limit}". Must be a positive integer.`,
|
|
39
|
+
undefined,
|
|
40
|
+
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
41
|
+
);
|
|
42
|
+
}
|
|
34
43
|
return buildKit(query, options);
|
|
35
44
|
}
|
|
@@ -149,6 +149,8 @@ export function resolveCoreSourcePath(coreDir: string, dirName: string): string
|
|
|
149
149
|
/**
|
|
150
150
|
* Resolve a bare (unscoped) name to a `.doc.mjs`: core first, then back-compat
|
|
151
151
|
* externals, then a conservative fuzzy search. Throws ERR_UNKNOWN_COMPONENT
|
|
152
|
+
* for a genuinely unknown name, and ERR_AMBIGUOUS_COMPONENT when multiple
|
|
153
|
+
* packages provide the same name
|
|
152
154
|
* (with candidate suggestions when close) or ERR_NO_DOC.
|
|
153
155
|
* @param {string} dirName - bare component name (no `XDS` prefix)
|
|
154
156
|
* @param {{coreDir: string, cwd: string, name: string}} ctx - `name` is the caller's original (prefixed) input, used in error text
|
|
@@ -324,7 +324,7 @@ export class ComponentAmbiguityError extends AstryxError {
|
|
|
324
324
|
super(
|
|
325
325
|
`Component "${dirName}" is provided by multiple packages. Re-run with --package <pkg> to choose one.`,
|
|
326
326
|
owners.map(o => ({name: o.package, reason: 'provides this component'})),
|
|
327
|
-
ERROR_CODES.
|
|
327
|
+
ERROR_CODES.ERR_AMBIGUOUS_COMPONENT,
|
|
328
328
|
);
|
|
329
329
|
this.candidates = owners.map(owner => ({
|
|
330
330
|
package: owner.package,
|
|
@@ -375,6 +375,8 @@ export function resolveCoreSourcePath(coreDir, dirName) {
|
|
|
375
375
|
/**
|
|
376
376
|
* Resolve a bare (unscoped) name to a `.doc.mjs`: core first, then back-compat
|
|
377
377
|
* externals, then a conservative fuzzy search. Throws ERR_UNKNOWN_COMPONENT
|
|
378
|
+
* for a genuinely unknown name, and ERR_AMBIGUOUS_COMPONENT when multiple
|
|
379
|
+
* packages provide the same name
|
|
378
380
|
* (with candidate suggestions when close) or ERR_NO_DOC.
|
|
379
381
|
* @param {string} dirName - bare component name (no `XDS` prefix)
|
|
380
382
|
* @param {{coreDir: string, cwd: string, name: string}} ctx - `name` is the caller's original (prefixed) input, used in error text
|
|
@@ -170,7 +170,11 @@ export const doc = {
|
|
|
170
170
|
},
|
|
171
171
|
{
|
|
172
172
|
code: 'ERR_UNKNOWN_COMPONENT',
|
|
173
|
-
when: 'name is not a string, resolves to no known component,
|
|
173
|
+
when: 'name is not a string, resolves to no known component, or is absent from the requested options.package',
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
code: 'ERR_AMBIGUOUS_COMPONENT',
|
|
177
|
+
when: 'the component is provided by multiple packages (pass options.package to disambiguate)',
|
|
174
178
|
},
|
|
175
179
|
{
|
|
176
180
|
code: 'ERR_UNKNOWN_PACKAGE',
|
|
@@ -48,6 +48,22 @@ describe('every shipped topic compiles to plain JSON', () => {
|
|
|
48
48
|
);
|
|
49
49
|
});
|
|
50
50
|
|
|
51
|
+
describe('author-a-theme color guidance', () => {
|
|
52
|
+
it('teaches committed generated palette references as the main example', async () => {
|
|
53
|
+
const catalog = await loadDocsCatalog();
|
|
54
|
+
const topic = detailView(
|
|
55
|
+
await compileTopic(catalog, catalog.resolve('author-a-theme')),
|
|
56
|
+
);
|
|
57
|
+
const rendered = JSON.stringify(topic);
|
|
58
|
+
|
|
59
|
+
expect(rendered).toContain("import {palette} from './palette.generated';");
|
|
60
|
+
expect(rendered).toContain('palette.neutral.light[100]');
|
|
61
|
+
expect(rendered).toContain('palette.neutral.dark[15]');
|
|
62
|
+
expect(rendered).toContain('color (existing themes)');
|
|
63
|
+
expect(rendered).not.toContain("color: { accent: ['#7B61FF'");
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
51
67
|
describe('reads that share a catalog', () => {
|
|
52
68
|
it(
|
|
53
69
|
'never let one read change another',
|
|
@@ -23,7 +23,7 @@ export const doc = {
|
|
|
23
23
|
'integration provider identity and contribution issues, agent docs, the ' +
|
|
24
24
|
'detected package manager, and the health of the docs the CLI reads (authoring ' +
|
|
25
25
|
'and CLI docs, the docs tree, doc size), and returns a structured ' +
|
|
26
|
-
'report. Theme checks run when the generated app module exists; without one, doctor reports that the CLI manages no themes and names theme add
|
|
26
|
+
'report. Theme checks run when the generated app module exists; without one, doctor reports that the CLI manages no themes and names theme add. Earlier descriptor-less copies are a non-failing upgrade warning. It never installs, writes, or mutates. It imports astryx.config, executes every added theme source while validating private inputs, and loads every recorded built theme module to prove its runtime imports work, including themes from installed packages. Local theme source also runs during build-freshness checks. Stylesheets are parsed without execution. Config and theme top-level code therefore run, so use doctor only with project code you trust.',
|
|
27
27
|
importPath: '@astryxdesign/cli/api',
|
|
28
28
|
signature: 'doctor(options?: DoctorOptions): Promise<DoctorResponse>',
|
|
29
29
|
keywords: ['doctor', 'diagnose', 'health', 'check', 'verify', 'environment'],
|
|
@@ -1122,3 +1122,31 @@ describe('doctor says why it skipped and what it checked', () => {
|
|
|
1122
1122
|
);
|
|
1123
1123
|
});
|
|
1124
1124
|
});
|
|
1125
|
+
|
|
1126
|
+
describe('no Astryx-owned environment variables (spec:AST-017 FR14)', () => {
|
|
1127
|
+
it('no source file reads an ASTRYX_* env var', () => {
|
|
1128
|
+
const cliDir = path.resolve(REPO, 'packages/cli');
|
|
1129
|
+
const SKIP = new Set(['node_modules', 'dist', 'coverage']);
|
|
1130
|
+
const ENV_READ = /process\.env(?:\.|\[\s*['"`])ASTRYX_/;
|
|
1131
|
+
/** @type {string[]} */
|
|
1132
|
+
const hits = [];
|
|
1133
|
+
/** @param {string} dir */
|
|
1134
|
+
const walk = dir => {
|
|
1135
|
+
for (const entry of fs.readdirSync(dir, {withFileTypes: true})) {
|
|
1136
|
+
if (SKIP.has(entry.name)) continue;
|
|
1137
|
+
const full = path.join(dir, entry.name);
|
|
1138
|
+
if (entry.isDirectory()) {
|
|
1139
|
+
walk(full);
|
|
1140
|
+
continue;
|
|
1141
|
+
}
|
|
1142
|
+
if (!/\.[cm]?[jt]sx?$/.test(entry.name)) continue;
|
|
1143
|
+
if (/\.test\.|\.d\.[cm]?ts$/.test(entry.name)) continue;
|
|
1144
|
+
if (ENV_READ.test(fs.readFileSync(full, 'utf8'))) {
|
|
1145
|
+
hits.push(path.relative(cliDir, full));
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
};
|
|
1149
|
+
walk(cliDir);
|
|
1150
|
+
expect(hits).toEqual([]);
|
|
1151
|
+
});
|
|
1152
|
+
});
|
|
@@ -69,7 +69,7 @@ function unavailableChecks(message, moduleError = null) {
|
|
|
69
69
|
moduleError && id === 'theme-module' ? moduleError.message : message,
|
|
70
70
|
...(moduleError && id === 'theme-module'
|
|
71
71
|
? {
|
|
72
|
-
fix: 'Keep one CLI-generated astryx-themes.ts or astryx-themes.js file, then run `astryx theme add <slug
|
|
72
|
+
fix: 'Keep one CLI-generated astryx-themes.ts or astryx-themes.js file, then run `astryx theme add <slug>`.',
|
|
73
73
|
}
|
|
74
74
|
: {}),
|
|
75
75
|
}));
|
|
@@ -101,12 +101,12 @@ function refreshThemeCommand(projectDir, run, available, slug, owner) {
|
|
|
101
101
|
);
|
|
102
102
|
if (!isLocalThemeOwner(owner)) {
|
|
103
103
|
const selector = theme?.package ?? owner;
|
|
104
|
-
return `npm install ${owner}@latest; ${run} theme add ${slug} --
|
|
104
|
+
return `npm install ${owner}@latest; ${run} theme add ${slug} --package ${selector}`;
|
|
105
105
|
}
|
|
106
106
|
const source = theme
|
|
107
107
|
? relative(projectDir, path.join(theme.sourceDir, theme.entry))
|
|
108
108
|
: projectPath(path.join(owner, slug, `${slug}Theme.ts`));
|
|
109
|
-
return `${run} theme build ${source}; ${run} theme add ${slug}
|
|
109
|
+
return `${run} theme build ${source}; ${run} theme add ${slug}`;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
/** @param {string} source */
|
|
@@ -478,7 +478,7 @@ export function checkThemes(cwd, appChecks) {
|
|
|
478
478
|
label,
|
|
479
479
|
status: 'warn',
|
|
480
480
|
message: 'No @astryxdesign/theme-* packages are installed.',
|
|
481
|
-
fix: `Install a theme, e.g. \`npm install @astryxdesign/theme-neutral\`, then add it to the app with \`${run} theme add neutral
|
|
481
|
+
fix: `Install a theme, e.g. \`npm install @astryxdesign/theme-neutral\`, then add it to the app with \`${run} theme add neutral\`.`,
|
|
482
482
|
};
|
|
483
483
|
}
|
|
484
484
|
const names = packages.join(', ');
|
|
@@ -488,7 +488,7 @@ export function checkThemes(cwd, appChecks) {
|
|
|
488
488
|
label,
|
|
489
489
|
status: 'warn',
|
|
490
490
|
message: `Theme package(s) installed (${names}) but no theme appears wired.`,
|
|
491
|
-
fix: `Add one to the app with \`${run} theme add <slug
|
|
491
|
+
fix: `Add one to the app with \`${run} theme add <slug>\`.`,
|
|
492
492
|
};
|
|
493
493
|
}
|
|
494
494
|
return {
|
|
@@ -538,7 +538,7 @@ export async function checkAppThemes(cwd) {
|
|
|
538
538
|
message: state.legacyTheme
|
|
539
539
|
? `The CLI manages no themes. The released package.json astryx.theme value ${JSON.stringify(state.legacyTheme)} remains active.`
|
|
540
540
|
: 'The CLI manages no themes because this project has no generated theme module.',
|
|
541
|
-
fix: `Start managing app themes with \`${run} theme add <slug
|
|
541
|
+
fix: `Start managing app themes with \`${run} theme add <slug>\`.`,
|
|
542
542
|
},
|
|
543
543
|
];
|
|
544
544
|
const migration = unmigratedCopyCheck(state.projectDir);
|
|
@@ -656,7 +656,7 @@ export async function checkAppThemes(cwd) {
|
|
|
656
656
|
label: 'Theme owners and built imports',
|
|
657
657
|
status: 'fail',
|
|
658
658
|
message: 'The generated record has no added themes.',
|
|
659
|
-
fix: `${run} theme add <slug
|
|
659
|
+
fix: `${run} theme add <slug>`,
|
|
660
660
|
});
|
|
661
661
|
} else if (discoveryError) {
|
|
662
662
|
checks.push({
|
|
@@ -664,7 +664,7 @@ export async function checkAppThemes(cwd) {
|
|
|
664
664
|
label: 'Theme owners and built imports',
|
|
665
665
|
status: 'fail',
|
|
666
666
|
message: discoveryError.message,
|
|
667
|
-
fix: `${run} theme add <slug
|
|
667
|
+
fix: `${run} theme add <slug>`,
|
|
668
668
|
});
|
|
669
669
|
} else if (resolutionProblems.length > 0) {
|
|
670
670
|
checks.push({
|
|
@@ -1003,7 +1003,7 @@ export async function checkAppThemes(cwd) {
|
|
|
1003
1003
|
fix:
|
|
1004
1004
|
ownerEntries.length > 0
|
|
1005
1005
|
? `${run} theme use ${ownerEntries[0][0]}`
|
|
1006
|
-
: `${run} theme add <slug
|
|
1006
|
+
: `${run} theme add <slug>`,
|
|
1007
1007
|
},
|
|
1008
1008
|
);
|
|
1009
1009
|
|
|
@@ -1083,7 +1083,7 @@ export async function checkAppThemes(cwd) {
|
|
|
1083
1083
|
if (localWarnings.length > 0) {
|
|
1084
1084
|
fontWarningFixes.push(
|
|
1085
1085
|
`Add <slug>.fonts.css beside each built local theme output, then ${localWarnings
|
|
1086
|
-
.map(problem => `${run} theme add ${problem.theme.slug}
|
|
1086
|
+
.map(problem => `${run} theme add ${problem.theme.slug}`)
|
|
1087
1087
|
.join('; ')}.`,
|
|
1088
1088
|
);
|
|
1089
1089
|
}
|
|
@@ -172,7 +172,7 @@ describe('the released themes check', () => {
|
|
|
172
172
|
label: 'Theme packages',
|
|
173
173
|
status: 'warn',
|
|
174
174
|
message: 'No @astryxdesign/theme-* packages are installed.',
|
|
175
|
-
fix: expect.stringContaining('theme add neutral
|
|
175
|
+
fix: expect.stringContaining('theme add neutral`.'),
|
|
176
176
|
});
|
|
177
177
|
|
|
178
178
|
installThemePackage(dir, 'neutral');
|
|
@@ -183,7 +183,7 @@ describe('the released themes check', () => {
|
|
|
183
183
|
status: 'warn',
|
|
184
184
|
message:
|
|
185
185
|
'Theme package(s) installed (@astryxdesign/theme-neutral) but no theme appears wired.',
|
|
186
|
-
fix: expect.stringContaining('theme add <slug
|
|
186
|
+
fix: expect.stringContaining('theme add <slug>`.'),
|
|
187
187
|
});
|
|
188
188
|
expect(unwired.fix).not.toContain('ASTRYX_THEME');
|
|
189
189
|
|
|
@@ -390,7 +390,7 @@ describe('app-theme doctor checks', () => {
|
|
|
390
390
|
|
|
391
391
|
expect(check(await checkAppThemes(dir), 'theme-owners')).toMatchObject({
|
|
392
392
|
status: 'fail',
|
|
393
|
-
fix: expect.stringContaining('theme add ocean
|
|
393
|
+
fix: expect.stringContaining('theme add ocean'),
|
|
394
394
|
});
|
|
395
395
|
});
|
|
396
396
|
|
|
@@ -592,9 +592,10 @@ describe('app-theme doctor checks', () => {
|
|
|
592
592
|
id: 'theme-management',
|
|
593
593
|
status: 'info',
|
|
594
594
|
message: expect.stringContaining('manages no themes'),
|
|
595
|
-
fix: expect.stringContaining('theme add <slug>
|
|
595
|
+
fix: expect.stringContaining('theme add <slug>'),
|
|
596
596
|
}),
|
|
597
597
|
]);
|
|
598
|
+
expect(checks[0]?.fix).not.toContain('--import');
|
|
598
599
|
});
|
|
599
600
|
|
|
600
601
|
it('reads astryx.theme from the app package when node_modules is hoisted to a workspace root', async () => {
|
|
@@ -74,7 +74,7 @@ export const doc = {
|
|
|
74
74
|
name: 'options.listCategories',
|
|
75
75
|
type: 'boolean',
|
|
76
76
|
description:
|
|
77
|
-
'Return categories without resolving a route or writing; the component and every other option are
|
|
77
|
+
'Return categories without resolving a route or writing; the component and every other option are refused with ERR_INVALID_ARGUMENT.',
|
|
78
78
|
default: 'false',
|
|
79
79
|
},
|
|
80
80
|
{
|
|
@@ -595,6 +595,21 @@ function aggregateStatus(deliveries) {
|
|
|
595
595
|
*/
|
|
596
596
|
export async function gapReport(component, options = {}) {
|
|
597
597
|
if (options.listCategories) {
|
|
598
|
+
const ignored = [
|
|
599
|
+
component ? 'component' : null,
|
|
600
|
+
options.category ? '--category' : null,
|
|
601
|
+
options.reason ? '--reason' : null,
|
|
602
|
+
options.detail ? '--additional-context' : null,
|
|
603
|
+
options.package ? '--package' : null,
|
|
604
|
+
options.confirmPublic ? '--confirm-public' : null,
|
|
605
|
+
].filter(Boolean);
|
|
606
|
+
if (ignored.length > 0) {
|
|
607
|
+
throw new AstryxError(
|
|
608
|
+
`\`--list-categories\` cannot be combined with ${ignored.join(', ')}: it lists categories and ignores submission options.`,
|
|
609
|
+
undefined,
|
|
610
|
+
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
611
|
+
);
|
|
612
|
+
}
|
|
598
613
|
return {
|
|
599
614
|
type: 'gap-report.categories',
|
|
600
615
|
data: GAP_REPORT_CATEGORIES.map(category => ({...category})),
|
|
@@ -1195,7 +1195,7 @@ describe('gapReport aggregate status and CLI exit', () => {
|
|
|
1195
1195
|
`,
|
|
1196
1196
|
});
|
|
1197
1197
|
configure(['@test/inspector']);
|
|
1198
|
-
vi.stubEnv('
|
|
1198
|
+
vi.stubEnv('AGENT', 'secret-agent');
|
|
1199
1199
|
|
|
1200
1200
|
const result = await gapReport('Button', {
|
|
1201
1201
|
...reportOptions,
|
package/api/index.d.mts
CHANGED
|
@@ -33,14 +33,12 @@ export * from "./gap-report/gap-report.type.mjs";
|
|
|
33
33
|
export * from "./upgrade/upgrade.type.mjs";
|
|
34
34
|
export * from "./init/init.type.mjs";
|
|
35
35
|
export * from "./doctor/doctor.type.mjs";
|
|
36
|
-
export * from "./layout/layout.type.mjs";
|
|
37
36
|
export * from "./integration/integration-authoring.type.mjs";
|
|
38
37
|
export * from "./integration/pack-check.type.mjs";
|
|
39
38
|
export * from "./integration/validate-integration.type.mjs";
|
|
40
39
|
export * from "./integration/authoring-checks.type.mjs";
|
|
41
40
|
export type Logger = import("./logger.mjs").Logger;
|
|
42
41
|
export { themeBuild, themeAdd, themeRemove, themeUse, themeEject, themeTemplate, themeList, themeListAvailable, themeListCopySources, themeTargets, themePaletteGenerate, generateTonalPalette, listThemes } from "./theme/theme.mjs";
|
|
43
|
-
export { layoutExpand, layoutCheck, layoutGrammar } from "./layout/layout.mjs";
|
|
44
42
|
export { integrationAdd, integrationAddAgentDoc, integrationAddCodemod, integrationAddComponent, integrationAddDoc, integrationAddTemplate } from "./integration/add-contribution.mjs";
|
|
45
43
|
export { validateIntegration, summarizeIssues } from "./integration/validate-integration.mjs";
|
|
46
44
|
export { integrationTemplateConflicts, integrationComponentConflicts, integrationDocConflicts } from "./integration/authoring-checks.mjs";
|
package/api/index.mjs
CHANGED
|
@@ -48,7 +48,6 @@ export {gapReport} from './gap-report/gap-report.mjs';
|
|
|
48
48
|
export {upgrade} from './upgrade/upgrade.mjs';
|
|
49
49
|
export {init} from './init/init.mjs';
|
|
50
50
|
export {doctor} from './doctor/doctor.mjs';
|
|
51
|
-
export {layoutExpand, layoutCheck, layoutGrammar} from './layout/layout.mjs';
|
|
52
51
|
export {
|
|
53
52
|
integrationAdd,
|
|
54
53
|
integrationAddAgentDoc,
|
|
@@ -97,7 +96,6 @@ export * from './gap-report/gap-report.type.mjs';
|
|
|
97
96
|
export * from './upgrade/upgrade.type.mjs';
|
|
98
97
|
export * from './init/init.type.mjs';
|
|
99
98
|
export * from './doctor/doctor.type.mjs';
|
|
100
|
-
export * from './layout/layout.type.mjs';
|
|
101
99
|
export * from './integration/integration-authoring.type.mjs';
|
|
102
100
|
export * from './integration/pack-check.type.mjs';
|
|
103
101
|
export * from './integration/validate-integration.type.mjs';
|
package/api/init/init.doc.mjs
CHANGED
|
@@ -76,10 +76,14 @@ export const doc = {
|
|
|
76
76
|
{
|
|
77
77
|
type: 'init.remove',
|
|
78
78
|
description:
|
|
79
|
-
'
|
|
79
|
+
'The removal receipt, returned when `removeAgents` is set: `data.removed` is true when a managed agent-docs block was found and removed, and false when there was none to remove.',
|
|
80
80
|
},
|
|
81
81
|
],
|
|
82
82
|
throws: [
|
|
83
|
+
{
|
|
84
|
+
code: 'ERR_INVALID_ARGUMENT',
|
|
85
|
+
when: '--remove-agents is combined with --features, --all, --agent, or --agent-docs-path; or --all is combined with --features',
|
|
86
|
+
},
|
|
83
87
|
{
|
|
84
88
|
code: 'ERR_UNKNOWN_AGENT',
|
|
85
89
|
when: 'the agents feature runs (default mode, features includes agents, or all) and `agent` is not one of claude, cursor, codex, hermes, muse, all',
|
package/api/init/init.mjs
CHANGED
|
@@ -18,6 +18,8 @@
|
|
|
18
18
|
|
|
19
19
|
import {run} from './run/run.mjs';
|
|
20
20
|
import {remove} from './remove/remove.mjs';
|
|
21
|
+
import {AstryxError} from '../error.mjs';
|
|
22
|
+
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
21
23
|
|
|
22
24
|
export {getNextSteps} from './run/run.mjs';
|
|
23
25
|
|
|
@@ -42,7 +44,27 @@ export {getNextSteps} from './run/run.mjs';
|
|
|
42
44
|
*/
|
|
43
45
|
export async function init(options = {}, {cwd = process.cwd()} = {}) {
|
|
44
46
|
if (options.removeAgents) {
|
|
47
|
+
const ignored = [
|
|
48
|
+
options.features ? '--features' : null,
|
|
49
|
+
options.all ? '--all' : null,
|
|
50
|
+
options.agent ? '--agent' : null,
|
|
51
|
+
options.agentDocsPath ? '--agent-docs-path' : null,
|
|
52
|
+
].filter(Boolean);
|
|
53
|
+
if (ignored.length > 0) {
|
|
54
|
+
throw new AstryxError(
|
|
55
|
+
`\`--remove-agents\` cannot be combined with ${ignored.join(', ')}: it removes the managed block and ignores install options.`,
|
|
56
|
+
undefined,
|
|
57
|
+
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
58
|
+
);
|
|
59
|
+
}
|
|
45
60
|
return remove({cwd});
|
|
46
61
|
}
|
|
62
|
+
if (options.all && options.features) {
|
|
63
|
+
throw new AstryxError(
|
|
64
|
+
'`--all` and `--features` cannot be used together: `--all` installs every feature, so a feature list is redundant.',
|
|
65
|
+
undefined,
|
|
66
|
+
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
67
|
+
);
|
|
68
|
+
}
|
|
47
69
|
return run(options, {cwd});
|
|
48
70
|
}
|
package/api/init/init.type.d.mts
CHANGED
|
@@ -52,8 +52,11 @@ export type InitRunResponse = {
|
|
|
52
52
|
};
|
|
53
53
|
export type InitRemoveResponse = {
|
|
54
54
|
type: "init.remove";
|
|
55
|
+
/**
|
|
56
|
+
* False when no managed agent-docs block was found, so nothing was removed.
|
|
57
|
+
*/
|
|
55
58
|
data: {
|
|
56
|
-
removed:
|
|
59
|
+
removed: boolean;
|
|
57
60
|
};
|
|
58
61
|
};
|
|
59
62
|
/**
|
package/api/init/init.type.mjs
CHANGED
|
@@ -23,7 +23,12 @@ import {logger} from '../../logger.mjs';
|
|
|
23
23
|
* @returns {Promise<import('../init.type.mjs').InitRemoveResponse>}
|
|
24
24
|
*/
|
|
25
25
|
export async function remove({cwd = process.cwd()} = {}) {
|
|
26
|
-
removeAgentDocs(cwd);
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
const removedFrom = removeAgentDocs(cwd);
|
|
27
|
+
const removed = removedFrom.length > 0;
|
|
28
|
+
logger.log(
|
|
29
|
+
removed
|
|
30
|
+
? '[ok] AI agent docs removed.'
|
|
31
|
+
: '[ok] Nothing to remove: no Astryx agent-docs block was found.',
|
|
32
|
+
);
|
|
33
|
+
return {type: 'init.remove', data: {removed}};
|
|
29
34
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
import {describe, it, expect, beforeEach, afterEach, vi} from 'vitest';
|
|
3
|
+
import * as fs from 'node:fs'; import * as path from 'node:path';
|
|
4
|
+
import {init} from '../init.mjs'; import {remove} from './remove.mjs'; import {logger} from '../../logger.mjs';
|
|
5
|
+
let dir;
|
|
6
|
+
beforeEach(() => { dir = fs.mkdtempSync(path.join(process.cwd(), '.astryx-rm-')); fs.writeFileSync(path.join(dir,'package.json'),JSON.stringify({name:'c',version:'1.0.0'})); });
|
|
7
|
+
afterEach(() => { fs.rmSync(dir,{recursive:true,force:true}); logger.setSilent(true); });
|
|
8
|
+
describe('init.remove says whether anything was removed', () => {
|
|
9
|
+
it('false on clean', async () => { const r=await remove({cwd:dir}); expect(r.type).toBe('init.remove'); expect(r.data.removed).toBe(false); });
|
|
10
|
+
it('true then false', async () => { await init({features:['agents']},{cwd:dir}); expect(fs.readFileSync(path.join(dir,'AGENTS.md'),'utf8')).toContain('<!-- ASTRYX:START -->'); const a=await remove({cwd:dir}); expect(a.data.removed).toBe(true); const b=await remove({cwd:dir}); expect(b.data.removed).toBe(false); });
|
|
11
|
+
it('human line', async () => { const l=[]; const s=vi.spyOn(console,'log').mockImplementation((...a)=>l.push(a.join(' '))); logger.setSilent(false); try{await remove({cwd:dir});}finally{logger.setSilent(true);s.mockRestore();} expect(l.join('\n')).toContain('Nothing to remove'); });
|
|
12
|
+
});
|
package/api/init/run/run.d.mts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* Build the "Next steps" lines printed at the end of `astryx init`.
|
|
6
6
|
*
|
|
7
|
-
* Theme guidance follows the generated app-module workflow. `theme add
|
|
7
|
+
* Theme guidance follows the generated app-module workflow. `theme add` records
|
|
8
8
|
* installed built themes and imports their production and font stylesheets. The
|
|
9
9
|
* app imports that module once and passes its default to <Theme>.
|
|
10
10
|
*
|
package/api/init/run/run.mjs
CHANGED
|
@@ -35,7 +35,7 @@ const VALID_AGENTS = ['claude', 'cursor', 'codex', 'hermes', 'muse', 'all'];
|
|
|
35
35
|
/**
|
|
36
36
|
* Build the "Next steps" lines printed at the end of `astryx init`.
|
|
37
37
|
*
|
|
38
|
-
* Theme guidance follows the generated app-module workflow. `theme add
|
|
38
|
+
* Theme guidance follows the generated app-module workflow. `theme add` records
|
|
39
39
|
* installed built themes and imports their production and font stylesheets. The
|
|
40
40
|
* app imports that module once and passes its default to <Theme>.
|
|
41
41
|
*
|
|
@@ -53,7 +53,7 @@ export function getNextSteps(invocation) {
|
|
|
53
53
|
" 3. Import components: import { Button } from '@astryxdesign/core'",
|
|
54
54
|
' 4. Add and wire a theme:',
|
|
55
55
|
' npm install @astryxdesign/theme-neutral',
|
|
56
|
-
` ${invocation} theme add neutral
|
|
56
|
+
` ${invocation} theme add neutral`,
|
|
57
57
|
" import { Theme } from '@astryxdesign/core'",
|
|
58
58
|
" import { themes, defaultThemeSlug } from './astryx-themes'",
|
|
59
59
|
' <Theme theme={themes[defaultThemeSlug]}>...</Theme>',
|
|
@@ -141,7 +141,7 @@ function applyTheme(cwd, invocation, data) {
|
|
|
141
141
|
logger.error('Could not write the theme template.');
|
|
142
142
|
}
|
|
143
143
|
logger.log(
|
|
144
|
-
` Edit the blank template for a new theme, or run \`${invocation} theme add <slug
|
|
144
|
+
` Edit the blank template for a new theme, or run \`${invocation} theme add <slug>\` to import an installed built theme (\`${invocation} theme list\` to browse). Extend an imported theme for ordinary customization; use \`${invocation} theme eject <slug>\` only to fork source.`,
|
|
145
145
|
);
|
|
146
146
|
}
|
|
147
147
|
|
|
@@ -62,6 +62,10 @@ export type ValidateResult = {
|
|
|
62
62
|
* Absolute path to the loaded manifest.
|
|
63
63
|
*/
|
|
64
64
|
manifestFile?: string | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* Why nothing was validated (internal).
|
|
67
|
+
*/
|
|
68
|
+
reason?: "no_package_json" | undefined;
|
|
65
69
|
issues: Issue[];
|
|
66
70
|
integration?: import("../../foundation/integrations/integrations.mjs").LoadedIntegration | undefined;
|
|
67
71
|
};
|