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/client.js
CHANGED
|
@@ -24,12 +24,27 @@ import { loadConfigSync as sharedLoadConfigSync } from "./commands/utils/loadCon
|
|
|
24
24
|
import { spawnSync } from "node:child_process";
|
|
25
25
|
import validations from "./commands/Validations.js";
|
|
26
26
|
import Print from "./commands/Print.js";
|
|
27
|
-
import build from './commands/build/build.js';
|
|
28
|
-
import
|
|
29
|
-
import
|
|
27
|
+
import build from './commands/build/build.js';
|
|
28
|
+
import exportStatic from './commands/export/export.js';
|
|
29
|
+
import lintCommand from './commands/lint/lint.js';
|
|
30
|
+
import typecheckCommand from './commands/typecheck/typecheck.js';
|
|
30
31
|
import setupLintCommand from './commands/setup/lint.js';
|
|
31
32
|
import { runGenerateTypes } from './commands/types/types.js';
|
|
32
33
|
import { runDocsGet, runDocsList, runDocsSearch } from './commands/docs/docs.js';
|
|
34
|
+
import { checkDocs, generateDocs, hasDocumentationScaffold } from './commands/docs/index.js';
|
|
35
|
+
|
|
36
|
+
async function syncAgentDocs() {
|
|
37
|
+
const projectRoot = getProjectRoot(import.meta.url);
|
|
38
|
+
if (!(await hasDocumentationScaffold(projectRoot))) return;
|
|
39
|
+
try {
|
|
40
|
+
await generateDocs({
|
|
41
|
+
projectRoot,
|
|
42
|
+
target: 'agents',
|
|
43
|
+
});
|
|
44
|
+
} catch (error) {
|
|
45
|
+
Print.warning(`Could not update AGENTS.md: ${error.message}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
33
48
|
import { cleanBundles, bundleInfo } from './commands/bundle/bundle.js';
|
|
34
49
|
import {
|
|
35
50
|
isLocalDelegationDisabled,
|
|
@@ -69,7 +84,6 @@ function parsePort(value) {
|
|
|
69
84
|
async function withNodeEnv(env, fn) {
|
|
70
85
|
const prevEnv = process.env.NODE_ENV;
|
|
71
86
|
process.env.NODE_ENV = env;
|
|
72
|
-
listComponents();
|
|
73
87
|
try {
|
|
74
88
|
return await fn();
|
|
75
89
|
} finally {
|
|
@@ -101,7 +115,7 @@ async function runWithVersionCheck(commandFunction, ...args) {
|
|
|
101
115
|
return result;
|
|
102
116
|
} catch (error) {
|
|
103
117
|
Print.error(`Command execution: ${error.message}`);
|
|
104
|
-
|
|
118
|
+
Print.stack(error);
|
|
105
119
|
// A command that threw must not report success. This used to swallow the
|
|
106
120
|
// error and return normally, so `slice build` printed a red failure and
|
|
107
121
|
// still exited 0 — CI read that as a passing build and shipped it.
|
|
@@ -153,15 +167,15 @@ try {
|
|
|
153
167
|
const pkgPath = path.join(__dirname, "./package.json");
|
|
154
168
|
const pkgRaw = fs.readFileSync(pkgPath, "utf-8");
|
|
155
169
|
const pkg = JSON.parse(pkgRaw);
|
|
156
|
-
sliceClient.version(pkg.version).description("
|
|
170
|
+
sliceClient.name("slice").version(pkg.version).description("Build, run and maintain Slice.js projects");
|
|
157
171
|
} catch {
|
|
158
|
-
sliceClient.version("0.0.0").description("
|
|
172
|
+
sliceClient.name("slice").version("0.0.0").description("Build, run and maintain Slice.js projects");
|
|
159
173
|
}
|
|
160
174
|
|
|
161
175
|
// INIT COMMAND
|
|
162
176
|
sliceClient
|
|
163
177
|
.command("init")
|
|
164
|
-
.description("
|
|
178
|
+
.description("Create a new Slice.js project")
|
|
165
179
|
.argument("[name]", "Project name (defaults to my-slice-app)")
|
|
166
180
|
.option("-y, --yes", "Skip prompts")
|
|
167
181
|
.option("--pm <packageManager>", "Package manager to use (pnpm or npm). Auto-detected when omitted")
|
|
@@ -277,7 +291,7 @@ sliceClient
|
|
|
277
291
|
|
|
278
292
|
// BUILD COMMAND
|
|
279
293
|
const buildCommand = sliceClient.command("build")
|
|
280
|
-
.description("Build
|
|
294
|
+
.description("Build for production")
|
|
281
295
|
.action(async (options) => {
|
|
282
296
|
await withNodeEnv('production', () => runWithVersionCheck(async () => {
|
|
283
297
|
// build() reports failure by returning false (degraded files, missing
|
|
@@ -321,10 +335,38 @@ buildCommand
|
|
|
321
335
|
.option("--compress", "Precompress dist assets to .gz and .br (brotli) for static serving")
|
|
322
336
|
.option("--skip-clean", "Skip cleaning dist before build");
|
|
323
337
|
|
|
338
|
+
// EXPORT COMMAND - STATIC HOST PACKAGE (experimental)
|
|
339
|
+
sliceClient
|
|
340
|
+
.command("export")
|
|
341
|
+
.description("Package the production build for a static host (experimental)")
|
|
342
|
+
.option("-o, --out <dir>", "Output directory", "dist-static")
|
|
343
|
+
.option("--from-dist", "Reuse dist/ instead of running a build")
|
|
344
|
+
.option("--host <name>", "Host rules: cloudflare, netlify, vercel, nginx, github, s3, none (default: cloudflare)")
|
|
345
|
+
.option("--seo <file>", "SEO manifest (auto-detected: seo.json / public/seo.json)")
|
|
346
|
+
.option("--origin <url>", "Canonical origin override for prerendered pages")
|
|
347
|
+
.option("--images <file>", "Social card manifest (auto-detected: public/og/manifest.json)")
|
|
348
|
+
.option("--no-prerender", "Only the SPA shell and host rules")
|
|
349
|
+
.option("--spa", "Serve unknown routes with index.html (SPA fallback)")
|
|
350
|
+
.option("--keep-components", "Keep /Components in the export (component source is fetchable)")
|
|
351
|
+
.option("--check", "Validate an existing export without writing")
|
|
352
|
+
.option("--dry-run", "Report what would be written without writing")
|
|
353
|
+
.option("--sourcemap", "Emit source maps (not recommended for a public export)")
|
|
354
|
+
.option("--hash-filenames", "Add a content hash to bundle filenames")
|
|
355
|
+
.option("--compress", "Precompress dist assets (delegated to build)")
|
|
356
|
+
.option("--no-minify", "Disable minification (enabled by default)")
|
|
357
|
+
.option("--no-obfuscate", "Disable obfuscation (enabled by default)")
|
|
358
|
+
.action(async (options) => {
|
|
359
|
+
await withNodeEnv('production', () => runWithVersionCheck(async () => {
|
|
360
|
+
const ok = await exportStatic(options);
|
|
361
|
+
if (ok === false) process.exitCode = 1;
|
|
362
|
+
return ok;
|
|
363
|
+
}));
|
|
364
|
+
});
|
|
365
|
+
|
|
324
366
|
// DEV COMMAND (DEVELOPMENT)
|
|
325
367
|
sliceClient
|
|
326
368
|
.command("dev")
|
|
327
|
-
.description("Start development server
|
|
369
|
+
.description("Start the development server")
|
|
328
370
|
.option("-p, --port <port>", "Port for development server")
|
|
329
371
|
.option("--no-hmr", "Disable hot module reload (enabled by default)")
|
|
330
372
|
.action(async (options) => {
|
|
@@ -340,7 +382,7 @@ sliceClient
|
|
|
340
382
|
// START COMMAND - PRODUCTION MODE
|
|
341
383
|
sliceClient
|
|
342
384
|
.command("start")
|
|
343
|
-
.description("Serve production
|
|
385
|
+
.description("Serve the production build")
|
|
344
386
|
.option("-p, --port <port>", "Port for server")
|
|
345
387
|
.action(async (options) => {
|
|
346
388
|
await withNodeEnv('production', () => runWithVersionCheck(async () => {
|
|
@@ -352,13 +394,13 @@ sliceClient
|
|
|
352
394
|
});
|
|
353
395
|
|
|
354
396
|
// COMPONENT COMMAND GROUP - For local component management
|
|
355
|
-
const componentCommand = sliceClient.command("component").alias("comp").description("Manage
|
|
397
|
+
const componentCommand = sliceClient.command("component").alias("comp").description("Manage project components");
|
|
356
398
|
|
|
357
399
|
// CREATE LOCAL COMPONENT
|
|
358
400
|
componentCommand
|
|
359
401
|
.command("create [name]")
|
|
360
402
|
.alias("new")
|
|
361
|
-
.description("Create a
|
|
403
|
+
.description("Create a component")
|
|
362
404
|
.option("-c, --category <category>", "Component category (e.g. Visual, Service, AppComponents). Skips the prompt when provided.")
|
|
363
405
|
.action(async (name, options) => {
|
|
364
406
|
await runWithVersionCheck(async () => {
|
|
@@ -410,8 +452,8 @@ componentCommand
|
|
|
410
452
|
const result = createComponent(componentName, category);
|
|
411
453
|
if (result) {
|
|
412
454
|
Print.success(`Component '${componentName}' created successfully in category '${category}'`);
|
|
413
|
-
|
|
414
|
-
|
|
455
|
+
listComponents({ category });
|
|
456
|
+
await syncAgentDocs();
|
|
415
457
|
}
|
|
416
458
|
});
|
|
417
459
|
});
|
|
@@ -420,10 +462,13 @@ componentCommand
|
|
|
420
462
|
componentCommand
|
|
421
463
|
.command("list")
|
|
422
464
|
.alias("ls")
|
|
423
|
-
.description("List
|
|
424
|
-
.
|
|
465
|
+
.description("List local components")
|
|
466
|
+
.option("-a, --all", "List every component, not just a category summary")
|
|
467
|
+
.option("-c, --category <category>", "Only one category")
|
|
468
|
+
.option("--json", "Print machine-readable JSON")
|
|
469
|
+
.action(async (options) => {
|
|
425
470
|
await runWithVersionCheck(() => {
|
|
426
|
-
listComponents();
|
|
471
|
+
listComponents(options);
|
|
427
472
|
return Promise.resolve();
|
|
428
473
|
});
|
|
429
474
|
});
|
|
@@ -432,7 +477,7 @@ componentCommand
|
|
|
432
477
|
componentCommand
|
|
433
478
|
.command("delete [name]")
|
|
434
479
|
.alias("remove")
|
|
435
|
-
.description("Delete a component
|
|
480
|
+
.description("Delete a component")
|
|
436
481
|
.option("-c, --category <category>", "Component category. Skips the category prompt when provided.")
|
|
437
482
|
.option("-y, --yes", "Skip the confirmation prompt (for non-interactive use)")
|
|
438
483
|
.action(async (name, options) => {
|
|
@@ -523,8 +568,8 @@ componentCommand
|
|
|
523
568
|
// deleteComponent validates the name/category and that the component exists.
|
|
524
569
|
if (deleteComponent(componentName, category)) {
|
|
525
570
|
Print.success(`Component ${componentName} deleted successfully`);
|
|
526
|
-
|
|
527
|
-
|
|
571
|
+
listComponents({ category });
|
|
572
|
+
await syncAgentDocs();
|
|
528
573
|
}
|
|
529
574
|
} catch (error) {
|
|
530
575
|
Print.error(`Deleting component: ${error.message}`);
|
|
@@ -533,10 +578,10 @@ componentCommand
|
|
|
533
578
|
});
|
|
534
579
|
|
|
535
580
|
// REGISTRY COMMAND GROUP - For component registry operations
|
|
536
|
-
const registryCommand = sliceClient.command("registry").alias("reg").description("Manage components
|
|
581
|
+
const registryCommand = sliceClient.command("registry").alias("reg").description("Manage registry components");
|
|
537
582
|
|
|
538
583
|
// SKILL COMMAND GROUP - Claude Code skill fetched from the docs repo
|
|
539
|
-
const skillCommand = sliceClient.command("skill").description("Manage the
|
|
584
|
+
const skillCommand = sliceClient.command("skill").description("Manage the developer skill");
|
|
540
585
|
|
|
541
586
|
skillCommand
|
|
542
587
|
.command("add")
|
|
@@ -550,7 +595,7 @@ skillCommand
|
|
|
550
595
|
});
|
|
551
596
|
|
|
552
597
|
// DOCUMENTATION COMMAND GROUP - Framework and Slice.js Components docs
|
|
553
|
-
const docsCommand = sliceClient.command("docs").description("Search and
|
|
598
|
+
const docsCommand = sliceClient.command("docs").description("Search docs and generate project documentation");
|
|
554
599
|
|
|
555
600
|
docsCommand
|
|
556
601
|
.command("list")
|
|
@@ -588,6 +633,33 @@ docsCommand
|
|
|
588
633
|
});
|
|
589
634
|
});
|
|
590
635
|
|
|
636
|
+
docsCommand
|
|
637
|
+
.command("generate [target]")
|
|
638
|
+
.description("Generate project documentation: all, agents, types, or events")
|
|
639
|
+
.option("-o, --output <path>", "Custom types output path", "src/slice-build.generated.d.ts")
|
|
640
|
+
.action(async (target, options) => {
|
|
641
|
+
await runWithVersionCheck(async () => {
|
|
642
|
+
await generateDocs({
|
|
643
|
+
projectRoot: getProjectRoot(import.meta.url),
|
|
644
|
+
target: target || 'all',
|
|
645
|
+
outputPath: options.output,
|
|
646
|
+
});
|
|
647
|
+
});
|
|
648
|
+
});
|
|
649
|
+
|
|
650
|
+
docsCommand
|
|
651
|
+
.command("check [target]")
|
|
652
|
+
.description("Check generated project documentation for drift: all, agents, types, or events")
|
|
653
|
+
.action(async (target) => {
|
|
654
|
+
await runWithVersionCheck(async () => {
|
|
655
|
+
const result = await checkDocs({
|
|
656
|
+
projectRoot: getProjectRoot(import.meta.url),
|
|
657
|
+
target: target || 'all',
|
|
658
|
+
});
|
|
659
|
+
if (!result.ok) process.exitCode = 1;
|
|
660
|
+
});
|
|
661
|
+
});
|
|
662
|
+
|
|
591
663
|
skillCommand
|
|
592
664
|
.command("update")
|
|
593
665
|
.description("Update the installed skill to the latest compatible version")
|
|
@@ -607,7 +679,7 @@ skillCommand
|
|
|
607
679
|
});
|
|
608
680
|
|
|
609
681
|
// TYPES COMMAND GROUP - TypeScript declarations from static props
|
|
610
|
-
const typesCommand = sliceClient.command("types").description("Generate TypeScript declarations
|
|
682
|
+
const typesCommand = sliceClient.command("types").description("Generate TypeScript declarations");
|
|
611
683
|
|
|
612
684
|
typesCommand
|
|
613
685
|
.command("generate")
|
|
@@ -630,7 +702,7 @@ typesCommand
|
|
|
630
702
|
// GET COMPONENTS FROM REGISTRY
|
|
631
703
|
registryCommand
|
|
632
704
|
.command("get [components...]")
|
|
633
|
-
.description("
|
|
705
|
+
.description("Install components from the registry")
|
|
634
706
|
.option("-f, --force", "Force overwrite existing components")
|
|
635
707
|
.option("-s, --service", "Install Service components instead of Visual")
|
|
636
708
|
.option("--no-deps", "Do not resolve and install component dependencies")
|
|
@@ -641,6 +713,7 @@ registryCommand
|
|
|
641
713
|
service: options.service,
|
|
642
714
|
deps: options.deps
|
|
643
715
|
});
|
|
716
|
+
await syncAgentDocs();
|
|
644
717
|
});
|
|
645
718
|
});
|
|
646
719
|
|
|
@@ -648,7 +721,7 @@ registryCommand
|
|
|
648
721
|
registryCommand
|
|
649
722
|
.command("list")
|
|
650
723
|
.alias("ls")
|
|
651
|
-
.description("List
|
|
724
|
+
.description("List registry components")
|
|
652
725
|
.action(async () => {
|
|
653
726
|
await runWithVersionCheck(async () => {
|
|
654
727
|
await listRemoteComponents();
|
|
@@ -658,20 +731,21 @@ registryCommand
|
|
|
658
731
|
// SYNC COMPONENTS FROM REGISTRY
|
|
659
732
|
registryCommand
|
|
660
733
|
.command("sync")
|
|
661
|
-
.description("Update
|
|
734
|
+
.description("Update installed components")
|
|
662
735
|
.option("-f, --force", "Force update without confirmation")
|
|
663
736
|
.action(async (options) => {
|
|
664
737
|
await runWithVersionCheck(async () => {
|
|
665
738
|
await syncComponents({
|
|
666
739
|
force: options.force
|
|
667
740
|
});
|
|
741
|
+
await syncAgentDocs();
|
|
668
742
|
});
|
|
669
743
|
});
|
|
670
744
|
|
|
671
745
|
// SHORTCUTS - Top-level convenient commands
|
|
672
746
|
sliceClient
|
|
673
747
|
.command("get [components...]")
|
|
674
|
-
.description("
|
|
748
|
+
.description("Install components from the registry")
|
|
675
749
|
.option("-f, --force", "Force overwrite existing components")
|
|
676
750
|
.option("-s, --service", "Install Service components instead of Visual")
|
|
677
751
|
.option("--no-deps", "Do not resolve and install component dependencies")
|
|
@@ -690,12 +764,13 @@ sliceClient
|
|
|
690
764
|
service: options.service,
|
|
691
765
|
deps: options.deps
|
|
692
766
|
});
|
|
767
|
+
await syncAgentDocs();
|
|
693
768
|
});
|
|
694
769
|
});
|
|
695
770
|
|
|
696
771
|
sliceClient
|
|
697
772
|
.command("browse")
|
|
698
|
-
.description("
|
|
773
|
+
.description("Browse registry components")
|
|
699
774
|
.action(async () => {
|
|
700
775
|
await runWithVersionCheck(async () => {
|
|
701
776
|
await listRemoteComponents();
|
|
@@ -704,23 +779,27 @@ sliceClient
|
|
|
704
779
|
|
|
705
780
|
sliceClient
|
|
706
781
|
.command("sync")
|
|
707
|
-
.description("
|
|
782
|
+
.description("Update installed components")
|
|
708
783
|
.option("-f, --force", "Force update without confirmation")
|
|
709
784
|
.action(async (options) => {
|
|
710
785
|
await runWithVersionCheck(async () => {
|
|
711
786
|
await syncComponents({
|
|
712
787
|
force: options.force
|
|
713
788
|
});
|
|
789
|
+
await syncAgentDocs();
|
|
714
790
|
});
|
|
715
791
|
});
|
|
716
792
|
|
|
717
793
|
// LIST COMMAND - Quick shortcut for listing local components
|
|
718
794
|
sliceClient
|
|
719
795
|
.command("list")
|
|
720
|
-
.description("
|
|
721
|
-
.
|
|
796
|
+
.description("List local components")
|
|
797
|
+
.option("-a, --all", "List every component, not just a category summary")
|
|
798
|
+
.option("-c, --category <category>", "Only one category")
|
|
799
|
+
.option("--json", "Print machine-readable JSON")
|
|
800
|
+
.action(async (options) => {
|
|
722
801
|
await runWithVersionCheck(() => {
|
|
723
|
-
listComponents();
|
|
802
|
+
listComponents(options);
|
|
724
803
|
return Promise.resolve();
|
|
725
804
|
});
|
|
726
805
|
});
|
|
@@ -729,59 +808,59 @@ sliceClient
|
|
|
729
808
|
sliceClient
|
|
730
809
|
.command("doctor")
|
|
731
810
|
.alias("diagnose")
|
|
732
|
-
.description("
|
|
811
|
+
.description("Check project health")
|
|
733
812
|
.action(async () => {
|
|
734
813
|
await runWithVersionCheck(async () => {
|
|
735
814
|
await runDiagnostics();
|
|
736
815
|
});
|
|
737
816
|
});
|
|
738
817
|
|
|
739
|
-
// LINT COMMAND - runs the project's ESLint, with the shared config available
|
|
740
|
-
// as `slicejs-cli/eslint-config.js`. The CLI does not bundle ESLint itself.
|
|
741
|
-
sliceClient
|
|
742
|
-
.command("lint [paths...]")
|
|
743
|
-
.description("Run ESLint in this project")
|
|
744
|
-
.option("--fix", "Apply automatic fixes")
|
|
745
|
-
.option("--no-types", "Do not refresh the generated declarations")
|
|
746
|
-
.action(async (paths, options) => {
|
|
747
|
-
await runWithVersionCheck(async () => {
|
|
748
|
-
await lintCommand({ paths, fix: options.fix, types: options.types }, getProjectRoot(import.meta.url));
|
|
749
|
-
});
|
|
750
|
-
});
|
|
751
|
-
|
|
752
|
-
const setupCommand = sliceClient
|
|
753
|
-
.command("setup")
|
|
754
|
-
.description("Add optional tooling to an existing project");
|
|
755
|
-
|
|
756
|
-
setupCommand
|
|
757
|
-
.command("lint")
|
|
758
|
-
.description("Install ESLint and add the shared Slice config")
|
|
759
|
-
.option("--dry-run", "Show what would change, write nothing")
|
|
760
|
-
.option("--with-types", "Also install TypeScript and add a typecheck script")
|
|
761
|
-
.action(async (options) => {
|
|
762
|
-
await runWithVersionCheck(async () => {
|
|
763
|
-
await setupLintCommand(options, getProjectRoot(import.meta.url));
|
|
764
|
-
});
|
|
765
|
-
});
|
|
766
|
-
|
|
767
|
-
// TYPECHECK COMMAND - the compiler step. ESLint does not type-check; this runs
|
|
768
|
-
// the project tsc over the jsconfig that `slice types generate` maintains.
|
|
769
|
-
sliceClient
|
|
770
|
-
.command("typecheck")
|
|
771
|
-
.description("Type-check the project with its own TypeScript (jsconfig.json)")
|
|
772
|
-
.option("-p, --project <path>", "Config file (default: jsconfig.json, then tsconfig.json)")
|
|
773
|
-
.option("--no-types", "Do not refresh the generated declarations")
|
|
774
|
-
.action(async (options) => {
|
|
775
|
-
await runWithVersionCheck(async () => {
|
|
776
|
-
await typecheckCommand(options, getProjectRoot(import.meta.url));
|
|
777
|
-
});
|
|
778
|
-
});
|
|
779
|
-
|
|
818
|
+
// LINT COMMAND - runs the project's ESLint, with the shared config available
|
|
819
|
+
// as `slicejs-cli/eslint-config.js`. The CLI does not bundle ESLint itself.
|
|
820
|
+
sliceClient
|
|
821
|
+
.command("lint [paths...]")
|
|
822
|
+
.description("Run ESLint in this project")
|
|
823
|
+
.option("--fix", "Apply automatic fixes")
|
|
824
|
+
.option("--no-types", "Do not refresh the generated declarations")
|
|
825
|
+
.action(async (paths, options) => {
|
|
826
|
+
await runWithVersionCheck(async () => {
|
|
827
|
+
await lintCommand({ paths, fix: options.fix, types: options.types }, getProjectRoot(import.meta.url));
|
|
828
|
+
});
|
|
829
|
+
});
|
|
830
|
+
|
|
831
|
+
const setupCommand = sliceClient
|
|
832
|
+
.command("setup")
|
|
833
|
+
.description("Add optional tooling to an existing project");
|
|
834
|
+
|
|
835
|
+
setupCommand
|
|
836
|
+
.command("lint")
|
|
837
|
+
.description("Install ESLint and add the shared Slice config")
|
|
838
|
+
.option("--dry-run", "Show what would change, write nothing")
|
|
839
|
+
.option("--with-types", "Also install TypeScript and add a typecheck script")
|
|
840
|
+
.action(async (options) => {
|
|
841
|
+
await runWithVersionCheck(async () => {
|
|
842
|
+
await setupLintCommand(options, getProjectRoot(import.meta.url));
|
|
843
|
+
});
|
|
844
|
+
});
|
|
845
|
+
|
|
846
|
+
// TYPECHECK COMMAND - the compiler step. ESLint does not type-check; this runs
|
|
847
|
+
// the project tsc over the jsconfig that `slice types generate` maintains.
|
|
848
|
+
sliceClient
|
|
849
|
+
.command("typecheck")
|
|
850
|
+
.description("Type-check the project with its own TypeScript (jsconfig.json)")
|
|
851
|
+
.option("-p, --project <path>", "Config file (default: jsconfig.json, then tsconfig.json)")
|
|
852
|
+
.option("--no-types", "Do not refresh the generated declarations")
|
|
853
|
+
.action(async (options) => {
|
|
854
|
+
await runWithVersionCheck(async () => {
|
|
855
|
+
await typecheckCommand(options, getProjectRoot(import.meta.url));
|
|
856
|
+
});
|
|
857
|
+
});
|
|
858
|
+
|
|
780
859
|
// SEO COMMANDS — the artifacts are committed, so they are written on demand and
|
|
781
860
|
// guarded in CI rather than generated at request time.
|
|
782
861
|
const seoCommand = sliceClient
|
|
783
862
|
.command("seo")
|
|
784
|
-
.description("SEO helpers
|
|
863
|
+
.description("SEO helpers");
|
|
785
864
|
|
|
786
865
|
seoCommand
|
|
787
866
|
.command("sitemap")
|
|
@@ -825,7 +904,7 @@ seoCommand
|
|
|
825
904
|
const translatorCommand = sliceClient
|
|
826
905
|
.command("translator")
|
|
827
906
|
.alias("i18n")
|
|
828
|
-
.description("Translator helpers
|
|
907
|
+
.description("Translator helpers");
|
|
829
908
|
|
|
830
909
|
translatorCommand
|
|
831
910
|
.command("init")
|
|
@@ -853,14 +932,14 @@ translatorCommand
|
|
|
853
932
|
// POSTINSTALL COMMAND - Configure npm scripts in existing project
|
|
854
933
|
sliceClient
|
|
855
934
|
.command("postinstall")
|
|
856
|
-
.description("
|
|
935
|
+
.description("Add Slice scripts to package.json")
|
|
857
936
|
.action(() => {
|
|
858
937
|
const pnpmHome = process.env.PNPM_HOME;
|
|
859
938
|
const cliEntryPath = fileURLToPath(import.meta.url);
|
|
860
939
|
const isGlobal = process.env.npm_config_global === 'true'
|
|
861
940
|
|| (pnpmHome && cliEntryPath.startsWith(pnpmHome));
|
|
862
941
|
if (isGlobal) {
|
|
863
|
-
console.log('
|
|
942
|
+
console.log('Global installation of slicejs-cli detected.');
|
|
864
943
|
console.log(' We strongly recommend using a local installation to avoid version mismatches.');
|
|
865
944
|
console.log(` Uninstall global: ${pnpmHome ? 'pnpm remove -g slicejs-cli' : 'npm uninstall -g slicejs-cli'}`);
|
|
866
945
|
return;
|
|
@@ -895,10 +974,10 @@ sliceClient
|
|
|
895
974
|
}
|
|
896
975
|
|
|
897
976
|
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2), 'utf-8');
|
|
898
|
-
console.log(
|
|
977
|
+
console.log(`slicejs-cli installed successfully. Added ${addedCount} package scripts to package.json.`);
|
|
899
978
|
console.log(` Run: ${runScriptCommand(packageManager, 'slice:dev')}`);
|
|
900
979
|
} catch (err) {
|
|
901
|
-
console.log('
|
|
980
|
+
console.log('slicejs-cli installed successfully.');
|
|
902
981
|
console.log(' Could not auto-configure scripts:', err.message);
|
|
903
982
|
console.log(` Configure scripts manually and run: ${runScriptCommand(packageManager, 'slice:dev')}`);
|
|
904
983
|
}
|
|
@@ -969,7 +1048,7 @@ program.on('command:*', () => {
|
|
|
969
1048
|
});
|
|
970
1049
|
|
|
971
1050
|
// HELP Command
|
|
972
|
-
const helpCommand = sliceClient.command("help").description("Display help
|
|
1051
|
+
const helpCommand = sliceClient.command("help").description("Display CLI help").action(() => {
|
|
973
1052
|
sliceClient.outputHelp();
|
|
974
1053
|
});
|
|
975
1054
|
|