@algotao/uiscope 0.1.0 → 0.1.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/package.json
CHANGED
|
@@ -7,14 +7,17 @@ import { fileURLToPath } from 'node:url';
|
|
|
7
7
|
|
|
8
8
|
const scriptDir = path.dirname(fileURLToPath(import.meta.url));
|
|
9
9
|
|
|
10
|
-
function
|
|
10
|
+
function resolveCliPath() {
|
|
11
11
|
const require = createRequire(import.meta.url);
|
|
12
12
|
try {
|
|
13
|
-
return
|
|
13
|
+
return require.resolve('@algotao/uiscope/bin/uiscope.js');
|
|
14
14
|
} catch {
|
|
15
|
+
const fromPkgSkill = path.resolve(scriptDir, '../../../..');
|
|
16
|
+
const nested = path.join(fromPkgSkill, 'bin/uiscope.js');
|
|
17
|
+
if (fs.existsSync(nested)) return nested;
|
|
15
18
|
const fromSkillLayout = path.resolve(scriptDir, '../../..');
|
|
16
19
|
if (fs.existsSync(path.join(fromSkillLayout, 'bin/uiscope.js'))) {
|
|
17
|
-
return fromSkillLayout;
|
|
20
|
+
return path.join(fromSkillLayout, 'bin/uiscope.js');
|
|
18
21
|
}
|
|
19
22
|
throw new Error(
|
|
20
23
|
[
|
|
@@ -26,7 +29,7 @@ function resolvePackageRoot() {
|
|
|
26
29
|
}
|
|
27
30
|
}
|
|
28
31
|
|
|
29
|
-
const cli =
|
|
32
|
+
const cli = resolveCliPath();
|
|
30
33
|
const child = spawnSync(process.execPath, [cli, ...process.argv.slice(2)], {
|
|
31
34
|
stdio: 'inherit',
|
|
32
35
|
cwd: process.cwd(),
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
import { afterEach, describe, expect, it } from 'vitest';
|
|
7
|
+
import { runInstallSkill } from '../cli/install-skill.js';
|
|
8
|
+
|
|
9
|
+
const pkgRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..');
|
|
10
|
+
|
|
11
|
+
describe('skill forwarder uiscope.mjs', () => {
|
|
12
|
+
const tmpRoots: string[] = [];
|
|
13
|
+
|
|
14
|
+
afterEach(() => {
|
|
15
|
+
for (const root of tmpRoots) {
|
|
16
|
+
fs.rmSync(root, { recursive: true, force: true });
|
|
17
|
+
}
|
|
18
|
+
tmpRoots.length = 0;
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it(
|
|
22
|
+
'forwards to published-layout CLI after npm install',
|
|
23
|
+
() => {
|
|
24
|
+
const packDir = fs.mkdtempSync(path.join(os.tmpdir(), 'uiscope-pack-'));
|
|
25
|
+
tmpRoots.push(packDir);
|
|
26
|
+
const pack = spawnSync('npm', ['pack', '--pack-destination', packDir], {
|
|
27
|
+
cwd: pkgRoot,
|
|
28
|
+
encoding: 'utf8',
|
|
29
|
+
shell: true,
|
|
30
|
+
});
|
|
31
|
+
expect(pack.status).toBe(0);
|
|
32
|
+
const tgz = pack.stdout
|
|
33
|
+
.trim()
|
|
34
|
+
.split(/\r?\n/)
|
|
35
|
+
.filter((l) => l.endsWith('.tgz'))
|
|
36
|
+
.pop();
|
|
37
|
+
expect(tgz).toBeTruthy();
|
|
38
|
+
|
|
39
|
+
const cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'uiscope-fwd-'));
|
|
40
|
+
tmpRoots.push(cwd);
|
|
41
|
+
expect(spawnSync('npm', ['init', '-y'], { cwd, shell: true }).status).toBe(0);
|
|
42
|
+
const install = spawnSync('npm', ['install', path.join(packDir, tgz!)], { cwd, shell: true });
|
|
43
|
+
expect(install.status).toBe(0);
|
|
44
|
+
|
|
45
|
+
expect(runInstallSkill(cwd, {})).toBe(0);
|
|
46
|
+
const script = path.join(cwd, '.cursor/skills/uiscope-ux-optimize/scripts/uiscope.mjs');
|
|
47
|
+
const r = spawnSync(process.execPath, [script, '--help'], { cwd, encoding: 'utf8' });
|
|
48
|
+
expect(r.status, r.stderr).toBe(0);
|
|
49
|
+
expect(r.stdout).toContain('uiscope [install');
|
|
50
|
+
},
|
|
51
|
+
120_000,
|
|
52
|
+
);
|
|
53
|
+
});
|