slicejs-cli 3.4.1 → 3.5.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.
@@ -21,6 +21,15 @@ const STARTER_VISUAL_COMPONENTS = [
21
21
  'Route'
22
22
  ];
23
23
 
24
+ // Service components are now also pulled from the registry on init (instead of
25
+ // being vendored in the framework package), so Visual and Service share a single
26
+ // source of truth. Newcomers add more on demand with `slice get <Name>`.
27
+ const STARTER_SERVICE_COMPONENTS = [
28
+ 'FetchManager',
29
+ 'IndexedDbManager',
30
+ 'LocalStorageManager'
31
+ ];
32
+
24
33
  export default async function initializeProject(projectType) {
25
34
  try {
26
35
  const projectRoot = getProjectRoot(import.meta.url);
@@ -101,7 +110,7 @@ export default async function initializeProject(projectType) {
101
110
 
102
111
  if (stat.isDirectory()) {
103
112
  if (item === 'Components') {
104
- // Create Components structure but without copying Visual
113
+ // Create Components structure but without copying Visual or Service
105
114
  await fs.ensureDir(destItemPath);
106
115
 
107
116
  const componentItems = await fs.readdir(srcItemPath);
@@ -109,11 +118,11 @@ export default async function initializeProject(projectType) {
109
118
  const componentItemPath = path.join(srcItemPath, componentItem);
110
119
  const destComponentItemPath = path.join(destItemPath, componentItem);
111
120
 
112
- if (componentItem !== 'Visual') {
113
- // Copy Service and other component types
121
+ if (componentItem !== 'Visual' && componentItem !== 'Service') {
122
+ // Copy AppComponents and other template types from the framework
114
123
  await fs.copy(componentItemPath, destComponentItemPath, { recursive: true });
115
124
  } else {
116
- // Only create empty Visual directory
125
+ // Visual and Service are installed from the registry below
117
126
  await fs.ensureDir(destComponentItemPath);
118
127
  }
119
128
  }
@@ -176,6 +185,42 @@ export default async function initializeProject(projectType) {
176
185
  Print.info('You can add them later using "slice get <component-name>"');
177
186
  }
178
187
 
188
+ // 3b. DOWNLOAD STARTER SERVICE COMPONENTS FROM OFFICIAL REPOSITORY
189
+ const serviceSpinner = ora('Installing starter Service components...').start();
190
+ try {
191
+ const registry = new ComponentRegistry();
192
+ await registry.loadRegistry();
193
+
194
+ if (STARTER_SERVICE_COMPONENTS.length > 0) {
195
+ Print.info(`Installing ${STARTER_SERVICE_COMPONENTS.length} starter Service components: ${STARTER_SERVICE_COMPONENTS.join(', ')}`);
196
+ serviceSpinner.text = `Installing ${STARTER_SERVICE_COMPONENTS.length} starter Service components...`;
197
+
198
+ const results = await registry.installMultipleComponents(
199
+ STARTER_SERVICE_COMPONENTS,
200
+ 'Service',
201
+ true // force = true for initial installation
202
+ );
203
+
204
+ const successful = results.filter(r => r.success).length;
205
+ const failed = results.filter(r => !r.success).length;
206
+
207
+ if (successful > 0 && failed === 0) {
208
+ serviceSpinner.succeed(`All ${successful} Service components installed successfully`);
209
+ } else if (successful > 0) {
210
+ serviceSpinner.warn(`${successful} Service components installed, ${failed} failed`);
211
+ Print.info('You can install failed components later using "slice get <component-name>"');
212
+ } else {
213
+ serviceSpinner.fail('Failed to install Service components');
214
+ }
215
+ } else {
216
+ serviceSpinner.succeed('No starter Service components to install');
217
+ }
218
+ } catch (error) {
219
+ serviceSpinner.fail('Could not download Service components from official repository');
220
+ Print.error(`Repository error: ${error.message}`);
221
+ Print.info('You can add them later using "slice get <component-name>"');
222
+ }
223
+
179
224
  // 4. CONFIGURE SCRIPTS IN PROJECT package.json
180
225
  const pkgSpinner = ora('Configuring npm scripts...').start();
181
226
  try {
@@ -264,6 +309,8 @@ export default async function initializeProject(projectType) {
264
309
  }
265
310
  }
266
311
 
267
- // NOTE: `slice init` now installs only STARTER_VISUAL_COMPONENTS (see top of file).
312
+ // NOTE: `slice init` installs only STARTER_VISUAL_COMPONENTS and
313
+ // STARTER_SERVICE_COMPONENTS (see top of file); both Visual and Service are pulled
314
+ // from the registry rather than vendored in the framework package.
268
315
  // To install every registry component instead, iterate
269
- // `Object.keys(registry.getAvailableComponents('Visual'))`.
316
+ // `Object.keys(registry.getAvailableComponents('Visual'))` (and likewise 'Service').
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slicejs-cli",
3
- "version": "3.4.1",
3
+ "version": "3.5.0",
4
4
  "description": "Command client for developing web applications with Slice.js framework",
5
5
  "main": "client.js",
6
6
  "bin": {
@@ -55,4 +55,4 @@
55
55
  "slicejs-web-framework": "latest",
56
56
  "terser": "^5.43.1"
57
57
  }
58
- }
58
+ }