@principles/install-layout 0.2.6 → 0.2.7
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 +4 -2
- package/dist/index.test.d.ts +0 -1
- package/dist/index.test.js +0 -69
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@principles/install-layout",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -22,7 +22,9 @@
|
|
|
22
22
|
"access": "public"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
|
-
"build": "tsc",
|
|
25
|
+
"build": "npm run clean && tsc -p tsconfig.build.json && node ../../scripts/build/check-dist-hygiene.mjs",
|
|
26
|
+
"clean": "node ../../scripts/build/clean-dist.mjs",
|
|
27
|
+
"typecheck": "tsc --noEmit",
|
|
26
28
|
"test": "npm run build && vitest run"
|
|
27
29
|
},
|
|
28
30
|
"devDependencies": {
|
package/dist/index.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/index.test.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import * as path from 'node:path';
|
|
3
|
-
import { getInstallLayoutPaths, getConsoleServerEntry, parseInstallManifest, resolveInstallLayout, mergeInstallManifestWorkspaces, } from './index.js';
|
|
4
|
-
describe('install layout', () => {
|
|
5
|
-
it('resolves a canonical Codex-only install without OpenClaw', () => {
|
|
6
|
-
const paths = getInstallLayoutPaths('C:/Users/alice');
|
|
7
|
-
const result = resolveInstallLayout({
|
|
8
|
-
homeDir: 'C:/Users/alice',
|
|
9
|
-
manifest: { layoutVersion: 1, mode: 'canonical', hosts: ['codex'] },
|
|
10
|
-
canonicalRuntimeExists: true,
|
|
11
|
-
legacyExtensionExists: false,
|
|
12
|
-
});
|
|
13
|
-
expect(result.mode).toBe('canonical');
|
|
14
|
-
expect(result.manifest?.hosts).toEqual(['codex']);
|
|
15
|
-
expect(paths.openClawExtensionDir).toContain('.openclaw');
|
|
16
|
-
expect(paths.pluginDir).toContain('plugin');
|
|
17
|
-
expect(paths.installLayoutDir).toContain('install-layout');
|
|
18
|
-
expect(getConsoleServerEntry(result.paths, 'canonical')).toContain('.pd');
|
|
19
|
-
});
|
|
20
|
-
it('falls back to legacy only when the old extension exists', () => {
|
|
21
|
-
const result = resolveInstallLayout({
|
|
22
|
-
homeDir: '/home/alice',
|
|
23
|
-
manifest: undefined,
|
|
24
|
-
canonicalRuntimeExists: false,
|
|
25
|
-
legacyExtensionExists: true,
|
|
26
|
-
});
|
|
27
|
-
expect(result.mode).toBe('legacy');
|
|
28
|
-
expect(result.nextAction).toContain('migrate');
|
|
29
|
-
});
|
|
30
|
-
it('rejects malformed manifests instead of silently treating them as canonical', () => {
|
|
31
|
-
expect(parseInstallManifest({ layoutVersion: 1, mode: 'canonical', hosts: ['wat'] })).toEqual({
|
|
32
|
-
error: 'install_manifest_malformed: hosts must contain codex and/or openclaw',
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
it('accepts a manifest without workspaces (pre-PRI-624 manifests stay valid)', () => {
|
|
36
|
-
const { manifest, error } = parseInstallManifest({ layoutVersion: 1, mode: 'canonical', hosts: ['codex'] });
|
|
37
|
-
expect(error).toBeUndefined();
|
|
38
|
-
expect(manifest?.workspaces).toEqual([]);
|
|
39
|
-
});
|
|
40
|
-
it('parses workspaces as canonical absolute paths, deduped in insertion order', () => {
|
|
41
|
-
const { manifest, error } = parseInstallManifest({
|
|
42
|
-
layoutVersion: 1,
|
|
43
|
-
mode: 'canonical',
|
|
44
|
-
hosts: ['codex'],
|
|
45
|
-
workspaces: ['D:/Code/ws-a', 'D:\\Code\\ws-a', 'C:/work/ws b'],
|
|
46
|
-
});
|
|
47
|
-
expect(error).toBeUndefined();
|
|
48
|
-
expect(manifest?.workspaces?.length).toBe(2);
|
|
49
|
-
expect(manifest?.workspaces?.[0]).toBe(path.resolve('D:/Code/ws-a'));
|
|
50
|
-
expect(manifest?.workspaces).toContain(path.resolve('C:/work/ws b'));
|
|
51
|
-
});
|
|
52
|
-
it('rejects malformed workspace entries loudly', () => {
|
|
53
|
-
expect(parseInstallManifest({ layoutVersion: 1, mode: 'canonical', hosts: ['codex'], workspaces: [''] })).toEqual({
|
|
54
|
-
error: 'install_manifest_malformed: workspaces must be non-empty absolute paths',
|
|
55
|
-
});
|
|
56
|
-
expect(parseInstallManifest({ layoutVersion: 1, mode: 'canonical', hosts: ['codex'], workspaces: ['ws-a'] })).toEqual({
|
|
57
|
-
error: 'install_manifest_malformed: workspaces must be non-empty absolute paths',
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
it('merges a workspace into an existing manifest without duplicates', () => {
|
|
61
|
-
const merged = mergeInstallManifestWorkspaces({ layoutVersion: 1, mode: 'canonical', hosts: ['codex'], workspaces: ['D:/Code/ws-a'] }, 'D:\\Code\\ws-a');
|
|
62
|
-
expect(merged.length).toBe(1);
|
|
63
|
-
expect(merged[0]).toBe(path.resolve('D:/Code/ws-a'));
|
|
64
|
-
});
|
|
65
|
-
it('merge accepts unknown current manifests and starts a fresh list', () => {
|
|
66
|
-
const merged = mergeInstallManifestWorkspaces(undefined, 'D:/Code/ws-b');
|
|
67
|
-
expect(merged).toEqual([path.resolve('D:/Code/ws-b')]);
|
|
68
|
-
});
|
|
69
|
-
});
|