@astryxdesign/cli 0.6.6-canary.fcf255b → 0.6.6-canary.ffa4f72
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 +83 -83
- package/api/build/_adapter.d.mts +15 -0
- package/api/build/_adapter.mjs +22 -0
- package/api/build/build.doc.mjs +1 -1
- package/api/build/build.type.d.mts +4 -0
- package/api/build/build.type.mjs +1 -0
- package/api/build/help/help.mjs +1 -1
- package/api/build/kit/kit.mjs +12 -1
- package/api/component/component-replacement.test.mjs +12 -0
- package/api/component/component.doc.mjs +5 -2
- package/api/docs/_adapter.mjs +48 -1
- package/api/docs/compiled-topics.test.mjs +1 -1
- package/api/docs/detail/section/section.d.mts +44 -0
- package/api/docs/detail/section/section.mjs +164 -13
- package/api/docs/detail/section/section.test.mjs +4 -4
- package/api/docs/docOverlays.test.mjs +28 -17
- package/api/docs/docs.doc.mjs +3 -3
- package/api/docs/docs.mjs +11 -16
- package/api/docs/docs.test.mjs +9 -10
- package/api/docs/integration-tree.test.mjs +26 -26
- package/api/docs/integrationDocs.test.mjs +2 -2
- package/api/docs/namespace-section.test.mjs +260 -0
- package/api/docs/token-tables.test.mjs +93 -0
- package/api/doctor/_adapter.d.mts +7 -0
- package/api/doctor/_adapter.mjs +48 -0
- package/api/doctor/doctor.d.mts +6 -0
- package/api/doctor/doctor.mjs +154 -43
- package/api/doctor/doctor.test.mjs +104 -0
- package/api/doctor/theme-checks.d.mts +12 -0
- package/api/doctor/theme-checks.mjs +115 -1
- package/api/doctor/theme-checks.test.mjs +142 -1
- package/api/gap-report/gap-report.doc.mjs +2 -1
- package/api/init/run/run.mjs +1 -0
- package/api/integration/validate-integration.mjs +20 -4
- package/api/integration/validate-integration.test.mjs +73 -0
- package/api/layout/check/check.d.mts +1 -0
- package/api/layout/check/check.mjs +1 -0
- package/api/layout/expand/expand.d.mts +1 -0
- package/api/layout/expand/expand.mjs +1 -0
- package/api/layout/grammar/grammar.d.mts +1 -0
- package/api/layout/grammar/grammar.mjs +1 -0
- package/api/layout/layoutCheck.doc.mjs +1 -1
- package/api/layout/layoutExpand.doc.mjs +1 -1
- package/api/layout/layoutGrammar.doc.mjs +1 -1
- package/api/search/search.d.mts +44 -0
- package/api/search/search.domain-priority.test.mjs +261 -0
- package/api/search/search.mjs +191 -29
- package/api/swizzle/swizzle.doc.mjs +5 -2
- package/api/template/copy/copy.mjs +12 -0
- package/api/template/template.doc.mjs +1 -1
- package/api/template/template.type.d.mts +3 -0
- package/api/template/template.type.mjs +3 -0
- package/api/theme/build/build.d.mts +70 -0
- package/api/theme/build/build.mjs +205 -41
- package/api/theme/build/font-warning.d.mts +11 -0
- package/api/theme/build/font-warning.mjs +28 -3
- package/assets/docs/author-a-theme.doc.mjs +19 -14
- package/assets/docs/getting-started.doc.mjs +2 -2
- package/assets/docs/principles.doc.dense.mjs +3 -3
- package/assets/docs/principles.doc.mjs +4 -4
- package/assets/docs/principles.doc.zh.mjs +3 -3
- package/assets/docs/styling-overview.doc.mjs +211 -0
- package/assets/docs/theme.doc.dense.mjs +1 -1
- package/assets/docs/theme.doc.mjs +5 -5
- package/assets/docs/theme.doc.zh.mjs +1 -1
- package/assets/docs/tree/component-migration.doc.mjs +107 -0
- package/assets/docs/tree/css-and-stylex.doc.mjs +150 -0
- package/assets/docs/tree/font-setup.doc.mjs +122 -0
- package/assets/docs/tree/headers-and-footers.doc.mjs +0 -1
- package/assets/docs/tree/i18n-library-integration.doc.mjs +167 -0
- package/assets/docs/tree/i18n-quick-start.doc.mjs +101 -0
- package/assets/docs/{internationalization.doc.mjs → tree/i18n-rtl-and-testing.doc.mjs} +17 -223
- package/assets/docs/tree/internationalization.doc.mjs +29 -0
- package/assets/docs/tree/layout.doc.mjs +23 -0
- package/assets/docs/{migration.doc.mjs → tree/migration-setup.doc.mjs} +24 -129
- package/assets/docs/tree/migration-verification.doc.mjs +67 -0
- package/assets/docs/tree/migration.doc.mjs +28 -0
- package/assets/docs/tree/non-css-processing.doc.mjs +112 -0
- package/assets/docs/tree/other-libraries.doc.mjs +218 -0
- package/assets/docs/tree/responsive.doc.mjs +0 -4
- package/assets/docs/tree/scaffold.doc.mjs +0 -5
- package/assets/docs/tree/side-panels.doc.mjs +0 -1
- package/assets/docs/tree/structure.doc.mjs +0 -4
- package/assets/docs/tree/styling-advanced.doc.mjs +159 -0
- package/assets/docs/tree/styling-basics.doc.mjs +181 -0
- package/assets/docs/tree/styling-libraries.doc.mjs +30 -0
- package/assets/docs/tree/styling.doc.mjs +29 -0
- package/assets/docs/tree/tailwind.doc.mjs +65 -0
- package/assets/docs/tree/tokens-and-setup.doc.mjs +128 -0
- package/assets/docs/tree/tokens-border.doc.mjs +46 -0
- package/assets/docs/tree/tokens-color.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-color.doc.mjs +438 -0
- package/assets/docs/tree/tokens-color.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-data.doc.mjs +323 -0
- package/assets/docs/tree/tokens-duration.doc.mjs +78 -0
- package/assets/docs/tree/tokens-ease.doc.mjs +46 -0
- package/assets/docs/tree/tokens-focus.doc.mjs +57 -0
- package/assets/docs/tree/tokens-font-weight.doc.mjs +58 -0
- package/assets/docs/tree/tokens-radius.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-radius.doc.mjs +70 -0
- package/assets/docs/tree/tokens-radius.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-shadow.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-shadow.doc.mjs +74 -0
- package/assets/docs/tree/tokens-shadow.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-size.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-size.doc.mjs +54 -0
- package/assets/docs/tree/tokens-size.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-spacing.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-spacing.doc.mjs +102 -0
- package/assets/docs/tree/tokens-spacing.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-syntax.doc.mjs +98 -0
- package/assets/docs/tree/tokens-text-size.doc.mjs +90 -0
- package/assets/docs/tree/tokens-type-scale.doc.mjs +210 -0
- package/assets/docs/tree/tokens-typography.doc.mjs +54 -0
- package/assets/docs/tree/tokens-usage.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-usage.doc.mjs +36 -0
- package/assets/docs/tree/tokens-usage.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens.doc.mjs +28 -0
- package/assets/docs/tree/type-scale.doc.mjs +147 -0
- package/assets/docs/tree/typography-best-practices.doc.mjs +55 -0
- package/assets/docs/tree/typography.doc.mjs +29 -0
- package/assets/docs/use-a-theme.doc.mjs +162 -47
- package/assets/templates/pages/incident-console/page.tsx +1 -1
- package/assets/templates/pages/table-comparison/template.doc.mjs +1 -1
- package/assets/theme.template.ts +4 -3
- package/authoring/doctypes/template/type.ts +1 -0
- package/clients/cli/commands/blog.mjs +3 -3
- package/clients/cli/commands/build-theme.adaptations.test.mjs +1 -1
- package/clients/cli/commands/build-theme.ascii-output.test.mjs +11 -1
- package/clients/cli/commands/build-theme.batch-report.test.mjs +335 -0
- package/clients/cli/commands/build-theme.font-warning.test.mjs +36 -7
- package/clients/cli/commands/build-theme.import-path.test.mjs +3 -3
- package/clients/cli/commands/build-theme.mjs +68 -18
- package/clients/cli/commands/build-theme.watch.test.mjs +33 -0
- package/clients/cli/commands/build.mjs +1 -0
- package/clients/cli/commands/component/index.mjs +4 -1
- package/clients/cli/commands/component-replacement.text.test.mjs +45 -0
- package/clients/cli/commands/docs.doc.mjs +2 -1
- package/clients/cli/commands/docs.test.mjs +16 -13
- package/clients/cli/commands/doctor-integration-components.doc.mjs +1 -1
- package/clients/cli/commands/doctor.doc.mjs +1 -1
- package/clients/cli/commands/doctor.test.mjs +50 -1
- package/clients/cli/commands/import-hint-correctness.test.mjs +23 -0
- package/clients/cli/commands/layout-check.doc.mjs +1 -0
- package/clients/cli/commands/layout-expand.doc.mjs +1 -0
- package/clients/cli/commands/layout-grammar.doc.mjs +1 -0
- package/clients/cli/commands/layout.deprecation-lifecycle.test.mjs +140 -0
- package/clients/cli/commands/layout.doc.mjs +1 -0
- package/clients/cli/commands/layout.mjs +6 -11
- package/clients/cli/commands/search.test.mjs +6 -2
- package/clients/cli/commands/swizzle.routing.test.mjs +2 -1
- package/clients/cli/commands/template.mjs +4 -3
- package/clients/cli/commands/theme-add-lifecycle.test.mjs +9 -6
- package/clients/cli/commands/theme-build.doc.mjs +3 -1
- package/clients/cli/commands/upgrade.config-ordering.test.mjs +2 -1
- package/clients/cli/index.mjs +1 -1
- package/clients/cli/lib/component-format.mjs +13 -3
- package/clients/cli/lib/component-format.test.mjs +1 -1
- package/clients/cli/lib/define-command.mjs +4 -0
- package/foundation/agent-docs/agent-docs.mjs +18 -2
- package/foundation/agent-docs/agent-docs.test.mjs +18 -0
- package/foundation/config/project.test.mjs +1 -1
- package/foundation/discovery/docs-discovery.test.mjs +1 -1
- package/foundation/discovery/template-needs.d.mts +31 -0
- package/foundation/discovery/template-needs.mjs +156 -0
- package/foundation/discovery/template-needs.test.mjs +203 -0
- package/foundation/doc-compiler/bundle.mjs +52 -1
- package/foundation/doc-compiler/split-topic-keywords.test.mjs +73 -0
- package/foundation/doc-compiler/tree.d.mts +10 -0
- package/foundation/doc-compiler/tree.mjs +22 -0
- package/foundation/doc-compiler/tree.test.mjs +3 -2
- package/foundation/env/package-manager.d.mts +31 -8
- package/foundation/env/package-manager.mjs +120 -13
- package/foundation/env/package-manager.test.mjs +174 -1
- package/foundation/integrations/validate-contributions.d.mts +16 -0
- package/foundation/integrations/validate-contributions.mjs +56 -8
- package/foundation/response/response-types.doc.mjs +4 -4
- package/package.json +9 -9
- package/assets/docs/styling-libraries.doc.mjs +0 -469
- package/assets/docs/styling.doc.mjs +0 -412
- package/assets/docs/tokens.doc.dense.mjs +0 -15
- package/assets/docs/tokens.doc.mjs +0 -1491
- package/assets/docs/tokens.doc.zh.mjs +0 -15
- package/assets/docs/typography.doc.mjs +0 -286
|
@@ -6,7 +6,8 @@ import {afterEach, describe, expect, it} from 'vitest';
|
|
|
6
6
|
import * as fs from 'node:fs';
|
|
7
7
|
import * as path from 'node:path';
|
|
8
8
|
import {spawnSync} from 'node:child_process';
|
|
9
|
-
import {checkAppThemes} from './theme-checks.mjs';
|
|
9
|
+
import {checkAppThemes, checkThemes} from './theme-checks.mjs';
|
|
10
|
+
import {runChecks} from './doctor.mjs';
|
|
10
11
|
import {themeAdd} from '../theme/add/add.mjs';
|
|
11
12
|
import {themeEject} from '../theme/eject/eject.mjs';
|
|
12
13
|
import {themeBuild} from '../theme/build/build.mjs';
|
|
@@ -140,6 +141,146 @@ afterEach(() => {
|
|
|
140
141
|
}
|
|
141
142
|
});
|
|
142
143
|
|
|
144
|
+
describe('the released themes check', () => {
|
|
145
|
+
/** @param {string} name */
|
|
146
|
+
function emptyApp(name) {
|
|
147
|
+
const dir = fs.mkdtempSync(
|
|
148
|
+
path.join(process.cwd(), `.astryx-doctor-${name}-`),
|
|
149
|
+
);
|
|
150
|
+
dirs.push(dir);
|
|
151
|
+
write(path.join(dir, 'package.json'), '{"name":"app","private":true}\n');
|
|
152
|
+
return dir;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** @param {string} dir @param {string} slug */
|
|
156
|
+
function installThemePackage(dir, slug) {
|
|
157
|
+
write(
|
|
158
|
+
path.join(
|
|
159
|
+
dir,
|
|
160
|
+
'node_modules/@astryxdesign',
|
|
161
|
+
`theme-${slug}`,
|
|
162
|
+
'package.json',
|
|
163
|
+
),
|
|
164
|
+
JSON.stringify({name: `@astryxdesign/theme-${slug}`, version: '1.0.0'}),
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
it('keeps its released id, label, fields, and statuses without a generated theme module', async () => {
|
|
169
|
+
const dir = emptyApp('themes-none');
|
|
170
|
+
expect(checkThemes(dir, await checkAppThemes(dir))).toEqual({
|
|
171
|
+
id: 'themes',
|
|
172
|
+
label: 'Theme packages',
|
|
173
|
+
status: 'warn',
|
|
174
|
+
message: 'No @astryxdesign/theme-* packages are installed.',
|
|
175
|
+
fix: expect.stringContaining('theme add neutral --import'),
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
installThemePackage(dir, 'neutral');
|
|
179
|
+
const unwired = checkThemes(dir, await checkAppThemes(dir));
|
|
180
|
+
expect(unwired).toEqual({
|
|
181
|
+
id: 'themes',
|
|
182
|
+
label: 'Theme packages',
|
|
183
|
+
status: 'warn',
|
|
184
|
+
message:
|
|
185
|
+
'Theme package(s) installed (@astryxdesign/theme-neutral) but no theme appears wired.',
|
|
186
|
+
fix: expect.stringContaining('theme add <slug> --import'),
|
|
187
|
+
});
|
|
188
|
+
expect(unwired.fix).not.toContain('ASTRYX_THEME');
|
|
189
|
+
|
|
190
|
+
write(
|
|
191
|
+
path.join(dir, 'package.json'),
|
|
192
|
+
JSON.stringify({
|
|
193
|
+
name: 'app',
|
|
194
|
+
private: true,
|
|
195
|
+
astryx: {theme: '@astryxdesign/theme-neutral'},
|
|
196
|
+
}),
|
|
197
|
+
);
|
|
198
|
+
expect(checkThemes(dir, await checkAppThemes(dir))).toEqual({
|
|
199
|
+
id: 'themes',
|
|
200
|
+
label: 'Theme packages',
|
|
201
|
+
status: 'pass',
|
|
202
|
+
message:
|
|
203
|
+
'Theme package(s) installed (@astryxdesign/theme-neutral); wired via package.json astryx.theme.',
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it('reports the overall result of the app-theme checks with a generated module', async () => {
|
|
208
|
+
const healthy = await fixture();
|
|
209
|
+
expect(checkThemes(healthy.dir, await checkAppThemes(healthy.dir))).toEqual(
|
|
210
|
+
{
|
|
211
|
+
id: 'themes',
|
|
212
|
+
label: 'Theme packages',
|
|
213
|
+
status: 'pass',
|
|
214
|
+
message:
|
|
215
|
+
'App themes come from the generated theme module, and every theme check passes.',
|
|
216
|
+
},
|
|
217
|
+
);
|
|
218
|
+
|
|
219
|
+
// A module is loaded once per process, so the broken one is a new fixture.
|
|
220
|
+
const {dir, packageDir} = await fixture();
|
|
221
|
+
write(
|
|
222
|
+
path.join(packageDir, 'dist/ocean.js'),
|
|
223
|
+
`import '@acme/definitely-missing-dep';\nexport const oceanTheme = {name: 'ocean', tokens: {}};\n`,
|
|
224
|
+
);
|
|
225
|
+
expect(checkThemes(dir, await checkAppThemes(dir))).toEqual({
|
|
226
|
+
id: 'themes',
|
|
227
|
+
label: 'Theme packages',
|
|
228
|
+
status: 'fail',
|
|
229
|
+
message: 'One theme check needs attention: theme-owners.',
|
|
230
|
+
fix: 'Follow the fix on the theme-owners check.',
|
|
231
|
+
});
|
|
232
|
+
}, 30_000);
|
|
233
|
+
|
|
234
|
+
it('passes the module rollup only when every summarized check passed', () => {
|
|
235
|
+
/** @param {string} id @param {'pass'|'warn'|'fail'|'info'} status */
|
|
236
|
+
const result = (id, status) => ({id, label: id, status, message: id});
|
|
237
|
+
const passing = [
|
|
238
|
+
result('theme-owners', 'pass'),
|
|
239
|
+
result('theme-module', 'pass'),
|
|
240
|
+
];
|
|
241
|
+
|
|
242
|
+
expect(
|
|
243
|
+
checkThemes(process.cwd(), [
|
|
244
|
+
...passing,
|
|
245
|
+
result('theme-stylesheet-imports', 'info'),
|
|
246
|
+
]),
|
|
247
|
+
).toEqual({
|
|
248
|
+
id: 'themes',
|
|
249
|
+
label: 'Theme packages',
|
|
250
|
+
status: 'info',
|
|
251
|
+
message:
|
|
252
|
+
'One theme check could not prove its result: theme-stylesheet-imports.',
|
|
253
|
+
fix: 'See the theme-stylesheet-imports check.',
|
|
254
|
+
});
|
|
255
|
+
expect(
|
|
256
|
+
checkThemes(process.cwd(), [
|
|
257
|
+
result('theme-owners', 'fail'),
|
|
258
|
+
result('theme-module', 'pass'),
|
|
259
|
+
result('theme-fonts', 'warn'),
|
|
260
|
+
result('theme-global-rules', 'info'),
|
|
261
|
+
]),
|
|
262
|
+
).toMatchObject({
|
|
263
|
+
status: 'fail',
|
|
264
|
+
message: '2 theme checks need attention: theme-owners, theme-fonts.',
|
|
265
|
+
});
|
|
266
|
+
expect(checkThemes(process.cwd(), passing)).toMatchObject({
|
|
267
|
+
status: 'pass',
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
it('appears once in the doctor report, right after version alignment, with and without a module', async () => {
|
|
272
|
+
const {dir} = await fixture();
|
|
273
|
+
for (const cwd of [emptyApp('themes-report'), dir]) {
|
|
274
|
+
const ids = (await runChecks({cwd})).checks.map(item => item.id);
|
|
275
|
+
expect(ids.filter(id => id === 'themes')).toHaveLength(1);
|
|
276
|
+
expect(ids.indexOf('themes')).toBe(ids.indexOf('version-alignment') + 1);
|
|
277
|
+
expect(ids.indexOf('themes')).toBeLessThan(
|
|
278
|
+
ids.findIndex(id => id === 'theme-management' || id === 'theme-owners'),
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
}, 30_000);
|
|
282
|
+
});
|
|
283
|
+
|
|
143
284
|
describe('app-theme doctor checks', () => {
|
|
144
285
|
it('returns ten positive passes for a healthy package theme', async () => {
|
|
145
286
|
const {dir} = await fixture();
|
|
@@ -15,6 +15,7 @@ export const doc = {
|
|
|
15
15
|
summary:
|
|
16
16
|
'Report a missing or hard-to-use design-system capability to the package that owns it.',
|
|
17
17
|
description:
|
|
18
|
+
'Routes the report to the package that owns the gap: options.package when given, else the integration whose component replaces the named Core component, else the one package that provides the component, else Core. ' +
|
|
18
19
|
'Sends a gap report to every configured handler: the project config handler first, then each integration handler in config order. ' +
|
|
19
20
|
'Each handler has 30 s to finish, and its output goes to stderr. Public handlers run only with confirmPublic; internal handlers always run. ' +
|
|
20
21
|
"With no handler, it files a GitHub issue for the owning package only with confirmPublic (without it nothing is sent), or returns the package's issues URL when that is not on GitHub. " +
|
|
@@ -60,7 +61,7 @@ export const doc = {
|
|
|
60
61
|
name: 'options.package',
|
|
61
62
|
type: 'string',
|
|
62
63
|
description:
|
|
63
|
-
'Package that owns the gap: @astryxdesign/core, or a loaded integration by package name or config entry. Overrides automatic owner routing; required when more than one package provides the component.',
|
|
64
|
+
'Package that owns the gap: @astryxdesign/core, or a loaded integration by package name or config entry. Overrides automatic owner routing, which picks the integration whose component replaces the named Core component, else the one package that provides it, else Core; required when more than one package provides the component.',
|
|
64
65
|
},
|
|
65
66
|
{
|
|
66
67
|
name: 'options.confirmPublic',
|
package/api/init/run/run.mjs
CHANGED
|
@@ -54,6 +54,7 @@ export function getNextSteps(invocation) {
|
|
|
54
54
|
' 4. Add and wire a theme:',
|
|
55
55
|
' npm install @astryxdesign/theme-neutral',
|
|
56
56
|
` ${invocation} theme add neutral --import`,
|
|
57
|
+
" import { Theme } from '@astryxdesign/core'",
|
|
57
58
|
" import { themes, defaultThemeSlug } from './astryx-themes'",
|
|
58
59
|
' <Theme theme={themes[defaultThemeSlug]}>...</Theme>',
|
|
59
60
|
` Extend an imported theme to customize it. Run \`${invocation} theme eject <slug>\` only to fork source.`,
|
|
@@ -57,6 +57,7 @@ import {
|
|
|
57
57
|
validateLoadedIntegration,
|
|
58
58
|
issueError as error,
|
|
59
59
|
issueWarning as warning,
|
|
60
|
+
rootProblem,
|
|
60
61
|
} from '../../foundation/integrations/validate-contributions.mjs';
|
|
61
62
|
|
|
62
63
|
export {validateLoadedIntegration};
|
|
@@ -161,9 +162,24 @@ async function findUnreachableContributionIssues(packageDir, loaded) {
|
|
|
161
162
|
/** @param {string} dir */
|
|
162
163
|
async function walk(dir) {
|
|
163
164
|
if (roots.some(root => pathIsInside(dir, root))) return;
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
165
|
+
let entries;
|
|
166
|
+
try {
|
|
167
|
+
entries = fs
|
|
168
|
+
.readdirSync(dir, {withFileTypes: true})
|
|
169
|
+
.sort((a, b) => a.name.localeCompare(b.name));
|
|
170
|
+
} catch (err) {
|
|
171
|
+
// One folder the user running astryx cannot read must not end the whole
|
|
172
|
+
// validation: name it and keep checking the rest of the package.
|
|
173
|
+
const shown = `${path.relative(packageDir, dir).split(path.sep).join('/') || '.'}/`;
|
|
174
|
+
const reason = /** @type {any} */ (err)?.code ?? String(err);
|
|
175
|
+
issues.push(
|
|
176
|
+
warning(
|
|
177
|
+
'unreadable_folder',
|
|
178
|
+
`Could not read "${shown}" (${reason}), so it was not checked for contributions outside a declared root. Fix: make it readable by the user running astryx, or remove it if it does not belong in the package.`,
|
|
179
|
+
),
|
|
180
|
+
);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
167
183
|
for (const entry of entries) {
|
|
168
184
|
if (truncated) return;
|
|
169
185
|
if (UNREACHABLE_SKIP_DIRS.has(entry.name)) continue;
|
|
@@ -312,7 +328,7 @@ async function validateAtPackageDir(
|
|
|
312
328
|
// Roots + contribution checks are shared with validateLoadedIntegration so
|
|
313
329
|
// the everyday-command nudge runs the exact same validators.
|
|
314
330
|
issues.push(...(await validateLoadedIntegration(loaded)));
|
|
315
|
-
if (loaded.themes)
|
|
331
|
+
if (loaded.themes && !rootProblem(loaded.themes))
|
|
316
332
|
issues.push(...unreadThemeFolderIssues(packageDir, loaded));
|
|
317
333
|
if (scanUnreachable) {
|
|
318
334
|
issues.push(
|
|
@@ -680,3 +680,76 @@ describe('validated separates "checked and clean" from "never checked"', () => {
|
|
|
680
680
|
expect(summarizeIssues(res.data.issues).errors).toBeGreaterThan(0);
|
|
681
681
|
});
|
|
682
682
|
});
|
|
683
|
+
|
|
684
|
+
describe('unreadable folders are reported, never fatal', () => {
|
|
685
|
+
// Root reads every folder, so permission cases cannot be staged as root.
|
|
686
|
+
const asRoot = typeof process.getuid === 'function' && process.getuid() === 0;
|
|
687
|
+
/** @type {string[]} */
|
|
688
|
+
const locked = [];
|
|
689
|
+
afterEach(() => {
|
|
690
|
+
while (locked.length) fs.chmodSync(locked.pop(), 0o755);
|
|
691
|
+
});
|
|
692
|
+
/** @param {string} dir */
|
|
693
|
+
const lock = dir => {
|
|
694
|
+
fs.chmodSync(dir, 0o000);
|
|
695
|
+
locked.push(dir);
|
|
696
|
+
};
|
|
697
|
+
|
|
698
|
+
it.skipIf(asRoot)(
|
|
699
|
+
'names a folder it cannot read and checks the rest of the package',
|
|
700
|
+
async () => {
|
|
701
|
+
const pkgDir = path.join(tmpDir, 'pkg');
|
|
702
|
+
writePackage(pkgDir, {
|
|
703
|
+
manifest: "export default { components: './components' };\n",
|
|
704
|
+
});
|
|
705
|
+
fs.mkdirSync(path.join(pkgDir, 'components'));
|
|
706
|
+
fs.mkdirSync(path.join(pkgDir, 'cache'));
|
|
707
|
+
lock(path.join(pkgDir, 'cache'));
|
|
708
|
+
const result = await validateLocalIntegration(pkgDir);
|
|
709
|
+
expect(byCode(result.issues, 'unreadable_folder')).toEqual([
|
|
710
|
+
expect.objectContaining({
|
|
711
|
+
severity: 'warning',
|
|
712
|
+
message: expect.stringContaining('Could not read "cache/" (EACCES)'),
|
|
713
|
+
}),
|
|
714
|
+
]);
|
|
715
|
+
expect(summarizeIssues(result.issues).errors).toBe(0);
|
|
716
|
+
},
|
|
717
|
+
);
|
|
718
|
+
|
|
719
|
+
it.skipIf(asRoot)(
|
|
720
|
+
'reports a declared root it cannot read as unreadable_root',
|
|
721
|
+
async () => {
|
|
722
|
+
const pkgDir = path.join(tmpDir, 'pkg');
|
|
723
|
+
writePackage(pkgDir, {
|
|
724
|
+
manifest:
|
|
725
|
+
"export default { codemods: './codemods', themes: './themes' };\n",
|
|
726
|
+
});
|
|
727
|
+
fs.mkdirSync(path.join(pkgDir, 'codemods'));
|
|
728
|
+
fs.mkdirSync(path.join(pkgDir, 'themes'));
|
|
729
|
+
lock(path.join(pkgDir, 'codemods'));
|
|
730
|
+
lock(path.join(pkgDir, 'themes'));
|
|
731
|
+
const result = await validateLocalIntegration(pkgDir);
|
|
732
|
+
expect(
|
|
733
|
+
byCode(result.issues, 'unreadable_root').map(issue => issue.message),
|
|
734
|
+
).toEqual([
|
|
735
|
+
expect.stringMatching(/^Declared codemods root cannot be read \(EACCES\)/),
|
|
736
|
+
expect.stringMatching(/^Declared themes root cannot be read \(EACCES\)/),
|
|
737
|
+
]);
|
|
738
|
+
},
|
|
739
|
+
);
|
|
740
|
+
|
|
741
|
+
it('reports a declared root that is a file as invalid_root', async () => {
|
|
742
|
+
const pkgDir = path.join(tmpDir, 'pkg');
|
|
743
|
+
writePackage(pkgDir, {
|
|
744
|
+
manifest: "export default { codemods: './codemods.mjs' };\n",
|
|
745
|
+
});
|
|
746
|
+
fs.writeFileSync(path.join(pkgDir, 'codemods.mjs'), 'export default {};\n');
|
|
747
|
+
const result = await validateLocalIntegration(pkgDir);
|
|
748
|
+
expect(byCode(result.issues, 'invalid_root')).toEqual([
|
|
749
|
+
expect.objectContaining({
|
|
750
|
+
severity: 'error',
|
|
751
|
+
message: expect.stringContaining('is a file, not a folder'),
|
|
752
|
+
}),
|
|
753
|
+
]);
|
|
754
|
+
});
|
|
755
|
+
});
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
+
* @deprecated DEP-0006: Use `build`, `template`, and `docs layout` instead. Removal in CLN-0006.
|
|
5
6
|
* `astryx layout check "<expr>" [--form compact|outline]`
|
|
6
7
|
* Validates without expanding; echoes both canonical surfaces.
|
|
7
8
|
*
|
|
@@ -15,6 +15,7 @@ import {toCompact, toOutline} from '../../../foundation/xle/print.mjs';
|
|
|
15
15
|
import {analyze, formatIssue} from '../_adapter.mjs';
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
+
* @deprecated DEP-0006: Use `build`, `template`, and `docs layout` instead. Removal in CLN-0006.
|
|
18
19
|
* `astryx layout check "<expr>" [--form compact|outline]`
|
|
19
20
|
* Validates without expanding; echoes both canonical surfaces.
|
|
20
21
|
*
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
+
* @deprecated DEP-0006: Use `build`, `template`, and `docs layout` instead. Removal in CLN-0006.
|
|
5
6
|
* `astryx layout grammar` — the agent cheatsheet, with the alias table
|
|
6
7
|
* generated from this branch's registry (never hand-maintained).
|
|
7
8
|
*
|
|
@@ -13,6 +13,7 @@ import {buildRegistry} from '../../../foundation/xle/registry.mjs';
|
|
|
13
13
|
import {MAX_REPEAT} from '../../../foundation/xle/expand.mjs';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
+
* @deprecated DEP-0006: Use `build`, `template`, and `docs layout` instead. Removal in CLN-0006.
|
|
16
17
|
* `astryx layout grammar` — the agent cheatsheet, with the alias table
|
|
17
18
|
* generated from this branch's registry (never hand-maintained).
|
|
18
19
|
*
|
|
@@ -20,7 +20,7 @@ export const doc = {
|
|
|
20
20
|
'expression without generating any TSX, and echoes it back in both canonical surfaces ' +
|
|
21
21
|
'(compact and outline). Validation failures are reported in the layout.check envelope ' +
|
|
22
22
|
'(valid: false) with line/col and suggestions (not thrown) so callers can lint an ' +
|
|
23
|
-
'expression and surface fixes.',
|
|
23
|
+
'expression and surface fixes. **Deprecated (DEP-0006).** Use `build`, `template`, and `docs layout` instead. This function will be removed in a future minor release.',
|
|
24
24
|
importPath: '@astryxdesign/cli/api',
|
|
25
25
|
signature:
|
|
26
26
|
'layoutCheck(expression: string, options?: LayoutCheckOptions): Promise<LayoutCheckResponse>',
|
|
@@ -20,7 +20,7 @@ export const doc = {
|
|
|
20
20
|
'expression, then expands it into ready-to-use XDS TSX, auto-routing structural children ' +
|
|
21
21
|
'into the right slots, scaffolding typed useState for interactive controls, and splicing or ' +
|
|
22
22
|
'importing any referenced template blocks. Returns the code (and metadata) in a layout.expand ' +
|
|
23
|
-
'envelope, optionally writing it to a path within cwd.',
|
|
23
|
+
'envelope, optionally writing it to a path within cwd. **Deprecated (DEP-0006).** Use `build`, `template`, and `docs layout` instead. This function will be removed in a future minor release.',
|
|
24
24
|
importPath: '@astryxdesign/cli/api',
|
|
25
25
|
signature:
|
|
26
26
|
'layoutExpand(expression: string, options?: LayoutExpandOptions): Promise<LayoutExpandResponse>',
|
|
@@ -18,7 +18,7 @@ export const doc = {
|
|
|
18
18
|
description:
|
|
19
19
|
'The reference behind `astryx layout grammar`: the agent cheatsheet for writing XLE/XLO ' +
|
|
20
20
|
"layout expressions, with the alias table generated from this branch's registry rather than " +
|
|
21
|
-
'hand-maintained, so short names always reflect the components actually installed.',
|
|
21
|
+
'hand-maintained, so short names always reflect the components actually installed. **Deprecated (DEP-0006).** Use `build`, `template`, and `docs layout` instead. This function will be removed in a future minor release.',
|
|
22
22
|
importPath: '@astryxdesign/cli/api',
|
|
23
23
|
signature:
|
|
24
24
|
'layoutGrammar(options?: LayoutGrammarOptions): Promise<LayoutGrammarResponse>',
|
package/api/search/search.d.mts
CHANGED
|
@@ -24,6 +24,50 @@ export function sameWord(a: string, b: string): boolean;
|
|
|
24
24
|
* @returns {string[]}
|
|
25
25
|
*/
|
|
26
26
|
export function tokenizeQuery(term: string): string[];
|
|
27
|
+
/**
|
|
28
|
+
* A match's domain priority: 0 (none), 1, or 2 (a doc the whole query names).
|
|
29
|
+
* A component, hook, template, or theme with priority ranks ahead of any doc
|
|
30
|
+
* without it, whatever the two scores are. Docs among themselves rank by
|
|
31
|
+
* priority, then score; everything else ranks among itself by score.
|
|
32
|
+
*
|
|
33
|
+
* A component, hook, template, or theme has priority (1) when one of the
|
|
34
|
+
* query's words, or the whole query, hits its name or an authored keyword at
|
|
35
|
+
* {@link STRONG_TOKEN_SCORE} or above, or when it matches every word.
|
|
36
|
+
*
|
|
37
|
+
* A doc has priority when the reader asked for that doc:
|
|
38
|
+
* - 2: the whole query is the topic's name, its last route segment, or its
|
|
39
|
+
* own title, as words and whatever the plural (`font setup` is
|
|
40
|
+
* typography/font-setup, `side panel` is "Side panels");
|
|
41
|
+
* - 1: a word of the query is the topic's name (`illustration` in a longer
|
|
42
|
+
* question is the illustrations guide);
|
|
43
|
+
* - 1: the query holds one of the doc's titles whole (`resizable side panels`
|
|
44
|
+
* names "Side panels"; `light dark mode button` names "Light/Dark Mode");
|
|
45
|
+
* - 1: the doc matches every word of the query and one of them is a word of
|
|
46
|
+
* its title (`switch to a dark theme` and "Use a theme").
|
|
47
|
+
* A section answers to its topic's name.
|
|
48
|
+
*
|
|
49
|
+
* A doc that matched only by keyword, by a heading holding the query, or by
|
|
50
|
+
* words spread through its text has no priority. Docs are split into many
|
|
51
|
+
* small topics, and each declares its own keywords and headings, so a common
|
|
52
|
+
* phrase such as `font size` hits a guide's keyword or heading exactly
|
|
53
|
+
* (170-190) while the component the reader is after matches one word by
|
|
54
|
+
* keyword (`Text`, 98). Ranked on text alone, every split adds another doc
|
|
55
|
+
* above the component. Broad reference pages match every word of many queries
|
|
56
|
+
* in their text the same way. The score stays the text-match strength the
|
|
57
|
+
* result reports, so callers that gate on it (`build`) see the same numbers.
|
|
58
|
+
*
|
|
59
|
+
* @param {string} term - Lowercased search term.
|
|
60
|
+
* @param {string[]} tokens - Content tokens from tokenizeQuery(term).
|
|
61
|
+
* @param {Candidate} candidate
|
|
62
|
+
* @param {{score: number, matched: number, total: number}} hit - The
|
|
63
|
+
* candidate's scoreQuery result.
|
|
64
|
+
* @returns {0 | 1 | 2}
|
|
65
|
+
*/
|
|
66
|
+
export function domainPriority(term: string, tokens: string[], candidate: Candidate, hit: {
|
|
67
|
+
score: number;
|
|
68
|
+
matched: number;
|
|
69
|
+
total: number;
|
|
70
|
+
}): 0 | 1 | 2;
|
|
27
71
|
/**
|
|
28
72
|
* The first title or heading that holds every word of the query, in order and
|
|
29
73
|
* side by side, or null.
|