@oak-digital/types-4-strapi-2 0.2.7 → 0.2.8
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 +17 -13
- package/lib/index.js +3 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
# types-4-strapi-2
|
|
2
2
|
|
|
3
|
-
types-4-strapi-2 is a
|
|
4
|
-
This can be useful if you have a frontend written with
|
|
3
|
+
types-4-strapi-2 is a TypeScript program that will generate TypeScript types for your strapi projects.
|
|
4
|
+
This can be useful if you have a frontend written with TypeScript to make sure you are using the correct types and can help report errors at compile time.
|
|
5
5
|
|
|
6
|
-
types-4-strapi-2 is a rewrite of
|
|
6
|
+
types-4-strapi-2 is a rewrite of [francescolorenzetti/types-4-strapi](https://github.com/francescolorenzetti/types-4-strapi) written in TypeScript, with the goal of being much easier to extend and maintain.
|
|
7
7
|
|
|
8
8
|
## Getting started
|
|
9
9
|
|
|
10
10
|
Install the script for your project:
|
|
11
11
|
|
|
12
12
|
```bash
|
|
13
|
+
# NPM
|
|
13
14
|
npm install --save-dev @oak-digital/types-4-strapi-2
|
|
15
|
+
# YARN
|
|
16
|
+
yarn add -D @oak-digital/types-4-strapi-2
|
|
14
17
|
```
|
|
15
18
|
|
|
16
19
|
Then set up a script in your `package.json`
|
|
@@ -38,8 +41,8 @@ This can be done with the `--out` flag like in the following example.
|
|
|
38
41
|
|
|
39
42
|
## Features
|
|
40
43
|
|
|
41
|
-
* Generate
|
|
42
|
-
* Generate
|
|
44
|
+
* Generate TypeScript interfaces for all your api content-types and components
|
|
45
|
+
* Generate TypeScript interfaces for builtin types such as `Media` and `MediaFormat`
|
|
43
46
|
* Select input and output directory
|
|
44
47
|
* Prettier formatting and ability to use your own `.prettierrc`.
|
|
45
48
|
|
|
@@ -50,13 +53,14 @@ This can be done with the `--out` flag like in the following example.
|
|
|
50
53
|
|
|
51
54
|
## Flags
|
|
52
55
|
|
|
53
|
-
| **
|
|
54
|
-
|
|
55
|
-
| -i, --in <dir> | The src directory for strapi
|
|
56
|
-
| -o, --out <dir> | The output directory to output the types to
|
|
57
|
-
|
|
|
58
|
-
|
|
|
59
|
-
| --
|
|
56
|
+
| **Flag** | **Description** | **Default** |
|
|
57
|
+
|-----------------------------|--------------------------------------------------------------------------------------|-------------|
|
|
58
|
+
| -i, --in <dir> | The src directory for strapi | `./src` |
|
|
59
|
+
| -o, --out <dir> | The output directory to output the types to | `./types` |
|
|
60
|
+
| -prefix | A prefix for all generated interfaces | `I` |
|
|
61
|
+
| --component-prefix <prefix> | A prefix for components | none |
|
|
62
|
+
| -D, --delete-old | CAUTION: This option is equivalent to running `rm -rf` on the output directory first | `false` |
|
|
63
|
+
| --prettier <file> | The prettier config file to use for formatting TypeScript interfaces | none |
|
|
60
64
|
|
|
61
65
|
## Building
|
|
62
66
|
|
|
@@ -66,7 +70,7 @@ To build this project, use the following command
|
|
|
66
70
|
npm run build
|
|
67
71
|
```
|
|
68
72
|
|
|
69
|
-
##
|
|
73
|
+
## Publishing
|
|
70
74
|
|
|
71
75
|
```bash
|
|
72
76
|
npm run build
|
package/lib/index.js
CHANGED
|
@@ -10,6 +10,7 @@ commander_1.program
|
|
|
10
10
|
commander_1.program
|
|
11
11
|
.option('-i, --in <dir>', 'The src directory for strapi', './src')
|
|
12
12
|
.option('-o, --out <dir>', 'The output directory to output the types to', './types')
|
|
13
|
+
.option('--prefix <prefix>', 'A prefix for all generated interfaces', 'I')
|
|
13
14
|
.option('--component-prefix <prefix>', 'A prefix for components', '')
|
|
14
15
|
.option('-D, --delete-old', 'CAUTION: This option is equivalent to running rm -rf on the output directory first')
|
|
15
16
|
.option('--file-case <case>', 'Which case to use for generated files', 'pascal')
|
|
@@ -17,9 +18,10 @@ commander_1.program
|
|
|
17
18
|
.option('--prettier <file>', 'The prettier config file to use for formatting typescript interfaces');
|
|
18
19
|
commander_1.program.parse();
|
|
19
20
|
var options = commander_1.program.opts();
|
|
20
|
-
var input = options.in, out = options.out, componentPrefix = options.componentPrefix, prettierFile = options.prettier, deleteOld = options.deleteOld, fileCaseType = options.fileCase, folderCaseType = options.folderCase;
|
|
21
|
+
var input = options.in, out = options.out, componentPrefix = options.componentPrefix, prefix = options.prefix, prettierFile = options.prettier, deleteOld = options.deleteOld, fileCaseType = options.fileCase, folderCaseType = options.folderCase;
|
|
21
22
|
var manager = new InterfaceManager_1.default(out, input, {
|
|
22
23
|
componentPrefix: componentPrefix,
|
|
24
|
+
prefix: prefix,
|
|
23
25
|
prettierFile: prettierFile,
|
|
24
26
|
deleteOld: deleteOld,
|
|
25
27
|
fileCaseType: fileCaseType,
|