slicejs-cli 3.5.0 → 3.6.0

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.
Files changed (39) hide show
  1. package/README.md +34 -15
  2. package/client.js +67 -20
  3. package/commands/createComponent/createComponent.js +6 -2
  4. package/commands/deleteComponent/deleteComponent.js +4 -0
  5. package/commands/doctor/doctor.js +78 -3
  6. package/commands/getComponent/getComponent.js +33 -25
  7. package/commands/init/init.js +106 -28
  8. package/commands/utils/PackageManager.js +148 -0
  9. package/commands/utils/VersionChecker.js +6 -4
  10. package/commands/utils/bundling/BundleGenerator.js +271 -38
  11. package/commands/utils/sliceScripts.js +21 -0
  12. package/commands/utils/updateManager.js +54 -35
  13. package/package.json +15 -1
  14. package/post.js +8 -16
  15. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -29
  16. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -25
  17. package/.github/pull_request_template.md +0 -22
  18. package/AGENTS.md +0 -247
  19. package/CODE_OF_CONDUCT.md +0 -126
  20. package/ECOSYSTEM.md +0 -9
  21. package/docs/superpowers/specs/2026-05-10-pwa-generate-design.md +0 -182
  22. package/tests/bundle-generator.test.js +0 -691
  23. package/tests/bundle-v2-register-output.test.js +0 -470
  24. package/tests/client-launcher-contract.test.js +0 -211
  25. package/tests/client-update-flow-contract.test.js +0 -272
  26. package/tests/component-registry-parse.test.js +0 -34
  27. package/tests/dependency-analyzer.test.js +0 -24
  28. package/tests/fixtures/components.js +0 -8
  29. package/tests/fixtures/sliceConfig.json +0 -74
  30. package/tests/getcomponent.test.js +0 -407
  31. package/tests/helpers/setup.js +0 -97
  32. package/tests/init-command-contract.test.js +0 -46
  33. package/tests/local-cli-delegation.test.js +0 -81
  34. package/tests/path-helper.test.js +0 -206
  35. package/tests/postinstall-command.test.js +0 -72
  36. package/tests/types-breakage.test.js +0 -491
  37. package/tests/types-generator-errors.test.js +0 -361
  38. package/tests/types-generator.test.js +0 -344
  39. package/tests/update-manager-notifications.test.js +0 -88
@@ -1,206 +0,0 @@
1
- import { test, describe, before, after } from 'node:test';
2
- import assert from 'node:assert/strict';
3
- import path from 'node:path';
4
- import fs from 'node:fs';
5
- import { createTestProject, cleanupTestProject } from './helpers/setup.js';
6
-
7
- /** @type {string} */
8
- let tmpRoot;
9
- const origInitCwd = process.env.INIT_CWD;
10
-
11
- before(async () => {
12
- tmpRoot = await createTestProject();
13
- process.env.INIT_CWD = tmpRoot;
14
- });
15
-
16
- after(async () => {
17
- if (origInitCwd === undefined) {
18
- delete process.env.INIT_CWD;
19
- } else {
20
- process.env.INIT_CWD = origInitCwd;
21
- }
22
- await cleanupTestProject(tmpRoot);
23
- });
24
-
25
- describe('getProjectRoot', () => {
26
- test('resolves project root via INIT_CWD when pointing to a real project', async () => {
27
- const { getProjectRoot } = await import('../commands/utils/PathHelper.js');
28
- const root = getProjectRoot(import.meta.url);
29
- assert.ok(root, 'should return a path');
30
- assert.ok(fs.existsSync(root), `resolved path should exist: ${root}`);
31
- assert.equal(path.resolve(root), path.resolve(tmpRoot));
32
- });
33
-
34
- test('resolves project root via cwd when INIT_CWD is not set', async () => {
35
- const prev = process.env.INIT_CWD;
36
- delete process.env.INIT_CWD;
37
- try {
38
- const { getProjectRoot } = await import('../commands/utils/PathHelper.js');
39
- const root = getProjectRoot(import.meta.url);
40
- assert.ok(root, 'should return a path');
41
- assert.ok(fs.existsSync(root), `resolved path should exist: ${root}`);
42
- } finally {
43
- process.env.INIT_CWD = prev;
44
- }
45
- });
46
- });
47
-
48
- describe('getSrcPath', () => {
49
- test('returns src path relative to project root', async () => {
50
- const { getSrcPath } = await import('../commands/utils/PathHelper.js');
51
- const srcPath = getSrcPath(import.meta.url);
52
- assert.ok(srcPath.endsWith('src'), `should end with 'src': ${srcPath}`);
53
- assert.ok(fs.existsSync(srcPath), `src path should exist: ${srcPath}`);
54
- });
55
-
56
- test('accepts subpath segments', async () => {
57
- const { getSrcPath } = await import('../commands/utils/PathHelper.js');
58
- const result = getSrcPath(import.meta.url, 'Components', 'components.js');
59
- assert.ok(result.endsWith('src/Components/components.js') || result.endsWith('src\\Components\\components.js'));
60
- assert.ok(fs.existsSync(result), `file should exist: ${result}`);
61
- });
62
- });
63
-
64
- describe('getApiPath', () => {
65
- test('returns api path relative to project root', async () => {
66
- const { getApiPath } = await import('../commands/utils/PathHelper.js');
67
- const apiPath = getApiPath(import.meta.url);
68
- assert.ok(apiPath.endsWith('api'), `should end with 'api': ${apiPath}`);
69
- assert.ok(fs.existsSync(apiPath), `api path should exist: ${apiPath}`);
70
- });
71
-
72
- test('appends subpath to api', async () => {
73
- const { getApiPath } = await import('../commands/utils/PathHelper.js');
74
- const result = getApiPath(import.meta.url, 'index.js');
75
- assert.ok(result.endsWith('api/index.js') || result.endsWith('api\\index.js'));
76
- });
77
- });
78
-
79
- describe('getDistPath', () => {
80
- test('returns dist path relative to project root', async () => {
81
- const { getDistPath } = await import('../commands/utils/PathHelper.js');
82
- const distPath = getDistPath(import.meta.url);
83
- assert.ok(distPath.endsWith('dist'), `should end with 'dist': ${distPath}`);
84
- });
85
- });
86
-
87
- describe('getConfigPath', () => {
88
- test('returns sliceConfig.json path', async () => {
89
- const { getConfigPath } = await import('../commands/utils/PathHelper.js');
90
- const configPath = getConfigPath(import.meta.url);
91
- assert.ok(configPath.endsWith('sliceConfig.json'), `should end with 'sliceConfig.json': ${configPath}`);
92
- assert.ok(fs.existsSync(configPath), `config file should exist: ${configPath}`);
93
- });
94
- });
95
-
96
- describe('getComponentsJsPath', () => {
97
- test('returns components.js path', async () => {
98
- const { getComponentsJsPath } = await import('../commands/utils/PathHelper.js');
99
- const compPath = getComponentsJsPath(import.meta.url);
100
- assert.ok(compPath.endsWith('components.js'), `should end with 'components.js': ${compPath}`);
101
- assert.ok(fs.existsSync(compPath), `components.js should exist: ${compPath}`);
102
- });
103
- });
104
-
105
- describe('getPath', () => {
106
- test('joins arbitrary segments to project root', async () => {
107
- const { getPath } = await import('../commands/utils/PathHelper.js');
108
- const result = getPath(import.meta.url, 'src', 'routes.js');
109
- assert.ok(result.endsWith('routes.js'), `should end with 'routes.js': ${result}`);
110
- assert.ok(fs.existsSync(result), `routes.js should exist: ${result}`);
111
- });
112
-
113
- test('sanitizes leading slashes from segments', async () => {
114
- const { getPath } = await import('../commands/utils/PathHelper.js');
115
- const result = getPath(import.meta.url, '/src/', '/routes.js');
116
- assert.ok(result.endsWith('routes.js'), `should handle sanitized segments: ${result}`);
117
- });
118
- });
119
-
120
- describe('resolveProjectRoot (fallback via candidates)', () => {
121
- test('uses candidates() when INIT_CWD is not a valid path', async () => {
122
- const orig = process.env.INIT_CWD;
123
- process.env.INIT_CWD = 'C:\\nonexistent\\path';
124
-
125
- try {
126
- const { getProjectRoot } = await import('../commands/utils/PathHelper.js');
127
- const root = getProjectRoot(import.meta.url);
128
- assert.ok(root, 'should return a path');
129
- assert.ok(fs.existsSync(root), `fallback path should exist: ${root}`);
130
- } finally {
131
- process.env.INIT_CWD = orig;
132
- }
133
- });
134
- });
135
-
136
- describe('joinRoot', () => {
137
- test('joins segments relative to explicit root path', async () => {
138
- const { joinRoot } = await import('../commands/utils/PathHelper.js');
139
- const root = path.resolve('/test/project');
140
- const result = joinRoot(root, 'src', 'components');
141
- assert.equal(result, path.join(root, 'src', 'components'));
142
- });
143
-
144
- test('sanitizes leading slashes from segments', async () => {
145
- const { joinRoot } = await import('../commands/utils/PathHelper.js');
146
- const root = path.resolve('/test/project');
147
- const result = joinRoot(root, '/src', '/components');
148
- assert.equal(result, path.join(root, 'src', 'components'));
149
- });
150
-
151
- test('handles single segment', async () => {
152
- const { joinRoot } = await import('../commands/utils/PathHelper.js');
153
- const root = path.resolve('/test/project');
154
- const result = joinRoot(root, 'package.json');
155
- assert.equal(result, path.join(root, 'package.json'));
156
- });
157
-
158
- test('handles empty segments', async () => {
159
- const { joinRoot } = await import('../commands/utils/PathHelper.js');
160
- const root = path.resolve('/test/project');
161
- const result = joinRoot(root);
162
- assert.equal(result, root);
163
- });
164
- });
165
-
166
- describe('getConfigPath with explicit root', () => {
167
- test('returns sliceConfig.json under explicit root', async () => {
168
- const { getConfigPath } = await import('../commands/utils/PathHelper.js');
169
- const explicitRoot = path.resolve('/custom/project');
170
- const result = getConfigPath(import.meta.url, explicitRoot);
171
- assert.equal(result, path.join(explicitRoot, 'src', 'sliceConfig.json'));
172
- });
173
-
174
- test('returns sliceConfig.json without root (auto-resolve)', async () => {
175
- const { getConfigPath } = await import('../commands/utils/PathHelper.js');
176
- const result = getConfigPath(import.meta.url);
177
- assert.ok(result.endsWith('sliceConfig.json'));
178
- assert.ok(fs.existsSync(result));
179
- });
180
- });
181
-
182
- describe('getComponentsJsPath with explicit root', () => {
183
- test('returns components.js under explicit root', async () => {
184
- const { getComponentsJsPath } = await import('../commands/utils/PathHelper.js');
185
- const explicitRoot = path.resolve('/custom/project');
186
- const result = getComponentsJsPath(import.meta.url, explicitRoot);
187
- assert.equal(result, path.join(explicitRoot, 'src', 'Components', 'components.js'));
188
- });
189
-
190
- test('returns components.js without root (auto-resolve)', async () => {
191
- const { getComponentsJsPath } = await import('../commands/utils/PathHelper.js');
192
- const result = getComponentsJsPath(import.meta.url);
193
- assert.ok(result.endsWith('components.js'));
194
- assert.ok(fs.existsSync(result));
195
- });
196
- });
197
-
198
- describe('getSrcPath integration', () => {
199
- test('getSrcPath matches joinRoot with src prefix', async () => {
200
- const { getSrcPath, getProjectRoot, joinRoot } = await import('../commands/utils/PathHelper.js');
201
- const root = getProjectRoot(import.meta.url);
202
- const viaHelper = getSrcPath(import.meta.url, 'Components', 'components.js');
203
- const viaJoinRoot = joinRoot(root, 'src', 'Components', 'components.js');
204
- assert.equal(viaHelper, viaJoinRoot);
205
- });
206
- });
@@ -1,72 +0,0 @@
1
- import { test, describe } from 'node:test';
2
- import assert from 'node:assert/strict';
3
- import fs from 'node:fs';
4
- import path from 'node:path';
5
- import { fileURLToPath } from 'node:url';
6
-
7
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
8
- const clientPath = path.join(__dirname, '..', 'client.js');
9
- const source = fs.readFileSync(clientPath, 'utf-8');
10
-
11
- test('postinstall command is registered in client.js', () => {
12
- const hasSetupCommand = source.includes('.command("postinstall")');
13
- assert.ok(hasSetupCommand, 'client.js must register a "postinstall" command');
14
- });
15
-
16
- test('postinstall command has a description', () => {
17
- const match = source.match(/\.command\(["']postinstall["']\)\s*\.description\(["']([^"']+)["']\)/);
18
- assert.ok(match, 'postinstall command must have a .description() call');
19
- assert.ok(match[1].length > 0, 'postinstall command description must not be empty');
20
- });
21
-
22
- test('postinstall command checks npm_config_global environment variable', () => {
23
- const hasGlobalCheck = source.includes('npm_config_global');
24
- assert.ok(hasGlobalCheck, 'postinstall command must check npm_config_global to detect global installation');
25
- });
26
-
27
- test('postinstall command prints global install warning', () => {
28
- const hasGlobalWarning = source.includes('Global installation');
29
- assert.ok(hasGlobalWarning, 'postinstall command must warn about global installation');
30
- });
31
-
32
- test('postinstall command prints local install success message', () => {
33
- const hasSuccessMsg = source.includes('installed successfully');
34
- assert.ok(hasSuccessMsg, 'postinstall command must show success message for local installs');
35
- });
36
-
37
- test('postinstall command uses getProjectRoot from PathHelper', () => {
38
- const hasPathHelper = source.includes("getProjectRoot(import.meta.url)");
39
- assert.ok(hasPathHelper, 'postinstall command must use getProjectRoot resolver');
40
- });
41
-
42
- test('postinstall command writes npm scripts to package.json via fs', () => {
43
- const hasFsWrite = source.includes('writeFileSync(pkgPath');
44
- assert.ok(hasFsWrite, 'postinstall command must write scripts to package.json');
45
- });
46
-
47
- test('postinstall command writes slice:dev script to package.json', () => {
48
- const hasDevScript = source.includes("'slice:dev': 'slice dev'");
49
- assert.ok(hasDevScript, 'postinstall command must add "slice:dev" script to package.json');
50
- });
51
-
52
- test('postinstall command writes all slice:* scripts to package.json', () => {
53
- const scripts = [
54
- 'slice:dev', 'slice:start', 'slice:create', 'slice:list',
55
- 'slice:delete', 'slice:init', 'slice:get', 'slice:browse',
56
- 'slice:sync', 'slice:version', 'slice:update'
57
- ];
58
- for (const script of scripts) {
59
- assert.ok(source.includes(script), `postinstall command must configure ${script} script`);
60
- }
61
- });
62
-
63
- test('postinstall command action is a function', () => {
64
- const SetupActionPattern = /\.command\(["']postinstall["']\)[\s\S]*?\.action\(\(\)\s*=>\s*\{[\s\S]*?\}\)/;
65
- const match = source.match(SetupActionPattern);
66
- assert.ok(match, 'postinstall command must have an .action() with arrow function');
67
- });
68
-
69
- test('postinstall command provides npm uninstall -g instruction for global installs', () => {
70
- const hasUninstallInstruction = source.includes('npm uninstall -g slicejs-cli');
71
- assert.ok(hasUninstallInstruction, 'postinstall command must tell users how to uninstall global CLI');
72
- });