@travetto/doc 3.0.0-rc.2 → 3.0.0-rc.5
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/README.md +14 -63
- package/{index.ts → __index__.ts} +0 -0
- package/package.json +14 -8
- package/src/doc.ts +2 -2
- package/src/mod-mapping.ts +258 -0
- package/src/mod.ts +4 -71
- package/src/nodes.ts +38 -18
- package/src/render/code-highlight.ts +16 -23
- package/src/render/context.ts +12 -31
- package/src/render/markdown.ts +1 -1
- package/src/render/prism.d.ts +14 -386
- package/src/render/util.ts +19 -3
- package/src/types.ts +3 -8
- package/src/util/file.ts +20 -16
- package/src/util/resolve.ts +13 -20
- package/src/util/run.ts +18 -20
- package/support/cli.doc.ts +84 -0
- package/bin/cli-doc.ts +0 -84
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<!-- This file was generated by @travetto/doc and should not be modified directly -->
|
|
2
|
-
<!-- Please modify https://github.com/travetto/travetto/tree/main/module/doc/
|
|
2
|
+
<!-- Please modify https://github.com/travetto/travetto/tree/main/module/doc/DOC.ts and execute "npx trv doc" to rebuild -->
|
|
3
3
|
# Documentation
|
|
4
4
|
## Documentation support for the travetto framework
|
|
5
5
|
|
|
@@ -14,7 +14,7 @@ This module provides the ability to generate documentation in [HTML](https://en.
|
|
|
14
14
|
```typescript
|
|
15
15
|
import { d, mod } from '@travetto/doc';
|
|
16
16
|
|
|
17
|
-
export const text = d`
|
|
17
|
+
export const text = () => d`
|
|
18
18
|
${d.Header()}
|
|
19
19
|
|
|
20
20
|
Sample documentation for fictional module. This module fictitiously relies upon ${mod.Cache} functionality.
|
|
@@ -27,7 +27,7 @@ ${d.Ordered(
|
|
|
27
27
|
|
|
28
28
|
${d.Section('Content')}
|
|
29
29
|
|
|
30
|
-
${d.Code('Document Sample', '
|
|
30
|
+
${d.Code('Document Sample', './src/test.ts')}
|
|
31
31
|
|
|
32
32
|
${d.SubSection('Output')}
|
|
33
33
|
|
|
@@ -38,7 +38,7 @@ ${d.Execute('Run program', 'trv')}
|
|
|
38
38
|
**Code: Document Context**
|
|
39
39
|
```typescript
|
|
40
40
|
export interface DocumentShape<T extends DocNode = DocNode> {
|
|
41
|
-
text:
|
|
41
|
+
text: () => (T | Promise<T>);
|
|
42
42
|
wrap?: Wrapper;
|
|
43
43
|
}
|
|
44
44
|
```
|
|
@@ -81,7 +81,7 @@ As you can see, you need to export a field named `text` as the body of the help
|
|
|
81
81
|
* `Table` - Table
|
|
82
82
|
* `TableOfContents` - Table Of Contents
|
|
83
83
|
* `Terminal` - Terminal output
|
|
84
|
-
* `Text` - Simple Text
|
|
84
|
+
* `Text` - Simple Text Contentf
|
|
85
85
|
|
|
86
86
|
## Libraries
|
|
87
87
|
|
|
@@ -102,69 +102,20 @@ $ trv doc --help
|
|
|
102
102
|
Usage: doc [options]
|
|
103
103
|
|
|
104
104
|
Options:
|
|
105
|
-
-i, --input <input>
|
|
106
|
-
-o, --
|
|
107
|
-
-
|
|
108
|
-
-
|
|
109
|
-
-h, --help
|
|
105
|
+
-i, --input <input> Input File (default: "DOC.ts")
|
|
106
|
+
-o, --outputs <outputs> Outputs (default: [])
|
|
107
|
+
-w, --watch Watch
|
|
108
|
+
-s, --stdout Write to stdout (default: false)
|
|
109
|
+
-h, --help display help for command
|
|
110
|
+
|
|
111
|
+
[s[r[u
|
|
110
112
|
```
|
|
111
113
|
|
|
112
114
|
By default, running the command will output the [Markdown](https://en.wikipedia.org/wiki/Markdown) content directly to the terminal.
|
|
113
115
|
|
|
114
116
|
**Terminal: Sample CLI Output**
|
|
115
117
|
```bash
|
|
116
|
-
$ trv doc -
|
|
117
|
-
|
|
118
|
-
<!-- This file was generated by @travetto/doc and should not be modified directly -->
|
|
119
|
-
<!-- Please modify https://github.com/travetto/travetto/tree/main/module/doc/docs/sample/doc.ts and execute "npx trv doc" to rebuild -->
|
|
120
|
-
<h1>Documentation
|
|
121
|
-
<small>Documentation support for the travetto framework</small>
|
|
122
|
-
|
|
123
|
-
</h1>
|
|
124
|
-
|
|
125
|
-
<figure class="install">
|
|
126
|
-
<figcaption class="install">Install @travetto/doc
|
|
127
|
-
|
|
128
|
-
</figcaption>
|
|
129
|
-
<pre><code class="language-bash"><span class="token function">npm</span> <span class="token function">install</span> @travetto/doc</code></pre>
|
|
130
|
-
</figure>
|
|
131
|
-
|
|
132
|
-
Sample documentation for fictional module. This module fictitiously relies upon <a class="module-link" href="https://github.com/travetto/travetto/tree/main/module/cache" title="Caching functionality with decorators for declarative use.">Caching</a> functionality.
|
|
133
|
-
|
|
134
|
-
<ol> <li>First</li>
|
|
135
|
-
<li>Second</li>
|
|
136
|
-
<li><code class="item path">Special</code></li></ol>
|
|
118
|
+
$ trv doc -f html --stdout
|
|
137
119
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
<figure class="code">
|
|
141
|
-
<figcaption class="code">Document Sample
|
|
142
|
-
<cite><a target="_blank" href="https://github.com/travetto/travetto/tree/main/module/doc/docs/test.ts">Source</a></cite>
|
|
143
|
-
</figcaption>
|
|
144
|
-
<pre><code class="language-typescript"><span class="token keyword">class</span> <span class="token class-name">TestFile</span> <span class="token punctuation">{{'{'}}</span>
|
|
145
|
-
<span class="token keyword">static</span> <span class="token function">method</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">:</span> <span class="token keyword">void</span> <span class="token punctuation">{{'{'}}</span> <span class="token punctuation">{{'}'}}</span>
|
|
146
|
-
<span class="token punctuation">{{'}'}}</span></code></pre>
|
|
147
|
-
</figure>
|
|
148
|
-
|
|
149
|
-
<h3 id="output">Output</h3>
|
|
150
|
-
|
|
151
|
-
<figure class="terminal">
|
|
152
|
-
<figcaption class="terminal">Run program
|
|
153
|
-
|
|
154
|
-
</figcaption>
|
|
155
|
-
<pre><code class="language-bash">$ trv
|
|
156
|
-
|
|
157
|
-
Usage: <span class="token punctuation">[</span>options<span class="token punctuation">]</span> <span class="token punctuation">[</span>command<span class="token punctuation">]</span>
|
|
158
|
-
|
|
159
|
-
Options:
|
|
160
|
-
-V, <span class="token parameter variable">--version</span> output the version number
|
|
161
|
-
-h, <span class="token parameter variable">--help</span> display <span class="token builtin class-name">help</span> <span class="token keyword">for</span> <span class="token builtin class-name">command</span>
|
|
162
|
-
|
|
163
|
-
Commands:
|
|
164
|
-
build <span class="token punctuation">[</span>options<span class="token punctuation">]</span>
|
|
165
|
-
clean <span class="token punctuation">[</span>options<span class="token punctuation">]</span>
|
|
166
|
-
doc <span class="token punctuation">[</span>options<span class="token punctuation">]</span>
|
|
167
|
-
<span class="token builtin class-name">test</span> <span class="token punctuation">[</span>options<span class="token punctuation">]</span> <span class="token punctuation">[</span>regexes<span class="token punctuation">..</span>.<span class="token punctuation">]</span>
|
|
168
|
-
<span class="token builtin class-name">help</span> <span class="token punctuation">[</span>command<span class="token punctuation">]</span> display <span class="token builtin class-name">help</span> <span class="token keyword">for</span> <span class="token builtin class-name">command</span></code></pre>
|
|
169
|
-
</figure>
|
|
120
|
+
[s[r[u
|
|
170
121
|
```
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/doc",
|
|
3
|
-
"
|
|
4
|
-
"version": "3.0.0-rc.2",
|
|
3
|
+
"version": "3.0.0-rc.5",
|
|
5
4
|
"description": "Documentation support for the travetto framework",
|
|
6
5
|
"keywords": [
|
|
7
6
|
"docs",
|
|
@@ -15,27 +14,34 @@
|
|
|
15
14
|
"name": "Travetto Framework"
|
|
16
15
|
},
|
|
17
16
|
"files": [
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
17
|
+
"__index__.ts",
|
|
18
|
+
"src",
|
|
19
|
+
"support"
|
|
21
20
|
],
|
|
22
|
-
"main": "
|
|
21
|
+
"main": "__index__.ts",
|
|
23
22
|
"repository": {
|
|
24
23
|
"url": "https://github.com/travetto/travetto.git",
|
|
25
24
|
"directory": "module/doc"
|
|
26
25
|
},
|
|
27
26
|
"dependencies": {
|
|
28
|
-
"@travetto/base": "^3.0.0-rc.
|
|
27
|
+
"@travetto/base": "^3.0.0-rc.5",
|
|
28
|
+
"@types/prismjs": "^1.26.0",
|
|
29
29
|
"prismjs": "^1.29.0"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"@travetto/cli": "^3.0.0-rc.
|
|
32
|
+
"@travetto/cli": "^3.0.0-rc.5"
|
|
33
33
|
},
|
|
34
34
|
"peerDependenciesMeta": {
|
|
35
35
|
"@travetto/cli": {
|
|
36
36
|
"optional": true
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
|
+
"travetto": {
|
|
40
|
+
"profiles": [
|
|
41
|
+
"doc"
|
|
42
|
+
],
|
|
43
|
+
"displayName": "Documentation"
|
|
44
|
+
},
|
|
39
45
|
"private": false,
|
|
40
46
|
"publishConfig": {
|
|
41
47
|
"access": "public"
|
package/src/doc.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AllType, node } from './nodes';
|
|
2
2
|
|
|
3
|
-
export function doc(values: TemplateStringsArray, ...keys: (AllType |
|
|
3
|
+
export function doc(values: TemplateStringsArray, ...keys: (AllType | Function | string)[]): AllType {
|
|
4
4
|
const out: AllType[] = [];
|
|
5
5
|
|
|
6
6
|
keys.forEach((el, i) =>
|
|
@@ -8,7 +8,7 @@ export function doc(values: TemplateStringsArray, ...keys: (AllType | { ᚕfile:
|
|
|
8
8
|
node.Text(values[i] ?? ''),
|
|
9
9
|
typeof el === 'string' ?
|
|
10
10
|
node.Text(el) :
|
|
11
|
-
'
|
|
11
|
+
typeof el === 'function' ? node.Ref(el.name, el) : el
|
|
12
12
|
)
|
|
13
13
|
);
|
|
14
14
|
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
export const MOD_MAPPING = {
|
|
2
|
+
App: {
|
|
3
|
+
name:'@travetto/app', folder:'@travetto/app', displayName: 'Application',
|
|
4
|
+
description: 'Application registration/management and run support.'
|
|
5
|
+
},
|
|
6
|
+
Asset: {
|
|
7
|
+
name:'@travetto/asset', folder:'@travetto/asset', displayName: 'Asset',
|
|
8
|
+
description: 'Modular library for storing and retrieving binary assets'
|
|
9
|
+
},
|
|
10
|
+
AssetRest: {
|
|
11
|
+
name:'@travetto/asset-rest', folder:'@travetto/asset-rest', displayName: 'Asset Rest Support',
|
|
12
|
+
description: 'Provides integration between the travetto asset and rest module.'
|
|
13
|
+
},
|
|
14
|
+
Auth: {
|
|
15
|
+
name:'@travetto/auth', folder:'@travetto/auth', displayName: 'Authentication',
|
|
16
|
+
description: 'Authentication scaffolding for the travetto framework'
|
|
17
|
+
},
|
|
18
|
+
AuthModel: {
|
|
19
|
+
name:'@travetto/auth-model', folder:'@travetto/auth-model', displayName: 'Authentication Model',
|
|
20
|
+
description: 'Authentication model support for the travetto framework'
|
|
21
|
+
},
|
|
22
|
+
AuthRest: {
|
|
23
|
+
name:'@travetto/auth-rest', folder:'@travetto/auth-rest', displayName: 'Rest Auth',
|
|
24
|
+
description: 'Rest authentication integration support for the travetto framework'
|
|
25
|
+
},
|
|
26
|
+
AuthRestContext: {
|
|
27
|
+
name:'@travetto/auth-rest-context', folder:'@travetto/auth-rest-context', displayName: 'Rest Auth Context',
|
|
28
|
+
description: 'Rest authentication context integration support for the travetto framework'
|
|
29
|
+
},
|
|
30
|
+
AuthRestJwt: {
|
|
31
|
+
name:'@travetto/auth-rest-jwt', folder:'@travetto/auth-rest-jwt', displayName: 'Rest Auth JWT',
|
|
32
|
+
description: 'Rest authentication JWT integration support for the travetto framework'
|
|
33
|
+
},
|
|
34
|
+
AuthRestPassport: {
|
|
35
|
+
name:'@travetto/auth-rest-passport', folder:'@travetto/auth-rest-passport', displayName: 'Rest Auth Passport',
|
|
36
|
+
description: 'Rest authentication integration support for the travetto framework'
|
|
37
|
+
},
|
|
38
|
+
AuthRestSession: {
|
|
39
|
+
name:'@travetto/auth-rest-session', folder:'@travetto/auth-rest-session', displayName: 'Rest Auth Session',
|
|
40
|
+
description: 'Rest authentication session integration support for the travetto framework'
|
|
41
|
+
},
|
|
42
|
+
Base: {
|
|
43
|
+
name:'@travetto/base', folder:'@travetto/base', displayName: 'Base',
|
|
44
|
+
description: 'Environment config and common utilities for travetto applications.'
|
|
45
|
+
},
|
|
46
|
+
Cache: {
|
|
47
|
+
name:'@travetto/cache', folder:'@travetto/cache', displayName: 'Caching',
|
|
48
|
+
description: 'Caching functionality with decorators for declarative use.'
|
|
49
|
+
},
|
|
50
|
+
Cli: {
|
|
51
|
+
name:'@travetto/cli', folder:'@travetto/cli', displayName: 'Command Line Interface',
|
|
52
|
+
description: 'CLI infrastructure for travetto framework'
|
|
53
|
+
},
|
|
54
|
+
Command: {
|
|
55
|
+
name:'@travetto/command', folder:'@travetto/command', displayName: 'Command',
|
|
56
|
+
description: 'Support for executing complex commands at runtime.'
|
|
57
|
+
},
|
|
58
|
+
Compiler: {
|
|
59
|
+
name:'@travetto/compiler', folder:'@travetto/compiler', displayName: 'Compiler',
|
|
60
|
+
description: 'Compiler'
|
|
61
|
+
},
|
|
62
|
+
Config: {
|
|
63
|
+
name:'@travetto/config', folder:'@travetto/config', displayName: 'Configuration',
|
|
64
|
+
description: 'Configuration support'
|
|
65
|
+
},
|
|
66
|
+
Context: {
|
|
67
|
+
name:'@travetto/context', folder:'@travetto/context', displayName: 'Async Context',
|
|
68
|
+
description: 'Async-aware state management, maintaining context across asynchronous calls.'
|
|
69
|
+
},
|
|
70
|
+
Di: {
|
|
71
|
+
name:'@travetto/di', folder:'@travetto/di', displayName: 'Dependency Injection',
|
|
72
|
+
description: 'Dependency registration/management and injection support.'
|
|
73
|
+
},
|
|
74
|
+
Doc: {
|
|
75
|
+
name:'@travetto/doc', folder:'@travetto/doc', displayName: 'Documentation',
|
|
76
|
+
description: 'Documentation support for the travetto framework'
|
|
77
|
+
},
|
|
78
|
+
Email: {
|
|
79
|
+
name:'@travetto/email', folder:'@travetto/email', displayName: 'Email',
|
|
80
|
+
description: 'Email transmission module.'
|
|
81
|
+
},
|
|
82
|
+
EmailNodemailer: {
|
|
83
|
+
name:'@travetto/email-nodemailer', folder:'@travetto/email-nodemailer', displayName: 'Email Nodemailer Support',
|
|
84
|
+
description: 'Email transmission module.'
|
|
85
|
+
},
|
|
86
|
+
EmailTemplate: {
|
|
87
|
+
name:'@travetto/email-template', folder:'@travetto/email-template', displayName: 'Email Templating',
|
|
88
|
+
description: 'Email templating module'
|
|
89
|
+
},
|
|
90
|
+
EslintPlugin: {
|
|
91
|
+
name:'@travetto/eslint-plugin', folder:'@travetto/eslint-plugin', displayName: 'ES Linting Rules',
|
|
92
|
+
description: 'ES Linting Rules'
|
|
93
|
+
},
|
|
94
|
+
Image: {
|
|
95
|
+
name:'@travetto/image', folder:'@travetto/image', displayName: 'Image',
|
|
96
|
+
description: 'Image support, resizing, and optimization'
|
|
97
|
+
},
|
|
98
|
+
Jwt: {
|
|
99
|
+
name:'@travetto/jwt', folder:'@travetto/jwt', displayName: 'JWT',
|
|
100
|
+
description: 'JSON Web Token implementation'
|
|
101
|
+
},
|
|
102
|
+
Log: {
|
|
103
|
+
name:'@travetto/log', folder:'@travetto/log', displayName: 'Logging',
|
|
104
|
+
description: 'Logging framework that integrates at the console.log level.'
|
|
105
|
+
},
|
|
106
|
+
Manifest: {
|
|
107
|
+
name:'@travetto/manifest', folder:'@travetto/manifest', displayName: 'Manifest',
|
|
108
|
+
description: 'Manifest support'
|
|
109
|
+
},
|
|
110
|
+
Model: {
|
|
111
|
+
name:'@travetto/model', folder:'@travetto/model', displayName: 'Data Modeling Support',
|
|
112
|
+
description: 'Datastore abstraction for core operations.'
|
|
113
|
+
},
|
|
114
|
+
ModelDynamodb: {
|
|
115
|
+
name:'@travetto/model-dynamodb', folder:'@travetto/model-dynamodb', displayName: 'DynamoDB Model Support',
|
|
116
|
+
description: 'DynamoDB backing for the travetto model module.'
|
|
117
|
+
},
|
|
118
|
+
ModelElasticsearch: {
|
|
119
|
+
name:'@travetto/model-elasticsearch', folder:'@travetto/model-elasticsearch', displayName: 'Elasticsearch Model Source',
|
|
120
|
+
description: 'Elasticsearch backing for the travetto model module, with real-time modeling support for Elasticsearch mappings.'
|
|
121
|
+
},
|
|
122
|
+
ModelFirestore: {
|
|
123
|
+
name:'@travetto/model-firestore', folder:'@travetto/model-firestore', displayName: 'Firestore Model Support',
|
|
124
|
+
description: 'Firestore backing for the travetto model module.'
|
|
125
|
+
},
|
|
126
|
+
ModelMongo: {
|
|
127
|
+
name:'@travetto/model-mongo', folder:'@travetto/model-mongo', displayName: 'MongoDB Model Support',
|
|
128
|
+
description: 'Mongo backing for the travetto model module.'
|
|
129
|
+
},
|
|
130
|
+
ModelMysql: {
|
|
131
|
+
name:'@travetto/model-mysql', folder:'@travetto/model-mysql', displayName: 'MySQL Model Service',
|
|
132
|
+
description: 'MySQL backing for the travetto model module, with real-time modeling support for SQL schemas.'
|
|
133
|
+
},
|
|
134
|
+
ModelPostgres: {
|
|
135
|
+
name:'@travetto/model-postgres', folder:'@travetto/model-postgres', displayName: 'PostgreSQL Model Service',
|
|
136
|
+
description: 'PostgreSQL backing for the travetto model module, with real-time modeling support for SQL schemas.'
|
|
137
|
+
},
|
|
138
|
+
ModelQuery: {
|
|
139
|
+
name:'@travetto/model-query', folder:'@travetto/model-query', displayName: 'Data Model Querying',
|
|
140
|
+
description: 'Datastore abstraction for advanced query support.'
|
|
141
|
+
},
|
|
142
|
+
ModelRedis: {
|
|
143
|
+
name:'@travetto/model-redis', folder:'@travetto/model-redis', displayName: 'Redis Model Support',
|
|
144
|
+
description: 'Redis backing for the travetto model module.'
|
|
145
|
+
},
|
|
146
|
+
ModelS3: {
|
|
147
|
+
name:'@travetto/model-s3', folder:'@travetto/model-s3', displayName: 'S3 Model Support',
|
|
148
|
+
description: 'S3 backing for the travetto model module.'
|
|
149
|
+
},
|
|
150
|
+
ModelSql: {
|
|
151
|
+
name:'@travetto/model-sql', folder:'@travetto/model-sql', displayName: 'SQL Model Service',
|
|
152
|
+
description: 'SQL backing for the travetto model module, with real-time modeling support for SQL schemas.'
|
|
153
|
+
},
|
|
154
|
+
ModelSqlite: {
|
|
155
|
+
name:'@travetto/model-sqlite', folder:'@travetto/model-sqlite', displayName: 'SQLite Model Service',
|
|
156
|
+
description: 'SQLite backing for the travetto model module, with real-time modeling support for SQL schemas.'
|
|
157
|
+
},
|
|
158
|
+
Openapi: {
|
|
159
|
+
name:'@travetto/openapi', folder:'@travetto/openapi', displayName: 'OpenAPI Specification',
|
|
160
|
+
description: 'OpenAPI integration support for the travetto framework'
|
|
161
|
+
},
|
|
162
|
+
Overview: {
|
|
163
|
+
name:'@travetto/overview', folder:'@travetto/overview', displayName: 'Overview Docs',
|
|
164
|
+
description: 'Documentation overview'
|
|
165
|
+
},
|
|
166
|
+
Pack: {
|
|
167
|
+
name:'@travetto/pack', folder:'@travetto/pack', displayName: 'Pack',
|
|
168
|
+
description: 'Code packing utilities'
|
|
169
|
+
},
|
|
170
|
+
Registry: {
|
|
171
|
+
name:'@travetto/registry', folder:'@travetto/registry', displayName: 'Registry',
|
|
172
|
+
description: 'Patterns and utilities for handling registration of metadata and functionality for run-time use'
|
|
173
|
+
},
|
|
174
|
+
Repo: {
|
|
175
|
+
name:'@travetto/repo', folder:'@travetto/repo', displayName: 'Repo',
|
|
176
|
+
description: 'Monorepo utilities'
|
|
177
|
+
},
|
|
178
|
+
Rest: {
|
|
179
|
+
name:'@travetto/rest', folder:'@travetto/rest', displayName: 'RESTful API',
|
|
180
|
+
description: 'Declarative api for RESTful APIs with support for the dependency injection module.'
|
|
181
|
+
},
|
|
182
|
+
RestAwsLambda: {
|
|
183
|
+
name:'@travetto/rest-aws-lambda', folder:'@travetto/rest-aws-lambda', displayName: 'RESTful AWS Lambda',
|
|
184
|
+
description: 'RESTful APIs entry point support for AWS Lambdas.'
|
|
185
|
+
},
|
|
186
|
+
RestExpress: {
|
|
187
|
+
name:'@travetto/rest-express', folder:'@travetto/rest-express', displayName: 'Express REST Source',
|
|
188
|
+
description: 'Express provider for the travetto rest module.'
|
|
189
|
+
},
|
|
190
|
+
RestExpressLambda: {
|
|
191
|
+
name:'@travetto/rest-express-lambda', folder:'@travetto/rest-express-lambda', displayName: 'Express REST AWS Lambda Source',
|
|
192
|
+
description: 'Express AWS Lambda provider for the travetto rest module.'
|
|
193
|
+
},
|
|
194
|
+
RestFastify: {
|
|
195
|
+
name:'@travetto/rest-fastify', folder:'@travetto/rest-fastify', displayName: 'Fastify REST Source',
|
|
196
|
+
description: 'Fastify provider for the travetto rest module.'
|
|
197
|
+
},
|
|
198
|
+
RestFastifyLambda: {
|
|
199
|
+
name:'@travetto/rest-fastify-lambda', folder:'@travetto/rest-fastify-lambda', displayName: 'Fastify REST AWS Lambda Source',
|
|
200
|
+
description: 'Fastify AWS Lambda provider for the travetto rest module.'
|
|
201
|
+
},
|
|
202
|
+
RestKoa: {
|
|
203
|
+
name:'@travetto/rest-koa', folder:'@travetto/rest-koa', displayName: 'Koa REST Source',
|
|
204
|
+
description: 'Koa provider for the travetto rest module.'
|
|
205
|
+
},
|
|
206
|
+
RestKoaLambda: {
|
|
207
|
+
name:'@travetto/rest-koa-lambda', folder:'@travetto/rest-koa-lambda', displayName: 'Koa REST AWS Lambda Source',
|
|
208
|
+
description: 'Koa provider for the travetto rest module.'
|
|
209
|
+
},
|
|
210
|
+
RestModel: {
|
|
211
|
+
name:'@travetto/rest-model', folder:'@travetto/rest-model', displayName: 'RESTful Model Routes',
|
|
212
|
+
description: 'RESTful support for generating APIs from Model classes.'
|
|
213
|
+
},
|
|
214
|
+
RestModelQuery: {
|
|
215
|
+
name:'@travetto/rest-model-query', folder:'@travetto/rest-model-query', displayName: 'RESTful Model Query Routes',
|
|
216
|
+
description: 'RESTful support for generating query APIs from Model classes.'
|
|
217
|
+
},
|
|
218
|
+
RestSession: {
|
|
219
|
+
name:'@travetto/rest-session', folder:'@travetto/rest-session', displayName: 'REST Session',
|
|
220
|
+
description: 'Session provider for the travetto rest module.'
|
|
221
|
+
},
|
|
222
|
+
Scaffold: {
|
|
223
|
+
name:'@travetto/scaffold', folder:'@travetto/scaffold', displayName: 'App Scaffold',
|
|
224
|
+
description: 'App Scaffold for the Travetto framework'
|
|
225
|
+
},
|
|
226
|
+
Schema: {
|
|
227
|
+
name:'@travetto/schema', folder:'@travetto/schema', displayName: 'Schema',
|
|
228
|
+
description: 'Data type registry for runtime validation, reflection and binding.'
|
|
229
|
+
},
|
|
230
|
+
SchemaFaker: {
|
|
231
|
+
name:'@travetto/schema-faker', folder:'@travetto/schema-faker', displayName: 'Schema Faker',
|
|
232
|
+
description: 'Data generation for schema-registered objects.'
|
|
233
|
+
},
|
|
234
|
+
Terminal: {
|
|
235
|
+
name:'@travetto/terminal', folder:'@travetto/terminal', displayName: 'Terminal',
|
|
236
|
+
description: 'General terminal support'
|
|
237
|
+
},
|
|
238
|
+
Test: {
|
|
239
|
+
name:'@travetto/test', folder:'@travetto/test', displayName: 'Testing',
|
|
240
|
+
description: 'Declarative test framework'
|
|
241
|
+
},
|
|
242
|
+
TodoApp: {
|
|
243
|
+
name:'@travetto/todo-app', folder:'@travetto/todo-app', displayName: 'Todo Application',
|
|
244
|
+
description: ''
|
|
245
|
+
},
|
|
246
|
+
Transformer: {
|
|
247
|
+
name:'@travetto/transformer', folder:'@travetto/transformer', displayName: 'Transformation',
|
|
248
|
+
description: 'Functionality for AST transformations, with transformer registration, and general utils'
|
|
249
|
+
},
|
|
250
|
+
Worker: {
|
|
251
|
+
name:'@travetto/worker', folder:'@travetto/worker', displayName: 'Worker',
|
|
252
|
+
description: 'Process management utilities, with a focus on inter-process communication'
|
|
253
|
+
},
|
|
254
|
+
Yaml: {
|
|
255
|
+
name:'@travetto/yaml', folder:'@travetto/yaml', displayName: 'YAML',
|
|
256
|
+
description: 'Simple YAML support, provides only clean subset of yaml'
|
|
257
|
+
}
|
|
258
|
+
};
|
package/src/mod.ts
CHANGED
|
@@ -1,73 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { node } from './nodes';
|
|
2
|
+
import { MOD_MAPPING } from './mod-mapping';
|
|
2
3
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
Asset: '@travetto/asset',
|
|
6
|
-
AssetRest: '@travetto/asset-rest',
|
|
7
|
-
Auth: '@travetto/auth',
|
|
8
|
-
AuthRest: '@travetto/auth-rest',
|
|
9
|
-
AuthRestContext: '@travetto/auth-rest-context',
|
|
10
|
-
AuthRestJwt: '@travetto/auth-rest-jwt',
|
|
11
|
-
AuthRestSession: '@travetto/auth-rest-session',
|
|
12
|
-
AuthRestPassport: '@travetto/auth-rest-passport',
|
|
13
|
-
Base: '@travetto/base',
|
|
14
|
-
Boot: '@travetto/boot',
|
|
15
|
-
Cache: '@travetto/cache',
|
|
16
|
-
Cli: '@travetto/cli',
|
|
17
|
-
Command: '@travetto/command',
|
|
18
|
-
Compiler: '@travetto/compiler',
|
|
19
|
-
Config: '@travetto/config',
|
|
20
|
-
Context: '@travetto/context',
|
|
21
|
-
Di: '@travetto/di',
|
|
22
|
-
Doc: '@travetto/doc',
|
|
23
|
-
Email: '@travetto/email',
|
|
24
|
-
EmailNodemailer: '@travetto/email-nodemailer',
|
|
25
|
-
EmailTemplate: '@travetto/email-template',
|
|
26
|
-
Image: '@travetto/image',
|
|
27
|
-
Jwt: '@travetto/jwt',
|
|
28
|
-
Log: '@travetto/log',
|
|
29
|
-
Model: '@travetto/model',
|
|
30
|
-
ModelDynamodb: '@travetto/model-dynamodb',
|
|
31
|
-
ModelElasticsearch: '@travetto/model-elasticsearch',
|
|
32
|
-
ModelFirestore: '@travetto/model-firestore',
|
|
33
|
-
ModelMongo: '@travetto/model-mongo',
|
|
34
|
-
ModelQuery: '@travetto/model-query',
|
|
35
|
-
ModelRedis: '@travetto/model-redis',
|
|
36
|
-
ModelS3: '@travetto/model-s3',
|
|
37
|
-
ModelSQLite: '@travetto/model-sqlite',
|
|
38
|
-
ModelPostgres: '@travetto/model-postgres',
|
|
39
|
-
ModelMysql: '@travetto/model-mysql',
|
|
40
|
-
ModelSql: '@travetto/model-sql',
|
|
41
|
-
Openapi: '@travetto/openapi',
|
|
42
|
-
Pack: '@travetto/pack',
|
|
43
|
-
Registry: '@travetto/registry',
|
|
44
|
-
Rest: '@travetto/rest',
|
|
45
|
-
RestAwsLambda: '@travetto/rest-aws-lambda',
|
|
46
|
-
RestExpress: '@travetto/rest-express',
|
|
47
|
-
RestExpressLambda: '@travetto/rest-express-lambda',
|
|
48
|
-
RestFastify: '@travetto/rest-fastify',
|
|
49
|
-
RestFastifyLambda: '@travetto/rest-fastify-lambda',
|
|
50
|
-
RestKoa: '@travetto/rest-koa',
|
|
51
|
-
RestKoaLambda: '@travetto/rest-koa-lambda',
|
|
52
|
-
RestModel: '@travetto/rest-model',
|
|
53
|
-
RestModelQuery: '@travetto/rest-model-query',
|
|
54
|
-
RestSession: '@travetto/rest-session',
|
|
55
|
-
Scaffold: '@travetto/scaffold',
|
|
56
|
-
Schema: '@travetto/schema',
|
|
57
|
-
SchemaFaker: '@travetto/schema-faker',
|
|
58
|
-
Test: '@travetto/test',
|
|
59
|
-
Transformer: '@travetto/transformer',
|
|
60
|
-
Watch: '@travetto/watch',
|
|
61
|
-
Worker: '@travetto/worker',
|
|
62
|
-
Yaml: '@travetto/yaml'
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
export const mod = new Proxy<Record<keyof typeof MAPPING, AllTypeMap['Mod']>>(
|
|
66
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
67
|
-
{} as Record<keyof typeof MAPPING, AllTypeMap['Mod']>,
|
|
68
|
-
{
|
|
69
|
-
get(tgt, p: keyof typeof MAPPING): AllTypeMap['Mod'] {
|
|
70
|
-
return node.Mod(MAPPING[p]);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
4
|
+
export const mod = Object.fromEntries(
|
|
5
|
+
Object.entries(MOD_MAPPING).map(([k, v]) => [k, node.Mod(v.name, v)])
|
|
73
6
|
);
|
package/src/nodes.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { existsSync } from 'fs';
|
|
2
|
+
|
|
3
|
+
import { path, RootIndex, PackageUtil } from '@travetto/manifest';
|
|
3
4
|
|
|
4
5
|
import { FileUtil, } from './util/file';
|
|
5
6
|
import { DocRunUtil, RunConfig } from './util/run';
|
|
@@ -158,25 +159,30 @@ export const node = {
|
|
|
158
159
|
*/
|
|
159
160
|
Execute: (title: Content, cmd: string, args: string[] = [], cfg: RunConfig = {}) => {
|
|
160
161
|
if (cmd !== 'trv') {
|
|
161
|
-
cmd = FileUtil.resolveFile(cmd).
|
|
162
|
+
cmd = FileUtil.resolveFile(cmd).replace(path.cwd(), '.');
|
|
162
163
|
}
|
|
163
164
|
|
|
164
165
|
const script = DocRunUtil.run(cmd, args, cfg);
|
|
165
|
-
const prefix = !/.*\/doc\/.*[.]ts$/.test(cmd) ? '$' :
|
|
166
|
-
`$ node @travetto/${cfg.module ?? 'base'}/bin/main`;
|
|
166
|
+
const prefix = !/.*\/doc\/.*[.]ts$/.test(cmd) ? '$' : '$ node ';
|
|
167
167
|
|
|
168
168
|
return node.Terminal(title, `${prefix} ${cmd} ${args.join(' ')}\n\n${script}`);
|
|
169
169
|
},
|
|
170
170
|
|
|
171
171
|
/**
|
|
172
172
|
* Node Module Reference
|
|
173
|
-
* @param
|
|
174
|
-
*/
|
|
175
|
-
Mod(folder: string) {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
173
|
+
* @param name
|
|
174
|
+
*/
|
|
175
|
+
Mod(name: string, cfg?: { folder: string, displayName: string, description: string }) {
|
|
176
|
+
if (!cfg) {
|
|
177
|
+
const folder = RootIndex.getModule(name)!.source;
|
|
178
|
+
const pkg = PackageUtil.readPackage(folder);
|
|
179
|
+
cfg = {
|
|
180
|
+
folder,
|
|
181
|
+
displayName: pkg.travetto!.displayName!,
|
|
182
|
+
description: pkg.description!
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
return $n('mod', { title: $c(cfg.displayName), link: $c(cfg.folder), description: $c(cfg.description), name: $c(name) });
|
|
180
186
|
},
|
|
181
187
|
|
|
182
188
|
/**
|
|
@@ -184,7 +190,10 @@ export const node = {
|
|
|
184
190
|
* @param title
|
|
185
191
|
* @param file
|
|
186
192
|
*/
|
|
187
|
-
Ref: (title: Content, file: string) => {
|
|
193
|
+
Ref: (title: Content, file: string | Function) => {
|
|
194
|
+
if (typeof file === 'function') {
|
|
195
|
+
file = RootIndex.getFunctionMetadata(file)!.source;
|
|
196
|
+
}
|
|
188
197
|
const res = ResolveUtil.resolveRef(title, file);
|
|
189
198
|
return $n('ref', { title: $c(res.title), link: $c(res.file), line: res.line });
|
|
190
199
|
},
|
|
@@ -196,7 +205,10 @@ export const node = {
|
|
|
196
205
|
* @param outline
|
|
197
206
|
* @param language
|
|
198
207
|
*/
|
|
199
|
-
Code: (title: Content, content: Content, outline = false, language = 'typescript') => {
|
|
208
|
+
Code: (title: Content, content: Content | Function, outline = false, language = 'typescript') => {
|
|
209
|
+
if (typeof content === 'function') {
|
|
210
|
+
content = RootIndex.getFunctionMetadata(content)!.source;
|
|
211
|
+
}
|
|
200
212
|
const res = ResolveUtil.resolveCode(content, language, outline);
|
|
201
213
|
return $n('code', { title: $c(title), content: $c(res.content), language: res.language, file: $c(res.file) });
|
|
202
214
|
},
|
|
@@ -217,8 +229,13 @@ export const node = {
|
|
|
217
229
|
* @param install
|
|
218
230
|
* @param pkg
|
|
219
231
|
*/
|
|
220
|
-
Header: (
|
|
221
|
-
|
|
232
|
+
Header: (mod?: string, install = true) => {
|
|
233
|
+
if (!mod) {
|
|
234
|
+
mod = RootIndex.mainPackage.name;
|
|
235
|
+
}
|
|
236
|
+
const pkg = PackageUtil.readPackage(RootIndex.getModule(mod)!.source);
|
|
237
|
+
return $n('header', { title: $c(pkg.travetto?.displayName ?? pkg.name), description: $c(pkg.description), package: pkg.name, install });
|
|
238
|
+
},
|
|
222
239
|
|
|
223
240
|
/**
|
|
224
241
|
* Comment
|
|
@@ -235,7 +252,10 @@ export const node = {
|
|
|
235
252
|
* @param endPattern
|
|
236
253
|
* @param outline
|
|
237
254
|
*/
|
|
238
|
-
Snippet: (title: Content, file: string, startPattern: RegExp, endPattern?: RegExp, outline?: boolean) => {
|
|
255
|
+
Snippet: (title: Content, file: string | Function, startPattern: RegExp, endPattern?: RegExp, outline?: boolean) => {
|
|
256
|
+
if (typeof file !== 'string') {
|
|
257
|
+
file = RootIndex.getFunctionMetadata(file)!.source;
|
|
258
|
+
}
|
|
239
259
|
const res = ResolveUtil.resolveSnippet(file, startPattern, endPattern, outline);
|
|
240
260
|
return $n('code', {
|
|
241
261
|
title: $c(title), content: $c(res.text), line: res.line, file: $c(res.file), language: res.language,
|
|
@@ -284,7 +304,7 @@ export const node = {
|
|
|
284
304
|
* @param file
|
|
285
305
|
*/
|
|
286
306
|
Image: (title: Content, file: string) => {
|
|
287
|
-
if (!/^https?:/.test(file) && !
|
|
307
|
+
if (!/^https?:/.test(file) && !existsSync(file)) {
|
|
288
308
|
throw new Error(`${file} is not a valid location`);
|
|
289
309
|
}
|
|
290
310
|
return $n('image', { title: $c(title), link: $c(file) });
|