slicejs-cli 3.6.2 → 3.6.4
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.
- package/LICENSE +21 -21
- package/README.md +226 -226
- package/client.js +744 -744
- package/commands/Print.js +163 -163
- package/commands/Validations.js +92 -92
- package/commands/build/build.js +40 -40
- package/commands/buildProduction/buildProduction.js +577 -579
- package/commands/bundle/bundle.js +234 -234
- package/commands/createComponent/VisualComponentTemplate.js +55 -55
- package/commands/createComponent/createComponent.js +128 -128
- package/commands/deleteComponent/deleteComponent.js +81 -81
- package/commands/doctor/doctor.js +440 -440
- package/commands/getComponent/getComponent.js +701 -692
- package/commands/init/init.js +467 -463
- package/commands/listComponents/listComponents.js +172 -172
- package/commands/startServer/startServer.js +261 -261
- package/commands/startServer/watchServer.js +66 -79
- package/commands/types/types.js +580 -580
- package/commands/utils/LocalCliDelegation.js +53 -53
- package/commands/utils/PackageManager.js +148 -148
- package/commands/utils/PathHelper.js +75 -75
- package/commands/utils/VersionChecker.js +169 -169
- package/commands/utils/bundling/BundleGenerator.js +2525 -2525
- package/commands/utils/bundling/DependencyAnalyzer.js +925 -925
- package/commands/utils/loadConfig.js +31 -31
- package/commands/utils/sliceScripts.js +23 -23
- package/commands/utils/updateManager.js +471 -471
- package/package.json +73 -73
- package/post.js +60 -60
package/commands/Print.js
CHANGED
|
@@ -1,164 +1,164 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
|
|
3
|
-
export default class Print {
|
|
4
|
-
constructor() { }
|
|
5
|
-
|
|
6
|
-
static error(message) {
|
|
7
|
-
console.error(chalk.red(`❌ Error: ${message}`));
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
static success(message) {
|
|
11
|
-
console.log(chalk.green(`✅ Success: ${message}`));
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
static warning(message) {
|
|
15
|
-
console.log(chalk.yellow(`⚠️ Warning: ${message}`));
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
static info(message) {
|
|
19
|
-
console.log(chalk.cyan(`ℹ️ Info: ${message}`));
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
static title(message) {
|
|
23
|
-
console.log(chalk.magenta.bold(`🎯 ${message}`));
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
static subtitle(message) {
|
|
27
|
-
console.log(chalk.blue(`📋 ${message}`));
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
static step(stepNumber, message) {
|
|
31
|
-
console.log(chalk.cyan(`${stepNumber}. ${message}`));
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
static highlight(message) {
|
|
35
|
-
console.log(chalk.bgYellow.black(` ${message} `));
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
static newLine() {
|
|
39
|
-
console.log('');
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
static separator() {
|
|
43
|
-
console.log(chalk.gray('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'));
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Methods for CLI-specific context
|
|
47
|
-
static componentSuccess(componentName, action = 'processed') {
|
|
48
|
-
console.log(chalk.green(`✅ ${componentName} ${action} successfully!`));
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
static componentError(componentName, action = 'processing', error) {
|
|
52
|
-
console.error(chalk.red(`❌ Error ${action} ${componentName}: ${error}`));
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
static downloadProgress(fileName) {
|
|
56
|
-
console.log(chalk.cyan(` 📥 Downloading ${fileName}...`));
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
static downloadError(fileName) {
|
|
60
|
-
console.error(chalk.red(` ❌ ${fileName}`));
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
static registryUpdate(message) {
|
|
64
|
-
console.log(chalk.magenta(`📝 Registry: ${message}`));
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
static versionInfo(component, currentVersion, latestVersion = null) {
|
|
68
|
-
if (latestVersion && currentVersion !== latestVersion) {
|
|
69
|
-
console.log(chalk.yellow(`🔄 ${component}: v${currentVersion} → v${latestVersion}`));
|
|
70
|
-
} else {
|
|
71
|
-
console.log(chalk.green(`✅ ${component}: v${currentVersion}`));
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
static commandExample(description, command) {
|
|
76
|
-
console.log(chalk.gray(`💡 ${description}:`));
|
|
77
|
-
console.log(chalk.white(` ${command}`));
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
static summary(successful, failed, total) {
|
|
81
|
-
Print.separator();
|
|
82
|
-
console.log(chalk.bold('📊 Summary:'));
|
|
83
|
-
if (successful > 0) {
|
|
84
|
-
Print.success(`Successful: ${successful}/${total}`);
|
|
85
|
-
}
|
|
86
|
-
if (failed > 0) {
|
|
87
|
-
Print.error(`Failed: ${failed}/${total}`);
|
|
88
|
-
}
|
|
89
|
-
Print.separator();
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// Method to show minification results
|
|
93
|
-
static minificationResult(filename, originalSize, minifiedSize, savingsPercent) {
|
|
94
|
-
const originalKB = (originalSize / 1024).toFixed(1);
|
|
95
|
-
const minifiedKB = (minifiedSize / 1024).toFixed(1);
|
|
96
|
-
|
|
97
|
-
console.log(chalk.green(` ✅ ${filename}`));
|
|
98
|
-
console.log(chalk.gray(` ${originalKB}KB → ${minifiedKB}KB (${savingsPercent}% saved)`));
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// Method to show build progress
|
|
102
|
-
static buildProgress(message) {
|
|
103
|
-
console.log(chalk.cyan(`🔄 ${message}`));
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// Method to show server statistics
|
|
107
|
-
static serverStats(mode, port, directory) {
|
|
108
|
-
Print.newLine();
|
|
109
|
-
console.log(chalk.magenta(`🌐 Server Configuration:`));
|
|
110
|
-
console.log(chalk.gray(` Mode: ${mode}`));
|
|
111
|
-
console.log(chalk.gray(` Port: ${port}`));
|
|
112
|
-
console.log(chalk.gray(` Serving: /${directory}`));
|
|
113
|
-
Print.newLine();
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// Method to show the server is ready with highlighted URL
|
|
117
|
-
static serverReady(port) {
|
|
118
|
-
Print.newLine();
|
|
119
|
-
console.log(chalk.bgGreen.black.bold(' ✓ SERVER READY '));
|
|
120
|
-
Print.newLine();
|
|
121
|
-
console.log(chalk.cyan.bold(` → Local: http://localhost:${port}`));
|
|
122
|
-
console.log(chalk.gray(` → Network: http://127.0.0.1:${port}`));
|
|
123
|
-
Print.newLine();
|
|
124
|
-
console.log(chalk.yellow(` Press Ctrl+C to stop the server`));
|
|
125
|
-
Print.newLine();
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// Method to show server status during startup
|
|
129
|
-
static serverStatus(status, message = '') {
|
|
130
|
-
const icons = {
|
|
131
|
-
checking: '🔍',
|
|
132
|
-
starting: '🚀',
|
|
133
|
-
ready: '✅',
|
|
134
|
-
error: '❌'
|
|
135
|
-
};
|
|
136
|
-
const colors = {
|
|
137
|
-
checking: chalk.cyan,
|
|
138
|
-
starting: chalk.magenta,
|
|
139
|
-
ready: chalk.green,
|
|
140
|
-
error: chalk.red
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
const icon = icons[status] || 'ℹ️';
|
|
144
|
-
const color = colors[status] || chalk.white;
|
|
145
|
-
const displayMessage = message || status;
|
|
146
|
-
|
|
147
|
-
console.log(color(`${icon} ${displayMessage}`));
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// Method to show port checking status
|
|
151
|
-
static checkingPort(port) {
|
|
152
|
-
console.log(chalk.cyan(`🔍 Checking port ${port}...`));
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// New: Debug method
|
|
156
|
-
static debug(message) {
|
|
157
|
-
console.log(chalk.gray(`🐛 DEBUG: ${message}`));
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
// New: Verbose logging method
|
|
161
|
-
static verbose(message) {
|
|
162
|
-
console.log(chalk.gray(`📝 ${message}`));
|
|
163
|
-
}
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
|
|
3
|
+
export default class Print {
|
|
4
|
+
constructor() { }
|
|
5
|
+
|
|
6
|
+
static error(message) {
|
|
7
|
+
console.error(chalk.red(`❌ Error: ${message}`));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
static success(message) {
|
|
11
|
+
console.log(chalk.green(`✅ Success: ${message}`));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
static warning(message) {
|
|
15
|
+
console.log(chalk.yellow(`⚠️ Warning: ${message}`));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
static info(message) {
|
|
19
|
+
console.log(chalk.cyan(`ℹ️ Info: ${message}`));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
static title(message) {
|
|
23
|
+
console.log(chalk.magenta.bold(`🎯 ${message}`));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
static subtitle(message) {
|
|
27
|
+
console.log(chalk.blue(`📋 ${message}`));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static step(stepNumber, message) {
|
|
31
|
+
console.log(chalk.cyan(`${stepNumber}. ${message}`));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static highlight(message) {
|
|
35
|
+
console.log(chalk.bgYellow.black(` ${message} `));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
static newLine() {
|
|
39
|
+
console.log('');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
static separator() {
|
|
43
|
+
console.log(chalk.gray('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Methods for CLI-specific context
|
|
47
|
+
static componentSuccess(componentName, action = 'processed') {
|
|
48
|
+
console.log(chalk.green(`✅ ${componentName} ${action} successfully!`));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
static componentError(componentName, action = 'processing', error) {
|
|
52
|
+
console.error(chalk.red(`❌ Error ${action} ${componentName}: ${error}`));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
static downloadProgress(fileName) {
|
|
56
|
+
console.log(chalk.cyan(` 📥 Downloading ${fileName}...`));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
static downloadError(fileName) {
|
|
60
|
+
console.error(chalk.red(` ❌ ${fileName}`));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
static registryUpdate(message) {
|
|
64
|
+
console.log(chalk.magenta(`📝 Registry: ${message}`));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
static versionInfo(component, currentVersion, latestVersion = null) {
|
|
68
|
+
if (latestVersion && currentVersion !== latestVersion) {
|
|
69
|
+
console.log(chalk.yellow(`🔄 ${component}: v${currentVersion} → v${latestVersion}`));
|
|
70
|
+
} else {
|
|
71
|
+
console.log(chalk.green(`✅ ${component}: v${currentVersion}`));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
static commandExample(description, command) {
|
|
76
|
+
console.log(chalk.gray(`💡 ${description}:`));
|
|
77
|
+
console.log(chalk.white(` ${command}`));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
static summary(successful, failed, total) {
|
|
81
|
+
Print.separator();
|
|
82
|
+
console.log(chalk.bold('📊 Summary:'));
|
|
83
|
+
if (successful > 0) {
|
|
84
|
+
Print.success(`Successful: ${successful}/${total}`);
|
|
85
|
+
}
|
|
86
|
+
if (failed > 0) {
|
|
87
|
+
Print.error(`Failed: ${failed}/${total}`);
|
|
88
|
+
}
|
|
89
|
+
Print.separator();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Method to show minification results
|
|
93
|
+
static minificationResult(filename, originalSize, minifiedSize, savingsPercent) {
|
|
94
|
+
const originalKB = (originalSize / 1024).toFixed(1);
|
|
95
|
+
const minifiedKB = (minifiedSize / 1024).toFixed(1);
|
|
96
|
+
|
|
97
|
+
console.log(chalk.green(` ✅ ${filename}`));
|
|
98
|
+
console.log(chalk.gray(` ${originalKB}KB → ${minifiedKB}KB (${savingsPercent}% saved)`));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Method to show build progress
|
|
102
|
+
static buildProgress(message) {
|
|
103
|
+
console.log(chalk.cyan(`🔄 ${message}`));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Method to show server statistics
|
|
107
|
+
static serverStats(mode, port, directory) {
|
|
108
|
+
Print.newLine();
|
|
109
|
+
console.log(chalk.magenta(`🌐 Server Configuration:`));
|
|
110
|
+
console.log(chalk.gray(` Mode: ${mode}`));
|
|
111
|
+
console.log(chalk.gray(` Port: ${port}`));
|
|
112
|
+
console.log(chalk.gray(` Serving: /${directory}`));
|
|
113
|
+
Print.newLine();
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Method to show the server is ready with highlighted URL
|
|
117
|
+
static serverReady(port) {
|
|
118
|
+
Print.newLine();
|
|
119
|
+
console.log(chalk.bgGreen.black.bold(' ✓ SERVER READY '));
|
|
120
|
+
Print.newLine();
|
|
121
|
+
console.log(chalk.cyan.bold(` → Local: http://localhost:${port}`));
|
|
122
|
+
console.log(chalk.gray(` → Network: http://127.0.0.1:${port}`));
|
|
123
|
+
Print.newLine();
|
|
124
|
+
console.log(chalk.yellow(` Press Ctrl+C to stop the server`));
|
|
125
|
+
Print.newLine();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Method to show server status during startup
|
|
129
|
+
static serverStatus(status, message = '') {
|
|
130
|
+
const icons = {
|
|
131
|
+
checking: '🔍',
|
|
132
|
+
starting: '🚀',
|
|
133
|
+
ready: '✅',
|
|
134
|
+
error: '❌'
|
|
135
|
+
};
|
|
136
|
+
const colors = {
|
|
137
|
+
checking: chalk.cyan,
|
|
138
|
+
starting: chalk.magenta,
|
|
139
|
+
ready: chalk.green,
|
|
140
|
+
error: chalk.red
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const icon = icons[status] || 'ℹ️';
|
|
144
|
+
const color = colors[status] || chalk.white;
|
|
145
|
+
const displayMessage = message || status;
|
|
146
|
+
|
|
147
|
+
console.log(color(`${icon} ${displayMessage}`));
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Method to show port checking status
|
|
151
|
+
static checkingPort(port) {
|
|
152
|
+
console.log(chalk.cyan(`🔍 Checking port ${port}...`));
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// New: Debug method
|
|
156
|
+
static debug(message) {
|
|
157
|
+
console.log(chalk.gray(`🐛 DEBUG: ${message}`));
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// New: Verbose logging method
|
|
161
|
+
static verbose(message) {
|
|
162
|
+
console.log(chalk.gray(`📝 ${message}`));
|
|
163
|
+
}
|
|
164
164
|
}
|
package/commands/Validations.js
CHANGED
|
@@ -1,92 +1,92 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import Print from './Print.js';
|
|
4
|
-
import { getComponentsJsPath } from './utils/PathHelper.js';
|
|
5
|
-
import { loadConfigSync } from './utils/loadConfig.js';
|
|
6
|
-
|
|
7
|
-
class Validations {
|
|
8
|
-
constructor() {
|
|
9
|
-
this._config = null;
|
|
10
|
-
this._categories = null;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
_ensureConfig() {
|
|
14
|
-
if (!this._config) {
|
|
15
|
-
this._config = this.loadConfig();
|
|
16
|
-
if (this._config) {
|
|
17
|
-
this._categories = this._config.paths?.components;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
get config() {
|
|
23
|
-
this._ensureConfig();
|
|
24
|
-
return this._config;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
isValidComponentName(componentName) {
|
|
28
|
-
// Regex to check if the name contains special characters
|
|
29
|
-
const regex = /^[a-zA-Z][a-zA-Z0-9]*$/;
|
|
30
|
-
return regex.test(componentName);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
loadConfig() {
|
|
34
|
-
return loadConfigSync(import.meta.url);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
getCategories() {
|
|
38
|
-
this._ensureConfig();
|
|
39
|
-
return this._categories;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
getCategoryPath(category) {
|
|
43
|
-
this._ensureConfig();
|
|
44
|
-
return this._categories && this._categories[category] ? this._categories[category].path : null;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
getCategoryType(category) {
|
|
48
|
-
this._ensureConfig();
|
|
49
|
-
return this._categories && this._categories[category] ? this._categories[category].type : null;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
isValidCategory(category) {
|
|
53
|
-
this._ensureConfig();
|
|
54
|
-
if (!this._categories) return { isValid: false, category: null };
|
|
55
|
-
|
|
56
|
-
const availableCategories = Object.keys(this._categories).map(cat => cat.toLowerCase());
|
|
57
|
-
|
|
58
|
-
if (availableCategories.includes(category.toLowerCase())) {
|
|
59
|
-
return { isValid: true, category };
|
|
60
|
-
} else {
|
|
61
|
-
return { isValid: false, category: null };
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
componentExists(componentName) {
|
|
66
|
-
try {
|
|
67
|
-
const componentFilePath = getComponentsJsPath(import.meta.url);
|
|
68
|
-
|
|
69
|
-
if (!fs.existsSync(componentFilePath)) {
|
|
70
|
-
Print.error('components.js not found in expected path');
|
|
71
|
-
Print.info('Run "slice component list" to generate components.js');
|
|
72
|
-
return false;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const fileContent = fs.readFileSync(componentFilePath, 'utf-8');
|
|
76
|
-
const match = fileContent.match(/const components = ({[\s\S]*?});/);
|
|
77
|
-
if (!match) return false;
|
|
78
|
-
const components = JSON.parse(match[1]);
|
|
79
|
-
|
|
80
|
-
return components.hasOwnProperty(componentName);
|
|
81
|
-
|
|
82
|
-
} catch (error) {
|
|
83
|
-
Print.error(`Error checking component existence: ${error.message}`);
|
|
84
|
-
Print.info('The components.js file may be corrupted');
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const validations = new Validations();
|
|
91
|
-
|
|
92
|
-
export default validations;
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import Print from './Print.js';
|
|
4
|
+
import { getComponentsJsPath } from './utils/PathHelper.js';
|
|
5
|
+
import { loadConfigSync } from './utils/loadConfig.js';
|
|
6
|
+
|
|
7
|
+
class Validations {
|
|
8
|
+
constructor() {
|
|
9
|
+
this._config = null;
|
|
10
|
+
this._categories = null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
_ensureConfig() {
|
|
14
|
+
if (!this._config) {
|
|
15
|
+
this._config = this.loadConfig();
|
|
16
|
+
if (this._config) {
|
|
17
|
+
this._categories = this._config.paths?.components;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
get config() {
|
|
23
|
+
this._ensureConfig();
|
|
24
|
+
return this._config;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
isValidComponentName(componentName) {
|
|
28
|
+
// Regex to check if the name contains special characters
|
|
29
|
+
const regex = /^[a-zA-Z][a-zA-Z0-9]*$/;
|
|
30
|
+
return regex.test(componentName);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
loadConfig() {
|
|
34
|
+
return loadConfigSync(import.meta.url);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
getCategories() {
|
|
38
|
+
this._ensureConfig();
|
|
39
|
+
return this._categories;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
getCategoryPath(category) {
|
|
43
|
+
this._ensureConfig();
|
|
44
|
+
return this._categories && this._categories[category] ? this._categories[category].path : null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
getCategoryType(category) {
|
|
48
|
+
this._ensureConfig();
|
|
49
|
+
return this._categories && this._categories[category] ? this._categories[category].type : null;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
isValidCategory(category) {
|
|
53
|
+
this._ensureConfig();
|
|
54
|
+
if (!this._categories) return { isValid: false, category: null };
|
|
55
|
+
|
|
56
|
+
const availableCategories = Object.keys(this._categories).map(cat => cat.toLowerCase());
|
|
57
|
+
|
|
58
|
+
if (availableCategories.includes(category.toLowerCase())) {
|
|
59
|
+
return { isValid: true, category };
|
|
60
|
+
} else {
|
|
61
|
+
return { isValid: false, category: null };
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
componentExists(componentName) {
|
|
66
|
+
try {
|
|
67
|
+
const componentFilePath = getComponentsJsPath(import.meta.url);
|
|
68
|
+
|
|
69
|
+
if (!fs.existsSync(componentFilePath)) {
|
|
70
|
+
Print.error('components.js not found in expected path');
|
|
71
|
+
Print.info('Run "slice component list" to generate components.js');
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const fileContent = fs.readFileSync(componentFilePath, 'utf-8');
|
|
76
|
+
const match = fileContent.match(/const components = ({[\s\S]*?});/);
|
|
77
|
+
if (!match) return false;
|
|
78
|
+
const components = JSON.parse(match[1]);
|
|
79
|
+
|
|
80
|
+
return components.hasOwnProperty(componentName);
|
|
81
|
+
|
|
82
|
+
} catch (error) {
|
|
83
|
+
Print.error(`Error checking component existence: ${error.message}`);
|
|
84
|
+
Print.info('The components.js file may be corrupted');
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const validations = new Validations();
|
|
91
|
+
|
|
92
|
+
export default validations;
|
package/commands/build/build.js
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import bundle from '../bundle/bundle.js';
|
|
2
|
-
import buildProduction, { serveProductionBuild } from '../buildProduction/buildProduction.js';
|
|
3
|
-
import Print from '../Print.js';
|
|
4
|
-
|
|
5
|
-
export default async function build(options = {}) {
|
|
6
|
-
const minify = options.minify !== false;
|
|
7
|
-
const obfuscate = options.obfuscate !== false;
|
|
8
|
-
|
|
9
|
-
if (options.analyze) {
|
|
10
|
-
return bundle({ analyze: true, verbose: options.verbose });
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
if (options.serve) {
|
|
14
|
-
await serveProductionBuild(options.port);
|
|
15
|
-
return true;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const success = await buildProduction({
|
|
19
|
-
...options,
|
|
20
|
-
minify,
|
|
21
|
-
obfuscate
|
|
22
|
-
});
|
|
23
|
-
if (!success) {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
Print.info('Generating bundles for production build...');
|
|
28
|
-
await bundle({
|
|
29
|
-
verbose: options.verbose,
|
|
30
|
-
minify,
|
|
31
|
-
obfuscate,
|
|
32
|
-
output: 'dist'
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
if (options.preview) {
|
|
36
|
-
await serveProductionBuild(options.port);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
1
|
+
import bundle from '../bundle/bundle.js';
|
|
2
|
+
import buildProduction, { serveProductionBuild } from '../buildProduction/buildProduction.js';
|
|
3
|
+
import Print from '../Print.js';
|
|
4
|
+
|
|
5
|
+
export default async function build(options = {}) {
|
|
6
|
+
const minify = options.minify !== false;
|
|
7
|
+
const obfuscate = options.obfuscate !== false;
|
|
8
|
+
|
|
9
|
+
if (options.analyze) {
|
|
10
|
+
return bundle({ analyze: true, verbose: options.verbose });
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (options.serve) {
|
|
14
|
+
await serveProductionBuild(options.port);
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const success = await buildProduction({
|
|
19
|
+
...options,
|
|
20
|
+
minify,
|
|
21
|
+
obfuscate
|
|
22
|
+
});
|
|
23
|
+
if (!success) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
Print.info('Generating bundles for production build...');
|
|
28
|
+
await bundle({
|
|
29
|
+
verbose: options.verbose,
|
|
30
|
+
minify,
|
|
31
|
+
obfuscate,
|
|
32
|
+
output: 'dist'
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
if (options.preview) {
|
|
36
|
+
await serveProductionBuild(options.port);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return true;
|
|
40
|
+
}
|