@nx/js 16.0.0-beta.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 (184) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE +22 -0
  3. package/README.md +63 -0
  4. package/babel.d.ts +10 -0
  5. package/babel.js +89 -0
  6. package/babel.js.map +1 -0
  7. package/executors.json +37 -0
  8. package/generators.json +52 -0
  9. package/migrations.json +60 -0
  10. package/package.json +64 -0
  11. package/src/executors/node/compat.d.ts +2 -0
  12. package/src/executors/node/compat.js +6 -0
  13. package/src/executors/node/compat.js.map +1 -0
  14. package/src/executors/node/node-with-require-overrides.d.ts +5 -0
  15. package/src/executors/node/node-with-require-overrides.js +20 -0
  16. package/src/executors/node/node-with-require-overrides.js.map +1 -0
  17. package/src/executors/node/node.impl.d.ts +8 -0
  18. package/src/executors/node/node.impl.js +184 -0
  19. package/src/executors/node/node.impl.js.map +1 -0
  20. package/src/executors/node/schema.d.ts +16 -0
  21. package/src/executors/node/schema.json +74 -0
  22. package/src/executors/swc/compat.d.ts +2 -0
  23. package/src/executors/swc/compat.js +6 -0
  24. package/src/executors/swc/compat.js.map +1 -0
  25. package/src/executors/swc/schema.json +147 -0
  26. package/src/executors/swc/swc.impl.d.ts +11 -0
  27. package/src/executors/swc/swc.impl.js +126 -0
  28. package/src/executors/swc/swc.impl.js.map +1 -0
  29. package/src/executors/tsc/compat.d.ts +2 -0
  30. package/src/executors/tsc/compat.js +6 -0
  31. package/src/executors/tsc/compat.js.map +1 -0
  32. package/src/executors/tsc/schema.json +156 -0
  33. package/src/executors/tsc/tsc.impl.d.ts +7 -0
  34. package/src/executors/tsc/tsc.impl.js +106 -0
  35. package/src/executors/tsc/tsc.impl.js.map +1 -0
  36. package/src/generators/convert-to-swc/convert-to-swc.d.ts +5 -0
  37. package/src/generators/convert-to-swc/convert-to-swc.js +62 -0
  38. package/src/generators/convert-to-swc/convert-to-swc.js.map +1 -0
  39. package/src/generators/convert-to-swc/schema.d.ts +4 -0
  40. package/src/generators/convert-to-swc/schema.json +36 -0
  41. package/src/generators/init/files/__fileName__ +20 -0
  42. package/src/generators/init/init.d.ts +5 -0
  43. package/src/generators/init/init.js +67 -0
  44. package/src/generators/init/init.js.map +1 -0
  45. package/src/generators/init/schema.d.ts +6 -0
  46. package/src/generators/init/schema.json +30 -0
  47. package/src/generators/library/files/jest-config/jest.config.__ext__ +24 -0
  48. package/src/generators/library/files/lib/README.md +19 -0
  49. package/src/generators/library/files/lib/src/index.ts__tmpl__ +1 -0
  50. package/src/generators/library/files/lib/src/lib/__fileName__.spec.ts__tmpl__ +7 -0
  51. package/src/generators/library/files/lib/src/lib/__fileName__.ts__tmpl__ +3 -0
  52. package/src/generators/library/files/lib/tsconfig.json__tmpl__ +14 -0
  53. package/src/generators/library/files/lib/tsconfig.lib.json__tmpl__ +10 -0
  54. package/src/generators/library/library.d.ts +15 -0
  55. package/src/generators/library/library.js +388 -0
  56. package/src/generators/library/library.js.map +1 -0
  57. package/src/generators/library/schema.json +134 -0
  58. package/src/index.d.ts +15 -0
  59. package/src/index.js +24 -0
  60. package/src/index.js.map +1 -0
  61. package/src/migrations/update-13-10-1/update-lib-swcrc-exclude.d.ts +2 -0
  62. package/src/migrations/update-13-10-1/update-lib-swcrc-exclude.js +32 -0
  63. package/src/migrations/update-13-10-1/update-lib-swcrc-exclude.js.map +1 -0
  64. package/src/migrations/update-13-8-5/update-node-executor.d.ts +2 -0
  65. package/src/migrations/update-13-8-5/update-node-executor.js +28 -0
  66. package/src/migrations/update-13-8-5/update-node-executor.js.map +1 -0
  67. package/src/migrations/update-13-8-5/update-swcrc.d.ts +2 -0
  68. package/src/migrations/update-13-8-5/update-swcrc.js +35 -0
  69. package/src/migrations/update-13-8-5/update-swcrc.js.map +1 -0
  70. package/src/migrations/update-14-0-0/exclude-jest-config-swcrc.d.ts +3 -0
  71. package/src/migrations/update-14-0-0/exclude-jest-config-swcrc.js +27 -0
  72. package/src/migrations/update-14-0-0/exclude-jest-config-swcrc.js.map +1 -0
  73. package/src/migrations/update-14-1-5/update-swcrc-path.d.ts +3 -0
  74. package/src/migrations/update-14-1-5/update-swcrc-path.js +30 -0
  75. package/src/migrations/update-14-1-5/update-swcrc-path.js.map +1 -0
  76. package/src/migrations/update-15-8-0/rename-swcrc-config.d.ts +2 -0
  77. package/src/migrations/update-15-8-0/rename-swcrc-config.js +81 -0
  78. package/src/migrations/update-15-8-0/rename-swcrc-config.js.map +1 -0
  79. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
  80. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +13 -0
  81. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js.map +1 -0
  82. package/src/utils/add-babel-inputs.d.ts +2 -0
  83. package/src/utils/add-babel-inputs.js +23 -0
  84. package/src/utils/add-babel-inputs.js.map +1 -0
  85. package/src/utils/assets/assets.d.ts +10 -0
  86. package/src/utils/assets/assets.js +38 -0
  87. package/src/utils/assets/assets.js.map +1 -0
  88. package/src/utils/assets/copy-assets-handler.d.ts +28 -0
  89. package/src/utils/assets/copy-assets-handler.js +155 -0
  90. package/src/utils/assets/copy-assets-handler.js.map +1 -0
  91. package/src/utils/assets/index.d.ts +16 -0
  92. package/src/utils/assets/index.js +31 -0
  93. package/src/utils/assets/index.js.map +1 -0
  94. package/src/utils/buildable-libs-utils.d.ts +32 -0
  95. package/src/utils/buildable-libs-utils.js +309 -0
  96. package/src/utils/buildable-libs-utils.js.map +1 -0
  97. package/src/utils/check-dependencies.d.ts +8 -0
  98. package/src/utils/check-dependencies.js +24 -0
  99. package/src/utils/check-dependencies.js.map +1 -0
  100. package/src/utils/code-frames/highlight.d.ts +1 -0
  101. package/src/utils/code-frames/highlight.js +87 -0
  102. package/src/utils/code-frames/highlight.js.map +1 -0
  103. package/src/utils/code-frames/identifiers.d.ts +5 -0
  104. package/src/utils/code-frames/identifiers.js +53 -0
  105. package/src/utils/code-frames/identifiers.js.map +1 -0
  106. package/src/utils/compiler-helper-dependency.d.ts +17 -0
  107. package/src/utils/compiler-helper-dependency.js +111 -0
  108. package/src/utils/compiler-helper-dependency.js.map +1 -0
  109. package/src/utils/generate-globs.d.ts +6 -0
  110. package/src/utils/generate-globs.js +81 -0
  111. package/src/utils/generate-globs.js.map +1 -0
  112. package/src/utils/inline.d.ts +19 -0
  113. package/src/utils/inline.js +211 -0
  114. package/src/utils/inline.js.map +1 -0
  115. package/src/utils/minimal-publish-script.d.ts +2 -0
  116. package/src/utils/minimal-publish-script.js +76 -0
  117. package/src/utils/minimal-publish-script.js.map +1 -0
  118. package/src/utils/package-json/index.d.ts +13 -0
  119. package/src/utils/package-json/index.js +34 -0
  120. package/src/utils/package-json/index.js.map +1 -0
  121. package/src/utils/package-json/update-package-json.d.ts +20 -0
  122. package/src/utils/package-json/update-package-json.js +142 -0
  123. package/src/utils/package-json/update-package-json.js.map +1 -0
  124. package/src/utils/prettier.d.ts +6 -0
  125. package/src/utils/prettier.js +38 -0
  126. package/src/utils/prettier.js.map +1 -0
  127. package/src/utils/schema.d.ts +81 -0
  128. package/src/utils/swc/add-swc-config.d.ts +3 -0
  129. package/src/utils/swc/add-swc-config.js +44 -0
  130. package/src/utils/swc/add-swc-config.js.map +1 -0
  131. package/src/utils/swc/add-swc-dependencies.d.ts +2 -0
  132. package/src/utils/swc/add-swc-dependencies.js +15 -0
  133. package/src/utils/swc/add-swc-dependencies.js.map +1 -0
  134. package/src/utils/swc/compile-swc.d.ts +13 -0
  135. package/src/utils/swc/compile-swc.js +161 -0
  136. package/src/utils/swc/compile-swc.js.map +1 -0
  137. package/src/utils/swc/get-swcrc-path.d.ts +2 -0
  138. package/src/utils/swc/get-swcrc-path.js +14 -0
  139. package/src/utils/swc/get-swcrc-path.js.map +1 -0
  140. package/src/utils/swc/inline.d.ts +2 -0
  141. package/src/utils/swc/inline.js +13 -0
  142. package/src/utils/swc/inline.js.map +1 -0
  143. package/src/utils/typescript/__mocks__/plugin-a.d.ts +1 -0
  144. package/src/utils/typescript/__mocks__/plugin-a.js +6 -0
  145. package/src/utils/typescript/__mocks__/plugin-a.js.map +1 -0
  146. package/src/utils/typescript/__mocks__/plugin-b.d.ts +1 -0
  147. package/src/utils/typescript/__mocks__/plugin-b.js +6 -0
  148. package/src/utils/typescript/__mocks__/plugin-b.js.map +1 -0
  149. package/src/utils/typescript/ast-utils.d.ts +22 -0
  150. package/src/utils/typescript/ast-utils.js +199 -0
  151. package/src/utils/typescript/ast-utils.js.map +1 -0
  152. package/src/utils/typescript/compile-typescript-files.d.ts +10 -0
  153. package/src/utils/typescript/compile-typescript-files.js +45 -0
  154. package/src/utils/typescript/compile-typescript-files.js.map +1 -0
  155. package/src/utils/typescript/create-ts-config.d.ts +17 -0
  156. package/src/utils/typescript/create-ts-config.js +48 -0
  157. package/src/utils/typescript/create-ts-config.js.map +1 -0
  158. package/src/utils/typescript/ensure-typescript.d.ts +1 -0
  159. package/src/utils/typescript/ensure-typescript.js +10 -0
  160. package/src/utils/typescript/ensure-typescript.js.map +1 -0
  161. package/src/utils/typescript/get-source-nodes.d.ts +2 -0
  162. package/src/utils/typescript/get-source-nodes.js +19 -0
  163. package/src/utils/typescript/get-source-nodes.js.map +1 -0
  164. package/src/utils/typescript/load-ts-transformers.d.ts +5 -0
  165. package/src/utils/typescript/load-ts-transformers.js +63 -0
  166. package/src/utils/typescript/load-ts-transformers.js.map +1 -0
  167. package/src/utils/typescript/print-diagnostics.d.ts +1 -0
  168. package/src/utils/typescript/print-diagnostics.js +22 -0
  169. package/src/utils/typescript/print-diagnostics.js.map +1 -0
  170. package/src/utils/typescript/run-type-check.d.ts +32 -0
  171. package/src/utils/typescript/run-type-check.js +125 -0
  172. package/src/utils/typescript/run-type-check.js.map +1 -0
  173. package/src/utils/typescript/ts-config.d.ts +6 -0
  174. package/src/utils/typescript/ts-config.js +50 -0
  175. package/src/utils/typescript/ts-config.js.map +1 -0
  176. package/src/utils/typescript/types.d.ts +18 -0
  177. package/src/utils/typescript/types.js +3 -0
  178. package/src/utils/typescript/types.js.map +1 -0
  179. package/src/utils/versions.d.ts +8 -0
  180. package/src/utils/versions.js +13 -0
  181. package/src/utils/versions.js.map +1 -0
  182. package/src/utils/watch-for-single-file-changes.d.ts +1 -0
  183. package/src/utils/watch-for-single-file-changes.js +27 -0
  184. package/src/utils/watch-for-single-file-changes.js.map +1 -0
@@ -0,0 +1,22 @@
1
+ import type { Tree } from '@nx/devkit';
2
+ import type * as ts from 'typescript';
3
+ export declare function insertChange(host: Tree, sourceFile: ts.SourceFile, filePath: string, insertPosition: number, contentToInsert: string): ts.SourceFile;
4
+ export declare function replaceChange(host: Tree, sourceFile: ts.SourceFile, filePath: string, insertPosition: number, contentToInsert: string, oldContent: string): ts.SourceFile;
5
+ export declare function removeChange(host: Tree, sourceFile: ts.SourceFile, filePath: string, removePosition: number, contentToRemove: string): ts.SourceFile;
6
+ export declare function insertImport(host: Tree, source: ts.SourceFile, fileToEdit: string, symbolName: string, fileName: string, isDefault?: boolean): ts.SourceFile;
7
+ export declare function addGlobal(host: Tree, source: ts.SourceFile, modulePath: string, statement: string): ts.SourceFile;
8
+ export declare function getImport(source: ts.SourceFile, predicate: (a: any) => boolean): {
9
+ moduleSpec: string;
10
+ bindings: string[];
11
+ }[];
12
+ export declare function replaceNodeValue(host: Tree, sourceFile: ts.SourceFile, modulePath: string, node: ts.Node, content: string): ts.SourceFile;
13
+ export declare function addParameterToConstructor(tree: Tree, source: ts.SourceFile, modulePath: string, opts: {
14
+ className: string;
15
+ param: string;
16
+ }): ts.SourceFile;
17
+ export declare function addMethod(tree: Tree, source: ts.SourceFile, modulePath: string, opts: {
18
+ className: string;
19
+ methodHeader: string;
20
+ body?: string;
21
+ }): ts.SourceFile;
22
+ export declare function findClass(source: ts.SourceFile, className: string, silent?: boolean): ts.ClassDeclaration;
@@ -0,0 +1,199 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.findClass = exports.addMethod = exports.addParameterToConstructor = exports.replaceNodeValue = exports.getImport = exports.addGlobal = exports.insertImport = exports.removeChange = exports.replaceChange = exports.insertChange = void 0;
4
+ // TODO(colum): replace when https://github.com/nrwl/nx/pull/15497 is merged
5
+ const typescript_1 = require("@nx/workspace/src/utilities/typescript");
6
+ const typescript_2 = require("nx/src/utils/typescript");
7
+ const ensure_typescript_1 = require("./ensure-typescript");
8
+ let tsModule;
9
+ function nodesByPosition(first, second) {
10
+ return first.getStart() - second.getStart();
11
+ }
12
+ function updateTsSourceFile(host, sourceFile, filePath) {
13
+ const newFileContents = host.read(filePath).toString('utf-8');
14
+ return sourceFile.update(newFileContents, {
15
+ newLength: newFileContents.length,
16
+ span: {
17
+ length: sourceFile.text.length,
18
+ start: 0,
19
+ },
20
+ });
21
+ }
22
+ function insertChange(host, sourceFile, filePath, insertPosition, contentToInsert) {
23
+ const content = host.read(filePath).toString();
24
+ const prefix = content.substring(0, insertPosition);
25
+ const suffix = content.substring(insertPosition);
26
+ host.write(filePath, `${prefix}${contentToInsert}${suffix}`);
27
+ return updateTsSourceFile(host, sourceFile, filePath);
28
+ }
29
+ exports.insertChange = insertChange;
30
+ function replaceChange(host, sourceFile, filePath, insertPosition, contentToInsert, oldContent) {
31
+ const content = host.read(filePath, 'utf-8');
32
+ const prefix = content.substring(0, insertPosition);
33
+ const suffix = content.substring(insertPosition + oldContent.length);
34
+ const text = content.substring(insertPosition, insertPosition + oldContent.length);
35
+ if (text !== oldContent) {
36
+ throw new Error(`Invalid replace: "${text}" != "${oldContent}".`);
37
+ }
38
+ host.write(filePath, `${prefix}${contentToInsert}${suffix}`);
39
+ return updateTsSourceFile(host, sourceFile, filePath);
40
+ }
41
+ exports.replaceChange = replaceChange;
42
+ function removeChange(host, sourceFile, filePath, removePosition, contentToRemove) {
43
+ const content = host.read(filePath).toString();
44
+ const prefix = content.substring(0, removePosition);
45
+ const suffix = content.substring(removePosition + contentToRemove.length);
46
+ host.write(filePath, `${prefix}${suffix}`);
47
+ return updateTsSourceFile(host, sourceFile, filePath);
48
+ }
49
+ exports.removeChange = removeChange;
50
+ function insertImport(host, source, fileToEdit, symbolName, fileName, isDefault = false) {
51
+ if (!tsModule) {
52
+ tsModule = (0, ensure_typescript_1.ensureTypescript)();
53
+ }
54
+ const rootNode = source;
55
+ const allImports = (0, typescript_2.findNodes)(rootNode, tsModule.SyntaxKind.ImportDeclaration);
56
+ // get nodes that map to import statements from the file fileName
57
+ const relevantImports = allImports.filter((node) => {
58
+ // StringLiteral of the ImportDeclaration is the import file (fileName in this case).
59
+ const importFiles = node
60
+ .getChildren()
61
+ .filter((child) => child.kind === tsModule.SyntaxKind.StringLiteral)
62
+ .map((n) => n.text);
63
+ return importFiles.filter((file) => file === fileName).length === 1;
64
+ });
65
+ if (relevantImports.length > 0) {
66
+ let importsAsterisk = false;
67
+ // imports from import file
68
+ const imports = [];
69
+ relevantImports.forEach((n) => {
70
+ Array.prototype.push.apply(imports, (0, typescript_2.findNodes)(n, tsModule.SyntaxKind.Identifier));
71
+ if ((0, typescript_2.findNodes)(n, tsModule.SyntaxKind.AsteriskToken).length > 0) {
72
+ importsAsterisk = true;
73
+ }
74
+ });
75
+ // if imports * from fileName, don't add symbolName
76
+ if (importsAsterisk) {
77
+ return source;
78
+ }
79
+ const importTextNodes = imports.filter((n) => n.text === symbolName);
80
+ // insert import if it's not there
81
+ if (importTextNodes.length === 0) {
82
+ const fallbackPos = (0, typescript_2.findNodes)(relevantImports[0], tsModule.SyntaxKind.CloseBraceToken)[0].getStart() ||
83
+ (0, typescript_2.findNodes)(relevantImports[0], tsModule.SyntaxKind.FromKeyword)[0].getStart();
84
+ return insertAfterLastOccurrence(host, source, imports, `, ${symbolName}`, fileToEdit, fallbackPos);
85
+ }
86
+ return source;
87
+ }
88
+ // no such import declaration exists
89
+ const useStrict = (0, typescript_2.findNodes)(rootNode, tsModule.SyntaxKind.StringLiteral).filter((n) => n.text === 'use strict');
90
+ let fallbackPos = 0;
91
+ if (useStrict.length > 0) {
92
+ fallbackPos = useStrict[0].end;
93
+ }
94
+ const open = isDefault ? '' : '{ ';
95
+ const close = isDefault ? '' : ' }';
96
+ // if there are no imports or 'use strict' statement, insert import at beginning of file
97
+ const insertAtBeginning = allImports.length === 0 && useStrict.length === 0;
98
+ const separator = insertAtBeginning ? '' : ';\n';
99
+ const toInsert = `${separator}import ${open}${symbolName}${close}` +
100
+ ` from '${fileName}'${insertAtBeginning ? ';\n' : ''}`;
101
+ return insertAfterLastOccurrence(host, source, allImports, toInsert, fileToEdit, fallbackPos, tsModule.SyntaxKind.StringLiteral);
102
+ }
103
+ exports.insertImport = insertImport;
104
+ function insertAfterLastOccurrence(host, sourceFile, nodes, toInsert, pathToFile, fallbackPos, syntaxKind) {
105
+ // sort() has a side effect, so make a copy so that we won't overwrite the parent's object.
106
+ let lastItem = [...nodes].sort(nodesByPosition).pop();
107
+ if (!lastItem) {
108
+ throw new Error();
109
+ }
110
+ if (syntaxKind) {
111
+ lastItem = (0, typescript_2.findNodes)(lastItem, syntaxKind).sort(nodesByPosition).pop();
112
+ }
113
+ if (!lastItem && fallbackPos == undefined) {
114
+ throw new Error(`tried to insert ${toInsert} as first occurrence with no fallback position`);
115
+ }
116
+ const lastItemPosition = lastItem ? lastItem.getEnd() : fallbackPos;
117
+ return insertChange(host, sourceFile, pathToFile, lastItemPosition, toInsert);
118
+ }
119
+ function addGlobal(host, source, modulePath, statement) {
120
+ if (!tsModule) {
121
+ tsModule = (0, ensure_typescript_1.ensureTypescript)();
122
+ }
123
+ const allImports = (0, typescript_2.findNodes)(source, tsModule.SyntaxKind.ImportDeclaration);
124
+ if (allImports.length > 0) {
125
+ const lastImport = allImports[allImports.length - 1];
126
+ return insertChange(host, source, modulePath, lastImport.end + 1, `\n${statement}\n`);
127
+ }
128
+ else {
129
+ return insertChange(host, source, modulePath, 0, `${statement}\n`);
130
+ }
131
+ }
132
+ exports.addGlobal = addGlobal;
133
+ function getImport(source, predicate) {
134
+ if (!tsModule) {
135
+ tsModule = (0, ensure_typescript_1.ensureTypescript)();
136
+ }
137
+ const allImports = (0, typescript_2.findNodes)(source, tsModule.SyntaxKind.ImportDeclaration);
138
+ const matching = allImports.filter((i) => predicate(i.moduleSpecifier.getText()));
139
+ return matching.map((i) => {
140
+ const moduleSpec = i.moduleSpecifier
141
+ .getText()
142
+ .substring(1, i.moduleSpecifier.getText().length - 1);
143
+ const t = i.importClause.namedBindings.getText();
144
+ const bindings = t
145
+ .replace('{', '')
146
+ .replace('}', '')
147
+ .split(',')
148
+ .map((q) => q.trim());
149
+ return { moduleSpec, bindings };
150
+ });
151
+ }
152
+ exports.getImport = getImport;
153
+ function replaceNodeValue(host, sourceFile, modulePath, node, content) {
154
+ return replaceChange(host, sourceFile, modulePath, node.getStart(node.getSourceFile()), content, node.getText());
155
+ }
156
+ exports.replaceNodeValue = replaceNodeValue;
157
+ function addParameterToConstructor(tree, source, modulePath, opts) {
158
+ if (!tsModule) {
159
+ tsModule = (0, ensure_typescript_1.ensureTypescript)();
160
+ }
161
+ const clazz = findClass(source, opts.className);
162
+ const constructor = clazz.members.filter((m) => m.kind === tsModule.SyntaxKind.Constructor)[0];
163
+ if (constructor) {
164
+ throw new Error('Should be tested'); // TODO: check this
165
+ }
166
+ return addMethod(tree, source, modulePath, {
167
+ className: opts.className,
168
+ methodHeader: `constructor(${opts.param})`,
169
+ });
170
+ }
171
+ exports.addParameterToConstructor = addParameterToConstructor;
172
+ function addMethod(tree, source, modulePath, opts) {
173
+ const clazz = findClass(source, opts.className);
174
+ const body = opts.body
175
+ ? `
176
+ ${opts.methodHeader} {
177
+ ${opts.body}
178
+ }
179
+ `
180
+ : `
181
+ ${opts.methodHeader} {}
182
+ `;
183
+ return insertChange(tree, source, modulePath, clazz.end - 1, body);
184
+ }
185
+ exports.addMethod = addMethod;
186
+ function findClass(source, className, silent = false) {
187
+ if (!tsModule) {
188
+ tsModule = (0, ensure_typescript_1.ensureTypescript)();
189
+ }
190
+ const nodes = (0, typescript_1.getSourceNodes)(source);
191
+ const clazz = nodes.filter((n) => n.kind === tsModule.SyntaxKind.ClassDeclaration &&
192
+ n.name.text === className)[0];
193
+ if (!clazz && !silent) {
194
+ throw new Error(`Cannot find class '${className}'.`);
195
+ }
196
+ return clazz;
197
+ }
198
+ exports.findClass = findClass;
199
+ //# sourceMappingURL=ast-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ast-utils.js","sourceRoot":"","sources":["../../../../../../packages/js/src/utils/typescript/ast-utils.ts"],"names":[],"mappings":";;;AAEA,4EAA4E;AAC5E,uEAAwE;AACxE,wDAAoD;AACpD,2DAAuD;AAEvD,IAAI,QAAqC,CAAC;AAE1C,SAAS,eAAe,CAAC,KAAc,EAAE,MAAe;IACtD,OAAO,KAAK,CAAC,QAAQ,EAAE,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;AAC9C,CAAC;AAED,SAAS,kBAAkB,CACzB,IAAU,EACV,UAAyB,EACzB,QAAgB;IAEhB,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC9D,OAAO,UAAU,CAAC,MAAM,CAAC,eAAe,EAAE;QACxC,SAAS,EAAE,eAAe,CAAC,MAAM;QACjC,IAAI,EAAE;YACJ,MAAM,EAAE,UAAU,CAAC,IAAI,CAAC,MAAM;YAC9B,KAAK,EAAE,CAAC;SACT;KACF,CAAC,CAAC;AACL,CAAC;AAED,SAAgB,YAAY,CAC1B,IAAU,EACV,UAAyB,EACzB,QAAgB,EAChB,cAAsB,EACtB,eAAuB;IAEvB,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC/C,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;IACpD,MAAM,MAAM,GAAG,OAAO,CAAC,SA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CAAC,CAAC;IAErC,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CACxB,CAAC,CAAC,EAAE,EAAE,CACJ,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,UAAU,CAAC,gBAAgB;QACzC,CAAE,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,CACnC,CAAC,CAAC,CAAwB,CAAC;IAE5B,IAAI,CAAC,KAAK,IAAI,CAAC,MAAM,EAAE;QACrB,MAAM,IAAI,KAAK,CAAC,sBAAsB,SAAS,IAAI,CAAC,CAAC;KACtD;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AArBD,8BAqBC"}
@@ -0,0 +1,10 @@
1
+ import { TypeScriptCompilationOptions } from '@nx/workspace/src/utilities/typescript/compilation';
2
+ import { NormalizedExecutorOptions } from '../schema';
3
+ export interface TypescriptCompilationResult {
4
+ success: boolean;
5
+ outfile: string;
6
+ }
7
+ export declare function compileTypeScriptFiles(normalizedOptions: NormalizedExecutorOptions, tscOptions: TypeScriptCompilationOptions, postCompilationCallback: () => void | Promise<void>): {
8
+ iterator: AsyncIterable<TypescriptCompilationResult>;
9
+ close: () => void | Promise<void>;
10
+ };
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.compileTypeScriptFiles = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const compilation_1 = require("@nx/workspace/src/utilities/typescript/compilation");
6
+ const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
7
+ const TYPESCRIPT_FOUND_N_ERRORS_WATCHING_FOR_FILE_CHANGES = 6194;
8
+ // Typescript diagnostic message for 6194: Found {0} errors. Watching for file changes.
9
+ // https://github.com/microsoft/TypeScript/blob/d45012c5e2ab122919ee4777a7887307c5f4a1e0/src/compiler/diagnosticMessages.json#L4763-L4766
10
+ const ERROR_COUNT_REGEX = /Found (\d+) errors/;
11
+ function getErrorCountFromMessage(messageText) {
12
+ return Number.parseInt(ERROR_COUNT_REGEX.exec(messageText)[1]);
13
+ }
14
+ function compileTypeScriptFiles(normalizedOptions, tscOptions, postCompilationCallback) {
15
+ const getResult = (success) => ({
16
+ success,
17
+ outfile: normalizedOptions.mainOutputPath,
18
+ });
19
+ let tearDown;
20
+ return {
21
+ iterator: (0, async_iterable_1.createAsyncIterable)(({ next, done }) => tslib_1.__awaiter(this, void 0, void 0, function* () {
22
+ if (normalizedOptions.watch) {
23
+ const host = (0, compilation_1.compileTypeScriptWatcher)(tscOptions, (d) => tslib_1.__awaiter(this, void 0, void 0, function* () {
24
+ if (d.code === TYPESCRIPT_FOUND_N_ERRORS_WATCHING_FOR_FILE_CHANGES) {
25
+ yield postCompilationCallback();
26
+ next(getResult(getErrorCountFromMessage(d.messageText) === 0));
27
+ }
28
+ }));
29
+ tearDown = () => {
30
+ host.close();
31
+ done();
32
+ };
33
+ }
34
+ else {
35
+ const { success } = (0, compilation_1.compileTypeScript)(tscOptions);
36
+ yield postCompilationCallback();
37
+ next(getResult(success));
38
+ done();
39
+ }
40
+ })),
41
+ close: () => tearDown === null || tearDown === void 0 ? void 0 : tearDown(),
42
+ };
43
+ }
44
+ exports.compileTypeScriptFiles = compileTypeScriptFiles;
45
+ //# sourceMappingURL=compile-typescript-files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compile-typescript-files.js","sourceRoot":"","sources":["../../../../../../packages/js/src/utils/typescript/compile-typescript-files.ts"],"names":[],"mappings":";;;;AAAA,oFAI4D;AAE5D,wEAA0E;AAG1E,MAAM,mDAAmD,GAAG,IAAI,CAAC;AACjE,uFAAuF;AACvF,yIAAyI;AACzI,MAAM,iBAAiB,GAAG,oBAAoB,CAAC;AAE/C,SAAS,wBAAwB,CAAC,WAAmB;IACnD,OAAO,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACjE,CAAC;AAOD,SAAgB,sBAAsB,CACpC,iBAA4C,EAC5C,UAAwC,EACxC,uBAAmD;IAKnD,MAAM,SAAS,GAAG,CAAC,OAAgB,EAAE,EAAE,CAAC,CAAC;QACvC,OAAO;QACP,OAAO,EAAE,iBAAiB,CAAC,cAAc;KAC1C,CAAC,CAAC;IAEH,IAAI,QAAkC,CAAC;IAEvC,OAAO;QACL,QAAQ,EAAE,IAAA,oCAAmB,EAC3B,CAAO,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE;YACvB,IAAI,iBAAiB,CAAC,KAAK,EAAE;gBAC3B,MAAM,IAAI,GAAG,IAAA,sCAAwB,EACnC,UAAU,EACV,CAAO,CAAa,EAAE,EAAE;oBACtB,IACE,CAAC,CAAC,IAAI,KAAK,mDAAmD,EAC9D;wBACA,MAAM,uBAAuB,EAAE,CAAC;wBAChC,IAAI,CACF,SAAS,CACP,wBAAwB,CAAC,CAAC,CAAC,WAAqB,CAAC,KAAK,CAAC,CACxD,CACF,CAAC;qBACH;gBACH,CAAC,CAAA,CACF,CAAC;gBAEF,QAAQ,GAAG,GAAG,EAAE;oBACd,IAAI,CAAC,KAAK,EAAE,CAAC;oBACb,IAAI,EAAE,CAAC;gBACT,CAAC,CAAC;aACH;iBAAM;gBACL,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,+BAAiB,EAAC,UAAU,CAAC,CAAC;gBAClD,MAAM,uBAAuB,EAAE,CAAC;gBAChC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;gBACzB,IAAI,EAAE,CAAC;aACR;QACH,CAAC,CAAA,CACF;QACD,KAAK,EAAE,GAAG,EAAE,CAAC,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,EAAI;KAC1B,CAAC;AACJ,CAAC;AAjDD,wDAiDC"}
@@ -0,0 +1,17 @@
1
+ import { Tree } from 'nx/src/generators/tree';
2
+ export declare const tsConfigBaseOptions: {
3
+ rootDir: string;
4
+ sourceMap: boolean;
5
+ declaration: boolean;
6
+ moduleResolution: string;
7
+ emitDecoratorMetadata: boolean;
8
+ experimentalDecorators: boolean;
9
+ importHelpers: boolean;
10
+ target: string;
11
+ module: string;
12
+ lib: string[];
13
+ skipLibCheck: boolean;
14
+ skipDefaultLibCheck: boolean;
15
+ baseUrl: string;
16
+ };
17
+ export declare function extractTsConfigBase(host: Tree): void;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractTsConfigBase = exports.tsConfigBaseOptions = void 0;
4
+ const json_1 = require("nx/src/generators/utils/json");
5
+ exports.tsConfigBaseOptions = {
6
+ rootDir: '.',
7
+ sourceMap: true,
8
+ declaration: false,
9
+ moduleResolution: 'node',
10
+ emitDecoratorMetadata: true,
11
+ experimentalDecorators: true,
12
+ importHelpers: true,
13
+ target: 'es2015',
14
+ module: 'esnext',
15
+ lib: ['es2017', 'dom'],
16
+ skipLibCheck: true,
17
+ skipDefaultLibCheck: true,
18
+ baseUrl: '.',
19
+ };
20
+ function extractTsConfigBase(host) {
21
+ if (host.exists('tsconfig.base.json'))
22
+ return;
23
+ const tsconfig = (0, json_1.readJson)(host, 'tsconfig.json');
24
+ const baseCompilerOptions = {};
25
+ for (let compilerOption of Object.keys(exports.tsConfigBaseOptions)) {
26
+ baseCompilerOptions[compilerOption] =
27
+ tsconfig.compilerOptions[compilerOption];
28
+ delete tsconfig.compilerOptions[compilerOption];
29
+ }
30
+ (0, json_1.writeJson)(host, 'tsconfig.base.json', {
31
+ compileOnSave: false,
32
+ compilerOptions: baseCompilerOptions,
33
+ exclude: tsconfig.exclude,
34
+ });
35
+ tsconfig.extends = './tsconfig.base.json';
36
+ delete tsconfig.compileOnSave;
37
+ delete tsconfig.exclude;
38
+ (0, json_1.writeJson)(host, 'tsconfig.json', tsconfig);
39
+ // special case for updating e2e tests.
40
+ if (host.exists('e2e/tsconfig.json')) {
41
+ (0, json_1.updateJson)(host, 'e2e/tsconfig.json', (json) => {
42
+ json.extends = '../tsconfig.base.json';
43
+ return json;
44
+ });
45
+ }
46
+ }
47
+ exports.extractTsConfigBase = extractTsConfigBase;
48
+ //# sourceMappingURL=create-ts-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-ts-config.js","sourceRoot":"","sources":["../../../../../../packages/js/src/utils/typescript/create-ts-config.ts"],"names":[],"mappings":";;;AACA,uDAA+E;AAElE,QAAA,mBAAmB,GAAG;IACjC,OAAO,EAAE,GAAG;IACZ,SAAS,EAAE,IAAI;IACf,WAAW,EAAE,KAAK;IAClB,gBAAgB,EAAE,MAAM;IACxB,qBAAqB,EAAE,IAAI;IAC3B,sBAAsB,EAAE,IAAI;IAC5B,aAAa,EAAE,IAAI;IACnB,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,GAAG,EAAE,CAAC,QAAQ,EAAE,KAAK,CAAC;IACtB,YAAY,EAAE,IAAI;IAClB,mBAAmB,EAAE,IAAI;IACzB,OAAO,EAAE,GAAG;CACb,CAAC;AAEF,SAAgB,mBAAmB,CAAC,IAAU;IAC5C,IAAI,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC;QAAE,OAAO;IAE9C,MAAM,QAAQ,GAAG,IAAA,eAAQ,EAAC,IAAI,EAAE,eAAe,CAAC,CAAC;IACjD,MAAM,mBAAmB,GAAG,EAAS,CAAC;IACtC,KAAK,IAAI,cAAc,IAAI,MAAM,CAAC,IAAI,CAAC,2BAAmB,CAAC,EAAE;QAC3D,mBAAmB,CAAC,cAAc,CAAC;YACjC,QAAQ,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;QAC3C,OAAO,QAAQ,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;KACjD;IACD,IAAA,gBAAS,EAAC,IAAI,EAAE,oBAAoB,EAAE;QACpC,aAAa,EAAE,KAAK;QACpB,eAAe,EAAE,mBAAmB;QACpC,OAAO,EAAE,QAAQ,CAAC,OAAO;KAC1B,CAAC,CAAC;IACH,QAAQ,CAAC,OAAO,GAAG,sBAAsB,CAAC;IAC1C,OAAO,QAAQ,CAAC,aAAa,CAAC;IAC9B,OAAO,QAAQ,CAAC,OAAO,CAAC;IAExB,IAAA,gBAAS,EAAC,IAAI,EAAE,eAAe,EAAE,QAAQ,CAAC,CAAC;IAE3C,uCAAuC;IACvC,IAAI,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,EAAE;QACpC,IAAA,iBAAU,EAAC,IAAI,EAAE,mBAAmB,EAAE,CAAC,IAAI,EAAE,EAAE;YAC7C,IAAI,CAAC,OAAO,GAAG,uBAAuB,CAAC;YACvC,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;KACJ;AACH,CAAC;AA5BD,kDA4BC"}
@@ -0,0 +1 @@
1
+ export declare function ensureTypescript(): typeof import("typescript");
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ensureTypescript = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const versions_1 = require("../versions");
6
+ function ensureTypescript() {
7
+ return (0, devkit_1.ensurePackage)('typescript', versions_1.typescriptVersion);
8
+ }
9
+ exports.ensureTypescript = ensureTypescript;
10
+ //# sourceMappingURL=ensure-typescript.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ensure-typescript.js","sourceRoot":"","sources":["../../../../../../packages/js/src/utils/typescript/ensure-typescript.ts"],"names":[],"mappings":";;;AAAA,uCAA2C;AAC3C,0CAAgD;AAEhD,SAAgB,gBAAgB;IAC9B,OAAO,IAAA,sBAAa,EAClB,YAAY,EACZ,4BAAiB,CAClB,CAAC;AACJ,CAAC;AALD,4CAKC"}
@@ -0,0 +1,2 @@
1
+ import type * as ts from 'typescript';
2
+ export declare function getSourceNodes(sourceFile: ts.SourceFile): ts.Node[];
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSourceNodes = void 0;
4
+ function getSourceNodes(sourceFile) {
5
+ const nodes = [sourceFile];
6
+ const result = [];
7
+ while (nodes.length > 0) {
8
+ const node = nodes.shift();
9
+ if (node) {
10
+ result.push(node);
11
+ if (node.getChildCount(sourceFile) >= 0) {
12
+ nodes.unshift(...node.getChildren());
13
+ }
14
+ }
15
+ }
16
+ return result;
17
+ }
18
+ exports.getSourceNodes = getSourceNodes;
19
+ //# sourceMappingURL=get-source-nodes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-source-nodes.js","sourceRoot":"","sources":["../../../../../../packages/js/src/utils/typescript/get-source-nodes.ts"],"names":[],"mappings":";;;AAEA,SAAgB,cAAc,CAAC,UAAyB;IACtD,MAAM,KAAK,GAAc,CAAC,UAAU,CAAC,CAAC;IACtC,MAAM,MAAM,GAAG,EAAE,CAAC;IAElB,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;QACvB,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC;QAE3B,IAAI,IAAI,EAAE;YACR,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAClB,IAAI,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;gBACvC,KAAK,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;aACtC;SACF;KACF;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAhBD,wCAgBC"}
@@ -0,0 +1,5 @@
1
+ import { CompilerPluginHooks, TransformerEntry } from './types';
2
+ export declare function loadTsTransformers(plugins: TransformerEntry[], moduleResolver?: typeof require.resolve): {
3
+ compilerPluginHooks: CompilerPluginHooks;
4
+ hasPlugin: boolean;
5
+ };
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.loadTsTransformers = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const path_1 = require("path");
6
+ function loadTsTransformers(plugins, moduleResolver = require.resolve) {
7
+ const beforeHooks = [];
8
+ const afterHooks = [];
9
+ const afterDeclarationsHooks = [];
10
+ if (!plugins || !plugins.length)
11
+ return {
12
+ compilerPluginHooks: {
13
+ beforeHooks,
14
+ afterHooks,
15
+ afterDeclarationsHooks,
16
+ },
17
+ hasPlugin: false,
18
+ };
19
+ const normalizedPlugins = plugins.map((plugin) => typeof plugin === 'string' ? { name: plugin, options: {} } : plugin);
20
+ const nodeModulePaths = [
21
+ (0, path_1.join)(process.cwd(), 'node_modules'),
22
+ ...module.paths,
23
+ ];
24
+ const pluginRefs = normalizedPlugins.map(({ name }) => {
25
+ try {
26
+ const binaryPath = moduleResolver(name, {
27
+ paths: nodeModulePaths,
28
+ });
29
+ return require(binaryPath);
30
+ }
31
+ catch (e) {
32
+ devkit_1.logger.warn(`"${name}" plugin could not be found!`);
33
+ return {};
34
+ }
35
+ });
36
+ for (let i = 0; i < pluginRefs.length; i++) {
37
+ const { name: pluginName, options: pluginOptions } = normalizedPlugins[i];
38
+ const { before, after, afterDeclarations } = pluginRefs[i];
39
+ if (!before && !after && !afterDeclarations) {
40
+ devkit_1.logger.warn(`${pluginName} is not a Transformer Plugin. It does not provide neither before(), after(), nor afterDeclarations()`);
41
+ continue;
42
+ }
43
+ if (before) {
44
+ beforeHooks.push(before.bind(before, pluginOptions));
45
+ }
46
+ if (after) {
47
+ afterHooks.push(after.bind(after, pluginOptions));
48
+ }
49
+ if (afterDeclarations) {
50
+ afterDeclarationsHooks.push(afterDeclarations.bind(afterDeclarations, pluginOptions));
51
+ }
52
+ }
53
+ return {
54
+ compilerPluginHooks: {
55
+ beforeHooks,
56
+ afterHooks,
57
+ afterDeclarationsHooks,
58
+ },
59
+ hasPlugin: true,
60
+ };
61
+ }
62
+ exports.loadTsTransformers = loadTsTransformers;
63
+ //# sourceMappingURL=load-ts-transformers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-ts-transformers.js","sourceRoot":"","sources":["../../../../../../packages/js/src/utils/typescript/load-ts-transformers.ts"],"names":[],"mappings":";;;AAAA,uCAAoC;AACpC,+BAA4B;AAQ5B,S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,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC;QAC1E,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,EAAE,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;QAC3D,IAAI,CAAC,MAAM,IAAI,CAAC,KAAK,IAAI,CAAC,iBAAiB,EAAE;YAC3C,eAAM,CAAC,IAAI,CACT,GAAG,UAAU,sGAAsG,CACpH,CAAC;YACF,SAAS;SACV;QAED,IAAI,MAAM,EAAE;YACV,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC;SACtD;QAED,IAAI,KAAK,EAAE;YACT,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC;SACnD;QAED,IAAI,iBAAiB,EAAE;YACrB,sBAAsB,CAAC,IAAI,CACzB,iBAAiB,CAAC,IAAI,CAAC,iBAAiB,EAAE,aAAa,CAAC,CACzD,CAAC;SACH;KACF;IAED,OAAO;QACL,mBAAmB,EAAE;YACnB,WAAW;YACX,UAAU;YACV,sBAAsB;SACvB;QACD,SAAS,EAAE,IAAI;KAChB,CAAC;AACJ,CAAC;AA5ED,gDA4EC"}
@@ -0,0 +1 @@
1
+ export declare function printDiagnostics(errors?: string[], warnings?: string[]): Promise<void>;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.printDiagnostics = void 0;
4
+ const tslib_1 = require("tslib");
5
+ function printDiagnostics(errors = [], warnings = []) {
6
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
7
+ if (errors.length > 0) {
8
+ errors.forEach((err) => {
9
+ console.log(`${err}\n`);
10
+ });
11
+ console.log(`Found ${errors.length} error${errors.length > 1 ? 's' : ''}.`);
12
+ }
13
+ else if (warnings.length > 0) {
14
+ warnings.forEach((err) => {
15
+ console.log(`${err}\n`);
16
+ });
17
+ console.log(`Found ${warnings.length} warnings.`);
18
+ }
19
+ });
20
+ }
21
+ exports.printDiagnostics = printDiagnostics;
22
+ //# sourceMappingURL=print-diagnostics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"print-diagnostics.js","sourceRoot":"","sources":["../../../../../../packages/js/src/utils/typescript/print-diagnostics.ts"],"names":[],"mappings":";;;;AAAA,SAAsB,gBAAgB,CACpC,SAAmB,EAAE,EACrB,WAAqB,EAAE;;QAEvB,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;YACrB,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;gBACrB,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC;YAC1B,CAAC,CAAC,CAAC;YAEH,OAAO,CAAC,GAAG,CAAC,SAAS,MAAM,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;SAC7E;aAAM,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;YAC9B,QAAQ,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;gBACvB,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC;YAC1B,CAAC,CAAC,CAAC;YAEH,OAAO,CAAC,GAAG,CAAC,SAAS,QAAQ,CAAC,MAAM,YAAY,CAAC,CAAC;SACnD;IACH,CAAC;CAAA;AAjBD,4CAiBC"}
@@ -0,0 +1,32 @@
1
+ import type { Diagnostic } from 'typescript';
2
+ export interface TypeCheckResult {
3
+ warnings?: string[];
4
+ errors?: string[];
5
+ inputFilesCount: number;
6
+ totalFilesCount: number;
7
+ incremental: boolean;
8
+ }
9
+ export type TypeCheckOptions = BaseTypeCheckOptions & Mode;
10
+ interface BaseTypeCheckOptions {
11
+ workspaceRoot: string;
12
+ tsConfigPath: string;
13
+ cacheDir?: string;
14
+ incremental?: boolean;
15
+ rootDir?: string;
16
+ }
17
+ type Mode = NoEmitMode | EmitDeclarationOnlyMode;
18
+ interface NoEmitMode {
19
+ mode: 'noEmit';
20
+ }
21
+ interface EmitDeclarationOnlyMode {
22
+ mode: 'emitDeclarationOnly';
23
+ outDir: string;
24
+ }
25
+ export declare function runTypeCheckWatch(options: TypeCheckOptions, callback: (diagnostic: Diagnostic, formattedDiagnostic: string, errorCount?: number) => void | Promise<void>): Promise<{
26
+ close: any;
27
+ preEmitErrors: string[];
28
+ preEmitWarnings: string[];
29
+ }>;
30
+ export declare function runTypeCheck(options: TypeCheckOptions): Promise<TypeCheckResult>;
31
+ export declare function getFormattedDiagnostic(ts: typeof import('typescript'), workspaceRoot: string, diagnostic: Diagnostic): string;
32
+ export {};