@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.
Files changed (82) hide show
  1. package/CHANGELOG.md +25 -1
  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
@@ -3,54 +3,38 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.ExampleMiner = exports.MarkdownMiner = exports.CodeMiner = exports.getPermalinkRoot = exports.getRemoteHttpOrigin = exports.getRemoteOrigin = exports.getCommitHash = exports.execRead = exports.getCodeFiles = exports.getAllFiles = exports.IGNORE_PATHS = exports.filterCodeFiles = exports.filterAllFiles = exports.readFile = void 0;
7
-
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;
8
7
  var fs = _interopRequireWildcard(require("fs"));
9
-
10
8
  var _path = _interopRequireDefault(require("path"));
11
-
12
9
  var _child_process = require("child_process");
13
-
14
10
  var _sdkCodegenUtils = require("@looker/sdk-codegen-utils");
15
-
16
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
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); }
19
-
20
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; }
21
-
22
- 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; }
23
-
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); }
24
17
  var readFile = fileName => fs.readFileSync(fileName, {
25
18
  encoding: 'utf-8'
26
19
  });
27
-
28
20
  exports.readFile = readFile;
29
21
  var sdkPattern = /(\b[a-z0-9_]*sdk)\.\s*([a-z0-9_]*)\s*[(<]/gi;
30
22
  var mdPattern = /(\[(.+?)\]\((.+?)\))/gim;
31
23
  var linkPattern = /(.*)\[\[link\]\]\((.+?)\)/gim;
32
-
33
24
  var filterAllFiles = fileName => fileName.trim().length > 0;
34
-
35
25
  exports.filterAllFiles = filterAllFiles;
36
-
37
26
  var filterCodeFiles = fileName => {
38
27
  if (/(^|\/)node_modules\//gi.test(fileName)) return false;
39
-
40
28
  var ext = _path.default.extname(fileName).toLocaleLowerCase();
41
-
42
29
  return ext in fileMiners;
43
30
  };
44
-
45
31
  exports.filterCodeFiles = filterCodeFiles;
46
32
  var IGNORE_PATHS = ['node_modules', 'lib', 'dist', 'bazel-bin', 'build', 'bin', '.build', '.direnv', '.github', '.vscode', '.idea', '.gradle', 'results'];
47
33
  exports.IGNORE_PATHS = IGNORE_PATHS;
48
-
49
34
  var skipFolder = function skipFolder(name) {
50
35
  var excludeList = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : IGNORE_PATHS;
51
36
  return new RegExp(excludeList.join('|'), 'gi').test(name);
52
37
  };
53
-
54
38
  var getAllFiles = function getAllFiles(searchPath) {
55
39
  var listOfFiles = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
56
40
  var filter = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : filterAllFiles;
@@ -63,7 +47,6 @@ var getAllFiles = function getAllFiles(searchPath) {
63
47
  } else {
64
48
  if (filter(file)) {
65
49
  var _fileName = _path.default.join(searchPath, '/', file);
66
-
67
50
  listOfFiles.push(_fileName);
68
51
  }
69
52
  }
@@ -71,77 +54,57 @@ var getAllFiles = function getAllFiles(searchPath) {
71
54
  });
72
55
  return listOfFiles;
73
56
  };
74
-
75
57
  exports.getAllFiles = getAllFiles;
76
-
77
58
  var getCodeFiles = function getCodeFiles(searchPath) {
78
59
  var listOfFiles = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
79
60
  var filter = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : filterCodeFiles;
80
61
  var ignorePaths = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : IGNORE_PATHS;
81
62
  return getAllFiles(searchPath, listOfFiles, filter, ignorePaths);
82
63
  };
83
-
84
64
  exports.getCodeFiles = getCodeFiles;
85
-
86
65
  var execRead = command => {
87
66
  return (0, _child_process.execSync)(command, {
88
67
  encoding: 'utf-8'
89
68
  }).trim();
90
69
  };
91
-
92
70
  exports.execRead = execRead;
93
-
94
71
  var getCommitHash = () => execRead('git rev-parse HEAD');
95
-
96
72
  exports.getCommitHash = getCommitHash;
97
-
98
73
  var getRemoteOrigin = () => {
99
74
  return execRead('git remote get-url origin');
100
75
  };
101
-
102
76
  exports.getRemoteOrigin = getRemoteOrigin;
103
-
104
77
  var getRemoteHttpOrigin = () => {
105
78
  var origin = getRemoteOrigin();
106
79
  var gitExtractor = /git@github\.com:(.*)\.git/gi;
107
80
  var match = gitExtractor.exec(origin);
108
-
109
81
  if (!match) {
110
82
  var httpExtractor = /(https:\/\/github.com.*)(|.git)/;
111
83
  match = httpExtractor.exec(origin);
112
-
113
84
  if (!match) {
114
85
  return '';
115
86
  }
116
-
117
87
  return match[1];
118
88
  }
119
-
120
89
  return "https://github.com/".concat(match[1]);
121
90
  };
122
-
123
91
  exports.getRemoteHttpOrigin = getRemoteHttpOrigin;
124
-
125
92
  var getPermalinkRoot = () => {
126
93
  var root = getRemoteHttpOrigin();
127
94
  if (root.endsWith('.git')) root = root.substr(0, root.length - 4);
128
95
  return root;
129
96
  };
130
-
131
97
  exports.getPermalinkRoot = getPermalinkRoot;
132
-
133
98
  class CodeMiner {
134
99
  ignoreCall(call) {
135
100
  if (!/sdk/i.test(call.sdk)) return true;
136
101
  return CodeMiner.ignoreOps.has(call.operationId);
137
102
  }
138
-
139
103
  mineCode(sourceCode) {
140
104
  var lines = sourceCode.split('\n');
141
105
  var result = [];
142
106
  lines.forEach((line, index) => {
143
107
  var match = sdkPattern.exec(line);
144
-
145
108
  while (match !== null) {
146
109
  if (match && match.length > 2) {
147
110
  var sdkRef = match[1].trim();
@@ -151,75 +114,56 @@ class CodeMiner {
151
114
  line: index + 1,
152
115
  column: match.index
153
116
  };
154
-
155
117
  if (!this.ignoreCall(_call)) {
156
118
  result.push(_call);
157
119
  }
158
120
  }
159
-
160
121
  match = sdkPattern.exec(line);
161
122
  }
162
123
  });
163
124
  return result;
164
125
  }
165
-
166
126
  mineFile(fileName) {
167
127
  return this.mineCode(readFile(fileName));
168
128
  }
169
-
170
129
  }
171
-
172
130
  exports.CodeMiner = CodeMiner;
173
-
174
131
  _defineProperty(CodeMiner, "ignoreOps", new Set(['ok', 'init31', 'init40']));
175
-
176
132
  class MarkdownMiner {
177
133
  ignoreLink(linkFile) {
178
134
  linkFile = this.stripSearch(linkFile);
179
-
180
135
  var ext = _path.default.extname(linkFile).toLocaleLowerCase();
181
-
182
136
  var notCode = ext === '.md' || !filterCodeFiles(linkFile);
183
137
  var isHttp = /^(http|https):/gi.test(linkFile);
184
138
  return notCode || isHttp;
185
139
  }
186
-
187
140
  noDash(value) {
188
141
  value = value.trim();
189
142
  var dasher = /^\s*-\s*(.*)/g;
190
-
191
143
  if (dasher.test(value)) {
192
144
  value = value.replace(dasher, '$1');
193
145
  }
194
-
195
146
  return value.trim();
196
147
  }
197
-
198
148
  stripSearch(fileName) {
199
149
  fileName = fileName.trim();
200
150
  var match = /(.*)#.*/gi.exec(fileName);
201
151
  if (match) fileName = match[1];
202
152
  return fileName;
203
153
  }
204
-
205
154
  sourcerer(sourceFileName, linkFile) {
206
155
  linkFile = this.stripSearch(linkFile);
207
156
  if (linkFile.startsWith('/')) return linkFile.substr(1);
208
-
209
157
  var base = _path.default.dirname(sourceFileName);
210
-
211
158
  return _path.default.join(base, '/', linkFile);
212
159
  }
213
-
214
160
  mineContent(fileName, content) {
215
161
  var result = [];
216
162
  var match = mdPattern.exec(content);
217
163
  var linkFile;
218
-
219
164
  while (match !== null) {
220
165
  var summary = this.noDash(match[2]);
221
166
  linkFile = this.stripSearch(match[3]);
222
-
223
167
  if (!this.ignoreLink(linkFile)) {
224
168
  if (summary.localeCompare('[link]', undefined, {
225
169
  sensitivity: 'base'
@@ -231,17 +175,12 @@ class MarkdownMiner {
231
175
  });
232
176
  }
233
177
  }
234
-
235
178
  match = mdPattern.exec(content);
236
179
  }
237
-
238
180
  match = linkPattern.exec(content);
239
-
240
181
  while (match != null) {
241
182
  var _summary = this.noDash(match[1]);
242
-
243
183
  linkFile = this.stripSearch(match[2]);
244
-
245
184
  if (!this.ignoreLink(linkFile)) {
246
185
  linkFile = this.sourcerer(fileName, linkFile);
247
186
  result.push({
@@ -249,19 +188,14 @@ class MarkdownMiner {
249
188
  sourceFile: linkFile
250
189
  });
251
190
  }
252
-
253
191
  match = linkPattern.exec(content);
254
192
  }
255
-
256
193
  return result;
257
194
  }
258
-
259
195
  mineFile(fileName) {
260
196
  return this.mineContent(fileName, readFile(fileName));
261
197
  }
262
-
263
198
  }
264
-
265
199
  exports.MarkdownMiner = MarkdownMiner;
266
200
  var fileMiners = {
267
201
  '.cs': new CodeMiner(),
@@ -276,22 +210,15 @@ var fileMiners = {
276
210
  '.go': new CodeMiner(),
277
211
  '.java': new CodeMiner()
278
212
  };
279
-
280
213
  class ExampleMiner {
281
214
  constructor(sourcePath) {
282
215
  this.sourcePath = sourcePath;
283
-
284
216
  _defineProperty(this, "summaries", {});
285
-
286
217
  _defineProperty(this, "nuggets", {});
287
-
288
218
  _defineProperty(this, "commitHash", getCommitHash());
289
-
290
219
  _defineProperty(this, "remoteOrigin", getPermalinkRoot());
291
-
292
220
  this.execute(sourcePath);
293
221
  }
294
-
295
222
  get lode() {
296
223
  return {
297
224
  commitHash: this.commitHash,
@@ -300,15 +227,12 @@ class ExampleMiner {
300
227
  nuggets: this.nuggets
301
228
  };
302
229
  }
303
-
304
230
  addCall(ext, relativeFile, call) {
305
231
  function addFileCall(nugget) {
306
232
  var fileCalls = nugget.calls[ext];
307
-
308
233
  if (!fileCalls) {
309
234
  fileCalls = [];
310
235
  }
311
-
312
236
  var sdkCall = call;
313
237
  var fileCall = {
314
238
  sourceFile: relativeFile,
@@ -318,33 +242,27 @@ class ExampleMiner {
318
242
  if (!fileCalls.find(f => f.line === fileCall.line && f.column === fileCall.column && f.sourceFile === fileCall.sourceFile)) fileCalls.push(fileCall);
319
243
  nugget.calls[ext] = fileCalls;
320
244
  }
321
-
322
245
  if ('summary' in call) {
323
246
  var s = call;
324
247
  s.sourceFile = ExampleMiner.relate(this.sourcePath, s.sourceFile);
325
248
  this.summaries[s.sourceFile] = s;
326
249
  } else {
327
250
  var nugget = this.nuggets[call.operationId];
328
-
329
251
  if (!nugget) {
330
252
  nugget = {
331
253
  operationId: call.operationId,
332
254
  calls: {}
333
255
  };
334
256
  }
335
-
336
257
  addFileCall(nugget);
337
258
  this.nuggets[nugget.operationId] = nugget;
338
259
  }
339
260
  }
340
-
341
261
  static relate(sourcePath, fileName) {
342
262
  return _path.default.relative(sourcePath, fileName);
343
263
  }
344
-
345
264
  processFile(fileName) {
346
265
  var ext = _path.default.extname(fileName);
347
-
348
266
  if (ext in fileMiners) {
349
267
  var coder = fileMiners[ext];
350
268
  var calls = coder.mineFile(fileName);
@@ -356,7 +274,6 @@ class ExampleMiner {
356
274
  (0, _sdkCodegenUtils.warn)("".concat(fileName, " cannot be mined"));
357
275
  }
358
276
  }
359
-
360
277
  execute() {
361
278
  var sourcePath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
362
279
  var dirPath = sourcePath !== null && sourcePath !== void 0 ? sourcePath : this.sourcePath;
@@ -364,8 +281,6 @@ class ExampleMiner {
364
281
  files.forEach(f => this.processFile(f));
365
282
  return this.lode;
366
283
  }
367
-
368
284
  }
369
-
370
285
  exports.ExampleMiner = ExampleMiner;
371
286
  //# sourceMappingURL=exampleMiner.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/exampleMiner.ts"],"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","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","rel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C,WAApB,IAAmC8C,MAAnC;AACD;AACF;;AASmB,SAANQ,MAAM,CAAClB,UAAD,EAAqB7F,QAArB,EAAuC;AACzD,WAAOa,cAAKmG,QAAL,CAAcnB,UAAd,EAA0B7F,QAA1B,CAAP;AACD;;AAEDiH,EAAAA,WAAW,CAACjH,QAAD,EAAmB;AAC5B,QAAMY,GAAG,GAAGC,cAAKC,OAAL,CAAad,QAAb,CAAZ;;AACA,QAAIY,GAAG,IAAII,UAAX,EAAuB;AACrB,UAAMkG,KAAK,GAAGlG,UAAU,CAACJ,GAAD,CAAxB;AACA,UAAM6F,KAAK,GAAGS,KAAK,CAAC/C,QAAN,CAAenE,QAAf,CAAd;AACAyG,MAAAA,KAAK,CAAC3E,OAAN,CAAeuB,IAAD,IAA+B;AAC3C,YAAM8D,OAAO,GAAGxB,YAAY,CAACoB,MAAb,CAAoB,KAAKlB,UAAzB,EAAqC7F,QAArC,CAAhB;AACA,aAAKoG,OAAL,CAAaxF,GAAb,EAAkBuG,OAAlB,EAA2B9D,IAA3B;AACD,OAHD;AAID,KAPD,MAOO;AACL,2CAAQrD,QAAR;AACD;AACF;;AAED8F,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,IAAMA,QAAQ,GAAIC,QAAgB,IACvCC,EAAE,CAACC,YAAY,CAACF,QAAQ,EAAE;EAAEG,QAAQ,EAAE;AAAQ,CAAC,CAAC;AAAA;AAElD,IAAMC,UAAU,GAAG,6CAA6C;AAChE,IAAMC,SAAS,GAAG,yBAAyB;AAC3C,IAAMC,WAAW,GAAG,8BAA8B;AAW3C,IAAMC,cAAc,GAAIP,QAAgB,IAAKA,QAAQ,CAACQ,IAAI,EAAE,CAACC,MAAM,GAAG,CAAC;AAAA;AAMvE,IAAMC,eAAe,GAAIV,QAAgB,IAAK;EACnD,IAAI,wBAAwB,CAACW,IAAI,CAACX,QAAQ,CAAC,EAAE,OAAO,KAAK;EACzD,IAAMY,GAAG,GAAGC,aAAI,CAACC,OAAO,CAACd,QAAQ,CAAC,CAACe,iBAAiB,EAAE;EAEtD,OAAOH,GAAG,IAAII,UAAU;AAC1B,CAAC;AAAA;AAEM,IAAMC,YAAY,GAAG,CAC1B,cAAc,EACd,KAAK,EACL,MAAM,EACN,WAAW,EACX,OAAO,EACP,KAAK,EACL,QAAQ,EACR,SAAS,EACT,SAAS,EACT,SAAS,EACT,OAAO,EACP,SAAS,EACT,SAAS,CACV;AAAA;AAED,IAAMC,UAAU,G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