{"version":3,"file":"index.cjs","sources":["../src/helpers/append-bundle-file-extension.function.ts","../src/helpers/defaults.const.ts","../src/helpers/auto-bin.class.options.ts","../src/helpers/auto-copy-license.class.options.ts","../src/helpers/auto-entry.class.options.ts","../src/helpers/auto-export-static.class.options.ts","../src/helpers/auto-metadata.class.options.ts","../src/plugins/autolib.plugin.options.ts","../src/helpers/enter-path.function.ts","../src/helpers/exists-directory.function.ts","../src/helpers/offset-relative-path-posix.function.ts","../src/helpers/strip-file-extension.function.ts","../src/helpers/collect-export-entries.function.ts","../src/helpers/make-javascript-files-executable.function.options.ts","../src/helpers/make-javascript-files-executable.function.ts","../src/helpers/normalize-package-name.function.ts","../src/helpers/auto-bin.class.ts","../src/helpers/auto-copy-license.class.ts","../src/helpers/create-path-record-from-paths.function.ts","../src/helpers/retarget-package-json-path.function.ts","../src/helpers/auto-entry.class.ts","../src/helpers/collect-export-map.function.ts","../src/helpers/copy-all-into.function.ts","../src/helpers/auto-export-static.class.ts","../src/helpers/clone-json-serializable.function.ts","../src/helpers/exists-file.function.ts","../src/helpers/exists-symlink.function.ts","../src/helpers/prepared-update.type.ts","../src/helpers/auto-metadata.class.ts","../src/helpers/auto-peer.class.ts","../src/helpers/auto-reorder.class.options.ts","../src/helpers/auto-reorder.class.ts","../src/plugins/autolib.plugin.ts","../src/plugins/update-package-json.plugin.ts"],"sourcesContent":["import type { ModuleFormat } from 'rollup';\n\nexport interface GetBundledFileExtensionOptions {\n\tformat: ModuleFormat;\n\t/**\n\t * @defaultValue 'commonjs'\n\t */\n\tpackageType?: 'module' | 'commonjs' | undefined;\n}\n\nexport type JsExtensionStubs = 'js' | 'cjs' | 'mjs' | `${string}.js`;\nexport type JsExtensions = `.${JsExtensionStubs}`;\n/**\n * Default rollup behavior.\n *\n */\nexport const getBundledFileExtension = (options: GetBundledFileExtensionOptions): JsExtensions => {\n\tconst packageType = options.packageType ?? 'commonjs';\n\tswitch (options.format) {\n\t\tcase 'es':\n\t\tcase 'esm': {\n\t\t\treturn packageType === 'module' ? '.js' : '.mjs';\n\t\t}\n\t\tcase 'cjs': {\n\t\t\treturn packageType === 'commonjs' ? '.js' : '.cjs';\n\t\t}\n\t\tdefault: {\n\t\t\treturn `.${options.format}.js`;\n\t\t}\n\t}\n};\n","import type { LibraryFormats } from 'vite';\n\nexport const DEFAULT_OUT_DIR = './dist';\nexport const DEFAULT_ENTRY = './src/index.ts';\nexport const DEFAULT_EXPORT_FORMATS: LibraryFormats[] = ['es', 'cjs'];\nexport const DEFAULT_BUILD_TARGET = 'es2020';\n","import type { Defined } from '@alexaegis/common';\nimport { normalizeCwdOption, type CwdOption } from '@alexaegis/fs';\nimport { normalizeLoggerOption, type LoggerOption } from '@alexaegis/logging';\nimport { DEFAULT_SRC_DIR } from '../plugins/autolib.plugin.options.js';\nimport { ALL_NPM_HOOKS } from './auto-bin.class.js';\nimport { DEFAULT_OUT_DIR } from './defaults.const.js';\n\nexport const DEFAULT_BIN_DIR = 'bin';\nexport const DEFAULT_BINSHIM_DIR = 'shims';\n\nexport interface AutoBinOptions extends CwdOption, LoggerOption {\n\t/**\n\t * @defaultValue 'src'\n\t */\n\tsrcDir?: string | undefined;\n\n\t/**\n\t * Every script directly in this folder will be treated as a bin\n\t *\n\t * Relative to `srcDir`.\n\t *\n\t * @defaultValue 'bin'\n\t */\n\tbinDir?: string | undefined;\n\n\t/**\n\t * Relative to the package.json, usually './dist'\n\t *\n\t * used to mark the built scripts as executable\n\t *\n\t * @defaultValue 'dist'\n\t */\n\toutDir?: string | undefined;\n\n\t/**\n\t * A directory where shims for the built bins would be placed\n\t * All these scripts do is to import the yet-to-be-built binary so\n\t * package managers hava something to symlink to before it's built.\n\t *\n\t * ! This folder has to be ignored by typescript as it contains broken\n\t * ! imports before the package is built\n\t *\n\t * @defaultValue 'shims'\n\t */\n\tshimDir?: string | undefined;\n\n\t/**\n\t * The hooks this function will search for\n\t * @defaultValue ALL_NPM_HOOKS\n\t */\n\tenabledHooks?: string[] | undefined;\n}\n\nexport const normalizeAutoBinOptions = (options: AutoBinOptions): Defined<AutoBinOptions> => {\n\treturn {\n\t\t...normalizeLoggerOption(options),\n\t\t...normalizeCwdOption(options),\n\t\tsrcDir: options.srcDir ?? DEFAULT_SRC_DIR,\n\t\toutDir: options.outDir ?? DEFAULT_OUT_DIR,\n\t\tbinDir: options.binDir ?? DEFAULT_BIN_DIR,\n\t\tshimDir: options.shimDir ?? DEFAULT_BINSHIM_DIR,\n\t\tenabledHooks: options.enabledHooks ?? ALL_NPM_HOOKS,\n\t};\n};\n","import { normalizeCwdOption, type CwdOption } from '@alexaegis/fs';\nimport { normalizeLoggerOption, type LoggerOption } from '@alexaegis/logging';\nimport { DEFAULT_OUT_DIR } from '../index.js';\n\nexport interface AutoCopyLicenseOptions extends LoggerOption, CwdOption {\n\t/**\n\t * relative to cwd, this is where copied files will end up\n\t * @defaultValue 'dist'\n\t */\n\toutDir?: string;\n}\n\nexport const normalizeAutoCopyLicenseOptions = (\n\toptions?: AutoCopyLicenseOptions\n): Required<AutoCopyLicenseOptions> => {\n\treturn {\n\t\t...normalizeCwdOption(options),\n\t\t...normalizeLoggerOption(options),\n\t\toutDir: options?.outDir ?? DEFAULT_OUT_DIR,\n\t};\n};\n","import { normalizeCwdOption, type CwdOption } from '@alexaegis/fs';\nimport { normalizeLoggerOption, type LoggerOption } from '@alexaegis/logging';\nimport type { LibraryFormats } from 'vite';\nimport { DEFAULT_EXPORT_FORMATS, DEFAULT_OUT_DIR } from '../index.js';\nimport { DEFAULT_SRC_DIR } from '../plugins/autolib.plugin.options.js';\n\nexport const DEFAULT_ENTRY_DIR = './';\n\nexport interface AutoEntryOptions extends CwdOption, LoggerOption {\n\t/**\n\t * @defaultValue 'src'\n\t */\n\tsourceDirectory?: string;\n\n\t/**\n\t * @defaultValue '[\"es\", \"cjs\"]'\n\t */\n\tformats?: LibraryFormats[];\n\n\t/**\n\t * @defaultValue 'dist'\n\t */\n\toutDir?: string;\n\n\t/**\n\t * The files to treat as entry points to be exported from relative from\n\t * the `srcDir` directory.\n\t * It's usually `.` meaning files directly in `src` are considered the\n\t * entry points of the library\n\t *\n\t * @defaultValue '.'\n\t */\n\tentryDir?: string;\n}\n\nexport const normalizeAutoEntryOptions = (\n\toptions: AutoEntryOptions\n): Required<AutoEntryOptions> => {\n\treturn {\n\t\t...normalizeCwdOption(options),\n\t\t...normalizeLoggerOption(options),\n\t\tentryDir: options.entryDir ?? DEFAULT_ENTRY_DIR,\n\t\tformats: options.formats ?? DEFAULT_EXPORT_FORMATS,\n\t\toutDir: options.outDir ?? DEFAULT_OUT_DIR,\n\t\tsourceDirectory: options.sourceDirectory ?? DEFAULT_SRC_DIR,\n\t};\n};\n","import { normalizeCwdOption, type CwdOption } from '@alexaegis/fs';\nimport { normalizeLoggerOption, type LoggerOption } from '@alexaegis/logging';\nimport { DEFAULT_OUT_DIR } from '../index.js';\n\nexport const DEFAULT_STATIC_EXPORT_GLOBS = ['readme.md', 'static/**/*', 'export/**/*'];\n\nexport interface AutoExportStaticOptions extends LoggerOption, CwdOption {\n\t/**\n\t * relative to cwd, this is where copied files will end up\n\t * @defaultValue 'dist'\n\t */\n\toutDir?: string;\n\n\t/**\n\t * Relative to cwd, a folder whats content will be simply copied to\n\t * `outDir` and made available using simple, additional export statements.\n\t * Make sure their names don't overlap with other exports!\n\t *\n\t * @defaultValue [\"readme.md\", \"static/\\*\\*\", \"export/**\"]\n\t */\n\tstaticExportGlobs?: string[];\n}\n\nexport const normalizeAutoExportStaticOptions = (\n\toptions: AutoExportStaticOptions\n): Required<AutoExportStaticOptions> => {\n\treturn {\n\t\t...normalizeCwdOption(options),\n\t\t...normalizeLoggerOption(options),\n\t\toutDir: options.outDir ?? DEFAULT_OUT_DIR,\n\t\tstaticExportGlobs: options.staticExportGlobs ?? DEFAULT_STATIC_EXPORT_GLOBS,\n\t};\n};\n","import { normalizeLoggerOption, type LoggerOption } from '@alexaegis/logging';\n\nexport interface AutoMetadataOptions extends LoggerOption {\n\t/**\n\t * A list of packageJson keys to read to autofill in built artifacts\n\t *\n\t * Keys already present in the package's packageJson file will take\n\t * precendence if they are objects or arrays, otherwise overwritten\n\t *\n\t * @defaultValue DEFAULT_AUTO_METADATA_KEYS_FROM_WORKSPACE - [\"license\", \"author\", \"homepage\", \"bugs\", \"keywords\", \"config\", \"engines\"]\n\t */\n\tkeysFromWorkspace?: string[];\n\n\t/**\n\t * Keys that you must define yourself. This plugin can't figure them out\n\t * for you, but it can add their keys as empty values into the source\n\t * packageJson. When one is missing or empty, the build is aborted!\n\t *\n\t * @defaultValue DEFAULT_AUTO_METADATA_MANDATORY_KEYS - [\"name\", \"description\", \"version\"]\n\t */\n\tmandatoryKeys?: string[];\n\n\t/**\n\t * A set of key value pairs that will only be used as packageJson values\n\t * when not found in the workspace packageJson\n\t *\n\t * @defaultValue {}\n\t */\n\tfallbackEntries?: Record<string, string>;\n\n\t/**\n\t * A set of key value pairs that will always be used and overwrite\n\t * everything else\n\t *\n\t * @defaultValue {}\n\t */\n\toverrideEntries?: Record<string, string>;\n}\n\nexport const DEFAULT_AUTO_METADATA_KEYS_FROM_WORKSPACE = [\n\t'license',\n\t'author',\n\t'homepage',\n\t'bugs',\n\t'keywords',\n\t'config',\n\t'engines',\n\t'repository',\n];\n\nexport const DEFAULT_AUTO_METADATA_MANDATORY_KEYS = ['name', 'description', 'version'];\n\nexport type NormalizedAutoMetadataOptions = Required<AutoMetadataOptions>;\n\nexport const normalizeAutoMetadataOptions = (\n\toptions?: AutoMetadataOptions\n): NormalizedAutoMetadataOptions => {\n\treturn {\n\t\t...normalizeLoggerOption(options),\n\t\tkeysFromWorkspace: options?.keysFromWorkspace ?? DEFAULT_AUTO_METADATA_KEYS_FROM_WORKSPACE,\n\t\tmandatoryKeys: options?.mandatoryKeys ?? DEFAULT_AUTO_METADATA_MANDATORY_KEYS,\n\t\tfallbackEntries: options?.fallbackEntries ?? {},\n\t\toverrideEntries: options?.overrideEntries ?? {},\n\t};\n};\n","import type { ObjectKeyOrder } from '@alexaegis/common';\nimport {\n\tnormalizeCwdOption,\n\tnormalizeWriteJsonOptions,\n\ttype CwdOption,\n\ttype WriteJsonOptions,\n} from '@alexaegis/fs';\nimport { normalizeLoggerOption, type LoggerOption } from '@alexaegis/logging';\nimport { DEFAULT_PACKAGE_JSON_SORTING_PREFERENCE } from '@alexaegis/workspace-tools';\nimport { DEFAULT_BINSHIM_DIR, DEFAULT_BIN_DIR } from '../helpers/auto-bin.class.options.js';\nimport {\n\tnormalizeAutoCopyLicenseOptions,\n\ttype AutoCopyLicenseOptions,\n} from '../helpers/auto-copy-license.class.options.js';\nimport { DEFAULT_ENTRY_DIR } from '../helpers/auto-entry.class.options.js';\nimport { DEFAULT_STATIC_EXPORT_GLOBS } from '../helpers/auto-export-static.class.options.js';\nimport {\n\tnormalizeAutoMetadataOptions,\n\ttype AutoMetadataOptions,\n} from '../helpers/auto-metadata.class.options.js';\n\nexport const DEFAULT_SRC_DIR = 'src';\n\nexport enum PackageJsonKind {\n\t/**\n\t * Used in the repository as the source packageJson\n\t */\n\tDEVELOPMENT = 'development',\n\t/**\n\t * The packageJson that will be in the distributed package\n\t */\n\tDISTRIBUTION = 'distribution',\n}\n\nexport enum PackageJsonExportTarget {\n\t/**\n\t * This targets the source files.\n\t *\n\t * For example the `development` packageJson targets the local entry points\n\t * for types\n\t */\n\tSOURCE = 'source',\n\t/**\n\t * This targets the directory where compiled files end up in. Wherever\n\t * `outDir` points to.\n\t *\n\t * For example both the `development` and `distribution` packageJson files\n\t * target this for the actual imports.\n\t */\n\tDIST = 'dist',\n\t/**\n\t * The shim folder is used for local bins\n\t *\n\t * For example the `development` packageJson files bin entries target the\n\t * shim directory. So pnpm can link them event before the package is built.\n\t */\n\tSHIM = 'shim',\n}\n\nexport interface AutolibPluginOptions extends WriteJsonOptions, CwdOption, LoggerOption {\n\t/**\n\t * source root, relative to cwd\n\t * @defaultValue 'src'\n\t */\n\tsrc?: string;\n\n\t/**\n\t * packageJson to modify and put in the artifact, relative to `cwd`\n\t * @defaultValue './package.json'\n\t */\n\tsourcePackageJson?: string;\n\n\t/**\n\t * Generates exports entries form rollup inputs, from a directory relative\n\t * to `srcDir`\n\t *\n\t * If autoExport is disabled, the plugin expects you to either set\n\t * `build.lib.entry` yourself or have a `src/index.ts` file as the entry\n\t * point\n\t *\n\t * @defaultValue [\".\"]\n\t */\n\tautoEntryDir?: string | false;\n\n\t/**\n\t * Automatically export the content of a directory as is\n\t *\n\t * @defaultValue [\"export/**\", \"static/**\"]\n\t */\n\tautoExportStaticGlobs?: string[] | false;\n\n\t/**\n\t * Automatically order the keys in the packageJson files.\n\t *\n\t * @defaultValue DEFAULT_PACKAGE_JSON_ORDER_PREFERENCE\n\t */\n\tautoOrderPackageJson?: ObjectKeyOrder | false;\n\n\t/**\n\t * Generates bin entries from files under `srcDir` + `autoBinDirectory`\n\t * It also treats all files named as npm hooks as npm hooks, prefixing them\n\t * and adding them as hooks for the npm artifact\n\t *\n\t * For example a file called `postinstall.ts` in a package called\n\t * `@org/name`, it will generate an npm script entry as such:\n\t * `\"postinstall\": \"bin/postinstall.js\"`. The hook is still treated as a\n\t * `bin` so you can invoke it directly. To avoid name collisions, all\n\t * \"hookbins\" are prefixed with the normalized packagename like so:\n\t * `org-name-postinstall`\n\t *\n\t * @defaultValue [\"./bin/*.ts\"]\n\t */\n\tautoBin?: AutoLibraryAutoBinOptions | false;\n\n\t/**\n\t * Fills out packageJson fields of the distributed packageJson based on\n\t * either manually defined key-value pairs or a set of keys that then will\n\t * be read from the workspace packageJson file. Or both, in which case if a\n\t * key is defined in both the manual takes precedence.\n\t */\n\tautoMetadata?: AutoMetadataOptions | false;\n\n\t/**\n\t * Automatically copies the license file to the outDir so it can be part\n\t * of the distributed package. It uses the license file you defined in the\n\t * root of your project. Or if you wish to override it, place one into\n\t * the packages folder.\n\t *\n\t * @defaultValue true\n\t */\n\tautoCopyLicense?: AutoCopyLicenseOptions | false;\n\n\t/**\n\t * Removes duplicated dependency and peerDependency entries leaving only\n\t * the peerDependencies behind.\n\t *\n\t * The point of this is to let peerDependencies install locally too by\n\t * defining them twice, once as a peerDependency, and once as a normal\n\t * dependency. This step will remove the one that was meant to only be\n\t * present locally.\n\t *\n\t * @defaultValue true\n\t */\n\tautoPeer?: boolean;\n}\n\nexport const normalizeAutolibOptions = (\n\toptions?: AutolibPluginOptions\n): Required<AutolibPluginOptions> => {\n\treturn {\n\t\t...normalizeCwdOption(options),\n\t\t...normalizeLoggerOption(options),\n\t\t...normalizeWriteJsonOptions(options),\n\t\tautoPrettier: options?.autoPrettier ?? true,\n\t\tautoBin: options?.autoBin ? false : normalizeAutoBinOption(options?.autoBin),\n\t\tautoMetadata:\n\t\t\toptions?.autoMetadata === false\n\t\t\t\t? false\n\t\t\t\t: normalizeAutoMetadataOptions(options?.autoMetadata),\n\t\tautoCopyLicense:\n\t\t\toptions?.autoCopyLicense === false\n\t\t\t\t? false\n\t\t\t\t: normalizeAutoCopyLicenseOptions(options?.autoCopyLicense),\n\t\tautoPeer: options?.autoPeer ?? true,\n\t\tautoEntryDir:\n\t\t\toptions?.autoEntryDir === false ? false : options?.autoEntryDir ?? DEFAULT_ENTRY_DIR,\n\t\tautoExportStaticGlobs:\n\t\t\toptions?.autoExportStaticGlobs === false\n\t\t\t\t? false\n\t\t\t\t: options?.autoExportStaticGlobs ?? DEFAULT_STATIC_EXPORT_GLOBS,\n\t\tautoOrderPackageJson:\n\t\t\toptions?.autoOrderPackageJson === false\n\t\t\t\t? false\n\t\t\t\t: options?.autoOrderPackageJson ?? DEFAULT_PACKAGE_JSON_SORTING_PREFERENCE,\n\t\tsourcePackageJson: options?.sourcePackageJson ?? 'package.json',\n\t\tsrc: options?.src ?? DEFAULT_SRC_DIR,\n\t};\n};\n\nexport interface AutoLibraryAutoBinOptions {\n\tbinDir?: string;\n\tshimDir?: string;\n}\n\nexport const normalizeAutoBinOption = (\n\tautoBin?: AutoLibraryAutoBinOptions | false\n): Required<AutoLibraryAutoBinOptions> | false => {\n\treturn autoBin === false\n\t\t? false\n\t\t: {\n\t\t\t\tbinDir: autoBin?.binDir ?? DEFAULT_BIN_DIR,\n\t\t\t\tshimDir: autoBin?.shimDir ?? DEFAULT_BINSHIM_DIR,\n\t\t  };\n};\n","import { posix } from 'node:path';\n\n/**\n * Moves one directory in into a path. It strips one directory off from\n * the beginning. if it started with a `./` it keeps it.\n * @example 'foo/bar/file' => 'bar/file'\n */\nexport const enterPathPosix = (path: string, enterCount = 1): string => {\n\tconst explodedPath = posix.normalize(path).split(posix.sep);\n\tconst directoryCount = explodedPath.length - 1;\n\texplodedPath.splice(0, Math.min(enterCount, directoryCount));\n\tconst prefix = path.startsWith('./') ? './' : '';\n\treturn prefix + posix.join(...explodedPath);\n};\n","import { statSync } from 'node:fs';\n\nexport const existsDirectory = (path: string): boolean =>\n\tstatSync(path, { throwIfNoEntry: false })?.isDirectory() ?? false;\n","import { join, sep } from 'node:path/posix';\n\n/**\n * A regular posix join, but adds a `./` at the beginning\n */\nexport const offsetRelativePathPosix = (offsetPath: string, path: string): string => {\n\tconst joined = join(offsetPath, path);\n\treturn joined === '.' ? joined : `.${sep}${joined}`;\n};\n","import { extname } from 'node:path';\n\nexport const stripFileExtension = (name: string): string =>\n\tname.replace(new RegExp(`${extname(name)}$`), '');\n","import { readdir } from 'node:fs/promises';\n\nimport { basename, join } from 'node:path';\nimport { enterPathPosix } from './enter-path.function.js';\nimport { existsDirectory } from './exists-directory.function.js';\nimport { offsetRelativePathPosix } from './offset-relative-path-posix.function.js';\nimport { stripFileExtension } from './strip-file-extension.function.js';\n\nexport const isTestFileName = (fileName: string): boolean =>\n\tfileName.includes('.spec.') || fileName.includes('.test.');\n\nexport const collectImmediate = async (\n\tpath: string = process.cwd(),\n\tkind?: 'file' | 'directory'\n): Promise<string[]> => {\n\tif (existsDirectory(path)) {\n\t\tconst entries = await readdir(path, { withFileTypes: true });\n\t\treturn entries\n\t\t\t.filter((entry) =>\n\t\t\t\tkind\n\t\t\t\t\t? (kind === 'file' && entry.isFile()) ||\n\t\t\t\t\t  (kind === 'directory' && entry.isDirectory())\n\t\t\t\t\t: true\n\t\t\t)\n\t\t\t.map((entry) => entry.name)\n\t\t\t.filter((fileName) => !isTestFileName(fileName));\n\t} else {\n\t\treturn [];\n\t}\n};\n\n/**\n * @param rootPath path entry will be relative to this\n * @param exportPath path from which files are collected\n */\nexport const collectFileNamePathEntries = async (\n\trootPath: string,\n\texportPath = '.'\n): Promise<Record<string, string>> => {\n\tconst collectPath = join(rootPath, exportPath);\n\tconst immediateFileNames = await collectImmediate(collectPath, 'file');\n\n\treturn immediateFileNames.reduce<Record<string, string>>((accumulator, next) => {\n\t\tconst fileName = basename(next);\n\t\tconst namestub = stripFileExtension(next);\n\t\taccumulator[namestub] = join(exportPath, fileName);\n\t\treturn accumulator;\n\t}, {});\n};\n\nexport const offsetPathArray = (\n\tpathArray: string[],\n\toffsetPath: string,\n\tskipOffset?: string[]\n): string[] => {\n\treturn pathArray.map((path) =>\n\t\tskipOffset?.includes(path) ? path : offsetRelativePathPosix(offsetPath, path)\n\t);\n};\n\nexport const offsetPathRecordValues = (\n\tpathRecord: Record<string, string>,\n\toffsetPath: string,\n\tenterCount = 0,\n\tskipOffset: string[] = []\n): Record<string, string> => {\n\treturn Object.entries(pathRecord).reduce<Record<string, string>>((result, [key, path]) => {\n\t\tif (path) {\n\t\t\tconst enteredPath = enterPathPosix(path, enterCount);\n\t\t\tresult[key] = skipOffset.includes(path)\n\t\t\t\t? enteredPath\n\t\t\t\t: offsetRelativePathPosix(offsetPath, enteredPath);\n\t\t}\n\t\treturn result;\n\t}, {});\n};\n","import { normalizeCwdOption, type CwdOption } from '@alexaegis/fs';\nimport { normalizeLoggerOption, type LoggerOption } from '@alexaegis/logging';\nimport type { InternalModuleFormat } from 'rollup';\n\nexport interface MakeJavascriptFilesExecutableOptions extends CwdOption, LoggerOption {\n\tformat: InternalModuleFormat;\n\tpackageJsonType: 'module' | 'commonjs';\n}\n\nexport type NormalizedMakeJavascriptFilesExecutableOptions =\n\tRequired<MakeJavascriptFilesExecutableOptions>;\n\nexport const normalizeMakeJavascriptFilesExecutableOptions = (\n\toptions: MakeJavascriptFilesExecutableOptions\n): NormalizedMakeJavascriptFilesExecutableOptions => {\n\treturn {\n\t\t...normalizeCwdOption(options),\n\t\t...normalizeLoggerOption(options),\n\t\tformat: options.format,\n\t\tpackageJsonType: options.packageJsonType,\n\t};\n};\n","import { turnIntoExecutable } from '@alexaegis/fs';\nimport { globby } from 'globby';\nimport { getBundledFileExtension } from './append-bundle-file-extension.function.js';\nimport {\n\tnormalizeMakeJavascriptFilesExecutableOptions,\n\ttype MakeJavascriptFilesExecutableOptions,\n} from './make-javascript-files-executable.function.options.js';\n\nexport const makeJavascriptFilesExecutable = async (\n\tpath: string | string[],\n\trawOptions: MakeJavascriptFilesExecutableOptions\n): Promise<void> => {\n\tconst options = normalizeMakeJavascriptFilesExecutableOptions(rawOptions);\n\tconst dirtectoryContent = await globby(path, { cwd: options.cwd });\n\tconst executables = dirtectoryContent.filter((bin) =>\n\t\tbin.endsWith(\n\t\t\tgetBundledFileExtension({\n\t\t\t\tformat: options.format,\n\t\t\t\tpackageType: options.packageJsonType,\n\t\t\t})\n\t\t)\n\t);\n\tawait Promise.all(executables.map((executable) => turnIntoExecutable(executable, options)));\n};\n","/**\n * Takes out the @ in front of a packageName and replaces / with a -\n */\nexport const normalizePackageName = (packageName: string | undefined): string => {\n\treturn packageName?.replace(/^@/, '')?.replace('/', '-') ?? '';\n};\n","import { getPrettierFormatter, toAbsolute } from '@alexaegis/fs';\nimport { getWorkspaceRoot, type PackageJson } from '@alexaegis/workspace-tools';\n\nimport { existsSync } from 'node:fs';\nimport { mkdir, readFile, rename, rm, symlink, writeFile } from 'node:fs/promises';\nimport { dirname, join, posix, relative } from 'node:path';\nimport type { InternalModuleFormat } from 'rollup';\nimport type { UserConfig } from 'vite';\nimport { PackageJsonKind } from '../plugins/autolib.plugin.options.js';\nimport { getBundledFileExtension } from './append-bundle-file-extension.function.js';\n\nimport type { Defined } from '@alexaegis/common';\nimport { normalizeAutoBinOptions, type AutoBinOptions } from './auto-bin.class.options.js';\nimport { collectFileNamePathEntries } from './collect-export-entries.function.js';\nimport { enterPathPosix } from './enter-path.function.js';\nimport { makeJavascriptFilesExecutable } from './make-javascript-files-executable.function.js';\nimport { normalizePackageName } from './normalize-package-name.function.js';\nimport type { PreparedBuildUpdate } from './prepared-build-update.type.js';\nimport { stripFileExtension } from './strip-file-extension.function.js';\n\nexport const NPM_INSTALL_HOOKS = [\n\t'preinstall',\n\t'install',\n\t'postinstall',\n\t'prepublish',\n\t'preprepare',\n\t'prepare',\n\t'postprepare',\n];\n\n/**\n * From https://docs.npmjs.com/cli/v8/using-npm/scripts\n * And anything that start pre- and post- that also matches a user defined\n * script (prebuild and postbuild works if 'build' exists)\n */\nexport const ALL_NPM_HOOKS = [\n\t...NPM_INSTALL_HOOKS,\n\t'prepare',\n\t'prepack',\n\t'postpack',\n\t'prepublishOnly',\n\t'publish',\n\t'postpublish',\n\t'prerestart',\n\t'restart',\n\t'postrestart',\n];\n\nexport const ALL_ROLLUP_MODULE_FORMATS: readonly InternalModuleFormat[] = [\n\t'es',\n\t'cjs',\n\t'amd',\n\t'umd',\n\t'iife',\n\t'system',\n] as const;\n\nexport interface BinPaths {\n\tsrcPath: string;\n\tshimPaths: Record<InternalModuleFormat, string>;\n\toutPath: Record<InternalModuleFormat, string>;\n\toutToOutPath: Record<InternalModuleFormat, string>;\n}\n\nexport class AutoBin implements PreparedBuildUpdate {\n\tprivate options: Defined<AutoBinOptions>;\n\n\tprivate entryMap: Record<string, string> = {};\n\n\tprivate markComment = ' # autogenerated';\n\tprivate outDirAbs: string;\n\tprivate shimDirAbs: string;\n\tprivate outBinDirAbs: string;\n\tprivate packageType: NonNullable<PackageJson['type']> = 'commonjs';\n\n\tprivate pathMap: Record<string, BinPaths> = {};\n\tprivate oldBins: Record<string, string> | undefined;\n\n\tconstructor(options: AutoBinOptions) {\n\t\tthis.options = normalizeAutoBinOptions(options);\n\n\t\tthis.outDirAbs = toAbsolute(this.options.outDir, this.options);\n\t\tthis.shimDirAbs = join(this.options.cwd, this.options.shimDir);\n\t\tthis.outBinDirAbs = join(this.outDirAbs, this.options.binDir);\n\t}\n\n\t/**\n\t * The keys in this entry has to be keyed with the entire extensionless path\n\t * of each bin. example: \"bin/foo\": \"bin/foo.ts\"\n\t */\n\tgetViteConfigUpdates(): UserConfig {\n\t\treturn { build: { lib: { entry: this.entryMap } } };\n\t}\n\n\tasync preUpdate(packageJson: PackageJson): Promise<void> {\n\t\tthis.oldBins = packageJson.bin;\n\t\tthis.packageType = packageJson.type ?? 'commonjs';\n\n\t\t// Making sure removed bins and scripts will be dropped at the end\n\t\tpackageJson.bin = undefined;\n\t\tfor (const script in packageJson.scripts) {\n\t\t\tif (packageJson.scripts[script]?.endsWith(this.markComment)) {\n\t\t\t\tpackageJson.scripts[script] = undefined;\n\t\t\t}\n\t\t}\n\n\t\t// paths here are from cwd poointing to the source\n\t\tconst directBinPaths = await collectFileNamePathEntries(\n\t\t\tthis.options.srcDir,\n\t\t\tthis.options.binDir\n\t\t);\n\n\t\tfor (const [bin, binPath] of Object.entries(directBinPaths)) {\n\t\t\tconst source = join(this.options.srcDir, binPath);\n\t\t\tconst out = this.getAllExtensionVariantsOfPath(join(this.options.outDir, binPath));\n\t\t\tthis.pathMap[bin] = {\n\t\t\t\tsrcPath: source,\n\t\t\t\toutPath: out,\n\t\t\t\toutToOutPath: this.getAllExtensionVariantsOfPath(binPath),\n\n\t\t\t\tshimPaths: this.getAllExtensionVariantsOfPath(\n\t\t\t\t\tjoin(this.options.shimDir, enterPathPosix(binPath, 1))\n\t\t\t\t),\n\t\t\t};\n\n\t\t\tthis.entryMap[stripFileExtension(binPath)] = source;\n\t\t}\n\t}\n\n\tprivate getAllExtensionVariantsOfPath(path: string): Record<InternalModuleFormat, string> {\n\t\tconst extensionless = stripFileExtension(path);\n\n\t\treturn ALL_ROLLUP_MODULE_FORMATS.reduce<Record<string, string>>((acc, format) => {\n\t\t\tacc[format] =\n\t\t\t\textensionless +\n\t\t\t\tgetBundledFileExtension({\n\t\t\t\t\tformat,\n\t\t\t\t\tpackageType: this.packageType,\n\t\t\t\t});\n\t\t\treturn acc;\n\t\t}, {});\n\t}\n\n\t/**\n\t * for module based packages, bins are modules too and the adjust path\n\t * step only acts for the 'es' format\n\t */\n\tasync adjustPaths(\n\t\tpackageJson: PackageJson,\n\t\tpackageJsonKind: PackageJsonKind,\n\t\tformat: InternalModuleFormat\n\t): Promise<PackageJson | undefined> {\n\t\tif (\n\t\t\t(this.packageType === 'module' && format === 'es') ||\n\t\t\t(this.packageType === 'commonjs' && format !== 'es')\n\t\t) {\n\t\t\tconst packageName = normalizePackageName(packageJson.name);\n\n\t\t\tawait this.ensureEsmBinEntriesRenamed(this.packageType);\n\n\t\t\tif (packageJsonKind === PackageJsonKind.DEVELOPMENT) {\n\t\t\t\tawait this.createShims(\n\t\t\t\t\tObject.values(this.pathMap).map((pathKinds) => pathKinds.shimPaths[format]),\n\t\t\t\t\tformat\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tawait makeJavascriptFilesExecutable(\n\t\t\t\tObject.values(this.pathMap).flatMap((pathKinds) => [\n\t\t\t\t\tpathKinds.outPath[format],\n\t\t\t\t\tpathKinds.shimPaths[format],\n\t\t\t\t]),\n\t\t\t\t{\n\t\t\t\t\tcwd: this.options.cwd,\n\t\t\t\t\tlogger: this.options.logger,\n\t\t\t\t\tformat,\n\t\t\t\t\tpackageJsonType: this.packageType,\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tawait this.preLink(\n\t\t\t\tObject.fromEntries(\n\t\t\t\t\tObject.entries(this.pathMap).map(([binName, pathKinds]) => [\n\t\t\t\t\t\tbinName,\n\t\t\t\t\t\tpathKinds.outPath[format],\n\t\t\t\t\t])\n\t\t\t\t),\n\t\t\t\tpackageName\n\t\t\t);\n\n\t\t\tconst manualBins: Record<string, string> = Object.fromEntries(\n\t\t\t\tObject.entries(this.oldBins ?? {}).filter(\n\t\t\t\t\t([, path]) =>\n\t\t\t\t\t\t!path.startsWith('.' + posix.sep + this.options.shimDir) ||\n\t\t\t\t\t\t!path.endsWith('js') ||\n\t\t\t\t\t\tpath.includes('manual')\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tconst update = Object.entries(this.pathMap).reduce<PackageJson>(\n\t\t\t\t(result, [key, value]) => {\n\t\t\t\t\tif (result.scripts && this.options.enabledHooks.includes(key)) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t!packageJson.scripts?.[key] ||\n\t\t\t\t\t\t\tpackageJson.scripts[key]?.endsWith(this.markComment)\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tif (packageJsonKind === PackageJsonKind.DISTRIBUTION) {\n\t\t\t\t\t\t\t\tresult.scripts[key] = value.outToOutPath[format] + this.markComment; // before update\n\t\t\t\t\t\t\t} else if (NPM_INSTALL_HOOKS.includes(key)) {\n\t\t\t\t\t\t\t\t// Disable local postinstall hooks\n\t\t\t\t\t\t\t\tresult.scripts[key] =\n\t\t\t\t\t\t\t\t\t'# local install hooks are disabled' + this.markComment;\n\t\t\t\t\t\t\t\t// Change the script target to source if its an install hook as it wont be compiled by the time it runs\n\t\t\t\t\t\t\t\t// result.scripts[key] =\n\t\t\t\t\t\t\t\t// \tthis.tsNode[this.packageType] +\n\t\t\t\t\t\t\t\t// \tvalue.srcPath +\n\t\t\t\t\t\t\t\t// \tthis.markComment; // before update\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// Otherwise just point to the shim\n\t\t\t\t\t\t\t\tresult.scripts[key] = value.shimPaths[format] + this.markComment; // before update\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// Hooks are renamed to avoid conflicts, except for their scripts\n\t\t\t\t\t\tkey = packageName + '-' + key;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!result.bin) {\n\t\t\t\t\t\tresult.bin = {};\n\t\t\t\t\t}\n\n\t\t\t\t\t// the distributed build artifacts bins point to the built bins\n\t\t\t\t\t// otherwise, the bins are pointing to their shims\n\t\t\t\t\tresult.bin[key] =\n\t\t\t\t\t\t'.' +\n\t\t\t\t\t\tposix.sep +\n\t\t\t\t\t\t(packageJsonKind === PackageJsonKind.DISTRIBUTION\n\t\t\t\t\t\t\t? value.outToOutPath[format]\n\t\t\t\t\t\t\t: value.shimPaths[format]);\n\n\t\t\t\t\treturn result;\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tbin: manualBins,\n\t\t\t\t\tscripts: {},\n\t\t\t\t}\n\t\t\t);\n\t\t\tif (typeof update.bin === 'object' && Object.keys(update.bin).length === 0) {\n\t\t\t\tdelete update.bin;\n\t\t\t}\n\n\t\t\tif (typeof update.scripts === 'object' && Object.keys(update.scripts).length === 0) {\n\t\t\t\tdelete update.scripts;\n\t\t\t}\n\t\t\treturn update;\n\t\t}\n\t\treturn {};\n\t}\n\n\t/**\n\t * Ensures shimDir exists and creates simple javascript files that are\n\t * importing their counterpart from `outDir`\n\t */\n\tprivate async createShims(shimPaths: string[], format: InternalModuleFormat): Promise<void> {\n\t\tif (\n\t\t\t(this.packageType === 'module' && format === 'es') ||\n\t\t\t(this.packageType === 'commonjs' && format !== 'es')\n\t\t) {\n\t\t\tthis.options.logger.info(\n\t\t\t\t`Creating shims for bins in ${format}/${this.packageType} format`\n\t\t\t);\n\t\t\t// Clean up\n\t\t\tawait rm(this.shimDirAbs, { force: true, recursive: true });\n\n\t\t\tconst shimDirToOutBin = relative(this.shimDirAbs, this.outBinDirAbs);\n\t\t\tconst formatJs = await getPrettierFormatter();\n\n\t\t\t// check writable shim files\n\t\t\tconst shimPathsToMake = await Promise.all(\n\t\t\t\tshimPaths.map((path) =>\n\t\t\t\t\treadFile(toAbsolute(path, this.options), { encoding: 'utf8' })\n\t\t\t\t\t\t.then((content) =>\n\t\t\t\t\t\t\tcontent.includes('// autogenerated') ? path : undefined\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.catch(() => path)\n\t\t\t\t)\n\t\t\t).then((results) => results.filter((result): result is string => result !== undefined));\n\n\t\t\tif (shimPathsToMake.length > 0) {\n\t\t\t\tthis.options.logger.info(`create shims for ${shimPathsToMake.join('; ')}`);\n\n\t\t\t\tawait mkdir(this.shimDirAbs, { recursive: true });\n\n\t\t\t\tawait Promise.allSettled(\n\t\t\t\t\tshimPathsToMake.map((path) => {\n\t\t\t\t\t\tconst outBinPath = enterPathPosix(path, path.split(posix.sep).length - 1);\n\t\t\t\t\t\tconst builtBinFromShims = shimDirToOutBin + posix.sep + outBinPath;\n\t\t\t\t\t\tconst formattedESShimContent = formatJs(\n\t\t\t\t\t\t\t`// autogenerated\n\t\t\t\t\t\t\texport * from '${builtBinFromShims}';`\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst formattedCJSShimContent = formatJs(\n\t\t\t\t\t\t\t`// autogenerated as seen from tsc\n\t\t\t\t\t\t\t/* eslint-disable unicorn/prefer-module */\n\t\t\t\t\t\t\t/* eslint-disable @typescript-eslint/no-var-requires */\n\t\t\t\t\t\t\t/* eslint-disable no-prototype-builtins */\n\t\t\t\t\t\t\tvar __createBinding = function(o, m, k, k2) {\n\t\t\t\t\t\t\t\tif (k2 === undefined) k2 = k;\n\t\t\t\t\t\t\t\tObject.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\tvar __exportStar = function(m, exports) {\n\t\t\t\t\t\t\t\tfor (var p in m) if (p !== 'default' && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);\n\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\t__exportStar(require('${builtBinFromShims}'), exports);`\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\treturn writeFile(\n\t\t\t\t\t\t\tjoin(this.shimDirAbs, outBinPath),\n\t\t\t\t\t\t\tformat === 'es' ? formattedESShimContent : formattedCJSShimContent\n\t\t\t\t\t\t).catch(() => undefined);\n\t\t\t\t\t})\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate async ensureEsmBinEntriesRenamed(packageType?: PackageJson['type']): Promise<void> {\n\t\tif (packageType === 'module') {\n\t\t\tconst data = Object.entries(this.pathMap).flatMap(([_binName, binPaths]) => {\n\t\t\t\tconst basename = stripFileExtension(binPaths.outPath.es);\n\t\t\t\treturn [\n\t\t\t\t\t{\n\t\t\t\t\t\tbinPath: basename + '.js',\n\t\t\t\t\t\tnewBinPath: binPaths.outPath.es,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tbinPath: basename + '.js.map',\n\t\t\t\t\t\tnewBinPath: binPaths.outPath.es + '.map',\n\t\t\t\t\t},\n\t\t\t\t];\n\t\t\t});\n\n\t\t\tawait Promise.all(\n\t\t\t\tdata\n\t\t\t\t\t.filter(({ binPath }) => existsSync(binPath))\n\t\t\t\t\t.map(({ binPath, newBinPath }) =>\n\t\t\t\t\t\trename(binPath, newBinPath).catch(() => false)\n\t\t\t\t\t)\n\t\t\t);\n\t\t}\n\t}\n\n\t// TODO: something is funky, there are extensionless files in the distbin dir and they are not executable.\n\t/**\n\t *\n\t */\n\tprivate async preLink(binRecord: Record<string, string>, packageName: string): Promise<void> {\n\t\tconst workspaceRoot = getWorkspaceRoot(this.options.cwd);\n\t\tif (!workspaceRoot) {\n\t\t\tthis.options.logger.error(\n\t\t\t\t`Cannot execute prelink, not in a workspace ${this.options.cwd}`\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tconst workspaceBinDirectoryPath = join(workspaceRoot, 'node_modules', '.bin');\n\n\t\tconst packageBinDirectoryPath = toAbsolute(join('node_modules', '.bin'), this.options);\n\n\t\tconst symlinksToMake = Object.entries(binRecord).flatMap(([binName, binPath]) => {\n\t\t\tif (this.options.enabledHooks.includes(binName)) {\n\t\t\t\tbinName = packageName + '-' + binName;\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\tjoin(workspaceBinDirectoryPath, binName),\n\t\t\t\tjoin(packageBinDirectoryPath, binName),\n\t\t\t].map((targetFilePath) => {\n\t\t\t\tconst relativeFromTargetBackToFile = relative(dirname(targetFilePath), binPath);\n\t\t\t\treturn { relativeFromTargetBackToFile, targetFilePath };\n\t\t\t});\n\t\t});\n\n\t\tawait Promise.all(\n\t\t\tsymlinksToMake.map(async ({ targetFilePath, relativeFromTargetBackToFile }) => {\n\t\t\t\ttry {\n\t\t\t\t\tawait symlink(relativeFromTargetBackToFile, targetFilePath);\n\t\t\t\t\tthis.options.logger.info(\n\t\t\t\t\t\t`symlinked ${targetFilePath} to ${relativeFromTargetBackToFile}`\n\t\t\t\t\t);\n\t\t\t\t} catch {\n\t\t\t\t\tthis.options.logger.info(`${targetFilePath} is already present`);\n\t\t\t\t}\n\t\t\t})\n\t\t);\n\t}\n}\n","import { toAbsolute } from '@alexaegis/fs';\nimport { getWorkspaceRoot, type PackageJson } from '@alexaegis/workspace-tools';\nimport { existsSync } from 'node:fs';\nimport { cp } from 'node:fs/promises';\nimport { basename, join } from 'node:path';\nimport {\n\tnormalizeAutoExportStaticOptions,\n\ttype AutoExportStaticOptions,\n} from './auto-export-static.class.options.js';\nimport type { PreparedBuildUpdate } from './prepared-build-update.type.js';\n\nexport class AutoCopyLicense implements PreparedBuildUpdate {\n\tprivate options: Required<AutoExportStaticOptions>;\n\tprivate workspaceRoot: string | undefined;\n\n\tconstructor(options: AutoExportStaticOptions) {\n\t\tthis.options = normalizeAutoExportStaticOptions(options);\n\t\tthis.workspaceRoot = getWorkspaceRoot(options.cwd);\n\t}\n\n\tasync writeBundleOnlyOnce(_packageJson: PackageJson): Promise<void> {\n\t\tif (this.workspaceRoot) {\n\t\t\tconst licensePath = [\n\t\t\t\tjoin(this.options.cwd, 'license'),\n\t\t\t\tjoin(this.options.cwd, 'LICENSE'),\n\t\t\t\tjoin(this.workspaceRoot, 'license'),\n\t\t\t\tjoin(this.workspaceRoot, 'LICENSE'),\n\t\t\t].find((path) => existsSync(path));\n\n\t\t\tif (licensePath) {\n\t\t\t\tawait cp(\n\t\t\t\t\tlicensePath,\n\t\t\t\t\tjoin(toAbsolute(this.options.outDir, this.options), basename(licensePath))\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n}\n","import { basename } from 'node:path';\nimport { stripFileExtension } from './strip-file-extension.function.js';\n\nexport interface CreatePathRecordFromPathsOptions {\n\t/**\n\t * @defaultValue true\n\t */\n\tkeyOnlyFilename?: boolean;\n}\n\nexport const createPathRecordFromPaths = (\n\tpaths: string[],\n\toptions?: CreatePathRecordFromPathsOptions\n): Record<string, string> => {\n\tconst keyOnlyFilename = options?.keyOnlyFilename ?? true;\n\treturn paths.reduce<Record<string, string>>((accumulator, next) => {\n\t\tlet key = stripFileExtension(next);\n\t\tif (keyOnlyFilename) {\n\t\t\tkey = basename(key);\n\t\t}\n\t\taccumulator[key] = next;\n\t\treturn accumulator;\n\t}, {});\n};\n","import { posix } from 'node:path';\nimport { DEFAULT_OUT_DIR } from '../index.js';\nimport { PackageJsonExportTarget, PackageJsonKind } from '../plugins/autolib.plugin.options.js';\nimport { DEFAULT_BINSHIM_DIR, DEFAULT_BIN_DIR } from './auto-bin.class.options.js';\nimport { enterPathPosix } from './enter-path.function.js';\nimport { offsetRelativePathPosix } from './offset-relative-path-posix.function.js';\n\nexport interface RetargetPackageJsonOptions {\n\tpackageJsonKind: PackageJsonKind;\n\tpackageJsonExportTarget: PackageJsonExportTarget;\n\n\t/**\n\t * @defaultValue 'dist'\n\t */\n\toutDir?: string;\n\n\t/**\n\t * @defaultValue 'shims'\n\t */\n\tshimDir?: string;\n\n\t/**\n\t * @defaultValue 'bin\n\t */\n\tbinDir?: string;\n}\n\n/**\n * This function should be able to turn a relative path from cwd pointing to\n * a source file, into a path that will point to a\n * different projection of the same file, like it's built equivalent or its\n * shim\n *\n */\nexport const retargetPackageJsonPath = (\n\tpath: string,\n\toptions: RetargetPackageJsonOptions\n): string => {\n\tconst outDir = options.outDir ?? DEFAULT_OUT_DIR;\n\tconst binDir = options.binDir ?? DEFAULT_BIN_DIR;\n\tconst shimDir = options.shimDir ?? DEFAULT_BINSHIM_DIR;\n\t// How many path segments to pop off from the beginning of the path\n\tlet enterCount = 0;\n\t// Path segment to prepend the path with\n\tlet offsetPath = '';\n\n\tif (options.packageJsonKind === PackageJsonKind.DEVELOPMENT) {\n\t\tswitch (options.packageJsonExportTarget) {\n\t\t\tcase PackageJsonExportTarget.SOURCE: {\n\t\t\t\toffsetPath = '';\n\t\t\t\tenterCount = 0;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase PackageJsonExportTarget.DIST: {\n\t\t\t\toffsetPath = outDir;\n\t\t\t\tenterCount = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase PackageJsonExportTarget.SHIM: {\n\t\t\t\toffsetPath = shimDir;\n\t\t\t\tenterCount = 1 + posix.normalize(binDir).split(posix.sep).length;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tswitch (options.packageJsonExportTarget) {\n\t\t\tcase PackageJsonExportTarget.SOURCE: {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'Invalid configuration! The distrubuted packageJson can only target the distributed exports!'\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase PackageJsonExportTarget.DIST: {\n\t\t\t\toffsetPath = '';\n\t\t\t\tenterCount = 1;\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase PackageJsonExportTarget.SHIM: {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'Invalid configuration! The distrubuted packageJson can only target the distributed exports!'\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst enteredPath = enterPathPosix(path, enterCount);\n\treturn offsetRelativePathPosix(offsetPath, enteredPath);\n};\n","import { isNotNullish } from '@alexaegis/common';\nimport type {\n\tPackageJson,\n\tPackageJsonExportConditions,\n\tPackageJsonExports,\n} from '@alexaegis/workspace-tools';\nimport { join, posix } from 'node:path';\nimport type { UserConfig } from 'vite';\nimport { PackageJsonExportTarget, PackageJsonKind } from '../plugins/autolib.plugin.options.js';\nimport { getBundledFileExtension } from './append-bundle-file-extension.function.js';\nimport { normalizeAutoEntryOptions, type AutoEntryOptions } from './auto-entry.class.options.js';\nimport { collectImmediate, offsetPathRecordValues } from './collect-export-entries.function.js';\nimport { createPathRecordFromPaths } from './create-path-record-from-paths.function.js';\nimport type { PreparedBuildUpdate } from './prepared-build-update.type.js';\nimport { retargetPackageJsonPath } from './retarget-package-json-path.function.js';\nimport { stripFileExtension } from './strip-file-extension.function.js';\n\nexport class AutoEntry implements PreparedBuildUpdate {\n\tprivate options: Required<AutoEntryOptions>;\n\n\tprivate entryFiles: string[] = [];\n\tprivate entryMap: Record<string, string> = {};\n\tprivate entryExports: Record<string, PackageJsonExportConditions> = {};\n\n\tconstructor(options: AutoEntryOptions) {\n\t\tthis.options = normalizeAutoEntryOptions(options);\n\t}\n\n\tgetViteConfigUpdates(): UserConfig {\n\t\treturn { build: { lib: { entry: this.entryMap } } };\n\t}\n\n\tasync preUpdate(packageJson: PackageJson): Promise<void> {\n\t\tpackageJson.exports = undefined;\n\t\tpackageJson.main = undefined;\n\t\tpackageJson.module = undefined;\n\n\t\tconst fullEntryPath = join(this.options.sourceDirectory, this.options.entryDir);\n\t\tthis.entryFiles = await collectImmediate(fullEntryPath, 'file');\n\n\t\tthis.entryMap = createPathRecordFromPaths(this.entryFiles, { keyOnlyFilename: true });\n\n\t\tthis.entryMap = offsetPathRecordValues(this.entryMap, fullEntryPath);\n\t}\n\n\tupdate(packageJson: PackageJson) {\n\t\tconst hasUmd = this.options.formats.includes('umd');\n\t\tconst hasEsm = this.options.formats.includes('es');\n\t\tconst hasCjs = this.options.formats.includes('cjs');\n\n\t\tconst umdExtension = getBundledFileExtension({\n\t\t\tformat: 'umd',\n\t\t\tpackageType: packageJson.type,\n\t\t});\n\t\tconst esmExtension = getBundledFileExtension({\n\t\t\tformat: 'es',\n\t\t\tpackageType: packageJson.type,\n\t\t});\n\t\tconst cjsExtension = getBundledFileExtension({\n\t\t\tformat: 'cjs',\n\t\t\tpackageType: packageJson.type,\n\t\t});\n\n\t\tthis.entryExports = Object.entries(this.entryMap).reduce<\n\t\t\tRecord<string, PackageJsonExportConditions>\n\t\t>((accumulator, [key, entryFile]) => {\n\t\t\tconst extensionlessPath = stripFileExtension(entryFile);\n\t\t\t// Assume there will be a `.d.ts` generated\n\t\t\tconst typesPath = `.${posix.sep}${posix.normalize(`${extensionlessPath}.d.ts`)}`;\n\t\t\tconst exportConditions: PackageJsonExportConditions = {\n\t\t\t\ttypes: typesPath,\n\t\t\t};\n\n\t\t\tif (hasUmd) {\n\t\t\t\texportConditions.require = `.${posix.sep}${posix.normalize(\n\t\t\t\t\t`${extensionlessPath}${umdExtension}`\n\t\t\t\t)}`;\n\t\t\t}\n\n\t\t\tif (hasCjs) {\n\t\t\t\texportConditions.require = `.${posix.sep}${posix.normalize(\n\t\t\t\t\t`${extensionlessPath}${cjsExtension}`\n\t\t\t\t)}`;\n\t\t\t}\n\n\t\t\tif (hasEsm) {\n\t\t\t\texportConditions.import = `.${posix.sep}${posix.normalize(\n\t\t\t\t\t`${extensionlessPath}${esmExtension}`\n\t\t\t\t)}`;\n\t\t\t}\n\t\t\tif (key === 'index') {\n\t\t\t\taccumulator['.'] = exportConditions;\n\t\t\t} else {\n\t\t\t\taccumulator['./' + key] = exportConditions;\n\t\t\t}\n\t\t\treturn accumulator;\n\t\t}, {});\n\n\t\treturn { exports: this.entryExports };\n\t}\n\n\tadjustPaths(packageJson: PackageJson, packageJsonKind: PackageJsonKind): PackageJson {\n\t\tconst entryExportsOffset = Object.entries(\n\t\t\tpackageJson.exports ?? {}\n\t\t).reduce<PackageJsonExports>((accumulator, [conditionKey, exportCondition]) => {\n\t\t\taccumulator[conditionKey] =\n\t\t\t\tconditionKey in this.entryExports && typeof exportCondition === 'object'\n\t\t\t\t\t? Object.entries(exportCondition).reduce<PackageJsonExportConditions>(\n\t\t\t\t\t\t\t(conditions, [condition, path]) => {\n\t\t\t\t\t\t\t\tconst isTypesFieldOfDevPackageJson =\n\t\t\t\t\t\t\t\t\tpackageJsonKind === PackageJsonKind.DEVELOPMENT &&\n\t\t\t\t\t\t\t\t\tcondition === 'types';\n\n\t\t\t\t\t\t\t\tif (isNotNullish(path)) {\n\t\t\t\t\t\t\t\t\tconst adjustedExtension = isTypesFieldOfDevPackageJson\n\t\t\t\t\t\t\t\t\t\t? path.replace('.d.ts', '.ts')\n\t\t\t\t\t\t\t\t\t\t: path;\n\t\t\t\t\t\t\t\t\tconditions[condition] = retargetPackageJsonPath(\n\t\t\t\t\t\t\t\t\t\tadjustedExtension,\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tpackageJsonKind,\n\t\t\t\t\t\t\t\t\t\t\tpackageJsonExportTarget: isTypesFieldOfDevPackageJson\n\t\t\t\t\t\t\t\t\t\t\t\t? PackageJsonExportTarget.SOURCE\n\t\t\t\t\t\t\t\t\t\t\t\t: PackageJsonExportTarget.DIST,\n\t\t\t\t\t\t\t\t\t\t\toutDir: this.options.outDir,\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn conditions;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{}\n\t\t\t\t\t  )\n\t\t\t\t\t: (exportCondition as PackageJsonExportConditions);\n\n\t\t\treturn accumulator;\n\t\t}, {});\n\n\t\treturn { exports: entryExportsOffset };\n\t}\n}\n","import { globby } from 'globby';\nimport { basename, posix } from 'node:path';\nimport { stripFileExtension } from './strip-file-extension.function.js';\n\nexport const collectFileMap = async (\n\tcwd: string,\n\tglobs: string[]\n): Promise<Record<string, string>> => {\n\tconst globbyResult = await globby(globs, { cwd, dot: true });\n\treturn globbyResult.reduce<Record<string, string>>((accumulator, next) => {\n\t\tconst key = `.${posix.sep}${basename(stripFileExtension(next))}`;\n\t\taccumulator[key] = `.${posix.sep}${next}`;\n\t\treturn accumulator;\n\t}, {});\n};\n","import { existsSync } from 'node:fs';\nimport { cp } from 'node:fs/promises';\nimport { join } from 'node:path';\n\nexport const copyAllInto = async (sourceFiles: string[], outDirectory: string): Promise<void> => {\n\tawait Promise.allSettled(\n\t\tsourceFiles\n\t\t\t.map((sourceFile) => ({ sourceFile, targetFile: join(outDirectory, sourceFile) }))\n\t\t\t.filter(\n\t\t\t\t({ sourceFile, targetFile }) => existsSync(sourceFile) && !existsSync(targetFile)\n\t\t\t)\n\t\t\t.map(({ sourceFile, targetFile }) =>\n\t\t\t\tcp(sourceFile, targetFile, {\n\t\t\t\t\tpreserveTimestamps: true,\n\t\t\t\t\trecursive: true,\n\t\t\t\t})\n\t\t\t)\n\t);\n};\n","import { toAbsolute } from '@alexaegis/fs';\nimport type { PackageJson } from '@alexaegis/workspace-tools';\nimport {\n\tnormalizeAutoExportStaticOptions,\n\ttype AutoExportStaticOptions,\n} from './auto-export-static.class.options.js';\nimport { collectFileMap } from './collect-export-map.function.js';\nimport { copyAllInto } from './copy-all-into.function.js';\nimport type { PreparedBuildUpdate } from './prepared-build-update.type.js';\n\nexport class AutoExportStatic implements PreparedBuildUpdate {\n\tprivate options: Required<AutoExportStaticOptions>;\n\tprivate staticExports: Record<string, string> = {};\n\n\tconstructor(options: AutoExportStaticOptions) {\n\t\tthis.options = normalizeAutoExportStaticOptions(options);\n\t}\n\n\tasync preUpdate(packageJson: PackageJson): Promise<PackageJson | undefined> {\n\t\tthis.staticExports = await collectFileMap(this.options.cwd, this.options.staticExportGlobs);\n\n\t\tpackageJson.exports = undefined;\n\n\t\treturn packageJson;\n\t}\n\n\tupdate(packageJson: PackageJson): PackageJson {\n\t\tpackageJson.exports = {\n\t\t\t...this.staticExports,\n\t\t\t...packageJson.exports,\n\t\t};\n\t\treturn packageJson;\n\t}\n\n\tasync writeBundleOnlyOnce(): Promise<void> {\n\t\tawait copyAllInto(\n\t\t\tObject.values(this.staticExports),\n\t\t\ttoAbsolute(this.options.outDir, this.options)\n\t\t);\n\t}\n}\n","export const cloneJsonSerializable = <T>(jsonSerializable: T): T =>\n\tJSON.parse(JSON.stringify(jsonSerializable)) as T;\n","import { lstatSync } from 'node:fs';\n\nexport const existsFile = (path: string): boolean =>\n\tlstatSync(path, { throwIfNoEntry: false })?.isFile() ?? false;\n","import { lstatSync } from 'node:fs';\n\nexport const existsSymlink = (path: string): boolean =>\n\tlstatSync(path, { throwIfNoEntry: false })?.isSymbolicLink() ?? false;\n","import { deepMerge, type Awaitable, type SimpleObjectKey } from '@alexaegis/common';\n\nexport type PreparedCreateUpdates<T extends Record<SimpleObjectKey, unknown>> = (\n\tt: T\n) => Awaitable<Partial<T>>;\n\nexport type PreparedUpdate<T extends Record<SimpleObjectKey, unknown>> = (t: T) => Awaitable<T>;\n\nexport const createPreparedUpdate = <T extends Record<SimpleObjectKey, unknown>>(\n\tcreateUpdates: PreparedCreateUpdates<T>\n): PreparedUpdate<T> => {\n\treturn async (t) => {\n\t\tconst updates = await createUpdates(t);\n\t\treturn deepMerge(t, updates);\n\t};\n};\n","import {\n\tcollectWorkspacePackages,\n\ttype PackageJson,\n\ttype WorkspacePackage,\n} from '@alexaegis/workspace-tools';\nimport { PackageJsonKind } from '../plugins/autolib.plugin.options.js';\nimport {\n\tnormalizeAutoMetadataOptions,\n\ttype AutoMetadataOptions,\n\ttype NormalizedAutoMetadataOptions,\n} from './auto-metadata.class.options.js';\n\nimport type { PreparedBuildUpdate } from './prepared-build-update.type.js';\n\n/**\n * Fills out packageJson fields of the distributed packageJson based on\n * either manually defined key-value pairs or a set of keys that then will\n * be read from the workspace packageJson file. Or both, in which case if a key\n * is defined in both the manual takes precedence.\n */\nexport class AutoMetadata implements PreparedBuildUpdate {\n\toptions: NormalizedAutoMetadataOptions;\n\tworkspacePackageJson: PackageJson | undefined;\n\tmetadataFromWorkspacePackageJson: PackageJson | undefined;\n\n\tconstructor(rawOptions?: AutoMetadataOptions) {\n\t\tthis.options = normalizeAutoMetadataOptions(rawOptions);\n\t}\n\n\tasync preUpdate(): Promise<PackageJson> {\n\t\t// TODO: A collect call already happens at plugin level, change function signature for preUpdate\n\t\tconst packages = await collectWorkspacePackages({ onlyWorkspaceRoot: true });\n\n\t\tthis.workspacePackageJson = packages[0]?.packageJson;\n\n\t\tif (!this.workspacePackageJson) {\n\t\t\tthis.options.logger.error('cant read root metadata, not in a workspace');\n\t\t\treturn {};\n\t\t}\n\n\t\tthis.metadataFromWorkspacePackageJson = Object.fromEntries(\n\t\t\tObject.entries(this.workspacePackageJson).filter(([key]) =>\n\t\t\t\tthis.options.keysFromWorkspace.includes(key)\n\t\t\t)\n\t\t);\n\n\t\treturn {};\n\t}\n\n\tpostprocess(workspacePackage: WorkspacePackage, packageJsonKind: PackageJsonKind): PackageJson {\n\t\tif (packageJsonKind === PackageJsonKind.DISTRIBUTION) {\n\t\t\tconst filledPackageJson = {\n\t\t\t\t...this.options.fallbackEntries,\n\t\t\t\t...workspacePackage.packageJson,\n\t\t\t\t...this.metadataFromWorkspacePackageJson,\n\t\t\t\t...this.options.overrideEntries,\n\t\t\t};\n\t\t\tif (typeof filledPackageJson.repository === 'object') {\n\t\t\t\tfilledPackageJson.repository.directory =\n\t\t\t\t\tworkspacePackage.packagePathFromRootPackage;\n\t\t\t}\n\n\t\t\tconst missingKeys = this.options.mandatoryKeys.filter(\n\t\t\t\t(mandatoryKey) => !Object.hasOwn(filledPackageJson, mandatoryKey)\n\t\t\t);\n\n\t\t\tif (missingKeys.length > 0) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'Some keys are missing! Please define the following keys ' +\n\t\t\t\t\t\t`in your packageJson file: ${missingKeys.join(', ')}`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn filledPackageJson;\n\t\t} else {\n\t\t\treturn workspacePackage.packageJson;\n\t\t}\n\t}\n}\n","import type { PackageJson, RegularWorkspacePackage } from '@alexaegis/workspace-tools';\nimport { PackageJsonKind } from '../plugins/autolib.plugin.options.js';\n\nimport type { PreparedBuildUpdate } from './prepared-build-update.type.js';\n\n/**\n * Removes duplicated dependency and peerDependency entries leaving only the\n * peerDependencies behind.\n *\n * The point of this is to let peerDependencies install locally too by defining\n * them twice, once as a peerDependency, and once as a normal dependency. This\n * step will remove the one that was meant to only be present locally.\n */\nexport class AutoPeer implements PreparedBuildUpdate {\n\tpostprocess(\n\t\tworkspacePackage: RegularWorkspacePackage,\n\t\tpackageJsonKind: PackageJsonKind\n\t): PackageJson {\n\t\tif (\n\t\t\tpackageJsonKind === PackageJsonKind.DISTRIBUTION &&\n\t\t\tworkspacePackage.packageJson.dependencies &&\n\t\t\tworkspacePackage.packageJson.peerDependencies\n\t\t) {\n\t\t\tconst peerDependencies = Object.keys(workspacePackage.packageJson.peerDependencies);\n\t\t\treturn {\n\t\t\t\t...workspacePackage.packageJson,\n\t\t\t\tdependencies: Object.fromEntries(\n\t\t\t\t\tObject.entries(workspacePackage.packageJson.dependencies).filter(\n\t\t\t\t\t\t([dependency]) => !peerDependencies.includes(dependency)\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t\t};\n\t\t} else {\n\t\t\treturn workspacePackage.packageJson;\n\t\t}\n\t}\n}\n","import type { ObjectKeyOrder } from '@alexaegis/common';\nimport { normalizeLoggerOption, type LoggerOption } from '@alexaegis/logging';\nimport {\n\tDEFAULT_PACKAGE_JSON_SORTING_PREFERENCE,\n\tnormalizeSortingPreferenceForPackageJson,\n} from '@alexaegis/workspace-tools';\n\nexport interface AutoReorderOptions extends LoggerOption {\n\t/**\n\t * Define an order of keys that will be applied to the target object\n\t * The rest of the keys will be ordered in alphabetical order.\n\t * You can nest ordering by adding an object, that defines a sub-ordering.\n\t *\n\t * ! All ordering keys are treated as regular expressions, make sure they\n\t * ! are valid!\n\t *\n\t * To keep your package.json valid some order rules may be overwritten,\n\t * like making sure 'types' is always the first entry in 'exports' objects\n\t *\n\t * By default it orders everything in alphabetical order.\n\t *\n\t * @example ['name', '.*', { key: 'scripts', order: ['start', 'build.*'] }, '.*']\n\t * @defaultValue []\n\t */\n\tsortingPreference?: ObjectKeyOrder;\n}\n\nexport type NormalizedAutoReorderOptions = Required<AutoReorderOptions>;\n\nexport const normalizeAutoReorderOptions = (\n\toptions?: AutoReorderOptions\n): NormalizedAutoReorderOptions => {\n\treturn {\n\t\t...normalizeLoggerOption(options),\n\t\tsortingPreference: options?.sortingPreference\n\t\t\t? normalizeSortingPreferenceForPackageJson(options.sortingPreference)\n\t\t\t: DEFAULT_PACKAGE_JSON_SORTING_PREFERENCE,\n\t};\n};\n","import { sortObject } from '@alexaegis/common';\nimport type { PackageJson, RegularWorkspacePackage } from '@alexaegis/workspace-tools';\nimport {\n\tnormalizeAutoReorderOptions,\n\ttype AutoReorderOptions,\n} from './auto-reorder.class.options.js';\nimport type { PreparedBuildUpdate } from './prepared-build-update.type.js';\n\nexport class AutoSort implements PreparedBuildUpdate {\n\tprivate options: Required<AutoReorderOptions>;\n\n\tconstructor(options?: AutoReorderOptions) {\n\t\tthis.options = normalizeAutoReorderOptions(options);\n\t}\n\n\tpostprocess(workspacePackage: RegularWorkspacePackage): PackageJson {\n\t\treturn sortObject(workspacePackage.packageJson, this.options.sortingPreference);\n\t}\n}\n","import { asyncFilterMap, deepMerge, isNotNullish } from '@alexaegis/common';\nimport { readJson, toAbsolute, writeJson } from '@alexaegis/fs';\nimport { createLogger } from '@alexaegis/logging';\nimport {\n\tcollectWorkspacePackages,\n\ttype PackageJson,\n\ttype RegularWorkspacePackage,\n} from '@alexaegis/workspace-tools';\nimport { join, posix, sep } from 'node:path';\nimport { mergeConfig, type LibraryFormats, type Plugin, type UserConfig } from 'vite';\nimport { AutoCopyLicense } from '../helpers/auto-copy-license.class.js';\nimport { DEFAULT_ENTRY_DIR } from '../helpers/auto-entry.class.options.js';\nimport { AutoExportStatic } from '../helpers/auto-export-static.class.js';\nimport { AutoMetadata } from '../helpers/auto-metadata.class.js';\nimport { AutoPeer } from '../helpers/auto-peer.class.js';\nimport { AutoSort } from '../helpers/auto-reorder.class.js';\nimport { cloneJsonSerializable } from '../helpers/clone-json-serializable.function.js';\nimport { AutoBin, AutoEntry, DEFAULT_EXPORT_FORMATS, DEFAULT_OUT_DIR } from '../helpers/index.js';\nimport type { PreparedBuildUpdate } from '../helpers/prepared-build-update.type.js';\nimport {\n\tPackageJsonKind,\n\tnormalizeAutolibOptions,\n\ttype AutolibPluginOptions,\n} from './autolib.plugin.options.js';\n\nexport const autolib = (rawOptions?: AutolibPluginOptions): Plugin => {\n\tconst options = normalizeAutolibOptions(rawOptions);\n\tconst pluginName = 'autolib';\n\toptions.logger = createLogger({\n\t\tname: `vite:${pluginName}`,\n\t});\n\n\tconst packageDirName = options.cwd.slice(Math.max(0, options.cwd.lastIndexOf(sep)));\n\n\toptions.logger.info(packageDirName, options.cwd, 'starting...');\n\n\tlet workspacePackage: RegularWorkspacePackage;\n\n\t// At the end of these definitions as these will only settle once\n\t// `configResolved` ran\n\tlet formats: LibraryFormats[];\n\tlet sourceDirectory: string;\n\tlet outDirectory: string;\n\n\t// All updates leave all paths relative to the package before finalization\n\tconst buildUpdates: PreparedBuildUpdate[] = [];\n\n\tlet error: Error | undefined;\n\n\tlet packageJson: PackageJson;\n\tlet writeBundleCalled = 0;\n\n\treturn {\n\t\tname: pluginName,\n\t\tapply: 'build',\n\t\tconfig: async (config) => {\n\t\t\tconst startTime = performance.now();\n\t\t\toptions.logger.trace('lifecycle: config', config, startTime);\n\n\t\t\tconst workspace = await collectWorkspacePackages(options);\n\t\t\tconst w = workspace.find(\n\t\t\t\t(workspacePackage): workspacePackage is RegularWorkspacePackage =>\n\t\t\t\t\tworkspacePackage.packageKind === 'regular' &&\n\t\t\t\t\tworkspacePackage.packagePath.includes(options.cwd) &&\n\t\t\t\t\t(workspacePackage.packagePath + sep).includes(packageDirName + sep)\n\t\t\t);\n\n\t\t\tif (!w) {\n\t\t\t\tthrow new Error('Package could not be determined');\n\t\t\t}\n\t\t\tworkspacePackage = w;\n\n\t\t\toptions.logger.info('Building workspace package at', workspacePackage.packageJsonPath);\n\n\t\t\tformats =\n\t\t\t\tconfig.build?.lib && config.build.lib.formats\n\t\t\t\t\t? config.build.lib.formats\n\t\t\t\t\t: DEFAULT_EXPORT_FORMATS;\n\n\t\t\tsourceDirectory =\n\t\t\t\tconfig.build?.lib && typeof config.build.lib.entry === 'string'\n\t\t\t\t\t? posix.dirname(config.build.lib.entry)\n\t\t\t\t\t: options.src;\n\n\t\t\toutDirectory = config.build?.outDir ?? DEFAULT_OUT_DIR;\n\n\t\t\tif (options.autoBin) {\n\t\t\t\tbuildUpdates.push(\n\t\t\t\t\tnew AutoBin({\n\t\t\t\t\t\tcwd: options.cwd,\n\t\t\t\t\t\tbinDir: options.autoBin.binDir,\n\t\t\t\t\t\tshimDir: options.autoBin.shimDir,\n\t\t\t\t\t\toutDir: outDirectory,\n\t\t\t\t\t\tsrcDir: sourceDirectory,\n\t\t\t\t\t\tlogger: options.logger.getSubLogger({ name: 'auto-bin' }),\n\t\t\t\t\t})\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (options.autoEntryDir) {\n\t\t\t\tbuildUpdates.push(\n\t\t\t\t\tnew AutoEntry({\n\t\t\t\t\t\tcwd: options.cwd,\n\t\t\t\t\t\tformats,\n\t\t\t\t\t\tentryDir: options.autoEntryDir,\n\t\t\t\t\t\toutDir: outDirectory,\n\t\t\t\t\t\tsourceDirectory,\n\t\t\t\t\t\tlogger: options.logger.getSubLogger({ name: 'auto-entry' }),\n\t\t\t\t\t})\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (options.autoExportStaticGlobs) {\n\t\t\t\tbuildUpdates.push(\n\t\t\t\t\tnew AutoExportStatic({\n\t\t\t\t\t\tcwd: options.cwd,\n\t\t\t\t\t\toutDir: outDirectory,\n\t\t\t\t\t\tstaticExportGlobs: options.autoExportStaticGlobs,\n\t\t\t\t\t\tlogger: options.logger.getSubLogger({ name: 'auto-export-static' }),\n\t\t\t\t\t})\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (options.autoMetadata) {\n\t\t\t\tbuildUpdates.push(\n\t\t\t\t\tnew AutoMetadata({\n\t\t\t\t\t\t...options.autoMetadata,\n\t\t\t\t\t\tlogger: options.logger.getSubLogger({ name: 'auto-metadata' }),\n\t\t\t\t\t})\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (options.autoOrderPackageJson) {\n\t\t\t\tbuildUpdates.push(\n\t\t\t\t\tnew AutoSort({\n\t\t\t\t\t\tsortingPreference: options.autoOrderPackageJson,\n\t\t\t\t\t\tlogger: options.logger.getSubLogger({ name: 'auto-sort' }),\n\t\t\t\t\t})\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (options.autoCopyLicense) {\n\t\t\t\tbuildUpdates.push(\n\t\t\t\t\tnew AutoCopyLicense({\n\t\t\t\t\t\t...options.autoCopyLicense,\n\t\t\t\t\t\tlogger: options.logger.getSubLogger({ name: 'auto-copy-license' }),\n\t\t\t\t\t})\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (options.autoPeer) {\n\t\t\t\tbuildUpdates.push(new AutoPeer());\n\t\t\t}\n\n\t\t\tconst rawPackageJson = await readJson<PackageJson>(workspacePackage.packageJsonPath);\n\t\t\tif (rawPackageJson) {\n\t\t\t\tpackageJson = rawPackageJson;\n\t\t\t} else {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`${pluginName} didn't find package.json at ${workspacePackage.packageJsonPath}!`\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst preUpdates = await asyncFilterMap(\n\t\t\t\tbuildUpdates,\n\t\t\t\tasync (buildUpdate) => await buildUpdate.preUpdate?.(packageJson)\n\t\t\t);\n\n\t\t\tdeepMerge(packageJson, ...preUpdates);\n\n\t\t\tconst baseViteConfigUpdates: Partial<UserConfig> = {\n\t\t\t\tbuild: {\n\t\t\t\t\tsourcemap: true,\n\t\t\t\t\tmanifest: true,\n\t\t\t\t\tssr: true,\n\t\t\t\t\tlib: {\n\t\t\t\t\t\tformats,\n\t\t\t\t\t\tentry: DEFAULT_ENTRY_DIR,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst viteConfigUpdates = await asyncFilterMap(\n\t\t\t\tbuildUpdates,\n\t\t\t\tasync (buildUpdate) => await buildUpdate.getViteConfigUpdates?.(config)\n\t\t\t);\n\n\t\t\tconst updates = viteConfigUpdates\n\t\t\t\t.filter(isNotNullish)\n\t\t\t\t.reduce(\n\t\t\t\t\t(accumulator, next) => mergeConfig(accumulator, next),\n\t\t\t\t\tbaseViteConfigUpdates\n\t\t\t\t);\n\n\t\t\toptions.logger.info(\n\t\t\t\t`prepare phase took ${Math.floor(performance.now() - startTime)}ms to finish`\n\t\t\t);\n\n\t\t\treturn updates;\n\t\t},\n\t\tbuildEnd: (buildError) => {\n\t\t\toptions.logger.trace('lifecycle: buildEnd', buildError);\n\n\t\t\terror = buildError;\n\t\t},\n\t\twriteBundle: async (outputOptions) => {\n\t\t\toptions.logger.trace('lifecycle: writeBundle');\n\n\t\t\tif (writeBundleCalled < 1) {\n\t\t\t\tawait asyncFilterMap(\n\t\t\t\t\tbuildUpdates,\n\t\t\t\t\tasync (buildUpdate) => await buildUpdate.writeBundleOnlyOnce?.(packageJson)\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst handlePackageJson =\n\t\t\t\t(packageJson.type === 'module' && outputOptions.format === 'es') ||\n\t\t\t\t((packageJson.type === 'commonjs' || packageJson.type === undefined) &&\n\t\t\t\t\toutputOptions.format !== 'es');\n\n\t\t\tif (!handlePackageJson) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (error) {\n\t\t\t\toptions.logger.error(\"didn't run, error happened during build!\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst updates = await asyncFilterMap(\n\t\t\t\tbuildUpdates,\n\t\t\t\tasync (buildUpdate) => await buildUpdate.update?.(packageJson, outputOptions.format)\n\t\t\t);\n\t\t\t// I have to cheat a little bit because other plugins will steal the\n\t\t\t// thread during an async copy step\n\t\t\tconst startTime = performance.now();\n\n\t\t\tpackageJson = deepMerge(packageJson, ...updates);\n\n\t\t\tawait asyncFilterMap(Object.values(PackageJsonKind), async (packageJsonTarget) => {\n\t\t\t\tlet packageJsonForArtifact = cloneJsonSerializable(packageJson);\n\n\t\t\t\tconst pathOffsets = await asyncFilterMap(\n\t\t\t\t\tbuildUpdates,\n\t\t\t\t\tasync (buildUpdate) =>\n\t\t\t\t\t\tawait buildUpdate.adjustPaths?.(\n\t\t\t\t\t\t\tpackageJsonForArtifact,\n\t\t\t\t\t\t\tpackageJsonTarget,\n\t\t\t\t\t\t\toutputOptions.format\n\t\t\t\t\t\t)\n\t\t\t\t);\n\n\t\t\t\tpackageJsonForArtifact = deepMerge(packageJsonForArtifact, ...pathOffsets);\n\n\t\t\t\tpackageJsonForArtifact = buildUpdates.reduce(\n\t\t\t\t\t(packageJson, buildUpdate) =>\n\t\t\t\t\t\tbuildUpdate.postprocess?.(\n\t\t\t\t\t\t\t{ ...workspacePackage, packageJson },\n\t\t\t\t\t\t\tpackageJsonTarget\n\t\t\t\t\t\t) ?? packageJson,\n\t\t\t\t\tpackageJsonForArtifact\n\t\t\t\t);\n\n\t\t\t\tconst destination =\n\t\t\t\t\tpackageJsonTarget === PackageJsonKind.DISTRIBUTION\n\t\t\t\t\t\t? toAbsolute(join(outDirectory, 'package.json'), options)\n\t\t\t\t\t\t: toAbsolute('package.json', options);\n\n\t\t\t\treturn await writeJson(cloneJsonSerializable(packageJsonForArtifact), destination, {\n\t\t\t\t\tautoPrettier: options.autoPrettier,\n\t\t\t\t\tdry: options.dry,\n\t\t\t\t});\n\t\t\t});\n\n\t\t\toptions.logger.info(\n\t\t\t\t`update phase took ~${Math.floor(performance.now() - startTime)}ms to finish`\n\t\t\t);\n\n\t\t\twriteBundleCalled += 1;\n\t\t},\n\t};\n};\n","import { getPrettierFormatter, readJson, toAbsolute } from '@alexaegis/fs';\nimport { PACKAGE_JSON_NAME, type PackageJson } from '@alexaegis/workspace-tools';\nimport { writeFile } from 'node:fs/promises';\nimport type { Plugin } from 'vite';\n\nexport interface UpdatePackageJsonPluginOptions {\n\tfilename?: string;\n\tupdater: (packageJson: PackageJson) => PackageJson;\n\tcwd?: string;\n\tautoPrettier?: boolean;\n}\n\nexport const updatePackageJsonPlugin = (options: UpdatePackageJsonPluginOptions): Plugin => ({\n\tname: 'update-package-json',\n\tapply: 'build',\n\tbuildEnd: async (error) => {\n\t\tif (!error) {\n\t\t\tconst cwd = options.cwd ?? process.cwd();\n\t\t\tconst packageJsonLocation = toAbsolute(options.filename ?? PACKAGE_JSON_NAME, { cwd });\n\n\t\t\tconst packageJson = await readJson<PackageJson>(packageJsonLocation);\n\t\t\tif (!packageJson) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`updatePackageJsonPlugin didn't find packageJson at ${packageJsonLocation}!`\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst augmentedPackageJson = options.updater(packageJson);\n\t\t\tlet rawAugmentedPackageJson = JSON.stringify(augmentedPackageJson);\n\n\t\t\tif (options.autoPrettier ?? true) {\n\t\t\t\tconst formatter = await getPrettierFormatter({ parser: 'json-stringify', cwd });\n\t\t\t\trawAugmentedPackageJson = formatter(rawAugmentedPackageJson);\n\t\t\t}\n\n\t\t\tawait writeFile(packageJsonLocation, rawAugmentedPackageJson);\n\t\t}\n\t},\n});\n"],"names":["normalizeLoggerOption","normalizeCwdOption","PackageJsonKind","PackageJsonExportTarget","normalizeWriteJsonOptions","DEFAULT_PACKAGE_JSON_SORTING_PREFERENCE","posix","statSync","join","sep","extname","readdir","basename","globby","turnIntoExecutable","toAbsolute","rm","relative","getPrettierFormatter","readFile","mkdir","writeFile","existsSync","rename","getWorkspaceRoot","dirname","symlink","cp","isNotNullish","lstatSync","deepMerge","collectWorkspacePackages","normalizeSortingPreferenceForPackageJson","sortObject","createLogger","workspacePackage","readJson","asyncFilterMap","mergeConfig","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