@astryxdesign/cli 0.7.8-canary.ffd29c5 → 0.7.9-canary.0200dfe
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 +62 -0
- package/README.md +1 -1
- package/api/component/__fixtures__/resolutions/modules.txt +2 -2
- package/api/discover/_adapter.d.mts +1 -1
- package/api/docs/_adapter.d.mts +8 -2
- package/api/docs/_adapter.mjs +10 -4
- package/api/docs/detail/section/section.d.mts +5 -2
- package/api/docs/detail/section/section.mjs +6 -2
- package/api/docs/docs.mjs +7 -1
- package/api/doctor/_adapter.d.mts +6 -2
- package/api/doctor/_adapter.mjs +5 -3
- package/api/doctor/built-checks.d.mts +9 -4
- package/api/doctor/built-checks.mjs +15 -10
- package/api/search/_adapter.d.mts +3 -1
- package/api/search/_adapter.mjs +12 -2
- package/api/search/_candidate-score.d.mts +4 -1
- package/api/search/_candidate-score.mjs +46 -28
- package/api/search/_gather-components.mjs +5 -0
- package/api/search/_gather-templates.mjs +31 -6
- package/api/search/_lexical.d.mts +14 -0
- package/api/search/_lexical.mjs +4 -0
- package/api/search/_main-searcher.mjs +1 -1
- package/api/search/_result.d.mts +6 -5
- package/api/search/_result.mjs +1 -0
- package/api/search/_words.d.mts +44 -7
- package/api/search/_words.mjs +113 -21
- package/api/search/search.d.mts +4 -2
- package/api/search/search.doc.mjs +1 -1
- package/api/search/search.mjs +9 -8
- package/api/search/search.type.d.mts +4 -0
- package/api/search/search.type.mjs +1 -0
- package/api/swizzle/_adapter.d.mts +10 -0
- package/api/swizzle/_adapter.mjs +24 -1
- package/api/swizzle/copy/copy.mjs +9 -4
- package/api/theme/build/build.d.mts +26 -1
- package/api/theme/build/build.mjs +71 -20
- package/api/theme/build/core-interception.d.mts +2 -1
- package/api/theme/build/core-interception.mjs +23 -5
- package/assets/codemods/registry.mjs +1 -0
- package/assets/codemods/transforms/next/index.mjs +1 -11
- package/assets/codemods/transforms/v0.7.8/index.mjs +20 -0
- package/assets/discover/official-packages.json +4 -0
- package/assets/docs/browser-support.doc.mjs +27 -1
- package/assets/docs/tree/calendar-systems.doc.mjs +146 -0
- package/assets/docs/tree/calendars.doc.mjs +46 -0
- package/assets/docs/tree/i18n-calendars.doc.mjs +51 -0
- package/assets/docs/tree/internationalization.doc.mjs +3 -3
- package/assets/docs/tree/tokens-color.doc.mjs +1 -1
- package/assets/templates/blocks/components/Hooks/useClickableContainerHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Hooks/useClickableContainerHookUsage.tsx +67 -0
- package/assets/templates/blocks/components/Hooks/useClipboardHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Hooks/useClipboardHookUsage.tsx +35 -0
- package/assets/templates/blocks/components/Hooks/useImageModeHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Hooks/useImageModeHookUsage.tsx +55 -0
- package/assets/templates/blocks/components/Hooks/useTreeFocusHookUsage.doc.mjs +15 -0
- package/assets/templates/blocks/components/Hooks/useTreeFocusHookUsage.tsx +98 -0
- package/assets/templates/blocks/components/Icon/useIconHookUsage.doc.mjs +19 -0
- package/assets/templates/blocks/components/Icon/useIconHookUsage.tsx +68 -0
- package/assets/templates/blocks/components/InfoTip/InfoTipMetricDefinitions.doc.mjs +14 -0
- package/assets/templates/blocks/components/InfoTip/InfoTipMetricDefinitions.tsx +46 -0
- package/assets/templates/blocks/components/InfoTip/InfoTipPermissionNotes.doc.mjs +14 -0
- package/assets/templates/blocks/components/InfoTip/InfoTipPermissionNotes.tsx +41 -0
- package/assets/templates/blocks/components/InfoTip/InfoTipShowcase.doc.mjs +13 -0
- package/assets/templates/blocks/components/InfoTip/InfoTipShowcase.tsx +24 -0
- package/assets/templates/blocks/components/PowerSearch/PowerSearchContentSearch.tsx +8 -7
- package/assets/templates/blocks/components/PowerSearch/PowerSearchFullFeatured.tsx +8 -7
- package/assets/templates/blocks/components/PowerSearch/PowerSearchPresetFilters.tsx +8 -7
- package/assets/templates/blocks/components/PowerSearch/PowerSearchSearchWithTable.tsx +12 -10
- package/assets/templates/blocks/components/PowerSearch/PowerSearchShowcase.tsx +8 -7
- package/assets/templates/blocks/components/Tokenizer/TokenizerClear.doc.mjs +2 -1
- package/assets/templates/blocks/components/Tokenizer/TokenizerClear.tsx +2 -2
- package/assets/templates/blocks/components/Tokenizer/TokenizerCreatable.tsx +0 -1
- package/assets/templates/blocks/components/Tokenizer/TokenizerEndContent.tsx +0 -1
- package/assets/templates/blocks/components/Tokenizer/TokenizerOverflow.doc.mjs +2 -1
- package/assets/templates/blocks/components/Tokenizer/TokenizerOverflow.tsx +0 -2
- package/assets/templates/pages/table-inbox/page.tsx +11 -8
- package/assets/templates/pages/work-item-detail/page.tsx +6 -2
- package/assets/theme.template.ts +1 -1
- package/authoring/debug/parse.d.mts +2 -2
- package/authoring/doctypes/_schema.d.mts +16 -0
- package/authoring/doctypes/_schema.mjs +15 -0
- package/authoring/doctypes/component/component.doc.mjs +6 -0
- package/authoring/doctypes/component/type.ts +16 -0
- package/authoring/index.d.ts +1 -0
- package/clients/cli/commands/build.mjs +9 -3
- package/clients/cli/commands/ensure-core-built.mjs +399 -43
- package/clients/cli/commands/search.mjs +8 -2
- package/clients/cli/formatters/index.mjs +11 -0
- package/clients/cli/index.mjs +11 -6
- package/foundation/agent-docs/agent-docs-target.d.mts +49 -0
- package/foundation/agent-docs/agent-docs-target.mjs +201 -0
- package/foundation/agent-docs/agent-docs.d.mts +1 -38
- package/foundation/agent-docs/agent-docs.mjs +16 -181
- package/foundation/config/config-path.d.mts +13 -0
- package/foundation/config/config-path.mjs +42 -0
- package/foundation/config/project.d.mts +1 -10
- package/foundation/config/project.mjs +31 -35
- package/foundation/discovery/component-discovery.mjs +56 -10
- package/foundation/discovery/component-loader.d.mts +1 -1
- package/foundation/discovery/icon-set-paths.d.mts +18 -0
- package/foundation/discovery/icon-set-paths.mjs +23 -0
- package/foundation/discovery/icon-set-writer.d.mts +2 -7
- package/foundation/discovery/icon-set-writer.mjs +3 -12
- package/foundation/discovery/template-adapter.d.mts +10 -0
- package/foundation/discovery/template-adapter.mjs +94 -4
- package/foundation/env/search-path.d.mts +12 -0
- package/foundation/env/search-path.mjs +71 -43
- package/foundation/fs/module-loader.d.mts +2 -8
- package/foundation/fs/module-loader.mjs +3 -12
- package/foundation/fs/present-files.d.mts +11 -0
- package/foundation/fs/present-files.mjs +25 -0
- package/foundation/integrations/autolink.d.mts +2 -21
- package/foundation/integrations/autolink.mjs +6 -42
- package/foundation/integrations/contribution-fixes.mjs +26 -3
- package/foundation/integrations/contribution-inventory.mjs +1 -1
- package/foundation/integrations/installed-package.d.mts +36 -0
- package/foundation/integrations/installed-package.mjs +57 -0
- package/foundation/integrations/integrations.d.mts +3 -75
- package/foundation/integrations/integrations.mjs +3 -16
- package/foundation/integrations/manifest-paths.d.mts +13 -0
- package/foundation/integrations/manifest-paths.mjs +31 -0
- package/foundation/integrations/manifest-writer.d.mts +3 -4
- package/foundation/integrations/manifest-writer.mjs +5 -3
- package/foundation/release/cache.d.mts +11 -4
- package/foundation/release/cache.mjs +15 -7
- package/foundation/response/response-types.doc.mjs +1 -1
- package/foundation/runtime/locked-versions.mjs +1 -1
- package/foundation/runtime/package-set.mjs +1 -1
- package/foundation/text/levenshtein.d.mts +4 -1
- package/foundation/text/levenshtein.mjs +44 -1
- package/package.json +9 -9
- package/api/swizzle/_github.d.mts +0 -8
- package/api/swizzle/_github.mjs +0 -22
- /package/assets/codemods/transforms/{next → v0.7.8}/promote-tokenizer-presentation.mjs +0 -0
|
@@ -21,6 +21,15 @@ import type {
|
|
|
21
21
|
UsageDoc,
|
|
22
22
|
} from '../base/type.js';
|
|
23
23
|
|
|
24
|
+
/** What replaces a deprecated component (`ComponentBaseDoc.deprecated`). */
|
|
25
|
+
export interface ComponentDeprecation {
|
|
26
|
+
/** `name` of the documented component to use instead, e.g. `'BottomSheet'`. */
|
|
27
|
+
replacement: string;
|
|
28
|
+
/** The modernization route in a sentence or two: what to write instead,
|
|
29
|
+
* and where the migration is described. */
|
|
30
|
+
description: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
24
33
|
/**
|
|
25
34
|
* Shared fields between single-component and multi-component docs.
|
|
26
35
|
* Do not use this interface directly — use `ComponentDoc` (the union type).
|
|
@@ -63,6 +72,13 @@ export interface ComponentBaseDoc extends AuthoredDocGraphFields {
|
|
|
63
72
|
* range, and on older CLIs that do not read `replaces`, the component keeps
|
|
64
73
|
* its own name. */
|
|
65
74
|
replaces?: string;
|
|
75
|
+
/** Marks a deprecated component (spec:AST-017 FR26, FR29b): it keeps
|
|
76
|
+
* working and stays documented, labeled with its replacement. The docsite
|
|
77
|
+
* shows a Deprecated badge in its page header and index tile, labels its
|
|
78
|
+
* search result, and adds a notice that links the replacement; `astryx
|
|
79
|
+
* search` results and `astryx build` kit entries carry the field. Omit for
|
|
80
|
+
* a component that is not deprecated. */
|
|
81
|
+
deprecated?: ComponentDeprecation;
|
|
66
82
|
/** Search keywords for CLI discovery. Terms a developer might type when
|
|
67
83
|
* looking for this component: synonyms, related UI concepts, and common
|
|
68
84
|
* names from other design systems (MUI, Chakra, Radix, and others).
|
package/authoring/index.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ import {jsonOut} from '../../../foundation/response/json.mjs';
|
|
|
21
21
|
import {resultSet, resultSetOf} from '../../../foundation/debug/index.mjs';
|
|
22
22
|
import {
|
|
23
23
|
emit,
|
|
24
|
+
formatDeprecation,
|
|
24
25
|
section,
|
|
25
26
|
text,
|
|
26
27
|
list,
|
|
@@ -172,18 +173,23 @@ export function registerBuild(program) {
|
|
|
172
173
|
'package',
|
|
173
174
|
'domain',
|
|
174
175
|
'displayName',
|
|
176
|
+
'deprecated',
|
|
175
177
|
'score',
|
|
176
178
|
'reason',
|
|
177
179
|
'import',
|
|
178
180
|
'description',
|
|
179
181
|
'command',
|
|
180
182
|
],
|
|
181
|
-
format: {command: formatCliCommand},
|
|
183
|
+
format: {command: formatCliCommand, deprecated: formatDeprecation},
|
|
182
184
|
};
|
|
183
185
|
/** @param {string[]} fields */
|
|
184
186
|
const brief = fields => ({
|
|
185
187
|
fields,
|
|
186
|
-
format: {
|
|
188
|
+
format: {
|
|
189
|
+
command: formatCliCommand,
|
|
190
|
+
description: firstSentence,
|
|
191
|
+
deprecated: formatDeprecation,
|
|
192
|
+
},
|
|
187
193
|
});
|
|
188
194
|
// Blocks and components are extras: the text names the top few, and
|
|
189
195
|
// says how many more the JSON and --verbose carry.
|
|
@@ -277,7 +283,7 @@ export function registerBuild(program) {
|
|
|
277
283
|
? [
|
|
278
284
|
records(
|
|
279
285
|
shown(domain),
|
|
280
|
-
verbose ? full : brief(['name', 'package', 'description']),
|
|
286
|
+
verbose ? full : brief(['name', 'package', 'deprecated', 'description']),
|
|
281
287
|
),
|
|
282
288
|
]
|
|
283
289
|
: []),
|
|
@@ -1,23 +1,18 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @file Shared test helper:
|
|
4
|
+
* @file Shared test helper: builds @astryxdesign/core once per run, race-free.
|
|
5
|
+
* @input Core's sources, translations and build scripts; this checkout's lock
|
|
6
|
+
* and run leases in the system temp directory.
|
|
7
|
+
* @output A packages/core/dist whose last output is newer than every source.
|
|
8
|
+
* @position Called by the node global setup and the build-theme suites.
|
|
5
9
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* built core. The CI `test` job runs `pnpm test` without a prior core build,
|
|
9
|
-
* and Vitest runs test files in parallel worker forks. When two build-theme
|
|
10
|
-
* suites each ran `if (!exists) pnpm -F @astryxdesign/core build` in their own
|
|
11
|
-
* beforeAll, both workers saw dist missing and launched concurrent builds that
|
|
12
|
-
* collided on the shared packages/core/dist: one worker cleaned dist while the
|
|
13
|
-
* other was mid-write, failing nondeterministically ("Could not resolve
|
|
14
|
-
* dist/index.js" / "ENOTEMPTY rmdir dist/hooks").
|
|
15
|
-
*
|
|
16
|
-
* This serializes the build behind a filesystem lock so exactly one worker
|
|
17
|
-
* builds and the rest wait for it to finish before reading dist.
|
|
10
|
+
* A Core build deletes dist first. Only the global setup rebuilds a stale
|
|
11
|
+
* build, before the workers start, and only after earlier runs end.
|
|
18
12
|
*/
|
|
19
13
|
|
|
20
14
|
import {execFileSync} from 'node:child_process';
|
|
15
|
+
import {createHash} from 'node:crypto';
|
|
21
16
|
import * as fs from 'node:fs';
|
|
22
17
|
import * as os from 'node:os';
|
|
23
18
|
import * as path from 'node:path';
|
|
@@ -27,12 +22,153 @@ const REPO_ROOT = path.resolve(
|
|
|
27
22
|
path.dirname(fileURLToPath(import.meta.url)),
|
|
28
23
|
'../../../../..',
|
|
29
24
|
);
|
|
30
|
-
|
|
25
|
+
// The build's last output. `build:css` writes it after the compiled modules,
|
|
26
|
+
// their declarations and the declaration extensions. So a build that was
|
|
27
|
+
// interrupted or failed before it finished has no marker, and reads as missing.
|
|
28
|
+
// (`dist/theme/index.js`, which the build-theme suites import, comes about
|
|
29
|
+
// 11 s into a 38 s build.)
|
|
30
|
+
export const CORE_BUILD_MARKER = path.join(
|
|
31
31
|
REPO_ROOT,
|
|
32
|
-
'packages/core/dist/
|
|
32
|
+
'packages/core/dist/astryx.css',
|
|
33
33
|
);
|
|
34
|
-
//
|
|
35
|
-
|
|
34
|
+
// What the build compiles, and the scripts and config it compiles with: a file
|
|
35
|
+
// here newer than the marker means dist is stale. A checkout rewrites the files
|
|
36
|
+
// it changes, so they read as newer. The translations live outside src, in
|
|
37
|
+
// locales. The scripts are the ones Core's `build*` scripts run that write
|
|
38
|
+
// output (not its checks).
|
|
39
|
+
export const CORE_SOURCES = [
|
|
40
|
+
path.join(REPO_ROOT, 'packages/core/src'),
|
|
41
|
+
path.join(REPO_ROOT, 'packages/core/locales'),
|
|
42
|
+
path.join(REPO_ROOT, 'packages/core/package.json'),
|
|
43
|
+
path.join(REPO_ROOT, 'packages/core/babel.config.json'),
|
|
44
|
+
path.join(REPO_ROOT, 'packages/core/babel-plugin-add-extensions.cjs'),
|
|
45
|
+
path.join(REPO_ROOT, 'packages/core/tsconfig.build.json'),
|
|
46
|
+
path.join(REPO_ROOT, 'tsconfig.json'),
|
|
47
|
+
path.join(REPO_ROOT, 'packages/core/scripts/build-pseudo-locale.mjs'),
|
|
48
|
+
path.join(REPO_ROOT, 'scripts/generate-i18n-runtime.mjs'),
|
|
49
|
+
path.join(REPO_ROOT, 'scripts/i18n-english-fallback.mjs'),
|
|
50
|
+
path.join(REPO_ROOT, 'scripts/add-declaration-extensions.mjs'),
|
|
51
|
+
path.join(REPO_ROOT, 'scripts/build-css.mjs'),
|
|
52
|
+
path.join(REPO_ROOT, 'scripts/lib/stylex-generated-variable.mjs'),
|
|
53
|
+
path.join(REPO_ROOT, 'scripts/stylex-module-resolution.cjs'),
|
|
54
|
+
];
|
|
55
|
+
// Git-ignored output generated from those sources, by the build and again by
|
|
56
|
+
// the Vitest global setup (internal/test-utils/src/globalSetup.ts). Rewritten
|
|
57
|
+
// after a build, it would read as newer than that build.
|
|
58
|
+
export const CORE_GENERATED = [
|
|
59
|
+
path.join(REPO_ROOT, 'packages/core/src/i18n/generated-english'),
|
|
60
|
+
path.join(REPO_ROOT, 'packages/core/src/i18n/generated-locales'),
|
|
61
|
+
path.join(REPO_ROOT, 'packages/core/locales/pseudo.json'),
|
|
62
|
+
];
|
|
63
|
+
/**
|
|
64
|
+
* The lock directory (mkdir is atomic across processes) that guards the Core
|
|
65
|
+
* build of the checkout at `repoRoot`: one per checkout.
|
|
66
|
+
* @param {string} repoRoot
|
|
67
|
+
* @returns {string}
|
|
68
|
+
*/
|
|
69
|
+
export function coreBuildLockDir(repoRoot) {
|
|
70
|
+
const key = createHash('sha256')
|
|
71
|
+
.update(path.resolve(repoRoot))
|
|
72
|
+
.digest('hex')
|
|
73
|
+
.slice(0, 16);
|
|
74
|
+
return path.join(os.tmpdir(), `astryx-core-build-${key}.lock`);
|
|
75
|
+
}
|
|
76
|
+
const LOCK_DIR = coreBuildLockDir(REPO_ROOT);
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The directory where each node test run of the checkout at `repoRoot` holds
|
|
80
|
+
* a lease for as long as it runs. Each run has one file, named by its process
|
|
81
|
+
* id and holding the time it started.
|
|
82
|
+
* @param {string} repoRoot
|
|
83
|
+
*/
|
|
84
|
+
export function coreRunLeaseDir(repoRoot) {
|
|
85
|
+
return coreBuildLockDir(repoRoot).replace(/\.lock$/, '.runs');
|
|
86
|
+
}
|
|
87
|
+
const RUN_LEASE_DIR = coreRunLeaseDir(REPO_ROOT);
|
|
88
|
+
|
|
89
|
+
/** @param {number} pid */
|
|
90
|
+
function processIsAlive(pid) {
|
|
91
|
+
try {
|
|
92
|
+
process.kill(pid, 0);
|
|
93
|
+
return true;
|
|
94
|
+
} catch (error) {
|
|
95
|
+
const {code} = /** @type {NodeJS.ErrnoException} */ (error);
|
|
96
|
+
// ESRCH: no such process, so it has ended. EPERM: it runs as another user.
|
|
97
|
+
if (code === 'ESRCH') return false;
|
|
98
|
+
if (code === 'EPERM') return true;
|
|
99
|
+
throw error;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Registers this process as a running test run of the checkout, and returns
|
|
105
|
+
* the function that ends its lease (the global setup's teardown).
|
|
106
|
+
* @param {{leaseDir?: string, pid?: number, now?: number}} [options]
|
|
107
|
+
*/
|
|
108
|
+
export function registerTestRun({
|
|
109
|
+
leaseDir = RUN_LEASE_DIR,
|
|
110
|
+
pid = process.pid,
|
|
111
|
+
now = Date.now(),
|
|
112
|
+
} = {}) {
|
|
113
|
+
fs.mkdirSync(leaseDir, {recursive: true});
|
|
114
|
+
const file = path.join(leaseDir, String(pid));
|
|
115
|
+
fs.writeFileSync(file, String(now));
|
|
116
|
+
return () => fs.rmSync(file, {force: true});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* The runs in `leaseDir` that started before this one (by start time, then
|
|
121
|
+
* process id) and are still alive. Those may be reading the build now. A run
|
|
122
|
+
* that started later waits for this one instead, so two runs never wait for
|
|
123
|
+
* each other. A lease whose process is gone is removed.
|
|
124
|
+
* @param {string} leaseDir
|
|
125
|
+
* @param {{pid?: number, isAlive?: (pid: number) => boolean}} [options]
|
|
126
|
+
*/
|
|
127
|
+
export function earlierLiveRuns(
|
|
128
|
+
leaseDir,
|
|
129
|
+
{pid = process.pid, isAlive = processIsAlive} = {},
|
|
130
|
+
) {
|
|
131
|
+
/** @type {string[]} */
|
|
132
|
+
let names;
|
|
133
|
+
try {
|
|
134
|
+
names = fs.readdirSync(leaseDir);
|
|
135
|
+
} catch (error) {
|
|
136
|
+
// No run has registered in this checkout yet.
|
|
137
|
+
if (/** @type {NodeJS.ErrnoException} */ (error).code === 'ENOENT') {
|
|
138
|
+
return [];
|
|
139
|
+
}
|
|
140
|
+
throw error;
|
|
141
|
+
}
|
|
142
|
+
/** @param {string} name */
|
|
143
|
+
const startOf = name => {
|
|
144
|
+
try {
|
|
145
|
+
return Number(fs.readFileSync(path.join(leaseDir, name), 'utf8'));
|
|
146
|
+
} catch (error) {
|
|
147
|
+
// The run ended, and its lease went, between the listing and this read.
|
|
148
|
+
if (/** @type {NodeJS.ErrnoException} */ (error).code === 'ENOENT') {
|
|
149
|
+
return NaN;
|
|
150
|
+
}
|
|
151
|
+
throw error;
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
const own = startOf(String(pid));
|
|
155
|
+
const ownStart = Number.isFinite(own) ? own : Infinity;
|
|
156
|
+
/** @type {number[]} */
|
|
157
|
+
const earlier = [];
|
|
158
|
+
for (const name of names) {
|
|
159
|
+
const other = Number(name);
|
|
160
|
+
if (!Number.isInteger(other) || other === pid) continue;
|
|
161
|
+
if (!isAlive(other)) {
|
|
162
|
+
fs.rmSync(path.join(leaseDir, name), {force: true});
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
const start = startOf(name);
|
|
166
|
+
if (start < ownStart || (start === ownStart && other < pid)) {
|
|
167
|
+
earlier.push(other);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return earlier;
|
|
171
|
+
}
|
|
36
172
|
|
|
37
173
|
const BUILD_TIMEOUT_MS = 180_000;
|
|
38
174
|
// A lock older than this is assumed abandoned by a crashed/killed worker.
|
|
@@ -44,6 +180,56 @@ function sleepSync(ms) {
|
|
|
44
180
|
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
|
45
181
|
}
|
|
46
182
|
|
|
183
|
+
/**
|
|
184
|
+
* Whether `entry` is missing or older than any file under `roots` (files or
|
|
185
|
+
* directories; `node_modules`, `dist` and the paths in `generated` are
|
|
186
|
+
* skipped).
|
|
187
|
+
* @param {string} entry
|
|
188
|
+
* @param {readonly string[]} roots
|
|
189
|
+
* @param {readonly string[]} [generated]
|
|
190
|
+
* @returns {boolean}
|
|
191
|
+
*/
|
|
192
|
+
export function coreBuildIsStale(entry, roots, generated = []) {
|
|
193
|
+
let built;
|
|
194
|
+
try {
|
|
195
|
+
built = fs.statSync(entry).mtimeMs;
|
|
196
|
+
} catch (error) {
|
|
197
|
+
// Not built yet.
|
|
198
|
+
if (/** @type {NodeJS.ErrnoException} */ (error).code === 'ENOENT') {
|
|
199
|
+
return true;
|
|
200
|
+
}
|
|
201
|
+
throw error;
|
|
202
|
+
}
|
|
203
|
+
const skipped = new Set(generated.map(p => path.resolve(p)));
|
|
204
|
+
const pending = [...roots];
|
|
205
|
+
while (pending.length > 0) {
|
|
206
|
+
const current = /** @type {string} */ (pending.pop());
|
|
207
|
+
if (skipped.has(path.resolve(current))) {
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
let stat;
|
|
211
|
+
try {
|
|
212
|
+
stat = fs.statSync(current);
|
|
213
|
+
} catch (error) {
|
|
214
|
+
// Removed while the walk ran.
|
|
215
|
+
if (/** @type {NodeJS.ErrnoException} */ (error).code === 'ENOENT') {
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
throw error;
|
|
219
|
+
}
|
|
220
|
+
if (stat.isDirectory()) {
|
|
221
|
+
for (const name of fs.readdirSync(current)) {
|
|
222
|
+
if (name !== 'node_modules' && name !== 'dist') {
|
|
223
|
+
pending.push(path.join(current, name));
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
} else if (stat.mtimeMs > built) {
|
|
227
|
+
return true;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return false;
|
|
231
|
+
}
|
|
232
|
+
|
|
47
233
|
function buildCore() {
|
|
48
234
|
execFileSync('pnpm', ['-F', '@astryxdesign/core', 'build'], {
|
|
49
235
|
cwd: REPO_ROOT,
|
|
@@ -52,28 +238,46 @@ function buildCore() {
|
|
|
52
238
|
});
|
|
53
239
|
}
|
|
54
240
|
|
|
55
|
-
|
|
241
|
+
/**
|
|
242
|
+
* @param {string} lockDir
|
|
243
|
+
* @param {number} staleLockMs
|
|
244
|
+
*/
|
|
245
|
+
function lockIsStale(lockDir, staleLockMs) {
|
|
56
246
|
try {
|
|
57
|
-
return Date.now() - fs.statSync(
|
|
247
|
+
return Date.now() - fs.statSync(lockDir).mtimeMs > staleLockMs;
|
|
58
248
|
} catch {
|
|
59
249
|
// Vanished between the exists check and stat — treat as released.
|
|
60
250
|
return false;
|
|
61
251
|
}
|
|
62
252
|
}
|
|
63
253
|
|
|
64
|
-
/**
|
|
65
|
-
|
|
254
|
+
/**
|
|
255
|
+
* Whether another worker holds the lock: it is building, and dist is not
|
|
256
|
+
* whole yet.
|
|
257
|
+
* @param {string} lockDir
|
|
258
|
+
* @param {number} staleLockMs
|
|
259
|
+
*/
|
|
260
|
+
function lockIsHeld(lockDir, staleLockMs) {
|
|
261
|
+
return fs.existsSync(lockDir) && !lockIsStale(lockDir, staleLockMs);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Try to acquire the lock. Returns true if this worker now holds it.
|
|
266
|
+
* @param {string} lockDir
|
|
267
|
+
* @param {number} staleLockMs
|
|
268
|
+
*/
|
|
269
|
+
function tryAcquire(lockDir, staleLockMs) {
|
|
66
270
|
try {
|
|
67
|
-
fs.mkdirSync(
|
|
271
|
+
fs.mkdirSync(lockDir);
|
|
68
272
|
return true;
|
|
69
273
|
} catch (err) {
|
|
70
274
|
if (/** @type {NodeJS.ErrnoException} */ (err).code !== 'EEXIST') {
|
|
71
275
|
throw err;
|
|
72
276
|
}
|
|
73
|
-
if (lockIsStale()) {
|
|
74
|
-
fs.rmSync(
|
|
277
|
+
if (lockIsStale(lockDir, staleLockMs)) {
|
|
278
|
+
fs.rmSync(lockDir, {recursive: true, force: true});
|
|
75
279
|
try {
|
|
76
|
-
fs.mkdirSync(
|
|
280
|
+
fs.mkdirSync(lockDir);
|
|
77
281
|
return true;
|
|
78
282
|
} catch (retryErr) {
|
|
79
283
|
if (/** @type {NodeJS.ErrnoException} */ (retryErr).code !== 'EEXIST') {
|
|
@@ -86,35 +290,187 @@ function tryAcquire() {
|
|
|
86
290
|
}
|
|
87
291
|
|
|
88
292
|
/**
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
* build
|
|
293
|
+
* Run `build` unless `isBuilt()`, in exactly one process at a time: the one
|
|
294
|
+
* holding `lockDir`. Every other caller returns only once no process holds
|
|
295
|
+
* the lock and the build is current, so none reads a build still being
|
|
296
|
+
* written.
|
|
297
|
+
* @param {{isBuilt: () => boolean, build: () => void, lockDir: string, staleLockMs?: number, pollMs?: number}} options
|
|
92
298
|
*/
|
|
93
|
-
export function
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
299
|
+
export function ensureBuiltOnce({
|
|
300
|
+
isBuilt,
|
|
301
|
+
build,
|
|
302
|
+
lockDir,
|
|
303
|
+
staleLockMs = STALE_LOCK_MS,
|
|
304
|
+
pollMs = POLL_MS,
|
|
305
|
+
}) {
|
|
306
|
+
const deadline = Date.now() + staleLockMs;
|
|
99
307
|
while (Date.now() < deadline) {
|
|
100
|
-
if (
|
|
308
|
+
if (!lockIsHeld(lockDir, staleLockMs) && isBuilt()) {
|
|
101
309
|
return;
|
|
102
310
|
}
|
|
103
|
-
if (tryAcquire()) {
|
|
311
|
+
if (tryAcquire(lockDir, staleLockMs)) {
|
|
104
312
|
try {
|
|
105
|
-
if (!
|
|
106
|
-
|
|
313
|
+
if (!isBuilt()) {
|
|
314
|
+
build();
|
|
107
315
|
}
|
|
108
316
|
} finally {
|
|
109
|
-
fs.rmSync(
|
|
317
|
+
fs.rmSync(lockDir, {recursive: true, force: true});
|
|
110
318
|
}
|
|
111
319
|
return;
|
|
112
320
|
}
|
|
113
|
-
// Another worker is building; wait for it to
|
|
114
|
-
sleepSync(
|
|
321
|
+
// Another worker is building; wait for it to release the lock.
|
|
322
|
+
sleepSync(pollMs);
|
|
115
323
|
}
|
|
116
324
|
|
|
117
|
-
// Waited past the stale threshold without the
|
|
325
|
+
// Waited past the stale threshold without the lock coming free — build it
|
|
118
326
|
// ourselves rather than let the suite fail on a missing entry.
|
|
119
|
-
|
|
327
|
+
build();
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Build Core when `entry` is missing, or also when it is older than
|
|
332
|
+
* `roots` with `rebuildStale`, in one process at a time.
|
|
333
|
+
* @param {{entry: string, roots: readonly string[], generated?: readonly string[], build: () => void, lockDir: string, rebuildStale?: boolean, staleLockMs?: number, pollMs?: number}} options
|
|
334
|
+
*/
|
|
335
|
+
export function ensureCoreBuiltAt({
|
|
336
|
+
entry,
|
|
337
|
+
roots,
|
|
338
|
+
generated = [],
|
|
339
|
+
build,
|
|
340
|
+
lockDir,
|
|
341
|
+
rebuildStale = false,
|
|
342
|
+
staleLockMs,
|
|
343
|
+
pollMs = POLL_MS,
|
|
344
|
+
}) {
|
|
345
|
+
ensureBuiltOnce({
|
|
346
|
+
isBuilt: rebuildStale
|
|
347
|
+
? () => !coreBuildIsStale(entry, roots, generated)
|
|
348
|
+
: () => fs.existsSync(entry),
|
|
349
|
+
build,
|
|
350
|
+
lockDir,
|
|
351
|
+
staleLockMs,
|
|
352
|
+
pollMs,
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Ensure packages/core/dist is built exactly once, even when called
|
|
358
|
+
* concurrently from parallel Vitest workers. A build-theme suite's beforeAll
|
|
359
|
+
* calls it with no options, and it builds only a missing Core. The node global
|
|
360
|
+
* setup rebuilds a build older than Core's sources (`ensureCoreBuiltForRun`).
|
|
361
|
+
* It does so before any worker forks, once every run that started before it
|
|
362
|
+
* has ended, so never under a running suite.
|
|
363
|
+
* @param {{rebuildStale?: boolean}} [options]
|
|
364
|
+
*/
|
|
365
|
+
export function ensureCoreBuilt({rebuildStale = false} = {}) {
|
|
366
|
+
ensureCoreBuiltAt({
|
|
367
|
+
entry: CORE_BUILD_MARKER,
|
|
368
|
+
roots: CORE_SOURCES,
|
|
369
|
+
generated: CORE_GENERATED,
|
|
370
|
+
build: buildCore,
|
|
371
|
+
lockDir: LOCK_DIR,
|
|
372
|
+
rebuildStale,
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/** How long a run waits for the runs that started before it, ms. */
|
|
377
|
+
export const EARLIER_RUN_WAIT_MS = 120_000;
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Waits while the build is stale and a run that started before this one is
|
|
381
|
+
* still live (`leaseDir`). It waits on a timer, so the event loop stays free
|
|
382
|
+
* and Ctrl-C still stops the run. Gives up after `limitMs`. Resolves to the runs still
|
|
383
|
+
* live when it gave up, or to none.
|
|
384
|
+
* @param {{entry: string, roots: readonly string[], generated?: readonly string[], leaseDir: string, isAlive?: (pid: number) => boolean, pid?: number, pollMs?: number, limitMs?: number}} options
|
|
385
|
+
* @returns {Promise<number[]>}
|
|
386
|
+
*/
|
|
387
|
+
export async function waitForEarlierRuns({
|
|
388
|
+
entry,
|
|
389
|
+
roots,
|
|
390
|
+
generated = [],
|
|
391
|
+
leaseDir,
|
|
392
|
+
isAlive,
|
|
393
|
+
pid,
|
|
394
|
+
pollMs = POLL_MS,
|
|
395
|
+
limitMs = EARLIER_RUN_WAIT_MS,
|
|
396
|
+
}) {
|
|
397
|
+
const deadline = Date.now() + limitMs;
|
|
398
|
+
let announced = false;
|
|
399
|
+
for (;;) {
|
|
400
|
+
if (!fs.existsSync(entry) || !coreBuildIsStale(entry, roots, generated)) {
|
|
401
|
+
return [];
|
|
402
|
+
}
|
|
403
|
+
const earlier = earlierLiveRuns(leaseDir, {pid, isAlive});
|
|
404
|
+
if (earlier.length === 0 || Date.now() >= deadline) {
|
|
405
|
+
return earlier;
|
|
406
|
+
}
|
|
407
|
+
if (!announced) {
|
|
408
|
+
console.warn(
|
|
409
|
+
`[ensure-core-built] Core changed; waiting up to ${Math.round(limitMs / 1000)} s for the test run already running in this checkout (pid ${earlier.join(', ')}) to end before rebuilding it.`,
|
|
410
|
+
);
|
|
411
|
+
announced = true;
|
|
412
|
+
}
|
|
413
|
+
await new Promise(resolve => setTimeout(resolve, pollMs));
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* The node global setup's Core step: once the runs that started earlier have
|
|
419
|
+
* ended, a stale build is rebuilt. If one is still live at the limit, this run
|
|
420
|
+
* stops with an error naming it. Rebuilding would delete dist under that run,
|
|
421
|
+
* and testing the stale build would test old code.
|
|
422
|
+
* @param {{entry: string, roots: readonly string[], generated?: readonly string[], build: () => void, lockDir: string, leaseDir: string, isAlive?: (pid: number) => boolean, pid?: number, pollMs?: number, limitMs?: number}} options
|
|
423
|
+
*/
|
|
424
|
+
export async function ensureCoreBuiltForRunAt({
|
|
425
|
+
entry,
|
|
426
|
+
roots,
|
|
427
|
+
generated = [],
|
|
428
|
+
build,
|
|
429
|
+
lockDir,
|
|
430
|
+
leaseDir,
|
|
431
|
+
isAlive,
|
|
432
|
+
pid,
|
|
433
|
+
pollMs,
|
|
434
|
+
limitMs,
|
|
435
|
+
}) {
|
|
436
|
+
const stillLive = await waitForEarlierRuns({
|
|
437
|
+
entry,
|
|
438
|
+
roots,
|
|
439
|
+
generated,
|
|
440
|
+
leaseDir,
|
|
441
|
+
isAlive,
|
|
442
|
+
pid,
|
|
443
|
+
pollMs,
|
|
444
|
+
limitMs,
|
|
445
|
+
});
|
|
446
|
+
if (stillLive.length > 0) {
|
|
447
|
+
throw new Error(
|
|
448
|
+
`[ensure-core-built] Core's sources changed since packages/core/dist was built, and test run ${stillLive.join(', ')} in this checkout still uses that build after ${Math.round((limitMs ?? EARLIER_RUN_WAIT_MS) / 1000)} s: rebuilding would delete dist under it, and this run would test old code. Run again once it ends; if that process is not a test run, remove its lease: ${stillLive.map(pid => path.join(leaseDir, String(pid))).join(', ')}.`,
|
|
449
|
+
);
|
|
450
|
+
}
|
|
451
|
+
ensureCoreBuiltAt({
|
|
452
|
+
entry,
|
|
453
|
+
roots,
|
|
454
|
+
generated,
|
|
455
|
+
build,
|
|
456
|
+
lockDir,
|
|
457
|
+
rebuildStale: true,
|
|
458
|
+
pollMs,
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* `ensureCoreBuiltForRunAt` for this checkout: the node global setup's step.
|
|
464
|
+
* @param {{limitMs?: number}} [options]
|
|
465
|
+
*/
|
|
466
|
+
export function ensureCoreBuiltForRun({limitMs} = {}) {
|
|
467
|
+
return ensureCoreBuiltForRunAt({
|
|
468
|
+
entry: CORE_BUILD_MARKER,
|
|
469
|
+
roots: CORE_SOURCES,
|
|
470
|
+
generated: CORE_GENERATED,
|
|
471
|
+
build: buildCore,
|
|
472
|
+
lockDir: LOCK_DIR,
|
|
473
|
+
leaseDir: RUN_LEASE_DIR,
|
|
474
|
+
limitMs,
|
|
475
|
+
});
|
|
120
476
|
}
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
} from '../../../foundation/env/package-manager.mjs';
|
|
28
28
|
import {jsonOut} from '../../../foundation/response/json.mjs';
|
|
29
29
|
import {resultSetOf} from '../../../foundation/debug/index.mjs';
|
|
30
|
-
import {emit, section, text, records} from '../formatters/index.mjs';
|
|
30
|
+
import {emit, formatDeprecation, section, text, records} from '../formatters/index.mjs';
|
|
31
31
|
import {cliError} from '../lib/cli-error.mjs';
|
|
32
32
|
import {defineCommand} from '../lib/define-command.mjs';
|
|
33
33
|
import {search as searchApi} from '../../../api/search/search.mjs';
|
|
@@ -145,6 +145,7 @@ export function registerSearch(program) {
|
|
|
145
145
|
'title',
|
|
146
146
|
'displayName',
|
|
147
147
|
'kind',
|
|
148
|
+
'deprecated',
|
|
148
149
|
'score',
|
|
149
150
|
'reason',
|
|
150
151
|
'import',
|
|
@@ -160,6 +161,7 @@ export function registerSearch(program) {
|
|
|
160
161
|
'title',
|
|
161
162
|
'displayName',
|
|
162
163
|
'kind',
|
|
164
|
+
'deprecated',
|
|
163
165
|
'import',
|
|
164
166
|
'description',
|
|
165
167
|
'command',
|
|
@@ -177,7 +179,11 @@ export function registerSearch(program) {
|
|
|
177
179
|
),
|
|
178
180
|
records(results, {
|
|
179
181
|
fields,
|
|
180
|
-
format: {
|
|
182
|
+
format: {
|
|
183
|
+
command: formatCliCommand,
|
|
184
|
+
parent: formatCliCommand,
|
|
185
|
+
deprecated: formatDeprecation,
|
|
186
|
+
},
|
|
181
187
|
}),
|
|
182
188
|
...note,
|
|
183
189
|
...discoverHint(run, q, options.type),
|
|
@@ -371,6 +371,17 @@ function isBlock(b) {
|
|
|
371
371
|
return b instanceof Block;
|
|
372
372
|
}
|
|
373
373
|
|
|
374
|
+
/**
|
|
375
|
+
* The text value of a deprecated component's `deprecated` field: the component
|
|
376
|
+
* to use instead, then the modernization route. Every command that prints a
|
|
377
|
+
* component result's fields prints it this way.
|
|
378
|
+
* @param {{replacement: string, description: string}} deprecation
|
|
379
|
+
* @returns {string}
|
|
380
|
+
*/
|
|
381
|
+
export function formatDeprecation(deprecation) {
|
|
382
|
+
return `use ${deprecation.replacement}: ${deprecation.description}`;
|
|
383
|
+
}
|
|
384
|
+
|
|
374
385
|
/**
|
|
375
386
|
* The one sanctioned way to write human output to stdout. Joins blocks with a
|
|
376
387
|
* single blank line and hands the result to `humanLog`, which is a no-op in
|