@astryxdesign/cli 0.7.8 → 0.7.9-canary.07992bb
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/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/search/_adapter.d.mts +3 -1
- package/api/search/_adapter.mjs +12 -2
- package/api/search/_main-searcher.mjs +1 -1
- package/api/search/_result.d.mts +5 -5
- package/api/search/search.d.mts +4 -2
- package/api/search/search.mjs +9 -8
- package/api/theme/build/build.d.mts +26 -1
- package/api/theme/build/build.mjs +50 -19
- package/api/theme/build/core-interception.d.mts +2 -1
- package/api/theme/build/core-interception.mjs +23 -5
- 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/useImageModeHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Hooks/useImageModeHookUsage.tsx +55 -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/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 +4 -26
- package/foundation/discovery/component-discovery.mjs +39 -4
- 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/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/release/cache.d.mts +11 -4
- package/foundation/release/cache.mjs +15 -7
- package/foundation/runtime/locked-versions.mjs +1 -1
- package/foundation/runtime/package-set.mjs +1 -1
- package/package.json +9 -9
|
@@ -31,7 +31,6 @@
|
|
|
31
31
|
|
|
32
32
|
import {spawnSync} from 'node:child_process';
|
|
33
33
|
import * as fs from 'node:fs';
|
|
34
|
-
import * as os from 'node:os';
|
|
35
34
|
import * as path from 'node:path';
|
|
36
35
|
import {findCoreDir, findInstalledPackage, CLI_ROOT} from '../fs/paths.mjs';
|
|
37
36
|
import {assertWithin, PathSafetyError} from '../fs/path-safety.mjs';
|
|
@@ -67,6 +66,12 @@ import {
|
|
|
67
66
|
WORKFLOW_STEPS,
|
|
68
67
|
WORKFLOW_TITLE,
|
|
69
68
|
} from './agent-doc-state.mjs';
|
|
69
|
+
import {
|
|
70
|
+
agentDocsTargetDir,
|
|
71
|
+
assertAgentDocsTarget,
|
|
72
|
+
realDir,
|
|
73
|
+
REPOSITORY_MARKERS,
|
|
74
|
+
} from './agent-docs-target.mjs';
|
|
70
75
|
|
|
71
76
|
// The agent-doc locations, markers, and the setup-state predicates
|
|
72
77
|
// (discoverAgentDocs, isAstryxInitialized, isAstryxPromptInReach) are the ONE
|
|
@@ -77,6 +82,16 @@ import {
|
|
|
77
82
|
// keep their `from './agent-docs.mjs'` paths.
|
|
78
83
|
export {discoverAgentDocs, isAstryxInitialized, isAstryxPromptInReach};
|
|
79
84
|
|
|
85
|
+
// The folder the docs go to lives in ./agent-docs-target.mjs, with node
|
|
86
|
+
// builtins only. So the per-command setup nudge loads it without this
|
|
87
|
+
// module's discovery and config. Re-exported here for existing importers.
|
|
88
|
+
export {
|
|
89
|
+
AgentDocsHomeError,
|
|
90
|
+
agentDocsTargetDir,
|
|
91
|
+
assertAgentDocsTarget,
|
|
92
|
+
resolveAgentDocsRoot,
|
|
93
|
+
} from './agent-docs-target.mjs';
|
|
94
|
+
|
|
80
95
|
const MAX_PROJECT_AGENT_DOC_LINES = 32;
|
|
81
96
|
const MANAGED_MARKER_TEXT = /(?:ASTRYX|XDS):(START|END)/u;
|
|
82
97
|
|
|
@@ -321,186 +336,6 @@ function geminiImportsAgentsMd(targetDir) {
|
|
|
321
336
|
);
|
|
322
337
|
}
|
|
323
338
|
|
|
324
|
-
/**
|
|
325
|
-
* Thrown when agent docs would be written into the home folder, or into a
|
|
326
|
-
* settings folder in it such as `~/.gemini` outside a project. Agents read the
|
|
327
|
-
* files there (for example `~/.claude/CLAUDE.md` or `~/.gemini/GEMINI.md`) in
|
|
328
|
-
* every project, so a project's version-pinned block never goes there. Removal
|
|
329
|
-
* stays allowed.
|
|
330
|
-
*/
|
|
331
|
-
export class AgentDocsHomeError extends Error {
|
|
332
|
-
/** @param {string} dir */
|
|
333
|
-
constructor(dir) {
|
|
334
|
-
super(
|
|
335
|
-
`Agent docs are not written into the home folder, or into a settings folder in it outside a project (${dir}): agents read the files there in every project. Run init inside a project folder.`,
|
|
336
|
-
);
|
|
337
|
-
this.name = 'AgentDocsHomeError';
|
|
338
|
-
/** The refused folder. */
|
|
339
|
-
this.dir = dir;
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
* `p` resolved, through symlinks when it exists.
|
|
345
|
-
* @param {string} p
|
|
346
|
-
* @returns {string}
|
|
347
|
-
*/
|
|
348
|
-
function realDir(p) {
|
|
349
|
-
try {
|
|
350
|
-
return fs.realpathSync(path.resolve(p));
|
|
351
|
-
} catch {
|
|
352
|
-
return path.resolve(p);
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
/**
|
|
357
|
-
* `dir` relative to the home folder, compared without symlinks (and without
|
|
358
|
-
* case on Windows). null when there is no home folder.
|
|
359
|
-
* @param {string} dir
|
|
360
|
-
* @returns {string | null}
|
|
361
|
-
*/
|
|
362
|
-
function relativeToHome(dir) {
|
|
363
|
-
let home;
|
|
364
|
-
try {
|
|
365
|
-
home = os.homedir();
|
|
366
|
-
} catch {
|
|
367
|
-
return null;
|
|
368
|
-
}
|
|
369
|
-
if (!home) return null;
|
|
370
|
-
/** @param {string} p */
|
|
371
|
-
const fold = p => (process.platform === 'win32' ? p.toLowerCase() : p);
|
|
372
|
-
return path.relative(fold(realDir(home)), fold(realDir(dir)));
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
/**
|
|
376
|
-
* Whether `dir` is the home folder.
|
|
377
|
-
* @param {string} dir
|
|
378
|
-
* @returns {boolean}
|
|
379
|
-
*/
|
|
380
|
-
function isHomeFolder(dir) {
|
|
381
|
-
return relativeToHome(dir) === '';
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
/**
|
|
385
|
-
* Whether agent docs stay out of `dir`: the home folder, or a folder in a
|
|
386
|
-
* settings folder of it (a folder of the home folder whose name starts with a
|
|
387
|
-
* dot, such as `~/.gemini` or `~/.claude`) that belongs to no project there.
|
|
388
|
-
* Agents read the files at the top of a settings folder in every project, so
|
|
389
|
-
* the settings folder itself is never a project, even with a package.json. A
|
|
390
|
-
* folder below it with a package.json at or above it is a project, such as an
|
|
391
|
-
* agent worktree in `~/.codex/worktrees/<id>/<repo>`.
|
|
392
|
-
* @param {string} dir
|
|
393
|
-
* @returns {boolean}
|
|
394
|
-
*/
|
|
395
|
-
function isHomeOrSettingsFolder(dir) {
|
|
396
|
-
const rel = relativeToHome(dir);
|
|
397
|
-
if (rel == null) return false;
|
|
398
|
-
if (rel === '') return true;
|
|
399
|
-
if (rel === '..' || rel.startsWith(`..${path.sep}`) || path.isAbsolute(rel)) {
|
|
400
|
-
return false;
|
|
401
|
-
}
|
|
402
|
-
const parts = rel.split(path.sep);
|
|
403
|
-
if (!parts[0].startsWith('.')) return false;
|
|
404
|
-
// Look for a package.json from `dir` up to, not including, the settings folder.
|
|
405
|
-
let current = realDir(dir);
|
|
406
|
-
for (let depth = parts.length; depth > 1; depth--) {
|
|
407
|
-
if (fs.existsSync(path.join(current, 'package.json'))) return false;
|
|
408
|
-
current = path.dirname(current);
|
|
409
|
-
}
|
|
410
|
-
return true;
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
/**
|
|
414
|
-
* Throw {@link AgentDocsHomeError} when `targetDir` is the home folder, or a
|
|
415
|
-
* settings folder in it outside a project.
|
|
416
|
-
* @param {string} targetDir
|
|
417
|
-
*/
|
|
418
|
-
export function assertAgentDocsTarget(targetDir) {
|
|
419
|
-
if (isHomeOrSettingsFolder(targetDir)) throw new AgentDocsHomeError(realDir(targetDir));
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
/** Folders that mark a repository root; the project search stops there. */
|
|
423
|
-
const REPOSITORY_MARKERS = ['.git', '.hg', '.sl'];
|
|
424
|
-
|
|
425
|
-
/** Dependency fields where a project declares the Astryx packages it uses. */
|
|
426
|
-
const DEPENDENCY_FIELDS = [
|
|
427
|
-
'dependencies',
|
|
428
|
-
'devDependencies',
|
|
429
|
-
'peerDependencies',
|
|
430
|
-
'optionalDependencies',
|
|
431
|
-
];
|
|
432
|
-
|
|
433
|
-
/**
|
|
434
|
-
* The package.json in `dir`: its parsed content, `null` when it exists but
|
|
435
|
-
* does not parse, or `undefined` when there is none.
|
|
436
|
-
* @param {string} dir
|
|
437
|
-
* @returns {Record<string, unknown> | null | undefined}
|
|
438
|
-
*/
|
|
439
|
-
function readPackageJson(dir) {
|
|
440
|
-
const file = path.join(dir, 'package.json');
|
|
441
|
-
if (!fs.existsSync(file)) return undefined;
|
|
442
|
-
try {
|
|
443
|
-
const parsed = JSON.parse(fs.readFileSync(file, 'utf-8'));
|
|
444
|
-
return parsed && typeof parsed === 'object' ? parsed : null;
|
|
445
|
-
} catch {
|
|
446
|
-
return null;
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
/**
|
|
451
|
-
* Whether a parsed package.json declares an `@astryxdesign` package.
|
|
452
|
-
* @param {Record<string, unknown> | null} manifest
|
|
453
|
-
* @returns {boolean}
|
|
454
|
-
*/
|
|
455
|
-
function declaresAstryx(manifest) {
|
|
456
|
-
return DEPENDENCY_FIELDS.some(field => {
|
|
457
|
-
const deps = manifest?.[field];
|
|
458
|
-
return (
|
|
459
|
-
deps != null &&
|
|
460
|
-
typeof deps === 'object' &&
|
|
461
|
-
Object.keys(deps).some(name => name.startsWith('@astryxdesign/'))
|
|
462
|
-
);
|
|
463
|
-
});
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
/**
|
|
467
|
-
* The folder a run started in `cwd` writes agent docs to: the nearest folder at
|
|
468
|
-
* or above it whose package.json declares an `@astryxdesign` package, else the
|
|
469
|
-
* nearest folder with any package.json. The search stops at a repository root
|
|
470
|
-
* and never reaches the home folder, so a stray `~/package.json` cannot pull
|
|
471
|
-
* the docs there.
|
|
472
|
-
* @param {string} cwd
|
|
473
|
-
* @returns {string | null} null when no folder it searches has a package.json;
|
|
474
|
-
* init then writes where it runs, as before.
|
|
475
|
-
*/
|
|
476
|
-
export function resolveAgentDocsRoot(cwd) {
|
|
477
|
-
let dir = path.resolve(cwd);
|
|
478
|
-
/** @type {string | null} */
|
|
479
|
-
let nearest = null;
|
|
480
|
-
for (let i = 0; i < 50 && !isHomeFolder(dir); i++) {
|
|
481
|
-
const manifest = readPackageJson(dir);
|
|
482
|
-
if (manifest !== undefined) {
|
|
483
|
-
if (declaresAstryx(manifest)) return dir;
|
|
484
|
-
nearest ??= dir;
|
|
485
|
-
}
|
|
486
|
-
if (REPOSITORY_MARKERS.some(marker => fs.existsSync(path.join(dir, marker)))) break;
|
|
487
|
-
const parent = path.dirname(dir);
|
|
488
|
-
if (parent === dir) break;
|
|
489
|
-
dir = parent;
|
|
490
|
-
}
|
|
491
|
-
return nearest;
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
/**
|
|
495
|
-
* The folder `init` run in `cwd` writes the agent docs to: the project root
|
|
496
|
-
* {@link resolveAgentDocsRoot} finds, else `cwd` itself. The one definition
|
|
497
|
-
* that init, its removal, and the per-command setup nudge all use.
|
|
498
|
-
* @param {string} cwd
|
|
499
|
-
* @returns {string}
|
|
500
|
-
*/
|
|
501
|
-
export function agentDocsTargetDir(cwd) {
|
|
502
|
-
return resolveAgentDocsRoot(cwd) ?? cwd;
|
|
503
|
-
}
|
|
504
339
|
|
|
505
340
|
/**
|
|
506
341
|
* Agent tool presets — maps tool names to their file search paths.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
|
|
2
|
+
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Find astryx.config.{ts,mjs,js} as a sibling of the nearest package.json.
|
|
6
|
+
* Returns the absolute path, or null if none is present. Throws if multiple
|
|
7
|
+
* config files exist at that root.
|
|
8
|
+
* @param {string} [startDir]
|
|
9
|
+
* @returns {string|null}
|
|
10
|
+
*/
|
|
11
|
+
export function findConfigPath(startDir?: string): string | null;
|
|
12
|
+
/** Conventional config basenames, in load-precedence order. */
|
|
13
|
+
export const CONFIG_BASENAMES: string[];
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file config-path.mjs
|
|
5
|
+
* @input The folder a run starts in
|
|
6
|
+
* @output CONFIG_BASENAMES and findConfigPath: the project's Astryx config
|
|
7
|
+
* file, or null
|
|
8
|
+
* @position packages/cli/foundation/config: finds the config without loading
|
|
9
|
+
* project.mjs, so a run in a folder with no config loads none of it.
|
|
10
|
+
* project.mjs re-exports both.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import * as path from 'node:path';
|
|
14
|
+
import {findPackageRoot} from '../fs/paths.mjs';
|
|
15
|
+
import {findPresentFiles} from '../fs/present-files.mjs';
|
|
16
|
+
|
|
17
|
+
/** Conventional config basenames, in load-precedence order. */
|
|
18
|
+
export const CONFIG_BASENAMES = [
|
|
19
|
+
'astryx.config.ts',
|
|
20
|
+
'astryx.config.mjs',
|
|
21
|
+
'astryx.config.js',
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Find astryx.config.{ts,mjs,js} as a sibling of the nearest package.json.
|
|
26
|
+
* Returns the absolute path, or null if none is present. Throws if multiple
|
|
27
|
+
* config files exist at that root.
|
|
28
|
+
* @param {string} [startDir]
|
|
29
|
+
* @returns {string|null}
|
|
30
|
+
*/
|
|
31
|
+
export function findConfigPath(startDir = process.cwd()) {
|
|
32
|
+
const root = findPackageRoot(startDir) ?? startDir;
|
|
33
|
+
const present = findPresentFiles(root, CONFIG_BASENAMES);
|
|
34
|
+
if (present.length > 1) {
|
|
35
|
+
throw new Error(
|
|
36
|
+
`Multiple Astryx config files found in ${root} (${present
|
|
37
|
+
.map(p => path.basename(p))
|
|
38
|
+
.join(', ')}). Keep exactly one.`,
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
return present.length === 1 ? present[0] : null;
|
|
42
|
+
}
|
|
@@ -19,14 +19,6 @@ export function computerIntegrationCandidates(cwd?: string): import("../integrat
|
|
|
19
19
|
* @returns {Promise<import('../integrations/computer-integrations.mjs').ComputerIntegrationCandidate[]>}
|
|
20
20
|
*/
|
|
21
21
|
export function availableComputerIntegrations(cwd: string, installed: Set<string>): Promise<import("../integrations/computer-integrations.mjs").ComputerIntegrationCandidate[]>;
|
|
22
|
-
/**
|
|
23
|
-
* Find astryx.config.{ts,mjs,js} as a sibling of the nearest package.json.
|
|
24
|
-
* Returns the absolute path, or null if none is present. Throws if multiple
|
|
25
|
-
* config files exist at that root.
|
|
26
|
-
* @param {string} [startDir]
|
|
27
|
-
* @returns {string|null}
|
|
28
|
-
*/
|
|
29
|
-
export function findConfigPath(startDir?: string): string | null;
|
|
30
22
|
/**
|
|
31
23
|
* The provider ledger a Project resolved at load: one outcome for every
|
|
32
24
|
* package directory configured, autolinked, or authored. Internal: upgrade
|
|
@@ -41,8 +33,6 @@ export function providerLedgerOf(project: Project): import("../integrations/prov
|
|
|
41
33
|
* `package` that produced it, which Project tracks for routing/dedup.
|
|
42
34
|
* @typedef {import('../integrations/issue').AstryxIntegrationIssue & {package: string}} ProjectIntegrationIssue
|
|
43
35
|
*/
|
|
44
|
-
/** Conventional config basenames, in load-precedence order. */
|
|
45
|
-
export const CONFIG_BASENAMES: string[];
|
|
46
36
|
/** Default issue tracker used when neither config nor integration routes one. */
|
|
47
37
|
export const DEFAULT_ISSUES_URL: "https://github.com/meta/astryx/issues/new";
|
|
48
38
|
/**
|
|
@@ -268,3 +258,4 @@ export type ProjectIntegrationIssue = import("../integrations/issue").AstryxInte
|
|
|
268
258
|
package: string;
|
|
269
259
|
};
|
|
270
260
|
import { DocsCatalog } from '../discovery/docs-discovery.mjs';
|
|
261
|
+
export { CONFIG_BASENAMES, findConfigPath } from "./config-path.mjs";
|
|
@@ -35,7 +35,8 @@
|
|
|
35
35
|
|
|
36
36
|
import * as fs from 'node:fs';
|
|
37
37
|
import * as path from 'node:path';
|
|
38
|
-
import {
|
|
38
|
+
import {loadModuleWithParser} from '../fs/module-loader.mjs';
|
|
39
|
+
import {findConfigPath} from './config-path.mjs';
|
|
39
40
|
import {parseConfig} from '../../authoring/config/parse.mjs';
|
|
40
41
|
import {
|
|
41
42
|
loadIntegrations,
|
|
@@ -105,6 +106,8 @@ import {
|
|
|
105
106
|
configContentHash,
|
|
106
107
|
} from './config-cache.mjs';
|
|
107
108
|
|
|
109
|
+
export {CONFIG_BASENAMES, findConfigPath} from './config-path.mjs';
|
|
110
|
+
|
|
108
111
|
/**
|
|
109
112
|
* Extract a human-readable message from an unknown thrown value.
|
|
110
113
|
* Reproduces the historical `err?.message ?? String(err)` behavior in a
|
|
@@ -321,12 +324,6 @@ function readPackageJson(dir) {
|
|
|
321
324
|
* @typedef {import('../integrations/issue').AstryxIntegrationIssue & {package: string}} ProjectIntegrationIssue
|
|
322
325
|
*/
|
|
323
326
|
|
|
324
|
-
/** Conventional config basenames, in load-precedence order. */
|
|
325
|
-
export const CONFIG_BASENAMES = [
|
|
326
|
-
'astryx.config.ts',
|
|
327
|
-
'astryx.config.mjs',
|
|
328
|
-
'astryx.config.js',
|
|
329
|
-
];
|
|
330
327
|
|
|
331
328
|
/** Default issue tracker used when neither config nor integration routes one. */
|
|
332
329
|
export const DEFAULT_ISSUES_URL =
|
|
@@ -367,25 +364,6 @@ function inheritsIntegrationDebug(projectDir) {
|
|
|
367
364
|
}
|
|
368
365
|
}
|
|
369
366
|
|
|
370
|
-
/**
|
|
371
|
-
* Find astryx.config.{ts,mjs,js} as a sibling of the nearest package.json.
|
|
372
|
-
* Returns the absolute path, or null if none is present. Throws if multiple
|
|
373
|
-
* config files exist at that root.
|
|
374
|
-
* @param {string} [startDir]
|
|
375
|
-
* @returns {string|null}
|
|
376
|
-
*/
|
|
377
|
-
export function findConfigPath(startDir = process.cwd()) {
|
|
378
|
-
const root = findPackageRoot(startDir) ?? startDir;
|
|
379
|
-
const present = findPresentFiles(root, CONFIG_BASENAMES);
|
|
380
|
-
if (present.length > 1) {
|
|
381
|
-
throw new Error(
|
|
382
|
-
`Multiple Astryx config files found in ${root} (${present
|
|
383
|
-
.map(p => path.basename(p))
|
|
384
|
-
.join(', ')}). Keep exactly one.`,
|
|
385
|
-
);
|
|
386
|
-
}
|
|
387
|
-
return present.length === 1 ? present[0] : null;
|
|
388
|
-
}
|
|
389
367
|
|
|
390
368
|
/**
|
|
391
369
|
* The provider ledger each loaded Project resolved, kept off the class so it
|
|
@@ -11,6 +11,7 @@ import {DOC_EXPORTS} from '../doc-compiler/read.mjs';
|
|
|
11
11
|
import {
|
|
12
12
|
listDir,
|
|
13
13
|
listDirEntries,
|
|
14
|
+
listingCacheActive,
|
|
14
15
|
oncePerListing,
|
|
15
16
|
pathExists,
|
|
16
17
|
withListingCache,
|
|
@@ -511,6 +512,42 @@ export function discoverComponents(coreDir) {
|
|
|
511
512
|
return ordered;
|
|
512
513
|
}
|
|
513
514
|
|
|
515
|
+
/**
|
|
516
|
+
* The folders of `srcDir`, in listing order, whose own listing holds one of
|
|
517
|
+
* `names`: the only folders a probe for `<folder>/<name>` can find. Inside an
|
|
518
|
+
* operation each listing is read once, for every name. Outside one, every
|
|
519
|
+
* folder is returned, so each probe reads the disk.
|
|
520
|
+
* @param {string} srcDir
|
|
521
|
+
* @param {fs.Dirent[]} entries `srcDir`'s listing
|
|
522
|
+
* @param {string[]} names
|
|
523
|
+
* @returns {fs.Dirent[]}
|
|
524
|
+
*/
|
|
525
|
+
function foldersHolding(srcDir, entries, names) {
|
|
526
|
+
const folders = entries.filter(entry => entry.isDirectory());
|
|
527
|
+
if (!listingCacheActive()) return folders;
|
|
528
|
+
const byName = oncePerListing(`folder-names\0${srcDir}`, () => {
|
|
529
|
+
/** @type {Map<string, Set<string>>} */
|
|
530
|
+
const index = new Map();
|
|
531
|
+
for (const folder of folders) {
|
|
532
|
+
let listed;
|
|
533
|
+
try {
|
|
534
|
+
listed = listDir(path.join(srcDir, folder.name));
|
|
535
|
+
} catch {
|
|
536
|
+
continue;
|
|
537
|
+
}
|
|
538
|
+
for (const name of listed) {
|
|
539
|
+
let holders = index.get(name);
|
|
540
|
+
if (!holders) index.set(name, (holders = new Set()));
|
|
541
|
+
holders.add(folder.name);
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
return index;
|
|
545
|
+
});
|
|
546
|
+
return folders.filter(folder =>
|
|
547
|
+
names.some(name => byName.get(name)?.has(folder.name)),
|
|
548
|
+
);
|
|
549
|
+
}
|
|
550
|
+
|
|
514
551
|
/**
|
|
515
552
|
* Find the .doc.mjs file for a component.
|
|
516
553
|
* For sub-components (e.g. StackItem), returns the parent's .doc.mjs
|
|
@@ -532,8 +569,7 @@ export function findComponentReadme(coreDir, name) {
|
|
|
532
569
|
|
|
533
570
|
// Nested match: src/*/{name}/{Name}.doc.mjs or src/*/{name}/Astryx{Name}.doc.mjs
|
|
534
571
|
const entries = listDirEntries(srcDir);
|
|
535
|
-
for (const entry of entries) {
|
|
536
|
-
if (!entry.isDirectory()) continue;
|
|
572
|
+
for (const entry of foldersHolding(srcDir, entries, [name])) {
|
|
537
573
|
const nested = path.join(srcDir, entry.name, name, exactDoc);
|
|
538
574
|
if (existsCaseExact(nested, srcDir)) return nested;
|
|
539
575
|
const nestedXds = path.join(srcDir, entry.name, name, xdsDoc);
|
|
@@ -541,8 +577,7 @@ export function findComponentReadme(coreDir, name) {
|
|
|
541
577
|
}
|
|
542
578
|
|
|
543
579
|
// Per-component doc in a parent directory: src/*/{Name}.doc.mjs or src/*/Astryx{Name}.doc.mjs
|
|
544
|
-
for (const entry of entries) {
|
|
545
|
-
if (!entry.isDirectory()) continue;
|
|
580
|
+
for (const entry of foldersHolding(srcDir, entries, [exactDoc, xdsDoc])) {
|
|
546
581
|
const perComp = path.join(srcDir, entry.name, exactDoc);
|
|
547
582
|
if (existsCaseExact(perComp, srcDir)) return perComp;
|
|
548
583
|
const perCompXds = path.join(srcDir, entry.name, xdsDoc);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
|
|
2
|
+
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @file icon-set-paths.mjs
|
|
6
|
+
* @input A generated icon module's path
|
|
7
|
+
* @output generatedTypesPath: the declaration file beside it
|
|
8
|
+
* @position packages/cli/foundation/discovery: a path helper with no imports,
|
|
9
|
+
* so the contribution inventory reads it without icon-set-writer.mjs and
|
|
10
|
+
* that module's parser and manifest writer. icon-set-writer.mjs re-exports it.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* The declaration file beside a generated module (`x.generated.js` →
|
|
14
|
+
* `x.generated.d.ts`, `.mjs` → `.d.mts`); null for a TypeScript module.
|
|
15
|
+
* @param {string} generated
|
|
16
|
+
* @returns {string | null}
|
|
17
|
+
*/
|
|
18
|
+
export function generatedTypesPath(generated: string): string | null;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file icon-set-paths.mjs
|
|
5
|
+
* @input A generated icon module's path
|
|
6
|
+
* @output generatedTypesPath: the declaration file beside it
|
|
7
|
+
* @position packages/cli/foundation/discovery: a path helper with no imports,
|
|
8
|
+
* so the contribution inventory reads it without icon-set-writer.mjs and
|
|
9
|
+
* that module's parser and manifest writer. icon-set-writer.mjs re-exports it.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The declaration file beside a generated module (`x.generated.js` →
|
|
14
|
+
* `x.generated.d.ts`, `.mjs` → `.d.mts`); null for a TypeScript module.
|
|
15
|
+
* @param {string} generated
|
|
16
|
+
* @returns {string | null}
|
|
17
|
+
*/
|
|
18
|
+
export function generatedTypesPath(generated) {
|
|
19
|
+
if (/\.m?tsx?$/u.test(generated)) return null;
|
|
20
|
+
if (generated.endsWith('.mjs')) return generated.replace(/\.mjs$/u, '.d.mts');
|
|
21
|
+
if (generated.endsWith('.cjs')) return generated.replace(/\.cjs$/u, '.d.cts');
|
|
22
|
+
return generated.replace(/\.jsx?$/u, '.d.ts');
|
|
23
|
+
}
|
|
@@ -239,13 +239,6 @@ export function writeDefinitionFile(set: DiscoveredIconSet, doc: {
|
|
|
239
239
|
* @param {string} packageDir
|
|
240
240
|
*/
|
|
241
241
|
export function generatedModulePath(set: DiscoveredIconSet, packageDir: string): string;
|
|
242
|
-
/**
|
|
243
|
-
* The declaration file beside a generated module (`x.generated.js` →
|
|
244
|
-
* `x.generated.d.ts`, `.mjs` → `.d.mts`); null for a TypeScript module.
|
|
245
|
-
* @param {string} generated
|
|
246
|
-
* @returns {string | null}
|
|
247
|
-
*/
|
|
248
|
-
export function generatedTypesPath(generated: string): string | null;
|
|
249
242
|
/**
|
|
250
243
|
* The declaration file's text for a generated module's statements: each
|
|
251
244
|
* re-export as written, so a component keeps its library's types; each
|
|
@@ -452,6 +445,7 @@ export function iconsWithWord(set: {
|
|
|
452
445
|
* @returns {string | null}
|
|
453
446
|
*/
|
|
454
447
|
export function localSourceNote(packageDir: string, module: string): string | null;
|
|
448
|
+
export { generatedTypesPath };
|
|
455
449
|
/** @typedef {import('./icon-set-discovery.mjs').DiscoveredIconSet} DiscoveredIconSet */
|
|
456
450
|
/** @typedef {import('../../authoring/doctypes/icon-set/type').IconSetData} IconSetData */
|
|
457
451
|
/**
|
|
@@ -510,3 +504,4 @@ export type GeneratedIcon = {
|
|
|
510
504
|
*/
|
|
511
505
|
adapt: boolean;
|
|
512
506
|
};
|
|
507
|
+
import { generatedTypesPath } from './icon-set-paths.mjs';
|
|
@@ -33,6 +33,9 @@ import {findLocalIntegrationManifestOrNull} from '../integrations/manifest-write
|
|
|
33
33
|
import {loadManifestObject} from '../integrations/integrations.mjs';
|
|
34
34
|
import {levenshteinDistance} from '../text/string-utils.mjs';
|
|
35
35
|
import {astryxDefinitionsByName} from './icon-definition-discovery.mjs';
|
|
36
|
+
import {generatedTypesPath} from './icon-set-paths.mjs';
|
|
37
|
+
|
|
38
|
+
export {generatedTypesPath};
|
|
36
39
|
import {
|
|
37
40
|
discoverIconSetDirectory,
|
|
38
41
|
NOTICE_FILE_RE,
|
|
@@ -988,18 +991,6 @@ export function generatedModulePath(set, packageDir) {
|
|
|
988
991
|
const THEME_ELEMENT_PROPS =
|
|
989
992
|
"{'aria-hidden': true, 'width': '1em', 'height': '1em'}";
|
|
990
993
|
|
|
991
|
-
/**
|
|
992
|
-
* The declaration file beside a generated module (`x.generated.js` →
|
|
993
|
-
* `x.generated.d.ts`, `.mjs` → `.d.mts`); null for a TypeScript module.
|
|
994
|
-
* @param {string} generated
|
|
995
|
-
* @returns {string | null}
|
|
996
|
-
*/
|
|
997
|
-
export function generatedTypesPath(generated) {
|
|
998
|
-
if (/\.m?tsx?$/u.test(generated)) return null;
|
|
999
|
-
if (generated.endsWith('.mjs')) return generated.replace(/\.mjs$/u, '.d.mts');
|
|
1000
|
-
if (generated.endsWith('.cjs')) return generated.replace(/\.cjs$/u, '.d.cts');
|
|
1001
|
-
return generated.replace(/\.jsx?$/u, '.d.ts');
|
|
1002
|
-
}
|
|
1003
994
|
|
|
1004
995
|
/**
|
|
1005
996
|
* The declaration file's text for a generated module's statements: each
|
|
@@ -29,14 +29,6 @@ export function importUserModule(file: string, { fresh }?: {
|
|
|
29
29
|
* @returns {Promise<Record<string, unknown>>}
|
|
30
30
|
*/
|
|
31
31
|
export function importThemeArtifact(specifier: string, cwd: string): Promise<Record<string, unknown>>;
|
|
32
|
-
/**
|
|
33
|
-
* Return the conventional files (by basename, in the given precedence order)
|
|
34
|
-
* that exist directly in `dir`, as absolute paths. Never throws.
|
|
35
|
-
* @param {string} dir
|
|
36
|
-
* @param {string[]} basenames precedence-ordered
|
|
37
|
-
* @returns {string[]} absolute paths of present files, in basenames order
|
|
38
|
-
*/
|
|
39
|
-
export function findPresentFiles(dir: string, basenames: string[]): string[];
|
|
40
32
|
/**
|
|
41
33
|
* Import a user-authored module, take its default export, and validate it
|
|
42
34
|
* through an authoring parser. This is the single load/validation boundary for
|
|
@@ -57,3 +49,5 @@ export function loadModuleWithParser<T>(file: string, parse: (input: unknown, la
|
|
|
57
49
|
label?: string;
|
|
58
50
|
fresh?: boolean;
|
|
59
51
|
}): Promise<T>;
|
|
52
|
+
export { findPresentFiles };
|
|
53
|
+
import { findPresentFiles } from './present-files.mjs';
|
|
@@ -25,6 +25,9 @@ import {createRequire} from 'node:module';
|
|
|
25
25
|
import {pathToFileURL} from 'node:url';
|
|
26
26
|
import * as fs from 'node:fs';
|
|
27
27
|
import {createJiti} from 'jiti';
|
|
28
|
+
import {findPresentFiles} from './present-files.mjs';
|
|
29
|
+
|
|
30
|
+
export {findPresentFiles};
|
|
28
31
|
|
|
29
32
|
/** @type {ReturnType<typeof createJiti> | undefined} */
|
|
30
33
|
let jitiInstance;
|
|
@@ -275,18 +278,6 @@ async function importModule(file, fresh) {
|
|
|
275
278
|
return await import(url.href);
|
|
276
279
|
}
|
|
277
280
|
|
|
278
|
-
/**
|
|
279
|
-
* Return the conventional files (by basename, in the given precedence order)
|
|
280
|
-
* that exist directly in `dir`, as absolute paths. Never throws.
|
|
281
|
-
* @param {string} dir
|
|
282
|
-
* @param {string[]} basenames precedence-ordered
|
|
283
|
-
* @returns {string[]} absolute paths of present files, in basenames order
|
|
284
|
-
*/
|
|
285
|
-
export function findPresentFiles(dir, basenames) {
|
|
286
|
-
return basenames
|
|
287
|
-
.filter(name => fs.existsSync(path.join(dir, name)))
|
|
288
|
-
.map(name => path.join(dir, name));
|
|
289
|
-
}
|
|
290
281
|
|
|
291
282
|
/**
|
|
292
283
|
* Import a user-authored module, take its default export, and validate it
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
|
|
2
|
+
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Return the conventional files (by basename, in the given precedence order)
|
|
6
|
+
* that exist directly in `dir`, as absolute paths. Never throws.
|
|
7
|
+
* @param {string} dir
|
|
8
|
+
* @param {string[]} basenames precedence-ordered
|
|
9
|
+
* @returns {string[]} absolute paths of present files, in basenames order
|
|
10
|
+
*/
|
|
11
|
+
export function findPresentFiles(dir: string, basenames: string[]): string[];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file present-files.mjs
|
|
5
|
+
* @input A folder and the file names to look for in it
|
|
6
|
+
* @output findPresentFiles: the paths of those that exist, in order
|
|
7
|
+
* @position packages/cli/foundation/fs: node builtins only, so a run reads it
|
|
8
|
+
* without module-loader.mjs and its jiti. module-loader.mjs re-exports it.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import * as fs from 'node:fs';
|
|
12
|
+
import * as path from 'node:path';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Return the conventional files (by basename, in the given precedence order)
|
|
16
|
+
* that exist directly in `dir`, as absolute paths. Never throws.
|
|
17
|
+
* @param {string} dir
|
|
18
|
+
* @param {string[]} basenames precedence-ordered
|
|
19
|
+
* @returns {string[]} absolute paths of present files, in basenames order
|
|
20
|
+
*/
|
|
21
|
+
export function findPresentFiles(dir, basenames) {
|
|
22
|
+
return basenames
|
|
23
|
+
.filter(name => fs.existsSync(path.join(dir, name)))
|
|
24
|
+
.map(name => path.join(dir, name));
|
|
25
|
+
}
|
|
@@ -15,27 +15,6 @@ export function readDeclaredDependencies(projectDir: string): Array<{
|
|
|
15
15
|
name: string;
|
|
16
16
|
field: string;
|
|
17
17
|
}>;
|
|
18
|
-
/**
|
|
19
|
-
* Resolve an installed package's directory the way Node's resolver finds it:
|
|
20
|
-
* the nearest `node_modules/<name>` walking up from `fromDir`.
|
|
21
|
-
*
|
|
22
|
-
* Walking up matters because hoisting is normal — yarn and npm workspaces lift
|
|
23
|
-
* a workspace member's dependency to the repo root, so the app's own
|
|
24
|
-
* node_modules can be empty of a package it genuinely declares. Integrations
|
|
25
|
-
* named in astryx.config resolve through the same walk.
|
|
26
|
-
*
|
|
27
|
-
* Presence is decided by the package's own package.json, not the directory, so
|
|
28
|
-
* a stale empty directory is not mistaken for an install.
|
|
29
|
-
*
|
|
30
|
-
* @param {string} name bare package name
|
|
31
|
-
* @param {string} fromDir directory to start walking up from
|
|
32
|
-
* @returns {{packageDir: string, hostDir: string}|null} the resolved package
|
|
33
|
-
* directory and the directory whose node_modules holds it
|
|
34
|
-
*/
|
|
35
|
-
export function resolveInstalledPackageDir(name: string, fromDir: string): {
|
|
36
|
-
packageDir: string;
|
|
37
|
-
hostDir: string;
|
|
38
|
-
} | null;
|
|
39
18
|
/**
|
|
40
19
|
* @typedef {object} AutolinkCandidate
|
|
41
20
|
* @property {string} spec
|
|
@@ -131,6 +110,7 @@ export function autolinkIntegrations({ projectDir, loaded, fresh, }: {
|
|
|
131
110
|
loaded?: import("./integrations.mjs").LoadedIntegration[] | undefined;
|
|
132
111
|
fresh?: boolean | undefined;
|
|
133
112
|
}): Promise<import("./integrations.mjs").LoadedIntegration[]>;
|
|
113
|
+
export { resolveInstalledPackageDir };
|
|
134
114
|
/**
|
|
135
115
|
* package.json fields whose keys name a dependency this project installs.
|
|
136
116
|
*
|
|
@@ -152,3 +132,4 @@ export type AutolinkCandidate = {
|
|
|
152
132
|
*/
|
|
153
133
|
repeat?: boolean | undefined;
|
|
154
134
|
};
|
|
135
|
+
import { resolveInstalledPackageDir } from './installed-package.mjs';
|