slicejs-cli 3.3.0 → 3.4.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 (46) hide show
  1. package/AGENTS.md +247 -0
  2. package/LICENSE +21 -21
  3. package/client.js +663 -626
  4. package/commands/Print.js +163 -167
  5. package/commands/Validations.js +92 -103
  6. package/commands/build/build.js +40 -40
  7. package/commands/buildProduction/buildProduction.js +576 -579
  8. package/commands/bundle/bundle.js +234 -235
  9. package/commands/createComponent/VisualComponentTemplate.js +55 -55
  10. package/commands/createComponent/createComponent.js +124 -126
  11. package/commands/deleteComponent/deleteComponent.js +77 -77
  12. package/commands/doctor/doctor.js +366 -369
  13. package/commands/getComponent/getComponent.js +684 -747
  14. package/commands/init/init.js +269 -261
  15. package/commands/listComponents/listComponents.js +172 -175
  16. package/commands/startServer/startServer.js +261 -264
  17. package/commands/startServer/watchServer.js +79 -79
  18. package/commands/types/types.js +69 -27
  19. package/commands/utils/LocalCliDelegation.js +53 -53
  20. package/commands/utils/PathHelper.js +75 -68
  21. package/commands/utils/VersionChecker.js +167 -167
  22. package/commands/utils/bundling/BundleGenerator.js +2292 -2292
  23. package/commands/utils/bundling/DependencyAnalyzer.js +925 -933
  24. package/commands/utils/loadConfig.js +31 -0
  25. package/commands/utils/updateManager.js +452 -453
  26. package/docs/superpowers/specs/2026-05-10-pwa-generate-design.md +105 -105
  27. package/package.json +58 -46
  28. package/post.js +66 -65
  29. package/tests/bundle-generator.test.js +691 -708
  30. package/tests/bundle-v2-register-output.test.js +470 -470
  31. package/tests/client-launcher-contract.test.js +211 -211
  32. package/tests/client-update-flow-contract.test.js +272 -272
  33. package/tests/component-registry-parse.test.js +34 -0
  34. package/tests/dependency-analyzer.test.js +24 -24
  35. package/tests/fixtures/components.js +8 -0
  36. package/tests/fixtures/sliceConfig.json +74 -0
  37. package/tests/getcomponent.test.js +407 -0
  38. package/tests/helpers/setup.js +97 -0
  39. package/tests/init-command-contract.test.js +46 -0
  40. package/tests/local-cli-delegation.test.js +81 -79
  41. package/tests/path-helper.test.js +206 -0
  42. package/tests/types-breakage.test.js +491 -0
  43. package/tests/types-generator-errors.test.js +361 -0
  44. package/tests/types-generator.test.js +172 -184
  45. package/tests/update-manager-notifications.test.js +88 -88
  46. package/.github/workflows/docs-render-cicd.yml +0 -65
@@ -1,167 +1,167 @@
1
- // commands/utils/VersionChecker.js
2
-
3
- import fs from "fs-extra";
4
- import path from "path";
5
- import { fileURLToPath } from "url";
6
- import Print from "../Print.js";
7
- import { getProjectRoot } from "../utils/PathHelper.js";
8
-
9
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
10
-
11
- class VersionChecker {
12
- constructor() {
13
- this.currentCliVersion = null;
14
- this.currentFrameworkVersion = null;
15
- this.latestCliVersion = null;
16
- this.latestFrameworkVersion = null;
17
- }
18
-
19
- async getCurrentVersions() {
20
- try {
21
- // Get CLI version
22
- const cliPackagePath = path.join(__dirname, '../../package.json');
23
- const cliPackage = await fs.readJson(cliPackagePath);
24
- this.currentCliVersion = cliPackage.version;
25
-
26
- // Get Framework version from project node_modules
27
- const projectRoot = getProjectRoot(import.meta.url);
28
- const frameworkPackagePath = path.join(projectRoot, 'node_modules', 'slicejs-web-framework', 'package.json');
29
- if (await fs.pathExists(frameworkPackagePath)) {
30
- const frameworkPackage = await fs.readJson(frameworkPackagePath);
31
- this.currentFrameworkVersion = frameworkPackage.version;
32
- }
33
-
34
- // Get Project's CLI version
35
- const projectPackagePath = path.join(__dirname, '../../../../package.json');
36
- if (await fs.pathExists(projectPackagePath)) {
37
- const projectPackage = await fs.readJson(projectPackagePath);
38
- if (projectPackage.dependencies && projectPackage.dependencies['slicejs-cli']) {
39
- // This could be different from the currently running CLI version
40
- }
41
- }
42
-
43
- return {
44
- cli: this.currentCliVersion,
45
- framework: this.currentFrameworkVersion
46
- };
47
- } catch (error) {
48
- return null;
49
- }
50
- }
51
-
52
- async getLatestVersions() {
53
- try {
54
- // Check CLI version
55
- const cliResponse = await fetch('https://registry.npmjs.org/slicejs-cli/latest', {
56
- headers: { 'Accept': 'application/json' }
57
- });
58
-
59
- if (cliResponse.ok) {
60
- const cliData = await cliResponse.json();
61
- this.latestCliVersion = cliData.version;
62
- }
63
-
64
- // Check Framework version
65
- const frameworkResponse = await fetch('https://registry.npmjs.org/slicejs-web-framework/latest', {
66
- headers: { 'Accept': 'application/json' }
67
- });
68
-
69
- if (frameworkResponse.ok) {
70
- const frameworkData = await frameworkResponse.json();
71
- this.latestFrameworkVersion = frameworkData.version;
72
- }
73
-
74
- return {
75
- cli: this.latestCliVersion,
76
- framework: this.latestFrameworkVersion
77
- };
78
- } catch (error) {
79
- // Silent fail - don't interrupt commands for version check failures
80
- return null;
81
- }
82
- }
83
-
84
- compareVersions(current, latest) {
85
- if (!current || !latest) return null;
86
-
87
- const currentParts = current.split('.').map(Number);
88
- const latestParts = latest.split('.').map(Number);
89
-
90
- for (let i = 0; i < Math.max(currentParts.length, latestParts.length); i++) {
91
- const currentPart = currentParts[i] || 0;
92
- const latestPart = latestParts[i] || 0;
93
-
94
- if (latestPart > currentPart) return 'outdated';
95
- if (currentPart > latestPart) return 'newer';
96
- }
97
-
98
- return 'current';
99
- }
100
-
101
- async checkForUpdates(silent = false) {
102
- try {
103
- const current = await this.getCurrentVersions();
104
- if (!current) return;
105
-
106
- const latest = await this.getLatestVersions();
107
- if (!latest) return;
108
-
109
- const cliStatus = this.compareVersions(current.cli, latest.cli);
110
- const frameworkStatus = this.compareVersions(current.framework, latest.framework);
111
-
112
- if (!silent && (cliStatus === 'outdated' || frameworkStatus === 'outdated')) {
113
- console.log(''); // Line break
114
- Print.warning('šŸ“¦ Available Updates:');
115
-
116
- if (cliStatus === 'outdated') {
117
- console.log(` šŸ”§ CLI: ${current.cli} → ${latest.cli}`);
118
- console.log(` npm update slicejs-cli`);
119
- }
120
-
121
- if (frameworkStatus === 'outdated') {
122
- console.log(` ⚔ Framework: ${current.framework} → ${latest.framework}`);
123
- console.log(` npm update slicejs-web-framework`);
124
- }
125
-
126
- console.log(' šŸ“š Changelog: https://github.com/VKneider/slice.js/releases');
127
- console.log(''); // Line break
128
- }
129
-
130
- return {
131
- cli: { current: current.cli, latest: latest.cli, status: cliStatus },
132
- framework: { current: current.framework, latest: latest.framework, status: frameworkStatus }
133
- };
134
-
135
- } catch (error) {
136
- // Silent fail - don't interrupt commands
137
- return null;
138
- }
139
- }
140
-
141
- async showVersionInfo() {
142
- const current = await this.getCurrentVersions();
143
- const latest = await this.getLatestVersions();
144
-
145
- console.log('\nšŸ“‹ Version Information:');
146
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
147
-
148
- if (current?.cli) {
149
- const cliStatus = this.compareVersions(current.cli, latest?.cli);
150
- const statusIcon = cliStatus === 'current' ? 'āœ…' : cliStatus === 'outdated' ? 'šŸ”„' : 'šŸ†•';
151
- console.log(`${statusIcon} CLI: v${current.cli}${latest?.cli && latest.cli !== current.cli ? ` (latest: v${latest.cli})` : ''}`);
152
- }
153
-
154
- if (current?.framework) {
155
- const frameworkStatus = this.compareVersions(current.framework, latest?.framework);
156
- const statusIcon = frameworkStatus === 'current' ? 'āœ…' : frameworkStatus === 'outdated' ? 'šŸ”„' : 'šŸ†•';
157
- console.log(`${statusIcon} Framework: v${current.framework}${latest?.framework && latest.framework !== current.framework ? ` (latest: v${latest.framework})` : ''}`);
158
- }
159
-
160
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n');
161
- }
162
- }
163
-
164
- // Singleton instance
165
- const versionChecker = new VersionChecker();
166
-
167
- export default versionChecker;
1
+ // commands/utils/VersionChecker.js
2
+
3
+ import fs from "fs-extra";
4
+ import path from "path";
5
+ import { fileURLToPath } from "url";
6
+ import Print from "../Print.js";
7
+ import { getProjectRoot, getPath } from "../utils/PathHelper.js";
8
+
9
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
10
+
11
+ class VersionChecker {
12
+ constructor() {
13
+ this.currentCliVersion = null;
14
+ this.currentFrameworkVersion = null;
15
+ this.latestCliVersion = null;
16
+ this.latestFrameworkVersion = null;
17
+ }
18
+
19
+ async getCurrentVersions() {
20
+ try {
21
+ // Get CLI version
22
+ const cliPackagePath = path.join(__dirname, '../../package.json');
23
+ const cliPackage = await fs.readJson(cliPackagePath);
24
+ this.currentCliVersion = cliPackage.version;
25
+
26
+ // Get Framework version from project node_modules
27
+ const projectRoot = getProjectRoot(import.meta.url);
28
+ const frameworkPackagePath = getPath(import.meta.url, 'node_modules', 'slicejs-web-framework', 'package.json');
29
+ if (await fs.pathExists(frameworkPackagePath)) {
30
+ const frameworkPackage = await fs.readJson(frameworkPackagePath);
31
+ this.currentFrameworkVersion = frameworkPackage.version;
32
+ }
33
+
34
+ // Get Project's CLI version
35
+ const projectPackagePath = getPath(import.meta.url, 'package.json');
36
+ if (await fs.pathExists(projectPackagePath)) {
37
+ const projectPackage = await fs.readJson(projectPackagePath);
38
+ if (projectPackage.dependencies && projectPackage.dependencies['slicejs-cli']) {
39
+ // This could be different from the currently running CLI version
40
+ }
41
+ }
42
+
43
+ return {
44
+ cli: this.currentCliVersion,
45
+ framework: this.currentFrameworkVersion
46
+ };
47
+ } catch (error) {
48
+ return null;
49
+ }
50
+ }
51
+
52
+ async getLatestVersions() {
53
+ try {
54
+ // Check CLI version
55
+ const cliResponse = await fetch('https://registry.npmjs.org/slicejs-cli/latest', {
56
+ headers: { 'Accept': 'application/json' }
57
+ });
58
+
59
+ if (cliResponse.ok) {
60
+ const cliData = await cliResponse.json();
61
+ this.latestCliVersion = cliData.version;
62
+ }
63
+
64
+ // Check Framework version
65
+ const frameworkResponse = await fetch('https://registry.npmjs.org/slicejs-web-framework/latest', {
66
+ headers: { 'Accept': 'application/json' }
67
+ });
68
+
69
+ if (frameworkResponse.ok) {
70
+ const frameworkData = await frameworkResponse.json();
71
+ this.latestFrameworkVersion = frameworkData.version;
72
+ }
73
+
74
+ return {
75
+ cli: this.latestCliVersion,
76
+ framework: this.latestFrameworkVersion
77
+ };
78
+ } catch (error) {
79
+ // Silent fail - don't interrupt commands for version check failures
80
+ return null;
81
+ }
82
+ }
83
+
84
+ compareVersions(current, latest) {
85
+ if (!current || !latest) return null;
86
+
87
+ const currentParts = current.split('.').map(Number);
88
+ const latestParts = latest.split('.').map(Number);
89
+
90
+ for (let i = 0; i < Math.max(currentParts.length, latestParts.length); i++) {
91
+ const currentPart = currentParts[i] || 0;
92
+ const latestPart = latestParts[i] || 0;
93
+
94
+ if (latestPart > currentPart) return 'outdated';
95
+ if (currentPart > latestPart) return 'newer';
96
+ }
97
+
98
+ return 'current';
99
+ }
100
+
101
+ async checkForUpdates(silent = false) {
102
+ try {
103
+ const current = await this.getCurrentVersions();
104
+ if (!current) return;
105
+
106
+ const latest = await this.getLatestVersions();
107
+ if (!latest) return;
108
+
109
+ const cliStatus = this.compareVersions(current.cli, latest.cli);
110
+ const frameworkStatus = this.compareVersions(current.framework, latest.framework);
111
+
112
+ if (!silent && (cliStatus === 'outdated' || frameworkStatus === 'outdated')) {
113
+ console.log(''); // Line break
114
+ Print.warning('šŸ“¦ Available Updates:');
115
+
116
+ if (cliStatus === 'outdated') {
117
+ console.log(` šŸ”§ CLI: ${current.cli} → ${latest.cli}`);
118
+ console.log(` npm update slicejs-cli`);
119
+ }
120
+
121
+ if (frameworkStatus === 'outdated') {
122
+ console.log(` ⚔ Framework: ${current.framework} → ${latest.framework}`);
123
+ console.log(` npm update slicejs-web-framework`);
124
+ }
125
+
126
+ console.log(' šŸ“š Changelog: https://github.com/VKneider/slice.js/releases');
127
+ console.log(''); // Line break
128
+ }
129
+
130
+ return {
131
+ cli: { current: current.cli, latest: latest.cli, status: cliStatus },
132
+ framework: { current: current.framework, latest: latest.framework, status: frameworkStatus }
133
+ };
134
+
135
+ } catch (error) {
136
+ // Silent fail - don't interrupt commands
137
+ return null;
138
+ }
139
+ }
140
+
141
+ async showVersionInfo() {
142
+ const current = await this.getCurrentVersions();
143
+ const latest = await this.getLatestVersions();
144
+
145
+ console.log('\nšŸ“‹ Version Information:');
146
+ console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
147
+
148
+ if (current?.cli) {
149
+ const cliStatus = this.compareVersions(current.cli, latest?.cli);
150
+ const statusIcon = cliStatus === 'current' ? 'āœ…' : cliStatus === 'outdated' ? 'šŸ”„' : 'šŸ†•';
151
+ console.log(`${statusIcon} CLI: v${current.cli}${latest?.cli && latest.cli !== current.cli ? ` (latest: v${latest.cli})` : ''}`);
152
+ }
153
+
154
+ if (current?.framework) {
155
+ const frameworkStatus = this.compareVersions(current.framework, latest?.framework);
156
+ const statusIcon = frameworkStatus === 'current' ? 'āœ…' : frameworkStatus === 'outdated' ? 'šŸ”„' : 'šŸ†•';
157
+ console.log(`${statusIcon} Framework: v${current.framework}${latest?.framework && latest.framework !== current.framework ? ` (latest: v${latest.framework})` : ''}`);
158
+ }
159
+
160
+ console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n');
161
+ }
162
+ }
163
+
164
+ // Singleton instance
165
+ const versionChecker = new VersionChecker();
166
+
167
+ export default versionChecker;