@astryxdesign/cli 0.7.4-canary.ac8260d → 0.7.4-canary.ad6782d
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.
|
@@ -101,6 +101,17 @@ export function resolveAgentPaths(targetDir: string, agent: string): {
|
|
|
101
101
|
* @returns {'stylex' | 'tailwind' | 'css'}
|
|
102
102
|
*/
|
|
103
103
|
export function detectStylingSystem(targetDir: string): "stylex" | "tailwind" | "css";
|
|
104
|
+
/**
|
|
105
|
+
* Whether the project at `dir` can run `astryx doctor --built`: the CLI it
|
|
106
|
+
* installs, which answers it whatever the running copy is, has the option.
|
|
107
|
+
* Read from the installed CLI (the folder's own, or its workspace's), never
|
|
108
|
+
* from declared ranges or the running copy, so a block written before
|
|
109
|
+
* install, or by a newer copy, never names an option the project's CLI
|
|
110
|
+
* rejects; the next `init` or `upgrade --apply` after install adds it.
|
|
111
|
+
* @param {string} dir
|
|
112
|
+
* @returns {boolean}
|
|
113
|
+
*/
|
|
114
|
+
export function projectHasBuiltCheck(dir: string): boolean;
|
|
104
115
|
/**
|
|
105
116
|
* Generate the agent cheat sheet from live CLI metadata.
|
|
106
117
|
*
|
|
@@ -125,10 +136,10 @@ export function detectStylingSystem(targetDir: string): "stylex" | "tailwind" |
|
|
|
125
136
|
* `getting-started` is the one it should reach for first.
|
|
126
137
|
*
|
|
127
138
|
* @param {string | null} version the Core version
|
|
128
|
-
* @param {{coreDir?: string|null, invocation?: string, stylingSystem?: 'stylex'|'tailwind'|'css', zh?: boolean, lang?: string, topics?: string[], agentDocs?: Array<{package: string, append: readonly string[]}
|
|
139
|
+
* @param {{coreDir?: string|null, invocation?: string, stylingSystem?: 'stylex'|'tailwind'|'css', zh?: boolean, lang?: string, topics?: string[], agentDocs?: Array<{package: string, append: readonly string[]}>, builtCheck?: boolean}} [options]
|
|
129
140
|
* @returns {string}
|
|
130
141
|
*/
|
|
131
|
-
export function generateCompressedIndex(version: string | null, { coreDir, invocation, stylingSystem, topics, agentDocs, }?: {
|
|
142
|
+
export function generateCompressedIndex(version: string | null, { coreDir, invocation, stylingSystem, topics, agentDocs, builtCheck, }?: {
|
|
132
143
|
coreDir?: string | null;
|
|
133
144
|
invocation?: string;
|
|
134
145
|
stylingSystem?: "stylex" | "tailwind" | "css";
|
|
@@ -139,6 +150,7 @@ export function generateCompressedIndex(version: string | null, { coreDir, invoc
|
|
|
139
150
|
package: string;
|
|
140
151
|
append: readonly string[];
|
|
141
152
|
}>;
|
|
153
|
+
builtCheck?: boolean;
|
|
142
154
|
}): string;
|
|
143
155
|
/**
|
|
144
156
|
* Resolve the complete expected block for one installed project.
|
|
@@ -33,10 +33,11 @@ import {spawnSync} from 'node:child_process';
|
|
|
33
33
|
import * as fs from 'node:fs';
|
|
34
34
|
import * as os from 'node:os';
|
|
35
35
|
import * as path from 'node:path';
|
|
36
|
-
import {findCoreDir, CLI_ROOT} from '../fs/paths.mjs';
|
|
36
|
+
import {findCoreDir, findInstalledPackage, CLI_ROOT} from '../fs/paths.mjs';
|
|
37
37
|
import {assertWithin, PathSafetyError} from '../fs/path-safety.mjs';
|
|
38
38
|
import {createFileProtectionResolver} from '../fs/file-protection.mjs';
|
|
39
39
|
import {getCliInvocation} from '../env/package-manager.mjs';
|
|
40
|
+
import {isValidSemver, semverGte} from '../env/semver.mjs';
|
|
40
41
|
import {discoverComponents} from '../discovery/component-discovery.mjs';
|
|
41
42
|
import {Project} from '../config/project.mjs';
|
|
42
43
|
import {cliRootNamespaceNames} from '../doc-compiler/tree.mjs';
|
|
@@ -683,6 +684,45 @@ export function detectStylingSystem(targetDir) {
|
|
|
683
684
|
}
|
|
684
685
|
}
|
|
685
686
|
|
|
687
|
+
/** The first release whose `doctor` takes `--built`. */
|
|
688
|
+
const BUILT_CHECK_SINCE = '0.7.4';
|
|
689
|
+
|
|
690
|
+
/**
|
|
691
|
+
* Whether a project on this Core release can run `astryx doctor --built`. A
|
|
692
|
+
* prerelease of the first release is below it: its canaries predate the
|
|
693
|
+
* option.
|
|
694
|
+
* @param {string | null | undefined} version
|
|
695
|
+
*/
|
|
696
|
+
function hasBuiltCheck(version) {
|
|
697
|
+
if (typeof version !== 'string' || !isValidSemver(version)) return false;
|
|
698
|
+
const [release, prerelease] = version.split('-', 2);
|
|
699
|
+
if (prerelease !== undefined && release === BUILT_CHECK_SINCE) return false;
|
|
700
|
+
return semverGte(release, BUILT_CHECK_SINCE);
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
/**
|
|
704
|
+
* Whether the project at `dir` can run `astryx doctor --built`: the CLI it
|
|
705
|
+
* installs, which answers it whatever the running copy is, has the option.
|
|
706
|
+
* Read from the installed CLI (the folder's own, or its workspace's), never
|
|
707
|
+
* from declared ranges or the running copy, so a block written before
|
|
708
|
+
* install, or by a newer copy, never names an option the project's CLI
|
|
709
|
+
* rejects; the next `init` or `upgrade --apply` after install adds it.
|
|
710
|
+
* @param {string} dir
|
|
711
|
+
* @returns {boolean}
|
|
712
|
+
*/
|
|
713
|
+
export function projectHasBuiltCheck(dir) {
|
|
714
|
+
const installed = findInstalledPackage(dir, '@astryxdesign/cli');
|
|
715
|
+
if (!installed) return false;
|
|
716
|
+
try {
|
|
717
|
+
const {version} = JSON.parse(
|
|
718
|
+
fs.readFileSync(path.join(installed, 'package.json'), 'utf8'),
|
|
719
|
+
);
|
|
720
|
+
return hasBuiltCheck(version);
|
|
721
|
+
} catch {
|
|
722
|
+
return false;
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
|
|
686
726
|
/**
|
|
687
727
|
* Generate the agent cheat sheet from live CLI metadata.
|
|
688
728
|
*
|
|
@@ -707,7 +747,7 @@ export function detectStylingSystem(targetDir) {
|
|
|
707
747
|
* `getting-started` is the one it should reach for first.
|
|
708
748
|
*
|
|
709
749
|
* @param {string | null} version the Core version
|
|
710
|
-
* @param {{coreDir?: string|null, invocation?: string, stylingSystem?: 'stylex'|'tailwind'|'css', zh?: boolean, lang?: string, topics?: string[], agentDocs?: Array<{package: string, append: readonly string[]}
|
|
750
|
+
* @param {{coreDir?: string|null, invocation?: string, stylingSystem?: 'stylex'|'tailwind'|'css', zh?: boolean, lang?: string, topics?: string[], agentDocs?: Array<{package: string, append: readonly string[]}>, builtCheck?: boolean}} [options]
|
|
711
751
|
* @returns {string}
|
|
712
752
|
*/
|
|
713
753
|
export function generateCompressedIndex(
|
|
@@ -718,6 +758,7 @@ export function generateCompressedIndex(
|
|
|
718
758
|
stylingSystem = 'css',
|
|
719
759
|
topics,
|
|
720
760
|
agentDocs = [],
|
|
761
|
+
builtCheck = false,
|
|
721
762
|
} = {},
|
|
722
763
|
) {
|
|
723
764
|
const run = invocation;
|
|
@@ -767,6 +808,13 @@ export function generateCompressedIndex(
|
|
|
767
808
|
// intentionally omitted from the command reference below.
|
|
768
809
|
lines.push(WORKFLOW_TITLE, ...WORKFLOW_STEPS);
|
|
769
810
|
lines.push('Changing an existing page? Keep it: skip step 2 and add blocks/components inside its sections.');
|
|
811
|
+
// Only for a project whose recorded releases have `doctor --built`
|
|
812
|
+
// (projectHasBuiltCheck): a newer copy may write this block in a project
|
|
813
|
+
// whose install then brings an older CLI, which rejects the option. The computer-level
|
|
814
|
+
// skill names only entry points every release keeps (AST-081 FR8).
|
|
815
|
+
if (builtCheck) {
|
|
816
|
+
lines.push("Before you deliver a build, run `astryx doctor --built <dir>`; don't deliver it if it fails.");
|
|
817
|
+
}
|
|
770
818
|
lines.push('');
|
|
771
819
|
|
|
772
820
|
// Rules — the top error-preventers.
|
|
@@ -911,6 +959,7 @@ export async function renderAgentDocsBlock(
|
|
|
911
959
|
|
|
912
960
|
return generateCompressedIndex(version, {
|
|
913
961
|
coreDir,
|
|
962
|
+
builtCheck: projectHasBuiltCheck(targetDir),
|
|
914
963
|
invocation: getCliInvocation(targetDir),
|
|
915
964
|
stylingSystem: detectStylingSystem(targetDir),
|
|
916
965
|
topics,
|
|
@@ -999,6 +1048,7 @@ export function injectAgentsMd(targetDir, version) {
|
|
|
999
1048
|
const agentsPath = path.join(targetDir, AGENTS_MD);
|
|
1000
1049
|
const compressedIndex = generateCompressedIndex(version, {
|
|
1001
1050
|
coreDir: findCoreDir(targetDir),
|
|
1051
|
+
builtCheck: projectHasBuiltCheck(targetDir),
|
|
1002
1052
|
stylingSystem: detectStylingSystem(targetDir),
|
|
1003
1053
|
});
|
|
1004
1054
|
injectXdsBlock(agentsPath, compressedIndex, {
|
|
@@ -1019,6 +1069,7 @@ export function injectClaudeMd(targetDir, version) {
|
|
|
1019
1069
|
const claudePath = path.join(targetDir, CLAUDE_MD);
|
|
1020
1070
|
const compressedIndex = generateCompressedIndex(version, {
|
|
1021
1071
|
coreDir: findCoreDir(targetDir),
|
|
1072
|
+
builtCheck: projectHasBuiltCheck(targetDir),
|
|
1022
1073
|
stylingSystem: detectStylingSystem(targetDir),
|
|
1023
1074
|
});
|
|
1024
1075
|
return injectXdsBlock(claudePath, compressedIndex);
|
|
@@ -1743,6 +1794,7 @@ export function installAgentDocs(
|
|
|
1743
1794
|
renderedBlock ??
|
|
1744
1795
|
generateCompressedIndex(version, {
|
|
1745
1796
|
coreDir,
|
|
1797
|
+
builtCheck: projectHasBuiltCheck(targetDir),
|
|
1746
1798
|
zh,
|
|
1747
1799
|
lang,
|
|
1748
1800
|
invocation,
|
|
@@ -4,8 +4,10 @@ import {describe, it, expect, beforeEach, afterEach, vi} from 'vitest';
|
|
|
4
4
|
import * as fs from 'node:fs';
|
|
5
5
|
import * as path from 'node:path';
|
|
6
6
|
import * as os from 'node:os';
|
|
7
|
+
import {renderComputerAgentText} from './computer-agent-text.mjs';
|
|
7
8
|
import {
|
|
8
9
|
generateCompressedIndex,
|
|
10
|
+
projectHasBuiltCheck,
|
|
9
11
|
detectStylingSystem,
|
|
10
12
|
getXdsVersion,
|
|
11
13
|
installAgentDocs,
|
|
@@ -95,6 +97,65 @@ describe('generateCompressedIndex', () => {
|
|
|
95
97
|
expect(result).toContain('<!-- ASTRYX:END -->');
|
|
96
98
|
});
|
|
97
99
|
|
|
100
|
+
it('tells agents to check a build with doctor --built; the computer-level skill does not', () => {
|
|
101
|
+
const line =
|
|
102
|
+
"Before you deliver a build, run `astryx doctor --built <dir>`; don't deliver it if it fails.";
|
|
103
|
+
expect(generateCompressedIndex('0.7.4', {builtCheck: true})).toContain(line);
|
|
104
|
+
expect(generateCompressedIndex('0.7.4')).not.toContain('doctor --built');
|
|
105
|
+
expect(renderComputerAgentText({command: 'astryx'})).not.toContain(
|
|
106
|
+
'doctor --built',
|
|
107
|
+
);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
describe('projectHasBuiltCheck reads the CLI the project installs', () => {
|
|
111
|
+
/**
|
|
112
|
+
* @param {string | null} cliVersion the installed CLI, or none
|
|
113
|
+
* @param {{workspace?: boolean}} [options] install it at a workspace root
|
|
114
|
+
*/
|
|
115
|
+
const project = (cliVersion, {workspace = false} = {}) => {
|
|
116
|
+
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-built-check-'));
|
|
117
|
+
const app = workspace ? path.join(root, 'apps', 'web') : root;
|
|
118
|
+
fs.mkdirSync(app, {recursive: true});
|
|
119
|
+
if (workspace) {
|
|
120
|
+
fs.writeFileSync(
|
|
121
|
+
path.join(root, 'package.json'),
|
|
122
|
+
JSON.stringify({name: 'repo', private: true, workspaces: ['apps/*'], devDependencies: {'@astryxdesign/cli': cliVersion ?? '0.7.3'}}),
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
fs.writeFileSync(
|
|
126
|
+
path.join(app, 'package.json'),
|
|
127
|
+
JSON.stringify({name: 'web', dependencies: {'@astryxdesign/core': '0.7.4'}}),
|
|
128
|
+
);
|
|
129
|
+
if (cliVersion) {
|
|
130
|
+
const cliDir = path.join(root, 'node_modules', '@astryxdesign', 'cli');
|
|
131
|
+
fs.mkdirSync(cliDir, {recursive: true});
|
|
132
|
+
fs.writeFileSync(
|
|
133
|
+
path.join(cliDir, 'package.json'),
|
|
134
|
+
JSON.stringify({name: '@astryxdesign/cli', version: cliVersion}),
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
return {root, app};
|
|
138
|
+
};
|
|
139
|
+
it.each([
|
|
140
|
+
['an installed CLI 0.7.4', '0.7.4', {}, true],
|
|
141
|
+
['an installed CLI 0.8.0', '0.8.0', {}, true],
|
|
142
|
+
['an installed CLI 0.7.3', '0.7.3', {}, false],
|
|
143
|
+
['an installed 0.7.4 canary', '0.7.4-canary.b25f95e', {}, false],
|
|
144
|
+
['no installed CLI (before install, or Core only)', null, {}, false],
|
|
145
|
+
['a workspace root that installs CLI 0.7.3', '0.7.3', {workspace: true}, false],
|
|
146
|
+
['a workspace root that installs CLI 0.7.4', '0.7.4', {workspace: true}, true],
|
|
147
|
+
])('%s', (_label, cliVersion, options, expected) => {
|
|
148
|
+
const {root, app} = project(cliVersion, options);
|
|
149
|
+
try {
|
|
150
|
+
expect(projectHasBuiltCheck(app)).toBe(expected);
|
|
151
|
+
} finally {
|
|
152
|
+
fs.rmSync(root, {recursive: true, force: true});
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
98
159
|
it('includes theme nudge rule', () => {
|
|
99
160
|
const result = generateCompressedIndex('1.0.0');
|
|
100
161
|
expect(result).toMatch(/astryx docs theme/);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astryxdesign/cli",
|
|
3
|
-
"version": "0.7.4-canary.
|
|
3
|
+
"version": "0.7.4-canary.ad6782d",
|
|
4
4
|
"displayName": "CLI",
|
|
5
5
|
"description": "Scaffold projects, browse templates, generate themes, and get agent-ready docs from the command line.",
|
|
6
6
|
"author": "Meta Open Source",
|
|
@@ -106,10 +106,10 @@
|
|
|
106
106
|
"zod": "^4.4.3"
|
|
107
107
|
},
|
|
108
108
|
"peerDependencies": {
|
|
109
|
-
"@astryxdesign/charts": "0.7.4-canary.
|
|
110
|
-
"@astryxdesign/core": "0.7.4-canary.
|
|
111
|
-
"@astryxdesign/lab": "0.7.4-canary.
|
|
112
|
-
"@astryxdesign/theme-neutral": "0.7.4-canary.
|
|
109
|
+
"@astryxdesign/charts": "0.7.4-canary.ad6782d",
|
|
110
|
+
"@astryxdesign/core": "0.7.4-canary.ad6782d",
|
|
111
|
+
"@astryxdesign/lab": "0.7.4-canary.ad6782d",
|
|
112
|
+
"@astryxdesign/theme-neutral": "0.7.4-canary.ad6782d"
|
|
113
113
|
},
|
|
114
114
|
"peerDependenciesMeta": {
|
|
115
115
|
"@astryxdesign/charts": {
|
|
@@ -126,10 +126,10 @@
|
|
|
126
126
|
}
|
|
127
127
|
},
|
|
128
128
|
"devDependencies": {
|
|
129
|
-
"@astryxdesign/charts": "0.7.4-canary.
|
|
130
|
-
"@astryxdesign/core": "0.7.4-canary.
|
|
131
|
-
"@astryxdesign/lab": "0.7.4-canary.
|
|
132
|
-
"@astryxdesign/theme-neutral": "0.7.4-canary.
|
|
129
|
+
"@astryxdesign/charts": "0.7.4-canary.ad6782d",
|
|
130
|
+
"@astryxdesign/core": "0.7.4-canary.ad6782d",
|
|
131
|
+
"@astryxdesign/lab": "0.7.4-canary.ad6782d",
|
|
132
|
+
"@astryxdesign/theme-neutral": "0.7.4-canary.ad6782d",
|
|
133
133
|
"@heroicons/react": "^2.2.0",
|
|
134
134
|
"@stylexjs/stylex": "^0.19.0",
|
|
135
135
|
"@types/babel__core": "^7.20.5",
|