UNPKG

weapp-tailwindcss

Version:

把 tailwindcss 原子化样式思想,带给小程序开发者们! bring tailwindcss to miniprogram developers!

697 lines (668 loc) 25.4 kB
"use strict"; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _chunkA2OSQ5CVjs = require('./chunk-A2OSQ5CV.js'); var _chunkPT4IJT3Qjs = require('./chunk-PT4IJT3Q.js'); require('./chunk-6R4BK6D6.js'); require('./chunk-FMBPNII7.js'); require('./chunk-MB4BR57E.js'); // src/cli.ts var _process = require('process'); var _process2 = _interopRequireDefault(_process); var _semver = require('semver'); var _semver2 = _interopRequireDefault(_semver); var _tailwindcsspatch = require('tailwindcss-patch'); // src/cli/context.ts var _path = require('path'); var _path2 = _interopRequireDefault(_path); function formatOutputPath(target, baseDir) { const root = _nullishCoalesce(baseDir, () => ( _process2.default.cwd())); const relative = _path2.default.relative(root, target); if (!relative) { return "."; } if (relative.startsWith("..")) { return _path2.default.normalize(target); } return relative.startsWith(".") ? relative : `.${_path2.default.sep}${relative}`; } // src/cli/helpers.ts var _promises = require('fs/promises'); // src/tailwindcss/index.ts var _localpkg = require('local-pkg'); function getTailwindcssPackageInfo(options) { return _localpkg.getPackageInfoSync.call(void 0, "tailwindcss", options); } // src/cli/helpers.ts function readStringOption(flag, value) { if (value == null) { return void 0; } if (typeof value !== "string") { throw new TypeError(`Option "--${flag}" expects a string value.`); } const trimmed = value.trim(); if (trimmed.length === 0) { throw new TypeError(`Option "--${flag}" expects a non-empty value.`); } return trimmed; } function readStringArrayOption(flag, value) { if (value == null) { return void 0; } if (Array.isArray(value)) { const normalized2 = value.filter((entry) => entry != null).map((entry) => { if (typeof entry !== "string") { throw new TypeError(`Option "--${flag}" expects string values.`); } const trimmed = entry.trim(); if (!trimmed) { throw new TypeError(`Option "--${flag}" expects non-empty values.`); } return trimmed; }); return normalized2.length > 0 ? normalized2 : void 0; } const normalized = readStringOption(flag, value); return normalized ? [normalized] : void 0; } function toBoolean(value, fallback) { if (typeof value === "boolean") { return value; } if (typeof value === "string") { if (value === "true") { return true; } if (value === "false") { return false; } } if (value == null) { return fallback; } return Boolean(value); } function resolveCliCwd(value) { const raw = readStringOption("cwd", value); if (!raw) { return void 0; } return _path2.default.isAbsolute(raw) ? _path2.default.normalize(raw) : _path2.default.resolve(_process2.default.cwd(), raw); } function normalizeCandidatePath(baseDir, candidate) { if (!candidate) { return void 0; } return _path2.default.isAbsolute(candidate) ? _path2.default.normalize(candidate) : _path2.default.resolve(baseDir, candidate); } function detectTailwindWorkspace(paths) { for (const candidate of paths) { try { const info = getTailwindcssPackageInfo({ paths: [candidate] }); if (_optionalChain([info, 'optionalAccess', _ => _.rootPath])) { return candidate; } } catch (e) { } } return void 0; } function resolvePatchDefaultCwd(currentCwd = _process2.default.cwd()) { const baseDir = _path2.default.normalize(currentCwd); const explicitCwd = normalizeCandidatePath(baseDir, _process2.default.env.WEAPP_TW_PATCH_CWD); if (explicitCwd) { return explicitCwd; } const workspaceRoot = _chunkPT4IJT3Qjs.findWorkspaceRoot.call(void 0, baseDir); const initCwd = normalizeCandidatePath(baseDir, _process2.default.env.INIT_CWD); const localPrefix = normalizeCandidatePath(baseDir, _process2.default.env.npm_config_local_prefix); const candidates = [ baseDir, workspaceRoot, initCwd, localPrefix ].filter(Boolean); const detected = detectTailwindWorkspace([...new Set(candidates)]); if (detected) { return detected; } return _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(initCwd, () => ( localPrefix)), () => ( workspaceRoot)), () => ( baseDir)); } async function ensureDir(dir) { await _promises.mkdir.call(void 0, dir, { recursive: true }); } function handleCliError(error) { if (error instanceof Error) { _chunkPT4IJT3Qjs.logger.error(error.message); if (error.stack && _process2.default.env.WEAPP_TW_DEBUG === "1") { _chunkPT4IJT3Qjs.logger.error(error.stack); } } else { _chunkPT4IJT3Qjs.logger.error(String(error)); } } function commandAction(handler) { return async (...args) => { try { await handler(...args); } catch (error) { handleCliError(error); _process2.default.exitCode = 1; } }; } // src/cli/mount-options.ts // src/cli/patch-options.ts var DEFAULT_EXTEND_LENGTH_UNITS_FEATURE = { enabled: true, units: ["rpx"], overwrite: true }; function withDefaultExtendLengthUnits(options) { const normalized = _nullishCoalesce(options, () => ( {})); const extendLengthUnits = _optionalChain([normalized, 'access', _2 => _2.features, 'optionalAccess', _3 => _3.extendLengthUnits]); if (extendLengthUnits == null) { return { ...normalized, features: { ..._nullishCoalesce(normalized.features, () => ( {})), extendLengthUnits: DEFAULT_EXTEND_LENGTH_UNITS_FEATURE } }; } return normalized; } function buildExtendLengthUnitsOverride(options) { const extendLengthUnits = _optionalChain([options, 'optionalAccess', _4 => _4.features, 'optionalAccess', _5 => _5.extendLengthUnits]); if (extendLengthUnits == null) { return { features: { ..._nullishCoalesce(_optionalChain([options, 'optionalAccess', _6 => _6.features]), () => ( {})), extendLengthUnits: DEFAULT_EXTEND_LENGTH_UNITS_FEATURE } }; } return void 0; } // src/cli/workspace.ts var _fs = require('fs'); var _fastglob = require('fast-glob'); var _fastglob2 = _interopRequireDefault(_fastglob); var _yaml = require('yaml'); function tryReadJson(file) { try { const content = _fs.readFileSync.call(void 0, file, "utf8"); return JSON.parse(content); } catch (e2) { return void 0; } } function parseWorkspaceGlobsFromPackageJson(workspaceRoot) { const pkgJsonPath = _path2.default.join(workspaceRoot, "package.json"); const pkg = tryReadJson(pkgJsonPath); if (!_optionalChain([pkg, 'optionalAccess', _7 => _7.workspaces])) { return []; } if (Array.isArray(pkg.workspaces)) { return pkg.workspaces.filter(Boolean); } if (Array.isArray(pkg.workspaces.packages)) { return pkg.workspaces.packages.filter(Boolean); } return []; } function parseWorkspaceGlobsFromWorkspaceFile(workspaceRoot) { const workspaceFile = _path2.default.join(workspaceRoot, "pnpm-workspace.yaml"); if (!_fs.existsSync.call(void 0, workspaceFile)) { return []; } try { const parsed = _yaml.parse.call(void 0, _fs.readFileSync.call(void 0, workspaceFile, "utf8")); return Array.isArray(_optionalChain([parsed, 'optionalAccess', _8 => _8.packages])) ? parsed.packages.filter(Boolean) : []; } catch (e3) { return []; } } function parseImportersFromLock(workspaceRoot) { const lockPath = _path2.default.join(workspaceRoot, "pnpm-lock.yaml"); if (!_fs.existsSync.call(void 0, lockPath)) { return []; } try { const parsed = _yaml.parse.call(void 0, _fs.readFileSync.call(void 0, lockPath, "utf8")); const importers = _optionalChain([parsed, 'optionalAccess', _9 => _9.importers]); if (!importers) { return []; } return Object.keys(importers).map((key) => { if (!key || key === ".") { return workspaceRoot; } return _path2.default.join(workspaceRoot, key); }); } catch (e4) { return []; } } async function resolveWorkspacePackageDirs(workspaceRoot) { const dirs = /* @__PURE__ */ new Set(); for (const importerDir of parseImportersFromLock(workspaceRoot)) { dirs.add(_path2.default.normalize(importerDir)); } if (!dirs.size) { let globs = parseWorkspaceGlobsFromWorkspaceFile(workspaceRoot); if (!globs.length) { globs = parseWorkspaceGlobsFromPackageJson(workspaceRoot); } if (globs.length > 0) { const patterns = globs.map((pattern) => { const normalized = pattern.replace(/\\/g, "/").replace(/\/+$/, ""); return normalized.endsWith("package.json") ? normalized : `${normalized}/package.json`; }); const packageJsonFiles = await _fastglob2.default.call(void 0, patterns, { cwd: workspaceRoot, absolute: true, onlyFiles: true, unique: true, ignore: ["**/node_modules/**", "**/.git/**"] }); for (const file of packageJsonFiles) { dirs.add(_path2.default.normalize(_path2.default.dirname(file))); } } } const rootPkg = _path2.default.join(workspaceRoot, "package.json"); if (_fs.existsSync.call(void 0, rootPkg)) { dirs.add(_path2.default.normalize(workspaceRoot)); } return [...dirs]; } function createWorkspacePatcher(cwd) { const normalized = _tailwindcsspatch.normalizeOptions.call(void 0, withDefaultExtendLengthUnits({ cwd }) ); return new (0, _tailwindcsspatch.TailwindcssPatcher)(normalized); } function formatDisplayName(workspaceRoot, dir, name) { const relative = _path2.default.relative(workspaceRoot, dir) || "."; return name ? `${name} (${relative})` : relative; } async function patchWorkspace(options) { const cwd = _nullishCoalesce(options.cwd, () => ( _process2.default.cwd())); const workspaceRoot = _nullishCoalesce(_chunkPT4IJT3Qjs.findWorkspaceRoot.call(void 0, cwd), () => ( cwd)); const packageDirs = await resolveWorkspacePackageDirs(workspaceRoot); if (packageDirs.length === 0) { _chunkPT4IJT3Qjs.logger.warn("\u672A\u5728 %s \u68C0\u6D4B\u5230 workspace \u5305\uFF0C\u5DF2\u8DF3\u8FC7\u6279\u91CF patch\u3002", workspaceRoot); return; } const results = []; for (const dir of packageDirs) { const pkgJsonPath = _path2.default.join(dir, "package.json"); const pkgJson = tryReadJson(pkgJsonPath); const displayName = formatDisplayName(workspaceRoot, dir, _optionalChain([pkgJson, 'optionalAccess', _10 => _10.name])); const tailwindInfo = getTailwindcssPackageInfo({ paths: [dir] }); if (!_optionalChain([tailwindInfo, 'optionalAccess', _11 => _11.rootPath])) { results.push({ dir, name: _optionalChain([pkgJson, 'optionalAccess', _12 => _12.name]), status: "skipped", message: "tailwindcss \u672A\u5B89\u88C5\uFF0C\u5DF2\u8DF3\u8FC7\u3002" }); _chunkPT4IJT3Qjs.logger.info("[workspace] \u8DF3\u8FC7 %s\uFF08tailwindcss \u672A\u5B89\u88C5\uFF09\u3002", displayName); continue; } try { const patcher = createWorkspacePatcher(dir); if (options.clearCache) { await _chunkA2OSQ5CVjs.clearTailwindcssPatcherCache.call(void 0, patcher, { removeDirectory: true }); } const recorder = _chunkA2OSQ5CVjs.createPatchTargetRecorder.call(void 0, dir, patcher, { source: "cli", cwd: dir, recordTarget: options.recordTarget !== false, alwaysRecord: true }); if (_optionalChain([recorder, 'optionalAccess', _13 => _13.message])) { _chunkPT4IJT3Qjs.logger.info("[workspace] %s %s", displayName, recorder.message); } _chunkA2OSQ5CVjs.logTailwindcssTarget.call(void 0, "cli", patcher, dir); await patcher.patch(); if (_optionalChain([recorder, 'optionalAccess', _14 => _14.onPatched])) { await recorder.onPatched(); } results.push({ dir, name: _optionalChain([pkgJson, 'optionalAccess', _15 => _15.name]), status: "patched", message: "\u5DF2\u5B8C\u6210 patch\u3002" }); _chunkPT4IJT3Qjs.logger.success("[workspace] \u5DF2\u8865\u4E01 %s", displayName); } catch (error) { const reason = error instanceof Error ? error.message : String(error); const suggestion = `\u8BF7\u5728 ${dir} \u8FD0\u884C "weapp-tw patch --cwd ${dir}".`; const message = `${reason}\uFF0C${suggestion}`; results.push({ dir, name: _optionalChain([pkgJson, 'optionalAccess', _16 => _16.name]), status: "failed", message }); _chunkPT4IJT3Qjs.logger.error("[workspace] \u8865\u4E01\u5931\u8D25 %s\uFF1A%s", displayName, message); } } const patched = results.filter((result) => result.status === "patched").length; const skipped = results.filter((result) => result.status === "skipped").length; const failed = results.filter((result) => result.status === "failed").length; _chunkPT4IJT3Qjs.logger.info("[workspace] \u6C47\u603B\uFF1A\u5DF2\u8865\u4E01 %d\uFF0C\u8DF3\u8FC7 %d\uFF0C\u5931\u8D25 %d", patched, skipped, failed); } // src/cli/mount-options.ts function handleCliError2(error) { if (error instanceof Error) { _chunkPT4IJT3Qjs.logger.error(error.message); if (error.stack && _process2.default.env.WEAPP_TW_DEBUG === "1") { _chunkPT4IJT3Qjs.logger.error(error.stack); } } else { _chunkPT4IJT3Qjs.logger.error(String(error)); } } function withCommandErrorHandling(handler) { return (async (ctx, next) => { try { return await handler(ctx, next); } catch (error) { handleCliError2(error); _process2.default.exitCode = 1; return void 0; } }); } async function createPatcherWithDefaultExtendLengthUnits(ctx) { const patchOptions = await ctx.loadPatchOptions(); const extendLengthUnitsOverride = buildExtendLengthUnitsOverride(patchOptions); if (extendLengthUnitsOverride) { return ctx.createPatcher(extendLengthUnitsOverride); } return ctx.createPatcher(); } function formatStatusFilesHint(files) { if (!_optionalChain([files, 'optionalAccess', _17 => _17.length])) { return ""; } return ` (${files.join(", ")})`; } function logPatchStatusReport(report) { const applied = report.entries.filter((entry) => entry.status === "applied"); const pending = report.entries.filter((entry) => entry.status === "not-applied"); const skipped = report.entries.filter( (entry) => entry.status === "skipped" || entry.status === "unsupported" ); const packageLabel = `${_nullishCoalesce(report.package.name, () => ( "tailwindcss"))}@${_nullishCoalesce(report.package.version, () => ( "unknown"))}`; _chunkPT4IJT3Qjs.logger.info(`Patch status for ${packageLabel} (v${report.majorVersion})`); if (applied.length) { _chunkPT4IJT3Qjs.logger.success("Applied:"); applied.forEach((entry) => { _chunkPT4IJT3Qjs.logger.success(` - ${entry.name}${formatStatusFilesHint(entry.files)}`); }); } if (pending.length) { _chunkPT4IJT3Qjs.logger.warn("Needs attention:"); pending.forEach((entry) => { const details = entry.reason ? ` - ${entry.reason}` : ""; _chunkPT4IJT3Qjs.logger.warn(` - ${entry.name}${formatStatusFilesHint(entry.files)}${details}`); }); } else { _chunkPT4IJT3Qjs.logger.success("All applicable patches are applied."); } if (skipped.length) { _chunkPT4IJT3Qjs.logger.info("Skipped:"); skipped.forEach((entry) => { const details = entry.reason ? ` - ${entry.reason}` : ""; _chunkPT4IJT3Qjs.logger.info(` - ${entry.name}${details}`); }); } } var mountOptions = { commandOptions: { install: { name: "patch", aliases: ["install"], appendDefaultOptions: false, optionDefs: [ { flags: "--cwd <dir>", description: "Working directory", config: { default: resolvePatchDefaultCwd() } }, { flags: "--record-target", description: 'Write tailwindcss target metadata (node_modules/.cache/weapp-tailwindcss/tailwindcss-target.json). Pass "--record-target false" to skip.', config: { default: true } }, { flags: "--clear-cache", description: "Clear tailwindcss-patch cache before patch (opt-in)" }, { flags: "--workspace", description: "Scan pnpm workspace packages and patch each Tailwind CSS dependency" } ] }, status: { appendDefaultOptions: false, optionDefs: [ { flags: "--cwd <dir>", description: "Working directory", config: { default: resolvePatchDefaultCwd() } }, { flags: "--json", description: "Print a JSON report of patch status" } ] } }, commandHandlers: { install: withCommandErrorHandling(async (ctx) => { const shouldClearCache = toBoolean(ctx.args.clearCache, false); const shouldRecordTarget = toBoolean(ctx.args.recordTarget, true); const runWorkspace = toBoolean(ctx.args.workspace, false); if (runWorkspace) { await patchWorkspace({ cwd: ctx.cwd, clearCache: shouldClearCache, recordTarget: shouldRecordTarget }); return; } const patcher = await createPatcherWithDefaultExtendLengthUnits(ctx); if (shouldClearCache) { await _chunkA2OSQ5CVjs.clearTailwindcssPatcherCache.call(void 0, patcher, { removeDirectory: true }); } const recorder = _chunkA2OSQ5CVjs.createPatchTargetRecorder.call(void 0, ctx.cwd, patcher, { source: "cli", cwd: ctx.cwd, recordTarget: shouldRecordTarget, alwaysRecord: true }); if (_optionalChain([recorder, 'optionalAccess', _18 => _18.message])) { _chunkPT4IJT3Qjs.logger.info(recorder.message); } _chunkA2OSQ5CVjs.logTailwindcssTarget.call(void 0, "cli", patcher, ctx.cwd); await patcher.patch(); if (_optionalChain([recorder, 'optionalAccess', _19 => _19.onPatched])) { const recordPath = await recorder.onPatched(); if (recordPath) { _chunkPT4IJT3Qjs.logger.info(`\u8BB0\u5F55 weapp-tw patch \u76EE\u6807 -> ${formatOutputPath(recordPath, ctx.cwd)}`); } } _chunkPT4IJT3Qjs.logger.success("Tailwind CSS \u8FD0\u884C\u65F6\u8865\u4E01\u5DF2\u5B8C\u6210\u3002"); }), extract: withCommandErrorHandling(async (_ctx, next) => next()), tokens: withCommandErrorHandling(async (_ctx, next) => next()), init: withCommandErrorHandling(async (_ctx, next) => next()), status: withCommandErrorHandling(async (ctx) => { const patcher = await createPatcherWithDefaultExtendLengthUnits(ctx); const report = await patcher.getPatchStatus(); if (ctx.args.json) { _chunkPT4IJT3Qjs.logger.log(JSON.stringify(report, null, 2)); return report; } logPatchStatusReport(report); return report; }) } }; // src/cli/vscode-entry.ts var DEFAULT_VSCODE_ENTRY_OUTPUT = ".vscode/weapp-tailwindcss.intellisense.css"; var DEFAULT_VSCODE_SOURCES = [ 'not "./dist"', 'not "./unpackage"', "./src/**/*.{wxml,axml,swan,qml,ttml,ux,uts}", "./src/**/*.{js,jsx,ts,tsx}", "./src/**/*.{vue,svelte,html,md,mdx}" ]; var SINGLE_QUOTE = "'"; var DOUBLE_QUOTE = '"'; function toPosixPath(filepath) { return filepath.replace(/\\/g, "/"); } async function assertFileExists(filepath) { try { await _promises.access.call(void 0, filepath, _fs.constants.F_OK); } catch (error) { const err = error; if (_optionalChain([err, 'optionalAccess', _20 => _20.code]) === "ENOENT") { throw new Error(`CSS entry file not found: ${filepath}`); } throw err; } } async function assertCanWrite(filepath, force) { try { await _promises.access.call(void 0, filepath, _fs.constants.F_OK); if (!force) { throw new Error( `VS Code helper already exists at ${filepath}. Re-run with --force to overwrite it.` ); } } catch (error) { const err = error; if (_optionalChain([err, 'optionalAccess', _21 => _21.code]) === "ENOENT") { return; } throw err; } } function toCssLiteral(value) { const normalized = toPosixPath(value); return JSON.stringify(normalized); } function formatSource(pattern) { const trimmed = pattern.trim(); if (!trimmed) { return null; } if (trimmed.startsWith("@source ")) { return trimmed.endsWith(";") ? trimmed : `${trimmed};`; } let body = trimmed; let keyword = ""; if (body.startsWith("not ")) { keyword = "not "; body = body.slice(4).trim(); } else if (body.startsWith("!")) { keyword = "not "; body = body.slice(1).trim(); } if (!body) { throw new Error("Invalid @source pattern: empty body."); } if (!body.startsWith(SINGLE_QUOTE) && !body.startsWith(DOUBLE_QUOTE)) { body = toCssLiteral(body); } return `@source ${keyword}${body};`; } function resolveOutputPath(baseDir, output) { const target = _nullishCoalesce(output, () => ( DEFAULT_VSCODE_ENTRY_OUTPUT)); return _path2.default.isAbsolute(target) ? _path2.default.normalize(target) : _path2.default.resolve(baseDir, target); } function resolveCssEntry(baseDir, entry) { return _path2.default.isAbsolute(entry) ? _path2.default.normalize(entry) : _path2.default.resolve(baseDir, entry); } function toRelativeImport(fromFile, targetFile) { const fromDir = _path2.default.dirname(fromFile); let relative = _path2.default.relative(fromDir, targetFile); if (!relative) { relative = _path2.default.basename(targetFile); } if (!relative.startsWith(".")) { relative = `./${relative}`; } return toPosixPath(relative); } async function generateVscodeIntellisenseEntry(options) { const baseDir = options.baseDir; const cssEntryPath = resolveCssEntry(baseDir, options.cssEntry); await assertFileExists(cssEntryPath); const outputPath = resolveOutputPath(baseDir, options.output); await ensureDir(_path2.default.dirname(outputPath)); await assertCanWrite(outputPath, options.force); const sources = options.sources && options.sources.length > 0 ? options.sources : DEFAULT_VSCODE_SOURCES; const formattedSources = sources.map(formatSource).filter((statement) => Boolean(statement)); const cssImport = toRelativeImport(outputPath, cssEntryPath); const separator = formattedSources.length > 0 ? [""] : []; const content = [ "/*", " * Auto-generated by weapp-tailwindcss.", " * This file exists solely to activate Tailwind CSS IntelliSense in VS Code.", " * Do not import it in your actual mini-program bundles.", " */", "@import 'tailwindcss';", "", ...formattedSources, ...separator, `@import '${cssImport}';`, "" ].filter((line, idx, arr) => !(line === "" && arr[idx - 1] === "")).join("\n"); await _promises.writeFile.call(void 0, outputPath, `${content} `, "utf8"); return { outputPath, cssEntryPath }; } // src/cli.ts _process2.default.title = "node (weapp-tailwindcss)"; if (_semver2.default.lt(_process2.default.versions.node, _chunkA2OSQ5CVjs.WEAPP_TW_REQUIRED_NODE_VERSION)) { _chunkPT4IJT3Qjs.logger.warn( `You are using Node.js ${_process2.default.versions.node}. For weapp-tailwindcss, Node.js version >= v${_chunkA2OSQ5CVjs.WEAPP_TW_REQUIRED_NODE_VERSION} is required.` ); } var cli = _tailwindcsspatch.createTailwindcssPatchCli.call(void 0, { name: "weapp-tailwindcss", mountOptions }); cli.command("vscode-entry", "Generate a VS Code helper CSS for Tailwind IntelliSense").option("--cwd <dir>", "Working directory").option("--css <file>", "Path to the CSS file that imports weapp-tailwindcss (required)").option("--output <file>", `Helper output path. Defaults to ${DEFAULT_VSCODE_ENTRY_OUTPUT}`).option("--source <pattern>", "Additional @source glob (can be repeated)").option("--force", "Overwrite the helper file when it already exists").action( commandAction(async (options) => { const resolvedCwd = resolveCliCwd(options.cwd); const baseDir = _nullishCoalesce(resolvedCwd, () => ( _process2.default.cwd())); const cssEntry = readStringOption("css", options.css); if (!cssEntry) { throw new Error('Option "--css" is required.'); } const output = readStringOption("output", options.output); const sources = readStringArrayOption("source", options.source); const force = toBoolean(options.force, false); const result = await generateVscodeIntellisenseEntry({ baseDir, cssEntry, output, sources, force }); _chunkPT4IJT3Qjs.logger.success( `VS Code helper generated -> ${formatOutputPath(result.outputPath, resolvedCwd)}` ); }) ); cli.help(); cli.version(_nullishCoalesce(_process2.default.env.npm_package_version, () => ( "0.0.0"))); cli.parse();