jiek 0.4.7-alpha.13 → 0.4.7-alpha.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. package/bin/jiek.js +4 -7
  2. package/dist/cli.d.mts.map +1 -0
  3. package/dist/cli.d.ts.map +1 -0
  4. package/dist/cli.js +95 -4277
  5. package/dist/cli.js.map +1 -0
  6. package/dist/cli.min.js +1 -19
  7. package/dist/cli.min.js.map +1 -0
  8. package/dist/cli.min.mjs +1 -0
  9. package/dist/cli.min.mjs.map +1 -0
  10. package/dist/cli.mjs +803 -0
  11. package/dist/cli.mjs.map +1 -0
  12. package/dist/index.d.mts.map +1 -0
  13. package/dist/index.d.ts.map +1 -0
  14. package/dist/index.js +3 -1
  15. package/dist/index.js.map +1 -0
  16. package/dist/index.min.js +1 -1
  17. package/dist/index.min.js.map +1 -0
  18. package/dist/index.min.mjs +1 -0
  19. package/dist/index.min.mjs.map +1 -0
  20. package/dist/index.mjs +3 -0
  21. package/dist/index.mjs.map +1 -0
  22. package/dist/rollup/index.d.mts.map +1 -0
  23. package/dist/rollup/index.d.ts.map +1 -0
  24. package/dist/rollup/index.js +68 -4183
  25. package/dist/rollup/index.js.map +1 -0
  26. package/dist/rollup/index.min.js +1 -19
  27. package/dist/rollup/index.min.js.map +1 -0
  28. package/dist/rollup/index.min.mjs +1 -0
  29. package/dist/rollup/index.min.mjs.map +1 -0
  30. package/dist/rollup/index.mjs +551 -0
  31. package/dist/rollup/index.mjs.map +1 -0
  32. package/package.json +11 -13
  33. package/src/commands/base.ts +2 -1
  34. package/src/commands/build.ts +2 -4
  35. package/src/pkg.ts +1 -0
  36. package/src/rollup/index.ts +3 -5
  37. package/src/utils/filterSupport.ts +0 -2
  38. package/src/utils/tsRegister.ts +0 -4
  39. package/dist/cli.cjs +0 -5037
  40. package/dist/cli.min.cjs +0 -19
  41. package/dist/index.cjs +0 -5
  42. package/dist/index.min.cjs +0 -1
  43. package/dist/rollup/index.cjs +0 -4683
  44. package/dist/rollup/index.min.cjs +0 -19
  45. /package/dist/{cli.d.cts → cli.d.mts} +0 -0
  46. /package/dist/{index.d.cts → index.d.mts} +0 -0
  47. /package/dist/rollup/{index.d.cts → index.d.mts} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.min.mjs","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","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":"4pBAIA,IAAIA,ECCAC,EDAG,SAASC,IACV,GAAAF,EAAa,OAAAA,EAEX,MAAAG,EAAaC,EAAQC,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,EAAed,EAAMe,GAGlC,OAFPJ,GAAgBE,EACXZ,EAAAD,EACE,CAAEC,KAA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