@travetto/doc 8.0.0-alpha.0 → 8.0.0-alpha.2

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/package.json +3 -3
  2. package/support/cli.doc.ts +11 -21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/doc",
3
- "version": "8.0.0-alpha.0",
3
+ "version": "8.0.0-alpha.2",
4
4
  "description": "Documentation support for the Travetto framework",
5
5
  "keywords": [
6
6
  "docs",
@@ -24,12 +24,12 @@
24
24
  "directory": "module/doc"
25
25
  },
26
26
  "dependencies": {
27
- "@travetto/runtime": "^8.0.0-alpha.0",
27
+ "@travetto/runtime": "^8.0.0-alpha.2",
28
28
  "@types/prismjs": "^1.26.6",
29
29
  "prismjs": "^1.30.0"
30
30
  },
31
31
  "peerDependencies": {
32
- "@travetto/cli": "^8.0.0-alpha.0"
32
+ "@travetto/cli": "^8.0.0-alpha.3"
33
33
  },
34
34
  "peerDependenciesMeta": {
35
35
  "@travetto/cli": {
@@ -1,15 +1,21 @@
1
1
  import fs from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
 
4
- import { PackageUtil } from '@travetto/manifest';
5
4
  import { ExecUtil, Env, Runtime, WatchUtil } from '@travetto/runtime';
6
- import { type CliCommandShape, CliCommand, type CliValidationError } from '@travetto/cli';
7
- import { MinLength } from '@travetto/schema';
5
+ import { type CliCommandShape, CliCommand } from '@travetto/cli';
6
+ import { MinLength, Validator } from '@travetto/schema';
7
+ import { PackageUtil } from '@travetto/manifest';
8
8
 
9
9
  /**
10
10
  * Command line support for generating module docs.
11
11
  */
12
12
  @CliCommand()
13
+ @Validator(async (cmd) => {
14
+ const docFile = path.resolve(cmd.input);
15
+ if (!(await fs.stat(docFile).catch(() => false))) {
16
+ return { message: `input: ${cmd.input} does not exist`, path: 'input', source: 'flag', kind: 'invalid' };
17
+ }
18
+ })
13
19
  export class DocCommand implements CliCommandShape {
14
20
 
15
21
  /** Input File */
@@ -17,12 +23,12 @@ export class DocCommand implements CliCommandShape {
17
23
 
18
24
  /** Outputs */
19
25
  @MinLength(1)
20
- outputs: string[] = [];
26
+ outputs: string[] = PackageUtil.readPackage(Runtime.workspace.path)?.travetto?.doc?.outputs ?? ['README.md'];
21
27
 
22
28
  /** Watch? */
23
29
  watch = false;
24
30
 
25
- preMain(): void {
31
+ finalize(): void {
26
32
  Env.DEBUG.set(false);
27
33
  Env.TRV_ROLE.set('doc');
28
34
  Env.TRV_CLI_IPC.clear();
@@ -30,22 +36,6 @@ export class DocCommand implements CliCommandShape {
30
36
  Env.FORCE_COLOR.set(false);// Prevent restarting
31
37
  }
32
38
 
33
- preBind(): void {
34
- const workspacePkg = PackageUtil.readPackage(Runtime.workspace.path);
35
- this.outputs = workspacePkg.travetto?.doc?.outputs ?? ['README.md'];
36
- }
37
-
38
- preHelp(): void {
39
- this.preBind();
40
- }
41
-
42
- async validate(): Promise<CliValidationError | undefined> {
43
- const docFile = path.resolve(this.input);
44
- if (!(await fs.stat(docFile).catch(() => false))) {
45
- return { message: `input: ${this.input} does not exist`, source: 'flag' };
46
- }
47
- }
48
-
49
39
  async runWatch(): Promise<void> {
50
40
  const [first, ...args] = process.argv.slice(2).filter(arg => !/(-w|--watch)/.test(arg));
51
41
  await WatchUtil.watchCompilerEvents('change', async ({ file }) => {