@alint-js/config 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +3 -2
- package/dist/index.mjs +31 -2
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AlintConfig, AlintConfig as AlintConfig$1, ModelSize, ProviderDefinition, ProviderType, RunnerConfig, SetupConfig, SetupConfig as SetupConfig$1, SetupModelDefinition } from "@alint-js/core";
|
|
1
|
+
import { AlintConfig, AlintConfig as AlintConfig$1, ModelSize, ProviderDefinition, ProviderType, RunnerConfig, RunnerStatsConfig, SetupConfig, SetupConfig as SetupConfig$1, SetupModelDefinition } from "@alint-js/core";
|
|
2
2
|
|
|
3
3
|
//#region src/config/load.d.ts
|
|
4
4
|
declare function loadAlintConfig(cwd: string, configFile?: string): Promise<AlintConfig$1>;
|
|
@@ -10,6 +10,7 @@ interface GlobalSetupConfigPathOptions {
|
|
|
10
10
|
}
|
|
11
11
|
declare function getGlobalSetupConfigPath(env?: NodeJS.ProcessEnv, options?: GlobalSetupConfigPathOptions): string;
|
|
12
12
|
declare function getProjectSetupConfigPath(cwd: string): string;
|
|
13
|
+
declare function getStatsDir(env?: NodeJS.ProcessEnv, options?: GlobalSetupConfigPathOptions): string;
|
|
13
14
|
//#endregion
|
|
14
15
|
//#region src/setup/load.d.ts
|
|
15
16
|
declare const emptySetupConfig: SetupConfig$1;
|
|
@@ -23,4 +24,4 @@ declare function stringifySetupConfigToml(config: SetupConfig$1): string;
|
|
|
23
24
|
//#region src/setup/write.d.ts
|
|
24
25
|
declare function writeSetupConfig(filePath: string, config: SetupConfig$1): Promise<void>;
|
|
25
26
|
//#endregion
|
|
26
|
-
export { type AlintConfig, type GlobalSetupConfigPathOptions, type ModelSize, type ProviderDefinition, type ProviderType, type RunnerConfig, type SetupConfig, type SetupModelDefinition, emptySetupConfig, getGlobalSetupConfigPath, getProjectSetupConfigPath, loadAlintConfig, loadSetupConfig, mergeSetupConfigs, parseSetupConfigToml, stringifySetupConfigToml, writeSetupConfig };
|
|
27
|
+
export { type AlintConfig, type GlobalSetupConfigPathOptions, type ModelSize, type ProviderDefinition, type ProviderType, type RunnerConfig, type RunnerStatsConfig, type SetupConfig, type SetupModelDefinition, emptySetupConfig, getGlobalSetupConfigPath, getProjectSetupConfigPath, getStatsDir, loadAlintConfig, loadSetupConfig, mergeSetupConfigs, parseSetupConfigToml, stringifySetupConfigToml, writeSetupConfig };
|
package/dist/index.mjs
CHANGED
|
@@ -19,11 +19,17 @@ async function loadAlintConfig(cwd, configFile) {
|
|
|
19
19
|
//#endregion
|
|
20
20
|
//#region src/paths.ts
|
|
21
21
|
function getGlobalSetupConfigPath(env = process.env, options = {}) {
|
|
22
|
-
return join(env
|
|
22
|
+
return join(resolveAlintHome(env, options), "config.toml");
|
|
23
23
|
}
|
|
24
24
|
function getProjectSetupConfigPath(cwd) {
|
|
25
25
|
return join(cwd, ".alint", "config.toml");
|
|
26
26
|
}
|
|
27
|
+
function getStatsDir(env = process.env, options = {}) {
|
|
28
|
+
return join(resolveAlintHome(env, options), "stats");
|
|
29
|
+
}
|
|
30
|
+
function resolveAlintHome(env, options) {
|
|
31
|
+
return join(env.XDG_CONFIG_HOME ?? resolveDefaultConfigHome(options), "alint");
|
|
32
|
+
}
|
|
27
33
|
function resolveDefaultConfigHome(options) {
|
|
28
34
|
if (options.isMacOS ?? process.platform === "darwin") return join(homedir(), ".config");
|
|
29
35
|
return options.xdgConfig ?? xdgConfig ?? join(homedir(), ".config");
|
|
@@ -97,6 +103,7 @@ function parseRunner(runner) {
|
|
|
97
103
|
if (runner.cache !== void 0) parsedRunner.cache = parseRunnerCache(runner.cache);
|
|
98
104
|
if (runner.file_concurrency !== void 0) parsedRunner.fileConcurrency = parsePositiveInteger(runner.file_concurrency, "runner file_concurrency");
|
|
99
105
|
if (runner.rule_concurrency !== void 0) parsedRunner.ruleConcurrency = parsePositiveInteger(runner.rule_concurrency, "runner rule_concurrency");
|
|
106
|
+
if (runner.stats !== void 0) parsedRunner.stats = parseRunnerStats(runner.stats);
|
|
100
107
|
if (runner.timeout_ms !== void 0) parsedRunner.timeoutMs = parsePositiveInteger(runner.timeout_ms, "runner timeout_ms");
|
|
101
108
|
return parsedRunner;
|
|
102
109
|
}
|
|
@@ -112,6 +119,19 @@ function parseRunnerCache(cache) {
|
|
|
112
119
|
if (tomlCache.location !== void 0) parsedCache.location = readNonEmptyString(tomlCache.location, "runner cache location");
|
|
113
120
|
return parsedCache;
|
|
114
121
|
}
|
|
122
|
+
function parseRunnerStats(stats) {
|
|
123
|
+
if (typeof stats === "boolean") return stats;
|
|
124
|
+
if (!isPlainObject(stats)) throw new TypeError("Invalid runner stats: must be a boolean or an object.");
|
|
125
|
+
const tomlStats = stats;
|
|
126
|
+
const parsedStats = {};
|
|
127
|
+
if (tomlStats.enabled !== void 0) {
|
|
128
|
+
if (typeof tomlStats.enabled !== "boolean") throw new TypeError("Invalid runner stats enabled: must be a boolean.");
|
|
129
|
+
parsedStats.enabled = tomlStats.enabled;
|
|
130
|
+
}
|
|
131
|
+
if (tomlStats.location !== void 0) parsedStats.location = readNonEmptyString(tomlStats.location, "runner stats location");
|
|
132
|
+
if (tomlStats.retention_months !== void 0) parsedStats.retentionMonths = parsePositiveInteger(tomlStats.retention_months, "runner stats retention_months");
|
|
133
|
+
return parsedStats;
|
|
134
|
+
}
|
|
115
135
|
function readFiniteNumber(value, label) {
|
|
116
136
|
if (typeof value !== "number" || !Number.isFinite(value)) throw new TypeError(`Invalid ${label}: must be a finite number.`);
|
|
117
137
|
return value;
|
|
@@ -163,12 +183,21 @@ function toTomlRunner(runner) {
|
|
|
163
183
|
cache: toTomlRunnerCache(runner.cache),
|
|
164
184
|
file_concurrency: runner.fileConcurrency,
|
|
165
185
|
rule_concurrency: runner.ruleConcurrency,
|
|
186
|
+
stats: toTomlRunnerStats(runner.stats),
|
|
166
187
|
timeout_ms: runner.timeoutMs
|
|
167
188
|
};
|
|
168
189
|
}
|
|
169
190
|
function toTomlRunnerCache(cache) {
|
|
170
191
|
return cache;
|
|
171
192
|
}
|
|
193
|
+
function toTomlRunnerStats(stats) {
|
|
194
|
+
if (stats === void 0 || typeof stats === "boolean") return stats;
|
|
195
|
+
return {
|
|
196
|
+
enabled: stats.enabled,
|
|
197
|
+
location: stats.location,
|
|
198
|
+
retention_months: stats.retentionMonths
|
|
199
|
+
};
|
|
200
|
+
}
|
|
172
201
|
//#endregion
|
|
173
202
|
//#region src/setup/load.ts
|
|
174
203
|
const emptySetupConfig = {
|
|
@@ -277,4 +306,4 @@ async function writeSetupConfig(filePath, config) {
|
|
|
277
306
|
await writeFile(filePath, stringifySetupConfigToml(config), "utf8");
|
|
278
307
|
}
|
|
279
308
|
//#endregion
|
|
280
|
-
export { emptySetupConfig, getGlobalSetupConfigPath, getProjectSetupConfigPath, loadAlintConfig, loadSetupConfig, mergeSetupConfigs, parseSetupConfigToml, stringifySetupConfigToml, writeSetupConfig };
|
|
309
|
+
export { emptySetupConfig, getGlobalSetupConfigPath, getProjectSetupConfigPath, getStatsDir, loadAlintConfig, loadSetupConfig, mergeSetupConfigs, parseSetupConfigToml, stringifySetupConfigToml, writeSetupConfig };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alint-js/config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.9",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
7
7
|
"types": "./dist/index.d.mts",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"pathe": "^2.0.3",
|
|
18
18
|
"smol-toml": "^1.7.0",
|
|
19
19
|
"xdg-basedir": "^5.1.0",
|
|
20
|
-
"@alint-js/core": "0.0.
|
|
20
|
+
"@alint-js/core": "0.0.9"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@types/node": "^26.0.1",
|