@astryxdesign/cli 0.6.3-canary.f839b67 → 0.6.4-canary.06c8fa3
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/CHANGELOG.md +194 -0
- package/README.md +64 -66
- package/api/component/_adapter.d.mts +25 -0
- package/api/component/_adapter.mjs +59 -5
- package/api/component/component.d.mts +6 -3
- package/api/component/component.doc.mjs +23 -10
- package/api/component/component.mjs +249 -9
- package/api/component/component.type.d.mts +25 -0
- package/api/component/component.type.mjs +44 -0
- package/api/discover/_adapter.d.mts +114 -6
- package/api/discover/_adapter.mjs +372 -17
- package/api/discover/_adapter.test.mjs +215 -0
- package/api/discover/_catalog-view.d.mts +115 -0
- package/api/discover/_catalog-view.mjs +203 -0
- package/api/discover/_catalog-view.test.mjs +128 -0
- package/api/discover/detail/detail.d.mts +18 -6
- package/api/discover/detail/detail.mjs +67 -13
- package/api/discover/detail/detail.test.mjs +85 -0
- package/api/discover/detail/item/item.d.mts +26 -0
- package/api/discover/detail/item/item.mjs +78 -0
- package/api/discover/detail/item/item.test.mjs +73 -0
- package/api/discover/discover.d.mts +3 -9
- package/api/discover/discover.doc.mjs +61 -18
- package/api/discover/discover.mjs +220 -36
- package/api/discover/discover.test.mjs +11 -2
- package/api/discover/discover.type.d.mts +147 -8
- package/api/discover/discover.type.mjs +102 -12
- package/api/discover/list/list.d.mts +20 -6
- package/api/discover/list/list.mjs +45 -12
- package/api/discover/list/list.test.mjs +46 -0
- package/api/discover/search/search.d.mts +18 -16
- package/api/discover/search/search.mjs +102 -56
- package/api/discover/search/search.test.mjs +144 -10
- package/api/docs/_adapter.d.mts +49 -7
- package/api/docs/_adapter.mjs +284 -33
- package/api/docs/docs.doc.mjs +4 -3
- package/api/docs/docs.test.mjs +2 -0
- package/api/docs/docs.type.d.mts +21 -5
- package/api/docs/docs.type.mjs +21 -5
- package/api/docs/integration-tree.test.mjs +9 -1
- package/api/docs/reference-blocks.test.mjs +406 -0
- package/api/doctor/doctor.d.mts +8 -3
- package/api/doctor/doctor.mjs +95 -10
- package/api/doctor/doctor.test.mjs +122 -10
- package/api/index.d.mts +1 -2
- package/api/index.mjs +4 -4
- package/api/integration/add-helpers.d.mts +5 -2
- package/api/integration/add-helpers.mjs +36 -9
- package/api/integration/authoring-checks.mjs +14 -1
- package/api/integration/pack-check.lifecycle-output.test.mjs +105 -0
- package/api/integration/pack-check.mjs +28 -3
- package/api/json/index.ts +0 -1
- package/api/search/search.test.mjs +18 -0
- package/api/template/table-floating-bulk-actions.test.mjs +66 -0
- package/api/template/template-integration.test.mjs +1 -65
- package/api/template/template.mjs +1 -1
- package/api/theme/add/add.mjs +17 -25
- package/api/theme/add/add.rollback.test.mjs +158 -0
- package/api/theme/add/add.staging.test.mjs +40 -23
- package/api/theme/build/build.family.test.mjs +7 -12
- package/api/theme/build/build.mjs +8 -18
- package/api/theme/build/build.rollback.test.mjs +148 -0
- package/api/upgrade/run/files-changed.test.mjs +111 -0
- package/api/upgrade/run/run.mjs +6 -4
- package/api/upgrade/upgrade.type.mjs +2 -2
- package/assets/codemods/__tests__/registry.test.mjs +1 -0
- package/assets/codemods/__tests__/runner.test.mjs +3 -1
- package/assets/codemods/file-count.test.mjs +163 -0
- package/assets/codemods/integration-runner.mjs +3 -3
- package/assets/codemods/registry.mjs +1 -0
- package/assets/codemods/runner.mjs +5 -4
- package/assets/codemods/transforms/next/index.mjs +1 -19
- package/assets/codemods/transforms/v0.6.4/index.mjs +31 -0
- package/assets/docs/internationalization.doc.mjs +7 -5
- package/assets/docs/styling-libraries.doc.mjs +1 -1
- package/assets/docs/theme.doc.mjs +1 -1
- package/assets/docs/tree/component-lookups.doc.mjs +149 -0
- package/assets/docs/tree/integrations.doc.mjs +20 -1
- package/assets/templates/blocks/components/CheckboxList/CheckboxListSelectAllPattern.doc.mjs +1 -1
- package/assets/templates/blocks/components/CheckboxList/CheckboxListSelectAllPattern.tsx +1 -3
- package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider01ShippedLocale.tsx +1 -1
- package/assets/templates/blocks/components/Table/TableBulkActionsTable.doc.mjs +14 -0
- package/assets/templates/blocks/components/Table/TableBulkActionsTable.tsx +71 -0
- package/assets/templates/blocks/components/Table/TableFloatingBulkActionsTable.doc.mjs +19 -0
- package/assets/templates/blocks/components/Table/TableFloatingBulkActionsTable.tsx +139 -0
- package/authoring/config/config.doc.mjs +9 -1
- package/authoring/config/parse.d.mts +2 -0
- package/authoring/config/parse.mjs +19 -0
- package/authoring/config/parse.test.mjs +8 -0
- package/authoring/config/type.ts +13 -2
- package/authoring/discover/discover.doc.d.mts +13 -0
- package/authoring/discover/discover.doc.mjs +138 -0
- package/authoring/discover/parse.d.mts +24 -0
- package/authoring/discover/parse.mjs +128 -0
- package/authoring/discover/parse.test.mjs +124 -0
- package/authoring/discover/type.ts +87 -0
- package/authoring/doctypes/_schema.d.mts +72 -0
- package/authoring/doctypes/_schema.mjs +25 -1
- package/authoring/doctypes/command/command.doc.mjs +1 -1
- package/authoring/doctypes/command/type.ts +1 -1
- package/authoring/doctypes/load-contract.test.mjs +25 -0
- package/authoring/doctypes/reference/reference.doc.mjs +31 -4
- package/authoring/doctypes/reference/type.ts +20 -5
- package/authoring/index.d.mts +1 -0
- package/authoring/index.d.ts +10 -0
- package/authoring/index.mjs +1 -0
- package/clients/cli/command-result-coverage.test.mjs +7 -7
- package/clients/cli/commands/component/index.mjs +152 -55
- package/clients/cli/commands/component-batch.test.mjs +341 -0
- package/clients/cli/commands/component-ownership.test.mjs +89 -0
- package/clients/cli/commands/component.doc.mjs +23 -6
- package/clients/cli/commands/debug-result-summary.test.mjs +2 -2
- package/clients/cli/commands/discover.doc.mjs +53 -9
- package/clients/cli/commands/discover.mjs +393 -118
- package/clients/cli/commands/discover.sources.test.mjs +267 -0
- package/clients/cli/commands/docs.mjs +2 -2
- package/clients/cli/commands/docs.test.mjs +29 -0
- package/clients/cli/commands/doctor-integration-docs.doc.mjs +1 -1
- package/clients/cli/commands/text-json-parity.test.mjs +0 -17
- package/clients/cli/index.mjs +0 -4
- package/clients/cli/lib/exit-codes.test.mjs +1 -8
- package/clients/cli/lib/json-shim.mjs +24 -14
- package/clients/cli/lib/json-shim.test.mjs +6 -20
- package/clients/cli/lib/manifest.mjs +3 -8
- package/clients/cli/lib/manifest.test.mjs +5 -2
- package/clients/cli/lib/parse-error-format.test.mjs +81 -0
- package/foundation/discovery/authoring-self-docs.d.mts +12 -0
- package/foundation/discovery/authoring-self-docs.mjs +21 -8
- package/foundation/discovery/authoring-self-docs.test.mjs +7 -2
- package/foundation/discovery/docs-discovery.d.mts +4 -1
- package/foundation/discovery/docs-discovery.mjs +40 -6
- package/foundation/discovery/docs-discovery.test.mjs +40 -0
- package/foundation/discovery/template-adapter.mjs +1 -1
- package/foundation/doc-compiler/doc-loads.test.mjs +0 -12
- package/foundation/doc-compiler/lenses.d.mts +5 -3
- package/foundation/doc-compiler/lenses.mjs +48 -3
- package/foundation/doc-compiler/links.d.mts +30 -3
- package/foundation/doc-compiler/links.mjs +46 -5
- package/foundation/doc-compiler/links.test.mjs +53 -0
- package/foundation/doc-compiler/tree.test.mjs +9 -1
- package/foundation/integrations/cli-requirement.test.mjs +17 -42
- package/foundation/integrations/integrations.d.mts +14 -1
- package/foundation/integrations/integrations.mjs +41 -1
- package/foundation/integrations/integrations.test.mjs +31 -0
- package/foundation/response/batch.type.d.mts +33 -0
- package/foundation/response/batch.type.mjs +34 -0
- package/foundation/response/response-types.doc.mjs +15 -21
- package/foundation/response/response-types.doc.test.mjs +23 -0
- package/foundation/xle/browser.d.mts +3 -3
- package/foundation/xle/browser.mjs +3 -3
- package/foundation/xle/expand.mjs +2 -2
- package/foundation/xle/parse.mjs +1 -1
- package/foundation/xle/print.mjs +2 -2
- package/foundation/xle/splice.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 -16
- package/api/layout/check/check.mjs +0 -40
- package/api/layout/expand/expand.d.mts +0 -22
- package/api/layout/expand/expand.mjs +0 -155
- package/api/layout/expand/expand.path-safety.test.mjs +0 -53
- package/api/layout/grammar/grammar.d.mts +0 -13
- package/api/layout/grammar/grammar.mjs +0 -87
- 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 -89
- package/api/layout/layout.type.mjs +0 -103
- 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/clients/cli/commands/layout-check.doc.mjs +0 -65
- package/clients/cli/commands/layout-expand.doc.mjs +0 -83
- package/clients/cli/commands/layout-grammar.doc.mjs +0 -30
- package/clients/cli/commands/layout.doc.mjs +0 -34
- 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.mjs +0 -275
- 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/assets/codemods/transforms/{next → v0.6.4}/__tests__/migrate-native-picker-to-presentation.test.mjs +0 -0
- /package/assets/codemods/transforms/{next → v0.6.4}/__tests__/migrate-theme-catalog-to-descriptors.test.mjs +0 -0
- /package/assets/codemods/transforms/{next → v0.6.4}/migrate-native-picker-to-presentation.mjs +0 -0
- /package/assets/codemods/transforms/{next → v0.6.4}/migrate-theme-catalog-to-descriptors.mjs +0 -0
|
@@ -354,16 +354,31 @@ describe('checkImplicitIntegrations', () => {
|
|
|
354
354
|
});
|
|
355
355
|
|
|
356
356
|
it('names the package, the field, and what it contributes', () => {
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
357
|
+
// Roots count only when they exist, so this one gives them real folders.
|
|
358
|
+
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-implicit-'));
|
|
359
|
+
try {
|
|
360
|
+
const dir = name => {
|
|
361
|
+
fs.mkdirSync(path.join(root, name));
|
|
362
|
+
return path.join(root, name);
|
|
363
|
+
};
|
|
364
|
+
const c = checkImplicitIntegrations({
|
|
365
|
+
integrations: [
|
|
366
|
+
autolinked({
|
|
367
|
+
components: dir('components'),
|
|
368
|
+
templates: dir('templates'),
|
|
369
|
+
themes: dir('themes'),
|
|
370
|
+
}),
|
|
371
|
+
],
|
|
372
|
+
});
|
|
373
|
+
expect(c.message).toContain('@acme/widgets@1.0.0');
|
|
374
|
+
expect(c.message).toContain('from dependencies');
|
|
375
|
+
expect(c.message).toContain(
|
|
376
|
+
'contributing components, templates, themes',
|
|
377
|
+
);
|
|
378
|
+
expect(c.message).not.toContain('missing on disk');
|
|
379
|
+
} finally {
|
|
380
|
+
fs.rmSync(root, {recursive: true, force: true});
|
|
381
|
+
}
|
|
367
382
|
});
|
|
368
383
|
|
|
369
384
|
it('names the declared key too when an npm alias makes them differ', () => {
|
|
@@ -906,3 +921,100 @@ describe('checkDocsProgressiveDisclosure languages', () => {
|
|
|
906
921
|
expect(c.message).not.toMatch(/deploying overview:/);
|
|
907
922
|
});
|
|
908
923
|
});
|
|
924
|
+
|
|
925
|
+
describe('doctor says what it could not check', () => {
|
|
926
|
+
const CORE = {
|
|
927
|
+
'node_modules/@astryxdesign/core/package.json': JSON.stringify({
|
|
928
|
+
name: '@astryxdesign/core',
|
|
929
|
+
version: '0.6.3',
|
|
930
|
+
}),
|
|
931
|
+
};
|
|
932
|
+
|
|
933
|
+
/** Installed dependency whose manifest declares roots that do not exist. */
|
|
934
|
+
const dangling = {
|
|
935
|
+
'node_modules/@acme/dangling/package.json': JSON.stringify({
|
|
936
|
+
name: '@acme/dangling',
|
|
937
|
+
version: '2.0.0',
|
|
938
|
+
}),
|
|
939
|
+
'node_modules/@acme/dangling/astryx.integration.mjs':
|
|
940
|
+
"export default {providerId: 'acme-dangling', components: './components', templates: './templates', docs: './docs'};\n",
|
|
941
|
+
};
|
|
942
|
+
|
|
943
|
+
/** Installed dependency whose manifest cannot be parsed at all. */
|
|
944
|
+
const broken = {
|
|
945
|
+
'node_modules/@acme/broken/package.json': JSON.stringify({
|
|
946
|
+
name: '@acme/broken',
|
|
947
|
+
version: '1.0.0',
|
|
948
|
+
}),
|
|
949
|
+
'node_modules/@acme/broken/astryx.integration.mjs':
|
|
950
|
+
'export default { this is not valid javascript ((\n',
|
|
951
|
+
};
|
|
952
|
+
|
|
953
|
+
/** @param {Record<string, string>} extra @param {string[]} deps */
|
|
954
|
+
const project = (extra, deps) =>
|
|
955
|
+
mkProject({
|
|
956
|
+
'package.json': JSON.stringify({
|
|
957
|
+
name: 'consumer',
|
|
958
|
+
version: '1.0.0',
|
|
959
|
+
dependencies: Object.fromEntries(
|
|
960
|
+
['@astryxdesign/core', ...deps].map(d => [d, '1.0.0']),
|
|
961
|
+
),
|
|
962
|
+
}),
|
|
963
|
+
...CORE,
|
|
964
|
+
...extra,
|
|
965
|
+
});
|
|
966
|
+
|
|
967
|
+
// An unparseable manifest is kept out of the loaded set on purpose, and
|
|
968
|
+
// doctor used to report that no installed dependency ships a manifest.
|
|
969
|
+
it('names an installed dependency whose manifest cannot be loaded', async () => {
|
|
970
|
+
const report = (await doctor({cwd: project(broken, ['@acme/broken'])})).data;
|
|
971
|
+
const check = report.checks.find(c => c.id === 'implicit-integrations');
|
|
972
|
+
|
|
973
|
+
expect(check.status).toBe('info');
|
|
974
|
+
expect(check.message).toContain('@acme/broken');
|
|
975
|
+
expect(check.message).toContain('could not be loaded');
|
|
976
|
+
expect(check.message).not.toContain('no installed dependency ships');
|
|
977
|
+
expect(report.summary.fail).toBe(0);
|
|
978
|
+
}, SLOW);
|
|
979
|
+
|
|
980
|
+
it('does not claim contributions from roots that are missing on disk', async () => {
|
|
981
|
+
const report = (await doctor({cwd: project(dangling, ['@acme/dangling'])}))
|
|
982
|
+
.data;
|
|
983
|
+
const implicit = report.checks.find(c => c.id === 'implicit-integrations');
|
|
984
|
+
const issues = report.checks.find(c => c.id === 'integration-issues');
|
|
985
|
+
|
|
986
|
+
expect(implicit.message).toContain('contributing nothing');
|
|
987
|
+
expect(implicit.message).toContain('missing on disk');
|
|
988
|
+
expect(implicit.message).not.toContain('contributing components');
|
|
989
|
+
expect(issues.status).toBe('warn');
|
|
990
|
+
expect(issues.message).toContain('@acme/dangling');
|
|
991
|
+
}, SLOW);
|
|
992
|
+
|
|
993
|
+
it('still says no dependency ships a manifest when none does', async () => {
|
|
994
|
+
const report = (await doctor({cwd: project({}, [])})).data;
|
|
995
|
+
const check = report.checks.find(c => c.id === 'implicit-integrations');
|
|
996
|
+
|
|
997
|
+
expect(check.message).toBe(
|
|
998
|
+
'None — no installed dependency ships an astryx.integration.* manifest.',
|
|
999
|
+
);
|
|
1000
|
+
}, SLOW);
|
|
1001
|
+
|
|
1002
|
+
it('says how many integrations could not be read, rather than counting silently', () => {
|
|
1003
|
+
/** @type {any} */
|
|
1004
|
+
const ctx = {
|
|
1005
|
+
cwd: '/x',
|
|
1006
|
+
nodeVersion: process.versions.node,
|
|
1007
|
+
coreDir: null,
|
|
1008
|
+
configPath: null,
|
|
1009
|
+
configTheme: null,
|
|
1010
|
+
integrations: [
|
|
1011
|
+
{name: '@acme/ok', __spec: '@acme/ok', providerId: 'ok'},
|
|
1012
|
+
{name: '@acme/bad', __spec: '@acme/bad', __loadError: 'boom'},
|
|
1013
|
+
],
|
|
1014
|
+
};
|
|
1015
|
+
const check = checkProviderIdentity(ctx);
|
|
1016
|
+
|
|
1017
|
+
expect(check.message).toContain('1 loaded integration has its own provider ID.');
|
|
1018
|
+
expect(check.message).toContain('could not be read');
|
|
1019
|
+
});
|
|
1020
|
+
});
|
package/api/index.d.mts
CHANGED
|
@@ -18,6 +18,7 @@ export { integrationAddTheme } from "./integration/add-theme.mjs";
|
|
|
18
18
|
export { integrationPackCheck } from "./integration/pack-check.mjs";
|
|
19
19
|
export { AstryxError } from "./error.mjs";
|
|
20
20
|
export { logger } from "./logger.mjs";
|
|
21
|
+
export * from "../foundation/response/batch.type.mjs";
|
|
21
22
|
export * from "./component/component.type.mjs";
|
|
22
23
|
export * from "./docs/docs.type.mjs";
|
|
23
24
|
export * from "./blog/blog.type.mjs";
|
|
@@ -32,14 +33,12 @@ export * from "./gap-report/gap-report.type.mjs";
|
|
|
32
33
|
export * from "./upgrade/upgrade.type.mjs";
|
|
33
34
|
export * from "./init/init.type.mjs";
|
|
34
35
|
export * from "./doctor/doctor.type.mjs";
|
|
35
|
-
export * from "./layout/layout.type.mjs";
|
|
36
36
|
export * from "./integration/integration-authoring.type.mjs";
|
|
37
37
|
export * from "./integration/pack-check.type.mjs";
|
|
38
38
|
export * from "./integration/validate-integration.type.mjs";
|
|
39
39
|
export * from "./integration/authoring-checks.type.mjs";
|
|
40
40
|
export type Logger = import("./logger.mjs").Logger;
|
|
41
41
|
export { themeBuild, themeAdd, themeTemplate, themeList, themeListAvailable, themeTargets, themePaletteGenerate, generateTonalPalette, listThemes } from "./theme/theme.mjs";
|
|
42
|
-
export { layoutExpand, layoutCheck, layoutGrammar } from "./layout/layout.mjs";
|
|
43
42
|
export { integrationAdd, integrationAddAgentDoc, integrationAddCodemod, integrationAddComponent, integrationAddDoc, integrationAddTemplate } from "./integration/add-contribution.mjs";
|
|
44
43
|
export { validateIntegration, summarizeIssues } from "./integration/validate-integration.mjs";
|
|
45
44
|
export { integrationTemplateConflicts, integrationComponentConflicts, integrationDocConflicts } from "./integration/authoring-checks.mjs";
|
package/api/index.mjs
CHANGED
|
@@ -44,7 +44,6 @@ export {gapReport} from './gap-report/gap-report.mjs';
|
|
|
44
44
|
export {upgrade} from './upgrade/upgrade.mjs';
|
|
45
45
|
export {init} from './init/init.mjs';
|
|
46
46
|
export {doctor} from './doctor/doctor.mjs';
|
|
47
|
-
export {layoutExpand, layoutCheck, layoutGrammar} from './layout/layout.mjs';
|
|
48
47
|
export {
|
|
49
48
|
integrationAdd,
|
|
50
49
|
integrationAddAgentDoc,
|
|
@@ -73,10 +72,12 @@ export {logger} from './logger.mjs';
|
|
|
73
72
|
* @typedef {import('./logger.mjs').Logger} Logger
|
|
74
73
|
*/
|
|
75
74
|
|
|
76
|
-
// ── Types (re-exported from each command's
|
|
75
|
+
// ── Types (re-exported from the shared response foundation and each command's
|
|
76
|
+
// colocated `.type.mjs`) ──────────────────────────────────────────────────
|
|
77
77
|
// Runtime no-ops (the .type.mjs files are `export {}`); tsc carries these
|
|
78
78
|
// through to the generated api/index.d.mts so the public type surface exposes
|
|
79
|
-
// every command's Options + response types
|
|
79
|
+
// the shared receipt vocabulary and every command's Options + response types.
|
|
80
|
+
export * from '../foundation/response/batch.type.mjs';
|
|
80
81
|
export * from './component/component.type.mjs';
|
|
81
82
|
export * from './docs/docs.type.mjs';
|
|
82
83
|
export * from './blog/blog.type.mjs';
|
|
@@ -91,7 +92,6 @@ export * from './gap-report/gap-report.type.mjs';
|
|
|
91
92
|
export * from './upgrade/upgrade.type.mjs';
|
|
92
93
|
export * from './init/init.type.mjs';
|
|
93
94
|
export * from './doctor/doctor.type.mjs';
|
|
94
|
-
export * from './layout/layout.type.mjs';
|
|
95
95
|
export * from './integration/integration-authoring.type.mjs';
|
|
96
96
|
export * from './integration/pack-check.type.mjs';
|
|
97
97
|
export * from './integration/validate-integration.type.mjs';
|
|
@@ -8,7 +8,7 @@ export function findPackageDir(startDir: string): string;
|
|
|
8
8
|
/**
|
|
9
9
|
* @typedef {object} WritePlan
|
|
10
10
|
* @property {string} path
|
|
11
|
-
* @property {string} contents
|
|
11
|
+
* @property {string | Buffer} contents a Buffer is written byte for byte
|
|
12
12
|
* @property {boolean} createOnly
|
|
13
13
|
* @property {Buffer} [expectedOriginal] bytes captured before validation;
|
|
14
14
|
* a different current file is a concurrent edit and must never be overwritten
|
|
@@ -56,7 +56,10 @@ export function packageJsonUpdate(packageFile: string, rootPath: string, manifes
|
|
|
56
56
|
export function applyWrites(plans: WritePlan[]): () => void;
|
|
57
57
|
export type WritePlan = {
|
|
58
58
|
path: string;
|
|
59
|
-
|
|
59
|
+
/**
|
|
60
|
+
* a Buffer is written byte for byte
|
|
61
|
+
*/
|
|
62
|
+
contents: string | Buffer;
|
|
60
63
|
createOnly: boolean;
|
|
61
64
|
/**
|
|
62
65
|
* bytes captured before validation;
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Hosts the atomic staged-write transaction, package.json files-array
|
|
7
7
|
* maintenance, package-dir resolution, and project-path normalization that
|
|
8
|
-
* every `integration add <kind>` command needs.
|
|
8
|
+
* every `integration add <kind>` command needs. `theme add` and `theme build`
|
|
9
|
+
* write through the same transaction. Stateless and side-effect-free
|
|
9
10
|
* outside of {@link applyWrites}.
|
|
10
11
|
*/
|
|
11
12
|
|
|
@@ -40,7 +41,7 @@ export function findPackageDir(startDir) {
|
|
|
40
41
|
/**
|
|
41
42
|
* @typedef {object} WritePlan
|
|
42
43
|
* @property {string} path
|
|
43
|
-
* @property {string} contents
|
|
44
|
+
* @property {string | Buffer} contents a Buffer is written byte for byte
|
|
44
45
|
* @property {boolean} createOnly
|
|
45
46
|
* @property {Buffer} [expectedOriginal] bytes captured before validation;
|
|
46
47
|
* a different current file is a concurrent edit and must never be overwritten
|
|
@@ -192,21 +193,29 @@ export function packageJsonUpdate(
|
|
|
192
193
|
|
|
193
194
|
// ── Atomic staged-write transaction ─────────────────────────────────
|
|
194
195
|
|
|
195
|
-
/**
|
|
196
|
+
/**
|
|
197
|
+
* @param {string} file
|
|
198
|
+
* @returns {boolean} false when the file is still there
|
|
199
|
+
*/
|
|
196
200
|
function removeTemporary(file) {
|
|
197
201
|
try {
|
|
198
202
|
fs.rmSync(file, {force: true});
|
|
203
|
+
return true;
|
|
199
204
|
} catch {
|
|
200
205
|
// Best effort. The transaction error remains the actionable failure.
|
|
206
|
+
return false;
|
|
201
207
|
}
|
|
202
208
|
}
|
|
203
209
|
|
|
204
210
|
/**
|
|
205
211
|
* Restore writes that already published. Best-effort so callers preserve
|
|
206
|
-
* the original actionable error.
|
|
212
|
+
* the original actionable error; returns every path it could not put back.
|
|
207
213
|
* @param {Array<WritePlan & {temporary: string, original: Buffer|null, mode: number}>} published
|
|
214
|
+
* @returns {string[]}
|
|
208
215
|
*/
|
|
209
216
|
function rollbackWrites(published) {
|
|
217
|
+
/** @type {string[]} */
|
|
218
|
+
const unrestored = [];
|
|
210
219
|
for (const plan of [...published].reverse()) {
|
|
211
220
|
let restore = null;
|
|
212
221
|
try {
|
|
@@ -225,12 +234,18 @@ function rollbackWrites(published) {
|
|
|
225
234
|
fs.renameSync(restore, plan.path);
|
|
226
235
|
restore = null;
|
|
227
236
|
}
|
|
228
|
-
} catch {
|
|
229
|
-
//
|
|
237
|
+
} catch (error) {
|
|
238
|
+
// A created file that is already gone needs nothing. Any other failure
|
|
239
|
+
// leaves this call's bytes, or no bytes, where the original was.
|
|
240
|
+
const gone =
|
|
241
|
+
error instanceof Error &&
|
|
242
|
+
/** @type {NodeJS.ErrnoException} */ (error).code === 'ENOENT';
|
|
243
|
+
if (!(gone && plan.original == null)) unrestored.push(plan.path);
|
|
230
244
|
} finally {
|
|
231
245
|
if (restore != null) removeTemporary(restore);
|
|
232
246
|
}
|
|
233
247
|
}
|
|
248
|
+
return unrestored;
|
|
234
249
|
}
|
|
235
250
|
|
|
236
251
|
/** @param {string} file */
|
|
@@ -325,10 +340,22 @@ export function applyWrites(plans) {
|
|
|
325
340
|
}
|
|
326
341
|
published.push(plan);
|
|
327
342
|
}
|
|
328
|
-
return () =>
|
|
343
|
+
return () => {
|
|
344
|
+
rollbackWrites(published);
|
|
345
|
+
};
|
|
329
346
|
} catch (error) {
|
|
330
|
-
|
|
331
|
-
|
|
347
|
+
const leftovers = staged
|
|
348
|
+
.filter(plan => !removeTemporary(plan.temporary))
|
|
349
|
+
.map(plan => plan.temporary);
|
|
350
|
+
const unrestored = rollbackWrites(published);
|
|
351
|
+
if (error instanceof Error) {
|
|
352
|
+
if (unrestored.length > 0) {
|
|
353
|
+
error.message += ` Could not restore: ${unrestored.join(', ')}.`;
|
|
354
|
+
}
|
|
355
|
+
if (leftovers.length > 0) {
|
|
356
|
+
error.message += ` Could not remove temporary files: ${leftovers.join(', ')}.`;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
332
359
|
throw error;
|
|
333
360
|
}
|
|
334
361
|
}
|
|
@@ -15,7 +15,10 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import {getCliInvocation} from '../../foundation/env/package-manager.mjs';
|
|
18
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
packageDocsProblems,
|
|
20
|
+
packageReferenceProblems,
|
|
21
|
+
} from '../docs/_adapter.mjs';
|
|
19
22
|
import {findCoreDir} from '../../foundation/fs/paths.mjs';
|
|
20
23
|
import {
|
|
21
24
|
discoverIntegrationComponents,
|
|
@@ -371,6 +374,16 @@ export async function integrationDocConflicts(pkg, options = {}) {
|
|
|
371
374
|
)) {
|
|
372
375
|
issues.push({code: 'invalid_doc_graph', severity: 'warning', message});
|
|
373
376
|
}
|
|
377
|
+
|
|
378
|
+
// A reference block includes content rather than linking to it, so one
|
|
379
|
+
// that cannot include what it names loses that content for every reader:
|
|
380
|
+
// an error, where a link that names no doc still prints as written.
|
|
381
|
+
for (const message of await packageReferenceProblems(
|
|
382
|
+
/** @type {{name: string}} */ (resolved.integration),
|
|
383
|
+
discovered,
|
|
384
|
+
)) {
|
|
385
|
+
issues.push({code: 'invalid_doc_reference', severity: 'error', message});
|
|
386
|
+
}
|
|
374
387
|
}
|
|
375
388
|
|
|
376
389
|
return {
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
import {afterEach, beforeEach, describe, expect, it} from 'vitest';
|
|
4
|
+
import * as fs from 'node:fs';
|
|
5
|
+
import * as path from 'node:path';
|
|
6
|
+
import {integrationPackCheck} from './pack-check.mjs';
|
|
7
|
+
|
|
8
|
+
let tmpDir;
|
|
9
|
+
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
tmpDir = fs.mkdtempSync(path.join(process.cwd(), '.astryx-pack-check-'));
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
afterEach(() => {
|
|
15
|
+
fs.rmSync(tmpDir, {recursive: true, force: true});
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
/** @param {Record<string, string>} scripts */
|
|
19
|
+
function writeThemePackage(scripts) {
|
|
20
|
+
fs.writeFileSync(
|
|
21
|
+
path.join(tmpDir, 'package.json'),
|
|
22
|
+
`${JSON.stringify(
|
|
23
|
+
{
|
|
24
|
+
name: '@acme/widgets',
|
|
25
|
+
version: '1.0.0',
|
|
26
|
+
files: ['astryx.integration.mjs', 'themes'],
|
|
27
|
+
scripts,
|
|
28
|
+
},
|
|
29
|
+
null,
|
|
30
|
+
2,
|
|
31
|
+
)}\n`,
|
|
32
|
+
);
|
|
33
|
+
fs.writeFileSync(
|
|
34
|
+
path.join(tmpDir, 'astryx.integration.mjs'),
|
|
35
|
+
"export default {themes: './themes'};\n",
|
|
36
|
+
);
|
|
37
|
+
const root = path.join(tmpDir, 'themes');
|
|
38
|
+
fs.mkdirSync(path.join(root, 'ocean'), {recursive: true});
|
|
39
|
+
fs.writeFileSync(
|
|
40
|
+
path.join(root, 'ocean', 'oceanTheme.ts'),
|
|
41
|
+
"import {defineTheme} from '@astryxdesign/core/theme';\n\nexport const oceanTheme = defineTheme({name: 'ocean'});\n",
|
|
42
|
+
);
|
|
43
|
+
fs.writeFileSync(
|
|
44
|
+
path.join(root, 'ocean', 'oceanTheme.doc.mjs'),
|
|
45
|
+
`/** @type {import('@astryxdesign/cli/authoring').ThemeDoc} */
|
|
46
|
+
export default {type: 'theme', name: 'ocean', displayName: 'Ocean', description: 'Ocean theme.', maintained: true};
|
|
47
|
+
`,
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
describe('integrationPackCheck with lifecycle script output', () => {
|
|
52
|
+
it('checks the tarball when lifecycle scripts print to stdout', async () => {
|
|
53
|
+
writeThemePackage({
|
|
54
|
+
prepack: 'node -e "console.log(\'building the package\')"',
|
|
55
|
+
prepare: 'node -e "console.log(\'preparing\')"',
|
|
56
|
+
postpack: 'node -e "console.log(\'packed\')"',
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const result = await integrationPackCheck({cwd: tmpDir});
|
|
60
|
+
|
|
61
|
+
expect(result.data.issues).toEqual([]);
|
|
62
|
+
expect(result.data.packable).toBe(true);
|
|
63
|
+
expect(result.data.tarball?.filename).toBe('acme-widgets-1.0.0.tgz');
|
|
64
|
+
expect(result.data.contributions.packed).toEqual(
|
|
65
|
+
result.data.contributions.local,
|
|
66
|
+
);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('still runs a chatty lifecycle script and compares what it packed', async () => {
|
|
70
|
+
const renameTheme = [
|
|
71
|
+
"console.log('renaming ocean to storm')",
|
|
72
|
+
"const fs=require('fs')",
|
|
73
|
+
"fs.renameSync('themes/ocean','themes/storm')",
|
|
74
|
+
"const p='themes/storm/oceanTheme.doc.mjs'",
|
|
75
|
+
"let x=fs.readFileSync(p,'utf8')",
|
|
76
|
+
"x=x.replace(/name: 'ocean'/, 'name: '+String.fromCharCode(39)+'storm'+String.fromCharCode(39))",
|
|
77
|
+
'fs.writeFileSync(p,x)',
|
|
78
|
+
].join(';');
|
|
79
|
+
writeThemePackage({prepack: `node -e "${renameTheme}"`});
|
|
80
|
+
|
|
81
|
+
const result = await integrationPackCheck({cwd: tmpDir});
|
|
82
|
+
const codes = result.data.issues.map(issue => issue.code);
|
|
83
|
+
|
|
84
|
+
expect(codes).not.toContain('pack_failed');
|
|
85
|
+
expect(codes).toContain('identity_not_packed');
|
|
86
|
+
expect(codes).toContain('packed_identity_unexpected');
|
|
87
|
+
expect(result.data.packable).toBe(false);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('keeps a failing lifecycle script output in the pack_failed issue', async () => {
|
|
91
|
+
writeThemePackage({
|
|
92
|
+
prepack:
|
|
93
|
+
'node -e "console.error(\'prepack exploded\'); process.exit(3)"',
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
const result = await integrationPackCheck({cwd: tmpDir});
|
|
97
|
+
const failure = result.data.issues.find(
|
|
98
|
+
issue => issue.code === 'pack_failed',
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
expect(result.data.packable).toBe(false);
|
|
102
|
+
expect(failure?.message).toContain('npm pack failed (exit 3)');
|
|
103
|
+
expect(failure?.message).toContain('prepack exploded');
|
|
104
|
+
});
|
|
105
|
+
});
|
|
@@ -162,6 +162,22 @@ export function parseNpmPackOutput(output) {
|
|
|
162
162
|
};
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
+
/**
|
|
166
|
+
* Summarize the JSON error npm prints on stdout when `--json` pack fails.
|
|
167
|
+
* @param {string} output
|
|
168
|
+
* @returns {string}
|
|
169
|
+
*/
|
|
170
|
+
function npmPackErrorDetail(output) {
|
|
171
|
+
try {
|
|
172
|
+
const error = JSON.parse(output)?.error;
|
|
173
|
+
return [error?.summary, error?.detail]
|
|
174
|
+
.filter(part => typeof part === 'string' && part.trim() !== '')
|
|
175
|
+
.join(': ');
|
|
176
|
+
} catch {
|
|
177
|
+
return (output || '').trim();
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
165
181
|
/**
|
|
166
182
|
* Run `npm pack --json` with output directed to `destDir` so no preexisting
|
|
167
183
|
* tgz is overwritten. This intentionally runs the package lifecycle, matching
|
|
@@ -175,16 +191,25 @@ export function parseNpmPackOutput(output) {
|
|
|
175
191
|
function runNpmPack(packageDir, destDir) {
|
|
176
192
|
const result = spawnSync(
|
|
177
193
|
'npm',
|
|
178
|
-
[
|
|
194
|
+
[
|
|
195
|
+
'pack',
|
|
196
|
+
'--json',
|
|
197
|
+
'--silent',
|
|
198
|
+
// Lifecycle scripts still run; background mode keeps their output off
|
|
199
|
+
// the stdout that carries the JSON result.
|
|
200
|
+
'--foreground-scripts=false',
|
|
201
|
+
`--pack-destination=${destDir}`,
|
|
202
|
+
],
|
|
179
203
|
{cwd: packageDir, encoding: 'utf-8', timeout: 60_000},
|
|
180
204
|
);
|
|
181
205
|
if (result.error) {
|
|
182
206
|
throw new Error(`Could not start npm pack: ${result.error.message}`);
|
|
183
207
|
}
|
|
184
208
|
if (result.status !== 0) {
|
|
185
|
-
const
|
|
209
|
+
const detail =
|
|
210
|
+
(result.stderr || '').trim() || npmPackErrorDetail(result.stdout);
|
|
186
211
|
throw new Error(
|
|
187
|
-
`npm pack failed (exit ${result.status})${
|
|
212
|
+
`npm pack failed (exit ${result.status})${detail ? `: ${detail}` : ''}.`,
|
|
188
213
|
);
|
|
189
214
|
}
|
|
190
215
|
return parseNpmPackOutput(result.stdout);
|
package/api/json/index.ts
CHANGED
|
@@ -26,7 +26,6 @@ export type * from '../gap-report/gap-report.type.mjs';
|
|
|
26
26
|
export type * from '../upgrade/upgrade.type.mjs';
|
|
27
27
|
export type * from '../init/init.type.mjs';
|
|
28
28
|
export type * from '../doctor/doctor.type.mjs';
|
|
29
|
-
export type * from '../layout/layout.type.mjs';
|
|
30
29
|
export type * from '../integration/validate-integration.type.mjs';
|
|
31
30
|
export type * from '../integration/authoring-checks.type.mjs';
|
|
32
31
|
export type * from '../integration/pack-check.type.mjs';
|
|
@@ -127,6 +127,24 @@ describe('search leaf — docs at the grain a reader reads them', () => {
|
|
|
127
127
|
SLOW,
|
|
128
128
|
);
|
|
129
129
|
|
|
130
|
+
it(
|
|
131
|
+
'finds the component batch guide from task language',
|
|
132
|
+
async () => {
|
|
133
|
+
const result = await search('look up several components', {
|
|
134
|
+
cwd,
|
|
135
|
+
type: 'doc',
|
|
136
|
+
});
|
|
137
|
+
expect(result.data.results).toContainEqual(
|
|
138
|
+
expect.objectContaining({
|
|
139
|
+
name: 'cli/component-lookups',
|
|
140
|
+
section: 'several',
|
|
141
|
+
command: 'astryx docs cli/component-lookups several',
|
|
142
|
+
}),
|
|
143
|
+
);
|
|
144
|
+
},
|
|
145
|
+
SLOW,
|
|
146
|
+
);
|
|
147
|
+
|
|
130
148
|
it(
|
|
131
149
|
'gives a top-level namespace hit the topic list as its parent',
|
|
132
150
|
async () => {
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Regression coverage for the floating bulk-actions Table block.
|
|
5
|
+
* @input The shipped TableFloatingBulkActionsTable source.
|
|
6
|
+
* @output Assertions for width, logical scrolling, local stacking, and shared toolbar geometry.
|
|
7
|
+
* @position Template contract test for the website example layout.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import fs from 'node:fs';
|
|
11
|
+
import path from 'node:path';
|
|
12
|
+
import {fileURLToPath} from 'node:url';
|
|
13
|
+
import {describe, expect, it} from 'vitest';
|
|
14
|
+
|
|
15
|
+
const sourcePath = path.resolve(
|
|
16
|
+
path.dirname(fileURLToPath(import.meta.url)),
|
|
17
|
+
'../../assets/templates/blocks/components/Table/TableFloatingBulkActionsTable.tsx',
|
|
18
|
+
);
|
|
19
|
+
const source = fs.readFileSync(sourcePath, 'utf8');
|
|
20
|
+
const pageStyles = source.match(/page:\s*\{([\s\S]*?)\n\s{2}\},/)?.[1];
|
|
21
|
+
const tableRegionStyles = source.match(
|
|
22
|
+
/tableRegion:\s*\{([\s\S]*?)\n\s{2}\},/,
|
|
23
|
+
)?.[1];
|
|
24
|
+
const toolbarStyles = source.match(/toolbar:\s*\{([\s\S]*?)\n\s{2}\},/)?.[1];
|
|
25
|
+
const columns = source.match(
|
|
26
|
+
/const columns:[\s\S]*?=\s*\[([\s\S]*?)\n\];/,
|
|
27
|
+
)?.[1];
|
|
28
|
+
|
|
29
|
+
describe('Table floating bulk-actions template', () => {
|
|
30
|
+
it('caps the demo height without capping its width', () => {
|
|
31
|
+
expect(pageStyles).toContain('maxBlockSize: 640');
|
|
32
|
+
expect(pageStyles).not.toContain('maxWidth');
|
|
33
|
+
expect(pageStyles).not.toContain('marginInline');
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('uses the shared logical-axis scroll behavior', () => {
|
|
37
|
+
expect(source).toContain(
|
|
38
|
+
"import {ScrollableArea} from '@astryxdesign/core/ScrollableArea'",
|
|
39
|
+
);
|
|
40
|
+
expect(source).toMatch(
|
|
41
|
+
/<ScrollableArea[\s\S]*?axis="block"[\s\S]*?label="Bulk actions example"[\s\S]*?overscroll="contain"/,
|
|
42
|
+
);
|
|
43
|
+
expect(source).not.toContain('role="region"');
|
|
44
|
+
expect(source).not.toContain('tabIndex={0}');
|
|
45
|
+
expect(source).not.toContain('aria-label="Metrics"');
|
|
46
|
+
expect(pageStyles).not.toContain('overflowY');
|
|
47
|
+
expect(pageStyles).not.toContain('overscrollBehavior');
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('keeps the floating toolbar inside an isolated local stacking context', () => {
|
|
51
|
+
expect(pageStyles).toContain("isolation: 'isolate'");
|
|
52
|
+
expect(toolbarStyles).toContain('zIndex: 1');
|
|
53
|
+
expect(toolbarStyles).not.toContain('zIndex: 20');
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('shares one reserved-space variable across the placement geometry', () => {
|
|
57
|
+
expect(tableRegionStyles).toContain("'--table-bulk-actions-space'");
|
|
58
|
+
expect(source.match(/var\(--table-bulk-actions-space\)/g)).toHaveLength(4);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('keeps the email column compact enough to avoid horizontal overflow', () => {
|
|
62
|
+
expect(columns).toContain(
|
|
63
|
+
"{key: 'email', header: 'Email', width: proportional(1)}",
|
|
64
|
+
);
|
|
65
|
+
});
|
|
66
|
+
});
|