endpoints-sdk-cli 2.8.0 → 3.0.0-alpha-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/binary.js +56 -0
- package/install.js +4 -0
- package/package.json +8 -69
- package/run.js +4 -0
- package/LICENSE +0 -21
- package/README.md +0 -152
- package/bin/run +0 -5
- package/bin/run.cmd +0 -3
- package/lib/classes/Config.d.ts +0 -38
- package/lib/classes/Config.js +0 -47
- package/lib/classes/Repository.d.ts +0 -50
- package/lib/classes/Repository.js +0 -65
- package/lib/commands/add.d.ts +0 -15
- package/lib/commands/add.js +0 -85
- package/lib/commands/install.d.ts +0 -5
- package/lib/commands/install.js +0 -37
- package/lib/commands/update.d.ts +0 -8
- package/lib/commands/update.js +0 -50
- package/lib/endpoints/sumyca.d.ts +0 -8
- package/lib/endpoints/sumyca.guest-v3.d.ts +0 -1131
- package/lib/endpoints/sumyca.guest-v3.js +0 -1312
- package/lib/endpoints/sumyca.js +0 -9
- package/lib/endpoints/sumyca.manager-v3.d.ts +0 -2073
- package/lib/endpoints/sumyca.manager-v3.js +0 -2670
- package/lib/endpoints/sumyca.v3.d.ts +0 -3104
- package/lib/endpoints/sumyca.v3.js +0 -3834
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -5
- package/lib/makeFiles.d.ts +0 -9
- package/lib/makeFiles.js +0 -25
- package/lib/templates/files/endpoints.d.ts +0 -9
- package/lib/templates/files/endpoints.js +0 -23
- package/lib/templates/files/index.d.ts +0 -2
- package/lib/templates/files/index.js +0 -7
- package/lib/templates/files/indexFile.d.ts +0 -8
- package/lib/templates/files/indexFile.js +0 -17
- package/lib/templates/functions/endpoint.d.ts +0 -2
- package/lib/templates/functions/endpoint.js +0 -98
- package/lib/templates/functions/index.d.ts +0 -2
- package/lib/templates/functions/index.js +0 -5
- package/lib/templates/functions/root.d.ts +0 -6
- package/lib/templates/functions/root.js +0 -31
- package/lib/templates/index.d.ts +0 -2
- package/lib/templates/index.js +0 -6
- package/lib/utils/camelCase.d.ts +0 -1
- package/lib/utils/camelCase.js +0 -10
- package/lib/utils/format.d.ts +0 -1
- package/lib/utils/format.js +0 -9
- package/lib/utils/unique.d.ts +0 -1
- package/lib/utils/unique.js +0 -15
- package/oclif.manifest.json +0 -1
package/binary.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const { Binary } = require("binary-install");
|
|
2
|
+
const os = require("os");
|
|
3
|
+
|
|
4
|
+
const windows = "x86_64-pc-windows-msvc";
|
|
5
|
+
|
|
6
|
+
const getPlatform = () => {
|
|
7
|
+
const type = os.type();
|
|
8
|
+
const arch = os.arch();
|
|
9
|
+
|
|
10
|
+
// https://github.com/nodejs/node/blob/c3664227a83cf009e9a2e1ddeadbd09c14ae466f/deps/uv/src/win/util.c#L1566-L1573
|
|
11
|
+
if (
|
|
12
|
+
(type === "Windows_NT" || type.startsWith("MINGW32_NT-")) &&
|
|
13
|
+
arch === "x64"
|
|
14
|
+
) {
|
|
15
|
+
return windows;
|
|
16
|
+
}
|
|
17
|
+
if (type === "Linux" && arch === "x64") {
|
|
18
|
+
return "x86_64-unknown-linux-musl";
|
|
19
|
+
}
|
|
20
|
+
if (type === "Linux" && arch === "arm64") {
|
|
21
|
+
return "aarch64-unknown-linux-musl";
|
|
22
|
+
}
|
|
23
|
+
if (type === "Darwin" && (arch === "x64" || arch === "arm64")) {
|
|
24
|
+
return "x86_64-apple-darwin";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
throw new Error(`Unsupported platform: ${type} ${arch}`);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const getBinary = () => {
|
|
31
|
+
const platform = getPlatform();
|
|
32
|
+
const pkg = require("./package.json");
|
|
33
|
+
const version = pkg.version;
|
|
34
|
+
const org = "matsuri-tech";
|
|
35
|
+
const name = pkg.name;
|
|
36
|
+
const url = `https://github.com/${org}/${name}/releases/download/v${version}/${name}-v${version}-${platform}.tar.gz`;
|
|
37
|
+
return new Binary(
|
|
38
|
+
platform === windows ? "literate-disco.exe" : "literate-disco",
|
|
39
|
+
url
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const install = () => {
|
|
44
|
+
const binary = getBinary();
|
|
45
|
+
binary.install();
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const run = () => {
|
|
49
|
+
const binary = getBinary();
|
|
50
|
+
binary.run();
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
module.exports = {
|
|
54
|
+
install,
|
|
55
|
+
run,
|
|
56
|
+
};
|
package/install.js
ADDED
package/package.json
CHANGED
|
@@ -1,76 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "endpoints-sdk-cli",
|
|
3
|
-
"description": "endpoints sdk cli",
|
|
4
|
-
"version": "2.8.0",
|
|
5
3
|
"author": "hrdtbs",
|
|
4
|
+
"version": "3.0.0-alpha-2.0",
|
|
5
|
+
"main": "binary.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"postinstall": "node ./install.js"
|
|
8
|
+
},
|
|
6
9
|
"bin": {
|
|
7
|
-
"mes": "./
|
|
10
|
+
"mes": "./run.js"
|
|
8
11
|
},
|
|
9
|
-
"bugs": "https://github.com/matsuri-tech/endpoints-sdk-cli/issues",
|
|
10
12
|
"dependencies": {
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
"@oclif/command": "^1.8.0",
|
|
14
|
-
"@oclif/config": "^1.17.0",
|
|
15
|
-
"@oclif/plugin-help": "^3.2.0",
|
|
16
|
-
"cli-ux": "^5.4.10",
|
|
17
|
-
"json-schema-to-typescript": "^13.1.1",
|
|
18
|
-
"prettier": "^2.1.1",
|
|
19
|
-
"rimraf": "^3.0.2",
|
|
20
|
-
"tslib": "^2.0.1"
|
|
21
|
-
},
|
|
22
|
-
"devDependencies": {
|
|
23
|
-
"@oclif/dev-cli": "^1",
|
|
24
|
-
"@oclif/test": "^1.2.6",
|
|
25
|
-
"@types/chai": "^4.2.12",
|
|
26
|
-
"@types/mocha": "^8.0.3",
|
|
27
|
-
"@types/node": "^14.6.1",
|
|
28
|
-
"@types/prettier": "^2.1.0",
|
|
29
|
-
"@types/rimraf": "^3.0.0",
|
|
30
|
-
"@types/supports-color": "^5.3.0",
|
|
31
|
-
"chai": "^4",
|
|
32
|
-
"eslint": "^7.7.0",
|
|
33
|
-
"eslint-config-oclif": "^3.1",
|
|
34
|
-
"eslint-config-oclif-typescript": "^0.2.0",
|
|
35
|
-
"globby": "^11.0.1",
|
|
36
|
-
"mocha": "^10.0.0",
|
|
37
|
-
"nyc": "^15.1.0",
|
|
38
|
-
"standard-version": "^9.0.0",
|
|
39
|
-
"ts-node": "^9.0.0",
|
|
40
|
-
"typescript": "^4.0.2"
|
|
41
|
-
},
|
|
42
|
-
"engines": {
|
|
43
|
-
"node": ">=8.0.0"
|
|
44
|
-
},
|
|
45
|
-
"files": [
|
|
46
|
-
"/bin",
|
|
47
|
-
"/lib",
|
|
48
|
-
"/npm-shrinkwrap.json",
|
|
49
|
-
"/oclif.manifest.json",
|
|
50
|
-
"/schema.json"
|
|
51
|
-
],
|
|
52
|
-
"homepage": "https://github.com/matsuri-tech/endpoints-sdk-cli",
|
|
53
|
-
"keywords": [
|
|
54
|
-
"oclif"
|
|
55
|
-
],
|
|
56
|
-
"license": "MIT",
|
|
57
|
-
"main": "lib/index.js",
|
|
58
|
-
"oclif": {
|
|
59
|
-
"commands": "./lib/commands",
|
|
60
|
-
"bin": "mes",
|
|
61
|
-
"plugins": [
|
|
62
|
-
"@oclif/plugin-help"
|
|
63
|
-
]
|
|
64
|
-
},
|
|
65
|
-
"repository": "matsuri-tech/endpoints-sdk-cli",
|
|
66
|
-
"scripts": {
|
|
67
|
-
"dev": "tsc -b",
|
|
68
|
-
"devlink": "yarn unlink && yarn dev && yarn link",
|
|
69
|
-
"postpack": "rm -f oclif.manifest.json",
|
|
70
|
-
"posttest": "eslint . --ext .ts --config .eslintrc",
|
|
71
|
-
"prepack": "rm -rf lib && tsc -b && oclif-dev manifest && oclif-dev readme",
|
|
72
|
-
"test": "nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\"",
|
|
73
|
-
"release": "yarn dev && standard-version && yarn prepack && git add README.md && git commit --amend --no-edit && git push --follow-tags origin master"
|
|
74
|
-
},
|
|
75
|
-
"types": "lib/index.d.ts"
|
|
13
|
+
"binary-install": "^1.0.1"
|
|
14
|
+
}
|
|
76
15
|
}
|
package/run.js
ADDED
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2019 Jeff Dickey @jdxcode
|
|
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
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
matsuri-tech/endpoints-sdk-cli (mes)
|
|
2
|
-
=======================
|
|
3
|
-
|
|
4
|
-
Endpoints SDK for JavaScript
|
|
5
|
-
|
|
6
|
-
※ Include the generated endpoint files in commits.
|
|
7
|
-
|
|
8
|
-
<!-- toc -->
|
|
9
|
-
* [Usage](#usage)
|
|
10
|
-
* [Commands](#commands)
|
|
11
|
-
* [Support of `create-react-app`](#support-of-create-react-app)
|
|
12
|
-
* [Override root url](#override-root-url)
|
|
13
|
-
<!-- tocstop -->
|
|
14
|
-
# Usage
|
|
15
|
-
<!-- usage -->
|
|
16
|
-
```sh-session
|
|
17
|
-
$ npm install -g endpoints-sdk-cli
|
|
18
|
-
$ mes COMMAND
|
|
19
|
-
running command...
|
|
20
|
-
$ mes (-v|--version|version)
|
|
21
|
-
endpoints-sdk-cli/2.8.0 darwin-arm64 node-v18.19.0
|
|
22
|
-
$ mes --help [COMMAND]
|
|
23
|
-
USAGE
|
|
24
|
-
$ mes COMMAND
|
|
25
|
-
...
|
|
26
|
-
```
|
|
27
|
-
<!-- usagestop -->
|
|
28
|
-
# Commands
|
|
29
|
-
<!-- commands -->
|
|
30
|
-
* [`mes add [REPOSITORY]`](#mes-add-repository)
|
|
31
|
-
* [`mes help [COMMAND]`](#mes-help-command)
|
|
32
|
-
* [`mes install`](#mes-install)
|
|
33
|
-
* [`mes update [SERVICE]`](#mes-update-service)
|
|
34
|
-
|
|
35
|
-
## `mes add [REPOSITORY]`
|
|
36
|
-
|
|
37
|
-
add service to dependencies & make endpoints files.
|
|
38
|
-
|
|
39
|
-
```
|
|
40
|
-
USAGE
|
|
41
|
-
$ mes add [REPOSITORY]
|
|
42
|
-
|
|
43
|
-
OPTIONS
|
|
44
|
-
-b, --branch=branch branch name to clone
|
|
45
|
-
-e, --excludes=excludes exclude periods
|
|
46
|
-
-v, --version=version latest or commit hash
|
|
47
|
-
-w, --workspace=workspace a path to workspace containing .endpoints.json
|
|
48
|
-
|
|
49
|
-
DESCRIPTION
|
|
50
|
-
add service to dependencies & make endpoints files.
|
|
51
|
-
|
|
52
|
-
1. make endpoints.config.json for version control.
|
|
53
|
-
|
|
54
|
-
{
|
|
55
|
-
"dependencies": {
|
|
56
|
-
"service-name": {
|
|
57
|
-
"version": "26177ed7e673daf0cc5a69e9793dd863424d272f",
|
|
58
|
-
"repository": "git@github.com:[username/repository].git"
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
> service name is inferred from Repository name.
|
|
64
|
-
|
|
65
|
-
2. make src/endpoints/[service-name].ts
|
|
66
|
-
|
|
67
|
-
EXAMPLES
|
|
68
|
-
$ mes add [username/repository]
|
|
69
|
-
$ mes add [username/repository] --version [commmit hash]
|
|
70
|
-
$ mes add [username/repository] -v [commmit hash]
|
|
71
|
-
$ mes add [username/repository] -v latest
|
|
72
|
-
$ mes add [username/repository] --workspace [workspace directory]
|
|
73
|
-
$ mes add [username/repository] -w [workspace directory]
|
|
74
|
-
$ mes add [username/repository] --branch [branch name]
|
|
75
|
-
$ mes add [username/repository] -b [branch name]
|
|
76
|
-
$ mes add [username/repository] --excludes [period name]
|
|
77
|
-
$ mes add [username/repository] -e [period name]
|
|
78
|
-
$ mes add [username/repository] -e [period name] [period name]
|
|
79
|
-
$ mes add /Users/.../local-repository/
|
|
80
|
-
$ mes add ./local-repository
|
|
81
|
-
$ mes add git@github.com:[username/repository].git
|
|
82
|
-
$ mes add https://github.com/[username/repository].git
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
_See code: [src/commands/add.ts](https://github.com/matsuri-tech/endpoints-sdk-cli/blob/v2.8.0/src/commands/add.ts)_
|
|
86
|
-
|
|
87
|
-
## `mes help [COMMAND]`
|
|
88
|
-
|
|
89
|
-
display help for mes
|
|
90
|
-
|
|
91
|
-
```
|
|
92
|
-
USAGE
|
|
93
|
-
$ mes help [COMMAND]
|
|
94
|
-
|
|
95
|
-
ARGUMENTS
|
|
96
|
-
COMMAND command to show help for
|
|
97
|
-
|
|
98
|
-
OPTIONS
|
|
99
|
-
--all see all commands in CLI
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v3.3.1/src/commands/help.ts)_
|
|
103
|
-
|
|
104
|
-
## `mes install`
|
|
105
|
-
|
|
106
|
-
generate endpoints files based on endpoints.config.json
|
|
107
|
-
|
|
108
|
-
```
|
|
109
|
-
USAGE
|
|
110
|
-
$ mes install
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
_See code: [src/commands/install.ts](https://github.com/matsuri-tech/endpoints-sdk-cli/blob/v2.8.0/src/commands/install.ts)_
|
|
114
|
-
|
|
115
|
-
## `mes update [SERVICE]`
|
|
116
|
-
|
|
117
|
-
update service version & regenerate endpoints files
|
|
118
|
-
|
|
119
|
-
```
|
|
120
|
-
USAGE
|
|
121
|
-
$ mes update [SERVICE]
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
_See code: [src/commands/update.ts](https://github.com/matsuri-tech/endpoints-sdk-cli/blob/v2.8.0/src/commands/update.ts)_
|
|
125
|
-
<!-- commandsstop -->
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
# Support of `create-react-app`
|
|
129
|
-
|
|
130
|
-
```json
|
|
131
|
-
{
|
|
132
|
-
"environment_identifier": "process.env.REACT_APP_ENV",
|
|
133
|
-
}
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
# Override root url
|
|
137
|
-
|
|
138
|
-
```json
|
|
139
|
-
{
|
|
140
|
-
"dependencies": {
|
|
141
|
-
"my-service": {
|
|
142
|
-
"version": "ba832b61d0319f42b3cbb30c815cbdecfece959a",
|
|
143
|
-
"repository": "git@github.com:hoge/my-service.git",
|
|
144
|
-
"roots":{
|
|
145
|
-
"dev": "https://dev.hoge.com",
|
|
146
|
-
"prod": "https://hoge.com",
|
|
147
|
-
"local": "http://localhost:3000"
|
|
148
|
-
}
|
|
149
|
-
},
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
```
|
package/bin/run
DELETED
package/bin/run.cmd
DELETED
package/lib/classes/Config.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
export interface Roots {
|
|
2
|
-
[env: string]: string;
|
|
3
|
-
}
|
|
4
|
-
interface Dependencies {
|
|
5
|
-
[service: string]: {
|
|
6
|
-
version: string;
|
|
7
|
-
repository: string;
|
|
8
|
-
roots?: Roots;
|
|
9
|
-
workspaces?: string[];
|
|
10
|
-
branch?: string;
|
|
11
|
-
exclude_periods?: string[];
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
interface ConfigData {
|
|
15
|
-
$shema: string;
|
|
16
|
-
dependencies: Dependencies;
|
|
17
|
-
path: string;
|
|
18
|
-
output: string;
|
|
19
|
-
environment_identifier: string;
|
|
20
|
-
}
|
|
21
|
-
export declare class Config {
|
|
22
|
-
data: Partial<ConfigData>;
|
|
23
|
-
dependencies: Dependencies;
|
|
24
|
-
path: string;
|
|
25
|
-
output: string;
|
|
26
|
-
environment_identifier: string;
|
|
27
|
-
constructor();
|
|
28
|
-
push({ name, path, version, workspace, branch, exclude_periods }: {
|
|
29
|
-
name: string;
|
|
30
|
-
path: string;
|
|
31
|
-
version: string;
|
|
32
|
-
workspace?: string;
|
|
33
|
-
branch: string | undefined;
|
|
34
|
-
exclude_periods: string[] | undefined;
|
|
35
|
-
}): void;
|
|
36
|
-
publish(): void;
|
|
37
|
-
}
|
|
38
|
-
export {};
|
package/lib/classes/Config.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
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("node:fs"));
|
|
6
|
-
const path = tslib_1.__importStar(require("node:path"));
|
|
7
|
-
const prettier = tslib_1.__importStar(require("prettier"));
|
|
8
|
-
const unique_1 = require("../utils/unique");
|
|
9
|
-
class Config {
|
|
10
|
-
constructor() {
|
|
11
|
-
this.data = {};
|
|
12
|
-
this.dependencies = {};
|
|
13
|
-
this.path = 'endpoints.config.json';
|
|
14
|
-
this.output = fs.existsSync(path.resolve('./src')) ? './src/endpoints/' : './endpoints/';
|
|
15
|
-
this.environment_identifier = 'process.env.NODE_ENV';
|
|
16
|
-
if (fs.existsSync(this.path)) {
|
|
17
|
-
const data = JSON.parse(fs.readFileSync(this.path).toString());
|
|
18
|
-
this.data = data;
|
|
19
|
-
if (data.dependencies) {
|
|
20
|
-
this.dependencies = data.dependencies;
|
|
21
|
-
}
|
|
22
|
-
if (data.output) {
|
|
23
|
-
this.output = data.output;
|
|
24
|
-
}
|
|
25
|
-
if (!fs.existsSync(this.output)) {
|
|
26
|
-
fs.mkdirSync(this.output);
|
|
27
|
-
}
|
|
28
|
-
if (data.environment_identifier) {
|
|
29
|
-
this.environment_identifier = data.environment_identifier;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
push({ name, path, version, workspace, branch, exclude_periods }) {
|
|
34
|
-
var _a, _b, _c;
|
|
35
|
-
const workspaces = (0, unique_1.unique)([
|
|
36
|
-
...(((_b = (_a = this.dependencies) === null || _a === void 0 ? void 0 : _a[name]) === null || _b === void 0 ? void 0 : _b.workspaces) || []),
|
|
37
|
-
workspace,
|
|
38
|
-
]).filter((w) => Boolean(w));
|
|
39
|
-
this.dependencies = Object.assign(Object.assign({}, this.dependencies), { [name]: Object.assign(Object.assign({}, (_c = this.dependencies) === null || _c === void 0 ? void 0 : _c[name]), { version, repository: path, branch,
|
|
40
|
-
exclude_periods, workspaces: workspaces.length > 0 ? workspaces : undefined }) });
|
|
41
|
-
}
|
|
42
|
-
publish() {
|
|
43
|
-
const data = Object.assign(Object.assign({}, this.data), { $schema: 'https://matsuri-tech.github.io/endpoints-sdk-cli/schema.json', output: this.output, environment_identifier: this.environment_identifier, dependencies: this.dependencies });
|
|
44
|
-
fs.writeFileSync(this.path, prettier.format(JSON.stringify(data, null, 2), { parser: 'json' }));
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
exports.Config = Config;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
export interface Env {
|
|
2
|
-
local: string;
|
|
3
|
-
dev: string;
|
|
4
|
-
prod: string;
|
|
5
|
-
[key: string]: string;
|
|
6
|
-
}
|
|
7
|
-
export declare type AuthSchema = {
|
|
8
|
-
type: 'Bearer' | 'Basic';
|
|
9
|
-
header: 'Authorization';
|
|
10
|
-
} | {
|
|
11
|
-
type: 'ApiKey';
|
|
12
|
-
header: 'X-Access-Token';
|
|
13
|
-
};
|
|
14
|
-
export interface Endpoint {
|
|
15
|
-
path: string;
|
|
16
|
-
desc: string;
|
|
17
|
-
method?: string;
|
|
18
|
-
authSchema?: AuthSchema;
|
|
19
|
-
request?: null | Record<string, unknown>;
|
|
20
|
-
response?: null | Record<string, unknown>;
|
|
21
|
-
}
|
|
22
|
-
export interface Api {
|
|
23
|
-
[endpoint: string]: Endpoint;
|
|
24
|
-
}
|
|
25
|
-
export interface Period {
|
|
26
|
-
env: Env;
|
|
27
|
-
api: Api;
|
|
28
|
-
}
|
|
29
|
-
export interface Data {
|
|
30
|
-
[version: string]: Period;
|
|
31
|
-
}
|
|
32
|
-
export declare class Repository {
|
|
33
|
-
name: string;
|
|
34
|
-
path: string;
|
|
35
|
-
cache: string;
|
|
36
|
-
hash: string;
|
|
37
|
-
data: Data;
|
|
38
|
-
constructor(str: string);
|
|
39
|
-
clone({ version, workspace, branch }: {
|
|
40
|
-
version?: string;
|
|
41
|
-
workspace?: string;
|
|
42
|
-
branch: string | undefined;
|
|
43
|
-
}): Promise<void>;
|
|
44
|
-
private checkout;
|
|
45
|
-
private revParse;
|
|
46
|
-
private reset;
|
|
47
|
-
clean(): void;
|
|
48
|
-
private inferPath;
|
|
49
|
-
private getName;
|
|
50
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
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("node:path"));
|
|
6
|
-
const node_child_process_1 = require("node:child_process");
|
|
7
|
-
const fs = tslib_1.__importStar(require("node:fs"));
|
|
8
|
-
const rimraf_1 = tslib_1.__importDefault(require("rimraf"));
|
|
9
|
-
const json_schema_ref_parser_1 = tslib_1.__importDefault(require("@apidevtools/json-schema-ref-parser"));
|
|
10
|
-
class Repository {
|
|
11
|
-
constructor(str) {
|
|
12
|
-
this.hash = 'latest';
|
|
13
|
-
this.data = {};
|
|
14
|
-
this.path = this.inferPath(str);
|
|
15
|
-
this.name = this.getName();
|
|
16
|
-
this.cache = path.resolve(`./node_modules/.endpoints-tmp/${Math.random().toString(36).slice(-8)}`);
|
|
17
|
-
}
|
|
18
|
-
async clone({ version, workspace = '', branch }) {
|
|
19
|
-
(0, node_child_process_1.execSync)(`git clone --no-checkout --quiet ${this.path} ${this.cache}`);
|
|
20
|
-
this.reset(version);
|
|
21
|
-
this.hash = this.revParse();
|
|
22
|
-
this.data = await this.checkout(workspace, branch);
|
|
23
|
-
}
|
|
24
|
-
async checkout(workspace, branch) {
|
|
25
|
-
const file = path.resolve(this.cache, workspace, '.endpoints.json');
|
|
26
|
-
const targetBranch = branch ? `origin/${branch}` : (0, node_child_process_1.execSync)(`cd ${this.cache}; git rev-parse --abbrev-ref origin/HEAD`)
|
|
27
|
-
.toString()
|
|
28
|
-
.trim();
|
|
29
|
-
(0, node_child_process_1.execSync)(`cd ${this.cache}; git checkout ${targetBranch} -- ${file}`);
|
|
30
|
-
const schema = (await json_schema_ref_parser_1.default.dereference(JSON.parse(fs.readFileSync(file).toString())));
|
|
31
|
-
delete schema.$defs;
|
|
32
|
-
return schema;
|
|
33
|
-
}
|
|
34
|
-
revParse() {
|
|
35
|
-
const hash = (0, node_child_process_1.execSync)(`cd ${this.cache}; git rev-parse HEAD`)
|
|
36
|
-
.toString()
|
|
37
|
-
.trim();
|
|
38
|
-
return hash;
|
|
39
|
-
}
|
|
40
|
-
reset(version) {
|
|
41
|
-
if (version && version !== 'latest') {
|
|
42
|
-
(0, node_child_process_1.execSync)(`cd ${this.cache}; git reset --hard ${version}`);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
clean() {
|
|
46
|
-
rimraf_1.default.sync(this.cache);
|
|
47
|
-
}
|
|
48
|
-
inferPath(str) {
|
|
49
|
-
if (str.startsWith('https://') ||
|
|
50
|
-
str.startsWith('git@') ||
|
|
51
|
-
str.startsWith('/')) {
|
|
52
|
-
return str;
|
|
53
|
-
}
|
|
54
|
-
if (str.startsWith('./')) {
|
|
55
|
-
return path.resolve(str);
|
|
56
|
-
}
|
|
57
|
-
return `git@github.com:${str}.git`;
|
|
58
|
-
}
|
|
59
|
-
getName() {
|
|
60
|
-
const splits = this.path.split('/');
|
|
61
|
-
const name = splits[splits.length - 1].split(/\./)[0];
|
|
62
|
-
return name;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
exports.Repository = Repository;
|
package/lib/commands/add.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Command, flags } from '@oclif/command';
|
|
2
|
-
export default class Add extends Command {
|
|
3
|
-
static description: string;
|
|
4
|
-
static args: {
|
|
5
|
-
name: string;
|
|
6
|
-
}[];
|
|
7
|
-
static flags: {
|
|
8
|
-
version: flags.IOptionFlag<string | undefined>;
|
|
9
|
-
workspace: flags.IOptionFlag<string | undefined>;
|
|
10
|
-
branch: flags.IOptionFlag<string | undefined>;
|
|
11
|
-
excludes: flags.IOptionFlag<string[]>;
|
|
12
|
-
};
|
|
13
|
-
static examples: string[];
|
|
14
|
-
run(): Promise<void>;
|
|
15
|
-
}
|
package/lib/commands/add.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const Config_1 = require("../classes/Config");
|
|
4
|
-
const command_1 = require("@oclif/command");
|
|
5
|
-
const color_1 = require("@oclif/color");
|
|
6
|
-
const Repository_1 = require("../classes/Repository");
|
|
7
|
-
const makeFiles_1 = require("../makeFiles");
|
|
8
|
-
class Add extends command_1.Command {
|
|
9
|
-
async run() {
|
|
10
|
-
const { flags: { version, workspace, branch, excludes }, args } = this.parse(Add);
|
|
11
|
-
const repository = new Repository_1.Repository(args.repository);
|
|
12
|
-
try {
|
|
13
|
-
await repository.clone({ version, workspace, branch });
|
|
14
|
-
const config = new Config_1.Config();
|
|
15
|
-
await (0, makeFiles_1.makeFiles)({ repository, config, workspace, exclude_periods: excludes });
|
|
16
|
-
config.push({
|
|
17
|
-
name: repository.name,
|
|
18
|
-
path: repository.path,
|
|
19
|
-
version: version || repository.hash,
|
|
20
|
-
workspace,
|
|
21
|
-
branch,
|
|
22
|
-
exclude_periods: excludes,
|
|
23
|
-
});
|
|
24
|
-
config.publish();
|
|
25
|
-
this.log(`${color_1.color.green('success')}: ${repository.name} updated!`);
|
|
26
|
-
}
|
|
27
|
-
catch (error) {
|
|
28
|
-
// @ts-expect-error
|
|
29
|
-
this.error(color_1.color.red(error.stack));
|
|
30
|
-
}
|
|
31
|
-
finally {
|
|
32
|
-
repository.clean();
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
exports.default = Add;
|
|
37
|
-
Add.description = `
|
|
38
|
-
add service to dependencies & make endpoints files.
|
|
39
|
-
|
|
40
|
-
1. make endpoints.config.json for version control.
|
|
41
|
-
|
|
42
|
-
{
|
|
43
|
-
"dependencies": {
|
|
44
|
-
"service-name": {
|
|
45
|
-
"version": "26177ed7e673daf0cc5a69e9793dd863424d272f",
|
|
46
|
-
"repository": "git@github.com:[username/repository].git"
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
> service name is inferred from Repository name.
|
|
52
|
-
|
|
53
|
-
2. make src/endpoints/[service-name].ts
|
|
54
|
-
`;
|
|
55
|
-
Add.args = [{ name: 'repository' }];
|
|
56
|
-
Add.flags = {
|
|
57
|
-
version: command_1.flags.string({ char: 'v', description: 'latest or commit hash' }),
|
|
58
|
-
workspace: command_1.flags.string({
|
|
59
|
-
char: 'w',
|
|
60
|
-
description: 'a path to workspace containing .endpoints.json',
|
|
61
|
-
}),
|
|
62
|
-
branch: command_1.flags.string({ char: 'b', description: 'branch name to clone' }),
|
|
63
|
-
excludes: command_1.flags.string({
|
|
64
|
-
char: 'e',
|
|
65
|
-
description: 'exclude periods',
|
|
66
|
-
multiple: true,
|
|
67
|
-
}),
|
|
68
|
-
};
|
|
69
|
-
Add.examples = [
|
|
70
|
-
'$ mes add [username/repository]',
|
|
71
|
-
'$ mes add [username/repository] --version [commmit hash]',
|
|
72
|
-
'$ mes add [username/repository] -v [commmit hash]',
|
|
73
|
-
'$ mes add [username/repository] -v latest',
|
|
74
|
-
'$ mes add [username/repository] --workspace [workspace directory]',
|
|
75
|
-
'$ mes add [username/repository] -w [workspace directory]',
|
|
76
|
-
'$ mes add [username/repository] --branch [branch name]',
|
|
77
|
-
'$ mes add [username/repository] -b [branch name]',
|
|
78
|
-
'$ mes add [username/repository] --excludes [period name]',
|
|
79
|
-
'$ mes add [username/repository] -e [period name]',
|
|
80
|
-
'$ mes add [username/repository] -e [period name] [period name]',
|
|
81
|
-
'$ mes add /Users/.../local-repository/',
|
|
82
|
-
'$ mes add ./local-repository',
|
|
83
|
-
'$ mes add git@github.com:[username/repository].git',
|
|
84
|
-
'$ mes add https://github.com/[username/repository].git',
|
|
85
|
-
];
|