@reelout/config 0.0.0 → 0.4.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/LICENSE +21 -0
- package/dist/index.js +127 -1
- package/dist/index.js.map +1 -0
- package/package.json +22 -5
- package/src/defaultConfig.ts +35 -0
- package/src/index.ts +6 -2
- package/src/mergeConfig.ts +25 -0
- package/src/normalizeConfig.ts +62 -0
- package/src/resolveConfig.ts +34 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Fai
|
|
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.
|
package/dist/index.js
CHANGED
|
@@ -1 +1,127 @@
|
|
|
1
|
-
|
|
1
|
+
import { assignWith } from "lodash-es";
|
|
2
|
+
import { compact, normalizeCommitFilter, normalizeReleaseRule, resolvePlugin } from "@reelout/core";
|
|
3
|
+
import { cosmiconfig } from "cosmiconfig";
|
|
4
|
+
//#region src/defaultConfig.ts
|
|
5
|
+
/**
|
|
6
|
+
* Default release configuration used when no user config is provided.
|
|
7
|
+
*
|
|
8
|
+
* Includes defaults for user identity, workspace layout, release rules,
|
|
9
|
+
* commit-to-release mappings, and built-in plugins.
|
|
10
|
+
*/
|
|
11
|
+
var defaultConfig = Object.freeze({
|
|
12
|
+
author: {
|
|
13
|
+
name: "github-actions[bot]",
|
|
14
|
+
email: "41898282+github-actions[bot]@users.noreply.github.com"
|
|
15
|
+
},
|
|
16
|
+
classifier: {
|
|
17
|
+
major: [],
|
|
18
|
+
minor: ["feat"],
|
|
19
|
+
patch: [
|
|
20
|
+
"fix",
|
|
21
|
+
"perf",
|
|
22
|
+
"revert"
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
rules: [
|
|
26
|
+
{
|
|
27
|
+
type: "branch",
|
|
28
|
+
pattern: "alpha",
|
|
29
|
+
qualifier: "alpha",
|
|
30
|
+
channel: "alpha"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
type: "branch",
|
|
34
|
+
pattern: "beta",
|
|
35
|
+
qualifier: "beta",
|
|
36
|
+
channel: "beta"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
type: "branch",
|
|
40
|
+
pattern: "next",
|
|
41
|
+
qualifier: "next",
|
|
42
|
+
channel: "next"
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
plugins: [
|
|
46
|
+
"@reelout/core/analyzer",
|
|
47
|
+
"@reelout/core/builder",
|
|
48
|
+
"@reelout/core/changelog",
|
|
49
|
+
"@reelout/npm",
|
|
50
|
+
"@reelout/git",
|
|
51
|
+
"@reelout/github"
|
|
52
|
+
]
|
|
53
|
+
});
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/mergeConfig.ts
|
|
56
|
+
/**
|
|
57
|
+
* Merge a user configuration into the defaults, preserving unspecified keys.
|
|
58
|
+
*
|
|
59
|
+
* Uses `lodash.assignWith` to avoid overwriting default values with
|
|
60
|
+
* `undefined` from the user configuration.
|
|
61
|
+
*
|
|
62
|
+
* @param defaultConfig Default configuration object
|
|
63
|
+
* @param userConfig Partial user-provided configuration
|
|
64
|
+
* @returns Merged configuration object
|
|
65
|
+
*/
|
|
66
|
+
function mergeConfig(defaultConfig, userConfig) {
|
|
67
|
+
return assignWith({}, defaultConfig, userConfig, (objValue, srcValue) => {
|
|
68
|
+
if (srcValue === void 0) return objValue;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/normalizeConfig.ts
|
|
73
|
+
/**
|
|
74
|
+
* Normalize and resolve a release configuration.
|
|
75
|
+
*
|
|
76
|
+
* Applies default author settings when incomplete, normalizes commit filters
|
|
77
|
+
* and release rules, and loads specified plugins.
|
|
78
|
+
*
|
|
79
|
+
* @param cwd Working directory path used for plugin resolution
|
|
80
|
+
* @param config User-supplied release configuration
|
|
81
|
+
* @returns Resolved and normalized release configuration
|
|
82
|
+
* @throws If a configured plugin cannot be resolved
|
|
83
|
+
*/
|
|
84
|
+
async function normalizeConfig(cwd, config) {
|
|
85
|
+
const author = config.author.name && config.author.email ? {
|
|
86
|
+
name: config.author.name,
|
|
87
|
+
email: config.author.email
|
|
88
|
+
} : { ...defaultConfig.author };
|
|
89
|
+
const classifier = normalizeCommitFilter(config.classifier);
|
|
90
|
+
const rules = compact(config.rules.map((rule) => normalizeReleaseRule(rule)));
|
|
91
|
+
const plugins = compact(await Promise.all(config.plugins.map(async (plugin) => {
|
|
92
|
+
try {
|
|
93
|
+
return await resolvePlugin(cwd, plugin);
|
|
94
|
+
} catch (err) {
|
|
95
|
+
try {
|
|
96
|
+
return await resolvePlugin(import.meta.filename, plugin);
|
|
97
|
+
} catch {}
|
|
98
|
+
throw err;
|
|
99
|
+
}
|
|
100
|
+
})));
|
|
101
|
+
return {
|
|
102
|
+
...config,
|
|
103
|
+
author,
|
|
104
|
+
classifier,
|
|
105
|
+
rules,
|
|
106
|
+
plugins
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
//#endregion
|
|
110
|
+
//#region src/resolveConfig.ts
|
|
111
|
+
/**
|
|
112
|
+
* Resolve and normalize a release configuration for a target directory.
|
|
113
|
+
*
|
|
114
|
+
* Searches for configuration files using `cosmiconfig`, merges discovered user
|
|
115
|
+
* settings with default configurations, and normalizes the resulting structure.
|
|
116
|
+
*
|
|
117
|
+
* @param cwd Working directory path to search from
|
|
118
|
+
* @param name Module name used for configuration file discovery
|
|
119
|
+
* @returns Resolved and normalized release configuration
|
|
120
|
+
*/
|
|
121
|
+
async function resolveConfig(cwd, name = "reelout") {
|
|
122
|
+
return normalizeConfig(cwd, mergeConfig(defaultConfig, (await cosmiconfig(name).search(cwd))?.config));
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
125
|
+
export { defaultConfig, mergeConfig, normalizeConfig, resolveConfig };
|
|
126
|
+
|
|
127
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/defaultConfig.ts","../src/mergeConfig.ts","../src/normalizeConfig.ts","../src/resolveConfig.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { ReleaseConfig } from '@reelout/core'\n\n/**\n * Default release configuration used when no user config is provided.\n *\n * Includes defaults for user identity, workspace layout, release rules,\n * commit-to-release mappings, and built-in plugins.\n */\nexport const defaultConfig = Object.freeze({\n author: {\n name: 'github-actions[bot]',\n email: '41898282+github-actions[bot]@users.noreply.github.com',\n },\n classifier: {\n major: [],\n minor: ['feat'],\n patch: ['fix', 'perf', 'revert'],\n },\n rules: [\n { type: 'branch', pattern: 'alpha', qualifier: 'alpha', channel: 'alpha' },\n { type: 'branch', pattern: 'beta', qualifier: 'beta', channel: 'beta' },\n { type: 'branch', pattern: 'next', qualifier: 'next', channel: 'next' },\n ],\n plugins: [\n '@reelout/core/analyzer', // Analyze the commits and determine the release type.\n '@reelout/core/builder', // Build the release artifacts.\n '@reelout/core/changelog', // Generate and write changelog entries for each release.\n '@reelout/npm', // Update package manifests and publish packages to npm.\n '@reelout/git', // Create release commits and tags, then push them.\n '@reelout/github', // Create GitHub releases from finalized plans.\n ],\n} satisfies Required<ReleaseConfig>)\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { assignWith } from 'lodash-es'\n\n/**\n * Merge a user configuration into the defaults, preserving unspecified keys.\n *\n * Uses `lodash.assignWith` to avoid overwriting default values with\n * `undefined` from the user configuration.\n *\n * @param defaultConfig Default configuration object\n * @param userConfig Partial user-provided configuration\n * @returns Merged configuration object\n */\nexport function mergeConfig<T>(\n defaultConfig: T,\n userConfig: Partial<T> | null | undefined\n): T {\n return assignWith({}, defaultConfig, userConfig, (objValue, srcValue) => {\n if (srcValue === undefined) {\n return objValue\n }\n })\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport {\n compact,\n normalizeCommitFilter,\n normalizeReleaseRule,\n resolvePlugin,\n type GitAuthor,\n type ReleaseConfig,\n type ResolvedReleaseConfig,\n} from '@reelout/core'\nimport { defaultConfig } from './defaultConfig'\n\n/**\n * Normalize and resolve a release configuration.\n *\n * Applies default author settings when incomplete, normalizes commit filters\n * and release rules, and loads specified plugins.\n *\n * @param cwd Working directory path used for plugin resolution\n * @param config User-supplied release configuration\n * @returns Resolved and normalized release configuration\n * @throws If a configured plugin cannot be resolved\n */\nexport async function normalizeConfig(\n cwd: string,\n config: Required<ReleaseConfig>\n): Promise<ResolvedReleaseConfig> {\n const author: GitAuthor =\n config.author.name && config.author.email\n ? { name: config.author.name, email: config.author.email }\n : { ...defaultConfig.author }\n\n const classifier = normalizeCommitFilter(config.classifier)\n\n const rules = compact(config.rules.map((rule) => normalizeReleaseRule(rule)))\n\n const plugins = compact(\n await Promise.all(\n config.plugins.map(async (plugin) => {\n try {\n return await resolvePlugin(cwd, plugin)\n } catch (err) {\n try {\n return await resolvePlugin(import.meta.filename, plugin)\n } catch {}\n\n throw err\n }\n })\n )\n )\n\n return {\n ...config,\n author,\n classifier,\n rules,\n plugins,\n }\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport type { ReleaseConfig, ResolvedReleaseConfig } from '@reelout/core'\nimport { cosmiconfig } from 'cosmiconfig'\nimport { defaultConfig } from './defaultConfig'\nimport { mergeConfig } from './mergeConfig'\nimport { normalizeConfig } from './normalizeConfig'\n\n/**\n * Resolve and normalize a release configuration for a target directory.\n *\n * Searches for configuration files using `cosmiconfig`, merges discovered user\n * settings with default configurations, and normalizes the resulting structure.\n *\n * @param cwd Working directory path to search from\n * @param name Module name used for configuration file discovery\n * @returns Resolved and normalized release configuration\n */\nexport async function resolveConfig(\n cwd: string,\n name = 'reelout'\n): Promise<ResolvedReleaseConfig> {\n const explorer = cosmiconfig(name)\n\n const result = await explorer.search(cwd)\n\n const config = mergeConfig<Required<ReleaseConfig>>(\n defaultConfig,\n result?.config\n )\n\n return normalizeConfig(cwd, config)\n}\n"],"mappings":";;;;;;;;;;AAWA,IAAa,gBAAgB,OAAO,OAAO;CACzC,QAAQ;EACN,MAAM;EACN,OAAO;CACT;CACA,YAAY;EACV,OAAO,CAAC;EACR,OAAO,CAAC,MAAM;EACd,OAAO;GAAC;GAAO;GAAQ;EAAQ;CACjC;CACA,OAAO;EACL;GAAE,MAAM;GAAU,SAAS;GAAS,WAAW;GAAS,SAAS;EAAQ;EACzE;GAAE,MAAM;GAAU,SAAS;GAAQ,WAAW;GAAQ,SAAS;EAAO;EACtE;GAAE,MAAM;GAAU,SAAS;GAAQ,WAAW;GAAQ,SAAS;EAAO;CACxE;CACA,SAAS;EACP;EACA;EACA;EACA;EACA;EACA;CACF;AACF,CAAmC;;;;;;;;;;;;;ACnBnC,SAAgB,YACd,eACA,YACG;CACH,OAAO,WAAW,CAAC,GAAG,eAAe,aAAa,UAAU,aAAa;EACvE,IAAI,aAAa,KAAA,GACf,OAAO;CAEX,CAAC;AACH;;;;;;;;;;;;;;ACCA,eAAsB,gBACpB,KACA,QACgC;CAChC,MAAM,SACJ,OAAO,OAAO,QAAQ,OAAO,OAAO,QAChC;EAAE,MAAM,OAAO,OAAO;EAAM,OAAO,OAAO,OAAO;CAAM,IACvD,EAAE,GAAG,cAAc,OAAO;CAEhC,MAAM,aAAa,sBAAsB,OAAO,UAAU;CAE1D,MAAM,QAAQ,QAAQ,OAAO,MAAM,KAAK,SAAS,qBAAqB,IAAI,CAAC,CAAC;CAE5E,MAAM,UAAU,QACd,MAAM,QAAQ,IACZ,OAAO,QAAQ,IAAI,OAAO,WAAW;EACnC,IAAI;GACF,OAAO,MAAM,cAAc,KAAK,MAAM;EACxC,SAAS,KAAK;GACZ,IAAI;IACF,OAAO,MAAM,cAAc,YAAY,UAAU,MAAM;GACzD,QAAQ,CAAC;GAET,MAAM;EACR;CACF,CAAC,CACH,CACF;CAEA,OAAO;EACL,GAAG;EACH;EACA;EACA;EACA;CACF;AACF;;;;;;;;;;;;;AC1CA,eAAsB,cACpB,KACA,OAAO,WACyB;CAUhC,OAAO,gBAAgB,KALR,YACb,gBACA,MANe,YAAY,IAER,CAAA,CAAS,OAAO,GAAG,EAItC,EAAQ,MAGkB,CAAM;AACpC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reelout/config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "Release config loading and normalization.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/aicest/reelout.git",
|
|
8
|
+
"directory": "packages/config"
|
|
9
|
+
},
|
|
4
10
|
"license": "MIT",
|
|
5
11
|
"type": "module",
|
|
6
12
|
"imports": {},
|
|
@@ -25,11 +31,22 @@
|
|
|
25
31
|
"./dist",
|
|
26
32
|
"./src"
|
|
27
33
|
],
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@reelout/core": "^0.4.0",
|
|
36
|
+
"@reelout/git": "^0.4.0",
|
|
37
|
+
"@reelout/github": "^0.4.0",
|
|
38
|
+
"@reelout/npm": "^0.4.0",
|
|
39
|
+
"cosmiconfig": "^10.0.1",
|
|
40
|
+
"lodash-es": "^4.18.1"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@types/lodash-es": "^4.17.12"
|
|
44
|
+
},
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=24.15"
|
|
47
|
+
},
|
|
28
48
|
"scripts": {
|
|
29
49
|
"build": "vite build --ssr --sourcemap",
|
|
30
50
|
"dev": "vite build --ssr --watch"
|
|
31
|
-
},
|
|
32
|
-
"engines": {
|
|
33
|
-
"node": ">=24.11"
|
|
34
51
|
}
|
|
35
|
-
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// Copyright (c) 2026 Fai
|
|
3
|
+
|
|
4
|
+
import type { ReleaseConfig } from '@reelout/core'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Default release configuration used when no user config is provided.
|
|
8
|
+
*
|
|
9
|
+
* Includes defaults for user identity, workspace layout, release rules,
|
|
10
|
+
* commit-to-release mappings, and built-in plugins.
|
|
11
|
+
*/
|
|
12
|
+
export const defaultConfig = Object.freeze({
|
|
13
|
+
author: {
|
|
14
|
+
name: 'github-actions[bot]',
|
|
15
|
+
email: '41898282+github-actions[bot]@users.noreply.github.com',
|
|
16
|
+
},
|
|
17
|
+
classifier: {
|
|
18
|
+
major: [],
|
|
19
|
+
minor: ['feat'],
|
|
20
|
+
patch: ['fix', 'perf', 'revert'],
|
|
21
|
+
},
|
|
22
|
+
rules: [
|
|
23
|
+
{ type: 'branch', pattern: 'alpha', qualifier: 'alpha', channel: 'alpha' },
|
|
24
|
+
{ type: 'branch', pattern: 'beta', qualifier: 'beta', channel: 'beta' },
|
|
25
|
+
{ type: 'branch', pattern: 'next', qualifier: 'next', channel: 'next' },
|
|
26
|
+
],
|
|
27
|
+
plugins: [
|
|
28
|
+
'@reelout/core/analyzer', // Analyze the commits and determine the release type.
|
|
29
|
+
'@reelout/core/builder', // Build the release artifacts.
|
|
30
|
+
'@reelout/core/changelog', // Generate and write changelog entries for each release.
|
|
31
|
+
'@reelout/npm', // Update package manifests and publish packages to npm.
|
|
32
|
+
'@reelout/git', // Create release commits and tags, then push them.
|
|
33
|
+
'@reelout/github', // Create GitHub releases from finalized plans.
|
|
34
|
+
],
|
|
35
|
+
} satisfies Required<ReleaseConfig>)
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
//
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// Copyright (c) 2026 Fai
|
|
2
3
|
|
|
3
|
-
export
|
|
4
|
+
export * from './defaultConfig'
|
|
5
|
+
export * from './mergeConfig'
|
|
6
|
+
export * from './normalizeConfig'
|
|
7
|
+
export * from './resolveConfig'
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// Copyright (c) 2026 Fai
|
|
3
|
+
|
|
4
|
+
import { assignWith } from 'lodash-es'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Merge a user configuration into the defaults, preserving unspecified keys.
|
|
8
|
+
*
|
|
9
|
+
* Uses `lodash.assignWith` to avoid overwriting default values with
|
|
10
|
+
* `undefined` from the user configuration.
|
|
11
|
+
*
|
|
12
|
+
* @param defaultConfig Default configuration object
|
|
13
|
+
* @param userConfig Partial user-provided configuration
|
|
14
|
+
* @returns Merged configuration object
|
|
15
|
+
*/
|
|
16
|
+
export function mergeConfig<T>(
|
|
17
|
+
defaultConfig: T,
|
|
18
|
+
userConfig: Partial<T> | null | undefined
|
|
19
|
+
): T {
|
|
20
|
+
return assignWith({}, defaultConfig, userConfig, (objValue, srcValue) => {
|
|
21
|
+
if (srcValue === undefined) {
|
|
22
|
+
return objValue
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// Copyright (c) 2026 Fai
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
compact,
|
|
6
|
+
normalizeCommitFilter,
|
|
7
|
+
normalizeReleaseRule,
|
|
8
|
+
resolvePlugin,
|
|
9
|
+
type GitAuthor,
|
|
10
|
+
type ReleaseConfig,
|
|
11
|
+
type ResolvedReleaseConfig,
|
|
12
|
+
} from '@reelout/core'
|
|
13
|
+
import { defaultConfig } from './defaultConfig'
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Normalize and resolve a release configuration.
|
|
17
|
+
*
|
|
18
|
+
* Applies default author settings when incomplete, normalizes commit filters
|
|
19
|
+
* and release rules, and loads specified plugins.
|
|
20
|
+
*
|
|
21
|
+
* @param cwd Working directory path used for plugin resolution
|
|
22
|
+
* @param config User-supplied release configuration
|
|
23
|
+
* @returns Resolved and normalized release configuration
|
|
24
|
+
* @throws If a configured plugin cannot be resolved
|
|
25
|
+
*/
|
|
26
|
+
export async function normalizeConfig(
|
|
27
|
+
cwd: string,
|
|
28
|
+
config: Required<ReleaseConfig>
|
|
29
|
+
): Promise<ResolvedReleaseConfig> {
|
|
30
|
+
const author: GitAuthor =
|
|
31
|
+
config.author.name && config.author.email
|
|
32
|
+
? { name: config.author.name, email: config.author.email }
|
|
33
|
+
: { ...defaultConfig.author }
|
|
34
|
+
|
|
35
|
+
const classifier = normalizeCommitFilter(config.classifier)
|
|
36
|
+
|
|
37
|
+
const rules = compact(config.rules.map((rule) => normalizeReleaseRule(rule)))
|
|
38
|
+
|
|
39
|
+
const plugins = compact(
|
|
40
|
+
await Promise.all(
|
|
41
|
+
config.plugins.map(async (plugin) => {
|
|
42
|
+
try {
|
|
43
|
+
return await resolvePlugin(cwd, plugin)
|
|
44
|
+
} catch (err) {
|
|
45
|
+
try {
|
|
46
|
+
return await resolvePlugin(import.meta.filename, plugin)
|
|
47
|
+
} catch {}
|
|
48
|
+
|
|
49
|
+
throw err
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
)
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
...config,
|
|
57
|
+
author,
|
|
58
|
+
classifier,
|
|
59
|
+
rules,
|
|
60
|
+
plugins,
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// Copyright (c) 2026 Fai
|
|
3
|
+
|
|
4
|
+
import type { ReleaseConfig, ResolvedReleaseConfig } from '@reelout/core'
|
|
5
|
+
import { cosmiconfig } from 'cosmiconfig'
|
|
6
|
+
import { defaultConfig } from './defaultConfig'
|
|
7
|
+
import { mergeConfig } from './mergeConfig'
|
|
8
|
+
import { normalizeConfig } from './normalizeConfig'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Resolve and normalize a release configuration for a target directory.
|
|
12
|
+
*
|
|
13
|
+
* Searches for configuration files using `cosmiconfig`, merges discovered user
|
|
14
|
+
* settings with default configurations, and normalizes the resulting structure.
|
|
15
|
+
*
|
|
16
|
+
* @param cwd Working directory path to search from
|
|
17
|
+
* @param name Module name used for configuration file discovery
|
|
18
|
+
* @returns Resolved and normalized release configuration
|
|
19
|
+
*/
|
|
20
|
+
export async function resolveConfig(
|
|
21
|
+
cwd: string,
|
|
22
|
+
name = 'reelout'
|
|
23
|
+
): Promise<ResolvedReleaseConfig> {
|
|
24
|
+
const explorer = cosmiconfig(name)
|
|
25
|
+
|
|
26
|
+
const result = await explorer.search(cwd)
|
|
27
|
+
|
|
28
|
+
const config = mergeConfig<Required<ReleaseConfig>>(
|
|
29
|
+
defaultConfig,
|
|
30
|
+
result?.config
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
return normalizeConfig(cwd, config)
|
|
34
|
+
}
|