endpoints-sdk-cli 2.1.3 → 2.3.1
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 +11 -11
- package/lib/classes/Config.js +3 -3
- package/lib/classes/Repository.d.ts +1 -0
- package/lib/classes/Repository.js +8 -7
- package/lib/commands/add.js +2 -1
- package/lib/commands/install.js +8 -7
- package/lib/commands/update.js +6 -5
- package/lib/endpoints/lab.hoge.d.ts +4 -0
- package/lib/endpoints/lab.hoge.js +7 -0
- package/lib/endpoints/lab.hoge.v1.d.ts +123 -0
- package/lib/endpoints/lab.hoge.v1.js +219 -0
- package/lib/endpoints/lab.poyo.d.ts +4 -0
- package/lib/endpoints/lab.poyo.js +7 -0
- package/lib/endpoints/lab.poyo.v1.d.ts +123 -0
- package/lib/endpoints/lab.poyo.v1.js +219 -0
- package/lib/endpoints/m2m-core.js +1 -1
- package/lib/endpoints/m2m-core.v1.d.ts +371 -252
- package/lib/endpoints/m2m-core.v1.js +532 -696
- package/lib/makeFiles.js +8 -7
- package/lib/templates/files/endpoints.js +4 -3
- package/lib/templates/files/indexFile.js +5 -4
- package/lib/templates/functions/endpoint.js +9 -7
- package/lib/templates/functions/root.js +4 -3
- package/lib/utils/camelCase.js +3 -2
- package/lib/utils/format.js +2 -1
- package/lib/utils/unique.js +3 -2
- package/oclif.manifest.json +1 -1
- package/package.json +2 -2
- package/CHANGELOG.md +0 -2618
package/lib/makeFiles.js
CHANGED
|
@@ -2,20 +2,21 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.makeFiles = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const path = tslib_1.__importStar(require("path"));
|
|
5
|
+
const path = tslib_1.__importStar(require("node:path"));
|
|
6
6
|
const templates = tslib_1.__importStar(require("./templates"));
|
|
7
|
-
const fs = tslib_1.__importStar(require("fs"));
|
|
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
|
-
|
|
12
|
+
const makeFiles = ({ repository, workspace, config }) => {
|
|
13
13
|
const files = [];
|
|
14
|
-
Object.entries(repository.data)
|
|
14
|
+
for (const [version, period] of Object.entries(repository.data)) {
|
|
15
15
|
const content = templates.files.endpoints({ repository, version, period, config });
|
|
16
16
|
const basename = makeName(repository.name, workspace, version);
|
|
17
17
|
files.push({ version, basename });
|
|
18
|
-
fs.writeFileSync(path.resolve(config.output, `${basename}.ts`), format_1.format(content));
|
|
19
|
-
}
|
|
20
|
-
fs.writeFileSync(path.resolve(config.output, `${makeName(repository.name, workspace)}.ts`), format_1.format(templates.files.index({ files, repository })));
|
|
18
|
+
fs.writeFileSync(path.resolve(config.output, `${basename}.ts`), (0, format_1.format)(content));
|
|
19
|
+
}
|
|
20
|
+
fs.writeFileSync(path.resolve(config.output, `${makeName(repository.name, workspace)}.ts`), (0, format_1.format)(templates.files.index({ files, repository })));
|
|
21
21
|
};
|
|
22
|
+
exports.makeFiles = makeFiles;
|
|
@@ -4,14 +4,14 @@ exports.endpoints = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const templates = tslib_1.__importStar(require("../functions"));
|
|
6
6
|
const camelCase_1 = require("../../utils/camelCase");
|
|
7
|
-
|
|
7
|
+
const endpoints = ({ repository, version, period, config, }) => {
|
|
8
8
|
const names = [];
|
|
9
9
|
const fns = Object.entries(period.api).map(([_name, endpoint]) => {
|
|
10
|
-
const name = camelCase_1.camelCase(_name);
|
|
10
|
+
const name = (0, camelCase_1.camelCase)(_name);
|
|
11
11
|
names.push(name);
|
|
12
12
|
return templates.endpoint(name, endpoint);
|
|
13
13
|
});
|
|
14
|
-
const exportFns = `export const ${camelCase_1.camelCase(repository.name)}_${camelCase_1.camelCase(version)} = {${names.join(',')}}`;
|
|
14
|
+
const exportFns = `export const ${(0, camelCase_1.camelCase)(repository.name)}_${(0, camelCase_1.camelCase)(version)} = {${names.join(',')}}`;
|
|
15
15
|
return [
|
|
16
16
|
'/* eslint-disable */',
|
|
17
17
|
templates.root({ period, config }),
|
|
@@ -19,3 +19,4 @@ exports.endpoints = ({ repository, version, period, config, }) => {
|
|
|
19
19
|
exportFns,
|
|
20
20
|
].join('');
|
|
21
21
|
};
|
|
22
|
+
exports.endpoints = endpoints;
|
|
@@ -2,15 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.indexFile = void 0;
|
|
4
4
|
const camelCase_1 = require("../../utils/camelCase");
|
|
5
|
-
|
|
5
|
+
const indexFile = ({ files, repository, }) => {
|
|
6
6
|
return `
|
|
7
7
|
/* eslint-disable */
|
|
8
8
|
${files
|
|
9
9
|
.map(({ version, basename }) => {
|
|
10
|
-
return `import * as ${camelCase_1.camelCase(version)} from './${basename}'`;
|
|
10
|
+
return `import * as ${(0, camelCase_1.camelCase)(version)} from './${basename}'`;
|
|
11
11
|
})
|
|
12
12
|
.join('\n')}
|
|
13
|
-
export const ${camelCase_1.camelCase(repository.name)} = {${files
|
|
14
|
-
.map(({ version }) => camelCase_1.camelCase(version))
|
|
13
|
+
export const ${(0, camelCase_1.camelCase)(repository.name)} = {${files
|
|
14
|
+
.map(({ version }) => (0, camelCase_1.camelCase)(version))
|
|
15
15
|
.join(',')}}`;
|
|
16
16
|
};
|
|
17
|
+
exports.indexFile = indexFile;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.endpoint = void 0;
|
|
4
4
|
const unique_1 = require("../../utils/unique");
|
|
5
5
|
const isNumberLiteral = (str) => {
|
|
6
|
-
return str && isFinite(Number(str));
|
|
6
|
+
return str && Number.isFinite(Number(str));
|
|
7
7
|
};
|
|
8
8
|
const detectType = (str) => {
|
|
9
9
|
return isNumberLiteral(str) ? 'number' : 'string';
|
|
@@ -56,19 +56,19 @@ const makePathTemplate = (p) => {
|
|
|
56
56
|
.join('/');
|
|
57
57
|
return t.startsWith('/') ? t.slice(1) : t;
|
|
58
58
|
};
|
|
59
|
-
|
|
59
|
+
const endpoint = (name, e) => {
|
|
60
60
|
const [path, queryParamsStr] = e.path.split('?');
|
|
61
61
|
const queryParams = makeQueryParams(queryParamsStr);
|
|
62
62
|
const pathParams = makePathParams(path);
|
|
63
63
|
const queryParamNames = pickNames(queryParams);
|
|
64
64
|
const pathParamNames = pickNames(pathParams);
|
|
65
|
-
const paramNames = unique_1.unique([...queryParamNames, ...pathParamNames]);
|
|
66
|
-
const params = unique_1.unique([...queryParams, ...pathParams]);
|
|
65
|
+
const paramNames = (0, unique_1.unique)([...queryParamNames, ...pathParamNames]);
|
|
66
|
+
const params = (0, unique_1.unique)([...queryParams, ...pathParams]);
|
|
67
67
|
const QUERY_PARAMS_COMMENTS = makeQueryParamsComments(queryParams);
|
|
68
68
|
const QUERY_PARAMS_OBJECT = `{${queryParamNames.join(',')}}`;
|
|
69
69
|
const ARGUMENTS = makeArguments(params, paramNames, pathParamNames);
|
|
70
70
|
const PATH_TEMPLATE = makePathTemplate(path);
|
|
71
|
-
return `
|
|
71
|
+
return [`
|
|
72
72
|
/**
|
|
73
73
|
* ${e.desc}
|
|
74
74
|
${QUERY_PARAMS_COMMENTS}
|
|
@@ -84,6 +84,8 @@ exports.endpoint = (name, e) => {
|
|
|
84
84
|
}).join("&");
|
|
85
85
|
const __path = \`\${__root}/\${\`${PATH_TEMPLATE}\`}\`;
|
|
86
86
|
return __queries ? \`\${__path}?\${__queries}\` : __path;
|
|
87
|
-
}
|
|
88
|
-
|
|
87
|
+
};
|
|
88
|
+
`,
|
|
89
|
+
e.method ? `${name}.method='${e.method}';` : null].filter(Boolean).join('\n');
|
|
89
90
|
};
|
|
91
|
+
exports.endpoint = endpoint;
|
|
@@ -4,13 +4,13 @@ exports.root = void 0;
|
|
|
4
4
|
const normalizeName = (n) => {
|
|
5
5
|
return n === 'dev' ?
|
|
6
6
|
'development' :
|
|
7
|
-
n === 'prod' ?
|
|
8
|
-
'production' : n;
|
|
7
|
+
(n === 'prod' ?
|
|
8
|
+
'production' : n);
|
|
9
9
|
};
|
|
10
10
|
const normalizeUrl = (u) => {
|
|
11
11
|
return u.endsWith('/') ? u.slice(0, -1) : u;
|
|
12
12
|
};
|
|
13
|
-
|
|
13
|
+
const root = ({ period, config }) => {
|
|
14
14
|
const content = Object.entries(period.env).map(([n, u]) => {
|
|
15
15
|
return `
|
|
16
16
|
if(${config.environment_identifier}==="${normalizeName(n)}"){
|
|
@@ -28,3 +28,4 @@ exports.root = ({ period, config }) => {
|
|
|
28
28
|
return __root
|
|
29
29
|
}`;
|
|
30
30
|
};
|
|
31
|
+
exports.root = root;
|
package/lib/utils/camelCase.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.camelCase = void 0;
|
|
4
|
-
|
|
4
|
+
const camelCase = (str) => {
|
|
5
5
|
const tmp = str.charAt(0).toLowerCase() + str.slice(1);
|
|
6
|
-
return tmp.replace(/[-
|
|
6
|
+
return tmp.replace(/[._-](.)/g, (_, group1) => {
|
|
7
7
|
return group1.toUpperCase();
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
+
exports.camelCase = camelCase;
|
package/lib/utils/format.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.format = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const prettier = tslib_1.__importStar(require("prettier"));
|
|
6
|
-
|
|
6
|
+
const format = (content) => {
|
|
7
7
|
return prettier.format(content, { parser: 'typescript' });
|
|
8
8
|
};
|
|
9
|
+
exports.format = format;
|
package/lib/utils/unique.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.unique = void 0;
|
|
4
|
-
|
|
5
|
-
const a = arr
|
|
4
|
+
const unique = (arr) => {
|
|
5
|
+
const a = [...arr];
|
|
6
6
|
for (let i = 0; i < a.length; ++i) {
|
|
7
7
|
for (let j = i + 1; j < a.length; ++j) {
|
|
8
8
|
if (a[i] === a[j]) {
|
|
@@ -12,3 +12,4 @@ exports.unique = (arr) => {
|
|
|
12
12
|
}
|
|
13
13
|
return a;
|
|
14
14
|
};
|
|
15
|
+
exports.unique = unique;
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"2.1
|
|
1
|
+
{"version":"2.3.1","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.1
|
|
4
|
+
"version": "2.3.1",
|
|
5
5
|
"author": "hrdtbs",
|
|
6
6
|
"bin": {
|
|
7
7
|
"mes": "./bin/run"
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"eslint-config-oclif": "^3.1",
|
|
32
32
|
"eslint-config-oclif-typescript": "^0.2.0",
|
|
33
33
|
"globby": "^11.0.1",
|
|
34
|
-
"mocha": "^
|
|
34
|
+
"mocha": "^10.0.0",
|
|
35
35
|
"nyc": "^15.1.0",
|
|
36
36
|
"standard-version": "^9.0.0",
|
|
37
37
|
"ts-node": "^9.0.0",
|