UNPKG

typle

Version:

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

42 lines (31 loc) • 2.83 kB
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _chunkDST4XDNTjs = require('./chunk-DST4XDNT.js'); // src/cli.ts var _clittle = require('clittle'); var _lilconfig = require('lilconfig'); var _fs = require('fs'); function runCLI() { return _chunkDST4XDNTjs.__async.call(void 0, this, null, function* () { let version = yield _chunkDST4XDNTjs.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", cache: !0 }); function loadConfig(configPath) { var _a; try { return configPath && !_fs.existsSync.call(void 0, _chunkDST4XDNTjs.joincwd.call(void 0, configPath)) ? (_chunkDST4XDNTjs.logger_default.warn(configPath, "doesn't exist"), {}) : (_a = configPath ? configExplorer.load(configPath) : configExplorer.search()) == null ? void 0 : _a.config; } catch (e) { return _chunkDST4XDNTjs.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) => _chunkDST4XDNTjs.__async.call(void 0, this, null, function* () { let config = loadConfig(args.options.config), options = _chunkDST4XDNTjs.__spreadValues.call(void 0, _chunkDST4XDNTjs.__spreadValues.call(void 0, { patterns: args.patterns }, config), args.options); yield _chunkDST4XDNTjs.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) => _chunkDST4XDNTjs.__async.call(void 0, this, null, function* () { let options = _chunkDST4XDNTjs.__spreadValues.call(void 0, _chunkDST4XDNTjs.__spreadValues.call(void 0, {}, loadConfig()), args.options); yield _chunkDST4XDNTjs.install.call(void 0, args.libraries, options); })), prog.parse(), _chunkDST4XDNTjs.logger_default.info("v" + version); }); } exports.runCLI = runCLI;