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,346 +0,0 @@
1
- import { test } from 'node:test';
2
- import assert from 'node:assert/strict';
3
- import fs from 'node:fs';
4
- import path from 'node:path';
5
- import { createTestProject, cleanupTestProject } from './helpers/setup.js';
6
-
7
- import {
8
- ensureEditorConfigForTypes,
9
- ensureNoCheckInPublicVendorFiles,
10
- extractStaticPropsFromSource,
11
- generateDeclarationContent,
12
- generateTypesFile
13
- } from '../commands/types/types.js';
14
-
15
- test('extractStaticPropsFromSource reads static props definitions', () => {
16
- const source = `
17
- export default class Button extends HTMLElement {
18
- static props = {
19
- value: { type: 'string', default: 'Button', allowedValues: ['Button', 'Submit'] },
20
- disabled: { type: 'boolean', default: false },
21
- size: { type: 'number', allowedValues: [12, 16, 20] },
22
- options: {
23
- type: 'object',
24
- schema: {
25
- theme: {
26
- type: 'object',
27
- schema: {
28
- mode: { type: 'string', allowedValues: ['light', 'dark'] }
29
- }
30
- }
31
- }
32
- },
33
- steps: {
34
- type: 'array',
35
- items: {
36
- type: 'object',
37
- schema: {
38
- id: { type: 'string', required: true },
39
- enabled: { type: 'boolean', default: true }
40
- }
41
- }
42
- },
43
- onClickCallback: { type: 'function', required: true }
44
- };
45
- }
46
- `;
47
-
48
- const result = extractStaticPropsFromSource(source);
49
-
50
- assert.deepEqual(result, {
51
- value: { type: 'string', required: false, allowedValues: ['Button', 'Submit'] },
52
- disabled: { type: 'boolean', required: false },
53
- size: { type: 'number', required: false, allowedValues: [12, 16, 20] },
54
- options: {
55
- type: 'object',
56
- required: false,
57
- schema: {
58
- theme: {
59
- type: 'object',
60
- required: false,
61
- schema: {
62
- mode: {
63
- type: 'string',
64
- required: false,
65
- allowedValues: ['light', 'dark']
66
- }
67
- }
68
- }
69
- }
70
- },
71
- steps: {
72
- type: 'array',
73
- required: false,
74
- items: {
75
- type: 'object',
76
- required: false,
77
- schema: {
78
- id: { type: 'string', required: true },
79
- enabled: { type: 'boolean', required: false }
80
- }
81
- }
82
- },
83
- onClickCallback: { type: 'function', required: true }
84
- });
85
- });
86
-
87
- test('generateDeclarationContent creates build typing map', () => {
88
- const content = generateDeclarationContent({
89
- Button: {
90
- value: { type: 'string', required: false, allowedValues: ['primary', 'secondary', 'danger'] },
91
- size: { type: 'number', required: false, allowedValues: [12, 16] },
92
- disabled: { type: 'boolean', required: false },
93
- status: { type: 'string', required: false, allowedValues: ['ok', 1] },
94
- options: {
95
- type: 'object',
96
- required: false,
97
- schema: {
98
- mode: { type: 'string', required: false, allowedValues: ['light', 'dark'] }
99
- }
100
- },
101
- steps: {
102
- type: 'array',
103
- required: false,
104
- items: {
105
- type: 'object',
106
- required: false,
107
- schema: {
108
- id: { type: 'string', required: true }
109
- }
110
- }
111
- }
112
- },
113
- FetchManager: {
114
- baseUrl: { type: 'string', required: true }
115
- }
116
- });
117
-
118
- assert.match(content, /export interface ButtonProps/);
119
- assert.match(content, /\[key: string\]: unknown;/);
120
- assert.match(content, /value\?: 'primary' \| 'secondary' \| 'danger';/);
121
- assert.match(content, /size\?: 12 \| 16;/);
122
- assert.match(content, /disabled\?: boolean;/);
123
- assert.match(content, /status\?: string;/);
124
- assert.match(content, /export interface FetchManagerProps/);
125
- assert.match(content, /baseUrl: string;/);
126
- assert.match(content, /export interface SliceComponentPropsMap/);
127
- assert.match(content, /Button: ButtonProps;/);
128
- assert.match(content, /FetchManager: FetchManagerProps;/);
129
- assert.match(content, /options\?: \{/);
130
- assert.match(content, /mode\?: 'light' \| 'dark';/);
131
- assert.match(content, /steps\?: \{/);
132
- assert.match(content, /id: string;/);
133
- assert.match(content, /}\[\];/);
134
- assert.match(content, /declare module 'slicejs-web-framework'/);
135
- assert.match(content, /interface SliceApi \{/);
136
- assert.match(content, /export type SliceDynamicElement = HTMLElement & Record<string, any>;/);
137
- assert.match(content, /build<K extends SliceComponentName>/);
138
- assert.match(content, /getComponent<T extends SliceDynamicElement = SliceDynamicElement>\(/);
139
- assert.match(content, /componentSliceId: string/);
140
- assert.match(content, /\): T \| undefined;/);
141
- assert.match(content, /interface Element \{/);
142
- assert.match(content, /querySelector<E extends Element = HTMLElement>\(selectors: string\): E \| null;/);
143
- assert.match(content, /querySelectorAll<E extends Element = HTMLElement>\(selectors: string\): NodeListOf<E>;/);
144
- assert.match(content, /interface HTMLElement \{/);
145
- assert.match(content, /\[key: string\]: any;/);
146
- assert.match(content, /const slice: SliceBuildApi & Record<string, any>;/);
147
- assert.match(content, /interface EventTarget \{/);
148
- assert.match(content, /interface Event \{/);
149
- assert.match(content, /detail: any;/);
150
- assert.match(content, /currentTarget: any;/);
151
- });
152
-
153
- test('generateTypesFile creates declaration file from local components', async () => {
154
- const tmpRoot = await createTestProject();
155
- const srcDir = path.join(tmpRoot, 'src');
156
-
157
- try {
158
- const visualDir = path.join(srcDir, 'Components', 'Visual', 'Button');
159
- const noStaticDir = path.join(srcDir, 'Components', 'Visual', 'Tabs');
160
- const serviceDir = path.join(srcDir, 'Components', 'Service', 'FetchManager');
161
- const outputFile = path.join(srcDir, 'slice-build.generated.d.ts');
162
-
163
- fs.mkdirSync(visualDir, { recursive: true });
164
- fs.mkdirSync(noStaticDir, { recursive: true });
165
- fs.mkdirSync(serviceDir, { recursive: true });
166
-
167
- fs.writeFileSync(
168
- path.join(visualDir, 'Button.js'),
169
- `
170
- export default class Button extends HTMLElement {
171
- static props = {
172
- value: { type: 'string', default: 'Button', allowedValues: ['Button', 'Submit'] },
173
- size: { type: 'number', allowedValues: [12, 16] },
174
- disabled: { type: 'boolean', default: false }
175
- };
176
- }
177
- `,
178
- 'utf8'
179
- );
180
-
181
- fs.writeFileSync(
182
- path.join(noStaticDir, 'Tabs.js'),
183
- `
184
- export default class Tabs extends HTMLElement {
185
- constructor() {
186
- super();
187
- }
188
- }
189
- `,
190
- 'utf8'
191
- );
192
-
193
- fs.writeFileSync(
194
- path.join(serviceDir, 'FetchManager.js'),
195
- `
196
- export default class FetchManager extends HTMLElement {
197
- static props = {
198
- baseUrl: { type: 'string', required: true }
199
- };
200
- }
201
- `,
202
- 'utf8'
203
- );
204
-
205
- fs.writeFileSync(
206
- path.join(srcDir, 'Components', 'components.js'),
207
- 'const components = {"Button": "Visual", "Tabs": "Visual", "FetchManager": "Service"};\n\nexport default components;\n',
208
- 'utf8'
209
- );
210
-
211
- const result = await generateTypesFile({
212
- projectRoot: tmpRoot,
213
- outputPath: outputFile
214
- });
215
-
216
- assert.equal(result.componentsProcessed, 3);
217
- assert.equal(fs.existsSync(result.outputPath), true);
218
-
219
- const declaration = fs.readFileSync(result.outputPath, 'utf8');
220
- assert.match(declaration, /export interface ButtonProps/);
221
- assert.match(declaration, /value\?: 'Button' \| 'Submit';/);
222
- assert.match(declaration, /size\?: 12 \| 16;/);
223
- assert.match(declaration, /export interface TabsProps/);
224
- assert.match(declaration, /\[key: string\]: unknown;/);
225
- assert.match(declaration, /export interface FetchManagerProps/);
226
- assert.match(declaration, /Tabs: TabsProps;/);
227
- assert.match(declaration, /build<K extends SliceComponentName>/);
228
- } finally {
229
- await cleanupTestProject(tmpRoot);
230
- }
231
- });
232
-
233
- test('ensureEditorConfigForTypes creates jsconfig when missing', async () => {
234
- const tmpRoot = await createTestProject();
235
- const outputFile = path.join(tmpRoot, 'src', 'slice-build.generated.d.ts');
236
-
237
- try {
238
- fs.writeFileSync(outputFile, 'export {};\n', 'utf8');
239
-
240
- const result = await ensureEditorConfigForTypes({
241
- projectRoot: tmpRoot,
242
- outputPath: outputFile
243
- });
244
-
245
- assert.equal(result.mode, 'created_jsconfig');
246
-
247
- const jsconfigPath = path.join(tmpRoot, 'jsconfig.json');
248
- assert.equal(fs.existsSync(jsconfigPath), true);
249
-
250
- const jsconfig = JSON.parse(fs.readFileSync(jsconfigPath, 'utf8'));
251
- assert.equal(Array.isArray(jsconfig.include), true);
252
- assert.equal(jsconfig.include.includes('src/Components/**/*.js'), true);
253
- assert.equal(jsconfig.include.includes('src/**/*.d.ts'), true);
254
- assert.equal(jsconfig.include.includes('api/**/*.js'), false);
255
- assert.equal(jsconfig.include.includes('tests/**/*.js'), false);
256
- assert.equal(jsconfig.include.includes('src/**/*.js'), false);
257
- assert.equal(jsconfig.compilerOptions.checkJs, true);
258
- assert.equal(jsconfig.compilerOptions.strictNullChecks, false);
259
- assert.equal(jsconfig.compilerOptions.noImplicitAny, false);
260
- assert.equal(jsconfig.compilerOptions.strict, false);
261
- assert.equal(Array.isArray(jsconfig.exclude), true);
262
- assert.equal(jsconfig.exclude.includes('src/libs/**'), true);
263
- assert.equal(jsconfig.exclude.includes('tests/**'), true);
264
- } finally {
265
- await cleanupTestProject(tmpRoot);
266
- }
267
- });
268
-
269
- test('types functions use PathHelper with explicit projectRoot', async () => {
270
- const tmpRoot = await createTestProject({ visualComponents: ['Button'] });
271
- const srcDir = path.join(tmpRoot, 'src');
272
- const outputFile = path.join(srcDir, 'slice-build.generated.d.ts');
273
-
274
- try {
275
- const visualDir = path.join(srcDir, 'Components', 'Visual', 'Button');
276
- fs.writeFileSync(
277
- path.join(visualDir, 'Button.js'),
278
- `export default class Button extends HTMLElement {
279
- static props = { value: { type: 'string' } };
280
- }`,
281
- 'utf8'
282
- );
283
-
284
- const result = await generateTypesFile({
285
- projectRoot: tmpRoot,
286
- outputPath: outputFile
287
- });
288
-
289
- assert.equal(result.componentsProcessed, 1);
290
- assert.equal(fs.existsSync(result.outputPath), true);
291
-
292
- const declaration = fs.readFileSync(result.outputPath, 'utf8');
293
- assert.match(declaration, /export interface ButtonProps/);
294
- assert.match(declaration, /build<K extends SliceComponentName>/);
295
- } finally {
296
- await cleanupTestProject(tmpRoot);
297
- }
298
- });
299
-
300
- test('ensureEditorConfigForTypes augments existing jsconfig include list', async () => {
301
- const tmpRoot = await createTestProject();
302
- const outputFile = path.join(tmpRoot, 'src', 'slice-build.generated.d.ts');
303
- const jsconfigPath = path.join(tmpRoot, 'jsconfig.json');
304
-
305
- try {
306
- fs.writeFileSync(outputFile, 'export {};\n', 'utf8');
307
- fs.writeFileSync(
308
- jsconfigPath,
309
- JSON.stringify(
310
- {
311
- compilerOptions: {
312
- allowJs: true
313
- },
314
- include: ['src/Components/**/*.js', 'src/**/*.js', 'api/**/*.js', 'tests/**/*.js']
315
- },
316
- null,
317
- 2
318
- ),
319
- 'utf8'
320
- );
321
-
322
- const result = await ensureEditorConfigForTypes({
323
- projectRoot: tmpRoot,
324
- outputPath: outputFile
325
- });
326
-
327
- assert.equal(result.mode, 'updated_jsconfig');
328
-
329
- const jsconfig = JSON.parse(fs.readFileSync(jsconfigPath, 'utf8'));
330
- assert.equal(jsconfig.include.includes('src/Components/**/*.js'), true);
331
- assert.equal(jsconfig.include.includes('src/**/*.d.ts'), true);
332
- assert.equal(jsconfig.include.includes('src/**/*.js'), false);
333
- assert.equal(jsconfig.include.includes('api/**/*.js'), false);
334
- assert.equal(jsconfig.include.includes('tests/**/*.js'), false);
335
- assert.equal(jsconfig.compilerOptions.allowJs, true);
336
- assert.equal(jsconfig.compilerOptions.checkJs, true);
337
- assert.equal(jsconfig.compilerOptions.noImplicitAny, false);
338
- assert.equal(jsconfig.compilerOptions.strictNullChecks, false);
339
- assert.equal(jsconfig.compilerOptions.strict, false);
340
- assert.equal(Array.isArray(jsconfig.exclude), true);
341
- assert.equal(jsconfig.exclude.includes('src/libs/**'), true);
342
- assert.equal(jsconfig.exclude.includes('tests/**'), true);
343
- } finally {
344
- await cleanupTestProject(tmpRoot);
345
- }
346
- });
@@ -1,88 +0,0 @@
1
- import { test } from 'node:test';
2
- import assert from 'node:assert/strict';
3
- import Print from '../commands/Print.js';
4
- import { UpdateManager } from '../commands/utils/updateManager.js';
5
-
6
- test('notifyAvailableUpdates shows advisory output and never invokes interactive update flow', async () => {
7
- const manager = new UpdateManager();
8
- const calls = {
9
- display: 0,
10
- prompted: 0,
11
- info: [],
12
- error: []
13
- };
14
-
15
- manager.checkForUpdates = async () => ({
16
- hasUpdates: true,
17
- updates: [
18
- {
19
- name: 'slicejs-web-framework',
20
- displayName: 'Slice.js Framework',
21
- current: '2.4.3',
22
- latest: '2.5.0',
23
- type: 'framework'
24
- }
25
- ],
26
- allCurrent: false
27
- });
28
-
29
- manager.displayUpdates = () => {
30
- calls.display += 1;
31
- };
32
-
33
- manager.checkAndPromptUpdates = async () => {
34
- calls.prompted += 1;
35
- return true;
36
- };
37
-
38
- const originalInfo = Print.info;
39
- const originalError = Print.error;
40
-
41
- Print.info = (message) => calls.info.push(message);
42
- Print.error = (message) => calls.error.push(message);
43
-
44
- try {
45
- const result = await manager.notifyAvailableUpdates();
46
-
47
- assert.equal(result, true);
48
- assert.equal(calls.display, 1);
49
- assert.equal(calls.prompted, 0);
50
- assert.equal(calls.error.length, 0);
51
- assert.equal(calls.info.length, 1);
52
- assert.match(calls.info[0], /slice update/);
53
- } finally {
54
- Print.info = originalInfo;
55
- Print.error = originalError;
56
- }
57
- });
58
-
59
- test('notifyAvailableUpdates returns false and prints nothing when no updates are available', async () => {
60
- const manager = new UpdateManager();
61
- const calls = {
62
- display: 0,
63
- info: []
64
- };
65
-
66
- manager.checkForUpdates = async () => ({
67
- hasUpdates: false,
68
- updates: [],
69
- allCurrent: true
70
- });
71
-
72
- manager.displayUpdates = () => {
73
- calls.display += 1;
74
- };
75
-
76
- const originalInfo = Print.info;
77
- Print.info = (message) => calls.info.push(message);
78
-
79
- try {
80
- const result = await manager.notifyAvailableUpdates();
81
-
82
- assert.equal(result, false);
83
- assert.equal(calls.display, 0);
84
- assert.equal(calls.info.length, 0);
85
- } finally {
86
- Print.info = originalInfo;
87
- }
88
- });