slicejs-cli 4.5.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.
- package/client.js +162 -83
- package/commands/Print.js +158 -164
- package/commands/build/build.js +27 -1
- package/commands/buildProduction/buildProduction.js +42 -71
- package/commands/bundle/bundle.js +65 -60
- package/commands/docs/agents.js +260 -0
- package/commands/docs/events.js +365 -0
- package/commands/docs/index.js +123 -0
- package/commands/doctor/doctor.js +43 -9
- package/commands/export/checkExport.js +163 -0
- package/commands/export/clientRedirects.js +72 -0
- package/commands/export/copyDist.js +180 -0
- package/commands/export/export.js +236 -0
- package/commands/export/files.js +33 -0
- package/commands/export/hosts/cloudflare.js +48 -0
- package/commands/export/hosts/github.js +31 -0
- package/commands/export/hosts/index.js +69 -0
- package/commands/export/hosts/netlify.js +42 -0
- package/commands/export/hosts/nginx.js +73 -0
- package/commands/export/hosts/none.js +23 -0
- package/commands/export/hosts/s3.js +24 -0
- package/commands/export/hosts/shared.js +62 -0
- package/commands/export/hosts/vercel.js +69 -0
- package/commands/export/outDir.js +91 -0
- package/commands/export/prerender.js +121 -0
- package/commands/getComponent/getComponent.js +39 -34
- package/commands/init/init.js +32 -22
- package/commands/lint/lint.js +2 -2
- package/commands/lint/types.js +1 -1
- package/commands/listComponents/listComponents.js +205 -172
- package/commands/seo/check.js +1 -1
- package/commands/seo/images.js +1 -1
- package/commands/seo/sitemap.js +1 -1
- package/commands/setup/lint.js +1 -1
- package/commands/skill/skill.js +2 -2
- package/commands/startServer/startServer.js +60 -21
- package/commands/startServer/watchServer.js +3 -3
- package/commands/translator/check.js +1 -1
- package/commands/translator/init.js +1 -1
- package/commands/typecheck/typecheck.js +2 -2
- package/commands/types/types.js +22 -3
- package/commands/utils/VersionChecker.js +14 -14
- package/commands/utils/bundling/BundleGenerator.js +45 -27
- package/commands/utils/bundling/DependencyAnalyzer.js +38 -17
- package/commands/utils/componentCatalog.js +120 -0
- package/commands/utils/publicEnv.js +74 -0
- package/commands/utils/updateManager.js +12 -12
- package/package.json +22 -23
package/commands/Print.js
CHANGED
|
@@ -1,164 +1,158 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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
|
+
}
|
package/commands/build/build.js
CHANGED
|
@@ -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;
|