@looker/sdk-codegen-scripts 21.4.7 → 21.5.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.
Files changed (82) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/lib/convert.js +0 -10
  3. package/lib/convert.js.map +1 -1
  4. package/lib/declarationMiner.js +11 -37
  5. package/lib/declarationMiner.js.map +1 -1
  6. package/lib/esm/convert.js +20 -18
  7. package/lib/esm/convert.js.map +1 -1
  8. package/lib/esm/declarationMiner.js +32 -41
  9. package/lib/esm/declarationMiner.js.map +1 -1
  10. package/lib/esm/exampleMiner.js +52 -77
  11. package/lib/esm/exampleMiner.js.map +1 -1
  12. package/lib/esm/fetchSpec.js +65 -83
  13. package/lib/esm/fetchSpec.js.map +1 -1
  14. package/lib/esm/index.js +93 -8
  15. package/lib/esm/index.js.map +1 -1
  16. package/lib/esm/languages.js +16 -11
  17. package/lib/esm/languages.js.map +1 -1
  18. package/lib/esm/legacy.js +8 -9
  19. package/lib/esm/legacy.js.map +1 -1
  20. package/lib/esm/legacyGenerator.js +19 -22
  21. package/lib/esm/legacyGenerator.js.map +1 -1
  22. package/lib/esm/nodeUtils.js +39 -22
  23. package/lib/esm/nodeUtils.js.map +1 -1
  24. package/lib/esm/prettify.js +15 -9
  25. package/lib/esm/prettify.js.map +1 -1
  26. package/lib/esm/reformatter.js +53 -102
  27. package/lib/esm/reformatter.js.map +1 -1
  28. package/lib/esm/sdkConfig.js +19 -13
  29. package/lib/esm/sdkConfig.js.map +1 -1
  30. package/lib/esm/sdkGen.js +43 -59
  31. package/lib/esm/sdkGen.js.map +1 -1
  32. package/lib/esm/sdkGenerator.js +34 -47
  33. package/lib/esm/sdkGenerator.js.map +1 -1
  34. package/lib/esm/specConvert.js +20 -27
  35. package/lib/esm/specConvert.js.map +1 -1
  36. package/lib/esm/testUtils/index.js +28 -0
  37. package/lib/esm/testUtils/index.js.map +1 -0
  38. package/lib/esm/testUtils/mocks.js +16 -0
  39. package/lib/esm/testUtils/mocks.js.map +1 -0
  40. package/lib/esm/testUtils/testUtils.js +66 -0
  41. package/lib/esm/testUtils/testUtils.js.map +1 -0
  42. package/lib/esm/utils.js +43 -60
  43. package/lib/esm/utils.js.map +1 -1
  44. package/lib/esm/yamlToJson.js +8 -6
  45. package/lib/esm/yamlToJson.js.map +1 -1
  46. package/lib/exampleMiner.js +4 -89
  47. package/lib/exampleMiner.js.map +1 -1
  48. package/lib/fetchSpec.js +6 -76
  49. package/lib/fetchSpec.js.map +1 -1
  50. package/lib/index.js +0 -16
  51. package/lib/index.js.map +1 -1
  52. package/lib/languages.js +0 -11
  53. package/lib/languages.js.map +1 -1
  54. package/lib/legacy.js +0 -5
  55. package/lib/legacy.js.map +1 -1
  56. package/lib/legacyGenerator.js +0 -15
  57. package/lib/legacyGenerator.js.map +1 -1
  58. package/lib/nodeUtils.js +1 -34
  59. package/lib/nodeUtils.js.map +1 -1
  60. package/lib/prettify.js +5 -14
  61. package/lib/prettify.js.map +1 -1
  62. package/lib/reformatter.js +3 -70
  63. package/lib/reformatter.js.map +1 -1
  64. package/lib/sdkConfig.js +0 -16
  65. package/lib/sdkConfig.js.map +1 -1
  66. package/lib/sdkGen.js +0 -41
  67. package/lib/sdkGen.js.map +1 -1
  68. package/lib/sdkGenerator.js +4 -52
  69. package/lib/sdkGenerator.js.map +1 -1
  70. package/lib/specConvert.js +0 -19
  71. package/lib/specConvert.js.map +1 -1
  72. package/lib/testUtils/index.js +0 -4
  73. package/lib/testUtils/index.js.map +1 -1
  74. package/lib/testUtils/mocks.js +0 -4
  75. package/lib/testUtils/mocks.js.map +1 -1
  76. package/lib/testUtils/testUtils.js +1 -17
  77. package/lib/testUtils/testUtils.js.map +1 -1
  78. package/lib/utils.js +6 -48
  79. package/lib/utils.js.map +1 -1
  80. package/lib/yamlToJson.js +0 -7
  81. package/lib/yamlToJson.js.map +1 -1
  82. package/package.json +6 -6
@@ -1,29 +1,41 @@
1
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
1
+ "use strict";
2
2
 
3
- import * as fs from 'fs';
4
- import path from 'path';
5
- import { execSync } from 'child_process';
6
- import { warn } from '@looker/sdk-codegen-utils';
7
- export var readFile = fileName => fs.readFileSync(fileName, {
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.readFile = exports.getRemoteOrigin = exports.getRemoteHttpOrigin = exports.getPermalinkRoot = exports.getCommitHash = exports.getCodeFiles = exports.getAllFiles = exports.filterCodeFiles = exports.filterAllFiles = exports.execRead = exports.MarkdownMiner = exports.IGNORE_PATHS = exports.ExampleMiner = exports.CodeMiner = void 0;
7
+ var fs = _interopRequireWildcard(require("fs"));
8
+ var _path = _interopRequireDefault(require("path"));
9
+ var _child_process = require("child_process");
10
+ var _sdkCodegenUtils = require("@looker/sdk-codegen-utils");
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
13
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
14
+ 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; }
15
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
16
+ 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); }
17
+ var readFile = fileName => fs.readFileSync(fileName, {
8
18
  encoding: 'utf-8'
9
19
  });
20
+ exports.readFile = readFile;
10
21
  var sdkPattern = /(\b[a-z0-9_]*sdk)\.\s*([a-z0-9_]*)\s*[(<]/gi;
11
22
  var mdPattern = /(\[(.+?)\]\((.+?)\))/gim;
12
23
  var linkPattern = /(.*)\[\[link\]\]\((.+?)\)/gim;
13
- export var filterAllFiles = fileName => fileName.trim().length > 0;
14
- export var filterCodeFiles = fileName => {
24
+ var filterAllFiles = fileName => fileName.trim().length > 0;
25
+ exports.filterAllFiles = filterAllFiles;
26
+ var filterCodeFiles = fileName => {
15
27
  if (/(^|\/)node_modules\//gi.test(fileName)) return false;
16
- var ext = path.extname(fileName).toLocaleLowerCase();
28
+ var ext = _path.default.extname(fileName).toLocaleLowerCase();
17
29
  return ext in fileMiners;
18
30
  };
19
- export var IGNORE_PATHS = ['node_modules', 'lib', 'dist', 'bazel-bin', 'build', 'bin', '.build', '.direnv', '.github', '.vscode', '.idea', '.gradle', 'results'];
20
-
31
+ exports.filterCodeFiles = filterCodeFiles;
32
+ var IGNORE_PATHS = ['node_modules', 'lib', 'dist', 'bazel-bin', 'build', 'bin', '.build', '.direnv', '.github', '.vscode', '.idea', '.gradle', 'results'];
33
+ exports.IGNORE_PATHS = IGNORE_PATHS;
21
34
  var skipFolder = function skipFolder(name) {
22
35
  var excludeList = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : IGNORE_PATHS;
23
36
  return new RegExp(excludeList.join('|'), 'gi').test(name);
24
37
  };
25
-
26
- export var getAllFiles = function getAllFiles(searchPath) {
38
+ var getAllFiles = function getAllFiles(searchPath) {
27
39
  var listOfFiles = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
28
40
  var filter = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : filterAllFiles;
29
41
  var ignorePaths = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
@@ -34,8 +46,7 @@ export var getAllFiles = function getAllFiles(searchPath) {
34
46
  if (!skipFolder(file, ignorePaths)) listOfFiles = getAllFiles(searchPath + '/' + file, listOfFiles, filter, ignorePaths);
35
47
  } else {
36
48
  if (filter(file)) {
37
- var _fileName = path.join(searchPath, '/', file);
38
-
49
+ var _fileName = _path.default.join(searchPath, '/', file);
39
50
  listOfFiles.push(_fileName);
40
51
  }
41
52
  }
@@ -43,56 +54,57 @@ export var getAllFiles = function getAllFiles(searchPath) {
43
54
  });
44
55
  return listOfFiles;
45
56
  };
46
- export var getCodeFiles = function getCodeFiles(searchPath) {
57
+ exports.getAllFiles = getAllFiles;
58
+ var getCodeFiles = function getCodeFiles(searchPath) {
47
59
  var listOfFiles = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
48
60
  var filter = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : filterCodeFiles;
49
61
  var ignorePaths = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : IGNORE_PATHS;
50
62
  return getAllFiles(searchPath, listOfFiles, filter, ignorePaths);
51
63
  };
52
- export var execRead = command => {
53
- return execSync(command, {
64
+ exports.getCodeFiles = getCodeFiles;
65
+ var execRead = command => {
66
+ return (0, _child_process.execSync)(command, {
54
67
  encoding: 'utf-8'
55
68
  }).trim();
56
69
  };
57
- export var getCommitHash = () => execRead('git rev-parse HEAD');
58
- export var getRemoteOrigin = () => {
70
+ exports.execRead = execRead;
71
+ var getCommitHash = () => execRead('git rev-parse HEAD');
72
+ exports.getCommitHash = getCommitHash;
73
+ var getRemoteOrigin = () => {
59
74
  return execRead('git remote get-url origin');
60
75
  };
61
- export var getRemoteHttpOrigin = () => {
76
+ exports.getRemoteOrigin = getRemoteOrigin;
77
+ var getRemoteHttpOrigin = () => {
62
78
  var origin = getRemoteOrigin();
63
79
  var gitExtractor = /git@github\.com:(.*)\.git/gi;
64
80
  var match = gitExtractor.exec(origin);
65
-
66
81
  if (!match) {
67
82
  var httpExtractor = /(https:\/\/github.com.*)(|.git)/;
68
83
  match = httpExtractor.exec(origin);
69
-
70
84
  if (!match) {
71
85
  return '';
72
86
  }
73
-
74
87
  return match[1];
75
88
  }
76
-
77
89
  return "https://github.com/".concat(match[1]);
78
90
  };
79
- export var getPermalinkRoot = () => {
91
+ exports.getRemoteHttpOrigin = getRemoteHttpOrigin;
92
+ var getPermalinkRoot = () => {
80
93
  var root = getRemoteHttpOrigin();
81
94
  if (root.endsWith('.git')) root = root.substr(0, root.length - 4);
82
95
  return root;
83
96
  };
84
- export class CodeMiner {
97
+ exports.getPermalinkRoot = getPermalinkRoot;
98
+ class CodeMiner {
85
99
  ignoreCall(call) {
86
100
  if (!/sdk/i.test(call.sdk)) return true;
87
101
  return CodeMiner.ignoreOps.has(call.operationId);
88
102
  }
89
-
90
103
  mineCode(sourceCode) {
91
104
  var lines = sourceCode.split('\n');
92
105
  var result = [];
93
106
  lines.forEach((line, index) => {
94
107
  var match = sdkPattern.exec(line);
95
-
96
108
  while (match !== null) {
97
109
  if (match && match.length > 2) {
98
110
  var sdkRef = match[1].trim();
@@ -102,69 +114,56 @@ export class CodeMiner {
102
114
  line: index + 1,
103
115
  column: match.index
104
116
  };
105
-
106
117
  if (!this.ignoreCall(_call)) {
107
118
  result.push(_call);
108
119
  }
109
120
  }
110
-
111
121
  match = sdkPattern.exec(line);
112
122
  }
113
123
  });
114
124
  return result;
115
125
  }
116
-
117
126
  mineFile(fileName) {
118
127
  return this.mineCode(readFile(fileName));
119
128
  }
120
-
121
129
  }
122
-
130
+ exports.CodeMiner = CodeMiner;
123
131
  _defineProperty(CodeMiner, "ignoreOps", new Set(['ok', 'init31', 'init40']));
124
-
125
- export class MarkdownMiner {
132
+ class MarkdownMiner {
126
133
  ignoreLink(linkFile) {
127
134
  linkFile = this.stripSearch(linkFile);
128
- var ext = path.extname(linkFile).toLocaleLowerCase();
135
+ var ext = _path.default.extname(linkFile).toLocaleLowerCase();
129
136
  var notCode = ext === '.md' || !filterCodeFiles(linkFile);
130
137
  var isHttp = /^(http|https):/gi.test(linkFile);
131
138
  return notCode || isHttp;
132
139
  }
133
-
134
140
  noDash(value) {
135
141
  value = value.trim();
136
142
  var dasher = /^\s*-\s*(.*)/g;
137
-
138
143
  if (dasher.test(value)) {
139
144
  value = value.replace(dasher, '$1');
140
145
  }
141
-
142
146
  return value.trim();
143
147
  }
144
-
145
148
  stripSearch(fileName) {
146
149
  fileName = fileName.trim();
147
150
  var match = /(.*)#.*/gi.exec(fileName);
148
151
  if (match) fileName = match[1];
149
152
  return fileName;
150
153
  }
151
-
152
154
  sourcerer(sourceFileName, linkFile) {
153
155
  linkFile = this.stripSearch(linkFile);
154
156
  if (linkFile.startsWith('/')) return linkFile.substr(1);
155
- var base = path.dirname(sourceFileName);
156
- return path.join(base, '/', linkFile);
157
+ var base = _path.default.dirname(sourceFileName);
158
+ return _path.default.join(base, '/', linkFile);
157
159
  }
158
-
159
160
  mineContent(fileName, content) {
160
161
  var result = [];
161
162
  var match = mdPattern.exec(content);
162
163
  var linkFile;
163
-
164
164
  while (match !== null) {
165
165
  var summary = this.noDash(match[2]);
166
166
  linkFile = this.stripSearch(match[3]);
167
-
168
167
  if (!this.ignoreLink(linkFile)) {
169
168
  if (summary.localeCompare('[link]', undefined, {
170
169
  sensitivity: 'base'
@@ -176,17 +175,12 @@ export class MarkdownMiner {
176
175
  });
177
176
  }
178
177
  }
179
-
180
178
  match = mdPattern.exec(content);
181
179
  }
182
-
183
180
  match = linkPattern.exec(content);
184
-
185
181
  while (match != null) {
186
182
  var _summary = this.noDash(match[1]);
187
-
188
183
  linkFile = this.stripSearch(match[2]);
189
-
190
184
  if (!this.ignoreLink(linkFile)) {
191
185
  linkFile = this.sourcerer(fileName, linkFile);
192
186
  result.push({
@@ -194,18 +188,15 @@ export class MarkdownMiner {
194
188
  sourceFile: linkFile
195
189
  });
196
190
  }
197
-
198
191
  match = linkPattern.exec(content);
199
192
  }
200
-
201
193
  return result;
202
194
  }
203
-
204
195
  mineFile(fileName) {
205
196
  return this.mineContent(fileName, readFile(fileName));
206
197
  }
207
-
208
198
  }
199
+ exports.MarkdownMiner = MarkdownMiner;
209
200
  var fileMiners = {
210
201
  '.cs': new CodeMiner(),
211
202
  '.kt': new CodeMiner(),
@@ -219,21 +210,15 @@ var fileMiners = {
219
210
  '.go': new CodeMiner(),
220
211
  '.java': new CodeMiner()
221
212
  };
222
- export class ExampleMiner {
213
+ class ExampleMiner {
223
214
  constructor(sourcePath) {
224
215
  this.sourcePath = sourcePath;
225
-
226
216
  _defineProperty(this, "summaries", {});
227
-
228
217
  _defineProperty(this, "nuggets", {});
229
-
230
218
  _defineProperty(this, "commitHash", getCommitHash());
231
-
232
219
  _defineProperty(this, "remoteOrigin", getPermalinkRoot());
233
-
234
220
  this.execute(sourcePath);
235
221
  }
236
-
237
222
  get lode() {
238
223
  return {
239
224
  commitHash: this.commitHash,
@@ -242,15 +227,12 @@ export class ExampleMiner {
242
227
  nuggets: this.nuggets
243
228
  };
244
229
  }
245
-
246
230
  addCall(ext, relativeFile, call) {
247
231
  function addFileCall(nugget) {
248
232
  var fileCalls = nugget.calls[ext];
249
-
250
233
  if (!fileCalls) {
251
234
  fileCalls = [];
252
235
  }
253
-
254
236
  var sdkCall = call;
255
237
  var fileCall = {
256
238
  sourceFile: relativeFile,
@@ -260,33 +242,27 @@ export class ExampleMiner {
260
242
  if (!fileCalls.find(f => f.line === fileCall.line && f.column === fileCall.column && f.sourceFile === fileCall.sourceFile)) fileCalls.push(fileCall);
261
243
  nugget.calls[ext] = fileCalls;
262
244
  }
263
-
264
245
  if ('summary' in call) {
265
246
  var s = call;
266
247
  s.sourceFile = ExampleMiner.relate(this.sourcePath, s.sourceFile);
267
248
  this.summaries[s.sourceFile] = s;
268
249
  } else {
269
250
  var nugget = this.nuggets[call.operationId];
270
-
271
251
  if (!nugget) {
272
252
  nugget = {
273
253
  operationId: call.operationId,
274
254
  calls: {}
275
255
  };
276
256
  }
277
-
278
257
  addFileCall(nugget);
279
258
  this.nuggets[nugget.operationId] = nugget;
280
259
  }
281
260
  }
282
-
283
261
  static relate(sourcePath, fileName) {
284
- return path.relative(sourcePath, fileName);
262
+ return _path.default.relative(sourcePath, fileName);
285
263
  }
286
-
287
264
  processFile(fileName) {
288
- var ext = path.extname(fileName);
289
-
265
+ var ext = _path.default.extname(fileName);
290
266
  if (ext in fileMiners) {
291
267
  var coder = fileMiners[ext];
292
268
  var calls = coder.mineFile(fileName);
@@ -295,10 +271,9 @@ export class ExampleMiner {
295
271
  this.addCall(ext, relFile, call);
296
272
  });
297
273
  } else {
298
- warn("".concat(fileName, " cannot be mined"));
274
+ (0, _sdkCodegenUtils.warn)("".concat(fileName, " cannot be mined"));
299
275
  }
300
276
  }
301
-
302
277
  execute() {
303
278
  var sourcePath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
304
279
  var dirPath = sourcePath !== null && sourcePath !== void 0 ? sourcePath : this.sourcePath;
@@ -306,6 +281,6 @@ export class ExampleMiner {
306
281
  files.forEach(f => this.processFile(f));
307
282
  return this.lode;
308
283
  }
309
-
310
284
  }
285
+ exports.ExampleMiner = ExampleMiner;
311
286
  //# sourceMappingURL=exampleMiner.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/exampleMiner.ts"],"names":["fs","path","execSync","warn","readFile","fileName","readFileSync","encoding","sdkPattern","mdPattern","linkPattern","filterAllFiles","trim","length","filterCodeFiles","test","ext","extname","toLocaleLowerCase","fileMiners","IGNORE_PATHS","skipFolder","name","excludeList","RegExp","join","getAllFiles","searchPath","listOfFiles","filter","ignorePaths","files","readdirSync","forEach","file","statSync","isDirectory","push","_e","getCodeFiles","execRead","command","getCommitHash","getRemoteOrigin","getRemoteHttpOrigin","origin","gitExtractor","match","exec","httpExtractor","getPermalinkRoot","root","endsWith","substr","CodeMiner","ignoreCall","call","sdk","ignoreOps","has","operationId","mineCode","sourceCode","lines","split","result","line","index","sdkRef","column","mineFile","Set","MarkdownMiner","ignoreLink","linkFile","stripSearch","notCode","isHttp","noDash","value","dasher","replace","sourcerer","sourceFileName","startsWith","base","dirname","mineContent","content","summary","localeCompare","undefined","sensitivity","sourceFile","ExampleMiner","constructor","sourcePath","execute","lode","commitHash","remoteOrigin","summaries","nuggets","addCall","relativeFile","addFileCall","nugget","fileCalls","calls","sdkCall","fileCall","find","f","s","relate","relative","processFile","coder","relFile","dirPath"],"mappings":";;AA0BA,OAAO,KAAKA,EAAZ,MAAoB,IAApB;AACA,OAAOC,IAAP,MAAiB,MAAjB;AACA,SAASC,QAAT,QAAyB,eAAzB;AACA,SAASC,IAAT,QAAqB,2BAArB;AAwBA,OAAO,IAAMC,QAAQ,GAAIC,QAAD,IACtBL,EAAE,CAACM,YAAH,CAAgBD,QAAhB,EAA0B;AAAEE,EAAAA,QAAQ,EAAE;AAAZ,CAA1B,CADK;AAGP,IAAMC,UAAU,GAAG,6CAAnB;AACA,IAAMC,SAAS,GAAG,yBAAlB;AACA,IAAMC,WAAW,GAAG,8BAApB;AAWA,OAAO,IAAMC,cAAc,GAAIN,QAAD,IAAsBA,QAAQ,CAACO,IAAT,GAAgBC,MAAhB,GAAyB,CAAtE;AAMP,OAAO,IAAMC,eAAe,GAAIT,QAAD,IAAsB;AACnD,MAAI,yBAAyBU,IAAzB,CAA8BV,QAA9B,CAAJ,EAA6C,OAAO,KAAP;AAC7C,MAAMW,GAAG,GAAGf,IAAI,CAACgB,OAAL,CAAa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AAM8D,OAAO,GAAGxB,YAAY,CAACoB,MAAb,CAAoB,KAAKlB,UAAzB,EAAqC3F,QAArC,CAAhB;AACA,aAAKkG,OAAL,CAAavF,GAAb,EAAkBsG,OAAlB,EAA2B9D,IAA3B;AACD,OAHD;AAID,KAPD,MAOO;AACLrD,MAAAA,IAAI,WAAIE,QAAJ,sBAAJ;AACD;AACF;;AAED4F,EAAAA,OAAO,GAAmC;AAAA,QAAlCD,UAAkC,uEAAN,IAAM;AACxC,QAAMuB,OAAO,GAAGvB,UAAH,aAAGA,UAAH,cAAGA,UAAH,GAAiB,KAAKA,UAAnC;AACA,QAAMjE,KAAK,GAAGQ,YAAY,CAACgF,OAAD,CAA1B;AACAxF,IAAAA,KAAK,CAACE,OAAN,CAAe+E,CAAD,IAAO,KAAKI,WAAL,CAAiBJ,CAAjB,CAArB;AACA,WAAO,KAAKd,IAAZ;AACD;;AAxFuB","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 * as fs from 'fs'\nimport path from 'path'\nimport { execSync } from 'child_process'\nimport { warn } from '@looker/sdk-codegen-utils'\nimport type {\n IFileCall,\n INugget,\n ISDKCall,\n ISummary,\n Nuggets,\n SDKCalls,\n Summaries,\n IExampleMine,\n} from '@looker/sdk-codegen'\n\nexport interface IFileMine {\n mineFile(fileName: string): SDKCalls\n mineCode(code: string): SDKCalls\n ignoreCall(call: ISDKCall): boolean\n}\n\nexport interface IDocMine {\n mineFile(fileName: string): ISummary[]\n mineContent(sourceFile: string, content: string): ISummary[]\n ignoreLink(fileName: string): boolean\n}\n\nexport const readFile = (fileName: string) =>\n fs.readFileSync(fileName, { encoding: 'utf-8' })\n\nconst sdkPattern = /(\\b[a-z0-9_]*sdk)\\.\\s*([a-z0-9_]*)\\s*[(<]/gi\nconst mdPattern = /(\\[(.+?)\\]\\((.+?)\\))/gim\nconst linkPattern = /(.*)\\[\\[link\\]\\]\\((.+?)\\)/gim\n\nexport type IMiners = { [key: string]: IFileMine | IDocMine }\n\n/** file-filtering lambda for `getAllFiles()` and `getCodeFiles()` */\nexport type FileFilter = (fileName: string, pattern?: RegExp) => boolean\n\n/**\n * Filter to include every file that has a non-empty file name\n * @param fileName name of file to check\n */\nexport const filterAllFiles = (fileName: string) => fileName.trim().length > 0\n\n/**\n * Filter for code files\n * @param fileName name of file from which to extract its extension\n */\nexport const filterCodeFiles = (fileName: string) => {\n if (/(^|\\/)node_modules\\//gi.test(fileName)) return false\n const ext = path.extname(fileName).toLocaleLowerCase()\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n return ext in fileMiners\n}\n\nexport const IGNORE_PATHS = [\n 'node_modules',\n 'lib',\n 'dist',\n 'bazel-bin',\n 'build',\n 'bin',\n '.build',\n '.direnv',\n '.github',\n '.vscode',\n '.idea',\n '.gradle',\n 'results',\n]\n\nconst skipFolder = (name: string, excludeList: string[] = IGNORE_PATHS) =>\n new RegExp(excludeList.join('|'), 'gi').test(name)\n\n/**\n * Finds all file recursively\n * @param searchPath starting directory for file search\n * @param listOfFiles list of current files already found\n * @param filter lambda for file inclusion in results. truthy analyzes the file\n * @param ignorePaths paths to ignore\n */\nexport const getAllFiles = (\n searchPath: string,\n listOfFiles: string[] = [],\n filter: FileFilter = filterAllFiles,\n ignorePaths: string[] = []\n) => {\n const files = fs.readdirSync(searchPath)\n\n files.forEach((file) => {\n try {\n if (fs.statSync(searchPath + '/' + file).isDirectory()) {\n if (!skipFolder(file, ignorePaths))\n listOfFiles = getAllFiles(\n searchPath + '/' + file,\n listOfFiles,\n filter,\n ignorePaths\n )\n } else {\n if (filter(file)) {\n const fileName = path.join(searchPath, '/', file)\n listOfFiles.push(fileName)\n }\n }\n } catch (_e: any) {\n // warn(`skipping ${file}: ${e}`)\n }\n })\n\n return listOfFiles\n}\n\n/**\n * Find all source code files recursively\n * @param searchPath starting directory for file search\n * @param listOfFiles list of source code files that can be mined\n * @param filter function to determine whether a file should be analyzed\n * @param ignorePaths paths to ignore\n */\nexport const getCodeFiles = (\n searchPath: string,\n listOfFiles: string[] = [],\n filter: FileFilter = filterCodeFiles,\n ignorePaths: string[] = IGNORE_PATHS\n) => {\n return getAllFiles(searchPath, listOfFiles, filter, ignorePaths)\n}\n\n/** get the trimmed output of the command as a UTF-8 string */\nexport const execRead = (command: string) => {\n return execSync(command, { encoding: 'utf-8' }).trim()\n}\n\n/** get this git repository's current commit hash */\nexport const getCommitHash = () => execRead('git rev-parse HEAD')\n\n/** get the remote origin url for this repository */\nexport const getRemoteOrigin = () => {\n return execRead('git remote get-url origin')\n}\n\n/**\n * Convert this github repository's git address to an HTTP url\n */\nexport const getRemoteHttpOrigin = () => {\n const origin = getRemoteOrigin()\n const gitExtractor = /git@github\\.com:(.*)\\.git/gi\n let match = gitExtractor.exec(origin)\n if (!match) {\n // git origin on CI: https://github.com/looker-open-source/sdk-codegen\n const httpExtractor = /(https:\\/\\/github.com.*)(|.git)/\n match = httpExtractor.exec(origin)\n if (!match) {\n return ''\n }\n return match[1]\n }\n return `https://github.com/${match[1]}`\n}\n\n/** Permalink paths should not have the `.git` ending for a repo */\nexport const getPermalinkRoot = () => {\n let root = getRemoteHttpOrigin()\n if (root.endsWith('.git')) root = root.substr(0, root.length - 4)\n return root\n}\n\nexport class CodeMiner implements IFileMine {\n static ignoreOps = new Set<string>(['ok', 'init31', 'init40'])\n ignoreCall(call: ISDKCall): boolean {\n if (!/sdk/i.test(call.sdk)) return true\n return CodeMiner.ignoreOps.has(call.operationId)\n }\n\n mineCode(sourceCode: string): SDKCalls {\n const lines = sourceCode.split('\\n')\n const result: SDKCalls = []\n lines.forEach((line, index) => {\n let match = sdkPattern.exec(line)\n while (match !== null) {\n // TODO need to ignore source code comments?\n if (match && match.length > 2) {\n const sdkRef = match[1].trim()\n const call: ISDKCall = {\n sdk: sdkRef,\n operationId: match[2].trim(),\n line: index + 1,\n column: match.index,\n }\n if (!this.ignoreCall(call)) {\n result.push(call)\n }\n }\n match = sdkPattern.exec(line)\n }\n })\n return result\n }\n\n mineFile(fileName: string): SDKCalls {\n return this.mineCode(readFile(fileName))\n }\n}\n\n/**\n * Processes markdown files and extracts links to source code to use as summaries\n */\nexport class MarkdownMiner implements IDocMine {\n // TODO ensure summaries don't include markdown files\n ignoreLink(linkFile: string): boolean {\n linkFile = this.stripSearch(linkFile)\n const ext = path.extname(linkFile).toLocaleLowerCase()\n const notCode = ext === '.md' || !filterCodeFiles(linkFile)\n const isHttp = /^(http|https):/gi.test(linkFile)\n return notCode || isHttp\n }\n\n /**\n * Remove leading - from a string\n * @param value string to process\n */\n noDash(value: string) {\n value = value.trim()\n const dasher = /^\\s*-\\s*(.*)/g\n if (dasher.test(value)) {\n value = value.replace(dasher, '$1')\n }\n return value.trim()\n }\n\n stripSearch(fileName: string) {\n fileName = fileName.trim()\n const match = /(.*)#.*/gi.exec(fileName)\n if (match) fileName = match[1]\n return fileName\n }\n\n /**\n * Fully qualify the path for `linkFile`\n * @param sourceFileName\n * @param linkFile\n */\n sourcerer(sourceFileName: string, linkFile: string) {\n linkFile = this.stripSearch(linkFile)\n if (linkFile.startsWith('/')) return linkFile.substr(1)\n const base = path.dirname(sourceFileName)\n return path.join(base, '/', linkFile)\n }\n\n /**\n * Get all links from content\n * @param fileName fully qualified source file name\n * @param content markdown to parse\n */\n mineContent(fileName: string, content: string): ISummary[] {\n const result: ISummary[] = []\n let match = mdPattern.exec(content)\n let linkFile: string\n while (match !== null) {\n const summary = this.noDash(match[2])\n linkFile = this.stripSearch(match[3])\n if (!this.ignoreLink(linkFile)) {\n if (\n summary.localeCompare('[link]', undefined, {\n sensitivity: 'base',\n }) !== 0\n ) {\n linkFile = this.sourcerer(fileName, linkFile)\n result.push({ summary, sourceFile: linkFile })\n }\n }\n match = mdPattern.exec(content)\n }\n\n match = linkPattern.exec(content)\n while (match != null) {\n const summary = this.noDash(match[1])\n linkFile = this.stripSearch(match[2])\n if (!this.ignoreLink(linkFile)) {\n linkFile = this.sourcerer(fileName, linkFile)\n result.push({ summary, sourceFile: linkFile })\n }\n match = linkPattern.exec(content)\n }\n return result\n }\n\n mineFile(fileName: string): ISummary[] {\n return this.mineContent(fileName, readFile(fileName))\n }\n}\n\nconst fileMiners: IMiners = {\n '.cs': new CodeMiner(),\n '.kt': new CodeMiner(),\n '.py': new CodeMiner(),\n '.swift': new CodeMiner(),\n '.ts': new CodeMiner(),\n '.tsx': new CodeMiner(),\n '.rb': new CodeMiner(),\n '.md': new MarkdownMiner(),\n '.dart': new CodeMiner(),\n '.go': new CodeMiner(),\n '.java': new CodeMiner(),\n // '.rst': new MarkdownMiner(), // TODO .rst miner? Probably not needed\n}\n\nexport class ExampleMiner {\n summaries: Summaries = {}\n nuggets: Nuggets = {}\n commitHash: string = getCommitHash()\n remoteOrigin: string = getPermalinkRoot()\n\n constructor(public readonly sourcePath: string) {\n this.execute(sourcePath)\n }\n\n get lode(): IExampleMine {\n return {\n commitHash: this.commitHash,\n remoteOrigin: this.remoteOrigin,\n summaries: this.summaries,\n nuggets: this.nuggets,\n }\n }\n\n addCall(ext: string, relativeFile: string, call: ISDKCall | ISummary) {\n function addFileCall(nugget: INugget) {\n // Extension is key for language\n let fileCalls = nugget.calls[ext]\n if (!fileCalls) {\n fileCalls = []\n }\n const sdkCall = call as ISDKCall\n const fileCall: IFileCall = {\n sourceFile: relativeFile,\n column: sdkCall.column,\n line: sdkCall.line,\n }\n if (\n !fileCalls.find(\n (f) =>\n f.line === fileCall.line &&\n f.column === fileCall.column &&\n f.sourceFile === fileCall.sourceFile\n )\n )\n fileCalls.push(fileCall)\n nugget.calls[ext] = fileCalls\n }\n\n if ('summary' in call) {\n const s = call as ISummary\n s.sourceFile = ExampleMiner.relate(this.sourcePath, s.sourceFile)\n this.summaries[s.sourceFile] = s\n } else {\n let nugget: INugget = this.nuggets[call.operationId]\n if (!nugget) {\n nugget = { operationId: call.operationId, calls: {} }\n }\n addFileCall(nugget)\n this.nuggets[nugget.operationId] = nugget\n }\n }\n\n /**\n * Derive relative path, retaining last directory\n * @param sourcePath original file search path\n * @param fileName fully qualified name of found file\n *\n * @example `Miner.relate('/a/b/c/', '/a/b/c/d.txt')` returns 'd.txt'\n */\n public static relate(sourcePath: string, fileName: string) {\n return path.relative(sourcePath, fileName)\n }\n\n processFile(fileName: string) {\n const ext = path.extname(fileName)\n if (ext in fileMiners) {\n const coder = fileMiners[ext]\n const calls = coder.mineFile(fileName)\n calls.forEach((call: ISDKCall | ISummary) => {\n const relFile = ExampleMiner.relate(this.sourcePath, fileName)\n this.addCall(ext, relFile, call)\n })\n } else {\n warn(`${fileName} cannot be mined`)\n }\n }\n\n execute(sourcePath: string | null = null) {\n const dirPath = sourcePath ?? this.sourcePath\n const files = getCodeFiles(dirPath)\n files.forEach((f) => this.processFile(f))\n return this.lode\n }\n}\n"],"file":"exampleMiner.js"}
1
+ {"version":3,"file":"exampleMiner.js","names":["readFile","fileName","fs","readFileSync","encoding","sdkPattern","mdPattern","linkPattern","filterAllFiles","trim","length","filterCodeFiles","test","ext","path","extname","toLocaleLowerCase","fileMiners","IGNORE_PATHS","skipFolder","name","excludeList","RegExp","join","getAllFiles","searchPath","listOfFiles","filter","ignorePaths","files","readdirSync","forEach","file","statSync","isDirectory","push","_e","getCodeFiles","execRead","command","execSync","getCommitHash","getRemoteOrigin","getRemoteHttpOrigin","origin","gitExtractor","match","exec","httpExtractor","getPermalinkRoot","root","endsWith","substr","CodeMiner","ignoreCall","call","sdk","ignoreOps","has","operationId","mineCode","sourceCode","lines","split","result","line","index","sdkRef","column","mineFile","Set","MarkdownMiner","ignoreLink","linkFile","stripSearch","notCode","isHttp","noDash","value","dasher","replace","sourcerer","sourceFileName","startsWith","base","dirname","mineContent","content","summary","localeCompare","undefined","sensitivity","sourceFile","ExampleMiner","constructor","sourcePath","execute","lode","commitHash","remoteOrigin","summaries","nuggets","addCall","relativeFile","addFileCall","nugget","fileCalls","calls","sdkCall","fileCall","find","f","s","relate","relative","processFile","coder","relFile","warn","dirPath"],"sources":["../../src/exampleMiner.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 * as fs from 'fs'\nimport path from 'path'\nimport { execSync } from 'child_process'\nimport { warn } from '@looker/sdk-codegen-utils'\nimport type {\n IFileCall,\n INugget,\n ISDKCall,\n ISummary,\n Nuggets,\n SDKCalls,\n Summaries,\n IExampleMine,\n} from '@looker/sdk-codegen'\n\nexport interface IFileMine {\n mineFile(fileName: string): SDKCalls\n mineCode(code: string): SDKCalls\n ignoreCall(call: ISDKCall): boolean\n}\n\nexport interface IDocMine {\n mineFile(fileName: string): ISummary[]\n mineContent(sourceFile: string, content: string): ISummary[]\n ignoreLink(fileName: string): boolean\n}\n\nexport const readFile = (fileName: string) =>\n fs.readFileSync(fileName, { encoding: 'utf-8' })\n\nconst sdkPattern = /(\\b[a-z0-9_]*sdk)\\.\\s*([a-z0-9_]*)\\s*[(<]/gi\nconst mdPattern = /(\\[(.+?)\\]\\((.+?)\\))/gim\nconst linkPattern = /(.*)\\[\\[link\\]\\]\\((.+?)\\)/gim\n\nexport type IMiners = { [key: string]: IFileMine | IDocMine }\n\n/** file-filtering lambda for `getAllFiles()` and `getCodeFiles()` */\nexport type FileFilter = (fileName: string, pattern?: RegExp) => boolean\n\n/**\n * Filter to include every file that has a non-empty file name\n * @param fileName name of file to check\n */\nexport const filterAllFiles = (fileName: string) => fileName.trim().length > 0\n\n/**\n * Filter for code files\n * @param fileName name of file from which to extract its extension\n */\nexport const filterCodeFiles = (fileName: string) => {\n if (/(^|\\/)node_modules\\//gi.test(fileName)) return false\n const ext = path.extname(fileName).toLocaleLowerCase()\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n return ext in fileMiners\n}\n\nexport const IGNORE_PATHS = [\n 'node_modules',\n 'lib',\n 'dist',\n 'bazel-bin',\n 'build',\n 'bin',\n '.build',\n '.direnv',\n '.github',\n '.vscode',\n '.idea',\n '.gradle',\n 'results',\n]\n\nconst skipFolder = (name: string, excludeList: string[] = IGNORE_PATHS) =>\n new RegExp(excludeList.join('|'), 'gi').test(name)\n\n/**\n * Finds all file recursively\n * @param searchPath starting directory for file search\n * @param listOfFiles list of current files already found\n * @param filter lambda for file inclusion in results. truthy analyzes the file\n * @param ignorePaths paths to ignore\n */\nexport const getAllFiles = (\n searchPath: string,\n listOfFiles: string[] = [],\n filter: FileFilter = filterAllFiles,\n ignorePaths: string[] = []\n) => {\n const files = fs.readdirSync(searchPath)\n\n files.forEach((file) => {\n try {\n if (fs.statSync(searchPath + '/' + file).isDirectory()) {\n if (!skipFolder(file, ignorePaths))\n listOfFiles = getAllFiles(\n searchPath + '/' + file,\n listOfFiles,\n filter,\n ignorePaths\n )\n } else {\n if (filter(file)) {\n const fileName = path.join(searchPath, '/', file)\n listOfFiles.push(fileName)\n }\n }\n } catch (_e: any) {\n // warn(`skipping ${file}: ${e}`)\n }\n })\n\n return listOfFiles\n}\n\n/**\n * Find all source code files recursively\n * @param searchPath starting directory for file search\n * @param listOfFiles list of source code files that can be mined\n * @param filter function to determine whether a file should be analyzed\n * @param ignorePaths paths to ignore\n */\nexport const getCodeFiles = (\n searchPath: string,\n listOfFiles: string[] = [],\n filter: FileFilter = filterCodeFiles,\n ignorePaths: string[] = IGNORE_PATHS\n) => {\n return getAllFiles(searchPath, listOfFiles, filter, ignorePaths)\n}\n\n/** get the trimmed output of the command as a UTF-8 string */\nexport const execRead = (command: string) => {\n return execSync(command, { encoding: 'utf-8' }).trim()\n}\n\n/** get this git repository's current commit hash */\nexport const getCommitHash = () => execRead('git rev-parse HEAD')\n\n/** get the remote origin url for this repository */\nexport const getRemoteOrigin = () => {\n return execRead('git remote get-url origin')\n}\n\n/**\n * Convert this github repository's git address to an HTTP url\n */\nexport const getRemoteHttpOrigin = () => {\n const origin = getRemoteOrigin()\n const gitExtractor = /git@github\\.com:(.*)\\.git/gi\n let match = gitExtractor.exec(origin)\n if (!match) {\n // git origin on CI: https://github.com/looker-open-source/sdk-codegen\n const httpExtractor = /(https:\\/\\/github.com.*)(|.git)/\n match = httpExtractor.exec(origin)\n if (!match) {\n return ''\n }\n return match[1]\n }\n return `https://github.com/${match[1]}`\n}\n\n/** Permalink paths should not have the `.git` ending for a repo */\nexport const getPermalinkRoot = () => {\n let root = getRemoteHttpOrigin()\n if (root.endsWith('.git')) root = root.substr(0, root.length - 4)\n return root\n}\n\nexport class CodeMiner implements IFileMine {\n static ignoreOps = new Set<string>(['ok', 'init31', 'init40'])\n ignoreCall(call: ISDKCall): boolean {\n if (!/sdk/i.test(call.sdk)) return true\n return CodeMiner.ignoreOps.has(call.operationId)\n }\n\n mineCode(sourceCode: string): SDKCalls {\n const lines = sourceCode.split('\\n')\n const result: SDKCalls = []\n lines.forEach((line, index) => {\n let match = sdkPattern.exec(line)\n while (match !== null) {\n // TODO need to ignore source code comments?\n if (match && match.length > 2) {\n const sdkRef = match[1].trim()\n const call: ISDKCall = {\n sdk: sdkRef,\n operationId: match[2].trim(),\n line: index + 1,\n column: match.index,\n }\n if (!this.ignoreCall(call)) {\n result.push(call)\n }\n }\n match = sdkPattern.exec(line)\n }\n })\n return result\n }\n\n mineFile(fileName: string): SDKCalls {\n return this.mineCode(readFile(fileName))\n }\n}\n\n/**\n * Processes markdown files and extracts links to source code to use as summaries\n */\nexport class MarkdownMiner implements IDocMine {\n // TODO ensure summaries don't include markdown files\n ignoreLink(linkFile: string): boolean {\n linkFile = this.stripSearch(linkFile)\n const ext = path.extname(linkFile).toLocaleLowerCase()\n const notCode = ext === '.md' || !filterCodeFiles(linkFile)\n const isHttp = /^(http|https):/gi.test(linkFile)\n return notCode || isHttp\n }\n\n /**\n * Remove leading - from a string\n * @param value string to process\n */\n noDash(value: string) {\n value = value.trim()\n const dasher = /^\\s*-\\s*(.*)/g\n if (dasher.test(value)) {\n value = value.replace(dasher, '$1')\n }\n return value.trim()\n }\n\n stripSearch(fileName: string) {\n fileName = fileName.trim()\n const match = /(.*)#.*/gi.exec(fileName)\n if (match) fileName = match[1]\n return fileName\n }\n\n /**\n * Fully qualify the path for `linkFile`\n * @param sourceFileName\n * @param linkFile\n */\n sourcerer(sourceFileName: string, linkFile: string) {\n linkFile = this.stripSearch(linkFile)\n if (linkFile.startsWith('/')) return linkFile.substr(1)\n const base = path.dirname(sourceFileName)\n return path.join(base, '/', linkFile)\n }\n\n /**\n * Get all links from content\n * @param fileName fully qualified source file name\n * @param content markdown to parse\n */\n mineContent(fileName: string, content: string): ISummary[] {\n const result: ISummary[] = []\n let match = mdPattern.exec(content)\n let linkFile: string\n while (match !== null) {\n const summary = this.noDash(match[2])\n linkFile = this.stripSearch(match[3])\n if (!this.ignoreLink(linkFile)) {\n if (\n summary.localeCompare('[link]', undefined, {\n sensitivity: 'base',\n }) !== 0\n ) {\n linkFile = this.sourcerer(fileName, linkFile)\n result.push({ summary, sourceFile: linkFile })\n }\n }\n match = mdPattern.exec(content)\n }\n\n match = linkPattern.exec(content)\n while (match != null) {\n const summary = this.noDash(match[1])\n linkFile = this.stripSearch(match[2])\n if (!this.ignoreLink(linkFile)) {\n linkFile = this.sourcerer(fileName, linkFile)\n result.push({ summary, sourceFile: linkFile })\n }\n match = linkPattern.exec(content)\n }\n return result\n }\n\n mineFile(fileName: string): ISummary[] {\n return this.mineContent(fileName, readFile(fileName))\n }\n}\n\nconst fileMiners: IMiners = {\n '.cs': new CodeMiner(),\n '.kt': new CodeMiner(),\n '.py': new CodeMiner(),\n '.swift': new CodeMiner(),\n '.ts': new CodeMiner(),\n '.tsx': new CodeMiner(),\n '.rb': new CodeMiner(),\n '.md': new MarkdownMiner(),\n '.dart': new CodeMiner(),\n '.go': new CodeMiner(),\n '.java': new CodeMiner(),\n // '.rst': new MarkdownMiner(), // TODO .rst miner? Probably not needed\n}\n\nexport class ExampleMiner {\n summaries: Summaries = {}\n nuggets: Nuggets = {}\n commitHash: string = getCommitHash()\n remoteOrigin: string = getPermalinkRoot()\n\n constructor(public readonly sourcePath: string) {\n this.execute(sourcePath)\n }\n\n get lode(): IExampleMine {\n return {\n commitHash: this.commitHash,\n remoteOrigin: this.remoteOrigin,\n summaries: this.summaries,\n nuggets: this.nuggets,\n }\n }\n\n addCall(ext: string, relativeFile: string, call: ISDKCall | ISummary) {\n function addFileCall(nugget: INugget) {\n // Extension is key for language\n let fileCalls = nugget.calls[ext]\n if (!fileCalls) {\n fileCalls = []\n }\n const sdkCall = call as ISDKCall\n const fileCall: IFileCall = {\n sourceFile: relativeFile,\n column: sdkCall.column,\n line: sdkCall.line,\n }\n if (\n !fileCalls.find(\n (f) =>\n f.line === fileCall.line &&\n f.column === fileCall.column &&\n f.sourceFile === fileCall.sourceFile\n )\n )\n fileCalls.push(fileCall)\n nugget.calls[ext] = fileCalls\n }\n\n if ('summary' in call) {\n const s = call as ISummary\n s.sourceFile = ExampleMiner.relate(this.sourcePath, s.sourceFile)\n this.summaries[s.sourceFile] = s\n } else {\n let nugget: INugget = this.nuggets[call.operationId]\n if (!nugget) {\n nugget = { operationId: call.operationId, calls: {} }\n }\n addFileCall(nugget)\n this.nuggets[nugget.operationId] = nugget\n }\n }\n\n /**\n * Derive relative path, retaining last directory\n * @param sourcePath original file search path\n * @param fileName fully qualified name of found file\n *\n * @example `Miner.relate('/a/b/c/', '/a/b/c/d.txt')` returns 'd.txt'\n */\n public static relate(sourcePath: string, fileName: string) {\n return path.relative(sourcePath, fileName)\n }\n\n processFile(fileName: string) {\n const ext = path.extname(fileName)\n if (ext in fileMiners) {\n const coder = fileMiners[ext]\n const calls = coder.mineFile(fileName)\n calls.forEach((call: ISDKCall | ISummary) => {\n const relFile = ExampleMiner.relate(this.sourcePath, fileName)\n this.addCall(ext, relFile, call)\n })\n } else {\n warn(`${fileName} cannot be mined`)\n }\n }\n\n execute(sourcePath: string | null = null) {\n const dirPath = sourcePath ?? this.sourcePath\n const files = getCodeFiles(dirPath)\n files.forEach((f) => this.processFile(f))\n return this.lode\n }\n}\n"],"mappings":";;;;;;AA0BA;AACA;AACA;AACA;AAAgD;AAAA;AAAA;AAAA;AAAA;AAAA;AAwBzC,I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