@astryxdesign/cli 0.6.5-canary.24fe2cd → 0.6.5-canary.2ad3b83
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 +13 -14
- package/api/build/_adapter.d.mts +2 -36
- package/api/build/_adapter.mjs +10 -41
- package/api/build/build.doc.mjs +2 -2
- package/api/build/build.test.mjs +2 -38
- package/api/build/kit/kit.mjs +21 -65
- package/api/build/kit/rank.d.mts +8 -24
- package/api/build/kit/rank.mjs +97 -277
- package/api/build/kit/rank.test.mjs +48 -231
- package/api/error.d.mts +0 -22
- package/api/error.mjs +0 -42
- package/api/integration/add-contribution.d.mts +1 -2
- package/api/integration/add-contribution.mjs +3 -7
- package/api/integration/add-contribution.test.mjs +3 -3
- package/api/integration/add-theme.mjs +22 -243
- package/api/integration/add-theme.test.mjs +0 -213
- package/api/integration/authoring-checks.mjs +7 -10
- package/api/integration/authoring-checks.type.d.mts +0 -8
- package/api/integration/authoring-checks.type.mjs +3 -7
- package/api/integration/integration-authoring.type.d.mts +1 -4
- package/api/integration/integration-authoring.type.mjs +1 -6
- package/api/integration/integrationAdd.doc.mjs +0 -6
- package/api/integration/integrationAddTheme.doc.mjs +0 -10
- package/api/integration/integrationComponentConflicts.doc.mjs +1 -1
- package/api/integration/integrationDocConflicts.doc.mjs +1 -1
- package/api/integration/integrationTemplateConflicts.doc.mjs +1 -1
- package/api/integration/pack-check.mjs +2 -11
- package/api/integration/pack-check.test.mjs +1 -38
- package/api/integration/validate-integration.d.mts +2 -4
- package/api/integration/validate-integration.mjs +2 -7
- package/api/integration/validate-integration.test.mjs +0 -55
- package/api/integration/validate-integration.type.d.mts +0 -5
- package/api/integration/validate-integration.type.mjs +1 -5
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/layout/expand/expand.mjs +7 -12
- package/api/layout/layout.type.d.mts +0 -1
- package/api/layout/layout.type.mjs +0 -1
- package/api/layout/layoutExpand.doc.mjs +1 -1
- package/api/search/search.d.mts +0 -24
- package/api/search/search.mjs +1 -71
- package/api/swizzle/copy/copy.mjs +3 -66
- package/api/swizzle/swizzle.doc.mjs +0 -4
- package/api/template/copy/copy.mjs +8 -14
- package/api/template/show/show.mjs +4 -15
- package/api/template/template-integration.test.mjs +0 -14
- package/api/template/template.d.mts +1 -1
- package/api/template/template.doc.mjs +2 -6
- package/api/template/template.mjs +0 -1
- package/api/template/template.type.d.mts +0 -2
- package/api/template/template.type.mjs +0 -2
- package/api/theme/build/build.d.mts +0 -24
- package/api/theme/build/build.mjs +8 -235
- package/api/upgrade/run/run.mjs +3 -20
- package/api/upgrade/run/run.test.mjs +1 -45
- package/api/upgrade/upgrade.doc.mjs +1 -1
- package/api/upgrade/upgrade.type.d.mts +0 -1
- package/api/upgrade/upgrade.type.mjs +0 -1
- package/assets/docs/tree/check-your-docs.doc.mjs +2 -2
- package/assets/docs/tree/checks.doc.mjs +1 -1
- package/assets/docs/tree/sections-and-placement.doc.mjs +1 -1
- package/assets/docs/tree/template-doc-overview.doc.mjs +1 -13
- package/assets/docs/tree/troubleshooting.doc.mjs +3 -7
- package/assets/docs/tree/versioning.doc.mjs +6 -6
- package/assets/templates/pages/ai-chat/template.doc.mjs +1 -16
- package/assets/templates/pages/ai-chat-landing/template.doc.mjs +1 -9
- package/assets/templates/pages/blank/template.doc.mjs +1 -3
- package/assets/templates/pages/canvas-editor/template.doc.mjs +1 -9
- package/assets/templates/pages/centered-hero/template.doc.mjs +1 -3
- package/assets/templates/pages/checkout-wizard/template.doc.mjs +0 -1
- package/assets/templates/pages/classic-gallery/template.doc.mjs +1 -3
- package/assets/templates/pages/contact-form/template.doc.mjs +1 -16
- package/assets/templates/pages/dashboard/template.doc.mjs +1 -15
- package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +1 -23
- package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +1 -10
- package/assets/templates/pages/dashboard-comparison/template.doc.mjs +1 -9
- package/assets/templates/pages/dashboard-composition/template.doc.mjs +1 -10
- package/assets/templates/pages/dashboard-progress/template.doc.mjs +1 -17
- package/assets/templates/pages/dashboard-scorecard/template.doc.mjs +1 -2
- package/assets/templates/pages/detail-page/template.doc.mjs +0 -8
- package/assets/templates/pages/documentation/template.doc.mjs +1 -10
- package/assets/templates/pages/documentation-design/template.doc.mjs +1 -10
- package/assets/templates/pages/documentation-technical/template.doc.mjs +1 -10
- package/assets/templates/pages/editor/template.doc.mjs +1 -9
- package/assets/templates/pages/file-explorer/template.doc.mjs +1 -3
- package/assets/templates/pages/form-two-column/template.doc.mjs +1 -17
- package/assets/templates/pages/form-wizard/template.doc.mjs +1 -14
- package/assets/templates/pages/form-wizard-dialog/template.doc.mjs +0 -1
- package/assets/templates/pages/gallery-hero/template.doc.mjs +1 -10
- package/assets/templates/pages/ide/template.doc.mjs +1 -9
- package/assets/templates/pages/incident-console/template.doc.mjs +1 -10
- package/assets/templates/pages/kanban-board/template.doc.mjs +1 -11
- package/assets/templates/pages/library/template.doc.mjs +1 -15
- package/assets/templates/pages/login/template.doc.mjs +1 -10
- package/assets/templates/pages/login-card/template.doc.mjs +1 -11
- package/assets/templates/pages/login-split/template.doc.mjs +1 -10
- package/assets/templates/pages/login-sso/template.doc.mjs +1 -10
- package/assets/templates/pages/messaging-shell/template.doc.mjs +1 -11
- package/assets/templates/pages/mixed-gallery/template.doc.mjs +1 -10
- package/assets/templates/pages/payment-form/template.doc.mjs +1 -3
- package/assets/templates/pages/product-detail/template.doc.mjs +1 -9
- package/assets/templates/pages/product-gallery/template.doc.mjs +1 -10
- package/assets/templates/pages/settings/template.doc.mjs +1 -3
- package/assets/templates/pages/settings-dialog/template.doc.mjs +1 -9
- package/assets/templates/pages/settings-sidebar/template.doc.mjs +1 -9
- package/assets/templates/pages/shell-nav/template.doc.mjs +1 -10
- package/assets/templates/pages/shell-side-nav/template.doc.mjs +1 -14
- package/assets/templates/pages/shell-top-nav/template.doc.mjs +1 -11
- package/assets/templates/pages/side-gallery/template.doc.mjs +1 -3
- package/assets/templates/pages/table/template.doc.mjs +1 -11
- package/assets/templates/pages/table-filter/template.doc.mjs +1 -21
- package/assets/templates/pages/table-grouped/template.doc.mjs +1 -15
- package/assets/templates/pages/table-inbox/template.doc.mjs +6 -18
- package/assets/templates/pages/table-page/template.doc.mjs +1 -20
- package/assets/templates/pages/table-tree/template.doc.mjs +1 -14
- package/assets/templates/pages/theme-showcase/template.doc.mjs +1 -10
- package/assets/templates/pages/work-item-detail/template.doc.mjs +0 -10
- package/authoring/doctypes/template/parse.d.mts +0 -2
- package/authoring/doctypes/template/parse.mjs +0 -1
- package/authoring/doctypes/template/parse.test.mjs +0 -21
- package/authoring/doctypes/template/template.doc.mjs +0 -6
- package/authoring/doctypes/template/type.ts +0 -10
- package/clients/cli/commands/doctor.mjs +4 -4
- package/clients/cli/commands/integration-add.doc.mjs +0 -10
- package/clients/cli/commands/integration-authoring.test.mjs +2 -12
- package/clients/cli/commands/integration.mjs +1 -3
- package/clients/cli/commands/layout-expand.doc.mjs +1 -3
- package/clients/cli/commands/layout.mjs +0 -16
- package/clients/cli/commands/template.mjs +5 -19
- package/clients/cli/commands/upgrade.ascii-output.test.mjs +0 -14
- package/clients/cli/lib/manifest.mjs +165 -44
- package/clients/cli/lib/manifest.test.mjs +7 -98
- package/foundation/discovery/template-adapter.d.mts +0 -14
- package/foundation/discovery/template-adapter.fixture-refs.test.mjs +1 -37
- package/foundation/discovery/template-adapter.mjs +1 -21
- package/foundation/doc-compiler/doc-loads.test.mjs +2 -2
- package/foundation/integrations/cli-requirement.d.mts +11 -23
- package/foundation/integrations/cli-requirement.mjs +18 -40
- package/foundation/integrations/cli-requirement.test.mjs +15 -66
- package/foundation/response/response-types.doc.d.mts +5 -5
- package/foundation/response/response-types.doc.mjs +13 -13
- package/package.json +9 -9
- package/api/docs/docs.test.mjs +0 -279
- package/api/docs/integration-tree.test.mjs +0 -572
- package/api/docs/integrationDocs.test.mjs +0 -336
- package/api/layout/expand/expand.receipt.test.mjs +0 -74
- package/api/search/search.test.mjs +0 -710
- package/api/template/copy/copy.receipt.test.mjs +0 -77
- package/api/template/show/show.test.mjs +0 -76
- package/api/theme/build/build.project-core.test.mjs +0 -165
- package/clients/cli/commands/docs.test.mjs +0 -383
- package/clients/cli/commands/layout.expand-receipt.test.mjs +0 -94
- package/clients/cli/commands/template.copy-receipt.test.mjs +0 -60
- package/clients/cli/commands/template.show-media.test.mjs +0 -62
- package/clients/cli/commands/write-failure.test.mjs +0 -175
- package/foundation/agent-docs/agent-docs.test.mjs +0 -1160
- package/foundation/doc-compiler/tree.test.mjs +0 -649
|
@@ -2,15 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @file Tests for build's page ranker: long ideas, head nouns, family bases,
|
|
5
|
-
* rare-word weighting,
|
|
6
|
-
* themselves, and parts told from pages by the system's own components.
|
|
5
|
+
* rare-word weighting, and family words taken from the templates themselves.
|
|
7
6
|
*/
|
|
8
7
|
|
|
9
8
|
import {describe, it, expect} from 'vitest';
|
|
10
9
|
import * as path from 'node:path';
|
|
11
10
|
import {fileURLToPath} from 'node:url';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
11
|
+
import {pickStart, rankPages} from './rank.mjs';
|
|
12
|
+
import {loadPageTemplates} from '../_adapter.mjs';
|
|
14
13
|
|
|
15
14
|
// api/build/kit/ -> up 5 = repo root (has packages/core and the templates).
|
|
16
15
|
const REPO = path.resolve(
|
|
@@ -18,24 +17,14 @@ const REPO = path.resolve(
|
|
|
18
17
|
'../../../../..',
|
|
19
18
|
);
|
|
20
19
|
|
|
21
|
-
/**
|
|
22
|
-
|
|
23
|
-
* @param {string} category
|
|
24
|
-
* @param {string} description
|
|
25
|
-
* @param {string[]} [keywords]
|
|
26
|
-
*/
|
|
27
|
-
const page = (name, category, description, keywords = []) => ({
|
|
20
|
+
/** @param {string} name @param {string} category @param {string} description */
|
|
21
|
+
const page = (name, category, description) => ({
|
|
28
22
|
name,
|
|
29
23
|
displayName: name,
|
|
30
24
|
category,
|
|
31
25
|
description,
|
|
32
|
-
keywords,
|
|
33
|
-
command: `astryx template ${name} --type page`,
|
|
34
26
|
});
|
|
35
27
|
|
|
36
|
-
/** @param {string} name @param {string[]} [keywords] */
|
|
37
|
-
const component = (name, keywords = []) => ({name, keywords});
|
|
38
|
-
|
|
39
28
|
describe('rankPages on the shipped page templates', () => {
|
|
40
29
|
/** @param {string} query */
|
|
41
30
|
const start = async query =>
|
|
@@ -60,19 +49,6 @@ describe('rankPages on the shipped page templates', () => {
|
|
|
60
49
|
);
|
|
61
50
|
});
|
|
62
51
|
|
|
63
|
-
it('keeps the family base when a variant shares one incidental word', async () => {
|
|
64
|
-
// "comparison" and "cohort" name dashboard variants, but here each is one
|
|
65
|
-
// small part of a general dashboard.
|
|
66
|
-
expect(
|
|
67
|
-
await start(
|
|
68
|
-
'support dashboard with ticket volume charts and a small comparison note',
|
|
69
|
-
),
|
|
70
|
-
).toBe('dashboard');
|
|
71
|
-
expect(
|
|
72
|
-
await start('sales dashboard with a cohort filter and weekly charts'),
|
|
73
|
-
).toBe('dashboard');
|
|
74
|
-
});
|
|
75
|
-
|
|
76
52
|
it('lets the head noun decide between families', async () => {
|
|
77
53
|
// Both ideas mention a table and summary numbers; the head says which
|
|
78
54
|
// page it is.
|
|
@@ -88,14 +64,6 @@ describe('rankPages on the shipped page templates', () => {
|
|
|
88
64
|
).toMatch(/^table-/);
|
|
89
65
|
});
|
|
90
66
|
|
|
91
|
-
it('keeps a variant that leads when its family base cannot start alone', async () => {
|
|
92
|
-
// The dashboard base matches only the family word here; the funnel
|
|
93
|
-
// dashboard matches the idea.
|
|
94
|
-
expect(await start('a funnel for a dashboard')).toBe(
|
|
95
|
-
'dashboard-cohort-funnel',
|
|
96
|
-
);
|
|
97
|
-
});
|
|
98
|
-
|
|
99
67
|
it('does not start from one rare word', async () => {
|
|
100
68
|
// "board" is the kanban board's own word; a game board is not a kanban.
|
|
101
69
|
expect(
|
|
@@ -107,10 +75,11 @@ describe('rankPages on the shipped page templates', () => {
|
|
|
107
75
|
describe('rankPages on any catalog', () => {
|
|
108
76
|
it('ranks only the templates it is given', () => {
|
|
109
77
|
const ranked = rankPages('dashboard', [
|
|
110
|
-
page(
|
|
78
|
+
page(
|
|
111
79
|
'dashboard',
|
|
112
|
-
'
|
|
113
|
-
|
|
80
|
+
'Dashboard - Analytics',
|
|
81
|
+
'Tiles, charts, tables. Dashboard, metrics.',
|
|
82
|
+
),
|
|
114
83
|
]);
|
|
115
84
|
expect(ranked.map(r => r.name)).toEqual(['dashboard']);
|
|
116
85
|
});
|
|
@@ -119,14 +88,17 @@ describe('rankPages on any catalog', () => {
|
|
|
119
88
|
// An integration's family: its word is in two of its ids, so an idea
|
|
120
89
|
// naming it picks the family, and its base template leads it.
|
|
121
90
|
const catalog = [
|
|
122
|
-
page(
|
|
91
|
+
page(
|
|
123
92
|
'dashboard',
|
|
124
|
-
'
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
page('widget
|
|
128
|
-
|
|
129
|
-
|
|
93
|
+
'Dashboard - Analytics',
|
|
94
|
+
'Tiles, charts, tables. Dashboard, metrics.',
|
|
95
|
+
),
|
|
96
|
+
page('widget', 'Widget - Basic', 'One compact card. Widget, tile.'),
|
|
97
|
+
page(
|
|
98
|
+
'widget-grid',
|
|
99
|
+
'Widget - Grid',
|
|
100
|
+
'Many compact cards in a grid. Widget wall.',
|
|
101
|
+
),
|
|
130
102
|
];
|
|
131
103
|
const ranked = rankPages('weather widget with charts', catalog);
|
|
132
104
|
expect(ranked[0].name).toBe('widget');
|
|
@@ -134,41 +106,15 @@ describe('rankPages on any catalog', () => {
|
|
|
134
106
|
expect(pickStart(ranked)?.name).toBe('widget');
|
|
135
107
|
});
|
|
136
108
|
|
|
137
|
-
it("counts a template's keywords above words in its description", () => {
|
|
138
|
-
// Both mention uptime; only one names it as an idea it serves.
|
|
139
|
-
const catalog = [
|
|
140
|
-
page('ops', 'Dashboard - Ops', 'Uptime strips beside alert rows.'),
|
|
141
|
-
page('health', 'Dashboard - Health', 'Status tiles over time charts.', [
|
|
142
|
-
'uptime',
|
|
143
|
-
]),
|
|
144
|
-
];
|
|
145
|
-
expect(rankPages('uptime overview', catalog)[0].name).toBe('health');
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
it("lets a variant displace its family's base only with two words of its own", () => {
|
|
149
|
-
const catalog = [
|
|
150
|
-
page('widget', 'Widget - Basic', 'One compact card.', ['widget']),
|
|
151
|
-
page('widget-weather', 'Widget - Weather', 'A forecast card.', [
|
|
152
|
-
'weather',
|
|
153
|
-
'forecast',
|
|
154
|
-
'radar',
|
|
155
|
-
]),
|
|
156
|
-
];
|
|
157
|
-
// One word of the variant's own: still the family's base.
|
|
158
|
-
expect(rankPages('weather widget', catalog)[0].name).toBe('widget');
|
|
159
|
-
// Two: the variant.
|
|
160
|
-
expect(rankPages('weather widget with radar', catalog)[0].name).toBe(
|
|
161
|
-
'widget-weather',
|
|
162
|
-
);
|
|
163
|
-
});
|
|
164
|
-
|
|
165
109
|
it('weighs a word by how rare it is among page templates', () => {
|
|
166
110
|
const catalog = [
|
|
167
|
-
page('alpha', 'Dashboard - Alpha', 'Status tiles.
|
|
168
|
-
page('beta', 'Dashboard - Beta', 'Status rows.
|
|
169
|
-
page(
|
|
170
|
-
'
|
|
171
|
-
|
|
111
|
+
page('alpha', 'Dashboard - Alpha', 'Status tiles. Status overview.'),
|
|
112
|
+
page('beta', 'Dashboard - Beta', 'Status rows. Status list.'),
|
|
113
|
+
page(
|
|
114
|
+
'gamma',
|
|
115
|
+
'Dashboard - Gamma',
|
|
116
|
+
'Funnel of stages. Funnel conversion.',
|
|
117
|
+
),
|
|
172
118
|
];
|
|
173
119
|
// "status" is on two templates, "funnel" on one: the rare word wins.
|
|
174
120
|
const ranked = rankPages('status funnel', catalog);
|
|
@@ -181,24 +127,22 @@ describe('rankPages structure signals', () => {
|
|
|
181
127
|
page(
|
|
182
128
|
'dialog-panel',
|
|
183
129
|
'Settings - Dialog',
|
|
184
|
-
'Preferences inside a modal container.',
|
|
185
|
-
|
|
130
|
+
'Preferences inside a modal container. Settings, or modal dialog.',
|
|
131
|
+
),
|
|
132
|
+
page(
|
|
133
|
+
'tree-table',
|
|
134
|
+
'Table - Tree',
|
|
135
|
+
'Nested rows under parents. Tree, nested rows, file browser.',
|
|
136
|
+
),
|
|
137
|
+
page(
|
|
138
|
+
'item-detail',
|
|
139
|
+
'Content - Item Detail',
|
|
140
|
+
'One item with its media. Product, listing, or item detail.',
|
|
186
141
|
),
|
|
187
|
-
page('tree-table', 'Table - Tree', 'Nested rows under parents.', [
|
|
188
|
-
'tree',
|
|
189
|
-
'nested rows',
|
|
190
|
-
'file browser',
|
|
191
|
-
]),
|
|
192
|
-
page('item-detail', 'Content - Item Detail', 'One item with its media.', [
|
|
193
|
-
'product',
|
|
194
|
-
'listing',
|
|
195
|
-
'item detail',
|
|
196
|
-
]),
|
|
197
142
|
page(
|
|
198
143
|
'docs-catalog',
|
|
199
144
|
'Content - Documentation Catalog',
|
|
200
|
-
'A grid of category cards.',
|
|
201
|
-
['documentation', 'docs', 'api index'],
|
|
145
|
+
'A grid of category cards. Documentation, docs, or API index.',
|
|
202
146
|
),
|
|
203
147
|
];
|
|
204
148
|
|
|
@@ -235,145 +179,18 @@ describe('rankPages structure signals', () => {
|
|
|
235
179
|
it('does not treat a synonym as a family name', () => {
|
|
236
180
|
// "landing" is a synonym of "hero" in search, not a family word here.
|
|
237
181
|
const heroes = [
|
|
238
|
-
page(
|
|
239
|
-
'hero',
|
|
240
|
-
'
|
|
241
|
-
'landing',
|
|
242
|
-
|
|
243
|
-
page(
|
|
244
|
-
'hero',
|
|
245
|
-
'
|
|
246
|
-
|
|
182
|
+
page(
|
|
183
|
+
'hero-centered',
|
|
184
|
+
'Gallery - Hero',
|
|
185
|
+
'A centered hero. Hero, banner, or landing.',
|
|
186
|
+
),
|
|
187
|
+
page(
|
|
188
|
+
'hero-split',
|
|
189
|
+
'Gallery - Hero Split',
|
|
190
|
+
'A split hero. Hero or splash.',
|
|
191
|
+
),
|
|
247
192
|
];
|
|
248
193
|
const ranked = rankPages('internal landing page', heroes);
|
|
249
194
|
expect(ranked.every(r => !r.familyNamed)).toBe(true);
|
|
250
195
|
});
|
|
251
196
|
});
|
|
252
|
-
|
|
253
|
-
describe('ideaKind: a part of a page, told by the components the system ships', () => {
|
|
254
|
-
const pages = [
|
|
255
|
-
page('table', 'Table - Basic', 'Rows of records.'),
|
|
256
|
-
page('table-filter', 'Table - Filtering', 'Rows narrowed by filters.'),
|
|
257
|
-
page('settings', 'Settings', 'Grouped preferences.'),
|
|
258
|
-
];
|
|
259
|
-
const components = [
|
|
260
|
-
component('DateRangeInput', ['date picker']),
|
|
261
|
-
component('Tooltip'),
|
|
262
|
-
component('Calendar'),
|
|
263
|
-
component('Table'),
|
|
264
|
-
component('Dialog', ['modal']),
|
|
265
|
-
];
|
|
266
|
-
/** @param {string} idea @param {object[]} [using] */
|
|
267
|
-
const kind = (idea, using = components) => ideaKind(idea, pages, using);
|
|
268
|
-
|
|
269
|
-
it('takes a part from a component name or keyword at the head', () => {
|
|
270
|
-
expect(kind('a date range input')).toBe('part');
|
|
271
|
-
expect(kind('a date picker with presets')).toBe('part');
|
|
272
|
-
expect(kind('a tooltip')).toBe('part');
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
it('takes a page word or a family word at the head as a page', () => {
|
|
276
|
-
expect(kind('a calendar')).toBe('part');
|
|
277
|
-
expect(kind('a team calendar page')).toBe('page');
|
|
278
|
-
// Table is a component, but table is also a family of page templates.
|
|
279
|
-
expect(kind('a data table with filters')).toBe('page');
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
it("reads parts from the project's own components", () => {
|
|
283
|
-
// An integration's component joins the vocabulary by existing.
|
|
284
|
-
expect(kind('a revenue gauge')).toBe('page');
|
|
285
|
-
expect(
|
|
286
|
-
kind('a revenue gauge', [...components, component('AcmeGauge')]),
|
|
287
|
-
).toBe('part');
|
|
288
|
-
});
|
|
289
|
-
|
|
290
|
-
it("takes an idea that lists a page's worth of pieces as a page", () => {
|
|
291
|
-
expect(kind('a calendar with a tooltip')).toBe('part');
|
|
292
|
-
expect(kind('a calendar, a tooltip, and a date range input')).toBe('page');
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
it('takes the frame of a container phrase as the frame, not the head', () => {
|
|
296
|
-
expect(kind('a dialog')).toBe('part');
|
|
297
|
-
expect(kind('saved drafts in a modal')).toBe('page');
|
|
298
|
-
});
|
|
299
|
-
|
|
300
|
-
it('takes a change to an existing page or part as an edit', () => {
|
|
301
|
-
expect(kind('add a sort toggle to the existing reports table')).toBe(
|
|
302
|
-
'edit',
|
|
303
|
-
);
|
|
304
|
-
expect(kind('reuse the existing tooltip on the chart')).toBe('edit');
|
|
305
|
-
});
|
|
306
|
-
|
|
307
|
-
it('does not take "existing" that names no page or part as an edit', () => {
|
|
308
|
-
expect(kind('a new settings page inspired by the existing one')).toBe(
|
|
309
|
-
'page',
|
|
310
|
-
);
|
|
311
|
-
expect(kind('show existing users in a settings page')).toBe('page');
|
|
312
|
-
});
|
|
313
|
-
|
|
314
|
-
it('does not take a request for a new page as an edit', () => {
|
|
315
|
-
expect(
|
|
316
|
-
kind('a new settings page based on the existing settings page'),
|
|
317
|
-
).toBe('page');
|
|
318
|
-
expect(kind('clone the existing table as a new page')).toBe('page');
|
|
319
|
-
// "A new column" asks for a part, so the change stays a change.
|
|
320
|
-
expect(kind('add a new column to the existing reports table')).toBe('edit');
|
|
321
|
-
});
|
|
322
|
-
});
|
|
323
|
-
|
|
324
|
-
describe('pickStart on parts and edits (spec:AST-048/FR3)', () => {
|
|
325
|
-
const shipped = Promise.all([loadPageTemplates(REPO), loadComponents(REPO)]);
|
|
326
|
-
/** @param {string} query */
|
|
327
|
-
const start = async query => {
|
|
328
|
-
const [catalog, components] = await shipped;
|
|
329
|
-
const kind = ideaKind(query, catalog, components);
|
|
330
|
-
return pickStart(rankPages(query, catalog), kind)?.name ?? null;
|
|
331
|
-
};
|
|
332
|
-
|
|
333
|
-
it('starts a part from the page it names, else from the app shell', async () => {
|
|
334
|
-
expect(await start('an empty state for a settings page')).toBe('settings');
|
|
335
|
-
expect(await start('a date range picker')).toBeNull();
|
|
336
|
-
expect(await start('compact status pill with a tooltip')).toBeNull();
|
|
337
|
-
});
|
|
338
|
-
|
|
339
|
-
it('starts an edit of an existing page or part from the app shell', async () => {
|
|
340
|
-
for (const idea of [
|
|
341
|
-
'add a sparkline column to the existing incidents table',
|
|
342
|
-
'add a sort toggle to the existing reports dashboard',
|
|
343
|
-
'swap the existing banner for a toast',
|
|
344
|
-
]) {
|
|
345
|
-
expect(await start(idea)).toBeNull();
|
|
346
|
-
}
|
|
347
|
-
});
|
|
348
|
-
|
|
349
|
-
it('starts a new page that mentions something existing from its template', async () => {
|
|
350
|
-
expect(await start('a new dashboard inspired by the existing one')).toBe(
|
|
351
|
-
'dashboard',
|
|
352
|
-
);
|
|
353
|
-
expect(await start('show existing users in a table page')).toMatch(
|
|
354
|
-
/^table/,
|
|
355
|
-
);
|
|
356
|
-
});
|
|
357
|
-
|
|
358
|
-
it('starts a new page that names an existing one from its template', async () => {
|
|
359
|
-
for (const idea of [
|
|
360
|
-
'a new dashboard based on the existing dashboard',
|
|
361
|
-
'a new dashboard like the existing dashboard',
|
|
362
|
-
'clone the existing dashboard as a new page',
|
|
363
|
-
]) {
|
|
364
|
-
expect(await start(idea)).toBe('dashboard');
|
|
365
|
-
}
|
|
366
|
-
});
|
|
367
|
-
|
|
368
|
-
it('reads a bare "existing" phrase that names a page as the builder\'s page', async () => {
|
|
369
|
-
expect(
|
|
370
|
-
await start('existing reports dashboard with a date filter'),
|
|
371
|
-
).toBeNull();
|
|
372
|
-
});
|
|
373
|
-
|
|
374
|
-
it('still starts a whole page from its template', async () => {
|
|
375
|
-
expect(
|
|
376
|
-
await start('saved drafts in a modal with resume and delete row actions'),
|
|
377
|
-
).toBe('settings-dialog');
|
|
378
|
-
});
|
|
379
|
-
});
|
package/api/error.d.mts
CHANGED
|
@@ -1,28 +1,6 @@
|
|
|
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
|
-
* The error for a write that failed on the filesystem: no permission, a
|
|
6
|
-
* read-only mount, a full disk, a path component that is not a directory.
|
|
7
|
-
*
|
|
8
|
-
* A raw Node errno error reached the envelope as
|
|
9
|
-
* `{"error": "EACCES: permission denied, open '/home/you/p/readonly/x.tsx'",
|
|
10
|
-
* "code": "ERR_UNKNOWN"}` — the wrong code (ERR_WRITE_FAILED is in the frozen
|
|
11
|
-
* registry for exactly this) and an absolute host path in the message. This
|
|
12
|
-
* keeps the errno, which is the part that tells you what to fix, and reports
|
|
13
|
-
* the target the way every other Astryx message does: relative to the project.
|
|
14
|
-
*
|
|
15
|
-
* A caller that wrote files before the failure must undo them first and pass
|
|
16
|
-
* the ones it could not restore as `unrestored`, so the message never says
|
|
17
|
-
* nothing was written when something was.
|
|
18
|
-
*
|
|
19
|
-
* @param {string} target absolute path the write was aimed at
|
|
20
|
-
* @param {string} cwd project root, for the relative form
|
|
21
|
-
* @param {unknown} cause the error the filesystem call threw
|
|
22
|
-
* @param {string[]} [unrestored] absolute paths an undo could not put back
|
|
23
|
-
* @returns {AstryxError}
|
|
24
|
-
*/
|
|
25
|
-
export function writeFailed(target: string, cwd: string, cause: unknown, unrestored?: string[]): AstryxError;
|
|
26
4
|
export class AstryxError extends Error {
|
|
27
5
|
/**
|
|
28
6
|
* @param {string} message
|
package/api/error.mjs
CHANGED
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
import {ERROR_CODES} from '../foundation/response/error-codes.mjs';
|
|
15
|
-
import * as path from 'node:path';
|
|
16
15
|
|
|
17
16
|
export class AstryxError extends Error {
|
|
18
17
|
/** @type {import('../foundation/response/base').Suggestion[] | undefined} */
|
|
@@ -37,44 +36,3 @@ export class AstryxError extends Error {
|
|
|
37
36
|
if (Array.isArray(suggestions) && suggestions.length) this.suggestions = suggestions;
|
|
38
37
|
}
|
|
39
38
|
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* The error for a write that failed on the filesystem: no permission, a
|
|
43
|
-
* read-only mount, a full disk, a path component that is not a directory.
|
|
44
|
-
*
|
|
45
|
-
* A raw Node errno error reached the envelope as
|
|
46
|
-
* `{"error": "EACCES: permission denied, open '/home/you/p/readonly/x.tsx'",
|
|
47
|
-
* "code": "ERR_UNKNOWN"}` — the wrong code (ERR_WRITE_FAILED is in the frozen
|
|
48
|
-
* registry for exactly this) and an absolute host path in the message. This
|
|
49
|
-
* keeps the errno, which is the part that tells you what to fix, and reports
|
|
50
|
-
* the target the way every other Astryx message does: relative to the project.
|
|
51
|
-
*
|
|
52
|
-
* A caller that wrote files before the failure must undo them first and pass
|
|
53
|
-
* the ones it could not restore as `unrestored`, so the message never says
|
|
54
|
-
* nothing was written when something was.
|
|
55
|
-
*
|
|
56
|
-
* @param {string} target absolute path the write was aimed at
|
|
57
|
-
* @param {string} cwd project root, for the relative form
|
|
58
|
-
* @param {unknown} cause the error the filesystem call threw
|
|
59
|
-
* @param {string[]} [unrestored] absolute paths an undo could not put back
|
|
60
|
-
* @returns {AstryxError}
|
|
61
|
-
*/
|
|
62
|
-
export function writeFailed(target, cwd, cause, unrestored = []) {
|
|
63
|
-
const rel = path.relative(cwd, target) || target;
|
|
64
|
-
const errno =
|
|
65
|
-
typeof (/** @type {any} */ (cause)?.code) === 'string'
|
|
66
|
-
? /** @type {any} */ (cause).code
|
|
67
|
-
: null;
|
|
68
|
-
const why = errno === 'EACCES' || errno === 'EPERM' ? ' (no permission)' : '';
|
|
69
|
-
const outcome =
|
|
70
|
-
unrestored.length === 0
|
|
71
|
-
? 'Nothing was written.'
|
|
72
|
-
: `Earlier writes could not all be undone: ${unrestored
|
|
73
|
-
.map(file => path.relative(cwd, file) || file)
|
|
74
|
-
.join(', ')}.`;
|
|
75
|
-
return new AstryxError(
|
|
76
|
-
`Could not write ${rel}${errno ? `: ${errno}` : ''}${why}. ${outcome}`,
|
|
77
|
-
undefined,
|
|
78
|
-
ERROR_CODES.ERR_WRITE_FAILED,
|
|
79
|
-
);
|
|
80
|
-
}
|
|
@@ -31,7 +31,7 @@ export function integrationAddAgentDoc(line: string, options?: import("./integra
|
|
|
31
31
|
*
|
|
32
32
|
* @param {'component'|'doc'|'template'|'codemod'|'agent-doc'|'theme'} kind
|
|
33
33
|
* @param {string} name
|
|
34
|
-
* @param {{cwd?: string, dryRun?: boolean, templateType?: 'page'|'block', to?: string, replaces?: string, extends?: string, parent?: string
|
|
34
|
+
* @param {{cwd?: string, dryRun?: boolean, templateType?: 'page'|'block', to?: string, replaces?: string, extends?: string, parent?: string}} [options]
|
|
35
35
|
* @returns {Promise<import('./integration-authoring.type.mjs').IntegrationAddResponse>}
|
|
36
36
|
*/
|
|
37
37
|
export function integrationAdd(kind: "component" | "doc" | "template" | "codemod" | "agent-doc" | "theme", name: string, options?: {
|
|
@@ -42,5 +42,4 @@ export function integrationAdd(kind: "component" | "doc" | "template" | "codemod
|
|
|
42
42
|
replaces?: string;
|
|
43
43
|
extends?: string;
|
|
44
44
|
parent?: string;
|
|
45
|
-
from?: string;
|
|
46
45
|
}): Promise<import("./integration-authoring.type.mjs").IntegrationAddResponse>;
|
|
@@ -1211,7 +1211,7 @@ const KIND_OPTIONS = {
|
|
|
1211
1211
|
template: new Set(['cwd', 'dryRun', 'templateType']),
|
|
1212
1212
|
codemod: new Set(['cwd', 'dryRun', 'to']),
|
|
1213
1213
|
'agent-doc': new Set(['cwd', 'dryRun']),
|
|
1214
|
-
theme: new Set(['cwd', 'dryRun'
|
|
1214
|
+
theme: new Set(['cwd', 'dryRun']),
|
|
1215
1215
|
};
|
|
1216
1216
|
|
|
1217
1217
|
/**
|
|
@@ -1238,7 +1238,7 @@ function validateKindOptions(kind, options) {
|
|
|
1238
1238
|
*
|
|
1239
1239
|
* @param {'component'|'doc'|'template'|'codemod'|'agent-doc'|'theme'} kind
|
|
1240
1240
|
* @param {string} name
|
|
1241
|
-
* @param {{cwd?: string, dryRun?: boolean, templateType?: 'page'|'block', to?: string, replaces?: string, extends?: string, parent?: string
|
|
1241
|
+
* @param {{cwd?: string, dryRun?: boolean, templateType?: 'page'|'block', to?: string, replaces?: string, extends?: string, parent?: string}} [options]
|
|
1242
1242
|
* @returns {Promise<import('./integration-authoring.type.mjs').IntegrationAddResponse>}
|
|
1243
1243
|
*/
|
|
1244
1244
|
export async function integrationAdd(kind, name, options = {}) {
|
|
@@ -1270,10 +1270,6 @@ export async function integrationAdd(kind, name, options = {}) {
|
|
|
1270
1270
|
case 'agent-doc':
|
|
1271
1271
|
return integrationAddAgentDoc(name, options);
|
|
1272
1272
|
case 'theme':
|
|
1273
|
-
return integrationAddTheme(name,
|
|
1274
|
-
cwd: options.cwd,
|
|
1275
|
-
dryRun: options.dryRun,
|
|
1276
|
-
from: options.from,
|
|
1277
|
-
});
|
|
1273
|
+
return integrationAddTheme(name, options);
|
|
1278
1274
|
}
|
|
1279
1275
|
}
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
integrationAddTemplate,
|
|
13
13
|
} from './add-contribution.mjs';
|
|
14
14
|
import {validateLocalIntegration} from './validate-integration.mjs';
|
|
15
|
-
import {
|
|
15
|
+
import {DOCS_TREE_CLI} from '../../foundation/integrations/cli-requirement.mjs';
|
|
16
16
|
|
|
17
17
|
let tmpDir;
|
|
18
18
|
|
|
@@ -355,7 +355,7 @@ describe('integrationAdd doc', () => {
|
|
|
355
355
|
|
|
356
356
|
// The namespace doc needs a CLI that reads it, declared as an optional peer.
|
|
357
357
|
const pkg = JSON.parse(fs.readFileSync(path.join(tmpDir, 'package.json'), 'utf-8'));
|
|
358
|
-
expect(pkg.peerDependencies).toEqual({'@astryxdesign/cli':
|
|
358
|
+
expect(pkg.peerDependencies).toEqual({'@astryxdesign/cli': `>=${DOCS_TREE_CLI}`});
|
|
359
359
|
expect(pkg.peerDependenciesMeta).toEqual({'@astryxdesign/cli': {optional: true}});
|
|
360
360
|
|
|
361
361
|
const second = await integrationAdd('doc', 'upgrading', {
|
|
@@ -429,7 +429,7 @@ describe('integrationAdd doc', () => {
|
|
|
429
429
|
write('^0.6.0');
|
|
430
430
|
await integrationAdd('doc', 'deploying', {cwd: tmpDir, parent: 'acme'});
|
|
431
431
|
expect(JSON.parse(fs.readFileSync(file, 'utf-8')).peerDependencies).toEqual({
|
|
432
|
-
'@astryxdesign/cli': `>=${
|
|
432
|
+
'@astryxdesign/cli': `>=${DOCS_TREE_CLI}`,
|
|
433
433
|
});
|
|
434
434
|
write('^9.1.0');
|
|
435
435
|
await integrationAdd('doc', 'upgrading', {cwd: tmpDir, parent: 'acme'});
|