@travetto/doc 3.0.0-rc.2 → 3.0.0-rc.20

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 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/doc.ts and execute "npx trv doc" to rebuild -->
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', 'docs/test.ts')}
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: T | (() => (T | Promise<T>));
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 Content
84
+ * `Text` - Simple Text Contentf
85
85
 
86
86
  ## Libraries
87
87
 
@@ -102,31 +102,29 @@ $ trv doc --help
102
102
  Usage: doc [options]
103
103
 
104
104
  Options:
105
- -i, --input <input> Input File (default: "doc.ts")
106
- -o, --output <output> Output files (default: [])
107
- -f, --format <format> Format (default: "md")
108
- -w, --watch Watch
109
- -h, --help display help for command
105
+ -i, --input <input> Input File (default: "DOC.ts")
106
+ -o, --outputs <outputs> Outputs (default: [])
107
+ -w, --watch Watch
108
+ -h, --help display help for command
110
109
  ```
111
110
 
112
111
  By default, running the command will output the [Markdown](https://en.wikipedia.org/wiki/Markdown) content directly to the terminal.
113
112
 
114
113
  **Terminal: Sample CLI Output**
115
114
  ```bash
116
- $ trv doc -i docs/sample/doc.ts -f html
115
+ $ trv doc -o html
117
116
 
118
117
  <!-- 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
-
118
+ <!-- Please modify @travetto/doc/doc-exec/DOC.ts and execute "npx trv doc" to rebuild -->
119
+ <h1>@travetto-doc/doc
120
+
123
121
  </h1>
124
122
 
125
123
  <figure class="install">
126
- <figcaption class="install">Install @travetto/doc
124
+ <figcaption class="install">Install @travetto-doc/doc
127
125
 
128
126
  </figcaption>
129
- <pre><code class="language-bash"><span class="token function">npm</span> <span class="token function">install</span> @travetto/doc</code></pre>
127
+ <pre><code class="language-bash"><span class="token function">npm</span> <span class="token function">install</span> @travetto-doc/doc</code></pre>
130
128
  </figure>
131
129
 
132
130
  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.
@@ -139,7 +137,7 @@ Sample documentation for fictional module. This module fictitiously relies upon
139
137
 
140
138
  <figure class="code">
141
139
  <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>
140
+ <cite><a target="_blank" href="@travetto/doc/doc-exec/src/test.ts">Source</a></cite>
143
141
  </figcaption>
144
142
  <pre><code class="language-typescript"><span class="token keyword">class</span> <span class="token class-name">TestFile</span> <span class="token punctuation">{{'{'}}</span>
145
143
  <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>
@@ -157,14 +155,13 @@ Sample documentation for fictional module. This module fictitiously relies upon
157
155
  Usage: <span class="token punctuation">[</span>options<span class="token punctuation">]</span> <span class="token punctuation">[</span>command<span class="token punctuation">]</span>
158
156
 
159
157
  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>
158
+ -V, <span class="token parameter variable">--version</span> output the version number
159
+ -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
160
 
163
161
  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
162
  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>
163
+ main <span class="token operator">&lt;</span>fileOrImport<span class="token operator">></span> <span class="token punctuation">[</span>args<span class="token punctuation">..</span>.<span class="token punctuation">]</span>
164
+ <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
165
  </figure>
166
+ Wrote docs for DOC.ts
170
167
  ```
package/package.json CHANGED
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/doc",
3
- "displayName": "Documentation",
4
- "version": "3.0.0-rc.2",
3
+ "version": "3.0.0-rc.20",
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
- "bin",
19
- "index.ts",
20
- "src"
17
+ "__index__.ts",
18
+ "src",
19
+ "support"
21
20
  ],
22
- "main": "index.ts",
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.2",
27
+ "@travetto/base": "^3.0.0-rc.20",
28
+ "@types/prismjs": "^1.26.0",
29
29
  "prismjs": "^1.29.0"
30
30
  },
31
31
  "peerDependencies": {
32
- "@travetto/cli": "^3.0.0-rc.2"
32
+ "@travetto/cli": "^3.0.0-rc.23"
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 | { ᚕfile: string, name: string } | string)[]): 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
- 'ᚕfile' in el ? node.Ref(el.name.replace(/[$]/, ''), el.ᚕfile) : el
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
+ Eslint: {
91
+ name:'@travetto/eslint', folder:'@travetto/eslint', 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 { AllTypeMap, node } from './nodes';
1
+ import { node } from './nodes';
2
+ import { MOD_MAPPING } from './mod-mapping';
2
3
 
3
- const MAPPING = {
4
- App: '@travetto/app',
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 { PathUtil, Package, FsUtil } from '@travetto/boot';
2
- import { readPackage } from '@travetto/boot/src/internal/package';
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';
@@ -18,6 +19,8 @@ const $n = <T extends string, U extends Record<string, unknown>>(t: T, values: U
18
19
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
19
20
  ({ _type: t, ...values } as { _type: T } & U);
20
21
 
22
+ type FormattedCommand = { formatCommand?(cmd: string, args: string[]): string };
23
+
21
24
  /* eslint-disable @typescript-eslint/explicit-function-return-type */
22
25
 
23
26
  /**
@@ -156,27 +159,34 @@ export const node = {
156
159
  * @param args
157
160
  * @param cfg
158
161
  */
159
- Execute: (title: Content, cmd: string, args: string[] = [], cfg: RunConfig = {}) => {
162
+ Execute: (title: Content, cmd: string, args: string[] = [], cfg: RunConfig & FormattedCommand = {}) => {
160
163
  if (cmd !== 'trv') {
161
- cmd = FileUtil.resolveFile(cmd).resolved.replace(PathUtil.cwd, '.');
164
+ cmd = FileUtil.resolveFile(cmd).replace(path.cwd(), '.');
162
165
  }
163
166
 
164
167
  const script = DocRunUtil.run(cmd, args, cfg);
165
- const prefix = !/.*\/doc\/.*[.]ts$/.test(cmd) ? '$' :
166
- `$ node @travetto/${cfg.module ?? 'base'}/bin/main`;
168
+ const prefix = !/.*\/doc\/.*[.]ts$/.test(cmd) ? '$' : '$ node ';
169
+
170
+ const commandDisplay = cfg.formatCommand?.(cmd, args) ?? `${cmd} ${args.join(' ')}`;
167
171
 
168
- return node.Terminal(title, `${prefix} ${cmd} ${args.join(' ')}\n\n${script}`);
172
+ return node.Terminal(title, `${prefix} ${commandDisplay}\n\n${script}`);
169
173
  },
170
174
 
171
175
  /**
172
176
  * Node Module Reference
173
- * @param folder
174
- */
175
- Mod(folder: string) {
176
- folder = PathUtil.resolveFrameworkPath(PathUtil.resolveUnix('node_modules', folder));
177
-
178
- const { description, displayName } = readPackage(folder);
179
- return $n('mod', { title: $c(displayName!), link: $c(folder), description: $c(description!) });
177
+ * @param name
178
+ */
179
+ Mod(name: string, cfg?: { folder: string, displayName: string, description: string }) {
180
+ if (!cfg) {
181
+ const folder = RootIndex.getModule(name)!.sourcePath;
182
+ const pkg = PackageUtil.readPackage(folder);
183
+ cfg = {
184
+ folder,
185
+ displayName: pkg.travetto!.displayName!,
186
+ description: pkg.description!
187
+ };
188
+ }
189
+ return $n('mod', { title: $c(cfg.displayName), link: $c(cfg.folder), description: $c(cfg.description), name: $c(name) });
180
190
  },
181
191
 
182
192
  /**
@@ -184,7 +194,10 @@ export const node = {
184
194
  * @param title
185
195
  * @param file
186
196
  */
187
- Ref: (title: Content, file: string) => {
197
+ Ref: (title: Content, file: string | Function) => {
198
+ if (typeof file === 'function') {
199
+ file = RootIndex.getFunctionMetadata(file)!.source;
200
+ }
188
201
  const res = ResolveUtil.resolveRef(title, file);
189
202
  return $n('ref', { title: $c(res.title), link: $c(res.file), line: res.line });
190
203
  },
@@ -196,7 +209,10 @@ export const node = {
196
209
  * @param outline
197
210
  * @param language
198
211
  */
199
- Code: (title: Content, content: Content, outline = false, language = 'typescript') => {
212
+ Code: (title: Content, content: Content | Function, outline = false, language = 'typescript') => {
213
+ if (typeof content === 'function') {
214
+ content = RootIndex.getFunctionMetadata(content)!.source;
215
+ }
200
216
  const res = ResolveUtil.resolveCode(content, language, outline);
201
217
  return $n('code', { title: $c(title), content: $c(res.content), language: res.language, file: $c(res.file) });
202
218
  },
@@ -217,8 +233,13 @@ export const node = {
217
233
  * @param install
218
234
  * @param pkg
219
235
  */
220
- Header: (install = true, pkg = Package) =>
221
- $n('header', { title: $c(pkg.displayName ?? pkg.name), description: $c(pkg.description), package: pkg.name, install }),
236
+ Header: (mod?: string, install = true) => {
237
+ if (!mod) {
238
+ mod = RootIndex.mainPackage.name;
239
+ }
240
+ const pkg = PackageUtil.readPackage(RootIndex.getModule(mod)!.sourcePath);
241
+ return $n('header', { title: $c(pkg.travetto?.displayName ?? pkg.name), description: $c(pkg.description), package: pkg.name, install });
242
+ },
222
243
 
223
244
  /**
224
245
  * Comment
@@ -235,7 +256,10 @@ export const node = {
235
256
  * @param endPattern
236
257
  * @param outline
237
258
  */
238
- Snippet: (title: Content, file: string, startPattern: RegExp, endPattern?: RegExp, outline?: boolean) => {
259
+ Snippet: (title: Content, file: string | Function, startPattern: RegExp, endPattern?: RegExp, outline?: boolean) => {
260
+ if (typeof file !== 'string') {
261
+ file = RootIndex.getFunctionMetadata(file)!.source;
262
+ }
239
263
  const res = ResolveUtil.resolveSnippet(file, startPattern, endPattern, outline);
240
264
  return $n('code', {
241
265
  title: $c(title), content: $c(res.text), line: res.line, file: $c(res.file), language: res.language,
@@ -284,7 +308,7 @@ export const node = {
284
308
  * @param file
285
309
  */
286
310
  Image: (title: Content, file: string) => {
287
- if (!/^https?:/.test(file) && !FsUtil.existsSync(file)) {
311
+ if (!/^https?:/.test(file) && !existsSync(file)) {
288
312
  throw new Error(`${file} is not a valid location`);
289
313
  }
290
314
  return $n('image', { title: $c(title), link: $c(file) });