slicejs-cli 4.2.0 → 4.4.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/LICENSE +21 -21
- package/README.md +260 -257
- package/client.js +927 -780
- package/commands/Print.js +163 -163
- package/commands/Validations.js +92 -92
- package/commands/build/build.js +97 -107
- package/commands/buildProduction/buildProduction.js +613 -613
- package/commands/bundle/bundle.js +251 -239
- package/commands/createComponent/VisualComponentTemplate.js +55 -55
- package/commands/createComponent/createComponent.js +128 -128
- package/commands/deleteComponent/deleteComponent.js +81 -81
- package/commands/docs/docs.js +365 -0
- package/commands/doctor/doctor.js +677 -563
- package/commands/getComponent/getComponent.js +842 -842
- package/commands/init/init.js +526 -475
- package/commands/lint/lint.js +75 -0
- package/commands/lint/types.js +85 -0
- package/commands/listComponents/listComponents.js +172 -172
- package/commands/seo/check.js +91 -0
- package/commands/seo/images.js +586 -0
- package/commands/seo/sitemap.js +106 -0
- package/commands/seo/support.js +130 -0
- package/commands/setup/lint.js +151 -0
- package/commands/skill/skill.js +236 -236
- package/commands/startServer/startServer.js +240 -240
- package/commands/startServer/watchServer.js +66 -66
- package/commands/typecheck/typecheck.js +83 -0
- package/commands/types/types.js +1378 -1097
- package/commands/utils/JsMinifier.js +230 -230
- package/commands/utils/LocalCliDelegation.js +78 -53
- package/commands/utils/PackageManager.js +148 -148
- package/commands/utils/PathHelper.js +87 -75
- package/commands/utils/ProjectValidation.js +274 -0
- package/commands/utils/SourceDiagnostics.js +201 -201
- package/commands/utils/VersionChecker.js +169 -169
- package/commands/utils/analyzeSource.js +77 -77
- package/commands/utils/bundling/BundleGenerator.js +3748 -3776
- package/commands/utils/bundling/DependencyAnalyzer.js +976 -976
- package/commands/utils/bundling/ExternalModuleBundler.js +298 -298
- package/commands/utils/componentAudit.js +74 -0
- package/commands/utils/compressAssets.js +103 -103
- package/commands/utils/cssScope.js +83 -0
- package/commands/utils/loadConfig.js +31 -31
- package/commands/utils/semver.js +66 -0
- package/commands/utils/sliceConfigSchema.js +72 -0
- package/commands/utils/sliceScripts.js +48 -48
- package/commands/utils/updateManager.js +471 -471
- package/eslint-config.js +128 -0
- package/package.json +19 -13
package/commands/build/build.js
CHANGED
|
@@ -1,107 +1,97 @@
|
|
|
1
|
-
import bundle from '../bundle/bundle.js';
|
|
2
|
-
import buildProduction, { serveProductionBuild } from '../buildProduction/buildProduction.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
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
|
-
Print.info(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
minify,
|
|
74
|
-
obfuscate
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
Print.info('No compressible assets found to precompress.');
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
if (options.preview) {
|
|
103
|
-
await serveProductionBuild(options.port);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return true;
|
|
107
|
-
}
|
|
1
|
+
import bundle from '../bundle/bundle.js';
|
|
2
|
+
import buildProduction, { serveProductionBuild } from '../buildProduction/buildProduction.js';
|
|
3
|
+
import { validateProject, validateServerEntry, classifyValidation, describeIssue } from '../utils/ProjectValidation.js';
|
|
4
|
+
import { getProjectRoot, getDistPath } from '../utils/PathHelper.js';
|
|
5
|
+
import { precompressDirectory } from '../utils/compressAssets.js';
|
|
6
|
+
import Print from '../Print.js';
|
|
7
|
+
|
|
8
|
+
export default async function build(options = {}) {
|
|
9
|
+
const minify = options.minify !== false;
|
|
10
|
+
const obfuscate = options.obfuscate !== false;
|
|
11
|
+
|
|
12
|
+
if (options.analyze) {
|
|
13
|
+
return bundle({ analyze: true, verbose: options.verbose });
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (options.serve) {
|
|
17
|
+
await serveProductionBuild(options.port);
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// One static pass: config rules, components and routes. `slice doctor`
|
|
22
|
+
// reports exactly this result, so a green doctor means the build's pre-flight
|
|
23
|
+
// passes. `--no-validate` skips the component findings; config and routes
|
|
24
|
+
// always run, because both produce a broken deployment rather than a style
|
|
25
|
+
// issue.
|
|
26
|
+
const validation = await validateProject({
|
|
27
|
+
projectRoot: getProjectRoot(import.meta.url),
|
|
28
|
+
skipComponents: options.validate === false,
|
|
29
|
+
// CSS scoping is a doctor advisory: it never blocks, and on an existing app
|
|
30
|
+
// it can be dozens of lines that do not belong in a build log.
|
|
31
|
+
includeCss: false
|
|
32
|
+
});
|
|
33
|
+
// The server entry is not part of the bundle, but a deploy with a broken
|
|
34
|
+
// api/index.js is a broken deploy: it joins the same blocking list.
|
|
35
|
+
const server = await validateServerEntry({ projectRoot: getProjectRoot(import.meta.url) });
|
|
36
|
+
const { blocking, advisory } = classifyValidation({ ...validation, ...server });
|
|
37
|
+
|
|
38
|
+
if (validation.configErrors.length > 0) {
|
|
39
|
+
for (const problem of validation.configErrors) {
|
|
40
|
+
Print.error(`sliceConfig: ${problem.path} ${problem.message}`);
|
|
41
|
+
}
|
|
42
|
+
Print.info('Fix sliceConfig.json and run the build again.');
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (blocking.length > 0) {
|
|
47
|
+
Print.error(`Build blocked: ${blocking.length} issue(s) found.`);
|
|
48
|
+
for (const issue of blocking) {
|
|
49
|
+
Print.info(` ${describeIssue(issue)}`);
|
|
50
|
+
}
|
|
51
|
+
Print.newLine();
|
|
52
|
+
Print.info('Fix the entries above. Component files that do not parse, have no default export or import a missing file cannot be bundled; routes.js is served as-is, so a broken import stops the app from navigating.');
|
|
53
|
+
Print.info('Bypass the component checks with "slice build --no-validate" (not recommended).');
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
for (const issue of advisory) {
|
|
58
|
+
Print.warning(describeIssue(issue));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const success = await buildProduction({
|
|
62
|
+
...options,
|
|
63
|
+
minify,
|
|
64
|
+
obfuscate
|
|
65
|
+
});
|
|
66
|
+
if (!success) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
Print.info('Generating bundles for production build...');
|
|
71
|
+
await bundle({
|
|
72
|
+
verbose: options.verbose,
|
|
73
|
+
minify,
|
|
74
|
+
obfuscate,
|
|
75
|
+
output: 'dist',
|
|
76
|
+
strictExternal: options.strictExternal,
|
|
77
|
+
sourcemap: options.sourcemap,
|
|
78
|
+
hashFilenames: options.hashFilenames
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
if (options.compress) {
|
|
82
|
+
Print.info('Precompressing assets (gzip + brotli)...');
|
|
83
|
+
const stats = await precompressDirectory(getDistPath(import.meta.url));
|
|
84
|
+
if (stats.files > 0) {
|
|
85
|
+
const pct = (n) => `${Math.round((1 - n / stats.originalBytes) * 100)}%`;
|
|
86
|
+
Print.info(`Precompressed ${stats.files} file(s): ${(stats.originalBytes / 1024).toFixed(0)} KB → gzip ${(stats.gzipBytes / 1024).toFixed(0)} KB (${pct(stats.gzipBytes)}), brotli ${(stats.brotliBytes / 1024).toFixed(0)} KB (${pct(stats.brotliBytes)})`);
|
|
87
|
+
} else {
|
|
88
|
+
Print.info('No compressible assets found to precompress.');
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (options.preview) {
|
|
93
|
+
await serveProductionBuild(options.port);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return true;
|
|
97
|
+
}
|