jiek 0.1.12-alpha.1 → 0.1.12-alpha.3
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/commands/build.esm.js +9 -31
- package/dist/commands/build.esm.js.map +1 -1
- package/dist/commands/build.esm.min.js +1 -1
- package/dist/commands/build.esm.min.js.map +1 -1
- package/dist/commands/publish.esm.js +11 -17
- package/dist/commands/publish.esm.js.map +1 -1
- package/dist/commands/publish.esm.min.js +1 -1
- package/dist/commands/publish.esm.min.js.map +1 -1
- package/dist/index.esm.js +4 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/index.iife.js +1 -56
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +1 -1
- package/dist/index.iife.min.js.map +1 -1
- package/dist/index.umd.js +1 -56
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/dist/rollup.esm.js +5 -5
- package/dist/rollup.esm.min.js +1 -1
- package/dist/rollup.esm.min.js.map +1 -1
- package/dist/utils/filterSupport.esm.js.map +1 -0
- package/dist/utils/filterSupport.esm.min.js.map +1 -0
- package/package.json +13 -9
- package/dist/package.json.esm.js +0 -58
- package/dist/package.json.esm.js.map +0 -1
- package/dist/package.json.esm.min.js +0 -2
- package/dist/package.json.esm.min.js.map +0 -1
- package/dist/src/commands/build.esm.js +0 -53
- package/dist/src/commands/build.esm.js.map +0 -1
- package/dist/src/commands/build.esm.min.js +0 -2
- package/dist/src/commands/build.esm.min.js.map +0 -1
- package/dist/src/commands/publish.esm.js +0 -54
- package/dist/src/commands/publish.esm.js.map +0 -1
- package/dist/src/commands/publish.esm.min.js +0 -2
- package/dist/src/commands/publish.esm.min.js.map +0 -1
- package/dist/src/inner.esm.js +0 -10
- package/dist/src/inner.esm.js.map +0 -1
- package/dist/src/inner.esm.min.js +0 -2
- package/dist/src/inner.esm.min.js.map +0 -1
- package/dist/src/merge-package-json.esm.js +0 -16
- package/dist/src/merge-package-json.esm.js.map +0 -1
- package/dist/src/merge-package-json.esm.min.js +0 -2
- package/dist/src/merge-package-json.esm.min.js.map +0 -1
- package/dist/src/rollup/plugins/globals.esm.js +0 -31
- package/dist/src/rollup/plugins/globals.esm.js.map +0 -1
- package/dist/src/rollup/plugins/globals.esm.min.js +0 -2
- package/dist/src/rollup/plugins/globals.esm.min.js.map +0 -1
- package/dist/src/rollup/plugins/skip.esm.js +0 -16
- package/dist/src/rollup/plugins/skip.esm.js.map +0 -1
- package/dist/src/rollup/plugins/skip.esm.min.js +0 -2
- package/dist/src/rollup/plugins/skip.esm.min.js.map +0 -1
- package/dist/src/rollup/utils/commonOptions.esm.js +0 -10
- package/dist/src/rollup/utils/commonOptions.esm.js.map +0 -1
- package/dist/src/rollup/utils/commonOptions.esm.min.js +0 -2
- package/dist/src/rollup/utils/commonOptions.esm.min.js.map +0 -1
- package/dist/src/rollup/utils/externalResolver.esm.js +0 -10
- package/dist/src/rollup/utils/externalResolver.esm.js.map +0 -1
- package/dist/src/rollup/utils/externalResolver.esm.min.js +0 -2
- package/dist/src/rollup/utils/externalResolver.esm.min.js.map +0 -1
- package/dist/src/rollup/utils/globalResolver.esm.js +0 -26
- package/dist/src/rollup/utils/globalResolver.esm.js.map +0 -1
- package/dist/src/rollup/utils/globalResolver.esm.min.js +0 -2
- package/dist/src/rollup/utils/globalResolver.esm.min.js.map +0 -1
- package/dist/src/rollup/utils/withMinify.esm.js +0 -15
- package/dist/src/rollup/utils/withMinify.esm.js.map +0 -1
- package/dist/src/rollup/utils/withMinify.esm.min.js +0 -2
- package/dist/src/rollup/utils/withMinify.esm.min.js.map +0 -1
- package/dist/src/utils/filterSupport.esm.js.map +0 -1
- package/dist/src/utils/filterSupport.esm.min.js.map +0 -1
- /package/dist/{src/utils → utils}/filterSupport.esm.js +0 -0
- /package/dist/{src/utils → utils}/filterSupport.esm.min.js +0 -0
package/dist/index.umd.js
CHANGED
@@ -208,62 +208,7 @@ module.exports = require('${process.env.NODE_ENV === "test" ? "jiek/src/rollup/i
|
|
208
208
|
actionDone();
|
209
209
|
});
|
210
210
|
|
211
|
-
|
212
|
-
var version = "0.1.12";
|
213
|
-
var description = "YiJie's personal kits.";
|
214
|
-
var bin = {
|
215
|
-
jiek: "bin/jiek.js",
|
216
|
-
"jiek-dev": "bin/jiek-dev.js"
|
217
|
-
};
|
218
|
-
var jiek = {
|
219
|
-
inputs: [
|
220
|
-
"index.ts",
|
221
|
-
"rollup/index.ts"
|
222
|
-
]
|
223
|
-
};
|
224
|
-
var scripts = {
|
225
|
-
build: "jiek-dev build"
|
226
|
-
};
|
227
|
-
var dependencies = {
|
228
|
-
"@jiek/pkger": "workspace:^*",
|
229
|
-
"@jiek/utils": "workspace:^*",
|
230
|
-
"@rollup/plugin-json": "^6.0.1",
|
231
|
-
"@rollup/plugin-terser": "^0.4.4",
|
232
|
-
autoprefixer: "^10.4.16",
|
233
|
-
commander: "^12.0.0",
|
234
|
-
"js-yaml": "^4.1.0",
|
235
|
-
rollup: "^4.1.5",
|
236
|
-
"rollup-plugin-copy": "^3.5.0",
|
237
|
-
"rollup-plugin-dts": "^6.1.0",
|
238
|
-
"rollup-plugin-esbuild": "^6.1.0",
|
239
|
-
"rollup-plugin-postcss": "^4.0.2"
|
240
|
-
};
|
241
|
-
var optionalDependencies = {
|
242
|
-
"@pnpm/filter-workspace-packages": "^7.2.13"
|
243
|
-
};
|
244
|
-
var devDependencies = {
|
245
|
-
"@npm/types": "^1.0.2",
|
246
|
-
"@pnpm/workspace.pkgs-graph": "^2.0.15",
|
247
|
-
"@pnpm/filter-workspace-packages": "^7.2.13",
|
248
|
-
"@types/js-yaml": "^4.0.9",
|
249
|
-
"esbuild-register": "^3.5.0"
|
250
|
-
};
|
251
|
-
var files = [
|
252
|
-
"dist"
|
253
|
-
];
|
254
|
-
var pkg = {
|
255
|
-
name: name,
|
256
|
-
version: version,
|
257
|
-
description: description,
|
258
|
-
bin: bin,
|
259
|
-
jiek: jiek,
|
260
|
-
scripts: scripts,
|
261
|
-
dependencies: dependencies,
|
262
|
-
optionalDependencies: optionalDependencies,
|
263
|
-
devDependencies: devDependencies,
|
264
|
-
files: files
|
265
|
-
};
|
266
|
-
|
211
|
+
const pkg = require("../package.json");
|
267
212
|
commander.program.version(pkg.version).description(pkg.description).option("--root <root>", "root path");
|
268
213
|
commander.program.parse(process.argv);
|
269
214
|
|
package/dist/index.umd.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":["../src/utils/filterSupport.ts","../src/inner.ts","../src/merge-package-json.ts","../src/commands/publish.ts","../src/commands/build.ts","../src/index.ts"],"sourcesContent":["import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport { filterPackagesFromDir } from '@pnpm/filter-workspace-packages'\nimport { program } from 'commander'\nimport { load } from 'js-yaml'\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 rootOption = program.getOptionValue('root')\n const root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n let notWorkspace = false\n let wd: string\n try {\n wd = getWorkspaceDir(root, 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 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, 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, root,\n value: {\n [wd]: JSON.parse(fs.readFileSync(path.resolve(wd, 'package.json'), 'utf-8'))\n }\n }\n}\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","import { type Options, pkger } from '@jiek/pkger'\nimport type { PackageJson } from '@npm/types'\nimport type { Manifest } from '@pnpm/workspace.pkgs-graph'\n\nexport function mergePackageJson(manifest: Manifest & {\n jiek?: Options\n exports?: unknown | unknown[]\n}, cwd: string) {\n const {\n jiek: { inputs: jiekInputs, cwd: _, ...jiek } = {}, exports\n } = manifest\n const inputs = jiekInputs ?? (\n Array.isArray(exports) ? exports : undefined\n )\n return {\n ...manifest,\n ...pkger({ inputs, cwd, ...jiek })\n } as PackageJson\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { bump, type BumperType } from '@jiek/utils/bumper'\nimport type { PackageJson } from '@npm/types'\nimport * as childProcess from 'child_process'\nimport { program } from 'commander'\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('--bumper <bumper>', 'bump version', 'patch')\n .action(async ({ bumper, ...options }: {\n root?: string\n filter?: string\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: [dir: string, PackageJson][] = []\n selectedProjectsGraphEntries\n .forEach(([dir, manifest]) => {\n mainfests.push([\n dir, mergePackageJson(manifest, dir)\n ])\n })\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, m] of mainfests) {\n const newVersion = bump(m.version, bumper)\n const newManifest = {\n ...m,\n version: newVersion\n }\n fs.renameSync(path.join(dir, 'package.json'), path.join(dir, 'package.json.bak'))\n fs.writeFileSync(path.join(dir, 'package.json'), JSON.stringify(newManifest, null, 2))\n console.log(newManifest)\n try {\n childProcess.execSync(['pnpm', 'publish', '--access', 'public', '--no-git-checks', ...passArgs].join(' '), {\n cwd: dir,\n stdio: 'inherit'\n })\n const oldPackageJson = JSON.parse(fs.readFileSync(path.join(dir, 'package.json.bak'), 'utf-8'))\n oldPackageJson.version = newVersion\n fs.writeFileSync(path.join(dir, 'package.json.bak'), JSON.stringify(oldPackageJson, null, 2))\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 * as childProcess from 'node:child_process'\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport { program } from 'commander'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\nimport { getSelectedProjectsGraph } from '../utils/filterSupport'\n\nconst FILE_TEMPLATE = (manifest: unknown) => `\nconst pkg = ${JSON.stringify(manifest, null, 2)}\nconst { jiek = {} } = pkg\nconst templateArg = jiek.templateArgFilePath\n ? require.resolve(jiek.templateArgFilePath)\n : {\n styled: jiek.styled\n }\nmodule.exports = require('${\n process.env.NODE_ENV === 'test'\n ? 'jiek/src/rollup/index.ts'\n : 'jiek/rollup'\n}').template(templateArg, pkg)\n`.trimStart()\n\nprogram\n .command('build')\n .action(async () => {\n actionRestore()\n const {\n wd, value = {}\n } = await getSelectedProjectsGraph() ?? {}\n\n if (Object.keys(value).length === 0) {\n throw new Error('no package found')\n }\n const jiekTempDir = (...paths: string[]) => path.resolve(wd, 'node_modules/.jiek', ...paths)\n if (!fs.existsSync(jiekTempDir())) fs.mkdirSync(jiekTempDir())\n\n const rollupBinaryPath = require.resolve('rollup')\n .replace(/dist\\/rollup.js$/, 'dist/bin/rollup')\n let i = 0\n for (const [dir, manifest] of Object.entries(value)) {\n const newManifest = mergePackageJson(manifest, dir)\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(newManifest))\n let prefix = ''\n if (process.env.NODE_ENV === 'test') {\n const registerPath = require.resolve('esbuild-register')\n const loaderPath = require.resolve('esbuild-register/loader')\n prefix = `node --import ${registerPath} -r ${loaderPath} `\n }\n // TODO replace with `spawn` to support watch mode\n childProcess.execSync(`${prefix}${rollupBinaryPath} -c ${configFile}`, {\n cwd: dir, stdio: 'inherit'\n })\n }\n\n actionDone()\n })\n","import './utils/filterSupport'\nimport './commands/publish'\nimport './commands/build'\n\nimport { program } from 'commander'\n\nimport pkg from '../package.json'\n\nprogram\n .version(pkg.version)\n .description(pkg.description)\n .option('--root <root>', 'root path')\n\nprogram.parse(process.argv)\n"],"names":["program","path","getWorksp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EAAA,KAClB,CAAA,CAAA;EAAA,GACH;EAEA,EAAW,UAAA,EAAA,CAAA;EACb,CAAC,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACvDHV,mBACG,CAAA,OAAA,CAAQ,GAAI,CAAA,OAAO,CACnB,CAAA,WAAA,CAAY,IAAI,WAAW,CAAA,CAC3B,MAAO,CAAA,eAAA,EAAiB,WAAW,CAAA,CAAA;AAEtCA,mBAAQ,CAAA,KAAA,CAAM,QAAQ,IAAI,CAAA;;;;;;"}
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../src/utils/filterSupport.ts","../src/inner.ts","../src/merge-package-json.ts","../src/commands/publish.ts","../src/commands/build.ts","../src/index.ts"],"sourcesContent":["import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport { filterPackagesFromDir } from '@pnpm/filter-workspace-packages'\nimport { program } from 'commander'\nimport { load } from 'js-yaml'\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 rootOption = program.getOptionValue('root')\n const root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n let notWorkspace = false\n let wd: string\n try {\n wd = getWorkspaceDir(root, 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 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, 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, root,\n value: {\n [wd]: JSON.parse(fs.readFileSync(path.resolve(wd, 'package.json'), 'utf-8'))\n }\n }\n}\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","import { type Options, pkger } from '@jiek/pkger'\nimport type { PackageJson } from '@npm/types'\nimport type { Manifest } from '@pnpm/workspace.pkgs-graph'\n\nexport function mergePackageJson(manifest: Manifest & {\n jiek?: Options\n exports?: unknown | unknown[]\n}, cwd: string) {\n const {\n jiek: { inputs: jiekInputs, cwd: _, ...jiek } = {}, exports\n } = manifest\n const inputs = jiekInputs ?? (\n Array.isArray(exports) ? exports : undefined\n )\n return {\n ...manifest,\n ...pkger({ inputs, cwd, ...jiek })\n } as PackageJson\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { bump, type BumperType } from '@jiek/utils/bumper'\nimport type { PackageJson } from '@npm/types'\nimport * as childProcess from 'child_process'\nimport { program } from 'commander'\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('--bumper <bumper>', 'bump version', 'patch')\n .action(async ({ bumper, ...options }: {\n root?: string\n filter?: string\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: [dir: string, PackageJson][] = []\n selectedProjectsGraphEntries\n .forEach(([dir, manifest]) => {\n mainfests.push([\n dir, mergePackageJson(manifest, dir)\n ])\n })\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, m] of mainfests) {\n const newVersion = bump(m.version, bumper)\n const newManifest = {\n ...m,\n version: newVersion\n }\n fs.renameSync(path.join(dir, 'package.json'), path.join(dir, 'package.json.bak'))\n fs.writeFileSync(path.join(dir, 'package.json'), JSON.stringify(newManifest, null, 2))\n console.log(newManifest)\n try {\n childProcess.execSync(['pnpm', 'publish', '--access', 'public', '--no-git-checks', ...passArgs].join(' '), {\n cwd: dir,\n stdio: 'inherit'\n })\n const oldPackageJson = JSON.parse(fs.readFileSync(path.join(dir, 'package.json.bak'), 'utf-8'))\n oldPackageJson.version = newVersion\n fs.writeFileSync(path.join(dir, 'package.json.bak'), JSON.stringify(oldPackageJson, null, 2))\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 * as childProcess from 'node:child_process'\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport { program } from 'commander'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\nimport { getSelectedProjectsGraph } from '../utils/filterSupport'\n\nconst FILE_TEMPLATE = (manifest: unknown) => `\nconst pkg = ${JSON.stringify(manifest, null, 2)}\nconst { jiek = {} } = pkg\nconst templateArg = jiek.templateArgFilePath\n ? require.resolve(jiek.templateArgFilePath)\n : {\n styled: jiek.styled\n }\nmodule.exports = require('${\n process.env.NODE_ENV === 'test'\n ? 'jiek/src/rollup/index.ts'\n : 'jiek/rollup'\n}').template(templateArg, pkg)\n`.trimStart()\n\nprogram\n .command('build')\n .action(async () => {\n actionRestore()\n const {\n wd, value = {}\n } = await getSelectedProjectsGraph() ?? {}\n\n if (Object.keys(value).length === 0) {\n throw new Error('no package found')\n }\n const jiekTempDir = (...paths: string[]) => path.resolve(wd, 'node_modules/.jiek', ...paths)\n if (!fs.existsSync(jiekTempDir())) fs.mkdirSync(jiekTempDir())\n\n const rollupBinaryPath = require.resolve('rollup')\n .replace(/dist\\/rollup.js$/, 'dist/bin/rollup')\n let i = 0\n for (const [dir, manifest] of Object.entries(value)) {\n const newManifest = mergePackageJson(manifest, dir)\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(newManifest))\n let prefix = ''\n if (process.env.NODE_ENV === 'test') {\n const registerPath = require.resolve('esbuild-register')\n const loaderPath = require.resolve('esbuild-register/loader')\n prefix = `node --import ${registerPath} -r ${loaderPath} `\n }\n // TODO replace with `spawn` to support watch mode\n childProcess.execSync(`${prefix}${rollupBinaryPath} -c ${configFile}`, {\n cwd: dir, stdio: 'inherit'\n })\n }\n\n actionDone()\n })\n","import './utils/filterSupport'\nimport './commands/publish'\nimport './commands/build'\n\nimport { program } from 'commander'\n\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst pkg = require('../package.json')\n\nprogram\n .version(pkg.version)\n .description(pkg.description)\n .option('--root <root>', 'root path')\n\nprogram.parse(process.argv)\n"],"names":["program","path","getWorkspaceDir","fs","load","filterPackagesFromDir","pkger","bumper","value","bump","childProcess"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQO,IAAI,IAAO,GAAA,EAAA,CAAA;EAElB,IAAI;EACF,EAAA,OAAA,CAAQ,QAAQ,iCAAiC,CAAA,CAAA;EACjD,EAAO,IAAA,GAAA,MAAA,CAAA;EACT,CAAQ,CAAA,MAAA;EAAc,CAAA;EACtB,IAAI,SAAS,EAAI,EAAA;EACf,EACGA,iBAAA,CAAA,MAAA,CAAO,yBAAyB,iBAAiB,CAAA,CAAA;EACtD,CAAA;EAUA,eAAsB,wBAAmD,GAAA;EACvE,EAAI,IAAA,MAAA,GAASA,iBAAQ,CAAA,cAAA,CAAe,QAAQ,CAAA,CAAA;EAC5C,EAAM,MAAA,UAAA,GAAaA,iBAAQ,CAAA,cAAA,CAAe,MAAM,CAAA,CAAA;EAChD,EAAA,MAAM,IAAO,GAAA,UAAA,GACTC,qBAAK,CAAA,UAAA,CAAW,UAAU,CACxB,GAAA,UAAA,GACAA,qBAAK,CAAA,OAAA,CAAQ,QAAQ,GAAI,EAAA,EAAG,UAAU,CAAA,GACxC,QAAQ,GAAI,EAAA,CAAA;EAChB,EAAA,IAAI,YAAe,GAAA,KAAA,CAAA;EACnB,EAAI,IAAA,EAAA,CAAA;EACJ,EAAI,IAAA;EACF,IAAK,EAAA,GAAAC,+BAAA,CAAgB,MAAM,IAAI,CAAA,CAAA;EAAA,WACxB,CAAG,EAAA;EAEV,IAAA,IAAI,SAAa,IAAA,CAAA,IAAK,CAAE,CAAA,OAAA,KAAY,0BAA4B,EAAA;EAC9D,MAAK,EAAA,GAAA,IAAA,CAAA;EACL,MAAe,YAAA,GAAA,IAAA,CAAA;EAAA,KACV,MAAA;EACL,MAAM,MAAA,CAAA,CAAA;EAAA,KACR;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CAAA,IAAA,EAAO,UAAU,CAAI,CAAA,EAAA;EAAA,MACrE,GAAK,EAAA,GAAA;EAAA,MAAK,KAAO,EAAA,SAAA;EAAA,KAClB,CAAA,CAAA;EAAA,GACH;EAEA,EAAW,UAAA,EAAA,CAAA;EACb,CAAC,CAAA;;ECxDH,MAAM,GAAA,GAAM,QAAQ,iBAAiB,CAAA,CAAA;AAErCV,mBACG,CAAA,OAAA,CAAQ,GAAI,CAAA,OAAO,CACnB,CAAA,WAAA,CAAY,IAAI,WAAW,CAAA,CAC3B,MAAO,CAAA,eAAA,EAAiB,WAAW,CAAA,CAAA;AAEtCA,mBAAQ,CAAA,KAAA,CAAM,QAAQ,IAAI,CAAA;;;;;;"}
|
package/dist/index.umd.min.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(require("node:fs"),require("node:path"),require("@jiek/utils/getWorkspaceDir"),require("@pnpm/filter-workspace-packages"),require("commander"),require("js-yaml"),require("@jiek/utils/bumper"),require("child_process"),require("@jiek/pkger"),require("node:child_process")):"function"==typeof define&&define.amd?define(["node:fs","node:path","@jiek/utils/getWorkspaceDir","@pnpm/filter-workspace-packages","commander","js-yaml","@jiek/utils/bumper","child_process","@jiek/pkger","node:child_process"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).fs,e.path,e.getWorkspaceDir,e.filterWorkspacePackages,e.commander,e.jsYaml,e.bumper,e.childProcess,e.pkger,e.childProcess$1)}(this,(function(e,r,t,o,a,
|
1
|
+
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(require("node:fs"),require("node:path"),require("@jiek/utils/getWorkspaceDir"),require("@pnpm/filter-workspace-packages"),require("commander"),require("js-yaml"),require("@jiek/utils/bumper"),require("child_process"),require("@jiek/pkger"),require("node:child_process")):"function"==typeof define&&define.amd?define(["node:fs","node:path","@jiek/utils/getWorkspaceDir","@pnpm/filter-workspace-packages","commander","js-yaml","@jiek/utils/bumper","child_process","@jiek/pkger","node:child_process"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).fs,e.path,e.getWorkspaceDir,e.filterWorkspacePackages,e.commander,e.jsYaml,e.bumper,e.childProcess,e.pkger,e.childProcess$1)}(this,(function(e,r,t,o,n,a,s,i,c,l){"use strict";function p(e){return e&&e.__esModule?e:{default:e}}function u(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,o.get?o:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}var d=p(e),f=p(r),g=u(i),k=u(l);let m,j="";try{require.resolve("@pnpm/filter-workspace-packages"),j="pnpm"}catch{}async function y(){let e=n.program.getOptionValue("filter");const r=n.program.getOptionValue("root"),s=r?f.default.isAbsolute(r)?r:f.default.resolve(process.cwd(),r):process.cwd();let i,c=!1;try{i=t.getWorkspaceDir(s,j)}catch(e){if(!("message"in e)||"workspace root not found"!==e.message)throw e;i=s,c=!0}if(!c&&"pnpm"===j){const r=f.default.resolve(i,"pnpm-workspace.yaml"),t=d.default.readFileSync(r,"utf-8"),n=a.load(t);if(s===i&&!e)throw new Error("root path is workspace root, please provide a filter");if(s!==i&&!e){if(!d.default.existsSync(f.default.resolve(s,"package.json")))throw new Error("root path is not workspace root, please provide a filter");const r=JSON.parse(d.default.readFileSync(f.default.resolve(s,"package.json"),"utf-8"));if(!r.name)throw new Error("root path is not workspace root, please provide a filter");e=r.name}const{selectedProjectsGraph:c}=await o.filterPackagesFromDir(i,[{filter:e??"",followProdDepsOnly:!0}],{prefix:s,workspaceDir:i,patterns:n.packages});return{wd:i,root:s,value:Object.entries(c).reduce(((e,[r,t])=>(e[r]=t.package.manifest,e)),{})}}return{wd:i,root:s,value:{[i]:JSON.parse(d.default.readFileSync(f.default.resolve(i,"package.json"),"utf-8"))}}}function h(){m()}function w(){new Promise((e=>m=e))}function b(e,r){const{jiek:{inputs:t,cwd:o,...n}={},exports:a}=e,s=t??(Array.isArray(a)?a:void 0);return{...e,...c.pkger({inputs:s,cwd:r,...n})}}""!==j&&n.program.option("-f, --filter <filter>","filter packages"),n.program.command("publish").aliases(["pub","p"]).option("--bumper <bumper>","bump version","patch").action((async({bumper:e,...r})=>{w();const{value:t={}}=await y()??{},o=Object.entries(t);if(0===o.length)throw new Error("no packages selected");const n=[];o.forEach((([e,r])=>{n.push([e,b(r,e)])}));const a=Object.entries(r).reduce(((e,[r,t])=>(t&&e.push(`--${r}`,t),e)),[]);for(const[r,t]of n){const o=s.bump(t.version,e),n={...t,version:o};d.default.renameSync(f.default.join(r,"package.json"),f.default.join(r,"package.json.bak")),d.default.writeFileSync(f.default.join(r,"package.json"),JSON.stringify(n,null,2)),console.log(n);try{g.execSync(["pnpm","publish","--access","public","--no-git-checks",...a].join(" "),{cwd:r,stdio:"inherit"});const e=JSON.parse(d.default.readFileSync(f.default.join(r,"package.json.bak"),"utf-8"));e.version=o,d.default.writeFileSync(f.default.join(r,"package.json.bak"),JSON.stringify(e,null,2))}finally{d.default.unlinkSync(f.default.join(r,"package.json")),d.default.renameSync(f.default.join(r,"package.json.bak"),f.default.join(r,"package.json"))}}h()}));const v=e=>`\nconst pkg = ${JSON.stringify(e,null,2)}\nconst { jiek = {} } = pkg\nconst templateArg = jiek.templateArgFilePath\n ? require.resolve(jiek.templateArgFilePath)\n : {\n styled: jiek.styled\n }\nmodule.exports = require('${"test"===process.env.NODE_ENV?"jiek/src/rollup/index.ts":"jiek/rollup"}').template(templateArg, pkg)\n`.trimStart();n.program.command("build").action((async()=>{w();const{wd:e,value:r={}}=await y()??{};if(0===Object.keys(r).length)throw new Error("no package found");const t=(...r)=>f.default.resolve(e,"node_modules/.jiek",...r);d.default.existsSync(t())||d.default.mkdirSync(t());const o=require.resolve("rollup").replace(/dist\/rollup.js$/,"dist/bin/rollup");let n=0;for(const[e,a]of Object.entries(r)){const r=b(a,e),s=a.name?.replace(/^@/g,"").replace(/\//g,"+"),i=t(`${s??"anonymous-"+n++}.rollup.config.js`);d.default.writeFileSync(i,v(r));let c="";if("test"===process.env.NODE_ENV){c=`node --import ${require.resolve("esbuild-register")} -r ${require.resolve("esbuild-register/loader")} `}k.execSync(`${c}${o} -c ${i}`,{cwd:e,stdio:"inherit"})}h()}));const O=require("../package.json");n.program.version(O.version).description(O.description).option("--root <root>","root path"),n.program.parse(process.argv)}));
|
2
2
|
//# sourceMappingURL=index.umd.min.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.umd.min.js","sources":["../src/utils/filterSupport.ts","../src/inner.ts","../src/merge-package-json.ts","../src/commands/publish.ts","../src/commands/build.ts","../src/index.ts"],"sourcesContent":["import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport { filterPackagesFromDir } from '@pnpm/filter-workspace-packages'\nimport { program } from 'commander'\nimport { load } from 'js-yaml'\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 rootOption = program.getOptionValue('root')\n const root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n let notWorkspace = false\n let wd: string\n try {\n wd = getWorkspaceDir(root, 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 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, 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, root,\n value: {\n [wd]: JSON.parse(fs.readFileSync(path.resolve(wd, 'package.json'), 'utf-8'))\n }\n }\n}\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","import { type Options, pkger } from '@jiek/pkger'\nimport type { PackageJson } from '@npm/types'\nimport type { Manifest } from '@pnpm/workspace.pkgs-graph'\n\nexport function mergePackageJson(manifest: Manifest & {\n jiek?: Options\n exports?: unknown | unknown[]\n}, cwd: string) {\n const {\n jiek: { inputs: jiekInputs, cwd: _, ...jiek } = {}, exports\n } = manifest\n const inputs = jiekInputs ?? (\n Array.isArray(exports) ? exports : undefined\n )\n return {\n ...manifest,\n ...pkger({ inputs, cwd, ...jiek })\n } as PackageJson\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { bump, type BumperType } from '@jiek/utils/bumper'\nimport type { PackageJson } from '@npm/types'\nimport * as childProcess from 'child_process'\nimport { program } from 'commander'\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('--bumper <bumper>', 'bump version', 'patch')\n .action(async ({ bumper, ...options }: {\n root?: string\n filter?: string\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: [dir: string, PackageJson][] = []\n selectedProjectsGraphEntries\n .forEach(([dir, manifest]) => {\n mainfests.push([\n dir, mergePackageJson(manifest, dir)\n ])\n })\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, m] of mainfests) {\n const newVersion = bump(m.version, bumper)\n const newManifest = {\n ...m,\n version: newVersion\n }\n fs.renameSync(path.join(dir, 'package.json'), path.join(dir, 'package.json.bak'))\n fs.writeFileSync(path.join(dir, 'package.json'), JSON.stringify(newManifest, null, 2))\n console.log(newManifest)\n try {\n childProcess.execSync(['pnpm', 'publish', '--access', 'public', '--no-git-checks', ...passArgs].join(' '), {\n cwd: dir,\n stdio: 'inherit'\n })\n const oldPackageJson = JSON.parse(fs.readFileSync(path.join(dir, 'package.json.bak'), 'utf-8'))\n oldPackageJson.version = newVersion\n fs.writeFileSync(path.join(dir, 'package.json.bak'), JSON.stringify(oldPackageJson, null, 2))\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 * as childProcess from 'node:child_process'\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport { program } from 'commander'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\nimport { getSelectedProjectsGraph } from '../utils/filterSupport'\n\nconst FILE_TEMPLATE = (manifest: unknown) => `\nconst pkg = ${JSON.stringify(manifest, null, 2)}\nconst { jiek = {} } = pkg\nconst templateArg = jiek.templateArgFilePath\n ? require.resolve(jiek.templateArgFilePath)\n : {\n styled: jiek.styled\n }\nmodule.exports = require('${\n process.env.NODE_ENV === 'test'\n ? 'jiek/src/rollup/index.ts'\n : 'jiek/rollup'\n}').template(templateArg, pkg)\n`.trimStart()\n\nprogram\n .command('build')\n .action(async () => {\n actionRestore()\n const {\n wd, value = {}\n } = await getSelectedProjectsGraph() ?? {}\n\n if (Object.keys(value).length === 0) {\n throw new Error('no package found')\n }\n const jiekTempDir = (...paths: string[]) => path.resolve(wd, 'node_modules/.jiek', ...paths)\n if (!fs.existsSync(jiekTempDir())) fs.mkdirSync(jiekTempDir())\n\n const rollupBinaryPath = require.resolve('rollup')\n .replace(/dist\\/rollup.js$/, 'dist/bin/rollup')\n let i = 0\n for (const [dir, manifest] of Object.entries(value)) {\n const newManifest = mergePackageJson(manifest, dir)\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(newManifest))\n let prefix = ''\n if (process.env.NODE_ENV === 'test') {\n const registerPath = require.resolve('esbuild-register')\n const loaderPath = require.resolve('esbuild-register/loader')\n prefix = `node --import ${registerPath} -r ${loaderPath} `\n }\n // TODO replace with `spawn` to support watch mode\n childProcess.execSync(`${prefix}${rollupBinaryPath} -c ${configFile}`, {\n cwd: dir, stdio: 'inherit'\n })\n }\n\n actionDone()\n })\n","import './utils/filterSupport'\nimport './commands/publish'\nimport './commands/build'\n\nimport { program } from 'commander'\n\nimport pkg from '../package.json'\n\nprogram\n .version(pkg.version)\n .description(pkg.description)\n .option('--root <root>', 'root path')\n\nprogram.parse(process.argv)\n"],"names":["resolve","type","require","async","getSelectedProjectsGraph","filter","program","getOptionValue","rootOption","root","path","isAbsolute","process","cwd","wd","notWorkspace","getWorkspaceDir","e","message","pnpmWorkspaceFilePath","default","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","actionDone","actionRestore","Promise","r","mergePackageJson","jiek","inputs","jiekInputs","_","exports","Array","isArray","pkger","option","command","aliases","action","bumper","options","selectedProjectsGraphEntries","length","mainfests","forEach","dir","push","passArgs","m","newVersion","bump","version","newManifest","renameSync","join","writeFileSync","stringify","console","log","childProcess","execSync","stdio","oldPackageJson","unlinkSync","FILE_TEMPLATE","env","NODE_ENV","trimStart","commander","keys","jiekTempDir","paths","mkdirSync","rollupBinaryPath","replace","i","escapeManifestName","configFile","pkg","description","argv"],"mappings":"opCAQO,ICRHA,EDQOC,EAAO,GAElB,IACEC,QAAQF,QAAQ,mCACTC,EAAA,MACT,CAAQ,MAAc,CActBE,eAAsBC,IAChB,IAAAC,EAASC,EAAAA,QAAQC,eAAe,UAC9B,MAAAC,EAAaF,EAAAA,QAAQC,eAAe,QACpCE,EAAOD,EACTE,EAAAA,QAAKC,WAAWH,GACdA,EACAE,EAAAA,QAAKV,QAAQY,QAAQC,MAAOL,GAC9BI,QAAQC,MACZ,IACIC,EADAC,GAAe,EAEf,IACGD,EAAAE,EAAAA,gBAAgBP,EAAMR,SACpBgB,GAEP,KAAI,YAAaA,IAAmB,6BAAdA,EAAEC,QAIhB,MAAAD,EAHDH,EAAAL,EACUM,GAAA,CAInB,CACI,IAACA,GAAyB,SAATd,EAAiB,CACpC,MAAMkB,EAAwBT,EAAAU,QAAKpB,QAAQc,EAAI,uBACzCO,EAA2BC,EAAAF,QAAGG,aAAaJ,EAAuB,SAClEK,EAAgBC,OAAKJ,GAGvB,GAAAZ,IA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.ts","../src/inner.ts","../src/merge-package-json.ts","../src/commands/publish.ts","../src/commands/build.ts","../src/index.ts"],"sourcesContent":["import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport { filterPackagesFromDir } from '@pnpm/filter-workspace-packages'\nimport { program } from 'commander'\nimport { load } from 'js-yaml'\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 rootOption = program.getOptionValue('root')\n const root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n let notWorkspace = false\n let wd: string\n try {\n wd = getWorkspaceDir(root, 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 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, 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, root,\n value: {\n [wd]: JSON.parse(fs.readFileSync(path.resolve(wd, 'package.json'), 'utf-8'))\n }\n }\n}\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","import { type Options, pkger } from '@jiek/pkger'\nimport type { PackageJson } from '@npm/types'\nimport type { Manifest } from '@pnpm/workspace.pkgs-graph'\n\nexport function mergePackageJson(manifest: Manifest & {\n jiek?: Options\n exports?: unknown | unknown[]\n}, cwd: string) {\n const {\n jiek: { inputs: jiekInputs, cwd: _, ...jiek } = {}, exports\n } = manifest\n const inputs = jiekInputs ?? (\n Array.isArray(exports) ? exports : undefined\n )\n return {\n ...manifest,\n ...pkger({ inputs, cwd, ...jiek })\n } as PackageJson\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { bump, type BumperType } from '@jiek/utils/bumper'\nimport type { PackageJson } from '@npm/types'\nimport * as childProcess from 'child_process'\nimport { program } from 'commander'\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('--bumper <bumper>', 'bump version', 'patch')\n .action(async ({ bumper, ...options }: {\n root?: string\n filter?: string\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: [dir: string, PackageJson][] = []\n selectedProjectsGraphEntries\n .forEach(([dir, manifest]) => {\n mainfests.push([\n dir, mergePackageJson(manifest, dir)\n ])\n })\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, m] of mainfests) {\n const newVersion = bump(m.version, bumper)\n const newManifest = {\n ...m,\n version: newVersion\n }\n fs.renameSync(path.join(dir, 'package.json'), path.join(dir, 'package.json.bak'))\n fs.writeFileSync(path.join(dir, 'package.json'), JSON.stringify(newManifest, null, 2))\n console.log(newManifest)\n try {\n childProcess.execSync(['pnpm', 'publish', '--access', 'public', '--no-git-checks', ...passArgs].join(' '), {\n cwd: dir,\n stdio: 'inherit'\n })\n const oldPackageJson = JSON.parse(fs.readFileSync(path.join(dir, 'package.json.bak'), 'utf-8'))\n oldPackageJson.version = newVersion\n fs.writeFileSync(path.join(dir, 'package.json.bak'), JSON.stringify(oldPackageJson, null, 2))\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 * as childProcess from 'node:child_process'\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport { program } from 'commander'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\nimport { getSelectedProjectsGraph } from '../utils/filterSupport'\n\nconst FILE_TEMPLATE = (manifest: unknown) => `\nconst pkg = ${JSON.stringify(manifest, null, 2)}\nconst { jiek = {} } = pkg\nconst templateArg = jiek.templateArgFilePath\n ? require.resolve(jiek.templateArgFilePath)\n : {\n styled: jiek.styled\n }\nmodule.exports = require('${\n process.env.NODE_ENV === 'test'\n ? 'jiek/src/rollup/index.ts'\n : 'jiek/rollup'\n}').template(templateArg, pkg)\n`.trimStart()\n\nprogram\n .command('build')\n .action(async () => {\n actionRestore()\n const {\n wd, value = {}\n } = await getSelectedProjectsGraph() ?? {}\n\n if (Object.keys(value).length === 0) {\n throw new Error('no package found')\n }\n const jiekTempDir = (...paths: string[]) => path.resolve(wd, 'node_modules/.jiek', ...paths)\n if (!fs.existsSync(jiekTempDir())) fs.mkdirSync(jiekTempDir())\n\n const rollupBinaryPath = require.resolve('rollup')\n .replace(/dist\\/rollup.js$/, 'dist/bin/rollup')\n let i = 0\n for (const [dir, manifest] of Object.entries(value)) {\n const newManifest = mergePackageJson(manifest, dir)\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(newManifest))\n let prefix = ''\n if (process.env.NODE_ENV === 'test') {\n const registerPath = require.resolve('esbuild-register')\n const loaderPath = require.resolve('esbuild-register/loader')\n prefix = `node --import ${registerPath} -r ${loaderPath} `\n }\n // TODO replace with `spawn` to support watch mode\n childProcess.execSync(`${prefix}${rollupBinaryPath} -c ${configFile}`, {\n cwd: dir, stdio: 'inherit'\n })\n }\n\n actionDone()\n })\n","import './utils/filterSupport'\nimport './commands/publish'\nimport './commands/build'\n\nimport { program } from 'commander'\n\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst pkg = require('../package.json')\n\nprogram\n .version(pkg.version)\n .description(pkg.description)\n .option('--root <root>', 'root path')\n\nprogram.parse(process.argv)\n"],"names":["resolve","type","require","async","getSelectedProjectsGraph","filter","program","getOptionValue","rootOption","root","path","isAbsolute","process","cwd","wd","notWorkspace","getWorkspaceDir","e","message","pnpmWorkspaceFilePath","default","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","actionDone","actionRestore","Promise","r","mergePackageJson","jiek","inputs","jiekInputs","_","exports","Array","isArray","pkger","option","command","aliases","action","bumper","options","selectedProjectsGraphEntries","length","mainfests","forEach","dir","push","passArgs","m","newVersion","bump","version","newManifest","renameSync","join","writeFileSync","stringify","console","log","childProcess","execSync","stdio","oldPackageJson","unlinkSync","FILE_TEMPLATE","env","NODE_ENV","trimStart","commander","keys","jiekTempDir","paths","mkdirSync","rollupBinaryPath","replace","i","escapeManifestName","configFile","pkg","description","argv"],"mappings":"opCAQO,ICRHA,EDQOC,EAAO,GAElB,IACEC,QAAQF,QAAQ,mCACTC,EAAA,MACT,CAAQ,MAAc,CActBE,eAAsBC,IAChB,IAAAC,EAASC,EAAAA,QAAQC,eAAe,UAC9B,MAAAC,EAAaF,EAAAA,QAAQC,eAAe,QACpCE,EAAOD,EACTE,EAAAA,QAAKC,WAAWH,GACdA,EACAE,EAAAA,QAAKV,QAAQY,QAAQC,MAAOL,GAC9BI,QAAQC,MACZ,IACIC,EADAC,GAAe,EAEf,IACGD,EAAAE,EAAAA,gBAAgBP,EAAMR,SACpBgB,GAEP,KAAI,YAAaA,IAAmB,6BAAdA,EAAEC,QAIhB,MAAAD,EAHDH,EAAAL,EACUM,GAAA,CAInB,CACI,IAACA,GAAyB,SAATd,EAAiB,CACpC,MAAMkB,EAAwBT,EAAAU,QAAKpB,QAAQc,EAAI,uBACzCO,EAA2BC,EAAAF,QAAGG,aAAaJ,EAAuB,SAClEK,EAAgBC,OAAKJ,GAGvB,GAAAZ,IAASK,IAAOT,EACZ,MAAA,IAAIqB,MAAM,wDAGd,GAAAjB,IAASK,IAAOT,EAAQ,CAE1B,IAD2BiB,EAAGF,QAAAO,WAAWjB,EAAAA,QAAKV,QAAQS,EAAM,iBAEpD,MAAA,IAAIiB,MAAM,4DAEZ,MAAAE,EAAcC,KAAKC,MAAMR,EAAGF,QAAAG,aAAab,UAAKV,QAAQS,EAAM,gBAAiB,UAC/E,IAACmB,EAAYG,KACT,MAAA,IAAIL,MAAM,4DAElBrB,EAASuB,EAAY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AAA,IAAIzC,MAAM,oBAEZ,MAAAqE,EAAc,IAAIC,IAAoBtF,EAAAU,QAAKpB,QAAQc,EAAI,wBAAyBkF,GACjF1E,EAAAF,QAAGO,WAAWoE,MAAmBzE,UAAA2E,UAAUF,KAEhD,MAAMG,EAAmBhG,QAAQF,QAAQ,UACtCmG,QAAQ,mBAAoB,mBAC/B,IAAIC,EAAI,EACR,IAAA,MAAY9B,EAAKxB,KAAaN,OAAOC,QAAQF,GAAQ,CAC7C,MAAAsC,EAAc1B,EAAiBL,EAAUwB,GAEzC+B,EAAqBvD,EAASf,MAAMoE,QAAQ,MAAO,IAAIA,QAAQ,MAAO,KACtEG,EAAaP,EACjB,GAAGM,GAAsB,aAAaD,wBAExC9E,EAAAA,QAAG0D,cAAcsB,EAAYb,EAAcZ,IAC3C,IAAI1C,EAAS,GACT,GAAyB,SAAzBvB,QAAQ8E,IAAIC,SAAqB,CAG1BxD,EAAA,iBAFYjC,QAAQF,QAAQ,0BAClBE,QAAQF,QAAQ,6BAErC,CAEAoF,EAAaC,SAAS,GAAGlD,IAAS+D,QAAuBI,IAAc,CACrEzF,IAAKyD,EAAKgB,MAAO,WAErB,CAEWvC,GAAA,ICvDf,MAAMwD,EAAMrG,QAAQ,mBAGjB2F,EAAAvF,QAAAsE,QAAQ2B,EAAI3B,SACZ4B,YAAYD,EAAIC,aAChB5C,OAAO,gBAAiB,aAE3BtD,EAAAA,QAAQwB,MAAMlB,QAAQ6F"}
|
package/dist/rollup.esm.js
CHANGED
@@ -5,11 +5,11 @@ import autoprefixer from 'autoprefixer';
|
|
5
5
|
import { dts } from 'rollup-plugin-dts';
|
6
6
|
import esbuild from 'rollup-plugin-esbuild';
|
7
7
|
import postcss from 'rollup-plugin-postcss';
|
8
|
-
import { createGlobalsLinkage } from './
|
9
|
-
import skip from './
|
10
|
-
import { commonOutputOptions } from './
|
11
|
-
import externalResolver from './
|
12
|
-
import withMinify from './
|
8
|
+
import { createGlobalsLinkage } from './rollup/plugins/globals.esm.js';
|
9
|
+
import skip from './rollup/plugins/skip.esm.js';
|
10
|
+
import { commonOutputOptions } from './rollup/utils/commonOptions.esm.js';
|
11
|
+
import externalResolver from './rollup/utils/externalResolver.esm.js';
|
12
|
+
import withMinify from './rollup/utils/withMinify.esm.js';
|
13
13
|
|
14
14
|
const workspaceRoot = getWorkspaceDir();
|
15
15
|
function resolveWorkspacePath(p) {
|
package/dist/rollup.esm.min.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
import{resolve as e}from"node:path";import{getWorkspaceDir as r}from"@jiek/utils/getWorkspaceDir";import s from"@rollup/plugin-json";import t from"autoprefixer";import{dts as o}from"rollup-plugin-dts";import i from"rollup-plugin-esbuild";import n from"rollup-plugin-postcss";import{createGlobalsLinkage as p}from"./
|
1
|
+
import{resolve as e}from"node:path";import{getWorkspaceDir as r}from"@jiek/utils/getWorkspaceDir";import s from"@rollup/plugin-json";import t from"autoprefixer";import{dts as o}from"rollup-plugin-dts";import i from"rollup-plugin-esbuild";import n from"rollup-plugin-postcss";import{createGlobalsLinkage as p}from"./rollup/plugins/globals.esm.min.js";import l from"./rollup/plugins/skip.esm.min.js";import{commonOutputOptions as m}from"./rollup/utils/commonOptions.esm.min.js";import u from"./rollup/utils/externalResolver.esm.min.js";import a from"./rollup/utils/withMinify.esm.min.js";const c=r();const d=({styled:r=!1,plugins:{index:d=[],entry:f=[],dts:g=[]}={}}={},j)=>{if(!j.name)throw new Error("pkg.name is required");const x=j.name.replace(/[@|/-](\w)/g,((e,r)=>r.toUpperCase())),y=Object.fromEntries(Object.entries(j.exports??{}).filter((([e])=>!/\.(json|css|scss)$/.test(e))).filter((([,e])=>"object"==typeof e&&e["inner-src"]&&e.import)).map((([e,r])=>[e.replace(/^\.$/,"index").replace(/^\.\//,""),"string"==typeof r?r:r["inner-src"]]))),[$,b]=p(),v=u(),w=[s()];return[{input:y,output:[...a({...m,format:"esm",entryFileNames:"[name].esm.js",preserveModules:!0})],plugins:[w,$({external:v}),r&&l({patterns:[/\.s?css$/]}),i(),d]},...Object.entries(y).map((([e,s])=>{const o=x+("index"===e?"":e.replace(/[@|/-](\w)/g,((e,r)=>r.toUpperCase())));return{input:s,output:[...a({...m,name:o,format:"iife",entryFileNames:`${e}.iife.js`}),...a({...m,name:o,format:"umd",entryFileNames:`${e}.umd.js`})],plugins:[w,b,r&&n({plugins:[t],minimize:!0,sourceMap:!0,extract:`${e}.css`}),i(),f],external:v}})),{input:y,output:[{dir:"dist",entryFileNames:({name:e})=>`${e.replace(/^src\//,"")}.esm.d.ts`,preserveModules:!0},{dir:"dist"}],plugins:[w,r&&l({patterns:[/\.s?css$/]}),o({tsconfig:(O="tsconfig.dts.json",e(c,O))}),{name:"rollup-plugin-declare-module-replacer",generateBundle(e,r){for(const e of Object.values(r))"code"in e&&(e.code=e.code.replace(/declare module ['|"]\..*['|"]/g,`declare module '${j.name}'`))}},g],external:v}];var O};export{d as template};
|
2
2
|
//# sourceMappingURL=rollup.esm.min.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"rollup.esm.min.js","sources":["../src/rollup/index.ts"],"sourcesContent":["import { resolve } from 'node:path'\n\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport json from '@rollup/plugin-json'\nimport autoprefixer from 'autoprefixer'\nimport type { InputPluginOption, RollupOptions } from 'rollup'\nimport { dts } from 'rollup-plugin-dts'\nimport esbuild from 'rollup-plugin-esbuild'\nimport postcss from 'rollup-plugin-postcss'\n\nimport { createGlobalsLinkage } from './plugins/globals'\nimport skip from './plugins/skip'\nimport { commonOutputOptions } from './utils/commonOptions'\nimport externalResolver from './utils/externalResolver'\nimport withMinify from './utils/withMinify'\n\nconst workspaceRoot = getWorkspaceDir()\nfunction resolveWorkspacePath(p: string) {\n return resolve(workspaceRoot, p)\n}\n\nexport const template = (\n {\n styled = false,\n plugins: {\n index: indexPlugins = [],\n entry: entryPlugins = [],\n dts: dtsPlugins = []\n } = {}\n }: {\n /**\n * include styles files\n */\n styled?: boolean\n plugins?: {\n index?: InputPluginOption\n entry?: InputPluginOption\n dts?: InputPluginOption\n }\n } = {},\n pkg: {\n name?: string\n exports?: Record<string, string | {\n import: string\n 'inner-src': string\n }>\n }\n) => {\n if (!pkg.name) {\n throw new Error('pkg.name is required')\n }\n const namePrefix = pkg\n .name\n .replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\n const exportsEntries = Object.fromEntries(\n Object.entries(pkg.exports ?? {})\n // filter static files\n .filter(([key]) => !/\\.(json|css|scss)$/.test(key))\n // filter no `inner-src` or `import` field entries\n .filter(([, value]) => typeof value === 'object' && value['inner-src'] && value['import'])\n .map(([key, value]) => [\n key\n .replace(/^\\.$/, 'index')\n .replace(/^\\.\\//, ''),\n typeof value === 'string' ? value : value['inner-src']\n ])\n )\n\n const [globalsRegister, globalsOutput] = createGlobalsLinkage()\n const external = externalResolver()\n\n const commonPlugins = [\n json()\n ]\n return [\n {\n input: exportsEntries,\n output: [\n ...withMinify({\n ...commonOutputOptions,\n format: 'esm',\n entryFileNames: '[name].esm.js',\n preserveModules: true\n })\n ],\n plugins: [\n commonPlugins,\n globalsRegister({ external }),\n styled && skip({ patterns: [/\\.s?css$/] }),\n esbuild(),\n indexPlugins\n ]\n },\n ...Object.entries(exportsEntries).map(([name, input]) => {\n const outputName = namePrefix + (\n name === 'index' ? '' : (\n name.replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\n )\n )\n return {\n input: input,\n output: [\n ...withMinify({\n ...commonOutputOptions,\n name: outputName,\n format: 'iife',\n entryFileNames: `${name}.iife.js`\n }),\n ...withMinify({\n ...commonOutputOptions,\n name: outputName,\n format: 'umd',\n entryFileNames: `${name}.umd.js`\n })\n ],\n plugins: [\n commonPlugins,\n globalsOutput,\n styled && postcss({\n plugins: [autoprefixer],\n minimize: true,\n sourceMap: true,\n extract: `${name}.css`\n }),\n esbuild(),\n entryPlugins\n ],\n external\n }\n }),\n {\n input: exportsEntries,\n output: [\n {\n dir: 'dist',\n entryFileNames: ({ name }) => `${name.replace(/^src\\//, '')}.esm.d.ts`,\n preserveModules: true\n },\n {\n dir: 'dist'\n }\n ],\n plugins: [\n commonPlugins,\n styled && skip({ patterns: [/\\.s?css$/] }),\n dts({ tsconfig: resolveWorkspacePath('tsconfig.dts.json') }),\n {\n name: 'rollup-plugin-declare-module-replacer',\n /**\n * replace relative path `declare module './xxx'` to `declare module '{{package name}}'`\n * in output file generated\n */\n generateBundle(_, bundle) {\n for (const file of Object.values(bundle)) {\n if (!('code' in file)) continue\n\n file.code = file.code.replace(\n /declare module ['|\"]\\..*['|\"]/g,\n `declare module '${pkg.name}'`\n )\n }\n }\n },\n dtsPlugins\n ],\n external\n }\n ] as RollupOptions[]\n}\n"],"names":["workspaceRoot","getWorkspaceDir","template","styled","plugins","index","indexPlugins","entry","entryPlugins","dts","dtsPlugins","pkg","name","Error","namePrefix","replace","_","$1","toUpperCase","exportsEntries","Object","fromEntries","entries","exports","filter","key","test","value","map","globalsRegister","globalsOutput","createGlobalsLinkage","external","externalResolver","commonPlugins","json","input","output","withMinify","commonOutputOptions","format","entryFileNames","preserveModules","skip","patterns","esbuild","outputName","postcss","autoprefixer","minimize","sourceMap","extract","dir","tsconfig","p","resolve","generateBundle","bundle","file","values","code"],"mappings":"
|
1
|
+
{"version":3,"file":"rollup.esm.min.js","sources":["../src/rollup/index.ts"],"sourcesContent":["import { resolve } from 'node:path'\n\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport json from '@rollup/plugin-json'\nimport autoprefixer from 'autoprefixer'\nimport type { InputPluginOption, RollupOptions } from 'rollup'\nimport { dts } from 'rollup-plugin-dts'\nimport esbuild from 'rollup-plugin-esbuild'\nimport postcss from 'rollup-plugin-postcss'\n\nimport { createGlobalsLinkage } from './plugins/globals'\nimport skip from './plugins/skip'\nimport { commonOutputOptions } from './utils/commonOptions'\nimport externalResolver from './utils/externalResolver'\nimport withMinify from './utils/withMinify'\n\nconst workspaceRoot = getWorkspaceDir()\nfunction resolveWorkspacePath(p: string) {\n return resolve(workspaceRoot, p)\n}\n\nexport const template = (\n {\n styled = false,\n plugins: {\n index: indexPlugins = [],\n entry: entryPlugins = [],\n dts: dtsPlugins = []\n } = {}\n }: {\n /**\n * include styles files\n */\n styled?: boolean\n plugins?: {\n index?: InputPluginOption\n entry?: InputPluginOption\n dts?: InputPluginOption\n }\n } = {},\n pkg: {\n name?: string\n exports?: Record<string, string | {\n import: string\n 'inner-src': string\n }>\n }\n) => {\n if (!pkg.name) {\n throw new Error('pkg.name is required')\n }\n const namePrefix = pkg\n .name\n .replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\n const exportsEntries = Object.fromEntries(\n Object.entries(pkg.exports ?? {})\n // filter static files\n .filter(([key]) => !/\\.(json|css|scss)$/.test(key))\n // filter no `inner-src` or `import` field entries\n .filter(([, value]) => typeof value === 'object' && value['inner-src'] && value['import'])\n .map(([key, value]) => [\n key\n .replace(/^\\.$/, 'index')\n .replace(/^\\.\\//, ''),\n typeof value === 'string' ? value : value['inner-src']\n ])\n )\n\n const [globalsRegister, globalsOutput] = createGlobalsLinkage()\n const external = externalResolver()\n\n const commonPlugins = [\n json()\n ]\n return [\n {\n input: exportsEntries,\n output: [\n ...withMinify({\n ...commonOutputOptions,\n format: 'esm',\n entryFileNames: '[name].esm.js',\n preserveModules: true\n })\n ],\n plugins: [\n commonPlugins,\n globalsRegister({ external }),\n styled && skip({ patterns: [/\\.s?css$/] }),\n esbuild(),\n indexPlugins\n ]\n },\n ...Object.entries(exportsEntries).map(([name, input]) => {\n const outputName = namePrefix + (\n name === 'index' ? '' : (\n name.replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\n )\n )\n return {\n input: input,\n output: [\n ...withMinify({\n ...commonOutputOptions,\n name: outputName,\n format: 'iife',\n entryFileNames: `${name}.iife.js`\n }),\n ...withMinify({\n ...commonOutputOptions,\n name: outputName,\n format: 'umd',\n entryFileNames: `${name}.umd.js`\n })\n ],\n plugins: [\n commonPlugins,\n globalsOutput,\n styled && postcss({\n plugins: [autoprefixer],\n minimize: true,\n sourceMap: true,\n extract: `${name}.css`\n }),\n esbuild(),\n entryPlugins\n ],\n external\n }\n }),\n {\n input: exportsEntries,\n output: [\n {\n dir: 'dist',\n entryFileNames: ({ name }) => `${name.replace(/^src\\//, '')}.esm.d.ts`,\n preserveModules: true\n },\n {\n dir: 'dist'\n }\n ],\n plugins: [\n commonPlugins,\n styled && skip({ patterns: [/\\.s?css$/] }),\n dts({ tsconfig: resolveWorkspacePath('tsconfig.dts.json') }),\n {\n name: 'rollup-plugin-declare-module-replacer',\n /**\n * replace relative path `declare module './xxx'` to `declare module '{{package name}}'`\n * in output file generated\n */\n generateBundle(_, bundle) {\n for (const file of Object.values(bundle)) {\n if (!('code' in file)) continue\n\n file.code = file.code.replace(\n /declare module ['|\"]\\..*['|\"]/g,\n `declare module '${pkg.name}'`\n )\n }\n }\n },\n dtsPlugins\n ],\n external\n }\n ] as RollupOptions[]\n}\n"],"names":["workspaceRoot","getWorkspaceDir","template","styled","plugins","index","indexPlugins","entry","entryPlugins","dts","dtsPlugins","pkg","name","Error","namePrefix","replace","_","$1","toUpperCase","exportsEntries","Object","fromEntries","entries","exports","filter","key","test","value","map","globalsRegister","globalsOutput","createGlobalsLinkage","external","externalResolver","commonPlugins","json","input","output","withMinify","commonOutputOptions","format","entryFileNames","preserveModules","skip","patterns","esbuild","outputName","postcss","autoprefixer","minimize","sourceMap","extract","dir","tsconfig","p","resolve","generateBundle","bundle","file","values","code"],"mappings":"0kBAgBA,MAAMA,EAAgBC,IAKf,MAAMC,EAAW,EAEpBC,UAAS,EACTC,SACEC,MAAOC,EAAe,GACtBC,MAAOC,EAAe,GACtBC,IAAKC,EAAa,IAChB,CAAC,GAWH,CAAA,EACJC,KAQI,IAACA,EAAIC,KACD,MAAA,IAAIC,MAAM,wBAEZ,MAAAC,EAAaH,EAChBC,KACAG,QAAQ,eAAe,CAACC,EAAGC,IAAO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AK,CAAEC,SAAU,CAAC,cAC5BnC,EAAI,CAAE4C,UAhIgBC,EAgIe,oBA/HpCC,EAAQvD,EAAesD,MAgIxB,CACE1C,KAAM,wCAKN,cAAA4C,CAAexC,EAAGyC,GAChB,IAAA,MAAWC,KAAQtC,OAAOuC,OAAOF,GACzB,SAAUC,IAEXA,EAAAE,KAAOF,EAAKE,KAAK7C,QACpB,iCACA,mBAAmBJ,EAAIC,SAG7B,GAEFF,GAEFsB,aApJN,IAA8BsB,CAsJ5B"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"filterSupport.esm.js","sources":["../../src/utils/filterSupport.ts"],"sourcesContent":["import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport { filterPackagesFromDir } from '@pnpm/filter-workspace-packages'\nimport { program } from 'commander'\nimport { load } from 'js-yaml'\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 rootOption = program.getOptionValue('root')\n const root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n let notWorkspace = false\n let wd: string\n try {\n wd = getWorkspaceDir(root, 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 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, 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, root,\n value: {\n [wd]: JSON.parse(fs.readFileSync(path.resolve(wd, 'package.json'), 'utf-8'))\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;AAQO,IAAI,IAAO,GAAA,GAAA;AAElB,IAAI;AACF,EAAA,OAAA,CAAQ,QAAQ,iCAAiC,CAAA,CAAA;AACjD,EAAO,IAAA,GAAA,MAAA,CAAA;AACT,CAAQ,CAAA,MAAA;AAAc,CAAA;AACtB,IAAI,SAAS,EAAI,EAAA;AACf,EACG,OAAA,CAAA,MAAA,CAAO,yBAAyB,iBAAiB,CAAA,CAAA;AACtD,CAAA;AAUA,eAAsB,wBAAmD,GAAA;AACvE,EAAI,IAAA,MAAA,GAAS,OAAQ,CAAA,cAAA,CAAe,QAAQ,CAAA,CAAA;AAC5C,EAAM,MAAA,UAAA,GAAa,OAAQ,CAAA,cAAA,CAAe,MAAM,CAAA,CAAA;AAChD,EAAA,MAAM,IAAO,GAAA,UAAA,GACT,IAAK,CAAA,UAAA,CAAW,UAAU,CACxB,GAAA,UAAA,GACA,IAAK,CAAA,OAA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sources":["../../src/utils/filterSupport.ts"],"sourcesContent":["import fs from 'node:fs'\nimport path from 'node:path'\n\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport { filterPackagesFromDir } from '@pnpm/filter-workspace-packages'\nimport { program } from 'commander'\nimport { load } from 'js-yaml'\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 rootOption = program.getOptionValue('root')\n const root = rootOption\n ? path.isAbsolute(rootOption)\n ? rootOption\n : path.resolve(process.cwd(), rootOption)\n : process.cwd()\n let notWorkspace = false\n let wd: string\n try {\n wd = getWorkspaceDir(root, 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 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, 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, root,\n value: {\n [wd]: JSON.parse(fs.readFileSync(path.resolve(wd, 'package.json'), 'utf-8'))\n }\n }\n}\n"],"names":["type","require","resolve","async","getSelectedProjectsGraph","filter","program","getOptionValue","rootOption","root","path","isAbsolute","process","cwd","wd","notWorkspace","getWorkspaceDir","e","message","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"],"mappings":"yPAQO,IAAIA,EAAO,GAElB,IACEC,QAAQC,QAAQ,mCACTF,EAAA,MACT,CAAQ,MAAc,CActBG,eAAsBC,IAChB,IAAAC,EAASC,EAAQC,eAAe,UAC9B,MAAAC,EAAaF,EAAQC,eAAe,QACpCE,EAAOD,EACTE,EAAKC,WAAWH,GACdA,EACAE,EAAKR,QAAQU,QAAQC,MAAOL,GAC9BI,QAAQC,MACZ,IACIC,EADAC,GAAe,EAEf,IACGD,EAAAE,EAAgBP,EAAMT,SACpBiB,GAEP,KAAI,YAAaA,IAAmB,6BAAdA,EAAEC,QAIhB,MAAAD,EAHDH,EAAAL,EACUM,GAAA,CAInB,CACI,IAACA,GAAyB,SAATf,EAAiB,CACpC,MAAMmB,EAAwBT,EAAKR,QAAQY,EAAI,uBACzCM,EAA2BC,EAAGC,aAAaH,EAAuB,SAClEI,EAAgBC,EAAKJ,GAGvB,GAAAX,IAASK,IAAOT,EACZ,MAAA,IAAIoB,MAAM,wDAGd,GAAAhB,IAASK,IAAOT,EAAQ,CAE1B,IAD2BgB,EAAGK,WAAWhB,EAAKR,QAAQO,EAAM,iBAEpD,MAAA,IAAIgB,MAAM,4DAEZ,MAAAE,EAAcC,KAAKC,MAAMR,EAAGC,aAAaZ,EAAKR,QAAQO,EAAM,gBAAiB,UAC/E,IAACkB,EAAYG,KACT,MAAA,IAAIL,MAAM,4DAElBpB,EAASsB,EAAYG,IACvB,CACA,MAAMC,sBAAEA,SAAgCC,EAAsBlB,EAAI,CAAC,CACjET,OAAQA,GAAU,GAClB4B,oBAAoB,IAClB,CACFC,OAAQzB,EACR0B,aAAcrB,EACdsB,SAAUb,EAAcc,WAEnB,MAAA,CACLvB,KAAIL,OACJ6B,MAAOC,OAAOC,QAAQT,GACnBU,QAAO,CAACC,GAAMC,EAAKL,MACdI,EAAAC,GAAOL,EAAMM,QAAQC,SAClBH,IACN,IAET,CACO,MAAA,CACL5B,KAAIL,OACJ6B,MAAO,CACLxB,CAACA,GAAKc,KAAKC,MAAMR,EAAGC,aAAaZ,EAAKR,QAAQY,EAAI,gBAAiB,WAGzE,CA9Ea,KAATd,GAECM,EAAAwC,OAAO,wBAAyB"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "jiek",
|
3
|
-
"version": "0.1.12-alpha.
|
3
|
+
"version": "0.1.12-alpha.3",
|
4
4
|
"description": "YiJie's personal kits.",
|
5
5
|
"bin": {
|
6
6
|
"jiek": "bin/jiek.js",
|
@@ -12,12 +12,17 @@
|
|
12
12
|
"rollup/index.ts"
|
13
13
|
]
|
14
14
|
},
|
15
|
+
"files": [
|
16
|
+
"dist"
|
17
|
+
],
|
15
18
|
"dependencies": {
|
16
19
|
"@rollup/plugin-json": "^6.0.1",
|
17
20
|
"@rollup/plugin-terser": "^0.4.4",
|
18
21
|
"autoprefixer": "^10.4.16",
|
19
22
|
"commander": "^12.0.0",
|
23
|
+
"detect-indent": "^7.0.1",
|
20
24
|
"js-yaml": "^4.1.0",
|
25
|
+
"jsonc-parser": "^3.2.1",
|
21
26
|
"rollup": "^4.1.5",
|
22
27
|
"rollup-plugin-copy": "^3.5.0",
|
23
28
|
"rollup-plugin-dts": "^6.1.0",
|
@@ -31,19 +36,21 @@
|
|
31
36
|
},
|
32
37
|
"devDependencies": {
|
33
38
|
"@npm/types": "^1.0.2",
|
34
|
-
"@pnpm/workspace.pkgs-graph": "^2.0.15",
|
35
39
|
"@pnpm/filter-workspace-packages": "^7.2.13",
|
40
|
+
"@pnpm/workspace.pkgs-graph": "^2.0.15",
|
36
41
|
"@types/js-yaml": "^4.0.9",
|
37
42
|
"esbuild-register": "^3.5.0"
|
38
43
|
},
|
39
|
-
"
|
40
|
-
"dist"
|
41
|
-
|
44
|
+
"publishConfig": {
|
45
|
+
"jsdelivr": "./dist/index.umd.min.js"
|
46
|
+
},
|
47
|
+
"scripts": {
|
48
|
+
"build": "jiek-dev build"
|
49
|
+
},
|
42
50
|
"types": "./dist/index.d.ts",
|
43
51
|
"main": "./dist/index.umd.js",
|
44
52
|
"module": "./dist/index.esm.js",
|
45
53
|
"unpkg": "./dist/index.umd.min.js",
|
46
|
-
"jsdelivr": "./dist/index.umd.min.js",
|
47
54
|
"browser": "./dist/index.umd.min.js",
|
48
55
|
"typesVersions": {
|
49
56
|
"<5.0": {
|
@@ -68,8 +75,5 @@
|
|
68
75
|
"require": "./dist/rollup.umd.js",
|
69
76
|
"inner-src": "./src/rollup/index.ts"
|
70
77
|
}
|
71
|
-
},
|
72
|
-
"scripts": {
|
73
|
-
"build": "jiek-dev build"
|
74
78
|
}
|
75
79
|
}
|
package/dist/package.json.esm.js
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
var name = "jiek";
|
2
|
-
var version = "0.1.12";
|
3
|
-
var description = "YiJie's personal kits.";
|
4
|
-
var bin = {
|
5
|
-
jiek: "bin/jiek.js",
|
6
|
-
"jiek-dev": "bin/jiek-dev.js"
|
7
|
-
};
|
8
|
-
var jiek = {
|
9
|
-
inputs: [
|
10
|
-
"index.ts",
|
11
|
-
"rollup/index.ts"
|
12
|
-
]
|
13
|
-
};
|
14
|
-
var scripts = {
|
15
|
-
build: "jiek-dev build"
|
16
|
-
};
|
17
|
-
var dependencies = {
|
18
|
-
"@jiek/pkger": "workspace:^*",
|
19
|
-
"@jiek/utils": "workspace:^*",
|
20
|
-
"@rollup/plugin-json": "^6.0.1",
|
21
|
-
"@rollup/plugin-terser": "^0.4.4",
|
22
|
-
autoprefixer: "^10.4.16",
|
23
|
-
commander: "^12.0.0",
|
24
|
-
"js-yaml": "^4.1.0",
|
25
|
-
rollup: "^4.1.5",
|
26
|
-
"rollup-plugin-copy": "^3.5.0",
|
27
|
-
"rollup-plugin-dts": "^6.1.0",
|
28
|
-
"rollup-plugin-esbuild": "^6.1.0",
|
29
|
-
"rollup-plugin-postcss": "^4.0.2"
|
30
|
-
};
|
31
|
-
var optionalDependencies = {
|
32
|
-
"@pnpm/filter-workspace-packages": "^7.2.13"
|
33
|
-
};
|
34
|
-
var devDependencies = {
|
35
|
-
"@npm/types": "^1.0.2",
|
36
|
-
"@pnpm/workspace.pkgs-graph": "^2.0.15",
|
37
|
-
"@pnpm/filter-workspace-packages": "^7.2.13",
|
38
|
-
"@types/js-yaml": "^4.0.9",
|
39
|
-
"esbuild-register": "^3.5.0"
|
40
|
-
};
|
41
|
-
var files = [
|
42
|
-
"dist"
|
43
|
-
];
|
44
|
-
var pkg = {
|
45
|
-
name: name,
|
46
|
-
version: version,
|
47
|
-
description: description,
|
48
|
-
bin: bin,
|
49
|
-
jiek: jiek,
|
50
|
-
scripts: scripts,
|
51
|
-
dependencies: dependencies,
|
52
|
-
optionalDependencies: optionalDependencies,
|
53
|
-
devDependencies: devDependencies,
|
54
|
-
files: files
|
55
|
-
};
|
56
|
-
|
57
|
-
export { bin, pkg as default, dependencies, description, devDependencies, files, jiek, name, optionalDependencies, scripts, version };
|
58
|
-
//# sourceMappingURL=package.json.esm.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"package.json.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
@@ -1,2 +0,0 @@
|
|
1
|
-
var e="jiek",p="0.1.12",i="YiJie's personal kits.",s={jiek:"bin/jiek.js","jiek-dev":"bin/jiek-dev.js"},l={inputs:["index.ts","rollup/index.ts"]},r={build:"jiek-dev build"},n={"@jiek/pkger":"workspace:^*","@jiek/utils":"workspace:^*","@rollup/plugin-json":"^6.0.1","@rollup/plugin-terser":"^0.4.4",autoprefixer:"^10.4.16",commander:"^12.0.0","js-yaml":"^4.1.0",rollup:"^4.1.5","rollup-plugin-copy":"^3.5.0","rollup-plugin-dts":"^6.1.0","rollup-plugin-esbuild":"^6.1.0","rollup-plugin-postcss":"^4.0.2"},o={"@pnpm/filter-workspace-packages":"^7.2.13"},u={"@npm/types":"^1.0.2","@pnpm/workspace.pkgs-graph":"^2.0.15","@pnpm/filter-workspace-packages":"^7.2.13","@types/js-yaml":"^4.0.9","esbuild-register":"^3.5.0"},a=["dist"],t={name:e,version:p,description:i,bin:s,jiek:l,scripts:r,dependencies:n,optionalDependencies:o,devDependencies:u,files:a};export{s as bin,t as default,n as dependencies,i as description,u as devDependencies,a as files,l as jiek,e as name,o as optionalDependencies,r as scripts,p as version};
|
2
|
-
//# sourceMappingURL=package.json.esm.min.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"package.json.esm.min.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
@@ -1,53 +0,0 @@
|
|
1
|
-
import * as childProcess from 'node:child_process';
|
2
|
-
import fs from 'node:fs';
|
3
|
-
import path from 'node:path';
|
4
|
-
import { program } from 'commander';
|
5
|
-
import { actionRestore, actionDone } from '../inner.esm.js';
|
6
|
-
import { mergePackageJson } from '../merge-package-json.esm.js';
|
7
|
-
import { getSelectedProjectsGraph } from '../utils/filterSupport.esm.js';
|
8
|
-
|
9
|
-
const FILE_TEMPLATE = (manifest) => `
|
10
|
-
const pkg = ${JSON.stringify(manifest, null, 2)}
|
11
|
-
const { jiek = {} } = pkg
|
12
|
-
const templateArg = jiek.templateArgFilePath
|
13
|
-
? require.resolve(jiek.templateArgFilePath)
|
14
|
-
: {
|
15
|
-
styled: jiek.styled
|
16
|
-
}
|
17
|
-
module.exports = require('${process.env.NODE_ENV === "test" ? "jiek/src/rollup/index.ts" : "jiek/rollup"}').template(templateArg, pkg)
|
18
|
-
`.trimStart();
|
19
|
-
program.command("build").action(async () => {
|
20
|
-
actionRestore();
|
21
|
-
const {
|
22
|
-
wd,
|
23
|
-
value = {}
|
24
|
-
} = await getSelectedProjectsGraph() ?? {};
|
25
|
-
if (Object.keys(value).length === 0) {
|
26
|
-
throw new Error("no package found");
|
27
|
-
}
|
28
|
-
const jiekTempDir = (...paths) => path.resolve(wd, "node_modules/.jiek", ...paths);
|
29
|
-
if (!fs.existsSync(jiekTempDir()))
|
30
|
-
fs.mkdirSync(jiekTempDir());
|
31
|
-
const rollupBinaryPath = require.resolve("rollup").replace(/dist\/rollup.js$/, "dist/bin/rollup");
|
32
|
-
let i = 0;
|
33
|
-
for (const [dir, manifest] of Object.entries(value)) {
|
34
|
-
const newManifest = mergePackageJson(manifest, dir);
|
35
|
-
const escapeManifestName = manifest.name?.replace(/^@/g, "").replace(/\//g, "+");
|
36
|
-
const configFile = jiekTempDir(
|
37
|
-
`${escapeManifestName ?? `anonymous-${i++}`}.rollup.config.js`
|
38
|
-
);
|
39
|
-
fs.writeFileSync(configFile, FILE_TEMPLATE(newManifest));
|
40
|
-
let prefix = "";
|
41
|
-
if (process.env.NODE_ENV === "test") {
|
42
|
-
const registerPath = require.resolve("esbuild-register");
|
43
|
-
const loaderPath = require.resolve("esbuild-register/loader");
|
44
|
-
prefix = `node --import ${registerPath} -r ${loaderPath} `;
|
45
|
-
}
|
46
|
-
childProcess.execSync(`${prefix}${rollupBinaryPath} -c ${configFile}`, {
|
47
|
-
cwd: dir,
|
48
|
-
stdio: "inherit"
|
49
|
-
});
|
50
|
-
}
|
51
|
-
actionDone();
|
52
|
-
});
|
53
|
-
//# sourceMappingURL=build.esm.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"build.esm.js","sources":["../../../src/commands/build.ts"],"sourcesContent":["import * as childProcess from 'node:child_process'\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport { program } from 'commander'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\nimport { getSelectedProjectsGraph } from '../utils/filterSupport'\n\nconst FILE_TEMPLATE = (manifest: unknown) => `\nconst pkg = ${JSON.stringify(manifest, null, 2)}\nconst { jiek = {} } = pkg\nconst templateArg = jiek.templateArgFilePath\n ? require.resolve(jiek.templateArgFilePath)\n : {\n styled: jiek.styled\n }\nmodule.exports = require('${\n process.env.NODE_ENV === 'test'\n ? 'jiek/src/rollup/index.ts'\n : 'jiek/rollup'\n}').template(templateArg, pkg)\n`.trimStart()\n\nprogram\n .command('build')\n .action(async () => {\n actionRestore()\n const {\n wd, value = {}\n } = await getSelectedProjectsGraph() ?? {}\n\n if (Object.keys(value).length === 0) {\n throw new Error('no package found')\n }\n const jiekTempDir = (...paths: string[]) => path.resolve(wd, 'node_modules/.jiek', ...paths)\n if (!fs.existsSync(jiekTempDir())) fs.mkdirSync(jiekTempDir())\n\n const rollupBinaryPath = require.resolve('rollup')\n .replace(/dist\\/rollup.js$/, 'dist/bin/rollup')\n let i = 0\n for (const [dir, manifest] of Object.entries(value)) {\n const newManifest = mergePackageJson(manifest, dir)\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(newManifest))\n let prefix = ''\n if (process.env.NODE_ENV === 'test') {\n const registerPath = require.resolve('esbuild-register')\n const loaderPath = require.resolve('esbuild-register/loader')\n prefix = `node --import ${registerPath} -r ${loaderPath} `\n }\n // TODO replace with `spawn` to support watch mode\n childProcess.execSync(`${prefix}${rollupBinaryPath} -c ${configFile}`, {\n cwd: dir, stdio: 'inherit'\n })\n }\n\n actionDone()\n })\n"],"names":[],"mappings":";;;;;;;;AAUA,MAAM,aAAA,GAAgB,CAAC,QAAsB,KAAA,CAAA;AAAA,YAAA,EAC/B,IAAK,CAAA,SAAA,CAAU,QAAU,EAAA,IAAA,EAAM,CAAC,CAAC,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAA,EAQ7C,OAAQ,CAAA,GAAA,CAAI,QAAa,KAAA,MAAA,GACrB,6BACA,aACN,CAAA;AAAA,CAAA,CACE,SAAU,EAAA,CAAA;AAEZ,OAAA,CACG,OAAQ,CAAA,OAAO,CACf,CAAA,MAAA,CAAO,YAAY;AAClB,EAAc,aAAA,EAAA,CAAA;AACd,EAAM,MAAA;AAAA,IACJ,EAAA;AAAA,IAAI,QAAQ,EAAC;AAAA,GACX,GAAA,MAAM,wBAAyB,EAAA,IAAK,EAAC,CAAA;AAEzC,EAAA,IAAI,MAAO,CAAA,IAAA,CAAK,KAAK,CAAA,CAAE,WAAW,CAAG,EAAA;AACnC,IAAM,MAAA,IAAI,MAAM,kBAAkB,CAAA,CAAA;AAAA,GACpC;AACA,EAAM,MAAA,WAAA,GAAc,IAAI,KAAoB,KAAA,IAAA,CAAK,QAAQ,EAAI,EAAA,oBAAA,EAAsB,GAAG,KAAK,CAAA,CAAA;AAC3F,EAAA,IAAI,CAAC,EAAA,CAAG,UAAW,CAAA,WAAA,EAAa,CAAA;AAAG,IAAG,EAAA,CAAA,SAAA,CAAU,aAAa,CAAA,CAAA;AAE7D,EAAA,MAAM,mBAAmB,OAAQ,CAAA,OAAA,CAAQ,QAAQ,CAC9C,CAAA,OAAA,CAAQ,oBAAoB,iBAAiB,CAAA,CAAA;AAChD,EAAA,IAAI,CAAI,GAAA,CAAA,CAAA;AACR,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program as t}from"commander";import{actionRestore as i,actionDone as s}from"../inner.esm.min.js";import{mergePackageJson as n}from"../merge-package-json.esm.min.js";import{getSelectedProjectsGraph as l}from"../utils/filterSupport.esm.min.js";const m=e=>`\nconst pkg = ${JSON.stringify(e,null,2)}\nconst { jiek = {} } = pkg\nconst templateArg = jiek.templateArgFilePath\n ? require.resolve(jiek.templateArgFilePath)\n : {\n styled: jiek.styled\n }\nmodule.exports = require('${"test"===process.env.NODE_ENV?"jiek/src/rollup/index.ts":"jiek/rollup"}').template(templateArg, pkg)\n`.trimStart();t.command("build").action((async()=>{i();const{wd:t,value:p={}}=await l()??{};if(0===Object.keys(p).length)throw new Error("no package found");const c=(...e)=>o.resolve(t,"node_modules/.jiek",...e);r.existsSync(c())||r.mkdirSync(c());const a=require.resolve("rollup").replace(/dist\/rollup.js$/,"dist/bin/rollup");let d=0;for(const[o,t]of Object.entries(p)){const i=n(t,o),s=t.name?.replace(/^@/g,"").replace(/\//g,"+"),l=c(`${s??"anonymous-"+d++}.rollup.config.js`);r.writeFileSync(l,m(i));let p="";if("test"===process.env.NODE_ENV){p=`node --import ${require.resolve("esbuild-register")} -r ${require.resolve("esbuild-register/loader")} `}e.execSync(`${p}${a} -c ${l}`,{cwd:o,stdio:"inherit"})}s()}));
|
2
|
-
//# sourceMappingURL=build.esm.min.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"build.esm.min.js","sources":["../../../src/commands/build.ts"],"sourcesContent":["import * as childProcess from 'node:child_process'\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport { program } from 'commander'\n\nimport { actionDone, actionRestore } from '../inner'\nimport { mergePackageJson } from '../merge-package-json'\nimport { getSelectedProjectsGraph } from '../utils/filterSupport'\n\nconst FILE_TEMPLATE = (manifest: unknown) => `\nconst pkg = ${JSON.stringify(manifest, null, 2)}\nconst { jiek = {} } = pkg\nconst templateArg = jiek.templateArgFilePath\n ? require.resolve(jiek.templateArgFilePath)\n : {\n styled: jiek.styled\n }\nmodule.exports = require('${\n process.env.NODE_ENV === 'test'\n ? 'jiek/src/rollup/index.ts'\n : 'jiek/rollup'\n}').template(templateArg, pkg)\n`.trimStart()\n\nprogram\n .command('build')\n .action(async () => {\n actionRestore()\n const {\n wd, value = {}\n } = await getSelectedProjectsGraph() ?? {}\n\n if (Object.keys(value).length === 0) {\n throw new Error('no package found')\n }\n const jiekTempDir = (...paths: string[]) => path.resolve(wd, 'node_modules/.jiek', ...paths)\n if (!fs.existsSync(jiekTempDir())) fs.mkdirSync(jiekTempDir())\n\n const rollupBinaryPath = require.resolve('rollup')\n .replace(/dist\\/rollup.js$/, 'dist/bin/rollup')\n let i = 0\n for (const [dir, manifest] of Object.entries(value)) {\n const newManifest = mergePackageJson(manifest, dir)\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(newManifest))\n let prefix = ''\n if (process.env.NODE_ENV === 'test') {\n const registerPath = require.resolve('esbuild-register')\n const loaderPath = require.resolve('esbuild-register/loader')\n prefix = `node --import ${registerPath} -r ${loaderPath} `\n }\n // TODO replace with `spawn` to support watch mode\n childProcess.execSync(`${prefix}${rollupBinaryPath} -c ${configFile}`, {\n cwd: dir, stdio: 'inherit'\n })\n }\n\n actionDone()\n })\n"],"names":["FILE_TEMPLATE","manifest","JSON","stringify","process","env","NODE_ENV","trimStart","program","command","action","async","actionRestore","wd","value","getSelectedProjectsGraph","Object","keys","length","Error","jiekTempDir","paths","path","resolve","fs","existsSync","mkdirSync","rollupBinaryPath","require","replace","i","dir","entries","newManifest","mergePackageJson","escapeManifestName","name","configFile","writeFileSync","prefix","childProcess","execSync","cwd","stdio","actionDone"],"mappings":"8UAUA,MAAMA,EAAiBC,GAAsB,iBAC/BC,KAAKC,UAAUF,EAAU,KAAM,8LAQlB,SAAzBG,QAAQC,IAAIC,SACR,2BACA,+CAEJC,YAEFC,EACGC,QAAQ,SACRC,QAAOC,UACQC,IACR,MAAAC,GACJA,EAAAC,MAAIA,EAAQ,CAAC,SACLC,KAA8B,GAExC,GAAkC,IAA9BC,OAAOC,KAAKH,GAAOI,OACf,MAAA,IAAIC,MAAM,oBAEZ,MAAAC,EAAc,IAAIC,IAAoBC,EAAKC,QAAQV,EAAI,wBAAyBQ,GACjFG,EAAGC,WAAWL,MAAmBI,EAAAE,UAAUN,KAEhD,MAAMO,EAAmBC,QAAQL,QAAQ,UACtCM,QAAQ,mBAAoB,mBAC/B,IAAIC,EAAI,EACR,IAAA,MAAYC,EAAK9B,KAAae,OAAOgB,QAAQlB,GAAQ,CAC7C,MAAAmB,EAAcC,EAAiBjC,EAAU8B,GAEzCI,EAAqBlC,EAASmC,MAAMP,QAAQ,MAAO,IAAIA,QAAQ,MAAO,KACtEQ,EAAajB,EACjB,GAAGe,GAAsB,aAAaL,wBAExCN,EAAGc,cAAcD,EAAYrC,EAAciC,IAC3C,IAAIM,EAAS,GACT,GAAyB,SAAzBnC,QAAQC,IAAIC,SAAqB,CAG1BiC,EAAA,iBAFYX,QAAQL,QAAQ,0BAClBK,QAAQL,QAAQ,6BAErC,CAEAiB,EAAaC,SAAS,GAAGF,IAASZ,QAAuBU,IAAc,CACrEK,IAAKX,EAAKY,MAAO,WAErB,CAEWC,GAAA"}
|