@axinom/mosaic-cli 0.8.0 → 0.9.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/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +20 -2
- package/dist/cli/index.js.map +1 -1
- package/dist/commands/create-extension-config/create-extension-config.d.ts +9 -0
- package/dist/commands/create-extension-config/create-extension-config.js +88 -0
- package/dist/commands/create-extension-config/create-extension-config.js.map +1 -0
- package/dist/commands/create-extension-config/index.d.ts +3 -0
- package/dist/commands/create-extension-config/index.js +21 -0
- package/dist/commands/create-extension-config/index.js.map +1 -0
- package/package.json +6 -4
package/dist/cli/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const run: () => void
|
|
1
|
+
export declare const run: () => Promise<void>;
|
package/dist/cli/index.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.run = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
4
5
|
const yargs = require("yargs");
|
|
5
6
|
const apply_templates_1 = require("../commands/apply-templates");
|
|
7
|
+
const create_extension_config_1 = require("../commands/create-extension-config");
|
|
6
8
|
const get_access_token_1 = require("../commands/get-access-token");
|
|
7
9
|
const msg_codegen_1 = require("../commands/msg-codegen");
|
|
8
10
|
const pg_dump_1 = require("../commands/pg-dump");
|
|
9
11
|
const publish_schema_to_db_1 = require("../commands/publish-schema-to-db");
|
|
10
|
-
const run = () => {
|
|
12
|
+
const run = () => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () {
|
|
11
13
|
yargs
|
|
12
14
|
.scriptName('mosaic')
|
|
13
15
|
.env()
|
|
@@ -37,9 +39,25 @@ const run = () => {
|
|
|
37
39
|
.command(publish_schema_to_db_1.publishSchemaToDb)
|
|
38
40
|
.command(pg_dump_1.pgDump)
|
|
39
41
|
.command(msg_codegen_1.msgCodegen)
|
|
42
|
+
.command(create_extension_config_1.createExtensionConfigCommand);
|
|
43
|
+
//adding cli extensions:
|
|
44
|
+
yield Promise.all((0, create_extension_config_1.getExtensions)().map((library) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () {
|
|
45
|
+
try {
|
|
46
|
+
const { cliExtension } = yield Promise.resolve().then(() => require(library));
|
|
47
|
+
if (cliExtension) {
|
|
48
|
+
cliExtension().map((cmd) => {
|
|
49
|
+
yargs.command(cmd);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
//package is either not installed, or doesn't have cli extension
|
|
55
|
+
}
|
|
56
|
+
})));
|
|
57
|
+
yargs
|
|
40
58
|
.demandCommand()
|
|
41
59
|
.help()
|
|
42
60
|
.epilog(`For more information, visit https://portal.axinom.com.`).argv;
|
|
43
|
-
};
|
|
61
|
+
});
|
|
44
62
|
exports.run = run;
|
|
45
63
|
//# sourceMappingURL=index.js.map
|
package/dist/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";;;;AAAA,+BAA+B;AAC/B,iEAA6D;AAC7D,iFAG6C;AAC7C,mEAA8D;AAC9D,yDAAqD;AACrD,iDAA6C;AAC7C,2EAAqE;AAE9D,MAAM,GAAG,GAAG,GAAwB,EAAE;IAC3C,KAAK;SACF,UAAU,CAAC,QAAQ,CAAC;SACpB,GAAG,EAAE;SACL,OAAO,CACN,iBAAiB,EACjB,+CAA+C,EAC/C,CAAC,KAAK,EAAE,EAAE;QACR,KAAK;aACF,MAAM,CAAC,MAAM,EAAE;YACd,KAAK,EAAE,GAAG;YACV,QAAQ,EACN,gHAAgH;YAClH,MAAM,EAAE,IAAI;YACZ,OAAO,EAAE,IAAI;SACd,CAAC;aACD,MAAM,CAAC,SAAS,EAAE;YACjB,KAAK,EAAE,GAAG;YACV,QAAQ,EACN,2EAA2E;YAC7E,OAAO,EAAE,KAAK;YACd,OAAO,EAAE,IAAI;SACd,CAAC;aACD,MAAM,CAAC,KAAK,EAAE;YACb,KAAK,EAAE,GAAG;YACV,IAAI,EAAE,SAAS;YACf,QAAQ,EACN,4FAA4F;YAC9F,OAAO,EAAE,KAAK;YACd,OAAO,EAAE,IAAI;SACd,CAAC,CAAC;IACP,CAAC,EACD,gCAAc,CACf;SACA,OAAO,CAAC,iCAAc,CAAC;SACvB,OAAO,CAAC,wCAAiB,CAAC;SAC1B,OAAO,CAAC,gBAAM,CAAC;SACf,OAAO,CAAC,wBAAU,CAAC;SACnB,OAAO,CAAC,sDAA4B,CAAC,CAAC;IAEzC,wBAAwB;IACxB,MAAM,OAAO,CAAC,GAAG,CACf,IAAA,uCAAa,GAAE,CAAC,GAAG,CAAC,CAAO,OAAO,EAAE,EAAE;QACpC,IAAI;YACF,MAAM,EAAE,YAAY,EAAE,GAAG,2CAAa,OAAO,EAAC,CAAC;YAC/C,IAAI,YAAY,EAAE;gBAChB,YAAY,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;oBACzB,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;gBACrB,CAAC,CAAC,CAAC;aACJ;SACF;QAAC,OAAO,KAAK,EAAE;YACd,gEAAgE;SACjE;IACH,CAAC,CAAA,CAAC,CACH,CAAC;IAEF,KAAK;SACF,aAAa,EAAE;SACf,IAAI,EAAE;SACN,MAAM,CAAC,wDAAwD,CAAC,CAAC,IAAI,CAAC;AAC3E,CAAC,CAAA,CAAC;AA5DW,QAAA,GAAG,OA4Dd"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provides path to '.mosaic' configuration file.
|
|
3
|
+
* Path to file provided based on the location of `yarn.lock`.
|
|
4
|
+
*/
|
|
5
|
+
export declare const getExtensionConfigPath: () => string;
|
|
6
|
+
/**
|
|
7
|
+
* Creates `.mosaic` configuration file with list of libraries, that provide extension for Mosaic CLI.
|
|
8
|
+
*/
|
|
9
|
+
export declare const createExtensionConfig: () => Promise<void>;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createExtensionConfig = exports.getExtensionConfigPath = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const child_process_1 = require("child_process");
|
|
6
|
+
const findNearestFile = require("find-nearest-file");
|
|
7
|
+
const fs = require("fs");
|
|
8
|
+
const path = require("path");
|
|
9
|
+
const util_1 = require("util");
|
|
10
|
+
const execAsync = (0, util_1.promisify)(child_process_1.exec);
|
|
11
|
+
/**
|
|
12
|
+
* Regex to determine version of yarn installed in project: Classic, or Modern.
|
|
13
|
+
* Required to correctly build yarn command to retrieve list of installed packages.
|
|
14
|
+
*/
|
|
15
|
+
const yarnClassicVersionRegex = /^1\..*$/gim;
|
|
16
|
+
/**
|
|
17
|
+
* Regex for Mosaic libraries.
|
|
18
|
+
*/
|
|
19
|
+
const mosaicLibraryRegex = /(?<prefix>@axinom\/mosaic-)(?<library>[-A-Za-z0-9]+)/gim;
|
|
20
|
+
/**
|
|
21
|
+
* Find all Mosaic packages used in project.
|
|
22
|
+
* @returns list of installed packages.
|
|
23
|
+
*/
|
|
24
|
+
const findInstalledPackages = () => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () {
|
|
25
|
+
var _a;
|
|
26
|
+
let installedMosaicLibs = [];
|
|
27
|
+
const yarnVersionResult = yield execAsync('yarn -v');
|
|
28
|
+
if (yarnVersionResult.stderr) {
|
|
29
|
+
console.log(yarnVersionResult.stderr);
|
|
30
|
+
}
|
|
31
|
+
if (yarnVersionResult.stdout) {
|
|
32
|
+
const packagesListCommand = yarnClassicVersionRegex.test(yarnVersionResult.stdout)
|
|
33
|
+
? 'yarn list --pattern @axinom/mosaic-* --depth=0'
|
|
34
|
+
: 'yarn info @axinom/mosaic-* --recursive --all --name-only';
|
|
35
|
+
const packagesListResult = yield execAsync(packagesListCommand);
|
|
36
|
+
if (packagesListResult.stdout) {
|
|
37
|
+
installedMosaicLibs = [
|
|
38
|
+
...new Set((_a = packagesListResult.stdout.match(mosaicLibraryRegex)) !== null && _a !== void 0 ? _a : []),
|
|
39
|
+
];
|
|
40
|
+
}
|
|
41
|
+
if (packagesListResult.stderr) {
|
|
42
|
+
console.log(packagesListResult.stderr);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return installedMosaicLibs;
|
|
46
|
+
});
|
|
47
|
+
/**
|
|
48
|
+
* Provides path to '.mosaic' configuration file.
|
|
49
|
+
* Path to file provided based on the location of `yarn.lock`.
|
|
50
|
+
*/
|
|
51
|
+
const getExtensionConfigPath = () => {
|
|
52
|
+
const yarnLockFilePath = findNearestFile('yarn.lock');
|
|
53
|
+
if (yarnLockFilePath) {
|
|
54
|
+
return path.resolve(path.dirname(yarnLockFilePath), '.mosaic');
|
|
55
|
+
}
|
|
56
|
+
return path.resolve('.mosaic');
|
|
57
|
+
};
|
|
58
|
+
exports.getExtensionConfigPath = getExtensionConfigPath;
|
|
59
|
+
/**
|
|
60
|
+
* Creates `.mosaic` configuration file with list of libraries, that provide extension for Mosaic CLI.
|
|
61
|
+
*/
|
|
62
|
+
const createExtensionConfig = () => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () {
|
|
63
|
+
console.log(`Starting extension configuration generation!`);
|
|
64
|
+
const installedMosaicLibs = yield findInstalledPackages();
|
|
65
|
+
const extensions = [];
|
|
66
|
+
yield Promise.all(installedMosaicLibs.map((lib) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () {
|
|
67
|
+
//filter libraries, that have cli extension
|
|
68
|
+
try {
|
|
69
|
+
const result = yield Promise.resolve().then(() => require(lib));
|
|
70
|
+
if (result.cliExtension) {
|
|
71
|
+
extensions.push(lib);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
//mosaic libraries, that are always(?) failing to load:
|
|
76
|
+
//all `@axinom/mosaic-*-workflows`, @axinom/mosaic-portal, @axinom/mosaic-ui, @axinom/mosaic-home, @axinom/mosaic-id-link
|
|
77
|
+
//todo: extend regex to exclude libraries?
|
|
78
|
+
}
|
|
79
|
+
})));
|
|
80
|
+
console.log(`Modular CLI extensions: ${extensions}`);
|
|
81
|
+
//save library names, that can be used in command line
|
|
82
|
+
const configFilePath = (0, exports.getExtensionConfigPath)();
|
|
83
|
+
const config = `CLI_EXTENSIONS=${extensions.join(',')}`;
|
|
84
|
+
fs.writeFileSync(configFilePath, config);
|
|
85
|
+
console.log(`Success! Extensions configuration file path: ${configFilePath}`);
|
|
86
|
+
});
|
|
87
|
+
exports.createExtensionConfig = createExtensionConfig;
|
|
88
|
+
//# sourceMappingURL=create-extension-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-extension-config.js","sourceRoot":"","sources":["../../../src/commands/create-extension-config/create-extension-config.ts"],"names":[],"mappings":";;;;AAAA,iDAAqC;AACrC,qDAAqD;AACrD,yBAAyB;AACzB,6BAA6B;AAC7B,+BAAiC;AACjC,MAAM,SAAS,GAAG,IAAA,gBAAS,EAAC,oBAAI,CAAC,CAAC;AAElC;;;GAGG;AACH,MAAM,uBAAuB,GAAG,YAAY,CAAC;AAE7C;;GAEG;AACH,MAAM,kBAAkB,GACtB,yDAAyD,CAAC;AAE5D;;;GAGG;AACH,MAAM,qBAAqB,GAAG,GAA4B,EAAE;;IAC1D,IAAI,mBAAmB,GAAa,EAAE,CAAC;IACvC,MAAM,iBAAiB,GAAG,MAAM,SAAS,CAAC,SAAS,CAAC,CAAC;IAErD,IAAI,iBAAiB,CAAC,MAAM,EAAE;QAC5B,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;KACvC;IAED,IAAI,iB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AM,MAAM,GAAG,2CAAa,GAAG,EAAC,CAAC;YACjC,IAAI,MAAM,CAAC,YAAY,EAAE;gBACvB,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;aACtB;SACF;QAAC,OAAO,KAAK,EAAE;YACd,uDAAuD;YACvD,yHAAyH;YACzH,0CAA0C;SAC3C;IACH,CAAC,CAAA,CAAC,CACH,CAAC;IACF,OAAO,CAAC,GAAG,CAAC,2BAA2B,UAAU,EAAE,CAAC,CAAC;IACrD,sDAAsD;IACtD,MAAM,cAAc,GAAG,IAAA,8BAAsB,GAAE,CAAC;IAChD,MAAM,MAAM,GAAG,kBAAkB,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;IACxD,EAAE,CAAC,aAAa,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;IACzC,OAAO,CAAC,GAAG,CAAC,gDAAgD,cAAc,EAAE,CAAC,CAAC;AAChF,CAAC,CAAA,CAAC;AAzBW,QAAA,qBAAqB,yBAyBhC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getExtensions = exports.createExtensionConfigCommand = void 0;
|
|
4
|
+
const dotenv = require("dotenv");
|
|
5
|
+
const create_extension_config_1 = require("./create-extension-config");
|
|
6
|
+
exports.createExtensionConfigCommand = {
|
|
7
|
+
command: 'create-extension-config',
|
|
8
|
+
describe: 'Creates Mosaic CLI configuration file, that allows to access commands from all installed Mosaic libraries through `mosaic` script.',
|
|
9
|
+
handler: create_extension_config_1.createExtensionConfig,
|
|
10
|
+
};
|
|
11
|
+
const getExtensions = () => {
|
|
12
|
+
dotenv.config({
|
|
13
|
+
path: (0, create_extension_config_1.getExtensionConfigPath)(),
|
|
14
|
+
});
|
|
15
|
+
if (process.env.CLI_EXTENSIONS) {
|
|
16
|
+
return process.env.CLI_EXTENSIONS.split(',');
|
|
17
|
+
}
|
|
18
|
+
return [];
|
|
19
|
+
};
|
|
20
|
+
exports.getExtensions = getExtensions;
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/create-extension-config/index.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AAEjC,uEAGmC;AAEtB,QAAA,4BAA4B,GAAsC;IAC7E,OAAO,EAAE,yBAAyB;IAClC,QAAQ,EACN,oIAAoI;IACtI,OAAO,EAAE,+CAAqB;CAC/B,CAAC;AAEK,MAAM,aAAa,GAAG,GAAa,EAAE;IAC1C,MAAM,CAAC,MAAM,CAAC;QACZ,IAAI,EAAE,IAAA,gDAAsB,GAAE;KAC/B,CAAC,CAAC;IACH,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE;QAC9B,OAAO,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;KAC9C;IACD,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AARW,QAAA,aAAa,iBAQxB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axinom/mosaic-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0-rc.0",
|
|
4
4
|
"description": "The Axinom Mosaic CLI",
|
|
5
5
|
"author": "Axinom",
|
|
6
6
|
"license": "PROPRIETARY",
|
|
@@ -28,12 +28,14 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@asyncapi/modelina": "^0.43.0",
|
|
30
30
|
"@asyncapi/parser": "^1.13.2",
|
|
31
|
-
"@axinom/mosaic-id-link-be": "^0.
|
|
32
|
-
"@axinom/mosaic-service-common": "^0.14.
|
|
31
|
+
"@axinom/mosaic-id-link-be": "^0.6.0-rc.1",
|
|
32
|
+
"@axinom/mosaic-service-common": "^0.14.1-rc.2",
|
|
33
33
|
"@stoplight/spectral": "^5.9.1",
|
|
34
34
|
"chalk": "^4.1.0",
|
|
35
35
|
"diff": "^5.0.0",
|
|
36
|
+
"dotenv": "^8.2.0",
|
|
36
37
|
"endent": "^2.0.1",
|
|
38
|
+
"find-nearest-file": "^1.1.0",
|
|
37
39
|
"glob": "^7.1.6",
|
|
38
40
|
"graphile-build": "^4.12.0",
|
|
39
41
|
"graphile-build-pg": "^4.12.1",
|
|
@@ -58,5 +60,5 @@
|
|
|
58
60
|
"publishConfig": {
|
|
59
61
|
"access": "public"
|
|
60
62
|
},
|
|
61
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "d155d361420d2b7ecbc4cc0cc9114cec2a66a711"
|
|
62
64
|
}
|