@reliverse/config 2.2.9 → 2.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,3 +1,4 @@
1
+ import type { LoadedConfig } from "./config-loader.js";
1
2
  import { type BaseConfig } from "./core.js";
2
3
  import type { PackageKind } from "./publish.js";
3
4
  export interface AssetOptions {
@@ -78,6 +79,7 @@ export interface GoBuildOptions {
78
79
  }
79
80
  export interface PackageBuildConfig {
80
81
  enable?: boolean;
82
+ entry?: string | string[];
81
83
  bundler?: "bun" | "mkdist";
82
84
  target?: "browser" | "bun" | "node";
83
85
  format?: "esm" | "cjs" | "iife";
@@ -164,3 +166,11 @@ export declare const getPackageBuildConfig: (packageName: string, dlerConfig: {
164
166
  * Merge build options with package-specific configuration
165
167
  */
166
168
  export declare const mergeBuildOptions: <T extends Record<string, any>>(cliOptions: T, packageConfig?: PackageBuildConfig) => T;
169
+ /**
170
+ * Get package-specific build configuration from dler.config.ts (unified approach)
171
+ */
172
+ export declare const getPackageBuildConfigUnified: (packageName: string, dlerConfig: LoadedConfig | null) => Promise<PackageBuildConfig | undefined>;
173
+ /**
174
+ * Merge build options with package-specific configuration from dler.config.ts (unified approach)
175
+ */
176
+ export declare const mergeBuildOptionsUnified: <T extends Record<string, any>>(cliOptions: T, packageName: string, dlerConfig: LoadedConfig | null) => T;
@@ -1,10 +1,14 @@
1
1
  import { mergeConfig, resolvePackageConfig } from "./core.js";
2
2
  export const getPackageBuildConfig = async (packageName, dlerConfig) => {
3
- return resolvePackageConfig(
4
- packageName,
5
- dlerConfig?.build
6
- );
3
+ return resolvePackageConfig(packageName, dlerConfig?.build);
7
4
  };
8
5
  export const mergeBuildOptions = (cliOptions, packageConfig) => {
9
6
  return mergeConfig(cliOptions, packageConfig);
10
7
  };
8
+ export const getPackageBuildConfigUnified = async (packageName, dlerConfig) => {
9
+ return resolvePackageConfig(packageName, dlerConfig?.build);
10
+ };
11
+ export const mergeBuildOptionsUnified = (cliOptions, packageName, dlerConfig) => {
12
+ const packageConfig = getPackageBuildConfigUnified(packageName, dlerConfig);
13
+ return mergeConfig(cliOptions, packageConfig);
14
+ };
@@ -0,0 +1,37 @@
1
+ import type { BuildConfig } from "./build.js";
2
+ import type { PublishConfig } from "./publish.js";
3
+ export interface LoadedConfig {
4
+ name?: string;
5
+ version?: string;
6
+ description?: string;
7
+ commands?: {
8
+ manifest?: string;
9
+ directory?: string;
10
+ generateReport?: boolean;
11
+ };
12
+ build?: BuildConfig;
13
+ dev: {
14
+ watch: boolean;
15
+ inspect: boolean;
16
+ port?: number;
17
+ };
18
+ test: {
19
+ pattern: string | string[];
20
+ coverage: boolean;
21
+ watch: boolean;
22
+ };
23
+ workspace: {
24
+ packages?: string[];
25
+ shared?: any;
26
+ versionStrategy: "fixed" | "independent";
27
+ };
28
+ release: {
29
+ npm: boolean;
30
+ github: boolean;
31
+ tagFormat: string;
32
+ conventionalCommits: boolean;
33
+ };
34
+ plugins: any[];
35
+ publish?: PublishConfig;
36
+ }
37
+ export declare function loadConfig(cwd?: any): Promise<LoadedConfig>;
@@ -0,0 +1,67 @@
1
+ import { existsSync } from "node:fs";
2
+ import path from "node:path";
3
+ import { remptsConfigSchema } from "@reliverse/rempts-core";
4
+ const CONFIG_NAMES = ["dler.config.ts", "dler.config.js", "dler.config.mjs"];
5
+ function transformBuildConfig(build) {
6
+ if (!build) {
7
+ return void 0;
8
+ }
9
+ if (build.global || build.packages || build.patterns) {
10
+ return build;
11
+ }
12
+ return {
13
+ global: build
14
+ };
15
+ }
16
+ export async function loadConfig(cwd = process.cwd()) {
17
+ for (const configName of CONFIG_NAMES) {
18
+ const configPath = path.join(cwd, configName);
19
+ if (existsSync(configPath)) {
20
+ try {
21
+ const module = await import(configPath);
22
+ const validatedConfig2 = remptsConfigSchema.assert(module.default || module);
23
+ const config = {
24
+ ...validatedConfig2,
25
+ build: transformBuildConfig(validatedConfig2.build),
26
+ dev: validatedConfig2.dev ?? { watch: true, inspect: false },
27
+ test: validatedConfig2.test ?? {
28
+ pattern: ["**/*.test.ts", "**/*.spec.ts"],
29
+ coverage: false,
30
+ watch: false
31
+ },
32
+ workspace: validatedConfig2.workspace ?? { versionStrategy: "fixed" },
33
+ release: validatedConfig2.release ?? {
34
+ npm: true,
35
+ github: false,
36
+ tagFormat: "v${version}",
37
+ conventionalCommits: true
38
+ },
39
+ plugins: validatedConfig2.plugins ?? []
40
+ };
41
+ return config;
42
+ } catch (error) {
43
+ console.error(`Error loading config from ${configPath}:`, error);
44
+ throw error;
45
+ }
46
+ }
47
+ }
48
+ const validatedConfig = remptsConfigSchema.assert({});
49
+ return {
50
+ ...validatedConfig,
51
+ build: transformBuildConfig(validatedConfig.build),
52
+ dev: validatedConfig.dev ?? { watch: true, inspect: false },
53
+ test: validatedConfig.test ?? {
54
+ pattern: ["**/*.test.ts", "**/*.spec.ts"],
55
+ coverage: false,
56
+ watch: false
57
+ },
58
+ workspace: validatedConfig.workspace ?? { versionStrategy: "fixed" },
59
+ release: validatedConfig.release ?? {
60
+ npm: true,
61
+ github: false,
62
+ tagFormat: "v${version}",
63
+ conventionalCommits: true
64
+ },
65
+ plugins: validatedConfig.plugins ?? []
66
+ };
67
+ }
@@ -1,5 +1,4 @@
1
- import type { BuildConfig } from "./build.js";
2
- import type { PublishConfig } from "./publish.js";
1
+ import type { LoadedConfig } from "./config-loader.js";
3
2
  export interface BaseConfig {
4
3
  global?: Record<string, any>;
5
4
  packages?: Record<string, Record<string, any>>;
@@ -8,10 +7,6 @@ export interface BaseConfig {
8
7
  config: Record<string, any>;
9
8
  }>;
10
9
  }
11
- export interface DlerConfig {
12
- build?: BuildConfig;
13
- publish?: PublishConfig;
14
- }
15
10
  /**
16
11
  * Generic function to resolve package-specific configuration using pattern matching
17
12
  * Priority: packages (exact match) → patterns (glob match) → global
@@ -22,3 +17,19 @@ export declare const resolvePackageConfig: <T extends Record<string, any>>(packa
22
17
  * CLI options take precedence over config options
23
18
  */
24
19
  export declare const mergeConfig: <T extends Record<string, any>>(cliOptions: T, configOptions?: Record<string, any>) => T;
20
+ /**
21
+ * Get package-specific build configuration from dler.config.ts
22
+ */
23
+ export declare const getPackageBuildConfigUnified: (packageName: string, dlerConfig: LoadedConfig | null) => Promise<Record<string, any> | undefined>;
24
+ /**
25
+ * Get package-specific publish configuration from dler.config.ts
26
+ */
27
+ export declare const getPackagePublishConfigUnified: (packageName: string, dlerConfig: LoadedConfig | null) => Record<string, any> | undefined;
28
+ /**
29
+ * Merge build options with package-specific configuration from dler.config.ts
30
+ */
31
+ export declare const mergeBuildOptionsUnified: <T extends Record<string, any>>(cliOptions: T, packageName: string, dlerConfig: LoadedConfig | null) => T;
32
+ /**
33
+ * Merge publish options with package-specific configuration from dler.config.ts
34
+ */
35
+ export declare const mergePublishOptionsUnified: <T extends Record<string, any>>(cliOptions: T, packageName: string, dlerConfig: LoadedConfig | null) => T;
package/dist/impl/core.js CHANGED
@@ -28,9 +28,25 @@ export const resolvePackageConfig = (packageName, config) => {
28
28
  return globalConfig;
29
29
  };
30
30
  export const mergeConfig = (cliOptions, configOptions) => {
31
- if (!configOptions) return cliOptions;
31
+ if (!configOptions) {
32
+ return cliOptions;
33
+ }
32
34
  return {
33
35
  ...configOptions,
34
36
  ...cliOptions
35
37
  };
36
38
  };
39
+ export const getPackageBuildConfigUnified = async (packageName, dlerConfig) => {
40
+ return resolvePackageConfig(packageName, dlerConfig?.build);
41
+ };
42
+ export const getPackagePublishConfigUnified = (packageName, dlerConfig) => {
43
+ return resolvePackageConfig(packageName, dlerConfig?.publish);
44
+ };
45
+ export const mergeBuildOptionsUnified = (cliOptions, packageName, dlerConfig) => {
46
+ const packageConfig = getPackageBuildConfigUnified(packageName, dlerConfig);
47
+ return mergeConfig(cliOptions, packageConfig);
48
+ };
49
+ export const mergePublishOptionsUnified = (cliOptions, packageName, dlerConfig) => {
50
+ const packageConfig = getPackagePublishConfigUnified(packageName, dlerConfig);
51
+ return mergeConfig(cliOptions, packageConfig);
52
+ };
@@ -1,3 +1,4 @@
1
+ import type { LoadedConfig } from "./config-loader.js";
1
2
  /**
2
3
  * Find monorepo root by looking for package.json with workspaces field
3
4
  */
@@ -39,28 +40,12 @@ export declare const filterPackages: (packages: {
39
40
  pkg: any;
40
41
  }[];
41
42
  /**
42
- * Load dler.ts configuration using c12
43
+ * Load dler.config.ts configuration
43
44
  *
44
- * c12 automatically handles:
45
- * - Searching up directory tree for config files
46
- * - Loading TypeScript/JavaScript config files
47
- * - Merging multiple config sources (dler.ts, package.json, .dlerrc, etc.)
48
- * - Environment-specific configurations ($test, $development, $production)
49
- * - Config extending from remote/local sources
50
- *
51
- * Additional c12 features available:
52
- * - .config/ directory support
53
- * - RC file support (.dlerrc)
54
- * - Environment-specific configs ($env: { staging: {...} })
55
- * - Config watching with auto-reload
56
- * - Remote config extending (gh:user/repo)
57
- */
58
- export declare const loadDlerConfig: <T extends Record<string, any> = any>(cwd?: string) => Promise<T | null>;
59
- /**
60
- * Watch dler.ts configuration for changes (development mode)
61
- * Uses c12's watchConfig for auto-reload and HMR support
45
+ * Uses the unified config loader which:
46
+ * - Validates against @reliverse/rempts schema
47
+ * - Loads dler.config.ts, dler.config.js, or dler.config.mjs files
48
+ * - Applies schema defaults
49
+ * - Returns LoadedConfig with extended build and publish configs
62
50
  */
63
- export declare const watchDlerConfig: <T extends Record<string, any> = any>(cwd?: string, options?: {
64
- onUpdate?: (config: T) => void;
65
- onError?: (error: Error) => void;
66
- }) => Promise<import("c12").ConfigWatcher<T, import("c12").ConfigLayerMeta>>;
51
+ export declare const loadDlerConfig: (cwd?: string) => Promise<LoadedConfig | null>;
@@ -1,7 +1,7 @@
1
1
  import { dirname, resolve } from "node:path";
2
2
  import { createIncludeFilter } from "@reliverse/matcha";
3
3
  import { readPackageJSON } from "@reliverse/typerso";
4
- import { loadConfig, watchConfig } from "c12";
4
+ import { loadConfig } from "./config-loader.js";
5
5
  export const findMonorepoRoot = async (cwd) => {
6
6
  let currentDir = cwd || process.cwd();
7
7
  const maxDepth = 10;
@@ -24,7 +24,9 @@ export const findMonorepoRoot = async (cwd) => {
24
24
  return null;
25
25
  };
26
26
  export const getWorkspacePatterns = (pkg) => {
27
- if (!pkg.workspaces) return [];
27
+ if (!pkg.workspaces) {
28
+ return [];
29
+ }
28
30
  if (Array.isArray(pkg.workspaces)) {
29
31
  return pkg.workspaces;
30
32
  }
@@ -39,7 +41,7 @@ export const hasWorkspaces = (pkg) => {
39
41
  export const resolvePackageInfo = async (packagePath) => {
40
42
  try {
41
43
  const pkg = await readPackageJSON(packagePath);
42
- if (!pkg || !pkg.name) {
44
+ if (!pkg?.name) {
43
45
  return null;
44
46
  }
45
47
  return {
@@ -85,7 +87,9 @@ export const getWorkspacePackages = async (cwd) => {
85
87
  const matches = glob.scanSync({ cwd: monorepoRoot, onlyFiles: false });
86
88
  for (const match of matches) {
87
89
  const packagePath = resolve(monorepoRoot, match);
88
- if (seenPaths.has(packagePath)) continue;
90
+ if (seenPaths.has(packagePath)) {
91
+ continue;
92
+ }
89
93
  seenPaths.add(packagePath);
90
94
  const pkgInfo = await resolvePackageInfo(packagePath);
91
95
  if (pkgInfo) {
@@ -94,7 +98,9 @@ export const getWorkspacePackages = async (cwd) => {
94
98
  }
95
99
  } else {
96
100
  const packagePath = resolve(monorepoRoot, pattern);
97
- if (seenPaths.has(packagePath)) continue;
101
+ if (seenPaths.has(packagePath)) {
102
+ continue;
103
+ }
98
104
  seenPaths.add(packagePath);
99
105
  const pkgInfo = await resolvePackageInfo(packagePath);
100
106
  if (pkgInfo) {
@@ -114,7 +120,9 @@ export const filterPackages = (packages, ignore, filter) => {
114
120
  const includeFilter = createIncludeFilter(filter);
115
121
  return includeFilter(packages);
116
122
  }
117
- if (!ignore) return packages;
123
+ if (!ignore) {
124
+ return packages;
125
+ }
118
126
  const ignorePatterns = Array.isArray(ignore) ? ignore : [ignore];
119
127
  return packages.filter((pkg) => {
120
128
  return !ignorePatterns.some((pattern) => {
@@ -128,31 +136,9 @@ export const filterPackages = (packages, ignore, filter) => {
128
136
  };
129
137
  export const loadDlerConfig = async (cwd) => {
130
138
  try {
131
- const { config } = await loadConfig({
132
- cwd: cwd || process.cwd(),
133
- name: "dler",
134
- configFile: "dler",
135
- packageJson: "dler",
136
- // Enable reading from package.json "dler" field
137
- dotenv: false
138
- });
139
- return config || null;
140
- } catch (_error) {
139
+ const config = await loadConfig(cwd || process.cwd());
140
+ return config;
141
+ } catch {
141
142
  return null;
142
143
  }
143
144
  };
144
- export const watchDlerConfig = (cwd, options) => {
145
- return watchConfig({
146
- cwd: cwd || process.cwd(),
147
- name: "dler",
148
- configFile: "dler",
149
- packageJson: "dler",
150
- dotenv: false,
151
- onUpdate: ({ newConfig }) => {
152
- options?.onUpdate?.(newConfig.config);
153
- },
154
- onWatch: (event) => {
155
- console.log("[dler config watcher]", event.type, event.path);
156
- }
157
- });
158
- };
@@ -1,3 +1,4 @@
1
+ import type { LoadedConfig } from "./config-loader.js";
1
2
  import { type BaseConfig } from "./core.js";
2
3
  import type { BumpType } from "./types.js";
3
4
  export type RegistryType = "npm" | "jsr" | "vercel" | "npm-jsr" | "none";
@@ -37,3 +38,11 @@ export declare const getPackagePublishConfig: (packageName: string, dlerConfig:
37
38
  export declare const mergePublishOptions: <T extends Record<string, any>>(cliOptions: T, packageName: string, dlerConfig: {
38
39
  publish?: PublishConfig;
39
40
  } | null) => T;
41
+ /**
42
+ * Get package-specific publish configuration from dler.config.ts (unified approach)
43
+ */
44
+ export declare const getPackagePublishConfigUnified: (packageName: string, dlerConfig: LoadedConfig | null) => PackagePublishConfig | undefined;
45
+ /**
46
+ * Merge publish options with package-specific configuration from dler.config.ts (unified approach)
47
+ */
48
+ export declare const mergePublishOptionsUnified: <T extends Record<string, any>>(cliOptions: T, packageName: string, dlerConfig: LoadedConfig | null) => T;
@@ -1,11 +1,15 @@
1
1
  import { mergeConfig, resolvePackageConfig } from "./core.js";
2
2
  export const getPackagePublishConfig = (packageName, dlerConfig) => {
3
- return resolvePackageConfig(
4
- packageName,
5
- dlerConfig?.publish
6
- );
3
+ return resolvePackageConfig(packageName, dlerConfig?.publish);
7
4
  };
8
5
  export const mergePublishOptions = (cliOptions, packageName, dlerConfig) => {
9
6
  const packageConfig = getPackagePublishConfig(packageName, dlerConfig);
10
7
  return mergeConfig(cliOptions, packageConfig);
11
8
  };
9
+ export const getPackagePublishConfigUnified = (packageName, dlerConfig) => {
10
+ return resolvePackageConfig(packageName, dlerConfig?.publish);
11
+ };
12
+ export const mergePublishOptionsUnified = (cliOptions, packageName, dlerConfig) => {
13
+ const packageConfig = getPackagePublishConfigUnified(packageName, dlerConfig);
14
+ return mergeConfig(cliOptions, packageConfig);
15
+ };
package/dist/mod.d.ts CHANGED
@@ -1,4 +1,7 @@
1
1
  import type { BumpType, VersionInfo } from "./impl/types.js";
2
+ export { type LoadedConfig, loadConfig } from "./impl/config-loader.js";
3
+ export { type BuildConfig, getPackageBuildConfigUnified, mergeBuildOptionsUnified, type PackageBuildConfig, } from "./impl/build.js";
4
+ export { getPackagePublishConfigUnified, mergePublishOptionsUnified, type PackageKind, type PackagePublishConfig, type PublishConfig, type RegistryType, } from "./impl/publish.js";
2
5
  /**
3
6
  * Parse and validate a semver version string
4
7
  */
package/dist/mod.js CHANGED
@@ -1,4 +1,13 @@
1
1
  import { inc, parse, valid } from "semver";
2
+ export { loadConfig } from "./impl/config-loader.js";
3
+ export {
4
+ getPackageBuildConfigUnified,
5
+ mergeBuildOptionsUnified
6
+ } from "./impl/build.js";
7
+ export {
8
+ getPackagePublishConfigUnified,
9
+ mergePublishOptionsUnified
10
+ } from "./impl/publish.js";
2
11
  export function parseVersion(version) {
3
12
  if (!valid(version)) {
4
13
  return null;
@@ -39,7 +48,11 @@ export function getReleaseType(version) {
39
48
  if (!parsed) {
40
49
  return null;
41
50
  }
42
- if (parsed.major > 0) return "major";
43
- if (parsed.minor > 0) return "minor";
51
+ if (parsed.major > 0) {
52
+ return "major";
53
+ }
54
+ if (parsed.minor > 0) {
55
+ return "minor";
56
+ }
44
57
  return "patch";
45
58
  }
package/package.json CHANGED
@@ -1,38 +1,43 @@
1
1
  {
2
2
  "name": "@reliverse/config",
3
+ "version": "2.3.2",
4
+ "private": false,
3
5
  "description": "Configuration management for Reliverse ecosystem",
6
+ "keywords": [
7
+ "build",
8
+ "config",
9
+ "dler",
10
+ "publish"
11
+ ],
12
+ "license": "MIT",
4
13
  "author": "reliverse",
5
- "version": "2.2.9",
6
- "private": false,
14
+ "files": [
15
+ "dist",
16
+ "package.json"
17
+ ],
7
18
  "type": "module",
8
19
  "exports": {
9
20
  ".": {
10
21
  "types": "./dist/mod.d.ts",
11
22
  "default": "./dist/mod.js"
12
23
  },
24
+ "./config-loader": {
25
+ "types": "./dist/impl/config-loader.d.ts",
26
+ "default": "./dist/impl/config-loader.js"
27
+ },
13
28
  "./impl/*": {
14
29
  "types": "./dist/impl/*.d.ts",
15
30
  "default": "./dist/impl/*.js"
16
31
  }
17
32
  },
18
- "dependencies": {
19
- "c12": "^3.3.3",
20
- "semver": "^7.7.3",
21
- "@reliverse/matcha": "2.2.9",
22
- "@reliverse/typerso": "2.2.9"
23
- },
24
- "keywords": [
25
- "dler",
26
- "config",
27
- "build",
28
- "publish"
29
- ],
30
33
  "publishConfig": {
31
34
  "access": "public"
32
35
  },
33
- "files": [
34
- "dist",
35
- "package.json"
36
- ],
37
- "license": "MIT"
36
+ "dependencies": {
37
+ "@reliverse/matcha": "2.3.2",
38
+ "@reliverse/rempts-core": "2.3.2",
39
+ "@reliverse/typerso": "2.3.2",
40
+ "c12": "^3.3.3",
41
+ "semver": "^7.7.3"
42
+ }
38
43
  }