jiek 0.4.7-alpha.1 → 0.4.7-alpha.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. package/bin/jiek.js +7 -4
  2. package/dist/cli.cjs +5028 -0
  3. package/dist/cli.js +4274 -92
  4. package/dist/cli.min.cjs +19 -0
  5. package/dist/cli.min.js +19 -1
  6. package/dist/index.cjs +5 -0
  7. package/dist/index.js +1 -3
  8. package/dist/index.min.cjs +1 -0
  9. package/dist/index.min.js +1 -1
  10. package/dist/rollup/index.cjs +4669 -0
  11. package/dist/rollup/index.js +4178 -65
  12. package/dist/rollup/index.min.cjs +19 -0
  13. package/dist/rollup/index.min.js +19 -1
  14. package/package.json +13 -11
  15. package/src/commands/base.ts +1 -2
  16. package/src/commands/build.ts +3 -0
  17. package/src/rollup/index.ts +2 -2
  18. package/src/utils/filterSupport.ts +2 -0
  19. package/dist/cli.d.mts.map +0 -1
  20. package/dist/cli.d.ts.map +0 -1
  21. package/dist/cli.js.map +0 -1
  22. package/dist/cli.min.js.map +0 -1
  23. package/dist/cli.min.mjs +0 -1
  24. package/dist/cli.min.mjs.map +0 -1
  25. package/dist/cli.mjs +0 -803
  26. package/dist/cli.mjs.map +0 -1
  27. package/dist/index.d.mts.map +0 -1
  28. package/dist/index.d.ts.map +0 -1
  29. package/dist/index.js.map +0 -1
  30. package/dist/index.min.js.map +0 -1
  31. package/dist/index.min.mjs +0 -1
  32. package/dist/index.min.mjs.map +0 -1
  33. package/dist/index.mjs +0 -3
  34. package/dist/index.mjs.map +0 -1
  35. package/dist/rollup/index.d.mts.map +0 -1
  36. package/dist/rollup/index.d.ts.map +0 -1
  37. package/dist/rollup/index.js.map +0 -1
  38. package/dist/rollup/index.min.js.map +0 -1
  39. package/dist/rollup/index.min.mjs +0 -1
  40. package/dist/rollup/index.min.mjs.map +0 -1
  41. package/dist/rollup/index.mjs +0 -551
  42. package/dist/rollup/index.mjs.map +0 -1
  43. package/src/pkg.ts +0 -1
  44. /package/dist/{cli.d.mts → cli.d.cts} +0 -0
  45. /package/dist/{index.d.mts → index.d.cts} +0 -0
  46. /package/dist/rollup/{index.d.mts → index.d.cts} +0 -0
package/dist/cli.js.map DELETED
@@ -1 +0,0 @@
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,CAAA;AACT;;ACVA,IAAI,EAAA,CAAA;AACJ,IAAI,YAAe,GAAA,KAAA,CAAA;AAEZ,SAAS,KAAQ,GAAA;AACtB,EAAI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AAA;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;;"}
@@ -1 +0,0 @@
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,wDAGd,GAAA7B,IAASC,IAAOqB,EAAQ,CAE1B,IAD2BG,EAAGK,WAAWxB,EAAKE,QAAQR,EAAM,iBAEpD,MAAA,IAAI6B,MAAM,4DAEZ,MAAAE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,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"}
package/dist/cli.min.mjs DELETED
@@ -1 +0,0 @@
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);
@@ -1 +0,0 @@
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,GA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