@apso/cli 0.0.4 → 0.0.43
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/LICENSE +21 -0
- package/README.md +313 -53
- package/bin/dev +17 -0
- package/bin/dev.cmd +3 -0
- package/bin/run +3 -3
- package/dist/commands/server/new.d.ts +22 -0
- package/dist/commands/server/new.js +105 -0
- package/dist/commands/server/scaffold.d.ts +14 -0
- package/dist/commands/server/scaffold.js +60 -0
- package/dist/index.d.ts +1 -0
- package/{lib → dist}/index.js +3 -2
- package/dist/lib/apsorc-parser.d.ts +26 -0
- package/dist/lib/apsorc-parser.js +65 -0
- package/dist/lib/base-command.d.ts +4 -0
- package/dist/lib/base-command.js +24 -0
- package/dist/lib/controller.d.ts +2 -0
- package/dist/lib/controller.js +36 -0
- package/dist/lib/dto.d.ts +7 -0
- package/dist/lib/dto.js +49 -0
- package/dist/lib/entity.d.ts +2 -0
- package/dist/lib/entity.js +43 -0
- package/dist/lib/enums.d.ts +6 -0
- package/dist/lib/enums.js +31 -0
- package/dist/lib/gql-dto.d.ts +3 -0
- package/dist/lib/gql-dto.js +43 -0
- package/dist/lib/index-module.d.ts +2 -0
- package/dist/lib/index-module.js +18 -0
- package/dist/lib/index.d.ts +10 -0
- package/dist/lib/index.js +21 -0
- package/dist/lib/module.d.ts +1 -0
- package/dist/lib/module.js +28 -0
- package/dist/lib/service.d.ts +1 -0
- package/dist/lib/service.js +24 -0
- package/dist/lib/templates/entities/entity-col-array.eta +12 -0
- package/dist/lib/templates/entities/entity-col-bigint.eta +11 -0
- package/dist/lib/templates/entities/entity-col-bigserial.eta +12 -0
- package/dist/lib/templates/entities/entity-col-boolean.eta +11 -0
- package/dist/lib/templates/entities/entity-col-bytea.eta +11 -0
- package/dist/lib/templates/entities/entity-col-char.eta +15 -0
- package/dist/lib/templates/entities/entity-col-date.eta +8 -0
- package/dist/lib/templates/entities/entity-col-decimal.eta +11 -0
- package/dist/lib/templates/entities/entity-col-double.eta +11 -0
- package/dist/lib/templates/entities/entity-col-enum.eta +12 -0
- package/dist/lib/templates/entities/entity-col-float.eta +7 -0
- package/dist/lib/templates/entities/entity-col-inet.eta +11 -0
- package/dist/lib/templates/entities/entity-col-int4range.eta +34 -0
- package/dist/lib/templates/entities/entity-col-integer.eta +11 -0
- package/dist/lib/templates/entities/entity-col-interval.eta +11 -0
- package/dist/lib/templates/entities/entity-col-json-plain.eta +8 -0
- package/dist/lib/templates/entities/entity-col-json.eta +5 -0
- package/dist/lib/templates/entities/entity-col-jsonb.eta +5 -0
- package/dist/lib/templates/entities/entity-col-money.eta +11 -0
- package/dist/lib/templates/entities/entity-col-numeric.eta +11 -0
- package/dist/lib/templates/entities/entity-col-point.eta +25 -0
- package/dist/lib/templates/entities/entity-col-real.eta +11 -0
- package/dist/lib/templates/entities/entity-col-serial.eta +12 -0
- package/dist/lib/templates/entities/entity-col-smallint.eta +11 -0
- package/dist/lib/templates/entities/entity-col-smallserial.eta +12 -0
- package/dist/lib/templates/entities/entity-col-string.eta +23 -0
- package/dist/lib/templates/entities/entity-col-text.eta +23 -0
- package/dist/lib/templates/entities/entity-col-time.eta +11 -0
- package/dist/lib/templates/entities/entity-col-timestamp.eta +4 -0
- package/dist/lib/templates/entities/entity-col-timestamptz.eta +4 -0
- package/dist/lib/templates/entities/entity-col-timetz.eta +11 -0
- package/dist/lib/templates/entities/entity-col-tsvector.eta +11 -0
- package/dist/lib/templates/entities/entity-col-uuid.eta +11 -0
- package/dist/lib/templates/entities/entity-col-varchar.eta +18 -0
- package/dist/lib/templates/entities/entity-col-xml.eta +11 -0
- package/dist/lib/templates/entities/entity.eta +116 -0
- package/dist/lib/templates/graphql/dto/dto-col-array.eta +4 -0
- package/dist/lib/templates/graphql/dto/dto-col-boolean.eta +6 -0
- package/dist/lib/templates/graphql/dto/dto-col-date.eta +4 -0
- package/dist/lib/templates/graphql/dto/dto-col-enum.eta +5 -0
- package/dist/lib/templates/graphql/dto/dto-col-float.eta +4 -0
- package/dist/lib/templates/graphql/dto/dto-col-integer.eta +4 -0
- package/dist/lib/templates/graphql/dto/dto-col-json-plain.eta +5 -0
- package/dist/lib/templates/graphql/dto/dto-col-json.eta +5 -0
- package/dist/lib/templates/graphql/dto/dto-col-text.eta +11 -0
- package/dist/lib/templates/graphql/dto/dto-col-timestamp.eta +3 -0
- package/dist/lib/templates/graphql/dto/dto-col-timestamptz.eta +3 -0
- package/dist/lib/templates/graphql/enums-graphql.eta +12 -0
- package/dist/lib/templates/graphql/gql-dto-graphql.eta +67 -0
- package/dist/lib/templates/graphql/index-module-graphql.eta +26 -0
- package/dist/lib/templates/graphql/module-graphql.eta +19 -0
- package/dist/lib/templates/header.eta +3 -0
- package/dist/lib/templates/rest/controller-rest-spec.eta +77 -0
- package/dist/lib/templates/rest/controller-rest.eta +171 -0
- package/dist/lib/templates/rest/dto-rest.eta +48 -0
- package/dist/lib/templates/rest/enums-rest.eta +7 -0
- package/dist/lib/templates/rest/index-module-rest.eta +11 -0
- package/dist/lib/templates/rest/module-rest.eta +16 -0
- package/dist/lib/templates/rest/ormconfig.eta +9 -0
- package/dist/lib/templates/rest/service-rest.eta +25 -0
- package/dist/lib/types/constraints.d.ts +4 -0
- package/dist/lib/types/constraints.js +2 -0
- package/dist/lib/types/entity.d.ts +13 -0
- package/dist/lib/types/entity.js +2 -0
- package/dist/lib/types/field.d.ts +16 -0
- package/dist/lib/types/field.js +2 -0
- package/dist/lib/types/index.d.ts +5 -0
- package/dist/lib/types/index.js +2 -0
- package/dist/lib/types/indices.d.ts +4 -0
- package/dist/lib/types/indices.js +2 -0
- package/dist/lib/types/json.d.ts +3 -0
- package/dist/lib/types/json.js +2 -0
- package/dist/lib/types/relationship.d.ts +43 -0
- package/dist/lib/types/relationship.js +2 -0
- package/dist/lib/utils/casing.d.ts +2 -0
- package/dist/lib/utils/casing.js +16 -0
- package/dist/lib/utils/field.d.ts +6 -0
- package/dist/lib/utils/field.js +65 -0
- package/dist/lib/utils/file-system.d.ts +2 -0
- package/dist/lib/utils/file-system.js +52 -0
- package/dist/lib/utils/relationships/index.d.ts +2 -0
- package/dist/lib/utils/relationships/index.js +11 -0
- package/dist/lib/utils/relationships/parse-v1.d.ts +4 -0
- package/dist/lib/utils/relationships/parse-v1.js +86 -0
- package/dist/lib/utils/relationships/parse.d.ts +11 -0
- package/dist/lib/utils/relationships/parse.js +192 -0
- package/dist/tests/templates/entities/types/array-template.spec.d.ts +1 -0
- package/dist/tests/templates/entities/types/array-template.spec.js +82 -0
- package/dist/tests/templates/entities/types/bigint-template.spec.d.ts +1 -0
- package/dist/tests/templates/entities/types/bigint-template.spec.js +82 -0
- package/dist/tests/templates/entities/types/boolean-template.spec.d.ts +1 -0
- package/dist/tests/templates/entities/types/boolean-template.spec.js +77 -0
- package/dist/tests/templates/entities/types/bytea-template.spec.d.ts +1 -0
- package/dist/tests/templates/entities/types/bytea-template.spec.js +68 -0
- package/dist/tests/templates/entities/types/char-template.spec.d.ts +1 -0
- package/dist/tests/templates/entities/types/char-template.spec.js +68 -0
- package/dist/tests/templates/entities/types/date-template.spec.d.ts +1 -0
- package/dist/tests/templates/entities/types/date-template.spec.js +56 -0
- package/dist/tests/templates/entities/types/decimal-template.spec.d.ts +1 -0
- package/dist/tests/templates/entities/types/decimal-template.spec.js +86 -0
- package/dist/tests/templates/entities/types/double-template.spec.d.ts +1 -0
- package/dist/tests/templates/entities/types/double-template.spec.js +67 -0
- package/dist/tests/templates/entities/types/enum-template.spec.d.ts +1 -0
- package/dist/tests/templates/entities/types/enum-template.spec.js +85 -0
- package/dist/tests/templates/entities/types/float-template.spec.d.ts +1 -0
- package/dist/tests/templates/entities/types/float-template.spec.js +67 -0
- package/dist/tests/templates/entities/types/inet-template.spec.d.ts +1 -0
- package/dist/tests/templates/entities/types/inet-template.spec.js +69 -0
- package/dist/tests/templates/entities/types/int4range-template.spec.d.ts +1 -0
- package/dist/tests/templates/entities/types/int4range-template.spec.js +60 -0
- package/dist/tests/templates/entities/types/integer-template.spec.d.ts +1 -0
- package/dist/tests/templates/entities/types/integer-template.spec.js +79 -0
- package/dist/tests/templates/entities/types/interval-template.spec.d.ts +1 -0
- package/dist/tests/templates/entities/types/interval-template.spec.js +68 -0
- package/dist/tests/templates/entities/types/json-plain-template.spec.d.ts +1 -0
- package/dist/tests/templates/entities/types/json-plain-template.spec.js +54 -0
- package/dist/tests/templates/entities/types/json-template.spec.d.ts +1 -0
- package/dist/tests/templates/entities/types/json-template.spec.js +40 -0
- package/dist/tests/templates/entities/types/jsonb-template.spec.d.ts +1 -0
- package/dist/tests/templates/entities/types/jsonb-template.spec.js +40 -0
- package/dist/tests/templates/entities/types/money-template.spec.d.ts +1 -0
- package/dist/tests/templates/entities/types/money-template.spec.js +68 -0
- package/dist/tests/templates/entities/types/numeric-template.spec.d.ts +1 -0
- package/dist/tests/templates/entities/types/numeric-template.spec.js +84 -0
- package/dist/tests/templates/entities/types/point-template.spec.d.ts +1 -0
- package/dist/tests/templates/entities/types/point-template.spec.js +58 -0
- package/dist/tests/templates/entities/types/real-template.spec.d.ts +1 -0
- package/dist/tests/templates/entities/types/real-template.spec.js +67 -0
- package/dist/tests/templates/entities/types/serial-template.spec.d.ts +1 -0
- package/dist/tests/templates/entities/types/serial-template.spec.js +113 -0
- package/dist/tests/templates/entities/types/smallint-template.spec.d.ts +1 -0
- package/dist/tests/templates/entities/types/smallint-template.spec.js +82 -0
- package/dist/tests/templates/entities/types/string-template.spec.d.ts +1 -0
- package/dist/tests/templates/entities/types/string-template.spec.js +111 -0
- package/dist/tests/templates/entities/types/text-template.spec.d.ts +1 -0
- package/dist/tests/templates/entities/types/text-template.spec.js +70 -0
- package/dist/tests/templates/entities/types/time-template.spec.d.ts +1 -0
- package/dist/tests/templates/entities/types/time-template.spec.js +68 -0
- package/dist/tests/templates/entities/types/timestamp-template.spec.d.ts +1 -0
- package/dist/tests/templates/entities/types/timestamp-template.spec.js +74 -0
- package/dist/tests/templates/entities/types/timetz-template.spec.d.ts +1 -0
- package/dist/tests/templates/entities/types/timetz-template.spec.js +68 -0
- package/dist/tests/templates/entities/types/tsvector-template.spec.d.ts +1 -0
- package/dist/tests/templates/entities/types/tsvector-template.spec.js +55 -0
- package/dist/tests/templates/entities/types/uuid-template.spec.d.ts +1 -0
- package/dist/tests/templates/entities/types/uuid-template.spec.js +82 -0
- package/dist/tests/templates/entities/types/varchar-template.spec.d.ts +1 -0
- package/dist/tests/templates/entities/types/varchar-template.spec.js +102 -0
- package/dist/tests/templates/entities/types/xml-template.spec.d.ts +1 -0
- package/dist/tests/templates/entities/types/xml-template.spec.js +55 -0
- package/dist/tests/templates/entities/utils/template-test-utils.d.ts +31 -0
- package/dist/tests/templates/entities/utils/template-test-utils.js +50 -0
- package/oclif.manifest.json +60 -1
- package/package.json +84 -55
- package/lib/commands/new.d.ts +0 -22
- package/lib/commands/new.js +0 -198
- package/lib/commands/scaffold.d.ts +0 -18
- package/lib/commands/scaffold.js +0 -106
- package/lib/index.d.ts +0 -1
- package/lib/lib/scaffold.d.ts +0 -30
- package/lib/lib/scaffold.js +0 -566
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 Salesforce
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,95 +1,355 @@
|
|
|
1
|
-
|
|
2
|
-
========
|
|
1
|
+
# Apso CLI
|
|
3
2
|
|
|
3
|
+
- [Apso CLI](#apso-cli)
|
|
4
|
+
- [Prerequisites](#prerequisites)
|
|
5
|
+
- [Usage](#usage)
|
|
6
|
+
- [Local Development](#local-development)
|
|
7
|
+
- [Debugging](##debugging)
|
|
8
|
+
- [Commands](#commands)
|
|
4
9
|
|
|
10
|
+
# Prerequisites
|
|
5
11
|
|
|
6
|
-
|
|
7
|
-
[
|
|
8
|
-
[](https://npmjs.org/package/apso)
|
|
9
|
-
[](https://github.com/mavric/apso/blob/master/package.json)
|
|
12
|
+
You need to have setup access to Mavric's private NPM packages.
|
|
13
|
+
Find out how [here](https://github.com/mavric/.github-private/blob/main/how-to/private-npm.md)
|
|
10
14
|
|
|
11
|
-
<!-- toc -->
|
|
12
|
-
* [Usage](#usage)
|
|
13
|
-
* [Commands](#commands)
|
|
14
|
-
<!-- tocstop -->
|
|
15
15
|
# Usage
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
```sh-session
|
|
18
|
-
$ npm install -g @apso
|
|
18
|
+
$ npm install -g @mavric/apso-cli
|
|
19
19
|
$ apso COMMAND
|
|
20
20
|
running command...
|
|
21
|
-
$ apso (
|
|
22
|
-
@apso
|
|
21
|
+
$ apso (--version)
|
|
22
|
+
@mavric/apso-cli/0.0.26 linux-x64 node-v18.20.2
|
|
23
23
|
$ apso --help [COMMAND]
|
|
24
24
|
USAGE
|
|
25
25
|
$ apso COMMAND
|
|
26
26
|
...
|
|
27
27
|
```
|
|
28
|
-
|
|
28
|
+
|
|
29
|
+
# Local Development
|
|
30
|
+
|
|
31
|
+
Clone apso-cli on your machine. Navigate to the repo in your code editor and run the below commands
|
|
32
|
+
|
|
33
|
+
```sh-session
|
|
34
|
+
npm install
|
|
35
|
+
npm run build && npm link
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
This will build the apso cli and make it available for use globally on your machine. Now make a new directory where you want to setup a new backend service. Run the below command in order to create a new service boilerplate. This will clone the apso-service-template from github.
|
|
39
|
+
|
|
40
|
+
Incase you face permission denied issue make sure that you have SSH key added in github and your local machine. Follow this [link](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent) for SSH keys generation.
|
|
41
|
+
|
|
42
|
+
```sh-session
|
|
43
|
+
apso server new -n <project-name>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Then navigate to the newly created service and update the apsorc file according to your project entities and relations.
|
|
47
|
+
|
|
48
|
+
Sample of apsorc files for both v1 and v2 are given in apso-cli code at "test/apsorc-json" so you can check it out in order to make sure that your apsorc file follows the right pattern.
|
|
49
|
+
|
|
50
|
+
You can also provide the key "apiType" in the apsorc file e.g (Rest, Graphql) incase you want to generate the GraphQL backend by default it would be REST.
|
|
51
|
+
|
|
52
|
+
Install the npm modules before continuing further.
|
|
53
|
+
|
|
54
|
+
Now we will run the scaffold command which will generate the all the relevant modules for us.
|
|
55
|
+
|
|
56
|
+
```sh-session
|
|
57
|
+
apso server scaffold
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Debugging
|
|
61
|
+
|
|
62
|
+
For debugging we would use the debug package so you need to import the package in file where you want to debug any code.
|
|
63
|
+
|
|
64
|
+
```sh-session
|
|
65
|
+
var debug = require("debug")("{name of your choice}");
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Then just add the debug statements wherever you want.
|
|
69
|
+
|
|
70
|
+
```sh-session
|
|
71
|
+
debug(`variable1 value is:`, variable1);
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Now inorder to see the debug output you need to run the cli in debug mode like this.
|
|
75
|
+
|
|
76
|
+
```sh-session
|
|
77
|
+
env DEBUG=\* ./bin/run server scaffold
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
So we are setting the env variable DEBUG and then giving the path of the bin/run file and then next will be your cli commmand.
|
|
81
|
+
|
|
82
|
+
Note: Whenever you make a change you need to rebuild the cli before running it in order to reflect the changes.
|
|
83
|
+
|
|
84
|
+
```sh-session
|
|
85
|
+
npm run build
|
|
86
|
+
```
|
|
87
|
+
|
|
29
88
|
# Commands
|
|
30
|
-
<!-- commands -->
|
|
31
|
-
* [`apso help [COMMAND]`](#apso-help-command)
|
|
32
|
-
* [`apso new [WEB] [SERVER] [SERVERLESS] [NAME]`](#apso-new-web-server-serverless-name)
|
|
33
|
-
* [`apso scaffold [WEB] [SERVER] [ENTITY]`](#apso-scaffold-web-server-entity)
|
|
34
89
|
|
|
35
|
-
|
|
90
|
+
- [`apso help [COMMANDS]`](#apso-help-commands)
|
|
91
|
+
- [`apso plugins`](#apso-plugins)
|
|
92
|
+
- [`apso plugins:install PLUGIN...`](#apso-pluginsinstall-plugin)
|
|
93
|
+
- [`apso plugins:inspect PLUGIN...`](#apso-pluginsinspect-plugin)
|
|
94
|
+
- [`apso plugins:install PLUGIN...`](#apso-pluginsinstall-plugin-1)
|
|
95
|
+
- [`apso plugins:link PLUGIN`](#apso-pluginslink-plugin)
|
|
96
|
+
- [`apso plugins:uninstall PLUGIN...`](#apso-pluginsuninstall-plugin)
|
|
97
|
+
- [`apso plugins:uninstall PLUGIN...`](#apso-pluginsuninstall-plugin-1)
|
|
98
|
+
- [`apso plugins:uninstall PLUGIN...`](#apso-pluginsuninstall-plugin-2)
|
|
99
|
+
- [`apso plugins update`](#apso-plugins-update)
|
|
100
|
+
|
|
101
|
+
## `apso help [COMMANDS]`
|
|
36
102
|
|
|
37
|
-
|
|
103
|
+
Display help for apso.
|
|
38
104
|
|
|
39
105
|
```
|
|
40
106
|
USAGE
|
|
41
|
-
$ apso help [
|
|
107
|
+
$ apso help [COMMANDS] [-n]
|
|
42
108
|
|
|
43
109
|
ARGUMENTS
|
|
44
|
-
|
|
110
|
+
COMMANDS Command to show help for.
|
|
45
111
|
|
|
46
|
-
|
|
47
|
-
--
|
|
112
|
+
FLAGS
|
|
113
|
+
-n, --nested-commands Include all nested commands in the output.
|
|
114
|
+
|
|
115
|
+
DESCRIPTION
|
|
116
|
+
Display help for apso.
|
|
48
117
|
```
|
|
49
118
|
|
|
50
|
-
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/
|
|
119
|
+
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v5.2.9/src/commands/help.ts)_
|
|
51
120
|
|
|
52
|
-
## `apso
|
|
121
|
+
## `apso plugins`
|
|
53
122
|
|
|
54
|
-
|
|
123
|
+
List installed plugins.
|
|
55
124
|
|
|
56
125
|
```
|
|
57
126
|
USAGE
|
|
58
|
-
$ apso
|
|
127
|
+
$ apso plugins [--json] [--core]
|
|
128
|
+
|
|
129
|
+
FLAGS
|
|
130
|
+
--core Show core plugins.
|
|
59
131
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
-f, --force
|
|
63
|
-
-h, --help show CLI help
|
|
64
|
-
-n, --name=name name of application
|
|
65
|
-
-s, --server initialize server application
|
|
66
|
-
-w, --web initialize web application
|
|
132
|
+
GLOBAL FLAGS
|
|
133
|
+
--json Format output as json.
|
|
67
134
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
135
|
+
DESCRIPTION
|
|
136
|
+
List installed plugins.
|
|
137
|
+
|
|
138
|
+
EXAMPLES
|
|
139
|
+
$ apso plugins
|
|
71
140
|
```
|
|
72
141
|
|
|
73
|
-
_See code: [
|
|
142
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.1.2/src/commands/plugins/index.ts)_
|
|
74
143
|
|
|
75
|
-
## `apso
|
|
144
|
+
## `apso plugins:install PLUGIN...`
|
|
76
145
|
|
|
77
|
-
|
|
146
|
+
Installs a plugin into the CLI.
|
|
78
147
|
|
|
79
148
|
```
|
|
80
149
|
USAGE
|
|
81
|
-
$ apso
|
|
150
|
+
$ apso plugins:install PLUGIN...
|
|
151
|
+
|
|
152
|
+
ARGUMENTS
|
|
153
|
+
PLUGIN Plugin to install.
|
|
154
|
+
|
|
155
|
+
FLAGS
|
|
156
|
+
-f, --force Run yarn install with force flag.
|
|
157
|
+
-h, --help Show CLI help.
|
|
158
|
+
-v, --verbose
|
|
159
|
+
|
|
160
|
+
DESCRIPTION
|
|
161
|
+
Installs a plugin into the CLI.
|
|
162
|
+
Can be installed from npm or a git url.
|
|
163
|
+
|
|
164
|
+
Installation of a user-installed plugin will override a core plugin.
|
|
165
|
+
|
|
166
|
+
e.g. If you have a core plugin that has a 'hello' command, installing a user-installed plugin with a 'hello' command
|
|
167
|
+
will override the core plugin implementation. This is useful if a user needs to update core plugin functionality in
|
|
168
|
+
the CLI without the need to patch and update the whole CLI.
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
ALIASES
|
|
172
|
+
$ apso plugins add
|
|
173
|
+
|
|
174
|
+
EXAMPLES
|
|
175
|
+
$ apso plugins:install myplugin
|
|
82
176
|
|
|
83
|
-
|
|
84
|
-
-h, --help show CLI help
|
|
85
|
-
-m, --entity=entity model name
|
|
86
|
-
-s, --server initialize server application
|
|
87
|
-
-w, --web initialize web application
|
|
177
|
+
$ apso plugins:install https://github.com/someuser/someplugin
|
|
88
178
|
|
|
89
|
-
|
|
90
|
-
$ apso scaffold
|
|
91
|
-
hello world from ./src/hello.ts!
|
|
179
|
+
$ apso plugins:install someuser/someplugin
|
|
92
180
|
```
|
|
93
181
|
|
|
94
|
-
|
|
95
|
-
|
|
182
|
+
## `apso plugins:inspect PLUGIN...`
|
|
183
|
+
|
|
184
|
+
Displays installation properties of a plugin.
|
|
185
|
+
|
|
186
|
+
```
|
|
187
|
+
USAGE
|
|
188
|
+
$ apso plugins:inspect PLUGIN...
|
|
189
|
+
|
|
190
|
+
ARGUMENTS
|
|
191
|
+
PLUGIN [default: .] Plugin to inspect.
|
|
192
|
+
|
|
193
|
+
FLAGS
|
|
194
|
+
-h, --help Show CLI help.
|
|
195
|
+
-v, --verbose
|
|
196
|
+
|
|
197
|
+
GLOBAL FLAGS
|
|
198
|
+
--json Format output as json.
|
|
199
|
+
|
|
200
|
+
DESCRIPTION
|
|
201
|
+
Displays installation properties of a plugin.
|
|
202
|
+
|
|
203
|
+
EXAMPLES
|
|
204
|
+
$ apso plugins:inspect myplugin
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## `apso plugins:install PLUGIN...`
|
|
208
|
+
|
|
209
|
+
Installs a plugin into the CLI.
|
|
210
|
+
|
|
211
|
+
```
|
|
212
|
+
USAGE
|
|
213
|
+
$ apso plugins:install PLUGIN...
|
|
214
|
+
|
|
215
|
+
ARGUMENTS
|
|
216
|
+
PLUGIN Plugin to install.
|
|
217
|
+
|
|
218
|
+
FLAGS
|
|
219
|
+
-f, --force Run yarn install with force flag.
|
|
220
|
+
-h, --help Show CLI help.
|
|
221
|
+
-v, --verbose
|
|
222
|
+
|
|
223
|
+
DESCRIPTION
|
|
224
|
+
Installs a plugin into the CLI.
|
|
225
|
+
Can be installed from npm or a git url.
|
|
226
|
+
|
|
227
|
+
Installation of a user-installed plugin will override a core plugin.
|
|
228
|
+
|
|
229
|
+
e.g. If you have a core plugin that has a 'hello' command, installing a user-installed plugin with a 'hello' command
|
|
230
|
+
will override the core plugin implementation. This is useful if a user needs to update core plugin functionality in
|
|
231
|
+
the CLI without the need to patch and update the whole CLI.
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
ALIASES
|
|
235
|
+
$ apso plugins add
|
|
236
|
+
|
|
237
|
+
EXAMPLES
|
|
238
|
+
$ apso plugins:install myplugin
|
|
239
|
+
|
|
240
|
+
$ apso plugins:install https://github.com/someuser/someplugin
|
|
241
|
+
|
|
242
|
+
$ apso plugins:install someuser/someplugin
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
## `apso plugins:link PLUGIN`
|
|
246
|
+
|
|
247
|
+
Links a plugin into the CLI for development.
|
|
248
|
+
|
|
249
|
+
```
|
|
250
|
+
USAGE
|
|
251
|
+
$ apso plugins:link PLUGIN
|
|
252
|
+
|
|
253
|
+
ARGUMENTS
|
|
254
|
+
PATH [default: .] path to plugin
|
|
255
|
+
|
|
256
|
+
FLAGS
|
|
257
|
+
-h, --help Show CLI help.
|
|
258
|
+
-v, --verbose
|
|
259
|
+
|
|
260
|
+
DESCRIPTION
|
|
261
|
+
Links a plugin into the CLI for development.
|
|
262
|
+
Installation of a linked plugin will override a user-installed or core plugin.
|
|
263
|
+
|
|
264
|
+
e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello'
|
|
265
|
+
command will override the user-installed or core plugin implementation. This is useful for development work.
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
EXAMPLES
|
|
269
|
+
$ apso plugins:link myplugin
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## `apso plugins:uninstall PLUGIN...`
|
|
273
|
+
|
|
274
|
+
Removes a plugin from the CLI.
|
|
275
|
+
|
|
276
|
+
```
|
|
277
|
+
USAGE
|
|
278
|
+
$ apso plugins:uninstall PLUGIN...
|
|
279
|
+
|
|
280
|
+
ARGUMENTS
|
|
281
|
+
PLUGIN plugin to uninstall
|
|
282
|
+
|
|
283
|
+
FLAGS
|
|
284
|
+
-h, --help Show CLI help.
|
|
285
|
+
-v, --verbose
|
|
286
|
+
|
|
287
|
+
DESCRIPTION
|
|
288
|
+
Removes a plugin from the CLI.
|
|
289
|
+
|
|
290
|
+
ALIASES
|
|
291
|
+
$ apso plugins unlink
|
|
292
|
+
$ apso plugins remove
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
## `apso plugins:uninstall PLUGIN...`
|
|
296
|
+
|
|
297
|
+
Removes a plugin from the CLI.
|
|
298
|
+
|
|
299
|
+
```
|
|
300
|
+
USAGE
|
|
301
|
+
$ apso plugins:uninstall PLUGIN...
|
|
302
|
+
|
|
303
|
+
ARGUMENTS
|
|
304
|
+
PLUGIN plugin to uninstall
|
|
305
|
+
|
|
306
|
+
FLAGS
|
|
307
|
+
-h, --help Show CLI help.
|
|
308
|
+
-v, --verbose
|
|
309
|
+
|
|
310
|
+
DESCRIPTION
|
|
311
|
+
Removes a plugin from the CLI.
|
|
312
|
+
|
|
313
|
+
ALIASES
|
|
314
|
+
$ apso plugins unlink
|
|
315
|
+
$ apso plugins remove
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
## `apso plugins:uninstall PLUGIN...`
|
|
319
|
+
|
|
320
|
+
Removes a plugin from the CLI.
|
|
321
|
+
|
|
322
|
+
```
|
|
323
|
+
USAGE
|
|
324
|
+
$ apso plugins:uninstall PLUGIN...
|
|
325
|
+
|
|
326
|
+
ARGUMENTS
|
|
327
|
+
PLUGIN plugin to uninstall
|
|
328
|
+
|
|
329
|
+
FLAGS
|
|
330
|
+
-h, --help Show CLI help.
|
|
331
|
+
-v, --verbose
|
|
332
|
+
|
|
333
|
+
DESCRIPTION
|
|
334
|
+
Removes a plugin from the CLI.
|
|
335
|
+
|
|
336
|
+
ALIASES
|
|
337
|
+
$ apso plugins unlink
|
|
338
|
+
$ apso plugins remove
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
## `apso plugins update`
|
|
342
|
+
|
|
343
|
+
Update installed plugins.
|
|
344
|
+
|
|
345
|
+
```
|
|
346
|
+
USAGE
|
|
347
|
+
$ apso plugins update [-h] [-v]
|
|
348
|
+
|
|
349
|
+
FLAGS
|
|
350
|
+
-h, --help Show CLI help.
|
|
351
|
+
-v, --verbose
|
|
352
|
+
|
|
353
|
+
DESCRIPTION
|
|
354
|
+
Update installed plugins.
|
|
355
|
+
```
|
package/bin/dev
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const oclif = require('@oclif/core')
|
|
4
|
+
|
|
5
|
+
const path = require('path')
|
|
6
|
+
const project = path.join(__dirname, '..', 'tsconfig.json')
|
|
7
|
+
|
|
8
|
+
// In dev mode -> use ts-node and dev plugins
|
|
9
|
+
process.env.NODE_ENV = 'development'
|
|
10
|
+
|
|
11
|
+
require('ts-node').register({project})
|
|
12
|
+
|
|
13
|
+
// In dev mode, always show stack traces
|
|
14
|
+
oclif.settings.debug = true;
|
|
15
|
+
|
|
16
|
+
// Start the CLI
|
|
17
|
+
oclif.run().then(oclif.flush).catch(oclif.Errors.handle)
|
package/bin/dev.cmd
ADDED
package/bin/run
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import BaseCommand from "../../lib/base-command";
|
|
2
|
+
export default class New extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
private CURR_DIR;
|
|
6
|
+
static flags: {
|
|
7
|
+
name: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
|
+
type: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
|
+
};
|
|
10
|
+
static args: {
|
|
11
|
+
name: import("@oclif/core/lib/interfaces/parser").Arg<string | undefined, Record<string, unknown>>;
|
|
12
|
+
};
|
|
13
|
+
installModules(path: string): Promise<void>;
|
|
14
|
+
formatApp(root: string): Promise<void>;
|
|
15
|
+
startApp(root: string): Promise<void>;
|
|
16
|
+
cloneTemplate(projectPath: string): Promise<void>;
|
|
17
|
+
run(): Promise<void>;
|
|
18
|
+
validateFlags(): Promise<{
|
|
19
|
+
projectName: string;
|
|
20
|
+
apiType: string;
|
|
21
|
+
}>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const core_1 = require("@oclif/core");
|
|
5
|
+
const child_process_1 = require("child_process");
|
|
6
|
+
const fs = tslib_1.__importStar(require("fs"));
|
|
7
|
+
const shelljs_1 = tslib_1.__importDefault(require("shelljs"));
|
|
8
|
+
const base_command_1 = tslib_1.__importDefault(require("../../lib/base-command"));
|
|
9
|
+
const path = tslib_1.__importStar(require("path"));
|
|
10
|
+
class New extends base_command_1.default {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
this.CURR_DIR = process.cwd();
|
|
14
|
+
}
|
|
15
|
+
async installModules(path) {
|
|
16
|
+
this.log("installing modules");
|
|
17
|
+
await this.runNpmCommand(["install", "--force", "--prefix", path]);
|
|
18
|
+
}
|
|
19
|
+
async formatApp(root) {
|
|
20
|
+
this.log("cleaning up");
|
|
21
|
+
shelljs_1.default.cd(root);
|
|
22
|
+
await this.runNpmCommand(["run", "format", "--prefix", root]);
|
|
23
|
+
}
|
|
24
|
+
async startApp(root) {
|
|
25
|
+
return new Promise((resolve, reject) => {
|
|
26
|
+
const command = "npm";
|
|
27
|
+
const args = ["start"];
|
|
28
|
+
// Explicitly set cwd() to work around issues like
|
|
29
|
+
// https://github.com/facebook/create-react-app/issues/3326.
|
|
30
|
+
// Unfortunately we can only do this for Yarn because npm support for
|
|
31
|
+
// equivalent --prefix flag doesn't help with this issue.
|
|
32
|
+
// This is why for npm, we run checkThatNpmCanReadCwd() early instead.
|
|
33
|
+
// args.push('--cwd')
|
|
34
|
+
// args.push(root)
|
|
35
|
+
// args.push('--verbose')
|
|
36
|
+
const child = (0, child_process_1.spawn)(command, args, { stdio: "inherit", cwd: root });
|
|
37
|
+
child.on("close", (code) => {
|
|
38
|
+
if (code !== 0) {
|
|
39
|
+
reject({
|
|
40
|
+
command: `${command} ${args.join(" ")}`,
|
|
41
|
+
});
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
resolve();
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
async cloneTemplate(projectPath) {
|
|
49
|
+
this.log("Creating project in current folder.");
|
|
50
|
+
if (!fs.existsSync(projectPath) && this.CURR_DIR !== projectPath) {
|
|
51
|
+
fs.mkdirSync(projectPath);
|
|
52
|
+
}
|
|
53
|
+
shelljs_1.default.cd(projectPath);
|
|
54
|
+
if (process.env.APSO_GIT_PAT) {
|
|
55
|
+
shelljs_1.default.exec(`git clone --depth=1 --branch=main https://${process.env.APSO_GIT_PAT}:@github.com/mavric/apso-service-template.git ${projectPath}`);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
shelljs_1.default.exec(`git clone --depth=1 --branch=main git@github.com:mavric/apso-service-template.git ${projectPath}`);
|
|
59
|
+
}
|
|
60
|
+
shelljs_1.default.exec(`rm -rf ${projectPath}/.git`);
|
|
61
|
+
shelljs_1.default.cd(this.CURR_DIR);
|
|
62
|
+
}
|
|
63
|
+
async run() {
|
|
64
|
+
this.log("Initializing New Apso Server...");
|
|
65
|
+
const { projectName,
|
|
66
|
+
// apiType,
|
|
67
|
+
} = await this.validateFlags();
|
|
68
|
+
const CURR_DIR = process.cwd();
|
|
69
|
+
const projectPath = path.join(CURR_DIR, projectName);
|
|
70
|
+
await this.cloneTemplate(projectPath);
|
|
71
|
+
await this.installModules(projectPath);
|
|
72
|
+
await this.formatApp(projectPath);
|
|
73
|
+
}
|
|
74
|
+
async validateFlags() {
|
|
75
|
+
var _a;
|
|
76
|
+
const { flags } = await this.parse(New);
|
|
77
|
+
let projectName = flags.name;
|
|
78
|
+
let apiType = (_a = flags.type) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
79
|
+
if (typeof projectName === "undefined") {
|
|
80
|
+
// this.error("`name` must be set (e.g. WoofyApp)");
|
|
81
|
+
projectName = '';
|
|
82
|
+
}
|
|
83
|
+
if (typeof apiType === "undefined") {
|
|
84
|
+
apiType = "rest";
|
|
85
|
+
}
|
|
86
|
+
if (apiType !== "rest" && apiType !== "graphql") {
|
|
87
|
+
this.error("`apiType` must be set (e.g. rest or graphql)");
|
|
88
|
+
}
|
|
89
|
+
return { projectName, apiType };
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
New.description = "Initialize your server project";
|
|
93
|
+
New.examples = [`$ apso server new --name TestProject`];
|
|
94
|
+
New.flags = {
|
|
95
|
+
name: core_1.Flags.string({
|
|
96
|
+
char: "n",
|
|
97
|
+
description: "name of application",
|
|
98
|
+
}),
|
|
99
|
+
type: core_1.Flags.string({
|
|
100
|
+
char: "t",
|
|
101
|
+
description: "api type (rest or graphql)",
|
|
102
|
+
}),
|
|
103
|
+
};
|
|
104
|
+
New.args = { name: core_1.Args.string() };
|
|
105
|
+
exports.default = New;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Entity, RelationshipMap } from "../../lib";
|
|
2
|
+
import BaseCommand from "../../lib/base-command";
|
|
3
|
+
export default class Scaffold extends BaseCommand {
|
|
4
|
+
static description: string;
|
|
5
|
+
static examples: string[];
|
|
6
|
+
static flags: {
|
|
7
|
+
help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
|
|
8
|
+
};
|
|
9
|
+
static args: {};
|
|
10
|
+
scaffoldServer(dir: string, entity: Entity, relationshipMap: RelationshipMap, apiType: string): Promise<void>;
|
|
11
|
+
setupRestFiles(dir: string, entity: Entity, relationshipMap: RelationshipMap): Promise<void>;
|
|
12
|
+
setupGraphqlFiles(dir: string, entity: Entity, relationshipMap: RelationshipMap): Promise<void>;
|
|
13
|
+
run(): Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const core_1 = require("@oclif/core");
|
|
5
|
+
const path = tslib_1.__importStar(require("path"));
|
|
6
|
+
const lib_1 = require("../../lib");
|
|
7
|
+
const base_command_1 = tslib_1.__importDefault(require("../../lib/base-command"));
|
|
8
|
+
const apsorc_parser_1 = require("../../lib/apsorc-parser");
|
|
9
|
+
class Scaffold extends base_command_1.default {
|
|
10
|
+
async scaffoldServer(dir, entity, relationshipMap, apiType) {
|
|
11
|
+
this.log(`Building... ${entity.name}`);
|
|
12
|
+
const entityName = entity.name;
|
|
13
|
+
const filePath = path.join(dir, entityName);
|
|
14
|
+
const entityRelationships = relationshipMap[entity.name] || [];
|
|
15
|
+
await (0, lib_1.createEntity)(filePath, entity, entityRelationships, apiType);
|
|
16
|
+
switch (apiType) {
|
|
17
|
+
case apsorc_parser_1.ApiType.Graphql:
|
|
18
|
+
await this.setupGraphqlFiles(dir, entity, relationshipMap);
|
|
19
|
+
break;
|
|
20
|
+
case apsorc_parser_1.ApiType.Rest:
|
|
21
|
+
await this.setupRestFiles(dir, entity, relationshipMap);
|
|
22
|
+
break;
|
|
23
|
+
default:
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
await (0, lib_1.createModule)(filePath, entityName, apiType);
|
|
27
|
+
}
|
|
28
|
+
async setupRestFiles(dir, entity, relationshipMap) {
|
|
29
|
+
const filePath = path.join(dir, entity.name);
|
|
30
|
+
const entityRelationships = relationshipMap[entity.name] || [];
|
|
31
|
+
await (0, lib_1.createDto)(filePath, entity, entityRelationships);
|
|
32
|
+
await (0, lib_1.createService)(filePath, entity.name);
|
|
33
|
+
await (0, lib_1.createController)(filePath, entity, relationshipMap);
|
|
34
|
+
}
|
|
35
|
+
async setupGraphqlFiles(dir, entity, relationshipMap) {
|
|
36
|
+
const filePath = path.join(dir, entity.name);
|
|
37
|
+
const entityRelationships = relationshipMap[entity.name] || [];
|
|
38
|
+
await (0, lib_1.createGqlDTO)(filePath, entity, entityRelationships);
|
|
39
|
+
}
|
|
40
|
+
async run() {
|
|
41
|
+
const { rootFolder, entities, relationshipMap, apiType } = (0, lib_1.parseApsorc)();
|
|
42
|
+
const rootPath = path.join(process.cwd(), rootFolder);
|
|
43
|
+
const autogenPath = path.join(rootPath, "autogen");
|
|
44
|
+
const lowerCaseApiType = apiType.toLowerCase();
|
|
45
|
+
await (0, lib_1.createEnums)(autogenPath, entities, lowerCaseApiType);
|
|
46
|
+
entities.forEach((entity) => {
|
|
47
|
+
const scaffoldModel = this.scaffoldServer.bind(this);
|
|
48
|
+
scaffoldModel(autogenPath, entity, relationshipMap, lowerCaseApiType);
|
|
49
|
+
});
|
|
50
|
+
await (0, lib_1.createIndexAppModule)(autogenPath, entities, lowerCaseApiType);
|
|
51
|
+
await this.runNpmCommand(["run", "format"]);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
Scaffold.description = "Setup new entities and interfaces for an Apso Server";
|
|
55
|
+
Scaffold.examples = [`$ apso server scaffold`];
|
|
56
|
+
Scaffold.flags = {
|
|
57
|
+
help: core_1.Flags.help({ char: "h" }),
|
|
58
|
+
};
|
|
59
|
+
Scaffold.args = {};
|
|
60
|
+
exports.default = Scaffold;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { run } from "@oclif/core";
|
package/{lib → dist}/index.js
RENAMED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
exports.run = void 0;
|
|
4
|
+
var core_1 = require("@oclif/core");
|
|
5
|
+
Object.defineProperty(exports, "run", { enumerable: true, get: function () { return core_1.run; } });
|