UNPKG

typle

Version:

📦 Scan and install missing Typescript type definitions for your dependencies.

73 lines (62 loc) • 3.7 kB
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var _chunkRPTZ5435js = require('./chunk-RPTZ5435.js'); // src/cli.ts var _clittle = require('clittle'); var _lilconfig = require('lilconfig'); var _jiti = require('jiti'); var _jiti2 = _interopRequireDefault(_jiti); var _fs = require('fs'); function loadTypescript(filepath) { return _jiti2.default.call(void 0, __filename, { interopDefault: !0 })(filepath); } var configPaths = [ "package.json", ".typlerc.js", ".typlerc.cjs", ".typlerc.json", "typle.config.js", "typle.config.cjs", ".config/typlerc", ".config/typlerc.json", ".config/typlerc.js", ".config/typlerc.cjs", ".typlerc.ts", ".typlerc.mts", ".typlerc.cts", "typle.config.ts", "typle.config.mts", "typle.config.cts", ".config/typlerc.ts", ".config/typlerc.mts", ".config/typlerc.cts" ]; function runCLI() { return _chunkRPTZ5435js.__async.call(void 0, this, null, function* () { let version = yield _chunkRPTZ5435js.getVersion.call(void 0, ), prog = _clittle.cli.call(void 0, "typle [patterns...]").version(version), configExplorer = _lilconfig.lilconfigSync.call(void 0, "typle", { stopDir: process.cwd(), packageProp: "typleConfig", searchPlaces: configPaths, loaders: { ".ts": loadTypescript, ".mts": loadTypescript, ".cts": loadTypescript }, cache: !0 }); function loadConfig(configPath) { var _a; try { return configPath && !_fs.existsSync.call(void 0, _chunkRPTZ5435js.joincwd.call(void 0, configPath)) ? (_chunkRPTZ5435js.logger_default.warn(configPath, "doesn't exist"), {}) : (_a = configPath ? configExplorer.load(configPath) : configExplorer.search()) == null ? void 0 : _a.config; } catch (e) { return _chunkRPTZ5435js.logger_default.error("couldn't load the config file"), {}; } } prog.describe("Scan and install missing Typescript type definitions for dependencies in 'package.json'.").option("--no-silent, Run install silently.").option("--no-install, Whether to install packages automatically or just update package.json.").option("--pkg-manager [manager], Which package manager to use.", { type: "string" }).option("--ignore-packages [packages...], List of packages to ignore.").option("--ignore-deps [deps...], List of certain dependency fields to ignore e.g. 'dev'.").option("--config [path], Path to the config file.").option("--cwd [path], The current working directory.").option("--dry-run, It won't cause any changes to package.json.").example("$ typle --ignore-packages nodemon eslint").example("$ typle packages/*").action((args) => _chunkRPTZ5435js.__async.call(void 0, this, null, function* () { let config = loadConfig(args.options.config), options = _chunkRPTZ5435js.__spreadValues.call(void 0, _chunkRPTZ5435js.__spreadValues.call(void 0, { patterns: args.patterns }, config), args.options); yield _chunkRPTZ5435js.run.call(void 0, options); })), prog.command("install [...libraries]", "Install packages with their corresponding type declarations.", { alias: "i" }).example("$ typle i semver (will install both semver and @types/semver)").action((args) => _chunkRPTZ5435js.__async.call(void 0, this, null, function* () { let options = _chunkRPTZ5435js.__spreadValues.call(void 0, _chunkRPTZ5435js.__spreadValues.call(void 0, {}, loadConfig()), args.options); yield _chunkRPTZ5435js.install.call(void 0, args.libraries, options); })), prog.parse(), _chunkRPTZ5435js.logger_default.info("v" + version); }); } exports.runCLI = runCLI;