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
package/commands/Print.js CHANGED
@@ -1,164 +1,158 @@
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
- }
1
+ import chalk from 'chalk';
2
+
3
+ /**
4
+ * CLI output vocabulary.
5
+ *
6
+ * One symbol per severity, one alignment for hints, no repeated "Info:" /
7
+ * "Success:" labels. Commands should print outcomes, not log levels.
8
+ */
9
+ export default class Print {
10
+ constructor() { }
11
+
12
+ static error(message) {
13
+ console.error(`${chalk.red('✖')} ${message}`);
14
+ }
15
+
16
+ static success(message) {
17
+ console.log(`${chalk.green('✔')} ${message}`);
18
+ }
19
+
20
+ static warning(message) {
21
+ console.log(`${chalk.yellow('!')} ${message}`);
22
+ }
23
+
24
+ static info(message) {
25
+ console.log(`${chalk.cyan('•')} ${message}`);
26
+ }
27
+
28
+ static title(message) {
29
+ console.log(`\n${chalk.bold(message)}`);
30
+ }
31
+
32
+ static subtitle(message) {
33
+ console.log(chalk.cyan.bold(message));
34
+ }
35
+
36
+ static step(stepNumber, message) {
37
+ console.log(`${chalk.cyan(`${stepNumber}.`)} ${message}`);
38
+ }
39
+
40
+ static highlight(message) {
41
+ console.log(chalk.bgYellow.black(` ${message} `));
42
+ }
43
+
44
+ static newLine() {
45
+ console.log('');
46
+ }
47
+
48
+ static separator() {
49
+ console.log(chalk.gray('─'.repeat(52)));
50
+ }
51
+
52
+ static componentSuccess(componentName, action = 'processed') {
53
+ console.log(`${chalk.green('✔')} ${chalk.bold(componentName)} ${action}`);
54
+ }
55
+
56
+ static componentError(componentName, action = 'processing', error) {
57
+ console.error(`${chalk.red('✖')} ${action} ${chalk.bold(componentName)}: ${error}`);
58
+ }
59
+
60
+ static downloadProgress(fileName) {
61
+ console.log(`${chalk.gray(' ↓')} ${fileName}`);
62
+ }
63
+
64
+ static downloadError(fileName) {
65
+ console.error(`${chalk.red(' ✖')} ${fileName}`);
66
+ }
67
+
68
+ static registryUpdate(message) {
69
+ console.log(`${chalk.magenta(' +')} ${message}`);
70
+ }
71
+
72
+ static versionInfo(component, currentVersion, latestVersion = null) {
73
+ if (latestVersion && currentVersion !== latestVersion) {
74
+ console.log(`${chalk.yellow('↑')} ${component}: v${currentVersion} → v${latestVersion}`);
75
+ } else {
76
+ console.log(`${chalk.green('✔')} ${component}: v${currentVersion}`);
77
+ }
78
+ }
79
+
80
+ static commandExample(description, command) {
81
+ console.log(chalk.gray(` ${description}`));
82
+ console.log(chalk.cyan(` → ${command}`));
83
+ }
84
+
85
+ static summary(successful, failed, total) {
86
+ Print.separator();
87
+ console.log(chalk.bold('Summary'));
88
+ if (successful > 0) Print.success(`Successful: ${successful}/${total}`);
89
+ if (failed > 0) Print.error(`Failed: ${failed}/${total}`);
90
+ Print.separator();
91
+ }
92
+
93
+ static minificationResult(filename, originalSize, minifiedSize, savingsPercent) {
94
+ const originalKB = (originalSize / 1024).toFixed(1);
95
+ const minifiedKB = (minifiedSize / 1024).toFixed(1);
96
+ console.log(`${chalk.green(' ✔')} ${filename}`);
97
+ console.log(chalk.gray(` ${originalKB} KB → ${minifiedKB} KB (${savingsPercent}% saved)`));
98
+ }
99
+
100
+ static buildProgress(message) {
101
+ console.log(`${chalk.cyan('→')} ${message}`);
102
+ }
103
+
104
+ static serverStats(mode, port, directory) {
105
+ Print.newLine();
106
+ console.log(chalk.bold('Server'));
107
+ console.log(`${chalk.gray(' Mode ')} ${mode}`);
108
+ console.log(`${chalk.gray(' Port ')} ${port}`);
109
+ console.log(`${chalk.gray(' Serving ')} /${directory}`);
110
+ Print.newLine();
111
+ }
112
+
113
+ static serverReady(port) {
114
+ Print.newLine();
115
+ console.log(chalk.bgGreen.black.bold(' READY '));
116
+ Print.newLine();
117
+ console.log(`${chalk.bold(' Local ')} ${chalk.cyan(`http://localhost:${port}`)}`);
118
+ console.log(`${chalk.gray(' Loopback ')} http://127.0.0.1:${port}`);
119
+ Print.newLine();
120
+ console.log(chalk.gray(' Press Ctrl+C to stop'));
121
+ Print.newLine();
122
+ }
123
+
124
+ static serverStatus(status, message = '') {
125
+ const icons = {
126
+ checking: '…',
127
+ starting: '→',
128
+ ready: '✔',
129
+ error: '✖'
130
+ };
131
+ const colors = {
132
+ checking: chalk.gray,
133
+ starting: chalk.cyan,
134
+ ready: chalk.green,
135
+ error: chalk.red
136
+ };
137
+ const icon = icons[status] || '•';
138
+ const color = colors[status] || chalk.white;
139
+ console.log(color(`${icon} ${message || status}`));
140
+ }
141
+
142
+ static checkingPort(port) {
143
+ console.log(chalk.gray(`… Checking port ${port}`));
144
+ }
145
+
146
+ static debug(message) {
147
+ console.log(chalk.gray(` debug ${message}`));
148
+ }
149
+
150
+ static stack(error) {
151
+ if (!process.env.SLICE_DEBUG) return;
152
+ console.error(chalk.gray(error?.stack || error));
153
+ }
154
+
155
+ static verbose(message) {
156
+ console.log(chalk.gray(` ${message}`));
157
+ }
158
+ }
@@ -1,13 +1,17 @@
1
+ import fs from 'fs-extra';
2
+ import path from 'path';
1
3
  import bundle from '../bundle/bundle.js';
2
4
  import buildProduction, { serveProductionBuild } from '../buildProduction/buildProduction.js';
3
5
  import { validateProject, validateServerEntry, classifyValidation, describeIssue } from '../utils/ProjectValidation.js';
4
6
  import { getProjectRoot, getDistPath } from '../utils/PathHelper.js';
5
7
  import { precompressDirectory } from '../utils/compressAssets.js';
8
+ import { checkDocs } from '../docs/index.js';
6
9
  import Print from '../Print.js';
7
10
 
8
11
  export default async function build(options = {}) {
9
12
  const minify = options.minify !== false;
10
13
  const obfuscate = options.obfuscate !== false;
14
+ const buildStart = Date.now();
11
15
 
12
16
  if (options.analyze) {
13
17
  return bundle({ analyze: true, verbose: options.verbose });
@@ -58,6 +62,21 @@ export default async function build(options = {}) {
58
62
  Print.warning(describeIssue(issue));
59
63
  }
60
64
 
65
+ // Projects created with the documentation scaffold must keep their generated
66
+ // docs current. Older projects without AGENTS.md/docs/events are untouched.
67
+ const projectRoot = getProjectRoot(import.meta.url);
68
+ if (
69
+ await fs.pathExists(path.join(projectRoot, 'AGENTS.md')) &&
70
+ await fs.pathExists(path.join(projectRoot, 'docs', 'events', 'index.md'))
71
+ ) {
72
+ const docs = await checkDocs({ projectRoot, target: 'all' });
73
+ if (!docs.ok) {
74
+ Print.error('Build blocked: generated documentation is out of date.');
75
+ Print.info('Run "slice docs generate" and commit the result.');
76
+ process.exit(1);
77
+ }
78
+ }
79
+
61
80
  const success = await buildProduction({
62
81
  ...options,
63
82
  minify,
@@ -67,7 +86,6 @@ export default async function build(options = {}) {
67
86
  return false;
68
87
  }
69
88
 
70
- Print.info('Generating bundles for production build...');
71
89
  await bundle({
72
90
  verbose: options.verbose,
73
91
  minify,
@@ -89,8 +107,16 @@ export default async function build(options = {}) {
89
107
  }
90
108
  }
91
109
 
110
+ const elapsed = ((Date.now() - buildStart) / 1000).toFixed(1);
111
+ Print.newLine();
112
+ Print.success(`Build completed in ${elapsed}s`);
113
+
92
114
  if (options.preview) {
93
115
  await serveProductionBuild(options.port);
116
+ } else {
117
+ Print.newLine();
118
+ Print.subtitle('Next steps');
119
+ Print.commandExample('Serve the production build', 'slice start');
94
120
  }
95
121
 
96
122
  return true;