endpoints-sdk-cli 2.3.2 → 2.4.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/README.md +23 -4
- package/lib/classes/Config.d.ts +4 -0
- package/lib/classes/Config.js +5 -9
- package/lib/classes/Repository.js +3 -3
- package/lib/commands/install.js +2 -2
- package/lib/makeFiles.d.ts +2 -1
- package/lib/makeFiles.js +5 -5
- package/lib/templates/files/endpoints.d.ts +3 -2
- package/lib/templates/files/endpoints.js +4 -3
- package/lib/templates/files/index.js +1 -1
- package/lib/templates/functions/endpoint.js +1 -1
- package/lib/templates/functions/index.js +2 -2
- package/lib/templates/functions/root.d.ts +3 -3
- package/lib/templates/functions/root.js +2 -2
- package/lib/templates/index.js +2 -2
- package/lib/utils/format.js +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +3 -2
- package/schema.json +52 -0
package/README.md
CHANGED
|
@@ -9,6 +9,7 @@ Endpoints SDK for JavaScript
|
|
|
9
9
|
* [Usage](#usage)
|
|
10
10
|
* [Commands](#commands)
|
|
11
11
|
* [Support of `create-react-app`](#support-of-create-react-app)
|
|
12
|
+
* [Override root url](#override-root-url)
|
|
12
13
|
<!-- tocstop -->
|
|
13
14
|
# Usage
|
|
14
15
|
<!-- usage -->
|
|
@@ -17,7 +18,7 @@ $ npm install -g endpoints-sdk-cli
|
|
|
17
18
|
$ mes COMMAND
|
|
18
19
|
running command...
|
|
19
20
|
$ mes (-v|--version|version)
|
|
20
|
-
endpoints-sdk-cli/2.
|
|
21
|
+
endpoints-sdk-cli/2.4.0 darwin-arm64 node-v16.17.0
|
|
21
22
|
$ mes --help [COMMAND]
|
|
22
23
|
USAGE
|
|
23
24
|
$ mes COMMAND
|
|
@@ -74,7 +75,7 @@ EXAMPLES
|
|
|
74
75
|
$ mes add https://github.com/[username/repository].git
|
|
75
76
|
```
|
|
76
77
|
|
|
77
|
-
_See code: [src/commands/add.ts](https://github.com/matsuri-tech/endpoints-sdk-cli/blob/v2.
|
|
78
|
+
_See code: [src/commands/add.ts](https://github.com/matsuri-tech/endpoints-sdk-cli/blob/v2.4.0/src/commands/add.ts)_
|
|
78
79
|
|
|
79
80
|
## `mes help [COMMAND]`
|
|
80
81
|
|
|
@@ -102,7 +103,7 @@ USAGE
|
|
|
102
103
|
$ mes install
|
|
103
104
|
```
|
|
104
105
|
|
|
105
|
-
_See code: [src/commands/install.ts](https://github.com/matsuri-tech/endpoints-sdk-cli/blob/v2.
|
|
106
|
+
_See code: [src/commands/install.ts](https://github.com/matsuri-tech/endpoints-sdk-cli/blob/v2.4.0/src/commands/install.ts)_
|
|
106
107
|
|
|
107
108
|
## `mes update [SERVICE]`
|
|
108
109
|
|
|
@@ -113,7 +114,7 @@ USAGE
|
|
|
113
114
|
$ mes update [SERVICE]
|
|
114
115
|
```
|
|
115
116
|
|
|
116
|
-
_See code: [src/commands/update.ts](https://github.com/matsuri-tech/endpoints-sdk-cli/blob/v2.
|
|
117
|
+
_See code: [src/commands/update.ts](https://github.com/matsuri-tech/endpoints-sdk-cli/blob/v2.4.0/src/commands/update.ts)_
|
|
117
118
|
<!-- commandsstop -->
|
|
118
119
|
|
|
119
120
|
|
|
@@ -124,3 +125,21 @@ _See code: [src/commands/update.ts](https://github.com/matsuri-tech/endpoints-sd
|
|
|
124
125
|
"environment_identifier": "process.env.REACT_APP_ENV",
|
|
125
126
|
}
|
|
126
127
|
```
|
|
128
|
+
|
|
129
|
+
# Override root url
|
|
130
|
+
|
|
131
|
+
```json
|
|
132
|
+
{
|
|
133
|
+
"dependencies": {
|
|
134
|
+
"my-service": {
|
|
135
|
+
"version": "ba832b61d0319f42b3cbb30c815cbdecfece959a",
|
|
136
|
+
"repository": "git@github.com:hoge/my-service.git",
|
|
137
|
+
"roots":{
|
|
138
|
+
"dev": "https://dev.hoge.com",
|
|
139
|
+
"prod": "https://hoge.com",
|
|
140
|
+
"local": "http://localhost:3000"
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
```
|
package/lib/classes/Config.d.ts
CHANGED
package/lib/classes/Config.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Config = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const fs =
|
|
6
|
-
const path =
|
|
7
|
-
const prettier =
|
|
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
8
|
const unique_1 = require("../utils/unique");
|
|
9
9
|
class Config {
|
|
10
10
|
constructor() {
|
|
@@ -29,16 +29,12 @@ class Config {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
push({ name, path, version, workspace }) {
|
|
32
|
-
var _a, _b;
|
|
32
|
+
var _a, _b, _c;
|
|
33
33
|
const workspaces = (0, unique_1.unique)([
|
|
34
34
|
...(((_b = (_a = this.dependencies) === null || _a === void 0 ? void 0 : _a[name]) === null || _b === void 0 ? void 0 : _b.workspaces) || []),
|
|
35
35
|
workspace,
|
|
36
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
|
-
} });
|
|
37
|
+
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, workspaces: workspaces.length > 0 ? workspaces : undefined }) });
|
|
42
38
|
}
|
|
43
39
|
publish() {
|
|
44
40
|
const data = {
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Repository = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const path =
|
|
5
|
+
const path = tslib_1.__importStar(require("node:path"));
|
|
6
6
|
const node_child_process_1 = require("node:child_process");
|
|
7
|
-
const fs =
|
|
8
|
-
const rimraf_1 =
|
|
7
|
+
const fs = tslib_1.__importStar(require("node:fs"));
|
|
8
|
+
const rimraf_1 = tslib_1.__importDefault(require("rimraf"));
|
|
9
9
|
class Repository {
|
|
10
10
|
constructor(str) {
|
|
11
11
|
this.hash = 'latest';
|
package/lib/commands/install.js
CHANGED
|
@@ -13,12 +13,12 @@ class Install extends command_1.Command {
|
|
|
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
|
-
for (const { repository: path, version, workspaces = [''] } of Object.values(config.dependencies)) {
|
|
16
|
+
for (const { repository: path, version, workspaces = [''], roots } of Object.values(config.dependencies)) {
|
|
17
17
|
for (const workspace of workspaces) {
|
|
18
18
|
const repository = new Repository_1.Repository(path);
|
|
19
19
|
repositories.push(repository);
|
|
20
20
|
repository.clone({ version, workspace });
|
|
21
|
-
(0, makeFiles_1.makeFiles)({ repository, workspace, config });
|
|
21
|
+
(0, makeFiles_1.makeFiles)({ repository, workspace, config, roots });
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
}
|
package/lib/makeFiles.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { Config } from './classes/Config';
|
|
1
|
+
import type { Config, Roots } from './classes/Config';
|
|
2
2
|
import type { Repository } from './classes/Repository';
|
|
3
3
|
export declare const makeFiles: (args: {
|
|
4
4
|
repository: Repository;
|
|
5
5
|
workspace?: string;
|
|
6
6
|
config: Config;
|
|
7
|
+
roots?: Roots;
|
|
7
8
|
}) => void;
|
package/lib/makeFiles.js
CHANGED
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.makeFiles = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const path =
|
|
6
|
-
const templates =
|
|
7
|
-
const fs =
|
|
5
|
+
const path = tslib_1.__importStar(require("node:path"));
|
|
6
|
+
const templates = tslib_1.__importStar(require("./templates"));
|
|
7
|
+
const fs = tslib_1.__importStar(require("node:fs"));
|
|
8
8
|
const format_1 = require("./utils/format");
|
|
9
9
|
const makeName = (...args) => {
|
|
10
10
|
return args.filter(e => Boolean(e)).join('.');
|
|
11
11
|
};
|
|
12
|
-
const makeFiles = ({ repository, workspace, config }) => {
|
|
12
|
+
const makeFiles = ({ repository, workspace, config, roots }) => {
|
|
13
13
|
const files = [];
|
|
14
14
|
for (const [version, period] of Object.entries(repository.data)) {
|
|
15
|
-
const content = templates.files.endpoints({ repository, version, period, config });
|
|
15
|
+
const content = templates.files.endpoints({ repository, version, period, config, roots });
|
|
16
16
|
const basename = makeName(repository.name, workspace, version);
|
|
17
17
|
files.push({ version, basename });
|
|
18
18
|
fs.writeFileSync(path.resolve(config.output, `${basename}.ts`), (0, format_1.format)(content));
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { Config } from '../../classes/Config';
|
|
1
|
+
import type { Config, Roots } from '../../classes/Config';
|
|
2
2
|
import type { Repository, Period } from '../../classes/Repository';
|
|
3
|
-
export declare const endpoints: ({ repository, version, period, config, }: {
|
|
3
|
+
export declare const endpoints: ({ repository, version, period, config, roots, }: {
|
|
4
4
|
repository: Repository;
|
|
5
5
|
version: string;
|
|
6
6
|
period: Period;
|
|
7
7
|
config: Config;
|
|
8
|
+
roots?: Roots | undefined;
|
|
8
9
|
}) => string;
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.endpoints = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const templates =
|
|
5
|
+
const templates = tslib_1.__importStar(require("../functions"));
|
|
6
6
|
const camelCase_1 = require("../../utils/camelCase");
|
|
7
|
-
const endpoints = ({ repository, version, period, config, }) => {
|
|
7
|
+
const endpoints = ({ repository, version, period, config, roots, }) => {
|
|
8
8
|
const names = [];
|
|
9
9
|
const fns = Object.entries(period.api).map(([_name, endpoint]) => {
|
|
10
10
|
const name = (0, camelCase_1.camelCase)(_name);
|
|
@@ -12,9 +12,10 @@ const endpoints = ({ repository, version, period, config, }) => {
|
|
|
12
12
|
return templates.endpoint(name, endpoint);
|
|
13
13
|
});
|
|
14
14
|
const exportFns = `export const ${(0, camelCase_1.camelCase)(repository.name)}_${(0, camelCase_1.camelCase)(version)} = {${names.join(',')}}`;
|
|
15
|
+
const env = Object.assign(Object.assign({}, period.env), roots);
|
|
15
16
|
return [
|
|
16
17
|
'/* eslint-disable */',
|
|
17
|
-
templates.root({
|
|
18
|
+
templates.root({ env, config }),
|
|
18
19
|
...fns,
|
|
19
20
|
exportFns,
|
|
20
21
|
].join('');
|
|
@@ -4,4 +4,4 @@ exports.index = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
var indexFile_1 = require("./indexFile");
|
|
6
6
|
Object.defineProperty(exports, "index", { enumerable: true, get: function () { return indexFile_1.indexFile; } });
|
|
7
|
-
|
|
7
|
+
tslib_1.__exportStar(require("./endpoints"), exports);
|
|
@@ -86,6 +86,6 @@ const endpoint = (name, e) => {
|
|
|
86
86
|
return __queries ? \`\${__path}?\${__queries}\` : __path;
|
|
87
87
|
};
|
|
88
88
|
`,
|
|
89
|
-
e.method ? `${name}.method='${e.method}';` : null].filter(Boolean).join('\n');
|
|
89
|
+
e.method ? `${name}.method='${e.method}' as const;` : null].filter(Boolean).join('\n');
|
|
90
90
|
};
|
|
91
91
|
exports.endpoint = endpoint;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
tslib_1.__exportStar(require("./root"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./endpoint"), exports);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Config } from '../../classes/Config';
|
|
2
2
|
import type { Period } from '../../classes/Repository';
|
|
3
|
-
export declare const root: (
|
|
4
|
-
|
|
3
|
+
export declare const root: ({ env, config }: {
|
|
4
|
+
env: Period['env'];
|
|
5
5
|
config: Config;
|
|
6
|
-
}) =>
|
|
6
|
+
}) => string;
|
|
@@ -10,8 +10,8 @@ const normalizeName = (n) => {
|
|
|
10
10
|
const normalizeUrl = (u) => {
|
|
11
11
|
return u.endsWith('/') ? u.slice(0, -1) : u;
|
|
12
12
|
};
|
|
13
|
-
const root = ({
|
|
14
|
-
const content = Object.entries(
|
|
13
|
+
const root = ({ env, config }) => {
|
|
14
|
+
const content = Object.entries(env).map(([n, u]) => {
|
|
15
15
|
return `
|
|
16
16
|
if(${config.environment_identifier}==="${normalizeName(n)}"){
|
|
17
17
|
__root = '${normalizeUrl(u)}'
|
package/lib/templates/index.js
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.functions = exports.files = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
exports.files =
|
|
6
|
-
exports.functions =
|
|
5
|
+
exports.files = tslib_1.__importStar(require("./files"));
|
|
6
|
+
exports.functions = tslib_1.__importStar(require("./functions"));
|
package/lib/utils/format.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.format = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const prettier =
|
|
5
|
+
const prettier = tslib_1.__importStar(require("prettier"));
|
|
6
6
|
const format = (content) => {
|
|
7
7
|
return prettier.format(content, { parser: 'typescript' });
|
|
8
8
|
};
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"2.
|
|
1
|
+
{"version":"2.4.0","commands":{"add":{"id":"add","description":"\nadd service to dependencies & make endpoints files.\n\n1. make endpoints.config.json for version control.\n\n{\n \"dependencies\": {\n \"service-name\": {\n \"version\": \"26177ed7e673daf0cc5a69e9793dd863424d272f\",\n \"repository\": \"git@github.com:[username/repository].git\"\n }\n }\n}\n\n> service name is inferred from Repository name.\n\n2. make src/endpoints/[service-name].ts\n","pluginName":"endpoints-sdk-cli","pluginType":"core","aliases":[],"examples":["$ mes add [username/repository]","$ mes add [username/repository] --version [commmit hash]","$ mes add [username/repository] -v [commmit hash]","$ mes add [username/repository] -v latest","$ mes add [username/repository] --workspace [workspace directory]","$ mes add [username/repository] -w [workspace directory]","$ mes add /Users/.../local-repository/","$ mes add ./local-repository","$ mes add git@github.com:[username/repository].git","$ mes add https://github.com/[username/repository].git"],"flags":{"version":{"name":"version","type":"option","char":"v","description":"latest or commit hash"},"workspace":{"name":"workspace","type":"option","char":"w","description":"a path to workspace containing .endpoints.json"}},"args":[{"name":"repository"}]},"install":{"id":"install","description":"generate endpoints files based on endpoints.config.json","pluginName":"endpoints-sdk-cli","pluginType":"core","aliases":[],"flags":{},"args":[]},"update":{"id":"update","description":"update service version & regenerate endpoints files","pluginName":"endpoints-sdk-cli","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"service"}]}}}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "endpoints-sdk-cli",
|
|
3
3
|
"description": "endpoints sdk cli",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.4.0",
|
|
5
5
|
"author": "hrdtbs",
|
|
6
6
|
"bin": {
|
|
7
7
|
"mes": "./bin/run"
|
|
@@ -44,7 +44,8 @@
|
|
|
44
44
|
"/bin",
|
|
45
45
|
"/lib",
|
|
46
46
|
"/npm-shrinkwrap.json",
|
|
47
|
-
"/oclif.manifest.json"
|
|
47
|
+
"/oclif.manifest.json",
|
|
48
|
+
"/schema.json"
|
|
48
49
|
],
|
|
49
50
|
"homepage": "https://github.com/matsuri-tech/endpoints-sdk-cli",
|
|
50
51
|
"keywords": [
|
package/schema.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"definitions": {},
|
|
3
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
|
+
"required": ["output", "environment_identifier", "dependencies"],
|
|
5
|
+
"properties": {
|
|
6
|
+
"output": {
|
|
7
|
+
"$id": "#/properties/output",
|
|
8
|
+
"type": "string",
|
|
9
|
+
"title": "Output directory",
|
|
10
|
+
"default": "./src/endpoints/"
|
|
11
|
+
},
|
|
12
|
+
"environment_identifier": {
|
|
13
|
+
"$id": "#/properties/environment_identifier",
|
|
14
|
+
"type": "string",
|
|
15
|
+
"title": "Environment identifier",
|
|
16
|
+
"default": "process.env.NODE_ENV",
|
|
17
|
+
"examples": ["process.env.NODE_ENV", "process.env.RUNTIME_ENV"]
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"$id": "#/properties/dependencies",
|
|
21
|
+
"type": "object",
|
|
22
|
+
"title": "Dependencies",
|
|
23
|
+
"default": {},
|
|
24
|
+
"additionalProperties": {
|
|
25
|
+
"type": "object",
|
|
26
|
+
"required": ["version", "repository"],
|
|
27
|
+
"properties": {
|
|
28
|
+
"version": {
|
|
29
|
+
"type": "string"
|
|
30
|
+
},
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "string"
|
|
33
|
+
},
|
|
34
|
+
"roots": {
|
|
35
|
+
"type": "object",
|
|
36
|
+
"title": "Override roots",
|
|
37
|
+
"additionalProperties": {
|
|
38
|
+
"type": "string"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"workspaces": {
|
|
42
|
+
"type": "array",
|
|
43
|
+
"title": "Set workspaces",
|
|
44
|
+
"items": {
|
|
45
|
+
"type": "string"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|