@teambit/dependencies 1.0.410 → 1.0.412

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.
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <testsuites tests="169" failures="0" errors="0" skipped="33">
3
- <testsuite name="teambit.dependencies/dependencies@1.0.410" tests="169" failures="0" errors="0" skipped="33">
3
+ <testsuite name="teambit.dependencies/dependencies@1.0.412" tests="169" failures="0" errors="0" skipped="33">
4
4
  <testcase classname="dist/dependencies.spec.js" name="should add the snap prefix" time="0.001"/>
5
5
  <testcase classname="dist/dependencies-loader/package-to-definetly-typed.spec.js" name="should map to @types/testing-library__jest-dom" time="0.001"/>
6
6
  <testcase classname="dist/dependencies-loader/package-to-definetly-typed.spec.js" name="should map to @types/chai"/>
@@ -40,7 +40,7 @@
40
40
  <testcase classname="dist/dependencies-loader/package-to-definetly-typed.spec.js" name="should map to @types/webpack-merge"/>
41
41
  <testcase classname="dist/files-dependency-builder/build-tree.spec.js" name="when no files are passed should return an empty tree" time="0.001"/>
42
42
  <testcase classname="dist/files-dependency-builder/build-tree.spec.js" name="when unsupported files are passed should return them with no dependencies" time="0.001"/>
43
- <testcase classname="dist/files-dependency-builder/build-tree.spec.js" name="when supported and unsupported files are passed should return them all" time="0.073"/>
43
+ <testcase classname="dist/files-dependency-builder/build-tree.spec.js" name="when supported and unsupported files are passed should return them all" time="0.086"/>
44
44
  <testcase classname="dist/files-dependency-builder/build-tree.spec.js" name="when a js file has parsing error it should add the file to the tree with the error instance">
45
45
  <skipped/>
46
46
  </testcase>
@@ -62,36 +62,36 @@
62
62
  <testcase classname="dist/files-dependency-builder/build-tree.spec.js" name="it should add the missing package to the missing section in the tree">
63
63
  <skipped/>
64
64
  </testcase>
65
- <testcase classname="dist/files-dependency-builder/build-tree.spec.js" name="should not throw an error and should remove itself from the dependencies files"/>
65
+ <testcase classname="dist/files-dependency-builder/build-tree.spec.js" name="should not throw an error and should remove itself from the dependencies files" time="0.001"/>
66
66
  <testcase classname="dist/files-dependency-builder/build-tree.spec.js" name="should not recognize the cycle dependencies as link files">
67
67
  <skipped/>
68
68
  </testcase>
69
69
  <testcase classname="dist/files-dependency-builder/dependency-tree/index.spec.js" name="returns an empty object for a non-existent filename" time="0.001"/>
70
70
  <testcase classname="dist/files-dependency-builder/dependency-tree/index.spec.js" name="handles nested tree structures" time="0.006"/>
71
- <testcase classname="dist/files-dependency-builder/dependency-tree/index.spec.js" name="does not include files that are not real (#13)" time="0.002"/>
72
- <testcase classname="dist/files-dependency-builder/dependency-tree/index.spec.js" name="does not choke on cyclic dependencies" time="0.102"/>
71
+ <testcase classname="dist/files-dependency-builder/dependency-tree/index.spec.js" name="does not include files that are not real (#13)" time="0.001"/>
72
+ <testcase classname="dist/files-dependency-builder/dependency-tree/index.spec.js" name="does not choke on cyclic dependencies" time="0.104"/>
73
73
  <testcase classname="dist/files-dependency-builder/dependency-tree/index.spec.js" name="excludes Nodejs core modules by default" time="0.001"/>
74
74
  <testcase classname="dist/files-dependency-builder/dependency-tree/index.spec.js" name="returns a list of absolutely pathed files"/>
75
- <testcase classname="dist/files-dependency-builder/dependency-tree/index.spec.js" name="passes it through to precinct" time="0.044"/>
75
+ <testcase classname="dist/files-dependency-builder/dependency-tree/index.spec.js" name="passes it through to precinct" time="0.047"/>
76
76
  <testcase classname="dist/files-dependency-builder/dependency-tree/index.spec.js" name="stores the invalid partials" time="0.001"/>
77
- <testcase classname="dist/files-dependency-builder/dependency-tree/index.spec.js" name="does not store anything" time="0.002"/>
78
- <testcase classname="dist/files-dependency-builder/dependency-tree/index.spec.js" name="stores the invalid ones" time="0.002"/>
79
- <testcase classname="dist/files-dependency-builder/dependency-tree/index.spec.js" name="should include the non-existent partial per file" time="0.002"/>
77
+ <testcase classname="dist/files-dependency-builder/dependency-tree/index.spec.js" name="does not store anything" time="0.003"/>
78
+ <testcase classname="dist/files-dependency-builder/dependency-tree/index.spec.js" name="stores the invalid ones" time="0.003"/>
79
+ <testcase classname="dist/files-dependency-builder/dependency-tree/index.spec.js" name="should include the non-existent partial per file" time="0.003"/>
80
80
  <testcase classname="dist/files-dependency-builder/dependency-tree/index.spec.js" name="throws if the filename is missing"/>
81
81
  <testcase classname="dist/files-dependency-builder/dependency-tree/index.spec.js" name="throws if the root is missing"/>
82
82
  <testcase classname="dist/files-dependency-builder/dependency-tree/index.spec.js" name="throws if a supplied filter is not a function"/>
83
- <testcase classname="dist/files-dependency-builder/dependency-tree/index.spec.js" name="does not throw on the legacy `root` option"/>
83
+ <testcase classname="dist/files-dependency-builder/dependency-tree/index.spec.js" name="does not throw on the legacy `root` option" time="0.001"/>
84
84
  <testcase classname="dist/files-dependency-builder/dependency-tree/index.spec.js" name="does not throw"/>
85
85
  <testcase classname="dist/files-dependency-builder/dependency-tree/index.spec.js" name="returns no dependencies"/>
86
86
  <testcase classname="dist/files-dependency-builder/dependency-tree/index.spec.js" name="returns the precomputed list of a cached entry point"/>
87
- <testcase classname="dist/files-dependency-builder/dependency-tree/index.spec.js" name="returns an object form of the dependency tree for a file" time="0.002"/>
88
- <testcase classname="dist/files-dependency-builder/dependency-tree/index.spec.js" name="returns an object form of the dependency tree for a file" time="0.002"/>
87
+ <testcase classname="dist/files-dependency-builder/dependency-tree/index.spec.js" name="returns an object form of the dependency tree for a file" time="0.003"/>
88
+ <testcase classname="dist/files-dependency-builder/dependency-tree/index.spec.js" name="returns an object form of the dependency tree for a file" time="0.003"/>
89
89
  <testcase classname="dist/files-dependency-builder/dependency-tree/index.spec.js" name="resolves files that have jsx" time="0.001"/>
90
- <testcase classname="dist/files-dependency-builder/dependency-tree/index.spec.js" name="resolves files with a jsx extension" time="0.001"/>
90
+ <testcase classname="dist/files-dependency-builder/dependency-tree/index.spec.js" name="resolves files with a jsx extension" time="0.002"/>
91
91
  <testcase classname="dist/files-dependency-builder/dependency-tree/index.spec.js" name="resolves files that have es7" time="0.001"/>
92
92
  <testcase classname="dist/files-dependency-builder/dependency-tree/index.spec.js" name="returns an object form of the dependency tree for a file" time="0.006"/>
93
93
  <testcase classname="dist/files-dependency-builder/dependency-tree/index.spec.js" name="returns an object form of the dependency tree for a file" time="0.001"/>
94
- <testcase classname="dist/files-dependency-builder/dependency-tree/index.spec.js" name="returns an object form of the dependency tree for a file" time="0.003"/>
94
+ <testcase classname="dist/files-dependency-builder/dependency-tree/index.spec.js" name="returns an object form of the dependency tree for a file" time="0.004"/>
95
95
  <testcase classname="dist/files-dependency-builder/dependency-tree/index.spec.js" name="returns an object form of the dependency tree for a file" time="0.011"/>
96
96
  <testcase classname="dist/files-dependency-builder/dependency-tree/index.spec.js" name="resolves unaliased modules">
97
97
  <skipped/>
@@ -110,10 +110,10 @@
110
110
  <testcase classname="dist/files-dependency-builder/dependency-tree/index.spec.js" name="should not show missing dependencies"/>
111
111
  <testcase classname="dist/files-dependency-builder/dependency-tree/index.spec.js" name="should not show missing dependencies when importing from https" time="0.001"/>
112
112
  <testcase classname="dist/files-dependency-builder/dependency-tree/index.spec.js" name="should not show missing dependencies when importing from http" time="0.001"/>
113
- <testcase classname="dist/files-dependency-builder/filing-cabinet/index.spec.js" name="uses a generic resolve for unsupported file extensions" time="0.002"/>
114
- <testcase classname="dist/files-dependency-builder/filing-cabinet/index.spec.js" name="reuses the ast when trying to determine the module type"/>
115
- <testcase classname="dist/files-dependency-builder/filing-cabinet/index.spec.js" name="resolves the dependency successfully"/>
116
- <testcase classname="dist/files-dependency-builder/filing-cabinet/index.spec.js" name="uses the filename to look for the module type" time="0.001"/>
113
+ <testcase classname="dist/files-dependency-builder/filing-cabinet/index.spec.js" name="uses a generic resolve for unsupported file extensions" time="0.009"/>
114
+ <testcase classname="dist/files-dependency-builder/filing-cabinet/index.spec.js" name="reuses the ast when trying to determine the module type" time="0.001"/>
115
+ <testcase classname="dist/files-dependency-builder/filing-cabinet/index.spec.js" name="resolves the dependency successfully" time="0.001"/>
116
+ <testcase classname="dist/files-dependency-builder/filing-cabinet/index.spec.js" name="uses the filename to look for the module type"/>
117
117
  <testcase classname="dist/files-dependency-builder/filing-cabinet/index.spec.js" name="assumes commonjs for es6 modules with no requirejs/webpack config">
118
118
  <skipped/>
119
119
  </testcase>
@@ -123,8 +123,8 @@
123
123
  </testcase>
124
124
  <testcase classname="dist/files-dependency-builder/filing-cabinet/index.spec.js" name="returns an empty string for an unresolved module"/>
125
125
  <testcase classname="dist/files-dependency-builder/filing-cabinet/index.spec.js" name="adds the directory to the require resolution paths" time="0.001"/>
126
- <testcase classname="dist/files-dependency-builder/filing-cabinet/index.spec.js" name="resolves a relative dependency about the filename" time="0.001"/>
127
- <testcase classname="dist/files-dependency-builder/filing-cabinet/index.spec.js" name="resolves a .. dependency to its parent directory's index.js file" time="0.001"/>
126
+ <testcase classname="dist/files-dependency-builder/filing-cabinet/index.spec.js" name="resolves a relative dependency about the filename"/>
127
+ <testcase classname="dist/files-dependency-builder/filing-cabinet/index.spec.js" name="resolves a .. dependency to its parent directory's index.js file"/>
128
128
  <testcase classname="dist/files-dependency-builder/filing-cabinet/index.spec.js" name="resolves a dependency within a directory outside of the given file">
129
129
  <skipped/>
130
130
  </testcase>
@@ -132,17 +132,17 @@
132
132
  <skipped/>
133
133
  </testcase>
134
134
  <testcase classname="dist/files-dependency-builder/filing-cabinet/index.spec.js" name="resolves a nested module" time="0.001"/>
135
- <testcase classname="dist/files-dependency-builder/filing-cabinet/index.spec.js" name="resolves to the index.js file of a directory" time="0.001"/>
136
- <testcase classname="dist/files-dependency-builder/filing-cabinet/index.spec.js" name="resolves implicit .jsx requires"/>
137
- <testcase classname="dist/files-dependency-builder/filing-cabinet/index.spec.js" name="resolves implicit .scss requires" time="0.001"/>
138
- <testcase classname="dist/files-dependency-builder/filing-cabinet/index.spec.js" name="resolves implicit .json requires"/>
135
+ <testcase classname="dist/files-dependency-builder/filing-cabinet/index.spec.js" name="resolves to the index.js file of a directory"/>
136
+ <testcase classname="dist/files-dependency-builder/filing-cabinet/index.spec.js" name="resolves implicit .jsx requires" time="0.001"/>
137
+ <testcase classname="dist/files-dependency-builder/filing-cabinet/index.spec.js" name="resolves implicit .scss requires"/>
138
+ <testcase classname="dist/files-dependency-builder/filing-cabinet/index.spec.js" name="resolves implicit .json requires" time="0.001"/>
139
139
  <testcase classname="dist/files-dependency-builder/filing-cabinet/index.spec.js" name="resolves an import"/>
140
- <testcase classname="dist/files-dependency-builder/filing-cabinet/index.spec.js" name="returns an empty result" time="0.001"/>
140
+ <testcase classname="dist/files-dependency-builder/filing-cabinet/index.spec.js" name="returns an empty result" time="0.002"/>
141
141
  <testcase classname="dist/files-dependency-builder/filing-cabinet/index.spec.js" name="uses the sass resolver for .scss files"/>
142
142
  <testcase classname="dist/files-dependency-builder/filing-cabinet/index.spec.js" name="uses the sass resolver for .sass files"/>
143
143
  <testcase classname="dist/files-dependency-builder/filing-cabinet/index.spec.js" name="uses the stylus resolver"/>
144
144
  <testcase classname="dist/files-dependency-builder/filing-cabinet/index.spec.js" name="resolves extensionless dependencies"/>
145
- <testcase classname="dist/files-dependency-builder/filing-cabinet/index.spec.js" name="resolves dependencies with a less extension"/>
145
+ <testcase classname="dist/files-dependency-builder/filing-cabinet/index.spec.js" name="resolves dependencies with a less extension" time="0.001"/>
146
146
  <testcase classname="dist/files-dependency-builder/filing-cabinet/index.spec.js" name="resolves dependencies with a css extension"/>
147
147
  <testcase classname="dist/files-dependency-builder/filing-cabinet/index.spec.js" name="uses a generic resolve for unsupported file extensions"/>
148
148
  <testcase classname="dist/files-dependency-builder/filing-cabinet/index.spec.js" name="supports passing env detectors"/>
@@ -191,9 +191,9 @@
191
191
  </testcase>
192
192
  <testcase classname="dist/files-dependency-builder/precinct/index.spec.js" name="accepts an AST"/>
193
193
  <testcase classname="dist/files-dependency-builder/precinct/index.spec.js" name="dangles off a given ast"/>
194
- <testcase classname="dist/files-dependency-builder/precinct/index.spec.js" name="dangles off the parsed ast from a .js file" time="0.002"/>
195
- <testcase classname="dist/files-dependency-builder/precinct/index.spec.js" name="dangles off the parsed ast from a scss detective" time="0.002"/>
196
- <testcase classname="dist/files-dependency-builder/precinct/index.spec.js" name="dangles off the parsed ast from a sass detective" time="0.005"/>
194
+ <testcase classname="dist/files-dependency-builder/precinct/index.spec.js" name="dangles off the parsed ast from a .js file" time="0.001"/>
195
+ <testcase classname="dist/files-dependency-builder/precinct/index.spec.js" name="dangles off the parsed ast from a scss detective" time="0.001"/>
196
+ <testcase classname="dist/files-dependency-builder/precinct/index.spec.js" name="dangles off the parsed ast from a sass detective" time="0.004"/>
197
197
  <testcase classname="dist/files-dependency-builder/precinct/index.spec.js" name="grabs dependencies of amd modules" time="0.001"/>
198
198
  <testcase classname="dist/files-dependency-builder/precinct/index.spec.js" name="grabs dependencies of commonjs modules" time="0.001"/>
199
199
  <testcase classname="dist/files-dependency-builder/precinct/index.spec.js" name="grabs dependencies of es6 modules" time="0.001"/>
@@ -210,16 +210,16 @@
210
210
  <testcase classname="dist/files-dependency-builder/precinct/index.spec.js" name="grabs dependencies of typescript files">
211
211
  <skipped/>
212
212
  </testcase>
213
- <testcase classname="dist/files-dependency-builder/precinct/index.spec.js" name="throws errors of typescript modules with syntax errors" time="0.001"/>
213
+ <testcase classname="dist/files-dependency-builder/precinct/index.spec.js" name="throws errors of typescript modules with syntax errors"/>
214
214
  <testcase classname="dist/files-dependency-builder/precinct/index.spec.js" name="supports the object form of type configuration"/>
215
- <testcase classname="dist/files-dependency-builder/precinct/index.spec.js" name="yields no dependencies for es6 modules with no imports" time="0.001"/>
215
+ <testcase classname="dist/files-dependency-builder/precinct/index.spec.js" name="yields no dependencies for es6 modules with no imports"/>
216
216
  <testcase classname="dist/files-dependency-builder/precinct/index.spec.js" name="yields no dependencies for non-modules"/>
217
217
  <testcase classname="dist/files-dependency-builder/precinct/index.spec.js" name="throw on unparsable .js files"/>
218
218
  <testcase classname="dist/files-dependency-builder/precinct/index.spec.js" name="does not blow up when parsing a gruntfile #2"/>
219
219
  <testcase classname="dist/files-dependency-builder/precinct/index.spec.js" name="returns the dependencies for the given filepath">
220
220
  <skipped/>
221
221
  </testcase>
222
- <testcase classname="dist/files-dependency-builder/precinct/index.spec.js" name="throws if the file cannot be found" time="0.001"/>
222
+ <testcase classname="dist/files-dependency-builder/precinct/index.spec.js" name="throws if the file cannot be found"/>
223
223
  <testcase classname="dist/files-dependency-builder/precinct/index.spec.js" name="filters out core modules if options.includeCore is false" time="0.001"/>
224
224
  <testcase classname="dist/files-dependency-builder/precinct/index.spec.js" name="does not filter out core modules by default">
225
225
  <skipped/>
@@ -231,10 +231,10 @@
231
231
  <testcase classname="dist/files-dependency-builder/precinct/index.spec.js" name="still does not filter out core module by default">
232
232
  <skipped/>
233
233
  </testcase>
234
- <testcase classname="dist/files-dependency-builder/precinct/index.spec.js" name="passes amd config to the amd detective" time="0.001"/>
234
+ <testcase classname="dist/files-dependency-builder/precinct/index.spec.js" name="passes amd config to the amd detective"/>
235
+ <testcase classname="dist/files-dependency-builder/precinct/index.spec.js" name="returns both the commonjs and es6 dependencies"/>
235
236
  <testcase classname="dist/files-dependency-builder/precinct/index.spec.js" name="returns both the commonjs and es6 dependencies"/>
236
- <testcase classname="dist/files-dependency-builder/precinct/index.spec.js" name="returns both the commonjs and es6 dependencies" time="0.001"/>
237
- <testcase classname="dist/files-dependency-builder/precinct/index.spec.js" name="grabs those lazy dependencies" time="0.001"/>
237
+ <testcase classname="dist/files-dependency-builder/precinct/index.spec.js" name="grabs those lazy dependencies"/>
238
238
  <testcase classname="dist/files-dependency-builder/precinct/index.spec.js" name="grabs the lazy imports" time="0.001"/>
239
239
  </testsuite>
240
240
  </testsuites>
@@ -20,6 +20,7 @@
20
20
  "line": 3,
21
21
  "character": 15
22
22
  },
23
+ "signature": "class DependenciesMain",
23
24
  "name": "DependenciesMain",
24
25
  "exportNode": {
25
26
  "__schema": "ClassSchema",
@@ -1446,6 +1447,7 @@
1446
1447
  "line": 4,
1447
1448
  "character": 10
1448
1449
  },
1450
+ "signature": "class DetectorHook",
1449
1451
  "name": "DetectorHook",
1450
1452
  "exportNode": {
1451
1453
  "__schema": "ClassSchema",
@@ -1601,6 +1603,7 @@
1601
1603
  "line": 4,
1602
1604
  "character": 24
1603
1605
  },
1606
+ "signature": "interface DependencyDetector",
1604
1607
  "name": "DependencyDetector",
1605
1608
  "exportNode": {
1606
1609
  "__schema": "InterfaceSchema",
@@ -1832,6 +1835,7 @@
1832
1835
  "line": 4,
1833
1836
  "character": 44
1834
1837
  },
1838
+ "signature": "type FileContext = {\n ext: string;\n}",
1835
1839
  "name": "FileContext",
1836
1840
  "exportNode": {
1837
1841
  "__schema": "TypeSchema",
@@ -1902,6 +1906,7 @@
1902
1906
  "line": 6,
1903
1907
  "character": 10
1904
1908
  },
1909
+ "signature": "const DependenciesAspect: Aspect",
1905
1910
  "name": "DependenciesAspect",
1906
1911
  "exportNode": {
1907
1912
  "__schema": "VariableLikeSchema",
@@ -4525,7 +4530,7 @@
4525
4530
  "componentId": {
4526
4531
  "scope": "teambit.dependencies",
4527
4532
  "name": "dependencies",
4528
- "version": "1.0.410"
4533
+ "version": "1.0.412"
4529
4534
  },
4530
4535
  "taggedModuleExports": []
4531
4536
  }
@@ -11,4 +11,9 @@ export declare class DependentsCmd implements Command {
11
11
  alias: string;
12
12
  options: CommandOptions;
13
13
  report([id]: [string]): Promise<string>;
14
+ json([id]: [string]): Promise<{
15
+ scopeDependents: any[];
16
+ workspaceDependents: any[];
17
+ id: string;
18
+ }>;
14
19
  }
@@ -26,6 +26,8 @@ function _template() {
26
26
  return data;
27
27
  }
28
28
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
29
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
30
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
29
31
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
30
32
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
31
33
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
@@ -40,7 +42,7 @@ class DependentsCmd {
40
42
  _defineProperty(this, "description", 'show dependents of the given component');
41
43
  _defineProperty(this, "group", 'info');
42
44
  _defineProperty(this, "alias", '');
43
- _defineProperty(this, "options", []);
45
+ _defineProperty(this, "options", [['j', 'json', 'return the dependents in JSON format']]);
44
46
  }
45
47
  async report([id]) {
46
48
  const results = await (0, _dependents().dependents)(id);
@@ -56,6 +58,19 @@ ${workspaceTable || '<none>'}
56
58
  ${_chalk().default.bold('Dependents originated from scope')}
57
59
  ${scopeTable || '<none>'}`;
58
60
  }
61
+ async json([id]) {
62
+ const results = await (0, _dependents().dependents)(id);
63
+ const depInfoToString = depInfo => {
64
+ return _objectSpread(_objectSpread({}, depInfo), {}, {
65
+ id: depInfo.id.toString()
66
+ });
67
+ };
68
+ return {
69
+ scopeDependents: results.scopeDependents.map(depInfoToString),
70
+ workspaceDependents: results.workspaceDependents.map(depInfoToString),
71
+ id: results.id.toString()
72
+ };
73
+ }
59
74
  }
60
75
  exports.DependentsCmd = DependentsCmd;
61
76
 
@@ -1 +1 @@
1
- {"version":3,"names":["_chalk","data","_interopRequireDefault","require","_dependents","_template","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","DependentsCmd","constructor","name","description","report","id","results","dependents","scopeDependents","length","workspaceDependents","toString","toStringWithoutVersion","scopeTable","generateDependentsInfoTable","workspaceTable","chalk","bold","exports"],"sources":["dependents-cmd.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { dependents, DependentsResults } from './dependents';\nimport { generateDependentsInfoTable } from './template';\n\nexport class DependentsCmd implements Command {\n name = 'dependents <component-name>';\n helpUrl = 'reference/dependencies/inspecting-dependencies#review-dependents';\n arguments = [\n {\n name: 'component-name',\n description: 'component name or component id',\n },\n ];\n description = 'show dependents of the given component';\n group = 'info';\n alias = '';\n options = [] as CommandOptions;\n\n async report([id]: [string]) {\n const results: DependentsResults = await dependents(id);\n if (!results.scopeDependents.length && !results.workspaceDependents.length) {\n return `no dependents found for ${results.id.toString()}.\ntry running \"bit cat-component ${results.id.toStringWithoutVersion()}\" to see whether the component/version exists locally`;\n }\n const scopeTable = generateDependentsInfoTable(results.scopeDependents, results.id);\n const workspaceTable = generateDependentsInfoTable(results.workspaceDependents, results.id);\n return `${chalk.bold('Dependents originated from workspace')}\n${workspaceTable || '<none>'}\n\n${chalk.bold('Dependents originated from scope')}\n${scopeTable || '<none>'}`;\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,YAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,WAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,UAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAA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,EAAE;IAC3B,MAAMC,OAA0B,GAAG,MAAM,IAAAC,wBAAU,EAACF,EAAE,CAAC;IACvD,IAAI,CAACC,OAAO,CAACE,eAAe,CAACC,MAAM,IAAI,CAACH,OAAO,CAACI,mBAAmB,CAACD,MAAM,EAAE;MAC1E,OAAO,2BAA2BH,OAAO,CAACD,EAAE,CAACM,QAAQ,CAAC,CAAC;AAC7D,iCAAiCL,OAAO,CAACD,EAAE,CAACO,sBAAsB,CAAC,CAAC,uDAAuD;IACvH;IACA,MAAMC,UAAU,GAAG,IAAAC,uCAA2B,EAACR,OAAO,CAACE,eAAe,EAAEF,OAAO,CAACD,EAAE,CAAC;IACnF,MAAMU,cAAc,GAAG,IAAAD,uCAA2B,EAACR,OAAO,CAACI,mBAAmB,EAAEJ,OAAO,CAACD,EAAE,CAAC;IAC3F,OAAO,GAAGW,gBAAK,CAACC,IAAI,CAAC,sCAAsC,CAAC;AAChE,EAAEF,cAAc,IAAI,QAAQ;AAC5B;AACA,EAAEC,gBAAK,CAACC,IAAI,CAAC,kCAAkC,CAAC;AAChD,EAAEJ,UAAU,IAAI,QAAQ,EAAE;EACxB;AACF;AAACK,OAAA,CAAAlB,aAAA,GAAAA,aAAA","ignoreList":[]}
1
+ {"version":3,"names":["_chalk","data","_interopRequireDefault","require","_dependents","_template","e","__esModule","default","ownKeys","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","DependentsCmd","constructor","name","description","report","id","results","dependents","scopeDependents","workspaceDependents","toString","toStringWithoutVersion","scopeTable","generateDependentsInfoTable","workspaceTable","chalk","bold","json","depInfoToString","depInfo","map","exports"],"sources":["dependents-cmd.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { dependents, DependentsResults } from './dependents';\nimport { generateDependentsInfoTable } from './template';\n\nexport class DependentsCmd implements Command {\n name = 'dependents <component-name>';\n helpUrl = 'reference/dependencies/inspecting-dependencies#review-dependents';\n arguments = [\n {\n name: 'component-name',\n description: 'component name or component id',\n },\n ];\n description = 'show dependents of the given component';\n group = 'info';\n alias = '';\n options = [['j', 'json', 'return the dependents in JSON format']] as CommandOptions;\n\n async report([id]: [string]) {\n const results: DependentsResults = await dependents(id);\n if (!results.scopeDependents.length && !results.workspaceDependents.length) {\n return `no dependents found for ${results.id.toString()}.\ntry running \"bit cat-component ${results.id.toStringWithoutVersion()}\" to see whether the component/version exists locally`;\n }\n const scopeTable = generateDependentsInfoTable(results.scopeDependents, results.id);\n const workspaceTable = generateDependentsInfoTable(results.workspaceDependents, results.id);\n return `${chalk.bold('Dependents originated from workspace')}\n${workspaceTable || '<none>'}\n\n${chalk.bold('Dependents originated from scope')}\n${scopeTable || '<none>'}`;\n }\n\n async json([id]: [string]) {\n const results: DependentsResults = await dependents(id);\n const depInfoToString = (depInfo) => {\n return {\n ...depInfo,\n id: depInfo.id.toString(),\n };\n };\n return {\n scopeDependents: results.scopeDependents.map(depInfoToString),\n workspaceDependents: results.workspaceDependents.map(depInfoToString),\n id: results.id.toString(),\n };\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,YAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,WAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,UAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,SAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAyD,SAAAC,uBAAAI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CAAiCJ,OAAO,CAACD,EAAE,CAACM,sBAAsB,CAAC,CAAC,uDAAuD;IACvH;IACA,MAAMC,UAAU,GAAG,IAAAC,uCAA2B,EAACP,OAAO,CAACE,eAAe,EAAEF,OAAO,CAACD,EAAE,CAAC;IACnF,MAAMS,cAAc,GAAG,IAAAD,uCAA2B,EAACP,OAAO,CAACG,mBAAmB,EAAEH,OAAO,CAACD,EAAE,CAAC;IAC3F,OAAO,GAAGU,gBAAK,CAACC,IAAI,CAAC,sCAAsC,CAAC;AAChE,EAAEF,cAAc,IAAI,QAAQ;AAC5B;AACA,EAAEC,gBAAK,CAACC,IAAI,CAAC,kCAAkC,CAAC;AAChD,EAAEJ,UAAU,IAAI,QAAQ,EAAE;EACxB;EAEA,MAAMK,IAAIA,CAAC,CAACZ,EAAE,CAAW,EAAE;IACzB,MAAMC,OAA0B,GAAG,MAAM,IAAAC,wBAAU,EAACF,EAAE,CAAC;IACvD,MAAMa,eAAe,GAAIC,OAAO,IAAK;MACnC,OAAAvC,aAAA,CAAAA,aAAA,KACKuC,OAAO;QACVd,EAAE,EAAEc,OAAO,CAACd,EAAE,CAACK,QAAQ,CAAC;MAAC;IAE7B,CAAC;IACD,OAAO;MACLF,eAAe,EAAEF,OAAO,CAACE,eAAe,CAACY,GAAG,CAACF,eAAe,CAAC;MAC7DT,mBAAmB,EAAEH,OAAO,CAACG,mBAAmB,CAACW,GAAG,CAACF,eAAe,CAAC;MACrEb,EAAE,EAAEC,OAAO,CAACD,EAAE,CAACK,QAAQ,CAAC;IAC1B,CAAC;EACH;AACF;AAACW,OAAA,CAAArB,aAAA,GAAAA,aAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_fsExtra","data","_interopRequireDefault","require","_path","_module","_moduleDefinition","_nodeSourceWalk","_detectiveAmd","_detectiveStylus","_nodeDepsDetectors","_stylingDepsDetectors","_stylingDepsDetectors2","_stylingDepsDetectors3","_stylingDepsDetectors4","_typescriptDepsDetectors","_detectorHook","e","__esModule","default","jsExt","extToType","typeToDetective","css","detectiveCss","sass","detectiveSass","less","detectiveLess","scss","detectiveScss","stylus","detectiveStylus","ts","detectiveTypeScript","commonjs","detectiveEs6","es6","amd","detectiveAmd","debug","detectorHook","DetectorHook","assign","o1","o2","key","hasOwnProperty","getFileInfo","filename","ext","path","extname","content","fs","readFileSync","type","ast","getDetector","fileInfo","options","normalizedOptions","envDetectors","detector","isSupported","detect","detective","jsx","undefined","getJsDetector","includes","walker","Walker","parse","message","useContent","getModuleType","fromSource","normalizeDeps","deps","includeCore","normalizedDeps","Array","isArray","Object","keys","filter","d","isBuiltin","getDepsFromFile","startsWith","precinct","paperwork","_default","exports"],"sources":["index.ts"],"sourcesContent":["/**\n * this file had been forked from https://github.com/dependents/node-precinct\n */\nimport fs from 'fs-extra';\nimport path from 'path';\n\n// @ts-ignore we currently have @types/node as v12, and this is available > 16. once updated, remove the ts-ignore\nimport { isBuiltin } from 'module';\n\nimport getModuleType from 'module-definition';\nimport Walker from 'node-source-walk';\n\nimport detectiveAmd from 'detective-amd';\nimport detectiveStylus from 'detective-stylus';\n\nimport detectiveEs6 from '@teambit/node.deps-detectors.detective-es6';\nimport detectiveCss from '@teambit/styling.deps-detectors.detective-css';\nimport detectiveLess from '@teambit/styling.deps-detectors.detective-less';\nimport detectiveSass from '@teambit/styling.deps-detectors.detective-sass';\nimport detectiveScss from '@teambit/styling.deps-detectors.detective-scss';\nimport detectiveTypeScript from '@teambit/typescript.deps-detectors.detective-typescript';\n\nimport { DependencyDetector, DetectorHook } from '../detector-hook';\n\n/**\n * The file info object.\n * - `ext` is the file extension.\n * - `content` is the input file content.\n * - `type` is the parsed file type from ext or content.\n * - `ast` is the eventually consumed content by the corresponding detective.\n */\ntype FileInfo = {\n ext: string;\n content: string | object;\n type: string;\n ast: any;\n};\n\ntype Options = {\n envDetectors?: DependencyDetector[];\n useContent?: boolean;\n includeCore?: boolean;\n type?: string;\n [lang: string]: any;\n};\n\ntype BuiltinDeps = string[] | Record<string, any>;\ntype Detective = (fileContent: string | object, options?: any) => BuiltinDeps;\n\nconst jsExt = ['.js', '.jsx', '.cjs', '.mjs'];\n\nconst extToType = {\n '.css': 'css',\n '.sass': 'sass',\n '.less': 'less',\n '.scss': 'scss',\n '.styl': 'stylus',\n '.mts': 'ts',\n '.cts': 'ts',\n '.ts': 'ts',\n '.tsx': 'ts',\n};\n\nconst typeToDetective: Record<string, Detective> = {\n css: detectiveCss,\n sass: detectiveSass,\n less: detectiveLess,\n scss: detectiveScss,\n stylus: detectiveStylus,\n ts: detectiveTypeScript,\n commonjs: detectiveEs6,\n es6: detectiveEs6,\n amd: detectiveAmd,\n};\n\nconst debug = require('debug')('precinct');\n\nconst detectorHook = new DetectorHook();\n\nconst assign = (o1, o2) => {\n // eslint-disable-next-line\n for (const key in o2) {\n // eslint-disable-next-line\n if (o2.hasOwnProperty(key)) {\n o1[key] = o2[key];\n }\n }\n\n return o1;\n};\n\n/**\n * Get file info from the given file path.\n */\nconst getFileInfo = (filename: string): FileInfo => {\n const ext = path.extname(filename);\n const content = fs.readFileSync(filename, 'utf8');\n return {\n ext,\n content,\n // determined later\n type: '',\n // initialized with the content\n ast: content,\n };\n};\n\n/**\n * Get the non-JS detective for the given file info.\n * The type of the file would be determined as well.\n * Return undefined if no proper detective found, perhaps it's plain\n * JavaScript or unknown content. We can deal with it later.\n */\nconst getDetector = (fileInfo: FileInfo, options?: Options): Detective | undefined => {\n const { ext } = fileInfo;\n const normalizedOptions: Options = options || {};\n\n // from env detectors\n if (options?.envDetectors) {\n for (const detector of options.envDetectors) {\n if (detector.isSupported({ ext })) {\n fileInfo.type = detector.type || '';\n return detector.detect as Detective;\n }\n }\n }\n\n // from builtin detectors\n // - check `fileInfo.type` first to support `precinct(content, { type })`\n const type = fileInfo.type || extToType[ext];\n if (typeToDetective[type]) {\n const detective = typeToDetective[type];\n fileInfo.type = type;\n // special logic for tsx files\n if (ext === '.tsx') {\n if (!normalizedOptions.ts) normalizedOptions.ts = {};\n normalizedOptions.ts.jsx = true;\n }\n return detective;\n }\n\n // from global detector hook (legacy)\n if (detectorHook.isSupported(ext)) {\n const detector = detectorHook.getDetector(ext);\n if (detector) {\n fileInfo.type = ext;\n typeToDetective[ext] = detector.detect as Detective;\n return detector.detect as Detective;\n }\n }\n\n return undefined;\n};\n\n/**\n * Get the JS detective (amd/es6/cjs) for the given file info.\n * The type and ast of the file would be determined as well.\n */\nconst getJsDetector = (fileInfo: FileInfo, options?: Options): Detective | undefined => {\n if (!jsExt.includes(fileInfo.ext)) {\n return undefined;\n }\n\n if (typeof fileInfo.content !== 'object') {\n const walker = new Walker();\n try {\n fileInfo.ast = walker.parse(fileInfo.content);\n } catch (e: any) {\n debug('could not parse content: %s', e.message);\n throw e;\n }\n }\n\n const useContent = options?.useContent;\n const type = useContent ? getModuleType.fromSource(fileInfo.content) : getModuleType.fromSource(fileInfo.ast);\n const detector = typeToDetective[type];\n fileInfo.type = type;\n\n return detector;\n};\n\n/**\n * Normalize the deps into an array.\n */\nconst normalizeDeps = (deps: BuiltinDeps, includeCore?: boolean): string[] => {\n const normalizedDeps = Array.isArray(deps) ? deps : Object.keys(deps);\n return includeCore ? normalizedDeps : normalizedDeps.filter((d) => !isBuiltin(d));\n};\n\nconst getDepsFromFile = (filename: string, options?: Options): string[] => {\n const normalizedOptions: Options = assign({ includeCore: true }, options || {});\n const fileInfo = getFileInfo(filename);\n if (\n typeof fileInfo.content === 'string' &&\n (fileInfo.content.startsWith('// @bit-no-check') || fileInfo.content.startsWith('/* @bit-no-check'))\n ) {\n debug(`skipping file ${filename}, it has a @bit-no-check comment`);\n return [];\n }\n\n const detective = getDetector(fileInfo, normalizedOptions) || getJsDetector(fileInfo, normalizedOptions);\n if (!detective) {\n debug(`skipping unsupported file ${filename}`);\n return [];\n }\n debug('module type: ', fileInfo.type);\n\n const deps = detective(fileInfo.ast, normalizedOptions[fileInfo.type]);\n\n return normalizeDeps(deps, normalizedOptions?.includeCore);\n};\n\n/**\n * Finds the list of dependencies for the given file\n *\n * @param {String|Object} content - File's content or AST\n * @param {Object} [options]\n * @param {String} [options.type] - The type of content being passed in. Useful if you want to use a non-js detective\n * @return {String[]}\n */\n// eslint-disable-next-line complexity\nconst precinct = (content: string | object, options?: string | Options): BuiltinDeps => {\n // Legacy form backCompat where type was the second parameter\n const normalizedOptions: Options = typeof options === 'string' ? { type: options } : options || {};\n const type = normalizedOptions.type || '';\n\n debug('options given: ', normalizedOptions);\n\n const fileInfo: FileInfo = {\n content,\n ast: content,\n ext: type ? '' : '.js',\n type,\n };\n\n const detective = getDetector(fileInfo, normalizedOptions) || getJsDetector(fileInfo, normalizedOptions);\n if (!detective) {\n return [];\n }\n\n const deps = detective(fileInfo.ast, normalizedOptions[fileInfo.type]);\n // @ts-ignore\n precinct.ast = detective.ast || fileInfo.ast;\n\n return deps;\n};\n\nprecinct.paperwork = getDepsFromFile;\n\nexport default precinct;\n"],"mappings":";;;;;;AAGA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,MAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,KAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAI,QAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,OAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAK,kBAAA;EAAA,MAAAL,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAG,iBAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,gBAAA;EAAA,MAAAN,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAI,eAAA,YAAAA,CAAA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AI,EAAElB,iBAAiB,EAAEmB,WAAW,CAAC;AAC5D,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMW,QAAQ,GAAGA,CAACtC,OAAwB,EAAEO,OAA0B,KAAkB;EACtF;EACA,MAAMC,iBAA0B,GAAG,OAAOD,OAAO,KAAK,QAAQ,GAAG;IAAEJ,IAAI,EAAEI;EAAQ,CAAC,GAAGA,OAAO,IAAI,CAAC,CAAC;EAClG,MAAMJ,IAAI,GAAGK,iBAAiB,CAACL,IAAI,IAAI,EAAE;EAEzChB,KAAK,CAAC,iBAAiB,EAAEqB,iBAAiB,CAAC;EAE3C,MAAMF,QAAkB,GAAG;IACzBN,OAAO;IACPI,GAAG,EAAEJ,OAAO;IACZH,GAAG,EAAEM,IAAI,GAAG,EAAE,GAAG,KAAK;IACtBA;EACF,CAAC;EAED,MAAMU,SAAS,GAAGR,WAAW,CAACC,QAAQ,EAAEE,iBAAiB,CAAC,IAAIQ,aAAa,CAACV,QAAQ,EAAEE,iBAAiB,CAAC;EACxG,IAAI,CAACK,SAAS,EAAE;IACd,OAAO,EAAE;EACX;EAEA,MAAMa,IAAI,GAAGb,SAAS,CAACP,QAAQ,CAACF,GAAG,EAAEI,iBAAiB,CAACF,QAAQ,CAACH,IAAI,CAAC,CAAC;EACtE;EACAmC,QAAQ,CAAClC,GAAG,GAAGS,SAAS,CAACT,GAAG,IAAIE,QAAQ,CAACF,GAAG;EAE5C,OAAOsB,IAAI;AACb,CAAC;AAEDY,QAAQ,CAACC,SAAS,GAAGH,eAAe;AAAC,IAAAI,QAAA,GAAAC,OAAA,CAAA3E,OAAA,GAEtBwE,QAAQ","ignoreList":[]}
1
+ {"version":3,"names":["_fsExtra","data","_interopRequireDefault","require","_path","_module","_moduleDefinition","_nodeSourceWalk","_detectiveAmd","_detectiveStylus","_nodeDepsDetectors","_stylingDepsDetectors","_stylingDepsDetectors2","_stylingDepsDetectors3","_stylingDepsDetectors4","_typescriptDepsDetectors","_detectorHook","e","__esModule","default","jsExt","extToType","typeToDetective","css","detectiveCss","sass","detectiveSass","less","detectiveLess","scss","detectiveScss","stylus","detectiveStylus","ts","detectiveTypeScript","commonjs","detectiveEs6","es6","amd","detectiveAmd","debug","detectorHook","DetectorHook","assign","o1","o2","key","hasOwnProperty","getFileInfo","filename","ext","path","extname","content","fs","readFileSync","type","ast","getDetector","fileInfo","options","normalizedOptions","envDetectors","detector","isSupported","detect","detective","jsx","undefined","getJsDetector","includes","walker","Walker","parse","message","useContent","getModuleType","fromSource","normalizeDeps","deps","includeCore","normalizedDeps","Array","isArray","Object","keys","filter","d","isBuiltin","getDepsFromFile","startsWith","precinct","paperwork","_default","exports"],"sources":["index.ts"],"sourcesContent":["/**\n * this file had been forked from https://github.com/dependents/node-precinct\n */\nimport fs from 'fs-extra';\nimport path from 'path';\n\n// @ts-ignore we currently have @types/node as v12, and this is available > 16. once updated, remove the ts-ignore\nimport { isBuiltin } from 'module';\n\nimport getModuleType from 'module-definition';\nimport Walker from 'node-source-walk';\n\nimport detectiveAmd from 'detective-amd';\nimport detectiveStylus from 'detective-stylus';\n\nimport detectiveEs6 from '@teambit/node.deps-detectors.detective-es6';\nimport detectiveCss from '@teambit/styling.deps-detectors.detective-css';\nimport detectiveLess from '@teambit/styling.deps-detectors.detective-less';\nimport detectiveSass from '@teambit/styling.deps-detectors.detective-sass';\nimport detectiveScss from '@teambit/styling.deps-detectors.detective-scss';\nimport detectiveTypeScript from '@teambit/typescript.deps-detectors.detective-typescript';\n\nimport { DependencyDetector, DetectorHook } from '../detector-hook';\n\n/**\n * The file info object.\n * - `ext` is the file extension.\n * - `content` is the input file content.\n * - `type` is the parsed file type from ext or content.\n * - `ast` is the eventually consumed content by the corresponding detective.\n */\ntype FileInfo = {\n ext: string;\n content: string | object;\n type: string;\n ast: any;\n};\n\ntype Options = {\n envDetectors?: DependencyDetector[];\n useContent?: boolean;\n includeCore?: boolean;\n type?: string;\n [lang: string]: any;\n};\n\ntype BuiltinDeps = string[] | Record<string, any>;\ntype Detective = (fileContent: string, options?: any) => BuiltinDeps;\n\nconst jsExt = ['.js', '.jsx', '.cjs', '.mjs'];\n\nconst extToType = {\n '.css': 'css',\n '.sass': 'sass',\n '.less': 'less',\n '.scss': 'scss',\n '.styl': 'stylus',\n '.mts': 'ts',\n '.cts': 'ts',\n '.ts': 'ts',\n '.tsx': 'ts',\n};\n\nconst typeToDetective: Record<string, Detective> = {\n css: detectiveCss,\n sass: detectiveSass,\n less: detectiveLess,\n scss: detectiveScss,\n stylus: detectiveStylus,\n ts: detectiveTypeScript,\n commonjs: detectiveEs6,\n es6: detectiveEs6,\n amd: detectiveAmd,\n};\n\nconst debug = require('debug')('precinct');\n\nconst detectorHook = new DetectorHook();\n\nconst assign = (o1, o2) => {\n // eslint-disable-next-line\n for (const key in o2) {\n // eslint-disable-next-line\n if (o2.hasOwnProperty(key)) {\n o1[key] = o2[key];\n }\n }\n\n return o1;\n};\n\n/**\n * Get file info from the given file path.\n */\nconst getFileInfo = (filename: string): FileInfo => {\n const ext = path.extname(filename);\n const content = fs.readFileSync(filename, 'utf8');\n return {\n ext,\n content,\n // determined later\n type: '',\n // initialized with the content\n ast: content,\n };\n};\n\n/**\n * Get the non-JS detective for the given file info.\n * The type of the file would be determined as well.\n * Return undefined if no proper detective found, perhaps it's plain\n * JavaScript or unknown content. We can deal with it later.\n */\nconst getDetector = (fileInfo: FileInfo, options?: Options): Detective | undefined => {\n const { ext } = fileInfo;\n const normalizedOptions: Options = options || {};\n\n // from env detectors\n if (options?.envDetectors) {\n for (const detector of options.envDetectors) {\n if (detector.isSupported({ ext })) {\n fileInfo.type = detector.type || '';\n return detector.detect as Detective;\n }\n }\n }\n\n // from builtin detectors\n // - check `fileInfo.type` first to support `precinct(content, { type })`\n const type = fileInfo.type || extToType[ext];\n if (typeToDetective[type]) {\n const detective = typeToDetective[type];\n fileInfo.type = type;\n // special logic for tsx files\n if (ext === '.tsx') {\n if (!normalizedOptions.ts) normalizedOptions.ts = {};\n normalizedOptions.ts.jsx = true;\n }\n return detective;\n }\n\n // from global detector hook (legacy)\n if (detectorHook.isSupported(ext)) {\n const detector = detectorHook.getDetector(ext);\n if (detector) {\n fileInfo.type = ext;\n typeToDetective[ext] = detector.detect as Detective;\n return detector.detect as Detective;\n }\n }\n\n return undefined;\n};\n\n/**\n * Get the JS detective (amd/es6/cjs) for the given file info.\n * The type and ast of the file would be determined as well.\n */\nconst getJsDetector = (fileInfo: FileInfo, options?: Options): Detective | undefined => {\n if (!jsExt.includes(fileInfo.ext)) {\n return undefined;\n }\n\n if (typeof fileInfo.content !== 'object') {\n const walker = new Walker();\n try {\n fileInfo.ast = walker.parse(fileInfo.content);\n } catch (e: any) {\n debug('could not parse content: %s', e.message);\n throw e;\n }\n }\n\n const useContent = options?.useContent;\n const type = useContent ? getModuleType.fromSource(fileInfo.content) : getModuleType.fromSource(fileInfo.ast);\n const detector = typeToDetective[type];\n fileInfo.type = type;\n\n return detector;\n};\n\n/**\n * Normalize the deps into an array.\n */\nconst normalizeDeps = (deps: BuiltinDeps, includeCore?: boolean): string[] => {\n const normalizedDeps = Array.isArray(deps) ? deps : Object.keys(deps);\n return includeCore ? normalizedDeps : normalizedDeps.filter((d) => !isBuiltin(d));\n};\n\nconst getDepsFromFile = (filename: string, options?: Options): string[] => {\n const normalizedOptions: Options = assign({ includeCore: true }, options || {});\n const fileInfo = getFileInfo(filename);\n if (\n typeof fileInfo.content === 'string' &&\n (fileInfo.content.startsWith('// @bit-no-check') || fileInfo.content.startsWith('/* @bit-no-check'))\n ) {\n debug(`skipping file ${filename}, it has a @bit-no-check comment`);\n return [];\n }\n\n const detective = getDetector(fileInfo, normalizedOptions) || getJsDetector(fileInfo, normalizedOptions);\n if (!detective) {\n debug(`skipping unsupported file ${filename}`);\n return [];\n }\n debug('module type: ', fileInfo.type);\n\n const deps = detective(fileInfo.ast, normalizedOptions[fileInfo.type]);\n\n return normalizeDeps(deps, normalizedOptions?.includeCore);\n};\n\n/**\n * Finds the list of dependencies for the given file\n *\n * @param {String|Object} content - File's content or AST\n * @param {Object} [options]\n * @param {String} [options.type] - The type of content being passed in. Useful if you want to use a non-js detective\n * @return {String[]}\n */\n// eslint-disable-next-line complexity\nconst precinct = (content: string | object, options?: string | Options): BuiltinDeps => {\n // Legacy form backCompat where type was the second parameter\n const normalizedOptions: Options = typeof options === 'string' ? { type: options } : options || {};\n const type = normalizedOptions.type || '';\n\n debug('options given: ', normalizedOptions);\n\n const fileInfo: FileInfo = {\n content,\n ast: content,\n ext: type ? '' : '.js',\n type,\n };\n\n const detective = getDetector(fileInfo, normalizedOptions) || getJsDetector(fileInfo, normalizedOptions);\n if (!detective) {\n return [];\n }\n\n const deps = detective(fileInfo.ast, normalizedOptions[fileInfo.type]);\n // @ts-ignore\n precinct.ast = detective.ast || fileInfo.ast;\n\n return deps;\n};\n\nprecinct.paperwork = getDepsFromFile;\n\nexport default precinct;\n"],"mappings":";;;;;;AAGA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,MAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,KAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAI,QAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,OAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAK,kBAAA;EAAA,MAAAL,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAG,iBAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,gBAAA;EAAA,MAAAN,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAI,eAAA,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Aa,CAACC,IAAI,EAAElB,iBAAiB,EAAEmB,WAAW,CAAC;AAC5D,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMW,QAAQ,GAAGA,CAACtC,OAAwB,EAAEO,OAA0B,KAAkB;EACtF;EACA,MAAMC,iBAA0B,GAAG,OAAOD,OAAO,KAAK,QAAQ,GAAG;IAAEJ,IAAI,EAAEI;EAAQ,CAAC,GAAGA,OAAO,IAAI,CAAC,CAAC;EAClG,MAAMJ,IAAI,GAAGK,iBAAiB,CAACL,IAAI,IAAI,EAAE;EAEzChB,KAAK,CAAC,iBAAiB,EAAEqB,iBAAiB,CAAC;EAE3C,MAAMF,QAAkB,GAAG;IACzBN,OAAO;IACPI,GAAG,EAAEJ,OAAO;IACZH,GAAG,EAAEM,IAAI,GAAG,EAAE,GAAG,KAAK;IACtBA;EACF,CAAC;EAED,MAAMU,SAAS,GAAGR,WAAW,CAACC,QAAQ,EAAEE,iBAAiB,CAAC,IAAIQ,aAAa,CAACV,QAAQ,EAAEE,iBAAiB,CAAC;EACxG,IAAI,CAACK,SAAS,EAAE;IACd,OAAO,EAAE;EACX;EAEA,MAAMa,IAAI,GAAGb,SAAS,CAACP,QAAQ,CAACF,GAAG,EAAEI,iBAAiB,CAACF,QAAQ,CAACH,IAAI,CAAC,CAAC;EACtE;EACAmC,QAAQ,CAAClC,GAAG,GAAGS,SAAS,CAACT,GAAG,IAAIE,QAAQ,CAACF,GAAG;EAE5C,OAAOsB,IAAI;AACb,CAAC;AAEDY,QAAQ,CAACC,SAAS,GAAGH,eAAe;AAAC,IAAAI,QAAA,GAAAC,OAAA,CAAA3E,OAAA,GAEtBwE,QAAQ","ignoreList":[]}
@@ -45,7 +45,7 @@ type Options = {
45
45
  };
46
46
 
47
47
  type BuiltinDeps = string[] | Record<string, any>;
48
- type Detective = (fileContent: string | object, options?: any) => BuiltinDeps;
48
+ type Detective = (fileContent: string, options?: any) => BuiltinDeps;
49
49
 
50
50
  const jsExt = ['.js', '.jsx', '.cjs', '.mjs'];
51
51
 
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/dependencies",
3
- "version": "1.0.410",
3
+ "version": "1.0.412",
4
4
  "homepage": "https://bit.cloud/teambit/dependencies/dependencies",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.dependencies",
8
8
  "name": "dependencies",
9
- "version": "1.0.410"
9
+ "version": "1.0.412"
10
10
  },
11
11
  "dependencies": {
12
12
  "archy": "1.0.0",
@@ -30,34 +30,33 @@
30
30
  "@teambit/component-id": "1.2.0",
31
31
  "@teambit/bit-error": "0.0.404",
32
32
  "@teambit/component-version": "1.0.3",
33
- "@teambit/styling.deps-lookups.lookup-styling": "0.0.2",
33
+ "@teambit/styling.deps-lookups.lookup-styling": "0.0.4",
34
34
  "@teambit/typescript.deps-lookups.lookup-typescript": "0.0.2",
35
35
  "@teambit/node.deps-detectors.detective-es6": "0.0.5",
36
- "@teambit/styling.deps-detectors.detective-css": "0.0.4",
37
- "@teambit/styling.deps-detectors.detective-less": "0.0.4",
38
- "@teambit/styling.deps-detectors.detective-sass": "0.0.7",
39
- "@teambit/styling.deps-detectors.detective-scss": "0.0.7",
36
+ "@teambit/styling.deps-detectors.detective-css": "0.0.6",
37
+ "@teambit/styling.deps-detectors.detective-less": "0.0.6",
38
+ "@teambit/styling.deps-detectors.detective-sass": "0.0.9",
39
+ "@teambit/styling.deps-detectors.detective-scss": "0.0.9",
40
40
  "@teambit/typescript.deps-detectors.detective-typescript": "0.0.6",
41
- "@teambit/cli": "0.0.987",
42
- "@teambit/graph": "1.0.410",
43
- "@teambit/aspect-loader": "1.0.410",
41
+ "@teambit/cli": "0.0.989",
42
+ "@teambit/graph": "1.0.412",
43
+ "@teambit/aspect-loader": "1.0.412",
44
44
  "@teambit/component-package-version": "0.0.434",
45
- "@teambit/dependency-resolver": "1.0.410",
46
- "@teambit/dev-files": "1.0.410",
47
- "@teambit/scope": "1.0.410",
48
- "@teambit/workspace": "1.0.410",
49
- "@teambit/component.sources": "0.0.29",
45
+ "@teambit/dependency-resolver": "1.0.412",
46
+ "@teambit/dev-files": "1.0.412",
47
+ "@teambit/scope": "1.0.412",
48
+ "@teambit/workspace": "1.0.412",
49
+ "@teambit/component.sources": "0.0.30",
50
50
  "@teambit/legacy.utils": "0.0.5",
51
51
  "@teambit/toolbox.path.path": "0.0.4",
52
52
  "@teambit/component-issues": "0.0.150",
53
- "@teambit/legacy.bit-map": "0.0.33",
53
+ "@teambit/legacy.bit-map": "0.0.34",
54
54
  "@teambit/toolbox.fs.extension-getter": "0.0.1",
55
55
  "@teambit/toolbox.fs.last-modified": "0.0.1"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@types/cli-table": "^0.3.0",
59
59
  "@types/lodash": "4.14.165",
60
- "@types/chai": "4.2.15",
61
60
  "chai": "4.3.0",
62
61
  "@types/fs-extra": "9.0.7",
63
62
  "@types/semver": "7.3.4",
@@ -65,12 +64,13 @@
65
64
  "sinon": "17.0.1",
66
65
  "@types/mocha": "9.1.0",
67
66
  "@teambit/defender.fs.global-bit-temp-dir": "0.0.1",
68
- "@teambit/harmony.envs.core-aspect-env": "0.0.47",
69
- "@teambit/component.testing.mock-components": "0.0.235",
70
- "@teambit/harmony.testing.load-aspect": "0.0.230",
67
+ "@teambit/harmony.envs.core-aspect-env": "0.0.59",
68
+ "@teambit/component.testing.mock-components": "0.0.236",
69
+ "@teambit/harmony.testing.load-aspect": "0.0.231",
71
70
  "@teambit/workspace.testing.mock-workspace": "0.0.27"
72
71
  },
73
72
  "peerDependencies": {
73
+ "@types/chai": "4.3.19",
74
74
  "@teambit/legacy": "1.0.624"
75
75
  },
76
76
  "license": "Apache-2.0",