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
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// slice typecheck — run the project's TypeScript over the JS, using the jsconfig
|
|
2
|
+
// that `slice types generate` maintains (`allowJs` + `checkJs`).
|
|
3
|
+
//
|
|
4
|
+
// ESLint does not type-check (no tsconfig, no type information). This is the
|
|
5
|
+
// compiler step: it compares the code against the generated prop and event
|
|
6
|
+
// declarations. TypeScript is the project's devDependency, like ESLint.
|
|
7
|
+
|
|
8
|
+
import fs from 'node:fs';
|
|
9
|
+
import path from 'node:path';
|
|
10
|
+
import { spawnSync } from 'node:child_process';
|
|
11
|
+
import { createRequire } from 'node:module';
|
|
12
|
+
import Print from '../Print.js';
|
|
13
|
+
import { runTypeRefresh } from '../lint/lint.js';
|
|
14
|
+
import { reportTypesRefresh } from '../lint/types.js';
|
|
15
|
+
|
|
16
|
+
/** The project's own tsc, or null when TypeScript is not installed. */
|
|
17
|
+
export function resolveTypeScript(projectRoot) {
|
|
18
|
+
try {
|
|
19
|
+
const require = createRequire(path.join(projectRoot, 'package.json'));
|
|
20
|
+
const pkgPath = require.resolve('typescript/package.json');
|
|
21
|
+
return path.join(path.dirname(pkgPath), 'bin', 'tsc');
|
|
22
|
+
} catch {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** The config to type-check with: explicit, jsconfig.json, or tsconfig.json. */
|
|
28
|
+
export function resolveProjectConfig(projectRoot, explicit = null) {
|
|
29
|
+
const candidates = explicit ? [explicit] : ['jsconfig.json', 'tsconfig.json'];
|
|
30
|
+
for (const candidate of candidates) {
|
|
31
|
+
const file = path.isAbsolute(candidate) ? candidate : path.join(projectRoot, candidate);
|
|
32
|
+
if (fs.existsSync(file)) return file;
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default async function typecheckCommand(options = {}, projectRoot) {
|
|
38
|
+
// Check the declarations that exist now, not the ones from before the last
|
|
39
|
+
// `slice get`: the registry changed, so the .d.ts has to follow.
|
|
40
|
+
if (options.types !== false) {
|
|
41
|
+
try {
|
|
42
|
+
const types = await runTypeRefresh(projectRoot, options);
|
|
43
|
+
if (types) reportTypesRefresh(types, projectRoot);
|
|
44
|
+
} catch (error) {
|
|
45
|
+
Print.warning('Could not refresh the generated types:', error.message);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const tsc = resolveTypeScript(projectRoot);
|
|
50
|
+
if (!tsc) {
|
|
51
|
+
Print.error('TypeScript is not installed in this project.');
|
|
52
|
+
Print.info('Install it: npm i -D typescript (or "pnpm add -D typescript")');
|
|
53
|
+
process.exitCode = 1;
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const config = resolveProjectConfig(projectRoot, options.project);
|
|
58
|
+
if (!config) {
|
|
59
|
+
Print.error('No jsconfig.json or tsconfig.json here: nothing to type-check with.');
|
|
60
|
+
Print.info('Run "slice types generate" to create the jsconfig that includes the generated declarations.');
|
|
61
|
+
process.exitCode = 1;
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const result = spawnSync(process.execPath, [tsc, '--noEmit', '-p', config], {
|
|
66
|
+
cwd: projectRoot,
|
|
67
|
+
stdio: 'inherit',
|
|
68
|
+
env: process.env
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
if (result.error) {
|
|
72
|
+
Print.error('Could not run tsc:', result.error.message);
|
|
73
|
+
process.exitCode = 1;
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (result.status !== 0) {
|
|
78
|
+
process.exitCode = result.status || 1;
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return true;
|
|
83
|
+
}
|