UNPKG

beesbuild

Version:

构建工具链

89 lines (88 loc) 4.5 kB
"use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod)); var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var stdin_exports = {}; __export(stdin_exports, { WORKSPACE_DIR: () => WORKSPACE_DIR, handleOptions: () => handleOptions, init: () => init }); module.exports = __toCommonJS(stdin_exports); var import_utils = require("@beesbuild/utils"); var import_lodash_unified = require("lodash-unified"); var import_commander = require("commander"); var import_fast_glob = __toESM(require("fast-glob")); var import_boolean_parser = require("../boolean-parser.cjs"); const WORKSPACE_DIR = "pnpm-workspace.yaml"; const handleOptions = (program, options) => { var _a; const opts = (0, import_lodash_unified.merge)({}, program.opts(), options); opts.json = (0, import_boolean_parser.booleanParser)(opts.json); opts.debug = (0, import_boolean_parser.booleanParser)(opts.debug); opts.syncVersion = (0, import_boolean_parser.booleanParser)(opts.syncVersion); opts.verbose = (0, import_boolean_parser.booleanParser)(opts.verbose); opts.debug && import_utils.consola.info(opts); opts.monorepo = (0, import_boolean_parser.booleanParser)(opts.monorepo); opts.clean = (0, import_boolean_parser.booleanParser)(opts.clean); if (!opts.monorepo) { const workspaces = import_fast_glob.default.sync([(_a = opts.workspaceDir) != null ? _a : WORKSPACE_DIR], { deep: 1, onlyFiles: true, absolute: false }); opts.monorepo = workspaces.length > 0; } return opts; }; const init = (options, program) => { if (!(program instanceof import_commander.Command)) { program = new import_commander.Command(); } program.name(options.name).summary("make a copy").addHelpText("before", `Version ${options.version}`).usage("[global options] [command]").usage("[ -h | --help | -v | --version ]").description("CLI to some JavaScript string utilities").version(options.version); program.option("-F, --filter <package_selector>", "\u8FC7\u6EE4\u5141\u8BB8\u60A8\u5C06\u547D\u4EE4\u9650\u5236\u4E3A\u7279\u5B9A\u7684\u5305\u5B50\u96C6\u3002", "./packages/**").option("-M, --monorepo", "\u591A\u4E2A\u5305\u7684\u652F\u6301").option("-C, --no-clean", "\u662F\u5426\u5220\u9664\u6253\u5305\u6587\u4EF6\u6216\u6587\u4EF6\u5939").option("-v, --verbose", "\u8BE6\u7EC6\u663E\u793A\u8FDB\u884C\u7684\u6B65\u9AA4").option("--no-sync-version <sync-version>", "\u540C\u6B65\u672C\u5730\u4E0ENPM\u7684\u5305\u7248\u672C\u4FE1\u606F").option("--changed-files-ignore-pattern <glob>", "\u5141\u8BB8\u5728\u8FC7\u6EE4\u81EA\u6307\u5B9A\u63D0\u4EA4/\u5206\u652F\u4EE5\u6765\u66F4\u6539\u7684\u9879\u76EE\u65F6\u6309 glob \u6A21\u5F0F\u5FFD\u7565\u66F4\u6539\u7684\u6587\u4EF6\u3002").option("--root-dir <rootDir>", "\u9879\u76EE\u6839\u76EE\u5F55", process.cwd()).option("--workspace-dir <workspaceDir>", "pnpm-workspace \u6587\u4EF6\u8DEF\u5F84", WORKSPACE_DIR).option("--debug", "\u8C03\u8BD5\u6A21\u5F0F"); const inst = { next: func => { typeof func === "function" && func(program); return inst; }, end: () => program }; return inst; }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { WORKSPACE_DIR, handleOptions, init });