@reliverse/relico 1.3.1 → 1.3.2

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.
@@ -1,1066 +0,0 @@
1
- // ==========================================================================
2
- // Dler & Relinka Types
3
- // ==========================================================================
4
-
5
- /**
6
- * Defines the configuration for building and publishing packages. This includes: versioning,
7
- * build settings, publishing options, libraries-dler-plugin built-in plugin, and more.
8
- * It customizes the build and publish pipeline for both NPM and JSR registries.
9
- */
10
- export interface DlerConfig {
11
- // ==========================================================================
12
- // Bump configuration
13
- // ==========================================================================
14
- /**
15
- * When `true`, disables version bumping.
16
- * Useful when retrying a failed publish with an already bumped version.
17
- *
18
- * @default false
19
- */
20
- bumpDisable: boolean;
21
-
22
- /**
23
- * Controls which files will have their version numbers updated during version bumping.
24
- *
25
- * Accepts:
26
- * - Standard file types like "package.json"
27
- * - Relative paths like "src/constants.ts"
28
- * - [Globbing patterns](https://github.com/mrmlnc/fast-glob#pattern-syntax)
29
- *
30
- * When empty, falls back to only updating "package.json".
31
- * Respects: .gitignore patterns, hidden files, .git & node_modules.
32
- *
33
- * @default ["package.json", ".config/rse.ts"]
34
- */
35
- bumpFilter: string[];
36
-
37
- /**
38
- * Specifies how the version number should be incremented:
39
- * - `patch`: Increments the patch version for backwards-compatible bug fixes (1.2.3 → 1.2.4)
40
- * - `minor`: Increments the minor version for new backwards-compatible features (1.2.3 → 1.3.0)
41
- * - `major`: Increments the major version for breaking changes (1.2.3 → 2.0.0)
42
- * - `auto`: Automatically determine the appropriate bump type
43
- * - `manual`: Set a specific version (requires bumpSet to be set)
44
- *
45
- * Please note: `dler` infers the version from the `package.json` file.
46
- *
47
- * @default "patch"
48
- */
49
- bumpMode: BumpMode;
50
-
51
- /**
52
- * Custom version to set when bumpMode is "manual".
53
- * Must be a valid semver version (e.g., "1.2.3").
54
- *
55
- * @default ""
56
- */
57
- bumpSet: string;
58
-
59
- // ==========================================================================
60
- // Common configuration
61
- // ==========================================================================
62
-
63
- /**
64
- * When `true`, stops after building and retains distribution folders.
65
- * Useful for development or inspecting the build output.
66
- *
67
- * @default true
68
- */
69
- commonPubPause: boolean;
70
-
71
- /**
72
- * Specifies which package registries to publish to:
73
- * - `npm`: Publish only to the NPM commonPubRegistry.
74
- * - `jsr`: Publish only to the JSR commonPubRegistry.
75
- * - `npm-jsr`: Publish to both NPM and JSR registries.
76
- *
77
- * @default "npm"
78
- */
79
- commonPubRegistry: "jsr" | "npm" | "npm-jsr";
80
-
81
- /**
82
- * When `true`, enables detailed logs during the build and publish process.
83
- * Useful for debugging or understanding the build flow.
84
- *
85
- * @default false
86
- */
87
- commonVerbose: boolean;
88
-
89
- /**
90
- * When `true`, displays detailed build and publish logs.
91
- * When `false`, only shows spinner with status messages during build and publish.
92
- *
93
- * @default true
94
- */
95
- displayBuildPubLogs: boolean;
96
-
97
- // ==========================================================================
98
- // Core configuration
99
- // ==========================================================================
100
-
101
- /**
102
- * When `true`, generates TypeScript declaration files (.d.ts) for NPM packages.
103
- * Essential for providing type intranspileFormation to TypeScript users.
104
- *
105
- * To reduce bundle size you can set this to `false` if your main project
106
- * is planned to be used only as a global CLI tool (e.g. `bunx dler`).
107
- *
108
- * @default true
109
- */
110
- coreDeclarations: boolean;
111
-
112
- /**
113
- * Path to the project's main entry file.
114
- * Used as the entry point for the NPM package.
115
- *
116
- * @default "mod.ts"
117
- */
118
- coreEntryFile: string;
119
-
120
- /**
121
- * Base directory containing the source entry files.
122
- * All paths are resolved relative to this directory.
123
- * Set to `"."` if entry files are in the project root.
124
- *
125
- * @default "src"
126
- */
127
- coreEntrySrcDir: string;
128
-
129
- /**
130
- * Directory where built files will be placed within the distribution directory.
131
- * For example, if set to "bin", CLI scripts will be placed in "dist-npm/bin" or "dist-jsr/bin".
132
- *
133
- * @default "bin"
134
- */
135
- coreBuildOutDir: string;
136
-
137
- /**
138
- * Configuration for CLI functionality:
139
- * - enabled: When `true`, indicates that the package has CLI capabilities
140
- * - scripts: Map of CLI script names to their entry file paths
141
- * The key will be used as the command name in package.json's bin field
142
- * The value should be the path to the executable script (e.g. "cli.ts")
143
- *
144
- * **The source scripts should be in your "coreEntrySrcDir" directory (by default "src")**
145
- *
146
- * @example
147
- * {
148
- * enabled: true,
149
- * scripts: {
150
- * "mycli": "cli.ts",
151
- * "othercmd": "other-cmd.ts"
152
- * }
153
- * }
154
- *
155
- * @default { enabled: false, scripts: {} }
156
- */
157
- coreIsCLI: {
158
- enabled: boolean;
159
- scripts: Record<string, string>;
160
- };
161
-
162
- /**
163
- * Optional description that overrides the description from package.json.
164
- * When provided, this description will be used in the dist's package.json.
165
- * If not provided, the description from the original package.json will be used.
166
- *
167
- * @default `package.json`'s "description"
168
- */
169
- coreDescription: string;
170
-
171
- // ==========================================================================
172
- // JSR-only config
173
- // ==========================================================================
174
-
175
- /**
176
- * When `true`, allows JSR publishing even with uncommitted changes.
177
- * Use with caution, as it may lead to inconsistent published versions.
178
- *
179
- * It is `true` by default to make it easier for new `dler` users to publish their projects.
180
- *
181
- * @default true
182
- */
183
- distJsrAllowDirty: boolean;
184
-
185
- /**
186
- * The bundler to use for creating JSR-compatible packages.
187
- * JSR's native bundler is recommended for best compatibility.
188
- *
189
- * @default "jsr"
190
- */
191
- distJsrBuilder: BundlerName;
192
-
193
- /**
194
- * Directory where JSR build artifacts are generated.
195
- * This directory will contain the package ready for JSR publishing.
196
- *
197
- * @default "dist-jsr"
198
- */
199
- distJsrDirName: string;
200
-
201
- /**
202
- * When `true`, simulates the publishing process without actually publishing.
203
- * Useful for testing the build and publish pipeline without side effects.
204
- *
205
- * @default false
206
- */
207
- distJsrDryRun: boolean;
208
-
209
- /**
210
- * When `true`, fails the build if warnings are detected.
211
- * Use with caution, as it may lead to inconsistent published versions.
212
- *
213
- * @default false
214
- */
215
- distJsrFailOnWarn: boolean;
216
-
217
- /**
218
- * When `true`, generates a `jsconfig.json` file for JSR's dist.
219
- *
220
- * @default false
221
- */
222
- distJsrGenTsconfig: boolean;
223
-
224
- /**
225
- * The file extension for output files in JSR packages.
226
- *
227
- * @default "ts"
228
- */
229
- distJsrOutFilesExt: NpmOutExt;
230
-
231
- /**
232
- * When `true`, enables JSR to process complex types, which may impact performance.
233
- * Enable this only if you cannot simplify or explicitly define exported types.
234
- *
235
- * JSR requires exported functions, classes, variables, and type aliases to have
236
- * explicitly written or easily inferred types. Otherwise, it may be unable to
237
- * generate documentation, type declarations for npm compatibility, or efficient
238
- * type checking for consumers.
239
- *
240
- * If "slow types" are present, type checking performance may degrade, and some
241
- * features may not work as expected.
242
- *
243
- * It is `true` by default to make it easier for new `dler` users to publish their projects.
244
- *
245
- * @see https://jsr.io/docs/about-slow-types
246
- * @default true
247
- */
248
- distJsrSlowTypes: boolean;
249
-
250
- // ==========================================================================
251
- // NPM-only config
252
- // ==========================================================================
253
-
254
- /**
255
- * The bundler to use for creating NPM-compatible packages.
256
- *
257
- * @default "mkdist"
258
- */
259
- distNpmBuilder: BundlerName;
260
-
261
- /**
262
- * Directory where NPM build artifacts are generated.
263
- * This directory will contain the package ready for NPM publishing.
264
- *
265
- * @default "dist-npm"
266
- */
267
- distNpmDirName: string;
268
-
269
- /**
270
- * Specifies the file extension for output files in NPM packages.
271
- * Determines the extension of compiled files in the NPM distribution.
272
- * We strongly recommend using `"js"` with the `"esm"` transpileFormat.
273
- *
274
- * @default "js"
275
- */
276
- distNpmOutFilesExt: NpmOutExt;
277
-
278
- // ==========================================================================
279
- // Libraries Dler Plugin
280
- // ==========================================================================
281
-
282
- /**
283
- * !! EXPERIMENTAL !!
284
- * Controls which parts of the project are built and published:
285
- * - `main-project-only`: Builds/publishes only the main package.
286
- * - `main-and-libs`: Builds/publishes both the main package and libraries.
287
- * - `libs-only`: Builds/publishes only the libraries.
288
- *
289
- * @default "main-project-only"
290
- */
291
- libsActMode: "libs-only" | "main-and-libs" | "main-project-only";
292
-
293
- /**
294
- * The directory where built libraries are stored before publishing.
295
- *
296
- * @default "dist-libs"
297
- */
298
- libsDirDist: string;
299
-
300
- /**
301
- * The directory containing library source files.
302
- *
303
- * @default "src/libs"
304
- */
305
- libsDirSrc: string;
306
-
307
- /**
308
- * !! EXPERIMENTAL !!
309
- * Configuration for building and publishing multiple libraries.
310
- * Each key represents a package name, and its value contains the configuration.
311
- *
312
- * @example
313
- * {
314
- * "@myorg/ml1": { main: "my-lib-1/mod.ts" },
315
- * "@myorg/ml2": { main: "my-lib-2/ml2-mod.ts" },
316
- * "@myorg/ml3": { main: "src/libs/my-lib-3/index.js" }
317
- * }
318
- */
319
- libsList: Record<string, LibConfig>;
320
-
321
- // ==========================================================================
322
- // Logger setup
323
- // ==========================================================================
324
-
325
- /**
326
- * The name of the log file. dler uses `@reliverse/relinka` for logging.
327
- *
328
- * @default ".logs/relinka.log"
329
- */
330
- logsFileName: string;
331
-
332
- /**
333
- * When `true`, cleans up the log file from previous runs.
334
- *
335
- * @default false
336
- */
337
- logsFreshFile: boolean;
338
-
339
- // ==========================================================================
340
- // Dependency filtering
341
- // ==========================================================================
342
-
343
- /**
344
- * Configuration for dependency removal/injection patterns.
345
- * Controls which dependencies are excluded from (or injected into) the final package.
346
- *
347
- * Pattern types:
348
- * - Regular patterns: Exclude deps that match the pattern
349
- * - Negation patterns (starting with !): Don't exclude deps that match the pattern
350
- * - Add patterns (starting with +): Inject deps into specific dists even if original package.json doesn't have them
351
- *
352
- * Structure (dist-specific patterns are merged with global):
353
- * - `global`: Patterns that are always applied to all builds
354
- * - `dist-npm`: NPM-specific patterns
355
- * - `dist-jsr`: JSR-specific patterns
356
- * - `dist-libs`: Library-specific patterns
357
- * Each library can have separate NPM and JSR patterns
358
- *
359
- * @example
360
- * {
361
- * global: ["@types", "eslint"],
362
- * "dist-npm": ["npm-specific"],
363
- * "dist-jsr": ["+bun"], // Explicitly include 'bun' in JSR builds
364
- * "dist-libs": {
365
- * "@myorg/lib1": {
366
- * npm: ["lib1-npm-specific"],
367
- * jsr: ["+bun"] // Explicitly include 'bun' in this lib's JSR build
368
- * }
369
- * }
370
- * }
371
- */
372
- filterDepsPatterns: {
373
- global: string[];
374
- "dist-npm": string[];
375
- "dist-jsr": string[];
376
- "dist-libs": Record<
377
- string,
378
- {
379
- npm: string[];
380
- jsr: string[];
381
- }
382
- >;
383
- };
384
-
385
- // ==========================================================================
386
- // Code quality tools
387
- // ==========================================================================
388
-
389
- /**
390
- * List of tools to run before the build process starts.
391
- * Available options: "tsc", "eslint", "biome", "knip", "dler-check"
392
- * Each tool will only run if it's installed in the system.
393
- *
394
- * @default []
395
- */
396
- runBeforeBuild: ("tsc" | "eslint" | "biome" | "knip" | "dler-check")[];
397
-
398
- /**
399
- * List of tools to run after the build process completes.
400
- * Available options: "dler-check"
401
- * Each tool will only run if it's installed in the system.
402
- *
403
- * @default []
404
- */
405
- runAfterBuild: "dler-check"[];
406
-
407
- // ==========================================================================
408
- // Build hooks
409
- // ==========================================================================
410
-
411
- /**
412
- * Array of functions to be executed before the build process starts.
413
- * These hooks will be called in sequence before any build steps.
414
- *
415
- * If you are a dler plugin developer, tell your users to
416
- * call your plugin's `beforeBuild`-related function here.
417
- *
418
- * @example
419
- * hooksBeforeBuild: [
420
- * async () => {
421
- * // Custom pre-build logic
422
- * await someAsyncOperation();
423
- *
424
- * // dler-plugin-my-plugin-name
425
- * await myPluginName_beforeBuild();
426
- * }
427
- * ]
428
- *
429
- * @default []
430
- */
431
- hooksBeforeBuild: (() => Promise<void>)[];
432
-
433
- /**
434
- * Array of functions to be executed after the build process completes.
435
- * These hooks will be called in sequence after all build steps.
436
- *
437
- * If you are a dler plugin developer, tell your users to
438
- * call your plugin's `afterBuild`-related function here.
439
- *
440
- * @example
441
- * hooksAfterBuild: [
442
- * async () => {
443
- * // Custom post-build logic
444
- * await someAsyncOperation();
445
- *
446
- * // dler-plugin-my-plugin-name
447
- * await myPluginName_afterBuild();
448
- * }
449
- * ]
450
- *
451
- * @default []
452
- */
453
- hooksAfterBuild: (() => Promise<void>)[];
454
-
455
- /**
456
- * When `true`, cleans up the temporary directories after the build process completes.
457
- *
458
- * @default true
459
- */
460
- postBuildSettings: {
461
- deleteDistTmpAfterBuild: boolean;
462
- };
463
-
464
- // ==========================================================================
465
- // Build setup
466
- // ==========================================================================
467
-
468
- /**
469
- * When `true`, fails the build if warnings are detected.
470
- * Use with caution, as it may lead to inconsistent published versions.
471
- *
472
- * @default false
473
- */
474
- transpileFailOnWarn: boolean;
475
-
476
- /**
477
- * The transpileTarget runtime environment for the built package.
478
- *
479
- * @default "es2023"
480
- */
481
- transpileEsbuild: Esbuild;
482
-
483
- /**
484
- * Output module transpileFormat for built files:
485
- * - `esm`: ECMAScript modules (import/export)
486
- * - `cjs`: CommonJS modules (require/exports)
487
- * - `iife`: Immediately Invoked Function Expression (for browsers)
488
- *
489
- * @default "esm"
490
- */
491
- transpileFormat: transpileFormat;
492
-
493
- /**
494
- * When `true`, minifies the output to reduce bundle size.
495
- * Recommended for production builds but may increase build time.
496
- *
497
- * @default true
498
- */
499
- transpileMinify: boolean;
500
-
501
- /**
502
- * The base URL for loading assets in the built package.
503
- * Important for packages that include assets like images or fonts.
504
- *
505
- * @default "/"
506
- */
507
- transpilePublicPath: string;
508
-
509
- /**
510
- * Controls source map generation for debugging (experimental):
511
- * - `true/false`: Enable/disable source maps.
512
- * - `"inline"`: Include source maps within output files.
513
- * - `"none"`: Do not generate source maps.
514
- * - `"linked"`: Generate separate source map files with links.
515
- * - `"external"`: Generate separate source map files.
516
- *
517
- * @default false
518
- */
519
- transpileSourcemap: Sourcemap;
520
-
521
- /**
522
- * When `true`, enables code transpileSplitting for improved load-time performance.
523
- * Useful for large applications but may not be needed for small projects.
524
- *
525
- * @default false
526
- */
527
- transpileSplitting: boolean;
528
-
529
- /**
530
- * Stub the package for JIT compilation.
531
- *
532
- * @default false
533
- */
534
- transpileStub: boolean;
535
-
536
- /**
537
- * Defines the transpileTarget runtime environment:
538
- * - `node`: Optimized for Node.js.
539
- * - `bun`: Optimized for Bun.
540
- * - `browser`: Optimized for web browsers.
541
- *
542
- * @default "node"
543
- */
544
- transpileTarget: transpileTarget;
545
-
546
- /**
547
- * Watch the src dir and rebuild on change (experimental).
548
- *
549
- * @default false
550
- */
551
- transpileWatch: boolean;
552
-
553
- /**
554
- * Specifies what resources to send to npm and jsr registries.
555
- * coreBuildOutDir (e.g. "bin") dir is automatically included.
556
- * The following is also included if publishArtifacts is {}:
557
- * - global: ["package.json", "README.md", "LICENSE"]
558
- * - dist-jsr,dist-libs/jsr: ["jsr.json"]
559
- *
560
- * Structure:
561
- * - `global`: Files to include in all distributions
562
- * - `dist-jsr`: Files specific to JSR distribution
563
- * - `dist-npm`: Files specific to NPM distribution
564
- * - `dist-libs`: Library-specific files for each distribution type
565
- *
566
- * Useful for including additional files like configuration or documentation.
567
- * Pro tip: set jsr.jsonc to generate jsr.jsonc instead of jsr.json config.
568
- *
569
- * @default
570
- * {
571
- * global: ["bin", "package.json", "README.md", "LICENSE"],
572
- * "dist-jsr": ["jsr.json"],
573
- * "dist-npm": [],
574
- * "dist-libs": {
575
- * "@myorg/lib1": {
576
- * jsr: ["jsr.json"],
577
- * npm: []
578
- * }
579
- * }
580
- * }
581
- */
582
- publishArtifacts?: {
583
- global: string[];
584
- "dist-jsr": string[];
585
- "dist-npm": string[];
586
- "dist-libs": Record<
587
- string,
588
- {
589
- jsr: string[];
590
- npm: string[];
591
- }
592
- >;
593
- };
594
-
595
- // Files with these extensions will be built
596
- // Any other files will be copied as-is to dist
597
- /**
598
- * File extensions that should be copied to temporary build directories during pre-build.
599
- * These files will be processed by the bundlers.
600
- * All other files will be copied as-is to final dist directories during post-build.
601
- * @default ["ts", "js"]
602
- */
603
- buildPreExtensions: string[];
604
-
605
- // If you need to exclude some ts/js files from being built,
606
- // you can store them in the dirs with buildTemplatesDir name
607
- /**
608
- * Directory name for templates that should be excluded from pre-build processing.
609
- * Files in this directory will be copied as-is during post-build.
610
- * @default "templates"
611
- */
612
- buildTemplatesDir: string;
613
-
614
- // ==========================================================================
615
- // Relinka Logger Configuration
616
- // ==========================================================================
617
-
618
- /**
619
- * Integrated relinka logger configuration.
620
- * @see https://github.com/reliverse/relinka
621
- *
622
- * @default See DEFAULT_RELINKA_CONFIG in defaults
623
- */
624
- relinka: RelinkaConfig;
625
- }
626
-
627
- export type BumpMode = "patch" | "minor" | "major" | "auto" | "manual";
628
-
629
- /**
630
- * Supported bundler names for building packages:
631
- * - bun: Bun's built-in bundler for fast builds
632
- * - copy: A simple file copy without bundling
633
- * - jsr: Similar to copy but optimized for the JSR commonPubRegistry
634
- * - mkdist: A lightweight bundler focused on TypeScript/ESM
635
- * - rollup: A traditional bundler with an extensive plugin ecosystem
636
- * - untyped: Types and markdown generation from a config object
637
- */
638
- export type BundlerName = "bun" | "copy" | "jsr" | "mkdist" | "rollup" | "untyped";
639
-
640
- export type NpmOutExt = "cjs" | "cts" | "js" | "mjs" | "mts" | "ts";
641
-
642
- /**
643
- * Configuration for a library to be built and published as a separate package.
644
- * Used when publishing multiple packages from a single repository.
645
- */
646
- export interface LibConfig {
647
- /**
648
- * When `true`, generates TypeScript declaration files (.d.ts) for NPM packages.
649
- */
650
- libDeclarations: boolean;
651
-
652
- /**
653
- * An optional description of the library, included in the dist's package.json.
654
- * Provides users with an overview of the library's purpose.
655
- *
656
- * @example "Utility functions for data manipulation"
657
- * @example "Core configuration module for the framework"
658
- *
659
- * @default `package.json`'s "description"
660
- */
661
- libDescription: string;
662
-
663
- /**
664
- * The directory where the library's dist files are stored.
665
- *
666
- * @default name is derived from the library's name after slash
667
- */
668
- libDirName: string;
669
-
670
- /**
671
- * The path to the library's main entry file.
672
- * This file serves as the primary entry point for imports.
673
- * The path should be relative to the project root.
674
- * The full path to the library's main file is derived by joining `libsDirDist` with `main`.
675
- *
676
- * @example "my-lib-1/mod.ts"
677
- * @example "my-lib-2/ml2-mod.ts"
678
- * @example "src/libs/my-lib-3/index.js"
679
- */
680
- libMainFile: string;
681
-
682
- /**
683
- * Dependencies to include in the dist's package.json.
684
- * The final output may vary based on `filterDepsPatterns`.
685
- * Defines how dependencies are handled during publishing:
686
- * - `string[]`: Includes only the specified dependencies.
687
- * - `true`: Includes all dependencies from the main package.json.
688
- * - `false` or `undefined`: Automatically determines dependencies based on imports.
689
- *
690
- * @example ["@reliverse/pathkit", "@reliverse/relifso"] - Only will include these specific dependencies.
691
- * @example true - Include all `dependencies` from the main package.json.
692
- */
693
- libPkgKeepDeps: boolean | string[];
694
-
695
- /**
696
- * When `true`, minifies the output to reduce bundle size.
697
- * Recommended for production builds but may increase build time.
698
- *
699
- * @default true
700
- */
701
- libTranspileMinify: boolean;
702
-
703
- /**
704
- * When true, pauses publishing for this specific library (overridden by commonPubPause).
705
- * If true, this library will be built but not published, even if other libs are published.
706
- *
707
- * @default false
708
- */
709
- libPubPause?: boolean;
710
-
711
- /**
712
- * The registry to publish the library to.
713
- *
714
- * @default "npm"
715
- */
716
- libPubRegistry?: "jsr" | "npm" | "npm-jsr";
717
-
718
- /**
719
- * Optional version override for the library.
720
- * If not provided, falls back to the version from the main package.json.
721
- *
722
- * @default `package.json`'s "version"
723
- */
724
- version?: string;
725
- }
726
-
727
- export type Esbuild = "es2019" | "es2020" | "es2021" | "es2022" | "es2023";
728
-
729
- /**
730
- * Supported output module transpileFormats for built packages.
731
- * - esm: ECMAScript modules (import/export)
732
- * - cjs: CommonJS modules (require/exports)
733
- * - iife: Immediately Invoked Function Expression (for browsers)
734
- */
735
- export type transpileFormat = "cjs" | "esm" | "iife";
736
-
737
- /**
738
- * Supported source map options for built packages.
739
- * - boolean: Enable/disable source maps.
740
- * - "inline": Include source maps within output files.
741
- * - "none": Do not generate source maps.
742
- * - "linked": Generate separate source map files with links.
743
- * - "external": Generate separate source map files.
744
- */
745
- export type Sourcemap = "external" | "inline" | "linked" | "none" | boolean;
746
-
747
- /**
748
- * Supported transpileTarget runtime environments for built packages.
749
- * - node: Optimized for Node.js.
750
- * - bun: Optimized for Bun.
751
- * - browser: Optimized for web browsers.
752
- */
753
- export type transpileTarget = "browser" | "bun" | "node";
754
-
755
- /** Configuration for directory-related settings. */
756
- export interface RelinkaDirsConfig {
757
- maxLogFiles?: number;
758
- }
759
-
760
- /** Log level types used by the logger. */
761
- export type LogLevel =
762
- | "error"
763
- | "fatal"
764
- | "info"
765
- | "success"
766
- | "verbose"
767
- | "warn"
768
- | "log"
769
- | "internal"
770
- | "null"
771
- | "step"
772
- | "box"
773
- | "message";
774
-
775
- /** Configuration for a single log level. */
776
- export interface LogLevelConfig {
777
- /**
778
- * Symbol to display for this log level.
779
- * @see https://symbl.cc
780
- */
781
- symbol: string;
782
-
783
- /**
784
- * Fallback symbol to use if Unicode is not supported.
785
- */
786
- fallbackSymbol: string;
787
-
788
- /**
789
- * Color to use for this log level.
790
- */
791
- color: string;
792
-
793
- /**
794
- * Number of spaces after the symbol/fallback
795
- */
796
- spacing?: number;
797
- }
798
-
799
- /** Configuration for all log levels. */
800
- export type LogLevelsConfig = Partial<Record<LogLevel, LogLevelConfig>>;
801
-
802
- /**
803
- * Configuration options for the Relinka logger.
804
- * All properties are optional to allow for partial configuration.
805
- * Defaults will be applied during initialization.
806
- */
807
- export interface RelinkaConfig {
808
- /**
809
- * Enables verbose (aka debug) mode for detailed logging.
810
- *
811
- * `true` here works only for end-users of CLIs/libs when theirs developers
812
- * has been awaited for user's config via `@reliverse/relinka`'s `await relinkaConfig;`
813
- */
814
- verbose?: boolean;
815
-
816
- /**
817
- * Configuration for directory-related settings.
818
- * - `maxLogFiles`: The maximum number of log files to keep before cleanup.
819
- */
820
- dirs?: RelinkaDirsConfig;
821
-
822
- /**
823
- * Disables color output in the console.
824
- */
825
- disableColors?: boolean;
826
-
827
- /**
828
- * Configuration for log file output.
829
- */
830
- logFile?: {
831
- /**
832
- * Path to the log file.
833
- */
834
- outputPath?: string;
835
- /**
836
- * How to handle date in the filename.
837
- * - `disable`: No date prefix/suffix
838
- * - `append-before`: Add date before the filename (e.g., "2024-01-15-log.txt")
839
- * - `append-after`: Add date after the filename (e.g., "log-2024-01-15.txt")
840
- */
841
- nameWithDate?: "disable" | "append-before" | "append-after";
842
- /**
843
- * If true, clears the log file when relinkaConfig is executed with supportFreshLogFile: true.
844
- * This is useful for starting with a clean log file on each run.
845
- */
846
- freshLogFile?: boolean;
847
- };
848
-
849
- /**
850
- * If true, logs will be saved to a file.
851
- */
852
- saveLogsToFile?: boolean;
853
-
854
- /**
855
- * Configuration for timestamp in log messages.
856
- */
857
- timestamp?: {
858
- /**
859
- * If true, timestamps will be added to log messages.
860
- */
861
- enabled: boolean;
862
- /**
863
- * The format for timestamps. Default is YYYY-MM-DD HH:mm:ss.SSS
864
- */
865
- format?: string;
866
- };
867
-
868
- /**
869
- * Allows to customize the log levels.
870
- */
871
- levels?: LogLevelsConfig;
872
-
873
- /**
874
- * Controls how often the log cleanup runs (in milliseconds)
875
- * Default: 10000 (10 seconds)
876
- */
877
- cleanupInterval?: number;
878
-
879
- /**
880
- * Maximum size of the log write buffer before flushing to disk (in bytes)
881
- * Default: 4096 (4KB)
882
- */
883
- bufferSize?: number;
884
-
885
- /**
886
- * Maximum time to hold logs in buffer before flushing to disk (in milliseconds)
887
- * Default: 5000 (5 seconds)
888
- */
889
- maxBufferAge?: number;
890
- }
891
-
892
- /**
893
- * Default configuration for the build and publish logic.
894
- */
895
- export const DEFAULT_CONFIG_DLER: DlerConfig = {
896
- bumpDisable: false,
897
- bumpFilter: ["package.json", ".config/rse.ts"],
898
- bumpMode: "patch",
899
- bumpSet: "",
900
- commonPubPause: true,
901
- commonPubRegistry: "npm",
902
- commonVerbose: false,
903
- displayBuildPubLogs: true,
904
- coreDeclarations: true,
905
- coreDescription: "",
906
- coreEntryFile: "mod.ts",
907
- coreEntrySrcDir: "src",
908
- coreBuildOutDir: "bin",
909
- coreIsCLI: { enabled: false, scripts: {} },
910
- distJsrAllowDirty: true,
911
- distJsrBuilder: "jsr",
912
- distJsrDirName: "dist-jsr",
913
- distJsrDryRun: false,
914
- distJsrFailOnWarn: false,
915
- distJsrGenTsconfig: false,
916
- distJsrOutFilesExt: "ts",
917
- distJsrSlowTypes: true,
918
- distNpmBuilder: "mkdist",
919
- distNpmDirName: "dist-npm",
920
- distNpmOutFilesExt: "js",
921
- libsActMode: "main-project-only",
922
- libsDirDist: "dist-libs",
923
- libsDirSrc: "src/libs",
924
- libsList: {},
925
- logsFileName: ".logs/relinka.log",
926
- logsFreshFile: true,
927
-
928
- // Dependency filtering
929
- filterDepsPatterns: {
930
- global: ["@types", "biome", "eslint", "knip", "prettier", "typescript", "@reliverse/dler"],
931
- "dist-npm": [],
932
- "dist-jsr": [],
933
- "dist-libs": {},
934
- },
935
-
936
- // Code quality tools
937
- runBeforeBuild: [], // tsc, eslint, biome, knip, dler-check
938
- runAfterBuild: [], // dler-check
939
-
940
- // Build hooks
941
- hooksBeforeBuild: [
942
- // async () => {
943
- // await someAsyncOperation();
944
- // }
945
- ],
946
- hooksAfterBuild: [
947
- // async () => {
948
- // await someAsyncOperation();
949
- // }
950
- ],
951
-
952
- postBuildSettings: {
953
- deleteDistTmpAfterBuild: true,
954
- },
955
-
956
- // Build setup
957
- transpileFailOnWarn: false,
958
- transpileEsbuild: "es2023",
959
- transpileFormat: "esm",
960
- transpileMinify: true,
961
- transpilePublicPath: "/",
962
- transpileSourcemap: "none",
963
- transpileSplitting: false,
964
- transpileStub: false,
965
- transpileTarget: "node",
966
- transpileWatch: false,
967
-
968
- // Publish artifacts configuration
969
- publishArtifacts: {
970
- global: ["package.json", "README.md", "LICENSE"],
971
- "dist-jsr": [],
972
- "dist-npm": [],
973
- "dist-libs": {},
974
- },
975
-
976
- // Files with these extensions will be built
977
- // Any other files will be copied as-is to dist
978
- buildPreExtensions: ["ts", "js"],
979
- // If you need to exclude some ts/js files from being built,
980
- // you can store them in the dirs with buildTemplatesDir name
981
- buildTemplatesDir: "templates",
982
-
983
- // Integrated relinka logger configuration
984
- relinka: {
985
- verbose: false,
986
- dirs: {
987
- maxLogFiles: 5,
988
- },
989
- disableColors: false,
990
- logFile: {
991
- outputPath: "logs.log",
992
- nameWithDate: "disable",
993
- freshLogFile: true,
994
- },
995
- saveLogsToFile: true,
996
- timestamp: {
997
- enabled: false,
998
- format: "HH:mm:ss",
999
- },
1000
- cleanupInterval: 10_000, // 10 seconds
1001
- bufferSize: 4096, // 4KB
1002
- maxBufferAge: 5000, // 5 seconds
1003
- levels: {
1004
- success: {
1005
- symbol: "✓",
1006
- fallbackSymbol: "[OK]",
1007
- color: "greenBright",
1008
- spacing: 3,
1009
- },
1010
- info: {
1011
- symbol: "i",
1012
- fallbackSymbol: "[i]",
1013
- color: "cyanBright",
1014
- spacing: 3,
1015
- },
1016
- error: {
1017
- symbol: "✖",
1018
- fallbackSymbol: "[ERR]",
1019
- color: "redBright",
1020
- spacing: 3,
1021
- },
1022
- warn: {
1023
- symbol: "⚠",
1024
- fallbackSymbol: "[WARN]",
1025
- color: "yellowBright",
1026
- spacing: 3,
1027
- },
1028
- fatal: {
1029
- symbol: "‼",
1030
- fallbackSymbol: "[FATAL]",
1031
- color: "redBright",
1032
- spacing: 3,
1033
- },
1034
- verbose: {
1035
- symbol: "✧",
1036
- fallbackSymbol: "[VERBOSE]",
1037
- color: "gray",
1038
- spacing: 3,
1039
- },
1040
- internal: {
1041
- symbol: "⚙",
1042
- fallbackSymbol: "[INTERNAL]",
1043
- color: "magentaBright",
1044
- spacing: 3,
1045
- },
1046
- log: { symbol: "│", fallbackSymbol: "|", color: "dim", spacing: 3 },
1047
- message: {
1048
- symbol: "🞠",
1049
- fallbackSymbol: "[MSG]",
1050
- color: "cyan",
1051
- spacing: 3,
1052
- },
1053
- },
1054
- },
1055
- };
1056
-
1057
- // TODO: implement migrator from build.config.ts to .config/dler.ts
1058
- // export function defineBuildConfig(
1059
- // config: UnifiedBuildConfig | UnifiedBuildConfig[],
1060
- // ): UnifiedBuildConfig[] {
1061
- // return (Array.isArray(config) ? config : [config]).filter(Boolean);
1062
- // }
1063
-
1064
- export const defineConfig = (userConfig: Partial<DlerConfig> = {}) => {
1065
- return { ...DEFAULT_CONFIG_DLER, ...userConfig };
1066
- };