@davidwells/extract-deps 0.0.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 (59) hide show
  1. package/README.md +211 -0
  2. package/_usage.js +175 -0
  3. package/examples/get-exports.js +31 -0
  4. package/package.json +27 -0
  5. package/src/detect-syntax.js +70 -0
  6. package/src/get-exports.js +299 -0
  7. package/src/get-imports.js +165 -0
  8. package/src/get-requires.js +104 -0
  9. package/src/index.js +90 -0
  10. package/src/utils.js +64 -0
  11. package/tests/detect-syntax.test.js +280 -0
  12. package/tests/get-exports.test.js +346 -0
  13. package/tests/get-imports.test.js +395 -0
  14. package/tests/get-requires.test.js +201 -0
  15. package/tests/index.test.js +202 -0
  16. package/tests/test-utils.js +30 -0
  17. package/tsconfig.json +19 -0
  18. package/types/detect-syntax.d.ts +39 -0
  19. package/types/detect-syntax.d.ts.map +1 -0
  20. package/types/extract-deps/_usage.d.ts +20 -0
  21. package/types/extract-deps/_usage.d.ts.map +1 -0
  22. package/types/extract-deps/examples/get-exports.d.ts +2 -0
  23. package/types/extract-deps/examples/get-exports.d.ts.map +1 -0
  24. package/types/extract-deps/src/detect-syntax.d.ts +39 -0
  25. package/types/extract-deps/src/detect-syntax.d.ts.map +1 -0
  26. package/types/extract-deps/src/get-exports.d.ts +52 -0
  27. package/types/extract-deps/src/get-exports.d.ts.map +1 -0
  28. package/types/extract-deps/src/get-imports.d.ts +53 -0
  29. package/types/extract-deps/src/get-imports.d.ts.map +1 -0
  30. package/types/extract-deps/src/get-requires.d.ts +34 -0
  31. package/types/extract-deps/src/get-requires.d.ts.map +1 -0
  32. package/types/extract-deps/src/index.d.ts +39 -0
  33. package/types/extract-deps/src/index.d.ts.map +1 -0
  34. package/types/extract-deps/src/utils.d.ts +4 -0
  35. package/types/extract-deps/src/utils.d.ts.map +1 -0
  36. package/types/extract-deps/tests/detect-syntax.test.d.ts +2 -0
  37. package/types/extract-deps/tests/detect-syntax.test.d.ts.map +1 -0
  38. package/types/extract-deps/tests/get-exports.test.d.ts +2 -0
  39. package/types/extract-deps/tests/get-exports.test.d.ts.map +1 -0
  40. package/types/extract-deps/tests/get-imports.test.d.ts +2 -0
  41. package/types/extract-deps/tests/get-imports.test.d.ts.map +1 -0
  42. package/types/extract-deps/tests/get-requires.test.d.ts +2 -0
  43. package/types/extract-deps/tests/get-requires.test.d.ts.map +1 -0
  44. package/types/extract-deps/tests/index.test.d.ts +18 -0
  45. package/types/extract-deps/tests/index.test.d.ts.map +1 -0
  46. package/types/extract-deps/tests/test-utils.d.ts +9 -0
  47. package/types/extract-deps/tests/test-utils.d.ts.map +1 -0
  48. package/types/get-exports.d.ts +52 -0
  49. package/types/get-exports.d.ts.map +1 -0
  50. package/types/get-imports.d.ts +53 -0
  51. package/types/get-imports.d.ts.map +1 -0
  52. package/types/get-requires.d.ts +34 -0
  53. package/types/get-requires.d.ts.map +1 -0
  54. package/types/index.d.ts +39 -0
  55. package/types/index.d.ts.map +1 -0
  56. package/types/packages-list/index.d.ts +138 -0
  57. package/types/packages-list/index.d.ts.map +1 -0
  58. package/types/utils.d.ts +4 -0
  59. package/types/utils.d.ts.map +1 -0
@@ -0,0 +1,52 @@
1
+ export function getExports(code: any, options?: {}): any[];
2
+ export function getDefaultExports(targetText?: string): {
3
+ line: string;
4
+ exportType: string;
5
+ exportName: any;
6
+ exportValue: string;
7
+ index: number;
8
+ isExport: boolean;
9
+ }[];
10
+ export function getNamedExports(targetText?: string): {
11
+ line: string;
12
+ exportType: string;
13
+ exportName: string;
14
+ index: number;
15
+ isExport: boolean;
16
+ }[];
17
+ export function getNamedDeclarationExports(targetText?: string): any[];
18
+ export function getAllExports(targetText?: string): {
19
+ line: string;
20
+ exportType: string;
21
+ from: string;
22
+ index: number;
23
+ isExport: boolean;
24
+ }[];
25
+ export function getNamespaceExports(targetText?: string): {
26
+ line: string;
27
+ exportType: string;
28
+ namespace: string;
29
+ from: string;
30
+ index: number;
31
+ isExport: boolean;
32
+ }[];
33
+ export function getTypeExports(targetText?: string): {
34
+ line: string;
35
+ exportType: string;
36
+ exportName: string;
37
+ index: number;
38
+ isExport: boolean;
39
+ }[];
40
+ export function getAssertionExports(targetText?: string): {
41
+ line: string;
42
+ exportType: string;
43
+ exportName: string;
44
+ definitions: any;
45
+ from: string;
46
+ assertion: string;
47
+ assertionType: string;
48
+ index: number;
49
+ isExport: boolean;
50
+ isAssertion: boolean;
51
+ }[];
52
+ //# sourceMappingURL=get-exports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-exports.d.ts","sourceRoot":"","sources":["../src/get-exports.js"],"names":[],"mappings":"AAiBA,2DAsBC;AAED;;;;;;;IA4BC;AAED;;;;;;IAeC;AAED,uEAmBC;AAED;;;;;;IAeC;AAED;;;;;;;IAgBC;AAED;;;;;;IAeC;AAED;;;;;;;;;;;IAuBC"}
@@ -0,0 +1,53 @@
1
+ export function getImports(code: any, options?: {}): {
2
+ line: string;
3
+ varType: string;
4
+ varName: string;
5
+ definitions: any;
6
+ from: string;
7
+ index: number;
8
+ isImport: boolean;
9
+ isRelative: boolean;
10
+ }[];
11
+ export function getStaticImports(targetText?: string): {
12
+ line: string;
13
+ varType: string;
14
+ varName: string;
15
+ definitions: any;
16
+ from: string;
17
+ index: number;
18
+ isImport: boolean;
19
+ isRelative: boolean;
20
+ }[];
21
+ export function getTypeImports(targetText?: string): {
22
+ importStatement: string;
23
+ importPath: string;
24
+ importName: string;
25
+ index: number;
26
+ isImport: boolean;
27
+ isRelative: boolean;
28
+ }[];
29
+ export function getDynamicImports(targetText?: string): {
30
+ line: string;
31
+ varType: string;
32
+ varName: string;
33
+ definitions: any;
34
+ from: string;
35
+ index: number;
36
+ isImport: boolean;
37
+ isRelative: boolean;
38
+ isDynamic: boolean;
39
+ }[];
40
+ export function getAssertionImports(targetText?: string): {
41
+ line: string;
42
+ varType: string;
43
+ varName: string;
44
+ definitions: any;
45
+ from: string;
46
+ assertion: string;
47
+ assertionType: string;
48
+ index: number;
49
+ isImport: boolean;
50
+ isRelative: boolean;
51
+ isAssertion: boolean;
52
+ }[];
53
+ //# sourceMappingURL=get-imports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-imports.d.ts","sourceRoot":"","sources":["../src/get-imports.js"],"names":[],"mappings":"AAWA;;;;;;;;;IAQC;AAGD;;;;;;;;;IAkBC;AAED;;;;;;;IAgBC;AAED;;;;;;;;;;IAoBC;AAED;;;;;;;;;;;;IAwBC"}
@@ -0,0 +1,34 @@
1
+ export function getRequires(code: any): {
2
+ line: string;
3
+ varType: string;
4
+ varName: string;
5
+ definitions: any;
6
+ from: string;
7
+ index: number;
8
+ isRequire: boolean;
9
+ isRelative: boolean;
10
+ isDynamic: boolean;
11
+ }[];
12
+ export function getStaticRequires(targetText?: string): {
13
+ line: string;
14
+ varType: string;
15
+ varName: string;
16
+ definitions: any;
17
+ from: string;
18
+ index: number;
19
+ isRequire: boolean;
20
+ isRelative: boolean;
21
+ isDynamic: boolean;
22
+ }[];
23
+ export function getDynamicRequires(code: any): {
24
+ line: string;
25
+ varType: string;
26
+ varName: string;
27
+ definitions: any;
28
+ from: string;
29
+ index: number;
30
+ isRequire: boolean;
31
+ isRelative: boolean;
32
+ isDynamic: boolean;
33
+ }[];
34
+ //# sourceMappingURL=get-requires.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-requires.d.ts","sourceRoot":"","sources":["../src/get-requires.js"],"names":[],"mappings":"AA8DA;;;;;;;;;;IAIC;AA5BD;;;;;;;;;;IAsBC;AArDD;;;;;;;;;;IA4BC"}
@@ -0,0 +1,39 @@
1
+ export function extractDeps(code: any): {
2
+ imports: {
3
+ line: string;
4
+ varType: string;
5
+ varName: string;
6
+ definitions: any;
7
+ from: string;
8
+ index: number;
9
+ isImport: boolean;
10
+ isRelative: boolean;
11
+ }[];
12
+ requires: {
13
+ line: string;
14
+ varType: string;
15
+ varName: string;
16
+ definitions: any;
17
+ from: string;
18
+ index: number;
19
+ isRequire: boolean;
20
+ isRelative: boolean;
21
+ isDynamic: boolean;
22
+ }[];
23
+ exports: any[];
24
+ };
25
+ import { getRequires } from "./get-requires";
26
+ import { getDynamicRequires } from "./get-requires";
27
+ import { getStaticRequires } from "./get-requires";
28
+ import { getImports } from "./get-imports";
29
+ import { getStaticImports } from "./get-imports";
30
+ import { getDynamicImports } from "./get-imports";
31
+ import { getExports } from "./get-exports";
32
+ import { getDefaultExports } from "./get-exports";
33
+ import { getNamedExports } from "./get-exports";
34
+ import { getNamedDeclarationExports } from "./get-exports";
35
+ import { getAllExports } from "./get-exports";
36
+ import { getNamespaceExports } from "./get-exports";
37
+ import { getTypeExports } from "./get-exports";
38
+ export { getRequires, getDynamicRequires, getStaticRequires, getImports, getStaticImports, getDynamicImports, getExports, getDefaultExports, getNamedExports, getNamedDeclarationExports, getAllExports, getNamespaceExports, getTypeExports };
39
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;;;;;;EAQC"}
@@ -0,0 +1,138 @@
1
+ export type PackagePath = {
2
+ /**
3
+ * - Relative path from root (e.g. './packages/foo/package.json')
4
+ */
5
+ relative: string;
6
+ /**
7
+ * - Clean relative path without leading ./ (e.g. 'packages/foo/package.json')
8
+ */
9
+ nice: string;
10
+ /**
11
+ * - Full absolute path to package.json
12
+ */
13
+ full: string;
14
+ };
15
+ export type PackageDir = {
16
+ /**
17
+ * - Relative directory path from root
18
+ */
19
+ relative: string;
20
+ /**
21
+ * - Clean relative directory path without leading ./
22
+ */
23
+ nice: string;
24
+ /**
25
+ * - Full absolute path to directory
26
+ */
27
+ full: string;
28
+ };
29
+ export type Package = {
30
+ /**
31
+ * - Package name from package.json
32
+ */
33
+ name: string;
34
+ /**
35
+ * - Whether this is the root package
36
+ */
37
+ isRoot: boolean;
38
+ /**
39
+ * - Package.json path information
40
+ */
41
+ path: PackagePath;
42
+ /**
43
+ * - Directory path information
44
+ */
45
+ dir: PackageDir;
46
+ /**
47
+ * - Full package.json contents
48
+ */
49
+ pkg: any;
50
+ /**
51
+ * - List of available npm scripts
52
+ */
53
+ scripts: string[];
54
+ /**
55
+ * - List of dependency names
56
+ */
57
+ deps: string[];
58
+ /**
59
+ * - List of dependencies with versions (e.g. ['lodash@4.17.21'])
60
+ */
61
+ depVersions: string[];
62
+ /**
63
+ * - List of peer dependency names
64
+ */
65
+ peerDeps: string[];
66
+ /**
67
+ * - List of peer dependencies with versions
68
+ */
69
+ peerDepVersions: string[];
70
+ /**
71
+ * - List of dev dependency names
72
+ */
73
+ devDeps: string[];
74
+ /**
75
+ * - List of dev dependencies with versions
76
+ */
77
+ devDepVersions: string[];
78
+ };
79
+ export type GetPackagesListOptions = {
80
+ /**
81
+ * - Root directory to search for packages
82
+ */
83
+ dir: string;
84
+ /**
85
+ * - Whether to search recursively
86
+ */
87
+ recursive?: boolean;
88
+ /**
89
+ * - Array of regex patterns to exclude
90
+ */
91
+ exclude?: RegExp[];
92
+ /**
93
+ * - Whether to exclude root packages (isRoot: true)
94
+ */
95
+ excludeRoot?: boolean;
96
+ };
97
+ /**
98
+ * @typedef {Object} PackagePath
99
+ * @property {string} relative - Relative path from root (e.g. './packages/foo/package.json')
100
+ * @property {string} nice - Clean relative path without leading ./ (e.g. 'packages/foo/package.json')
101
+ * @property {string} full - Full absolute path to package.json
102
+ */
103
+ /**
104
+ * @typedef {Object} PackageDir
105
+ * @property {string} relative - Relative directory path from root
106
+ * @property {string} nice - Clean relative directory path without leading ./
107
+ * @property {string} full - Full absolute path to directory
108
+ */
109
+ /**
110
+ * @typedef {Object} Package
111
+ * @property {string} name - Package name from package.json
112
+ * @property {boolean} isRoot - Whether this is the root package
113
+ * @property {PackagePath} path - Package.json path information
114
+ * @property {PackageDir} dir - Directory path information
115
+ * @property {Object} pkg - Full package.json contents
116
+ * @property {string[]} scripts - List of available npm scripts
117
+ * @property {string[]} deps - List of dependency names
118
+ * @property {string[]} depVersions - List of dependencies with versions (e.g. ['lodash@4.17.21'])
119
+ * @property {string[]} peerDeps - List of peer dependency names
120
+ * @property {string[]} peerDepVersions - List of peer dependencies with versions
121
+ * @property {string[]} devDeps - List of dev dependency names
122
+ * @property {string[]} devDepVersions - List of dev dependencies with versions
123
+ */
124
+ /**
125
+ * @typedef {Object} GetPackagesListOptions
126
+ * @property {string} dir - Root directory to search for packages
127
+ * @property {boolean} [recursive=true] - Whether to search recursively
128
+ * @property {RegExp[]} [exclude=[/node_modules/]] - Array of regex patterns to exclude
129
+ * @property {boolean} [excludeRoot=false] - Whether to exclude root packages (isRoot: true)
130
+ */
131
+ /**
132
+ * Gets a list of all packages in a directory
133
+ * @param {string|GetPackagesListOptions} dirOrOpts - Directory path or options object
134
+ * @param {Partial<GetPackagesListOptions>} [opts] - Options object
135
+ * @returns {Promise<Package[]>} Array of package information
136
+ */
137
+ export function getPackagesList(dirOrOpts: string | GetPackagesListOptions, opts?: Partial<GetPackagesListOptions>): Promise<Package[]>;
138
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../packages-list/index.js"],"names":[],"mappings":";;;;cAKc,MAAM;;;;UACN,MAAM;;;;UACN,MAAM;;;;;;cAKN,MAAM;;;;UACN,MAAM;;;;UACN,MAAM;;;;;;UAKN,MAAM;;;;YACN,OAAO;;;;UACP,WAAW;;;;SACX,UAAU;;;;;;;;aAEV,MAAM,EAAE;;;;UACR,MAAM,EAAE;;;;iBACR,MAAM,EAAE;;;;cACR,MAAM,EAAE;;;;qBACR,MAAM,EAAE;;;;aACR,MAAM,EAAE;;;;oBACR,MAAM,EAAE;;;;;;SAKR,MAAM;;;;gBACN,OAAO;;;;cACP,MAAM,EAAE;;;;kBACR,OAAO;;AAnCrB;;;;;GAKG;AAEH;;;;;GAKG;AAEH;;;;;;;;;;;;;;GAcG;AAEH;;;;;;GAMG;AAEH;;;;;GAKG;AACH,2CAJW,MAAM,GAAC,sBAAsB,SAC7B,QAAQ,sBAAsB,CAAC,GAC7B,QAAQ,OAAO,EAAE,CAAC,CA+D9B"}
@@ -0,0 +1,4 @@
1
+ export function isRelativeImport(importLocation: any): boolean;
2
+ export function isRelativeImportWithQuotes(importLocation: any): boolean;
3
+ export function getNames(names: any): any;
4
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.js"],"names":[],"mappings":"AAEA,+DAEC;AAED,yEAKC;AAED,0CA2CC"}