@snap/valdi 1.1.7 → 1.2.1
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/.metadata/.bazelrc.template +9 -7
- package/.metadata/AGENTS.md.template +7 -0
- package/.metadata/MODULE.bazel.template +47 -3
- package/.metadata/README.md.template +2 -2
- package/.metadata/bzl/patches/rules_python/1.9.0/BUILD.bazel.template +1 -0
- package/.metadata/bzl/patches/rules_python/1.9.0/remove_setuptools_spaces.patch.template +96 -0
- package/.metadata/skill-tests-README.md.template +1 -1
- package/README.md +47 -14
- package/bundled-skills/registry.json +2 -1
- package/bundled-skills/skills/valdi-animations/skill.md +49 -0
- package/bundled-skills/skills/valdi-async/skill.md +3 -2
- package/bundled-skills/skills/valdi-async/tests/README.md +1 -1
- package/bundled-skills/skills/valdi-bazel/skill.md +2 -6
- package/bundled-skills/skills/valdi-component-tests/tests/README.md +1 -1
- package/bundled-skills/skills/valdi-cpp-runtime/skill.md +18 -0
- package/bundled-skills/skills/valdi-custom-view/skill.md +1 -1
- package/bundled-skills/skills/valdi-error-handling/skill.md +1 -1
- package/bundled-skills/skills/valdi-gestures/skill.md +3 -3
- package/bundled-skills/skills/valdi-migrate/skill.md +2 -1
- package/bundled-skills/skills/valdi-migrate/tests/README.md +2 -2
- package/bundled-skills/skills/valdi-mock-breakdown/skill.md +4 -4
- package/bundled-skills/skills/valdi-mock-to-module/skill.md +9 -6
- package/bundled-skills/skills/valdi-overview/skill.md +2 -1
- package/bundled-skills/skills/valdi-perf/skill.md +121 -5
- package/bundled-skills/skills/valdi-perf/tests/README.md +1 -1
- package/bundled-skills/skills/valdi-pr-review/skill.md +189 -0
- package/bundled-skills/skills/valdi-profile/skill.md +5 -3
- package/bundled-skills/skills/valdi-setup/skill.md +3 -6
- package/bundled-skills/skills/valdi-testing/skill.md +1 -1
- package/bundled-skills/skills/valdi-tsx/skill.md +47 -11
- package/bundled-skills/skills/valdi-tsx/tests/README.md +1 -1
- package/debugger/README.md +356 -0
- package/debugger/debugger-actions.js +373 -0
- package/debugger/debugger-api.js +225 -0
- package/debugger/debugger-bootstrap.js +295 -0
- package/debugger/debugger-model.js +790 -0
- package/debugger/debugger-performance.js +573 -0
- package/debugger/debugger-preview-html.js +676 -0
- package/debugger/debugger-providers.js +389 -0
- package/debugger/debugger-render.js +529 -0
- package/debugger/debugger-runtime.js +387 -0
- package/debugger/debugger-session.js +188 -0
- package/debugger/debugger-settings.js +209 -0
- package/debugger/debugger-state.js +221 -0
- package/debugger/debugger-tree-model.js +539 -0
- package/debugger/debugger.css +1865 -0
- package/debugger/devtools-panel.css +1318 -0
- package/debugger/devtools-panel.html +273 -0
- package/debugger/devtools-panel.js +3329 -0
- package/debugger/index.html +279 -0
- package/dist/commands/bootstrap.js +7 -6
- package/dist/commands/build.js +7 -1
- package/dist/commands/debugger.js +163 -0
- package/dist/commands/doctor.js +3 -62
- package/dist/commands/export.js +47 -16
- package/dist/commands/hotreload.js +247 -27
- package/dist/commands/inspect.js +5 -2
- package/dist/commands/inspect_commands/input.js +176 -0
- package/dist/commands/inspect_commands/snapshot.js +1 -1
- package/dist/commands/inspect_commands/tree.js +1 -1
- package/dist/commands/install.js +79 -2
- package/dist/commands/projectsync.js +15 -0
- package/dist/commands/webHotreload.js +31 -0
- package/dist/core/constants.js +34 -7
- package/dist/debugger/chromiumConsole.js +279 -0
- package/dist/debugger/inputClient.js +473 -0
- package/dist/debugger/server.js +3801 -0
- package/dist/debugger/targetRegistry.js +436 -0
- package/dist/debugger/webPreviewPerformance.js +864 -0
- package/dist/index.js +0 -0
- package/dist/utils/BazelClient.js +34 -5
- package/dist/utils/applicationUtils.js +20 -2
- package/dist/utils/buildInfo.js +5 -1
- package/dist/utils/chromiumDevToolsClient.js +350 -0
- package/dist/utils/cliUtils.js +2 -2
- package/dist/utils/daemonClient.js +364 -44
- package/dist/utils/directorySync.js +153 -0
- package/dist/utils/githubUtils.js +1 -1
- package/dist/utils/hermesClient.js +82 -176
- package/dist/utils/loopbackHost.js +14 -0
- package/dist/utils/owlCdpClient.js +282 -0
- package/dist/utils/owlDevToolsExtension.js +142 -0
- package/dist/utils/processUtils.js +14 -0
- package/dist/utils/stringUtils.js +13 -1
- package/dist/utils/webApplicationSession.js +58 -0
- package/dist/utils/webHotReloadSession.js +212 -0
- package/dist/utils/webServerUtils.js +195 -0
- package/dist/utils/zipUtils.js +20 -2
- package/package.json +4 -2
- package/dist/commands/inspect_commands/snapshot.spec.js +0 -105
- package/dist/core/packageFiles.spec.js +0 -29
- package/dist/preview/previewGenerator.spec.js +0 -203
- package/dist/preview/viewModelParser.spec.js +0 -171
- package/dist/utils/linuxDistro.spec.js +0 -122
- package/dist/utils/skillsAdapters.spec.js +0 -141
- package/dist/utils/stringUtils.spec.js +0 -81
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
require("jasmine");
|
|
5
|
-
const fs = tslib_1.__importStar(require("fs"));
|
|
6
|
-
const os = tslib_1.__importStar(require("os"));
|
|
7
|
-
const path = tslib_1.__importStar(require("path"));
|
|
8
|
-
const previewGenerator_1 = require("./previewGenerator");
|
|
9
|
-
describe('previewGenerator', () => {
|
|
10
|
-
let tmpDir;
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'pg-test-'));
|
|
13
|
-
});
|
|
14
|
-
afterEach(() => {
|
|
15
|
-
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
16
|
-
});
|
|
17
|
-
describe('getPreviewDir', () => {
|
|
18
|
-
it('returns apps/preview under workspace root', () => {
|
|
19
|
-
expect((0, previewGenerator_1.getPreviewDir)('/workspace')).toBe('/workspace/apps/preview');
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
describe('getModuleNameFromImport', () => {
|
|
23
|
-
it('extracts the first path segment', () => {
|
|
24
|
-
expect((0, previewGenerator_1.getModuleNameFromImport)('widgets/src/components/Button')).toBe('widgets');
|
|
25
|
-
expect((0, previewGenerator_1.getModuleNameFromImport)('coreui/src/Cell')).toBe('coreui');
|
|
26
|
-
expect((0, previewGenerator_1.getModuleNameFromImport)('mymod')).toBe('mymod');
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
describe('findModuleDir', () => {
|
|
30
|
-
it('walks up to find BUILD.bazel with valdi_module()', () => {
|
|
31
|
-
const modDir = path.join(tmpDir, 'mod');
|
|
32
|
-
const srcDir = path.join(modDir, 'src', 'components');
|
|
33
|
-
fs.mkdirSync(srcDir, { recursive: true });
|
|
34
|
-
fs.writeFileSync(path.join(modDir, 'BUILD.bazel'), `
|
|
35
|
-
valdi_module(
|
|
36
|
-
name = "mymod",
|
|
37
|
-
srcs = glob(["**/*.tsx"]),
|
|
38
|
-
)
|
|
39
|
-
`, 'utf8');
|
|
40
|
-
const componentFile = path.join(srcDir, 'Button.tsx');
|
|
41
|
-
fs.writeFileSync(componentFile, 'export class Button {}', 'utf8');
|
|
42
|
-
expect((0, previewGenerator_1.findModuleDir)(componentFile)).toBe(modDir);
|
|
43
|
-
});
|
|
44
|
-
it('skips BUILD.bazel files without valdi_module()', () => {
|
|
45
|
-
const parentDir = path.join(tmpDir, 'parent');
|
|
46
|
-
const childDir = path.join(parentDir, 'child');
|
|
47
|
-
fs.mkdirSync(childDir, { recursive: true });
|
|
48
|
-
fs.writeFileSync(path.join(childDir, 'BUILD.bazel'), 'cc_library(name = "lib")', 'utf8');
|
|
49
|
-
fs.writeFileSync(path.join(parentDir, 'BUILD.bazel'), 'valdi_module(name = "mod")', 'utf8');
|
|
50
|
-
const componentFile = path.join(childDir, 'Comp.tsx');
|
|
51
|
-
fs.writeFileSync(componentFile, '', 'utf8');
|
|
52
|
-
expect((0, previewGenerator_1.findModuleDir)(componentFile)).toBe(parentDir);
|
|
53
|
-
});
|
|
54
|
-
it('throws when no valdi_module BUILD is found', () => {
|
|
55
|
-
const isolatedDir = path.join(tmpDir, 'isolated');
|
|
56
|
-
fs.mkdirSync(isolatedDir, { recursive: true });
|
|
57
|
-
const componentFile = path.join(isolatedDir, 'Comp.tsx');
|
|
58
|
-
fs.writeFileSync(componentFile, '', 'utf8');
|
|
59
|
-
expect(() => (0, previewGenerator_1.findModuleDir)(componentFile)).toThrowError(/Could not find a BUILD.bazel/);
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
describe('readModuleName', () => {
|
|
63
|
-
it('extracts module name from BUILD.bazel', () => {
|
|
64
|
-
const modDir = path.join(tmpDir, 'mymod');
|
|
65
|
-
fs.mkdirSync(modDir, { recursive: true });
|
|
66
|
-
fs.writeFileSync(path.join(modDir, 'BUILD.bazel'), `
|
|
67
|
-
load("@valdi//bzl:valdi.bzl", "valdi_module")
|
|
68
|
-
valdi_module(
|
|
69
|
-
name = "widgets",
|
|
70
|
-
srcs = glob(["**/*.tsx"]),
|
|
71
|
-
)
|
|
72
|
-
`, 'utf8');
|
|
73
|
-
expect((0, previewGenerator_1.readModuleName)(modDir)).toBe('widgets');
|
|
74
|
-
});
|
|
75
|
-
it('throws when no valdi_module name found', () => {
|
|
76
|
-
const modDir = path.join(tmpDir, 'bad');
|
|
77
|
-
fs.mkdirSync(modDir, { recursive: true });
|
|
78
|
-
fs.writeFileSync(path.join(modDir, 'BUILD.bazel'), 'cc_library(name = "lib")', 'utf8');
|
|
79
|
-
expect(() => (0, previewGenerator_1.readModuleName)(modDir)).toThrowError(/Could not find valdi_module name/);
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
describe('isValdiWorkspace', () => {
|
|
83
|
-
it('returns true for workspace named "valdi"', () => {
|
|
84
|
-
fs.writeFileSync(path.join(tmpDir, 'WORKSPACE'), 'workspace(name = "valdi")\n', 'utf8');
|
|
85
|
-
expect((0, previewGenerator_1.isValdiWorkspace)(tmpDir)).toBe(true);
|
|
86
|
-
});
|
|
87
|
-
it('returns false for other workspace names', () => {
|
|
88
|
-
fs.writeFileSync(path.join(tmpDir, 'WORKSPACE'), 'workspace(name = "my_app")\n', 'utf8');
|
|
89
|
-
expect((0, previewGenerator_1.isValdiWorkspace)(tmpDir)).toBe(false);
|
|
90
|
-
});
|
|
91
|
-
it('returns false when no WORKSPACE file exists', () => {
|
|
92
|
-
expect((0, previewGenerator_1.isValdiWorkspace)(tmpDir)).toBe(false);
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
describe('computeModuleLabel', () => {
|
|
96
|
-
it('computes a Bazel label from module dir', () => {
|
|
97
|
-
const modDir = path.join(tmpDir, 'src', 'widgets');
|
|
98
|
-
fs.mkdirSync(modDir, { recursive: true });
|
|
99
|
-
fs.writeFileSync(path.join(modDir, 'BUILD.bazel'), 'valdi_module(name = "widgets")', 'utf8');
|
|
100
|
-
expect((0, previewGenerator_1.computeModuleLabel)(modDir, tmpDir)).toBe('//src/widgets:widgets');
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
describe('generatePreviewFiles', () => {
|
|
104
|
-
it('generates PreviewRoot.tsx, BUILD.bazel, and tsconfig.json', () => {
|
|
105
|
-
const modDir = path.join(tmpDir, 'src', 'widgets');
|
|
106
|
-
fs.mkdirSync(modDir, { recursive: true });
|
|
107
|
-
fs.writeFileSync(path.join(modDir, 'BUILD.bazel'), 'valdi_module(name = "widgets")', 'utf8');
|
|
108
|
-
fs.writeFileSync(path.join(tmpDir, 'WORKSPACE'), 'workspace(name = "my_app")', 'utf8');
|
|
109
|
-
const configDir = path.join(tmpDir, 'valdi_modules', '_configs');
|
|
110
|
-
fs.mkdirSync(configDir, { recursive: true });
|
|
111
|
-
fs.writeFileSync(path.join(configDir, 'base.tsconfig.json'), '{}', 'utf8');
|
|
112
|
-
const config = {
|
|
113
|
-
componentFilePath: path.join(modDir, 'src', 'Button.tsx'),
|
|
114
|
-
importPath: 'widgets/src/Button',
|
|
115
|
-
moduleLabel: '//src/widgets:widgets',
|
|
116
|
-
workspaceRoot: tmpDir,
|
|
117
|
-
isValdiRepo: false,
|
|
118
|
-
viewModel: {
|
|
119
|
-
componentName: 'Button',
|
|
120
|
-
viewModelName: 'ButtonViewModel',
|
|
121
|
-
props: [
|
|
122
|
-
{ name: 'label', typeString: 'string', optional: false, isBoolean: false, isCallback: false, callbackParamType: undefined },
|
|
123
|
-
{ name: 'onTap', typeString: '() => void', optional: false, isBoolean: false, isCallback: true, callbackParamType: undefined },
|
|
124
|
-
],
|
|
125
|
-
extraImports: [],
|
|
126
|
-
},
|
|
127
|
-
};
|
|
128
|
-
(0, previewGenerator_1.generatePreviewFiles)(config);
|
|
129
|
-
const previewDir = (0, previewGenerator_1.getPreviewDir)(tmpDir);
|
|
130
|
-
expect(fs.existsSync(path.join(previewDir, 'PreviewRoot.tsx'))).toBe(true);
|
|
131
|
-
expect(fs.existsSync(path.join(previewDir, 'BUILD.bazel'))).toBe(true);
|
|
132
|
-
expect(fs.existsSync(path.join(previewDir, 'tsconfig.json'))).toBe(true);
|
|
133
|
-
const previewTsx = fs.readFileSync(path.join(previewDir, 'PreviewRoot.tsx'), 'utf8');
|
|
134
|
-
expect(previewTsx).toContain("import { Button } from 'widgets/src/Button'");
|
|
135
|
-
expect(previewTsx).toContain('<Button');
|
|
136
|
-
expect(previewTsx).toContain("label={'Sample'}");
|
|
137
|
-
expect(previewTsx).toContain('onTap={() => {}}');
|
|
138
|
-
const buildBazel = fs.readFileSync(path.join(previewDir, 'BUILD.bazel'), 'utf8');
|
|
139
|
-
expect(buildBazel).toContain('@valdi//bzl/valdi:valdi_application.bzl');
|
|
140
|
-
expect(buildBazel).toContain('//src/widgets:widgets');
|
|
141
|
-
expect(buildBazel).toContain('root_component_path = "PreviewRoot@preview/PreviewRoot"');
|
|
142
|
-
const tsconfig = JSON.parse(fs.readFileSync(path.join(previewDir, 'tsconfig.json'), 'utf8'));
|
|
143
|
-
expect(tsconfig.compilerOptions.paths['preview/*']).toEqual(['./*']);
|
|
144
|
-
});
|
|
145
|
-
it('generates StatefulComponent when interactive state is detected', () => {
|
|
146
|
-
const modDir = path.join(tmpDir, 'src', 'widgets');
|
|
147
|
-
fs.mkdirSync(modDir, { recursive: true });
|
|
148
|
-
fs.writeFileSync(path.join(modDir, 'BUILD.bazel'), 'valdi_module(name = "widgets")', 'utf8');
|
|
149
|
-
fs.writeFileSync(path.join(tmpDir, 'WORKSPACE'), 'workspace(name = "other")', 'utf8');
|
|
150
|
-
const configDir = path.join(tmpDir, 'valdi_modules', '_configs');
|
|
151
|
-
fs.mkdirSync(configDir, { recursive: true });
|
|
152
|
-
fs.writeFileSync(path.join(configDir, 'base.tsconfig.json'), '{}', 'utf8');
|
|
153
|
-
const config = {
|
|
154
|
-
componentFilePath: path.join(modDir, 'src', 'Toggle.tsx'),
|
|
155
|
-
importPath: 'widgets/src/Toggle',
|
|
156
|
-
moduleLabel: '//src/widgets:widgets',
|
|
157
|
-
workspaceRoot: tmpDir,
|
|
158
|
-
isValdiRepo: false,
|
|
159
|
-
viewModel: {
|
|
160
|
-
componentName: 'Toggle',
|
|
161
|
-
viewModelName: 'ToggleVM',
|
|
162
|
-
props: [
|
|
163
|
-
{ name: 'checked', typeString: 'boolean', optional: false, isBoolean: true, isCallback: false, callbackParamType: undefined },
|
|
164
|
-
{ name: 'onToggle', typeString: '(val: boolean) => void', optional: false, isBoolean: false, isCallback: true, callbackParamType: 'boolean' },
|
|
165
|
-
],
|
|
166
|
-
extraImports: [],
|
|
167
|
-
},
|
|
168
|
-
};
|
|
169
|
-
(0, previewGenerator_1.generatePreviewFiles)(config);
|
|
170
|
-
const previewTsx = fs.readFileSync(path.join((0, previewGenerator_1.getPreviewDir)(tmpDir), 'PreviewRoot.tsx'), 'utf8');
|
|
171
|
-
expect(previewTsx).toContain('StatefulComponent');
|
|
172
|
-
expect(previewTsx).toContain('state: PreviewState');
|
|
173
|
-
expect(previewTsx).toContain('this.state.checked');
|
|
174
|
-
expect(previewTsx).toContain('this.setState');
|
|
175
|
-
});
|
|
176
|
-
it('uses // prefix for Valdi repo BUILD.bazel', () => {
|
|
177
|
-
const modDir = path.join(tmpDir, 'src', 'widgets');
|
|
178
|
-
fs.mkdirSync(modDir, { recursive: true });
|
|
179
|
-
fs.writeFileSync(path.join(modDir, 'BUILD.bazel'), 'valdi_module(name = "widgets")', 'utf8');
|
|
180
|
-
fs.writeFileSync(path.join(tmpDir, 'WORKSPACE'), 'workspace(name = "valdi")', 'utf8');
|
|
181
|
-
const configDir = path.join(tmpDir, 'modules', '_configs');
|
|
182
|
-
fs.mkdirSync(configDir, { recursive: true });
|
|
183
|
-
fs.writeFileSync(path.join(configDir, 'base.tsconfig.json'), '{}', 'utf8');
|
|
184
|
-
const config = {
|
|
185
|
-
componentFilePath: path.join(modDir, 'src', 'Button.tsx'),
|
|
186
|
-
importPath: 'widgets/src/Button',
|
|
187
|
-
moduleLabel: '//src/widgets:widgets',
|
|
188
|
-
workspaceRoot: tmpDir,
|
|
189
|
-
isValdiRepo: true,
|
|
190
|
-
viewModel: {
|
|
191
|
-
componentName: 'Button',
|
|
192
|
-
viewModelName: 'ButtonVM',
|
|
193
|
-
props: [],
|
|
194
|
-
extraImports: [],
|
|
195
|
-
},
|
|
196
|
-
};
|
|
197
|
-
(0, previewGenerator_1.generatePreviewFiles)(config);
|
|
198
|
-
const buildBazel = fs.readFileSync(path.join((0, previewGenerator_1.getPreviewDir)(tmpDir), 'BUILD.bazel'), 'utf8');
|
|
199
|
-
expect(buildBazel).toContain('load("//bzl/valdi:valdi_application.bzl"');
|
|
200
|
-
expect(buildBazel).not.toContain('@valdi');
|
|
201
|
-
});
|
|
202
|
-
});
|
|
203
|
-
});
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
require("jasmine");
|
|
5
|
-
const fs = tslib_1.__importStar(require("fs"));
|
|
6
|
-
const os = tslib_1.__importStar(require("os"));
|
|
7
|
-
const path = tslib_1.__importStar(require("path"));
|
|
8
|
-
const viewModelParser_1 = require("./viewModelParser");
|
|
9
|
-
describe('viewModelParser', () => {
|
|
10
|
-
let tmpDir;
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'vmp-test-'));
|
|
13
|
-
});
|
|
14
|
-
afterEach(() => {
|
|
15
|
-
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
16
|
-
});
|
|
17
|
-
function writeComponent(filename, content) {
|
|
18
|
-
const filePath = path.join(tmpDir, filename);
|
|
19
|
-
fs.writeFileSync(filePath, content, 'utf8');
|
|
20
|
-
return filePath;
|
|
21
|
-
}
|
|
22
|
-
describe('parseComponentFile', () => {
|
|
23
|
-
it('parses a simple Component with ViewModel', () => {
|
|
24
|
-
const filePath = writeComponent('Simple.tsx', `
|
|
25
|
-
import { Component } from 'valdi_core/src/Component';
|
|
26
|
-
|
|
27
|
-
export interface SimpleViewModel {
|
|
28
|
-
title: string;
|
|
29
|
-
count: number;
|
|
30
|
-
enabled: boolean;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export class Simple extends Component<SimpleViewModel, {}> {
|
|
34
|
-
onRender(): void {}
|
|
35
|
-
}
|
|
36
|
-
`);
|
|
37
|
-
const result = (0, viewModelParser_1.parseComponentFile)(filePath);
|
|
38
|
-
expect(result.componentName).toBe('Simple');
|
|
39
|
-
expect(result.viewModelName).toBe('SimpleViewModel');
|
|
40
|
-
expect(result.props.length).toBe(3);
|
|
41
|
-
expect(result.props[0].name).toBe('title');
|
|
42
|
-
expect(result.props[0].typeString).toBe('string');
|
|
43
|
-
expect(result.props[0].optional).toBe(false);
|
|
44
|
-
expect(result.props[1].name).toBe('count');
|
|
45
|
-
expect(result.props[1].typeString).toBe('number');
|
|
46
|
-
expect(result.props[2].name).toBe('enabled');
|
|
47
|
-
expect(result.props[2].isBoolean).toBe(true);
|
|
48
|
-
});
|
|
49
|
-
it('parses optional props', () => {
|
|
50
|
-
const filePath = writeComponent('Optional.tsx', `
|
|
51
|
-
export interface OptViewModel {
|
|
52
|
-
label: string;
|
|
53
|
-
subtitle?: string;
|
|
54
|
-
icon?: number;
|
|
55
|
-
}
|
|
56
|
-
export class OptComponent extends Component<OptViewModel, {}> {
|
|
57
|
-
onRender(): void {}
|
|
58
|
-
}
|
|
59
|
-
`);
|
|
60
|
-
const result = (0, viewModelParser_1.parseComponentFile)(filePath);
|
|
61
|
-
expect(result.props.length).toBe(3);
|
|
62
|
-
expect(result.props[0].optional).toBe(false);
|
|
63
|
-
expect(result.props[1].optional).toBe(true);
|
|
64
|
-
expect(result.props[2].optional).toBe(true);
|
|
65
|
-
});
|
|
66
|
-
it('parses callback props', () => {
|
|
67
|
-
const filePath = writeComponent('Callback.tsx', `
|
|
68
|
-
export interface CbViewModel {
|
|
69
|
-
onTap: () => void;
|
|
70
|
-
onChange: (val: boolean) => void;
|
|
71
|
-
onSelect: (item: string) => void;
|
|
72
|
-
}
|
|
73
|
-
export class CbComponent extends Component<CbViewModel, {}> {
|
|
74
|
-
onRender(): void {}
|
|
75
|
-
}
|
|
76
|
-
`);
|
|
77
|
-
const result = (0, viewModelParser_1.parseComponentFile)(filePath);
|
|
78
|
-
expect(result.props.length).toBe(3);
|
|
79
|
-
expect(result.props[0].isCallback).toBe(true);
|
|
80
|
-
expect(result.props[0].callbackParamType).toBeUndefined();
|
|
81
|
-
expect(result.props[1].isCallback).toBe(true);
|
|
82
|
-
expect(result.props[1].callbackParamType).toBe('boolean');
|
|
83
|
-
expect(result.props[2].isCallback).toBe(true);
|
|
84
|
-
expect(result.props[2].callbackParamType).toBe('string');
|
|
85
|
-
});
|
|
86
|
-
it('parses StatefulComponent', () => {
|
|
87
|
-
const filePath = writeComponent('Stateful.tsx', `
|
|
88
|
-
export interface StatefulVM {
|
|
89
|
-
checked: boolean;
|
|
90
|
-
}
|
|
91
|
-
export class MyStateful extends StatefulComponent<StatefulVM> {
|
|
92
|
-
onRender(): void {}
|
|
93
|
-
}
|
|
94
|
-
`);
|
|
95
|
-
const result = (0, viewModelParser_1.parseComponentFile)(filePath);
|
|
96
|
-
expect(result.componentName).toBe('MyStateful');
|
|
97
|
-
expect(result.viewModelName).toBe('StatefulVM');
|
|
98
|
-
});
|
|
99
|
-
it('throws when no Component class is found', () => {
|
|
100
|
-
const filePath = writeComponent('NoClass.tsx', `
|
|
101
|
-
export interface SomeViewModel { title: string; }
|
|
102
|
-
`);
|
|
103
|
-
expect(() => (0, viewModelParser_1.parseComponentFile)(filePath)).toThrowError(/Could not find an exported Component class/);
|
|
104
|
-
});
|
|
105
|
-
it('throws when ViewModel interface is missing', () => {
|
|
106
|
-
const filePath = writeComponent('NoVM.tsx', `
|
|
107
|
-
export class Broken extends Component<MissingViewModel, {}> {
|
|
108
|
-
onRender(): void {}
|
|
109
|
-
}
|
|
110
|
-
`);
|
|
111
|
-
expect(() => (0, viewModelParser_1.parseComponentFile)(filePath)).toThrowError(/Could not find interface MissingViewModel/);
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
describe('detectInteractiveState', () => {
|
|
115
|
-
it('pairs boolean prop with onChange callback', () => {
|
|
116
|
-
const props = [
|
|
117
|
-
{ name: 'on', typeString: 'boolean', optional: false, isBoolean: true, isCallback: false, callbackParamType: undefined },
|
|
118
|
-
{ name: 'onChange', typeString: '(val: boolean) => void', optional: false, isBoolean: false, isCallback: true, callbackParamType: 'boolean' },
|
|
119
|
-
];
|
|
120
|
-
const pairs = (0, viewModelParser_1.detectInteractiveState)(props);
|
|
121
|
-
expect(pairs.length).toBe(1);
|
|
122
|
-
expect(pairs[0].boolPropName).toBe('on');
|
|
123
|
-
expect(pairs[0].callbackPropName).toBe('onChange');
|
|
124
|
-
});
|
|
125
|
-
it('pairs boolean prop with onTap callback', () => {
|
|
126
|
-
const props = [
|
|
127
|
-
{ name: 'selected', typeString: 'boolean', optional: false, isBoolean: true, isCallback: false, callbackParamType: undefined },
|
|
128
|
-
{ name: 'onTap', typeString: '(val: boolean) => void', optional: false, isBoolean: false, isCallback: true, callbackParamType: 'boolean' },
|
|
129
|
-
];
|
|
130
|
-
const pairs = (0, viewModelParser_1.detectInteractiveState)(props);
|
|
131
|
-
expect(pairs.length).toBe(1);
|
|
132
|
-
expect(pairs[0].boolPropName).toBe('selected');
|
|
133
|
-
expect(pairs[0].callbackPropName).toBe('onTap');
|
|
134
|
-
});
|
|
135
|
-
it('returns empty when no matching pair exists', () => {
|
|
136
|
-
const props = [
|
|
137
|
-
{ name: 'title', typeString: 'string', optional: false, isBoolean: false, isCallback: false, callbackParamType: undefined },
|
|
138
|
-
{ name: 'onTap', typeString: '() => void', optional: false, isBoolean: false, isCallback: true, callbackParamType: undefined },
|
|
139
|
-
];
|
|
140
|
-
const pairs = (0, viewModelParser_1.detectInteractiveState)(props);
|
|
141
|
-
expect(pairs.length).toBe(0);
|
|
142
|
-
});
|
|
143
|
-
it('skips optional boolean props', () => {
|
|
144
|
-
const props = [
|
|
145
|
-
{ name: 'checked', typeString: 'boolean', optional: true, isBoolean: true, isCallback: false, callbackParamType: undefined },
|
|
146
|
-
{ name: 'onToggle', typeString: '(val: boolean) => void', optional: false, isBoolean: false, isCallback: true, callbackParamType: 'boolean' },
|
|
147
|
-
];
|
|
148
|
-
const pairs = (0, viewModelParser_1.detectInteractiveState)(props);
|
|
149
|
-
expect(pairs.length).toBe(0);
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
describe('sampleValueForType', () => {
|
|
153
|
-
it('returns correct sample for primitive types', () => {
|
|
154
|
-
expect((0, viewModelParser_1.sampleValueForType)('boolean')).toBe('false');
|
|
155
|
-
expect((0, viewModelParser_1.sampleValueForType)('string')).toBe("'Sample'");
|
|
156
|
-
expect((0, viewModelParser_1.sampleValueForType)('number')).toBe('42');
|
|
157
|
-
expect((0, viewModelParser_1.sampleValueForType)('Date')).toBe('new Date()');
|
|
158
|
-
});
|
|
159
|
-
it('returns noop for function types', () => {
|
|
160
|
-
expect((0, viewModelParser_1.sampleValueForType)('() => void')).toBe('() => {}');
|
|
161
|
-
expect((0, viewModelParser_1.sampleValueForType)('(val: boolean) => void')).toBe('() => {}');
|
|
162
|
-
});
|
|
163
|
-
it('returns empty array for array types', () => {
|
|
164
|
-
expect((0, viewModelParser_1.sampleValueForType)('string[]')).toBe('[]');
|
|
165
|
-
expect((0, viewModelParser_1.sampleValueForType)('Array<number>')).toBe('[]');
|
|
166
|
-
});
|
|
167
|
-
it('falls back to undefined for unknown types', () => {
|
|
168
|
-
expect((0, viewModelParser_1.sampleValueForType)('SomeCustomType')).toBe('undefined as any');
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
});
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
require("jasmine");
|
|
4
|
-
const linuxDistro_1 = require("./linuxDistro");
|
|
5
|
-
describe('linuxDistro', () => {
|
|
6
|
-
describe('getPackageName', () => {
|
|
7
|
-
it('returns Debian package name for Debian distribution', () => {
|
|
8
|
-
const packageMap = {
|
|
9
|
-
debian: 'openjdk-17-jdk',
|
|
10
|
-
redhat: 'java-17-openjdk-devel',
|
|
11
|
-
unknown: 'openjdk-17',
|
|
12
|
-
};
|
|
13
|
-
const distro = {
|
|
14
|
-
type: linuxDistro_1.LinuxDistroType.DEBIAN,
|
|
15
|
-
name: 'Ubuntu',
|
|
16
|
-
packageManager: { name: 'apt', installCommand: 'apt-get install', requiresSudo: true },
|
|
17
|
-
};
|
|
18
|
-
const result = (0, linuxDistro_1.getPackageName)(packageMap, distro);
|
|
19
|
-
expect(result).toBe('openjdk-17-jdk');
|
|
20
|
-
});
|
|
21
|
-
it('returns RedHat package name for RedHat distribution', () => {
|
|
22
|
-
const packageMap = {
|
|
23
|
-
debian: 'openjdk-17-jdk',
|
|
24
|
-
redhat: 'java-17-openjdk-devel',
|
|
25
|
-
unknown: 'openjdk-17',
|
|
26
|
-
};
|
|
27
|
-
const distro = {
|
|
28
|
-
type: linuxDistro_1.LinuxDistroType.REDHAT,
|
|
29
|
-
name: 'Fedora',
|
|
30
|
-
packageManager: { name: 'dnf', installCommand: 'dnf install', requiresSudo: true },
|
|
31
|
-
};
|
|
32
|
-
const result = (0, linuxDistro_1.getPackageName)(packageMap, distro);
|
|
33
|
-
expect(result).toBe('java-17-openjdk-devel');
|
|
34
|
-
});
|
|
35
|
-
it('returns unknown fallback for distributions without specific mapping', () => {
|
|
36
|
-
const packageMap = {
|
|
37
|
-
debian: 'openjdk-17-jdk',
|
|
38
|
-
unknown: 'openjdk-17',
|
|
39
|
-
};
|
|
40
|
-
const distro = {
|
|
41
|
-
type: linuxDistro_1.LinuxDistroType.ARCH,
|
|
42
|
-
name: 'Arch Linux',
|
|
43
|
-
packageManager: { name: 'pacman', installCommand: 'pacman -S', requiresSudo: true },
|
|
44
|
-
};
|
|
45
|
-
const result = (0, linuxDistro_1.getPackageName)(packageMap, distro);
|
|
46
|
-
expect(result).toBe('openjdk-17');
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
describe('buildInstallCommand', () => {
|
|
50
|
-
it('builds install command for Debian', () => {
|
|
51
|
-
const distro = {
|
|
52
|
-
type: linuxDistro_1.LinuxDistroType.DEBIAN,
|
|
53
|
-
name: 'Ubuntu',
|
|
54
|
-
packageManager: { name: 'apt', installCommand: 'apt-get install', requiresSudo: true },
|
|
55
|
-
};
|
|
56
|
-
const result = (0, linuxDistro_1.buildInstallCommand)(['git', 'npm', 'watchman'], distro);
|
|
57
|
-
expect(result).toBe('sudo apt-get install git npm watchman');
|
|
58
|
-
});
|
|
59
|
-
it('builds install command for RedHat', () => {
|
|
60
|
-
const distro = {
|
|
61
|
-
type: linuxDistro_1.LinuxDistroType.REDHAT,
|
|
62
|
-
name: 'Fedora',
|
|
63
|
-
packageManager: { name: 'dnf', installCommand: 'dnf install', requiresSudo: true },
|
|
64
|
-
};
|
|
65
|
-
const result = (0, linuxDistro_1.buildInstallCommand)(['git', 'npm'], distro);
|
|
66
|
-
expect(result).toBe('sudo dnf install git npm');
|
|
67
|
-
});
|
|
68
|
-
it('builds install command for Arch', () => {
|
|
69
|
-
const distro = {
|
|
70
|
-
type: linuxDistro_1.LinuxDistroType.ARCH,
|
|
71
|
-
name: 'Arch Linux',
|
|
72
|
-
packageManager: { name: 'pacman', installCommand: 'pacman -S', requiresSudo: true },
|
|
73
|
-
};
|
|
74
|
-
const result = (0, linuxDistro_1.buildInstallCommand)(['git', 'npm'], distro);
|
|
75
|
-
expect(result).toBe('sudo pacman -S git npm');
|
|
76
|
-
});
|
|
77
|
-
it('returns comment for unknown distribution', () => {
|
|
78
|
-
const distro = {
|
|
79
|
-
type: linuxDistro_1.LinuxDistroType.UNKNOWN,
|
|
80
|
-
name: 'Unknown',
|
|
81
|
-
packageManager: { name: 'unknown', installCommand: '', requiresSudo: true },
|
|
82
|
-
};
|
|
83
|
-
const result = (0, linuxDistro_1.buildInstallCommand)(['git', 'npm'], distro);
|
|
84
|
-
expect(result).toContain('Unable to determine package manager');
|
|
85
|
-
expect(result).toContain('git, npm');
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
describe('getCommonPackageMappings', () => {
|
|
89
|
-
it('returns package mappings for common dependencies', () => {
|
|
90
|
-
const mappings = (0, linuxDistro_1.getCommonPackageMappings)();
|
|
91
|
-
expect(mappings['git']).toBeDefined();
|
|
92
|
-
expect(mappings['npm']).toBeDefined();
|
|
93
|
-
expect(mappings['openjdk-17']).toBeDefined();
|
|
94
|
-
expect(mappings['watchman']).toBeDefined();
|
|
95
|
-
expect(mappings['adb']).toBeDefined();
|
|
96
|
-
expect(mappings['fontconfig']).toBeDefined();
|
|
97
|
-
expect(mappings['zlib']).toBeDefined();
|
|
98
|
-
});
|
|
99
|
-
it('has platform-specific mappings for Java', () => {
|
|
100
|
-
const mappings = (0, linuxDistro_1.getCommonPackageMappings)();
|
|
101
|
-
const javaMappings = mappings['openjdk-17'];
|
|
102
|
-
expect(javaMappings).toBeDefined();
|
|
103
|
-
if (javaMappings) {
|
|
104
|
-
expect(javaMappings.debian).toBe('openjdk-17-jdk');
|
|
105
|
-
expect(javaMappings.redhat).toBe('java-17-openjdk-devel');
|
|
106
|
-
expect(javaMappings.arch).toBe('jdk17-openjdk');
|
|
107
|
-
expect(javaMappings.suse).toBe('java-17-openjdk-devel');
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
it('has platform-specific mappings for adb', () => {
|
|
111
|
-
const mappings = (0, linuxDistro_1.getCommonPackageMappings)();
|
|
112
|
-
const adbMappings = mappings['adb'];
|
|
113
|
-
expect(adbMappings).toBeDefined();
|
|
114
|
-
if (adbMappings) {
|
|
115
|
-
expect(adbMappings.debian).toBe('adb');
|
|
116
|
-
expect(adbMappings.redhat).toBe('android-tools');
|
|
117
|
-
expect(adbMappings.arch).toBe('android-tools');
|
|
118
|
-
expect(adbMappings.suse).toBe('android-tools');
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
});
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
require("jasmine");
|
|
5
|
-
const fs = tslib_1.__importStar(require("fs"));
|
|
6
|
-
const path = tslib_1.__importStar(require("path"));
|
|
7
|
-
const os = tslib_1.__importStar(require("os"));
|
|
8
|
-
const skillsAdapters_1 = require("./skillsAdapters");
|
|
9
|
-
describe('ClaudeCodeAdapter', () => {
|
|
10
|
-
let tmpHome;
|
|
11
|
-
let origHome;
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
tmpHome = fs.mkdtempSync(path.join(os.tmpdir(), 'valdi-test-'));
|
|
14
|
-
origHome = process.env['HOME'];
|
|
15
|
-
process.env['HOME'] = tmpHome;
|
|
16
|
-
fs.mkdirSync(path.join(tmpHome, '.claude'), { recursive: true });
|
|
17
|
-
});
|
|
18
|
-
afterEach(() => {
|
|
19
|
-
process.env['HOME'] = origHome;
|
|
20
|
-
fs.rmSync(tmpHome, { recursive: true, force: true });
|
|
21
|
-
});
|
|
22
|
-
function getAdapter() {
|
|
23
|
-
const adapter = (0, skillsAdapters_1.getAdapterByName)('claude');
|
|
24
|
-
expect(adapter).toBeDefined();
|
|
25
|
-
return adapter;
|
|
26
|
-
}
|
|
27
|
-
it('writes SKILL.md with frontmatter to ~/.claude/skills/', () => {
|
|
28
|
-
const adapter = getAdapter();
|
|
29
|
-
adapter.install('my-skill', '# My content', { name: 'my-skill', description: 'Desc', tags: [], path: '', category: [] });
|
|
30
|
-
const skillPath = path.join(tmpHome, '.claude', 'skills', 'my-skill', 'SKILL.md');
|
|
31
|
-
expect(fs.existsSync(skillPath)).toBe(true);
|
|
32
|
-
const content = fs.readFileSync(skillPath, 'utf8');
|
|
33
|
-
expect(content).toContain('name: my-skill');
|
|
34
|
-
expect(content).toContain('description: Desc');
|
|
35
|
-
expect(content).toContain('# My content');
|
|
36
|
-
});
|
|
37
|
-
it('does not modify settings.json', () => {
|
|
38
|
-
const settingsFile = path.join(tmpHome, '.claude', 'settings.json');
|
|
39
|
-
fs.writeFileSync(settingsFile, JSON.stringify({ model: 'claude-opus-4-6' }), 'utf8');
|
|
40
|
-
const adapter = getAdapter();
|
|
41
|
-
adapter.install('test-skill', '# Content', { name: 'test-skill', description: 'Desc', tags: [], path: '', category: [] });
|
|
42
|
-
const settings = JSON.parse(fs.readFileSync(settingsFile, 'utf8'));
|
|
43
|
-
expect(settings).toEqual({ model: 'claude-opus-4-6' });
|
|
44
|
-
});
|
|
45
|
-
it('lists installed skills', () => {
|
|
46
|
-
const adapter = getAdapter();
|
|
47
|
-
adapter.install('skill-a', '# A', { name: 'skill-a', description: 'A', tags: [], path: '', category: [] });
|
|
48
|
-
adapter.install('skill-b', '# B', { name: 'skill-b', description: 'B', tags: [], path: '', category: [] });
|
|
49
|
-
const installed = adapter.listInstalled();
|
|
50
|
-
expect(installed).toContain('skill-a');
|
|
51
|
-
expect(installed).toContain('skill-b');
|
|
52
|
-
});
|
|
53
|
-
it('removes a skill', () => {
|
|
54
|
-
const adapter = getAdapter();
|
|
55
|
-
adapter.install('to-remove', '# Remove me', { name: 'to-remove', description: 'R', tags: [], path: '', category: [] });
|
|
56
|
-
expect(adapter.listInstalled()).toContain('to-remove');
|
|
57
|
-
adapter.remove('to-remove');
|
|
58
|
-
expect(adapter.listInstalled()).not.toContain('to-remove');
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
describe('CursorAdapter', () => {
|
|
62
|
-
let tmpHome;
|
|
63
|
-
let origHome;
|
|
64
|
-
beforeEach(() => {
|
|
65
|
-
tmpHome = fs.mkdtempSync(path.join(os.tmpdir(), 'valdi-test-'));
|
|
66
|
-
origHome = process.env['HOME'];
|
|
67
|
-
process.env['HOME'] = tmpHome;
|
|
68
|
-
fs.mkdirSync(path.join(tmpHome, '.cursor'), { recursive: true });
|
|
69
|
-
});
|
|
70
|
-
afterEach(() => {
|
|
71
|
-
process.env['HOME'] = origHome;
|
|
72
|
-
fs.rmSync(tmpHome, { recursive: true, force: true });
|
|
73
|
-
});
|
|
74
|
-
function getAdapter() {
|
|
75
|
-
const adapter = (0, skillsAdapters_1.getAdapterByName)('cursor');
|
|
76
|
-
expect(adapter).toBeDefined();
|
|
77
|
-
return adapter;
|
|
78
|
-
}
|
|
79
|
-
it('installs SKILL.md to ~/.cursor/skills/ without double-prefixing', () => {
|
|
80
|
-
const adapter = getAdapter();
|
|
81
|
-
adapter.install('valdi-bazel', '# Content', { name: 'valdi-bazel', description: 'A skill', tags: [], path: '', category: [] });
|
|
82
|
-
const skillPath = path.join(tmpHome, '.cursor', 'skills', 'valdi-bazel', 'SKILL.md');
|
|
83
|
-
expect(fs.existsSync(skillPath)).toBe(true);
|
|
84
|
-
const content = fs.readFileSync(skillPath, 'utf8');
|
|
85
|
-
expect(content).toContain('name: valdi-bazel');
|
|
86
|
-
expect(content).toContain('description: A skill');
|
|
87
|
-
expect(content).toContain('# Content');
|
|
88
|
-
const badPath = path.join(tmpHome, '.cursor', 'skills', 'valdi-valdi-bazel', 'SKILL.md');
|
|
89
|
-
expect(fs.existsSync(badPath)).toBe(false);
|
|
90
|
-
});
|
|
91
|
-
it('does not install to deprecated ~/.cursor/rules/', () => {
|
|
92
|
-
const adapter = getAdapter();
|
|
93
|
-
adapter.install('valdi-bazel', '# Content', { name: 'valdi-bazel', description: 'A skill', tags: [], path: '', category: [] });
|
|
94
|
-
const legacyPath = path.join(tmpHome, '.cursor', 'rules', 'valdi-valdi-bazel.mdc');
|
|
95
|
-
expect(fs.existsSync(legacyPath)).toBe(false);
|
|
96
|
-
});
|
|
97
|
-
it('cleans up double-prefixed legacy .mdc file on install', () => {
|
|
98
|
-
const legacyDir = path.join(tmpHome, '.cursor', 'rules');
|
|
99
|
-
fs.mkdirSync(legacyDir, { recursive: true });
|
|
100
|
-
fs.writeFileSync(path.join(legacyDir, 'valdi-valdi-bazel.mdc'), 'old content', 'utf8');
|
|
101
|
-
const adapter = getAdapter();
|
|
102
|
-
adapter.install('valdi-bazel', '# New content', { name: 'valdi-bazel', description: 'A skill', tags: [], path: '', category: [] });
|
|
103
|
-
expect(fs.existsSync(path.join(legacyDir, 'valdi-valdi-bazel.mdc'))).toBe(false);
|
|
104
|
-
expect(fs.existsSync(path.join(tmpHome, '.cursor', 'skills', 'valdi-bazel', 'SKILL.md'))).toBe(true);
|
|
105
|
-
});
|
|
106
|
-
it('lists installed skills', () => {
|
|
107
|
-
const adapter = getAdapter();
|
|
108
|
-
adapter.install('valdi-tsx', '# A', { name: 'valdi-tsx', description: 'A', tags: [], path: '', category: [] });
|
|
109
|
-
adapter.install('valdi-bazel', '# B', { name: 'valdi-bazel', description: 'B', tags: [], path: '', category: [] });
|
|
110
|
-
const installed = adapter.listInstalled();
|
|
111
|
-
expect(installed).toContain('valdi-tsx');
|
|
112
|
-
expect(installed).toContain('valdi-bazel');
|
|
113
|
-
});
|
|
114
|
-
it('lists legacy .mdc skills from ~/.cursor/rules/', () => {
|
|
115
|
-
const rulesDir = path.join(tmpHome, '.cursor', 'rules');
|
|
116
|
-
fs.mkdirSync(rulesDir, { recursive: true });
|
|
117
|
-
fs.writeFileSync(path.join(rulesDir, 'valdi-valdi-legacy.mdc'), 'old content', 'utf8');
|
|
118
|
-
const adapter = getAdapter();
|
|
119
|
-
expect(adapter.listInstalled()).toContain('valdi-legacy');
|
|
120
|
-
});
|
|
121
|
-
it('deduplicates skills present in both locations', () => {
|
|
122
|
-
const adapter = getAdapter();
|
|
123
|
-
adapter.install('valdi-both', '# New', { name: 'valdi-both', description: 'B', tags: [], path: '', category: [] });
|
|
124
|
-
const rulesDir = path.join(tmpHome, '.cursor', 'rules');
|
|
125
|
-
fs.mkdirSync(rulesDir, { recursive: true });
|
|
126
|
-
fs.writeFileSync(path.join(rulesDir, 'valdi-valdi-both.mdc'), 'old', 'utf8');
|
|
127
|
-
const installed = adapter.listInstalled();
|
|
128
|
-
const count = installed.filter((s) => s === 'valdi-both').length;
|
|
129
|
-
expect(count).toBe(1);
|
|
130
|
-
});
|
|
131
|
-
it('removes a skill and cleans up legacy file', () => {
|
|
132
|
-
const adapter = getAdapter();
|
|
133
|
-
adapter.install('valdi-to-remove', '# Remove', { name: 'valdi-to-remove', description: 'R', tags: [], path: '', category: [] });
|
|
134
|
-
const legacyDir = path.join(tmpHome, '.cursor', 'rules');
|
|
135
|
-
fs.mkdirSync(legacyDir, { recursive: true });
|
|
136
|
-
fs.writeFileSync(path.join(legacyDir, 'valdi-valdi-to-remove.mdc'), 'old', 'utf8');
|
|
137
|
-
adapter.remove('valdi-to-remove');
|
|
138
|
-
expect(adapter.listInstalled()).not.toContain('valdi-to-remove');
|
|
139
|
-
expect(fs.existsSync(path.join(legacyDir, 'valdi-valdi-to-remove.mdc'))).toBe(false);
|
|
140
|
-
});
|
|
141
|
-
});
|