@plugjs/tsgo 0.0.0

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.
package/AGENTS.md ADDED
@@ -0,0 +1,9 @@
1
+ # Agent Instructions
2
+
3
+ ## Formatting And Linting
4
+
5
+ - After every edit, run `npm run lintfix` to apply the repository's formatting and linting fixes. This applies to every change.
6
+
7
+ ## Code And Test Changes
8
+
9
+ - When changing files under `src/` or `test/`, always run `npm run build fix=true` after the edits. This command checks types, runs tests and coverage, and formats/lints/fixes any inconsistencies.
package/LICENSE.md ADDED
@@ -0,0 +1,211 @@
1
+ # Apache License
2
+
3
+ Version 2.0, January 2004
4
+
5
+ [http://www.apache.org/licenses/](http://www.apache.org/licenses/)
6
+
7
+ ##### TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8
+
9
+ ### 1. Definitions.
10
+
11
+ "**License**" shall mean the terms and conditions for use, reproduction,
12
+ and distribution as defined by Sections 1 through 9 of this document.
13
+
14
+ "**Licensor**" shall mean the copyright owner or entity authorized by
15
+ the copyright owner that is granting the License.
16
+
17
+ "**Legal Entity**" shall mean the union of the acting entity and all
18
+ other entities that control, are controlled by, or are under common
19
+ control with that entity. For the purposes of this definition,
20
+ "**control**" means **(i)** the power, direct or indirect, to cause the
21
+ direction or management of such entity, whether by contract or
22
+ otherwise, _or_ **(ii)** ownership of fifty percent (50%) or more of
23
+ the outstanding shares, _or_ **(iii)** beneficial ownership of such
24
+ entity.
25
+
26
+ "**You**" (or "**Your**") shall mean an individual or Legal Entity
27
+ exercising permissions granted by this License.
28
+
29
+ "**Source**" form shall mean the preferred form for making
30
+ modifications, including but not limited to software source code,
31
+ documentation source, and configuration files.
32
+
33
+ "**Object**" form shall mean any form resulting from mechanical
34
+ transformation or translation of a Source form, including but not
35
+ limited to compiled object code, generated documentation, and
36
+ conversions to other media types.
37
+
38
+ "**Work**" shall mean the work of authorship, whether in Source or
39
+ Object form, made available under the License, as indicated by a
40
+ copyright notice that is included in or attached to the work (an example
41
+ is provided in the Appendix below).
42
+
43
+ "**Derivative Works**" shall mean any work, whether in Source or Object
44
+ form, that is based on (or derived from) the Work and for which the
45
+ editorial revisions, annotations, elaborations, or other modifications
46
+ represent, as a whole, an original work of authorship. For the purposes
47
+ of this License, Derivative Works shall not include works that remain
48
+ separable from, or merely link (or bind by name) to the interfaces of,
49
+ the Work and Derivative Works thereof.
50
+
51
+ "**Contribution**" shall mean any work of authorship, including the
52
+ original version of the Work and any modifications or additions to that
53
+ Work or Derivative Works thereof, that is intentionally submitted to
54
+ Licensor for inclusion in the Work by the copyright owner or by an
55
+ individual or Legal Entity authorized to submit on behalf of the
56
+ copyright owner. For the purposes of this definition, "**submitted**"
57
+ means any form of electronic, verbal, or written communication sent to
58
+ the Licensor or its representatives, including but not limited to
59
+ communication on electronic mailing lists, source code control systems,
60
+ and issue tracking systems that are managed by, or on behalf of, the
61
+ Licensor for the purpose of discussing and improving the Work, but
62
+ excluding communication that is conspicuously marked or otherwise
63
+ designated in writing by the copyright owner as "**Not a
64
+ Contribution**".
65
+
66
+ "**Contributor**" shall mean Licensor and any individual or Legal Entity
67
+ on behalf of whom a Contribution has been received by Licensor and
68
+ subsequently incorporated within the Work.
69
+
70
+ ### 2. Grant of Copyright License.
71
+
72
+ Subject to the terms and conditions of this License, each Contributor
73
+ hereby grants to You a perpetual, worldwide, non-exclusive, no-charge,
74
+ royalty-free, irrevocable copyright license to reproduce, prepare
75
+ Derivative Works of, publicly display, publicly perform, sublicense,
76
+ and distribute the Work and such Derivative Works in Source or Object
77
+ form.
78
+
79
+ ### 3. Grant of Patent License.
80
+
81
+ Subject to the terms and conditions of this License, each Contributor
82
+ hereby grants to You a perpetual, worldwide, non-exclusive, no-charge,
83
+ royalty-free, irrevocable (except as stated in this section) patent
84
+ license to make, have made, use, offer to sell, sell, import, and
85
+ otherwise transfer the Work, where such license applies only to those
86
+ patent claims licensable by such Contributor that are necessarily
87
+ infringed by their Contribution(s) alone or by combination of their
88
+ Contribution(s) with the Work to which such Contribution(s) was
89
+ submitted. If You institute patent litigation against any entity
90
+ (including a cross-claim or counterclaim in a lawsuit) alleging that
91
+ the Work or a Contribution incorporated within the Work constitutes
92
+ direct or contributory patent infringement, then any patent licenses
93
+ granted to You under this License for that Work shall terminate as of
94
+ the date such litigation is filed.
95
+
96
+ ### 4. Redistribution.
97
+
98
+ You may reproduce and distribute copies of the Work or Derivative Works
99
+ thereof in any medium, with or without modifications, and in Source or
100
+ Object form, provided that You meet the following conditions:
101
+
102
+ <ol type="a">
103
+ <li>You must give any other recipients of the Work or Derivative Works
104
+ a copy of this License; and
105
+ <li>You must cause any modified files to carry prominent notices
106
+ stating that You changed the files; and
107
+ <li>You must retain, in the Source form of any Derivative Works that
108
+ You distribute, all copyright, patent, trademark, and attribution
109
+ notices from the Source form of the Work, excluding those notices
110
+ that do not pertain to any part of the Derivative Works; and
111
+ <li>If the Work includes a "NOTICE" text file as part of its
112
+ distribution, then any Derivative Works that You distribute must
113
+ include a readable copy of the attribution notices contained within
114
+ such NOTICE file, excluding those notices that do not pertain to any
115
+ part of the Derivative Works, in at least one of the following
116
+ places: within a NOTICE text file distributed as part of the
117
+ Derivative Works; within the Source form or documentation, if
118
+ provided along with the Derivative Works; or, within a display
119
+ generated by the Derivative Works, if and wherever such third-party
120
+ notices normally appear. The contents of the NOTICE file are for
121
+ informational purposes only and do not modify the License. You may
122
+ add Your own attribution notices within Derivative Works that You
123
+ distribute, alongside or as an addendum to the NOTICE text from the
124
+ Work, provided that such additional attribution notices cannot be
125
+ construed as modifying the License.
126
+ </ol>
127
+
128
+ You may add Your own copyright statement to Your modifications and may
129
+ provide additional or different license terms and conditions for use,
130
+ reproduction, or distribution of Your modifications, or for any such
131
+ Derivative Works as a whole, provided Your use, reproduction, and
132
+ distribution of the Work otherwise complies with the conditions stated
133
+ in this License.
134
+
135
+ ### 5. Submission of Contributions.
136
+
137
+ Unless You explicitly state otherwise, any Contribution intentionally
138
+ submitted for inclusion in the Work by You to the Licensor shall be
139
+ under the terms and conditions of this License, without any additional
140
+ terms or conditions. Notwithstanding the above, nothing herein shall
141
+ supersede or modify the terms of any separate license agreement you may
142
+ have executed with Licensor regarding such Contributions.
143
+
144
+ ### 6. Trademarks.
145
+
146
+ This License does not grant permission to use the trade names,
147
+ trademarks, service marks, or product names of the Licensor, except as
148
+ required for reasonable and customary use in describing the origin of
149
+ the Work and reproducing the content of the NOTICE file.
150
+
151
+ ### 7. Disclaimer of Warranty.
152
+
153
+ Unless required by applicable law or agreed to in writing, Licensor
154
+ provides the Work (and each Contributor provides its Contributions) on
155
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
156
+ express or implied, including, without limitation, any warranties or
157
+ conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR
158
+ A PARTICULAR PURPOSE. You are solely responsible for determining the
159
+ appropriateness of using or redistributing the Work and assume any risks
160
+ associated with Your exercise of permissions under this License.
161
+
162
+ ### 8. Limitation of Liability.
163
+
164
+ In no event and under no legal theory, whether in tort (including
165
+ negligence), contract, or otherwise, unless required by applicable law
166
+ (such as deliberate and grossly negligent acts) or agreed to in writing,
167
+ shall any Contributor be liable to You for damages, including any
168
+ direct, indirect, special, incidental, or consequential damages of any
169
+ character arising as a result of this License or out of the use or
170
+ inability to use the Work (including but not limited to damages for loss
171
+ of goodwill, work stoppage, computer failure or malfunction, or any and
172
+ all other commercial damages or losses), even if such Contributor has
173
+ been advised of the possibility of such damages.
174
+
175
+ ### 9. Accepting Warranty or Additional Liability.
176
+
177
+ While redistributing the Work or Derivative Works thereof, You may
178
+ choose to offer, and charge a fee for, acceptance of support, warranty,
179
+ indemnity, or other liability obligations and/or rights consistent with
180
+ this License. However, in accepting such obligations, You may act only
181
+ on Your own behalf and on Your sole responsibility, not on behalf of any
182
+ other Contributor, and only if You agree to indemnify, defend, and hold
183
+ each Contributor harmless for any liability incurred by, or claims
184
+ asserted against, such Contributor by reason of your accepting any
185
+ such warranty or additional liability.
186
+
187
+ ##### END OF TERMS AND CONDITIONS
188
+
189
+ ## APPENDIX: How to apply the Apache License to your work.
190
+
191
+ To apply the Apache License to your work, attach the following
192
+ boilerplate notice, with the fields enclosed by brackets "[]"
193
+ replaced with your own identifying information. (Don't include the
194
+ brackets!) The text should be enclosed in the appropriate comment
195
+ syntax for the file format. We also recommend that a file or class name
196
+ and description of purpose be included on the same "printed page" as the
197
+ copyright notice for easier identification within third-party archives.
198
+
199
+ > #### Copyright [yyyy] [name of copyright owner]
200
+ >
201
+ > Licensed under the Apache License, Version 2.0 (the "License");
202
+ > you may not use this file except in compliance with the License.
203
+ > You may obtain a copy of the License at
204
+ >
205
+ > [http://www.apache.org/licenses/](http://www.apache.org/licenses/)
206
+ >
207
+ > Unless required by applicable law or agreed to in writing, software
208
+ > distributed under the License is distributed on an "AS IS" BASIS,
209
+ > WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
210
+ > See the License for the specific language governing permissions and
211
+ > limitations under the License.
package/NOTICE.md ADDED
@@ -0,0 +1,13 @@
1
+ # Copyright Juit GmbH
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ [http://www.apache.org/licenses/](http://www.apache.org/licenses/)
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,100 @@
1
+ TypeScript 7 support for PlugJS
2
+ ===============================
3
+
4
+ This plugin adds support for [TypeScript 7](https://www.typescriptlang.org/)
5
+ in [PlugJS](https://github.com/plugjs/plug/) builds.
6
+
7
+ ### Contents
8
+
9
+ - [Installation](#installation)
10
+ - [Helpers](#helpers)
11
+ - [Pipes](#pipes)
12
+ - [Apache 2.0 License](./LICENSE.md)
13
+ - [Copyright Notice](./NOTICE.md)
14
+
15
+ Installation
16
+ ------------
17
+
18
+ ```bash
19
+ npm install --save-dev @plugjs/tsgo
20
+ ```
21
+
22
+ Helpers
23
+ -------
24
+
25
+ The package exports helper pipes for the most common TypeScript compiler
26
+ workflows. Import them in your PlugJS build file and await them from your
27
+ tasks.
28
+
29
+ ```ts
30
+ import { plugjs } from '@plugjs/plug'
31
+ import { tsc } from '@plugjs/tsgo'
32
+
33
+ export default plugjs({
34
+ async build(): Promise<void> {
35
+ await tsc('src/tsconfig.json')
36
+ },
37
+ })
38
+ ```
39
+
40
+ The `tsc(...)` helper compiles one TypeScript project, identified either by a
41
+ `tsconfig.json` file or by a directory containing one. This is roughly
42
+ equivalent to `tsc --project <config>` and returns a pipe containing the files
43
+ emitted by the compiler.
44
+
45
+ The `tsbuild(...)` helper compiles a project and all of its TypeScript project
46
+ references. This is roughly equivalent to `tsc --build <config>` and is useful
47
+ for workspaces or packages linked through `references` in `tsconfig.json`.
48
+
49
+ ```ts
50
+ import { plugjs } from '@plugjs/plug'
51
+ import { tsbuild } from '@plugjs/tsgo'
52
+
53
+ export default plugjs({
54
+ async build(): Promise<void> {
55
+ await tsbuild('src/tsconfig.json', { directory: '@' })
56
+ },
57
+ })
58
+ ```
59
+
60
+ Both helpers take the same options:
61
+
62
+ - `directory`: base directory used to resolve the configuration path.
63
+ - `emitOnly`: controls which files TypeScript emits. Use:
64
+ - `'all'` or `true` to emit JavaScript and declaration files _(default)_,
65
+ - `'js'` to emit only JavaScript files,
66
+ - `'dts'` to emit only declaration files,
67
+ - `'none'` or `false` to type-check without emitting files.
68
+ - `reportDeprecations`: controls how deprecation diagnostics are reported. Use:
69
+ - `'notice'` or `true` to report them as notices _(default)_,
70
+ - `'warn'` to report them as warnings,
71
+ - `'off'` or `false` to silence them.
72
+
73
+ Pipes
74
+ -----
75
+
76
+ You can also use the TypeScript plug directly in a pipe. Whatever files are in
77
+ the pipe are treated as TypeScript project configs:
78
+
79
+ ```ts
80
+ import '@plugjs/tsgo'
81
+ import { find, plugjs } from '@plugjs/plug'
82
+
83
+ export default plugjs({
84
+ async build(): Promise<void> {
85
+ await find('**/tsconfig.json').typescript()
86
+ },
87
+ })
88
+ ```
89
+
90
+ This compiles all TypeScript projects in the pipe.
91
+
92
+ The `.typescript()` plug takes these options:
93
+
94
+ - `emitOnly`: controls which files TypeScript emits
95
+ _(as in the [Helpers](#helpers) section above)
96
+ - `reportDeprecations`: controls how deprecation diagnostics are reported
97
+ _(as in the [Helpers](#helpers) section above)
98
+ - `projectReferences`: controls whether referenced projects are built too. Use:
99
+ - `false` to build only the projects in the pipe _(default)_,
100
+ - `true` to build those projects and their project references.
@@ -0,0 +1,6 @@
1
+ import type { ReportRecord } from '@plugjs/plug/logging';
2
+ import type { AbsolutePath } from '@plugjs/plug/paths';
3
+ import type { Diagnostic, Program } from 'typescript/unstable/async';
4
+ export declare function convertDiagnostics(diagnostics: readonly Diagnostic[], program: Program, deprecations?: 'warn' | 'notice' | 'off'): Promise<ReportRecord[]>;
5
+ export declare function convertProjectDiagnostics(diagnostics: readonly Diagnostic[], program: Program, fileName: AbsolutePath): Promise<ReportRecord[]>;
6
+ //# sourceMappingURL=diagnostics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../src/diagnostics.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEtD,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AAqCpE,wBAAsB,kBAAkB,CACtC,WAAW,EAAE,SAAS,UAAU,EAAE,EAClC,OAAO,EAAE,OAAO,EAChB,YAAY,GAAE,MAAM,GAAG,QAAQ,GAAG,KAAgB,GACjD,OAAO,CAAC,YAAY,EAAE,CAAC,CA2DzB;AAED,wBAAsB,yBAAyB,CAC7C,WAAW,EAAE,SAAS,UAAU,EAAE,EAClC,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,YAAY,GACrB,OAAO,CAAC,YAAY,EAAE,CAAC,CASzB"}
@@ -0,0 +1,99 @@
1
+ import { ERROR, NOTICE, WARN } from '@plugjs/plug/logging';
2
+ import { assertAbsolutePath } from '@plugjs/plug/paths';
3
+ import { DiagnosticCategory } from 'typescript/unstable/async';
4
+ function convertDiagnostic(diagnostic, sourceFile) {
5
+ const record = {
6
+ level: NOTICE,
7
+ message: diagnostic.text,
8
+ tags: [`ts${diagnostic.code}`],
9
+ };
10
+ switch (diagnostic.category) {
11
+ case DiagnosticCategory.Error:
12
+ record.level = ERROR;
13
+ break;
14
+ case DiagnosticCategory.Warning:
15
+ record.level = WARN;
16
+ break;
17
+ }
18
+ if (diagnostic.reportsDeprecated)
19
+ record.tags.push('deprecated');
20
+ if (diagnostic.reportsUnnecessary)
21
+ record.tags.push('unnecessary');
22
+ if (diagnostic.fileName) {
23
+ assertAbsolutePath(diagnostic.fileName);
24
+ record.file = diagnostic.fileName;
25
+ }
26
+ if (sourceFile) {
27
+ const pos = sourceFile.getLineAndCharacterOfPosition(diagnostic.pos);
28
+ record.line = pos.line + 1;
29
+ record.column = pos.character + 1;
30
+ record.length = diagnostic.end - diagnostic.pos;
31
+ record.source = sourceFile.getFullText();
32
+ }
33
+ return record;
34
+ }
35
+ export async function convertDiagnostics(diagnostics, program, deprecations = 'notice') {
36
+ // Filter out any duplicate diagnostic *before* we convert them to report
37
+ // records (that might be expensive because of source file lookups)
38
+ const seen = new Set();
39
+ const unique = diagnostics.filter((diagnostic) => {
40
+ const key = JSON.stringify([
41
+ diagnostic.category,
42
+ diagnostic.code,
43
+ diagnostic.text,
44
+ diagnostic.pos,
45
+ diagnostic.end,
46
+ diagnostic.fileName,
47
+ ]);
48
+ if (seen.has(key))
49
+ return false;
50
+ seen.add(key);
51
+ return true;
52
+ });
53
+ // Convert all diagnostics to report records
54
+ const converted = await Promise.all(unique.map(async (diagnostic) => {
55
+ // Anything not an error is not critical
56
+ const isNonCritical = diagnostic.category !== DiagnosticCategory.Error;
57
+ // First of all see how we need to handle non-error deprecations: when
58
+ // "off" we suppress them, when "warn" we convert them to warnings...
59
+ if (diagnostic.reportsDeprecated && isNonCritical) {
60
+ if (deprecations === 'off')
61
+ return; // simply filter this out...
62
+ if (deprecations === 'warn') {
63
+ diagnostic = { ...diagnostic, category: DiagnosticCategory.Warning };
64
+ }
65
+ }
66
+ // First figure out where this diagnostic came from...
67
+ const sourceFileMetadata = diagnostic.fileName
68
+ ? await program.getSourceFileMetadata(diagnostic.fileName)
69
+ : /* coverage ignore next */ undefined;
70
+ // If the source file is in the default library (e.g. "lib.dom.ts") or
71
+ // from an external library (in "node_modules") then we ONLY keep errors
72
+ // and (we ignore things like warnings, suggestions, ...)
73
+ const isExternal = sourceFileMetadata?.isDefaultLibrary || sourceFileMetadata?.isFromExternalLibrary;
74
+ if (isExternal && isNonCritical)
75
+ return;
76
+ // Get the source file and its metadata (if any) for the diagnostic...
77
+ // We do this *after* the external check above as getting the source file
78
+ // is quite expensive (especially for things like "lib.es5.dts")...
79
+ const sourceFile = diagnostic.fileName
80
+ ? ((await program.getSourceFile(diagnostic.fileName)) ??
81
+ (await program.getConfigSourceFile(diagnostic.fileName)))
82
+ : /* coverage ignore next */ undefined;
83
+ // Convert our diagnostic to a report record and return it
84
+ return convertDiagnostic(diagnostic, sourceFile);
85
+ }));
86
+ // Filter out any null/undefined records
87
+ return converted.filter((record) => !!record);
88
+ }
89
+ export async function convertProjectDiagnostics(diagnostics, program, fileName) {
90
+ // Make sure that we have a file name for the diagnostics
91
+ const fileDiagnostics = diagnostics.map((diagnostic) => {
92
+ if (diagnostic.fileName)
93
+ return diagnostic;
94
+ return { ...diagnostic, fileName };
95
+ });
96
+ // Convert the diagnostics to report records and return them
97
+ return convertDiagnostics(fileDiagnostics, program);
98
+ }
99
+ //# sourceMappingURL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QAAQ;YAAE,OAAO,UAAU,CAAA;QAC1C,OAAO,EAAE,GAAG,UAAU,EAAE,QAAQ,EAAE,CAAA;IACpC,CAAC,CAAC,CAAA;IAEF,4DAA4D;IAC5D,OAAO,kBAAkB,CAAC,eAAe,EAAE,OAAO,CAAC,CAAA;AACrD,CAAC"}
@@ -0,0 +1,43 @@
1
+ /** Options for the {@link Pipe.typescript TypeScript} plug. */
2
+ export interface TypeScriptOptions {
3
+ /** Whether referenced projects are built too. Defaults to `false`. */
4
+ projectReferences?: boolean;
5
+ /**
6
+ * Controls how deprecation diagnostics are reported. Use `'notice'` or
7
+ * `true` for notices, `'warn'` for warnings, and `'off'` or `false` to
8
+ * silence them. Defaults to `'notice'`.
9
+ */
10
+ reportDeprecations?: 'warn' | 'notice' | 'off' | boolean;
11
+ /**
12
+ * Controls which files TypeScript emits. Use `'all'` or `true` for
13
+ * JavaScript and declaration files, `'js'` for JavaScript files, `'dts'`
14
+ * for declaration files, and `'none'` or `false` to type-check without
15
+ * emitting files. Defaults to `'all'`.
16
+ */
17
+ emitOnly?: 'js' | 'dts' | 'all' | 'none' | boolean;
18
+ }
19
+ /** Options for the {@link tsc} and {@link tsbuild} helpers. */
20
+ export interface TscOptions extends Omit<TypeScriptOptions, 'projectReferences'> {
21
+ /** Base directory used to resolve the configuration path. */
22
+ directory?: string;
23
+ }
24
+ declare module '@plugjs/plug' {
25
+ interface Pipe {
26
+ /**
27
+ * Run the {@link https://www.typescriptlang.org/ TypeScript Compiler}
28
+ * version 7 (native) over the `tsconfig.json` configuration files
29
+ * given as input to this {@link Pipe} instance.
30
+ */
31
+ typescript(): Pipe;
32
+ /**
33
+ * Run the {@link https://www.typescriptlang.org/ TypeScript Compiler}
34
+ * version 7 (native) over the `tsconfig.json` configuration files
35
+ * given as input to this {@link Pipe} instance.
36
+ *
37
+ * @param options {@link TypeScriptOptions} to use for the build.
38
+ */
39
+ typescript(options: TypeScriptOptions): Pipe;
40
+ }
41
+ }
42
+ export { tsbuild, tsc } from './typescript.ts';
43
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,+DAA+D;AAC/D,MAAM,WAAW,iBAAiB;IAChC,sEAAsE;IACtE,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAE3B;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,GAAG,OAAO,CAAA;IAExD;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,IAAI,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,CAAA;CACnD;AAED,+DAA+D;AAC/D,MAAM,WAAW,UAAW,SAAQ,IAAI,CAAC,iBAAiB,EAAE,mBAAmB,CAAC;IAC9E,6DAA6D;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAiB,IAAI;QACnB;;;;WAIG;QACH,UAAU,IAAI,IAAI,CAAA;QAElB;;;;;;WAMG;QACH,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAAA;KAC7C;CACF;AAID,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ import { install } from '@plugjs/plug/pipe';
2
+ import { TypeScript } from './typescript.js';
3
+ install('typescript', TypeScript);
4
+ export { tsbuild, tsc } from './typescript.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAE3C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAiD5C,OAAO,CAAC,YAAY,EAAE,UAAU,CAAC,CAAA;AAEjC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA"}
@@ -0,0 +1,72 @@
1
+ import type { ReportRecord } from '@plugjs/plug/logging';
2
+ import type { AbsolutePath } from '@plugjs/plug/paths';
3
+ import type { API, ParsedCommandLine } from 'typescript/unstable/async';
4
+ /** Interface describing the actual (resolved) config file and its references */
5
+ interface ProjectReferences {
6
+ /** The actual path of the configuration file containing the references */
7
+ path: AbsolutePath;
8
+ /** The actual configuration parsed from the configuration file */
9
+ config: ParsedCommandLine;
10
+ /** The actual paths of all configuration files referenced by this project */
11
+ references: AbsolutePath[];
12
+ /** Any errors encountered while reading the configuration file */
13
+ errors: ReportRecord[];
14
+ }
15
+ /** Interface describing a group of cross-referencing projects */
16
+ interface Projects {
17
+ /** All projects to build, each associated with its referencing projects */
18
+ projects: Map<AbsolutePath, Set<AbsolutePath>>;
19
+ /** Any errors encountered while reading the configuration files */
20
+ errors: ReportRecord[];
21
+ }
22
+ /** Interface describing the order of projects, including any cycles and unresolved projects */
23
+ interface ProjectOrder {
24
+ /** The order in which projects should be built */
25
+ order: AbsolutePath[];
26
+ /** Array of project reference cycles */
27
+ cycles: AbsolutePath[][];
28
+ /** Array containing all projects that could not be ordered because of cyclical dependencies */
29
+ unresolved: AbsolutePath[];
30
+ /** Any errors encountered while resolving the project order */
31
+ errors: ReportRecord[];
32
+ }
33
+ /**
34
+ * Find the TypeScript project configuration file for a given path.
35
+ *
36
+ * The path specified can be a `tsconfig.json` file name or a directory
37
+ * containing a `tsconfig.json` file.
38
+ *
39
+ * The returned path is the absolute path of the actual `tsconfig.json` file.
40
+ */
41
+ export declare function findProjectConfig(path: AbsolutePath): AbsolutePath;
42
+ /**
43
+ * Read the TypeScript project configuration file for a given path.
44
+ *
45
+ * The path specified can be a `tsconfig.json` file name or a directory
46
+ * containing a `tsconfig.json` file.
47
+ *
48
+ * The returned object contains the resolved configuration file name (in `path`)
49
+ * and the array of resolved project references (the actual resolved files on
50
+ * disk in `references`).
51
+ *
52
+ * Any errors encountered while reading the configuration file or resolving its
53
+ * references are returned in the `errors` array.
54
+ */
55
+ export declare function readProjectConfig(api: API, path: AbsolutePath): Promise<ProjectReferences>;
56
+ /**
57
+ * Find _all_ project references given a set of initial project paths.
58
+ *
59
+ * The returned map contains all the projects (resolved configuration file
60
+ * names) and their referring projects as values.
61
+ */
62
+ export declare function findProjectReferences(api: API, ...paths: AbsolutePath[]): Promise<Projects>;
63
+ /**
64
+ * Use Kahn's topological-sort algorithm on a map of projects and their
65
+ * references to determine the order in which they should be built.
66
+ *
67
+ * @param projects A map of projects and their referring projects
68
+ * @returns The order of projects, any unresolved projects, and cycles found
69
+ */
70
+ export declare function resolveProjectOrder(projects: ReadonlyMap<AbsolutePath, Set<AbsolutePath>>): ProjectOrder;
71
+ export {};
72
+ //# sourceMappingURL=projects.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projects.d.ts","sourceRoot":"","sources":["../src/projects.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,KAAK,EAAE,GAAG,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAEvE,gFAAgF;AAChF,UAAU,iBAAiB;IACzB,0EAA0E;IAC1E,IAAI,EAAE,YAAY,CAAA;IAClB,kEAAkE;IAClE,MAAM,EAAE,iBAAiB,CAAA;IACzB,6EAA6E;IAC7E,UAAU,EAAE,YAAY,EAAE,CAAA;IAC1B,kEAAkE;IAClE,MAAM,EAAE,YAAY,EAAE,CAAA;CACvB;AAED,iEAAiE;AACjE,UAAU,QAAQ;IAChB,2EAA2E;IAC3E,QAAQ,EAAE,GAAG,CAAC,YAAY,EAAE,GAAG,CAAC,YAAY,CAAC,CAAC,CAAA;IAC9C,mEAAmE;IACnE,MAAM,EAAE,YAAY,EAAE,CAAA;CACvB;AAED,+FAA+F;AAC/F,UAAU,Y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