@xylabs/ts-scripts-yarn3 3.0.22 → 3.0.23

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.
@@ -0,0 +1,59 @@
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
+ var getCompilerOptions_exports = {};
30
+ __export(getCompilerOptions_exports, {
31
+ getCompilerOptions: () => getCompilerOptions,
32
+ getCompilerOptionsJSONFollowExtends: () => getCompilerOptionsJSONFollowExtends
33
+ });
34
+ module.exports = __toCommonJS(getCompilerOptions_exports);
35
+ var import_merge = __toESM(require("lodash/merge"));
36
+ var import_typescript = require("typescript");
37
+ const getCompilerOptionsJSONFollowExtends = (filename) => {
38
+ let opts = {};
39
+ const config = (0, import_typescript.readConfigFile)(filename, import_typescript.sys.readFile).config;
40
+ if (config.extends) {
41
+ const requirePath = require.resolve(config.extends);
42
+ opts = getCompilerOptionsJSONFollowExtends(requirePath);
43
+ }
44
+ if (config?.error) {
45
+ throw Error(`getCompilerOptionsJSONFollowExtends failed ${JSON.stringify(config?.error?.messageText, null, 2)}`);
46
+ }
47
+ return { ...opts, ...config.compilerOptions };
48
+ };
49
+ const getCompilerOptions = (options, tsconfig = "tsconfig.json") => {
50
+ const configFileName = (0, import_typescript.findConfigFile)("./", import_typescript.sys.fileExists, tsconfig);
51
+ const configFileCompilerOptions = configFileName ? getCompilerOptionsJSONFollowExtends(configFileName) : void 0;
52
+ return (0, import_merge.default)({}, configFileCompilerOptions, options);
53
+ };
54
+ // Annotate the CommonJS export names for ESM import in node:
55
+ 0 && (module.exports = {
56
+ getCompilerOptions,
57
+ getCompilerOptionsJSONFollowExtends
58
+ });
59
+ //# sourceMappingURL=getCompilerOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/actions/package/compile/getCompilerOptions.ts"],"sourcesContent":["// eslint-disable-next-line import/no-internal-modules\nimport merge from 'lodash/merge'\nimport { CompilerOptions, findConfigFile, readConfigFile, sys } from 'typescript'\n\nexport const getCompilerOptionsJSONFollowExtends = (filename: string): CompilerOptions => {\n let opts = {}\n const config = readConfigFile(filename, sys.readFile).config\n if (config.extends) {\n const requirePath = require.resolve(config.extends)\n opts = getCompilerOptionsJSONFollowExtends(requirePath)\n }\n if (config?.error) {\n throw Error(`getCompilerOptionsJSONFollowExtends failed ${JSON.stringify(config?.error?.messageText, null, 2)}`)\n }\n\n return { ...opts, ...config.compilerOptions }\n}\n\nexport const getCompilerOptions = (options?: CompilerOptions, tsconfig: string = 'tsconfig.json'): CompilerOptions => {\n const configFileName = findConfigFile('./', sys.fileExists, tsconfig)\n const configFileCompilerOptions = configFileName ? getCompilerOptionsJSONFollowExtends(configFileName) : undefined\n\n return merge({}, configFileCompilerOptions, options)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,wBAAqE;AAE9D,MAAM,sCAAsC,CAAC,aAAsC;AACxF,MAAI,OAAO,CAAC;AACZ,QAAM,aAAS,kCAAe,UAAU,sBAAI,QAAQ,EAAE;AACtD,MAAI,OAAO,SAAS;AAClB,UAAM,cAAc,QAAQ,QAAQ,OAAO,OAAO;AAClD,WAAO,oCAAoC,WAAW;AAAA,EACxD;AACA,MAAI,QAAQ,OAAO;AACjB,UAAM,MAAM,8CAA8C,KAAK,UAAU,QAAQ,OAAO,aAAa,MAAM,CAAC,CAAC,EAAE;AAAA,EACjH;AAEA,SAAO,EAAE,GAAG,MAAM,GAAG,OAAO,gBAAgB;AAC9C;AAEO,MAAM,qBAAqB,CAAC,SAA2B,WAAmB,oBAAqC;AACpH,QAAM,qBAAiB,kCAAe,MAAM,sBAAI,YAAY,QAAQ;AACpE,QAAM,4BAA4B,iBAAiB,oCAAoC,cAAc,IAAI;AAEzG,aAAO,aAAAA,SAAM,CAAC,GAAG,2BAA2B,OAAO;AACrD;","names":["merge"]}
@@ -0,0 +1,24 @@
1
+ import merge from "lodash/merge";
2
+ import { findConfigFile, readConfigFile, sys } from "typescript";
3
+ const getCompilerOptionsJSONFollowExtends = (filename) => {
4
+ let opts = {};
5
+ const config = readConfigFile(filename, sys.readFile).config;
6
+ if (config.extends) {
7
+ const requirePath = require.resolve(config.extends);
8
+ opts = getCompilerOptionsJSONFollowExtends(requirePath);
9
+ }
10
+ if (config?.error) {
11
+ throw Error(`getCompilerOptionsJSONFollowExtends failed ${JSON.stringify(config?.error?.messageText, null, 2)}`);
12
+ }
13
+ return { ...opts, ...config.compilerOptions };
14
+ };
15
+ const getCompilerOptions = (options, tsconfig = "tsconfig.json") => {
16
+ const configFileName = findConfigFile("./", sys.fileExists, tsconfig);
17
+ const configFileCompilerOptions = configFileName ? getCompilerOptionsJSONFollowExtends(configFileName) : void 0;
18
+ return merge({}, configFileCompilerOptions, options);
19
+ };
20
+ export {
21
+ getCompilerOptions,
22
+ getCompilerOptionsJSONFollowExtends
23
+ };
24
+ //# sourceMappingURL=getCompilerOptions.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/actions/package/compile/getCompilerOptions.ts"],"sourcesContent":["// eslint-disable-next-line import/no-internal-modules\nimport merge from 'lodash/merge'\nimport { CompilerOptions, findConfigFile, readConfigFile, sys } from 'typescript'\n\nexport const getCompilerOptionsJSONFollowExtends = (filename: string): CompilerOptions => {\n let opts = {}\n const config = readConfigFile(filename, sys.readFile).config\n if (config.extends) {\n const requirePath = require.resolve(config.extends)\n opts = getCompilerOptionsJSONFollowExtends(requirePath)\n }\n if (config?.error) {\n throw Error(`getCompilerOptionsJSONFollowExtends failed ${JSON.stringify(config?.error?.messageText, null, 2)}`)\n }\n\n return { ...opts, ...config.compilerOptions }\n}\n\nexport const getCompilerOptions = (options?: CompilerOptions, tsconfig: string = 'tsconfig.json'): CompilerOptions => {\n const configFileName = findConfigFile('./', sys.fileExists, tsconfig)\n const configFileCompilerOptions = configFileName ? getCompilerOptionsJSONFollowExtends(configFileName) : undefined\n\n return merge({}, configFileCompilerOptions, options)\n}\n"],"mappings":"AACA,OAAO,WAAW;AAClB,SAA0B,gBAAgB,gBAAgB,WAAW;AAE9D,MAAM,sCAAsC,CAAC,aAAsC;AACxF,MAAI,OAAO,CAAC;AACZ,QAAM,SAAS,eAAe,UAAU,IAAI,QAAQ,EAAE;AACtD,MAAI,OAAO,SAAS;AAClB,UAAM,cAAc,QAAQ,QAAQ,OAAO,OAAO;AAClD,WAAO,oCAAoC,WAAW;AAAA,EACxD;AACA,MAAI,QAAQ,OAAO;AACjB,UAAM,MAAM,8CAA8C,KAAK,UAAU,QAAQ,OAAO,aAAa,MAAM,CAAC,CAAC,EAAE;AAAA,EACjH;AAEA,SAAO,EAAE,GAAG,MAAM,GAAG,OAAO,gBAAgB;AAC9C;AAEO,MAAM,qBAAqB,CAAC,SAA2B,WAAmB,oBAAqC;AACpH,QAAM,iBAAiB,eAAe,MAAM,IAAI,YAAY,QAAQ;AACpE,QAAM,4BAA4B,iBAAiB,oCAAoC,cAAc,IAAI;AAEzG,SAAO,MAAM,CAAC,GAAG,2BAA2B,OAAO;AACrD;","names":[]}
@@ -35,27 +35,11 @@ var import_chalk = __toESM(require("chalk"));
35
35
  var import_merge = __toESM(require("lodash/merge"));
36
36
  var import_typescript = require("typescript");
37
37
  var import_lib = require("../../../lib");
38
+ var import_getCompilerOptions = require("./getCompilerOptions");
38
39
  var import_inputs = require("./inputs");
39
- const getCompilerOptionsJSONFollowExtends = (filename) => {
40
- let opts = {};
41
- const config = (0, import_typescript.readConfigFile)(filename, import_typescript.sys.readFile).config;
42
- if (config.extends) {
43
- const requirePath = require.resolve(config.extends);
44
- opts = getCompilerOptionsJSONFollowExtends(requirePath);
45
- }
46
- if (config?.error) {
47
- throw Error(`getCompilerOptionsJSONFollowExtends failed ${JSON.stringify(config?.error?.messageText, null, 2)}`);
48
- }
49
- return { ...opts, ...config.compilerOptions };
50
- };
51
- const getCompilerOptions = (options, tsconfig = "tsconfig.json") => {
52
- const configFileName = (0, import_typescript.findConfigFile)("./", import_typescript.sys.fileExists, tsconfig);
53
- const configFileCompilerOptions = configFileName ? getCompilerOptionsJSONFollowExtends(configFileName) : void 0;
54
- return (0, import_merge.default)({}, configFileCompilerOptions, options);
55
- };
56
40
  const getConfigFile = (options, tsconfig = "tsconfig.json") => {
57
41
  const configFileName = (0, import_typescript.findConfigFile)("./", import_typescript.sys.fileExists, tsconfig);
58
- return { ...configFileName ? (0, import_typescript.readConfigFile)(configFileName, import_typescript.sys.readFile).config : {}, compilerOptions: getCompilerOptions(options) };
42
+ return { ...configFileName ? (0, import_typescript.readConfigFile)(configFileName, import_typescript.sys.readFile).config : {}, compilerOptions: (0, import_getCompilerOptions.getCompilerOptions)(options) };
59
43
  };
60
44
  const compile = (fileNames, options) => {
61
45
  console.log(import_chalk.default.blue("compile"));
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/actions/package/compile/tsc.ts"],"sourcesContent":["import chalk from 'chalk'\n// eslint-disable-next-line import/no-internal-modules\nimport merge from 'lodash/merge'\nimport {\n CompilerOptions,\n createProgram,\n Diagnostic,\n findConfigFile,\n flattenDiagnosticMessageText,\n getLineAndCharacterOfPosition,\n getPreEmitDiagnostics,\n readConfigFile,\n sys,\n} from 'typescript'\n\nimport { loadConfig } from '../../../lib'\nimport { CompileParams } from './CompileParams'\nimport { getAllInputs } from './inputs'\n\nexport type PackageCompileTscParams = Partial<\n CompileParams & {\n compile?: {\n tsc?: {\n compilerOptions?: CompilerOptions\n tsconfig?: string\n }\n }\n }\n>\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst getCompilerOptionsJSONFollowExtends = (filename: string): CompilerOptions => {\n let opts = {}\n const config = readConfigFile(filename, sys.readFile).config\n if (config.extends) {\n const requirePath = require.resolve(config.extends)\n opts = getCompilerOptionsJSONFollowExtends(requirePath)\n }\n if (config?.error) {\n throw Error(`getCompilerOptionsJSONFollowExtends failed ${JSON.stringify(config?.error?.messageText, null, 2)}`)\n }\n\n return { ...opts, ...config.compilerOptions }\n}\n\nconst getCompilerOptions = (options?: CompilerOptions, tsconfig: string = 'tsconfig.json'): CompilerOptions => {\n const configFileName = findConfigFile('./', sys.fileExists, tsconfig)\n const configFileCompilerOptions = configFileName ? getCompilerOptionsJSONFollowExtends(configFileName) : undefined\n\n return merge({}, configFileCompilerOptions, options)\n}\n\nconst getConfigFile = (options?: CompilerOptions, tsconfig: string = 'tsconfig.json') => {\n const configFileName = findConfigFile('./', sys.fileExists, tsconfig)\n return { ...(configFileName ? readConfigFile(configFileName, sys.readFile).config : {}), compilerOptions: getCompilerOptions(options) }\n}\n\nconst compile = (fileNames: string[], options: CompilerOptions) => {\n console.log(chalk.blue('compile'))\n console.log(chalk.magenta(`options: ${JSON.stringify(options, null, 2)}`))\n const program = createProgram(fileNames, options)\n console.log(chalk.blue('createProgram'))\n const emitResult = program.emit()\n console.log(chalk.blue('emit'))\n\n const allDiagnostics: Diagnostic[] = getPreEmitDiagnostics(program).concat(emitResult.diagnostics)\n\n const errorDiagnostics = allDiagnostics.filter((diagnostic) => diagnostic.category === 1)\n\n allDiagnostics.forEach((diagnostic) => {\n if (diagnostic.file) {\n const { line, character } = getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start!)\n const message = flattenDiagnosticMessageText(diagnostic.messageText, '\\n')\n console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`)\n } else {\n console.log(flattenDiagnosticMessageText(diagnostic.messageText, '\\n'))\n }\n })\n\n if (errorDiagnostics.length) {\n console.log(chalk.red(`Errors: ${errorDiagnostics.length}`))\n process.exit(errorDiagnostics.length)\n }\n\n return errorDiagnostics.length\n}\n\nexport const packageCompileTsc = async (params?: PackageCompileTscParams): Promise<number> => {\n const defaultCompilerOptions: CompilerOptions = {\n declaration: true,\n declarationMap: true,\n outDir: 'dist',\n rootDir: 'src',\n sourceMap: true,\n }\n const compilerOptions = merge({}, defaultCompilerOptions, params?.compile?.tsc?.compilerOptions)\n const config = await loadConfig(params)\n if (config.verbose) {\n console.log('Compiling with TSC')\n }\n\n const fileNames = (await getAllInputs(config.compile?.depth)).map((fileName) => `src/${fileName}`)\n const configFile = getConfigFile(compilerOptions)\n return compile(fileNames, configFile.compilerOptions)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAElB,mBAAkB;AAClB,wBAUO;AAEP,iBAA2B;AAE3B,oBAA6B;AAc7B,MAAM,sCAAsC,CAAC,aAAsC;AACjF,MAAI,OAAO,CAAC;AACZ,QAAM,aAAS,kCAAe,UAAU,sBAAI,QAAQ,EAAE;AACtD,MAAI,OAAO,SAAS;AAClB,UAAM,cAAc,QAAQ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AAU,QAAI,iDAA8B,WAAW,MAAM,WAAW,KAAM;AAC5F,YAAM,cAAU,gDAA6B,WAAW,aAAa,IAAI;AACzE,cAAQ,IAAI,GAAG,WAAW,KAAK,QAAQ,KAAK,OAAO,CAAC,IAAI,YAAY,CAAC,MAAM,OAAO,EAAE;AAAA,IACtF,OAAO;AACL,cAAQ,QAAI,gDAA6B,WAAW,aAAa,IAAI,CAAC;AAAA,IACxE;AAAA,EACF,CAAC;AAED,MAAI,iBAAiB,QAAQ;AAC3B,YAAQ,IAAI,aAAAA,QAAM,IAAI,WAAW,iBAAiB,MAAM,EAAE,CAAC;AAC3D,YAAQ,KAAK,iBAAiB,MAAM;AAAA,EACtC;AAEA,SAAO,iBAAiB;AAC1B;AAEO,MAAM,oBAAoB,OAAO,WAAsD;AAC5F,QAAM,yBAA0C;AAAA,IAC9C,aAAa;AAAA,IACb,gBAAgB;AAAA,IAChB,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,WAAW;AAAA,EACb;AACA,QAAM,sBAAkB,aAAAD,SAAM,CAAC,GAAG,wBAAwB,QAAQ,SAAS,KAAK,eAAe;AAC/F,QAAM,SAAS,UAAM,uBAAW,MAAM;AACtC,MAAI,OAAO,SAAS;AAClB,YAAQ,IAAI,oBAAoB;AAAA,EAClC;AAEA,QAAM,aAAa,UAAM,4BAAa,OAAO,SAAS,KAAK,GAAG,IAAI,CAAC,aAAa,OAAO,QAAQ,EAAE;AACjG,QAAM,aAAa,cAAc,eAAe;AAChD,SAAO,QAAQ,WAAW,WAAW,eAAe;AACtD;","names":["merge","chalk"]}
1
+ {"version":3,"sources":["../../../../src/actions/package/compile/tsc.ts"],"sourcesContent":["import chalk from 'chalk'\n// eslint-disable-next-line import/no-internal-modules\nimport merge from 'lodash/merge'\nimport {\n CompilerOptions,\n createProgram,\n Diagnostic,\n findConfigFile,\n flattenDiagnosticMessageText,\n getLineAndCharacterOfPosition,\n getPreEmitDiagnostics,\n readConfigFile,\n sys,\n} from 'typescript'\n\nimport { loadConfig } from '../../../lib'\nimport { CompileParams } from './CompileParams'\nimport { getCompilerOptions } from './getCompilerOptions'\nimport { getAllInputs } from './inputs'\n\nexport type PackageCompileTscParams = Partial<\n CompileParams & {\n compile?: {\n tsc?: {\n compilerOptions?: CompilerOptions\n tsconfig?: string\n }\n }\n }\n>\n\nconst getConfigFile = (options?: CompilerOptions, tsconfig: string = 'tsconfig.json') => {\n const configFileName = findConfigFile('./', sys.fileExists, tsconfig)\n return { ...(configFileName ? readConfigFile(configFileName, sys.readFile).config : {}), compilerOptions: getCompilerOptions(options) }\n}\n\nconst compile = (fileNames: string[], options: CompilerOptions) => {\n console.log(chalk.blue('compile'))\n console.log(chalk.magenta(`options: ${JSON.stringify(options, null, 2)}`))\n const program = createProgram(fileNames, options)\n console.log(chalk.blue('createProgram'))\n const emitResult = program.emit()\n console.log(chalk.blue('emit'))\n\n const allDiagnostics: Diagnostic[] = getPreEmitDiagnostics(program).concat(emitResult.diagnostics)\n\n const errorDiagnostics = allDiagnostics.filter((diagnostic) => diagnostic.category === 1)\n\n allDiagnostics.forEach((diagnostic) => {\n if (diagnostic.file) {\n const { line, character } = getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start!)\n const message = flattenDiagnosticMessageText(diagnostic.messageText, '\\n')\n console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`)\n } else {\n console.log(flattenDiagnosticMessageText(diagnostic.messageText, '\\n'))\n }\n })\n\n if (errorDiagnostics.length) {\n console.log(chalk.red(`Errors: ${errorDiagnostics.length}`))\n process.exit(errorDiagnostics.length)\n }\n\n return errorDiagnostics.length\n}\n\nexport const packageCompileTsc = async (params?: PackageCompileTscParams): Promise<number> => {\n const defaultCompilerOptions: CompilerOptions = {\n declaration: true,\n declarationMap: true,\n outDir: 'dist',\n rootDir: 'src',\n sourceMap: true,\n }\n const compilerOptions = merge({}, defaultCompilerOptions, params?.compile?.tsc?.compilerOptions)\n const config = await loadConfig(params)\n if (config.verbose) {\n console.log('Compiling with TSC')\n }\n\n const fileNames = (await getAllInputs(config.compile?.depth)).map((fileName) => `src/${fileName}`)\n const configFile = getConfigFile(compilerOptions)\n return compile(fileNames, configFile.compilerOptions)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAElB,mBAAkB;AAClB,wBAUO;AAEP,iBAA2B;AAE3B,gCAAmC;AACnC,oBAA6B;AAa7B,MAAM,gBAAgB,CAAC,SAA2B,WAAmB,oBAAoB;AACvF,QAAM,qBAAiB,kCAAe,MAAM,sBAAI,YAAY,QAAQ;AACpE,SAAO,EAAE,GAAI,qBAAiB,kCAAe,gBAAgB,sBAAI,QAAQ,EAAE,SAAS,CAAC,GAAI,qBAAiB,8CAAmB,OAAO,EAAE;AACxI;AAEA,MAAM,UAAU,CAAC,WAAqB,YAA6B;AACjE,UAAQ,IAAI,aAAAA,QAAM,KAAK,SAAS,CAAC;AACjC,UAAQ,IAAI,aAAAA,QAAM,QAAQ,YAAY,KAAK,UAAU,SAAS,MAAM,CAAC,CAAC,EAAE,CAAC;AACzE,QAAM,cAAU,iCAAc,WAAW,OAAO;AAChD,UAAQ,IAAI,aAAAA,QAAM,KAAK,eAAe,CAAC;AACvC,QAAM,aAAa,QAAQ,KAAK;AAChC,UAAQ,IAAI,aAAAA,QAAM,KAAK,MAAM,CAAC;AAE9B,QAAM,qBAA+B,yCAAsB,OAAO,EAAE,OAAO,WAAW,WAAW;AAEjG,QAAM,mBAAmB,eAAe,OAAO,CAAC,eAAe,WAAW,aAAa,CAAC;AAExF,iBAAe,QAAQ,CAAC,eAAe;AACrC,QAAI,WAAW,MAAM;AACnB,YAAM,EAAE,MAAM,UAAU,QAAI,iDAA8B,WAAW,MAAM,WAAW,KAAM;AAC5F,YAAM,cAAU,gDAA6B,WAAW,aAAa,IAAI;AACzE,cAAQ,IAAI,GAAG,WAAW,KAAK,QAAQ,KAAK,OAAO,CAAC,IAAI,YAAY,CAAC,MAAM,OAAO,EAAE;AAAA,IACtF,OAAO;AACL,cAAQ,QAAI,gDAA6B,WAAW,aAAa,IAAI,CAAC;AAAA,IACxE;AAAA,EACF,CAAC;AAED,MAAI,iBAAiB,QAAQ;AAC3B,YAAQ,IAAI,aAAAA,QAAM,IAAI,WAAW,iBAAiB,MAAM,EAAE,CAAC;AAC3D,YAAQ,KAAK,iBAAiB,MAAM;AAAA,EACtC;AAEA,SAAO,iBAAiB;AAC1B;AAEO,MAAM,oBAAoB,OAAO,WAAsD;AAC5F,QAAM,yBAA0C;AAAA,IAC9C,aAAa;AAAA,IACb,gBAAgB;AAAA,IAChB,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,WAAW;AAAA,EACb;AACA,QAAM,sBAAkB,aAAAC,SAAM,CAAC,GAAG,wBAAwB,QAAQ,SAAS,KAAK,eAAe;AAC/F,QAAM,SAAS,UAAM,uBAAW,MAAM;AACtC,MAAI,OAAO,SAAS;AAClB,YAAQ,IAAI,oBAAoB;AAAA,EAClC;AAEA,QAAM,aAAa,UAAM,4BAAa,OAAO,SAAS,KAAK,GAAG,IAAI,CAAC,aAAa,OAAO,QAAQ,EAAE;AACjG,QAAM,aAAa,cAAc,eAAe;AAChD,SAAO,QAAQ,WAAW,WAAW,eAAe;AACtD;","names":["chalk","merge"]}
@@ -10,24 +10,8 @@ import {
10
10
  sys
11
11
  } from "typescript";
12
12
  import { loadConfig } from "../../../lib";
13
+ import { getCompilerOptions } from "./getCompilerOptions";
13
14
  import { getAllInputs } from "./inputs";
14
- const getCompilerOptionsJSONFollowExtends = (filename) => {
15
- let opts = {};
16
- const config = readConfigFile(filename, sys.readFile).config;
17
- if (config.extends) {
18
- const requirePath = require.resolve(config.extends);
19
- opts = getCompilerOptionsJSONFollowExtends(requirePath);
20
- }
21
- if (config?.error) {
22
- throw Error(`getCompilerOptionsJSONFollowExtends failed ${JSON.stringify(config?.error?.messageText, null, 2)}`);
23
- }
24
- return { ...opts, ...config.compilerOptions };
25
- };
26
- const getCompilerOptions = (options, tsconfig = "tsconfig.json") => {
27
- const configFileName = findConfigFile("./", sys.fileExists, tsconfig);
28
- const configFileCompilerOptions = configFileName ? getCompilerOptionsJSONFollowExtends(configFileName) : void 0;
29
- return merge({}, configFileCompilerOptions, options);
30
- };
31
15
  const getConfigFile = (options, tsconfig = "tsconfig.json") => {
32
16
  const configFileName = findConfigFile("./", sys.fileExists, tsconfig);
33
17
  return { ...configFileName ? readConfigFile(configFileName, sys.readFile).config : {}, compilerOptions: getCompilerOptions(options) };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/actions/package/compile/tsc.ts"],"sourcesContent":["import chalk from 'chalk'\n// eslint-disable-next-line import/no-internal-modules\nimport merge from 'lodash/merge'\nimport {\n CompilerOptions,\n createProgram,\n Diagnostic,\n findConfigFile,\n flattenDiagnosticMessageText,\n getLineAndCharacterOfPosition,\n getPreEmitDiagnostics,\n readConfigFile,\n sys,\n} from 'typescript'\n\nimport { loadConfig } from '../../../lib'\nimport { CompileParams } from './CompileParams'\nimport { getAllInputs } from './inputs'\n\nexport type PackageCompileTscParams = Partial<\n CompileParams & {\n compile?: {\n tsc?: {\n compilerOptions?: CompilerOptions\n tsconfig?: string\n }\n }\n }\n>\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst getCompilerOptionsJSONFollowExtends = (filename: string): CompilerOptions => {\n let opts = {}\n const config = readConfigFile(filename, sys.readFile).config\n if (config.extends) {\n const requirePath = require.resolve(config.extends)\n opts = getCompilerOptionsJSONFollowExtends(requirePath)\n }\n if (config?.error) {\n throw Error(`getCompilerOptionsJSONFollowExtends failed ${JSON.stringify(config?.error?.messageText, null, 2)}`)\n }\n\n return { ...opts, ...config.compilerOptions }\n}\n\nconst getCompilerOptions = (options?: CompilerOptions, tsconfig: string = 'tsconfig.json'): CompilerOptions => {\n const configFileName = findConfigFile('./', sys.fileExists, tsconfig)\n const configFileCompilerOptions = configFileName ? getCompilerOptionsJSONFollowExtends(configFileName) : undefined\n\n return merge({}, configFileCompilerOptions, options)\n}\n\nconst getConfigFile = (options?: CompilerOptions, tsconfig: string = 'tsconfig.json') => {\n const configFileName = findConfigFile('./', sys.fileExists, tsconfig)\n return { ...(configFileName ? readConfigFile(configFileName, sys.readFile).config : {}), compilerOptions: getCompilerOptions(options) }\n}\n\nconst compile = (fileNames: string[], options: CompilerOptions) => {\n console.log(chalk.blue('compile'))\n console.log(chalk.magenta(`options: ${JSON.stringify(options, null, 2)}`))\n const program = createProgram(fileNames, options)\n console.log(chalk.blue('createProgram'))\n const emitResult = program.emit()\n console.log(chalk.blue('emit'))\n\n const allDiagnostics: Diagnostic[] = getPreEmitDiagnostics(program).concat(emitResult.diagnostics)\n\n const errorDiagnostics = allDiagnostics.filter((diagnostic) => diagnostic.category === 1)\n\n allDiagnostics.forEach((diagnostic) => {\n if (diagnostic.file) {\n const { line, character } = getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start!)\n const message = flattenDiagnosticMessageText(diagnostic.messageText, '\\n')\n console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`)\n } else {\n console.log(flattenDiagnosticMessageText(diagnostic.messageText, '\\n'))\n }\n })\n\n if (errorDiagnostics.length) {\n console.log(chalk.red(`Errors: ${errorDiagnostics.length}`))\n process.exit(errorDiagnostics.length)\n }\n\n return errorDiagnostics.length\n}\n\nexport const packageCompileTsc = async (params?: PackageCompileTscParams): Promise<number> => {\n const defaultCompilerOptions: CompilerOptions = {\n declaration: true,\n declarationMap: true,\n outDir: 'dist',\n rootDir: 'src',\n sourceMap: true,\n }\n const compilerOptions = merge({}, defaultCompilerOptions, params?.compile?.tsc?.compilerOptions)\n const config = await loadConfig(params)\n if (config.verbose) {\n console.log('Compiling with TSC')\n }\n\n const fileNames = (await getAllInputs(config.compile?.depth)).map((fileName) => `src/${fileName}`)\n const configFile = getConfigFile(compilerOptions)\n return compile(fileNames, configFile.compilerOptions)\n}\n"],"mappings":"AAAA,OAAO,WAAW;AAElB,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../../../../src/actions/package/compile/tsc.ts"],"sourcesContent":["import chalk from 'chalk'\n// eslint-disable-next-line import/no-internal-modules\nimport merge from 'lodash/merge'\nimport {\n CompilerOptions,\n createProgram,\n Diagnostic,\n findConfigFile,\n flattenDiagnosticMessageText,\n getLineAndCharacterOfPosition,\n getPreEmitDiagnostics,\n readConfigFile,\n sys,\n} from 'typescript'\n\nimport { loadConfig } from '../../../lib'\nimport { CompileParams } from './CompileParams'\nimport { getCompilerOptions } from './getCompilerOptions'\nimport { getAllInputs } from './inputs'\n\nexport type PackageCompileTscParams = Partial<\n CompileParams & {\n compile?: {\n tsc?: {\n compilerOptions?: CompilerOptions\n tsconfig?: string\n }\n }\n }\n>\n\nconst getConfigFile = (options?: CompilerOptions, tsconfig: string = 'tsconfig.json') => {\n const configFileName = findConfigFile('./', sys.fileExists, tsconfig)\n return { ...(configFileName ? readConfigFile(configFileName, sys.readFile).config : {}), compilerOptions: getCompilerOptions(options) }\n}\n\nconst compile = (fileNames: string[], options: CompilerOptions) => {\n console.log(chalk.blue('compile'))\n console.log(chalk.magenta(`options: ${JSON.stringify(options, null, 2)}`))\n const program = createProgram(fileNames, options)\n console.log(chalk.blue('createProgram'))\n const emitResult = program.emit()\n console.log(chalk.blue('emit'))\n\n const allDiagnostics: Diagnostic[] = getPreEmitDiagnostics(program).concat(emitResult.diagnostics)\n\n const errorDiagnostics = allDiagnostics.filter((diagnostic) => diagnostic.category === 1)\n\n allDiagnostics.forEach((diagnostic) => {\n if (diagnostic.file) {\n const { line, character } = getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start!)\n const message = flattenDiagnosticMessageText(diagnostic.messageText, '\\n')\n console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`)\n } else {\n console.log(flattenDiagnosticMessageText(diagnostic.messageText, '\\n'))\n }\n })\n\n if (errorDiagnostics.length) {\n console.log(chalk.red(`Errors: ${errorDiagnostics.length}`))\n process.exit(errorDiagnostics.length)\n }\n\n return errorDiagnostics.length\n}\n\nexport const packageCompileTsc = async (params?: PackageCompileTscParams): Promise<number> => {\n const defaultCompilerOptions: CompilerOptions = {\n declaration: true,\n declarationMap: true,\n outDir: 'dist',\n rootDir: 'src',\n sourceMap: true,\n }\n const compilerOptions = merge({}, defaultCompilerOptions, params?.compile?.tsc?.compilerOptions)\n const config = await loadConfig(params)\n if (config.verbose) {\n console.log('Compiling with TSC')\n }\n\n const fileNames = (await getAllInputs(config.compile?.depth)).map((fileName) => `src/${fileName}`)\n const configFile = getConfigFile(compilerOptions)\n return compile(fileNames, configFile.compilerOptions)\n}\n"],"mappings":"AAAA,OAAO,WAAW;AAElB,OAAO,WAAW;AAClB;AAAA,EAEE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,kBAAkB;AAE3B,SAAS,0BAA0B;AACnC,SAAS,oBAAoB;AAa7B,MAAM,gBAAgB,CAAC,SAA2B,WAAmB,oBAAoB;AACvF,QAAM,iBAAiB,eAAe,MAAM,IAAI,YAAY,QAAQ;AACpE,SAAO,EAAE,GAAI,iBAAiB,eAAe,gBAAgB,IAAI,QAAQ,EAAE,SAAS,CAAC,GAAI,iBAAiB,mBAAmB,OAAO,EAAE;AACxI;AAEA,MAAM,UAAU,CAAC,WAAqB,YAA6B;AACjE,UAAQ,IAAI,MAAM,KAAK,SAAS,CAAC;AACjC,UAAQ,IAAI,MAAM,QAAQ,YAAY,KAAK,UAAU,SAAS,MAAM,CAAC,CAAC,EAAE,CAAC;AACzE,QAAM,UAAU,cAAc,WAAW,OAAO;AAChD,UAAQ,IAAI,MAAM,KAAK,eAAe,CAAC;AACvC,QAAM,aAAa,QAAQ,KAAK;AAChC,UAAQ,IAAI,MAAM,KAAK,MAAM,CAAC;AAE9B,QAAM,iBAA+B,sBAAsB,OAAO,EAAE,OAAO,WAAW,WAAW;AAEjG,QAAM,mBAAmB,eAAe,OAAO,CAAC,eAAe,WAAW,aAAa,CAAC;AAExF,iBAAe,QAAQ,CAAC,eAAe;AACrC,QAAI,WAAW,MAAM;AACnB,YAAM,EAAE,MAAM,UAAU,IAAI,8BAA8B,WAAW,MAAM,WAAW,KAAM;AAC5F,YAAM,UAAU,6BAA6B,WAAW,aAAa,IAAI;AACzE,cAAQ,IAAI,GAAG,WAAW,KAAK,QAAQ,KAAK,OAAO,CAAC,IAAI,YAAY,CAAC,MAAM,OAAO,EAAE;AAAA,IACtF,OAAO;AACL,cAAQ,IAAI,6BAA6B,WAAW,aAAa,IAAI,CAAC;AAAA,IACxE;AAAA,EACF,CAAC;AAED,MAAI,iBAAiB,QAAQ;AAC3B,YAAQ,IAAI,MAAM,IAAI,WAAW,iBAAiB,MAAM,EAAE,CAAC;AAC3D,YAAQ,KAAK,iBAAiB,MAAM;AAAA,EACtC;AAEA,SAAO,iBAAiB;AAC1B;AAEO,MAAM,oBAAoB,OAAO,WAAsD;AAC5F,QAAM,yBAA0C;AAAA,IAC9C,aAAa;AAAA,IACb,gBAAgB;AAAA,IAChB,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,WAAW;AAAA,EACb;AACA,QAAM,kBAAkB,MAAM,CAAC,GAAG,wBAAwB,QAAQ,SAAS,KAAK,eAAe;AAC/F,QAAM,SAAS,MAAM,WAAW,MAAM;AACtC,MAAI,OAAO,SAAS;AAClB,YAAQ,IAAI,oBAAoB;AAAA,EAClC;AAEA,QAAM,aAAa,MAAM,aAAa,OAAO,SAAS,KAAK,GAAG,IAAI,CAAC,aAAa,OAAO,QAAQ,EAAE;AACjG,QAAM,aAAa,cAAc,eAAe;AAChD,SAAO,QAAQ,WAAW,WAAW,eAAe;AACtD;","names":[]}
@@ -25,11 +25,12 @@ var import_process = require("process");
25
25
  var import_tsc_prog = require("tsc-prog");
26
26
  var import_lib = require("../../../lib");
27
27
  var import_copyTypeFiles = require("./copyTypeFiles");
28
+ var import_getCompilerOptions = require("./getCompilerOptions");
28
29
  const packageCompileTscTypes = async (params) => {
29
30
  const pkg = process.env.INIT_CWD;
30
31
  const buildOptions = {
31
32
  basePath: pkg ?? (0, import_process.cwd)(),
32
- compilerOptions: {
33
+ compilerOptions: (0, import_getCompilerOptions.getCompilerOptions)({
33
34
  declaration: true,
34
35
  declarationMap: true,
35
36
  emitDeclarationOnly: true,
@@ -37,7 +38,7 @@ const packageCompileTscTypes = async (params) => {
37
38
  outDir: "dist",
38
39
  skipLibCheck: true,
39
40
  sourceMap: true
40
- },
41
+ }),
41
42
  exclude: ["dist", "docs", "*.spec.*", "src/**/spec/**/*"],
42
43
  include: ["src"]
43
44
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/actions/package/compile/tscTypes.ts"],"sourcesContent":["import { cwd } from 'process'\nimport { build, BuildOptions } from 'tsc-prog'\n\nimport { loadConfig } from '../../../lib'\nimport { CompileParams } from './CompileParams'\nimport { copyTypeFiles } from './copyTypeFiles'\n\nexport const packageCompileTscTypes = async (params?: CompileParams): Promise<number> => {\n const pkg = process.env.INIT_CWD\n const buildOptions: BuildOptions = {\n basePath: pkg ?? cwd(),\n compilerOptions: {\n declaration: true,\n declarationMap: true,\n emitDeclarationOnly: true,\n esModuleInterop: true,\n outDir: 'dist',\n skipLibCheck: true,\n sourceMap: true,\n },\n exclude: ['dist', 'docs', '*.spec.*', 'src/**/spec/**/*'],\n include: ['src'],\n }\n\n const config = await loadConfig(params)\n if (config.verbose) {\n console.log(`Compiling types with TSC [${pkg}]`)\n }\n\n build(buildOptions)\n await copyTypeFiles()\n return 0\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAoB;AACpB,sBAAoC;AAEpC,iBAA2B;AAE3B,2BAA8B;AAEvB,MAAM,yBAAyB,OAAO,WAA4C;AACvF,QAAM,MAAM,QAAQ,IAAI;AACxB,QAAM,eAA6B;AAAA,IACjC,UAAU,WAAO,oBAAI;AAAA,IACrB,iBAAiB;AAAA,MACf,aAAa;AAAA,MACb,gBAAgB;AAAA,MAChB,qBAAqB;AAAA,MACrB,iBAAiB;AAAA,MACjB,QAAQ;AAAA,MACR,cAAc;AAAA,MACd,WAAW;AAAA,IACb;AAAA,IACA,SAAS,CAAC,QAAQ,QAAQ,YAAY,kBAAkB;AAAA,IACxD,SAAS,CAAC,KAAK;AAAA,EACjB;AAEA,QAAM,SAAS,UAAM,uBAAW,MAAM;AACtC,MAAI,OAAO,SAAS;AAClB,YAAQ,IAAI,6BAA6B,GAAG,GAAG;AAAA,EACjD;AAEA,6BAAM,YAAY;AAClB,YAAM,oCAAc;AACpB,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../../src/actions/package/compile/tscTypes.ts"],"sourcesContent":["import { cwd } from 'process'\nimport { build, BuildOptions, TsConfigCompilerOptions } from 'tsc-prog'\n\nimport { loadConfig } from '../../../lib'\nimport { CompileParams } from './CompileParams'\nimport { copyTypeFiles } from './copyTypeFiles'\nimport { getCompilerOptions } from './getCompilerOptions'\n\nexport const packageCompileTscTypes = async (params?: CompileParams): Promise<number> => {\n const pkg = process.env.INIT_CWD\n const buildOptions: BuildOptions = {\n basePath: pkg ?? cwd(),\n compilerOptions: getCompilerOptions({\n declaration: true,\n declarationMap: true,\n emitDeclarationOnly: true,\n esModuleInterop: true,\n outDir: 'dist',\n skipLibCheck: true,\n sourceMap: true,\n }) as TsConfigCompilerOptions,\n exclude: ['dist', 'docs', '*.spec.*', 'src/**/spec/**/*'],\n include: ['src'],\n }\n\n const config = await loadConfig(params)\n if (config.verbose) {\n console.log(`Compiling types with TSC [${pkg}]`)\n }\n\n build(buildOptions)\n await copyTypeFiles()\n return 0\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAoB;AACpB,sBAA6D;AAE7D,iBAA2B;AAE3B,2BAA8B;AAC9B,gCAAmC;AAE5B,MAAM,yBAAyB,OAAO,WAA4C;AACvF,QAAM,MAAM,QAAQ,IAAI;AACxB,QAAM,eAA6B;AAAA,IACjC,UAAU,WAAO,oBAAI;AAAA,IACrB,qBAAiB,8CAAmB;AAAA,MAClC,aAAa;AAAA,MACb,gBAAgB;AAAA,MAChB,qBAAqB;AAAA,MACrB,iBAAiB;AAAA,MACjB,QAAQ;AAAA,MACR,cAAc;AAAA,MACd,WAAW;AAAA,IACb,CAAC;AAAA,IACD,SAAS,CAAC,QAAQ,QAAQ,YAAY,kBAAkB;AAAA,IACxD,SAAS,CAAC,KAAK;AAAA,EACjB;AAEA,QAAM,SAAS,UAAM,uBAAW,MAAM;AACtC,MAAI,OAAO,SAAS;AAClB,YAAQ,IAAI,6BAA6B,GAAG,GAAG;AAAA,EACjD;AAEA,6BAAM,YAAY;AAClB,YAAM,oCAAc;AACpB,SAAO;AACT;","names":[]}
@@ -2,11 +2,12 @@ import { cwd } from "process";
2
2
  import { build } from "tsc-prog";
3
3
  import { loadConfig } from "../../../lib";
4
4
  import { copyTypeFiles } from "./copyTypeFiles";
5
+ import { getCompilerOptions } from "./getCompilerOptions";
5
6
  const packageCompileTscTypes = async (params) => {
6
7
  const pkg = process.env.INIT_CWD;
7
8
  const buildOptions = {
8
9
  basePath: pkg ?? cwd(),
9
- compilerOptions: {
10
+ compilerOptions: getCompilerOptions({
10
11
  declaration: true,
11
12
  declarationMap: true,
12
13
  emitDeclarationOnly: true,
@@ -14,7 +15,7 @@ const packageCompileTscTypes = async (params) => {
14
15
  outDir: "dist",
15
16
  skipLibCheck: true,
16
17
  sourceMap: true
17
- },
18
+ }),
18
19
  exclude: ["dist", "docs", "*.spec.*", "src/**/spec/**/*"],
19
20
  include: ["src"]
20
21
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/actions/package/compile/tscTypes.ts"],"sourcesContent":["import { cwd } from 'process'\nimport { build, BuildOptions } from 'tsc-prog'\n\nimport { loadConfig } from '../../../lib'\nimport { CompileParams } from './CompileParams'\nimport { copyTypeFiles } from './copyTypeFiles'\n\nexport const packageCompileTscTypes = async (params?: CompileParams): Promise<number> => {\n const pkg = process.env.INIT_CWD\n const buildOptions: BuildOptions = {\n basePath: pkg ?? cwd(),\n compilerOptions: {\n declaration: true,\n declarationMap: true,\n emitDeclarationOnly: true,\n esModuleInterop: true,\n outDir: 'dist',\n skipLibCheck: true,\n sourceMap: true,\n },\n exclude: ['dist', 'docs', '*.spec.*', 'src/**/spec/**/*'],\n include: ['src'],\n }\n\n const config = await loadConfig(params)\n if (config.verbose) {\n console.log(`Compiling types with TSC [${pkg}]`)\n }\n\n build(buildOptions)\n await copyTypeFiles()\n return 0\n}\n"],"mappings":"AAAA,SAAS,WAAW;AACpB,SAAS,aAA2B;AAEpC,SAAS,kBAAkB;AAE3B,SAAS,qBAAqB;AAEvB,MAAM,yBAAyB,OAAO,WAA4C;AACvF,QAAM,MAAM,QAAQ,IAAI;AACxB,QAAM,eAA6B;AAAA,IACjC,UAAU,OAAO,IAAI;AAAA,IACrB,iBAAiB;AAAA,MACf,aAAa;AAAA,MACb,gBAAgB;AAAA,MAChB,qBAAqB;AAAA,MACrB,iBAAiB;AAAA,MACjB,QAAQ;AAAA,MACR,cAAc;AAAA,MACd,WAAW;AAAA,IACb;AAAA,IACA,SAAS,CAAC,QAAQ,QAAQ,YAAY,kBAAkB;AAAA,IACxD,SAAS,CAAC,KAAK;AAAA,EACjB;AAEA,QAAM,SAAS,MAAM,WAAW,MAAM;AACtC,MAAI,OAAO,SAAS;AAClB,YAAQ,IAAI,6BAA6B,GAAG,GAAG;AAAA,EACjD;AAEA,QAAM,YAAY;AAClB,QAAM,cAAc;AACpB,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../../src/actions/package/compile/tscTypes.ts"],"sourcesContent":["import { cwd } from 'process'\nimport { build, BuildOptions, TsConfigCompilerOptions } from 'tsc-prog'\n\nimport { loadConfig } from '../../../lib'\nimport { CompileParams } from './CompileParams'\nimport { copyTypeFiles } from './copyTypeFiles'\nimport { getCompilerOptions } from './getCompilerOptions'\n\nexport const packageCompileTscTypes = async (params?: CompileParams): Promise<number> => {\n const pkg = process.env.INIT_CWD\n const buildOptions: BuildOptions = {\n basePath: pkg ?? cwd(),\n compilerOptions: getCompilerOptions({\n declaration: true,\n declarationMap: true,\n emitDeclarationOnly: true,\n esModuleInterop: true,\n outDir: 'dist',\n skipLibCheck: true,\n sourceMap: true,\n }) as TsConfigCompilerOptions,\n exclude: ['dist', 'docs', '*.spec.*', 'src/**/spec/**/*'],\n include: ['src'],\n }\n\n const config = await loadConfig(params)\n if (config.verbose) {\n console.log(`Compiling types with TSC [${pkg}]`)\n }\n\n build(buildOptions)\n await copyTypeFiles()\n return 0\n}\n"],"mappings":"AAAA,SAAS,WAAW;AACpB,SAAS,aAAoD;AAE7D,SAAS,kBAAkB;AAE3B,SAAS,qBAAqB;AAC9B,SAAS,0BAA0B;AAE5B,MAAM,yBAAyB,OAAO,WAA4C;AACvF,QAAM,MAAM,QAAQ,IAAI;AACxB,QAAM,eAA6B;AAAA,IACjC,UAAU,OAAO,IAAI;AAAA,IACrB,iBAAiB,mBAAmB;AAAA,MAClC,aAAa;AAAA,MACb,gBAAgB;AAAA,MAChB,qBAAqB;AAAA,MACrB,iBAAiB;AAAA,MACjB,QAAQ;AAAA,MACR,cAAc;AAAA,MACd,WAAW;AAAA,IACb,CAAC;AAAA,IACD,SAAS,CAAC,QAAQ,QAAQ,YAAY,kBAAkB;AAAA,IACxD,SAAS,CAAC,KAAK;AAAA,EACjB;AAEA,QAAM,SAAS,MAAM,WAAW,MAAM;AACtC,MAAI,OAAO,SAAS;AAClB,YAAQ,IAAI,6BAA6B,GAAG,GAAG;AAAA,EACjD;AAEA,QAAM,YAAY;AAClB,QAAM,cAAc;AACpB,SAAO;AACT;","names":[]}
package/package.json CHANGED
@@ -66,7 +66,7 @@
66
66
  "@types/yargs": "^17.0.24",
67
67
  "@typescript-eslint/eslint-plugin": "^6.7.0",
68
68
  "@typescript-eslint/parser": "^6.7.0",
69
- "@xylabs/tsconfig": "~3.0.22",
69
+ "@xylabs/tsconfig": "~3.0.23",
70
70
  "chalk": "^4.1.2",
71
71
  "cosmiconfig": "^8.3.6",
72
72
  "cpy": "^8.1.2",
@@ -110,8 +110,8 @@
110
110
  "@types/license-checker": "^25.0.4",
111
111
  "@types/lodash": "^4.14.198",
112
112
  "@types/parse-git-config": "^3.0.1",
113
- "@xylabs/eslint-config": "^3.0.22",
114
- "@xylabs/tsconfig": "^3.0.22",
113
+ "@xylabs/eslint-config": "^3.0.23",
114
+ "@xylabs/tsconfig": "^3.0.23",
115
115
  "publint": "^0.2.2",
116
116
  "typescript": "^5.2.2"
117
117
  },
@@ -168,5 +168,5 @@
168
168
  "package-clean": "echo Not cleaning..."
169
169
  },
170
170
  "sideEffects": false,
171
- "version": "3.0.22"
171
+ "version": "3.0.23"
172
172
  }
@@ -0,0 +1,24 @@
1
+ // eslint-disable-next-line import/no-internal-modules
2
+ import merge from 'lodash/merge'
3
+ import { CompilerOptions, findConfigFile, readConfigFile, sys } from 'typescript'
4
+
5
+ export const getCompilerOptionsJSONFollowExtends = (filename: string): CompilerOptions => {
6
+ let opts = {}
7
+ const config = readConfigFile(filename, sys.readFile).config
8
+ if (config.extends) {
9
+ const requirePath = require.resolve(config.extends)
10
+ opts = getCompilerOptionsJSONFollowExtends(requirePath)
11
+ }
12
+ if (config?.error) {
13
+ throw Error(`getCompilerOptionsJSONFollowExtends failed ${JSON.stringify(config?.error?.messageText, null, 2)}`)
14
+ }
15
+
16
+ return { ...opts, ...config.compilerOptions }
17
+ }
18
+
19
+ export const getCompilerOptions = (options?: CompilerOptions, tsconfig: string = 'tsconfig.json'): CompilerOptions => {
20
+ const configFileName = findConfigFile('./', sys.fileExists, tsconfig)
21
+ const configFileCompilerOptions = configFileName ? getCompilerOptionsJSONFollowExtends(configFileName) : undefined
22
+
23
+ return merge({}, configFileCompilerOptions, options)
24
+ }
@@ -15,6 +15,7 @@ import {
15
15
 
16
16
  import { loadConfig } from '../../../lib'
17
17
  import { CompileParams } from './CompileParams'
18
+ import { getCompilerOptions } from './getCompilerOptions'
18
19
  import { getAllInputs } from './inputs'
19
20
 
20
21
  export type PackageCompileTscParams = Partial<
@@ -28,28 +29,6 @@ export type PackageCompileTscParams = Partial<
28
29
  }
29
30
  >
30
31
 
31
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
32
- const getCompilerOptionsJSONFollowExtends = (filename: string): CompilerOptions => {
33
- let opts = {}
34
- const config = readConfigFile(filename, sys.readFile).config
35
- if (config.extends) {
36
- const requirePath = require.resolve(config.extends)
37
- opts = getCompilerOptionsJSONFollowExtends(requirePath)
38
- }
39
- if (config?.error) {
40
- throw Error(`getCompilerOptionsJSONFollowExtends failed ${JSON.stringify(config?.error?.messageText, null, 2)}`)
41
- }
42
-
43
- return { ...opts, ...config.compilerOptions }
44
- }
45
-
46
- const getCompilerOptions = (options?: CompilerOptions, tsconfig: string = 'tsconfig.json'): CompilerOptions => {
47
- const configFileName = findConfigFile('./', sys.fileExists, tsconfig)
48
- const configFileCompilerOptions = configFileName ? getCompilerOptionsJSONFollowExtends(configFileName) : undefined
49
-
50
- return merge({}, configFileCompilerOptions, options)
51
- }
52
-
53
32
  const getConfigFile = (options?: CompilerOptions, tsconfig: string = 'tsconfig.json') => {
54
33
  const configFileName = findConfigFile('./', sys.fileExists, tsconfig)
55
34
  return { ...(configFileName ? readConfigFile(configFileName, sys.readFile).config : {}), compilerOptions: getCompilerOptions(options) }
@@ -1,15 +1,16 @@
1
1
  import { cwd } from 'process'
2
- import { build, BuildOptions } from 'tsc-prog'
2
+ import { build, BuildOptions, TsConfigCompilerOptions } from 'tsc-prog'
3
3
 
4
4
  import { loadConfig } from '../../../lib'
5
5
  import { CompileParams } from './CompileParams'
6
6
  import { copyTypeFiles } from './copyTypeFiles'
7
+ import { getCompilerOptions } from './getCompilerOptions'
7
8
 
8
9
  export const packageCompileTscTypes = async (params?: CompileParams): Promise<number> => {
9
10
  const pkg = process.env.INIT_CWD
10
11
  const buildOptions: BuildOptions = {
11
12
  basePath: pkg ?? cwd(),
12
- compilerOptions: {
13
+ compilerOptions: getCompilerOptions({
13
14
  declaration: true,
14
15
  declarationMap: true,
15
16
  emitDeclarationOnly: true,
@@ -17,7 +18,7 @@ export const packageCompileTscTypes = async (params?: CompileParams): Promise<nu
17
18
  outDir: 'dist',
18
19
  skipLibCheck: true,
19
20
  sourceMap: true,
20
- },
21
+ }) as TsConfigCompilerOptions,
21
22
  exclude: ['dist', 'docs', '*.spec.*', 'src/**/spec/**/*'],
22
23
  include: ['src'],
23
24
  }