UNPKG

setup-typescript-monorepo

Version:

Convert Workspaces to TypeScript's Project References

99 lines 4.78 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.run = exports.cli = void 0; var tslib_1 = require("tslib"); var meow_1 = tslib_1.__importDefault(require("meow")); var path_1 = tslib_1.__importDefault(require("path")); var index_1 = require("./index"); exports.cli = meow_1.default("\n Usage\n $ workspaces-to-typescript-project-references\n \n\n Options\n --root [Path:string] Root directory of the monorepo. \n Default: current working directory\n\n --package Only run on specified package and its dependencies, \n can be provided multiple times\n\n --check If set the flag, check only differences of tsconfig.json and does not update tsconfig.json.\n If the check is failed, exit status 1. It is useful for testing.\n \n --plugin [Path:string] Path to plugin script.\n Load the plugin script as module and use it. \n \n --tsconfigPath [Path:string] Use alternative config path inside the package. e.g.: tsconfig.test.json\n Default: tsconfig.json\n\n --removeComments If set the flag, removes comments from tsconfig.json.\n\n --indentation tsconfig.json indentation number, defaults to 2\n\n --onlyOnPath apply changes only on packages children of specified path\n\n --addInclude\n\n --addExtends\n\n --addRootDir\n\n --addComposite\n\n --addEsmTsconfig Adds a tsconfig.esm.json file to compile to esm\n\n Examples\n # Update project references in tsconfig.json\n $ workspaces-to-typescript-project-references\n # Test on CI\n $ workspaces-to-typescript-project-references --check\n", { flags: { root: { type: "string", default: process.cwd() }, check: { type: "boolean", default: false }, package: { type: "string", isMultiple: true }, removeComments: { type: "boolean", default: false }, indentation: { type: "number", default: 2 }, plugin: { type: "string", isMultiple: true }, onlyOnPath: { type: "string" }, addInclude: { type: "string", isMultiple: true }, addRootDir: { type: "string" }, addEsmTsconfig: { type: "string" }, addExtends: { type: "string" }, tsconfigPath: { type: "string", default: "tsconfig.json" } }, autoHelp: true, autoVersion: true }); exports.run = function (_input, flags) { if (_input === void 0) { _input = exports.cli.input; } if (flags === void 0) { flags = exports.cli.flags; } return tslib_1.__awaiter(void 0, void 0, void 0, function () { var plugins, customTsConfigFinder, result; return tslib_1.__generator(this, function (_a) { plugins = Array.isArray(flags.plugin) ? flags.plugin.map(function (pluginPath) { var plugin = require(path_1.default.join(process.cwd(), pluginPath)); if (typeof plugin.plugin !== "function") { throw new Error("plugin should export { plugin }."); } return plugin.plugin; }) : undefined; customTsConfigFinder = function (location) { return path_1.default.join(location, flags.tsconfigPath); }; result = index_1.toProjectReferences(tslib_1.__assign({ rootDir: flags.root, checkOnly: flags.check, plugins: plugins, tsConfigPathFinder: flags.tsconfigPath ? customTsConfigFinder : undefined, onlyPackages: flags.package }, flags)); if (result.ok) { return [2 /*return*/, { exitStatus: 0, stdout: flags.check ? "" : "Updated Project References!", stderr: null }]; } else if (result.errors) { return [2 /*return*/, { exitStatus: 1, stdout: null, stderr: '\n\n' + result.errors.join("\n\n\n") }]; } return [2 /*return*/, { exitStatus: 0, stdout: null, stderr: null }]; }); }); }; //# sourceMappingURL=cli.js.map