@travetto/doc 3.4.3 → 4.0.0-rc.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.
- package/package.json +4 -3
- package/src/mapping/lib-mapping.ts +2 -1
- package/src/render/context.ts +5 -5
- package/src/render/html.ts +4 -4
- package/src/render/markdown.ts +4 -4
- package/src/render/renderer.ts +14 -13
- package/src/util/file.ts +9 -10
- package/src/util/run.ts +29 -44
- package/support/cli.doc.ts +20 -19
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/doc",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-rc.1",
|
|
4
4
|
"description": "Documentation support for the Travetto framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"docs",
|
|
@@ -24,12 +24,13 @@
|
|
|
24
24
|
"directory": "module/doc"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@travetto/base": "^
|
|
27
|
+
"@travetto/base": "^4.0.0-rc.1",
|
|
28
|
+
"@travetto/terminal": "^4.0.0-rc.1",
|
|
28
29
|
"@types/prismjs": "^1.26.3",
|
|
29
30
|
"prismjs": "^1.29.0"
|
|
30
31
|
},
|
|
31
32
|
"peerDependencies": {
|
|
32
|
-
"@travetto/cli": "^
|
|
33
|
+
"@travetto/cli": "^4.0.0-rc.1"
|
|
33
34
|
},
|
|
34
35
|
"peerDependenciesMeta": {
|
|
35
36
|
"@travetto/cli": {
|
|
@@ -39,6 +39,7 @@ export const LIB_MAPPING = {
|
|
|
39
39
|
UUID: { title: 'UUID', href: 'https://en.wikipedia.org/wiki/Universally_unique_identifier' },
|
|
40
40
|
|
|
41
41
|
// Node
|
|
42
|
+
Process: { title: 'process', href: 'https://nodejs.org/api/process.html' },
|
|
42
43
|
ChildProcess: { title: 'child_process', href: 'https://nodejs.org/api/child_process.html' },
|
|
43
44
|
AsyncHooks: { title: 'async_hooks', href: 'https://nodejs.org/api/async_hooks.html' },
|
|
44
45
|
Http: { title: 'http', href: 'https://nodejs.org/api/http.html' },
|
|
@@ -97,7 +98,7 @@ export const LIB_MAPPING = {
|
|
|
97
98
|
// Rest
|
|
98
99
|
Express: { title: 'express', href: 'https://expressjs.com' },
|
|
99
100
|
Passport: { title: 'passport', href: 'http://passportjs.org' },
|
|
100
|
-
Busboy: { title: 'busboy', href: 'https://github.com/
|
|
101
|
+
Busboy: { title: '@fastify/busboy', href: 'https://github.com/fastify/busboy' },
|
|
101
102
|
Cookies: { title: 'cookies', href: 'https://www.npmjs.com/package/cookies' },
|
|
102
103
|
ServerlessExpress: { title: 'aws-serverless-express', href: 'https://github.com/awslabs/aws-serverless-express/blob/master/README.md' },
|
|
103
104
|
AwsLambdaFastify: { title: '@fastify/aws-lambda', href: 'https://github.com/fastify/aws-lambda-fastify/blob/master/README.md' },
|
package/src/render/context.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createElement, JSXRuntimeTag } from '@travetto/doc/jsx-runtime';
|
|
2
2
|
|
|
3
|
-
import { PackageUtil, path,
|
|
3
|
+
import { PackageUtil, path, RuntimeIndex } from '@travetto/manifest';
|
|
4
4
|
|
|
5
5
|
import { JSXElementByFn, c } from '../jsx';
|
|
6
6
|
import { DocResolveUtil, ResolvedCode, ResolvedRef, ResolvedSnippetLink } from '../util/resolve';
|
|
@@ -35,12 +35,12 @@ export class RenderContext {
|
|
|
35
35
|
|
|
36
36
|
constructor(file: string, baseUrl: string, repoRoot: string) {
|
|
37
37
|
|
|
38
|
-
const manifestPkg = PackageUtil.readPackage(
|
|
38
|
+
const manifestPkg = PackageUtil.readPackage(RuntimeIndex.getModule('@travetto/manifest')!.sourcePath);
|
|
39
39
|
|
|
40
40
|
this.file = path.toPosix(file);
|
|
41
41
|
this.baseUrl = baseUrl;
|
|
42
42
|
this.repoRoot = repoRoot;
|
|
43
|
-
this.travettoBaseUrl = repoRoot.includes('travetto.github') ? repoRoot : manifestPkg.travetto!.
|
|
43
|
+
this.travettoBaseUrl = repoRoot.includes('travetto.github') ? repoRoot : manifestPkg.travetto!.doc!.baseUrl!;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
@@ -105,7 +105,7 @@ export class RenderContext {
|
|
|
105
105
|
* Resolve code link
|
|
106
106
|
*/
|
|
107
107
|
async resolveCodeLink(node: JSXElementByFn<'CodeLink'>): Promise<ResolvedSnippetLink> {
|
|
108
|
-
const src = typeof node.props.src === 'string' ? node.props.src :
|
|
108
|
+
const src = typeof node.props.src === 'string' ? node.props.src : RuntimeIndex.getFunctionMetadata(node.props.src)!.source;
|
|
109
109
|
return DocResolveUtil.resolveCodeLink(src, node.props.startRe);
|
|
110
110
|
}
|
|
111
111
|
|
|
@@ -113,7 +113,7 @@ export class RenderContext {
|
|
|
113
113
|
* Resolve code/config
|
|
114
114
|
*/
|
|
115
115
|
async resolveCode(node: JSXElementByFn<'Code' | 'Config'>): Promise<ResolvedCode> {
|
|
116
|
-
const src = typeof node.props.src === 'string' ? node.props.src :
|
|
116
|
+
const src = typeof node.props.src === 'string' ? node.props.src : RuntimeIndex.getFunctionMetadata(node.props.src)!.source;
|
|
117
117
|
return node.props.startRe ?
|
|
118
118
|
DocResolveUtil.resolveSnippet(src, node.props.startRe, node.props.endRe, node.props.outline) :
|
|
119
119
|
DocResolveUtil.resolveCode(src, node.props.language, node.props.outline);
|
package/src/render/html.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import fs from 'fs/promises';
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
2
|
|
|
3
3
|
import { JSXElement } from '@travetto/doc/jsx-runtime';
|
|
4
|
-
import {
|
|
4
|
+
import { RuntimeIndex, PackageUtil, RuntimeContext } from '@travetto/manifest';
|
|
5
5
|
|
|
6
6
|
import { highlight } from './code-highlight';
|
|
7
7
|
import { RenderProvider, RenderState } from '../types';
|
|
@@ -144,8 +144,8 @@ yarn add ${el.props.pkg}
|
|
|
144
144
|
Header: async ({ props }) => `<h1>${props.title} ${props.description ? `\n<small>${props.description}</small>\n` : ''}</h1>\n`,
|
|
145
145
|
|
|
146
146
|
StdHeader: async state => {
|
|
147
|
-
const mod = state.el.props.mod ??
|
|
148
|
-
const pkg = PackageUtil.readPackage(
|
|
147
|
+
const mod = state.el.props.mod ?? RuntimeContext.main.name;
|
|
148
|
+
const pkg = PackageUtil.readPackage(RuntimeIndex.getModule(mod)!.sourcePath);
|
|
149
149
|
const title = pkg.travetto?.displayName ?? pkg.name;
|
|
150
150
|
const desc = pkg.description;
|
|
151
151
|
let install = '';
|
package/src/render/markdown.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import fs from 'fs/promises';
|
|
2
|
-
import { PackageUtil,
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import { PackageUtil, RuntimeIndex, RuntimeContext } from '@travetto/manifest';
|
|
3
3
|
|
|
4
4
|
import { RenderProvider } from '../types';
|
|
5
5
|
import { c, getComponentName } from '../jsx';
|
|
@@ -108,8 +108,8 @@ ${context.cleanText(content.text)}
|
|
|
108
108
|
Header: async ({ props }) => `# ${props.title}\n${props.description ? `## ${props.description}\n` : ''}\n`,
|
|
109
109
|
|
|
110
110
|
StdHeader: async state => {
|
|
111
|
-
const mod = state.el.props.mod ??
|
|
112
|
-
const pkg = PackageUtil.readPackage(
|
|
111
|
+
const mod = state.el.props.mod ?? RuntimeContext.main.name;
|
|
112
|
+
const pkg = PackageUtil.readPackage(RuntimeIndex.getModule(mod)!.sourcePath);
|
|
113
113
|
const title = pkg.travetto?.displayName ?? pkg.name;
|
|
114
114
|
const desc = pkg.description;
|
|
115
115
|
let install = '';
|
package/src/render/renderer.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ManifestContext, PackageUtil, path, RuntimeIndex } from '@travetto/manifest';
|
|
2
2
|
|
|
3
|
-
import { isJSXElement, JSXElement,
|
|
3
|
+
import { isJSXElement, JSXElement, JSXFragmentType } from '@travetto/doc/jsx-runtime';
|
|
4
4
|
|
|
5
5
|
import { EMPTY_ELEMENT, getComponentName, JSXElementByFn, c } from '../jsx';
|
|
6
6
|
import { DocumentShape, RenderProvider, RenderState } from '../types';
|
|
@@ -17,16 +17,17 @@ const providers = { [Html.ext]: Html, [Markdown.ext]: Markdown };
|
|
|
17
17
|
*/
|
|
18
18
|
export class DocRenderer {
|
|
19
19
|
|
|
20
|
-
static async get(file: string, manifest:
|
|
21
|
-
const mod =
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
static async get(file: string, manifest: ManifestContext): Promise<DocRenderer> {
|
|
21
|
+
const mod = RuntimeIndex.getFromSource(file)?.import;
|
|
22
|
+
if (!mod) {
|
|
23
|
+
throw new Error(`Unable to render ${file}, not in the manifest`);
|
|
24
|
+
}
|
|
25
|
+
const res: DocumentShape = await import(mod);
|
|
24
26
|
|
|
25
|
-
const pkg = PackageUtil.readPackage(manifest.
|
|
26
|
-
const
|
|
27
|
-
const repoBaseUrl = pkg.travetto?.docBaseUrl ?? mainPath;
|
|
27
|
+
const pkg = PackageUtil.readPackage(manifest.workspace.path);
|
|
28
|
+
const repoBaseUrl = pkg.travetto?.doc?.baseUrl ?? manifest.workspace.path;
|
|
28
29
|
return new DocRenderer(res,
|
|
29
|
-
new RenderContext(file, repoBaseUrl, path.resolve(pkg.travetto?.
|
|
30
|
+
new RenderContext(file, repoBaseUrl, path.resolve(pkg.travetto?.doc?.root ?? manifest.workspace.path))
|
|
30
31
|
);
|
|
31
32
|
}
|
|
32
33
|
|
|
@@ -56,13 +57,13 @@ export class DocRenderer {
|
|
|
56
57
|
} else if (isJSXElement(node)) {
|
|
57
58
|
let final: JSXElement = node;
|
|
58
59
|
// Render simple element if needed
|
|
59
|
-
if (typeof node.type === 'function') {
|
|
60
|
+
if (typeof node.type === 'function' && node.type !== JSXFragmentType) {
|
|
60
61
|
// @ts-expect-error
|
|
61
62
|
const out = node.type(node.props);
|
|
62
63
|
final = out !== EMPTY_ELEMENT ? out : final;
|
|
63
64
|
}
|
|
64
65
|
|
|
65
|
-
if (final.type ===
|
|
66
|
+
if (final.type === JSXFragmentType) {
|
|
66
67
|
return this.#render(renderer, final.props.children ?? []);
|
|
67
68
|
}
|
|
68
69
|
|
|
@@ -91,7 +92,7 @@ export class DocRenderer {
|
|
|
91
92
|
case 'bigint':
|
|
92
93
|
case 'boolean': return `${node}`;
|
|
93
94
|
default: {
|
|
94
|
-
const meta = (typeof node === 'function' ?
|
|
95
|
+
const meta = (typeof node === 'function' ? RuntimeIndex.getFunctionMetadata(node) : undefined);
|
|
95
96
|
if (meta && typeof node === 'function') {
|
|
96
97
|
const title = (await DocFileUtil.isDecorator(node.name, meta.source)) ? `@${node.name}` : node.name;
|
|
97
98
|
const el = this.#support.createElement('CodeLink', {
|
package/src/util/file.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import fs from 'fs/promises';
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
2
|
|
|
3
|
-
import { ManifestModuleUtil, path,
|
|
3
|
+
import { ManifestModuleUtil, path, RuntimeIndex } from '@travetto/manifest';
|
|
4
4
|
|
|
5
|
-
const ESLINT_PATTERN = /\s*\/\/ eslint
|
|
5
|
+
const ESLINT_PATTERN = /\s*\/\/ eslint.*$/g;
|
|
6
|
+
const ENV_KEY = /Env.([^.]+)[.]key/g;
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Standard file utilities
|
|
@@ -31,7 +32,7 @@ export class DocFileUtil {
|
|
|
31
32
|
let resolved = path.resolve(file);
|
|
32
33
|
if (!(await fs.stat(resolved).catch(() => false))) {
|
|
33
34
|
if (ManifestModuleUtil.getFileType(file) === 'ts') {
|
|
34
|
-
resolved =
|
|
35
|
+
resolved = RuntimeIndex.getSourceFile(file);
|
|
35
36
|
}
|
|
36
37
|
if (!(await fs.stat(resolved).catch(() => false))) {
|
|
37
38
|
throw new Error(`Unknown file to resolve: ${file}`);
|
|
@@ -57,12 +58,10 @@ export class DocFileUtil {
|
|
|
57
58
|
text = await fs.readFile(file, 'utf8');
|
|
58
59
|
|
|
59
60
|
text = text.split(/\n/)
|
|
60
|
-
.map(x =>
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return x;
|
|
65
|
-
})
|
|
61
|
+
.map(x => x
|
|
62
|
+
.replace(ESLINT_PATTERN, '')
|
|
63
|
+
.replace(ENV_KEY, (_, k) => `'${k}'`)
|
|
64
|
+
)
|
|
66
65
|
.filter(x => !x.includes('@doc-exclude'))
|
|
67
66
|
.join('\n');
|
|
68
67
|
}
|
package/src/util/run.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import os from 'os';
|
|
1
|
+
import os from 'node:os';
|
|
2
|
+
import { spawn, ChildProcess } from 'node:child_process';
|
|
2
3
|
|
|
3
|
-
import { path,
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { path, RuntimeIndex, RuntimeContext } from '@travetto/manifest';
|
|
5
|
+
import { Env, ExecUtil } from '@travetto/base';
|
|
6
|
+
import { StyleUtil } from '@travetto/terminal';
|
|
6
7
|
|
|
7
8
|
export const COMMON_DATE = new Date('2029-03-14T00:00:00.000').getTime();
|
|
8
9
|
|
|
@@ -15,12 +16,6 @@ export type RunConfig = {
|
|
|
15
16
|
cwd?: string;
|
|
16
17
|
};
|
|
17
18
|
|
|
18
|
-
type RunState = {
|
|
19
|
-
cmd: string;
|
|
20
|
-
args: string[];
|
|
21
|
-
opts: ExecutionOptions;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
19
|
class DocState {
|
|
25
20
|
baseline = COMMON_DATE;
|
|
26
21
|
_s = 37;
|
|
@@ -50,39 +45,15 @@ class DocState {
|
|
|
50
45
|
export class DocRunUtil {
|
|
51
46
|
static #docState = new DocState();
|
|
52
47
|
|
|
53
|
-
static runState(cmd: string, args: string[], config: RunConfig = {}): RunState {
|
|
54
|
-
const cwd = config.cwd ?? (config.module ? RootIndex.getModule(config.module)! : RootIndex.mainModule).sourcePath;
|
|
55
|
-
args = [...args];
|
|
56
|
-
return {
|
|
57
|
-
cmd,
|
|
58
|
-
args,
|
|
59
|
-
opts: {
|
|
60
|
-
cwd: path.toPosix(cwd),
|
|
61
|
-
shell: '/bin/bash',
|
|
62
|
-
env: {
|
|
63
|
-
...process.env,
|
|
64
|
-
DEBUG: '0',
|
|
65
|
-
TRV_CAN_RESTART: '0',
|
|
66
|
-
TRV_CLI_IPC: '',
|
|
67
|
-
TRV_MANIFEST: '',
|
|
68
|
-
TRV_BUILD: 'none',
|
|
69
|
-
TRV_MODULE: config.module ?? '',
|
|
70
|
-
...(config.envName ? { TRV_ENV: config.envName } : {}),
|
|
71
|
-
...(config.env ?? {})
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
|
|
77
48
|
/**
|
|
78
49
|
* Clean run output
|
|
79
50
|
*/
|
|
80
51
|
static cleanRunOutput(text: string, cfg: RunConfig): string {
|
|
81
|
-
const cwd = path.toPosix((cfg.module ?
|
|
82
|
-
text =
|
|
52
|
+
const cwd = path.toPosix((cfg.module ? RuntimeIndex.getModule(cfg.module)! : RuntimeIndex.mainModule).sourcePath);
|
|
53
|
+
text = StyleUtil.cleanText(text.trim())
|
|
83
54
|
.replaceAll(cwd, '.')
|
|
84
55
|
.replaceAll(os.tmpdir(), '/tmp')
|
|
85
|
-
.replaceAll(
|
|
56
|
+
.replaceAll(RuntimeContext.workspace.path, '<workspace-root>')
|
|
86
57
|
.replace(/[/]tmp[/][a-z_A-Z0-9\/\-]+/g, '/tmp/<temp-folder>')
|
|
87
58
|
.replace(/^(\s*framework:\s*')(\d+[.]\d+)[^']*('[,]?\s*)$/gm, (_, pre, ver, post) => `${pre}${ver}.x${post}`)
|
|
88
59
|
.replace(/^(\s*nodeVersion:\s*'v)(\d+)[^']*('[,]?\s*)$/gm, (_, pre, ver, post) => `${pre}${ver}.x.x${post}`)
|
|
@@ -101,11 +72,25 @@ export class DocRunUtil {
|
|
|
101
72
|
}
|
|
102
73
|
|
|
103
74
|
/**
|
|
104
|
-
*
|
|
75
|
+
* Spawn command with appropriate environment, and cwd
|
|
105
76
|
*/
|
|
106
|
-
static
|
|
107
|
-
|
|
108
|
-
|
|
77
|
+
static spawn(cmd: string, args: string[], config: RunConfig = {}): ChildProcess {
|
|
78
|
+
return spawn(cmd, args, {
|
|
79
|
+
cwd: path.toPosix(config.cwd ?? (config.module ? RuntimeIndex.getModule(config.module)! : RuntimeIndex.mainModule).sourcePath),
|
|
80
|
+
shell: '/bin/bash',
|
|
81
|
+
env: {
|
|
82
|
+
...process.env,
|
|
83
|
+
...Env.DEBUG.export(false),
|
|
84
|
+
...Env.TRV_CAN_RESTART.export(false),
|
|
85
|
+
...Env.TRV_CLI_IPC.export(undefined),
|
|
86
|
+
...Env.TRV_MANIFEST.export(''),
|
|
87
|
+
...Env.TRV_BUILD.export('none'),
|
|
88
|
+
...Env.TRV_ROLE.export(undefined),
|
|
89
|
+
...Env.TRV_MODULE.export(config.module ?? ''),
|
|
90
|
+
...(config.envName ? Env.TRV_ENV.export(config.envName) : {}),
|
|
91
|
+
...config.env
|
|
92
|
+
}
|
|
93
|
+
});
|
|
109
94
|
}
|
|
110
95
|
|
|
111
96
|
/**
|
|
@@ -114,12 +99,12 @@ export class DocRunUtil {
|
|
|
114
99
|
static async run(cmd: string, args: string[], config: RunConfig = {}): Promise<string> {
|
|
115
100
|
let final: string;
|
|
116
101
|
try {
|
|
117
|
-
const
|
|
118
|
-
const res = await ExecUtil.
|
|
102
|
+
const proc = this.spawn(cmd, args, config);
|
|
103
|
+
const res = await ExecUtil.getResult(proc, { catch: true });
|
|
119
104
|
if (!res.valid) {
|
|
120
105
|
throw new Error(res.stderr);
|
|
121
106
|
}
|
|
122
|
-
final =
|
|
107
|
+
final = StyleUtil.cleanText(res.stdout).trim() || StyleUtil.cleanText(res.stderr).trim();
|
|
123
108
|
} catch (err) {
|
|
124
109
|
if (err instanceof Error) {
|
|
125
110
|
final = err.message;
|
package/support/cli.doc.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import fs from 'fs/promises';
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import { spawn } from 'node:child_process';
|
|
2
3
|
|
|
3
|
-
import { PackageUtil, path,
|
|
4
|
-
import { ExecUtil,
|
|
4
|
+
import { PackageUtil, path, RuntimeIndex, RuntimeContext } from '@travetto/manifest';
|
|
5
|
+
import { ExecUtil, Env, watchCompiler } from '@travetto/base';
|
|
5
6
|
import { CliCommandShape, CliCommand, CliValidationError, CliUtil } from '@travetto/cli';
|
|
6
7
|
import { MinLength } from '@travetto/schema';
|
|
7
8
|
|
|
@@ -22,18 +23,16 @@ export class DocCommand implements CliCommandShape {
|
|
|
22
23
|
watch = false;
|
|
23
24
|
|
|
24
25
|
preMain(): void {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
});
|
|
31
|
-
defineEnv({ debug: false, });
|
|
26
|
+
Env.DEBUG.set(false);
|
|
27
|
+
Env.TRV_ROLE.set('doc');
|
|
28
|
+
Env.TRV_CLI_IPC.clear();
|
|
29
|
+
Env.TRV_LOG_PLAIN.set(true);
|
|
30
|
+
Env.FORCE_COLOR.set(false);
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
preBind(): void {
|
|
35
|
-
const workspacePkg = PackageUtil.readPackage(
|
|
36
|
-
this.outputs = workspacePkg.travetto?.
|
|
34
|
+
const workspacePkg = PackageUtil.readPackage(RuntimeContext.workspace.path);
|
|
35
|
+
this.outputs = workspacePkg.travetto?.doc?.outputs ?? ['README.md'];
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
preHelp(): void {
|
|
@@ -53,20 +52,22 @@ export class DocCommand implements CliCommandShape {
|
|
|
53
52
|
}
|
|
54
53
|
|
|
55
54
|
const args = process.argv.slice(2).filter(x => !/(-w|--watch)/.test(x));
|
|
56
|
-
await
|
|
55
|
+
for await (const { action, file } of watchCompiler({ restartOnExit: true })) {
|
|
57
56
|
if (action === 'update' && file === this.input) {
|
|
58
|
-
|
|
59
|
-
cwd:
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
const proc = spawn('npx', ['trv', ...args], {
|
|
58
|
+
cwd: RuntimeIndex.mainModule.sourcePath,
|
|
59
|
+
shell: false,
|
|
60
|
+
env: { ...process.env, ...Env.TRV_QUIET.export(true) },
|
|
61
|
+
stdio: 'inherit'
|
|
62
62
|
});
|
|
63
|
+
await ExecUtil.getResult(proc, { catch: true });
|
|
63
64
|
}
|
|
64
|
-
}
|
|
65
|
+
}
|
|
65
66
|
}
|
|
66
67
|
|
|
67
68
|
async render(): Promise<void> {
|
|
68
69
|
const { DocRenderer } = await import('../src/render/renderer.js');
|
|
69
|
-
const ctx = await DocRenderer.get(this.input,
|
|
70
|
+
const ctx = await DocRenderer.get(this.input, RuntimeContext);
|
|
70
71
|
const outputs = this.outputs.map(output =>
|
|
71
72
|
output.includes('.') ? [path.extname(output).replace('.', ''), path.resolve(output)] :
|
|
72
73
|
[output, null] as const
|