endpoints-sdk-cli 2.1.0 → 2.2.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/CHANGELOG.md +28 -0
- package/README.md +5 -5
- package/lib/classes/Config.d.ts +20 -0
- package/lib/classes/Config.js +52 -0
- package/lib/classes/Repository.d.ts +38 -0
- package/lib/classes/Repository.js +60 -0
- package/lib/commands/add.js +17 -28
- package/lib/commands/install.js +14 -12
- package/lib/commands/update.js +19 -16
- package/lib/endpoints/m2m-core.d.ts +4 -0
- package/lib/endpoints/m2m-core.js +7 -0
- package/lib/endpoints/m2m-core.v1.d.ts +527 -0
- package/lib/endpoints/m2m-core.v1.js +1084 -0
- package/lib/endpoints/m2m-notifications.d.ts +4 -0
- package/lib/endpoints/m2m-notifications.js +7 -0
- package/lib/endpoints/m2m-notifications.v1.d.ts +50 -0
- package/lib/endpoints/m2m-notifications.v1.js +133 -0
- package/lib/endpoints/m2m-users.d.ts +4 -0
- package/lib/endpoints/m2m-users.js +7 -0
- package/lib/endpoints/m2m-users.v1.d.ts +210 -0
- package/lib/endpoints/m2m-users.v1.js +529 -0
- package/lib/index.js +1 -0
- package/lib/makeFiles.d.ts +7 -0
- package/lib/makeFiles.js +21 -0
- package/lib/templates/files/endpoints.d.ts +8 -0
- package/lib/templates/files/endpoints.js +21 -0
- package/lib/templates/files/index.d.ts +2 -0
- package/lib/templates/files/index.js +7 -0
- package/lib/templates/files/indexFile.d.ts +8 -0
- package/lib/templates/files/indexFile.js +16 -0
- package/lib/templates/functions/endpoint.d.ts +2 -0
- package/lib/templates/functions/endpoint.js +89 -0
- package/lib/templates/functions/index.d.ts +2 -0
- package/lib/templates/functions/index.js +5 -0
- package/lib/templates/functions/root.d.ts +6 -0
- package/lib/templates/functions/root.js +30 -0
- package/lib/templates/index.d.ts +2 -0
- package/lib/templates/index.js +6 -0
- package/lib/utils/format.d.ts +1 -0
- package/lib/utils/format.js +8 -0
- package/lib/utils/unique.d.ts +1 -0
- package/lib/utils/unique.js +14 -0
- package/oclif.manifest.json +1 -1
- package/package.json +17 -17
- package/lib/constants.d.ts +0 -1
- package/lib/constants.js +0 -4
- package/lib/parts/makeEndpointsFiles.d.ts +0 -6
- package/lib/parts/makeEndpointsFiles.js +0 -41
- package/lib/parts/makeEndpointsSourceFromRepository.d.ts +0 -11
- package/lib/parts/makeEndpointsSourceFromRepository.js +0 -37
- package/lib/types.d.ts +0 -30
- package/lib/types.js +0 -1
- package/lib/utils/extractServiceNameFromPath.d.ts +0 -1
- package/lib/utils/extractServiceNameFromPath.js +0 -8
- package/lib/utils/getConfig.d.ts +0 -1
- package/lib/utils/getConfig.js +0 -12
- package/lib/utils/inferRepository.d.ts +0 -1
- package/lib/utils/inferRepository.js +0 -20
- package/lib/utils/parseEndpoints.d.ts +0 -23
- package/lib/utils/parseEndpoints.js +0 -74
- package/lib/utils/parseUrl.d.ts +0 -17
- package/lib/utils/parseUrl.js +0 -43
- package/lib/utils/updateConfigFile.d.ts +0 -6
- package/lib/utils/updateConfigFile.js +0 -20
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,34 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [2.2.0](https://github.com/matsuri-tech/endpoints-sdk-cli/compare/v2.1.3...v2.2.0) (2022-01-10)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* make it work with repositories whose main branch is not master ([574c1e8](https://github.com/matsuri-tech/endpoints-sdk-cli/commit/574c1e8d769cb6402ba32472f602db8a73ed7ec4))
|
|
11
|
+
|
|
12
|
+
### [2.1.3](https://github.com/matsuri-tech/endpoints-sdk-cli/compare/v2.1.2...v2.1.3) (2020-12-04)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* make config.output use relative path instead of absolute path ([5a57c95](https://github.com/matsuri-tech/endpoints-sdk-cli/commit/5a57c95034d685153839b6d05a3ec67b2f2643f9))
|
|
18
|
+
|
|
19
|
+
### [2.1.2](https://github.com/matsuri-tech/endpoints-sdk-cli/compare/v2.1.1...v2.1.2) (2020-09-10)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
* make function names camelCase ([8fcd5d2](https://github.com/matsuri-tech/endpoints-sdk-cli/commit/8fcd5d276648b320209c5fae172732f4ebb284db))
|
|
25
|
+
|
|
26
|
+
### [2.1.1](https://github.com/matsuri-tech/endpoints-sdk-cli/compare/v2.1.0...v2.1.1) (2020-08-20)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Bug Fixes
|
|
30
|
+
|
|
31
|
+
* replace path.relative with path.resolve ([c125116](https://github.com/matsuri-tech/endpoints-sdk-cli/commit/c125116f2ed2d3e0f1dfb936bd8eee2c7f98e134))
|
|
32
|
+
|
|
5
33
|
## [2.1.0](https://github.com/matsuri-tech/endpoints-sdk-cli/compare/v2.0.6...v2.1.0) (2020-07-16)
|
|
6
34
|
|
|
7
35
|
|
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ $ npm install -g endpoints-sdk-cli
|
|
|
17
17
|
$ mes COMMAND
|
|
18
18
|
running command...
|
|
19
19
|
$ mes (-v|--version|version)
|
|
20
|
-
endpoints-sdk-cli/2.
|
|
20
|
+
endpoints-sdk-cli/2.2.0 darwin-x64 node-v16.6.0
|
|
21
21
|
$ mes --help [COMMAND]
|
|
22
22
|
USAGE
|
|
23
23
|
$ mes COMMAND
|
|
@@ -74,7 +74,7 @@ EXAMPLES
|
|
|
74
74
|
$ mes add https://github.com/[username/repository].git
|
|
75
75
|
```
|
|
76
76
|
|
|
77
|
-
_See code: [src/commands/add.ts](https://github.com/matsuri-tech/endpoints-sdk-cli/blob/v2.
|
|
77
|
+
_See code: [src/commands/add.ts](https://github.com/matsuri-tech/endpoints-sdk-cli/blob/v2.2.0/src/commands/add.ts)_
|
|
78
78
|
|
|
79
79
|
## `mes help [COMMAND]`
|
|
80
80
|
|
|
@@ -91,7 +91,7 @@ OPTIONS
|
|
|
91
91
|
--all see all commands in CLI
|
|
92
92
|
```
|
|
93
93
|
|
|
94
|
-
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v3.
|
|
94
|
+
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v3.2.0/src/commands/help.ts)_
|
|
95
95
|
|
|
96
96
|
## `mes install`
|
|
97
97
|
|
|
@@ -102,7 +102,7 @@ USAGE
|
|
|
102
102
|
$ mes install
|
|
103
103
|
```
|
|
104
104
|
|
|
105
|
-
_See code: [src/commands/install.ts](https://github.com/matsuri-tech/endpoints-sdk-cli/blob/v2.
|
|
105
|
+
_See code: [src/commands/install.ts](https://github.com/matsuri-tech/endpoints-sdk-cli/blob/v2.2.0/src/commands/install.ts)_
|
|
106
106
|
|
|
107
107
|
## `mes update [SERVICE]`
|
|
108
108
|
|
|
@@ -113,7 +113,7 @@ USAGE
|
|
|
113
113
|
$ mes update [SERVICE]
|
|
114
114
|
```
|
|
115
115
|
|
|
116
|
-
_See code: [src/commands/update.ts](https://github.com/matsuri-tech/endpoints-sdk-cli/blob/v2.
|
|
116
|
+
_See code: [src/commands/update.ts](https://github.com/matsuri-tech/endpoints-sdk-cli/blob/v2.2.0/src/commands/update.ts)_
|
|
117
117
|
<!-- commandsstop -->
|
|
118
118
|
|
|
119
119
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare class Config {
|
|
2
|
+
dependencies: {
|
|
3
|
+
[service: string]: {
|
|
4
|
+
version: string;
|
|
5
|
+
repository: string;
|
|
6
|
+
workspaces?: string[];
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
path: string;
|
|
10
|
+
output: string;
|
|
11
|
+
environment_identifier: string;
|
|
12
|
+
constructor();
|
|
13
|
+
push({ name, path, version, workspace }: {
|
|
14
|
+
name: string;
|
|
15
|
+
path: string;
|
|
16
|
+
version: string;
|
|
17
|
+
workspace?: string;
|
|
18
|
+
}): void;
|
|
19
|
+
publish(): void;
|
|
20
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Config = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const fs = tslib_1.__importStar(require("fs"));
|
|
6
|
+
const path = tslib_1.__importStar(require("path"));
|
|
7
|
+
const prettier = tslib_1.__importStar(require("prettier"));
|
|
8
|
+
const unique_1 = require("../utils/unique");
|
|
9
|
+
class Config {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.dependencies = {};
|
|
12
|
+
this.path = 'endpoints.config.json';
|
|
13
|
+
this.output = fs.existsSync(path.resolve('./src')) ? './src/endpoints/' : './endpoints/';
|
|
14
|
+
this.environment_identifier = 'process.env.NODE_ENV';
|
|
15
|
+
if (fs.existsSync(this.path)) {
|
|
16
|
+
const data = JSON.parse(fs.readFileSync(this.path).toString());
|
|
17
|
+
if (data.dependencies) {
|
|
18
|
+
this.dependencies = data.dependencies;
|
|
19
|
+
}
|
|
20
|
+
if (data.output) {
|
|
21
|
+
this.output = data.output;
|
|
22
|
+
}
|
|
23
|
+
if (!fs.existsSync(this.output)) {
|
|
24
|
+
fs.mkdirSync(this.output);
|
|
25
|
+
}
|
|
26
|
+
if (data.environment_identifier) {
|
|
27
|
+
this.environment_identifier = data.environment_identifier;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
push({ name, path, version, workspace }) {
|
|
32
|
+
var _a, _b;
|
|
33
|
+
const workspaces = unique_1.unique([
|
|
34
|
+
...(((_b = (_a = this.dependencies) === null || _a === void 0 ? void 0 : _a[name]) === null || _b === void 0 ? void 0 : _b.workspaces) || []),
|
|
35
|
+
workspace,
|
|
36
|
+
]).filter((w) => Boolean(w));
|
|
37
|
+
this.dependencies = Object.assign(Object.assign({}, this.dependencies), { [name]: {
|
|
38
|
+
version,
|
|
39
|
+
repository: path,
|
|
40
|
+
workspaces: workspaces.length > 0 ? workspaces : undefined,
|
|
41
|
+
} });
|
|
42
|
+
}
|
|
43
|
+
publish() {
|
|
44
|
+
const data = {
|
|
45
|
+
output: this.output,
|
|
46
|
+
environment_identifier: this.environment_identifier,
|
|
47
|
+
dependencies: this.dependencies,
|
|
48
|
+
};
|
|
49
|
+
fs.writeFileSync(this.path, prettier.format(JSON.stringify(data, null, 2), { parser: 'json' }));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.Config = Config;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export interface Env {
|
|
2
|
+
local: string;
|
|
3
|
+
dev: string;
|
|
4
|
+
prod: string;
|
|
5
|
+
[key: string]: string;
|
|
6
|
+
}
|
|
7
|
+
export interface Endpoint {
|
|
8
|
+
path: string;
|
|
9
|
+
desc: string;
|
|
10
|
+
}
|
|
11
|
+
export interface Api {
|
|
12
|
+
[endpoint: string]: Endpoint;
|
|
13
|
+
}
|
|
14
|
+
export interface Period {
|
|
15
|
+
env: Env;
|
|
16
|
+
api: Api;
|
|
17
|
+
}
|
|
18
|
+
export interface Data {
|
|
19
|
+
[version: string]: Period;
|
|
20
|
+
}
|
|
21
|
+
export declare class Repository {
|
|
22
|
+
name: string;
|
|
23
|
+
path: string;
|
|
24
|
+
cache: string;
|
|
25
|
+
hash: string;
|
|
26
|
+
data: Data;
|
|
27
|
+
constructor(str: string);
|
|
28
|
+
clone({ version, workspace }: {
|
|
29
|
+
version?: string;
|
|
30
|
+
workspace?: string;
|
|
31
|
+
}): void;
|
|
32
|
+
private checkout;
|
|
33
|
+
private revParse;
|
|
34
|
+
private reset;
|
|
35
|
+
clean(): void;
|
|
36
|
+
private inferPath;
|
|
37
|
+
private getName;
|
|
38
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Repository = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const path = tslib_1.__importStar(require("path"));
|
|
6
|
+
const child_process_1 = require("child_process");
|
|
7
|
+
const fs = tslib_1.__importStar(require("fs"));
|
|
8
|
+
const rimraf_1 = tslib_1.__importDefault(require("rimraf"));
|
|
9
|
+
class Repository {
|
|
10
|
+
constructor(str) {
|
|
11
|
+
this.hash = 'latest';
|
|
12
|
+
this.data = {};
|
|
13
|
+
this.path = this.inferPath(str);
|
|
14
|
+
this.name = this.getName();
|
|
15
|
+
this.cache = path.resolve(`./node_modules/.endpoints-tmp/${Math.random().toString(36).slice(-8)}`);
|
|
16
|
+
}
|
|
17
|
+
clone({ version, workspace = '' }) {
|
|
18
|
+
child_process_1.execSync(`git clone --no-checkout --quiet ${this.path} ${this.cache}`);
|
|
19
|
+
this.reset(version);
|
|
20
|
+
this.hash = this.revParse();
|
|
21
|
+
this.data = this.checkout(workspace);
|
|
22
|
+
}
|
|
23
|
+
checkout(workspace) {
|
|
24
|
+
const file = path.resolve(this.cache, workspace, '.endpoints.json');
|
|
25
|
+
const mainBranch = child_process_1.execSync(`cd ${this.cache}; git rev-parse --abbrev-ref origin/HEAD`).toString().trim();
|
|
26
|
+
child_process_1.execSync(`cd ${this.cache}; git checkout ${mainBranch} -- ${file}`);
|
|
27
|
+
return JSON.parse(fs.readFileSync(file).toString());
|
|
28
|
+
}
|
|
29
|
+
revParse() {
|
|
30
|
+
const hash = child_process_1.execSync(`cd ${this.cache}; git rev-parse HEAD`)
|
|
31
|
+
.toString()
|
|
32
|
+
.trim();
|
|
33
|
+
return hash;
|
|
34
|
+
}
|
|
35
|
+
reset(version) {
|
|
36
|
+
if (version && version !== 'latest') {
|
|
37
|
+
child_process_1.execSync(`cd ${this.cache}; git reset --hard ${version}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
clean() {
|
|
41
|
+
rimraf_1.default.sync(this.cache);
|
|
42
|
+
}
|
|
43
|
+
inferPath(str) {
|
|
44
|
+
if (str.startsWith('https://') ||
|
|
45
|
+
str.startsWith('git@') ||
|
|
46
|
+
str.startsWith('/')) {
|
|
47
|
+
return str;
|
|
48
|
+
}
|
|
49
|
+
if (str.startsWith('./')) {
|
|
50
|
+
return path.resolve(str);
|
|
51
|
+
}
|
|
52
|
+
return `git@github.com:${str}.git`;
|
|
53
|
+
}
|
|
54
|
+
getName() {
|
|
55
|
+
const splits = this.path.split('/');
|
|
56
|
+
const name = splits[splits.length - 1].split(/\./)[0];
|
|
57
|
+
return name;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.Repository = Repository;
|
package/lib/commands/add.js
CHANGED
|
@@ -1,43 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const Config_1 = require("../classes/Config");
|
|
3
4
|
const command_1 = require("@oclif/command");
|
|
4
|
-
const fs_1 = require("fs");
|
|
5
5
|
const color_1 = require("@oclif/color");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const inferRepository_1 = require("../utils/inferRepository");
|
|
9
|
-
const extractServiceNameFromPath_1 = require("../utils/extractServiceNameFromPath");
|
|
10
|
-
const constants_1 = require("../constants");
|
|
11
|
-
const updateConfigFile_1 = require("../utils/updateConfigFile");
|
|
6
|
+
const Repository_1 = require("../classes/Repository");
|
|
7
|
+
const makeFiles_1 = require("../makeFiles");
|
|
12
8
|
class Add extends command_1.Command {
|
|
13
9
|
async run() {
|
|
14
|
-
const { flags, args } = this.parse(Add);
|
|
15
|
-
const repository =
|
|
16
|
-
const repository_name = extractServiceNameFromPath_1.extractServiceNameFromPath(repository);
|
|
17
|
-
const { getEndpointsSourceFromRepository, cleanEndpointsSourceFromRepository, } = makeEndpointsSourceFromRepository_1.makeEndpointsSourceFromRepository();
|
|
10
|
+
const { flags: { version, workspace }, args } = this.parse(Add);
|
|
11
|
+
const repository = new Repository_1.Repository(args.repository);
|
|
18
12
|
try {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
repository.clone({ version, workspace });
|
|
14
|
+
const config = new Config_1.Config();
|
|
15
|
+
makeFiles_1.makeFiles({ repository, config, workspace });
|
|
16
|
+
config.push({
|
|
17
|
+
name: repository.name,
|
|
18
|
+
path: repository.path,
|
|
19
|
+
version: version || repository.hash,
|
|
20
|
+
workspace,
|
|
23
21
|
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
{ dependencies: {} };
|
|
27
|
-
makeEndpointsFiles_1.makeEndpointsFiles({ workspace: flags.workspace, data, config, repository_name });
|
|
28
|
-
updateConfigFile_1.updateConfigFile(config, {
|
|
29
|
-
service: repository_name,
|
|
30
|
-
repository,
|
|
31
|
-
workspace: flags.workspace,
|
|
32
|
-
version: flags.version || hash,
|
|
33
|
-
});
|
|
34
|
-
this.log(`${color_1.color.green('success')}: ${repository_name} updated!`);
|
|
22
|
+
config.publish();
|
|
23
|
+
this.log(`${color_1.color.green('success')}: ${repository.name} updated!`);
|
|
35
24
|
}
|
|
36
25
|
catch (error) {
|
|
37
|
-
this.error(color_1.color.red(error.
|
|
26
|
+
this.error(color_1.color.red(error.stack));
|
|
38
27
|
}
|
|
39
28
|
finally {
|
|
40
|
-
|
|
29
|
+
repository.clean();
|
|
41
30
|
}
|
|
42
31
|
}
|
|
43
32
|
}
|
package/lib/commands/install.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const Config_1 = require("../classes/Config");
|
|
3
4
|
const command_1 = require("@oclif/command");
|
|
4
5
|
const color_1 = require("@oclif/color");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const makeEndpointsFiles_1 = require("../parts/makeEndpointsFiles");
|
|
6
|
+
const Repository_1 = require("../classes/Repository");
|
|
7
|
+
const makeFiles_1 = require("../makeFiles");
|
|
8
8
|
class Install extends command_1.Command {
|
|
9
9
|
async run() {
|
|
10
|
-
const
|
|
10
|
+
const repositories = [];
|
|
11
11
|
try {
|
|
12
|
-
const config =
|
|
12
|
+
const config = new Config_1.Config();
|
|
13
13
|
if (!config.dependencies) {
|
|
14
14
|
throw new Error('Dependencies property of the endpoints.config.json does not exist. Use the add command to add dependencies before installing');
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
Object.values(config.dependencies).forEach(({ repository: path, version, workspaces = [''] }) => {
|
|
17
|
+
workspaces.forEach(workspace => {
|
|
18
|
+
const repository = new Repository_1.Repository(path);
|
|
19
|
+
repositories.push(repository);
|
|
20
|
+
repository.clone({ version, workspace });
|
|
21
|
+
makeFiles_1.makeFiles({ repository, workspace, config });
|
|
22
22
|
});
|
|
23
23
|
});
|
|
24
24
|
}
|
|
@@ -26,7 +26,9 @@ class Install extends command_1.Command {
|
|
|
26
26
|
this.error(color_1.color.red(error.message));
|
|
27
27
|
}
|
|
28
28
|
finally {
|
|
29
|
-
|
|
29
|
+
repositories.forEach(repository => {
|
|
30
|
+
repository.clean();
|
|
31
|
+
});
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
34
|
}
|
package/lib/commands/update.js
CHANGED
|
@@ -1,41 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const Repository_1 = require("../classes/Repository");
|
|
4
|
+
const Config_1 = require("../classes/Config");
|
|
3
5
|
const command_1 = require("@oclif/command");
|
|
4
6
|
const color_1 = require("@oclif/color");
|
|
5
|
-
const
|
|
6
|
-
const makeEndpointsSourceFromRepository_1 = require("../parts/makeEndpointsSourceFromRepository");
|
|
7
|
-
const makeEndpointsFiles_1 = require("../parts/makeEndpointsFiles");
|
|
8
|
-
const updateConfigFile_1 = require("../utils/updateConfigFile");
|
|
7
|
+
const makeFiles_1 = require("../makeFiles");
|
|
9
8
|
class Update extends command_1.Command {
|
|
10
9
|
async run() {
|
|
11
10
|
const { args } = this.parse(Update);
|
|
12
|
-
const
|
|
11
|
+
const repositories = [];
|
|
13
12
|
try {
|
|
14
|
-
const config =
|
|
13
|
+
const config = new Config_1.Config();
|
|
15
14
|
if (!config.dependencies) {
|
|
16
15
|
throw new Error('Dependencies property of the endpoints.config.json does not exist. Use the add command to add dependencies before installing');
|
|
17
16
|
}
|
|
18
17
|
if (!(args.service in config.dependencies)) {
|
|
19
18
|
throw new Error('The service does not exist in the dependency. Check dependencies property of the endpoints.config.json. Or use the add command to add dependencies before installing');
|
|
20
19
|
}
|
|
21
|
-
const { repository, version, workspaces = [''] } = config.dependencies[args.service];
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
repository,
|
|
20
|
+
const { repository: path, version, workspaces = [''] } = config.dependencies[args.service];
|
|
21
|
+
workspaces.forEach(workspace => {
|
|
22
|
+
const repository = new Repository_1.Repository(path);
|
|
23
|
+
repository.clone({ version, workspace });
|
|
24
|
+
makeFiles_1.makeFiles({ repository, config, workspace });
|
|
25
|
+
config.push({
|
|
26
|
+
name: repository.name,
|
|
27
|
+
path: repository.path,
|
|
28
|
+
version: version || repository.hash,
|
|
30
29
|
workspace,
|
|
31
30
|
});
|
|
31
|
+
repositories.push(repository);
|
|
32
32
|
});
|
|
33
|
+
config.publish();
|
|
33
34
|
}
|
|
34
35
|
catch (error) {
|
|
35
36
|
this.error(color_1.color.red(error.message));
|
|
36
37
|
}
|
|
37
38
|
finally {
|
|
38
|
-
|
|
39
|
+
repositories.forEach(repository => {
|
|
40
|
+
repository.clean();
|
|
41
|
+
});
|
|
39
42
|
}
|
|
40
43
|
}
|
|
41
44
|
}
|