@teambit/dependencies 1.0.449 → 1.0.450

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.
@@ -34,6 +34,7 @@ type FileInfo = {
34
34
  content: string | object;
35
35
  type: string;
36
36
  ast: any;
37
+ filename: string;
37
38
  };
38
39
 
39
40
  type Options = {
@@ -102,6 +103,7 @@ const getFileInfo = (filename: string): FileInfo => {
102
103
  type: '',
103
104
  // initialized with the content
104
105
  ast: content,
106
+ filename,
105
107
  };
106
108
  };
107
109
 
@@ -112,13 +114,13 @@ const getFileInfo = (filename: string): FileInfo => {
112
114
  * JavaScript or unknown content. We can deal with it later.
113
115
  */
114
116
  const getDetector = (fileInfo: FileInfo, options?: Options): Detective | undefined => {
115
- const { ext } = fileInfo;
117
+ const { ext, filename } = fileInfo;
116
118
  const normalizedOptions: Options = options || {};
117
119
 
118
120
  // from env detectors
119
121
  if (options?.envDetectors) {
120
122
  for (const detector of options.envDetectors) {
121
- if (detector.isSupported({ ext })) {
123
+ if (detector.isSupported({ ext, filename })) {
122
124
  fileInfo.type = detector.type || '';
123
125
  return detector.detect as Detective;
124
126
  }
@@ -140,8 +142,8 @@ const getDetector = (fileInfo: FileInfo, options?: Options): Detective | undefin
140
142
  }
141
143
 
142
144
  // from global detector hook (legacy)
143
- if (detectorHook.isSupported(ext)) {
144
- const detector = detectorHook.getDetector(ext);
145
+ if (detectorHook.isSupported(ext, filename)) {
146
+ const detector = detectorHook.getDetector(ext, filename);
145
147
  if (detector) {
146
148
  fileInfo.type = ext;
147
149
  typeToDetective[ext] = detector.detect as Detective;
@@ -210,41 +212,8 @@ const getDepsFromFile = (filename: string, options?: Options): string[] => {
210
212
  return normalizeDeps(deps, normalizedOptions?.includeCore);
211
213
  };
212
214
 
213
- /**
214
- * Finds the list of dependencies for the given file
215
- *
216
- * @param {String|Object} content - File's content or AST
217
- * @param {Object} [options]
218
- * @param {String} [options.type] - The type of content being passed in. Useful if you want to use a non-js detective
219
- * @return {String[]}
220
- */
221
- // eslint-disable-next-line complexity
222
- const precinct = (content: string | object, options?: string | Options): BuiltinDeps => {
223
- // Legacy form backCompat where type was the second parameter
224
- const normalizedOptions: Options = typeof options === 'string' ? { type: options } : options || {};
225
- const type = normalizedOptions.type || '';
226
-
227
- debug('options given: ', normalizedOptions);
228
-
229
- const fileInfo: FileInfo = {
230
- content,
231
- ast: content,
232
- ext: type ? '' : '.js',
233
- type,
234
- };
235
-
236
- const detective = getDetector(fileInfo, normalizedOptions) || getJsDetector(fileInfo, normalizedOptions);
237
- if (!detective) {
238
- return [];
239
- }
240
-
241
- const deps = detective(fileInfo.ast, normalizedOptions[fileInfo.type]);
242
- // @ts-ignore
243
- precinct.ast = detective.ast || fileInfo.ast;
244
-
245
- return deps;
215
+ const precinct = {
216
+ paperwork: getDepsFromFile,
246
217
  };
247
218
 
248
- precinct.paperwork = getDepsFromFile;
249
-
250
219
  export default precinct;
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/dependencies",
3
- "version": "1.0.449",
3
+ "version": "1.0.450",
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.449"
9
+ "version": "1.0.450"
10
10
  },
11
11
  "dependencies": {
12
12
  "archy": "1.0.0",
@@ -38,20 +38,20 @@
38
38
  "@teambit/styling.deps-detectors.detective-sass": "0.0.9",
39
39
  "@teambit/styling.deps-detectors.detective-scss": "0.0.9",
40
40
  "@teambit/typescript.deps-detectors.detective-typescript": "0.0.8",
41
- "@teambit/cli": "0.0.1026",
42
- "@teambit/graph": "1.0.449",
43
- "@teambit/aspect-loader": "1.0.449",
41
+ "@teambit/cli": "0.0.1027",
42
+ "@teambit/graph": "1.0.450",
43
+ "@teambit/aspect-loader": "1.0.450",
44
44
  "@teambit/component-package-version": "0.0.434",
45
- "@teambit/dependency-resolver": "1.0.449",
46
- "@teambit/dev-files": "1.0.449",
47
- "@teambit/logger": "0.0.1119",
48
- "@teambit/scope": "1.0.449",
49
- "@teambit/workspace": "1.0.449",
50
- "@teambit/component.sources": "0.0.41",
45
+ "@teambit/dependency-resolver": "1.0.450",
46
+ "@teambit/dev-files": "1.0.450",
47
+ "@teambit/logger": "0.0.1120",
48
+ "@teambit/scope": "1.0.450",
49
+ "@teambit/workspace": "1.0.450",
50
+ "@teambit/component.sources": "0.0.42",
51
51
  "@teambit/legacy.utils": "0.0.6",
52
52
  "@teambit/toolbox.path.path": "0.0.4",
53
53
  "@teambit/component-issues": "0.0.151",
54
- "@teambit/legacy.bit-map": "0.0.45",
54
+ "@teambit/legacy.bit-map": "0.0.46",
55
55
  "@teambit/toolbox.fs.extension-getter": "0.0.1",
56
56
  "@teambit/toolbox.fs.last-modified": "0.0.1"
57
57
  },
@@ -66,8 +66,8 @@
66
66
  "@types/mocha": "9.1.0",
67
67
  "@teambit/defender.fs.global-bit-temp-dir": "0.0.1",
68
68
  "@teambit/harmony.envs.core-aspect-env": "0.0.60",
69
- "@teambit/component.testing.mock-components": "0.0.247",
70
- "@teambit/harmony.testing.load-aspect": "0.0.242",
69
+ "@teambit/component.testing.mock-components": "0.0.248",
70
+ "@teambit/harmony.testing.load-aspect": "0.0.243",
71
71
  "@teambit/workspace.testing.mock-workspace": "0.0.27"
72
72
  },
73
73
  "peerDependencies": {