slicejs-cli 4.4.0 → 4.6.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 (51) hide show
  1. package/client.js +192 -82
  2. package/commands/Print.js +158 -164
  3. package/commands/build/build.js +27 -1
  4. package/commands/buildProduction/buildProduction.js +42 -71
  5. package/commands/bundle/bundle.js +65 -60
  6. package/commands/docs/agents.js +260 -0
  7. package/commands/docs/events.js +365 -0
  8. package/commands/docs/index.js +123 -0
  9. package/commands/doctor/doctor.js +99 -12
  10. package/commands/export/checkExport.js +163 -0
  11. package/commands/export/clientRedirects.js +72 -0
  12. package/commands/export/copyDist.js +180 -0
  13. package/commands/export/export.js +236 -0
  14. package/commands/export/files.js +33 -0
  15. package/commands/export/hosts/cloudflare.js +48 -0
  16. package/commands/export/hosts/github.js +31 -0
  17. package/commands/export/hosts/index.js +69 -0
  18. package/commands/export/hosts/netlify.js +42 -0
  19. package/commands/export/hosts/nginx.js +73 -0
  20. package/commands/export/hosts/none.js +23 -0
  21. package/commands/export/hosts/s3.js +24 -0
  22. package/commands/export/hosts/shared.js +62 -0
  23. package/commands/export/hosts/vercel.js +69 -0
  24. package/commands/export/outDir.js +91 -0
  25. package/commands/export/prerender.js +121 -0
  26. package/commands/getComponent/getComponent.js +44 -40
  27. package/commands/init/init.js +32 -22
  28. package/commands/lint/lint.js +2 -2
  29. package/commands/lint/types.js +1 -1
  30. package/commands/listComponents/listComponents.js +205 -172
  31. package/commands/seo/check.js +7 -4
  32. package/commands/seo/images.js +77 -22
  33. package/commands/seo/sitemap.js +6 -3
  34. package/commands/seo/support.js +62 -0
  35. package/commands/setup/lint.js +1 -1
  36. package/commands/skill/skill.js +2 -2
  37. package/commands/startServer/startServer.js +60 -21
  38. package/commands/startServer/watchServer.js +3 -3
  39. package/commands/translator/check.js +32 -0
  40. package/commands/translator/init.js +125 -0
  41. package/commands/translator/scan.js +444 -0
  42. package/commands/typecheck/typecheck.js +2 -2
  43. package/commands/types/types.js +22 -3
  44. package/commands/utils/VersionChecker.js +14 -14
  45. package/commands/utils/bundling/BundleGenerator.js +45 -27
  46. package/commands/utils/bundling/DependencyAnalyzer.js +1007 -976
  47. package/commands/utils/componentCatalog.js +120 -0
  48. package/commands/utils/publicEnv.js +74 -0
  49. package/commands/utils/sliceConfigSchema.js +34 -0
  50. package/commands/utils/updateManager.js +12 -12
  51. package/package.json +22 -23
@@ -0,0 +1,73 @@
1
+ // commands/export/hosts/nginx.js
2
+ import fs from 'fs-extra';
3
+ import path from 'path';
4
+ import { nginxSecurityHeaders } from './shared.js';
5
+
6
+ const security = nginxSecurityHeaders(' ');
7
+
8
+ export default {
9
+ id: 'nginx',
10
+ spaMode: 'try-files',
11
+ clientRedirectPages: false,
12
+ ruleFiles: ['nginx.conf'],
13
+
14
+ async write({ outDir, redirects, spa }) {
15
+ const redirectBlock = redirects
16
+ .map(({ from, to, status }) => `location = ${from} {\n return ${status} ${to};\n}\n`)
17
+ .join('\n');
18
+ const fallback = spa ? 'try_files $uri $uri/ /index.html;' : 'try_files $uri $uri/ =404;';
19
+
20
+ const nginx = `root /var/www/dist-static;
21
+ index index.html;
22
+
23
+ ${redirectBlock}location / {
24
+ ${fallback}
25
+ ${security}
26
+ }
27
+
28
+ error_page 404 /404.html;
29
+
30
+ location /bundles/ {
31
+ ${security}
32
+ add_header Cache-Control "no-store";
33
+ }
34
+
35
+ location = /slice-env.json {
36
+ ${security}
37
+ add_header Cache-Control "no-store";
38
+ }
39
+
40
+ location = /slice-env.generated.js {
41
+ ${security}
42
+ add_header Cache-Control "no-store";
43
+ }
44
+ `;
45
+
46
+ await fs.writeFile(path.join(outDir, 'nginx.conf'), nginx, 'utf8');
47
+ return ['nginx.conf'];
48
+ },
49
+
50
+ async check({ outDir, explicitHost }) {
51
+ const issues = [];
52
+ const warnings = [];
53
+ const file = path.join(outDir, 'nginx.conf');
54
+ const hasNginx = await fs.pathExists(file);
55
+
56
+ if (hasNginx) {
57
+ const text = await fs.readFile(file, 'utf8');
58
+ if (!/error_page\s+404\s+\/404\.html/.test(text)) {
59
+ issues.push('nginx.conf does not map 404 to /404.html.');
60
+ }
61
+ }
62
+ if (explicitHost && !hasNginx) {
63
+ issues.push('nginx export is missing nginx.conf.');
64
+ }
65
+ return { issues, warnings };
66
+ },
67
+
68
+ async spaFallback({ outDir }) {
69
+ const file = path.join(outDir, 'nginx.conf');
70
+ if (!await fs.pathExists(file)) return false;
71
+ return /try_files\s+\$uri\s+\$uri\/\s+\/index\.html/.test(await fs.readFile(file, 'utf8'));
72
+ }
73
+ };
@@ -0,0 +1,23 @@
1
+ // commands/export/hosts/none.js
2
+ import { clientSpaFallback } from './shared.js';
3
+
4
+ export default {
5
+ id: 'none',
6
+ // Portable export: no host files. `--spa` writes the shell as 404.html; the
7
+ // server in front decides the status.
8
+ spaMode: 'client-404',
9
+ clientRedirectPages: true,
10
+ ruleFiles: [],
11
+
12
+ async write() {
13
+ return [];
14
+ },
15
+
16
+ async check() {
17
+ return { issues: [], warnings: [] };
18
+ },
19
+
20
+ spaFallback({ outDir }) {
21
+ return clientSpaFallback(outDir);
22
+ }
23
+ };
@@ -0,0 +1,24 @@
1
+ // commands/export/hosts/s3.js
2
+ import { clientSpaFallback } from './shared.js';
3
+
4
+ export default {
5
+ id: 's3',
6
+ // S3/CloudFront are configured in the bucket/distribution, not in the export.
7
+ // `--spa` writes the shell as 404.html; a CloudFront function is required for
8
+ // a true 200 navigation fallback.
9
+ spaMode: 'client-404',
10
+ clientRedirectPages: true,
11
+ ruleFiles: [],
12
+
13
+ async write() {
14
+ return [];
15
+ },
16
+
17
+ async check() {
18
+ return { issues: [], warnings: [] };
19
+ },
20
+
21
+ spaFallback({ outDir }) {
22
+ return clientSpaFallback(outDir);
23
+ }
24
+ };
@@ -0,0 +1,62 @@
1
+ // commands/export/hosts/shared.js
2
+ //
3
+ // Pieces every host preset shares: the security headers, the Cloudflare/Netlify
4
+ // `_headers` text, redirect lines and the marker used by the client-side
5
+ // 404 fallback.
6
+ import fs from 'fs-extra';
7
+ import path from 'path';
8
+
9
+ export const SECURITY_HEADERS = [
10
+ ['X-Content-Type-Options', 'nosniff'],
11
+ ['X-Frame-Options', 'DENY'],
12
+ ['Referrer-Policy', 'strict-origin-when-cross-origin']
13
+ ];
14
+
15
+ export const HEADER_RULES = `/*
16
+ X-Content-Type-Options: nosniff
17
+ X-Frame-Options: DENY
18
+ Referrer-Policy: strict-origin-when-cross-origin
19
+ /bundles/*
20
+ Cache-Control: no-store
21
+ /slice-env.json
22
+ Cache-Control: no-store
23
+ /slice-env.generated.js
24
+ Cache-Control: no-store
25
+ `;
26
+
27
+ // Written into the `404.html` shell used by GitHub Pages, S3 and `--host none`.
28
+ // `--check` uses it to know that unknown routes render the app.
29
+ export const CLIENT_SPA_MARKER = '<!-- slice:client-spa-fallback -->';
30
+
31
+ export function redirectLines(redirects) {
32
+ return redirects.map(({ from, to, status }) => `${from} ${to} ${status}`).join('\n');
33
+ }
34
+
35
+ export function redirectCatchAll(text) {
36
+ return /^\s*\/\*\s+\/index\.html\s+200\s*$/m.test(text);
37
+ }
38
+
39
+ export async function readJsonIfExists(file) {
40
+ if (!await fs.pathExists(file)) return null;
41
+ try {
42
+ return JSON.parse(await fs.readFile(file, 'utf8'));
43
+ } catch {
44
+ return null;
45
+ }
46
+ }
47
+
48
+ export function securityHeaderObjects() {
49
+ return SECURITY_HEADERS.map(([key, value]) => ({ key, value }));
50
+ }
51
+
52
+ export function nginxSecurityHeaders(indent = ' ') {
53
+ return SECURITY_HEADERS
54
+ .map(([key, value]) => `${indent}add_header ${key} "${value}" always;`)
55
+ .join('\n');
56
+ }
57
+
58
+ export async function clientSpaFallback(outDir) {
59
+ const file = path.join(outDir, '404.html');
60
+ if (!await fs.pathExists(file)) return false;
61
+ return (await fs.readFile(file, 'utf8')).includes(CLIENT_SPA_MARKER);
62
+ }
@@ -0,0 +1,69 @@
1
+ // commands/export/hosts/vercel.js
2
+ import fs from 'fs-extra';
3
+ import path from 'path';
4
+ import { readJsonIfExists, securityHeaderObjects } from './shared.js';
5
+
6
+ export default {
7
+ id: 'vercel',
8
+ // Vercel checks the filesystem before applying rewrites, so `/(.*)` does not
9
+ // shadow assets.
10
+ spaMode: 'rewrite',
11
+ clientRedirectPages: false,
12
+ ruleFiles: ['vercel.json'],
13
+
14
+ async write({ outDir, redirects, spa }) {
15
+ const securityHeaders = securityHeaderObjects();
16
+ const noStoreHeaders = [
17
+ ...securityHeaders,
18
+ { key: 'Cache-Control', value: 'no-store' }
19
+ ];
20
+ const vercel = {
21
+ headers: [
22
+ { source: '/(.*)', headers: securityHeaders },
23
+ { source: '/bundles/(.*)', headers: noStoreHeaders },
24
+ { source: '/slice-env.json', headers: noStoreHeaders },
25
+ { source: '/slice-env.generated.js', headers: noStoreHeaders }
26
+ ]
27
+ };
28
+
29
+ if (spa) {
30
+ vercel.rewrites = [{ source: '/(.*)', destination: '/index.html' }];
31
+ }
32
+ if (redirects.length) {
33
+ // `permanent` maps to 308/307; preserve the SEO status with `statusCode`.
34
+ vercel.redirects = redirects.map(({ from, to, status }) => ({
35
+ source: from,
36
+ destination: to,
37
+ statusCode: status
38
+ }));
39
+ }
40
+
41
+ await fs.writeFile(
42
+ path.join(outDir, 'vercel.json'),
43
+ `${JSON.stringify(vercel, null, 2)}\n`,
44
+ 'utf8'
45
+ );
46
+ return ['vercel.json'];
47
+ },
48
+
49
+ async check({ outDir, explicitHost }) {
50
+ const issues = [];
51
+ const warnings = [];
52
+ const file = path.join(outDir, 'vercel.json');
53
+ const hasVercel = await fs.pathExists(file);
54
+
55
+ if (hasVercel && !await readJsonIfExists(file)) {
56
+ issues.push('vercel.json is not valid JSON.');
57
+ }
58
+ if (explicitHost && !hasVercel) {
59
+ issues.push('Vercel export is missing vercel.json.');
60
+ }
61
+ return { issues, warnings };
62
+ },
63
+
64
+ async spaFallback({ outDir }) {
65
+ const vercel = await readJsonIfExists(path.join(outDir, 'vercel.json'));
66
+ const rewrites = Array.isArray(vercel?.rewrites) ? vercel.rewrites : [];
67
+ return rewrites.some((rewrite) => rewrite?.destination === '/index.html');
68
+ }
69
+ };
@@ -0,0 +1,91 @@
1
+ // commands/export/outDir.js
2
+ import fs from 'fs-extra';
3
+ import path from 'path';
4
+
5
+ const PROTECTED_OUT_DIRS = new Set([
6
+ 'src',
7
+ 'dist',
8
+ 'api',
9
+ 'node_modules',
10
+ '.git',
11
+ 'public',
12
+ 'locales',
13
+ 'components',
14
+ 'app',
15
+ 'bundles',
16
+ 'slice'
17
+ ]);
18
+
19
+ function isInside(parent, child) {
20
+ const relative = path.relative(parent, child);
21
+ return relative === '' || (!relative.startsWith('..') && !path.isAbsolute(relative));
22
+ }
23
+
24
+ async function nearestExistingAncestor(target) {
25
+ let current = target;
26
+ while (!await fs.pathExists(current)) {
27
+ const parent = path.dirname(current);
28
+ if (parent === current) return current;
29
+ current = parent;
30
+ }
31
+ return current;
32
+ }
33
+
34
+ /**
35
+ * `slice export --out` runs `fs.remove()` on the target. Validate it before any
36
+ * write, so a typo like `--out .` or `--out src` cannot delete the project.
37
+ */
38
+ export async function resolveSafeOutDir(projectRoot, outOption) {
39
+ const requested = outOption == null || outOption === '' ? 'dist-static' : String(outOption);
40
+ const outDir = path.resolve(projectRoot, requested);
41
+ const relative = path.relative(projectRoot, outDir);
42
+
43
+ if (relative === '') {
44
+ throw new Error('Refusing to export into the project root. Use a dedicated folder such as dist-static.');
45
+ }
46
+ if (relative.startsWith('..') || path.isAbsolute(relative)) {
47
+ throw new Error(`Refusing to export outside the project: ${outDir}`);
48
+ }
49
+ if (isInside(outDir, projectRoot)) {
50
+ throw new Error(`Refusing to export into an ancestor of the project: ${outDir}`);
51
+ }
52
+
53
+ const topLevel = relative.split(path.sep)[0];
54
+ if (PROTECTED_OUT_DIRS.has(topLevel.toLowerCase())) {
55
+ throw new Error(
56
+ `Refusing to export into ${topLevel}/: it holds source, build or runtime files. Use a dedicated folder such as dist-static.`
57
+ );
58
+ }
59
+
60
+ if (await fs.pathExists(outDir)) {
61
+ const stat = await fs.lstat(outDir);
62
+ if (stat.isSymbolicLink() || !stat.isDirectory()) {
63
+ throw new Error(`Refusing to overwrite ${outDir}: the output path is not a directory.`);
64
+ }
65
+
66
+ // Existing folders are only overwritten when they look like a previous
67
+ // export. This protects `docs/`, `tests/`, `.github/` and any other real
68
+ // project folder from a mistyped `--out`.
69
+ const markers = await Promise.all([
70
+ fs.pathExists(path.join(outDir, 'index.html')),
71
+ fs.pathExists(path.join(outDir, 'bundles', 'bundle.config.json')),
72
+ fs.pathExists(path.join(outDir, 'slice-env.json'))
73
+ ]);
74
+ if (!markers.some(Boolean)) {
75
+ throw new Error(
76
+ `Refusing to overwrite ${outDir}: it exists but does not look like a previous export. Remove it or choose a new --out folder.`
77
+ );
78
+ }
79
+ }
80
+
81
+ // A parent folder can be a symlink that points outside the project even when
82
+ // the textual path is inside it. Resolve the nearest existing ancestor before
83
+ // allowing `fs.remove()` to run.
84
+ const realProject = await fs.realpath(projectRoot);
85
+ const realExisting = await fs.realpath(await nearestExistingAncestor(outDir));
86
+ if (!isInside(realProject, realExisting)) {
87
+ throw new Error(`Refusing to export through a symlink that leaves the project: ${outDir}`);
88
+ }
89
+
90
+ return outDir;
91
+ }
@@ -0,0 +1,121 @@
1
+ // commands/export/prerender.js
2
+ import fs from 'fs-extra';
3
+ import path from 'path';
4
+
5
+ export const PARAM_ROUTE = /\$\{[^}]+\}/;
6
+
7
+ /**
8
+ * `slice export` needs a framework new enough to expose prepareSeo's
9
+ * pages/notFound/redirects and expandPatternPaths. Import lazily so a CLI
10
+ * installed with an older framework still runs every other command.
11
+ */
12
+ async function loadExportFramework() {
13
+ let serverModule;
14
+ let seoModule;
15
+ try {
16
+ serverModule = await import('slicejs-web-framework/api/framework/server.js');
17
+ seoModule = await import('slicejs-web-framework/api/framework/seo.js');
18
+ } catch (error) {
19
+ throw new Error(
20
+ `slice export needs a slicejs-web-framework with prepareSeo pages/notFound/redirects and expandPatternPaths. Update it with "npm install slicejs-web-framework@latest". ${error.message}`
21
+ );
22
+ }
23
+
24
+ const prepareSeo = serverModule?.prepareSeo;
25
+ const expandPatternPaths = seoModule?.expandPatternPaths;
26
+ if (typeof prepareSeo !== 'function' || typeof expandPatternPaths !== 'function') {
27
+ throw new Error(
28
+ 'The installed slicejs-web-framework is too old for slice export: prepareSeo must expose pages/notFound/redirects and seo.js must export expandPatternPaths. Update it with "npm install slicejs-web-framework@latest".'
29
+ );
30
+ }
31
+
32
+ return { prepareSeo, expandPatternPaths };
33
+ }
34
+
35
+ async function findSeoManifest(projectRoot, distDir, options) {
36
+ const candidates = [];
37
+ if (options.seo) candidates.push(options.seo);
38
+ candidates.push(
39
+ 'seo.json',
40
+ 'src/public/seo.json',
41
+ 'src/seo.json',
42
+ path.join(distDir, 'public', 'seo.json'),
43
+ path.join(distDir, 'seo.json')
44
+ );
45
+ for (const candidate of candidates) {
46
+ const full = path.isAbsolute(candidate) ? candidate : path.resolve(projectRoot, candidate);
47
+ if (await fs.pathExists(full)) return full;
48
+ }
49
+ return null;
50
+ }
51
+
52
+ async function findImagesManifest(projectRoot, distDir, options) {
53
+ const candidates = [];
54
+ if (options.images) candidates.push(options.images);
55
+ candidates.push(
56
+ 'src/public/og/manifest.json',
57
+ path.join(distDir, 'public', 'og', 'manifest.json')
58
+ );
59
+ for (const candidate of candidates) {
60
+ const full = path.isAbsolute(candidate) ? candidate : path.resolve(projectRoot, candidate);
61
+ if (await fs.pathExists(full)) return full;
62
+ }
63
+ return null;
64
+ }
65
+
66
+ export async function buildPrerender(projectRoot, distDir, options) {
67
+ if (options.prerender === false) return null;
68
+
69
+ const seoFile = await findSeoManifest(projectRoot, distDir, options);
70
+ if (!seoFile) return null;
71
+
72
+ const imagesFile = await findImagesManifest(projectRoot, distDir, options);
73
+ const { prepareSeo, expandPatternPaths } = await loadExportFramework();
74
+ const seo = await prepareSeo({
75
+ projectRoot,
76
+ mode: 'production',
77
+ port: options.port ? Number(options.port) : undefined,
78
+ seo: {
79
+ manifest: seoFile,
80
+ ...(options.origin ? { origin: options.origin } : {}),
81
+ ...(imagesFile ? { images: imagesFile } : {})
82
+ }
83
+ });
84
+ if (!seo) return null;
85
+
86
+ if (!(seo.pages instanceof Map) || !(seo.notFound instanceof Map) || !Array.isArray(seo.redirects)) {
87
+ throw new Error(
88
+ 'prepareSeo() from the installed slicejs-web-framework did not return pages/notFound/redirects. Update it with "npm install slicejs-web-framework@latest".'
89
+ );
90
+ }
91
+
92
+ // A `${param}` route cannot be enumerated unless it opts in with sitemap.paths.
93
+ const pages = new Map(seo.pages);
94
+ const locales = seo.translator?.enabled ? seo.translator.locales : [null];
95
+ let patternsSkipped = 0;
96
+
97
+ for (const route of seo.routes) {
98
+ if (!PARAM_ROUTE.test(route.path)) continue;
99
+ const values = seo.manifest.routes?.[route.path]?.sitemap?.paths;
100
+ const concretePaths = expandPatternPaths(route.path, values);
101
+ if (concretePaths.length === 0) {
102
+ patternsSkipped += 1;
103
+ continue;
104
+ }
105
+ for (const concrete of concretePaths) {
106
+ for (const locale of locales) {
107
+ const url = seo.translator?.enabled ? seo.translator.localize(concrete, locale) : concrete;
108
+ if (pages.has(url)) continue;
109
+ const result = seo.resolve(url);
110
+ if (result.status === 200 && result.page) pages.set(url, result.page);
111
+ }
112
+ }
113
+ }
114
+
115
+ return {
116
+ seo,
117
+ pages,
118
+ patternsSkipped,
119
+ localeCount: seo.translator?.enabled ? seo.translator.locales.length : 0
120
+ };
121
+ }
@@ -14,6 +14,23 @@ import ora from "ora";
14
14
  const DOCS_REPO_BASE_URL = 'https://raw.githubusercontent.com/VKneider/slicejs-components/master/src/Components';
15
15
  const COMPONENTS_REGISTRY_URL = 'https://raw.githubusercontent.com/VKneider/slicejs-components/master/src/Components/components.js';
16
16
 
17
+ function wrapNames(names, indent = ' ') {
18
+ const width = Math.max(40, (process.stdout.columns || 80) - indent.length);
19
+ const lines = [];
20
+ let current = '';
21
+ for (const name of names) {
22
+ const next = current ? `${current}, ${name}` : name;
23
+ if (next.length > width && current) {
24
+ lines.push(current);
25
+ current = name;
26
+ } else {
27
+ current = next;
28
+ }
29
+ }
30
+ if (current) lines.push(current);
31
+ return lines.map((line) => `${indent}${line}`);
32
+ }
33
+
17
34
  /**
18
35
  * Loads configuration from sliceConfig.json
19
36
  * @returns {object} - Configuration object
@@ -140,7 +157,7 @@ filterOfficialComponents(allComponents) {
140
157
 
141
158
  return JSON.parse(match[1]);
142
159
  } catch (error) {
143
- Print.warning(`⚠️ Could not read the local component registry at: ${componentsPath}`);
160
+ Print.warning(`Could not read the local component registry at ${componentsPath}`);
144
161
  return {};
145
162
  }
146
163
  }
@@ -186,11 +203,9 @@ filterOfficialComponents(allComponents) {
186
203
  // Logical routing components only need JS
187
204
  if (['Route', 'MultiRoute', 'Link'].includes(name)) {
188
205
  files = [`${name}.js`];
189
- } else if (name === 'Icon') {
190
- // Icon component needs font files to render glyphs
191
- files = [`${name}.js`, `${name}.html`, `${name}.css`, 'slc.eot', 'slc.woff2', 'slc.woff', 'slc.ttf', 'slc.svg'];
192
206
  } else {
193
- // Normal visual components need JS, HTML, CSS
207
+ // Normal visual components need JS, HTML, CSS (Icon draws inline SVG; its
208
+ // icons.generated.js arrives as a relative import, like any helper).
194
209
  files = [`${name}.js`, `${name}.html`, `${name}.css`];
195
210
  }
196
211
  } else {
@@ -380,8 +395,8 @@ filterOfficialComponents(allComponents) {
380
395
  await this.updateLocalRegistrySafe(componentName, category);
381
396
 
382
397
  Print.success(`${componentName} installed successfully from official repository!`);
383
- console.log(`📁 Location: ${[folderSuffix, categoryPath, componentName].join('/').replace(/\/+/g, '/')}/`);
384
- console.log(`📄 Files: ${downloadedFiles.join(', ')}`);
398
+ console.log(`Location: ${[folderSuffix, categoryPath, componentName].join('/').replace(/\/+/g, '/')}/`);
399
+ console.log(`Files: ${downloadedFiles.join(', ')}`);
385
400
 
386
401
  // Resolve and install what this component pulls in: other components via
387
402
  // slice.build('X') or relative imports, and helper .js modules it imports.
@@ -504,8 +519,9 @@ filterOfficialComponents(allComponents) {
504
519
  try {
505
520
  content = await fetchWithRetry(url, 3, 500, false);
506
521
  } catch (error) {
507
- Print.warning(`Could not download helper module '${repoRelPath}' — ${error.message}`);
508
- return;
522
+ // A component whose helper is missing installs as a broken import. Fail the install
523
+ // instead of printing "installed successfully".
524
+ throw new Error(`Could not download helper module '${repoRelPath}': ${error.message}`, { cause: error });
509
525
  }
510
526
 
511
527
  await fs.ensureDir(path.dirname(localPath));
@@ -571,10 +587,10 @@ filterOfficialComponents(allComponents) {
571
587
  }
572
588
 
573
589
  Print.newLine();
574
- Print.subtitle(`Found ${updatableComponents.length} updatable Visual components:`);
590
+ Print.subtitle(`Found ${updatableComponents.length} updatable Visual components`);
575
591
  Print.newLine();
576
592
  updatableComponents.forEach(comp => {
577
- console.log(`🎨 ${comp.name} (${comp.category})`);
593
+ console.log(` ${comp.name} (${comp.category})`);
578
594
  });
579
595
 
580
596
  if (!force) {
@@ -604,7 +620,7 @@ filterOfficialComponents(allComponents) {
604
620
  const totalFailed = results.filter(r => !r.success).length;
605
621
 
606
622
  Print.newLine();
607
- Print.title('Visual Components Sync Summary');
623
+ Print.title('Sync summary');
608
624
  Print.success(`Visual components updated: ${totalSuccessful}`);
609
625
 
610
626
  if (totalFailed > 0) {
@@ -626,40 +642,28 @@ filterOfficialComponents(allComponents) {
626
642
 
627
643
  displayAvailableComponents() {
628
644
  if (!this.componentsRegistry) {
629
- Print.error('❌ Could not load component registry');
645
+ Print.error('Could not load component registry');
630
646
  return;
631
647
  }
632
648
 
633
- console.log('\n📚 Available components in the official Slice.js repository:\n');
634
-
635
649
  const visualComponents = this.getAvailableComponents('Visual');
636
650
  const serviceComponents = this.getAvailableComponents('Service');
651
+ const visualNames = Object.keys(visualComponents).sort((a, b) => a.localeCompare(b));
652
+ const serviceNames = Object.keys(serviceComponents).sort((a, b) => a.localeCompare(b));
637
653
 
638
- // Only show names without descriptions
639
- Print.info('🎨 Visual Components (UI):');
640
- Object.keys(visualComponents).forEach(name => {
641
- const files = visualComponents[name].files;
642
- const fileIcons = files.map(file => {
643
- if (file.endsWith('.js')) return '📜';
644
- if (file.endsWith('.html')) return '🌐';
645
- if (file.endsWith('.css')) return '🎨';
646
- return '📄';
647
- }).join(' ');
648
- console.log(` • ${name} ${fileIcons}`);
649
- });
650
-
651
- Print.info('\n⚙️ Service Components (Logic):');
652
- Object.keys(serviceComponents).forEach(name => {
653
- console.log(` • ${name} 📜`);
654
- });
655
-
654
+ Print.title('Available components');
655
+ Print.subtitle(`Visual (${visualNames.length})`);
656
+ for (const line of wrapNames(visualNames)) console.log(line);
656
657
  Print.newLine();
657
- Print.info(`Total: ${Object.keys(visualComponents).length} Visual + ${Object.keys(serviceComponents).length} Service components`);
658
+ Print.subtitle(`Service (${serviceNames.length})`);
659
+ for (const line of wrapNames(serviceNames)) console.log(line);
658
660
 
659
- console.log(`\n💡 Usage examples:`);
660
- console.log(`slice get Button Card Input # Install Visual components`);
661
- console.log(`slice get FetchManager --service # Install Service component`);
662
- console.log(`slice sync # Sync Visual components`);
661
+ Print.newLine();
662
+ Print.info(`Total: ${visualNames.length} Visual + ${serviceNames.length} Service components`);
663
+ Print.subtitle('Usage examples');
664
+ Print.commandExample('Install Visual components', 'slice get Button Card Input');
665
+ Print.commandExample('Install a Service component', 'slice get FetchManager --service');
666
+ Print.commandExample('Sync Visual components', 'slice sync');
663
667
  }
664
668
 
665
669
  async interactiveInstall() {
@@ -669,8 +673,8 @@ filterOfficialComponents(allComponents) {
669
673
  name: 'componentType',
670
674
  message: 'Select the type of component to install from the repository:',
671
675
  choices: [
672
- { name: '🎨 Visual Components (UI)', value: 'Visual' },
673
- { name: '⚙️ Service Components (Logic)', value: 'Service' }
676
+ { name: 'Visual components (UI)', value: 'Visual' },
677
+ { name: 'Service components (logic)', value: 'Service' }
674
678
  ]
675
679
  }
676
680
  ]);