@pakk/core
Version:
The core library of pakk, that can manage your package.json for library development.
67 lines • 3.21 kB
TypeScript
import { PackageJson, WorkspacePackage } from '@alexaegis/workspace-tools';
import { InternalModuleFormat } from 'rollup';
import { NormalizedPakkContext, ViteFileNameFn } from '../../index.js';
import { PathMap } from '../../package-json/index.js';
import { PackageExportPathContext } from '../export/package-export-path-context.interface.js';
import { PackageExaminationResult, PakkFeature } from '../pakk-feature.type.js';
import { AutoBinOptions } from './auto-bin.class.options.js';
export declare const allBinPathCombinations: readonly ["development-to-source", "development-to-dist", "distribution-to-dist", "development-to-shim"];
export declare const mapPathMapToFormat: (binPaths: PathMap<string>, format: InternalModuleFormat | "SOURCE", fileNameFn: ViteFileNameFn) => BinPathMap;
/**
* BinPaths never point into the nothing. Dist points to dist but source only
* points to a shim generated by AutoBin not to confuse package managers when
* an unbuilt package is installed locally. The shim will be there for them.
* The shim will not be usable until the package is built though.
*
* TODO: generate shims that can self trigger builds when called and not built
*/
export type AllBinPathCombinations = (typeof allBinPathCombinations)[number];
export type BinPathMap = PathMap<AllBinPathCombinations>;
/**
* Generates bin entries from files under `srcDir` + `autoBinDirectory`
* It also treats all files named as npm hooks as npm hooks, prefixing them
* and adding them as hooks for the npm artifact
*
* For example a file called `postinstall.ts` in a package called
* `@org/name`, it will generate an npm script entry as such:
* `"postinstall": "bin/postinstall.js"`. The hook is still treated as a
* `bin` so you can invoke it directly. To avoid name collisions, all
* "hookbins" are prefixed with the normalized packagename like so:
* `org-name-postinstall`
*
* For a simpler packageJson, directories.bin could also be used in
* https://docs.npmjs.com/cli/v9/configuring-npm/package-json#directories
*/
export declare class AutoBin implements PakkFeature {
readonly order = 3;
private readonly options;
private readonly context;
private outDirAbs;
private shimDirAbs;
private outBinDirAbs;
private binPathMap;
private existingManualBinEntries;
constructor(context: NormalizedPakkContext, options?: AutoBinOptions);
private collectManualBinEntries;
examinePackage(workspacePackage: WorkspacePackage): Promise<Partial<PackageExaminationResult>>;
/**
* for module based packages, bins are modules too and the adjust path
* step only acts for the 'es' format
*/
process(packageJson: PackageJson, pathContext: PackageExportPathContext): Promise<PackageJson | undefined>;
/**
* Ensures shimDir exists and creates simple javascript files that are
* importing their counterpart from `outDir`
*/
private createShims;
/**
* Ensures that all .js files in the dist folder are renamed to the
* expected name this plugin added them to the bin entry.
*/
private ensureEsmBinEntriesRenamed;
/**
*
*/
private preLink;
}
//# sourceMappingURL=auto-bin.class.d.ts.map