@travetto/openapi 2.0.5 → 2.1.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/README.md CHANGED
@@ -67,7 +67,7 @@ export class ApiSpecConfig {
67
67
  /**
68
68
  * Should file be generated at runtime
69
69
  */
70
- persist: boolean = !EnvUtil.isReadonly();
70
+ persist: boolean = EnvUtil.isDynamic();
71
71
  /**
72
72
  * Skip emitting all routes
73
73
  */
@@ -122,7 +122,7 @@ The module provides a plugin for the [Command Line Interface](https://github.com
122
122
  ```bash
123
123
  $ trv openapi:client --help
124
124
 
125
- Usage: openapi:client [options] [forma]
125
+ Usage: openapi:client [options] [format-or-preset]
126
126
 
127
127
  Options:
128
128
  -x, --extended-help Show Extended Help
@@ -135,10 +135,10 @@ Options:
135
135
 
136
136
  Available Presets
137
137
  ----------------------------------
138
- * @trv/angular10 -- typescript-angular supportsES6=true,ngVersion=10.0
139
- * @trv/angular11 -- typescript-angular supportsES6=true,ngVersion=11.0
140
- * @trv/angular12 -- typescript-angular supportsES6=true,ngVersion=11.0
141
- * @trv/fetch -- typescript-fetch
138
+ * @trv:angular10 -- typescript-angular supportsES6=true,ngVersion=10.0
139
+ * @trv:angular11 -- typescript-angular supportsES6=true,ngVersion=11.0
140
+ * @trv:angular12 -- typescript-angular supportsES6=true,ngVersion=11.0
141
+ * @trv:fetch -- typescript-fetch
142
142
  ```
143
143
 
144
144
  This tool relies upon a custom build of [OpenAPI client generation tools](https://github.com/OpenAPITools/openapi-generator), which supports watching. This allows for fast responsive client generation as the shape of the API changes.
@@ -1,11 +1,12 @@
1
1
  import * as path from 'path';
2
- import * as fs from 'fs';
2
+ import * as fs from 'fs/promises';
3
+ import { readFileSync } from 'fs';
3
4
 
4
5
  import { BasePlugin } from '@travetto/cli/src/plugin-base';
5
6
  import { AppCache, ExecUtil, PathUtil } from '@travetto/boot';
6
7
  import { color } from '@travetto/cli/src/color';
7
8
 
8
- const presets = JSON.parse(fs.readFileSync(PathUtil.resolveUnix(__dirname, '..', 'resources', 'presets.json'), 'utf8')) as Record<string, [string, object] | [string]>;
9
+ const presets = JSON.parse(readFileSync(PathUtil.resolveUnix(__dirname, '..', 'resources', 'presets.json'), 'utf8')) as Record<string, [string, object] | [string]>;
9
10
 
10
11
  /**
11
12
  * CLI for generating the cli client
@@ -49,7 +50,7 @@ export class OpenApiClientPlugin extends BasePlugin {
49
50
  const presetEntries = Object
50
51
  .entries(presets)
51
52
  .sort(([a], [b]) => a.localeCompare(b))
52
- .map(([k, [cmd, v]]) => [`@trv/${k}`.padEnd(presetLen + 5), [cmd, this.presetMap(v)]] as const);
53
+ .map(([k, [cmd, v]]) => [`@trv:${k}`.padEnd(presetLen + 5), [cmd, this.presetMap(v)]] as const);
53
54
 
54
55
  const presetText = color`
55
56
  ${{ subtitle: 'Available Presets' }}
@@ -65,7 +66,7 @@ ${this.getListOfFormats().map(x => color`* ${{ input: x }}`).join('\n')} `;
65
66
  }
66
67
 
67
68
  getArgs() {
68
- return '[format or preset]';
69
+ return '[format-or-preset]';
69
70
  }
70
71
 
71
72
  async action(format: string) {
@@ -74,7 +75,7 @@ ${this.getListOfFormats().map(x => color`* ${{ input: x }}`).join('\n')} `;
74
75
  }
75
76
 
76
77
  // Ensure its there
77
- await fs.promises.mkdir(this.cmd.output, { recursive: true });
78
+ await fs.mkdir(this.cmd.output, { recursive: true });
78
79
 
79
80
  let propMap = Object.fromEntries(this.cmd.props?.map(p => p.split('=')) ?? []);
80
81
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@travetto/openapi",
3
3
  "displayName": "OpenAPI Specification",
4
- "version": "2.0.5",
4
+ "version": "2.1.1",
5
5
  "description": "OpenAPI integration support for the travetto framework",
6
6
  "keywords": [
7
7
  "rest",
@@ -28,14 +28,14 @@
28
28
  "directory": "module/openapi"
29
29
  },
30
30
  "dependencies": {
31
- "@travetto/config": "^2.0.3",
32
- "@travetto/rest": "^2.0.3",
33
- "@travetto/schema": "^2.0.5",
34
- "@travetto/yaml": "^2.0.2",
35
- "openapi3-ts": "^2.0.1"
31
+ "@travetto/config": "^2.1.1",
32
+ "@travetto/rest": "^2.1.1",
33
+ "@travetto/schema": "^2.1.1",
34
+ "@travetto/yaml": "^2.1.1",
35
+ "openapi3-ts": "^2.0.2"
36
36
  },
37
37
  "optionalPeerDependencies": {
38
- "@travetto/cli": "^2.0.2"
38
+ "@travetto/cli": "^2.1.1"
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public"
package/src/config.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as path from 'path';
2
- import * as fs from 'fs';
2
+ import * as fs from 'fs/promises';
3
3
  import { ServerObject, ContactObject, LicenseObject } from 'openapi3-ts/src/model/OpenApi';
4
4
 
5
5
  import { Config } from '@travetto/config';
@@ -65,7 +65,7 @@ export class ApiSpecConfig {
65
65
  if (!/[.](json|ya?ml)$/.test(this.output)) { // Assume a folder
66
66
  this.output = PathUtil.resolveUnix(this.output, 'openapi.yml');
67
67
  }
68
- await fs.promises.mkdir(path.dirname(this.output), { recursive: true });
68
+ await fs.mkdir(path.dirname(this.output), { recursive: true });
69
69
  }
70
70
  }
71
71
  }