@looker/sdk-codegen-scripts 21.4.8 → 21.5.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/CHANGELOG.md +25 -1
- package/lib/convert.js +0 -10
- package/lib/convert.js.map +1 -1
- package/lib/declarationMiner.js +11 -37
- package/lib/declarationMiner.js.map +1 -1
- package/lib/esm/convert.js +20 -18
- package/lib/esm/convert.js.map +1 -1
- package/lib/esm/declarationMiner.js +32 -41
- package/lib/esm/declarationMiner.js.map +1 -1
- package/lib/esm/exampleMiner.js +52 -77
- package/lib/esm/exampleMiner.js.map +1 -1
- package/lib/esm/fetchSpec.js +65 -83
- package/lib/esm/fetchSpec.js.map +1 -1
- package/lib/esm/index.js +93 -8
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/languages.js +16 -11
- package/lib/esm/languages.js.map +1 -1
- package/lib/esm/legacy.js +8 -9
- package/lib/esm/legacy.js.map +1 -1
- package/lib/esm/legacyGenerator.js +19 -22
- package/lib/esm/legacyGenerator.js.map +1 -1
- package/lib/esm/nodeUtils.js +39 -22
- package/lib/esm/nodeUtils.js.map +1 -1
- package/lib/esm/prettify.js +15 -9
- package/lib/esm/prettify.js.map +1 -1
- package/lib/esm/reformatter.js +53 -102
- package/lib/esm/reformatter.js.map +1 -1
- package/lib/esm/sdkConfig.js +19 -13
- package/lib/esm/sdkConfig.js.map +1 -1
- package/lib/esm/sdkGen.js +43 -59
- package/lib/esm/sdkGen.js.map +1 -1
- package/lib/esm/sdkGenerator.js +34 -47
- package/lib/esm/sdkGenerator.js.map +1 -1
- package/lib/esm/specConvert.js +20 -27
- package/lib/esm/specConvert.js.map +1 -1
- package/lib/esm/testUtils/index.js +28 -0
- package/lib/esm/testUtils/index.js.map +1 -0
- package/lib/esm/testUtils/mocks.js +16 -0
- package/lib/esm/testUtils/mocks.js.map +1 -0
- package/lib/esm/testUtils/testUtils.js +66 -0
- package/lib/esm/testUtils/testUtils.js.map +1 -0
- package/lib/esm/utils.js +43 -60
- package/lib/esm/utils.js.map +1 -1
- package/lib/esm/yamlToJson.js +8 -6
- package/lib/esm/yamlToJson.js.map +1 -1
- package/lib/exampleMiner.js +4 -89
- package/lib/exampleMiner.js.map +1 -1
- package/lib/fetchSpec.js +6 -76
- package/lib/fetchSpec.js.map +1 -1
- package/lib/index.js +0 -16
- package/lib/index.js.map +1 -1
- package/lib/languages.js +0 -11
- package/lib/languages.js.map +1 -1
- package/lib/legacy.js +0 -5
- package/lib/legacy.js.map +1 -1
- package/lib/legacyGenerator.js +0 -15
- package/lib/legacyGenerator.js.map +1 -1
- package/lib/nodeUtils.js +1 -34
- package/lib/nodeUtils.js.map +1 -1
- package/lib/prettify.js +5 -14
- package/lib/prettify.js.map +1 -1
- package/lib/reformatter.js +3 -70
- package/lib/reformatter.js.map +1 -1
- package/lib/sdkConfig.js +0 -16
- package/lib/sdkConfig.js.map +1 -1
- package/lib/sdkGen.js +0 -41
- package/lib/sdkGen.js.map +1 -1
- package/lib/sdkGenerator.js +4 -52
- package/lib/sdkGenerator.js.map +1 -1
- package/lib/specConvert.js +0 -19
- package/lib/specConvert.js.map +1 -1
- package/lib/testUtils/index.js +0 -4
- package/lib/testUtils/index.js.map +1 -1
- package/lib/testUtils/mocks.js +0 -4
- package/lib/testUtils/mocks.js.map +1 -1
- package/lib/testUtils/testUtils.js +1 -17
- package/lib/testUtils/testUtils.js.map +1 -1
- package/lib/utils.js +6 -48
- package/lib/utils.js.map +1 -1
- package/lib/yamlToJson.js +0 -7
- package/lib/yamlToJson.js.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
### Dependencies
|
|
4
|
+
|
|
5
|
+
* The following workspace dependencies were updated
|
|
6
|
+
* dependencies
|
|
7
|
+
* @looker/sdk bumped from ^23.0.0 to ^23.2.0
|
|
8
|
+
* @looker/sdk-node bumped from ^23.0.0 to ^23.2.0
|
|
9
|
+
|
|
10
|
+
## [21.5.0](https://github.com/looker-open-source/sdk-codegen/compare/sdk-codegen-scripts-v21.4.8...sdk-codegen-scripts-v21.5.0) (2023-02-22)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* generate SDKs for Looker 23.0 ([#1237](https://github.com/looker-open-source/sdk-codegen/issues/1237)) ([2ade858](https://github.com/looker-open-source/sdk-codegen/commit/2ade85815c43383169263659f5dddd783c062c09))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Dependencies
|
|
19
|
+
|
|
20
|
+
* The following workspace dependencies were updated
|
|
21
|
+
* dependencies
|
|
22
|
+
* @looker/sdk bumped from ^22.20.1 to ^23.0.0
|
|
23
|
+
* @looker/sdk-codegen bumped from ^21.7.4 to ^21.8.0
|
|
24
|
+
* @looker/sdk-node bumped from ^22.20.1 to ^23.0.0
|
|
25
|
+
* @looker/sdk-rtl bumped from ^21.5.0 to ^21.6.0
|
|
26
|
+
|
|
3
27
|
### [21.4.8](https://www.github.com/looker-open-source/sdk-codegen/compare/sdk-codegen-scripts-v21.4.7...sdk-codegen-scripts-v21.4.8) (2022-12-09)
|
|
4
28
|
|
|
5
29
|
|
|
@@ -531,4 +555,4 @@
|
|
|
531
555
|
* @looker/sdk-codegen bumped from ^21.0.10 to ^21.0.11
|
|
532
556
|
* @looker/sdk-codegen-utils bumped from ^21.0.10 to ^21.0.11
|
|
533
557
|
* @looker/sdk-node bumped from ^21.0.10 to ^21.4.0
|
|
534
|
-
* @looker/sdk-rtl bumped from ^21.0.10 to ^21.0.11
|
|
558
|
+
* @looker/sdk-rtl bumped from ^21.0.10 to ^21.0.11
|
package/lib/convert.js
CHANGED
|
@@ -4,24 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.convertSpec = void 0;
|
|
7
|
-
|
|
8
7
|
var _sdkCodegenUtils = require("@looker/sdk-codegen-utils");
|
|
9
|
-
|
|
10
8
|
var _sdkCodegen = require("@looker/sdk-codegen");
|
|
11
|
-
|
|
12
9
|
var _nodeUtils = require("./nodeUtils");
|
|
13
|
-
|
|
14
10
|
var convertSpec = function convertSpec(specFileName, openApiFilename) {
|
|
15
11
|
var force = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
16
|
-
|
|
17
12
|
if ((0, _nodeUtils.isFileSync)(openApiFilename) && !force) {
|
|
18
13
|
(0, _sdkCodegenUtils.log)("".concat(openApiFilename, " already exists. Skipping conversion."));
|
|
19
14
|
return openApiFilename;
|
|
20
15
|
}
|
|
21
|
-
|
|
22
16
|
var spec = (0, _nodeUtils.readFileSync)(specFileName);
|
|
23
17
|
var swagger = JSON.parse(spec);
|
|
24
|
-
|
|
25
18
|
if (swagger.swagger) {
|
|
26
19
|
(0, _nodeUtils.run)('yarn swagger2openapi', [specFileName, '-p', '-i', '""', '-o', openApiFilename]);
|
|
27
20
|
} else if (swagger.openapi) {
|
|
@@ -29,15 +22,12 @@ var convertSpec = function convertSpec(specFileName, openApiFilename) {
|
|
|
29
22
|
} else {
|
|
30
23
|
throw new Error("Bad specification file ".concat(specFileName));
|
|
31
24
|
}
|
|
32
|
-
|
|
33
25
|
if (!(0, _nodeUtils.isFileSync)(openApiFilename)) {
|
|
34
26
|
return (0, _nodeUtils.fail)('convertSpec', "creating ".concat(openApiFilename, " failed"));
|
|
35
27
|
}
|
|
36
|
-
|
|
37
28
|
var source = (0, _sdkCodegen.upgradeSpec)((0, _nodeUtils.readFileSync)(openApiFilename));
|
|
38
29
|
(0, _nodeUtils.createJsonFile)(openApiFilename, source);
|
|
39
30
|
return openApiFilename;
|
|
40
31
|
};
|
|
41
|
-
|
|
42
32
|
exports.convertSpec = convertSpec;
|
|
43
33
|
//# sourceMappingURL=convert.js.map
|
package/lib/convert.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"convert.js","names":["convertSpec","specFileName","openApiFilename","force","isFileSync","log","spec","readFileSync","swagger","JSON","parse","run","openapi","writeFileSync","stringify","Error","fail","source","upgradeSpec","createJsonFile"],"sources":["../src/convert.ts"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport { log } from '@looker/sdk-codegen-utils'\nimport { upgradeSpec } from '@looker/sdk-codegen'\nimport {\n createJsonFile,\n fail,\n isFileSync,\n readFileSync,\n run,\n writeFileSync,\n} from './nodeUtils'\n\n/**\n * Convert a Swagger specification to OpenAPI\n *\n * If the source spec is already an OpenAPI spec, fixes are still processed\n *\n * @param specFileName source Swagger spec file\n * @param openApiFilename destination OpenAPI spec file\n * @param force use `true` to force a conversion even if the file exists\n * @returns {Promise<string>} name of OpenAPI file\n */\nexport const convertSpec = (\n specFileName: string,\n openApiFilename: string,\n force = false\n) => {\n if (isFileSync(openApiFilename) && !force) {\n log(`${openApiFilename} already exists. Skipping conversion.`)\n return openApiFilename\n }\n const spec = readFileSync(specFileName)\n const swagger = JSON.parse(spec)\n if (swagger.swagger) {\n // Still a swagger spec. Convert it.\n // https://github.com/Mermade/oas-kit/tree/master/packages/swagger2openapi config options:\n // patch to fix up small errors in source definition (not required, just to ensure smooth process)\n // indent no spaces\n // output to openApiFilename\n run('yarn swagger2openapi', [\n specFileName,\n '-p',\n '-i',\n '\"\"',\n '-o',\n openApiFilename,\n ])\n } else if (swagger.openapi) {\n // We've already got an OpenAPI file\n writeFileSync(openApiFilename, JSON.stringify(swagger))\n } else {\n throw new Error(`Bad specification file ${specFileName}`)\n }\n if (!isFileSync(openApiFilename)) {\n return fail('convertSpec', `creating ${openApiFilename} failed`)\n }\n const source = upgradeSpec(readFileSync(openApiFilename))\n createJsonFile(openApiFilename, source)\n return openApiFilename\n}\n"],"mappings":";;;;;;AA0BA;AACA;AACA;AAmBO,IAAMA,WAAW,GAAG,SAAdA,WAAW,CACtBC,YAAoB,EACpBC,eAAuB,EAEpB;EAAA,IADHC,KAAK,uEAAG,KAAK;EAEb,IAAI,IAAAC,qBAAU,EAACF,eAAe,CAAC,IAAI,CAACC,KAAK,EAAE;IACzC,IAAAE,oBAAG,YAAIH,eAAe,2CAAwC;IAC9D,OAAOA,eAAe;EACxB;EACA,IAAMI,IAAI,GAAG,IAAAC,uBAAY,EAACN,YAAY,CAAC;EACvC,IAAMO,OAAO,GAAGC,IAAI,CAACC,KAAK,CAACJ,IAAI,CAAC;EAChC,IAAIE,OAAO,CAACA,OAAO,EAAE;IAMnB,IAAAG,cAAG,EAAC,sBAAsB,EAAE,CAC1BV,YAAY,EACZ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJC,eAAe,CAChB,CAAC;EACJ,CAAC,MAAM,IAAIM,OAAO,CAACI,OAAO,EAAE;IAE1B,IAAAC,wBAAa,EAACX,eAAe,EAAEO,IAAI,CAACK,SAAS,CAACN,OAAO,CAAC,CAAC;EACzD,CAAC,MAAM;IACL,MAAM,IAAIO,KAAK,kCAA2Bd,YAAY,EAAG;EAC3D;EACA,IAAI,CAAC,IAAAG,qBAAU,EAACF,eAAe,CAAC,EAAE;IAChC,OAAO,IAAAc,eAAI,EAAC,aAAa,qBAAcd,eAAe,aAAU;EAClE;EACA,IAAMe,MAAM,GAAG,IAAAC,uBAAW,EAAC,IAAAX,uBAAY,EAACL,eAAe,CAAC,CAAC;EACzD,IAAAiB,yBAAc,EAACjB,eAAe,EAAEe,MAAM,CAAC;EACvC,OAAOf,eAAe;AACxB,CAAC;AAAA"}
|
package/lib/declarationMiner.js
CHANGED
|
@@ -3,34 +3,25 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
|
|
6
|
+
exports.rubyTypeProbe = exports.rubyMethodProbe = exports.DeclarationMiner = void 0;
|
|
8
7
|
var _path = _interopRequireDefault(require("path"));
|
|
9
|
-
|
|
10
8
|
var _exampleMiner = require("./exampleMiner");
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
23
|
-
|
|
24
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
25
|
-
|
|
10
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
11
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
12
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
14
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
15
|
+
function _wrapRegExp() { _wrapRegExp = function _wrapRegExp(re, groups) { return new BabelRegExp(re, void 0, groups); }; var _super = RegExp.prototype, _groups = new WeakMap(); function BabelRegExp(re, flags, groups) { var _this = new RegExp(re, flags); return _groups.set(_this, groups || _groups.get(re)), _setPrototypeOf(_this, BabelRegExp.prototype); } function buildGroups(result, re) { var g = _groups.get(re); return Object.keys(g).reduce(function (groups, name) { var i = g[name]; if ("number" == typeof i) groups[name] = result[i];else { for (var k = 0; void 0 === result[i[k]] && k + 1 < i.length;) k++; groups[name] = result[i[k]]; } return groups; }, Object.create(null)); } return _inherits(BabelRegExp, RegExp), BabelRegExp.prototype.exec = function (str) { var result = _super.exec.call(this, str); if (result) { result.groups = buildGroups(result, this); var indices = result.indices; indices && (indices.groups = buildGroups(indices, this)); } return result; }, BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { if ("string" == typeof substitution) { var groups = _groups.get(this); return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) { var group = groups[name]; return "$" + (Array.isArray(group) ? group.join("$") : group); })); } if ("function" == typeof substitution) { var _this = this; return _super[Symbol.replace].call(this, str, function () { var args = arguments; return "object" != typeof args[args.length - 1] && (args = [].slice.call(args)).push(buildGroups(args, _this)), substitution.apply(this, args); }); } return _super[Symbol.replace].call(this, str, substitution); }, _wrapRegExp.apply(this, arguments); }
|
|
16
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
17
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
26
18
|
var fileFilter = (endpointFilePattern, typeFilePattern, fileName) => {
|
|
27
19
|
var fileMatch = endpointFilePattern.test(fileName) || typeFilePattern.test(fileName);
|
|
28
20
|
return (0, _exampleMiner.filterCodeFiles)(fileName) && fileMatch;
|
|
29
21
|
};
|
|
30
|
-
|
|
31
22
|
var rubyMethodProbe = {
|
|
32
23
|
fileNamePattern: /^(?!test).*_controller.rb$/,
|
|
33
|
-
declarationPattern: _wrapRegExp(/(GET|POST|DELETE|PUT|PATCH)
|
|
24
|
+
declarationPattern: _wrapRegExp(/(GET|POST|DELETE|PUT|PATCH)\s(?:"|')\/api\/3\.x(\S+)(?:"|')/i, {
|
|
34
25
|
verb: 1,
|
|
35
26
|
path: 2
|
|
36
27
|
}),
|
|
@@ -44,25 +35,21 @@ var rubyMethodProbe = {
|
|
|
44
35
|
exports.rubyMethodProbe = rubyMethodProbe;
|
|
45
36
|
var rubyTypeProbe = {
|
|
46
37
|
fileNamePattern: /^(?!test).*_mapper.rb$/,
|
|
47
|
-
declarationPattern: _wrapRegExp(/class
|
|
38
|
+
declarationPattern: _wrapRegExp(/class\s(\w+)Mapper/i, {
|
|
48
39
|
typeName: 1
|
|
49
40
|
}),
|
|
50
41
|
matchToSpecKeyTransform: match => match.groups.typeName
|
|
51
42
|
};
|
|
52
43
|
exports.rubyTypeProbe = rubyTypeProbe;
|
|
53
|
-
|
|
54
44
|
class DeclarationMiner {
|
|
55
45
|
constructor(sourcePath, methodProbe, typeProbe, originOverride) {
|
|
56
46
|
this.sourcePath = sourcePath;
|
|
57
47
|
this.methodProbe = methodProbe;
|
|
58
48
|
this.typeProbe = typeProbe;
|
|
59
49
|
this.originOverride = originOverride;
|
|
60
|
-
|
|
61
50
|
_defineProperty(this, "types", {});
|
|
62
|
-
|
|
63
51
|
_defineProperty(this, "methods", {});
|
|
64
52
|
}
|
|
65
|
-
|
|
66
53
|
execute(sourcePath, methodProbe, typeProbe) {
|
|
67
54
|
var filePath = sourcePath !== null && sourcePath !== void 0 ? sourcePath : this.sourcePath;
|
|
68
55
|
var mProbe = methodProbe !== null && methodProbe !== void 0 ? methodProbe : this.methodProbe;
|
|
@@ -70,9 +57,7 @@ class DeclarationMiner {
|
|
|
70
57
|
var files = (0, _exampleMiner.getCodeFiles)(filePath, undefined, fileFilter.bind(null, mProbe.fileNamePattern, tProbe.fileNamePattern), ['node_modules', 'dist']);
|
|
71
58
|
files.forEach(f => {
|
|
72
59
|
var relFile = this.processFile(f);
|
|
73
|
-
|
|
74
60
|
var fileName = _path.default.basename(relFile);
|
|
75
|
-
|
|
76
61
|
if (mProbe.fileNamePattern.test(fileName)) {
|
|
77
62
|
this.methods = _objectSpread(_objectSpread({}, this.methods), this.mineFile(relFile, f, mProbe));
|
|
78
63
|
} else {
|
|
@@ -81,21 +66,17 @@ class DeclarationMiner {
|
|
|
81
66
|
});
|
|
82
67
|
return this.lode;
|
|
83
68
|
}
|
|
84
|
-
|
|
85
69
|
get commitHash() {
|
|
86
70
|
process.chdir(this.sourcePath);
|
|
87
71
|
return (0, _exampleMiner.getCommitHash)();
|
|
88
72
|
}
|
|
89
|
-
|
|
90
73
|
get remoteOrigin() {
|
|
91
74
|
if (this.originOverride) {
|
|
92
75
|
return this.originOverride;
|
|
93
76
|
}
|
|
94
|
-
|
|
95
77
|
process.chdir(this.sourcePath);
|
|
96
78
|
return (0, _exampleMiner.getRemoteOrigin)();
|
|
97
79
|
}
|
|
98
|
-
|
|
99
80
|
get lode() {
|
|
100
81
|
return {
|
|
101
82
|
commitHash: this.commitHash,
|
|
@@ -104,23 +85,18 @@ class DeclarationMiner {
|
|
|
104
85
|
methods: this.methods
|
|
105
86
|
};
|
|
106
87
|
}
|
|
107
|
-
|
|
108
88
|
processFile(fileName) {
|
|
109
89
|
var relFile = _exampleMiner.ExampleMiner.relate(this.sourcePath, fileName);
|
|
110
|
-
|
|
111
90
|
return relFile;
|
|
112
91
|
}
|
|
113
|
-
|
|
114
92
|
mineFile(relFile, fileName, probe) {
|
|
115
93
|
return this.mineCode(relFile, (0, _exampleMiner.readFile)(fileName), probe);
|
|
116
94
|
}
|
|
117
|
-
|
|
118
95
|
mineCode(relFile, content, probe) {
|
|
119
96
|
var lines = content.split('\n');
|
|
120
97
|
var declarations = {};
|
|
121
98
|
lines.forEach((line, index) => {
|
|
122
99
|
var match = probe.declarationPattern.exec(line);
|
|
123
|
-
|
|
124
100
|
if (match) {
|
|
125
101
|
var key = probe.matchToSpecKeyTransform(match);
|
|
126
102
|
declarations[key] = {
|
|
@@ -131,8 +107,6 @@ class DeclarationMiner {
|
|
|
131
107
|
});
|
|
132
108
|
return declarations;
|
|
133
109
|
}
|
|
134
|
-
|
|
135
110
|
}
|
|
136
|
-
|
|
137
111
|
exports.DeclarationMiner = DeclarationMiner;
|
|
138
112
|
//# sourceMappingURL=declarationMiner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"declarationMiner.js","names":["fileFilter","endpointFilePattern","typeFilePattern","fileName","fileMatch","test","filterCodeFiles","rubyMethodProbe","fileNamePattern","declarationPattern","matchToSpecKeyTransform","match","verb","groups","toLocaleUpperCase","path","replace","key","rubyTypeProbe","typeName","DeclarationMiner","constructor","sourcePath","methodProbe","typeProbe","originOverride","execute","filePath","mProbe","tProbe","files","getCodeFiles","undefined","bind","forEach","f","relFile","processFile","basename","methods","mineFile","types","lode","commitHash","process","chdir","getCommitHash","remoteOrigin","getRemoteOrigin","ExampleMiner","relate","probe","mineCode","readFile","content","lines","split","declarations","line","index","exec","sourceFile"],"sources":["../src/declarationMiner.ts"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport path from 'path'\nimport type { DeclarationNuggets, IDeclarationMine } from '@looker/sdk-codegen'\n\nimport {\n filterCodeFiles,\n getCodeFiles,\n ExampleMiner,\n readFile,\n getCommitHash,\n getRemoteOrigin,\n} from './exampleMiner'\n\n/**\n * Filter that checks if given file name matches any of the specified patterns\n * @param endpointFilePattern A pattern that matches endpoint files\n * @param typeFilePattern A pattern that matches type files\n * @param fileName File name to check against patterns\n */\nconst fileFilter = (\n endpointFilePattern: RegExp,\n typeFilePattern: RegExp,\n fileName: string\n) => {\n const fileMatch =\n endpointFilePattern.test(fileName) || typeFilePattern.test(fileName)\n return filterCodeFiles(fileName) && fileMatch\n}\n\n/**\n * Reference method probe for a Ruby controller\n */\nexport const rubyMethodProbe = {\n fileNamePattern: /^(?!test).*_controller.rb$/,\n declarationPattern:\n /(?<verb>GET|POST|DELETE|PUT|PATCH)\\s(?:\"|')\\/api\\/3\\.x(?<path>\\S+)(?:\"|')/i,\n matchToSpecKeyTransform: (match: RegExpExecArray) => {\n const verb = match.groups!.verb.toLocaleUpperCase()\n const path = match\n .groups!.path.replace(':#', '')\n .replace('#', '')\n .replace(/:(\\w+)/g, '{$1}')\n const key = `${verb} ${path}`\n return key\n },\n}\n\n/**\n * Reference type probe for a Ruby mapper\n */\nexport const rubyTypeProbe: IProbe = {\n fileNamePattern: /^(?!test).*_mapper.rb$/,\n declarationPattern: /class\\s(?<typeName>\\w+)Mapper/i,\n matchToSpecKeyTransform: (match: RegExpExecArray) => match.groups!.typeName,\n}\n\nexport interface IProbe {\n /** Pattern of file names to mine */\n fileNamePattern: RegExp\n /** Pattern matching the declaration of a method/type */\n declarationPattern: RegExp\n /** A transform lambda for transforming a declaration match into a spec key */\n matchToSpecKeyTransform: (match: RegExpExecArray) => string\n}\n\nexport class DeclarationMiner {\n types: DeclarationNuggets = {}\n methods: DeclarationNuggets = {}\n\n constructor(\n public readonly sourcePath: string,\n public readonly methodProbe: IProbe,\n public readonly typeProbe: IProbe,\n private readonly originOverride: string\n ) {}\n\n execute(sourcePath?: string, methodProbe?: IProbe, typeProbe?: IProbe) {\n const filePath = sourcePath ?? this.sourcePath\n const mProbe = methodProbe ?? this.methodProbe\n const tProbe = typeProbe ?? this.typeProbe\n\n const files = getCodeFiles(\n filePath,\n undefined,\n fileFilter.bind(null, mProbe.fileNamePattern, tProbe.fileNamePattern),\n ['node_modules', 'dist']\n )\n\n files.forEach((f) => {\n const relFile = this.processFile(f)\n const fileName = path.basename(relFile)\n if (mProbe.fileNamePattern.test(fileName)) {\n this.methods = { ...this.methods, ...this.mineFile(relFile, f, mProbe) }\n } else {\n this.types = { ...this.types, ...this.mineFile(relFile, f, tProbe) }\n }\n })\n return this.lode\n }\n\n get commitHash(): string {\n process.chdir(this.sourcePath)\n return getCommitHash()\n }\n\n get remoteOrigin(): string {\n if (this.originOverride) {\n return this.originOverride\n }\n process.chdir(this.sourcePath)\n return getRemoteOrigin()\n }\n\n get lode(): IDeclarationMine {\n return {\n commitHash: this.commitHash,\n remoteOrigin: this.remoteOrigin,\n types: this.types,\n methods: this.methods,\n }\n }\n\n protected processFile(fileName: string) {\n const relFile = ExampleMiner.relate(this.sourcePath, fileName)\n return relFile\n }\n\n protected mineFile(relFile: string, fileName: string, probe: IProbe) {\n return this.mineCode(relFile, readFile(fileName), probe)\n }\n\n protected mineCode(relFile: string, content: string, probe: IProbe) {\n const lines = content.split('\\n')\n const declarations: DeclarationNuggets = {}\n lines.forEach((line, index) => {\n const match = probe.declarationPattern.exec(line)\n if (match) {\n const key = probe.matchToSpecKeyTransform(match)\n declarations[key] = {\n line: index + 1,\n sourceFile: relFile,\n }\n }\n })\n return declarations\n }\n}\n"],"mappings":";;;;;;AA0BA;AAGA;AAOuB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQvB,IAAMA,UAAU,GAAG,CACjBC,mBAA2B,EAC3BC,eAAuB,EACvBC,QAAgB,KACb;EACH,IAAMC,SAAS,GACbH,mBAAmB,CAACI,IAAI,CAACF,QAAQ,CAAC,IAAID,eAAe,CAACG,IAAI,CAACF,QAAQ,CAAC;EACtE,OAAO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onFile, fail, isFileSync, readFileSync, run, writeFileSync } from './nodeUtils';
|
|
4
|
-
export var convertSpec = function convertSpec(specFileName, openApiFilename) {
|
|
5
|
-
var force = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
1
|
+
"use strict";
|
|
6
2
|
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.convertSpec = void 0;
|
|
7
|
+
var _sdkCodegenUtils = require("@looker/sdk-codegen-utils");
|
|
8
|
+
var _sdkCodegen = require("@looker/sdk-codegen");
|
|
9
|
+
var _nodeUtils = require("./nodeUtils");
|
|
10
|
+
var convertSpec = function convertSpec(specFileName, openApiFilename) {
|
|
11
|
+
var force = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
12
|
+
if ((0, _nodeUtils.isFileSync)(openApiFilename) && !force) {
|
|
13
|
+
(0, _sdkCodegenUtils.log)("".concat(openApiFilename, " already exists. Skipping conversion."));
|
|
9
14
|
return openApiFilename;
|
|
10
15
|
}
|
|
11
|
-
|
|
12
|
-
var spec = readFileSync(specFileName);
|
|
16
|
+
var spec = (0, _nodeUtils.readFileSync)(specFileName);
|
|
13
17
|
var swagger = JSON.parse(spec);
|
|
14
|
-
|
|
15
18
|
if (swagger.swagger) {
|
|
16
|
-
run('yarn swagger2openapi', [specFileName, '-p', '-i', '""', '-o', openApiFilename]);
|
|
19
|
+
(0, _nodeUtils.run)('yarn swagger2openapi', [specFileName, '-p', '-i', '""', '-o', openApiFilename]);
|
|
17
20
|
} else if (swagger.openapi) {
|
|
18
|
-
writeFileSync(openApiFilename, JSON.stringify(swagger));
|
|
21
|
+
(0, _nodeUtils.writeFileSync)(openApiFilename, JSON.stringify(swagger));
|
|
19
22
|
} else {
|
|
20
23
|
throw new Error("Bad specification file ".concat(specFileName));
|
|
21
24
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return fail('convertSpec', "creating ".concat(openApiFilename, " failed"));
|
|
25
|
+
if (!(0, _nodeUtils.isFileSync)(openApiFilename)) {
|
|
26
|
+
return (0, _nodeUtils.fail)('convertSpec', "creating ".concat(openApiFilename, " failed"));
|
|
25
27
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
createJsonFile(openApiFilename, source);
|
|
28
|
+
var source = (0, _sdkCodegen.upgradeSpec)((0, _nodeUtils.readFileSync)(openApiFilename));
|
|
29
|
+
(0, _nodeUtils.createJsonFile)(openApiFilename, source);
|
|
29
30
|
return openApiFilename;
|
|
30
31
|
};
|
|
32
|
+
exports.convertSpec = convertSpec;
|
|
31
33
|
//# sourceMappingURL=convert.js.map
|
package/lib/esm/convert.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"convert.js","names":["convertSpec","specFileName","openApiFilename","force","isFileSync","log","spec","readFileSync","swagger","JSON","parse","run","openapi","writeFileSync","stringify","Error","fail","source","upgradeSpec","createJsonFile"],"sources":["../../src/convert.ts"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport { log } from '@looker/sdk-codegen-utils'\nimport { upgradeSpec } from '@looker/sdk-codegen'\nimport {\n createJsonFile,\n fail,\n isFileSync,\n readFileSync,\n run,\n writeFileSync,\n} from './nodeUtils'\n\n/**\n * Convert a Swagger specification to OpenAPI\n *\n * If the source spec is already an OpenAPI spec, fixes are still processed\n *\n * @param specFileName source Swagger spec file\n * @param openApiFilename destination OpenAPI spec file\n * @param force use `true` to force a conversion even if the file exists\n * @returns {Promise<string>} name of OpenAPI file\n */\nexport const convertSpec = (\n specFileName: string,\n openApiFilename: string,\n force = false\n) => {\n if (isFileSync(openApiFilename) && !force) {\n log(`${openApiFilename} already exists. Skipping conversion.`)\n return openApiFilename\n }\n const spec = readFileSync(specFileName)\n const swagger = JSON.parse(spec)\n if (swagger.swagger) {\n // Still a swagger spec. Convert it.\n // https://github.com/Mermade/oas-kit/tree/master/packages/swagger2openapi config options:\n // patch to fix up small errors in source definition (not required, just to ensure smooth process)\n // indent no spaces\n // output to openApiFilename\n run('yarn swagger2openapi', [\n specFileName,\n '-p',\n '-i',\n '\"\"',\n '-o',\n openApiFilename,\n ])\n } else if (swagger.openapi) {\n // We've already got an OpenAPI file\n writeFileSync(openApiFilename, JSON.stringify(swagger))\n } else {\n throw new Error(`Bad specification file ${specFileName}`)\n }\n if (!isFileSync(openApiFilename)) {\n return fail('convertSpec', `creating ${openApiFilename} failed`)\n }\n const source = upgradeSpec(readFileSync(openApiFilename))\n createJsonFile(openApiFilename, source)\n return openApiFilename\n}\n"],"mappings":";;;;;;AA0BA;AACA;AACA;AAmBO,IAAMA,WAAW,GAAG,SAAdA,WAAW,CACtBC,YAAoB,EACpBC,eAAuB,EAEpB;EAAA,IADHC,KAAK,uEAAG,KAAK;EAEb,IAAI,IAAAC,qBAAU,EAACF,eAAe,CAAC,IAAI,CAACC,KAAK,EAAE;IACzC,IAAAE,oBAAG,YAAIH,eAAe,2CAAwC;IAC9D,OAAOA,eAAe;EACxB;EACA,IAAMI,IAAI,GAAG,IAAAC,uBAAY,EAACN,YAAY,CAAC;EACvC,IAAMO,OAAO,GAAGC,IAAI,CAACC,KAAK,CAACJ,IAAI,CAAC;EAChC,IAAIE,OAAO,CAACA,OAAO,EAAE;IAMnB,IAAAG,cAAG,EAAC,sBAAsB,EAAE,CAC1BV,YAAY,EACZ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJC,eAAe,CAChB,CAAC;EACJ,CAAC,MAAM,IAAIM,OAAO,CAACI,OAAO,EAAE;IAE1B,IAAAC,wBAAa,EAACX,eAAe,EAAEO,IAAI,CAACK,SAAS,CAACN,OAAO,CAAC,CAAC;EACzD,CAAC,MAAM;IACL,MAAM,IAAIO,KAAK,kCAA2Bd,YAAY,EAAG;EAC3D;EACA,IAAI,CAAC,IAAAG,qBAAU,EAACF,eAAe,CAAC,EAAE;IAChC,OAAO,IAAAc,eAAI,EAAC,aAAa,qBAAcd,eAAe,aAAU;EAClE;EACA,IAAMe,MAAM,GAAG,IAAAC,uBAAW,EAAC,IAAAX,uBAAY,EAACL,eAAe,CAAC,CAAC;EACzD,IAAAiB,yBAAc,EAACjB,eAAe,EAAEe,MAAM,CAAC;EACvC,OAAOf,eAAe;AACxB,CAAC;AAAA"}
|
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.rubyTypeProbe = exports.rubyMethodProbe = exports.DeclarationMiner = void 0;
|
|
7
|
+
var _path = _interopRequireDefault(require("path"));
|
|
8
|
+
var _exampleMiner = require("./exampleMiner");
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
11
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
12
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
14
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
15
|
+
function _wrapRegExp() { _wrapRegExp = function _wrapRegExp(re, groups) { return new BabelRegExp(re, void 0, groups); }; var _super = RegExp.prototype, _groups = new WeakMap(); function BabelRegExp(re, flags, groups) { var _this = new RegExp(re, flags); return _groups.set(_this, groups || _groups.get(re)), _setPrototypeOf(_this, BabelRegExp.prototype); } function buildGroups(result, re) { var g = _groups.get(re); return Object.keys(g).reduce(function (groups, name) { var i = g[name]; if ("number" == typeof i) groups[name] = result[i];else { for (var k = 0; void 0 === result[i[k]] && k + 1 < i.length;) k++; groups[name] = result[i[k]]; } return groups; }, Object.create(null)); } return _inherits(BabelRegExp, RegExp), BabelRegExp.prototype.exec = function (str) { var result = _super.exec.call(this, str); if (result) { result.groups = buildGroups(result, this); var indices = result.indices; indices && (indices.groups = buildGroups(indices, this)); } return result; }, BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { if ("string" == typeof substitution) { var groups = _groups.get(this); return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) { var group = groups[name]; return "$" + (Array.isArray(group) ? group.join("$") : group); })); } if ("function" == typeof substitution) { var _this = this; return _super[Symbol.replace].call(this, str, function () { var args = arguments; return "object" != typeof args[args.length - 1] && (args = [].slice.call(args)).push(buildGroups(args, _this)), substitution.apply(this, args); }); } return _super[Symbol.replace].call(this, str, substitution); }, _wrapRegExp.apply(this, arguments); }
|
|
16
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
17
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
16
18
|
var fileFilter = (endpointFilePattern, typeFilePattern, fileName) => {
|
|
17
19
|
var fileMatch = endpointFilePattern.test(fileName) || typeFilePattern.test(fileName);
|
|
18
|
-
return filterCodeFiles(fileName) && fileMatch;
|
|
20
|
+
return (0, _exampleMiner.filterCodeFiles)(fileName) && fileMatch;
|
|
19
21
|
};
|
|
20
|
-
|
|
21
|
-
export var rubyMethodProbe = {
|
|
22
|
+
var rubyMethodProbe = {
|
|
22
23
|
fileNamePattern: /^(?!test).*_controller.rb$/,
|
|
23
|
-
declarationPattern: _wrapRegExp(/(GET|POST|DELETE|PUT|PATCH)
|
|
24
|
+
declarationPattern: _wrapRegExp(/(GET|POST|DELETE|PUT|PATCH)\s(?:"|')\/api\/3\.x(\S+)(?:"|')/i, {
|
|
24
25
|
verb: 1,
|
|
25
26
|
path: 2
|
|
26
27
|
}),
|
|
@@ -31,34 +32,32 @@ export var rubyMethodProbe = {
|
|
|
31
32
|
return key;
|
|
32
33
|
}
|
|
33
34
|
};
|
|
34
|
-
|
|
35
|
+
exports.rubyMethodProbe = rubyMethodProbe;
|
|
36
|
+
var rubyTypeProbe = {
|
|
35
37
|
fileNamePattern: /^(?!test).*_mapper.rb$/,
|
|
36
|
-
declarationPattern: _wrapRegExp(/class
|
|
38
|
+
declarationPattern: _wrapRegExp(/class\s(\w+)Mapper/i, {
|
|
37
39
|
typeName: 1
|
|
38
40
|
}),
|
|
39
41
|
matchToSpecKeyTransform: match => match.groups.typeName
|
|
40
42
|
};
|
|
41
|
-
|
|
43
|
+
exports.rubyTypeProbe = rubyTypeProbe;
|
|
44
|
+
class DeclarationMiner {
|
|
42
45
|
constructor(sourcePath, methodProbe, typeProbe, originOverride) {
|
|
43
46
|
this.sourcePath = sourcePath;
|
|
44
47
|
this.methodProbe = methodProbe;
|
|
45
48
|
this.typeProbe = typeProbe;
|
|
46
49
|
this.originOverride = originOverride;
|
|
47
|
-
|
|
48
50
|
_defineProperty(this, "types", {});
|
|
49
|
-
|
|
50
51
|
_defineProperty(this, "methods", {});
|
|
51
52
|
}
|
|
52
|
-
|
|
53
53
|
execute(sourcePath, methodProbe, typeProbe) {
|
|
54
54
|
var filePath = sourcePath !== null && sourcePath !== void 0 ? sourcePath : this.sourcePath;
|
|
55
55
|
var mProbe = methodProbe !== null && methodProbe !== void 0 ? methodProbe : this.methodProbe;
|
|
56
56
|
var tProbe = typeProbe !== null && typeProbe !== void 0 ? typeProbe : this.typeProbe;
|
|
57
|
-
var files = getCodeFiles(filePath, undefined, fileFilter.bind(null, mProbe.fileNamePattern, tProbe.fileNamePattern), ['node_modules', 'dist']);
|
|
57
|
+
var files = (0, _exampleMiner.getCodeFiles)(filePath, undefined, fileFilter.bind(null, mProbe.fileNamePattern, tProbe.fileNamePattern), ['node_modules', 'dist']);
|
|
58
58
|
files.forEach(f => {
|
|
59
59
|
var relFile = this.processFile(f);
|
|
60
|
-
var fileName =
|
|
61
|
-
|
|
60
|
+
var fileName = _path.default.basename(relFile);
|
|
62
61
|
if (mProbe.fileNamePattern.test(fileName)) {
|
|
63
62
|
this.methods = _objectSpread(_objectSpread({}, this.methods), this.mineFile(relFile, f, mProbe));
|
|
64
63
|
} else {
|
|
@@ -67,21 +66,17 @@ export class DeclarationMiner {
|
|
|
67
66
|
});
|
|
68
67
|
return this.lode;
|
|
69
68
|
}
|
|
70
|
-
|
|
71
69
|
get commitHash() {
|
|
72
70
|
process.chdir(this.sourcePath);
|
|
73
|
-
return getCommitHash();
|
|
71
|
+
return (0, _exampleMiner.getCommitHash)();
|
|
74
72
|
}
|
|
75
|
-
|
|
76
73
|
get remoteOrigin() {
|
|
77
74
|
if (this.originOverride) {
|
|
78
75
|
return this.originOverride;
|
|
79
76
|
}
|
|
80
|
-
|
|
81
77
|
process.chdir(this.sourcePath);
|
|
82
|
-
return getRemoteOrigin();
|
|
78
|
+
return (0, _exampleMiner.getRemoteOrigin)();
|
|
83
79
|
}
|
|
84
|
-
|
|
85
80
|
get lode() {
|
|
86
81
|
return {
|
|
87
82
|
commitHash: this.commitHash,
|
|
@@ -90,22 +85,18 @@ export class DeclarationMiner {
|
|
|
90
85
|
methods: this.methods
|
|
91
86
|
};
|
|
92
87
|
}
|
|
93
|
-
|
|
94
88
|
processFile(fileName) {
|
|
95
|
-
var relFile = ExampleMiner.relate(this.sourcePath, fileName);
|
|
89
|
+
var relFile = _exampleMiner.ExampleMiner.relate(this.sourcePath, fileName);
|
|
96
90
|
return relFile;
|
|
97
91
|
}
|
|
98
|
-
|
|
99
92
|
mineFile(relFile, fileName, probe) {
|
|
100
|
-
return this.mineCode(relFile, readFile(fileName), probe);
|
|
93
|
+
return this.mineCode(relFile, (0, _exampleMiner.readFile)(fileName), probe);
|
|
101
94
|
}
|
|
102
|
-
|
|
103
95
|
mineCode(relFile, content, probe) {
|
|
104
96
|
var lines = content.split('\n');
|
|
105
97
|
var declarations = {};
|
|
106
98
|
lines.forEach((line, index) => {
|
|
107
99
|
var match = probe.declarationPattern.exec(line);
|
|
108
|
-
|
|
109
100
|
if (match) {
|
|
110
101
|
var key = probe.matchToSpecKeyTransform(match);
|
|
111
102
|
declarations[key] = {
|
|
@@ -116,6 +107,6 @@ export class DeclarationMiner {
|
|
|
116
107
|
});
|
|
117
108
|
return declarations;
|
|
118
109
|
}
|
|
119
|
-
|
|
120
110
|
}
|
|
111
|
+
exports.DeclarationMiner = DeclarationMiner;
|
|
121
112
|
//# sourceMappingURL=declarationMiner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"declarationMiner.js","names":["fileFilter","endpointFilePattern","typeFilePattern","fileName","fileMatch","test","filterCodeFiles","rubyMethodProbe","fileNamePattern","declarationPattern","matchToSpecKeyTransform","match","verb","groups","toLocaleUpperCase","path","replace","key","rubyTypeProbe","typeName","DeclarationMiner","constructor","sourcePath","methodProbe","typeProbe","originOverride","execute","filePath","mProbe","tProbe","files","getCodeFiles","undefined","bind","forEach","f","relFile","processFile","basename","methods","mineFile","types","lode","commitHash","process","chdir","getCommitHash","remoteOrigin","getRemoteOrigin","ExampleMiner","relate","probe","mineCode","readFile","content","lines","split","declarations","line","index","exec","sourceFile"],"sources":["../../src/declarationMiner.ts"],"sourcesContent":["/*\n\n MIT License\n\n Copyright (c) 2021 Looker Data Sciences, Inc.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n\n */\n\nimport path from 'path'\nimport type { DeclarationNuggets, IDeclarationMine } from '@looker/sdk-codegen'\n\nimport {\n filterCodeFiles,\n getCodeFiles,\n ExampleMiner,\n readFile,\n getCommitHash,\n getRemoteOrigin,\n} from './exampleMiner'\n\n/**\n * Filter that checks if given file name matches any of the specified patterns\n * @param endpointFilePattern A pattern that matches endpoint files\n * @param typeFilePattern A pattern that matches type files\n * @param fileName File name to check against patterns\n */\nconst fileFilter = (\n endpointFilePattern: RegExp,\n typeFilePattern: RegExp,\n fileName: string\n) => {\n const fileMatch =\n endpointFilePattern.test(fileName) || typeFilePattern.test(fileName)\n return filterCodeFiles(fileName) && fileMatch\n}\n\n/**\n * Reference method probe for a Ruby controller\n */\nexport const rubyMethodProbe = {\n fileNamePattern: /^(?!test).*_controller.rb$/,\n declarationPattern:\n /(?<verb>GET|POST|DELETE|PUT|PATCH)\\s(?:\"|')\\/api\\/3\\.x(?<path>\\S+)(?:\"|')/i,\n matchToSpecKeyTransform: (match: RegExpExecArray) => {\n const verb = match.groups!.verb.toLocaleUpperCase()\n const path = match\n .groups!.path.replace(':#', '')\n .replace('#', '')\n .replace(/:(\\w+)/g, '{$1}')\n const key = `${verb} ${path}`\n return key\n },\n}\n\n/**\n * Reference type probe for a Ruby mapper\n */\nexport const rubyTypeProbe: IProbe = {\n fileNamePattern: /^(?!test).*_mapper.rb$/,\n declarationPattern: /class\\s(?<typeName>\\w+)Mapper/i,\n matchToSpecKeyTransform: (match: RegExpExecArray) => match.groups!.typeName,\n}\n\nexport interface IProbe {\n /** Pattern of file names to mine */\n fileNamePattern: RegExp\n /** Pattern matching the declaration of a method/type */\n declarationPattern: RegExp\n /** A transform lambda for transforming a declaration match into a spec key */\n matchToSpecKeyTransform: (match: RegExpExecArray) => string\n}\n\nexport class DeclarationMiner {\n types: DeclarationNuggets = {}\n methods: DeclarationNuggets = {}\n\n constructor(\n public readonly sourcePath: string,\n public readonly methodProbe: IProbe,\n public readonly typeProbe: IProbe,\n private readonly originOverride: string\n ) {}\n\n execute(sourcePath?: string, methodProbe?: IProbe, typeProbe?: IProbe) {\n const filePath = sourcePath ?? this.sourcePath\n const mProbe = methodProbe ?? this.methodProbe\n const tProbe = typeProbe ?? this.typeProbe\n\n const files = getCodeFiles(\n filePath,\n undefined,\n fileFilter.bind(null, mProbe.fileNamePattern, tProbe.fileNamePattern),\n ['node_modules', 'dist']\n )\n\n files.forEach((f) => {\n const relFile = this.processFile(f)\n const fileName = path.basename(relFile)\n if (mProbe.fileNamePattern.test(fileName)) {\n this.methods = { ...this.methods, ...this.mineFile(relFile, f, mProbe) }\n } else {\n this.types = { ...this.types, ...this.mineFile(relFile, f, tProbe) }\n }\n })\n return this.lode\n }\n\n get commitHash(): string {\n process.chdir(this.sourcePath)\n return getCommitHash()\n }\n\n get remoteOrigin(): string {\n if (this.originOverride) {\n return this.originOverride\n }\n process.chdir(this.sourcePath)\n return getRemoteOrigin()\n }\n\n get lode(): IDeclarationMine {\n return {\n commitHash: this.commitHash,\n remoteOrigin: this.remoteOrigin,\n types: this.types,\n methods: this.methods,\n }\n }\n\n protected processFile(fileName: string) {\n const relFile = ExampleMiner.relate(this.sourcePath, fileName)\n return relFile\n }\n\n protected mineFile(relFile: string, fileName: string, probe: IProbe) {\n return this.mineCode(relFile, readFile(fileName), probe)\n }\n\n protected mineCode(relFile: string, content: string, probe: IProbe) {\n const lines = content.split('\\n')\n const declarations: DeclarationNuggets = {}\n lines.forEach((line, index) => {\n const match = probe.declarationPattern.exec(line)\n if (match) {\n const key = probe.matchToSpecKeyTransform(match)\n declarations[key] = {\n line: index + 1,\n sourceFile: relFile,\n }\n }\n })\n return declarations\n }\n}\n"],"mappings":";;;;;;AA0BA;AAGA;AAOuB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQvB,IAAMA,UAAU,GAAG,CACjBC,mBAA2B,EAC3BC,eAAuB,EACvBC,QAAgB,KACb;EACH,IAAMC,SAAS,GACbH,mBAAmB,CAACI,IAAI,CAACF,QAAQ,CAAC,IAAID,eAAe,CAACG,IAAI,CAACF,QAAQ,CAAC;EACtE,OAAO,IAAAG,6BAAe,EAACH,QAAQ,CAAC,IAAIC,SAAS;AAC/C,CAAC;AAKM,IAAMG,eAAe,GAAG;EAC7BC,eAAe,EAAE,4BAA4B;EAC7CC,kBAAkB,cAChB,8DAA4E;IAAA;IAAA;EAAA;EAC9EC,uBAAuB,EAAGC,KAAsB,IAAK;IACnD,IAAMC,IAAI,GAAGD,KAAK,CAACE,MAAM,CAAED,IAAI,CAACE,iBAAiB,EAAE;IACnD,IAAMC,IAAI,GAAGJ,KAAK,CACfE,MAAM,CAAEE,IAAI,CAACC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAC9BA,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAChBA,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC;IAC7B,IAAMC,GAAG,aAAML,IAAI,cAAIG,IAAI,CAAE;IAC7B,OAAOE,GAAG;EACZ;AACF,CAAC;AAAA;AAKM,IAAMC,aAAqB,GAAG;EACnCV,eAAe,EAAE,wBAAwB;EACzCC,kBAA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