@zpress/cli 0.4.3 → 0.5.1

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 (2) hide show
  1. package/dist/145.mjs +63 -13
  2. package/package.json +7 -7
package/dist/145.mjs CHANGED
@@ -184,6 +184,7 @@ function runConfigCheck(params) {
184
184
  };
185
185
  }
186
186
  async function runBuildCheck(params) {
187
+ if (params.verbose) return runBuildCheckVerbose(params);
187
188
  const { error, captured } = await captureOutput(()=>buildSiteForCheck({
188
189
  config: params.config,
189
190
  paths: params.paths
@@ -228,6 +229,22 @@ function presentResults(params) {
228
229
  }
229
230
  return configResult.passed && 'passed' === buildResult.status;
230
231
  }
232
+ async function runBuildCheckVerbose(params) {
233
+ try {
234
+ await buildSiteForCheck({
235
+ config: params.config,
236
+ paths: params.paths
237
+ });
238
+ return {
239
+ status: 'passed'
240
+ };
241
+ } catch (error) {
242
+ return {
243
+ status: 'error',
244
+ message: toError(error).message
245
+ };
246
+ }
247
+ }
231
248
  function stripAnsi(text) {
232
249
  return text.replace(ANSI_PATTERN, '');
233
250
  }
@@ -366,10 +383,11 @@ const buildCommand = command({
366
383
  options: z.object({
367
384
  quiet: z.boolean().optional().default(false),
368
385
  clean: z.boolean().optional().default(false),
369
- check: z.boolean().optional().default(true)
386
+ check: z.boolean().optional().default(true),
387
+ verbose: z.boolean().optional().default(false)
370
388
  }),
371
389
  handler: async (ctx)=>{
372
- const { quiet, check } = ctx.args;
390
+ const { quiet, check, verbose } = ctx.args;
373
391
  const paths = createPaths(process.cwd());
374
392
  ctx.logger.intro('zpress build');
375
393
  if (ctx.args.clean) {
@@ -399,7 +417,8 @@ const buildCommand = command({
399
417
  ctx.logger.step('Building & checking for broken links...');
400
418
  const buildResult = await runBuildCheck({
401
419
  config,
402
- paths
420
+ paths,
421
+ verbose
403
422
  });
404
423
  const passed = presentResults({
405
424
  configResult,
@@ -530,10 +549,11 @@ const CONFIG_GLOBS = [
530
549
  const diffCommand = command({
531
550
  description: 'Show changed files in configured source directories',
532
551
  options: z.object({
533
- pretty: z.boolean().optional().default(false)
552
+ pretty: z.boolean().optional().default(false),
553
+ ref: z.string().optional().describe('Git ref to compare against HEAD (e.g. HEAD^, main). Exits 1 when changes are detected.')
534
554
  }),
535
555
  handler: async (ctx)=>{
536
- const { pretty } = ctx.args;
556
+ const { pretty, ref } = ctx.args;
537
557
  const paths = createPaths(process.cwd());
538
558
  const [configErr, config] = await loadConfig(paths.repoRoot);
539
559
  if (configErr) {
@@ -556,10 +576,14 @@ const diffCommand = command({
556
576
  }
557
577
  return;
558
578
  }
559
- const [gitErr, changed] = gitChangedFiles({
560
- repoRoot: paths.repoRoot,
561
- dirs
562
- });
579
+ const [gitErr, changed] = external_ts_pattern_match(ref).when((r)=>void 0 !== r, (r)=>gitDiffFiles({
580
+ repoRoot: paths.repoRoot,
581
+ dirs,
582
+ ref: r
583
+ })).otherwise(()=>gitChangedFiles({
584
+ repoRoot: paths.repoRoot,
585
+ dirs
586
+ }));
563
587
  if (gitErr) {
564
588
  if (pretty) {
565
589
  ctx.logger.intro('zpress diff');
@@ -581,9 +605,8 @@ const diffCommand = command({
581
605
  ctx.logger.step(`Watching ${dirs.length} path(s)`);
582
606
  ctx.logger.note(changed.join('\n'), `${changed.length} changed file(s)`);
583
607
  ctx.logger.outro('Done');
584
- return;
585
- }
586
- process.stdout.write(`${changed.join(' ')}\n`);
608
+ } else process.stdout.write(`${changed.join(' ')}\n`);
609
+ if (ref) process.exit(1);
587
610
  }
588
611
  });
589
612
  function collectWatchPaths(config) {
@@ -659,6 +682,33 @@ function stripQuotes(value) {
659
682
  if (trimmed.startsWith('"') && trimmed.endsWith('"')) return trimmed.slice(1, -1);
660
683
  return trimmed;
661
684
  }
685
+ function gitDiffFiles(params) {
686
+ const [err, output] = execSilent({
687
+ file: 'git',
688
+ args: [
689
+ 'diff',
690
+ '--name-only',
691
+ params.ref,
692
+ 'HEAD',
693
+ '--',
694
+ ...params.dirs
695
+ ],
696
+ cwd: params.repoRoot
697
+ });
698
+ if (err) return [
699
+ err,
700
+ null
701
+ ];
702
+ if (!output) return [
703
+ null,
704
+ []
705
+ ];
706
+ const files = output.split('\n').filter((line)=>line.length > 0);
707
+ return [
708
+ null,
709
+ files
710
+ ];
711
+ }
662
712
  function execSilent(params) {
663
713
  try {
664
714
  const output = execFileSync(params.file, [
@@ -1019,7 +1069,7 @@ const syncCommand = command({
1019
1069
  });
1020
1070
  await cli({
1021
1071
  name: 'zpress',
1022
- version: "0.4.3",
1072
+ version: "0.5.1",
1023
1073
  description: 'CLI for building and serving documentation',
1024
1074
  commands: {
1025
1075
  sync: syncCommand,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zpress/cli",
3
- "version": "0.4.3",
3
+ "version": "0.5.1",
4
4
  "description": "CLI for building and serving zpress documentation sites",
5
5
  "keywords": [
6
6
  "cli",
@@ -37,17 +37,17 @@
37
37
  "@kidd-cli/core": "^0.10.0",
38
38
  "@rspress/core": "^2.0.6",
39
39
  "es-toolkit": "^1.45.1",
40
- "get-port": "^7.1.0",
40
+ "get-port": "^7.2.0",
41
41
  "ts-pattern": "^5.9.0",
42
42
  "zod": "^4.3.6",
43
- "@zpress/core": "0.7.3",
44
- "@zpress/ui": "0.8.3",
45
- "@zpress/templates": "0.1.1"
43
+ "@zpress/core": "0.7.4",
44
+ "@zpress/templates": "0.1.1",
45
+ "@zpress/ui": "0.8.5"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@rslib/core": "^0.20.0",
49
- "typescript": "^5.9.3",
50
- "vitest": "^4.1.0"
49
+ "typescript": "^6.0.2",
50
+ "vitest": "^4.1.1"
51
51
  },
52
52
  "engines": {
53
53
  "node": ">=24.0.0"