@astryxdesign/cli 0.7.14 → 0.7.15-canary.g061b2fa
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 +63 -63
- package/api/build/_adapter.d.mts +4 -0
- package/api/build/_adapter.mjs +28 -2
- package/api/build/blocks/blocks.d.mts +10 -1
- package/api/build/blocks/blocks.mjs +84 -7
- package/api/build/build.mjs +6 -1
- package/api/build/tree.d.mts +4 -0
- package/api/build/tree.mjs +9 -2
- package/api/doctor/_adapter.d.mts +3 -1
- package/api/doctor/_adapter.mjs +14 -1
- package/api/doctor/_authoring-audit.d.mts +42 -0
- package/api/doctor/_authoring-audit.mjs +106 -0
- package/api/doctor/doctor.d.mts +7 -0
- package/api/doctor/doctor.mjs +24 -39
- package/api/doctor/theme-checks.mjs +56 -21
- package/api/integration/validate-integration.mjs +17 -3
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/search/_adapter.mjs +124 -3
- package/api/search/_candidate-score.mjs +63 -9
- package/api/search/_entries.d.mts +10 -0
- package/api/search/_entries.mjs +68 -1
- package/api/search/_gather-templates.d.mts +11 -0
- package/api/search/_gather-templates.mjs +22 -2
- package/api/search/_words.mjs +26 -6
- package/api/swizzle/copy/copy.mjs +1 -1
- package/api/theme/_adapter.d.mts +17 -1
- package/api/theme/_adapter.mjs +185 -40
- package/api/theme/build/build.d.mts +29 -1
- package/api/theme/build/build.mjs +426 -65
- package/api/theme/eject/eject.mjs +10 -6
- package/api/theme/targets/targets.d.mts +8 -0
- package/api/theme/targets/targets.mjs +24 -4
- package/api/theme/template/template.mjs +48 -2
- package/api/theme/theme.type.d.mts +8 -0
- package/api/theme/theme.type.mjs +5 -1
- package/api/theme/themeBuild.doc.mjs +7 -4
- package/api/theme/themeEject.doc.mjs +3 -3
- package/api/theme/themeRemove.doc.mjs +5 -2
- package/api/theme/themeTargets.doc.mjs +1 -1
- package/api/theme/themeTemplate.doc.mjs +2 -2
- package/api/theme/themeUse.doc.mjs +8 -2
- package/api/theme-edit/_adapter.d.mts +46 -3
- package/api/theme-edit/_adapter.mjs +372 -109
- package/api/theme-edit/_check.d.mts +6 -3
- package/api/theme-edit/_check.mjs +665 -87
- package/api/theme-edit/_color.mjs +4 -2
- package/api/theme-edit/_compiler.d.mts +2 -1
- package/api/theme-edit/_compiler.mjs +27 -13
- package/api/theme-edit/_context.d.mts +2 -1
- package/api/theme-edit/_context.mjs +47 -8
- package/api/theme-edit/_edit.d.mts +9 -3
- package/api/theme-edit/_edit.mjs +484 -66
- package/api/theme-edit/_how-commands.d.mts +33 -7
- package/api/theme-edit/_how-commands.mjs +57 -45
- package/api/theme-edit/_how-question.d.mts +4 -0
- package/api/theme-edit/_how-question.mjs +1004 -223
- package/api/theme-edit/_how.mjs +96 -9
- package/api/theme-edit/_palette.d.mts +38 -13
- package/api/theme-edit/_palette.mjs +620 -223
- package/api/theme-edit/_parts.mjs +63 -7
- package/api/theme-edit/_png.d.mts +4 -4
- package/api/theme-edit/_png.mjs +4 -2
- package/api/theme-edit/_preview-app.d.mts +6 -0
- package/api/theme-edit/_preview-app.mjs +1194 -207
- package/api/theme-edit/_preview.mjs +2 -2
- package/api/theme-edit/_project.d.mts +12 -1
- package/api/theme-edit/_project.mjs +37 -6
- package/api/theme-edit/_settings.d.mts +104 -33
- package/api/theme-edit/_settings.mjs +818 -118
- package/api/theme-edit/_tables.d.mts +7 -0
- package/api/theme-edit/_tables.mjs +61 -0
- package/api/theme-edit/theme-edit.type.d.mts +11 -1
- package/api/theme-edit/theme-edit.type.mjs +4 -3
- package/api/theme-edit/themeEditHow.doc.mjs +6 -0
- package/api/theme-edit/themeEditPreviewAdd.doc.mjs +1 -1
- package/api/theme-edit/themeEditPreviewApp.doc.mjs +1 -1
- package/api/theme-edit/themeEditPreviewList.doc.mjs +1 -1
- package/api/theme-edit/themeEditPreviewRemove.doc.mjs +5 -1
- package/api/theme-edit/themeEditUndo.doc.mjs +1 -1
- package/api/upgrade/_adapter.d.mts +1 -0
- package/assets/codemods/run-codemod.mjs +61 -0
- package/assets/codemods/runner.mjs +5 -4
- package/assets/codemods/transforms/v0.0.14/rename-status-variants.mjs +3 -0
- package/assets/codemods/transforms/v0.1.8/rename-avatar-size-scale.mjs +5 -1
- package/assets/codemods/transforms/v0.6.4/migrate-native-picker-to-presentation.mjs +3 -0
- package/assets/codemods/transforms/v0.7.0/migrate-deprecated-theme-surface.mjs +4 -0
- package/assets/codemods/transforms/v0.7.0/rename-empty-search-results-text.mjs +17 -12
- package/assets/codemods/transforms/v0.7.2/migrate-list-edge-compensation-to-edge.mjs +3 -0
- package/assets/codemods/transforms/v0.7.5/migrate-codeblock-tokenizer-to-language.mjs +3 -0
- package/assets/codemods/transforms/v0.7.8/promote-tokenizer-presentation.mjs +3 -0
- package/assets/docs/tree/calendars.doc.mjs +1 -3
- package/assets/docs/tree/checks.doc.mjs +22 -1
- package/assets/docs.generated.json +2 -1
- package/assets/self-audit.generated.json +1 -0
- package/assets/templates/blocks/components/Theme/useThemeNameHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Theme/useThemeNameHookUsage.tsx +31 -0
- package/assets/templates/components.generated.json +1 -1
- package/authoring/integration/integration.doc.mjs +8 -0
- package/authoring/integration/schema.d.mts +8 -0
- package/authoring/integration/schema.mjs +1 -0
- package/authoring/integration/type.ts +9 -0
- package/clients/cli/bin/astryx.mjs +19 -15
- package/clients/cli/build-id.generated.json +1 -0
- package/clients/cli/commands/ensure-core-built.mjs +12 -5
- package/clients/cli/commands/experimental/theme.mjs +178 -78
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -2
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-eject.doc.mjs +3 -3
- package/clients/cli/commands/experimental-theme-preview-add.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-list.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-remove.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-remove.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-template.doc.mjs +4 -3
- package/clients/cli/commands/manifest.mjs +5 -2
- package/clients/cli/commands/theme-build.doc.mjs +1 -1
- package/clients/cli/commands/theme-list.doc.mjs +1 -1
- package/clients/cli/commands/theme-template.doc.mjs +1 -1
- package/clients/cli/commands/theme.mjs +374 -42
- package/clients/cli/index.mjs +9 -3
- package/clients/cli/lib/manifest.mjs +37 -0
- package/clients/cli/lib/resolve-theme.mjs +2 -1
- package/clients/cli/manifest.generated.json +1 -0
- package/foundation/config/theme-state.d.mts +16 -0
- package/foundation/config/theme-state.mjs +84 -13
- package/foundation/discovery/module-exports.mjs +16 -2
- package/foundation/discovery/stored-self-audit.d.mts +31 -0
- package/foundation/discovery/stored-self-audit.mjs +119 -0
- package/foundation/discovery/template-adapter.d.mts +48 -2
- package/foundation/discovery/template-adapter.mjs +51 -19
- package/foundation/discovery/template-needs.d.mts +19 -0
- package/foundation/discovery/template-needs.mjs +50 -16
- package/foundation/discovery/template-source-tree.d.mts +7 -0
- package/foundation/discovery/template-source-tree.mjs +15 -0
- package/foundation/discovery/theme-discovery.d.mts +2 -1
- package/foundation/discovery/theme-discovery.mjs +2 -8
- package/foundation/discovery/theme-module-extensions.d.mts +18 -0
- package/foundation/discovery/theme-module-extensions.mjs +30 -0
- package/foundation/doc-compiler/import.mjs +22 -15
- package/foundation/doc-compiler/stored-docs.d.mts +18 -12
- package/foundation/doc-compiler/stored-docs.mjs +52 -19
- package/foundation/env/private-dir.d.mts +17 -0
- package/foundation/env/private-dir.mjs +42 -0
- package/foundation/fs/gather-cache.d.mts +108 -0
- package/foundation/fs/gather-cache.mjs +741 -0
- package/foundation/fs/jiti-cache.d.mts +21 -0
- package/foundation/fs/jiti-cache.mjs +66 -0
- package/foundation/fs/module-loader.mjs +14 -3
- package/foundation/fs/read-record.d.mts +31 -1
- package/foundation/fs/read-record.mjs +100 -7
- package/foundation/integrations/integrations.d.mts +8 -0
- package/foundation/integrations/integrations.mjs +4 -0
- package/foundation/integrations/validate-contributions.d.mts +62 -1
- package/foundation/integrations/validate-contributions.mjs +476 -40
- package/foundation/release/cache.d.mts +11 -2
- package/foundation/release/cache.mjs +59 -10
- package/foundation/release/folder-lock.d.mts +21 -0
- package/foundation/release/folder-lock.mjs +171 -0
- package/foundation/response/response-types.doc.mjs +1 -1
- package/package.json +8 -6
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
findTheme,
|
|
13
13
|
forkNeeds,
|
|
14
14
|
listAvailableThemes,
|
|
15
|
+
themeCommandsFor,
|
|
15
16
|
} from '../_adapter.mjs';
|
|
16
17
|
|
|
17
18
|
/**
|
|
@@ -34,17 +35,20 @@ export async function themeEject(slug, options = {}) {
|
|
|
34
35
|
cwd,
|
|
35
36
|
package: packageName,
|
|
36
37
|
includeLocal: false,
|
|
38
|
+
command: 'theme eject',
|
|
37
39
|
});
|
|
38
40
|
if (!match) {
|
|
39
41
|
const available = await listAvailableThemes(cwd, {includeLocal: false});
|
|
40
42
|
throw new AstryxError(
|
|
41
43
|
`Unknown theme "${slug}"${packageName ? ` in package "${packageName}"` : ''}`,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
themeCommandsFor('theme eject', slug, available, cwd).map(
|
|
45
|
+
({theme, name}) => ({
|
|
46
|
+
name,
|
|
47
|
+
reason: theme.bundled
|
|
48
|
+
? 'bundled theme'
|
|
49
|
+
: `provided by ${theme.package}`,
|
|
50
|
+
}),
|
|
51
|
+
),
|
|
48
52
|
ERROR_CODES.ERR_UNKNOWN_THEME,
|
|
49
53
|
);
|
|
50
54
|
}
|
|
@@ -1,6 +1,14 @@
|
|
|
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 targets filter as it is matched: trimmed, lowercase, and without a
|
|
6
|
+
* leading `.`, so a class copied from the output (`.astryx-switch`) reads as
|
|
7
|
+
* its name. Null when nothing is left, which means no filter.
|
|
8
|
+
* @param {string | undefined | null} filter
|
|
9
|
+
* @returns {string | null}
|
|
10
|
+
*/
|
|
11
|
+
export function normalizeTargetFilter(filter: string | undefined | null): string | null;
|
|
4
12
|
/**
|
|
5
13
|
* List every component theming target — the `defineTheme` `components` keys,
|
|
6
14
|
* with the props and states each one accepts.
|
|
@@ -15,6 +15,7 @@ import * as path from 'node:path';
|
|
|
15
15
|
import {requireThemeCoreDir} from '../_adapter.mjs';
|
|
16
16
|
import {collectThemingTargets} from '../../../foundation/discovery/theming-targets.mjs';
|
|
17
17
|
import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
|
|
18
|
+
import {formatCliCommand} from '../../../foundation/env/package-manager.mjs';
|
|
18
19
|
import {AstryxError, coreDirOrThrow} from '../../error.mjs';
|
|
19
20
|
|
|
20
21
|
/**
|
|
@@ -33,6 +34,19 @@ function matchesLoosely(target, filter) {
|
|
|
33
34
|
);
|
|
34
35
|
}
|
|
35
36
|
|
|
37
|
+
/**
|
|
38
|
+
* A targets filter as it is matched: trimmed, lowercase, and without a
|
|
39
|
+
* leading `.`, so a class copied from the output (`.astryx-switch`) reads as
|
|
40
|
+
* its name. Null when nothing is left, which means no filter.
|
|
41
|
+
* @param {string | undefined | null} filter
|
|
42
|
+
* @returns {string | null}
|
|
43
|
+
*/
|
|
44
|
+
export function normalizeTargetFilter(filter) {
|
|
45
|
+
return filter
|
|
46
|
+
? String(filter).trim().replace(/^\./, '').toLowerCase() || null
|
|
47
|
+
: null;
|
|
48
|
+
}
|
|
49
|
+
|
|
36
50
|
/**
|
|
37
51
|
* List every component theming target — the `defineTheme` `components` keys,
|
|
38
52
|
* with the props and states each one accepts.
|
|
@@ -49,7 +63,7 @@ export async function themeTargets(filter, {cwd = process.cwd()} = {}) {
|
|
|
49
63
|
const coreDir = coreDirOrThrow(requireThemeCoreDir, cwd);
|
|
50
64
|
|
|
51
65
|
const all = await collectThemingTargets(path.join(coreDir, 'src'));
|
|
52
|
-
const needle =
|
|
66
|
+
const needle = normalizeTargetFilter(filter);
|
|
53
67
|
let targets = all;
|
|
54
68
|
if (needle) {
|
|
55
69
|
const named = all.filter(t => t.component.toLowerCase() === needle);
|
|
@@ -61,10 +75,16 @@ export async function themeTargets(filter, {cwd = process.cwd()} = {}) {
|
|
|
61
75
|
.filter(name => name.toLowerCase().startsWith(needle.slice(0, 3)))
|
|
62
76
|
.sort()
|
|
63
77
|
.slice(0, 5)
|
|
64
|
-
.map(name => ({
|
|
78
|
+
.map(name => ({
|
|
79
|
+
name: formatCliCommand(`theme targets ${name}`, cwd),
|
|
80
|
+
reason: 'has theming targets',
|
|
81
|
+
}));
|
|
82
|
+
const listAll = formatCliCommand('theme targets', cwd);
|
|
65
83
|
throw new AstryxError(
|
|
66
|
-
`No theming target matches "${filter}". Run \`
|
|
67
|
-
near.length > 0
|
|
84
|
+
`No theming target matches "${filter}". Run \`${listAll}\` with no filter for the whole list.`,
|
|
85
|
+
near.length > 0
|
|
86
|
+
? near
|
|
87
|
+
: [{name: listAll, reason: 'every theming target'}],
|
|
68
88
|
ERROR_CODES.ERR_UNKNOWN_COMPONENT,
|
|
69
89
|
);
|
|
70
90
|
}
|
|
@@ -105,7 +105,19 @@ export function themeTemplate(options = {}) {
|
|
|
105
105
|
resolved = assertWithin(targetPath, cwd, {label: 'theme template path'});
|
|
106
106
|
} catch (err) {
|
|
107
107
|
if (err instanceof PathSafetyError) {
|
|
108
|
-
throw new AstryxError(
|
|
108
|
+
throw new AstryxError(
|
|
109
|
+
err.message,
|
|
110
|
+
[
|
|
111
|
+
{
|
|
112
|
+
name: formatCliCommand(
|
|
113
|
+
`theme template ${THEME_TEMPLATE_DEFAULT_PATH}`,
|
|
114
|
+
cwd,
|
|
115
|
+
),
|
|
116
|
+
reason: 'write the template in this project',
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
ERROR_CODES.ERR_PATH_TRAVERSAL,
|
|
120
|
+
);
|
|
109
121
|
}
|
|
110
122
|
throw err;
|
|
111
123
|
}
|
|
@@ -182,7 +194,21 @@ export function themeTemplate(options = {}) {
|
|
|
182
194
|
}
|
|
183
195
|
|
|
184
196
|
if (fs.existsSync(resolved) && !overwrite) {
|
|
185
|
-
|
|
197
|
+
// Whether --overwrite would replace this file, and if not, a path that
|
|
198
|
+
// takes the template, so the hint never names a command that refuses.
|
|
199
|
+
const overwritable =
|
|
200
|
+
!editorThemeRecord(path.dirname(resolved)) &&
|
|
201
|
+
isReplaceableThemeFile(resolved);
|
|
202
|
+
return {
|
|
203
|
+
type: 'theme.template',
|
|
204
|
+
data: {
|
|
205
|
+
path: relative,
|
|
206
|
+
written: false,
|
|
207
|
+
reason: 'exists',
|
|
208
|
+
overwritable,
|
|
209
|
+
alternative: overwritable ? null : freeTemplatePath(resolved, cwd),
|
|
210
|
+
},
|
|
211
|
+
};
|
|
186
212
|
}
|
|
187
213
|
|
|
188
214
|
// Our repo header has no business in someone else's source tree.
|
|
@@ -208,3 +234,23 @@ function isDirectory(file) {
|
|
|
208
234
|
return false;
|
|
209
235
|
}
|
|
210
236
|
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* A path near `file` that holds no file yet, for the template: the default
|
|
240
|
+
* name in its folder, then numbered names.
|
|
241
|
+
* @param {string} file
|
|
242
|
+
* @param {string} cwd
|
|
243
|
+
* @returns {string} relative to cwd, with `/`
|
|
244
|
+
*/
|
|
245
|
+
function freeTemplatePath(file, cwd) {
|
|
246
|
+
const dir = path.dirname(file);
|
|
247
|
+
for (let n = 1; n < 100; n += 1) {
|
|
248
|
+
const name =
|
|
249
|
+
n === 1 ? THEME_TEMPLATE_DEFAULT_PATH : `theme.template-${n}.ts`;
|
|
250
|
+
const candidate = path.join(dir, name);
|
|
251
|
+
if (!fs.existsSync(candidate)) {
|
|
252
|
+
return path.relative(cwd, candidate).split(path.sep).join('/');
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return THEME_TEMPLATE_DEFAULT_PATH;
|
|
256
|
+
}
|
|
@@ -193,10 +193,18 @@ export type ThemeEjectResponse = {
|
|
|
193
193
|
*/
|
|
194
194
|
export type ThemeTemplateResponse = {
|
|
195
195
|
type: "theme.template";
|
|
196
|
+
/**
|
|
197
|
+
* When the file was left as is, `overwritable` says whether `--overwrite`
|
|
198
|
+
* would replace it (a copy of the template or a theme source, outside a
|
|
199
|
+
* theme the editor made), and `alternative` is a free path for the template
|
|
200
|
+
* when it would not.
|
|
201
|
+
*/
|
|
196
202
|
data: {
|
|
197
203
|
path: string;
|
|
198
204
|
written: boolean;
|
|
199
205
|
reason: "exists" | null;
|
|
206
|
+
overwritable?: boolean;
|
|
207
|
+
alternative?: string | null;
|
|
200
208
|
};
|
|
201
209
|
};
|
|
202
210
|
/**
|
package/api/theme/theme.type.mjs
CHANGED
|
@@ -124,7 +124,11 @@
|
|
|
124
124
|
* re-run, and an edited template is the consumer's file to keep.
|
|
125
125
|
* @typedef {object} ThemeTemplateResponse
|
|
126
126
|
* @property {'theme.template'} type
|
|
127
|
-
* @property {{path: string, written: boolean, reason: 'exists' | null}} data
|
|
127
|
+
* @property {{path: string, written: boolean, reason: 'exists' | null, overwritable?: boolean, alternative?: string | null}} data
|
|
128
|
+
* When the file was left as is, `overwritable` says whether `--overwrite`
|
|
129
|
+
* would replace it (a copy of the template or a theme source, outside a
|
|
130
|
+
* theme the editor made), and `alternative` is a free path for the template
|
|
131
|
+
* when it would not.
|
|
128
132
|
*/
|
|
129
133
|
|
|
130
134
|
/**
|
|
@@ -58,7 +58,7 @@ export const doc = {
|
|
|
58
58
|
name: 'options.out',
|
|
59
59
|
type: 'string',
|
|
60
60
|
description:
|
|
61
|
-
'Override the output CSS path, relative or absolute; a build refuses a path outside cwd, and check mode refuses only a relative path that escapes cwd. The .js, .d.ts and any .variants.d.ts are written in the same directory, named after the theme (<name>.js), not after the CSS file. An existing folder, or a path that ends in a separator, names the folder: the CSS is written there as <name>.css.',
|
|
61
|
+
'Override the output CSS path, relative or absolute; a build refuses a path outside cwd, and check mode refuses only a relative path that escapes cwd. The .js, .d.ts and any .variants.d.ts are written in the same directory, named after the theme (<name>.js), not after the CSS file. An existing folder, or a path that ends in a separator, names the folder: the CSS is written there as <name>.css. A file path should end in .css; another name still builds, with a warning, and the import line it prints names the file as written.',
|
|
62
62
|
},
|
|
63
63
|
{
|
|
64
64
|
name: 'options.check',
|
|
@@ -94,14 +94,17 @@ export const doc = {
|
|
|
94
94
|
},
|
|
95
95
|
],
|
|
96
96
|
throws: [
|
|
97
|
-
{
|
|
97
|
+
{
|
|
98
|
+
code: 'ERR_FILE_NOT_FOUND',
|
|
99
|
+
when: 'the theme file does not exist; for a bare theme name or a path written with backslashes, the suggestions name the theme sources that exist',
|
|
100
|
+
},
|
|
98
101
|
{
|
|
99
102
|
code: 'ERR_THEME_LOAD',
|
|
100
|
-
when: 'the file cannot be loaded or parsed into a defineTheme() result',
|
|
103
|
+
when: 'the file cannot be loaded or parsed into a defineTheme() result, or its extension is not one a theme source has (.mjs, .js, .mts, .ts, .tsx, .jsx, .cjs, .cts), which is refused before loading',
|
|
101
104
|
},
|
|
102
105
|
{
|
|
103
106
|
code: 'ERR_THEME_INVALID',
|
|
104
|
-
when: 'the resolved theme is invalid, for example it has no name, a custom Heading type has no standalone rule with a declaration the compiler can emit, or its icon registry cannot be preserved through an import (also rejected in check mode); or an output would replace the theme source, two outputs share one path, or the file is itself an output of a build',
|
|
107
|
+
when: 'the resolved theme is invalid, for example it has no name, a custom Heading type has no standalone rule with a declaration the compiler can emit, or its icon registry cannot be preserved through an import (also rejected in check mode); or an output would replace the theme source, two outputs share one path, or the file is itself an output of a build, whatever its extension (refused before loading, naming the source it was built from); in a batch, two themes that build the same outputs are refused before either writes',
|
|
105
108
|
},
|
|
106
109
|
{
|
|
107
110
|
code: 'ERR_FILE_EXISTS',
|
|
@@ -30,8 +30,8 @@ export const doc = {
|
|
|
30
30
|
name: 'options.targetPath',
|
|
31
31
|
type: 'string',
|
|
32
32
|
description:
|
|
33
|
-
'Destination directory for ejected files. Must resolve within cwd.',
|
|
34
|
-
default: "'src/themes/<slug>'",
|
|
33
|
+
'Destination directory for ejected files, relative to cwd. Must resolve within the project (the nearest folder above cwd with a package.json).',
|
|
34
|
+
default: "'src/themes/<slug>' in the project root",
|
|
35
35
|
},
|
|
36
36
|
{
|
|
37
37
|
name: 'options.overwrite',
|
|
@@ -43,7 +43,7 @@ export const doc = {
|
|
|
43
43
|
name: 'options.cwd',
|
|
44
44
|
type: 'string',
|
|
45
45
|
description:
|
|
46
|
-
'
|
|
46
|
+
'Working directory: integration discovery and the project root start here, a relative targetPath resolves from it, and outputDir is relative to it.',
|
|
47
47
|
},
|
|
48
48
|
{
|
|
49
49
|
name: 'options.package',
|
|
@@ -37,10 +37,13 @@ export const doc = {
|
|
|
37
37
|
},
|
|
38
38
|
],
|
|
39
39
|
throws: [
|
|
40
|
-
{
|
|
40
|
+
{
|
|
41
|
+
code: 'ERR_UNKNOWN_THEME',
|
|
42
|
+
when: 'the theme is not added; the suggestion is `theme add <slug>` when a theme with that slug is available, else `theme list`',
|
|
43
|
+
},
|
|
41
44
|
{
|
|
42
45
|
code: 'ERR_THEME_INVALID',
|
|
43
|
-
when: 'the theme is the default or generated state is invalid',
|
|
46
|
+
when: 'the theme is the default (the suggestions name `theme use` with up to three other added themes, or `theme list` when it is the only one), generated state is invalid, or the slug is not added and names a local theme folder that is broken',
|
|
44
47
|
},
|
|
45
48
|
{code: 'ERR_WRITE_FAILED', when: 'the generated module cannot be written'},
|
|
46
49
|
],
|
|
@@ -40,7 +40,7 @@ export const doc = {
|
|
|
40
40
|
name: 'filter',
|
|
41
41
|
type: 'string',
|
|
42
42
|
description:
|
|
43
|
-
'A component name (exact, case-insensitive), or a substring of a target key, class or component. Omit for the whole surface.',
|
|
43
|
+
'A component name (exact, case-insensitive), or a substring of a target key, class or component. A class selector as the output prints it (`.astryx-switch`) reads without its dot, and surrounding spaces are ignored. Omit for the whole surface.',
|
|
44
44
|
},
|
|
45
45
|
{
|
|
46
46
|
name: 'ctx.cwd',
|
|
@@ -51,14 +51,14 @@ export const doc = {
|
|
|
51
51
|
{
|
|
52
52
|
type: 'theme.template',
|
|
53
53
|
description:
|
|
54
|
-
'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.',
|
|
54
|
+
'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; then `overwritable` says whether overwrite would replace that file, and `alternative` is a free path for the template when it would not.',
|
|
55
55
|
},
|
|
56
56
|
],
|
|
57
57
|
throws: [
|
|
58
58
|
{code: 'ERR_PATH_TRAVERSAL', when: 'the target path escapes cwd'},
|
|
59
59
|
{
|
|
60
60
|
code: 'ERR_INVALID_ARGUMENT',
|
|
61
|
-
when: 'the target path is blank, names a folder, or is not a .ts file',
|
|
61
|
+
when: 'the target path is blank, names a folder, or is not a .ts file (with or without overwrite)',
|
|
62
62
|
},
|
|
63
63
|
{
|
|
64
64
|
code: 'ERR_FILE_EXISTS',
|
|
@@ -37,8 +37,14 @@ export const doc = {
|
|
|
37
37
|
},
|
|
38
38
|
],
|
|
39
39
|
throws: [
|
|
40
|
-
{
|
|
41
|
-
|
|
40
|
+
{
|
|
41
|
+
code: 'ERR_UNKNOWN_THEME',
|
|
42
|
+
when: 'the theme is not added; the suggestion is `theme add <slug>` when a theme with that slug is available, else `theme list`',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
code: 'ERR_THEME_INVALID',
|
|
46
|
+
when: 'generated state is invalid, or the slug is not added and names a local theme folder that is broken',
|
|
47
|
+
},
|
|
42
48
|
{code: 'ERR_WRITE_FAILED', when: 'the generated module cannot be written'},
|
|
43
49
|
],
|
|
44
50
|
examples: [{label: 'Choose the default', code: "await themeUse('ocean');"}],
|
|
@@ -1,6 +1,15 @@
|
|
|
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
|
+
* `how`, run at the project root like the other editor commands, so a
|
|
6
|
+
* subfolder finds the app's themes. A picture named from the subfolder
|
|
7
|
+
* keeps pointing where it was named.
|
|
8
|
+
* @param {string} subject
|
|
9
|
+
* @param {import('./theme-edit.type.mjs').ThemeEditHowOptions} [options]
|
|
10
|
+
* @returns {Promise<import('./theme-edit.type.mjs').ThemeEditHowResponse>}
|
|
11
|
+
*/
|
|
12
|
+
export function themeEditHow(subject: string, options?: import("./theme-edit.type.mjs").ThemeEditHowOptions): Promise<import("./theme-edit.type.mjs").ThemeEditHowResponse>;
|
|
4
13
|
/**
|
|
5
14
|
* The project a command acts on: the Astryx project at or above `cwd`, found
|
|
6
15
|
* as `upgrade` finds it (the nearest package that declares an Astryx package
|
|
@@ -12,8 +21,42 @@
|
|
|
12
21
|
* @param {string} cwd
|
|
13
22
|
*/
|
|
14
23
|
export function projectRoot(cwd: string): string;
|
|
15
|
-
|
|
16
|
-
|
|
24
|
+
/**
|
|
25
|
+
* A clearer refusal for a theme the editor made, named to list, add, use,
|
|
26
|
+
* remove or eject: those commands work on package themes, and the editor
|
|
27
|
+
* theme is used by importing its module. Null for any other refusal.
|
|
28
|
+
* @param {AstryxError} err
|
|
29
|
+
* @param {string} cwd
|
|
30
|
+
* @returns {AstryxError | null}
|
|
31
|
+
*/
|
|
32
|
+
export function editorThemeRefusal(err: AstryxError, cwd: string): AstryxError | null;
|
|
33
|
+
/**
|
|
34
|
+
* A refusal before `compile` runs on an editor theme's files, or null: the
|
|
35
|
+
* editor's generated settings are not a theme source, `--family` does not
|
|
36
|
+
* take an editor theme, and `--check` checks an editor theme by the editor's
|
|
37
|
+
* own rules (waiting for a change in progress).
|
|
38
|
+
* @param {string[]} files
|
|
39
|
+
* @param {{cwd: string, check?: boolean, family?: boolean}} options
|
|
40
|
+
* @returns {Promise<AstryxError | null>}
|
|
41
|
+
*/
|
|
42
|
+
export function editorCompileProblem(files: string[], { cwd, check, family }: {
|
|
43
|
+
cwd: string;
|
|
44
|
+
check?: boolean;
|
|
45
|
+
family?: boolean;
|
|
46
|
+
}): Promise<AstryxError | null>;
|
|
47
|
+
/**
|
|
48
|
+
* Hold the theme lock of every editor theme among the files while
|
|
49
|
+
* `compile` builds or checks them, so it never reads a change half
|
|
50
|
+
* written. Resolves to the release.
|
|
51
|
+
* @param {string[]} files
|
|
52
|
+
* @param {{cwd: string}} options
|
|
53
|
+
* @returns {Promise<() => Promise<void>>}
|
|
54
|
+
*/
|
|
55
|
+
export function editorThemeHold(files: string[], { cwd }: {
|
|
56
|
+
cwd: string;
|
|
57
|
+
}): Promise<() => Promise<void>>;
|
|
58
|
+
export { parsePoints } from "./_how.mjs";
|
|
59
|
+
export function builtInThemes(): string[];
|
|
17
60
|
/** @type {typeof edit.themeEditNew} */
|
|
18
61
|
export const themeEditNew: typeof edit.themeEditNew;
|
|
19
62
|
/** @type {typeof edit.themeEditSet} */
|
|
@@ -35,6 +78,6 @@ export const themeEditPreviewApp: typeof preview.themeEditPreviewApp;
|
|
|
35
78
|
export const themeEditPreviewList: typeof preview.themeEditPreviewList;
|
|
36
79
|
/** @type {typeof preview.themeEditPreviewRemove} */
|
|
37
80
|
export const themeEditPreviewRemove: typeof preview.themeEditPreviewRemove;
|
|
81
|
+
import { AstryxError } from '../error.mjs';
|
|
38
82
|
import * as edit from './_edit.mjs';
|
|
39
83
|
import * as preview from './_preview-app.mjs';
|
|
40
|
-
export { themeEditHow, parsePoints } from "./_how.mjs";
|