slicejs-cli 3.5.1 → 3.6.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.
Files changed (75) hide show
  1. package/README.md +81 -26
  2. package/client.js +73 -23
  3. package/commands/buildProduction/buildProduction.js +6 -3
  4. package/commands/doctor/doctor.js +68 -3
  5. package/commands/getComponent/getComponent.js +33 -25
  6. package/commands/init/init.js +176 -49
  7. package/commands/utils/PackageManager.js +148 -0
  8. package/commands/utils/VersionChecker.js +6 -4
  9. package/commands/utils/sliceScripts.js +23 -0
  10. package/commands/utils/updateManager.js +54 -35
  11. package/package.json +12 -1
  12. package/post.js +13 -19
  13. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -29
  14. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -25
  15. package/.github/pull_request_template.md +0 -22
  16. package/.github/workflows/ci.yml +0 -43
  17. package/AGENTS.md +0 -247
  18. package/CODE_OF_CONDUCT.md +0 -126
  19. package/ECOSYSTEM.md +0 -9
  20. package/docs/superpowers/specs/2026-05-10-pwa-generate-design.md +0 -182
  21. package/playwright.config.js +0 -51
  22. package/tests/build-command-integration.test.js +0 -87
  23. package/tests/build-production-e2e.test.js +0 -140
  24. package/tests/builder-edge-cases.test.js +0 -322
  25. package/tests/bundle-generate-e2e.test.js +0 -115
  26. package/tests/bundle-generator.test.js +0 -691
  27. package/tests/bundle-v2-register-output.test.js +0 -470
  28. package/tests/bundling-dependency-edges.test.js +0 -127
  29. package/tests/bundling-imports-unit.test.js +0 -267
  30. package/tests/client-launcher-contract.test.js +0 -211
  31. package/tests/client-update-flow-contract.test.js +0 -272
  32. package/tests/commands-component-crud.test.js +0 -102
  33. package/tests/commands-doctor.test.js +0 -80
  34. package/tests/commands-version-checker.test.js +0 -37
  35. package/tests/component-registry-parse.test.js +0 -34
  36. package/tests/dependency-analyzer.test.js +0 -24
  37. package/tests/e2e/bundles.spec.js +0 -91
  38. package/tests/e2e/dependency-scenarios.spec.js +0 -56
  39. package/tests/e2e/fixtures/components/Service/FetchManager/FetchManager.js +0 -136
  40. package/tests/e2e/fixtures/components/Service/IndexedDbManager/IndexedDbManager.js +0 -149
  41. package/tests/e2e/fixtures/components/Service/LocalStorageManager/LocalStorageManager.js +0 -45
  42. package/tests/e2e/fixtures/components/Visual/Button/Button.css +0 -106
  43. package/tests/e2e/fixtures/components/Visual/Button/Button.html +0 -5
  44. package/tests/e2e/fixtures/components/Visual/Button/Button.js +0 -158
  45. package/tests/e2e/fixtures/components/Visual/Link/Link.js +0 -33
  46. package/tests/e2e/fixtures/components/Visual/Loading/Loading.css +0 -56
  47. package/tests/e2e/fixtures/components/Visual/Loading/Loading.html +0 -83
  48. package/tests/e2e/fixtures/components/Visual/Loading/Loading.js +0 -164
  49. package/tests/e2e/fixtures/components/Visual/MultiRoute/MultiRoute.js +0 -167
  50. package/tests/e2e/fixtures/components/Visual/Navbar/Navbar.css +0 -116
  51. package/tests/e2e/fixtures/components/Visual/Navbar/Navbar.html +0 -44
  52. package/tests/e2e/fixtures/components/Visual/Navbar/Navbar.js +0 -180
  53. package/tests/e2e/fixtures/components/Visual/NotFound/NotFound.js +0 -20
  54. package/tests/e2e/fixtures/components/Visual/Route/Route.js +0 -181
  55. package/tests/e2e/fixtures/components/registry.json +0 -12
  56. package/tests/e2e/fixtures/vendor-components.mjs +0 -65
  57. package/tests/e2e/navigation.spec.js +0 -44
  58. package/tests/e2e/render.spec.js +0 -34
  59. package/tests/e2e/serve.mjs +0 -264
  60. package/tests/e2e/shared-deps.spec.js +0 -61
  61. package/tests/e2e/unminified.spec.js +0 -33
  62. package/tests/e2e-serve.test.js +0 -148
  63. package/tests/fixtures/components.js +0 -8
  64. package/tests/fixtures/sliceConfig.json +0 -74
  65. package/tests/getcomponent.test.js +0 -407
  66. package/tests/helpers/setup.js +0 -102
  67. package/tests/init-command-contract.test.js +0 -46
  68. package/tests/local-cli-delegation.test.js +0 -81
  69. package/tests/path-helper.test.js +0 -206
  70. package/tests/perf-budget.test.js +0 -86
  71. package/tests/postinstall-command.test.js +0 -72
  72. package/tests/types-breakage.test.js +0 -491
  73. package/tests/types-generator-errors.test.js +0 -361
  74. package/tests/types-generator.test.js +0 -346
  75. 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,86 +0,0 @@
1
- import { test } from 'node:test';
2
- import assert from 'node:assert/strict';
3
- import path from 'node:path';
4
- import { fileURLToPath } from 'node:url';
5
- import fs from 'fs-extra';
6
- import { createTestProject, cleanupTestProject } from './helpers/setup.js';
7
-
8
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
9
- const FIXTURES = path.resolve(__dirname, 'e2e/fixtures/components');
10
- const FW_PKG = path.resolve(__dirname, '../node_modules/slicejs-web-framework');
11
-
12
- // Performance budgets for the realistic starter app (App Shell + the vendored
13
- // starter components). Bundle byte sizes are fully deterministic, so a surprise
14
- // failure here means a change degraded the output — review it, and only bump a
15
- // budget when the growth is intentional. (Actuals shown for reference.)
16
- const BUDGET = {
17
- bundleCount: 5, // actual: 4
18
- totalBundleBytes: 165_000, // actual: ~133.6 KB
19
- criticalBytes: 51_200, // actual: ~40.8 KB (bundler's own critical cap is 50 KB)
20
- frameworkBytes: 85_000, // actual: ~67.4 KB (tracks the slicejs-web-framework package)
21
- buildMs: 30_000, // actual: ~1 s — generous ceiling to catch pathological slowdowns
22
- };
23
-
24
- async function assembleAndBuild() {
25
- process.env.NODE_ENV = 'production';
26
- const app = await createTestProject();
27
-
28
- await fs.ensureDir(path.join(app, 'node_modules'));
29
- await fs
30
- .ensureSymlink(FW_PKG, path.join(app, 'node_modules', 'slicejs-web-framework'), 'dir')
31
- .catch(() => fs.copy(FW_PKG, path.join(app, 'node_modules', 'slicejs-web-framework')));
32
-
33
- await fs.copy(path.join(FIXTURES, 'Visual'), path.join(app, 'src', 'Components', 'Visual'));
34
- await fs.copy(path.join(FIXTURES, 'Service'), path.join(app, 'src', 'Components', 'Service'));
35
-
36
- process.env.INIT_CWD = app;
37
- (await import('../commands/listComponents/listComponents.js')).default();
38
-
39
- const build = (await import('../commands/build/build.js')).default;
40
- const start = Date.now();
41
- const ok = await build({ minify: true, obfuscate: true });
42
- const buildMs = Date.now() - start;
43
- assert.equal(ok, true, 'build should succeed');
44
- return { app, buildMs };
45
- }
46
-
47
- test('production build stays within performance budgets', async () => {
48
- const { app, buildMs } = await assembleAndBuild();
49
- try {
50
- const bundlesDir = path.join(app, 'dist', 'bundles');
51
- const files = (await fs.readdir(bundlesDir)).filter(
52
- (f) => f.startsWith('slice-bundle.') && f.endsWith('.js')
53
- );
54
-
55
- const sizes = {};
56
- let totalBundleBytes = 0;
57
- for (const f of files) {
58
- sizes[f] = (await fs.stat(path.join(bundlesDir, f))).size;
59
- totalBundleBytes += sizes[f];
60
- }
61
- const cfg = await fs.readJson(path.join(bundlesDir, 'bundle.config.json'));
62
- const criticalBytes = sizes['slice-bundle.critical.js'] || 0;
63
- const frameworkBytes = sizes['slice-bundle.framework.js'] || 0;
64
-
65
- // Always print the metrics so trends are visible even on a passing run.
66
- console.log(
67
- `\n [perf] bundles=${files.length} total=${Math.round(totalBundleBytes / 1024)}KB ` +
68
- `critical=${Math.round(criticalBytes / 1024)}KB framework=${Math.round(frameworkBytes / 1024)}KB ` +
69
- `requestReduction=${100 - Math.round((files.length / cfg.stats.totalComponents) * 100)}% build=${buildMs}ms`
70
- );
71
-
72
- assert.ok(files.length <= BUDGET.bundleCount, `bundle count ${files.length} exceeds budget ${BUDGET.bundleCount}`);
73
- assert.ok(
74
- totalBundleBytes <= BUDGET.totalBundleBytes,
75
- `total bundle bytes ${totalBundleBytes} exceeds budget ${BUDGET.totalBundleBytes}`
76
- );
77
- assert.ok(criticalBytes <= BUDGET.criticalBytes, `critical bundle ${criticalBytes} exceeds budget ${BUDGET.criticalBytes}`);
78
- assert.ok(frameworkBytes <= BUDGET.frameworkBytes, `framework bundle ${frameworkBytes} exceeds budget ${BUDGET.frameworkBytes}`);
79
- assert.ok(buildMs <= BUDGET.buildMs, `build took ${buildMs}ms, over budget ${BUDGET.buildMs}ms`);
80
-
81
- // Sanity: the realistic app actually bundled its full component set.
82
- assert.ok(cfg.stats.totalComponents >= 20, `unexpectedly few components bundled: ${cfg.stats.totalComponents}`);
83
- } finally {
84
- await cleanupTestProject(app);
85
- }
86
- });
@@ -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
- });