@reliverse/config 1.5.11 → 2.2.7
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/impl/build.d.ts +166 -0
- package/dist/impl/build.js +10 -0
- package/dist/impl/core.d.ts +24 -0
- package/dist/impl/core.js +36 -0
- package/dist/impl/discovery.d.ts +66 -0
- package/dist/impl/discovery.js +158 -0
- package/dist/impl/publish.d.ts +39 -0
- package/dist/impl/publish.js +11 -0
- package/dist/impl/types.d.ts +7 -0
- package/dist/impl/types.js +0 -0
- package/dist/mod.d.ts +21 -0
- package/dist/mod.js +45 -0
- package/package.json +27 -32
- package/LICENSE +0 -21
- package/README.md +0 -69
- package/bin/main.d.ts +0 -139
- package/bin/main.js +0 -417
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { type BaseConfig } from "./core.js";
|
|
2
|
+
import type { PackageKind } from "./publish.js";
|
|
3
|
+
export interface AssetOptions {
|
|
4
|
+
publicPath?: string;
|
|
5
|
+
copyFiles?: string[];
|
|
6
|
+
imageOptimization?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface PerformanceBudget {
|
|
9
|
+
maxBundleSize?: number;
|
|
10
|
+
maxChunkSize?: number;
|
|
11
|
+
maxAssetSize?: number;
|
|
12
|
+
maxInitialChunkSize?: number;
|
|
13
|
+
maxAsyncChunkSize?: number;
|
|
14
|
+
}
|
|
15
|
+
export interface HtmlOptions {
|
|
16
|
+
entryPoints?: string[];
|
|
17
|
+
inject?: boolean;
|
|
18
|
+
minify?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface DtsOptions {
|
|
21
|
+
/** Whether to generate declaration files */
|
|
22
|
+
enable?: boolean;
|
|
23
|
+
/** Provider for generating declaration files */
|
|
24
|
+
provider?: "dts-bundle-generator" | "api-extractor" | "typescript" | "mkdist";
|
|
25
|
+
/** Whether to bundle declaration files into a single file */
|
|
26
|
+
bundle?: boolean;
|
|
27
|
+
/** Output directory for declaration files (relative to package root) */
|
|
28
|
+
distPath?: string;
|
|
29
|
+
/** Whether to build with project references */
|
|
30
|
+
build?: boolean;
|
|
31
|
+
/** Whether to abort on declaration generation errors */
|
|
32
|
+
abortOnError?: boolean;
|
|
33
|
+
/** Whether to auto-set extension based on format (.d.ts, .d.mts, .d.cts) */
|
|
34
|
+
autoExtension?: boolean;
|
|
35
|
+
/** Path aliases for declaration files */
|
|
36
|
+
alias?: Record<string, string>;
|
|
37
|
+
/** Use experimental tsgo instead of TypeScript Compiler API */
|
|
38
|
+
tsgo?: boolean;
|
|
39
|
+
/** Banner content for declaration files */
|
|
40
|
+
banner?: string;
|
|
41
|
+
/** Footer content for declaration files */
|
|
42
|
+
footer?: string;
|
|
43
|
+
/** Options specific to dts-bundle-generator */
|
|
44
|
+
dtsBundleGenerator?: {
|
|
45
|
+
preferredConfigPath?: string;
|
|
46
|
+
externalInlines?: string[];
|
|
47
|
+
externalImports?: string[];
|
|
48
|
+
externalTypes?: string[];
|
|
49
|
+
umdModuleName?: string;
|
|
50
|
+
noBanner?: boolean;
|
|
51
|
+
};
|
|
52
|
+
/** Options specific to mkdist provider */
|
|
53
|
+
mkdist?: {
|
|
54
|
+
addRelativeDeclarationExtensions?: boolean;
|
|
55
|
+
pattern?: string;
|
|
56
|
+
globOptions?: Record<string, unknown>;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export interface GoBuildOptions {
|
|
60
|
+
/** Whether to enable Go build */
|
|
61
|
+
enable?: boolean;
|
|
62
|
+
/** Build provider: xgo (cross-compilation) or native (limited cross-compilation) */
|
|
63
|
+
provider?: "xgo" | "native";
|
|
64
|
+
/** Target platforms (e.g., "linux/amd64" or ["linux/amd64", "windows/amd64"]) */
|
|
65
|
+
targets?: string | string[];
|
|
66
|
+
/** Output directory for Go binaries (relative to package root, default: "release") */
|
|
67
|
+
outputDir?: string;
|
|
68
|
+
/** Output binary name prefix (default: derived from package name) */
|
|
69
|
+
outputName?: string;
|
|
70
|
+
/** Go build mode: c-shared, c-archive, or exe */
|
|
71
|
+
buildMode?: "c-shared" | "c-archive" | "exe";
|
|
72
|
+
/** Linker flags (default: "-s -w") */
|
|
73
|
+
ldflags?: string;
|
|
74
|
+
/** Main Go file to build (default: "main.go") */
|
|
75
|
+
mainFile?: string;
|
|
76
|
+
/** Go version for xgo (default: "1.20.3") */
|
|
77
|
+
goVersion?: string;
|
|
78
|
+
}
|
|
79
|
+
export interface PackageBuildConfig {
|
|
80
|
+
enable?: boolean;
|
|
81
|
+
bundler?: "bun" | "mkdist";
|
|
82
|
+
target?: "browser" | "bun" | "node";
|
|
83
|
+
format?: "esm" | "cjs" | "iife";
|
|
84
|
+
minify?: boolean | {
|
|
85
|
+
whitespace?: boolean;
|
|
86
|
+
syntax?: boolean;
|
|
87
|
+
identifiers?: boolean;
|
|
88
|
+
};
|
|
89
|
+
sourcemap?: string | boolean;
|
|
90
|
+
splitting?: boolean;
|
|
91
|
+
external?: string | string[];
|
|
92
|
+
bytecode?: boolean;
|
|
93
|
+
drop?: string | string[];
|
|
94
|
+
packages?: string;
|
|
95
|
+
publicPath?: string;
|
|
96
|
+
root?: string;
|
|
97
|
+
define?: Record<string, string>;
|
|
98
|
+
naming?: {
|
|
99
|
+
chunk?: string;
|
|
100
|
+
entry?: string;
|
|
101
|
+
asset?: string;
|
|
102
|
+
};
|
|
103
|
+
env?: string | Record<string, string>;
|
|
104
|
+
banner?: string | Record<string, string>;
|
|
105
|
+
footer?: string | Record<string, string>;
|
|
106
|
+
conditions?: string | string[];
|
|
107
|
+
loader?: Record<string, string>;
|
|
108
|
+
ignoreDCEAnnotations?: boolean;
|
|
109
|
+
emitDCEAnnotations?: boolean;
|
|
110
|
+
throw?: boolean;
|
|
111
|
+
jsx?: string | {
|
|
112
|
+
factory?: string;
|
|
113
|
+
fragment?: string;
|
|
114
|
+
importSource?: string;
|
|
115
|
+
pragma?: string;
|
|
116
|
+
pragmaFrag?: string;
|
|
117
|
+
runtime?: "automatic" | "classic";
|
|
118
|
+
development?: boolean;
|
|
119
|
+
};
|
|
120
|
+
keepNames?: boolean;
|
|
121
|
+
html?: boolean | HtmlOptions;
|
|
122
|
+
assets?: AssetOptions;
|
|
123
|
+
cssChunking?: boolean;
|
|
124
|
+
macros?: boolean;
|
|
125
|
+
sideEffects?: boolean | string[];
|
|
126
|
+
bundleAnalyzer?: boolean;
|
|
127
|
+
typeCheck?: boolean;
|
|
128
|
+
generateTypes?: boolean;
|
|
129
|
+
performanceBudget?: PerformanceBudget;
|
|
130
|
+
imageOptimization?: boolean;
|
|
131
|
+
fontOptimization?: boolean;
|
|
132
|
+
cssOptimization?: boolean;
|
|
133
|
+
svgAsReact?: boolean;
|
|
134
|
+
cssModules?: boolean;
|
|
135
|
+
workerSupport?: boolean;
|
|
136
|
+
compile?: boolean;
|
|
137
|
+
windowsHideConsole?: boolean;
|
|
138
|
+
windowsIcon?: string;
|
|
139
|
+
windowsTitle?: string;
|
|
140
|
+
windowsPublisher?: string;
|
|
141
|
+
windowsVersion?: string;
|
|
142
|
+
windowsDescription?: string;
|
|
143
|
+
windowsCopyright?: string;
|
|
144
|
+
dts?: boolean | DtsOptions;
|
|
145
|
+
go?: GoBuildOptions;
|
|
146
|
+
kind?: PackageKind;
|
|
147
|
+
bin?: string;
|
|
148
|
+
}
|
|
149
|
+
export interface BuildConfig extends BaseConfig {
|
|
150
|
+
global?: PackageBuildConfig;
|
|
151
|
+
packages?: Record<string, PackageBuildConfig>;
|
|
152
|
+
patterns?: Array<{
|
|
153
|
+
pattern: string;
|
|
154
|
+
config: PackageBuildConfig;
|
|
155
|
+
}>;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Get package-specific build configuration from dler.ts
|
|
159
|
+
*/
|
|
160
|
+
export declare const getPackageBuildConfig: (packageName: string, dlerConfig: {
|
|
161
|
+
build?: BuildConfig;
|
|
162
|
+
} | null) => Promise<PackageBuildConfig | undefined>;
|
|
163
|
+
/**
|
|
164
|
+
* Merge build options with package-specific configuration
|
|
165
|
+
*/
|
|
166
|
+
export declare const mergeBuildOptions: <T extends Record<string, any>>(cliOptions: T, packageConfig?: PackageBuildConfig) => T;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { mergeConfig, resolvePackageConfig } from "./core.js";
|
|
2
|
+
export const getPackageBuildConfig = async (packageName, dlerConfig) => {
|
|
3
|
+
return resolvePackageConfig(
|
|
4
|
+
packageName,
|
|
5
|
+
dlerConfig?.build
|
|
6
|
+
);
|
|
7
|
+
};
|
|
8
|
+
export const mergeBuildOptions = (cliOptions, packageConfig) => {
|
|
9
|
+
return mergeConfig(cliOptions, packageConfig);
|
|
10
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { BuildConfig } from "./build.js";
|
|
2
|
+
import type { PublishConfig } from "./publish.js";
|
|
3
|
+
export interface BaseConfig {
|
|
4
|
+
global?: Record<string, any>;
|
|
5
|
+
packages?: Record<string, Record<string, any>>;
|
|
6
|
+
patterns?: Array<{
|
|
7
|
+
pattern: string;
|
|
8
|
+
config: Record<string, any>;
|
|
9
|
+
}>;
|
|
10
|
+
}
|
|
11
|
+
export interface DlerConfig {
|
|
12
|
+
build?: BuildConfig;
|
|
13
|
+
publish?: PublishConfig;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Generic function to resolve package-specific configuration using pattern matching
|
|
17
|
+
* Priority: packages (exact match) → patterns (glob match) → global
|
|
18
|
+
*/
|
|
19
|
+
export declare const resolvePackageConfig: <T extends Record<string, any>>(packageName: string, config: BaseConfig | null | undefined) => T | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Generic function to merge configuration options
|
|
22
|
+
* CLI options take precedence over config options
|
|
23
|
+
*/
|
|
24
|
+
export declare const mergeConfig: <T extends Record<string, any>>(cliOptions: T, configOptions?: Record<string, any>) => T;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export const resolvePackageConfig = (packageName, config) => {
|
|
2
|
+
if (!config) {
|
|
3
|
+
return;
|
|
4
|
+
}
|
|
5
|
+
if (config.packages?.[packageName]) {
|
|
6
|
+
const packageConfig = config.packages[packageName];
|
|
7
|
+
if (packageConfig.enable === false) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
return packageConfig;
|
|
11
|
+
}
|
|
12
|
+
if (config.patterns) {
|
|
13
|
+
for (const { pattern, config: patternConfig } of config.patterns) {
|
|
14
|
+
const regexPattern = pattern.replace(/\*/g, ".*");
|
|
15
|
+
const patternWithoutWildcards = pattern.replace(/\*/g, "");
|
|
16
|
+
if (patternWithoutWildcards && packageName.includes(patternWithoutWildcards) || new RegExp(regexPattern).test(packageName)) {
|
|
17
|
+
if (patternConfig.enable === false) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
return patternConfig;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const globalConfig = config.global;
|
|
25
|
+
if (globalConfig?.enable === false) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
return globalConfig;
|
|
29
|
+
};
|
|
30
|
+
export const mergeConfig = (cliOptions, configOptions) => {
|
|
31
|
+
if (!configOptions) return cliOptions;
|
|
32
|
+
return {
|
|
33
|
+
...configOptions,
|
|
34
|
+
...cliOptions
|
|
35
|
+
};
|
|
36
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Find monorepo root by looking for package.json with workspaces field
|
|
3
|
+
*/
|
|
4
|
+
export declare const findMonorepoRoot: (cwd?: string) => Promise<string | null>;
|
|
5
|
+
/**
|
|
6
|
+
* Get workspace patterns from package.json
|
|
7
|
+
*/
|
|
8
|
+
export declare const getWorkspacePatterns: (pkg: any) => string[];
|
|
9
|
+
/**
|
|
10
|
+
* Check if package has workspaces
|
|
11
|
+
*/
|
|
12
|
+
export declare const hasWorkspaces: (pkg: any) => boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Resolve package info for a given path
|
|
15
|
+
*/
|
|
16
|
+
export declare const resolvePackageInfo: (packagePath: string) => Promise<{
|
|
17
|
+
name: string;
|
|
18
|
+
path: string;
|
|
19
|
+
pkg: any;
|
|
20
|
+
} | null>;
|
|
21
|
+
/**
|
|
22
|
+
* Get all workspace packages
|
|
23
|
+
*/
|
|
24
|
+
export declare const getWorkspacePackages: (cwd?: string) => Promise<{
|
|
25
|
+
name: string;
|
|
26
|
+
path: string;
|
|
27
|
+
pkg: any;
|
|
28
|
+
}[]>;
|
|
29
|
+
/**
|
|
30
|
+
* Filter packages based on ignore patterns or include filter
|
|
31
|
+
*/
|
|
32
|
+
export declare const filterPackages: (packages: {
|
|
33
|
+
name: string;
|
|
34
|
+
path: string;
|
|
35
|
+
pkg: any;
|
|
36
|
+
}[], ignore?: string | string[], filter?: string | string[]) => {
|
|
37
|
+
name: string;
|
|
38
|
+
path: string;
|
|
39
|
+
pkg: any;
|
|
40
|
+
}[];
|
|
41
|
+
/**
|
|
42
|
+
* Load dler.ts configuration using c12
|
|
43
|
+
*
|
|
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
|
|
62
|
+
*/
|
|
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>>;
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { dirname, resolve } from "node:path";
|
|
2
|
+
import { createIncludeFilter } from "@reliverse/matcha";
|
|
3
|
+
import { readPackageJSON } from "@reliverse/typerso";
|
|
4
|
+
import { loadConfig, watchConfig } from "c12";
|
|
5
|
+
export const findMonorepoRoot = async (cwd) => {
|
|
6
|
+
let currentDir = cwd || process.cwd();
|
|
7
|
+
const maxDepth = 10;
|
|
8
|
+
let depth = 0;
|
|
9
|
+
while (depth < maxDepth) {
|
|
10
|
+
try {
|
|
11
|
+
const pkg = await readPackageJSON(currentDir);
|
|
12
|
+
if (pkg?.workspaces) {
|
|
13
|
+
return currentDir;
|
|
14
|
+
}
|
|
15
|
+
} catch {
|
|
16
|
+
}
|
|
17
|
+
const parentDir = dirname(currentDir);
|
|
18
|
+
if (parentDir === currentDir) {
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
currentDir = parentDir;
|
|
22
|
+
depth++;
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
};
|
|
26
|
+
export const getWorkspacePatterns = (pkg) => {
|
|
27
|
+
if (!pkg.workspaces) return [];
|
|
28
|
+
if (Array.isArray(pkg.workspaces)) {
|
|
29
|
+
return pkg.workspaces;
|
|
30
|
+
}
|
|
31
|
+
if (pkg.workspaces.packages) {
|
|
32
|
+
return pkg.workspaces.packages;
|
|
33
|
+
}
|
|
34
|
+
return [];
|
|
35
|
+
};
|
|
36
|
+
export const hasWorkspaces = (pkg) => {
|
|
37
|
+
return !!(pkg.workspaces && (Array.isArray(pkg.workspaces) || typeof pkg.workspaces === "object" && pkg.workspaces.packages));
|
|
38
|
+
};
|
|
39
|
+
export const resolvePackageInfo = async (packagePath) => {
|
|
40
|
+
try {
|
|
41
|
+
const pkg = await readPackageJSON(packagePath);
|
|
42
|
+
if (!pkg || !pkg.name) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
name: pkg.name,
|
|
47
|
+
path: packagePath,
|
|
48
|
+
pkg
|
|
49
|
+
};
|
|
50
|
+
} catch {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
export const getWorkspacePackages = async (cwd) => {
|
|
55
|
+
const monorepoRoot = await findMonorepoRoot(cwd);
|
|
56
|
+
if (!monorepoRoot) {
|
|
57
|
+
const currentDir = cwd || process.cwd();
|
|
58
|
+
const currentPkg = await readPackageJSON(currentDir);
|
|
59
|
+
if (currentPkg?.name) {
|
|
60
|
+
return [
|
|
61
|
+
{
|
|
62
|
+
name: currentPkg.name,
|
|
63
|
+
path: currentDir,
|
|
64
|
+
pkg: currentPkg
|
|
65
|
+
}
|
|
66
|
+
];
|
|
67
|
+
}
|
|
68
|
+
throw new Error(
|
|
69
|
+
"\u274C No monorepo or valid package found. Ensure package.json has 'workspaces' field or contains a valid 'name' field."
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
const rootPkg = await readPackageJSON(monorepoRoot);
|
|
73
|
+
if (!rootPkg) {
|
|
74
|
+
throw new Error("\u274C Could not read root package.json");
|
|
75
|
+
}
|
|
76
|
+
const patterns = getWorkspacePatterns(rootPkg);
|
|
77
|
+
if (!patterns.length) {
|
|
78
|
+
throw new Error("\u274C No workspace patterns found in package.json");
|
|
79
|
+
}
|
|
80
|
+
const packages = [];
|
|
81
|
+
const seenPaths = /* @__PURE__ */ new Set();
|
|
82
|
+
for (const pattern of patterns) {
|
|
83
|
+
if (pattern.includes("*")) {
|
|
84
|
+
const glob = new Bun.Glob(pattern);
|
|
85
|
+
const matches = glob.scanSync({ cwd: monorepoRoot, onlyFiles: false });
|
|
86
|
+
for (const match of matches) {
|
|
87
|
+
const packagePath = resolve(monorepoRoot, match);
|
|
88
|
+
if (seenPaths.has(packagePath)) continue;
|
|
89
|
+
seenPaths.add(packagePath);
|
|
90
|
+
const pkgInfo = await resolvePackageInfo(packagePath);
|
|
91
|
+
if (pkgInfo) {
|
|
92
|
+
packages.push(pkgInfo);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
} else {
|
|
96
|
+
const packagePath = resolve(monorepoRoot, pattern);
|
|
97
|
+
if (seenPaths.has(packagePath)) continue;
|
|
98
|
+
seenPaths.add(packagePath);
|
|
99
|
+
const pkgInfo = await resolvePackageInfo(packagePath);
|
|
100
|
+
if (pkgInfo) {
|
|
101
|
+
packages.push(pkgInfo);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const filteredPackages = packages.filter((pkg) => {
|
|
106
|
+
const normalizedPkgPath = resolve(pkg.path);
|
|
107
|
+
const normalizedRootPath = resolve(monorepoRoot);
|
|
108
|
+
return normalizedPkgPath !== normalizedRootPath;
|
|
109
|
+
});
|
|
110
|
+
return filteredPackages;
|
|
111
|
+
};
|
|
112
|
+
export const filterPackages = (packages, ignore, filter) => {
|
|
113
|
+
if (filter) {
|
|
114
|
+
const includeFilter = createIncludeFilter(filter);
|
|
115
|
+
return includeFilter(packages);
|
|
116
|
+
}
|
|
117
|
+
if (!ignore) return packages;
|
|
118
|
+
const ignorePatterns = Array.isArray(ignore) ? ignore : [ignore];
|
|
119
|
+
return packages.filter((pkg) => {
|
|
120
|
+
return !ignorePatterns.some((pattern) => {
|
|
121
|
+
if (pattern.includes("*")) {
|
|
122
|
+
const regex = new RegExp(pattern.replace(/\*/g, ".*"));
|
|
123
|
+
return regex.test(pkg.name);
|
|
124
|
+
}
|
|
125
|
+
return pkg.name === pattern;
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
export const loadDlerConfig = async (cwd) => {
|
|
130
|
+
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) {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
};
|
|
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
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type BaseConfig } from "./core.js";
|
|
2
|
+
import type { BumpType } from "./types.js";
|
|
3
|
+
export type RegistryType = "npm" | "jsr" | "vercel" | "npm-jsr" | "none";
|
|
4
|
+
export type PackageKind = "library" | "browser-app" | "native-app" | "cli";
|
|
5
|
+
export interface PackagePublishConfig {
|
|
6
|
+
enable?: boolean;
|
|
7
|
+
dryRun?: boolean;
|
|
8
|
+
tag?: string;
|
|
9
|
+
access?: "public" | "restricted";
|
|
10
|
+
otp?: string;
|
|
11
|
+
authType?: "web" | "legacy";
|
|
12
|
+
concurrency?: number;
|
|
13
|
+
verbose?: boolean;
|
|
14
|
+
bump?: BumpType;
|
|
15
|
+
bumpDisable?: boolean;
|
|
16
|
+
registry?: RegistryType;
|
|
17
|
+
kind?: PackageKind;
|
|
18
|
+
bin?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface PublishConfig extends BaseConfig {
|
|
21
|
+
global?: PackagePublishConfig;
|
|
22
|
+
packages?: Record<string, PackagePublishConfig>;
|
|
23
|
+
patterns?: Array<{
|
|
24
|
+
pattern: string;
|
|
25
|
+
config: PackagePublishConfig;
|
|
26
|
+
}>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Get package-specific publish configuration from dler.ts
|
|
30
|
+
*/
|
|
31
|
+
export declare const getPackagePublishConfig: (packageName: string, dlerConfig: {
|
|
32
|
+
publish?: PublishConfig;
|
|
33
|
+
} | null) => PackagePublishConfig | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Merge CLI options with dler.ts configuration
|
|
36
|
+
*/
|
|
37
|
+
export declare const mergePublishOptions: <T extends Record<string, any>>(cliOptions: T, packageName: string, dlerConfig: {
|
|
38
|
+
publish?: PublishConfig;
|
|
39
|
+
} | null) => T;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { mergeConfig, resolvePackageConfig } from "./core.js";
|
|
2
|
+
export const getPackagePublishConfig = (packageName, dlerConfig) => {
|
|
3
|
+
return resolvePackageConfig(
|
|
4
|
+
packageName,
|
|
5
|
+
dlerConfig?.publish
|
|
6
|
+
);
|
|
7
|
+
};
|
|
8
|
+
export const mergePublishOptions = (cliOptions, packageName, dlerConfig) => {
|
|
9
|
+
const packageConfig = getPackagePublishConfig(packageName, dlerConfig);
|
|
10
|
+
return mergeConfig(cliOptions, packageConfig);
|
|
11
|
+
};
|
|
File without changes
|
package/dist/mod.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { BumpType, VersionInfo } from "./impl/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Parse and validate a semver version string
|
|
4
|
+
*/
|
|
5
|
+
export declare function parseVersion(version: string): string | null;
|
|
6
|
+
/**
|
|
7
|
+
* Bump a version string according to the specified type
|
|
8
|
+
*/
|
|
9
|
+
export declare function bumpVersion(currentVersion: string, type: BumpType): VersionInfo | null;
|
|
10
|
+
/**
|
|
11
|
+
* Get the next version for a given type without bumping
|
|
12
|
+
*/
|
|
13
|
+
export declare function getNextVersion(currentVersion: string, type: BumpType): string | null;
|
|
14
|
+
/**
|
|
15
|
+
* Check if a version is a prerelease
|
|
16
|
+
*/
|
|
17
|
+
export declare function isPrerelease(version: string): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Get the release type of a version (major, minor, patch)
|
|
20
|
+
*/
|
|
21
|
+
export declare function getReleaseType(version: string): "major" | "minor" | "patch" | null;
|
package/dist/mod.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { inc, parse, valid } from "semver";
|
|
2
|
+
export function parseVersion(version) {
|
|
3
|
+
if (!valid(version)) {
|
|
4
|
+
return null;
|
|
5
|
+
}
|
|
6
|
+
return version;
|
|
7
|
+
}
|
|
8
|
+
export function bumpVersion(currentVersion, type) {
|
|
9
|
+
const parsed = parse(currentVersion);
|
|
10
|
+
if (!parsed) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
const bumped = inc(parsed, type);
|
|
14
|
+
if (!bumped) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
current: currentVersion,
|
|
19
|
+
bumped,
|
|
20
|
+
type
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export function getNextVersion(currentVersion, type) {
|
|
24
|
+
const parsed = parse(currentVersion);
|
|
25
|
+
if (!parsed) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
return inc(parsed, type) || null;
|
|
29
|
+
}
|
|
30
|
+
export function isPrerelease(version) {
|
|
31
|
+
if (!version.includes("-")) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
const parsed = parse(version);
|
|
35
|
+
return parsed ? parsed.prerelease.length > 0 : false;
|
|
36
|
+
}
|
|
37
|
+
export function getReleaseType(version) {
|
|
38
|
+
const parsed = parse(version);
|
|
39
|
+
if (!parsed) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
if (parsed.major > 0) return "major";
|
|
43
|
+
if (parsed.minor > 0) return "minor";
|
|
44
|
+
return "patch";
|
|
45
|
+
}
|
package/package.json
CHANGED
|
@@ -1,43 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reliverse/config",
|
|
3
|
-
"
|
|
4
|
-
"license": "MIT",
|
|
5
|
-
"description": "This CLI tool can help you easily create new web projects, manage existing projects, and automatically make advanced codebase modifications, with more features coming soon.",
|
|
6
|
-
"type": "module",
|
|
3
|
+
"description": "Configuration management for Reliverse ecosystem",
|
|
7
4
|
"author": "reliverse",
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
},
|
|
12
|
-
"bugs": {
|
|
13
|
-
"url": "https://github.com/reliverse/cli/issues",
|
|
14
|
-
"email": "blefnk@gmail.com"
|
|
15
|
-
},
|
|
16
|
-
"keywords": [
|
|
17
|
-
"cli",
|
|
18
|
-
"reliverse"
|
|
19
|
-
],
|
|
20
|
-
"main": "./bin/main.js",
|
|
21
|
-
"module": "./bin/main.js",
|
|
5
|
+
"version": "2.2.7",
|
|
6
|
+
"private": false,
|
|
7
|
+
"type": "module",
|
|
22
8
|
"exports": {
|
|
23
|
-
".":
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/mod.d.ts",
|
|
11
|
+
"default": "./dist/mod.js"
|
|
12
|
+
},
|
|
13
|
+
"./impl/*": {
|
|
14
|
+
"types": "./dist/impl/*.d.ts",
|
|
15
|
+
"default": "./dist/impl/*.js"
|
|
16
|
+
}
|
|
24
17
|
},
|
|
25
|
-
"
|
|
26
|
-
"
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"c12": "^3.3.3",
|
|
20
|
+
"semver": "^7.7.3",
|
|
21
|
+
"@reliverse/matcha": "2.2.7",
|
|
22
|
+
"@reliverse/typerso": "2.2.7"
|
|
27
23
|
},
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
24
|
+
"keywords": [
|
|
25
|
+
"dler",
|
|
26
|
+
"config",
|
|
27
|
+
"build",
|
|
28
|
+
"publish"
|
|
33
29
|
],
|
|
34
30
|
"publishConfig": {
|
|
35
31
|
"access": "public"
|
|
36
32
|
},
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"devDependencies": {}
|
|
33
|
+
"files": [
|
|
34
|
+
"dist",
|
|
35
|
+
"package.json"
|
|
36
|
+
],
|
|
37
|
+
"license": "MIT"
|
|
43
38
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Nazarii Korniienko
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|