@tochii/build 2.5.0 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,12 +1,203 @@
1
+ // ---- index.d.mts ----
1
2
  import * as tsup from 'tsup';
2
- import { B as BuildUtils$1 } from './utils-dsfZeRyj.mjs';
3
+ import { build as build$1 } from 'tsup';
4
+ export { Format, NormalizedOptions, Options } from 'tsup';
5
+
6
+ declare module '@npmcli/arborist' {
7
+ export interface Node {
8
+ name: string;
9
+ path: string;
10
+ realpath: string;
11
+ package: Record<string, any>;
12
+ isLink?: boolean;
13
+ isRoot?: boolean;
14
+ children?: Map<string, Node>;
15
+ }
16
+
17
+ export default class Arborist {
18
+ constructor(options: { path: string });
19
+ loadActual(): Promise<Node>;
20
+ }
21
+ }
22
+
23
+ declare module 'npm-packlist' {
24
+ export default function packlist(tree: {
25
+ name: string;
26
+ path: string;
27
+ realpath: string;
28
+ package: Record<string, any>;
29
+ isLink?: boolean;
30
+ isRoot?: boolean;
31
+ children?: Map<string, any>;
32
+ }): Promise<string[]>;
33
+ }
34
+
35
+ /**
36
+ * Creates a tarball from a package
37
+ *
38
+ * @param options - options to customize the tarball
39
+ * @returns an object containing the tarball path and included files
40
+ */
41
+ declare function createTarball({ packageDir, packageJsonData, outputTarballPath }: PublishCreateOptions): Promise<PublishCreateResult>;
42
+
43
+ /**
44
+ * Merges the contents of all files from the `files` array into `outFile`
45
+ * @param files array of file paths or glob patterns (glob supported)
46
+ * @param outFile destination file to write merged content (relative/absolute)
47
+ * @param onResolvedFiles optional callback that is called after files are resolved and validated
48
+ */
49
+ declare function mergeFiles(files: string[], outFile: string, onResolvedFiles?: (resolvedFiles: string[]) => void): Promise<void>;
50
+
51
+ declare class BuildUtils$1 {
52
+ /**
53
+ * The default build options
54
+ */
55
+ static readonly defaultConfigOptions: BuildOptions;
56
+ /**
57
+ * Array of commonly ignored entries
58
+ */
59
+ static readonly ignoredEntries: string[];
60
+ /**
61
+ * Aray of commonly used entries
62
+ */
63
+ static readonly entriesCommon: string[];
64
+ /**
65
+ * Array of index entries
66
+ */
67
+ static readonly entriesIndex: string[];
68
+ /**
69
+ * Array of default entries including index files and commonly ignored entries
70
+ */
71
+ static readonly defaultEntriesIndex: string[];
72
+ /**
73
+ * Array of default entries including any .ts files and commonly ignored entries
74
+ */
75
+ static readonly defaultEntriesCommon: string[];
76
+ /**
77
+ * Default options
78
+ *
79
+ * See all available options here: https://www.jsdocs.io/package/tsup#Options
80
+ *
81
+ * @default '{ tsconfig: "tsconfig.json", dts: true, format: ["esm"], minify: true }'
82
+ * @param options configuration with entry, clean and splitting as required properties to avoid unintended behaviour
83
+ * @param config (optional) configure tochibuild behaviour
84
+ * @param throwErr (optional) whether or not to throw an error if something goes wrong
85
+ * @param isCli (optional) whether or not this is being called from the CLI
86
+ */
87
+ static readonly handleOptions: (options: BuildOptionsParams<"entry" | "clean" | "splitting">, config?: TochibuildConfig, throwErr?: boolean, isCli?: boolean) => any;
88
+ /**
89
+ * Default options for index files as entry
90
+ *
91
+ * See all available options here: https://www.jsdocs.io/package/tsup#Options
92
+ *
93
+ * @default '{ entry: BuildUtils.defaultEntriesIndex, tsconfig: "tsconfig.json", dts: true, format: ["esm"], minify: true }'
94
+ * @param options configuration with clean and splitting as required properties to avoid unintended behaviour
95
+ * @param config (optional) configure tochibuild behaviour
96
+ * @param throwErr (optional) whether or not to throw an error if something goes wrong
97
+ * @param isCli (optional) whether or not this is being called from the CLI
98
+ */
99
+ static readonly handleOptionsWithIndexEntries: (options: BuildOptionsParams<"clean" | "splitting">, config?: TochibuildConfig, throwErr?: boolean, isCli?: boolean) => any;
100
+ /**
101
+ * Default options for common files as entry
102
+ *
103
+ * See all available options here: https://www.jsdocs.io/package/tsup#Options
104
+ *
105
+ * @default '{ entry: BuildUtils.defaultEntriesCommon, tsconfig: "tsconfig.json", dts: true, format: ["esm"], minify: true }'
106
+ * @param options configuration with clean and splitting as required properties to avoid unintended behaviour
107
+ * @param config (optional) configure tochibuild behaviour
108
+ * @param throwErr (optional) whether or not to throw an error if something goes wrong
109
+ * @param isCli (optional) whether or not this is being called from the CLI
110
+ */
111
+ static readonly handleOptionsWithCommonEntries: (options: BuildOptionsParams<"clean" | "splitting">, config?: TochibuildConfig, throwErr?: boolean, isCli?: boolean) => any;
112
+ static readonly generateConfig: typeof generateConfig;
113
+ static readonly ensureEntries: typeof ensureEntries;
114
+ static readonly createTarball: typeof createTarball;
115
+ static readonly mergeFiles: typeof mergeFiles;
116
+ /**
117
+ * Merge build options
118
+ *
119
+ * @param options the primary build options
120
+ * @param config configure the overriding options and how to merge them
121
+ * @param throwErr (optional) whether or not to throw an error if something goes wrong
122
+ * @param isCli (optional) whether or not this is being called from the CLI
123
+ */
124
+ static readonly mergeBuildOptions: <TRequiredKeys extends keyof (BuildOptions | BuildOptionsWithConfig) = any, TOpts extends BuildOptionsResult<TRequiredKeys> | BuildOptionsParams<TRequiredKeys> = BuildOptionsParams<TRequiredKeys>>(options: TOpts, config: MergeBuildOptionsConfig, throwErr?: boolean, isCli?: boolean) => any;
125
+ /**
126
+ * Merge build options asynchronously
127
+ *
128
+ * @param options the primary build options
129
+ * @param config configure the overriding options and how to merge them
130
+ * @param throwErr (optional) whether or not to throw an error if something goes wrong
131
+ * @param isCli (optional) whether or not this is being called from the CLI
132
+ */
133
+ static readonly mergeBuildOptionsAsync: <TOpts extends BuildOptionsResult | BuildOptionsParams, TConfig extends MergeBuildOptionsConfigAsync>(options: TOpts, config: TConfig, throwErr?: boolean, isCli?: boolean) => Promise<any>;
134
+ /**
135
+ * Get the file path and json data from a package.json
136
+ *
137
+ * If no rootDir is passed or if it's undefined, then the current working directory will be used
138
+ *
139
+ * @param rootDir the directory the package.json is in
140
+ * @param throwErr whether or not to throw an error if something goes wrong
141
+ */
142
+ static readonly getPackageJson: <TPackageJson extends Record<string, any> = Record<string, any>>(rootDir?: string, throwErr?: boolean) => {
143
+ filePath: string | undefined;
144
+ data: TPackageJson | undefined;
145
+ };
146
+ /**
147
+ * Get dependencies from a package.json file using config
148
+ *
149
+ * @param config configuration from {@link TochibuildConfig}
150
+ * @param packageJsonPath the package.json file path
151
+ */
152
+ static readonly getPackageJsonDepsEntriesFromConfig: (config: TochibuildConfig | undefined, packageJsonPath?: string) => string[];
153
+ /**
154
+ * Get dependencies from a package.json file as entries
155
+ *
156
+ * @param packageJsonPath the package.json file path
157
+ * @param filter the types of dependencies to include
158
+ */
159
+ static readonly getPackageJsonDepsEntries: (packageJsonPath: string | undefined, filter?: ("dependencies" | "devDependencies" | "peerDependencies")[]) => string[];
160
+ /**
161
+ * Get dependencies from a package.json file
162
+ *
163
+ * @param packageJsonPath the package.json file path
164
+ * @param filter the types of dependencies to include
165
+ */
166
+ static readonly getPackageJsonDeps: (packageJsonPath: string | undefined) => {
167
+ toArray: (filter?: ("dependencies" | "devDependencies" | "peerDependencies")[]) => string[];
168
+ dependencies: any;
169
+ devDependencies: any;
170
+ peerDependencies: any;
171
+ };
172
+ }
173
+
174
+ /**
175
+ * Ensures that the passed entries includes the certain ones
176
+ *
177
+ * NOTE: only works for string arrays (otherwise will return the same entry) and will not overwrite or duplicate the entries
178
+ *
179
+ * @param entry the entries to check
180
+ * @param type the type of entries to ensure
181
+ */
182
+ declare function ensureEntries(entry: BuildOptions['entry'], type: ('ignoredEntries' | 'entriesIndex' | 'entriesCommon' | 'defaultEntriesIndex' | 'defaultEntriesCommon')[]): BuildOptions['entry'];
183
+ /**
184
+ * Generate a config file
185
+ *
186
+ * @param cliModule which module to use
187
+ * @param options (optional) configure how to generate the config
188
+ * @param throwErr (optional) whether or not to throw an error if something goes wrong
189
+ * @param isCli (optional) whether or not this is being called from the CLI
190
+ */
191
+ declare function generateConfig(cliModule: CLIModule, options?: GenerateConfigOptionsCLI, throwErr?: boolean, isCli?: boolean): void;
3
192
 
4
193
  type DefineConfigOptions = BuildOptionsParams<'entry' | 'clean' | 'splitting'>;
5
194
  type DefineConfigOptionsIndexEntries = BuildOptionsParams<'clean' | 'splitting'>;
6
195
  type DefineConfigOptionsCommonEntries = BuildOptionsParams<'clean' | 'splitting'>;
7
196
  declare const BuildUtils: typeof BuildUtils$1;
197
+ declare const build: typeof build$1;
8
198
  declare const _default: {
9
199
  utils: typeof BuildUtils$1;
200
+ build: typeof build$1;
10
201
  defineConfig: typeof defineConfig;
11
202
  defineConfigWithIndexEntries: typeof defineConfigWithIndexEntries;
12
203
  defineConfigWithCommonEntries: typeof defineConfigWithCommonEntries;
@@ -19,8 +210,9 @@ declare const _default: {
19
210
  *
20
211
  * @default '{ tsconfig: "tsconfig.json", dts: true, format: ["esm"], minify: true }'
21
212
  * @param options configuration with entry, clean and splitting as required properties to avoid unintended behaviour
213
+ * @param config (optional) configure tochibuild behaviour
22
214
  */
23
- declare function defineConfig(options: DefineConfigOptions): tsup.Options | tsup.Options[] | ((overrideOptions: tsup.Options) => tsup.Options | tsup.Options[] | Promise<tsup.Options | tsup.Options[]>);
215
+ declare function defineConfig(options: DefineConfigOptions, config?: TochibuildConfig): Promise<tsup.Options | tsup.Options[] | ((overrideOptions: tsup.Options) => tsup.Options | tsup.Options[] | Promise<tsup.Options | tsup.Options[]>)>;
24
216
  /**
25
217
  * Define tochibuild configuration with index files as entry
26
218
  *
@@ -28,8 +220,9 @@ declare function defineConfig(options: DefineConfigOptions): tsup.Options | tsup
28
220
  *
29
221
  * @default '{ entry: BuildUtils.defaultEntriesIndex, tsconfig: "tsconfig.json", dts: true, format: ["esm"], minify: true }'
30
222
  * @param options configuration with clean and splitting as required properties to avoid unintended behaviour
223
+ * @param config (optional) configure tochibuild behaviour
31
224
  */
32
- declare function defineConfigWithIndexEntries(options: DefineConfigOptionsIndexEntries): tsup.Options | tsup.Options[] | ((overrideOptions: tsup.Options) => tsup.Options | tsup.Options[] | Promise<tsup.Options | tsup.Options[]>);
225
+ declare function defineConfigWithIndexEntries(options: DefineConfigOptionsIndexEntries, config?: TochibuildConfig): Promise<tsup.Options | tsup.Options[] | ((overrideOptions: tsup.Options) => tsup.Options | tsup.Options[] | Promise<tsup.Options | tsup.Options[]>)>;
33
226
  /**
34
227
  * Define tochibuild configuration with common files as entry
35
228
  *
@@ -37,7 +230,1127 @@ declare function defineConfigWithIndexEntries(options: DefineConfigOptionsIndexE
37
230
  *
38
231
  * @default '{ entry: BuildUtils.defaultEntriesCommon, tsconfig: "tsconfig.json", dts: true, format: ["esm"], minify: true }'
39
232
  * @param options configuration with clean and splitting as required properties to avoid unintended behaviour
233
+ * @param config (optional) configure tochibuild behaviour
40
234
  */
41
- declare function defineConfigWithCommonEntries(options: DefineConfigOptionsCommonEntries): tsup.Options | tsup.Options[] | ((overrideOptions: tsup.Options) => tsup.Options | tsup.Options[] | Promise<tsup.Options | tsup.Options[]>);
235
+ declare function defineConfigWithCommonEntries(options: DefineConfigOptionsCommonEntries, config?: TochibuildConfig): Promise<tsup.Options | tsup.Options[] | ((overrideOptions: tsup.Options) => tsup.Options | tsup.Options[] | Promise<tsup.Options | tsup.Options[]>)>;
236
+
237
+ export { BuildUtils, type DefineConfigOptions, type DefineConfigOptionsCommonEntries, type DefineConfigOptionsIndexEntries, build, _default as default, defineConfig, defineConfigWithCommonEntries, defineConfigWithIndexEntries };
238
+
239
+
240
+ // ---- cli.d.ts ----
241
+ /// <reference types="commander" />
242
+
243
+ type CLICommand = import('commander').Command;
244
+ type CLIModule = '@tochii/build' | 'tochibuild';
245
+
246
+ type CommandHandler = (cliModule: CLIModule, program: CLICommand) => MaybePromise<void>;
247
+
248
+ type BuildOptionsCliFlag = keyof BuildOptionsCliFlagMap | '--no-config' | (string & {});
249
+
250
+ /**
251
+ * Maps CLI flags (both long and short versions) to their corresponding {@link BuildOptions} property keys.
252
+ */
253
+ interface BuildOptionsCliFlagMap extends Record<string, keyof BuildOptions> {
254
+ // output directory
255
+ '-d': 'outDir';
256
+ '--out-dir': 'outDir';
257
+
258
+ // format
259
+ '--format': 'format';
260
+
261
+ // minification
262
+ '--minify': 'minify';
263
+ '--minify-whitespace': 'minifyWhitespace';
264
+ '--minify-identifiers': 'minifyIdentifiers';
265
+ '--minify-syntax': 'minifySyntax';
266
+
267
+ // misc flags
268
+ '--keep-names': 'keepNames';
269
+ '--target': 'target';
270
+ '--legacy-output': 'legacyOutput';
271
+ '--sourcemap': 'sourcemap';
272
+
273
+ // watch and dev
274
+ '--watch': 'watch';
275
+ '--onSuccess': 'onSuccess';
276
+
277
+ // inject and externals
278
+ '--inject': 'inject';
279
+ '--external': 'external';
280
+
281
+ // output options
282
+ '--global-name': 'globalName';
283
+ '--jsxFactory': 'jsxFactory';
284
+ '--jsxFragment': 'jsxFragment';
285
+ '--replaceNodeEnv': 'replaceNodeEnv';
286
+ '--no-splitting': 'splitting';
287
+ '--clean': 'clean';
288
+ '--silent': 'silent';
289
+ '--pure': 'pure';
290
+ '--metafile': 'metafile';
291
+
292
+ // platform and env
293
+ '--platform': 'platform';
294
+ '--loader': 'loader';
295
+ '--tsconfig': 'tsconfig';
296
+ '--config': 'config';
297
+ '--shims': 'shims';
298
+ '--inject-style': 'injectStyle';
299
+
300
+ // tree shaking and public assets
301
+ '--treeshake': 'treeshake';
302
+ '--publicDir': 'publicDir';
303
+
304
+ // process control
305
+ '--killSignal': 'killSignal';
306
+ '--cjsInterop': 'cjsInterop';
307
+ }
308
+
309
+ /**
310
+ * Provides default values for supported CLI flags (where applicable).
311
+ */
312
+ interface BuildOptionsCliDefaults extends Partial<Record<keyof BuildOptionsCliFlagMap, unknown>> {
313
+ '--format': 'esm';
314
+ '--minify': false;
315
+ '--sourcemap': false;
316
+ '--watch': false;
317
+ '--clean': false;
318
+ '--silent': false;
319
+ '--shims': true;
320
+ '--splitting': true;
321
+ '--treeshake': true;
322
+ '--cjsInterop': true;
323
+ '--platform': 'node';
324
+ '--target': 'esnext';
325
+ }
326
+
327
+ type BuildOptionsCliAllowedTypes = string | string[] | boolean;
328
+ type BuildOptionsCliReplaceIfNotAllowed<T> = T extends BuildOptionsCliAllowedTypes ? T : string;
329
+ type BuildOptionsCliFlags = {
330
+ [K in BuildOptionsCliKeys]: BuildOptionsCliReplaceIfNotAllowed<BuildOptions[K]>;
331
+ };
332
+ type BuildOptionsCliKeys =
333
+ | 'outDir'
334
+ | 'format'
335
+ | 'minify'
336
+ | 'minifyWhitespace'
337
+ | 'minifyIdentifiers'
338
+ | 'minifySyntax'
339
+ | 'keepNames'
340
+ | 'target'
341
+ | 'legacyOutput'
342
+ | 'sourcemap'
343
+ | 'watch'
344
+ | 'onSuccess'
345
+ | 'inject'
346
+ | 'external'
347
+ | 'globalName'
348
+ | 'jsxFactory'
349
+ | 'jsxFragment'
350
+ | 'replaceNodeEnv'
351
+ | 'splitting'
352
+ | 'clean'
353
+ | 'silent'
354
+ | 'pure'
355
+ | 'metafile'
356
+ | 'platform'
357
+ | 'loader'
358
+ | 'tsconfig'
359
+ | 'config'
360
+ | 'shims'
361
+ | 'injectStyle'
362
+ | 'treeshake'
363
+ | 'publicDir'
364
+ | 'killSignal'
365
+ | 'cjsInterop';
366
+
367
+
368
+ // ---- commands.d.ts ----
369
+ type GenerateConfigOptionsCLI = {
370
+ /**
371
+ * The file extension to use
372
+ * @default '.ts'
373
+ */
374
+ ext?: '.ts' | '.js' | '.cjs' | '.json';
375
+
376
+ /**
377
+ * The name of the file to generate
378
+ * @default 'tochibuild.config'
379
+ */
380
+ filename?: 'tochibuild.config' | (string & {});
381
+
382
+ /**
383
+ * If the file already exists, overwrite it
384
+ * @default false
385
+ */
386
+ overwrite?: boolean;
387
+
388
+ /**
389
+ * The output directories
390
+ * @default the current working directory
391
+ */
392
+ outDir?: string[];
393
+ };
394
+
395
+ type CreateTarballOptionsCLI = {
396
+ /**
397
+ * Path to the original package directory (relative/absolute)
398
+ * @default the current working directory
399
+ */
400
+ dir?: string;
401
+
402
+ /**
403
+ * The custom path to the package.json file (relative/absolute)
404
+ * @default 'package.json'
405
+ */
406
+ pkg?: string;
407
+
408
+ /**
409
+ * The output tarball path (relative/absolute)
410
+ * @default tochibuild.package.tgz
411
+ */
412
+ out?: string[];
413
+ };
414
+
415
+
416
+ // ---- lifecycle.d.ts ----
417
+ type BuildLifecyclePackageJsonHandler =
418
+ | PackageJsonOptions
419
+ | ((override: PackageJsonOptions) => PackageJsonOptions);
420
+ type BuildLifecyclePackageJsonValue =
421
+ | string
422
+ | BuildLifecyclePackageJsonHandler
423
+ | {
424
+ /**
425
+ * The path to the package.json file (relative to the current working directory)
426
+ *
427
+ * Use the `data` property instead if you already have the package.json data
428
+ */
429
+ path?: string;
430
+
431
+ /**
432
+ * The package.json data
433
+ *
434
+ * Use the `path` property instead if you don't have the package.json data
435
+ */
436
+ data?: BuildLifecyclePackageJsonHandler;
437
+ };
438
+
439
+ type BuildLifecycleRegistryUri =
440
+ | 'https://registry.npmjs.org/'
441
+ | 'https://registry.yarnpkg.com/'
442
+ | 'https://npm.pkg.github.com/';
443
+
444
+ interface BuildLifecycleRegistry extends Record<string, BuildLifecycleRegistryUri> {
445
+ npm: 'https://registry.npmjs.org/';
446
+ yarn: 'https://registry.yarnpkg.com/';
447
+ pnpm: 'https://registry.npmjs.org/';
448
+ bun: 'https://registry.npmjs.org/';
449
+ github: 'https://npm.pkg.github.com/';
450
+ }
451
+
452
+ type BuildLifecycleHookOptions<
453
+ TDefaultHooks extends Record<string, any> = BuildLifecycleDefaultHooks<any>,
454
+ > = (BuildLifecycleHookOptionsCli | BuildLifecycleHookOptionsAction) & {
455
+ /**
456
+ * The description of what the hook does
457
+ * @example 'generate pokemons'
458
+ */
459
+ description?: string;
460
+
461
+ /**
462
+ * The lifecycle position of the hook
463
+ */
464
+ position:
465
+ | 'before.build'
466
+ | `before.${keyof TDefaultHooks}`
467
+ | 'after.build'
468
+ | `after.${keyof TDefaultHooks}`;
469
+ };
470
+
471
+ type BuildLifecycleHookOptionsCli = {
472
+ /**
473
+ * The name of the hook
474
+ * @example 'my special hook'
475
+ */
476
+ name?: string;
477
+
478
+ /**
479
+ * The cli to use for this hook
480
+ */
481
+ cli: {
482
+ /**
483
+ * The name of the cli to use for this hook
484
+ *
485
+ * If `undefined` or `null` is provided, then the one from {@link BuildLifecycleOptions} will be used
486
+ *
487
+ * @example 'node', 'nodemon' or 'tsx'
488
+ */
489
+ name:
490
+ | keyof Omit<BuildLifecycleRegistry, 'github'>
491
+ | 'node'
492
+ | (string & {})
493
+ | undefined
494
+ | null;
495
+
496
+ /**
497
+ * The command and arguments to use for this hook (eg. `run`, `script.js`)
498
+ *
499
+ * The provided cli name will be prefixed to the command
500
+ */
501
+ args: string[];
502
+ };
503
+ };
504
+
505
+ type TBuildUtils = typeof import('../utils/index').BuildUtils;
506
+ type BuildLifecycleHookOptionsAction = {
507
+ /**
508
+ * The name of the hook
509
+ * @example 'my special hook'
510
+ */
511
+ name: string;
512
+
513
+ /**
514
+ * The action to perform for this hook
515
+ *
516
+ * @param utils build utilities
517
+ * @param config the settings from the configuration file
518
+ * @param packageJson data from package.json
519
+ */
520
+ action: (
521
+ utils: TBuildUtils,
522
+ config: TochibuildConfig | undefined,
523
+ packageJson: PackageJsonOptions | undefined
524
+ ) => MaybePromise<void>;
525
+ };
526
+
527
+ type BuildLifecycleDefaultHookOptionsKnown<
528
+ TPackageManager extends keyof BuildLifecycleRegistry,
529
+ TBuildLifecycleHookName extends BuildLifecycleDefaultHookName,
530
+ > = BuildLifecyclePackageManagerOptions<
531
+ TPackageManager,
532
+ TBuildLifecycleHookName
533
+ >[TPackageManager][TBuildLifecycleHookName];
534
+
535
+ type BuildLifecycleDefaultHookOptionsUnknown = Record<string, any>;
536
+
537
+ type BuildLifecycleDefaultHookOptions<
538
+ TPackageManager extends keyof BuildLifecycleRegistry | (string & {}),
539
+ TBuildLifecycleHookName extends BuildLifecycleDefaultHookName,
540
+ > = (TPackageManager extends keyof BuildLifecycleRegistry
541
+ ? BuildLifecycleDefaultHookOptionsKnown<TPackageManager, TBuildLifecycleHookName>
542
+ : BuildLifecycleDefaultHookOptionsUnknown) & {
543
+ /**
544
+ * The package manager to use
545
+ *
546
+ * If none is provided, then the one from {@link BuildLifecycleOptions} will be used
547
+ */
548
+ packageManager?:
549
+ | ConditionalType<
550
+ TBuildLifecycleHookName,
551
+ 'deprecate',
552
+ 'npm',
553
+ keyof Omit<BuildLifecycleRegistry, 'github'>
554
+ >
555
+ | (string & {});
556
+
557
+ /**
558
+ * The command to use
559
+ */
560
+ command?: TBuildLifecycleHookName | (string & {});
561
+
562
+ /**
563
+ * The arguments for the command if any (eg. `--no-private`)
564
+ *
565
+ * NOTE: the tarball will be created automatically (recommended) if not provided
566
+ */
567
+ args?: string[];
568
+ };
569
+
570
+ type BuildLifecycleDefaultHookName = 'publish' | 'deprecate';
571
+ type BuildLifecycleDefaultHooks<
572
+ TPackageManager extends keyof BuildLifecycleRegistry | (string & {}),
573
+ > = {
574
+ /**
575
+ * The default publish command for the selected package manager
576
+ *
577
+ * More info:
578
+ * - [npm](https://docs.npmjs.com/cli/commands/npm-publish)
579
+ * - [yarn](https://yarnpkg.com/cli/npm/publish)
580
+ * - [pnpm](https://pnpm.io/cli/publish)
581
+ * - [bun](https://bun.sh/docs/cli/publish)
582
+ */
583
+ publish?: BuildLifecycleDefaultHookOptions<TPackageManager, 'publish'>;
584
+
585
+ /**
586
+ * The default deprecate command for the selected package manager
587
+ *
588
+ * NOTE: this hook is unaware of workspaces
589
+ *
590
+ * More info:
591
+ * - [npm](https://docs.npmjs.com/cli/commands/npm-deprecate)
592
+ * - only npm supports deprecating packages
593
+ */
594
+ deprecate?: BuildLifecycleDefaultHookOptions<TPackageManager, 'deprecate'>;
595
+ };
596
+
597
+ type BuildLifecycleOptions<TPackageManager extends keyof BuildLifecycleRegistry | (string & {})> = {
598
+ /**
599
+ * The package manager to use
600
+ */
601
+ packageManager: TPackageManager;
602
+
603
+ /**
604
+ * The access level of the package
605
+ * @default 'restricted'
606
+ */
607
+ access?: 'public' | 'restricted' | (string & {});
608
+
609
+ /**
610
+ * The registry to publish to
611
+ * @default 'https://registry.npmjs.org/'
612
+ */
613
+ registry?: BuildLifecycleRegistryUri | (string & {});
614
+
615
+ /**
616
+ * The hooks to use for the build lifecycle
617
+ *
618
+ * These hooks are not running or overriding any pre/post scripts in your package.json
619
+ */
620
+ hooks?: BuildLifecycleDefaultHooks<TPackageManager> & {
621
+ /**
622
+ * Add your own hook(s)
623
+ */
624
+ custom?: MaybeArray<BuildLifecycleHookOptions>;
625
+ };
626
+
627
+ /**
628
+ * The package.json to use for the published package
629
+ *
630
+ * If a string is provided (relative to the current working directory), it will be used as the path to the package.json
631
+ *
632
+ * Configure the options using {@link BuildLifecyclePackageJsonValue}
633
+ *
634
+ * @default 'package.json'
635
+ */
636
+ packageJson?: BuildLifecyclePackageJsonValue;
637
+ };
638
+
639
+ type MaybeNpmOnlyOptions<
640
+ TPackageManagerCommandName extends BuildLifecycleDefaultHookName,
641
+ TBuildLifecyclePackageManagerOptions extends Record<
642
+ TPackageManagerCommandName,
643
+ Record<string, any>
644
+ >,
645
+ > = ConditionalType<
646
+ TPackageManagerCommandName,
647
+ 'deprecate',
648
+ TBuildLifecyclePackageManagerOptions,
649
+ TPackageManager
650
+ >;
651
+
652
+ interface BuildLifecyclePackageManagerOptions<
653
+ TPackageManager extends keyof BuildLifecycleRegistry,
654
+ TPackageManagerCommandName extends BuildLifecycleDefaultHookName,
655
+ > extends Record<TPackageManager, Record<TPackageManagerCommandName, Record<string, any>>> {
656
+ npm: MaybeNpmOnlyOptions<
657
+ TPackageManagerCommandName,
658
+ BuildLifecyclePackageManagerOptionsNpm<TPackageManagerCommandName>
659
+ >;
660
+ yarn: MaybeNpmOnlyOptions<
661
+ TPackageManagerCommandName,
662
+ BuildLifecyclePackageManagerOptionsYarn<TPackageManagerCommandName>
663
+ >;
664
+ pnpm: MaybeNpmOnlyOptions<
665
+ TPackageManagerCommandName,
666
+ BuildLifecyclePackageManagerOptionsPnpm<TPackageManagerCommandName>
667
+ >;
668
+ bun: MaybeNpmOnlyOptions<
669
+ TPackageManagerCommandName,
670
+ BuildLifecyclePackageManagerOptionsBun<TPackageManagerCommandName>
671
+ >;
672
+ github: MaybeNpmOnlyOptions<
673
+ TPackageManagerCommandName,
674
+ BuildLifecyclePackageManagerOptionsGithub<TPackageManagerCommandName>
675
+ >;
676
+ }
677
+
678
+ interface BuildLifecyclePackageManagerOptionsNpm<
679
+ TPackageManagerCommandName extends BuildLifecycleDefaultHookName,
680
+ > extends Record<TPackageManagerCommandName, Record<string, any>> {
681
+ /**
682
+ * The publish command for `npm@11`
683
+ * @see https://docs.npmjs.com/cli/v11/commands/npm-publish
684
+ */
685
+ publish?: NpmPublishOptions;
686
+
687
+ /**
688
+ * The deprecate command for `npm@11`
689
+ * @see https://docs.npmjs.com/cli/v11/commands/npm-deprecate
690
+ */
691
+ deprecate?: NpmDeprecateOptions;
692
+ }
693
+
694
+ interface BuildLifecyclePackageManagerOptionsYarn<
695
+ TPackageManagerCommandName extends BuildLifecycleDefaultHookName,
696
+ > extends Record<TPackageManagerCommandName, Record<string, any>> {
697
+ /**
698
+ * The publish command for `yarn`
699
+ * @see https://yarnpkg.com/cli/publish
700
+ */
701
+ publish?: YarnPublishOptions;
702
+ }
703
+
704
+ interface BuildLifecyclePackageManagerOptionsYarn<
705
+ TPackageManagerCommandName extends BuildLifecycleDefaultHookName,
706
+ > extends Record<TPackageManagerCommandName, Record<string, any>> {
707
+ /**
708
+ * The publish command for `yarn`
709
+ * @see https://yarnpkg.com/cli/publish
710
+ */
711
+ publish?: YarnPublishOptions;
712
+ }
713
+
714
+ interface BuildLifecyclePackageManagerOptionsPnpm<
715
+ TPackageManagerCommandName extends BuildLifecycleDefaultHookName,
716
+ > extends Record<TPackageManagerCommandName, Record<string, any>> {
717
+ /**
718
+ * The publish command for `pnpm`
719
+ * @see https://pnpm.io/cli/publish
720
+ */
721
+ publish?: PnpmPublishOptions;
722
+ }
723
+
724
+ interface BuildLifecyclePackageManagerOptionsBun<
725
+ TPackageManagerCommandName extends BuildLifecycleDefaultHookName,
726
+ > extends Record<TPackageManagerCommandName, Record<string, any>> {
727
+ /**
728
+ * The publish command for `bun`
729
+ * @see https://bun.sh/docs/cli/publish
730
+ */
731
+ publish?: BunPublishOptions;
732
+ }
733
+
734
+ interface BuildLifecyclePackageManagerOptionsGithub<
735
+ TPackageManagerCommandName extends BuildLifecycleDefaultHookName,
736
+ > extends Record<TPackageManagerCommandName, Record<string, any>> {
737
+ /**
738
+ * The publish command for GitHub's npm registry
739
+ */
740
+ publish?: GithubPublishOptions;
741
+ }
742
+
743
+
744
+ // ---- npm.d.ts ----
745
+ interface NpmPublishOptions {
746
+ /**
747
+ * The tag that will be added to the package in the registry.
748
+ * @default 'latest'
749
+ */
750
+ tag?: string;
751
+
752
+ /**
753
+ * Control access level for scoped packages.
754
+ * @default 'public' for new packages; no change for existing
755
+ */
756
+ access?: 'public' | 'restricted' | null;
757
+
758
+ /**
759
+ * Indicates a dry run without actual publishing.
760
+ * @default false
761
+ */
762
+ 'dry-run'?: boolean;
763
+
764
+ /**
765
+ * One-time password for 2FA-enabled accounts.
766
+ * @default null
767
+ */
768
+ otp?: string | null;
769
+
770
+ /**
771
+ * Run the command in the context of a specific workspace.
772
+ * Can be passed multiple times.
773
+ */
774
+ workspace?: string | string[];
775
+
776
+ /**
777
+ * Run the command in the context of all configured workspaces.
778
+ * @default null
779
+ */
780
+ workspaces?: boolean | null;
781
+
782
+ /**
783
+ * Include the workspace root when workspaces are enabled.
784
+ * @default false
785
+ */
786
+ 'include-workspace-root'?: boolean;
787
+
788
+ /**
789
+ * Link the package to its CI/CD provenance on supported systems.
790
+ * Cannot be used with `provenance-file`.
791
+ * @default false
792
+ */
793
+ provenance?: boolean;
794
+
795
+ /**
796
+ * Path to a provenance bundle to use during publish.
797
+ * Cannot be used with `provenance`.
798
+ * @default null
799
+ */
800
+ 'provenance-file'?: string | null;
801
+
802
+ /**
803
+ * Skip publishing if package.json has "private": true.
804
+ * @default false
805
+ */
806
+ 'no-private'?: boolean;
807
+ }
808
+
809
+ interface NpmDeprecateOptions {
810
+ /**
811
+ * The version or semver range to deprecate.
812
+ */
813
+ version: string;
814
+
815
+ /**
816
+ * The deprecation message to be shown.
817
+ * Use an empty string to remove the deprecation.
818
+ */
819
+ message: string;
820
+
821
+ /**
822
+ * Indicates a dry run without actual changes.
823
+ * @default false
824
+ */
825
+ 'dry-run'?: boolean;
826
+
827
+ /**
828
+ * One-time password for 2FA-enabled accounts.
829
+ * @default null
830
+ */
831
+ otp?: string | null;
832
+ }
833
+
834
+ interface YarnPublishOptions
835
+ extends Omit<NpmPublishOptions, 'access' | 'otp' | 'provenance' | 'provenance-file'> {
836
+ 'no-git-tag-version'?: boolean;
837
+ }
838
+
839
+ interface PnpmPublishOptions extends Omit<NpmPublishOptions, 'provenance' | 'provenance-file'> {
840
+ tag?: string;
841
+ }
842
+
843
+ interface BunPublishOptions
844
+ extends Omit<
845
+ NpmPublishOptions,
846
+ | 'otp'
847
+ | 'provenance'
848
+ | 'provenance-file'
849
+ | 'workspace'
850
+ | 'workspaces'
851
+ | 'include-workspace-root'
852
+ > {}
853
+
854
+ interface GithubPublishOptions
855
+ extends Omit<NpmPublishOptions, 'access' | 'provenance' | 'provenance-file'> {
856
+ token?: string;
857
+ 'dry-run'?: boolean;
858
+ }
859
+
860
+
861
+ // ---- pkg.json.d.ts ----
862
+ /**
863
+ * Represents the structure of a package.json file.
864
+ * All properties are optional to allow for partial definitions.
865
+ */
866
+ interface PackageJsonOptions {
867
+ [key: string]: Record<string, any> | string | number | boolean | null;
868
+
869
+ /**
870
+ * The name of your package.
871
+ * Must be lowercase and may include hyphens and underscores.
872
+ * @example "my-awesome-package"
873
+ */
874
+ name?: string;
875
+
876
+ /**
877
+ * The version of your package.
878
+ * Must follow semantic versioning.
879
+ * @example "1.0.0"
880
+ */
881
+ version?: string;
882
+
883
+ /**
884
+ * A brief description of your package.
885
+ * @example "A package that does awesome things."
886
+ */
887
+ description?: string;
888
+
889
+ /**
890
+ * The entry point to your package.
891
+ * @example "index.js"
892
+ */
893
+ main?: string;
894
+
895
+ /**
896
+ * The module entry point for ES6 module systems.
897
+ * @example "dist/index.mjs"
898
+ */
899
+ module?: string;
900
+
901
+ /**
902
+ * The types entry point for TypeScript definitions.
903
+ * @example "dist/index.d.ts"
904
+ */
905
+ types?: string;
906
+
907
+ /**
908
+ * An array of keywords that describes your package.
909
+ * Helps people discover your package as it's listed in npm search.
910
+ * @example ["awesome", "package", "nodejs"]
911
+ */
912
+ keywords?: string[];
913
+
914
+ /**
915
+ * The license for your package.
916
+ * @example "MIT"
917
+ */
918
+ license?: string;
919
+
920
+ /**
921
+ * The author of the package.
922
+ * Can be a string or an object with name, email, and url.
923
+ * @example "Jane Doe <jane@example.com> (https://example.com)"
924
+ */
925
+ author?:
926
+ | string
927
+ | {
928
+ name: string;
929
+ email?: string;
930
+ url?: string;
931
+ };
932
+
933
+ /**
934
+ * A list of contributors to the package.
935
+ * Each contributor can be a string or an object with name, email, and url.
936
+ */
937
+ contributors?: Array<
938
+ | string
939
+ | {
940
+ name: string;
941
+ email?: string;
942
+ url?: string;
943
+ }
944
+ >;
945
+
946
+ /**
947
+ * The URL to the homepage of your package.
948
+ * @example "https://example.com"
949
+ */
950
+ homepage?: string;
951
+
952
+ /**
953
+ * Information about the bugs for your package.
954
+ * Can be a URL or an object with url and email.
955
+ */
956
+ bugs?:
957
+ | string
958
+ | {
959
+ url?: string;
960
+ email?: string;
961
+ };
962
+
963
+ /**
964
+ * The repository where your package's source code lives.
965
+ * Can be a string or an object with type and url.
966
+ */
967
+ repository?:
968
+ | string
969
+ | {
970
+ type: string;
971
+ url: string;
972
+ directory?: string;
973
+ };
974
+
975
+ /**
976
+ * Script commands that are run at various times in the lifecycle of your package.
977
+ * @example { "start": "node index.js", "test": "jest" }
978
+ */
979
+ scripts?: Record<string, string>;
980
+
981
+ /**
982
+ * Dependencies that are required to run your package.
983
+ * @example { "express": "^4.17.1" }
984
+ */
985
+ dependencies?: Record<string, string>;
986
+
987
+ /**
988
+ * Dependencies that are only needed for development and testing.
989
+ * @example { "jest": "^26.6.3" }
990
+ */
991
+ devDependencies?: Record<string, string>;
992
+
993
+ /**
994
+ * Optional dependencies that are not required for your package to work.
995
+ * @example { "fsevents": "^2.3.2" }
996
+ */
997
+ optionalDependencies?: Record<string, string>;
998
+
999
+ /**
1000
+ * Dependencies that are bundled when publishing the package.
1001
+ * @example { "lodash": "^4.17.21" }
1002
+ */
1003
+ bundledDependencies?: string[];
1004
+
1005
+ /**
1006
+ * Engines that your package is compatible with.
1007
+ * @example { "node": ">=12.0.0" }
1008
+ */
1009
+ engines?: Record<string, string>;
1010
+
1011
+ /**
1012
+ * Operating systems your package is compatible with.
1013
+ * @example ["darwin", "linux"]
1014
+ */
1015
+ os?: string[];
1016
+
1017
+ /**
1018
+ * CPU architectures your package is compatible with.
1019
+ * @example ["x64", "arm64"]
1020
+ */
1021
+ cpu?: string[];
1022
+
1023
+ /**
1024
+ * Files to include when publishing your package.
1025
+ * @example ["dist/", "README.md"]
1026
+ */
1027
+ files?: string[];
1028
+
1029
+ /**
1030
+ * The directory that contains the executable files.
1031
+ * @example "bin"
1032
+ */
1033
+ bin?: string | Record<string, string>;
1034
+
1035
+ /**
1036
+ * Configuration options for your package.
1037
+ * These can be used by your package's code.
1038
+ */
1039
+ config?: Record<string, any>;
1040
+
1041
+ /**
1042
+ * A map of package names to versions that your package depends on.
1043
+ * These dependencies are bundled when publishing the package.
1044
+ */
1045
+ bundleDependencies?: Record<string, string>;
1046
+
1047
+ /**
1048
+ * A map of package names to versions that your package depends on.
1049
+ * These dependencies are peer dependencies.
1050
+ */
1051
+ peerDependencies?: Record<string, string>;
1052
+
1053
+ /**
1054
+ * A map of package names to versions that your package depends on.
1055
+ * These dependencies are optional peer dependencies.
1056
+ */
1057
+ peerDependenciesMeta?: Record<
1058
+ string,
1059
+ {
1060
+ optional?: boolean;
1061
+ }
1062
+ >;
1063
+
1064
+ /**
1065
+ * A map of package names to versions that your package depends on.
1066
+ * These dependencies are used for overrides.
1067
+ */
1068
+ overrides?: Record<string, string | Record<string, string>>;
1069
+
1070
+ /**
1071
+ * A map of package names to versions that your package depends on.
1072
+ * These dependencies are used for resolutions.
1073
+ */
1074
+ resolutions?: Record<string, string>;
1075
+
1076
+ /**
1077
+ * A map of package names to versions that your package depends on.
1078
+ * These dependencies are used for workspaces.
1079
+ */
1080
+ workspaces?:
1081
+ | string[]
1082
+ | {
1083
+ packages?: string[];
1084
+ nohoist?: string[];
1085
+ };
1086
+
1087
+ /**
1088
+ * The package's publish configuration.
1089
+ */
1090
+ publishConfig?: {
1091
+ access?: 'public' | 'restricted';
1092
+ registry?: string;
1093
+ tag?: string;
1094
+ };
1095
+
1096
+ /**
1097
+ * The package's funding information.
1098
+ * Can be a string or an object with type and url.
1099
+ */
1100
+ funding?:
1101
+ | string
1102
+ | {
1103
+ type?: string;
1104
+ url: string;
1105
+ };
1106
+
1107
+ /**
1108
+ * The package's exports field.
1109
+ * Specifies which module should be used when the package is imported.
1110
+ */
1111
+ exports?: string | Record<string, string | Record<string, string>>;
1112
+
1113
+ /**
1114
+ * The package's imports field.
1115
+ * Specifies internal package imports.
1116
+ */
1117
+ imports?: Record<string, string | Record<string, string>>;
1118
+
1119
+ /**
1120
+ * The package's type.
1121
+ * Can be "commonjs" or "module".
1122
+ */
1123
+ type?: 'commonjs' | 'module';
1124
+
1125
+ /**
1126
+ * The package's side effects.
1127
+ * Can be a boolean or an array of strings.
1128
+ */
1129
+ sideEffects?: boolean | string[];
1130
+
1131
+ /**
1132
+ * The package's private flag.
1133
+ * If true, prevents the package from being published.
1134
+ */
1135
+ private?: boolean;
1136
+
1137
+ /**
1138
+ * The options available in `tochibuild.config.ts` Not all of them are available from CLI flags
1139
+ */
1140
+ tochibuild?: BuildOptions;
1141
+
1142
+ /**
1143
+ * The options available in `tsup.config.ts` Not all of them are available from CLI flags
1144
+ */
1145
+ tsup?: BuildOptions;
1146
+ }
1147
+
1148
+
1149
+ // ---- shims.d.ts ----
1150
+ declare module '@npmcli/arborist' {
1151
+ export interface Node {
1152
+ name: string;
1153
+ path: string;
1154
+ realpath: string;
1155
+ package: Record<string, any>;
1156
+ isLink?: boolean;
1157
+ isRoot?: boolean;
1158
+ children?: Map<string, Node>;
1159
+ }
1160
+
1161
+ export default class Arborist {
1162
+ constructor(options: { path: string });
1163
+ loadActual(): Promise<Node>;
1164
+ }
1165
+ }
1166
+
1167
+ declare module 'npm-packlist' {
1168
+ export default function packlist(tree: {
1169
+ name: string;
1170
+ path: string;
1171
+ realpath: string;
1172
+ package: Record<string, any>;
1173
+ isLink?: boolean;
1174
+ isRoot?: boolean;
1175
+ children?: Map<string, any>;
1176
+ }): Promise<string[]>;
1177
+ }
1178
+
1179
+
1180
+ // ---- tarball.d.ts ----
1181
+ /**
1182
+ * Options for creating a publishable tarball from a package.
1183
+ */
1184
+ interface PublishCreateOptions {
1185
+ /**
1186
+ * Path to the original package directory (relative/absolute).
1187
+ */
1188
+ packageDir: string;
1189
+
1190
+ /**
1191
+ * Custom `package.json` content to include in the tarball.
1192
+ *
1193
+ * If undefined then the original `package.json` will be used.
1194
+ */
1195
+ packageJsonData: PackageJsonOptions | undefined;
1196
+
1197
+ /**
1198
+ * Output path for the generated `.tgz` tarball (relative/absolute).
1199
+ *
1200
+ * @default 'tochibuild.package.tgz'
1201
+ */
1202
+ outputTarballPath?: string;
1203
+ }
1204
+
1205
+ /**
1206
+ * Result returned after successfully creating the tarball.
1207
+ */
1208
+ interface PublishCreateResult {
1209
+ /**
1210
+ * The name of the package (from the custom `package.json`).
1211
+ */
1212
+ name: string;
1213
+
1214
+ /**
1215
+ * Relative path (from `process.cwd()`) to the generated tarball.
1216
+ */
1217
+ tarballRelativePath: string;
1218
+
1219
+ /**
1220
+ * Absolute path to the generated tarball.
1221
+ */
1222
+ tarballPath: string;
1223
+
1224
+ /**
1225
+ * List of files included in the tarball (based on npm-packlist).
1226
+ */
1227
+ fileList: string[];
1228
+ }
1229
+
42
1230
 
43
- export { BuildUtils, type DefineConfigOptions, type DefineConfigOptionsCommonEntries, type DefineConfigOptionsIndexEntries, _default as default, defineConfig, defineConfigWithCommonEntries, defineConfigWithIndexEntries };
1231
+ // ---- types.d.ts ----
1232
+ /// <reference types="tsup" />
1233
+
1234
+ type TsupOptions = import('tsup').Options;
1235
+
1236
+ /**
1237
+ * The options available in tochibuild.config.ts
1238
+ *
1239
+ * Not all of them are available from CLI flags
1240
+ */
1241
+ interface BuildOptions extends TsupOptions {}
1242
+
1243
+ /**
1244
+ * The options available in tochibuild.config.ts including { `tochibuildConfig`: {@link TochibuildConfig} }
1245
+ *
1246
+ * Not all of them are available from CLI flags
1247
+ */
1248
+ type BuildOptionsWithConfig<
1249
+ TPackageManager extends
1250
+ | keyof BuildLifecycleRegistry
1251
+ | (string & {}) = keyof BuildLifecycleRegistry,
1252
+ > = BuildOptions & {
1253
+ tochibuildConfig?: TochibuildConfig<TPackageManager>;
1254
+ };
1255
+
1256
+ type MaybePromise<T> = T | Promise<T>;
1257
+ type MaybeArray<T> = T | T[];
1258
+
1259
+ type ConditionalType<IfType, ExtendsThisType, ThenA, ElseB> = IfType extends ExtendsThisType
1260
+ ? ThenA
1261
+ : ElseB;
1262
+
1263
+ type BuildOptionsParam<RequiredKeys extends keyof BuildOptions = any> = MaybeArray<
1264
+ WithRequired<BuildOptions, RequiredKeys>
1265
+ >;
1266
+
1267
+ /**
1268
+ * Override the config file options with the options derived from CLI flags
1269
+ * @param cliOptions the options derived from CLI flags
1270
+ */
1271
+ type BuildOptionsOverrideParam<RequiredKeys extends keyof BuildOptions = any> = (
1272
+ cliOptions: BuildOptions
1273
+ ) => MaybePromise<BuildOptionsParam<RequiredKeys>>;
1274
+
1275
+ type BuildOptionsParams<RequiredKeys extends keyof BuildOptions = any> =
1276
+ | BuildOptionsParam<RequiredKeys>
1277
+ | BuildOptionsOverrideParam<RequiredKeys>;
1278
+
1279
+ type BuildOptionsResultValue<RequiredKeys extends keyof BuildOptionsWithConfig = any> = MaybeArray<
1280
+ WithRequired<BuildOptionsWithConfig, RequiredKeys>
1281
+ >;
1282
+
1283
+ /**
1284
+ * Override the config file options with the options derived from CLI flags
1285
+ * @param cliOptions the options derived from CLI flags
1286
+ */
1287
+ type BuildOptionsResultOverrideValue<RequiredKeys extends keyof BuildOptionsWithConfig = any> = (
1288
+ cliOptions: BuildOptionsWithConfig
1289
+ ) => MaybePromise<BuildOptionsResultValue<RequiredKeys>>;
1290
+
1291
+ type BuildOptionsResult<RequiredKeys extends keyof BuildOptionsWithConfig = any> =
1292
+ | BuildOptionsResultValue<RequiredKeys>
1293
+ | BuildOptionsResultOverrideValue<RequiredKeys>;
1294
+
1295
+ type TochibuildConfig<
1296
+ TPackageManager extends
1297
+ | keyof BuildLifecycleRegistry
1298
+ | (string & {}) = keyof BuildLifecycleRegistry,
1299
+ > = {
1300
+ /**
1301
+ * @default false
1302
+ */
1303
+ includePackageJsonDeps?: boolean;
1304
+
1305
+ /**
1306
+ * @default false
1307
+ */
1308
+ includePackageJsonDevDeps?: boolean;
1309
+
1310
+ /**
1311
+ * @default false
1312
+ */
1313
+ includePackageJsonPeerDeps?: boolean;
1314
+ defaultBuildOptions?: BuildOptions;
1315
+
1316
+ /**
1317
+ * @default false
1318
+ */
1319
+ excludeIgnoredEntries?: boolean;
1320
+
1321
+ /**
1322
+ * Customize what happens before and after the build process using {@link BuildLifecycleOptions} (eg. publishing, deprecating, custom hooks, etc.)
1323
+ */
1324
+ lifecycle?: BuildLifecycleOptions<TPackageManager>;
1325
+ };
1326
+
1327
+ type MergeConfigOverride = {
1328
+ /**
1329
+ * The parameter (`opts:` {@link BuildOptionsResult}) from {@link mergeOptions} may be a function and therefore you should:
1330
+ *
1331
+ * - set `execute` to `true` if `opts` was dynamically imported from a module (config file) and should be resolved to get the final options.
1332
+ * - set `execute` to `false` if `opts` is not supposed to be resolved yet.
1333
+ */
1334
+ execute: true;
1335
+
1336
+ /**
1337
+ * Override the config file options with these options
1338
+ */
1339
+ overrideOptions: BuildOptionsWithConfig;
1340
+ };
1341
+
1342
+ type MergeConfigModify = {
1343
+ /**
1344
+ * Override the config file options with the options derived from CLI flags
1345
+ * @param cliOptions the options derived from CLI flags
1346
+ */
1347
+ overrideOptions: (cliOptions: BuildOptionsWithConfig) => BuildOptionsWithConfig;
1348
+
1349
+ /**
1350
+ * Override the result of `overrideOptions` with these options
1351
+ */
1352
+ overrideOptionsCustom?: BuildOptionsWithConfig;
1353
+ };
1354
+
1355
+ type MergeBuildOptionsConfig = MergeConfigModify;
1356
+ type MergeBuildOptionsConfigAsync = MergeConfigOverride | (MergeConfigModify & { execute?: false });