@astryxdesign/cli 0.7.15 → 0.7.16-canary.g8514aae
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 +5 -3
- package/api/component/_adapter.d.mts +1 -1
- package/api/component/_adapter.mjs +28 -1
- package/api/doctor/_adapter.d.mts +17 -0
- package/api/doctor/_adapter.mjs +35 -0
- package/api/doctor/doctor.mjs +18 -4
- package/api/integration/validate-integration.mjs +1 -1
- package/api/theme/_adapter.d.mts +5 -2
- package/api/theme/_adapter.mjs +43 -12
- package/api/theme/build/build.d.mts +1 -21
- package/api/theme/build/build.mjs +149 -37
- package/api/theme/eject/eject.mjs +22 -1
- package/api/theme/template/template.d.mts +19 -0
- package/api/theme/template/template.mjs +91 -19
- package/api/theme/theme.type.d.mts +5 -1
- package/api/theme/theme.type.mjs +2 -1
- package/api/theme/themeBuild.doc.mjs +3 -3
- package/api/theme/themeEject.doc.mjs +1 -1
- package/api/theme/themeTemplate.doc.mjs +9 -3
- package/api/theme-edit/_adapter.d.mts +21 -0
- package/api/theme-edit/_adapter.mjs +176 -22
- package/api/theme-edit/_check.d.mts +7 -0
- package/api/theme-edit/_check.mjs +1050 -173
- package/api/theme-edit/_color.d.mts +2 -8
- package/api/theme-edit/_color.mjs +292 -219
- package/api/theme-edit/_compiler.d.mts +1 -0
- package/api/theme-edit/_compiler.mjs +20 -1
- package/api/theme-edit/_context.d.mts +21 -0
- package/api/theme-edit/_context.mjs +235 -12
- package/api/theme-edit/_css.d.mts +50 -1
- package/api/theme-edit/_css.mjs +310 -28
- package/api/theme-edit/_edit.d.mts +9 -0
- package/api/theme-edit/_edit.mjs +907 -123
- package/api/theme-edit/_how-commands.d.mts +11 -26
- package/api/theme-edit/_how-commands.mjs +30 -2
- package/api/theme-edit/_how-question.d.mts +7 -0
- package/api/theme-edit/_how-question.mjs +1304 -176
- package/api/theme-edit/_how.mjs +144 -30
- package/api/theme-edit/_palette.d.mts +6 -0
- package/api/theme-edit/_palette.mjs +164 -62
- package/api/theme-edit/_parts.d.mts +16 -0
- package/api/theme-edit/_parts.mjs +49 -1
- package/api/theme-edit/_png.mjs +19 -14
- package/api/theme-edit/_preview-app.mjs +514 -27
- package/api/theme-edit/_preview.d.mts +11 -0
- package/api/theme-edit/_preview.mjs +245 -24
- package/api/theme-edit/_project.d.mts +11 -0
- package/api/theme-edit/_project.mjs +35 -9
- package/api/theme-edit/_settings.d.mts +122 -5
- package/api/theme-edit/_settings.mjs +1363 -71
- package/api/theme-edit/_tables.d.mts +19 -0
- package/api/theme-edit/_tables.mjs +205 -149
- package/api/theme-edit/_vet.d.mts +42 -0
- package/api/theme-edit/_vet.mjs +144 -0
- package/api/theme-edit/theme-edit.type.d.mts +2 -1
- package/api/theme-edit/theme-edit.type.mjs +1 -1
- package/api/theme-edit/themeEditNew.doc.mjs +1 -1
- package/api/theme-edit/themeEditShow.doc.mjs +11 -3
- package/assets/docs/tree/single-component.doc.mjs +11 -2
- package/assets/docs/tree/tokens-and-setup.doc.mjs +39 -3
- package/assets/docs.generated.json +2 -2
- package/assets/preview-app/next.config.mjs +7 -1
- package/assets/preview-app/src/app/globals.css +1 -0
- package/assets/self-audit.generated.json +1 -1
- package/assets/templates/blocks/components/Table/ColumnsVirtualizationHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Table/ColumnsVirtualizationHookUsage.tsx +53 -0
- package/assets/templates/blocks/components/Table/InfiniteScrollHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Table/InfiniteScrollHookUsage.tsx +33 -0
- package/assets/templates/components.generated.json +1 -1
- package/authoring/doctypes/_schema.d.mts +52 -5
- package/authoring/doctypes/_schema.mjs +62 -7
- package/authoring/doctypes/base/type.ts +10 -0
- package/authoring/doctypes/component/component.doc.mjs +1 -1
- package/authoring/doctypes/function/function.doc.mjs +6 -0
- package/authoring/doctypes/function/type.ts +3 -0
- package/authoring/doctypes/legacy.mjs +5 -1
- package/authoring/index.d.ts +1 -0
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/doctor.doc.mjs +2 -2
- package/clients/cli/commands/experimental/theme.mjs +188 -37
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-eject.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-template.doc.mjs +2 -2
- package/clients/cli/commands/theme-build.doc.mjs +2 -2
- package/clients/cli/commands/theme-eject.doc.mjs +1 -1
- package/clients/cli/commands/theme-template.doc.mjs +3 -1
- package/clients/cli/commands/theme.mjs +89 -6
- package/clients/cli/formatters/index.mjs +7 -4
- package/clients/cli/lib/cli-error.mjs +9 -3
- package/clients/cli/lib/component-format.mjs +27 -9
- package/clients/cli/lib/json-shim.mjs +40 -2
- package/clients/cli/manifest.generated.json +1 -1
- package/foundation/config/project.mjs +50 -14
- package/foundation/discovery/theme-discovery.d.mts +5 -1
- package/foundation/discovery/theme-discovery.mjs +24 -3
- package/foundation/fs/gather-cache.d.mts +9 -2
- package/foundation/fs/gather-cache.mjs +36 -10
- package/foundation/fs/paths.d.mts +16 -0
- package/foundation/fs/paths.mjs +25 -0
- package/foundation/render/host-exit.d.mts +8 -0
- package/foundation/render/host-exit.mjs +11 -0
- package/foundation/render/page-host.mjs +56 -10
- package/foundation/render/page-worker.mjs +14 -0
- package/foundation/render/render-page.mjs +37 -2
- package/foundation/response/error-codes.d.mts +2 -1
- package/foundation/response/error-codes.d.ts +1 -0
- package/foundation/response/error-codes.doc.mjs +5 -0
- package/foundation/response/error-codes.mjs +3 -0
- package/foundation/response/json.d.mts +15 -0
- package/foundation/response/json.mjs +52 -1
- package/foundation/response/response-types.doc.mjs +1 -1
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -223,6 +223,7 @@ if (isError(result)) {
|
|
|
223
223
|
| `ERR_WRITE_FAILED` | Writing output files failed (and was rolled back). |
|
|
224
224
|
| `ERR_THEME_INVALID` | A theme definition or contributed theme descriptor is invalid. |
|
|
225
225
|
| `ERR_THEME_LOAD` | A theme file could not be loaded / parsed into a defineTheme result. |
|
|
226
|
+
| `ERR_THEME_STALE` | `theme build --check` found stale or missing outputs: exit 1, in the check result (`code`), not an error. |
|
|
226
227
|
| `ERR_PALETTE_GENERATION` | A palette generation request or one of its constraints was invalid. |
|
|
227
228
|
| `ERR_VERSION_DETECT` | The current `@astryxdesign/core` version could not be detected. |
|
|
228
229
|
| `ERR_INVALID_VERSION` | A `--from`/`--to` value was not a valid semver string. |
|
|
@@ -511,7 +512,7 @@ Every response has a `type` discriminant. The full set is below (generated from
|
|
|
511
512
|
| `hook.detail` | One hook's full authored HookDoc. The envelope's package is @astryxdesign/core. |
|
|
512
513
|
| `hook.detail.params` | Just one hook's parameters table (HookParamDoc[]). The envelope's package is @astryxdesign/core. |
|
|
513
514
|
| `theme.build` | A theme build receipt: name, tokenCount and componentCount (override counts), sizeKB, the written outputs {css, cssDts, js, dts, and variantsDts when applicable}, warnings (defects to fix), and notices (advisories about a correct theme, such as a named font it does not load). |
|
|
514
|
-
| `theme.build.check` | The --check receipt: theme name, an upToDate flag, the stale outputs (each {path, reason: missing \| outdated}),
|
|
515
|
+
| `theme.build.check` | The --check receipt: theme name, an upToDate flag, the stale outputs (each {path, reason: missing \| outdated}), the full list of checked paths, and, when any is stale or missing, code ERR_THEME_STALE. Writes nothing. |
|
|
515
516
|
| `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. |
|
|
516
517
|
| `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. |
|
|
517
518
|
| `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. |
|
|
@@ -540,8 +541,9 @@ Every response has a `type` discriminant. The full set is below (generated from
|
|
|
540
541
|
|
|
541
542
|
## Doctor
|
|
542
543
|
|
|
543
|
-
`astryx doctor` runs
|
|
544
|
-
|
|
544
|
+
`astryx doctor` runs health checks against your project and environment. It
|
|
545
|
+
changes nothing in the project; once the per-user cache folder exists, it
|
|
546
|
+
keeps its docs checks and integration check results there. Each record uses `[ok]`, `[warn]`, `[fail]`, or `[info]`, and
|
|
545
547
|
includes an actionable `fix` when one is available. Field names match the
|
|
546
548
|
`--json` keys. The exact checks and values depend on the project; the output
|
|
547
549
|
shape is stable:
|
|
@@ -206,7 +206,7 @@ export function extractProps(docs: LoadedComponentDoc): any[];
|
|
|
206
206
|
* Augment a loaded `component.detail` doc with ownership metadata. Adds
|
|
207
207
|
* `package`, the resolved `import` specifier, and `sourceAvailable` (whether a
|
|
208
208
|
* swizzleable source file exists for the owner). Existing doc fields (name,
|
|
209
|
-
* usage, props, …) are preserved
|
|
209
|
+
* usage, props, …) are preserved; each example carries its `kind`.
|
|
210
210
|
* @param {LoadedComponentDoc} docs
|
|
211
211
|
* @param {OwnershipSubject} owner
|
|
212
212
|
* @param {string} componentName
|
|
@@ -589,11 +589,26 @@ export function extractProps(docs) {
|
|
|
589
589
|
);
|
|
590
590
|
}
|
|
591
591
|
|
|
592
|
+
/**
|
|
593
|
+
* Give every example its `kind`, so a JSON reader never has to know the
|
|
594
|
+
* default: an example with no `kind` is a `demo`.
|
|
595
|
+
* @param {unknown} examples
|
|
596
|
+
* @returns {unknown}
|
|
597
|
+
*/
|
|
598
|
+
function withExampleKinds(examples) {
|
|
599
|
+
if (!Array.isArray(examples)) return examples;
|
|
600
|
+
return examples.map(example =>
|
|
601
|
+
example && typeof example === 'object'
|
|
602
|
+
? {...example, kind: example.kind ?? 'demo'}
|
|
603
|
+
: example,
|
|
604
|
+
);
|
|
605
|
+
}
|
|
606
|
+
|
|
592
607
|
/**
|
|
593
608
|
* Augment a loaded `component.detail` doc with ownership metadata. Adds
|
|
594
609
|
* `package`, the resolved `import` specifier, and `sourceAvailable` (whether a
|
|
595
610
|
* swizzleable source file exists for the owner). Existing doc fields (name,
|
|
596
|
-
* usage, props, …) are preserved
|
|
611
|
+
* usage, props, …) are preserved; each example carries its `kind`.
|
|
597
612
|
* @param {LoadedComponentDoc} docs
|
|
598
613
|
* @param {OwnershipSubject} owner
|
|
599
614
|
* @param {string} componentName
|
|
@@ -605,8 +620,20 @@ export function withOwnership(docs, owner, componentName, coreDir) {
|
|
|
605
620
|
owner.package === CORE_PACKAGE
|
|
606
621
|
? (docs.import ?? resolveImportPath(coreDir, componentName))
|
|
607
622
|
: resolveIntegrationImportPath(owner, componentName, docs.import);
|
|
623
|
+
/** @type {any} */
|
|
624
|
+
const doc = docs;
|
|
608
625
|
return /** @type {any} */ ({
|
|
609
626
|
...docs,
|
|
627
|
+
...(doc.examples ? {examples: withExampleKinds(doc.examples)} : {}),
|
|
628
|
+
...(Array.isArray(doc.components)
|
|
629
|
+
? {
|
|
630
|
+
components: doc.components.map((/** @type {any} */ entry) =>
|
|
631
|
+
entry?.examples
|
|
632
|
+
? {...entry, examples: withExampleKinds(entry.examples)}
|
|
633
|
+
: entry,
|
|
634
|
+
),
|
|
635
|
+
}
|
|
636
|
+
: {}),
|
|
610
637
|
package: owner.package,
|
|
611
638
|
import: importSpec,
|
|
612
639
|
sourceAvailable: owner.sourcePath != null,
|
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
// @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* A doctor check that reads only files, kept between runs through the kept
|
|
6
|
+
* gather (foundation/fs/gather-cache.mjs): a later `doctor` with every file,
|
|
7
|
+
* folder, module and environment variable it read unchanged reads the check
|
|
8
|
+
* back. Only the docs checks go through here; a check that depends on the
|
|
9
|
+
* time, the network or anything else the stamps do not see never does.
|
|
10
|
+
* @template T
|
|
11
|
+
* @param {{name: string, cwd: string, coreDir: string | null}} where - The
|
|
12
|
+
* check, the project folder, and the Core folder the project loads.
|
|
13
|
+
* @param {() => Promise<T>} check
|
|
14
|
+
* @returns {Promise<T>}
|
|
15
|
+
*/
|
|
16
|
+
export function keptFileCheck<T>({ name, cwd, coreDir }: {
|
|
17
|
+
name: string;
|
|
18
|
+
cwd: string;
|
|
19
|
+
coreDir: string | null;
|
|
20
|
+
}, check: () => Promise<T>): Promise<T>;
|
|
4
21
|
/**
|
|
5
22
|
* Package written to the generated app record for one discovered theme.
|
|
6
23
|
* @param {import('../../foundation/discovery/theme-discovery.mjs').DiscoveredTheme} theme
|
package/api/doctor/_adapter.mjs
CHANGED
|
@@ -45,6 +45,11 @@ export {unlistedIconSets} from '../../foundation/discovery/icon-set-discovery.mj
|
|
|
45
45
|
import {elementPropOrigins} from '../../foundation/discovery/module-exports.mjs';
|
|
46
46
|
import {cssImports} from '../../foundation/render/embedded-imports.mjs';
|
|
47
47
|
import * as path from 'node:path';
|
|
48
|
+
import {
|
|
49
|
+
persistedGather,
|
|
50
|
+
recordedRun,
|
|
51
|
+
} from '../../foundation/fs/gather-cache.mjs';
|
|
52
|
+
import {getCliInvocation} from '../../foundation/env/package-manager.mjs';
|
|
48
53
|
import {
|
|
49
54
|
Project,
|
|
50
55
|
availableComputerIntegrations,
|
|
@@ -83,6 +88,36 @@ export {
|
|
|
83
88
|
authoringAuditData,
|
|
84
89
|
} from './_authoring-audit.mjs';
|
|
85
90
|
|
|
91
|
+
/** A doctor check record, kept as it is. */
|
|
92
|
+
const CHECK_CODEC = {
|
|
93
|
+
encode: (/** @type {any} */ check) => check,
|
|
94
|
+
decode: (/** @type {any} */ check) => check,
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* A doctor check that reads only files, kept between runs through the kept
|
|
99
|
+
* gather (foundation/fs/gather-cache.mjs): a later `doctor` with every file,
|
|
100
|
+
* folder, module and environment variable it read unchanged reads the check
|
|
101
|
+
* back. Only the docs checks go through here; a check that depends on the
|
|
102
|
+
* time, the network or anything else the stamps do not see never does.
|
|
103
|
+
* @template T
|
|
104
|
+
* @param {{name: string, cwd: string, coreDir: string | null}} where - The
|
|
105
|
+
* check, the project folder, and the Core folder the project loads.
|
|
106
|
+
* @param {() => Promise<T>} check
|
|
107
|
+
* @returns {Promise<T>}
|
|
108
|
+
*/
|
|
109
|
+
export function keptFileCheck({name, cwd, coreDir}, check) {
|
|
110
|
+
// Only a recorded run (a plain `doctor` from the bin) reads or keeps one: a
|
|
111
|
+
// hosted run names its commands its own way, so it always checks.
|
|
112
|
+
if (!recordedRun()) return check();
|
|
113
|
+
return persistedGather(
|
|
114
|
+
// With the command name the checks print commands with.
|
|
115
|
+
['doctor-check', name, cwd, coreDir, getCliInvocation(cwd)],
|
|
116
|
+
check,
|
|
117
|
+
CHECK_CODEC,
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
86
121
|
/**
|
|
87
122
|
* Package written to the generated app record for one discovered theme.
|
|
88
123
|
* @param {import('../../foundation/discovery/theme-discovery.mjs').DiscoveredTheme} theme
|
package/api/doctor/doctor.mjs
CHANGED
|
@@ -100,6 +100,7 @@ import {
|
|
|
100
100
|
COMPUTER_INSTALL_STEP,
|
|
101
101
|
} from '../../foundation/agent-docs/computer-agent-text.mjs';
|
|
102
102
|
import {
|
|
103
|
+
keptFileCheck,
|
|
103
104
|
alignCommand,
|
|
104
105
|
addCliCommandFor,
|
|
105
106
|
computerAgentTextState,
|
|
@@ -2192,7 +2193,7 @@ export function checkGatherCache() {
|
|
|
2192
2193
|
id: 'gather-cache',
|
|
2193
2194
|
label: 'Kept catalog cache',
|
|
2194
2195
|
status: 'info',
|
|
2195
|
-
message: `search, build, component, template, theme and
|
|
2196
|
+
message: `search, build, component, template, theme, discover and doctor keep what they gather (search's catalogs, each integration's check results, and doctor's docs checks) in ${summary.dir} (${summary.entries} ${summary.entries === 1 ? 'entry' : 'entries'}, ${size})${summary.pnp ? ", but not in a run under Yarn Plug'n'Play's loader, such as `yarn astryx`, which gathers every time" : ''}; each is used only while nothing it read has changed, and deleting the folder clears it.`,
|
|
2196
2197
|
};
|
|
2197
2198
|
}
|
|
2198
2199
|
|
|
@@ -2465,9 +2466,22 @@ export async function runChecks(options = {}) {
|
|
|
2465
2466
|
);
|
|
2466
2467
|
}
|
|
2467
2468
|
checks.push(await checkAuthoringDocs(ctx));
|
|
2468
|
-
checks
|
|
2469
|
-
|
|
2470
|
-
|
|
2469
|
+
// The checks that read only files, each kept while every file it read is
|
|
2470
|
+
// unchanged; the Core the project loads is part of what they read.
|
|
2471
|
+
const where = {cwd, coreDir: coreDir ?? null};
|
|
2472
|
+
checks.push(
|
|
2473
|
+
await keptFileCheck({name: 'cli-docs', ...where}, () => checkCliDocs(ctx)),
|
|
2474
|
+
);
|
|
2475
|
+
checks.push(
|
|
2476
|
+
await keptFileCheck({name: 'docs-tree', ...where}, () =>
|
|
2477
|
+
checkDocsTree(ctx),
|
|
2478
|
+
),
|
|
2479
|
+
);
|
|
2480
|
+
checks.push(
|
|
2481
|
+
await keptFileCheck({name: 'docs-progressive', ...where}, () =>
|
|
2482
|
+
checkDocsProgressiveDisclosure(ctx),
|
|
2483
|
+
),
|
|
2484
|
+
);
|
|
2471
2485
|
|
|
2472
2486
|
const summary = {pass: 0, warn: 0, fail: 0, info: 0};
|
|
2473
2487
|
for (const c of checks) summary[c.status] += 1;
|
|
@@ -293,7 +293,7 @@ async function findUnreachableContributionIssues(
|
|
|
293
293
|
issues.push(
|
|
294
294
|
warning(
|
|
295
295
|
'unreachable_contribution',
|
|
296
|
-
`Found contribution metadata "${path.relative(packageDir, full)}" outside every declared integration root, so it contributes nothing. ${unreachableFix(context, full, stamp)}`,
|
|
296
|
+
`Found contribution metadata "${path.relative(packageDir, full).split(path.sep).join('/')}" outside every declared integration root, so it contributes nothing. ${unreachableFix(context, full, stamp)}`,
|
|
297
297
|
),
|
|
298
298
|
);
|
|
299
299
|
}
|
package/api/theme/_adapter.d.mts
CHANGED
|
@@ -78,8 +78,10 @@ export function listUnmigratedThemeCopies(cwd: string): import("../../foundation
|
|
|
78
78
|
* @param {{cwd: string, targetPath?: string, overwrite?: boolean, takenSlugs?: Set<string>}} options
|
|
79
79
|
* `takenSlugs`: the slugs of the themes the project can use, which a fork's
|
|
80
80
|
* new folder name may not take
|
|
81
|
-
* @returns {{outputDir: string, files: string[]
|
|
82
|
-
* directory
|
|
81
|
+
* @returns {{outputDir: string, files: string[], editorFolder: string | null}}
|
|
82
|
+
* the output directory relative to the working folder, the files written,
|
|
83
|
+
* named as the fork names them, and the folder the theme editor made that
|
|
84
|
+
* holds the fork, relative to the working folder, or null
|
|
83
85
|
*/
|
|
84
86
|
export function ejectThemeFiles(theme: import("../../foundation/discovery/theme-discovery.mjs").DiscoveredTheme, { cwd, targetPath: typedPath, overwrite, takenSlugs }: {
|
|
85
87
|
cwd: string;
|
|
@@ -89,6 +91,7 @@ export function ejectThemeFiles(theme: import("../../foundation/discovery/theme-
|
|
|
89
91
|
}): {
|
|
90
92
|
outputDir: string;
|
|
91
93
|
files: string[];
|
|
94
|
+
editorFolder: string | null;
|
|
92
95
|
};
|
|
93
96
|
/**
|
|
94
97
|
* The packages the fork imports that the app does not declare. A fork that
|
package/api/theme/_adapter.mjs
CHANGED
|
@@ -16,6 +16,7 @@ import {createRequire} from 'node:module';
|
|
|
16
16
|
import {
|
|
17
17
|
findCarriedCoreDir,
|
|
18
18
|
findPackageRoot,
|
|
19
|
+
projectWritePath,
|
|
19
20
|
requireCoreDir,
|
|
20
21
|
} from '../../foundation/fs/paths.mjs';
|
|
21
22
|
import {tryLock, userCacheDir} from '../../foundation/release/cache.mjs';
|
|
@@ -645,8 +646,10 @@ function themeDescriptorName(file) {
|
|
|
645
646
|
* @param {{cwd: string, targetPath?: string, overwrite?: boolean, takenSlugs?: Set<string>}} options
|
|
646
647
|
* `takenSlugs`: the slugs of the themes the project can use, which a fork's
|
|
647
648
|
* new folder name may not take
|
|
648
|
-
* @returns {{outputDir: string, files: string[]
|
|
649
|
-
* directory
|
|
649
|
+
* @returns {{outputDir: string, files: string[], editorFolder: string | null}}
|
|
650
|
+
* the output directory relative to the working folder, the files written,
|
|
651
|
+
* named as the fork names them, and the folder the theme editor made that
|
|
652
|
+
* holds the fork, relative to the working folder, or null
|
|
650
653
|
*/
|
|
651
654
|
export function ejectThemeFiles(
|
|
652
655
|
theme,
|
|
@@ -655,15 +658,17 @@ export function ejectThemeFiles(
|
|
|
655
658
|
// The fork lands in the project, as list and add read it: the default root
|
|
656
659
|
// is the project's, and a relative [path] is read from the working folder
|
|
657
660
|
// but must stay inside the project.
|
|
658
|
-
|
|
659
|
-
//
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
661
|
+
// Read as every theme command reads a path it writes; a backslash
|
|
662
|
+
// separates folders on every platform.
|
|
663
|
+
const {
|
|
664
|
+
projectDir,
|
|
665
|
+
typed: targetPath,
|
|
666
|
+
relative: target,
|
|
667
|
+
} = projectWritePath(
|
|
668
|
+
cwd,
|
|
669
|
+
typedPath || undefined,
|
|
670
|
+
defaultEjectTarget(theme.slug),
|
|
671
|
+
);
|
|
667
672
|
let resolvedDir;
|
|
668
673
|
try {
|
|
669
674
|
resolvedDir = assertWithin(target, projectDir, {
|
|
@@ -830,7 +835,33 @@ export function ejectThemeFiles(
|
|
|
830
835
|
throw new AstryxError(message, undefined, ERROR_CODES.ERR_WRITE_FAILED);
|
|
831
836
|
}
|
|
832
837
|
|
|
833
|
-
|
|
838
|
+
const editorDir = enclosingEditorFolder(resolvedDir, projectDir);
|
|
839
|
+
return {
|
|
840
|
+
outputDir: path.relative(cwd, resolvedDir) || '.',
|
|
841
|
+
files: names,
|
|
842
|
+
editorFolder:
|
|
843
|
+
editorDir == null ? null : path.relative(cwd, editorDir) || '.',
|
|
844
|
+
};
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
/**
|
|
848
|
+
* The nearest folder above `dir`, up to the project root, that the theme
|
|
849
|
+
* editor made, or null. Eject refuses the editor's folder itself; a subfolder
|
|
850
|
+
* of it is written as released CLIs did, with a warning.
|
|
851
|
+
* @param {string} dir
|
|
852
|
+
* @param {string} projectDir
|
|
853
|
+
* @returns {string | null}
|
|
854
|
+
*/
|
|
855
|
+
function enclosingEditorFolder(dir, projectDir) {
|
|
856
|
+
const root = path.resolve(projectDir);
|
|
857
|
+
let current = path.resolve(dir);
|
|
858
|
+
while (current !== root) {
|
|
859
|
+
const parent = path.dirname(current);
|
|
860
|
+
if (parent === current) return null;
|
|
861
|
+
current = parent;
|
|
862
|
+
if (editorThemeRecord(current)) return current;
|
|
863
|
+
}
|
|
864
|
+
return null;
|
|
834
865
|
}
|
|
835
866
|
|
|
836
867
|
/**
|
|
@@ -190,24 +190,7 @@ export function themeBuildFamily(files: string[], options: {
|
|
|
190
190
|
};
|
|
191
191
|
}, { cwd }?: {
|
|
192
192
|
cwd?: string;
|
|
193
|
-
}): Promise<{
|
|
194
|
-
type: string;
|
|
195
|
-
data: {
|
|
196
|
-
name: any;
|
|
197
|
-
upToDate: boolean;
|
|
198
|
-
stale: {
|
|
199
|
-
path: string;
|
|
200
|
-
reason: "missing" | "outdated";
|
|
201
|
-
}[];
|
|
202
|
-
checked: string[];
|
|
203
|
-
tokenCount?: undefined;
|
|
204
|
-
componentCount?: undefined;
|
|
205
|
-
sizeKB?: undefined;
|
|
206
|
-
outputs?: undefined;
|
|
207
|
-
warnings?: undefined;
|
|
208
|
-
notices?: undefined;
|
|
209
|
-
};
|
|
210
|
-
} | {
|
|
193
|
+
}): Promise<import("../theme.type.mjs").ThemeBuildCheckResponse | {
|
|
211
194
|
type: string;
|
|
212
195
|
data: {
|
|
213
196
|
name: any;
|
|
@@ -222,9 +205,6 @@ export function themeBuildFamily(files: string[], options: {
|
|
|
222
205
|
};
|
|
223
206
|
warnings: any[];
|
|
224
207
|
notices: string[];
|
|
225
|
-
upToDate?: undefined;
|
|
226
|
-
stale?: undefined;
|
|
227
|
-
checked?: undefined;
|
|
228
208
|
};
|
|
229
209
|
}>;
|
|
230
210
|
/**
|