@axinom/mosaic-cli 0.14.2-rc.8 → 0.15.0-rc.0
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/package.json +6 -5
- package/src/cli/README.md +60 -0
- package/src/cli/index.ts +47 -0
- package/src/commands/apply-templates/apply-templates.spec.ts +623 -0
- package/src/commands/apply-templates/apply-templates.ts +494 -0
- package/src/commands/apply-templates/bitwarden-vault.ts +130 -0
- package/src/commands/apply-templates/index.ts +1 -0
- package/src/commands/create-extension-config/create-extension-config.ts +92 -0
- package/src/commands/create-extension-config/index.ts +23 -0
- package/src/commands/get-access-token/get-access-token-options.ts +9 -0
- package/src/commands/get-access-token/get-dev-access-token.ts +32 -0
- package/src/commands/get-access-token/index.ts +66 -0
- package/src/commands/graphql-diff.ts +143 -0
- package/src/commands/msg-codegen/codegen.ts +891 -0
- package/src/commands/msg-codegen/index.ts +48 -0
- package/src/commands/msg-codegen/lint.ts +84 -0
- package/src/commands/msg-codegen/message-codegen-options.ts +7 -0
- package/src/commands/msg-diff/asyncapi-override.ts +31 -0
- package/src/commands/msg-diff/git-checkout-tmp.ts +73 -0
- package/src/commands/msg-diff/index.ts +53 -0
- package/src/commands/msg-diff/message-diff-options.ts +7 -0
- package/src/commands/msg-diff/msg-diff.spec.ts +412 -0
- package/src/commands/msg-diff/msg-diff.ts +364 -0
- package/src/commands/msg-diff/test-resources/0/1-asyncapi.yml +38 -0
- package/src/commands/msg-diff/test-resources/0/2-asyncapi.yml +36 -0
- package/src/commands/msg-diff/test-resources/0/command.json +74 -0
- package/src/commands/msg-diff/test-resources/0/event.json +25 -0
- package/src/commands/msg-diff/test-resources/1/1-asyncapi.yml +25 -0
- package/src/commands/msg-diff/test-resources/1/moved-event.json +25 -0
- package/src/commands/msg-diff/test-resources/common.json +20 -0
- package/src/commands/pg-dump/README.md +21 -0
- package/src/commands/pg-dump/generate.ts +146 -0
- package/src/commands/pg-dump/index.ts +39 -0
- package/src/commands/pg-dump/pg-dump-options.ts +6 -0
- package/src/commands/publish-schema-to-db/README.md +130 -0
- package/src/commands/publish-schema-to-db/abstractions/base-smart-tags.ts +6 -0
- package/src/commands/publish-schema-to-db/abstractions/index.ts +5 -0
- package/src/commands/publish-schema-to-db/abstractions/pg-column.ts +31 -0
- package/src/commands/publish-schema-to-db/abstractions/pg-fk-column.ts +6 -0
- package/src/commands/publish-schema-to-db/abstractions/pg-table.ts +55 -0
- package/src/commands/publish-schema-to-db/abstractions/pg-type.ts +8 -0
- package/src/commands/publish-schema-to-db/content-entity-model.ts +93 -0
- package/src/commands/publish-schema-to-db/generate.ts +82 -0
- package/src/commands/publish-schema-to-db/index.ts +49 -0
- package/src/commands/publish-schema-to-db/jest.config.js +9 -0
- package/src/commands/publish-schema-to-db/pg-models/columns/fk-column.spec.ts +42 -0
- package/src/commands/publish-schema-to-db/pg-models/columns/fk-column.ts +41 -0
- package/src/commands/publish-schema-to-db/pg-models/columns/index.ts +4 -0
- package/src/commands/publish-schema-to-db/pg-models/columns/pk-column.spec.ts +47 -0
- package/src/commands/publish-schema-to-db/pg-models/columns/pk-column.ts +34 -0
- package/src/commands/publish-schema-to-db/pg-models/columns/primitive-column.spec.ts +65 -0
- package/src/commands/publish-schema-to-db/pg-models/columns/primitive-column.ts +62 -0
- package/src/commands/publish-schema-to-db/pg-models/columns/virtual-fk-column.spec.ts +24 -0
- package/src/commands/publish-schema-to-db/pg-models/columns/virtual-fk-column.ts +34 -0
- package/src/commands/publish-schema-to-db/pg-models/json-schema-parse-utils.spec.ts +182 -0
- package/src/commands/publish-schema-to-db/pg-models/json-schema-parse-utils.ts +166 -0
- package/src/commands/publish-schema-to-db/pg-models/pg-sql-gen-utils.spec.ts +19 -0
- package/src/commands/publish-schema-to-db/pg-models/pg-sql-gen-utils.ts +237 -0
- package/src/commands/publish-schema-to-db/pg-models/pgl-utils.spec.ts +19 -0
- package/src/commands/publish-schema-to-db/pg-models/pgl-utils.ts +115 -0
- package/src/commands/publish-schema-to-db/pg-models/tables/content-entity-table.ts +104 -0
- package/src/commands/publish-schema-to-db/pg-models/tables/index.ts +3 -0
- package/src/commands/publish-schema-to-db/pg-models/tables/object-property-table.ts +113 -0
- package/src/commands/publish-schema-to-db/pg-models/tables/relations-table.ts +115 -0
- package/src/commands/publish-schema-to-db/postprocessors/collection-postprocessor.ts +33 -0
- package/src/commands/publish-schema-to-db/postprocessors/content-entity-model-postprocessor.ts +13 -0
- package/src/commands/publish-schema-to-db/postprocessors/episode-postprocessor.ts +37 -0
- package/src/commands/publish-schema-to-db/postprocessors/index.ts +6 -0
- package/src/commands/publish-schema-to-db/postprocessors/movie-postprocessor.ts +30 -0
- package/src/commands/publish-schema-to-db/postprocessors/postprocessing-utils.ts +21 -0
- package/src/commands/publish-schema-to-db/postprocessors/season-postprocessor.ts +37 -0
- package/src/commands/publish-schema-to-db/postprocessors/tvshow-postprocessor.ts +30 -0
- package/src/commands/publish-schema-to-db/publish-schema-to-db-options.ts +15 -0
- package/src/commands/publish-schema-to-db/types/sql-formatter.d.ts +10 -0
- package/src/exports.ts +2 -0
- package/src/index.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axinom/mosaic-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0-rc.0",
|
|
4
4
|
"description": "The Axinom Mosaic CLI",
|
|
5
5
|
"author": "Axinom",
|
|
6
6
|
"license": "PROPRIETARY",
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
"mosaic": "./bin/mosaic.js"
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
|
-
"dist"
|
|
16
|
+
"dist",
|
|
17
|
+
"src"
|
|
17
18
|
],
|
|
18
19
|
"main": "dist/exports.js",
|
|
19
20
|
"types": "dist/exports.d.ts",
|
|
@@ -32,8 +33,8 @@
|
|
|
32
33
|
"@asyncapi/diff": "^0.4.0",
|
|
33
34
|
"@asyncapi/modelina": "^0.43.0",
|
|
34
35
|
"@asyncapi/parser": "^1.15.0",
|
|
35
|
-
"@axinom/mosaic-id-link-be": "^0.
|
|
36
|
-
"@axinom/mosaic-service-common": "^0.27.0-rc.
|
|
36
|
+
"@axinom/mosaic-id-link-be": "^0.10.0-rc.0",
|
|
37
|
+
"@axinom/mosaic-service-common": "^0.27.0-rc.11",
|
|
37
38
|
"@graphql-inspector/core": "^3.1.2",
|
|
38
39
|
"@stoplight/spectral": "^5.9.1",
|
|
39
40
|
"chalk": "^4.1.0",
|
|
@@ -66,5 +67,5 @@
|
|
|
66
67
|
"publishConfig": {
|
|
67
68
|
"access": "public"
|
|
68
69
|
},
|
|
69
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "140f827280ea9616400d5f6d2f770a0911ebf0e2"
|
|
70
71
|
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Modular Mosaic CLI
|
|
2
|
+
|
|
3
|
+
Mosaic CLI modularity achieved by using Typescript
|
|
4
|
+
[Dynamic Import Expressions](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-4.html#dynamic-import-expressions),
|
|
5
|
+
that allows to asynchronously request a module at any arbitrary point in the
|
|
6
|
+
program.
|
|
7
|
+
|
|
8
|
+
CLI provides possibility to access commands added in other Mosaic libraries
|
|
9
|
+
through `mosaic` script. To load CLI extension Mosaic CLI provides new command
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
mosaic create-extension-config
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
This command scans current project and finds all Mosaic `@axinom/mosaic-*`
|
|
16
|
+
packages used in the project. Each package is checked for CLI extension, by
|
|
17
|
+
importing method `cliExtension` from the package. If extension for Mosaic CLI is
|
|
18
|
+
provided, package will be saved to configuration file `.mosaic` in project root.
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
CLI_EXTENSIONS=@axinom/mosaic-db-common
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Mosaic CLI automatically imports all commands from packages saved in
|
|
25
|
+
configuration file.
|
|
26
|
+
|
|
27
|
+
## Create extension for Modular CLI
|
|
28
|
+
|
|
29
|
+
Mosaic packages can provide extension commands for Mosaic CLI. To define
|
|
30
|
+
extension commands should be used interface `CommandModule` from package
|
|
31
|
+
[`yargs`](https://github.com/yargs/yargs). When creating extension commands for
|
|
32
|
+
Mosaic CLI ensure, that the command name is unique across all Mosaic packages.
|
|
33
|
+
|
|
34
|
+
Extension commands should be exported through method `cliExtension`.
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
export const cliExtension = (): yargs.CommandModule<any, any>[] => [
|
|
38
|
+
{
|
|
39
|
+
command: 'extension-command-start',
|
|
40
|
+
describe: 'Command description...',
|
|
41
|
+
builder: (yargs) =>
|
|
42
|
+
yargs
|
|
43
|
+
.option(...)
|
|
44
|
+
.example(...)
|
|
45
|
+
...etc,
|
|
46
|
+
handler: commandHandler,
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
command: 'extension-command-do',
|
|
50
|
+
describe: 'Command description...',
|
|
51
|
+
builder: (yargs) =>
|
|
52
|
+
yargs
|
|
53
|
+
.option(...)
|
|
54
|
+
.example(...)
|
|
55
|
+
...etc,
|
|
56
|
+
handler: commandHandler,
|
|
57
|
+
},
|
|
58
|
+
];
|
|
59
|
+
|
|
60
|
+
```
|
package/src/cli/index.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as yargs from 'yargs';
|
|
2
|
+
import { applyTemplates } from '../commands/apply-templates';
|
|
3
|
+
import {
|
|
4
|
+
createExtensionConfigCommand,
|
|
5
|
+
getExtensions,
|
|
6
|
+
} from '../commands/create-extension-config';
|
|
7
|
+
import { getAccessToken } from '../commands/get-access-token';
|
|
8
|
+
import { graphqlDiff } from '../commands/graphql-diff';
|
|
9
|
+
import { msgCodegen } from '../commands/msg-codegen';
|
|
10
|
+
import { msgDiff } from '../commands/msg-diff';
|
|
11
|
+
import { pgDump } from '../commands/pg-dump';
|
|
12
|
+
import { publishSchemaToDb } from '../commands/publish-schema-to-db';
|
|
13
|
+
|
|
14
|
+
export const run = async (): Promise<void> => {
|
|
15
|
+
yargs
|
|
16
|
+
.scriptName('mosaic')
|
|
17
|
+
.env()
|
|
18
|
+
.command(applyTemplates)
|
|
19
|
+
.command(getAccessToken)
|
|
20
|
+
.command(publishSchemaToDb)
|
|
21
|
+
.command(pgDump)
|
|
22
|
+
.command(msgCodegen)
|
|
23
|
+
.command(msgDiff)
|
|
24
|
+
.command(createExtensionConfigCommand)
|
|
25
|
+
.command(graphqlDiff);
|
|
26
|
+
|
|
27
|
+
//adding cli extensions:
|
|
28
|
+
await Promise.all(
|
|
29
|
+
getExtensions().map(async (library) => {
|
|
30
|
+
try {
|
|
31
|
+
const { cliExtension } = await import(library);
|
|
32
|
+
if (cliExtension) {
|
|
33
|
+
cliExtension().map((cmd) => {
|
|
34
|
+
yargs.command(cmd);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
} catch (error) {
|
|
38
|
+
//package is either not installed, or doesn't have cli extension
|
|
39
|
+
}
|
|
40
|
+
}),
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
yargs
|
|
44
|
+
.demandCommand()
|
|
45
|
+
.help()
|
|
46
|
+
.epilog(`For more information, visit https://portal.axinom.com.`).argv;
|
|
47
|
+
};
|