slicejs-cli 2.1.2 → 2.1.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/client.js +80 -47
- package/commands/Print.js +85 -4
- package/commands/getComponent/getComponent.js +47 -50
- package/package.json +1 -1
- package/post.js +1 -1
package/client.js
CHANGED
|
@@ -21,7 +21,7 @@ const loadConfig = () => {
|
|
|
21
21
|
const rawData = fs.readFileSync(configPath, "utf-8");
|
|
22
22
|
return JSON.parse(rawData);
|
|
23
23
|
} catch (error) {
|
|
24
|
-
|
|
24
|
+
Print.error(`Loading configuration: ${error.message}`);
|
|
25
25
|
return null;
|
|
26
26
|
}
|
|
27
27
|
};
|
|
@@ -33,20 +33,25 @@ const getCategories = () => {
|
|
|
33
33
|
|
|
34
34
|
// Function to run version check for all commands
|
|
35
35
|
async function runWithVersionCheck(commandFunction, ...args) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
36
|
+
try {
|
|
37
|
+
// Run the command first
|
|
38
|
+
const result = await commandFunction(...args);
|
|
39
|
+
|
|
40
|
+
// Then check for updates (non-blocking)
|
|
41
|
+
setTimeout(() => {
|
|
42
|
+
versionChecker.checkForUpdates(true);
|
|
43
|
+
}, 100);
|
|
44
|
+
|
|
45
|
+
return result;
|
|
46
|
+
} catch (error) {
|
|
47
|
+
Print.error(`Command execution: ${error.message}`);
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
45
50
|
}
|
|
46
51
|
|
|
47
52
|
const sliceClient = program;
|
|
48
53
|
|
|
49
|
-
sliceClient.version("2.1.
|
|
54
|
+
sliceClient.version("2.1.3").description("CLI for managing Slice.js framework components");
|
|
50
55
|
|
|
51
56
|
// INIT COMMAND
|
|
52
57
|
sliceClient
|
|
@@ -80,7 +85,8 @@ componentCommand
|
|
|
80
85
|
await runWithVersionCheck(async () => {
|
|
81
86
|
const categories = getCategories();
|
|
82
87
|
if (categories.length === 0) {
|
|
83
|
-
Print.error("No categories available. Check your configuration
|
|
88
|
+
Print.error("No categories available. Check your configuration");
|
|
89
|
+
Print.info("Run 'slice init' to initialize your project");
|
|
84
90
|
return;
|
|
85
91
|
}
|
|
86
92
|
|
|
@@ -96,22 +102,28 @@ componentCommand
|
|
|
96
102
|
name: "category",
|
|
97
103
|
message: "Select the component category:",
|
|
98
104
|
choices: categories,
|
|
99
|
-
}])
|
|
100
|
-
|
|
101
|
-
if(validations.getCategoryType(answers.category)==='Visual'){
|
|
102
|
-
const properties = await inquirer.prompt([
|
|
103
|
-
{
|
|
104
|
-
type: "input",
|
|
105
|
-
name: "properties",
|
|
106
|
-
message: "Enter the properties (comma separated):"
|
|
107
|
-
},
|
|
108
|
-
]);
|
|
109
|
-
answers.properties = properties.properties.split(",").map((prop) => prop.trim());
|
|
110
|
-
} else {
|
|
111
|
-
answers.properties = [];
|
|
112
105
|
}
|
|
106
|
+
]);
|
|
107
|
+
|
|
108
|
+
if (validations.getCategoryType(answers.category) === 'Visual') {
|
|
109
|
+
const properties = await inquirer.prompt([
|
|
110
|
+
{
|
|
111
|
+
type: "input",
|
|
112
|
+
name: "properties",
|
|
113
|
+
message: "Enter the properties (comma separated):",
|
|
114
|
+
default: ""
|
|
115
|
+
},
|
|
116
|
+
]);
|
|
117
|
+
answers.properties = properties.properties
|
|
118
|
+
? properties.properties.split(",").map((prop) => prop.trim()).filter(Boolean)
|
|
119
|
+
: [];
|
|
120
|
+
} else {
|
|
121
|
+
answers.properties = [];
|
|
122
|
+
}
|
|
113
123
|
|
|
114
124
|
if (createComponent(answers.componentName, answers.category, answers.properties)) {
|
|
125
|
+
Print.success(`Component ${answers.componentName} created successfully`);
|
|
126
|
+
Print.info("Listing updated components:");
|
|
115
127
|
listComponents();
|
|
116
128
|
}
|
|
117
129
|
});
|
|
@@ -138,11 +150,16 @@ componentCommand
|
|
|
138
150
|
await runWithVersionCheck(async () => {
|
|
139
151
|
const categories = getCategories();
|
|
140
152
|
if (categories.length === 0) {
|
|
141
|
-
Print.error("No categories available. Check your configuration
|
|
153
|
+
Print.error("No categories available. Check your configuration");
|
|
154
|
+
Print.info("Run 'slice init' to initialize your project");
|
|
142
155
|
return;
|
|
143
156
|
}
|
|
144
157
|
|
|
145
|
-
|
|
158
|
+
try {
|
|
159
|
+
await deleteComponent();
|
|
160
|
+
} catch (error) {
|
|
161
|
+
Print.error(`Deleting component: ${error.message}`);
|
|
162
|
+
}
|
|
146
163
|
});
|
|
147
164
|
});
|
|
148
165
|
|
|
@@ -191,17 +208,16 @@ registryCommand
|
|
|
191
208
|
// SHORTCUTS - Top-level convenient commands
|
|
192
209
|
sliceClient
|
|
193
210
|
.command("get [components...]")
|
|
194
|
-
.description("
|
|
211
|
+
.description("Quick install components from registry")
|
|
195
212
|
.option("-f, --force", "Force overwrite existing components")
|
|
196
213
|
.option("-s, --service", "Install Service components instead of Visual")
|
|
197
214
|
.action(async (components, options) => {
|
|
198
215
|
await runWithVersionCheck(async () => {
|
|
199
216
|
if (!components || components.length === 0) {
|
|
200
|
-
Print.info("
|
|
201
|
-
Print.
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
console.log(" slice registry list");
|
|
217
|
+
Print.info("Use 'slice registry list' to see available components");
|
|
218
|
+
Print.commandExample("Get multiple components", "slice get Button Card Input");
|
|
219
|
+
Print.commandExample("Get service component", "slice get FetchManager --service");
|
|
220
|
+
Print.commandExample("Browse components", "slice browse");
|
|
205
221
|
return;
|
|
206
222
|
}
|
|
207
223
|
|
|
@@ -214,7 +230,7 @@ sliceClient
|
|
|
214
230
|
|
|
215
231
|
sliceClient
|
|
216
232
|
.command("browse")
|
|
217
|
-
.description("
|
|
233
|
+
.description("Quick browse available components")
|
|
218
234
|
.action(async () => {
|
|
219
235
|
await runWithVersionCheck(async () => {
|
|
220
236
|
await listRemoteComponents();
|
|
@@ -223,7 +239,7 @@ sliceClient
|
|
|
223
239
|
|
|
224
240
|
sliceClient
|
|
225
241
|
.command("sync")
|
|
226
|
-
.description("
|
|
242
|
+
.description("Quick sync local components to latest versions")
|
|
227
243
|
.option("-f, --force", "Force update without confirmation")
|
|
228
244
|
.action(async (options) => {
|
|
229
245
|
await runWithVersionCheck(async () => {
|
|
@@ -239,15 +255,22 @@ sliceClient
|
|
|
239
255
|
.alias("upgrade")
|
|
240
256
|
.description("Check for and show available updates for CLI and framework")
|
|
241
257
|
.action(async () => {
|
|
242
|
-
Print.info("
|
|
243
|
-
const updateInfo = await versionChecker.checkForUpdates(false);
|
|
258
|
+
Print.info("Checking for updates...");
|
|
244
259
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
260
|
+
try {
|
|
261
|
+
const updateInfo = await versionChecker.checkForUpdates(false);
|
|
262
|
+
|
|
263
|
+
if (updateInfo) {
|
|
264
|
+
if (updateInfo.cli.status === 'current' && updateInfo.framework.status === 'current') {
|
|
265
|
+
Print.success("All components are up to date!");
|
|
266
|
+
} else {
|
|
267
|
+
Print.info("Updates available - see details above");
|
|
268
|
+
}
|
|
269
|
+
} else {
|
|
270
|
+
Print.error("Could not check for updates. Please check your internet connection");
|
|
248
271
|
}
|
|
249
|
-
}
|
|
250
|
-
Print.
|
|
272
|
+
} catch (error) {
|
|
273
|
+
Print.error(`Checking updates: ${error.message}`);
|
|
251
274
|
}
|
|
252
275
|
});
|
|
253
276
|
|
|
@@ -259,9 +282,9 @@ sliceClient
|
|
|
259
282
|
subcommandTerm: (cmd) => cmd.name() + ' ' + cmd.usage()
|
|
260
283
|
});
|
|
261
284
|
|
|
262
|
-
// Custom help
|
|
285
|
+
// Custom help - usando Print para consistencia
|
|
263
286
|
sliceClient.addHelpText('after', `
|
|
264
|
-
|
|
287
|
+
Common Usage Examples:
|
|
265
288
|
slice init - Initialize new Slice.js project
|
|
266
289
|
slice get Button Card Input - Install Visual components from registry
|
|
267
290
|
slice get FetchManager -s - Install Service component from registry
|
|
@@ -270,18 +293,28 @@ sliceClient.addHelpText('after', `
|
|
|
270
293
|
slice component create - Create new local component
|
|
271
294
|
slice update - Check for CLI/framework updates
|
|
272
295
|
|
|
273
|
-
|
|
296
|
+
Command Categories:
|
|
274
297
|
• init, version, update - Project setup and maintenance
|
|
275
298
|
• get, browse, sync - Quick registry shortcuts
|
|
276
299
|
• component <cmd> - Local component management
|
|
277
300
|
• registry <cmd> - Official repository operations
|
|
278
301
|
|
|
279
|
-
|
|
302
|
+
More info: https://slice-js-docs.vercel.app/
|
|
280
303
|
`);
|
|
281
304
|
|
|
282
|
-
// Default action
|
|
305
|
+
// Default action with better messaging
|
|
283
306
|
if (!process.argv.slice(2).length) {
|
|
284
307
|
program.outputHelp();
|
|
308
|
+
Print.newLine();
|
|
309
|
+
Print.info("Start with: slice init");
|
|
310
|
+
Print.commandExample("View available components", "slice browse");
|
|
285
311
|
}
|
|
286
312
|
|
|
313
|
+
// Error handling for unknown commands
|
|
314
|
+
program.on('command:*', () => {
|
|
315
|
+
Print.error('Invalid command. See available commands above');
|
|
316
|
+
Print.info("Use 'slice --help' for help");
|
|
317
|
+
process.exit(1);
|
|
318
|
+
});
|
|
319
|
+
|
|
287
320
|
program.parse();
|
package/commands/Print.js
CHANGED
|
@@ -1,12 +1,93 @@
|
|
|
1
|
-
export default class Print{
|
|
2
|
-
constructor(){}
|
|
1
|
+
export default class Print {
|
|
2
|
+
constructor() {}
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
static error(message) {
|
|
5
5
|
console.error('\x1b[31m', `❌ Error: ${message}`, '\x1b[0m');
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
static success(message) {
|
|
9
9
|
console.log('\x1b[32m', `✅ Success: ${message}`, '\x1b[0m');
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
|
|
12
|
+
static warning(message) {
|
|
13
|
+
console.log('\x1b[33m', `⚠️ Warning: ${message}`, '\x1b[0m');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
static info(message) {
|
|
17
|
+
console.log('\x1b[36m', `ℹ️ Info: ${message}`, '\x1b[0m');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static title(message) {
|
|
21
|
+
console.log('\x1b[35m\x1b[1m', `🎯 ${message}`, '\x1b[0m');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
static subtitle(message) {
|
|
25
|
+
console.log('\x1b[34m', `📋 ${message}`, '\x1b[0m');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
static step(stepNumber, message) {
|
|
29
|
+
console.log('\x1b[36m', `${stepNumber}. ${message}`, '\x1b[0m');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
static highlight(message) {
|
|
33
|
+
console.log('\x1b[43m\x1b[30m', ` ${message} `, '\x1b[0m');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
static newLine() {
|
|
37
|
+
console.log('');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static separator() {
|
|
41
|
+
console.log('\x1b[90m', '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━', '\x1b[0m');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Métodos para el contexto específico del CLI
|
|
45
|
+
static componentSuccess(componentName, action = 'processed') {
|
|
46
|
+
console.log('\x1b[32m', `✅ ${componentName} ${action} successfully!`, '\x1b[0m');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static componentError(componentName, action = 'processing', error) {
|
|
50
|
+
console.error('\x1b[31m', `❌ Error ${action} ${componentName}: ${error}`, '\x1b[0m');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
static downloadProgress(fileName) {
|
|
54
|
+
console.log('\x1b[36m', ` 📥 Downloading ${fileName}...`, '\x1b[0m');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static downloadSuccess(fileName) {
|
|
58
|
+
console.log('\x1b[32m', ` ✅ ${fileName}`, '\x1b[0m');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
static downloadError(fileName, error) {
|
|
62
|
+
console.error('\x1b[31m', ` ❌ Error downloading ${fileName}: ${error}`, '\x1b[0m');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
static registryUpdate(message) {
|
|
66
|
+
console.log('\x1b[35m', `📝 Registry: ${message}`, '\x1b[0m');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
static versionInfo(component, currentVersion, latestVersion = null) {
|
|
70
|
+
if (latestVersion && currentVersion !== latestVersion) {
|
|
71
|
+
console.log('\x1b[33m', `🔄 ${component}: v${currentVersion} → v${latestVersion}`, '\x1b[0m');
|
|
72
|
+
} else {
|
|
73
|
+
console.log('\x1b[32m', `✅ ${component}: v${currentVersion}`, '\x1b[0m');
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
static commandExample(description, command) {
|
|
78
|
+
console.log('\x1b[90m', `💡 ${description}:`, '\x1b[0m');
|
|
79
|
+
console.log('\x1b[37m', ` ${command}`, '\x1b[0m');
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
static summary(successful, failed, total) {
|
|
83
|
+
Print.separator();
|
|
84
|
+
console.log('\x1b[1m', '📊 Summary:', '\x1b[0m');
|
|
85
|
+
if (successful > 0) {
|
|
86
|
+
Print.success(`Successful: ${successful}/${total}`);
|
|
87
|
+
}
|
|
88
|
+
if (failed > 0) {
|
|
89
|
+
Print.error(`Failed: ${failed}/${total}`);
|
|
90
|
+
}
|
|
91
|
+
Print.separator();
|
|
92
|
+
}
|
|
12
93
|
}
|
|
@@ -10,8 +10,8 @@ import Print from "../Print.js";
|
|
|
10
10
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
11
11
|
|
|
12
12
|
// Base URL del repositorio de documentación de Slice.js
|
|
13
|
-
const DOCS_REPO_BASE_URL = 'https://raw.githubusercontent.com/VKneider/
|
|
14
|
-
const COMPONENTS_REGISTRY_URL = 'https://raw.githubusercontent.com/VKneider/
|
|
13
|
+
const DOCS_REPO_BASE_URL = 'https://raw.githubusercontent.com/VKneider/slicejs_docs/main/src/Components';
|
|
14
|
+
const COMPONENTS_REGISTRY_URL = 'https://raw.githubusercontent.com/VKneider/slicejs_docs/main/src/Components/components.js';
|
|
15
15
|
|
|
16
16
|
class ComponentRegistry {
|
|
17
17
|
constructor() {
|
|
@@ -19,7 +19,7 @@ class ComponentRegistry {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
async loadRegistry() {
|
|
22
|
-
Print.info('
|
|
22
|
+
Print.info('Loading component registry from official repository...');
|
|
23
23
|
|
|
24
24
|
try {
|
|
25
25
|
const response = await fetch(COMPONENTS_REGISTRY_URL);
|
|
@@ -37,11 +37,11 @@ class ComponentRegistry {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
this.componentsRegistry = eval('(' + match[1] + ')');
|
|
40
|
-
Print.success('
|
|
40
|
+
Print.success('Component registry loaded successfully');
|
|
41
41
|
|
|
42
42
|
} catch (error) {
|
|
43
|
-
Print.error(
|
|
44
|
-
Print.info('
|
|
43
|
+
Print.error(`Loading component registry: ${error.message}`);
|
|
44
|
+
Print.info('Check your internet connection and repository accessibility');
|
|
45
45
|
throw error;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
@@ -154,7 +154,7 @@ class ComponentRegistry {
|
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
const downloadedFiles = [];
|
|
157
|
-
Print.info(
|
|
157
|
+
Print.info(`Downloading ${componentName} from official repository...`);
|
|
158
158
|
|
|
159
159
|
for (const fileName of component.files) {
|
|
160
160
|
const githubUrl = `${DOCS_REPO_BASE_URL}/${category}/${componentName}/${fileName}`;
|
|
@@ -164,16 +164,16 @@ class ComponentRegistry {
|
|
|
164
164
|
const response = await fetch(githubUrl);
|
|
165
165
|
|
|
166
166
|
if (!response.ok) {
|
|
167
|
-
throw new Error(`HTTP ${response.status}: ${response.statusText}
|
|
167
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText} for ${fileName}`);
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
const content = await response.text();
|
|
171
171
|
await fs.writeFile(localPath, content, 'utf8');
|
|
172
172
|
downloadedFiles.push(fileName);
|
|
173
173
|
|
|
174
|
-
|
|
174
|
+
Print.downloadSuccess(fileName);
|
|
175
175
|
} catch (error) {
|
|
176
|
-
Print.
|
|
176
|
+
Print.downloadError(fileName, error.message);
|
|
177
177
|
throw error;
|
|
178
178
|
}
|
|
179
179
|
}
|
|
@@ -215,13 +215,13 @@ class ComponentRegistry {
|
|
|
215
215
|
const newContent = `const components = ${newComponentsString}; export default components;`;
|
|
216
216
|
|
|
217
217
|
await fs.writeFile(componentsPath, newContent, 'utf8');
|
|
218
|
-
Print.
|
|
218
|
+
Print.registryUpdate(`Registered ${componentName} in local components.js`);
|
|
219
219
|
} else {
|
|
220
|
-
Print.info(
|
|
220
|
+
Print.info(`${componentName} already exists in local registry`);
|
|
221
221
|
}
|
|
222
222
|
|
|
223
223
|
} catch (error) {
|
|
224
|
-
Print.error(
|
|
224
|
+
Print.error(`Updating local components.js: ${error.message}`);
|
|
225
225
|
throw error;
|
|
226
226
|
}
|
|
227
227
|
}
|
|
@@ -248,7 +248,7 @@ class ComponentRegistry {
|
|
|
248
248
|
]);
|
|
249
249
|
|
|
250
250
|
if (!overwrite) {
|
|
251
|
-
Print.info('
|
|
251
|
+
Print.info('Installation cancelled by user');
|
|
252
252
|
return false;
|
|
253
253
|
}
|
|
254
254
|
}
|
|
@@ -263,14 +263,14 @@ class ComponentRegistry {
|
|
|
263
263
|
// Update components registry
|
|
264
264
|
await this.updateLocalRegistry(componentName, category);
|
|
265
265
|
|
|
266
|
-
Print.success(
|
|
267
|
-
console.log(`📁
|
|
268
|
-
console.log(`📄
|
|
266
|
+
Print.success(`${componentName} updated successfully from official repository!`);
|
|
267
|
+
console.log(`📁 Location: src/${categoryPath}/${componentName}/`);
|
|
268
|
+
console.log(`📄 Files: ${downloadedFiles.join(', ')}`);
|
|
269
269
|
|
|
270
270
|
return true;
|
|
271
271
|
|
|
272
272
|
} catch (error) {
|
|
273
|
-
Print.error(
|
|
273
|
+
Print.error(`Error updating ${componentName}: ${error.message}`);
|
|
274
274
|
// Clean up partial installation
|
|
275
275
|
if (await fs.pathExists(targetPath)) {
|
|
276
276
|
await fs.remove(targetPath);
|
|
@@ -281,14 +281,14 @@ class ComponentRegistry {
|
|
|
281
281
|
|
|
282
282
|
async installMultipleComponents(componentNames, category = 'Visual', force = false) {
|
|
283
283
|
const results = [];
|
|
284
|
-
Print.info(
|
|
284
|
+
Print.info(`Getting ${componentNames.length} ${category} components from official repository...`);
|
|
285
285
|
|
|
286
286
|
for (const componentName of componentNames) {
|
|
287
287
|
try {
|
|
288
288
|
const result = await this.installComponent(componentName, category, force);
|
|
289
289
|
results.push({ name: componentName, success: result });
|
|
290
290
|
} catch (error) {
|
|
291
|
-
Print.
|
|
291
|
+
Print.componentError(componentName, 'getting', error.message);
|
|
292
292
|
results.push({ name: componentName, success: false, error: error.message });
|
|
293
293
|
}
|
|
294
294
|
}
|
|
@@ -297,30 +297,26 @@ class ComponentRegistry {
|
|
|
297
297
|
const successful = results.filter(r => r.success).length;
|
|
298
298
|
const failed = results.filter(r => !r.success).length;
|
|
299
299
|
|
|
300
|
-
|
|
301
|
-
Print.
|
|
302
|
-
if (failed > 0) {
|
|
303
|
-
Print.error(`❌ Fallidos: ${failed}`);
|
|
304
|
-
results.filter(r => !r.success).forEach(r => {
|
|
305
|
-
console.log(` • ${r.name}: ${r.error}`);
|
|
306
|
-
});
|
|
307
|
-
}
|
|
300
|
+
Print.newLine();
|
|
301
|
+
Print.summary(successful, failed, componentNames.length);
|
|
308
302
|
|
|
309
303
|
return results;
|
|
310
304
|
}
|
|
311
305
|
|
|
312
306
|
async updateAllComponents(force = false) {
|
|
313
|
-
Print.info('
|
|
307
|
+
Print.info('Looking for updatable components...');
|
|
314
308
|
|
|
315
309
|
const updatableComponents = await this.findUpdatableComponents();
|
|
316
310
|
|
|
317
311
|
if (updatableComponents.length === 0) {
|
|
318
|
-
Print.info('
|
|
319
|
-
Print.info('
|
|
312
|
+
Print.info('No local components found that match the official repository');
|
|
313
|
+
Print.info('Use "npm run slice:browse" to see available components');
|
|
320
314
|
return true;
|
|
321
315
|
}
|
|
322
316
|
|
|
323
|
-
|
|
317
|
+
Print.newLine();
|
|
318
|
+
Print.subtitle(`Found ${updatableComponents.length} updatable components:`);
|
|
319
|
+
Print.newLine();
|
|
324
320
|
updatableComponents.forEach(comp => {
|
|
325
321
|
const icon = comp.category === 'Visual' ? '🎨' : '⚙️';
|
|
326
322
|
console.log(`${icon} ${comp.name} (${comp.category})`);
|
|
@@ -331,13 +327,13 @@ class ComponentRegistry {
|
|
|
331
327
|
{
|
|
332
328
|
type: 'confirm',
|
|
333
329
|
name: 'confirmUpdate',
|
|
334
|
-
message:
|
|
330
|
+
message: `Do you want to update all these components to the repository versions?`,
|
|
335
331
|
default: true
|
|
336
332
|
}
|
|
337
333
|
]);
|
|
338
334
|
|
|
339
335
|
if (!confirmUpdate) {
|
|
340
|
-
Print.info('
|
|
336
|
+
Print.info('Update cancelled by user');
|
|
341
337
|
return false;
|
|
342
338
|
}
|
|
343
339
|
}
|
|
@@ -350,14 +346,14 @@ class ComponentRegistry {
|
|
|
350
346
|
|
|
351
347
|
// Update Visual components
|
|
352
348
|
if (visualComponents.length > 0) {
|
|
353
|
-
Print.info(
|
|
349
|
+
Print.info(`Updating ${visualComponents.length} Visual components...`);
|
|
354
350
|
const visualResults = await this.installMultipleComponents(visualComponents, 'Visual', true);
|
|
355
351
|
allResults = allResults.concat(visualResults);
|
|
356
352
|
}
|
|
357
353
|
|
|
358
354
|
// Update Service components
|
|
359
355
|
if (serviceComponents.length > 0) {
|
|
360
|
-
Print.info(
|
|
356
|
+
Print.info(`Updating ${serviceComponents.length} Service components...`);
|
|
361
357
|
const serviceResults = await this.installMultipleComponents(serviceComponents, 'Service', true);
|
|
362
358
|
allResults = allResults.concat(serviceResults);
|
|
363
359
|
}
|
|
@@ -366,13 +362,14 @@ class ComponentRegistry {
|
|
|
366
362
|
const totalSuccessful = allResults.filter(r => r.success).length;
|
|
367
363
|
const totalFailed = allResults.filter(r => !r.success).length;
|
|
368
364
|
|
|
369
|
-
|
|
370
|
-
Print.
|
|
365
|
+
Print.newLine();
|
|
366
|
+
Print.title('Final Update Summary');
|
|
367
|
+
Print.success(`Components updated: ${totalSuccessful}`);
|
|
371
368
|
|
|
372
369
|
if (totalFailed > 0) {
|
|
373
|
-
Print.error(
|
|
370
|
+
Print.error(`Components failed: ${totalFailed}`);
|
|
374
371
|
} else {
|
|
375
|
-
Print.success(
|
|
372
|
+
Print.success('All your components are now updated to the latest official versions!');
|
|
376
373
|
}
|
|
377
374
|
|
|
378
375
|
return totalFailed === 0;
|
|
@@ -503,8 +500,8 @@ async function getComponents(componentNames = [], options = {}) {
|
|
|
503
500
|
try {
|
|
504
501
|
await registry.loadRegistry();
|
|
505
502
|
} catch (error) {
|
|
506
|
-
Print.error('
|
|
507
|
-
Print.info('
|
|
503
|
+
Print.error('Could not load component registry from official repository');
|
|
504
|
+
Print.info('Check your internet connection and try again');
|
|
508
505
|
return false;
|
|
509
506
|
}
|
|
510
507
|
|
|
@@ -522,8 +519,8 @@ async function getComponents(componentNames = [], options = {}) {
|
|
|
522
519
|
const componentInfo = registry.findComponentInRegistry(componentNames[0]);
|
|
523
520
|
|
|
524
521
|
if (!componentInfo) {
|
|
525
|
-
Print.error(`
|
|
526
|
-
Print.
|
|
522
|
+
Print.error(`Component '${componentNames[0]}' not found in official repository`);
|
|
523
|
+
Print.commandExample('View available components', 'npm run slice:browse');
|
|
527
524
|
return false;
|
|
528
525
|
}
|
|
529
526
|
|
|
@@ -534,7 +531,7 @@ async function getComponents(componentNames = [], options = {}) {
|
|
|
534
531
|
await registry.installComponent(componentInfo.name, actualCategory, options.force);
|
|
535
532
|
return true;
|
|
536
533
|
} catch (error) {
|
|
537
|
-
Print.error(
|
|
534
|
+
Print.error(`${error.message}`);
|
|
538
535
|
return false;
|
|
539
536
|
}
|
|
540
537
|
} else {
|
|
@@ -547,7 +544,7 @@ async function getComponents(componentNames = [], options = {}) {
|
|
|
547
544
|
await registry.installMultipleComponents(normalizedComponents, category, options.force);
|
|
548
545
|
return true;
|
|
549
546
|
} catch (error) {
|
|
550
|
-
Print.error(
|
|
547
|
+
Print.error(`${error.message}`);
|
|
551
548
|
return false;
|
|
552
549
|
}
|
|
553
550
|
}
|
|
@@ -562,8 +559,8 @@ async function listComponents() {
|
|
|
562
559
|
registry.displayAvailableComponents();
|
|
563
560
|
return true;
|
|
564
561
|
} catch (error) {
|
|
565
|
-
Print.error('
|
|
566
|
-
Print.info('
|
|
562
|
+
Print.error('Could not load component registry from official repository');
|
|
563
|
+
Print.info('Check your internet connection and try again');
|
|
567
564
|
return false;
|
|
568
565
|
}
|
|
569
566
|
}
|
|
@@ -576,8 +573,8 @@ async function syncComponents(options = {}) {
|
|
|
576
573
|
await registry.loadRegistry();
|
|
577
574
|
return await registry.updateAllComponents(options.force);
|
|
578
575
|
} catch (error) {
|
|
579
|
-
Print.error('
|
|
580
|
-
Print.info('
|
|
576
|
+
Print.error('Could not load component registry from official repository');
|
|
577
|
+
Print.info('Check your internet connection and try again');
|
|
581
578
|
return false;
|
|
582
579
|
}
|
|
583
580
|
}
|
package/package.json
CHANGED
package/post.js
CHANGED
|
@@ -85,7 +85,7 @@ fs.promises.access(projectPackageJsonPath, fs.constants.F_OK)
|
|
|
85
85
|
scripts: {
|
|
86
86
|
// Main commands
|
|
87
87
|
'slice:init': 'node node_modules/slicejs-cli/client.js init',
|
|
88
|
-
'slice:start': 'node
|
|
88
|
+
'slice:start': 'node api/index.js',
|
|
89
89
|
'slice:version': 'node node_modules/slicejs-cli/client.js version',
|
|
90
90
|
'slice:update': 'node node_modules/slicejs-cli/client.js update',
|
|
91
91
|
|