jiek 0.4.7-alpha.14 → 0.4.7-alpha.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. package/bin/jiek.js +4 -7
  2. package/dist/{cli.d.cts → cli.d.mts} +0 -15
  3. package/dist/cli.d.mts.map +1 -0
  4. package/dist/cli.d.ts +0 -15
  5. package/dist/cli.d.ts.map +1 -0
  6. package/dist/cli.js +222 -4408
  7. package/dist/cli.js.map +1 -0
  8. package/dist/cli.min.js +1 -19
  9. package/dist/cli.min.js.map +1 -0
  10. package/dist/cli.min.mjs +1 -0
  11. package/dist/cli.min.mjs.map +1 -0
  12. package/dist/cli.mjs +803 -0
  13. package/dist/cli.mjs.map +1 -0
  14. package/dist/{index.d.cts → index.d.mts} +0 -15
  15. package/dist/index.d.mts.map +1 -0
  16. package/dist/index.d.ts +0 -15
  17. package/dist/index.d.ts.map +1 -0
  18. package/dist/index.js +3 -1
  19. package/dist/index.js.map +1 -0
  20. package/dist/index.min.js +1 -1
  21. package/dist/index.min.js.map +1 -0
  22. package/dist/index.min.mjs +1 -0
  23. package/dist/index.min.mjs.map +1 -0
  24. package/dist/index.mjs +3 -0
  25. package/dist/index.mjs.map +1 -0
  26. package/dist/rollup/index.d.mts.map +1 -0
  27. package/dist/rollup/index.d.ts.map +1 -0
  28. package/dist/rollup/index.js +69 -4189
  29. package/dist/rollup/index.js.map +1 -0
  30. package/dist/rollup/index.min.js +1 -19
  31. package/dist/rollup/index.min.js.map +1 -0
  32. package/dist/rollup/index.min.mjs +1 -0
  33. package/dist/rollup/index.min.mjs.map +1 -0
  34. package/dist/rollup/index.mjs +551 -0
  35. package/dist/rollup/index.mjs.map +1 -0
  36. package/package.json +19 -11
  37. package/src/commands/base.ts +2 -1
  38. package/src/commands/build.ts +2 -4
  39. package/src/commands/publish.ts +2 -16
  40. package/src/pkg.ts +1 -0
  41. package/src/rollup/index.ts +3 -5
  42. package/src/utils/filterSupport.ts +0 -2
  43. package/src/utils/getExports.ts +7 -11
  44. package/src/utils/tsRegister.ts +0 -4
  45. package/dist/cli.cjs +0 -5041
  46. package/dist/cli.min.cjs +0 -19
  47. package/dist/index.cjs +0 -5
  48. package/dist/index.min.cjs +0 -1
  49. package/dist/rollup/index.cjs +0 -4688
  50. package/dist/rollup/index.min.cjs +0 -19
  51. /package/dist/rollup/{index.d.cts → index.d.mts} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sources":["../src/utils/getRoot.ts","../src/utils/getWD.ts","../src/utils/filterSupport.ts","../src/pkg.ts","../src/commands/base.ts","../src/inner.ts","../src/utils/tsRegister.ts","../src/utils/loadConfig.ts","../src/commands/build.ts","../src/commands/init.ts","../src/merge-package-json.ts","../src/commands/publish.ts","../src/cli.ts"],"sourcesContent":["import path from 'node:path'\n\nimport { program } from 'commander'\n\nlet root: string\nexport function getRoot() {\n if (root) return root\n\n const rootOption = program.getOptionValue('root')\n root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : undefined\n return root\n}\n","import { getWorkspaceDir, isWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\n\nimport { type } from './filterSupport'\nimport { getRoot } from './getRoot'\n\nlet wd: string\nlet notWorkspace = false\n\nexport function getWD() {\n if (wd) return { wd, notWorkspace }\n\n const root = getRoot()\n if (root !== undefined) {\n const isWorkspace = isWorkspaceDir(root, type)\n notWorkspace = !isWorkspace\n wd = root\n return { wd, notWorkspace }\n }\n try {\n wd = getWorkspaceDir(type)\n } catch (e) {\n // @ts-ignore\n if ('message' in e && e.message === 'workspace root not found') {\n wd = root\n notWorkspace = true\n } else {\n throw e\n }\n }\n return { wd, notWorkspace }\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { filterPackagesFromDir } from '@pnpm/filter-workspace-packages'\nimport { program } from 'commander'\nimport { load } from 'js-yaml'\n\nimport { getRoot } from './getRoot'\nimport { getWD } from './getWD'\n\nexport let type = ''\n\ntry {\n require.resolve('@pnpm/filter-workspace-packages')\n type = 'pnpm'\n} catch { /* empty */ }\nif (type !== '') {\n program\n .option('-f, --filter <filter>', 'filter packages')\n}\n\ninterface ProjectsGraph {\n wd: string\n root: string\n value?: Record<string, {\n name?: string\n }>\n}\n\nexport async function getSelectedProjectsGraph(): Promise<ProjectsGraph> {\n let filter = program.getOptionValue('filter')\n const root = getRoot()\n const { wd, notWorkspace } = getWD()\n if (!notWorkspace && type === 'pnpm') {\n const pnpmWorkspaceFilePath = path.resolve(wd, 'pnpm-workspace.yaml')\n const pnpmWorkspaceFileContent = fs.readFileSync(pnpmWorkspaceFilePath, 'utf-8')\n const pnpmWorkspace = load(pnpmWorkspaceFileContent) as {\n packages: string[]\n }\n if (root === wd && !filter) {\n throw new Error('root path is workspace root, please provide a filter')\n // TODO inquirer prompt support user select packages\n }\n if (root !== wd && !filter) {\n const packageJSONIsExist = fs.existsSync(path.resolve(root, 'package.json'))\n if (!packageJSONIsExist) {\n throw new Error('root path is not workspace root, please provide a filter')\n }\n const packageJSON = JSON.parse(fs.readFileSync(path.resolve(root, 'package.json'), 'utf-8'))\n if (!packageJSON.name) {\n throw new Error('root path is not workspace root, please provide a filter')\n }\n filter = packageJSON.name\n }\n const { selectedProjectsGraph } = await filterPackagesFromDir(wd, [{\n filter: filter ?? '',\n followProdDepsOnly: true\n }], {\n prefix: root,\n workspaceDir: wd,\n patterns: pnpmWorkspace.packages\n })\n return {\n wd,\n root,\n value: Object.entries(selectedProjectsGraph)\n .reduce((acc, [key, value]) => {\n acc[key] = value.package.manifest\n return acc\n }, {} as NonNullable<ProjectsGraph['value']>)\n }\n }\n return {\n wd,\n root,\n value: {\n [wd]: JSON.parse(fs.readFileSync(path.resolve(wd, 'package.json'), 'utf-8'))\n }\n }\n}\n","export default require('../package.json')\n","import { program } from 'commander'\n\nimport pkg from '../pkg'\n\nprogram\n .version(pkg.version)\n .description(pkg.description)\n .option('--root <root>', 'root path')\n .option('-c, --config-path <configPath>', 'config path')\n","let resolve: () => void\n\nexport let actionFuture: Promise<void>\n\nexport function actionDone() {\n resolve()\n}\n\nexport function actionRestore() {\n actionFuture = new Promise<void>(r => resolve = r)\n}\n","function packageIsExist(name: string) {\n try {\n require.resolve(name)\n return true\n } catch (e) {\n return false\n }\n}\n\nexport let tsRegisterName: string | undefined\nconst registers = [\n process.env.JIEK_TS_REGISTER,\n 'esbuild-register',\n '@swc-node/register',\n 'ts-node/register'\n].filter(Boolean) as string[]\nfor (const register of registers) {\n if (packageIsExist(register)) {\n tsRegisterName = register\n break\n }\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { program } from 'commander'\nimport type { Config } from 'jiek'\nimport { load } from 'js-yaml'\n\nimport { getWD } from './getWD'\nimport { tsRegisterName } from './tsRegister'\n\nlet configName = 'jiek.config'\n\nfunction getConfigPath(root: string) {\n const isSupportTsLoader = !!tsRegisterName\n function configWithExtIsExist(ext: string) {\n const filenames = [\n path.resolve(process.cwd(), `${configName}.${ext}`),\n path.resolve(process.cwd(), `.${configName}.${ext}`),\n path.resolve(root, `${configName}.${ext}`),\n path.resolve(root, `.${configName}.${ext}`)\n ]\n for (const filename of filenames) {\n if (\n fs.existsSync(filename)\n && fs.lstatSync(filename)\n .isFile()\n ) {\n return filename\n }\n }\n return\n }\n configName = configWithExtIsExist('js') ?? configName\n configName = configWithExtIsExist('json') ?? configName\n configName = configWithExtIsExist('yaml') ?? configName\n if (isSupportTsLoader) {\n configName = configWithExtIsExist('ts') ?? configName\n }\n return path.resolve(root, configName)\n}\n\nexport function loadConfig(): Config {\n const { wd: root, notWorkspace } = getWD()\n if (notWorkspace) {\n throw new Error('not in workspace')\n }\n\n let configPath = program.getOptionValue('configPath')\n\n if (!configPath) {\n configPath = getConfigPath(root)\n } else {\n if (!fs.existsSync(configPath)) {\n throw new Error(`config file not found: ${configPath}`)\n }\n if (!path.isAbsolute(configPath)) {\n configPath = path.resolve(root, configPath)\n }\n }\n const ext = path.extname(configPath)\n\n let module: any\n switch (ext) {\n case '.js':\n module = require(configPath)\n break\n case '.json':\n return require(configPath)\n case '.yaml':\n return load(fs.readFileSync(configPath, 'utf-8')) as Config\n case '.ts':\n if (tsRegisterName) {\n require(tsRegisterName)\n module = require(configPath)\n break\n }\n throw new Error(\n 'ts config file is not supported without ts register, '\n + 'please install esbuild-register or set JIEK_TS_REGISTER env for custom ts register'\n )\n case '.config':\n module = {}\n break\n default:\n throw new Error(`unsupported config file type: ${ext}`)\n }\n if (!module) throw new Error('config file is empty')\n\n return module.default ?? module\n}\n","import '../rollup/base'\n\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport { MultiBar, Presets } from 'cli-progress'\nimport { program } from 'commander'\nimport { execaCommand } from 'execa'\n\nimport { actionDone, actionRestore } from '../inner'\nimport type { RollupProgressEvent } from '../rollup/base'\nimport { getSelectedProjectsGraph } from '../utils/filterSupport'\nimport { loadConfig } from '../utils/loadConfig'\nimport { tsRegisterName } from '../utils/tsRegister'\n\nconst FILE_TEMPLATE = (manifest: unknown) => (`\nconst manifest = ${JSON.stringify(manifest, null, 2)}\nmodule.exports = require('jiek/rollup').template(manifest)\n`.trimStart())\n\nprogram\n .command('build')\n .option('-s, --silent', \"Don't display logs.\")\n .option('-e, --entries <ENTRIES>', \"Specify the entries of the package.json's 'exports' field.(support glob)\")\n .action(async ({\n silent,\n entries\n }: {\n silent: boolean\n entries: string\n }) => {\n actionRestore()\n const { build } = loadConfig()\n silent = silent ?? build?.silent ?? false\n const {\n wd,\n value = {}\n } = await getSelectedProjectsGraph() ?? {}\n\n if (Object.keys(value).length === 0) {\n throw new Error('no package found')\n }\n const wdNodeModules = path.resolve(wd, 'node_modules')\n if (!fs.existsSync(wdNodeModules)) {\n fs.mkdirSync(wdNodeModules)\n }\n const jiekTempDir = (...paths: string[]) => path.resolve(wdNodeModules, '.jiek', ...paths)\n if (!fs.existsSync(jiekTempDir())) {\n fs.mkdirSync(jiekTempDir())\n }\n\n const rollupBinaryPath = require.resolve('rollup')\n .replace(/dist\\/rollup.js$/, 'dist/bin/rollup')\n const multiBars = new MultiBar({\n clearOnComplete: false,\n hideCursor: true,\n format: '- {bar} | {status} | {input} | {message}'\n }, Presets.shades_classic)\n let i = 0\n await Promise.all(\n Object.entries(value).map(async ([dir, manifest]) => {\n // TODO support auto build child packages in workspaces\n const escapeManifestName = manifest.name?.replace(/^@/g, '').replace(/\\//g, '+')\n const configFile = jiekTempDir(\n `${escapeManifestName ?? `anonymous-${i++}`}.rollup.config.js`\n )\n fs.writeFileSync(configFile, FILE_TEMPLATE(manifest))\n let prefix = ''\n if (tsRegisterName) {\n prefix = `node -r ${tsRegisterName} `\n }\n // TODO replace with `spawn` to support watch mode\n const command = `${prefix}${rollupBinaryPath} --silent -c ${configFile}`\n const child = execaCommand(command, {\n ipc: true,\n cwd: dir,\n env: {\n ...process.env,\n JIEK_ROOT: wd,\n JIEK_ENTRIES: entries\n }\n })\n const bars: Record<string, ReturnType<typeof multiBars.create>> = {}\n let inputMaxLen = 10\n child.on('message', (e: RollupProgressEvent) => {\n if (e.type === 'debug') console.log(...(Array.isArray(e.data) ? e.data : [e.data]))\n })\n !silent && child.on('message', (e: RollupProgressEvent) => {\n if (e.type === 'init') {\n const { leafMap, targetsLength } = e.data\n const leafs = Array\n .from(leafMap.entries())\n .flatMap(([input, pathAndCondiions]) =>\n pathAndCondiions.map(([path, ...conditions]) => ({\n input,\n path,\n conditions\n }))\n )\n console.log(`Package '${manifest.name}' has ${targetsLength} targets to build`)\n leafs.forEach(({ input }) => {\n inputMaxLen = Math.max(inputMaxLen, input.length)\n })\n leafs.forEach(({ input, path }) => {\n const key = `${input}:${path}`\n if (bars[key]) return\n bars[key] = multiBars.create(50, 0, {\n input: input.padEnd(inputMaxLen),\n status: 'waiting'.padEnd(10)\n }, {\n barsize: 20,\n linewrap: true\n })\n })\n }\n if (e.type === 'progress') {\n const {\n path,\n tags,\n input,\n event,\n message\n } = e.data\n const bar = bars[`${input}:${path}`]\n if (!bar) return\n bar.update(\n {\n start: 0,\n resolve: 20,\n end: 50\n }[event ?? 'start'] ?? 0,\n {\n input: input.padEnd(inputMaxLen),\n status: event?.padEnd(10),\n message: `${tags?.join(', ')}: ${message}`\n }\n )\n }\n })\n await new Promise<void>((resolve, reject) => {\n let errorStr = ''\n child.stderr?.on('data', (data) => {\n errorStr += data\n })\n child.once('exit', (code) =>\n code === 0\n ? resolve()\n : reject(new Error(`rollup build failed:\\n${errorStr}`)))\n })\n })\n ).finally(() => {\n multiBars.stop()\n })\n\n actionDone()\n })\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { program } from 'commander'\nimport detectIndent from 'detect-indent'\nimport inquirer from 'inquirer'\nimport type { Config, InitNamed } from 'jiek'\nimport { applyEdits, modify } from 'jsonc-parser'\nimport { isMatch } from 'micromatch'\n\nimport { getWD } from '../utils/getWD'\nimport { loadConfig } from '../utils/loadConfig'\n\ndeclare module 'jiek' {\n export type InitNamedFunction = (\n argument: string,\n paths: {\n full: string\n relative: string\n basename?: string\n }\n ) => [name?: string, path?: string]\n export type InitNamed =\n | InitNamedFunction\n | {\n [key: string]: string | InitNamedFunction\n }\n export interface Config {\n init?: {\n /**\n * the package.json template file path or file content\n *\n * if it can be parsed as json, it will be parsed\n * if it is a relative file path, it will be resolved to an absolute path based on the current working directory\n * if it is an absolute file path, it will be used directly\n * @default '.jiek.template.package.json'\n */\n template?: string\n /**\n * the readme content\n *\n * $name will be replaced with the package name\n * $license will be replaced with the license\n */\n readme?:\n | string\n | ((ctx: {\n dir: string\n packageJson: Record<string, any>\n }) => string)\n /**\n * the readme template file path\n * @default '.jiek.template.readme.md'\n */\n readmeTemplate?: string\n bug?: {\n /**\n * @default 'bug_report.yml'\n */\n template?: string\n /**\n * @default ['bug']\n */\n labels?:\n | string[]\n | ((ctx: {\n name: string\n dir: string\n }) => string[])\n }\n named?: InitNamed\n }\n }\n}\n\nconst PACKAGE_JSON_TEMPLATE = `{\n \"name\": \"\",\n \"version\": \"0.0.1\",\n \"description\": \"\",\n \"license\": \"\",\n \"author\": \"\",\n \"files\": [\"dist\"],\n \"exports\": {\n \".\": \"./src/index.ts\"\n },\n \"scripts\": {\n },\n \"homepage\": \"\",\n \"repository\": \"\",\n \"bugs\": \"\"\n}`.trimStart()\nconst README_TEMPLATE = `# $name\n\n## Installation\n\n\\`\\`\\`bash\nnpm install $name\n# or\npnpm install $name\n# or\nyarn add $name\n\\`\\`\\`\n\n## Usage\n\n\n## License\n\n$license\n`.trimStart()\n\nfunction getTemplateStr(wd: string, template: string | undefined) {\n let templateString = template ?? PACKAGE_JSON_TEMPLATE\n let isTemplateFile = false\n try {\n if (template) JSON.parse(template)\n } catch (e) {\n isTemplateFile = true\n }\n if (isTemplateFile) {\n const templatePath = path.resolve(wd, template!)\n templateString = fs.readFileSync(templatePath, 'utf-8')\n }\n return templateString\n}\nconst wdCache = new Map<string, Record<string, any>>()\nfunction getWDPackageJSONFiled(wd: string, field: string) {\n if (wdCache.has(wd)) {\n return wdCache.get(wd)![field]\n }\n const packageJSONPath = path.resolve(wd, 'package.json')\n const packageJSON = JSON.parse(fs.readFileSync(packageJSONPath, 'utf-8'))\n wdCache.set(wd, packageJSON)\n return packageJSON[field]\n}\nasync function getName(\n named: InitNamed | undefined,\n name: string,\n {\n wd,\n cwd,\n workspaceName\n }: {\n wd: string\n cwd: string\n workspaceName: string\n }\n): Promise<[name?: string, path?: string]> {\n const relativePath = cwd.replace(`${wd}/`, '')\n let basename = path.basename(cwd)\n\n if (typeof named === 'function') {\n return named(name, {\n full: wd,\n relative: cwd\n })\n }\n\n let isParentMatched = false\n let matchedKey: string | undefined\n let matchedRule: NonNullable<typeof named>[string] | undefined\n if (typeof named === 'object') {\n const isWD = cwd === wd\n if (isWD) {\n const { rule } = await inquirer.prompt<{ rule: string }>({\n type: 'list',\n name: 'rule',\n message: 'choose a rule',\n default: 'default',\n choices: ['default'].concat(Object.keys(named))\n })\n if (rule !== 'default') {\n matchedKey = rule\n matchedRule = named[rule]\n }\n } else {\n for (const [key, value] of Object.entries(named)) {\n if (isMatch(relativePath, key)) {\n matchedKey = key\n matchedRule = value\n break\n }\n if (isMatch(`${relativePath}/jiek_ignore_dont_use_same_file_name`, key)) {\n isParentMatched = true\n matchedKey = key\n matchedRule = value\n break\n }\n }\n }\n }\n if (!matchedRule) {\n matchedKey = 'packages/*'\n matchedRule = `@${workspaceName}/$basename`\n }\n if (!matchedRule) {\n throw new Error('no matched rule')\n }\n if (!name && isParentMatched) {\n basename = await inquirer.prompt<{ name: string }>({\n type: 'input',\n name: 'name',\n message: `the matched rule is \\`${String(matchedRule)}\\`, please input the basename\\n`\n }).then(({ name }) => name)\n }\n\n if (typeof matchedRule === 'function') {\n return matchedRule(name, {\n full: wd,\n relative: cwd,\n basename: basename\n })\n }\n if (typeof matchedRule === 'string') {\n const dirName = name ?? basename\n return [\n matchedRule.replace(/\\$basename/g, dirName),\n matchedKey?.replace(/\\/\\*$/g, `/${dirName}`)\n ]\n }\n throw new Error('no matched rule')\n}\n\nprogram\n .command('init [name]')\n .option('-t, --template <template>', 'the package.json template file path or file content')\n .action(async () => {\n const [, name] = program.args\n const cwd = process.cwd()\n const { init = {} }: Config = loadConfig() ?? {}\n const { wd } = getWD()\n const workspaceName = path.basename(wd)\n\n const {\n named,\n template,\n bug = {},\n readme: _readme = README_TEMPLATE,\n readmeTemplate\n } = init\n const resolvedBug = {\n template: 'bug_report.yml',\n labels: ['bug'],\n ...bug\n }\n let readme = _readme\n if (readmeTemplate) {\n const readmeTemplatePath = path.resolve(wd, readmeTemplate)\n readme = fs.readFileSync(readmeTemplatePath, 'utf-8')\n }\n\n const templateString = getTemplateStr(wd, template)\n // TODO detectIndent by editorconfig\n const { indent = ' ' } = detectIndent(templateString)\n const formattingOptions = {\n tabSize: indent.length,\n insertSpaces: true\n }\n const passFields = [\n 'license',\n 'author'\n ]\n let newJSONString = templateString\n for (const field of passFields) {\n newJSONString = applyEdits(\n newJSONString,\n modify(\n newJSONString,\n [field],\n getWDPackageJSONFiled(wd, field),\n { formattingOptions }\n )\n )\n }\n let [pkgName, pkgDir] = await getName(named, name, {\n wd,\n cwd,\n workspaceName\n })\n if (!pkgDir) {\n const { dir } = await inquirer.prompt<{ dir: string }>({\n type: 'input',\n name: 'dir',\n message: 'package directory',\n default: name\n })\n pkgDir = dir\n }\n if (!pkgName) {\n const { name: inputName } = await inquirer.prompt<{\n name: string\n }>({\n type: 'input',\n name: 'name',\n message: 'package name',\n default: name\n })\n pkgName = inputName\n }\n newJSONString = applyEdits(newJSONString, modify(newJSONString, ['name'], pkgName, { formattingOptions }))\n\n let pkgRepo = getWDPackageJSONFiled(wd, 'repository')\n if (typeof pkgRepo === 'string') {\n pkgRepo = {\n type: 'git',\n url: pkgRepo,\n directory: pkgDir\n }\n }\n newJSONString = applyEdits(\n newJSONString,\n modify(\n newJSONString,\n ['repository'],\n pkgRepo,\n { formattingOptions }\n )\n )\n const homepage = `${pkgRepo?.url}/blob/master/${pkgDir}/README.md`\n newJSONString = applyEdits(\n newJSONString,\n modify(\n newJSONString,\n ['homepage'],\n homepage,\n { formattingOptions }\n )\n )\n let labels = resolvedBug.labels\n if (typeof labels === 'function') {\n labels = labels({\n name: pkgName,\n dir: pkgDir\n })\n }\n labels.push(`scope:${pkgName}`)\n const bugs = `${pkgRepo?.url}/issues/new?template=${resolvedBug.template}&labels=${labels.join(',')}`\n newJSONString = applyEdits(\n newJSONString,\n modify(\n newJSONString,\n ['bugs'],\n bugs,\n { formattingOptions }\n )\n )\n\n function pkgDirTo(to: string) {\n if (!pkgDir) throw new Error('pkgDir is not defined')\n\n return path.resolve(pkgDir, to)\n }\n if (!fs.existsSync(pkgDir)) fs.mkdirSync(pkgDir)\n const pkgJSONFilePath = pkgDirTo('package.json')\n if (fs.existsSync(pkgJSONFilePath)) {\n throw new Error('package.json already exists')\n }\n fs.writeFileSync(pkgJSONFilePath, newJSONString)\n console.log(newJSONString, 'written to', pkgJSONFilePath)\n\n const license = getWDPackageJSONFiled(wd, 'license')\n const readmeFilePath = pkgDirTo('README.md')\n if (typeof readme === 'function') {\n readme = readme({\n dir: pkgDir,\n packageJson: JSON.parse(newJSONString)\n })\n }\n const readmeContent = readme\n .replace(/\\$name/g, pkgName)\n .replace(/\\$license/g, license)\n fs.writeFileSync(readmeFilePath, readmeContent)\n })\n","import path from 'node:path'\n\nimport { type Options, pkger } from '@jiek/pkger'\nimport { commondir } from '@jiek/utils/commondir'\nimport type { Manifest } from '@pnpm/workspace.pkgs-graph'\n\nexport function mergePackageJson(manifest: Manifest & {\n jiek?: Options\n exports?: unknown | unknown[]\n}, cwd: string, options: {\n excludeDistInExports?: boolean\n} = {}) {\n const {\n excludeDistInExports = false\n } = options\n const {\n jiek: { cwd: _, ...jiek } = {}\n } = manifest\n const { outdir = 'dist' } = jiek\n let { exports } = manifest\n let includeIndex = false\n if (typeof exports === 'string') {\n includeIndex = true\n exports = { '.': exports }\n }\n if (exports === undefined) {\n exports = { '.': './src/index.ts' }\n }\n if (typeof exports === 'object') {\n if (Array.isArray(exports) && exports.length > 0) {\n includeIndex = true\n } else {\n includeIndex = !!(<Record<string, unknown>>exports)['.']\n }\n }\n let inputs = Array.isArray(exports)\n ? exports as string[]\n : Object\n .entries(<Record<string, unknown>>exports)\n .reduce((acc, [key, value]) => {\n if (typeof value === 'string') return key === '.'\n ? [value, ...acc]\n : acc.concat(value)\n if (Array.isArray(value)) return acc.concat(value)\n\n throw new TypeError(`Unexpected value type for key \"${key}\" in exports, expected string, got ${typeof value}`)\n }, [] as string[])\n if (excludeDistInExports) {\n inputs = inputs.filter(input => !input.startsWith(`./${outdir}`) && !input.startsWith(outdir))\n }\n if (inputs.length === 0)\n throw new Error('No inputs found')\n\n const absoluteInputs = inputs.map(input => path.isAbsolute(input)\n ? input\n : path.resolve(cwd, input)\n )\n let cDir = path.dirname(absoluteInputs[0])\n if (absoluteInputs.length > 1) {\n cDir = commondir(absoluteInputs, cwd)\n }\n const resolvedInputs = absoluteInputs.map(input => {\n return path.relative(cDir, input)\n })\n return {\n ...manifest,\n ...pkger({\n cwd,\n noIndex: !includeIndex,\n source: path.relative(cwd, cDir),\n inputs: resolvedInputs,\n ...jiek\n })\n }\n}\n","import * as childProcess from 'node:child_process'\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport { bump, type BumperType } from '@jiek/utils/bumper'\nimport { program } from 'commander'\nimport detectIndent from 'detect-indent'\nimport { applyEdits, modify } from 'jsonc-parser'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\nimport { getSelectedProjectsGraph } from '../utils/filterSupport'\n\nprogram\n .command('publish')\n .aliases(['pub', 'p'])\n .option('-b, --bumper <bumper>', 'bump version', 'patch')\n .option('-p, --preview', 'preview publish')\n .action(async ({ preview, bumper, ...options }: {\n preview?: boolean\n bumper: BumperType\n }) => {\n actionRestore()\n\n const { value = {} } = await getSelectedProjectsGraph() ?? {}\n const selectedProjectsGraphEntries = Object.entries(value)\n if (selectedProjectsGraphEntries.length === 0) {\n throw new Error('no packages selected')\n }\n const mainfests = selectedProjectsGraphEntries\n .map(([dir, manifest]) => [\n dir, mergePackageJson(manifest, dir)\n ] as const)\n const passArgs = Object\n .entries(options)\n .reduce((acc, [key, value]) => {\n if (value) {\n acc.push(`--${key}`, value as string)\n }\n return acc\n }, [] as string[])\n for (const [dir, manifest] of mainfests) {\n const oldJSONString = fs.readFileSync(path.join(dir, 'package.json'), 'utf-8')\n const oldJSON = JSON.parse(oldJSONString) ?? '0.0.0'\n const newVersion = bump(oldJSON.version, bumper)\n // TODO detectIndent by editorconfig\n const { indent = ' ' } = detectIndent(oldJSONString)\n const formattingOptions = {\n tabSize: indent.length,\n insertSpaces: true\n }\n let newJSONString = oldJSONString\n newJSONString = applyEdits(newJSONString, modify(\n newJSONString, ['version'], newVersion, { formattingOptions }\n ))\n for (const [key, value] of Object.entries(manifest)) {\n if (JSON.stringify(value) === JSON.stringify(oldJSON[key])) continue\n\n if (key !== 'exports') {\n newJSONString = applyEdits(newJSONString, modify(\n newJSONString, ['publishConfig', key], value, { formattingOptions }\n ))\n } else {\n for (const [k, v] of Object.entries(value)) {\n newJSONString = applyEdits(newJSONString, modify(\n newJSONString, ['publishConfig', 'exports', k], v, { formattingOptions }\n ))\n }\n }\n }\n try {\n fs.renameSync(path.join(dir, 'package.json'), path.join(dir, 'package.json.bak'))\n fs.writeFileSync(path.join(dir, 'package.json'), newJSONString)\n console.log(newJSONString)\n if (preview) {\n console.warn('preview mode')\n continue\n }\n childProcess.execSync(['pnpm', 'publish', '--access', 'public', '--no-git-checks', ...passArgs].join(' '), {\n cwd: dir,\n stdio: 'inherit'\n })\n const modifyVersionPackageJSON = applyEdits(oldJSONString, modify(oldJSONString, ['version'], newVersion, {}))\n fs.writeFileSync(path.join(dir, 'package.json.bak'), modifyVersionPackageJSON)\n } finally {\n fs.unlinkSync(path.join(dir, 'package.json'))\n fs.renameSync(path.join(dir, 'package.json.bak'), path.join(dir, 'package.json'))\n }\n }\n actionDone()\n })\n","import './utils/filterSupport'\nimport './commands/base'\nimport './commands/build'\nimport './commands/init'\nimport './commands/publish'\n\nimport { program } from 'commander'\n\nprogram.parse(process.argv)\n"],"names":["program","isWorkspaceDir","getWorkspaceDir","load","filterPackagesFromDir","MultiBar","Presets","execaCommand","path","isMatch","name","applyEdits","modify","commondir","pkger","bumper","value","bump","childProcess"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAI,IAAA,CAAA;AACG,SAAS,OAAU,GAAA;AACxB,EAAI,IAAA,IAAA;AAAM,IAAO,OAAA,IAAA,CAAA;AAEjB,EAAM,MAAA,UAAA,GAAaA,iBAAQ,CAAA,cAAA,CAAe,MAAM,CAAA,CAAA;AAChD,EAAA,IAAA,GAAO,UACH,GAAA,IAAA,CAAK,UAAW,CAAA,UAAU,CACxB,GAAA,UAAA,GACA,IAAK,CAAA,OAAA,CAAQ,OAAQ,CAAA,GAAA,EAAO,EAAA,UAAU,CACxC,GAAA,KAAA,CAAA,CAAA;AACJ,EAAO,OAAA,IAAA,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E,IAAK,CAAA,GAAG,CAAG,EAAA;AAAA,QACzG,GAAK,EAAA,GAAA;AAAA,QACL,KAAO,EAAA,SAAA;AAAA,OACR,CAAA,CAAA;AACD,MAAM,MAAA,wBAAA,GAA2BP,sBAAW,CAAA,aAAA,EAAeC,kBAAO,CAAA,aAAA,EAAe,CAAC,SAAS,CAAG,EAAA,UAAA,EAAY,EAAE,CAAC,CAAA,CAAA;AAC7G,MAAA,EAAA,CAAG,cAAc,IAAK,CAAA,IAAA,CAAK,GAAK,EAAA,kBAAkB,GAAG,wBAAwB,CAAA,CAAA;AAAA,KAC7E,SAAA;AACA,MAAA,EAAA,CAAG,UAAW,CAAA,IAAA,CAAK,IAAK,CAAA,GAAA,EAAK,cAAc,CAAC,CAAA,CAAA;AAC5C,MAAG,EAAA,CAAA,UAAA,CAAW,IAAK,CAAA,IAAA,CAAK,GAAK,EAAA,kBAAkB,GAAG,IAAK,CAAA,IAAA,CAAK,GAAK,EAAA,cAAc,CAAC,CAAA,CAAA;AAAA,KAClF;AAAA,GACF;AACA,EAAW,UAAA,EAAA,CAAA;AACb,CAAC,CAAA;;AClFHZ,iBAAQ,CAAA,KAAA,CAAM,QAAQ,IAAI,CAAA;;"}
package/dist/cli.min.js CHANGED
@@ -1,19 +1 @@
1
- import e from"node:fs";import{createRequire as t}from"node:module";import n,{resolve as r,relative as o}from"node:path";import{filterPackagesFromDir as s}from"@pnpm/filter-workspace-packages";import{program as a}from"commander";import{load as i}from"js-yaml";import{isWorkspaceDir as u,getWorkspaceDir as p}from"@jiek/utils/getWorkspaceDir";import{MultiBar as l,Presets as c}from"cli-progress";import{execaCommand as f}from"execa";import g from"detect-indent";import d from"inquirer";import{applyEdits as h,modify as A}from"jsonc-parser";import R from"util";import y from"path";import*as m from"node:child_process";import{bump as _}from"@jiek/utils/bumper";import{resolveEntrypoints as E,filterLeafs as b,DEFAULT_SKIP_VALUES as S,entrypoints2Exports as C}from"@jiek/pkger/entrypoints";let v,$;function x(){if(v)return v;const e=a.getOptionValue("root");return v=e?n.isAbsolute(e)?e:n.resolve(process.cwd(),e):void 0,v}let w=!1;function H(){if($)return{wd:$,notWorkspace:w};const e=x();if(void 0!==e){const t=u(e,k);return w=!t,$=e,{wd:$,notWorkspace:w}}try{$=p(k)}catch(t){if(!("message"in t)||"workspace root not found"!==t.message)throw t;$=e,w=!0}return{wd:$,notWorkspace:w}}let k="";try{t(import.meta.url).resolve("@pnpm/filter-workspace-packages"),k="pnpm"}catch{}async function O(){let t=a.getOptionValue("filter");const r=x(),{wd:o,notWorkspace:u}=H();if(!u&&"pnpm"===k){const a=n.resolve(o,"pnpm-workspace.yaml"),u=e.readFileSync(a,"utf-8"),p=i(u);if(r===o&&!t)throw new Error("root path is workspace root, please provide a filter");if(r!==o&&!t){if(!e.existsSync(n.resolve(r,"package.json")))throw new Error("root path is not workspace root, please provide a filter");const o=JSON.parse(e.readFileSync(n.resolve(r,"package.json"),"utf-8"));if(!o.name)throw new Error("root path is not workspace root, please provide a filter");t=o.name}const{selectedProjectsGraph:l}=await s(o,[{filter:t??"",followProdDepsOnly:!0}],{prefix:r,workspaceDir:o,patterns:p.packages});return{wd:o,root:r,value:Object.entries(l).reduce(((e,[t,n])=>(e[t]=n.package.manifest,e)),{})}}return{wd:o,root:r,value:{[o]:JSON.parse(e.readFileSync(n.resolve(o,"package.json"),"utf-8"))}}}""!==k&&a.option("-f, --filter <filter>","filter packages");var T="0.4.7-alpha.13",L="YiJie's personal kits.";let N;function I(){N()}function M(){new Promise((e=>N=e))}a.version(T).description(L).option("--root <root>","root path").option("-c, --config-path <configPath>","config path");const j=t(import.meta.url);function B(e){try{return j.resolve(e),!0}catch(e){return!1}}let P;const G=[process.env.JIEK_TS_REGISTER,"esbuild-register","@swc-node/register","ts-node/register"].filter(Boolean);for(const e of G)if(B(e)){P=e;break}let D="jiek.config";function K(t){const{wd:r}=H();let o=a.getOptionValue("configPath");if(o){if(!e.existsSync(o))throw new Error(`config file not found: ${o}`);n.isAbsolute(o)||(o=n.resolve(r,o))}else o=function(t,r){const o=!!P;function s(o){const s=[n.resolve(process.cwd(),`${D}.${o}`),n.resolve(process.cwd(),`.${D}.${o}`),n.resolve(t,`${D}.${o}`),n.resolve(t,`.${D}.${o}`)];r&&s.unshift(n.resolve(r,`${D}.${o}`),n.resolve(r,`.${D}.${o}`));for(const t of s)if(e.existsSync(t)&&e.lstatSync(t).isFile())return t}return D=s("js")??D,D=s("json")??D,D=s("yaml")??D,o&&(D=s("ts")??D),n.resolve(t,D)}(r,t);const s=n.extname(o);let u;switch(s){case".js":u=require(o);break;case".json":return require(o);case".yaml":return i(e.readFileSync(o,"utf-8"));case".ts":if(P){require(P),u=require(o);break}throw new Error("ts config file is not supported without ts register, please install esbuild-register or set JIEK_TS_REGISTER env for custom ts register");case".config":u={};break;default:throw new Error(`unsupported config file type: ${s}`)}if(!u)throw new Error("config file is empty");return u.default??u}const U=t(import.meta.url);a.command("build").option("-s, --silent","Don't display logs.").option("-e, --entries <ENTRIES>","Specify the entries of the package.json's 'exports' field.(support glob)").action((async({silent:t,entries:r})=>{M();const{build:o}=K();t=t??o?.silent??!1;const{wd:s,value:a={}}=await O()??{};if(0===Object.keys(a).length)throw new Error("no package found");const i=n.resolve(s,"node_modules");e.existsSync(i)||e.mkdirSync(i);const u=(...e)=>n.resolve(i,".jiek",...e);e.existsSync(u())||e.mkdirSync(u());const p=U.resolve("rollup").replace(/dist\/rollup.js$/,"dist/bin/rollup"),g=new l({clearOnComplete:!1,hideCursor:!0,format:"- {bar} | {status} | {input} | {message}"},c.shades_classic);let d=0;await Promise.all(Object.entries(a).map((async([n,o])=>{const a=o.name?.replace(/^@/g,"").replace(/\//g,"+"),i=u(`${a??"anonymous-"+d++}.rollup.config.js`);e.writeFileSync(i,(e=>`\nmodule.exports = require('jiek/rollup').template(${JSON.stringify(e,null,2)})\n`.trimStart())(o));let l="";P&&(l=`node -r ${P} `);const c=f(`${l}${p} --silent -c ${i}`,{ipc:!0,cwd:n,env:{...process.env,JIEK_ROOT:s,JIEK_ENTRIES:r}}),h={};let A=10;c.on("message",(e=>{"debug"===e.type&&console.log(...Array.isArray(e.data)?e.data:[e.data])})),!t&&c.on("message",(e=>{if("init"===e.type){const{leafMap:t,targetsLength:n}=e.data,r=Array.from(t.entries()).flatMap((([e,t])=>t.map((([t,...n])=>({input:e,path:t,conditions:n})))));console.log(`Package '${o.name}' has ${n} targets to build`),r.forEach((({input:e})=>{A=Math.max(A,e.length)})),r.forEach((({input:e,path:t})=>{const n=`${e}:${t}`;h[n]||(h[n]=g.create(50,0,{input:e.padEnd(A),status:"waiting".padEnd(10)},{barsize:20,linewrap:!0}))}))}if("progress"===e.type){const{path:t,tags:n,input:r,event:o,message:s}=e.data,a=h[`${r}:${t}`];if(!a)return;a.update({start:0,resolve:20,end:50}[o??"start"]??0,{input:r.padEnd(A),status:o?.padEnd(10),message:`${n?.join(", ")}: ${s}`})}})),await new Promise(((e,t)=>{let n="";c.stderr?.on("data",(e=>{n+=e})),c.once("exit",(r=>0===r?e():t(new Error(`rollup build failed:\n${n}`))))}))}))).finally((()=>{g.stop()})),I()}));var F,Q,W,X,q,Z,J,Y,z,V,ee,te,ne,re,oe,se,ae,ie,ue,pe={};function le(){return F||(F=1,function(e){e.isInteger=e=>"number"==typeof e?Number.isInteger(e):"string"==typeof e&&""!==e.trim()&&Number.isInteger(Number(e)),e.find=(e,t)=>e.nodes.find((e=>e.type===t)),e.exceedsLimit=(t,n,r=1,o)=>!1!==o&&(!(!e.isInteger(t)||!e.isInteger(n))&&(Number(n)-Number(t))/Number(r)>=o),e.escapeNode=(e,t=0,n)=>{let r=e.nodes[t];r&&(n&&r.type===n||"open"===r.type||"close"===r.type)&&!0!==r.escaped&&(r.value="\\"+r.value,r.escaped=!0)},e.encloseBrace=e=>"brace"===e.type&&(!(e.commas>>0+e.ranges)&&(e.invalid=!0,!0)),e.isInvalidBrace=e=>"brace"===e.type&&(!(!0!==e.invalid&&!e.dollar)||(e.commas>>0+e.ranges?(!0!==e.open||!0!==e.close)&&(e.invalid=!0,!0):(e.invalid=!0,!0))),e.isOpenOrClose=e=>"open"===e.type||"close"===e.type||(!0===e.open||!0===e.close),e.reduce=e=>e.reduce(((e,t)=>("text"===t.type&&e.push(t.value),"range"===t.type&&(t.type="text"),e)),[]),e.flatten=(...e)=>{const t=[],n=e=>{for(let r=0;r<e.length;r++){let o=e[r];Array.isArray(o)?n(o):void 0!==o&&t.push(o)}return t};return n(e),t}}(pe)),pe}function ce(){if(W)return Q;W=1;const e=le();return Q=(t,n={})=>{let r=(t,o={})=>{let s=n.escapeInvalid&&e.isInvalidBrace(o),a=!0===t.invalid&&!0===n.escapeInvalid,i="";if(t.value)return(s||a)&&e.isOpenOrClose(t)?"\\"+t.value:t.value;if(t.value)return t.value;if(t.nodes)for(let e of t.nodes)i+=r(e);return i};return r(t)}}
2
- /*!
3
- * is-number <https://github.com/jonschlinkert/is-number>
4
- *
5
- * Copyright (c) 2014-present, Jon Schlinkert.
6
- * Released under the MIT License.
7
- */function fe(){return q?X:(q=1,X=function(e){return"number"==typeof e?e-e==0:"string"==typeof e&&""!==e.trim()&&(Number.isFinite?Number.isFinite(+e):isFinite(+e))})}
8
- /*!
9
- * to-regex-range <https://github.com/micromatch/to-regex-range>
10
- *
11
- * Copyright (c) 2015-present, Jon Schlinkert.
12
- * Released under the MIT License.
13
- */function ge(){if(J)return Z;J=1;const e=fe(),t=(n,s,a)=>{if(!1===e(n))throw new TypeError("toRegexRange: expected the first argument to be a number");if(void 0===s||n===s)return String(n);if(!1===e(s))throw new TypeError("toRegexRange: expected the second argument to be a number.");let i={relaxZeros:!0,...a};"boolean"==typeof i.strictZeros&&(i.relaxZeros=!1===i.strictZeros);let u=n+":"+s+"="+String(i.relaxZeros)+String(i.shorthand)+String(i.capture)+String(i.wrap);if(t.cache.hasOwnProperty(u))return t.cache[u].result;let p=Math.min(n,s),l=Math.max(n,s);if(1===Math.abs(p-l)){let e=n+"|"+s;return i.capture?`(${e})`:!1===i.wrap?e:`(?:${e})`}let f=c(n)||c(s),g={min:n,max:s,a:p,b:l},d=[],h=[];if(f&&(g.isPadded=f,g.maxLen=String(g.max).length),p<0){h=r(l<0?Math.abs(l):1,Math.abs(p),g,i),p=g.a=0}return l>=0&&(d=r(p,l,g,i)),g.negatives=h,g.positives=d,g.result=function(e,t,n){let r=o(e,t,"-",!1)||[],s=o(t,e,"",!1)||[],a=o(e,t,"-?",!0)||[];return r.concat(a).concat(s).join("|")}(h,d),!0===i.capture?g.result=`(${g.result})`:!1!==i.wrap&&d.length+h.length>1&&(g.result=`(?:${g.result})`),t.cache[u]=g,g.result};function n(e,t,n){if(e===t)return{pattern:e,count:[],digits:0};let r=function(e,t){let n=[];for(let r=0;r<e.length;r++)n.push([e[r],t[r]]);return n}(e,t),o=r.length,s="",a=0;for(let e=0;e<o;e++){let[t,n]=r[e];t===n?s+=t:"0"!==t||"9"!==n?s+=l(t,n):a++}return a&&(s+=!0===n.shorthand?"\\d":"[0-9]"),{pattern:s,count:[a],digits:o}}function r(e,t,r,o){let a,l=function(e,t){let n=1,r=1,o=i(e,n),a=new Set([t]);for(;e<=o&&o<=t;)a.add(o),n+=1,o=i(e,n);for(o=u(t+1,r)-1;e<o&&o<=t;)a.add(o),r+=1,o=u(t+1,r)-1;return a=[...a],a.sort(s),a}(e,t),c=[],g=e;for(let e=0;e<l.length;e++){let t=l[e],s=n(String(g),String(t),o),i="";r.isPadded||!a||a.pattern!==s.pattern?(r.isPadded&&(i=f(t,r,o)),s.string=i+s.pattern+p(s.count),c.push(s),g=t+1,a=s):(a.count.length>1&&a.count.pop(),a.count.push(s.count[0]),a.string=a.pattern+p(a.count),g=t+1)}return c}function o(e,t,n,r,o){let s=[];for(let o of e){let{string:e}=o;r||a(t,"string",e)||s.push(n+e),r&&a(t,"string",e)&&s.push(n+e)}return s}function s(e,t){return e>t?1:t>e?-1:0}function a(e,t,n){return e.some((e=>e[t]===n))}function i(e,t){return Number(String(e).slice(0,-t)+"9".repeat(t))}function u(e,t){return e-e%Math.pow(10,t)}function p(e){let[t=0,n=""]=e;return n||t>1?`{${t+(n?","+n:"")}}`:""}function l(e,t,n){return`[${e}${t-e==1?"":"-"}${t}]`}function c(e){return/^-?(0+)\d/.test(e)}function f(e,t,n){if(!t.isPadded)return e;let r=Math.abs(t.maxLen-String(e).length),o=!1!==n.relaxZeros;switch(r){case 0:return"";case 1:return o?"0?":"0";case 2:return o?"0{0,2}":"00";default:return o?`0{0,${r}}`:`0{${r}}`}}return t.cache={},t.clearCache=()=>t.cache={},Z=t}
14
- /*!
15
- * fill-range <https://github.com/jonschlinkert/fill-range>
16
- *
17
- * Copyright (c) 2014-present, Jon Schlinkert.
18
- * Licensed under the MIT License.
19
- */function de(){if(z)return Y;z=1;const e=R,t=ge(),n=e=>null!==e&&"object"==typeof e&&!Array.isArray(e),r=e=>"number"==typeof e||"string"==typeof e&&""!==e,o=e=>Number.isInteger(+e),s=e=>{let t=`${e}`,n=-1;if("-"===t[0]&&(t=t.slice(1)),"0"===t)return!1;for(;"0"===t[++n];);return n>0},a=(e,t,n)=>{if(t>0){let n="-"===e[0]?"-":"";n&&(e=e.slice(1)),e=n+e.padStart(n?t-1:t,"0")}return!1===n?String(e):e},i=(e,t)=>{let n="-"===e[0]?"-":"";for(n&&(e=e.slice(1),t--);e.length<t;)e="0"+e;return n?"-"+e:e},u=(e,n,r,o)=>{if(r)return t(e,n,{wrap:!1,...o});let s=String.fromCharCode(e);return e===n?s:`[${s}-${String.fromCharCode(n)}]`},p=(e,n,r)=>{if(Array.isArray(e)){let t=!0===r.wrap,n=r.capture?"":"?:";return t?`(${n}${e.join("|")})`:e.join("|")}return t(e,n,r)},l=(...t)=>new RangeError("Invalid range arguments: "+e.inspect(...t)),c=(e,t,n)=>{if(!0===n.strictRanges)throw l([e,t]);return[]},f=(e,t,n=1,r={})=>{let o=Number(e),c=Number(t);if(!Number.isInteger(o)||!Number.isInteger(c)){if(!0===r.strictRanges)throw l([e,t]);return[]}0===o&&(o=0),0===c&&(c=0);let f=o>c,g=String(e),d=String(t),h=String(n);n=Math.max(Math.abs(n),1);let A=s(g)||s(d)||s(h),R=A?Math.max(g.length,d.length,h.length):0,y=!1===A&&!1===((e,t,n)=>"string"==typeof e||"string"==typeof t||!0===n.stringify)(e,t,r),m=r.transform||(e=>t=>!0===e?Number(t):String(t))(y);if(r.toRegex&&1===n)return u(i(e,R),i(t,R),!0,r);let _={negatives:[],positives:[]},E=[],b=0;for(;f?o>=c:o<=c;)!0===r.toRegex&&n>1?_[(S=o)<0?"negatives":"positives"].push(Math.abs(S)):E.push(a(m(o,b),R,y)),o=f?o-n:o+n,b++;var S;return!0===r.toRegex?n>1?((e,t)=>{e.negatives.sort(((e,t)=>e<t?-1:e>t?1:0)),e.positives.sort(((e,t)=>e<t?-1:e>t?1:0));let n,r=t.capture?"":"?:",o="",s="";return e.positives.length&&(o=e.positives.join("|")),e.negatives.length&&(s=`-(${r}${e.negatives.join("|")})`),n=o&&s?`${o}|${s}`:o||s,t.wrap?`(${r}${n})`:n})(_,r):p(E,null,{wrap:!1,...r}):E},g=(e,t,s,a={})=>{if(null==t&&r(e))return[e];if(!r(e)||!r(t))return c(e,t,a);if("function"==typeof s)return g(e,t,1,{transform:s});if(n(s))return g(e,t,0,s);let i={...a};return!0===i.capture&&(i.wrap=!0),s=s||i.step||1,o(s)?o(e)&&o(t)?f(e,t,s,i):((e,t,n=1,r={})=>{if(!o(e)&&e.length>1||!o(t)&&t.length>1)return c(e,t,r);let s=r.transform||(e=>String.fromCharCode(e)),a=`${e}`.charCodeAt(0),i=`${t}`.charCodeAt(0),l=a>i,f=Math.min(a,i),g=Math.max(a,i);if(r.toRegex&&1===n)return u(f,g,!1,r);let d=[],h=0;for(;l?a>=i:a<=i;)d.push(s(a,h)),a=l?a-n:a+n,h++;return!0===r.toRegex?p(d,null,{wrap:!1,options:r}):d})(e,t,Math.max(Math.abs(s),1),i):null==s||n(s)?g(e,t,1,s):((e,t)=>{if(!0===t.strictRanges)throw new TypeError(`Expected step "${e}" to be a number`);return[]})(s,i)};return Y=g}function he(){if(ae)return se;ae=1;const e=ce(),{MAX_LENGTH:t,CHAR_BACKSLASH:n,CHAR_BACKTICK:r,CHAR_COMMA:o,CHAR_DOT:s,CHAR_LEFT_PARENTHESES:a,CHAR_RIGHT_PARENTHESES:i,CHAR_LEFT_CURLY_BRACE:u,CHAR_RIGHT_CURLY_BRACE:p,CHAR_LEFT_SQUARE_BRACKET:l,CHAR_RIGHT_SQUARE_BRACKET:c,CHAR_DOUBLE_QUOTE:f,CHAR_SINGLE_QUOTE:g,CHAR_NO_BREAK_SPACE:d,CHAR_ZERO_WIDTH_NOBREAK_SPACE:h}=oe?re:(oe=1,re={MAX_LENGTH:65536,CHAR_0:"0",CHAR_9:"9",CHAR_UPPERCASE_A:"A",CHAR_LOWERCASE_A:"a",CHAR_UPPERCASE_Z:"Z",CHAR_LOWERCASE_Z:"z",CHAR_LEFT_PARENTHESES:"(",CHAR_RIGHT_PARENTHESES:")",CHAR_ASTERISK:"*",CHAR_AMPERSAND:"&",CHAR_AT:"@",CHAR_BACKSLASH:"\\",CHAR_BACKTICK:"`",CHAR_CARRIAGE_RETURN:"\r",CHAR_CIRCUMFLEX_ACCENT:"^",CHAR_COLON:":",CHAR_COMMA:",",CHAR_DOLLAR:"$",CHAR_DOT:".",CHAR_DOUBLE_QUOTE:'"',CHAR_EQUAL:"=",CHAR_EXCLAMATION_MARK:"!",CHAR_FORM_FEED:"\f",CHAR_FORWARD_SLASH:"/",CHAR_HASH:"#",CHAR_HYPHEN_MINUS:"-",CHAR_LEFT_ANGLE_BRACKET:"<",CHAR_LEFT_CURLY_BRACE:"{",CHAR_LEFT_SQUARE_BRACKET:"[",CHAR_LINE_FEED:"\n",CHAR_NO_BREAK_SPACE:" ",CHAR_PERCENT:"%",CHAR_PLUS:"+",CHAR_QUESTION_MARK:"?",CHAR_RIGHT_ANGLE_BRACKET:">",CHAR_RIGHT_CURLY_BRACE:"}",CHAR_RIGHT_SQUARE_BRACKET:"]",CHAR_SEMICOLON:";",CHAR_SINGLE_QUOTE:"'",CHAR_SPACE:" ",CHAR_TAB:"\t",CHAR_UNDERSCORE:"_",CHAR_VERTICAL_LINE:"|",CHAR_ZERO_WIDTH_NOBREAK_SPACE:"\ufeff"});return se=(A,R={})=>{if("string"!=typeof A)throw new TypeError("Expected a string");let y=R||{},m="number"==typeof y.maxLength?Math.min(t,y.maxLength):t;if(A.length>m)throw new SyntaxError(`Input length (${A.length}), exceeds max characters (${m})`);let _,E={type:"root",input:A,nodes:[]},b=[E],S=E,C=E,v=0,$=A.length,x=0,w=0;const H=()=>A[x++],k=e=>{if("text"===e.type&&"dot"===C.type&&(C.type="text"),!C||"text"!==C.type||"text"!==e.type)return S.nodes.push(e),e.parent=S,e.prev=C,C=e,e;C.value+=e.value};for(k({type:"bos"});x<$;)if(S=b[b.length-1],_=H(),_!==h&&_!==d)if(_!==n)if(_!==c)if(_!==l)if(_!==a)if(_!==i)if(_!==f&&_!==g&&_!==r)if(_!==u)if(_!==p)if(_===o&&w>0){if(S.ranges>0){S.ranges=0;let t=S.nodes.shift();S.nodes=[t,{type:"text",value:e(S)}]}k({type:"comma",value:_}),S.commas++}else if(_===s&&w>0&&0===S.commas){let e=S.nodes;if(0===w||0===e.length){k({type:"text",value:_});continue}if("dot"===C.type){if(S.range=[],C.value+=_,C.type="range",3!==S.nodes.length&&5!==S.nodes.length){S.invalid=!0,S.ranges=0,C.type="text";continue}S.ranges++,S.args=[];continue}if("range"===C.type){e.pop();let t=e[e.length-1];t.value+=C.value+_,C=t,S.ranges--;continue}k({type:"dot",value:_})}else k({type:"text",value:_});else{if("brace"!==S.type){k({type:"text",value:_});continue}let e="close";S=b.pop(),S.close=!0,k({type:e,value:_}),w--,S=b[b.length-1]}else{w++;let e=C.value&&"$"===C.value.slice(-1)||!0===S.dollar;S=k({type:"brace",open:!0,close:!1,dollar:e,depth:w,commas:0,ranges:0,nodes:[]}),b.push(S),k({type:"open",value:_})}else{let e,t=_;for(!0!==R.keepQuotes&&(_="");x<$&&(e=H());)if(e!==n){if(e===t){!0===R.keepQuotes&&(_+=e);break}_+=e}else _+=e+H();k({type:"text",value:_})}else{if("paren"!==S.type){k({type:"text",value:_});continue}S=b.pop(),k({type:"text",value:_}),S=b[b.length-1]}else S=k({type:"paren",nodes:[]}),b.push(S),k({type:"text",value:_});else{let e;for(v++;x<$&&(e=H());)if(_+=e,e!==l)if(e!==n){if(e===c&&(v--,0===v))break}else _+=H();else v++;k({type:"text",value:_})}else k({type:"text",value:"\\"+_});else k({type:"text",value:(R.keepEscaping?_:"")+H()});do{if(S=b.pop(),"root"!==S.type){S.nodes.forEach((e=>{e.nodes||("open"===e.type&&(e.isOpen=!0),"close"===e.type&&(e.isClose=!0),e.nodes||(e.type="text"),e.invalid=!0)}));let e=b[b.length-1],t=e.nodes.indexOf(S);e.nodes.splice(t,1,...S.nodes)}}while(b.length>0);return k({type:"eos"}),E},se}function Ae(){if(ue)return ie;ue=1;const e=ce(),t=function(){if(ee)return V;ee=1;const e=de(),t=le();return V=(n,r={})=>{let o=(n,s={})=>{let a=t.isInvalidBrace(s),i=!0===n.invalid&&!0===r.escapeInvalid,u=!0===a||!0===i,p=!0===r.escapeInvalid?"\\":"",l="";if(!0===n.isOpen)return p+n.value;if(!0===n.isClose)return p+n.value;if("open"===n.type)return u?p+n.value:"(";if("close"===n.type)return u?p+n.value:")";if("comma"===n.type)return"comma"===n.prev.type?"":u?n.value:"|";if(n.value)return n.value;if(n.nodes&&n.ranges>0){let o=t.reduce(n.nodes),s=e(...o,{...r,wrap:!1,toRegex:!0});if(0!==s.length)return o.length>1&&s.length>1?`(${s})`:s}if(n.nodes)for(let e of n.nodes)l+=o(e,n);return l};return o(n)}}(),n=function(){if(ne)return te;ne=1;const e=de(),t=ce(),n=le(),r=(e="",t="",o=!1)=>{let s=[];if(e=[].concat(e),!(t=[].concat(t)).length)return e;if(!e.length)return o?n.flatten(t).map((e=>`{${e}}`)):t;for(let n of e)if(Array.isArray(n))for(let e of n)s.push(r(e,t,o));else for(let e of t)!0===o&&"string"==typeof e&&(e=`{${e}}`),s.push(Array.isArray(e)?r(n,e,o):n+e);return n.flatten(s)};return te=(o,s={})=>{let a=void 0===s.rangeLimit?1e3:s.rangeLimit,i=(o,u={})=>{o.queue=[];let p=u,l=u.queue;for(;"brace"!==p.type&&"root"!==p.type&&p.parent;)p=p.parent,l=p.queue;if(o.invalid||o.dollar)return void l.push(r(l.pop(),t(o,s)));if("brace"===o.type&&!0!==o.invalid&&2===o.nodes.length)return void l.push(r(l.pop(),["{}"]));if(o.nodes&&o.ranges>0){let i=n.reduce(o.nodes);if(n.exceedsLimit(...i,s.step,a))throw new RangeError("expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.");let u=e(...i,s);return 0===u.length&&(u=t(o,s)),l.push(r(l.pop(),u)),void(o.nodes=[])}let c=n.encloseBrace(o),f=o.queue,g=o;for(;"brace"!==g.type&&"root"!==g.type&&g.parent;)g=g.parent,f=g.queue;for(let e=0;e<o.nodes.length;e++){let t=o.nodes[e];"comma"!==t.type||"brace"!==o.type?"close"!==t.type?t.value&&"open"!==t.type?f.push(r(f.pop(),t.value)):t.nodes&&i(t,o):l.push(r(l.pop(),f,c)):(1===e&&f.push(""),f.push(""))}return f};return n.flatten(i(o))}}(),r=he(),o=(e,t={})=>{let n=[];if(Array.isArray(e))for(let r of e){let e=o.create(r,t);Array.isArray(e)?n.push(...e):n.push(e)}else n=[].concat(o.create(e,t));return t&&!0===t.expand&&!0===t.nodupes&&(n=[...new Set(n)]),n};return o.parse=(e,t={})=>r(e,t),o.stringify=(t,n={})=>e("string"==typeof t?o.parse(t,n):t,n),o.compile=(e,n={})=>("string"==typeof e&&(e=o.parse(e,n)),t(e,n)),o.expand=(e,t={})=>{"string"==typeof e&&(e=o.parse(e,t));let r=n(e,t);return!0===t.noempty&&(r=r.filter(Boolean)),!0===t.nodupes&&(r=[...new Set(r)]),r},o.create=(e,t={})=>""===e||e.length<3?[e]:!0!==t.expand?o.compile(e,t):o.expand(e,t),ie=o}var Re,ye,me,_e,Ee,be,Se,Ce,ve,$e,xe,we,He,ke={};function Oe(){if(ye)return Re;ye=1;const e=y,t="\\\\/",n=`[^${t}]`,r="\\.",o="\\/",s="[^/]",a=`(?:${o}|$)`,i=`(?:^|${o})`,u=`${r}{1,2}${a}`,p={DOT_LITERAL:r,PLUS_LITERAL:"\\+",QMARK_LITERAL:"\\?",SLASH_LITERAL:o,ONE_CHAR:"(?=.)",QMARK:s,END_ANCHOR:a,DOTS_SLASH:u,NO_DOT:`(?!${r})`,NO_DOTS:`(?!${i}${u})`,NO_DOT_SLASH:`(?!${r}{0,1}${a})`,NO_DOTS_SLASH:`(?!${u})`,QMARK_NO_DOT:`[^.${o}]`,STAR:`${s}*?`,START_ANCHOR:i},l={...p,SLASH_LITERAL:`[${t}]`,QMARK:n,STAR:`${n}*?`,DOTS_SLASH:`${r}{1,2}(?:[${t}]|$)`,NO_DOT:`(?!${r})`,NO_DOTS:`(?!(?:^|[${t}])${r}{1,2}(?:[${t}]|$))`,NO_DOT_SLASH:`(?!${r}{0,1}(?:[${t}]|$))`,NO_DOTS_SLASH:`(?!${r}{1,2}(?:[${t}]|$))`,QMARK_NO_DOT:`[^.${t}]`,START_ANCHOR:`(?:^|[${t}])`,END_ANCHOR:`(?:[${t}]|$)`};return Re={MAX_LENGTH:65536,POSIX_REGEX_SOURCE:{alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"},REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,SEP:e.sep,extglobChars:e=>({"!":{type:"negate",open:"(?:(?!(?:",close:`))${e.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}),globChars:e=>!0===e?l:p}}function Te(){return me||(me=1,function(e){const t=y,n="win32"===process.platform,{REGEX_BACKSLASH:r,REGEX_REMOVE_BACKSLASH:o,REGEX_SPECIAL_CHARS:s,REGEX_SPECIAL_CHARS_GLOBAL:a}=Oe();e.isObject=e=>null!==e&&"object"==typeof e&&!Array.isArray(e),e.hasRegexChars=e=>s.test(e),e.isRegexChar=t=>1===t.length&&e.hasRegexChars(t),e.escapeRegex=e=>e.replace(a,"\\$1"),e.toPosixSlashes=e=>e.replace(r,"/"),e.removeBackslashes=e=>e.replace(o,(e=>"\\"===e?"":e)),e.supportsLookbehinds=()=>{const e=process.version.slice(1).split(".").map(Number);return 3===e.length&&e[0]>=9||8===e[0]&&e[1]>=10},e.isWindows=e=>e&&"boolean"==typeof e.windows?e.windows:!0===n||"\\"===t.sep,e.escapeLast=(t,n,r)=>{const o=t.lastIndexOf(n,r);return-1===o?t:"\\"===t[o-1]?e.escapeLast(t,n,o-1):`${t.slice(0,o)}\\${t.slice(o)}`},e.removePrefix=(e,t={})=>{let n=e;return n.startsWith("./")&&(n=n.slice(2),t.prefix="./"),n},e.wrapOutput=(e,t={},n={})=>{let r=`${n.contains?"":"^"}(?:${e})${n.contains?"":"$"}`;return!0===t.negated&&(r=`(?:^(?!${r}).*$)`),r}}(ke)),ke}function Le(){if(ve)return Ce;ve=1;const e=y,t=function(){if(Ee)return _e;Ee=1;const e=Te(),{CHAR_ASTERISK:t,CHAR_AT:n,CHAR_BACKWARD_SLASH:r,CHAR_COMMA:o,CHAR_DOT:s,CHAR_EXCLAMATION_MARK:a,CHAR_FORWARD_SLASH:i,CHAR_LEFT_CURLY_BRACE:u,CHAR_LEFT_PARENTHESES:p,CHAR_LEFT_SQUARE_BRACKET:l,CHAR_PLUS:c,CHAR_QUESTION_MARK:f,CHAR_RIGHT_CURLY_BRACE:g,CHAR_RIGHT_PARENTHESES:d,CHAR_RIGHT_SQUARE_BRACKET:h}=Oe(),A=e=>e===i||e===r,R=e=>{!0!==e.isPrefix&&(e.depth=e.isGlobstar?1/0:1)};return _e=(y,m)=>{const _=m||{},E=y.length-1,b=!0===_.parts||!0===_.scanToEnd,S=[],C=[],v=[];let $,x,w=y,H=-1,k=0,O=0,T=!1,L=!1,N=!1,I=!1,M=!1,j=!1,B=!1,P=!1,G=!1,D=!1,K=0,U={value:"",depth:0,isGlob:!1};const F=()=>H>=E,Q=()=>($=x,w.charCodeAt(++H));for(;H<E;){let e;if(x=Q(),x!==r){if(!0===j||x===u){for(K++;!0!==F()&&(x=Q());)if(x!==r)if(x!==u){if(!0!==j&&x===s&&(x=Q())===s){if(T=U.isBrace=!0,N=U.isGlob=!0,D=!0,!0===b)continue;break}if(!0!==j&&x===o){if(T=U.isBrace=!0,N=U.isGlob=!0,D=!0,!0===b)continue;break}if(x===g&&(K--,0===K)){j=!1,T=U.isBrace=!0,D=!0;break}}else K++;else B=U.backslashes=!0,Q();if(!0===b)continue;break}if(x!==i){if(!0!==_.noext&&!0==(x===c||x===n||x===t||x===f||x===a)&&w.charCodeAt(H+1)===p){if(N=U.isGlob=!0,I=U.isExtglob=!0,D=!0,x===a&&H===k&&(G=!0),!0===b){for(;!0!==F()&&(x=Q());)if(x!==r){if(x===d){N=U.isGlob=!0,D=!0;break}}else B=U.backslashes=!0,x=Q();continue}break}if(x===t){if($===t&&(M=U.isGlobstar=!0),N=U.isGlob=!0,D=!0,!0===b)continue;break}if(x===f){if(N=U.isGlob=!0,D=!0,!0===b)continue;break}if(x===l){for(;!0!==F()&&(e=Q());)if(e!==r){if(e===h){L=U.isBracket=!0,N=U.isGlob=!0,D=!0;break}}else B=U.backslashes=!0,Q();if(!0===b)continue;break}if(!0===_.nonegate||x!==a||H!==k){if(!0!==_.noparen&&x===p){if(N=U.isGlob=!0,!0===b){for(;!0!==F()&&(x=Q());)if(x!==p){if(x===d){D=!0;break}}else B=U.backslashes=!0,x=Q();continue}break}if(!0===N){if(D=!0,!0===b)continue;break}}else P=U.negated=!0,k++}else{if(S.push(H),C.push(U),U={value:"",depth:0,isGlob:!1},!0===D)continue;if($===s&&H===k+1){k+=2;continue}O=H+1}}else B=U.backslashes=!0,x=Q(),x===u&&(j=!0)}!0===_.noext&&(I=!1,N=!1);let W=w,X="",q="";k>0&&(X=w.slice(0,k),w=w.slice(k),O-=k),W&&!0===N&&O>0?(W=w.slice(0,O),q=w.slice(O)):!0===N?(W="",q=w):W=w,W&&""!==W&&"/"!==W&&W!==w&&A(W.charCodeAt(W.length-1))&&(W=W.slice(0,-1)),!0===_.unescape&&(q&&(q=e.removeBackslashes(q)),W&&!0===B&&(W=e.removeBackslashes(W)));const Z={prefix:X,input:y,start:k,base:W,glob:q,isBrace:T,isBracket:L,isGlob:N,isExtglob:I,isGlobstar:M,negated:P,negatedExtglob:G};if(!0===_.tokens&&(Z.maxDepth=0,A(x)||C.push(U),Z.tokens=C),!0===_.parts||!0===_.tokens){let e;for(let t=0;t<S.length;t++){const n=e?e+1:k,r=S[t],o=y.slice(n,r);_.tokens&&(0===t&&0!==k?(C[t].isPrefix=!0,C[t].value=X):C[t].value=o,R(C[t]),Z.maxDepth+=C[t].depth),0===t&&""===o||v.push(o),e=r}if(e&&e+1<y.length){const t=y.slice(e+1);v.push(t),_.tokens&&(C[C.length-1].value=t,R(C[C.length-1]),Z.maxDepth+=C[C.length-1].depth)}Z.slashes=S,Z.parts=v}return Z}}(),n=function(){if(Se)return be;Se=1;const e=Oe(),t=Te(),{MAX_LENGTH:n,POSIX_REGEX_SOURCE:r,REGEX_NON_SPECIAL_CHARS:o,REGEX_SPECIAL_CHARS_BACKREF:s,REPLACEMENTS:a}=e,i=(e,n)=>{if("function"==typeof n.expandRange)return n.expandRange(...e,n);e.sort();const r=`[${e.join("-")}]`;try{new RegExp(r)}catch(n){return e.map((e=>t.escapeRegex(e))).join("..")}return r},u=(e,t)=>`Missing ${e}: "${t}" - use "\\\\${t}" to match literal characters`,p=(l,c)=>{if("string"!=typeof l)throw new TypeError("Expected a string");l=a[l]||l;const f={...c},g="number"==typeof f.maxLength?Math.min(n,f.maxLength):n;let d=l.length;if(d>g)throw new SyntaxError(`Input length: ${d}, exceeds maximum allowed length: ${g}`);const h={type:"bos",value:"",output:f.prepend||""},A=[h],R=f.capture?"":"?:",y=t.isWindows(c),m=e.globChars(y),_=e.extglobChars(m),{DOT_LITERAL:E,PLUS_LITERAL:b,SLASH_LITERAL:S,ONE_CHAR:C,DOTS_SLASH:v,NO_DOT:$,NO_DOT_SLASH:x,NO_DOTS_SLASH:w,QMARK:H,QMARK_NO_DOT:k,STAR:O,START_ANCHOR:T}=m,L=e=>`(${R}(?:(?!${T}${e.dot?v:E}).)*?)`,N=f.dot?"":$,I=f.dot?H:k;let M=!0===f.bash?L(f):O;f.capture&&(M=`(${M})`),"boolean"==typeof f.noext&&(f.noextglob=f.noext);const j={input:l,index:-1,start:0,dot:!0===f.dot,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:A};l=t.removePrefix(l,j),d=l.length;const B=[],P=[],G=[];let D,K=h;const U=()=>j.index===d-1,F=j.peek=(e=1)=>l[j.index+e],Q=j.advance=()=>l[++j.index]||"",W=()=>l.slice(j.index+1),X=(e="",t=0)=>{j.consumed+=e,j.index+=t},q=e=>{j.output+=null!=e.output?e.output:e.value,X(e.value)},Z=()=>{let e=1;for(;"!"===F()&&("("!==F(2)||"?"===F(3));)Q(),j.start++,e++;return e%2!=0&&(j.negated=!0,j.start++,!0)},J=e=>{j[e]++,G.push(e)},Y=e=>{j[e]--,G.pop()},z=e=>{if("globstar"===K.type){const t=j.braces>0&&("comma"===e.type||"brace"===e.type),n=!0===e.extglob||B.length&&("pipe"===e.type||"paren"===e.type);"slash"===e.type||"paren"===e.type||t||n||(j.output=j.output.slice(0,-K.output.length),K.type="star",K.value="*",K.output=M,j.output+=K.output)}if(B.length&&"paren"!==e.type&&(B[B.length-1].inner+=e.value),(e.value||e.output)&&q(e),K&&"text"===K.type&&"text"===e.type)return K.value+=e.value,void(K.output=(K.output||"")+e.value);e.prev=K,A.push(e),K=e},V=(e,t)=>{const n={..._[t],conditions:1,inner:""};n.prev=K,n.parens=j.parens,n.output=j.output;const r=(f.capture?"(":"")+n.open;J("parens"),z({type:e,value:t,output:j.output?"":C}),z({type:"paren",extglob:!0,value:Q(),output:r}),B.push(n)},ee=e=>{let t,n=e.close+(f.capture?")":"");if("negate"===e.type){let r=M;if(e.inner&&e.inner.length>1&&e.inner.includes("/")&&(r=L(f)),(r!==M||U()||/^\)+$/.test(W()))&&(n=e.close=`)$))${r}`),e.inner.includes("*")&&(t=W())&&/^\.[^\\/.]+$/.test(t)){const o=p(t,{...c,fastpaths:!1}).output;n=e.close=`)${o})${r})`}"bos"===e.prev.type&&(j.negatedExtglob=!0)}z({type:"paren",extglob:!0,value:D,output:n}),Y("parens")};if(!1!==f.fastpaths&&!/(^[*!]|[/()[\]{}"])/.test(l)){let e=!1,n=l.replace(s,((t,n,r,o,s,a)=>"\\"===o?(e=!0,t):"?"===o?n?n+o+(s?H.repeat(s.length):""):0===a?I+(s?H.repeat(s.length):""):H.repeat(r.length):"."===o?E.repeat(r.length):"*"===o?n?n+o+(s?M:""):M:n?t:`\\${t}`));return!0===e&&(n=!0===f.unescape?n.replace(/\\/g,""):n.replace(/\\+/g,(e=>e.length%2==0?"\\\\":e?"\\":""))),n===l&&!0===f.contains?(j.output=l,j):(j.output=t.wrapOutput(n,j,c),j)}for(;!U();){if(D=Q(),"\0"===D)continue;if("\\"===D){const e=F();if("/"===e&&!0!==f.bash)continue;if("."===e||";"===e)continue;if(!e){D+="\\",z({type:"text",value:D});continue}const t=/^\\+/.exec(W());let n=0;if(t&&t[0].length>2&&(n=t[0].length,j.index+=n,n%2!=0&&(D+="\\")),!0===f.unescape?D=Q():D+=Q(),0===j.brackets){z({type:"text",value:D});continue}}if(j.brackets>0&&("]"!==D||"["===K.value||"[^"===K.value)){if(!1!==f.posix&&":"===D){const e=K.value.slice(1);if(e.includes("[")&&(K.posix=!0,e.includes(":"))){const e=K.value.lastIndexOf("["),t=K.value.slice(0,e),n=K.value.slice(e+2),o=r[n];if(o){K.value=t+o,j.backtrack=!0,Q(),h.output||1!==A.indexOf(K)||(h.output=C);continue}}}("["===D&&":"!==F()||"-"===D&&"]"===F())&&(D=`\\${D}`),"]"!==D||"["!==K.value&&"[^"!==K.value||(D=`\\${D}`),!0===f.posix&&"!"===D&&"["===K.value&&(D="^"),K.value+=D,q({value:D});continue}if(1===j.quotes&&'"'!==D){D=t.escapeRegex(D),K.value+=D,q({value:D});continue}if('"'===D){j.quotes=1===j.quotes?0:1,!0===f.keepQuotes&&z({type:"text",value:D});continue}if("("===D){J("parens"),z({type:"paren",value:D});continue}if(")"===D){if(0===j.parens&&!0===f.strictBrackets)throw new SyntaxError(u("opening","("));const e=B[B.length-1];if(e&&j.parens===e.parens+1){ee(B.pop());continue}z({type:"paren",value:D,output:j.parens?")":"\\)"}),Y("parens");continue}if("["===D){if(!0!==f.nobracket&&W().includes("]"))J("brackets");else{if(!0!==f.nobracket&&!0===f.strictBrackets)throw new SyntaxError(u("closing","]"));D=`\\${D}`}z({type:"bracket",value:D});continue}if("]"===D){if(!0===f.nobracket||K&&"bracket"===K.type&&1===K.value.length){z({type:"text",value:D,output:`\\${D}`});continue}if(0===j.brackets){if(!0===f.strictBrackets)throw new SyntaxError(u("opening","["));z({type:"text",value:D,output:`\\${D}`});continue}Y("brackets");const e=K.value.slice(1);if(!0===K.posix||"^"!==e[0]||e.includes("/")||(D=`/${D}`),K.value+=D,q({value:D}),!1===f.literalBrackets||t.hasRegexChars(e))continue;const n=t.escapeRegex(K.value);if(j.output=j.output.slice(0,-K.value.length),!0===f.literalBrackets){j.output+=n,K.value=n;continue}K.value=`(${R}${n}|${K.value})`,j.output+=K.value;continue}if("{"===D&&!0!==f.nobrace){J("braces");const e={type:"brace",value:D,output:"(",outputIndex:j.output.length,tokensIndex:j.tokens.length};P.push(e),z(e);continue}if("}"===D){const e=P[P.length-1];if(!0===f.nobrace||!e){z({type:"text",value:D,output:D});continue}let t=")";if(!0===e.dots){const e=A.slice(),n=[];for(let t=e.length-1;t>=0&&(A.pop(),"brace"!==e[t].type);t--)"dots"!==e[t].type&&n.unshift(e[t].value);t=i(n,f),j.backtrack=!0}if(!0!==e.comma&&!0!==e.dots){const n=j.output.slice(0,e.outputIndex),r=j.tokens.slice(e.tokensIndex);e.value=e.output="\\{",D=t="\\}",j.output=n;for(const e of r)j.output+=e.output||e.value}z({type:"brace",value:D,output:t}),Y("braces"),P.pop();continue}if("|"===D){B.length>0&&B[B.length-1].conditions++,z({type:"text",value:D});continue}if(","===D){let e=D;const t=P[P.length-1];t&&"braces"===G[G.length-1]&&(t.comma=!0,e="|"),z({type:"comma",value:D,output:e});continue}if("/"===D){if("dot"===K.type&&j.index===j.start+1){j.start=j.index+1,j.consumed="",j.output="",A.pop(),K=h;continue}z({type:"slash",value:D,output:S});continue}if("."===D){if(j.braces>0&&"dot"===K.type){"."===K.value&&(K.output=E);const e=P[P.length-1];K.type="dots",K.output+=D,K.value+=D,e.dots=!0;continue}if(j.braces+j.parens===0&&"bos"!==K.type&&"slash"!==K.type){z({type:"text",value:D,output:E});continue}z({type:"dot",value:D,output:E});continue}if("?"===D){if((!K||"("!==K.value)&&!0!==f.noextglob&&"("===F()&&"?"!==F(2)){V("qmark",D);continue}if(K&&"paren"===K.type){const e=F();let n=D;if("<"===e&&!t.supportsLookbehinds())throw new Error("Node.js v10 or higher is required for regex lookbehinds");("("===K.value&&!/[!=<:]/.test(e)||"<"===e&&!/<([!=]|\w+>)/.test(W()))&&(n=`\\${D}`),z({type:"text",value:D,output:n});continue}if(!0!==f.dot&&("slash"===K.type||"bos"===K.type)){z({type:"qmark",value:D,output:k});continue}z({type:"qmark",value:D,output:H});continue}if("!"===D){if(!0!==f.noextglob&&"("===F()&&("?"!==F(2)||!/[!=<:]/.test(F(3)))){V("negate",D);continue}if(!0!==f.nonegate&&0===j.index){Z();continue}}if("+"===D){if(!0!==f.noextglob&&"("===F()&&"?"!==F(2)){V("plus",D);continue}if(K&&"("===K.value||!1===f.regex){z({type:"plus",value:D,output:b});continue}if(K&&("bracket"===K.type||"paren"===K.type||"brace"===K.type)||j.parens>0){z({type:"plus",value:D});continue}z({type:"plus",value:b});continue}if("@"===D){if(!0!==f.noextglob&&"("===F()&&"?"!==F(2)){z({type:"at",extglob:!0,value:D,output:""});continue}z({type:"text",value:D});continue}if("*"!==D){"$"!==D&&"^"!==D||(D=`\\${D}`);const e=o.exec(W());e&&(D+=e[0],j.index+=e[0].length),z({type:"text",value:D});continue}if(K&&("globstar"===K.type||!0===K.star)){K.type="star",K.star=!0,K.value+=D,K.output=M,j.backtrack=!0,j.globstar=!0,X(D);continue}let e=W();if(!0!==f.noextglob&&/^\([^?]/.test(e)){V("star",D);continue}if("star"===K.type){if(!0===f.noglobstar){X(D);continue}const t=K.prev,n=t.prev,r="slash"===t.type||"bos"===t.type,o=n&&("star"===n.type||"globstar"===n.type);if(!0===f.bash&&(!r||e[0]&&"/"!==e[0])){z({type:"star",value:D,output:""});continue}const s=j.braces>0&&("comma"===t.type||"brace"===t.type),a=B.length&&("pipe"===t.type||"paren"===t.type);if(!r&&"paren"!==t.type&&!s&&!a){z({type:"star",value:D,output:""});continue}for(;"/**"===e.slice(0,3);){const t=l[j.index+4];if(t&&"/"!==t)break;e=e.slice(3),X("/**",3)}if("bos"===t.type&&U()){K.type="globstar",K.value+=D,K.output=L(f),j.output=K.output,j.globstar=!0,X(D);continue}if("slash"===t.type&&"bos"!==t.prev.type&&!o&&U()){j.output=j.output.slice(0,-(t.output+K.output).length),t.output=`(?:${t.output}`,K.type="globstar",K.output=L(f)+(f.strictSlashes?")":"|$)"),K.value+=D,j.globstar=!0,j.output+=t.output+K.output,X(D);continue}if("slash"===t.type&&"bos"!==t.prev.type&&"/"===e[0]){const n=void 0!==e[1]?"|$":"";j.output=j.output.slice(0,-(t.output+K.output).length),t.output=`(?:${t.output}`,K.type="globstar",K.output=`${L(f)}${S}|${S}${n})`,K.value+=D,j.output+=t.output+K.output,j.globstar=!0,X(D+Q()),z({type:"slash",value:"/",output:""});continue}if("bos"===t.type&&"/"===e[0]){K.type="globstar",K.value+=D,K.output=`(?:^|${S}|${L(f)}${S})`,j.output=K.output,j.globstar=!0,X(D+Q()),z({type:"slash",value:"/",output:""});continue}j.output=j.output.slice(0,-K.output.length),K.type="globstar",K.output=L(f),K.value+=D,j.output+=K.output,j.globstar=!0,X(D);continue}const n={type:"star",value:D,output:M};!0!==f.bash?!K||"bracket"!==K.type&&"paren"!==K.type||!0!==f.regex?(j.index!==j.start&&"slash"!==K.type&&"dot"!==K.type||("dot"===K.type?(j.output+=x,K.output+=x):!0===f.dot?(j.output+=w,K.output+=w):(j.output+=N,K.output+=N),"*"!==F()&&(j.output+=C,K.output+=C)),z(n)):(n.output=D,z(n)):(n.output=".*?","bos"!==K.type&&"slash"!==K.type||(n.output=N+n.output),z(n))}for(;j.brackets>0;){if(!0===f.strictBrackets)throw new SyntaxError(u("closing","]"));j.output=t.escapeLast(j.output,"["),Y("brackets")}for(;j.parens>0;){if(!0===f.strictBrackets)throw new SyntaxError(u("closing",")"));j.output=t.escapeLast(j.output,"("),Y("parens")}for(;j.braces>0;){if(!0===f.strictBrackets)throw new SyntaxError(u("closing","}"));j.output=t.escapeLast(j.output,"{"),Y("braces")}if(!0===f.strictSlashes||"star"!==K.type&&"bracket"!==K.type||z({type:"maybe_slash",value:"",output:`${S}?`}),!0===j.backtrack){j.output="";for(const e of j.tokens)j.output+=null!=e.output?e.output:e.value,e.suffix&&(j.output+=e.suffix)}return j};return p.fastpaths=(r,o)=>{const s={...o},i="number"==typeof s.maxLength?Math.min(n,s.maxLength):n,u=r.length;if(u>i)throw new SyntaxError(`Input length: ${u}, exceeds maximum allowed length: ${i}`);r=a[r]||r;const p=t.isWindows(o),{DOT_LITERAL:l,SLASH_LITERAL:c,ONE_CHAR:f,DOTS_SLASH:g,NO_DOT:d,NO_DOTS:h,NO_DOTS_SLASH:A,STAR:R,START_ANCHOR:y}=e.globChars(p),m=s.dot?h:d,_=s.dot?A:d,E=s.capture?"":"?:";let b=!0===s.bash?".*?":R;s.capture&&(b=`(${b})`);const S=e=>!0===e.noglobstar?b:`(${E}(?:(?!${y}${e.dot?g:l}).)*?)`,C=e=>{switch(e){case"*":return`${m}${f}${b}`;case".*":return`${l}${f}${b}`;case"*.*":return`${m}${b}${l}${f}${b}`;case"*/*":return`${m}${b}${c}${f}${_}${b}`;case"**":return m+S(s);case"**/*":return`(?:${m}${S(s)}${c})?${_}${f}${b}`;case"**/*.*":return`(?:${m}${S(s)}${c})?${_}${b}${l}${f}${b}`;case"**/.*":return`(?:${m}${S(s)}${c})?${l}${f}${b}`;default:{const t=/^(.*?)\.(\w+)$/.exec(e);if(!t)return;const n=C(t[1]);if(!n)return;return n+l+t[2]}}},v=t.removePrefix(r,{negated:!1,prefix:""});let $=C(v);return $&&!0!==s.strictSlashes&&($+=`${c}?`),$},be=p}(),r=Te(),o=Oe(),s=(e,t,n=!1)=>{if(Array.isArray(e)){const r=e.map((e=>s(e,t,n))),o=e=>{for(const t of r){const n=t(e);if(n)return n}return!1};return o}const o=(a=e)&&"object"==typeof a&&!Array.isArray(a)&&e.tokens&&e.input;var a;if(""===e||"string"!=typeof e&&!o)throw new TypeError("Expected pattern to be a non-empty string");const i=t||{},u=r.isWindows(t),p=o?s.compileRe(e,t):s.makeRe(e,t,!1,!0),l=p.state;delete p.state;let c=()=>!1;if(i.ignore){const e={...t,ignore:null,onMatch:null,onResult:null};c=s(i.ignore,e,n)}const f=(n,r=!1)=>{const{isMatch:o,match:a,output:f}=s.test(n,p,t,{glob:e,posix:u}),g={glob:e,state:l,regex:p,posix:u,input:n,output:f,match:a,isMatch:o};return"function"==typeof i.onResult&&i.onResult(g),!1===o?(g.isMatch=!1,!!r&&g):c(n)?("function"==typeof i.onIgnore&&i.onIgnore(g),g.isMatch=!1,!!r&&g):("function"==typeof i.onMatch&&i.onMatch(g),!r||g)};return n&&(f.state=l),f};return s.test=(e,t,n,{glob:o,posix:a}={})=>{if("string"!=typeof e)throw new TypeError("Expected input to be a string");if(""===e)return{isMatch:!1,output:""};const i=n||{},u=i.format||(a?r.toPosixSlashes:null);let p=e===o,l=p&&u?u(e):e;return!1===p&&(l=u?u(e):e,p=l===o),!1!==p&&!0!==i.capture||(p=!0===i.matchBase||!0===i.basename?s.matchBase(e,t,n,a):t.exec(l)),{isMatch:Boolean(p),match:p,output:l}},s.matchBase=(t,n,o,a=r.isWindows(o))=>(n instanceof RegExp?n:s.makeRe(n,o)).test(e.basename(t)),s.isMatch=(e,t,n)=>s(t,n)(e),s.parse=(e,t)=>Array.isArray(e)?e.map((e=>s.parse(e,t))):n(e,{...t,fastpaths:!1}),s.scan=(e,n)=>t(e,n),s.compileRe=(e,t,n=!1,r=!1)=>{if(!0===n)return e.output;const o=t||{},a=o.contains?"":"^",i=o.contains?"":"$";let u=`${a}(?:${e.output})${i}`;e&&!0===e.negated&&(u=`^(?!${u}).*$`);const p=s.toRegex(u,t);return!0===r&&(p.state=e),p},s.makeRe=(e,t={},r=!1,o=!1)=>{if(!e||"string"!=typeof e)throw new TypeError("Expected a non-empty string");let a={negated:!1,fastpaths:!0};return!1===t.fastpaths||"."!==e[0]&&"*"!==e[0]||(a.output=n.fastpaths(e,t)),a.output||(a=n(e,t)),s.compileRe(a,t,r,o)},s.toRegex=(e,t)=>{try{const n=t||{};return new RegExp(e,n.flags||(n.nocase?"i":""))}catch(e){if(t&&!0===t.debug)throw e;return/$^/}},s.constants=o,Ce=s}function Ne(){return xe?$e:(xe=1,$e=Le())}var Ie=function(){if(He)return we;He=1;const e=R,t=Ae(),n=Ne(),r=Te(),o=e=>""===e||"./"===e,s=(e,t,r)=>{t=[].concat(t),e=[].concat(e);let o=new Set,s=new Set,a=new Set,i=0,u=e=>{a.add(e.output),r&&r.onResult&&r.onResult(e)};for(let a=0;a<t.length;a++){let p=n(String(t[a]),{...r,onResult:u},!0),l=p.state.negated||p.state.negatedExtglob;l&&i++;for(let t of e){let e=p(t,!0);(l?!e.isMatch:e.isMatch)&&(l?o.add(e.output):(o.delete(e.output),s.add(e.output)))}}let p=(i===t.length?[...a]:[...s]).filter((e=>!o.has(e)));if(r&&0===p.length){if(!0===r.failglob)throw new Error(`No matches found for "${t.join(", ")}"`);if(!0===r.nonull||!0===r.nullglob)return r.unescape?t.map((e=>e.replace(/\\/g,""))):t}return p};return s.match=s,s.matcher=(e,t)=>n(e,t),s.any=s.isMatch=(e,t,r)=>n(t,r)(e),s.not=(e,t,n={})=>{t=[].concat(t).map(String);let r=new Set,o=[],a=new Set(s(e,t,{...n,onResult:e=>{n.onResult&&n.onResult(e),o.push(e.output)}}));for(let e of o)a.has(e)||r.add(e);return[...r]},s.contains=(t,n,r)=>{if("string"!=typeof t)throw new TypeError(`Expected a string: "${e.inspect(t)}"`);if(Array.isArray(n))return n.some((e=>s.contains(t,e,r)));if("string"==typeof n){if(o(t)||o(n))return!1;if(t.includes(n)||t.startsWith("./")&&t.slice(2).includes(n))return!0}return s.isMatch(t,n,{...r,contains:!0})},s.matchKeys=(e,t,n)=>{if(!r.isObject(e))throw new TypeError("Expected the first argument to be an object");let o=s(Object.keys(e),t,n),a={};for(let t of o)a[t]=e[t];return a},s.some=(e,t,r)=>{let o=[].concat(e);for(let e of[].concat(t)){let t=n(String(e),r);if(o.some((e=>t(e))))return!0}return!1},s.every=(e,t,r)=>{let o=[].concat(e);for(let e of[].concat(t)){let t=n(String(e),r);if(!o.every((e=>t(e))))return!1}return!0},s.all=(t,r,o)=>{if("string"!=typeof t)throw new TypeError(`Expected a string: "${e.inspect(t)}"`);return[].concat(r).every((e=>n(e,o)(t)))},s.capture=(e,t,o)=>{let s=r.isWindows(o),a=n.makeRe(String(e),{...o,capture:!0}).exec(s?r.toPosixSlashes(t):t);if(a)return a.slice(1).map((e=>void 0===e?"":e))},s.makeRe=(...e)=>n.makeRe(...e),s.scan=(...e)=>n.scan(...e),s.parse=(e,r)=>{let o=[];for(let s of[].concat(e||[]))for(let e of t(String(s),r))o.push(n.parse(e,r));return o},s.braces=(e,n)=>{if("string"!=typeof e)throw new TypeError("Expected a string");return n&&!0===n.nobrace||!/\{.*\}/.test(e)?[e]:t(e,n)},s.braceExpand=(e,t)=>{if("string"!=typeof e)throw new TypeError("Expected a string");return s.braces(e,{...t,expand:!0})},we=s}();const Me='{\n "name": "",\n "version": "0.0.1",\n "description": "",\n "license": "",\n "author": "",\n "files": ["dist"],\n "exports": {\n ".": "./src/index.ts"\n },\n "scripts": {\n },\n "homepage": "",\n "repository": "",\n "bugs": ""\n}'.trimStart(),je="# $name\n\n## Installation\n\n```bash\nnpm install $name\n# or\npnpm install $name\n# or\nyarn add $name\n```\n\n## Usage\n\n\n## License\n\n$license\n".trimStart();const Be=new Map;function Pe(t,r){if(Be.has(t))return Be.get(t)[r];const o=n.resolve(t,"package.json"),s=JSON.parse(e.readFileSync(o,"utf-8"));return Be.set(t,s),s[r]}a.command("init [name]").option("-t, --template <template>","the package.json template file path or file content").action((async()=>{const[,t]=a.args,r=process.cwd(),{init:o={}}=K()??{},{wd:s}=H(),i=n.basename(s),{named:u,template:p,bug:l={},readme:c=je,readmeTemplate:f}=o,R={template:"bug_report.yml",labels:["bug"],...l};let y=c;if(f){const t=n.resolve(s,f);y=e.readFileSync(t,"utf-8")}const m=function(t,r){let o=r??Me,s=!1;try{r&&JSON.parse(r)}catch(e){s=!0}if(s){const s=n.resolve(t,r);o=e.readFileSync(s,"utf-8")}return o}(s,p),{indent:_=" "}=g(m),E={tabSize:_.length,insertSpaces:!0},b=["license","author"];let S=m;for(const e of b)S=h(S,A(S,[e],Pe(s,e),{formattingOptions:E}));let[C,v]=await async function(e,t,{wd:r,cwd:o,workspaceName:s}){const a=o.replace(`${r}/`,"");let i=n.basename(o);if("function"==typeof e)return e(t,{full:r,relative:o});let u,p,l=!1;if("object"==typeof e)if(o===r){const{rule:t}=await d.prompt({type:"list",name:"rule",message:"choose a rule",default:"default",choices:["default"].concat(Object.keys(e))});"default"!==t&&(u=t,p=e[t])}else for(const[t,n]of Object.entries(e)){if(Ie.isMatch(a,t)){u=t,p=n;break}if(Ie.isMatch(`${a}/jiek_ignore_dont_use_same_file_name`,t)){l=!0,u=t,p=n;break}}if(p||(u="packages/*",p=`@${s}/$basename`),!p)throw new Error("no matched rule");if(!t&&l&&(i=await d.prompt({type:"input",name:"name",message:`the matched rule is \`${String(p)}\`, please input the basename\n`}).then((({name:e})=>e))),"function"==typeof p)return p(t,{full:r,relative:o,basename:i});if("string"==typeof p){const e=t??i;return[p.replace(/\$basename/g,e),u?.replace(/\/\*$/g,`/${e}`)]}throw new Error("no matched rule")}(u,t,{wd:s,cwd:r,workspaceName:i});if(!v){const{dir:e}=await d.prompt({type:"input",name:"dir",message:"package directory",default:t});v=e}if(!C){const{name:e}=await d.prompt({type:"input",name:"name",message:"package name",default:t});C=e}S=h(S,A(S,["name"],C,{formattingOptions:E}));let $=Pe(s,"repository");"string"==typeof $&&($={type:"git",url:$,directory:v}),S=h(S,A(S,["repository"],$,{formattingOptions:E}));S=h(S,A(S,["homepage"],`${$?.url}/blob/master/${v}/README.md`,{formattingOptions:E}));let x=R.labels;"function"==typeof x&&(x=x({name:C,dir:v})),x.push(`scope:${C}`);const w=`${$?.url}/issues/new?template=${R.template}&labels=${x.join(",")}`;function k(e){if(!v)throw new Error("pkgDir is not defined");return n.resolve(v,e)}S=h(S,A(S,["bugs"],w,{formattingOptions:E})),e.existsSync(v)||e.mkdirSync(v);const O=k("package.json");if(e.existsSync(O))throw new Error("package.json already exists");e.writeFileSync(O,S),console.log(S,"written to",O);const T=Pe(s,"license"),L=k("README.md");"function"==typeof y&&(y=y({dir:v,packageJson:JSON.parse(S)}));const N=y.replace(/\$name/g,C).replace(/\$license/g,T);e.writeFileSync(L,N)}));const Ge=(e,t)=>new Set([...e].filter((e=>t.has(e))));a.command("publish").aliases(["pub","p"]).option("-b, --bumper <bumper>","bump version","patch").option("-p, --preview","preview publish").action((async({preview:t,bumper:s,...a})=>{M();const{value:i={}}=await O()??{},u=Object.entries(i);if(0===u.length)throw new Error("no packages selected");const p=u.map((([e,t])=>{const{type:n,exports:s={}}=t,a="module"===n,i={...t},[u,p]=function({entrypoints:e,pkgIsModule:t,entries:n,config:s,dir:a,noFilter:i,isPublish:u}){const{build:p={},publish:{withSuffix:l=!1,withSource:c=!0}={}}=s??{},{crossModuleConvertor:f=!0}=p,g=`./${(e=>o(a??process.cwd(),e))(((...e)=>r(a??process.cwd(),...e))(("object"==typeof p?.output?.dir?p.output.dir.js:p?.output?.dir)??"dist"))}`,[,d]=E(e);n&&Object.entries(d).forEach((([e])=>{n.some((t=>Ie.isMatch(e,t,{matchBase:!0})))||delete d[e]}));const h=i?d:b(d,{skipValue:[/(^|\/)\.jk-noentry/,...S]});return[h,C(h,{outdir:g,withSuffix:u?l:void 0,withSource:u?c:void 0,withConditional:{...f?{import:e=>!t&&0===Ge(new Set(e.conditionals),new Set(["import","module"])).size&&e.dist.replace(/\.js$/,".mjs"),require:e=>!(!t||0!==Ge(new Set(e.conditionals),new Set(["require","node"])).size)&&e.dist.replace(/\.js$/,".cjs")}:{}}})]}({entrypoints:s,pkgIsModule:a,config:K(e),dir:e,noFilter:!0,isPublish:!0});return i.exports={...u,...p},[e,i]})),l=Object.entries(a).reduce(((e,[t,n])=>(n&&e.push(`--${t}`,n),e)),[]);for(const[r,o]of p){const a=e.readFileSync(n.join(r,"package.json"),"utf-8"),i=JSON.parse(a)??"0.0.0",u=_(i.version,s),{indent:p=" "}=g(a),c={tabSize:p.length,insertSpaces:!0};let f=a;f=h(f,A(f,["version"],u,{formattingOptions:c}));for(const[e,t]of Object.entries(o))if(JSON.stringify(t)!==JSON.stringify(i[e]))if("exports"!==e)f=h(f,A(f,["publishConfig",e],t,{formattingOptions:c}));else{const e=t;for(const[t,n]of Object.entries(e))f=h(f,A(f,["publishConfig","exports",t],n,{formattingOptions:c}));const n=e?.["."],r={};if(n){switch(typeof n){case"string":r["module"===o?.type?"module":"main"]=n;break;case"object":{const e=n;r.main=e.require??e.default,r.module=e.import??e.module??e.default;break}}for(const[e,t]of Object.entries(r))void 0!==t&&(f=h(f,A(f,["publishConfig",e],t,{formattingOptions:c})))}}try{if(e.renameSync(n.join(r,"package.json"),n.join(r,"package.json.bak")),e.writeFileSync(n.join(r,"package.json"),f),console.log(f),t){console.warn("preview mode");continue}m.execSync(["pnpm","publish","--access","public","--no-git-checks",...l].join(" "),{cwd:r,stdio:"inherit"});const o=h(a,A(a,["version"],u,{}));e.writeFileSync(n.join(r,"package.json.bak"),o)}finally{e.unlinkSync(n.join(r,"package.json")),e.renameSync(n.join(r,"package.json.bak"),n.join(r,"package.json"))}}I()})),a.parse(process.argv);
1
+ "use strict";var e=require("node:fs"),t=require("node:path"),r=require("@pnpm/filter-workspace-packages"),n=require("commander"),o=require("js-yaml"),s=require("@jiek/utils/getWorkspaceDir"),i=require("cli-progress"),a=require("execa"),c=require("detect-indent"),p=require("inquirer"),l=require("jsonc-parser"),u=require("micromatch"),f=require("node:child_process"),d=require("@jiek/utils/bumper"),m=require("@jiek/pkger/entrypoints");function g(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var y=g(f);let w,h;function b(){if(w)return w;const e=n.program.getOptionValue("root");return w=e?t.isAbsolute(e)?e:t.resolve(process.cwd(),e):void 0,w}let k=!1;function j(){if(h)return{wd:h,notWorkspace:k};const e=b();if(void 0!==e){const t=s.isWorkspaceDir(e,v);return k=!t,h=e,{wd:h,notWorkspace:k}}try{h=s.getWorkspaceDir(v)}catch(t){if(!("message"in t)||"workspace root not found"!==t.message)throw t;h=e,k=!0}return{wd:h,notWorkspace:k}}let v="";try{require.resolve("@pnpm/filter-workspace-packages"),v="pnpm"}catch{}async function S(){let s=n.program.getOptionValue("filter");const i=b(),{wd:a,notWorkspace:c}=j();if(!c&&"pnpm"===v){const n=t.resolve(a,"pnpm-workspace.yaml"),c=e.readFileSync(n,"utf-8"),p=o.load(c);if(i===a&&!s)throw new Error("root path is workspace root, please provide a filter");if(i!==a&&!s){if(!e.existsSync(t.resolve(i,"package.json")))throw new Error("root path is not workspace root, please provide a filter");const r=JSON.parse(e.readFileSync(t.resolve(i,"package.json"),"utf-8"));if(!r.name)throw new Error("root path is not workspace root, please provide a filter");s=r.name}const{selectedProjectsGraph:l}=await r.filterPackagesFromDir(a,[{filter:s??"",followProdDepsOnly:!0}],{prefix:i,workspaceDir:a,patterns:p.packages});return{wd:a,root:i,value:Object.entries(l).reduce(((e,[t,r])=>(e[t]=r.package.manifest,e)),{})}}return{wd:a,root:i,value:{[a]:JSON.parse(e.readFileSync(t.resolve(a,"package.json"),"utf-8"))}}}""!==v&&n.program.option("-f, --filter <filter>","filter packages");var $=require("../package.json");let E,O;function q(){E()}function x(){new Promise((e=>E=e))}function F(e){try{return require.resolve(e),!0}catch(e){return!1}}n.program.version($.version).description($.description).option("--root <root>","root path").option("-c, --config-path <configPath>","config path");const _=[process.env.JIEK_TS_REGISTER,"esbuild-register","@swc-node/register","ts-node/register"].filter(Boolean);for(const e of _)if(F(e)){O=e;break}let J="jiek.config";function M(r){const{wd:s}=j();let i=n.program.getOptionValue("configPath");if(i){if(!e.existsSync(i))throw new Error(`config file not found: ${i}`);t.isAbsolute(i)||(i=t.resolve(s,i))}else i=function(r,n){const o=!!O;function s(o){const s=[t.resolve(process.cwd(),`${J}.${o}`),t.resolve(process.cwd(),`.${J}.${o}`),t.resolve(r,`${J}.${o}`),t.resolve(r,`.${J}.${o}`)];n&&s.unshift(t.resolve(n,`${J}.${o}`),t.resolve(n,`.${J}.${o}`));for(const t of s)if(e.existsSync(t)&&e.lstatSync(t).isFile())return t}return J=s("js")??J,J=s("json")??J,J=s("yaml")??J,o&&(J=s("ts")??J),t.resolve(r,J)}(s,r);const a=t.extname(i);let c;switch(a){case".js":c=require(i);break;case".json":return require(i);case".yaml":return o.load(e.readFileSync(i,"utf-8"));case".ts":if(O){require(O),c=require(i);break}throw new Error("ts config file is not supported without ts register, please install esbuild-register or set JIEK_TS_REGISTER env for custom ts register");case".config":c={};break;default:throw new Error(`unsupported config file type: ${a}`)}if(!c)throw new Error("config file is empty");return c.default??c}n.program.command("build").option("-s, --silent","Don't display logs.").option("-e, --entries <ENTRIES>","Specify the entries of the package.json's 'exports' field.(support glob)").action((async({silent:r,entries:n})=>{x();const{build:o}=M();r=r??o?.silent??!1;const{wd:s,value:c={}}=await S()??{};if(0===Object.keys(c).length)throw new Error("no package found");const p=t.resolve(s,"node_modules");e.existsSync(p)||e.mkdirSync(p);const l=(...e)=>t.resolve(p,".jiek",...e);e.existsSync(l())||e.mkdirSync(l());const u=require.resolve("rollup").replace(/dist\/rollup.js$/,"dist/bin/rollup"),f=new i.MultiBar({clearOnComplete:!1,hideCursor:!0,format:"- {bar} | {status} | {input} | {message}"},i.Presets.shades_classic);let d=0;await Promise.all(Object.entries(c).map((async([t,o])=>{const i=o.name?.replace(/^@/g,"").replace(/\//g,"+"),c=l(`${i??"anonymous-"+d++}.rollup.config.js`);e.writeFileSync(c,(e=>`\nconst manifest = ${JSON.stringify(e,null,2)}\nmodule.exports = require('jiek/rollup').template(manifest)\n`.trimStart())(o));let p="";O&&(p=`node -r ${O} `);const m=`${p}${u} --silent -c ${c}`,g=a.execaCommand(m,{ipc:!0,cwd:t,env:{...process.env,JIEK_ROOT:s,JIEK_ENTRIES:n}}),y={};let w=10;g.on("message",(e=>{"debug"===e.type&&console.log(...Array.isArray(e.data)?e.data:[e.data])})),!r&&g.on("message",(e=>{if("init"===e.type){const{leafMap:t,targetsLength:r}=e.data,n=Array.from(t.entries()).flatMap((([e,t])=>t.map((([t,...r])=>({input:e,path:t,conditions:r})))));console.log(`Package '${o.name}' has ${r} targets to build`),n.forEach((({input:e})=>{w=Math.max(w,e.length)})),n.forEach((({input:e,path:t})=>{const r=`${e}:${t}`;y[r]||(y[r]=f.create(50,0,{input:e.padEnd(w),status:"waiting".padEnd(10)},{barsize:20,linewrap:!0}))}))}if("progress"===e.type){const{path:t,tags:r,input:n,event:o,message:s}=e.data,i=y[`${n}:${t}`];if(!i)return;i.update({start:0,resolve:20,end:50}[o??"start"]??0,{input:n.padEnd(w),status:o?.padEnd(10),message:`${r?.join(", ")}: ${s}`})}})),await new Promise(((e,t)=>{let r="";g.stderr?.on("data",(e=>{r+=e})),g.once("exit",(n=>0===n?e():t(new Error(`rollup build failed:\n${r}`))))}))}))).finally((()=>{f.stop()})),q()}));const N='{\n "name": "",\n "version": "0.0.1",\n "description": "",\n "license": "",\n "author": "",\n "files": ["dist"],\n "exports": {\n ".": "./src/index.ts"\n },\n "scripts": {\n },\n "homepage": "",\n "repository": "",\n "bugs": ""\n}'.trimStart(),P="# $name\n\n## Installation\n\n```bash\nnpm install $name\n# or\npnpm install $name\n# or\nyarn add $name\n```\n\n## Usage\n\n\n## License\n\n$license\n".trimStart();const D=new Map;function I(r,n){if(D.has(r))return D.get(r)[n];const o=t.resolve(r,"package.json"),s=JSON.parse(e.readFileSync(o,"utf-8"));return D.set(r,s),s[n]}n.program.command("init [name]").option("-t, --template <template>","the package.json template file path or file content").action((async()=>{const[,r]=n.program.args,o=process.cwd(),{init:s={}}=M()??{},{wd:i}=j(),a=t.basename(i),{named:f,template:d,bug:m={},readme:g=P,readmeTemplate:y}=s,w={template:"bug_report.yml",labels:["bug"],...m};let h=g;if(y){const r=t.resolve(i,y);h=e.readFileSync(r,"utf-8")}const b=function(r,n){let o=n??N,s=!1;try{n&&JSON.parse(n)}catch(e){s=!0}if(s){const s=t.resolve(r,n);o=e.readFileSync(s,"utf-8")}return o}(i,d),{indent:k=" "}=c(b),v={tabSize:k.length,insertSpaces:!0},S=["license","author"];let $=b;for(const e of S)$=l.applyEdits($,l.modify($,[e],I(i,e),{formattingOptions:v}));let[E,O]=await async function(e,r,{wd:n,cwd:o,workspaceName:s}){const i=o.replace(`${n}/`,"");let a=t.basename(o);if("function"==typeof e)return e(r,{full:n,relative:o});let c,l,f=!1;if("object"==typeof e)if(o===n){const{rule:t}=await p.prompt({type:"list",name:"rule",message:"choose a rule",default:"default",choices:["default"].concat(Object.keys(e))});"default"!==t&&(c=t,l=e[t])}else for(const[t,r]of Object.entries(e)){if(u.isMatch(i,t)){c=t,l=r;break}if(u.isMatch(`${i}/jiek_ignore_dont_use_same_file_name`,t)){f=!0,c=t,l=r;break}}if(l||(c="packages/*",l=`@${s}/$basename`),!l)throw new Error("no matched rule");if(!r&&f&&(a=await p.prompt({type:"input",name:"name",message:`the matched rule is \`${String(l)}\`, please input the basename\n`}).then((({name:e})=>e))),"function"==typeof l)return l(r,{full:n,relative:o,basename:a});if("string"==typeof l){const e=r??a;return[l.replace(/\$basename/g,e),c?.replace(/\/\*$/g,`/${e}`)]}throw new Error("no matched rule")}(f,r,{wd:i,cwd:o,workspaceName:a});if(!O){const{dir:e}=await p.prompt({type:"input",name:"dir",message:"package directory",default:r});O=e}if(!E){const{name:e}=await p.prompt({type:"input",name:"name",message:"package name",default:r});E=e}$=l.applyEdits($,l.modify($,["name"],E,{formattingOptions:v}));let q=I(i,"repository");"string"==typeof q&&(q={type:"git",url:q,directory:O}),$=l.applyEdits($,l.modify($,["repository"],q,{formattingOptions:v}));const x=`${q?.url}/blob/master/${O}/README.md`;$=l.applyEdits($,l.modify($,["homepage"],x,{formattingOptions:v}));let F=w.labels;"function"==typeof F&&(F=F({name:E,dir:O})),F.push(`scope:${E}`);const _=`${q?.url}/issues/new?template=${w.template}&labels=${F.join(",")}`;function J(e){if(!O)throw new Error("pkgDir is not defined");return t.resolve(O,e)}$=l.applyEdits($,l.modify($,["bugs"],_,{formattingOptions:v})),e.existsSync(O)||e.mkdirSync(O);const D=J("package.json");if(e.existsSync(D))throw new Error("package.json already exists");e.writeFileSync(D,$),console.log($,"written to",D);const A=I(i,"license"),R=J("README.md");"function"==typeof h&&(h=h({dir:O,packageJson:JSON.parse($)}));const T=h.replace(/\$name/g,E).replace(/\$license/g,A);e.writeFileSync(R,T)}));const A=(e,t)=>new Set([...e].filter((e=>t.has(e))));function R({entrypoints:e,pkgIsModule:r,entries:n,config:o,dir:s,noFilter:i}){const{build:a={}}=o??{},{crossModuleConvertor:c=!0}=a,p=`./${l=((...e)=>t.resolve(s??process.cwd(),...e))(("object"==typeof a?.output?.dir?a.output.dir.js:a?.output?.dir)??"dist"),t.relative(s??process.cwd(),l)}`;var l;const[,f]=m.resolveEntrypoints(e);n&&Object.entries(f).forEach((([e])=>{n.some((t=>u.isMatch(e,t,{matchBase:!0})))||delete f[e]}));const d=i?f:m.filterLeafs(f,{skipValue:[/(^|\/)\.jk-noentry/,...m.DEFAULT_SKIP_VALUES]}),g=c?{import:e=>!r&&0===A(new Set(e.conditionals),new Set(["import","module"])).size&&e.dist.replace(/\.js$/,".mjs"),require:e=>!(!r||0!==A(new Set(e.conditionals),new Set(["require","node"])).size)&&e.dist.replace(/\.js$/,".cjs")}:{};return[d,m.entrypoints2Exports(d,{outdir:p,withConditional:{...g}})]}n.program.command("publish").aliases(["pub","p"]).option("-b, --bumper <bumper>","bump version","patch").option("-p, --preview","preview publish").action((async({preview:r,bumper:n,...o})=>{x();const{value:s={}}=await S()??{},i=Object.entries(s);if(0===i.length)throw new Error("no packages selected");const a=i.map((([e,t])=>{const{type:r,exports:n={}}=t,o="module"===r,s={...t},[i,a]=R({entrypoints:n,pkgIsModule:o,config:M(e),dir:e,noFilter:!0});return s.exports={...i,...a},[e,s]})),p=Object.entries(o).reduce(((e,[t,r])=>(r&&e.push(`--${t}`,r),e)),[]);for(const[o,s]of a){const i=e.readFileSync(t.join(o,"package.json"),"utf-8"),a=JSON.parse(i)??"0.0.0",u=d.bump(a.version,n),{indent:f=" "}=c(i),m={tabSize:f.length,insertSpaces:!0};let g=i;g=l.applyEdits(g,l.modify(g,["version"],u,{formattingOptions:m}));for(const[e,t]of Object.entries(s))if(JSON.stringify(t)!==JSON.stringify(a[e]))if("exports"!==e)g=l.applyEdits(g,l.modify(g,["publishConfig",e],t,{formattingOptions:m}));else{const e=t;for(const[t,r]of Object.entries(e))g=l.applyEdits(g,l.modify(g,["publishConfig","exports",t],r,{formattingOptions:m}));const r=e?.["."],n={};if(r){switch(typeof r){case"string":n["module"===s?.type?"module":"main"]=r;break;case"object":{const e=r;n.main=e.require??e.default,n.module=e.import??e.module??e.default;break}}for(const[e,t]of Object.entries(n))void 0!==t&&(g=l.applyEdits(g,l.modify(g,["publishConfig",e],t,{formattingOptions:m})))}}try{if(e.renameSync(t.join(o,"package.json"),t.join(o,"package.json.bak")),e.writeFileSync(t.join(o,"package.json"),g),console.log(g),r){console.warn("preview mode");continue}y.execSync(["pnpm","publish","--access","public","--no-git-checks",...p].join(" "),{cwd:o,stdio:"inherit"});const n=l.applyEdits(i,l.modify(i,["version"],u,{}));e.writeFileSync(t.join(o,"package.json.bak"),n)}finally{e.unlinkSync(t.join(o,"package.json")),e.renameSync(t.join(o,"package.json.bak"),t.join(o,"package.json"))}}q()})),n.program.parse(process.argv);
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.min.js","sources":["../src/utils/getRoot.ts","../src/utils/getWD.ts","../src/utils/filterSupport.ts","../src/pkg.ts","../src/inner.ts","../src/utils/tsRegister.ts","../src/commands/base.ts","../src/utils/loadConfig.ts","../src/commands/build.ts","../src/commands/init.ts","../src/merge-package-json.ts","../src/commands/publish.ts","../src/cli.ts"],"sourcesContent":["import path from 'node:path'\n\nimport { program } from 'commander'\n\nlet root: string\nexport function getRoot() {\n if (root) return root\n\n const rootOption = program.getOptionValue('root')\n root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : undefined\n return root\n}\n","import { getWorkspaceDir, isWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\n\nimport { type } from './filterSupport'\nimport { getRoot } from './getRoot'\n\nlet wd: string\nlet notWorkspace = false\n\nexport function getWD() {\n if (wd) return { wd, notWorkspace }\n\n const root = getRoot()\n if (root !== undefined) {\n const isWorkspace = isWorkspaceDir(root, type)\n notWorkspace = !isWorkspace\n wd = root\n return { wd, notWorkspace }\n }\n try {\n wd = getWorkspaceDir(type)\n } catch (e) {\n // @ts-ignore\n if ('message' in e && e.message === 'workspace root not found') {\n wd = root\n notWorkspace = true\n } else {\n throw e\n }\n }\n return { wd, notWorkspace }\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { filterPackagesFromDir } from '@pnpm/filter-workspace-packages'\nimport { program } from 'commander'\nimport { load } from 'js-yaml'\n\nimport { getRoot } from './getRoot'\nimport { getWD } from './getWD'\n\nexport let type = ''\n\ntry {\n require.resolve('@pnpm/filter-workspace-packages')\n type = 'pnpm'\n} catch { /* empty */ }\nif (type !== '') {\n program\n .option('-f, --filter <filter>', 'filter packages')\n}\n\ninterface ProjectsGraph {\n wd: string\n root: string\n value?: Record<string, {\n name?: string\n }>\n}\n\nexport async function getSelectedProjectsGraph(): Promise<ProjectsGraph> {\n let filter = program.getOptionValue('filter')\n const root = getRoot()\n const { wd, notWorkspace } = getWD()\n if (!notWorkspace && type === 'pnpm') {\n const pnpmWorkspaceFilePath = path.resolve(wd, 'pnpm-workspace.yaml')\n const pnpmWorkspaceFileContent = fs.readFileSync(pnpmWorkspaceFilePath, 'utf-8')\n const pnpmWorkspace = load(pnpmWorkspaceFileContent) as {\n packages: string[]\n }\n if (root === wd && !filter) {\n throw new Error('root path is workspace root, please provide a filter')\n // TODO inquirer prompt support user select packages\n }\n if (root !== wd && !filter) {\n const packageJSONIsExist = fs.existsSync(path.resolve(root, 'package.json'))\n if (!packageJSONIsExist) {\n throw new Error('root path is not workspace root, please provide a filter')\n }\n const packageJSON = JSON.parse(fs.readFileSync(path.resolve(root, 'package.json'), 'utf-8'))\n if (!packageJSON.name) {\n throw new Error('root path is not workspace root, please provide a filter')\n }\n filter = packageJSON.name\n }\n const { selectedProjectsGraph } = await filterPackagesFromDir(wd, [{\n filter: filter ?? '',\n followProdDepsOnly: true\n }], {\n prefix: root,\n workspaceDir: wd,\n patterns: pnpmWorkspace.packages\n })\n return {\n wd,\n root,\n value: Object.entries(selectedProjectsGraph)\n .reduce((acc, [key, value]) => {\n acc[key] = value.package.manifest\n return acc\n }, {} as NonNullable<ProjectsGraph['value']>)\n }\n }\n return {\n wd,\n root,\n value: {\n [wd]: JSON.parse(fs.readFileSync(path.resolve(wd, 'package.json'), 'utf-8'))\n }\n }\n}\n","export default require('../package.json')\n","let resolve: () => void\n\nexport let actionFuture: Promise<void>\n\nexport function actionDone() {\n resolve()\n}\n\nexport function actionRestore() {\n actionFuture = new Promise<void>(r => resolve = r)\n}\n","function packageIsExist(name: string) {\n try {\n require.resolve(name)\n return true\n } catch (e) {\n return false\n }\n}\n\nexport let tsRegisterName: string | undefined\nconst registers = [\n process.env.JIEK_TS_REGISTER,\n 'esbuild-register',\n '@swc-node/register',\n 'ts-node/register'\n].filter(Boolean) as string[]\nfor (const register of registers) {\n if (packageIsExist(register)) {\n tsRegisterName = register\n break\n }\n}\n","import { program } from 'commander'\n\nimport pkg from '../pkg'\n\nprogram\n .version(pkg.version)\n .description(pkg.description)\n .option('--root <root>', 'root path')\n .option('-c, --config-path <configPath>', 'config path')\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { program } from 'commander'\nimport type { Config } from 'jiek'\nimport { load } from 'js-yaml'\n\nimport { getWD } from './getWD'\nimport { tsRegisterName } from './tsRegister'\n\nlet configName = 'jiek.config'\n\nfunction getConfigPath(root: string) {\n const isSupportTsLoader = !!tsRegisterName\n function configWithExtIsExist(ext: string) {\n const filenames = [\n path.resolve(process.cwd(), `${configName}.${ext}`),\n path.resolve(process.cwd(), `.${configName}.${ext}`),\n path.resolve(root, `${configName}.${ext}`),\n path.resolve(root, `.${configName}.${ext}`)\n ]\n for (const filename of filenames) {\n if (\n fs.existsSync(filename)\n && fs.lstatSync(filename)\n .isFile()\n ) {\n return filename\n }\n }\n return\n }\n configName = configWithExtIsExist('js') ?? configName\n configName = configWithExtIsExist('json') ?? configName\n configName = configWithExtIsExist('yaml') ?? configName\n if (isSupportTsLoader) {\n configName = configWithExtIsExist('ts') ?? configName\n }\n return path.resolve(root, configName)\n}\n\nexport function loadConfig(): Config {\n const { wd: root, notWorkspace } = getWD()\n if (notWorkspace) {\n throw new Error('not in workspace')\n }\n\n let configPath = program.getOptionValue('configPath')\n\n if (!configPath) {\n configPath = getConfigPath(root)\n } else {\n if (!fs.existsSync(configPath)) {\n throw new Error(`config file not found: ${configPath}`)\n }\n if (!path.isAbsolute(configPath)) {\n configPath = path.resolve(root, configPath)\n }\n }\n const ext = path.extname(configPath)\n\n let module: any\n switch (ext) {\n case '.js':\n module = require(configPath)\n break\n case '.json':\n return require(configPath)\n case '.yaml':\n return load(fs.readFileSync(configPath, 'utf-8')) as Config\n case '.ts':\n if (tsRegisterName) {\n require(tsRegisterName)\n module = require(configPath)\n break\n }\n throw new Error(\n 'ts config file is not supported without ts register, '\n + 'please install esbuild-register or set JIEK_TS_REGISTER env for custom ts register'\n )\n case '.config':\n module = {}\n break\n default:\n throw new Error(`unsupported config file type: ${ext}`)\n }\n if (!module) throw new Error('config file is empty')\n\n return module.default ?? module\n}\n","import '../rollup/base'\n\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport { MultiBar, Presets } from 'cli-progress'\nimport { program } from 'commander'\nimport { execaCommand } from 'execa'\n\nimport { actionDone, actionRestore } from '../inner'\nimport type { RollupProgressEvent } from '../rollup/base'\nimport { getSelectedProjectsGraph } from '../utils/filterSupport'\nimport { loadConfig } from '../utils/loadConfig'\nimport { tsRegisterName } from '../utils/tsRegister'\n\nconst FILE_TEMPLATE = (manifest: unknown) => (`\nconst manifest = ${JSON.stringify(manifest, null, 2)}\nmodule.exports = require('jiek/rollup').template(manifest)\n`.trimStart())\n\nprogram\n .command('build')\n .option('-s, --silent', \"Don't display logs.\")\n .option('-e, --entries <ENTRIES>', \"Specify the entries of the package.json's 'exports' field.(support glob)\")\n .action(async ({\n silent,\n entries\n }: {\n silent: boolean\n entries: string\n }) => {\n actionRestore()\n const { build } = loadConfig()\n silent = silent ?? build?.silent ?? false\n const {\n wd,\n value = {}\n } = await getSelectedProjectsGraph() ?? {}\n\n if (Object.keys(value).length === 0) {\n throw new Error('no package found')\n }\n const wdNodeModules = path.resolve(wd, 'node_modules')\n if (!fs.existsSync(wdNodeModules)) {\n fs.mkdirSync(wdNodeModules)\n }\n const jiekTempDir = (...paths: string[]) => path.resolve(wdNodeModules, '.jiek', ...paths)\n if (!fs.existsSync(jiekTempDir())) {\n fs.mkdirSync(jiekTempDir())\n }\n\n const rollupBinaryPath = require.resolve('rollup')\n .replace(/dist\\/rollup.js$/, 'dist/bin/rollup')\n const multiBars = new MultiBar({\n clearOnComplete: false,\n hideCursor: true,\n format: '- {bar} | {status} | {input} | {message}'\n }, Presets.shades_classic)\n let i = 0\n await Promise.all(\n Object.entries(value).map(async ([dir, manifest]) => {\n // TODO support auto build child packages in workspaces\n const escapeManifestName = manifest.name?.replace(/^@/g, '').replace(/\\//g, '+')\n const configFile = jiekTempDir(\n `${escapeManifestName ?? `anonymous-${i++}`}.rollup.config.js`\n )\n fs.writeFileSync(configFile, FILE_TEMPLATE(manifest))\n let prefix = ''\n if (tsRegisterName) {\n prefix = `node -r ${tsRegisterName} `\n }\n // TODO replace with `spawn` to support watch mode\n const command = `${prefix}${rollupBinaryPath} --silent -c ${configFile}`\n const child = execaCommand(command, {\n ipc: true,\n cwd: dir,\n env: {\n ...process.env,\n JIEK_ROOT: wd,\n JIEK_ENTRIES: entries\n }\n })\n const bars: Record<string, ReturnType<typeof multiBars.create>> = {}\n let inputMaxLen = 10\n child.on('message', (e: RollupProgressEvent) => {\n if (e.type === 'debug') console.log(...(Array.isArray(e.data) ? e.data : [e.data]))\n })\n !silent && child.on('message', (e: RollupProgressEvent) => {\n if (e.type === 'init') {\n const { leafMap, targetsLength } = e.data\n const leafs = Array\n .from(leafMap.entries())\n .flatMap(([input, pathAndCondiions]) =>\n pathAndCondiions.map(([path, ...conditions]) => ({\n input,\n path,\n conditions\n }))\n )\n console.log(`Package '${manifest.name}' has ${targetsLength} targets to build`)\n leafs.forEach(({ input }) => {\n inputMaxLen = Math.max(inputMaxLen, input.length)\n })\n leafs.forEach(({ input, path }) => {\n const key = `${input}:${path}`\n if (bars[key]) return\n bars[key] = multiBars.create(50, 0, {\n input: input.padEnd(inputMaxLen),\n status: 'waiting'.padEnd(10)\n }, {\n barsize: 20,\n linewrap: true\n })\n })\n }\n if (e.type === 'progress') {\n const {\n path,\n tags,\n input,\n event,\n message\n } = e.data\n const bar = bars[`${input}:${path}`]\n if (!bar) return\n bar.update(\n {\n start: 0,\n resolve: 20,\n end: 50\n }[event ?? 'start'] ?? 0,\n {\n input: input.padEnd(inputMaxLen),\n status: event?.padEnd(10),\n message: `${tags?.join(', ')}: ${message}`\n }\n )\n }\n })\n await new Promise<void>((resolve, reject) => {\n let errorStr = ''\n child.stderr?.on('data', (data) => {\n errorStr += data\n })\n child.once('exit', (code) =>\n code === 0\n ? resolve()\n : reject(new Error(`rollup build failed:\\n${errorStr}`)))\n })\n })\n ).finally(() => {\n multiBars.stop()\n })\n\n actionDone()\n })\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { program } from 'commander'\nimport detectIndent from 'detect-indent'\nimport inquirer from 'inquirer'\nimport type { Config, InitNamed } from 'jiek'\nimport { applyEdits, modify } from 'jsonc-parser'\nimport { isMatch } from 'micromatch'\n\nimport { getWD } from '../utils/getWD'\nimport { loadConfig } from '../utils/loadConfig'\n\ndeclare module 'jiek' {\n export type InitNamedFunction = (\n argument: string,\n paths: {\n full: string\n relative: string\n basename?: string\n }\n ) => [name?: string, path?: string]\n export type InitNamed =\n | InitNamedFunction\n | {\n [key: string]: string | InitNamedFunction\n }\n export interface Config {\n init?: {\n /**\n * the package.json template file path or file content\n *\n * if it can be parsed as json, it will be parsed\n * if it is a relative file path, it will be resolved to an absolute path based on the current working directory\n * if it is an absolute file path, it will be used directly\n * @default '.jiek.template.package.json'\n */\n template?: string\n /**\n * the readme content\n *\n * $name will be replaced with the package name\n * $license will be replaced with the license\n */\n readme?:\n | string\n | ((ctx: {\n dir: string\n packageJson: Record<string, any>\n }) => string)\n /**\n * the readme template file path\n * @default '.jiek.template.readme.md'\n */\n readmeTemplate?: string\n bug?: {\n /**\n * @default 'bug_report.yml'\n */\n template?: string\n /**\n * @default ['bug']\n */\n labels?:\n | string[]\n | ((ctx: {\n name: string\n dir: string\n }) => string[])\n }\n named?: InitNamed\n }\n }\n}\n\nconst PACKAGE_JSON_TEMPLATE = `{\n \"name\": \"\",\n \"version\": \"0.0.1\",\n \"description\": \"\",\n \"license\": \"\",\n \"author\": \"\",\n \"files\": [\"dist\"],\n \"exports\": {\n \".\": \"./src/index.ts\"\n },\n \"scripts\": {\n },\n \"homepage\": \"\",\n \"repository\": \"\",\n \"bugs\": \"\"\n}`.trimStart()\nconst README_TEMPLATE = `# $name\n\n## Installation\n\n\\`\\`\\`bash\nnpm install $name\n# or\npnpm install $name\n# or\nyarn add $name\n\\`\\`\\`\n\n## Usage\n\n\n## License\n\n$license\n`.trimStart()\n\nfunction getTemplateStr(wd: string, template: string | undefined) {\n let templateString = template ?? PACKAGE_JSON_TEMPLATE\n let isTemplateFile = false\n try {\n if (template) JSON.parse(template)\n } catch (e) {\n isTemplateFile = true\n }\n if (isTemplateFile) {\n const templatePath = path.resolve(wd, template!)\n templateString = fs.readFileSync(templatePath, 'utf-8')\n }\n return templateString\n}\nconst wdCache = new Map<string, Record<string, any>>()\nfunction getWDPackageJSONFiled(wd: string, field: string) {\n if (wdCache.has(wd)) {\n return wdCache.get(wd)![field]\n }\n const packageJSONPath = path.resolve(wd, 'package.json')\n const packageJSON = JSON.parse(fs.readFileSync(packageJSONPath, 'utf-8'))\n wdCache.set(wd, packageJSON)\n return packageJSON[field]\n}\nasync function getName(\n named: InitNamed | undefined,\n name: string,\n {\n wd,\n cwd,\n workspaceName\n }: {\n wd: string\n cwd: string\n workspaceName: string\n }\n): Promise<[name?: string, path?: string]> {\n const relativePath = cwd.replace(`${wd}/`, '')\n let basename = path.basename(cwd)\n\n if (typeof named === 'function') {\n return named(name, {\n full: wd,\n relative: cwd\n })\n }\n\n let isParentMatched = false\n let matchedKey: string | undefined\n let matchedRule: NonNullable<typeof named>[string] | undefined\n if (typeof named === 'object') {\n const isWD = cwd === wd\n if (isWD) {\n const { rule } = await inquirer.prompt<{ rule: string }>({\n type: 'list',\n name: 'rule',\n message: 'choose a rule',\n default: 'default',\n choices: ['default'].concat(Object.keys(named))\n })\n if (rule !== 'default') {\n matchedKey = rule\n matchedRule = named[rule]\n }\n } else {\n for (const [key, value] of Object.entries(named)) {\n if (isMatch(relativePath, key)) {\n matchedKey = key\n matchedRule = value\n break\n }\n if (isMatch(`${relativePath}/jiek_ignore_dont_use_same_file_name`, key)) {\n isParentMatched = true\n matchedKey = key\n matchedRule = value\n break\n }\n }\n }\n }\n if (!matchedRule) {\n matchedKey = 'packages/*'\n matchedRule = `@${workspaceName}/$basename`\n }\n if (!matchedRule) {\n throw new Error('no matched rule')\n }\n if (!name && isParentMatched) {\n basename = await inquirer.prompt<{ name: string }>({\n type: 'input',\n name: 'name',\n message: `the matched rule is \\`${String(matchedRule)}\\`, please input the basename\\n`\n }).then(({ name }) => name)\n }\n\n if (typeof matchedRule === 'function') {\n return matchedRule(name, {\n full: wd,\n relative: cwd,\n basename: basename\n })\n }\n if (typeof matchedRule === 'string') {\n const dirName = name ?? basename\n return [\n matchedRule.replace(/\\$basename/g, dirName),\n matchedKey?.replace(/\\/\\*$/g, `/${dirName}`)\n ]\n }\n throw new Error('no matched rule')\n}\n\nprogram\n .command('init [name]')\n .option('-t, --template <template>', 'the package.json template file path or file content')\n .action(async () => {\n const [, name] = program.args\n const cwd = process.cwd()\n const { init = {} }: Config = loadConfig() ?? {}\n const { wd } = getWD()\n const workspaceName = path.basename(wd)\n\n const {\n named,\n template,\n bug = {},\n readme: _readme = README_TEMPLATE,\n readmeTemplate\n } = init\n const resolvedBug = {\n template: 'bug_report.yml',\n labels: ['bug'],\n ...bug\n }\n let readme = _readme\n if (readmeTemplate) {\n const readmeTemplatePath = path.resolve(wd, readmeTemplate)\n readme = fs.readFileSync(readmeTemplatePath, 'utf-8')\n }\n\n const templateString = getTemplateStr(wd, template)\n // TODO detectIndent by editorconfig\n const { indent = ' ' } = detectIndent(templateString)\n const formattingOptions = {\n tabSize: indent.length,\n insertSpaces: true\n }\n const passFields = [\n 'license',\n 'author'\n ]\n let newJSONString = templateString\n for (const field of passFields) {\n newJSONString = applyEdits(\n newJSONString,\n modify(\n newJSONString,\n [field],\n getWDPackageJSONFiled(wd, field),\n { formattingOptions }\n )\n )\n }\n let [pkgName, pkgDir] = await getName(named, name, {\n wd,\n cwd,\n workspaceName\n })\n if (!pkgDir) {\n const { dir } = await inquirer.prompt<{ dir: string }>({\n type: 'input',\n name: 'dir',\n message: 'package directory',\n default: name\n })\n pkgDir = dir\n }\n if (!pkgName) {\n const { name: inputName } = await inquirer.prompt<{\n name: string\n }>({\n type: 'input',\n name: 'name',\n message: 'package name',\n default: name\n })\n pkgName = inputName\n }\n newJSONString = applyEdits(newJSONString, modify(newJSONString, ['name'], pkgName, { formattingOptions }))\n\n let pkgRepo = getWDPackageJSONFiled(wd, 'repository')\n if (typeof pkgRepo === 'string') {\n pkgRepo = {\n type: 'git',\n url: pkgRepo,\n directory: pkgDir\n }\n }\n newJSONString = applyEdits(\n newJSONString,\n modify(\n newJSONString,\n ['repository'],\n pkgRepo,\n { formattingOptions }\n )\n )\n const homepage = `${pkgRepo?.url}/blob/master/${pkgDir}/README.md`\n newJSONString = applyEdits(\n newJSONString,\n modify(\n newJSONString,\n ['homepage'],\n homepage,\n { formattingOptions }\n )\n )\n let labels = resolvedBug.labels\n if (typeof labels === 'function') {\n labels = labels({\n name: pkgName,\n dir: pkgDir\n })\n }\n labels.push(`scope:${pkgName}`)\n const bugs = `${pkgRepo?.url}/issues/new?template=${resolvedBug.template}&labels=${labels.join(',')}`\n newJSONString = applyEdits(\n newJSONString,\n modify(\n newJSONString,\n ['bugs'],\n bugs,\n { formattingOptions }\n )\n )\n\n function pkgDirTo(to: string) {\n if (!pkgDir) throw new Error('pkgDir is not defined')\n\n return path.resolve(pkgDir, to)\n }\n if (!fs.existsSync(pkgDir)) fs.mkdirSync(pkgDir)\n const pkgJSONFilePath = pkgDirTo('package.json')\n if (fs.existsSync(pkgJSONFilePath)) {\n throw new Error('package.json already exists')\n }\n fs.writeFileSync(pkgJSONFilePath, newJSONString)\n console.log(newJSONString, 'written to', pkgJSONFilePath)\n\n const license = getWDPackageJSONFiled(wd, 'license')\n const readmeFilePath = pkgDirTo('README.md')\n if (typeof readme === 'function') {\n readme = readme({\n dir: pkgDir,\n packageJson: JSON.parse(newJSONString)\n })\n }\n const readmeContent = readme\n .replace(/\\$name/g, pkgName)\n .replace(/\\$license/g, license)\n fs.writeFileSync(readmeFilePath, readmeContent)\n })\n","import path from 'node:path'\n\nimport { type Options, pkger } from '@jiek/pkger'\nimport { commondir } from '@jiek/utils/commondir'\nimport type { Manifest } from '@pnpm/workspace.pkgs-graph'\n\nexport function mergePackageJson(manifest: Manifest & {\n jiek?: Options\n exports?: unknown | unknown[]\n}, cwd: string, options: {\n excludeDistInExports?: boolean\n} = {}) {\n const {\n excludeDistInExports = false\n } = options\n const {\n jiek: { cwd: _, ...jiek } = {}\n } = manifest\n const { outdir = 'dist' } = jiek\n let { exports } = manifest\n let includeIndex = false\n if (typeof exports === 'string') {\n includeIndex = true\n exports = { '.': exports }\n }\n if (exports === undefined) {\n exports = { '.': './src/index.ts' }\n }\n if (typeof exports === 'object') {\n if (Array.isArray(exports) && exports.length > 0) {\n includeIndex = true\n } else {\n includeIndex = !!(<Record<string, unknown>>exports)['.']\n }\n }\n let inputs = Array.isArray(exports)\n ? exports as string[]\n : Object\n .entries(<Record<string, unknown>>exports)\n .reduce((acc, [key, value]) => {\n if (typeof value === 'string') return key === '.'\n ? [value, ...acc]\n : acc.concat(value)\n if (Array.isArray(value)) return acc.concat(value)\n\n throw new TypeError(`Unexpected value type for key \"${key}\" in exports, expected string, got ${typeof value}`)\n }, [] as string[])\n if (excludeDistInExports) {\n inputs = inputs.filter(input => !input.startsWith(`./${outdir}`) && !input.startsWith(outdir))\n }\n if (inputs.length === 0)\n throw new Error('No inputs found')\n\n const absoluteInputs = inputs.map(input => path.isAbsolute(input)\n ? input\n : path.resolve(cwd, input)\n )\n let cDir = path.dirname(absoluteInputs[0])\n if (absoluteInputs.length > 1) {\n cDir = commondir(absoluteInputs, cwd)\n }\n const resolvedInputs = absoluteInputs.map(input => {\n return path.relative(cDir, input)\n })\n return {\n ...manifest,\n ...pkger({\n cwd,\n noIndex: !includeIndex,\n source: path.relative(cwd, cDir),\n inputs: resolvedInputs,\n ...jiek\n })\n }\n}\n","import * as childProcess from 'node:child_process'\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport { bump, type BumperType } from '@jiek/utils/bumper'\nimport { program } from 'commander'\nimport detectIndent from 'detect-indent'\nimport { applyEdits, modify } from 'jsonc-parser'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\nimport { getSelectedProjectsGraph } from '../utils/filterSupport'\n\nprogram\n .command('publish')\n .aliases(['pub', 'p'])\n .option('-b, --bumper <bumper>', 'bump version', 'patch')\n .option('-p, --preview', 'preview publish')\n .action(async ({ preview, bumper, ...options }: {\n preview?: boolean\n bumper: BumperType\n }) => {\n actionRestore()\n\n const { value = {} } = await getSelectedProjectsGraph() ?? {}\n const selectedProjectsGraphEntries = Object.entries(value)\n if (selectedProjectsGraphEntries.length === 0) {\n throw new Error('no packages selected')\n }\n const mainfests = selectedProjectsGraphEntries\n .map(([dir, manifest]) => [\n dir, mergePackageJson(manifest, dir)\n ] as const)\n const passArgs = Object\n .entries(options)\n .reduce((acc, [key, value]) => {\n if (value) {\n acc.push(`--${key}`, value as string)\n }\n return acc\n }, [] as string[])\n for (const [dir, manifest] of mainfests) {\n const oldJSONString = fs.readFileSync(path.join(dir, 'package.json'), 'utf-8')\n const oldJSON = JSON.parse(oldJSONString) ?? '0.0.0'\n const newVersion = bump(oldJSON.version, bumper)\n // TODO detectIndent by editorconfig\n const { indent = ' ' } = detectIndent(oldJSONString)\n const formattingOptions = {\n tabSize: indent.length,\n insertSpaces: true\n }\n let newJSONString = oldJSONString\n newJSONString = applyEdits(newJSONString, modify(\n newJSONString, ['version'], newVersion, { formattingOptions }\n ))\n for (const [key, value] of Object.entries(manifest)) {\n if (JSON.stringify(value) === JSON.stringify(oldJSON[key])) continue\n\n if (key !== 'exports') {\n newJSONString = applyEdits(newJSONString, modify(\n newJSONString, ['publishConfig', key], value, { formattingOptions }\n ))\n } else {\n for (const [k, v] of Object.entries(value)) {\n newJSONString = applyEdits(newJSONString, modify(\n newJSONString, ['publishConfig', 'exports', k], v, { formattingOptions }\n ))\n }\n }\n }\n try {\n fs.renameSync(path.join(dir, 'package.json'), path.join(dir, 'package.json.bak'))\n fs.writeFileSync(path.join(dir, 'package.json'), newJSONString)\n console.log(newJSONString)\n if (preview) {\n console.warn('preview mode')\n continue\n }\n childProcess.execSync(['pnpm', 'publish', '--access', 'public', '--no-git-checks', ...passArgs].join(' '), {\n cwd: dir,\n stdio: 'inherit'\n })\n const modifyVersionPackageJSON = applyEdits(oldJSONString, modify(oldJSONString, ['version'], newVersion, {}))\n fs.writeFileSync(path.join(dir, 'package.json.bak'), modifyVersionPackageJSON)\n } finally {\n fs.unlinkSync(path.join(dir, 'package.json'))\n fs.renameSync(path.join(dir, 'package.json.bak'), path.join(dir, 'package.json'))\n }\n }\n actionDone()\n })\n","import './utils/filterSupport'\nimport './commands/base'\nimport './commands/build'\nimport './commands/init'\nimport './commands/publish'\n\nimport { program } from 'commander'\n\nprogram.parse(process.argv)\n"],"names":["root","wd","getRoot","rootOption","program","getOptionValue","path","isAbsolute","resolve","process","cwd","notWorkspace","getWD","isWorkspace","isWorkspaceDir","type","getWorkspaceDir","e","message","require","async","getSelectedProjectsGraph","filter","pnpmWorkspaceFilePath","pnpmWorkspaceFileContent","fs","readFileSync","pnpmWorkspace","load","Error","existsSync","packageJSON","JSON","parse","name","selectedProjectsGraph","filterPackagesFromDir","followProdDepsOnly","prefix","workspaceDir","patterns","packages","value","Object","entries","reduce","acc","key","package","manifest","option","pkg","tsRegisterName","actionDone","actionRestore","Promise","r","packageIsExist","version","description","registers","env","JIEK_TS_REGISTER","Boolean","register","configName","loadConfig","configPath","isSupportTsLoader","configWithExtIsExist","ext","filenames","filename","lstatSync","isFile","getConfigPath","extname","module","default","command","action","silent","build","keys","length","wdNodeModules","mkdirSync","jiekTempDir","paths","rollupBinaryPath","replace","multiBars","MultiBar","clearOnComplete","hideCursor","format","Presets","shades_classic","i","all","map","dir","escapeManifestName","configFile","writeFileSync","stringify","trimStart","FILE_TEMPLATE","child","execaCommand","ipc","JIEK_ROOT","JIEK_ENTRIES","bars","inputMaxLen","on","console","log","Array","isArray","data","leafMap","targetsLength","leafs","from","flatMap","input","pathAndCondiions","conditions","forEach","Math","max","create","padEnd","status","barsize","linewrap","tags","event","bar","update","start","end","join","reject","errorStr","stderr","once","code","finally","stop","PACKAGE_JSON_TEMPLATE","README_TEMPLATE","wdCache","Map","getWDPackageJSONFiled","field","has","get","packageJSONPath","set","mergePackageJson","options","excludeDistInExports","jiek","_","outdir","exports","includeIndex","inputs","concat","TypeError","startsWith","absoluteInputs","cDir","dirname","commondir","resolvedInputs","relative","pkger","noIndex","source","args","init","workspaceName","basename","named","template","bug","readme","_readme","readmeTemplate","resolvedBug","labels","readmeTemplatePath","templateString","isTemplateFile","templatePath","getTemplateStr","indent","detectIndent","formattingOptions","tabSize","insertSpaces","passFields","newJSONString","applyEdits","modify","pkgName","pkgDir","relativePath","full","matchedKey","matchedRule","isParentMatched","rule","inquirer","prompt","choices","isMatch","String","then","dirName","getName","inputName","pkgRepo","url","directory","homepage","push","bugs","pkgDirTo","to","pkgJSONFilePath","license","readmeFilePath","packageJson","readmeContent","aliases","preview","bumper","selectedProjectsGraphEntries","mainfests","passArgs","oldJSONString","oldJSON","newVersion","bump","k","v","renameSync","warn","childProcess","execSync","stdio","modifyVersionPackageJSON","unlinkSync","argv"],"mappings":"ytBAIA,IAAIA,ECCAC,EDAG,SAASC,IACV,GAAAF,EAAa,OAAAA,EAEX,MAAAG,EAAaC,EAAAA,QAAQC,eAAe,QAMnC,OALPL,EAAOG,EACHG,EAAKC,WAAWJ,GACdA,EACAG,EAAKE,QAAQC,QAAQC,MAAOP,QAC9B,EACGH,CACT,CCTA,IAAIW,GAAe,EAEZ,SAASC,IACV,GAAAX,EAAW,MAAA,CAAEA,KAAIU,gBAErB,MAAMX,EAAOE,IACb,QAAa,IAATF,EAAoB,CAChB,MAAAa,EAAcC,EAAAA,eAAed,EAAMe,GAGlC,OAFPJ,GAAgBE,EACXZ,EAAAD,EACE,CAAEC,KAAIU,eACf,CACI,IACFV,EAAKe,EAAAA,gBAAgBD,SACdE,GAEP,KAAI,YAAaA,IAAmB,6BAAdA,EAAEC,QAIhB,MAAAD,EAHDhB,EAAAD,EACUW,GAAA,CAInB,CACO,MAAA,CAAEV,KAAIU,eACf,CCpBO,IAAII,EAAO,GAElB,IACEI,QAAQX,QAAQ,mCACTO,EAAA,MACT,CAAQ,MAAc,CActBK,eAAsBC,IAChB,IAAAC,EAASlB,EAAAA,QAAQC,eAAe,UACpC,MAAML,EAAOE,KACPD,GAAEA,EAAAU,aAAIA,GAAiBC,IACzB,IAACD,GAAyB,SAATI,EAAiB,CACpC,MAAMQ,EAAwBjB,EAAKE,QAAQP,EAAI,uBACzCuB,EAA2BC,EAAGC,aAAaH,EAAuB,SAClEI,EAAgBC,OAAKJ,GAGvB,GAAAxB,IAASC,IAAOqB,EACZ,MAAA,IAAIO,MAAM,wDAG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EAAaC,SAAS,CAAC,OAAQ,UAAW,WAAY,SAAU,qBAAsBV,GAAUpG,KAAK,KAAM,CACzGrI,IAAK2F,EACLyJ,MAAO,YAEH,MAAAC,EAA2BjD,EAAAA,WAAWsC,EAAerC,SAAOqC,EAAe,CAAC,WAAYE,EAAY,CAAE,IAC5G7N,EAAG+E,cAAclG,EAAKyI,KAAK1C,EAAK,oBAAqB0J,EAAwB,CAC7E,QACAtO,EAAGuO,WAAW1P,EAAKyI,KAAK1C,EAAK,iBAC1B5E,EAAAiO,WAAWpP,EAAKyI,KAAK1C,EAAK,oBAAqB/F,EAAKyI,KAAK1C,EAAK,gBACnE,CACF,CACWhD,GAAA,ICjFfjD,EAAAA,QAAQ6B,MAAMxB,QAAQwP"}
@@ -0,0 +1 @@
1
+ import e from"node:fs";import t,{resolve as n,relative as o}from"node:path";import{filterPackagesFromDir as r}from"@pnpm/filter-workspace-packages";import{program as s}from"commander";import{load as i}from"js-yaml";import{isWorkspaceDir as a,getWorkspaceDir as c}from"@jiek/utils/getWorkspaceDir";import{MultiBar as p,Presets as l}from"cli-progress";import{execaCommand as f}from"execa";import u from"detect-indent";import m from"inquirer";import{applyEdits as d,modify as g}from"jsonc-parser";import{isMatch as w}from"micromatch";import*as y from"node:child_process";import{bump as h}from"@jiek/utils/bumper";import{resolveEntrypoints as k,filterLeafs as b,DEFAULT_SKIP_VALUES as j,entrypoints2Exports as S}from"@jiek/pkger/entrypoints";let v,$;function E(){if(v)return v;const e=s.getOptionValue("root");return v=e?t.isAbsolute(e)?e:t.resolve(process.cwd(),e):void 0,v}let O=!1;function x(){if($)return{wd:$,notWorkspace:O};const e=E();if(void 0!==e){const t=a(e,F);return O=!t,$=e,{wd:$,notWorkspace:O}}try{$=c(F)}catch(t){if(!("message"in t)||"workspace root not found"!==t.message)throw t;$=e,O=!0}return{wd:$,notWorkspace:O}}let F="";try{require.resolve("@pnpm/filter-workspace-packages"),F="pnpm"}catch{}async function _(){let n=s.getOptionValue("filter");const o=E(),{wd:a,notWorkspace:c}=x();if(!c&&"pnpm"===F){const s=t.resolve(a,"pnpm-workspace.yaml"),c=e.readFileSync(s,"utf-8"),p=i(c);if(o===a&&!n)throw new Error("root path is workspace root, please provide a filter");if(o!==a&&!n){if(!e.existsSync(t.resolve(o,"package.json")))throw new Error("root path is not workspace root, please provide a filter");const r=JSON.parse(e.readFileSync(t.resolve(o,"package.json"),"utf-8"));if(!r.name)throw new Error("root path is not workspace root, please provide a filter");n=r.name}const{selectedProjectsGraph:l}=await r(a,[{filter:n??"",followProdDepsOnly:!0}],{prefix:o,workspaceDir:a,patterns:p.packages});return{wd:a,root:o,value:Object.entries(l).reduce(((e,[t,n])=>(e[t]=n.package.manifest,e)),{})}}return{wd:a,root:o,value:{[a]:JSON.parse(e.readFileSync(t.resolve(a,"package.json"),"utf-8"))}}}""!==F&&s.option("-f, --filter <filter>","filter packages");var J=require("../package.json");let q,N;function I(){q()}function M(){new Promise((e=>q=e))}function R(e){try{return require.resolve(e),!0}catch(e){return!1}}s.version(J.version).description(J.description).option("--root <root>","root path").option("-c, --config-path <configPath>","config path");const P=[process.env.JIEK_TS_REGISTER,"esbuild-register","@swc-node/register","ts-node/register"].filter(Boolean);for(const e of P)if(R(e)){N=e;break}let T="jiek.config";function A(n){const{wd:o}=x();let r=s.getOptionValue("configPath");if(r){if(!e.existsSync(r))throw new Error(`config file not found: ${r}`);t.isAbsolute(r)||(r=t.resolve(o,r))}else r=function(n,o){const r=!!N;function s(r){const s=[t.resolve(process.cwd(),`${T}.${r}`),t.resolve(process.cwd(),`.${T}.${r}`),t.resolve(n,`${T}.${r}`),t.resolve(n,`.${T}.${r}`)];o&&s.unshift(t.resolve(o,`${T}.${r}`),t.resolve(o,`.${T}.${r}`));for(const t of s)if(e.existsSync(t)&&e.lstatSync(t).isFile())return t}return T=s("js")??T,T=s("json")??T,T=s("yaml")??T,r&&(T=s("ts")??T),t.resolve(n,T)}(o,n);const a=t.extname(r);let c;switch(a){case".js":c=require(r);break;case".json":return require(r);case".yaml":return i(e.readFileSync(r,"utf-8"));case".ts":if(N){require(N),c=require(r);break}throw new Error("ts config file is not supported without ts register, please install esbuild-register or set JIEK_TS_REGISTER env for custom ts register");case".config":c={};break;default:throw new Error(`unsupported config file type: ${a}`)}if(!c)throw new Error("config file is empty");return c.default??c}s.command("build").option("-s, --silent","Don't display logs.").option("-e, --entries <ENTRIES>","Specify the entries of the package.json's 'exports' field.(support glob)").action((async({silent:n,entries:o})=>{M();const{build:r}=A();n=n??r?.silent??!1;const{wd:s,value:i={}}=await _()??{};if(0===Object.keys(i).length)throw new Error("no package found");const a=t.resolve(s,"node_modules");e.existsSync(a)||e.mkdirSync(a);const c=(...e)=>t.resolve(a,".jiek",...e);e.existsSync(c())||e.mkdirSync(c());const u=require.resolve("rollup").replace(/dist\/rollup.js$/,"dist/bin/rollup"),m=new p({clearOnComplete:!1,hideCursor:!0,format:"- {bar} | {status} | {input} | {message}"},l.shades_classic);let d=0;await Promise.all(Object.entries(i).map((async([t,r])=>{const i=r.name?.replace(/^@/g,"").replace(/\//g,"+"),a=c(`${i??"anonymous-"+d++}.rollup.config.js`);e.writeFileSync(a,(e=>`\nconst manifest = ${JSON.stringify(e,null,2)}\nmodule.exports = require('jiek/rollup').template(manifest)\n`.trimStart())(r));let p="";N&&(p=`node -r ${N} `);const l=f(`${p}${u} --silent -c ${a}`,{ipc:!0,cwd:t,env:{...process.env,JIEK_ROOT:s,JIEK_ENTRIES:o}}),g={};let w=10;l.on("message",(e=>{"debug"===e.type&&console.log(...Array.isArray(e.data)?e.data:[e.data])})),!n&&l.on("message",(e=>{if("init"===e.type){const{leafMap:t,targetsLength:n}=e.data,o=Array.from(t.entries()).flatMap((([e,t])=>t.map((([t,...n])=>({input:e,path:t,conditions:n})))));console.log(`Package '${r.name}' has ${n} targets to build`),o.forEach((({input:e})=>{w=Math.max(w,e.length)})),o.forEach((({input:e,path:t})=>{const n=`${e}:${t}`;g[n]||(g[n]=m.create(50,0,{input:e.padEnd(w),status:"waiting".padEnd(10)},{barsize:20,linewrap:!0}))}))}if("progress"===e.type){const{path:t,tags:n,input:o,event:r,message:s}=e.data,i=g[`${o}:${t}`];if(!i)return;i.update({start:0,resolve:20,end:50}[r??"start"]??0,{input:o.padEnd(w),status:r?.padEnd(10),message:`${n?.join(", ")}: ${s}`})}})),await new Promise(((e,t)=>{let n="";l.stderr?.on("data",(e=>{n+=e})),l.once("exit",(o=>0===o?e():t(new Error(`rollup build failed:\n${n}`))))}))}))).finally((()=>{m.stop()})),I()}));const C='{\n "name": "",\n "version": "0.0.1",\n "description": "",\n "license": "",\n "author": "",\n "files": ["dist"],\n "exports": {\n ".": "./src/index.ts"\n },\n "scripts": {\n },\n "homepage": "",\n "repository": "",\n "bugs": ""\n}'.trimStart(),D="# $name\n\n## Installation\n\n```bash\nnpm install $name\n# or\npnpm install $name\n# or\nyarn add $name\n```\n\n## Usage\n\n\n## License\n\n$license\n".trimStart();const z=new Map;function W(n,o){if(z.has(n))return z.get(n)[o];const r=t.resolve(n,"package.json"),s=JSON.parse(e.readFileSync(r,"utf-8"));return z.set(n,s),s[o]}s.command("init [name]").option("-t, --template <template>","the package.json template file path or file content").action((async()=>{const[,n]=s.args,o=process.cwd(),{init:r={}}=A()??{},{wd:i}=x(),a=t.basename(i),{named:c,template:p,bug:l={},readme:f=D,readmeTemplate:y}=r,h={template:"bug_report.yml",labels:["bug"],...l};let k=f;if(y){const n=t.resolve(i,y);k=e.readFileSync(n,"utf-8")}const b=function(n,o){let r=o??C,s=!1;try{o&&JSON.parse(o)}catch(e){s=!0}if(s){const s=t.resolve(n,o);r=e.readFileSync(s,"utf-8")}return r}(i,p),{indent:j=" "}=u(b),S={tabSize:j.length,insertSpaces:!0},v=["license","author"];let $=b;for(const e of v)$=d($,g($,[e],W(i,e),{formattingOptions:S}));let[E,O]=await async function(e,n,{wd:o,cwd:r,workspaceName:s}){const i=r.replace(`${o}/`,"");let a=t.basename(r);if("function"==typeof e)return e(n,{full:o,relative:r});let c,p,l=!1;if("object"==typeof e)if(r===o){const{rule:t}=await m.prompt({type:"list",name:"rule",message:"choose a rule",default:"default",choices:["default"].concat(Object.keys(e))});"default"!==t&&(c=t,p=e[t])}else for(const[t,n]of Object.entries(e)){if(w(i,t)){c=t,p=n;break}if(w(`${i}/jiek_ignore_dont_use_same_file_name`,t)){l=!0,c=t,p=n;break}}if(p||(c="packages/*",p=`@${s}/$basename`),!p)throw new Error("no matched rule");if(!n&&l&&(a=await m.prompt({type:"input",name:"name",message:`the matched rule is \`${String(p)}\`, please input the basename\n`}).then((({name:e})=>e))),"function"==typeof p)return p(n,{full:o,relative:r,basename:a});if("string"==typeof p){const e=n??a;return[p.replace(/\$basename/g,e),c?.replace(/\/\*$/g,`/${e}`)]}throw new Error("no matched rule")}(c,n,{wd:i,cwd:o,workspaceName:a});if(!O){const{dir:e}=await m.prompt({type:"input",name:"dir",message:"package directory",default:n});O=e}if(!E){const{name:e}=await m.prompt({type:"input",name:"name",message:"package name",default:n});E=e}$=d($,g($,["name"],E,{formattingOptions:S}));let F=W(i,"repository");"string"==typeof F&&(F={type:"git",url:F,directory:O}),$=d($,g($,["repository"],F,{formattingOptions:S}));$=d($,g($,["homepage"],`${F?.url}/blob/master/${O}/README.md`,{formattingOptions:S}));let _=h.labels;"function"==typeof _&&(_=_({name:E,dir:O})),_.push(`scope:${E}`);const J=`${F?.url}/issues/new?template=${h.template}&labels=${_.join(",")}`;function q(e){if(!O)throw new Error("pkgDir is not defined");return t.resolve(O,e)}$=d($,g($,["bugs"],J,{formattingOptions:S})),e.existsSync(O)||e.mkdirSync(O);const N=q("package.json");if(e.existsSync(N))throw new Error("package.json already exists");e.writeFileSync(N,$),console.log($,"written to",N);const I=W(i,"license"),M=q("README.md");"function"==typeof k&&(k=k({dir:O,packageJson:JSON.parse($)}));const R=k.replace(/\$name/g,E).replace(/\$license/g,I);e.writeFileSync(M,R)}));const K=(e,t)=>new Set([...e].filter((e=>t.has(e))));s.command("publish").aliases(["pub","p"]).option("-b, --bumper <bumper>","bump version","patch").option("-p, --preview","preview publish").action((async({preview:r,bumper:s,...i})=>{M();const{value:a={}}=await _()??{},c=Object.entries(a);if(0===c.length)throw new Error("no packages selected");const p=c.map((([e,t])=>{const{type:r,exports:s={}}=t,i="module"===r,a={...t},[c,p]=function({entrypoints:e,pkgIsModule:t,entries:r,config:s,dir:i,noFilter:a}){const{build:c={}}=s??{},{crossModuleConvertor:p=!0}=c,l=`./${(e=>o(i??process.cwd(),e))(((...e)=>n(i??process.cwd(),...e))(("object"==typeof c?.output?.dir?c.output.dir.js:c?.output?.dir)??"dist"))}`,[,f]=k(e);r&&Object.entries(f).forEach((([e])=>{r.some((t=>w(e,t,{matchBase:!0})))||delete f[e]}));const u=a?f:b(f,{skipValue:[/(^|\/)\.jk-noentry/,...j]});return[u,S(u,{outdir:l,withConditional:{...p?{import:e=>!t&&0===K(new Set(e.conditionals),new Set(["import","module"])).size&&e.dist.replace(/\.js$/,".mjs"),require:e=>!(!t||0!==K(new Set(e.conditionals),new Set(["require","node"])).size)&&e.dist.replace(/\.js$/,".cjs")}:{}}})]}({entrypoints:s,pkgIsModule:i,config:A(e),dir:e,noFilter:!0});return a.exports={...c,...p},[e,a]})),l=Object.entries(i).reduce(((e,[t,n])=>(n&&e.push(`--${t}`,n),e)),[]);for(const[n,o]of p){const i=e.readFileSync(t.join(n,"package.json"),"utf-8"),a=JSON.parse(i)??"0.0.0",c=h(a.version,s),{indent:p=" "}=u(i),f={tabSize:p.length,insertSpaces:!0};let m=i;m=d(m,g(m,["version"],c,{formattingOptions:f}));for(const[e,t]of Object.entries(o))if(JSON.stringify(t)!==JSON.stringify(a[e]))if("exports"!==e)m=d(m,g(m,["publishConfig",e],t,{formattingOptions:f}));else{const e=t;for(const[t,n]of Object.entries(e))m=d(m,g(m,["publishConfig","exports",t],n,{formattingOptions:f}));const n=e?.["."],r={};if(n){switch(typeof n){case"string":r["module"===o?.type?"module":"main"]=n;break;case"object":{const e=n;r.main=e.require??e.default,r.module=e.import??e.module??e.default;break}}for(const[e,t]of Object.entries(r))void 0!==t&&(m=d(m,g(m,["publishConfig",e],t,{formattingOptions:f})))}}try{if(e.renameSync(t.join(n,"package.json"),t.join(n,"package.json.bak")),e.writeFileSync(t.join(n,"package.json"),m),console.log(m),r){console.warn("preview mode");continue}y.execSync(["pnpm","publish","--access","public","--no-git-checks",...l].join(" "),{cwd:n,stdio:"inherit"});const o=d(i,g(i,["version"],c,{}));e.writeFileSync(t.join(n,"package.json.bak"),o)}finally{e.unlinkSync(t.join(n,"package.json")),e.renameSync(t.join(n,"package.json.bak"),t.join(n,"package.json"))}}I()})),s.parse(process.argv);