slicejs-cli 3.3.0 → 3.4.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 (33) hide show
  1. package/LICENSE +21 -21
  2. package/client.js +664 -626
  3. package/commands/Print.js +167 -167
  4. package/commands/Validations.js +103 -103
  5. package/commands/build/build.js +40 -40
  6. package/commands/buildProduction/buildProduction.js +579 -579
  7. package/commands/bundle/bundle.js +235 -235
  8. package/commands/createComponent/VisualComponentTemplate.js +55 -55
  9. package/commands/createComponent/createComponent.js +126 -126
  10. package/commands/deleteComponent/deleteComponent.js +77 -77
  11. package/commands/doctor/doctor.js +369 -369
  12. package/commands/getComponent/getComponent.js +747 -747
  13. package/commands/init/init.js +265 -261
  14. package/commands/listComponents/listComponents.js +175 -175
  15. package/commands/startServer/startServer.js +264 -264
  16. package/commands/startServer/watchServer.js +79 -79
  17. package/commands/types/types.js +16 -9
  18. package/commands/utils/LocalCliDelegation.js +53 -53
  19. package/commands/utils/PathHelper.js +68 -68
  20. package/commands/utils/VersionChecker.js +167 -167
  21. package/commands/utils/bundling/BundleGenerator.js +2292 -2292
  22. package/commands/utils/bundling/DependencyAnalyzer.js +933 -933
  23. package/commands/utils/updateManager.js +453 -453
  24. package/package.json +46 -46
  25. package/post.js +66 -65
  26. package/tests/bundle-generator.test.js +708 -708
  27. package/tests/bundle-v2-register-output.test.js +470 -470
  28. package/tests/client-launcher-contract.test.js +211 -211
  29. package/tests/client-update-flow-contract.test.js +272 -272
  30. package/tests/dependency-analyzer.test.js +24 -24
  31. package/tests/local-cli-delegation.test.js +79 -79
  32. package/tests/update-manager-notifications.test.js +88 -88
  33. 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 } 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;