@astryxdesign/cli 0.6.3-canary.d0d49a4 → 0.6.3-canary.db4e378
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 +86 -72
- package/api/build/build.doc.mjs +3 -3
- package/api/build/build.test.mjs +14 -3
- package/api/build/build.type.d.mts +35 -1
- package/api/build/build.type.mjs +24 -3
- package/api/build/help/help.d.mts +8 -5
- package/api/build/help/help.mjs +56 -6
- package/api/component/component.doc.mjs +12 -3
- package/api/component/component.mjs +31 -2
- package/api/component/component.test.mjs +38 -0
- package/api/component/component.type.d.mts +16 -5
- package/api/component/component.type.mjs +13 -5
- package/api/component/detail/blocks/blocks.d.mts +2 -1
- package/api/component/detail/blocks/blocks.mjs +4 -3
- package/api/component/list/list.d.mts +0 -5
- package/api/component/list/list.mjs +37 -9
- package/api/discover/discover.doc.mjs +1 -1
- package/api/gap-report/gap-report.doc.mjs +7 -4
- package/api/init/init.doc.mjs +4 -0
- package/api/init/init.test.mjs +41 -1
- package/api/init/remove/remove.mjs +1 -1
- package/api/init/run/run.mjs +20 -10
- package/api/integration/add-contribution.component-names.test.mjs +120 -0
- package/api/integration/add-contribution.mjs +11 -0
- package/api/integration/add-contribution.test.mjs +80 -0
- package/api/integration/integrationAdd.doc.mjs +7 -4
- package/api/integration/integrationAddComponent.doc.mjs +1 -1
- package/api/integration/validate-integration.mjs +2 -0
- package/api/integration/validate-integration.test.mjs +91 -0
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/json/envelope-types.test.mjs +76 -0
- package/api/json/parseResponse.doc.mjs +2 -2
- package/api/layout/expand/expand.mjs +7 -5
- package/api/layout/expand/expand.path-safety.test.mjs +53 -0
- package/api/layout/grammar/grammar.mjs +2 -1
- package/api/layout/layoutExpand.doc.mjs +1 -1
- package/api/search/search-return-type.test.mjs +54 -0
- package/api/search/search.d.mts +2 -9
- package/api/search/search.doc.mjs +5 -1
- package/api/search/search.mjs +10 -3
- package/api/search/search.test.mjs +34 -0
- package/api/swizzle/copy/copy.mjs +28 -11
- package/api/swizzle/swizzle.doc.mjs +1 -1
- package/api/template/copy/copy.mjs +17 -23
- package/api/template/copy/copy.test.mjs +17 -0
- package/api/template/template.doc.mjs +2 -1
- package/api/theme/add/add.binary.test.mjs +91 -0
- package/api/theme/add/add.mjs +20 -3
- package/api/theme/add/add.staging.test.mjs +66 -0
- package/api/theme/build/build.mjs +114 -37
- package/api/theme/build/build.public-component-vars.test.mjs +1 -1
- package/api/theme/build/build.receipt-doc.test.mjs +111 -0
- package/api/theme/build/font-warning.mjs +3 -3
- package/api/theme/build/font-warning.test.mjs +5 -2
- package/api/theme/palette/generate/generate.mjs +7 -2
- package/api/theme/palette/generate/generate.test.mjs +96 -0
- package/api/theme/palette/generate/generator.mjs +8 -1
- package/api/theme/palette/generate/generator.test.mjs +10 -0
- package/api/theme/template/template.mjs +11 -2
- package/api/theme/template/template.test.mjs +15 -0
- package/api/theme/themeBuild.doc.mjs +7 -4
- package/api/theme/themeTemplate.doc.mjs +4 -1
- package/api/upgrade/_adapter.mjs +27 -4
- package/api/upgrade/list/list.mjs +2 -1
- package/api/upgrade/list/list.test.mjs +73 -0
- package/api/upgrade/status/status.mjs +2 -2
- package/api/upgrade/upgrade.doc.mjs +2 -1
- package/api/upgrade/upgrade.type.d.mts +4 -0
- package/api/upgrade/upgrade.type.mjs +1 -0
- package/assets/codemods/term-log.mjs +32 -8
- package/assets/codemods/term-log.test.mjs +19 -1
- package/assets/codemods/transform-prop.mjs +109 -0
- package/assets/codemods/transform-prop.test.mjs +95 -0
- package/assets/codemods/transforms/v0.0.14/__tests__/rename-status-variants.test.mjs +86 -165
- package/assets/codemods/transforms/v0.0.14/rename-status-variants.mjs +72 -210
- package/assets/codemods/transforms/v0.1.8/__tests__/rename-avatar-size-scale.test.mjs +83 -115
- package/assets/codemods/transforms/v0.1.8/rename-avatar-size-scale.mjs +57 -186
- package/assets/codemods/transforms/v0.6.0/__tests__/next-codemods.test.mjs +47 -0
- package/assets/codemods/transforms/v0.6.0/rename-resizable-pixel-bounds.mjs +57 -10
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaInlineRail.doc.mjs +14 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaInlineRail.tsx +61 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaOverscrollChaining.doc.mjs +14 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaOverscrollChaining.tsx +126 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaShowcase.doc.mjs +15 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaShowcase.tsx +86 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyGroupHeaders.doc.mjs +14 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyGroupHeaders.tsx +99 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyPassthrough.doc.mjs +14 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaStickyPassthrough.tsx +122 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaTwoAxisBoard.doc.mjs +14 -0
- package/assets/templates/blocks/components/ScrollableArea/ScrollableAreaTwoAxisBoard.tsx +95 -0
- package/assets/templates/pages/table-tree/page.tsx +1704 -0
- package/assets/templates/pages/table-tree/template.doc.mjs +12 -0
- package/authoring/config/config.doc.mjs +1 -1
- package/authoring/config/debug-composition.test.mjs +92 -0
- package/authoring/config/type.ts +15 -3
- package/clients/cli/command-load-failure.test.mjs +83 -0
- package/clients/cli/commands/blog.mjs +23 -8
- package/clients/cli/commands/blog.test.mjs +42 -1
- package/clients/cli/commands/build-theme.ascii-output.test.mjs +161 -0
- package/clients/cli/commands/build-theme.flag-docs.test.mjs +110 -0
- package/clients/cli/commands/build-theme.mjs +5 -5
- package/clients/cli/commands/build-theme.path-safety.test.mjs +86 -1
- package/clients/cli/commands/build-theme.variants.test.mjs +76 -0
- package/clients/cli/commands/build.doc.mjs +4 -1
- package/clients/cli/commands/build.exit-codes-doc.test.mjs +50 -0
- package/clients/cli/commands/build.mjs +32 -47
- package/clients/cli/commands/build.playbook.test.mjs +75 -0
- package/clients/cli/commands/build.text-fields.test.mjs +40 -0
- package/clients/cli/commands/component/index.mjs +2 -7
- package/clients/cli/commands/component-package.test.mjs +46 -0
- package/clients/cli/commands/component-resolution.test.mjs +21 -0
- package/clients/cli/commands/component.test.mjs +19 -0
- package/clients/cli/commands/detail-levels.test.mjs +2 -2
- package/clients/cli/commands/discover.broken-integration.test.mjs +48 -0
- package/clients/cli/commands/discover.components-flag.test.mjs +97 -0
- package/clients/cli/commands/discover.doc.mjs +4 -2
- package/clients/cli/commands/discover.mjs +3 -3
- package/clients/cli/commands/discover.text-projection.test.mjs +103 -0
- package/clients/cli/commands/doctor-integration.package-json.test.mjs +53 -0
- package/clients/cli/commands/doctor.mjs +6 -16
- package/clients/cli/commands/doctor.test.mjs +42 -0
- package/clients/cli/commands/gap-report.doc.mjs +16 -5
- package/clients/cli/commands/gap-report.test.mjs +72 -0
- package/clients/cli/commands/hook/index.mjs +7 -17
- package/clients/cli/commands/hook.text-projection.test.mjs +45 -0
- package/clients/cli/commands/init.doc.mjs +19 -8
- package/clients/cli/commands/init.flag-help.test.mjs +153 -0
- package/clients/cli/commands/integration-add.controls.test.mjs +132 -0
- package/clients/cli/commands/integration-add.doc.mjs +21 -5
- package/clients/cli/commands/interactive-guard.test.mjs +101 -24
- package/clients/cli/commands/json-contract.test.mjs +33 -0
- package/clients/cli/commands/layout-check.doc.mjs +14 -3
- package/clients/cli/commands/layout-expand.doc.mjs +21 -4
- package/clients/cli/commands/layout.doc.mjs +2 -2
- package/clients/cli/commands/layout.mjs +21 -9
- package/clients/cli/commands/layout.path-help.test.mjs +33 -0
- package/clients/cli/commands/layout.stdin-cap.test.mjs +47 -0
- package/clients/cli/commands/layout.text-fields.test.mjs +39 -0
- package/clients/cli/commands/no-prompt-wording.test.mjs +94 -0
- package/clients/cli/commands/search.doc.mjs +6 -3
- package/clients/cli/commands/search.mjs +17 -7
- package/clients/cli/commands/search.test.mjs +75 -0
- package/clients/cli/commands/swizzle.doc.mjs +2 -1
- package/clients/cli/commands/swizzle.path-safety.test.mjs +42 -0
- package/clients/cli/commands/template.doc.mjs +28 -6
- package/clients/cli/commands/template.flag-help.test.mjs +117 -0
- package/clients/cli/commands/template.path-help.test.mjs +40 -0
- package/clients/cli/commands/theme-add.doc.mjs +2 -1
- package/clients/cli/commands/theme-build.doc.mjs +7 -6
- package/clients/cli/commands/theme-palette-generate.test.mjs +19 -0
- package/clients/cli/commands/theme-template.behavior.test.mjs +12 -0
- package/clients/cli/commands/theme-template.doc.mjs +1 -1
- package/clients/cli/commands/upgrade.ascii-output.test.mjs +87 -0
- package/clients/cli/commands/upgrade.doc.mjs +17 -6
- package/clients/cli/commands/upgrade.flag-help.test.mjs +188 -0
- package/clients/cli/commands/upgrade.hook-output.test.mjs +88 -0
- package/clients/cli/index.mjs +13 -30
- package/clients/cli/latest-version-env.test.mjs +50 -0
- package/clients/cli/lib/cli-error.test.mjs +7 -0
- package/clients/cli/lib/component-format.mjs +9 -9
- package/clients/cli/lib/component-format.test.mjs +1 -1
- package/clients/cli/lib/define-command.mjs +32 -6
- package/clients/cli/lib/doc-text-ascii.test.mjs +82 -0
- package/clients/cli/lib/exit-codes.test.mjs +97 -0
- package/clients/cli/lib/hook-format.mjs +5 -5
- package/clients/cli/lib/json-shim.mjs +38 -2
- package/clients/cli/lib/json-shim.test.mjs +83 -0
- package/clients/cli/lib/manifest.d.ts +2 -0
- package/clients/cli/lib/manifest.mjs +22 -0
- package/clients/cli/lib/manifest.test.mjs +17 -0
- package/foundation/agent-docs/agent-docs.d.mts +4 -0
- package/foundation/agent-docs/agent-docs.mjs +69 -3
- package/foundation/agent-docs/agent-docs.path-safety.test.mjs +266 -4
- package/foundation/config/integration-debug.test.mjs +28 -3
- package/foundation/config/project.mjs +123 -9
- package/foundation/config/project.test.mjs +126 -0
- package/foundation/discovery/template-adapter.d.mts +14 -5
- package/foundation/discovery/template-adapter.fixture-refs.test.mjs +248 -0
- package/foundation/discovery/template-adapter.integration-isolation.test.mjs +94 -0
- package/foundation/discovery/template-adapter.mjs +292 -25
- package/foundation/discovery/theming-targets.test.mjs +4 -0
- package/foundation/fs/module-loader.d.mts +1 -0
- package/foundation/fs/module-loader.mjs +50 -1
- package/foundation/fs/module-loader.stdout.test.mjs +332 -0
- package/foundation/fs/path-safety.d.mts +3 -2
- package/foundation/fs/path-safety.mjs +49 -19
- package/foundation/fs/path-safety.test.mjs +50 -0
- package/foundation/fs/publish-file-hardlink-unavailable.test.mjs +129 -94
- package/foundation/integrations/autolink.mjs +6 -1
- package/foundation/response/base.d.ts +8 -4
- package/foundation/response/error-codes.doc.mjs +1 -2
- package/foundation/response/error-codes.mjs +1 -1
- package/foundation/response/error-codes.test.mjs +83 -0
- package/foundation/response/json-contract.test.mjs +11 -0
- package/foundation/response/json.d.mts +4 -2
- package/foundation/response/json.mjs +8 -10
- package/foundation/response/response-types.doc.mjs +10 -10
- package/foundation/response/response-types.doc.test.mjs +158 -0
- package/foundation/xle/expand.d.mts +2 -0
- package/foundation/xle/expand.mjs +3 -2
- package/foundation/xle/expand.test.mjs +54 -0
- package/package.json +9 -9
- package/clients/cli/lib/update-check.mjs +0 -83
- package/clients/cli/lib/update-check.test.mjs +0 -137
- package/clients/cli/update-hint-commands.test.mjs +0 -54
|
@@ -1,22 +1,31 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @file Path-safety regression tests for
|
|
4
|
+
* @file Path-safety regression tests for agent-doc writes.
|
|
5
5
|
*
|
|
6
6
|
* `installAgentDocs(targetDir, {paths})` previously joined each path
|
|
7
7
|
* onto `targetDir` with no validation, so:
|
|
8
8
|
* - `../OUT.md` wrote outside `targetDir`
|
|
9
9
|
* - `/tmp/x.md` was silently re-rooted under `targetDir`
|
|
10
10
|
*
|
|
11
|
-
*
|
|
11
|
+
* Auto-detected and preset files were never checked at all, so a `CLAUDE.md`
|
|
12
|
+
* or `.claude/` symlinked out of the project had the block written through
|
|
13
|
+
* it. Every case now throws PathSafetyError before any file is touched.
|
|
14
|
+
*
|
|
15
|
+
* `removeAgentDocs` (`init --remove-agents`) stripped or deleted a block
|
|
16
|
+
* through the same kind of link and reported success. It now refuses with
|
|
17
|
+
* `ERR_PATH_TRAVERSAL` before any file is touched.
|
|
12
18
|
*/
|
|
13
19
|
|
|
14
|
-
import {describe, it, expect, beforeEach, afterEach} from 'vitest';
|
|
20
|
+
import {describe, it, expect, beforeEach, afterEach, vi} from 'vitest';
|
|
15
21
|
import * as fs from 'node:fs';
|
|
16
22
|
import * as path from 'node:path';
|
|
17
23
|
import * as os from 'node:os';
|
|
18
|
-
import {installAgentDocs} from './agent-docs.mjs';
|
|
24
|
+
import {installAgentDocs, removeAgentDocs} from './agent-docs.mjs';
|
|
19
25
|
import {PathSafetyError} from '../fs/path-safety.mjs';
|
|
26
|
+
import {runCli} from '../../test-utils/run-cli.mjs';
|
|
27
|
+
|
|
28
|
+
const BLOCK = '<!-- ASTRYX:START -->\nmanaged\n<!-- ASTRYX:END -->';
|
|
20
29
|
|
|
21
30
|
let tmpDir;
|
|
22
31
|
beforeEach(() => {
|
|
@@ -26,6 +35,28 @@ afterEach(() => {
|
|
|
26
35
|
fs.rmSync(tmpDir, {recursive: true, force: true});
|
|
27
36
|
});
|
|
28
37
|
|
|
38
|
+
/** A project dir plus a sibling dir outside it. */
|
|
39
|
+
function layout() {
|
|
40
|
+
const project = path.join(tmpDir, 'project');
|
|
41
|
+
const outside = path.join(tmpDir, 'outside');
|
|
42
|
+
fs.mkdirSync(project, {recursive: true});
|
|
43
|
+
fs.mkdirSync(outside, {recursive: true});
|
|
44
|
+
return {project, outside};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @param {() => unknown} fn
|
|
49
|
+
* @returns {unknown} what `fn` threw
|
|
50
|
+
*/
|
|
51
|
+
function thrownBy(fn) {
|
|
52
|
+
try {
|
|
53
|
+
fn();
|
|
54
|
+
} catch (err) {
|
|
55
|
+
return err;
|
|
56
|
+
}
|
|
57
|
+
throw new Error('expected a throw');
|
|
58
|
+
}
|
|
59
|
+
|
|
29
60
|
describe('installAgentDocs path safety', () => {
|
|
30
61
|
it('rejects --agent-docs-path that escapes the target directory', () => {
|
|
31
62
|
const target = path.join(tmpDir, 'project');
|
|
@@ -64,3 +95,234 @@ describe('installAgentDocs path safety', () => {
|
|
|
64
95
|
expect(fs.existsSync(path.join(tmpDir, 'escaped.md'))).toBe(false);
|
|
65
96
|
});
|
|
66
97
|
});
|
|
98
|
+
|
|
99
|
+
describe('installAgentDocs never writes through a symlink out of the project', () => {
|
|
100
|
+
it('refuses an auto-detected file that links outside', () => {
|
|
101
|
+
const {project, outside} = layout();
|
|
102
|
+
const shared = path.join(outside, 'CLAUDE.md');
|
|
103
|
+
fs.writeFileSync(shared, '# Shared\n');
|
|
104
|
+
fs.symlinkSync(shared, path.join(project, 'CLAUDE.md'));
|
|
105
|
+
|
|
106
|
+
expect(() => installAgentDocs(project, {renderedBlock: BLOCK})).toThrow(
|
|
107
|
+
/outside the project root/,
|
|
108
|
+
);
|
|
109
|
+
expect(fs.readFileSync(shared, 'utf-8')).toBe('# Shared\n');
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it('refuses a preset file reached through a symlinked directory', () => {
|
|
113
|
+
const {project, outside} = layout();
|
|
114
|
+
fs.symlinkSync(outside, path.join(project, '.claude'));
|
|
115
|
+
|
|
116
|
+
expect(() =>
|
|
117
|
+
installAgentDocs(project, {agent: 'claude', renderedBlock: BLOCK}),
|
|
118
|
+
).toThrow(PathSafetyError);
|
|
119
|
+
expect(fs.readdirSync(outside)).toEqual([]);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it('refuses an existing preset file that links outside', () => {
|
|
123
|
+
const {project, outside} = layout();
|
|
124
|
+
const shared = path.join(outside, 'rules');
|
|
125
|
+
fs.writeFileSync(shared, 'rules\n');
|
|
126
|
+
fs.symlinkSync(shared, path.join(project, '.cursorrules'));
|
|
127
|
+
|
|
128
|
+
expect(() =>
|
|
129
|
+
installAgentDocs(project, {agent: 'cursor', renderedBlock: BLOCK}),
|
|
130
|
+
).toThrow(PathSafetyError);
|
|
131
|
+
expect(fs.readFileSync(shared, 'utf-8')).toBe('rules\n');
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it('writes nothing when any file of the set escapes', () => {
|
|
135
|
+
const {project, outside} = layout();
|
|
136
|
+
fs.writeFileSync(path.join(project, 'AGENTS.md'), '# Agents\n');
|
|
137
|
+
const shared = path.join(outside, 'CLAUDE.md');
|
|
138
|
+
fs.writeFileSync(shared, '# Shared\n');
|
|
139
|
+
fs.symlinkSync(shared, path.join(project, 'CLAUDE.md'));
|
|
140
|
+
|
|
141
|
+
expect(() => installAgentDocs(project, {renderedBlock: BLOCK})).toThrow(
|
|
142
|
+
PathSafetyError,
|
|
143
|
+
);
|
|
144
|
+
expect(fs.readFileSync(path.join(project, 'AGENTS.md'), 'utf-8')).toBe(
|
|
145
|
+
'# Agents\n',
|
|
146
|
+
);
|
|
147
|
+
expect(fs.readFileSync(shared, 'utf-8')).toBe('# Shared\n');
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it('refuses to refresh a managed block that lives outside', () => {
|
|
151
|
+
const {project, outside} = layout();
|
|
152
|
+
const shared = path.join(outside, 'CLAUDE.md');
|
|
153
|
+
fs.writeFileSync(shared, `# Shared\n\n${BLOCK.replace('managed', 'old')}\n`);
|
|
154
|
+
const before = fs.readFileSync(shared, 'utf-8');
|
|
155
|
+
fs.symlinkSync(shared, path.join(project, 'CLAUDE.md'));
|
|
156
|
+
|
|
157
|
+
expect(() =>
|
|
158
|
+
installAgentDocs(project, {onlyReplace: true, renderedBlock: BLOCK}),
|
|
159
|
+
).toThrow(PathSafetyError);
|
|
160
|
+
expect(fs.readFileSync(shared, 'utf-8')).toBe(before);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
it('refuses to strip a duplicate block from a wrapper that links outside', () => {
|
|
164
|
+
const {project, outside} = layout();
|
|
165
|
+
fs.writeFileSync(path.join(project, 'AGENTS.md'), `# Agents\n\n${BLOCK}\n`);
|
|
166
|
+
const shared = path.join(outside, 'CLAUDE.md');
|
|
167
|
+
fs.writeFileSync(shared, `@AGENTS.md\n\n${BLOCK}\n`);
|
|
168
|
+
fs.symlinkSync(shared, path.join(project, 'CLAUDE.md'));
|
|
169
|
+
|
|
170
|
+
expect(() => installAgentDocs(project, {renderedBlock: BLOCK})).toThrow(
|
|
171
|
+
PathSafetyError,
|
|
172
|
+
);
|
|
173
|
+
expect(fs.readFileSync(shared, 'utf-8')).toBe(`@AGENTS.md\n\n${BLOCK}\n`);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
it('still refreshes in-project blocks beside an unmarked outside link it skips', () => {
|
|
177
|
+
const {project, outside} = layout();
|
|
178
|
+
fs.writeFileSync(
|
|
179
|
+
path.join(project, 'AGENTS.md'),
|
|
180
|
+
`# Agents\n\n${BLOCK.replace('managed', 'old')}\n`,
|
|
181
|
+
);
|
|
182
|
+
const shared = path.join(outside, 'rules');
|
|
183
|
+
fs.writeFileSync(shared, 'rules\n');
|
|
184
|
+
fs.symlinkSync(shared, path.join(project, '.cursorrules'));
|
|
185
|
+
|
|
186
|
+
expect(
|
|
187
|
+
installAgentDocs(project, {onlyReplace: true, renderedBlock: BLOCK}),
|
|
188
|
+
).toEqual(['AGENTS.md']);
|
|
189
|
+
expect(fs.readFileSync(path.join(project, 'AGENTS.md'), 'utf-8')).toContain(
|
|
190
|
+
'managed',
|
|
191
|
+
);
|
|
192
|
+
expect(fs.readFileSync(shared, 'utf-8')).toBe('rules\n');
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
it('writes through a symlink that stays inside the project', () => {
|
|
196
|
+
const {project} = layout();
|
|
197
|
+
fs.writeFileSync(path.join(project, 'AGENTS.md'), '# Agents\n');
|
|
198
|
+
fs.symlinkSync('AGENTS.md', path.join(project, 'CLAUDE.md'));
|
|
199
|
+
|
|
200
|
+
expect(installAgentDocs(project, {renderedBlock: BLOCK})).toEqual([
|
|
201
|
+
'AGENTS.md',
|
|
202
|
+
'CLAUDE.md',
|
|
203
|
+
]);
|
|
204
|
+
const content = fs.readFileSync(path.join(project, 'AGENTS.md'), 'utf-8');
|
|
205
|
+
expect(content.split('<!-- ASTRYX:START -->')).toHaveLength(2);
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
describe('init --features agents with an agent doc linked outside the project', () => {
|
|
210
|
+
it('writes nothing outside, reports path-safety, and exits 1 in both modes', async () => {
|
|
211
|
+
const project = path.join(tmpDir, 'project');
|
|
212
|
+
const outside = path.join(tmpDir, 'outside');
|
|
213
|
+
fs.mkdirSync(project, {recursive: true});
|
|
214
|
+
fs.mkdirSync(outside, {recursive: true});
|
|
215
|
+
fs.writeFileSync(path.join(project, 'package.json'), '{"name":"app"}\n');
|
|
216
|
+
const shared = path.join(outside, 'CLAUDE.md');
|
|
217
|
+
fs.writeFileSync(shared, '# Shared\n');
|
|
218
|
+
fs.symlinkSync(shared, path.join(project, 'CLAUDE.md'));
|
|
219
|
+
|
|
220
|
+
const json = await runCli(['init', '--features', 'agents', '--json'], project);
|
|
221
|
+
expect(json.status).toBe(1);
|
|
222
|
+
const env = JSON.parse(json.stdout);
|
|
223
|
+
expect(env.type).toBe('init.run');
|
|
224
|
+
expect(env.data.docsError).toMatchObject({kind: 'path-safety'});
|
|
225
|
+
|
|
226
|
+
const text = await runCli(['init', '--features', 'agents'], project);
|
|
227
|
+
expect(text.status).toBe(1);
|
|
228
|
+
|
|
229
|
+
expect(fs.readFileSync(shared, 'utf-8')).toBe('# Shared\n');
|
|
230
|
+
}, 30_000);
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
describe('removeAgentDocs never changes a file out of the project', () => {
|
|
234
|
+
beforeEach(() => {
|
|
235
|
+
vi.spyOn(console, 'log').mockImplementation(() => {});
|
|
236
|
+
});
|
|
237
|
+
afterEach(() => {
|
|
238
|
+
vi.restoreAllMocks();
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
it('refuses to strip a block from a file that links outside', () => {
|
|
242
|
+
const {project, outside} = layout();
|
|
243
|
+
const shared = path.join(outside, 'CLAUDE.md');
|
|
244
|
+
fs.writeFileSync(shared, `# Shared\n\n${BLOCK}\n`);
|
|
245
|
+
fs.symlinkSync(shared, path.join(project, 'CLAUDE.md'));
|
|
246
|
+
|
|
247
|
+
const err = thrownBy(() => removeAgentDocs(project));
|
|
248
|
+
expect(err).toBeInstanceOf(PathSafetyError);
|
|
249
|
+
expect(err).toMatchObject({code: 'ERR_PATH_TRAVERSAL'});
|
|
250
|
+
expect(fs.readFileSync(shared, 'utf-8')).toBe(`# Shared\n\n${BLOCK}\n`);
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
it('refuses to delete a file reached through a symlinked directory', () => {
|
|
254
|
+
const {project, outside} = layout();
|
|
255
|
+
const shared = path.join(outside, 'CLAUDE.md');
|
|
256
|
+
const content = `# CLAUDE\n\nProject-specific guidance for AI coding agents.\n\n${BLOCK}\n`;
|
|
257
|
+
fs.writeFileSync(shared, content);
|
|
258
|
+
fs.symlinkSync(outside, path.join(project, '.claude'));
|
|
259
|
+
|
|
260
|
+
expect(thrownBy(() => removeAgentDocs(project))).toMatchObject({
|
|
261
|
+
code: 'ERR_PATH_TRAVERSAL',
|
|
262
|
+
});
|
|
263
|
+
expect(fs.readFileSync(shared, 'utf-8')).toBe(content);
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
it('changes nothing when any file of the set escapes', () => {
|
|
267
|
+
const {project, outside} = layout();
|
|
268
|
+
const agents = `# Agents\n\nkeep\n\n${BLOCK}\n`;
|
|
269
|
+
fs.writeFileSync(path.join(project, 'AGENTS.md'), agents);
|
|
270
|
+
const shared = path.join(outside, 'CLAUDE.md');
|
|
271
|
+
fs.writeFileSync(shared, `# Shared\n\n${BLOCK}\n`);
|
|
272
|
+
fs.symlinkSync(shared, path.join(project, 'CLAUDE.md'));
|
|
273
|
+
|
|
274
|
+
expect(thrownBy(() => removeAgentDocs(project))).toBeInstanceOf(PathSafetyError);
|
|
275
|
+
expect(fs.readFileSync(path.join(project, 'AGENTS.md'), 'utf-8')).toBe(agents);
|
|
276
|
+
expect(fs.readFileSync(shared, 'utf-8')).toBe(`# Shared\n\n${BLOCK}\n`);
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
it('still strips in-project blocks beside an unmarked outside link it skips', () => {
|
|
280
|
+
const {project, outside} = layout();
|
|
281
|
+
fs.writeFileSync(path.join(project, 'AGENTS.md'), `# Agents\n\nkeep\n\n${BLOCK}\n`);
|
|
282
|
+
const shared = path.join(outside, 'rules');
|
|
283
|
+
fs.writeFileSync(shared, 'rules\n');
|
|
284
|
+
fs.symlinkSync(shared, path.join(project, '.cursorrules'));
|
|
285
|
+
|
|
286
|
+
removeAgentDocs(project);
|
|
287
|
+
expect(fs.readFileSync(path.join(project, 'AGENTS.md'), 'utf-8')).toBe(
|
|
288
|
+
'# Agents\n\nkeep\n',
|
|
289
|
+
);
|
|
290
|
+
expect(fs.readFileSync(shared, 'utf-8')).toBe('rules\n');
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
it('strips through a symlink that stays inside the project', () => {
|
|
294
|
+
const {project} = layout();
|
|
295
|
+
fs.writeFileSync(path.join(project, 'AGENTS.md'), `# Agents\n\nkeep\n\n${BLOCK}\n`);
|
|
296
|
+
fs.symlinkSync('AGENTS.md', path.join(project, 'CLAUDE.md'));
|
|
297
|
+
|
|
298
|
+
removeAgentDocs(project);
|
|
299
|
+
expect(fs.readFileSync(path.join(project, 'AGENTS.md'), 'utf-8')).toBe(
|
|
300
|
+
'# Agents\n\nkeep\n',
|
|
301
|
+
);
|
|
302
|
+
});
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
describe('init --remove-agents with an agent doc linked outside the project', () => {
|
|
306
|
+
it('changes nothing outside, fails with ERR_PATH_TRAVERSAL, and exits 1 in both modes', async () => {
|
|
307
|
+
const {project, outside} = layout();
|
|
308
|
+
fs.writeFileSync(path.join(project, 'package.json'), '{"name":"app"}\n');
|
|
309
|
+
const shared = path.join(outside, 'CLAUDE.md');
|
|
310
|
+
const content = `# Shared\n\n${BLOCK}\n`;
|
|
311
|
+
fs.writeFileSync(shared, content);
|
|
312
|
+
fs.symlinkSync(shared, path.join(project, 'CLAUDE.md'));
|
|
313
|
+
|
|
314
|
+
const json = await runCli(['init', '--remove-agents', '--json'], project);
|
|
315
|
+
expect(json.status).toBe(1);
|
|
316
|
+
const env = JSON.parse(json.stdout);
|
|
317
|
+
expect(env).toMatchObject({apiVersion: 1, code: 'ERR_PATH_TRAVERSAL'});
|
|
318
|
+
expect(env.error).toMatch(/"CLAUDE\.md": resolves outside the project root/);
|
|
319
|
+
expect(env).not.toHaveProperty('data');
|
|
320
|
+
|
|
321
|
+
const text = await runCli(['init', '--remove-agents'], project);
|
|
322
|
+
expect(text.status).toBe(1);
|
|
323
|
+
expect(text.stderr).toMatch(/^Error: .*"CLAUDE\.md": resolves outside the project root/m);
|
|
324
|
+
expect(text.stdout).not.toMatch(/removed/i);
|
|
325
|
+
|
|
326
|
+
expect(fs.readFileSync(shared, 'utf-8')).toBe(content);
|
|
327
|
+
}, 30_000);
|
|
328
|
+
});
|
|
@@ -63,11 +63,18 @@ function config(integrations, ownHandler = false) {
|
|
|
63
63
|
);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
/**
|
|
67
|
-
|
|
66
|
+
/**
|
|
67
|
+
* @param {Record<string, unknown>} [astryx]
|
|
68
|
+
* @param {Record<string, string>} [dependencies]
|
|
69
|
+
*/
|
|
70
|
+
function packageJson(astryx, dependencies) {
|
|
68
71
|
fs.writeFileSync(
|
|
69
72
|
path.join(tmpDir, 'package.json'),
|
|
70
|
-
JSON.stringify({
|
|
73
|
+
JSON.stringify({
|
|
74
|
+
name: 'consumer',
|
|
75
|
+
...(dependencies ? {dependencies} : {}),
|
|
76
|
+
...(astryx ? {astryx} : {}),
|
|
77
|
+
}),
|
|
71
78
|
);
|
|
72
79
|
}
|
|
73
80
|
|
|
@@ -172,6 +179,24 @@ describe('an app can refuse an inherited handler', () => {
|
|
|
172
179
|
|
|
173
180
|
expect(fired()).toEqual(['reporting-integration']);
|
|
174
181
|
});
|
|
182
|
+
|
|
183
|
+
it('keeps an autolinked handler in a project with no astryx.config', async () => {
|
|
184
|
+
packageJson(undefined, {'reporting-integration': '1.0.0'});
|
|
185
|
+
integration('reporting-integration');
|
|
186
|
+
|
|
187
|
+
await runOneCommand();
|
|
188
|
+
|
|
189
|
+
expect(fired()).toEqual(['reporting-integration']);
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
it('drops an autolinked handler under astryx.inheritDebug false with no astryx.config', async () => {
|
|
193
|
+
packageJson({inheritDebug: false}, {'reporting-integration': '1.0.0'});
|
|
194
|
+
integration('reporting-integration');
|
|
195
|
+
|
|
196
|
+
await runOneCommand();
|
|
197
|
+
|
|
198
|
+
expect(fired()).toEqual([]);
|
|
199
|
+
});
|
|
175
200
|
});
|
|
176
201
|
|
|
177
202
|
describe('loading the project twice delivers once', () => {
|
|
@@ -39,6 +39,7 @@ import {
|
|
|
39
39
|
loadIntegrations,
|
|
40
40
|
loadLocalIntegration,
|
|
41
41
|
markProviderConflicts,
|
|
42
|
+
resolvePackageDir,
|
|
42
43
|
} from '../integrations/integrations.mjs';
|
|
43
44
|
import {autolinkIntegrations} from '../integrations/autolink.mjs';
|
|
44
45
|
import {
|
|
@@ -95,6 +96,118 @@ function errorMessage(err) {
|
|
|
95
96
|
return message == null ? String(err) : String(message);
|
|
96
97
|
}
|
|
97
98
|
|
|
99
|
+
/**
|
|
100
|
+
* Load the configured integrations one at a time, so a package that cannot
|
|
101
|
+
* load at all (not installed, no manifest, more than one manifest, not a bare
|
|
102
|
+
* name) becomes that entry's load-error marker instead of failing the project.
|
|
103
|
+
* @param {string[]} specs
|
|
104
|
+
* @param {{cwd: string, fresh: boolean}} options
|
|
105
|
+
* @returns {Promise<import('../integrations/integrations.mjs').LoadedIntegration[]>}
|
|
106
|
+
*/
|
|
107
|
+
async function loadConfiguredIntegrations(specs, {cwd, fresh}) {
|
|
108
|
+
/** @type {import('../integrations/integrations.mjs').LoadedIntegration[]} */
|
|
109
|
+
const loaded = [];
|
|
110
|
+
const seen = new Set();
|
|
111
|
+
for (const spec of specs) {
|
|
112
|
+
if (!spec || seen.has(spec)) continue;
|
|
113
|
+
seen.add(spec);
|
|
114
|
+
try {
|
|
115
|
+
loaded.push(
|
|
116
|
+
...(await loadIntegrations([spec], {
|
|
117
|
+
cwd,
|
|
118
|
+
fresh,
|
|
119
|
+
resolveProviders: false,
|
|
120
|
+
})),
|
|
121
|
+
);
|
|
122
|
+
} catch (err) {
|
|
123
|
+
/** @type {string|undefined} */
|
|
124
|
+
let packageDir;
|
|
125
|
+
try {
|
|
126
|
+
packageDir = resolvePackageDir(spec, cwd);
|
|
127
|
+
} catch {
|
|
128
|
+
// Not a bare package name: there is no install location to record.
|
|
129
|
+
}
|
|
130
|
+
const pkg = packageDir ? readPackageJson(packageDir) : null;
|
|
131
|
+
loaded.push(
|
|
132
|
+
loadErrorMarker({
|
|
133
|
+
name: packageName(pkg) ?? spec,
|
|
134
|
+
version: pkg?.version,
|
|
135
|
+
spec,
|
|
136
|
+
packageDir,
|
|
137
|
+
err,
|
|
138
|
+
}),
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return loaded;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Resolve the package being authored. Every failure, including an unreadable
|
|
147
|
+
* package.json or more than one manifest, becomes its load-error marker.
|
|
148
|
+
* @param {string} projectDir
|
|
149
|
+
* @param {boolean} fresh
|
|
150
|
+
* @returns {Promise<import('../integrations/integrations.mjs').LoadedIntegration|null>}
|
|
151
|
+
*/
|
|
152
|
+
async function loadLocalIntegrationSafely(projectDir, fresh) {
|
|
153
|
+
try {
|
|
154
|
+
return await loadLocalIntegration(projectDir, {fresh});
|
|
155
|
+
} catch (err) {
|
|
156
|
+
const pkg = readPackageJson(projectDir);
|
|
157
|
+
const name = packageName(pkg) ?? '(local integration)';
|
|
158
|
+
return {
|
|
159
|
+
...loadErrorMarker({
|
|
160
|
+
name,
|
|
161
|
+
version: pkg?.version,
|
|
162
|
+
spec: name,
|
|
163
|
+
packageDir: projectDir,
|
|
164
|
+
err,
|
|
165
|
+
}),
|
|
166
|
+
__local: true,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* An inert entry for an integration that could not be loaded. It contributes
|
|
173
|
+
* nothing; Project reports its `__loadError` as the package's issue.
|
|
174
|
+
* @param {{name: string, version?: unknown, spec: string, packageDir?: string, err: unknown}} input
|
|
175
|
+
* @returns {import('../integrations/integrations.mjs').LoadedIntegration}
|
|
176
|
+
*/
|
|
177
|
+
function loadErrorMarker({name, version, spec, packageDir, err}) {
|
|
178
|
+
return /** @type {import('../integrations/integrations.mjs').LoadedIntegration} */ ({
|
|
179
|
+
name,
|
|
180
|
+
...(typeof version === 'string' ? {version} : {}),
|
|
181
|
+
__spec: spec,
|
|
182
|
+
...(packageDir ? {__packageDir: packageDir} : {}),
|
|
183
|
+
__loadError: errorMessage(err),
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* @param {Record<string, unknown>|null} pkg
|
|
189
|
+
* @returns {string|undefined}
|
|
190
|
+
*/
|
|
191
|
+
function packageName(pkg) {
|
|
192
|
+
const name = pkg?.name;
|
|
193
|
+
return typeof name === 'string' && name.length > 0 ? name : undefined;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* @param {string} dir
|
|
198
|
+
* @returns {Record<string, unknown>|null}
|
|
199
|
+
*/
|
|
200
|
+
function readPackageJson(dir) {
|
|
201
|
+
try {
|
|
202
|
+
const pkg = JSON.parse(
|
|
203
|
+
fs.readFileSync(path.join(dir, 'package.json'), 'utf-8'),
|
|
204
|
+
);
|
|
205
|
+
return pkg && typeof pkg === 'object' ? pkg : null;
|
|
206
|
+
} catch {
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
98
211
|
/**
|
|
99
212
|
* An integration issue tagged with the owner package. The base
|
|
100
213
|
* {@link import('../integrations/issue').AstryxIntegrationIssue} fields plus the
|
|
@@ -147,13 +260,15 @@ function findPackageRoot(startDir) {
|
|
|
147
260
|
*
|
|
148
261
|
* This governs INHERITED handlers only. A project's own `debug` always runs.
|
|
149
262
|
*
|
|
150
|
-
*
|
|
263
|
+
* Read from the project root whether or not an astryx.config exists: an
|
|
264
|
+
* autolinked integration contributes a handler with no config at all.
|
|
265
|
+
*
|
|
266
|
+
* @param {string} projectDir directory holding the project's package.json
|
|
151
267
|
* @returns {boolean}
|
|
152
268
|
*/
|
|
153
|
-
function inheritsIntegrationDebug(
|
|
154
|
-
if (!configPath) return true;
|
|
269
|
+
function inheritsIntegrationDebug(projectDir) {
|
|
155
270
|
try {
|
|
156
|
-
const pkgPath = path.join(
|
|
271
|
+
const pkgPath = path.join(projectDir, 'package.json');
|
|
157
272
|
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
|
158
273
|
return pkg?.astryx?.inheritDebug !== false;
|
|
159
274
|
} catch {
|
|
@@ -276,11 +391,10 @@ export class Project {
|
|
|
276
391
|
fresh,
|
|
277
392
|
});
|
|
278
393
|
integrations = config.integrations ?? [];
|
|
279
|
-
|
|
394
|
+
// Provider identity is resolved once, below, over the final set.
|
|
395
|
+
loadedIntegrations = await loadConfiguredIntegrations(integrations, {
|
|
280
396
|
cwd: projectDir,
|
|
281
397
|
fresh,
|
|
282
|
-
// Provider identity is resolved once, below, over the final set.
|
|
283
|
-
resolveProviders: false,
|
|
284
398
|
});
|
|
285
399
|
}
|
|
286
400
|
|
|
@@ -305,7 +419,7 @@ export class Project {
|
|
|
305
419
|
// existing consumer command doubles as the author's preview. A local copy
|
|
306
420
|
// replaces the same installed package in place, preserving configured
|
|
307
421
|
// precedence while making the source being edited authoritative.
|
|
308
|
-
const localIntegration = await
|
|
422
|
+
const localIntegration = await loadLocalIntegrationSafely(projectDir, fresh);
|
|
309
423
|
if (localIntegration) {
|
|
310
424
|
const existing = loadedIntegrations.findIndex(
|
|
311
425
|
integration => integration.name === localIntegration.name,
|
|
@@ -335,7 +449,7 @@ export class Project {
|
|
|
335
449
|
// because Project.load can run more than once in a process and appending
|
|
336
450
|
// would deliver twice.
|
|
337
451
|
setDebugIntegrationEventHandlers(
|
|
338
|
-
inheritsIntegrationDebug(
|
|
452
|
+
inheritsIntegrationDebug(projectDir)
|
|
339
453
|
? loadedIntegrations.map(integration => integration.__debug)
|
|
340
454
|
: [],
|
|
341
455
|
);
|
|
@@ -515,6 +515,132 @@ describe('Project issues (skip + warn)', () => {
|
|
|
515
515
|
});
|
|
516
516
|
});
|
|
517
517
|
|
|
518
|
+
describe('Project loads each integration in isolation', () => {
|
|
519
|
+
/**
|
|
520
|
+
* Install a package under node_modules with the given root files.
|
|
521
|
+
* @param {string} name
|
|
522
|
+
* @param {string[]} manifests manifest basenames to write
|
|
523
|
+
*/
|
|
524
|
+
function installPackage(name, manifests) {
|
|
525
|
+
const dir = path.join(tmpDir, 'node_modules', ...name.split('/'));
|
|
526
|
+
fs.mkdirSync(dir, {recursive: true});
|
|
527
|
+
fs.writeFileSync(
|
|
528
|
+
path.join(dir, 'package.json'),
|
|
529
|
+
JSON.stringify({name, version: '1.0.0'}),
|
|
530
|
+
);
|
|
531
|
+
for (const file of manifests) {
|
|
532
|
+
fs.writeFileSync(path.join(dir, file), 'export default {};\n');
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
/** @param {string[]} integrations */
|
|
537
|
+
function writeConfig(integrations) {
|
|
538
|
+
fs.writeFileSync(
|
|
539
|
+
path.join(tmpDir, 'astryx.config.mjs'),
|
|
540
|
+
`export default ${JSON.stringify({integrations})};\n`,
|
|
541
|
+
);
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
/** @param {Project} project */
|
|
545
|
+
async function widgetComponents(project) {
|
|
546
|
+
return (await project.components())
|
|
547
|
+
.filter(component => component.package === '@acme/widgets')
|
|
548
|
+
.map(component => component.name);
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
it.each([
|
|
552
|
+
['is not installed', '@acme/broken', () => {}, /Install it first/],
|
|
553
|
+
[
|
|
554
|
+
'has no root manifest',
|
|
555
|
+
'@acme/broken',
|
|
556
|
+
() => installPackage('@acme/broken', []),
|
|
557
|
+
/no conventional root manifest/,
|
|
558
|
+
],
|
|
559
|
+
[
|
|
560
|
+
'has two root manifests',
|
|
561
|
+
'@acme/broken',
|
|
562
|
+
() =>
|
|
563
|
+
installPackage('@acme/broken', [
|
|
564
|
+
'astryx.integration.mjs',
|
|
565
|
+
'astryx.integration.js',
|
|
566
|
+
]),
|
|
567
|
+
/multiple root manifests/,
|
|
568
|
+
],
|
|
569
|
+
[
|
|
570
|
+
'is not a bare package name',
|
|
571
|
+
'../escape',
|
|
572
|
+
() => {},
|
|
573
|
+
/Invalid integration package name/,
|
|
574
|
+
],
|
|
575
|
+
])(
|
|
576
|
+
'keeps the others when a configured package %s',
|
|
577
|
+
async (_label, spec, install, message) => {
|
|
578
|
+
scaffold();
|
|
579
|
+
install();
|
|
580
|
+
writeConfig([spec, '@acme/widgets']);
|
|
581
|
+
|
|
582
|
+
const project = await Project.load(tmpDir);
|
|
583
|
+
|
|
584
|
+
expect(await widgetComponents(project)).toEqual(['Widget']);
|
|
585
|
+
expect(await project.issues()).toContainEqual(
|
|
586
|
+
expect.objectContaining({
|
|
587
|
+
package: spec,
|
|
588
|
+
code: 'integration_error',
|
|
589
|
+
message: expect.stringMatching(message),
|
|
590
|
+
}),
|
|
591
|
+
);
|
|
592
|
+
},
|
|
593
|
+
);
|
|
594
|
+
|
|
595
|
+
it('keeps configured integrations when the package being authored has two root manifests', async () => {
|
|
596
|
+
scaffold();
|
|
597
|
+
fs.writeFileSync(
|
|
598
|
+
path.join(tmpDir, 'package.json'),
|
|
599
|
+
JSON.stringify({name: '@acme/local', version: '1.0.0'}),
|
|
600
|
+
);
|
|
601
|
+
fs.writeFileSync(
|
|
602
|
+
path.join(tmpDir, 'astryx.integration.mjs'),
|
|
603
|
+
'export default {};\n',
|
|
604
|
+
);
|
|
605
|
+
fs.writeFileSync(
|
|
606
|
+
path.join(tmpDir, 'astryx.integration.js'),
|
|
607
|
+
'export default {};\n',
|
|
608
|
+
);
|
|
609
|
+
|
|
610
|
+
const project = await Project.load(tmpDir);
|
|
611
|
+
|
|
612
|
+
expect(await widgetComponents(project)).toEqual(['Widget']);
|
|
613
|
+
expect(await project.issues()).toContainEqual(
|
|
614
|
+
expect.objectContaining({
|
|
615
|
+
package: '@acme/local',
|
|
616
|
+
code: 'integration_error',
|
|
617
|
+
message: expect.stringMatching(/multiple root manifests/),
|
|
618
|
+
}),
|
|
619
|
+
);
|
|
620
|
+
});
|
|
621
|
+
|
|
622
|
+
it('puts the package being authored at its configured position when the config names it', async () => {
|
|
623
|
+
scaffold();
|
|
624
|
+
scaffoldLocalPackage({name: '@acme/local'});
|
|
625
|
+
writeConfig(['@acme/local', '@acme/widgets']);
|
|
626
|
+
|
|
627
|
+
const project = await Project.load(tmpDir);
|
|
628
|
+
|
|
629
|
+
expect(
|
|
630
|
+
project.loadedIntegrations.map(integration => [
|
|
631
|
+
integration.name,
|
|
632
|
+
Boolean(integration.__local),
|
|
633
|
+
]),
|
|
634
|
+
).toEqual([
|
|
635
|
+
['@acme/local', true],
|
|
636
|
+
['@acme/widgets', false],
|
|
637
|
+
]);
|
|
638
|
+
expect(await project.issues()).not.toContainEqual(
|
|
639
|
+
expect.objectContaining({package: '@acme/local', code: 'integration_error'}),
|
|
640
|
+
);
|
|
641
|
+
});
|
|
642
|
+
});
|
|
643
|
+
|
|
518
644
|
describe('Project.issuesUrl routing', () => {
|
|
519
645
|
it('routes core to config.issuesUrl, falling back to the default', async () => {
|
|
520
646
|
scaffold({issuesUrl: 'https://example.com/core'});
|
|
@@ -11,11 +11,20 @@ export function pkgOf(t: {
|
|
|
11
11
|
package?: string;
|
|
12
12
|
}): string;
|
|
13
13
|
/**
|
|
14
|
-
* Replace
|
|
15
|
-
* render with zero setup. Images get a self-contained data
|
|
16
|
-
* (which have no equivalent inline placeholder — see
|
|
17
|
-
* stripped to an empty src instead of being
|
|
18
|
-
* Builders drop in their own media either way.
|
|
14
|
+
* Replace each Astryx template fixture reference with a placeholder so
|
|
15
|
+
* scaffolded pages render with zero setup. Images get a self-contained data
|
|
16
|
+
* URI; videos (which have no equivalent inline placeholder — see
|
|
17
|
+
* VIDEO_EXTENSIONS) are stripped to an empty src instead of being
|
|
18
|
+
* mis-replaced with image data. Builders drop in their own media either way.
|
|
19
|
+
*
|
|
20
|
+
* A reference is a URL token that resolves to a root-relative path under
|
|
21
|
+
* FIXTURE_SEGMENT. It is replaced whole, query and fragment included, and
|
|
22
|
+
* classified by the suffix of its last path segment. A reference that cannot
|
|
23
|
+
* be replaced safely throws with its path rather than being guessed at or
|
|
24
|
+
* left behind. Prose is left as written: in text (JSX text, a word inside a
|
|
25
|
+
* longer string) trailing punctuation is not part of a path and a path with
|
|
26
|
+
* no suffix, such as the bare directory, is a mention; inside a comment
|
|
27
|
+
* nothing throws.
|
|
19
28
|
*
|
|
20
29
|
* @param {string} source - Template source code.
|
|
21
30
|
* @returns {string} Source with demo asset references replaced.
|