@plugjs/typescript 0.6.80 → 0.6.81

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/dist/index.cjs CHANGED
@@ -3,6 +3,10 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
6
10
  var __copyProps = (to, from, except, desc) => {
7
11
  if (from && typeof from === "object" || typeof from === "function") {
8
12
  for (let key of __getOwnPropNames(from))
@@ -15,8 +19,22 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
15
19
 
16
20
  // index.ts
17
21
  var index_exports = {};
22
+ __export(index_exports, {
23
+ tscBuild: () => tscBuild
24
+ });
18
25
  module.exports = __toCommonJS(index_exports);
26
+ var import_plug = require("@plugjs/plug");
19
27
  var import_fork = require("@plugjs/plug/fork");
20
28
  var import_paths = require("@plugjs/plug/paths");
21
29
  (0, import_fork.installForking)("tsc", (0, import_paths.requireResolve)(__filename, "./typescript"), "Tsc");
30
+ (0, import_fork.installForking)("tscBuild", (0, import_paths.requireResolve)(__filename, "./tscbuild"), "TscBuild");
31
+ function tscBuild(tsconfigOrOptions, maybeOptions) {
32
+ const [tsconfig, tscBuildOptions] = typeof tsconfigOrOptions === "string" ? [tsconfigOrOptions, maybeOptions] : ["tsconfig.json", tsconfigOrOptions];
33
+ const { directory, ...buildOptions } = tscBuildOptions || {};
34
+ return (0, import_plug.find)(tsconfig, { directory }).tscBuild(buildOptions);
35
+ }
36
+ // Annotate the CommonJS export names for ESM import in node:
37
+ 0 && (module.exports = {
38
+ tscBuild
39
+ });
22
40
  //# sourceMappingURL=index.cjs.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts"],
4
- "mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,kBAA+B;AAC/B,mBAA+B;AAAA,IA6D/B,4BAAe,WAAO,6BAAe,YAAW,cAAc,GAAG,KAAK;",
4
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAqB;AACrB,kBAA+B;AAC/B,mBAA+B;AAAA,IAgF/B,4BAAe,WAAO,6BAAe,YAAW,cAAc,GAAG,KAAK;AAAA,IACtE,4BAAe,gBAAY,6BAAe,YAAW,YAAY,GAAG,UAAU;AAiCvE,SAAS,SACZ,mBACA,cACI;AACN,QAAM,CAAE,UAAU,eAAgB,IAChC,OAAO,sBAAsB,WACzB,CAAE,mBAAmB,YAAa,IAClC,CAAE,iBAAiB,iBAAkB;AAE3C,QAAM,EAAE,WAAW,GAAG,aAAa,IAAI,mBAAmB,CAAC;AAC3D,aAAO,kBAAK,UAAU,EAAE,UAAU,CAAC,EAAE,SAAS,YAAY;AAC5D;",
5
5
  "names": []
6
6
  }
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import type { CompilerOptions } from 'typescript';
1
+ import type { Pipe } from '@plugjs/plug';
2
+ import type { BuildOptions, CompilerOptions } from 'typescript';
2
3
  /** Remove the mapped `[option: string]: ...` from `CompilerOptions`. */
3
4
  type KnownCompilerOptions = {
4
5
  [k in keyof CompilerOptions as string extends k ? never : k]: CompilerOptions[k];
@@ -48,6 +49,50 @@ declare module '@plugjs/plug' {
48
49
  * the contents of the specified `tsconfig.json`.
49
50
  */
50
51
  tsc(configFile: string, options: ExtendedCompilerOptions): Pipe;
52
+ /**
53
+ * Run the {@link https://www.typescriptlang.org/ TypeScript Builder}
54
+ * over the specified project `tsconfig.json` files.
55
+ */
56
+ tscBuild(): Pipe;
57
+ /**
58
+ * Run the {@link https://www.typescriptlang.org/ TypeScript Builder}
59
+ * over the specified project `tsconfig.json` files.
60
+ *
61
+ * With regards to `options`, the defaults are:
62
+ * - `verbose: true`
63
+ * - `force: true`
64
+ *
65
+ * @param options {@link BuildOptions} to use for the build.
66
+ */
67
+ tscBuild(options: BuildOptions): Pipe;
51
68
  }
52
69
  }
70
+ export interface TscBuildOptions extends BuildOptions {
71
+ /** The directory where to look for the `tsconfig.json` files. */
72
+ directory?: string;
73
+ }
74
+ /**
75
+ * Run `tsc --build` using `tsconfig.json` from the current directory.
76
+ */
77
+ export declare function tscBuild(): Pipe;
78
+ /**
79
+ * Run `tsc --build` using the specified `tsconfig.json` file.
80
+ */
81
+ export declare function tscBuild(tsconfig: string): Pipe;
82
+ /**
83
+ * Run `tsc --build` using the specified options.
84
+ *
85
+ * The `directory` option specifies where to look for the `tsconfig.json` files,
86
+ * and defaults to the current directory, `verbose` and `force` default to
87
+ * `true`.
88
+ */
89
+ export declare function tscBuild(options: TscBuildOptions): Pipe;
90
+ /**
91
+ * Run `tsc --build` using the specified `tsconfig.json` and options.
92
+ *
93
+ * The `directory` option specifies where to look for the `tsconfig.json` files,
94
+ * and defaults to the current directory, `verbose` and `force` default to
95
+ * `true`.
96
+ */
97
+ export declare function tscBuild(tsconfig: string, options?: TscBuildOptions): Pipe;
53
98
  export {};
package/dist/index.mjs CHANGED
@@ -1,5 +1,15 @@
1
1
  // index.ts
2
+ import { find } from "@plugjs/plug";
2
3
  import { installForking } from "@plugjs/plug/fork";
3
4
  import { requireResolve } from "@plugjs/plug/paths";
4
5
  installForking("tsc", requireResolve(import.meta.url, "./typescript"), "Tsc");
6
+ installForking("tscBuild", requireResolve(import.meta.url, "./tscbuild"), "TscBuild");
7
+ function tscBuild(tsconfigOrOptions, maybeOptions) {
8
+ const [tsconfig, tscBuildOptions] = typeof tsconfigOrOptions === "string" ? [tsconfigOrOptions, maybeOptions] : ["tsconfig.json", tsconfigOrOptions];
9
+ const { directory, ...buildOptions } = tscBuildOptions || {};
10
+ return find(tsconfig, { directory }).tscBuild(buildOptions);
11
+ }
12
+ export {
13
+ tscBuild
14
+ };
5
15
  //# sourceMappingURL=index.mjs.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts"],
4
- "mappings": ";AAAA,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AA6D/B,eAAe,OAAO,eAAe,iBAAW,cAAc,GAAG,KAAK;",
4
+ "mappings": ";AAAA,SAAS,YAAY;AACrB,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAgF/B,eAAe,OAAO,eAAe,iBAAW,cAAc,GAAG,KAAK;AACtE,eAAe,YAAY,eAAe,iBAAW,YAAY,GAAG,UAAU;AAiCvE,SAAS,SACZ,mBACA,cACI;AACN,QAAM,CAAE,UAAU,eAAgB,IAChC,OAAO,sBAAsB,WACzB,CAAE,mBAAmB,YAAa,IAClC,CAAE,iBAAiB,iBAAkB;AAE3C,QAAM,EAAE,WAAW,GAAG,aAAa,IAAI,mBAAmB,CAAC;AAC3D,SAAO,KAAK,UAAU,EAAE,UAAU,CAAC,EAAE,SAAS,YAAY;AAC5D;",
5
5
  "names": []
6
6
  }
package/dist/report.cjs CHANGED
@@ -86,9 +86,29 @@ function convertDiagnostics(diagnostics, directory) {
86
86
  }
87
87
  });
88
88
  }
89
- function updateReport(report, diagnostics, directory) {
89
+ function updateReport(report, diagnostics, directory, logger) {
90
90
  const records = convertDiagnostics(diagnostics, directory);
91
- report.add(...records);
91
+ if (!logger) {
92
+ report.add(...records);
93
+ return;
94
+ }
95
+ for (const record of records) {
96
+ if (record.file) {
97
+ report.add(record);
98
+ } else {
99
+ switch (record.level) {
100
+ case import_logging.ERROR:
101
+ logger.error(record.message);
102
+ break;
103
+ case import_logging.WARN:
104
+ logger.warn(record.message);
105
+ break;
106
+ case import_logging.NOTICE:
107
+ logger.info(record.message);
108
+ break;
109
+ }
110
+ }
111
+ }
92
112
  }
93
113
  // Annotate the CommonJS export names for ESM import in node:
94
114
  0 && (module.exports = {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version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WAAW,IAAI;AAGjC,QAAI,WAAW,MAAM;AACnB,YAAM,EAAE,MAAM,YAAY,OAAO,OAAO,IAAI;AAC5C,YAAM,WAAO,kCAAoB,WAAW,WAAW,QAAQ;AAC/D,YAAM,SAAS,WAAW,YAAY;AAGtC,UAAI,UAAU,QAAW;AACvB,cAAM,WAAW,WAAW,8BAA8B,KAAK;AAC/D,YAAI,EAAE,MAAM,WAAW,OAAO,IAAI;AAClC,kBAAU;AACV,gBAAQ;AAER,eAAO,EAAE,OAAO,SAAS,MAAM,MAAM,QAAQ,MAAM,QAAQ,OAAO;AAAA,MACpE,OAAO;AACL,eAAO,EAAE,OAAO,SAAS,MAAM,MAAM,OAAO;AAAA,MAC9C;AAAA,IACF,OAAO;AACL,aAAO,EAAE,OAAO,SAAS,KAAK;AAAA,IAChC;AAAA,EACF,CAAC;AACH;AASO,SAAS,aACZ,QACA,aACA,WACA,QACI;AACN,QAAM,UAAU,mBAAmB,aAAa,SAAS;AACzD,MAAI,CAAE,QAAQ;AACZ,WAAO,IAAI,GAAG,OAAO;AACrB;AAAA,EACF;AAEA,aAAW,UAAU,SAAS;AAC5B,QAAI,OAAO,MAAM;AACf,aAAO,IAAI,MAAM;AAAA,IACnB,OAAO;AACL,cAAQ,OAAO,OAAO;AAAA,QACpB,KAAK;AAAO,iBAAO,MAAM,OAAO,OAAO;AAAG;AAAA,QAC1C,KAAK;AAAM,iBAAO,KAAK,OAAO,OAAO;AAAG;AAAA,QACxC,KAAK;AAAQ,iBAAO,KAAK,OAAO,OAAO;AAAG;AAAA,MAC5C;AAAA,IACF;AAAA,EACF;AACF;",
5
5
  "names": ["ts"]
6
6
  }
package/dist/report.d.ts CHANGED
@@ -1,5 +1,11 @@
1
1
  import ts from 'typescript';
2
- import type { Report } from '@plugjs/plug/logging';
2
+ import type { Logger, Report } from '@plugjs/plug/logging';
3
3
  import type { AbsolutePath } from '@plugjs/plug/paths';
4
- /** Update a report, adding records from an array of {@link ts.Diagnostic} */
5
- export declare function updateReport(report: Report, diagnostics: readonly ts.Diagnostic[], directory: AbsolutePath): void;
4
+ /**
5
+ * Update a report, adding records from an array of {@link ts.Diagnostic}
6
+ *
7
+ * When a `logger` is provided, diagnostics without a file will be logged
8
+ * directly to the logger instead of being added to the report (therefore the
9
+ * report will not _fail_ in case of such diagnostics).
10
+ */
11
+ export declare function updateReport(report: Report, diagnostics: readonly ts.Diagnostic[], directory: AbsolutePath, logger?: Logger): void;
package/dist/report.mjs CHANGED
@@ -52,9 +52,29 @@ function convertDiagnostics(diagnostics, directory) {
52
52
  }
53
53
  });
54
54
  }
55
- function updateReport(report, diagnostics, directory) {
55
+ function updateReport(report, diagnostics, directory, logger) {
56
56
  const records = convertDiagnostics(diagnostics, directory);
57
- report.add(...records);
57
+ if (!logger) {
58
+ report.add(...records);
59
+ return;
60
+ }
61
+ for (const record of records) {
62
+ if (record.file) {
63
+ report.add(record);
64
+ } else {
65
+ switch (record.level) {
66
+ case ERROR:
67
+ logger.error(record.message);
68
+ break;
69
+ case WARN:
70
+ logger.warn(record.message);
71
+ break;
72
+ case NOTICE:
73
+ logger.info(record.message);
74
+ break;
75
+ }
76
+ }
77
+ }
58
78
  }
59
79
  export {
60
80
  updateReport
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/report.ts"],
4
- "mappings": ";AAAA,SAAS,OAAO,QAAQ,YAAY;AACpC,SAAS,2BAA2B;AACpC,OAAO,QAAQ;AAMf,SAAS,oBAAoB,OAAkC,SAAS,GAAa;AACnF,QAAM,UAAU,GAAG,GAAG,SAAS,SAAS,CAAC,CAAC,GAAG,MAAM,WAAW;AAE9D,MAAI,MAAM,MAAM;AACd,UAAM,OAAO,MAAM,KAAK,IAAI,CAAC,MAAM,oBAAoB,GAAG,SAAS,CAAC,CAAC;AACrE,WAAO,CAAE,SAAS,GAAG,KAAK,KAAK,CAAC,CAAE;AAAA,EACpC,OAAO;AACL,WAAO,CAAE,OAAQ;AAAA,EACnB;AACF;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aACA,WACA,QACI;AACN,QAAM,UAAU,mBAAmB,aAAa,SAAS;AACzD,MAAI,CAAE,QAAQ;AACZ,WAAO,IAAI,GAAG,OAAO;AACrB;AAAA,EACF;AAEA,aAAW,UAAU,SAAS;AAC5B,QAAI,OAAO,MAAM;AACf,aAAO,IAAI,MAAM;AAAA,IACnB,OAAO;AACL,cAAQ,OAAO,OAAO;AAAA,QACpB,KAAK;AAAO,iBAAO,MAAM,OAAO,OAAO;AAAG;AAAA,QAC1C,KAAK;AAAM,iBAAO,KAAK,OAAO,OAAO;AAAG;AAAA,QACxC,KAAK;AAAQ,iBAAO,KAAK,OAAO,OAAO;AAAG;AAAA,MAC5C;AAAA,IACF;AAAA,EACF;AACF;",
5
5
  "names": []
6
6
  }
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // tscbuild.ts
31
+ var tscbuild_exports = {};
32
+ __export(tscbuild_exports, {
33
+ TscBuild: () => TscBuild
34
+ });
35
+ module.exports = __toCommonJS(tscbuild_exports);
36
+ var import_plug = require("@plugjs/plug");
37
+ var import_files = require("@plugjs/plug/files");
38
+ var import_typescript = __toESM(require("typescript"), 1);
39
+ var import_report = require("./report.cjs");
40
+ var import_writefile = require("./writefile.cjs");
41
+ var TscBuild = class {
42
+ _options;
43
+ constructor(...args) {
44
+ this._options = {
45
+ verbose: true,
46
+ force: true,
47
+ ...args[0] || {}
48
+ };
49
+ }
50
+ async pipe(files, context) {
51
+ const report = context.log.report("TypeScript Builder Report");
52
+ const builder = import_files.Files.builder(files.directory);
53
+ const writeFile = (0, import_writefile.buildWriteFile)(builder, context);
54
+ function reporter(diagnostic) {
55
+ (0, import_report.updateReport)(report, [diagnostic], files.directory, context.log);
56
+ }
57
+ const solutionBuilderHost = import_typescript.default.createSolutionBuilderHost(
58
+ import_typescript.default.sys,
59
+ // system
60
+ void 0,
61
+ // createProgram
62
+ reporter,
63
+ // reportDiagnostic
64
+ reporter,
65
+ // reportSolutionBuilderStatus
66
+ void 0
67
+ // reportSolutionBuilderErrorSummary
68
+ );
69
+ const solutionBuilder = import_typescript.default.createSolutionBuilder(
70
+ solutionBuilderHost,
71
+ [...files.absolutePaths()],
72
+ this._options
73
+ );
74
+ const exitCode = solutionBuilder.build(
75
+ void 0,
76
+ // project (string)
77
+ void 0,
78
+ // cancellationToken
79
+ writeFile,
80
+ // writeFile
81
+ void 0
82
+ // getCustomTransformers
83
+ );
84
+ let failure;
85
+ switch (exitCode) {
86
+ case import_typescript.default.ExitStatus.Success:
87
+ context.log.info("TSC Build completed successfully");
88
+ failure = false;
89
+ break;
90
+ case import_typescript.default.ExitStatus.DiagnosticsPresent_OutputsSkipped:
91
+ context.log.error("TSC Build failed with errors (see report)");
92
+ failure = true;
93
+ break;
94
+ case import_typescript.default.ExitStatus.DiagnosticsPresent_OutputsGenerated:
95
+ context.log.warn("TSC Build completed with errors (see report)");
96
+ failure = true;
97
+ break;
98
+ case import_typescript.default.ExitStatus.InvalidProject_OutputsSkipped:
99
+ context.log.error("TSC Build failed due to invalid project configuration");
100
+ failure = true;
101
+ break;
102
+ case import_typescript.default.ExitStatus.ProjectReferenceCycle_OutputsSkipped:
103
+ context.log.error("TSC Build failed due to project reference cycle");
104
+ failure = true;
105
+ break;
106
+ default:
107
+ context.log.error("TSC Build failed with exit code", exitCode);
108
+ failure = true;
109
+ break;
110
+ }
111
+ report.done(true);
112
+ if (failure) (0, import_plug.fail)("TSC Build failed");
113
+ const outputs = builder.build();
114
+ context.log.info("TSC Build produced", outputs.length, "files into", (0, import_plug.$p)(outputs.directory));
115
+ return outputs;
116
+ }
117
+ };
118
+ // Annotate the CommonJS export names for ESM import in node:
119
+ 0 && (module.exports = {
120
+ TscBuild
121
+ });
122
+ //# sourceMappingURL=tscbuild.cjs.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/tscbuild.ts"],
4
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAyB;AACzB,mBAAsB;AACtB,wBAAe;AAEf,oBAA6B;AAC7B,uBAA+B;AAIxB,IAAM,WAAN,MAAsC;AAAA,EAC1B;AAAA,EAEjB,eAAe,MAAkC;AAC/C,SAAK,WAAW;AAAA,MACd,SAAS;AAAA,MACT,OAAO;AAAA,MACP,GAAI,KAAK,CAAC,KAAK,CAAC;AAAA,IAClB;AAAA,EACF;AAAA,EAEA,MAAM,KAAK,OAAc,SAAkC;AACzD,UAAM,SAAS,QAAQ,IAAI,OAAO,2BAA2B;AAC7D,UAAM,UAAU,mBAAM,QAAQ,MAAM,SAAS;AAC7C,UAAM,gBAAY,iCAAe,S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C1F,WAAO;AAAA,EACT;AACF;",
5
+ "names": ["ts"]
6
+ }
@@ -0,0 +1,7 @@
1
+ import { Files } from '@plugjs/plug/files';
2
+ import type { Context, PipeParameters, Plug } from '@plugjs/plug/pipe';
3
+ export declare class TscBuild implements Plug<Files> {
4
+ private readonly _options;
5
+ constructor(...args: PipeParameters<'tscBuild'>);
6
+ pipe(files: Files, context: Context): Promise<Files>;
7
+ }
@@ -0,0 +1,87 @@
1
+ // tscbuild.ts
2
+ import { $p, fail } from "@plugjs/plug";
3
+ import { Files } from "@plugjs/plug/files";
4
+ import ts from "typescript";
5
+ import { updateReport } from "./report.mjs";
6
+ import { buildWriteFile } from "./writefile.mjs";
7
+ var TscBuild = class {
8
+ _options;
9
+ constructor(...args) {
10
+ this._options = {
11
+ verbose: true,
12
+ force: true,
13
+ ...args[0] || {}
14
+ };
15
+ }
16
+ async pipe(files, context) {
17
+ const report = context.log.report("TypeScript Builder Report");
18
+ const builder = Files.builder(files.directory);
19
+ const writeFile = buildWriteFile(builder, context);
20
+ function reporter(diagnostic) {
21
+ updateReport(report, [diagnostic], files.directory, context.log);
22
+ }
23
+ const solutionBuilderHost = ts.createSolutionBuilderHost(
24
+ ts.sys,
25
+ // system
26
+ void 0,
27
+ // createProgram
28
+ reporter,
29
+ // reportDiagnostic
30
+ reporter,
31
+ // reportSolutionBuilderStatus
32
+ void 0
33
+ // reportSolutionBuilderErrorSummary
34
+ );
35
+ const solutionBuilder = ts.createSolutionBuilder(
36
+ solutionBuilderHost,
37
+ [...files.absolutePaths()],
38
+ this._options
39
+ );
40
+ const exitCode = solutionBuilder.build(
41
+ void 0,
42
+ // project (string)
43
+ void 0,
44
+ // cancellationToken
45
+ writeFile,
46
+ // writeFile
47
+ void 0
48
+ // getCustomTransformers
49
+ );
50
+ let failure;
51
+ switch (exitCode) {
52
+ case ts.ExitStatus.Success:
53
+ context.log.info("TSC Build completed successfully");
54
+ failure = false;
55
+ break;
56
+ case ts.ExitStatus.DiagnosticsPresent_OutputsSkipped:
57
+ context.log.error("TSC Build failed with errors (see report)");
58
+ failure = true;
59
+ break;
60
+ case ts.ExitStatus.DiagnosticsPresent_OutputsGenerated:
61
+ context.log.warn("TSC Build completed with errors (see report)");
62
+ failure = true;
63
+ break;
64
+ case ts.ExitStatus.InvalidProject_OutputsSkipped:
65
+ context.log.error("TSC Build failed due to invalid project configuration");
66
+ failure = true;
67
+ break;
68
+ case ts.ExitStatus.ProjectReferenceCycle_OutputsSkipped:
69
+ context.log.error("TSC Build failed due to project reference cycle");
70
+ failure = true;
71
+ break;
72
+ default:
73
+ context.log.error("TSC Build failed with exit code", exitCode);
74
+ failure = true;
75
+ break;
76
+ }
77
+ report.done(true);
78
+ if (failure) fail("TSC Build failed");
79
+ const outputs = builder.build();
80
+ context.log.info("TSC Build produced", outputs.length, "files into", $p(outputs.directory));
81
+ return outputs;
82
+ }
83
+ };
84
+ export {
85
+ TscBuild
86
+ };
87
+ //# sourceMappingURL=tscbuild.mjs.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/tscbuild.ts"],
4
+ "mappings": ";AAAA,SAAS,IAAI,YAAY;AACzB,SAAS,aAAa;AACtB,OAAO,QAAQ;AAEf,SAAS,oBAAoB;AAC7B,SAAS,sBAAsB;AAIxB,IAAM,WAAN,MAAsC;AAAA,EAC1B;AAAA,EAEjB,eAAe,MAAkC;AAC/C,SAAK,WAAW;AAAA,MACd,SAAS;AAAA,MACT,OAAO;AAAA,MACP,GAAI,KAAK,CAAC,KAAK,CAAC;AAAA,IAClB;AAAA,EACF;AAAA,EAEA,MAAM,KAAK,OAAc,SAAkC;AACzD,UAAM,SAAS,QAAQ,IAAI,OAAO,2BAA2B;AAC7D,UAAM,UAAU,MAAM,QAAQ,MAAM,SAAS;AAC7C,UAAM,YAAY,eAAe,SAAS,OAAO;AAEjD,aAAS,SAAS,YAAiC;AACjD,mBAAa,QAAQ,CAAE,UAAW,GAAG,MAAM,WAAW,QAAQ,GAAG;AAAA,IACnE;AAEA,UAAM,sBAAsB,GAAG;AAAA,MAC3B,GAAG;AAAA;AAAA,MACH;AAAA;AAAA,MACA;AAAA;AAAA,MACA;AAAA;AAAA,MACA;AAAA;AAAA,IACJ;AAEA,UAAM,kBAAkB,GAAG;AAAA,MACvB;AAAA,MACA,CAAE,GAAG,MAAM,cAAc,CAAE;AAAA,MAC3B,KAAK;AAAA,IACT;AAEA,UAAM,WAAW,gBAAgB;AAAA,MAC7B;AAAA;AAAA,MACA;AAAA;AAAA,MACA;AAAA;AAAA,MACA;AAAA;AAAA,IACJ;AAEA,QAAI;AACJ,YAAQ,UAAU;AAAA,MAChB,KAAK,GAAG,WAAW;AACjB,gBAAQ,IAAI,KAAK,kCAAkC;AACnD,kBAAU;AACV;AAAA,MACF,KAAK,GAAG,WAAW;AACjB,gBAAQ,IAAI,MAAM,2CAA2C;AAC7D,kBAAU;AACV;AAAA,MACF,KAAK,GAAG,WAAW;AACjB,gBAAQ,IAAI,KAAK,8CAA8C;AAC/D,kBAAU;AACV;AAAA,MACF,KAAK,GAAG,WAAW;AACjB,gBAAQ,IAAI,MAAM,uDAAuD;AACzE,kBAAU;AACV;AAAA,MACF,KAAK,GAAG,WAAW;AACjB,gBAAQ,IAAI,MAAM,iDAAiD;AACnE,kBAAU;AACV;AAAA,MACF;AACE,gBAAQ,IAAI,MAAM,mCAAmC,QAAQ;AAC7D,kBAAU;AACV;AAAA,IACJ;AAEA,WAAO,KAAK,IAAI;AAChB,QAAI,QAAS,MAAK,kBAAkB;AAEpC,UAAM,UAAU,QAAQ,MAAM;AAC9B,YAAQ,IAAI,KAAK,sBAAsB,QAAQ,QAAQ,cAAc,GAAG,QAAQ,SAAS,CAAC;AAC1F,WAAO;AAAA,EACT;AACF;",
5
+ "names": []
6
+ }
@@ -42,6 +42,7 @@ var import_typescript = __toESM(require("typescript"), 1);
42
42
  var import_compiler = require("./compiler.cjs");
43
43
  var import_options = require("./options.cjs");
44
44
  var import_report = require("./report.cjs");
45
+ var import_writefile = require("./writefile.cjs");
45
46
  function defaultRootDir(paths) {
46
47
  const [firstPath, ...restPaths] = paths.filter((path) => {
47
48
  return !path.match(/\.d\.[mc]?ts$/i);
@@ -119,20 +120,8 @@ var Tsc = class {
119
120
  (0, import_report.updateReport)(report, diagnostics, rootDir);
120
121
  if (report.errors) report.done(true);
121
122
  const builder = import_files.Files.builder(outDir);
122
- const promises = [];
123
- const result = program.emit(void 0, (fileName, code) => {
124
- promises.push(builder.write(fileName, code).then((file) => {
125
- context.log.trace("Written", (0, import_logging.$p)(file));
126
- }).catch(
127
- /* coverage ignore next */
128
- (error) => {
129
- const outFile = (0, import_paths.resolveAbsolutePath)(outDir, fileName);
130
- context.log.error("Error writing to", (0, import_logging.$p)(outFile), error);
131
- throw import_asserts.BuildFailure.fail();
132
- }
133
- ));
134
- });
135
- await (0, import_asserts.assertPromises)(promises);
123
+ const writeFile = (0, import_writefile.buildWriteFile)(builder, context);
124
+ const result = program.emit(void 0, writeFile);
136
125
  (0, import_report.updateReport)(report, result.diagnostics, rootDir);
137
126
  if (report.errors) report.done(true);
138
127
  const outputs = builder.build();
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/typescript.ts"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAqD;AACrD,mBAAsB;AACtB,qBAAmB;AACnB,mBAAgF;AAChF,mBAAmC;AACnC,wBAAe;AAEf,sBAA+B;AAC/B,qBAAmC;AACnC,oBAA6B;AAW7B,SAAS,eAAe,OAAqC;AAC3D,QAAM,CAAE,WAAW,GAAG,SAAU,IAAI,MAAM,OAAO,CAAC,SAAS;AACzD,WAAO,CAAE,KAAK,MAAM,gBAAgB;AAAA,EACtC,CAAC;AAED,6BAAO,WAAW,2CAA2C;AAC7D,MAAI,UAAU,OAAQ,YAAO,yBAAW,WAAW,GAAG,SAAS;AAC/D,aAAO,gCAAkB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ACzC,QAAI,OAAO,OAAQ,QAAO,KAAK,IAAI;AAGnC,UAAM,UAAU,mBAAM,QAAQ,MAAM;AACpC,UAAM,gBAAY,iCAAe,SAAS,OAAO;AACjD,UAAM,SAAS,QAAQ,KAAK,QAAW,SAAS;AAGhD,oCAAa,QAAQ,OAAO,aAAa,OAAO;AAEhD,QAAI,OAAO,OAAQ,QAAO,KAAK,IAAI;AAGnC,UAAM,UAAU,QAAQ,MAAM;AAC9B,YAAQ,IAAI,KAAK,gBAAgB,QAAQ,QAAQ,kBAAc,mBAAG,QAAQ,SAAS,CAAC;AACpF,WAAO;AAAA,EACT;AACF;",
5
5
  "names": ["ts"]
6
6
  }
@@ -1,5 +1,5 @@
1
1
  // typescript.ts
2
- import { assert, assertPromises, BuildFailure } from "@plugjs/plug/asserts";
2
+ import { assert } from "@plugjs/plug/asserts";
3
3
  import { Files } from "@plugjs/plug/files";
4
4
  import { $p } from "@plugjs/plug/logging";
5
5
  import { commonPath, getAbsoluteParent, resolveAbsolutePath, resolveFile } from "@plugjs/plug/paths";
@@ -8,6 +8,7 @@ import ts from "typescript";
8
8
  import { TypeScriptHost } from "./compiler.mjs";
9
9
  import { getCompilerOptions } from "./options.mjs";
10
10
  import { updateReport } from "./report.mjs";
11
+ import { buildWriteFile } from "./writefile.mjs";
11
12
  function defaultRootDir(paths) {
12
13
  const [firstPath, ...restPaths] = paths.filter((path) => {
13
14
  return !path.match(/\.d\.[mc]?ts$/i);
@@ -85,20 +86,8 @@ var Tsc = class {
85
86
  updateReport(report, diagnostics, rootDir);
86
87
  if (report.errors) report.done(true);
87
88
  const builder = Files.builder(outDir);
88
- const promises = [];
89
- const result = program.emit(void 0, (fileName, code) => {
90
- promises.push(builder.write(fileName, code).then((file) => {
91
- context.log.trace("Written", $p(file));
92
- }).catch(
93
- /* coverage ignore next */
94
- (error) => {
95
- const outFile = resolveAbsolutePath(outDir, fileName);
96
- context.log.error("Error writing to", $p(outFile), error);
97
- throw BuildFailure.fail();
98
- }
99
- ));
100
- });
101
- await assertPromises(promises);
89
+ const writeFile = buildWriteFile(builder, context);
90
+ const result = program.emit(void 0, writeFile);
102
91
  updateReport(report, result.diagnostics, rootDir);
103
92
  if (report.errors) report.done(true);
104
93
  const outputs = builder.build();
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/typescript.ts"],
4
- "mappings": ";AAAA,SAAS,QAAQ,gBAAgB,oBAAoB;AACrD,SAAS,aAAa;AACtB,SAAS,UAAU;AACnB,SAAS,YAAY,mBAAmB,qBAAqB,mBAAmB;AAChF,SAAS,cAAc,YAAY;AACnC,OAAO,QAAQ;AAEf,SAAS,sBAAsB;AAC/B,SAAS,0BAA0B;AACnC,SAAS,oBAAoB;AAW7B,SAAS,eAAe,OAAqC;AAC3D,QAAM,CAAE,WAAW,GAAG,SAAU,IAAI,MAAM,OAAO,CAAC,SAAS;AACzD,WAAO,CAAE,KAAK,MAAM,gBAAgB;AAAA,EACtC,CAAC;AAED,SAAO,WAAW,2CAA2C;AAC7D,MAAI,UAAU,OAAQ,QAAO,WAAW,WAAW,GAAG,SAAS;AAC/D,SAAO,kBAAkB,SAAS;AACpC;AAEO,IAAM,MAAN,MAAiC;AAAA,EACrB;AAAA,EACA;AAAA,EAEjB,eAAe,MAA6B;AAC1C,UAAM,EAAE,QAAQ,CAAE,QAAS,GAAG,QAAQ,IAAI,aAAa,MAAM,CAAC,CAAC;AAC/D,SAAK,YAAY;AACjB,SAAK,WAAW;AAAA,EAClB;AAAA,EAEA,MAAM,KAAK,OAAc,SAAkC;AACzD,UAAM,QAAQ,CAAE,GAAG,MAAM,cAAc,CAAE;AAGzC,UAAM,SAAS,QAAQ,IAAI,OAAO,mBAAmB;AAGrD,UAAM,EAAE,eAAe,GAAG,YAAY,IAAI,EAAE,GAAG,KAAK,SAAS;AAE7D,QAAI,eAAe;AACjB,YAAM,YAAY,QAAQ,QAAQ,aAAa;AAE/C,uBAAiB,QAAQ,KAAK,WAAW,CAAE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AAI,CAAC,GAAG;AAC3D,cAAM,KAAK,IAAI;AAAA,MACjB;AAAA,IACF;AAGA,UAAM,UAAU,QAAQ,UACtB,QAAQ,QAAQ,QAAQ,OAAO,IAC/B,eAAe,KAAK;AACtB,QAAI,EAAE,QAAQ,WAAW,QAAQ,UAAW,SAAQ,UAAU;AAG9D,UAAM,SAAS,QAAQ,SAAS,QAAQ,QAAQ,QAAQ,MAAM,IAAI;AAClE,QAAI,EAAE,QAAQ,UAAU,QAAQ,SAAU,SAAQ,SAAS;AAG3D,YAAQ,IAAI,KAAK,uBAAuB,OAAO;AAC/C,QAAI,mBAAmB,OAAQ,SAAQ,IAAI,KAAK,sBAAsB,iBAAiB;AAGvF,UAAM,OAAO,IAAI,eAAe,OAAO;AACvC,UAAM,UAAU,GAAG,cAAc;AAAA,MAC/B,8BAA8B;AAAA,MAC9B,WAAW;AAAA,MACX;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AACD,UAAM,cAAc,GAAG,sBAAsB,OAAO;AAGpD,iBAAa,QAAQ,aAAa,OAAO;AACzC,QAAI,OAAO,OAAQ,QAAO,KAAK,IAAI;AAGnC,UAAM,UAAU,MAAM,QAAQ,MAAM;AACpC,UAAM,YAAY,eAAe,SAAS,OAAO;AACjD,UAAM,SAAS,QAAQ,KAAK,QAAW,SAAS;AAGhD,iBAAa,QAAQ,OAAO,aAAa,OAAO;AAEhD,QAAI,OAAO,OAAQ,QAAO,KAAK,IAAI;AAGnC,UAAM,UAAU,QAAQ,MAAM;AAC9B,YAAQ,IAAI,KAAK,gBAAgB,QAAQ,QAAQ,cAAc,GAAG,QAAQ,SAAS,CAAC;AACpF,WAAO;AAAA,EACT;AACF;",
5
5
  "names": []
6
6
  }
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // writefile.ts
31
+ var writefile_exports = {};
32
+ __export(writefile_exports, {
33
+ buildWriteFile: () => buildWriteFile
34
+ });
35
+ module.exports = __toCommonJS(writefile_exports);
36
+ var import_plug = require("@plugjs/plug");
37
+ var import_paths = require("@plugjs/plug/paths");
38
+ var import_typescript = __toESM(require("typescript"), 1);
39
+ function buildWriteFile(builder, context) {
40
+ return function writeFile(fileName, code, writeBOM, onError) {
41
+ const outFile = (0, import_paths.resolveAbsolutePath)(builder.directory, fileName);
42
+ try {
43
+ import_typescript.default.sys.writeFile(outFile, code, writeBOM);
44
+ builder.add(outFile);
45
+ } catch (error) {
46
+ context.log.error("Error writing to", (0, import_plug.$p)(outFile), error);
47
+ if (onError && error.message) onError(error.message);
48
+ throw error;
49
+ }
50
+ };
51
+ }
52
+ // Annotate the CommonJS export names for ESM import in node:
53
+ 0 && (module.exports = {
54
+ buildWriteFile
55
+ });
56
+ //# sourceMappingURL=writefile.cjs.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/writefile.ts"],
4
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAmB;AACnB,mBAAoC;AACpC,wBAAe;AAMR,SAAS,eACZ,SACA,SACoB;AACtB,SAAO,SAAS,UACZ,UACA,MACA,UACA,SACI;AACN,UAAM,cAAU,kCAAoB,QAAQ,WAAW,QAAQ;AAE/D,QAAI;AACF,wBAAAA,QAAG,IAAI,UAAU,SAAS,MAAM,QAAQ;AACxC,cAAQ,IAAI,OAAO;AAAA,IACrB,SAAS,OAAY;AACnB,cAAQ,IAAI,MAAM,wBAAoB,gBAAG,OAAO,GAAG,KAAK;AACxD,UAAI,WAAW,MAAM,QAAS,SAAQ,MAAM,OAAO;AACnD,YAAM;AAAA,IACR;AAAA,EACF;AACF;",
5
+ "names": ["ts"]
6
+ }
@@ -0,0 +1,5 @@
1
+ import ts from 'typescript';
2
+ import type { FilesBuilder } from '@plugjs/plug/files';
3
+ import type { Context } from '@plugjs/plug/pipe';
4
+ /** Write a file (using `ts.sys.writeFile`) and add it to the builder */
5
+ export declare function buildWriteFile(builder: FilesBuilder, context: Context): ts.WriteFileCallback;
@@ -0,0 +1,21 @@
1
+ // writefile.ts
2
+ import { $p } from "@plugjs/plug";
3
+ import { resolveAbsolutePath } from "@plugjs/plug/paths";
4
+ import ts from "typescript";
5
+ function buildWriteFile(builder, context) {
6
+ return function writeFile(fileName, code, writeBOM, onError) {
7
+ const outFile = resolveAbsolutePath(builder.directory, fileName);
8
+ try {
9
+ ts.sys.writeFile(outFile, code, writeBOM);
10
+ builder.add(outFile);
11
+ } catch (error) {
12
+ context.log.error("Error writing to", $p(outFile), error);
13
+ if (onError && error.message) onError(error.message);
14
+ throw error;
15
+ }
16
+ };
17
+ }
18
+ export {
19
+ buildWriteFile
20
+ };
21
+ //# sourceMappingURL=writefile.mjs.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/writefile.ts"],
4
+ "mappings": ";AAAA,SAAS,UAAU;AACnB,SAAS,2BAA2B;AACpC,OAAO,QAAQ;AAMR,SAAS,eACZ,SACA,SACoB;AACtB,SAAO,SAAS,UACZ,UACA,MACA,UACA,SACI;AACN,UAAM,UAAU,oBAAoB,QAAQ,WAAW,QAAQ;AAE/D,QAAI;AACF,SAAG,IAAI,UAAU,SAAS,MAAM,QAAQ;AACxC,cAAQ,IAAI,OAAO;AAAA,IACrB,SAAS,OAAY;AACnB,cAAQ,IAAI,MAAM,oBAAoB,GAAG,OAAO,GAAG,KAAK;AACxD,UAAI,WAAW,MAAM,QAAS,SAAQ,MAAM,OAAO;AACnD,YAAM;AAAA,IACR;AAAA,EACF;AACF;",
5
+ "names": []
6
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plugjs/typescript",
3
- "version": "0.6.80",
3
+ "version": "0.6.81",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
@@ -33,7 +33,7 @@
33
33
  "typescript": "^5.9.3"
34
34
  },
35
35
  "peerDependencies": {
36
- "@plugjs/plug": "0.6.80"
36
+ "@plugjs/plug": "0.6.81"
37
37
  },
38
38
  "files": [
39
39
  "*.md",
package/src/index.ts CHANGED
@@ -1,7 +1,9 @@
1
+ import { find } from '@plugjs/plug'
1
2
  import { installForking } from '@plugjs/plug/fork'
2
3
  import { requireResolve } from '@plugjs/plug/paths'
3
4
 
4
- import type { CompilerOptions } from 'typescript'
5
+ import type { Pipe } from '@plugjs/plug'
6
+ import type { BuildOptions, CompilerOptions } from 'typescript'
5
7
 
6
8
  /** Remove the mapped `[option: string]: ...` from `CompilerOptions`. */
7
9
  type KnownCompilerOptions = {
@@ -57,7 +59,70 @@ declare module '@plugjs/plug' {
57
59
  * the contents of the specified `tsconfig.json`.
58
60
  */
59
61
  tsc(configFile: string, options: ExtendedCompilerOptions): Pipe
62
+
63
+ /**
64
+ * Run the {@link https://www.typescriptlang.org/ TypeScript Builder}
65
+ * over the specified project `tsconfig.json` files.
66
+ */
67
+ tscBuild(): Pipe
68
+
69
+ /**
70
+ * Run the {@link https://www.typescriptlang.org/ TypeScript Builder}
71
+ * over the specified project `tsconfig.json` files.
72
+ *
73
+ * With regards to `options`, the defaults are:
74
+ * - `verbose: true`
75
+ * - `force: true`
76
+ *
77
+ * @param options {@link BuildOptions} to use for the build.
78
+ */
79
+ tscBuild(options: BuildOptions): Pipe
60
80
  }
61
81
  }
62
82
 
63
83
  installForking('tsc', requireResolve(__fileurl, './typescript'), 'Tsc')
84
+ installForking('tscBuild', requireResolve(__fileurl, './tscbuild'), 'TscBuild')
85
+
86
+ export interface TscBuildOptions extends BuildOptions {
87
+ /** The directory where to look for the `tsconfig.json` files. */
88
+ directory?: string
89
+ }
90
+
91
+ /**
92
+ * Run `tsc --build` using `tsconfig.json` from the current directory.
93
+ */
94
+ export function tscBuild(): Pipe
95
+ /**
96
+ * Run `tsc --build` using the specified `tsconfig.json` file.
97
+ */
98
+ export function tscBuild(tsconfig: string): Pipe
99
+ /**
100
+ * Run `tsc --build` using the specified options.
101
+ *
102
+ * The `directory` option specifies where to look for the `tsconfig.json` files,
103
+ * and defaults to the current directory, `verbose` and `force` default to
104
+ * `true`.
105
+ */
106
+ export function tscBuild(options: TscBuildOptions): Pipe
107
+ /**
108
+ * Run `tsc --build` using the specified `tsconfig.json` and options.
109
+ *
110
+ * The `directory` option specifies where to look for the `tsconfig.json` files,
111
+ * and defaults to the current directory, `verbose` and `force` default to
112
+ * `true`.
113
+ */
114
+ export function tscBuild(tsconfig: string, options?: TscBuildOptions): Pipe
115
+
116
+ // Implementation overload
117
+ export function tscBuild(
118
+ tsconfigOrOptions?: string | TscBuildOptions,
119
+ maybeOptions?: TscBuildOptions,
120
+ ): Pipe {
121
+ const [ tsconfig, tscBuildOptions ] =
122
+ typeof tsconfigOrOptions === 'string'
123
+ ? [ tsconfigOrOptions, maybeOptions ]
124
+ : [ 'tsconfig.json', tsconfigOrOptions ]
125
+
126
+ const { directory, ...buildOptions } = tscBuildOptions || {}
127
+ return find(tsconfig, { directory }).tscBuild(buildOptions)
128
+ }
package/src/report.ts CHANGED
@@ -2,7 +2,7 @@ import { ERROR, NOTICE, WARN } from '@plugjs/plug/logging'
2
2
  import { resolveAbsolutePath } from '@plugjs/plug/paths'
3
3
  import ts from 'typescript'
4
4
 
5
- import type { Report, ReportLevel, ReportRecord } from '@plugjs/plug/logging'
5
+ import type { Logger, Report, ReportLevel, ReportRecord } from '@plugjs/plug/logging'
6
6
  import type { AbsolutePath } from '@plugjs/plug/paths'
7
7
 
8
8
 
@@ -69,12 +69,34 @@ function convertDiagnostics(
69
69
  })
70
70
  }
71
71
 
72
- /** Update a report, adding records from an array of {@link ts.Diagnostic} */
72
+ /**
73
+ * Update a report, adding records from an array of {@link ts.Diagnostic}
74
+ *
75
+ * When a `logger` is provided, diagnostics without a file will be logged
76
+ * directly to the logger instead of being added to the report (therefore the
77
+ * report will not _fail_ in case of such diagnostics).
78
+ */
73
79
  export function updateReport(
74
80
  report: Report,
75
81
  diagnostics: readonly ts.Diagnostic[],
76
82
  directory: AbsolutePath,
83
+ logger?: Logger,
77
84
  ): void {
78
85
  const records = convertDiagnostics(diagnostics, directory)
79
- report.add(...records)
86
+ if (! logger) {
87
+ report.add(...records)
88
+ return
89
+ }
90
+
91
+ for (const record of records) {
92
+ if (record.file) {
93
+ report.add(record)
94
+ } else {
95
+ switch (record.level) {
96
+ case ERROR: logger.error(record.message); break
97
+ case WARN: logger.warn(record.message); break
98
+ case NOTICE: logger.info(record.message); break
99
+ }
100
+ }
101
+ }
80
102
  }
@@ -0,0 +1,86 @@
1
+ import { $p, fail } from '@plugjs/plug'
2
+ import { Files } from '@plugjs/plug/files'
3
+ import ts from 'typescript'
4
+
5
+ import { updateReport } from './report'
6
+ import { buildWriteFile } from './writefile'
7
+
8
+ import type { Context, PipeParameters, Plug } from '@plugjs/plug/pipe'
9
+
10
+ export class TscBuild implements Plug<Files> {
11
+ private readonly _options: ts.BuildOptions
12
+
13
+ constructor(...args: PipeParameters<'tscBuild'>) {
14
+ this._options = {
15
+ verbose: true,
16
+ force: true,
17
+ ...(args[0] || {}),
18
+ }
19
+ }
20
+
21
+ async pipe(files: Files, context: Context): Promise<Files> {
22
+ const report = context.log.report('TypeScript Builder Report')
23
+ const builder = Files.builder(files.directory)
24
+ const writeFile = buildWriteFile(builder, context)
25
+
26
+ function reporter(diagnostic: ts.Diagnostic): void {
27
+ updateReport(report, [ diagnostic ], files.directory, context.log)
28
+ }
29
+
30
+ const solutionBuilderHost = ts.createSolutionBuilderHost(
31
+ ts.sys, // system
32
+ undefined, // createProgram
33
+ reporter, // reportDiagnostic
34
+ reporter, // reportSolutionBuilderStatus
35
+ undefined, // reportSolutionBuilderErrorSummary
36
+ )
37
+
38
+ const solutionBuilder = ts.createSolutionBuilder(
39
+ solutionBuilderHost,
40
+ [ ...files.absolutePaths() ],
41
+ this._options,
42
+ )
43
+
44
+ const exitCode = solutionBuilder.build(
45
+ undefined, // project (string)
46
+ undefined, // cancellationToken
47
+ writeFile, // writeFile
48
+ undefined, // getCustomTransformers
49
+ )
50
+
51
+ let failure: boolean
52
+ switch (exitCode) {
53
+ case ts.ExitStatus.Success: // 0
54
+ context.log.info('TSC Build completed successfully')
55
+ failure = false
56
+ break
57
+ case ts.ExitStatus.DiagnosticsPresent_OutputsSkipped: // 1
58
+ context.log.error('TSC Build failed with errors (see report)')
59
+ failure = true
60
+ break
61
+ case ts.ExitStatus.DiagnosticsPresent_OutputsGenerated: // 2
62
+ context.log.warn('TSC Build completed with errors (see report)')
63
+ failure = true
64
+ break
65
+ case ts.ExitStatus.InvalidProject_OutputsSkipped: // 3
66
+ context.log.error('TSC Build failed due to invalid project configuration')
67
+ failure = true
68
+ break
69
+ case ts.ExitStatus.ProjectReferenceCycle_OutputsSkipped: // 4
70
+ context.log.error('TSC Build failed due to project reference cycle')
71
+ failure = true
72
+ break
73
+ default:
74
+ context.log.error('TSC Build failed with exit code', exitCode)
75
+ failure = true
76
+ break
77
+ }
78
+
79
+ report.done(true)
80
+ if (failure) fail('TSC Build failed')
81
+
82
+ const outputs = builder.build()
83
+ context.log.info('TSC Build produced', outputs.length, 'files into', $p(outputs.directory))
84
+ return outputs
85
+ }
86
+ }
package/src/typescript.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { assert, assertPromises, BuildFailure } from '@plugjs/plug/asserts'
1
+ import { assert } from '@plugjs/plug/asserts'
2
2
  import { Files } from '@plugjs/plug/files'
3
3
  import { $p } from '@plugjs/plug/logging'
4
4
  import { commonPath, getAbsoluteParent, resolveAbsolutePath, resolveFile } from '@plugjs/plug/paths'
@@ -8,6 +8,7 @@ import ts from 'typescript'
8
8
  import { TypeScriptHost } from './compiler'
9
9
  import { getCompilerOptions } from './options'
10
10
  import { updateReport } from './report'
11
+ import { buildWriteFile } from './writefile'
11
12
 
12
13
  import type { AbsolutePath } from '@plugjs/plug/paths'
13
14
  import type { Context, PipeParameters, Plug } from '@plugjs/plug/pipe'
@@ -145,19 +146,8 @@ export class Tsc implements Plug<Files> {
145
146
 
146
147
  /* Write out all files asynchronously */
147
148
  const builder = Files.builder(outDir)
148
- const promises: Promise<void>[] = []
149
- const result = program.emit(undefined, (fileName, code) => {
150
- promises.push(builder.write(fileName, code).then((file) => {
151
- context.log.trace('Written', $p(file))
152
- }).catch(/* coverage ignore next */ (error) => {
153
- const outFile = resolveAbsolutePath(outDir, fileName)
154
- context.log.error('Error writing to', $p(outFile), error)
155
- throw BuildFailure.fail()
156
- }))
157
- })
158
-
159
- /* Await for all files to be written and check */
160
- await assertPromises(promises)
149
+ const writeFile = buildWriteFile(builder, context)
150
+ const result = program.emit(undefined, writeFile)
161
151
 
162
152
  /* Update report and fail on errors */
163
153
  updateReport(report, result.diagnostics, rootDir)
@@ -0,0 +1,30 @@
1
+ import { $p } from '@plugjs/plug'
2
+ import { resolveAbsolutePath } from '@plugjs/plug/paths'
3
+ import ts from 'typescript'
4
+
5
+ import type { FilesBuilder } from '@plugjs/plug/files'
6
+ import type { Context } from '@plugjs/plug/pipe'
7
+
8
+ /** Write a file (using `ts.sys.writeFile`) and add it to the builder */
9
+ export function buildWriteFile(
10
+ builder: FilesBuilder,
11
+ context: Context,
12
+ ): ts.WriteFileCallback {
13
+ return function writeFile(
14
+ fileName: string,
15
+ code: string,
16
+ writeBOM: boolean,
17
+ onError?: (message: string) => void,
18
+ ): void {
19
+ const outFile = resolveAbsolutePath(builder.directory, fileName)
20
+ /* coverage ignore catch */
21
+ try {
22
+ ts.sys.writeFile(outFile, code, writeBOM)
23
+ builder.add(outFile)
24
+ } catch (error: any) {
25
+ context.log.error('Error writing to', $p(outFile), error)
26
+ if (onError && error.message) onError(error.message)
27
+ throw error
28
+ }
29
+ }
30
+ }