@storm-software/config-tools 1.35.6 → 1.36.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/CHANGELOG.md +24 -0
- package/README.md +1 -1
- package/package.json +4 -2
- package/src/config-file/get-config-file.ts +30 -90
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
## 1.36.0 (2024-04-09)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### 🚀 Features
|
|
5
|
+
|
|
6
|
+
- **config-tools:** Significant improvements to logic to get config files ([0a0ac895](https://github.com/storm-software/storm-ops/commit/0a0ac895))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### ❤️ Thank You
|
|
10
|
+
|
|
11
|
+
- Patrick Sullivan
|
|
12
|
+
|
|
13
|
+
## 1.35.7 (2024-04-08)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### 🩹 Fixes
|
|
17
|
+
|
|
18
|
+
- **build-tools:** Resolved issue with module types used in build ([50a368d3](https://github.com/storm-software/storm-ops/commit/50a368d3))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### ❤️ Thank You
|
|
22
|
+
|
|
23
|
+
- Patrick Sullivan
|
|
24
|
+
|
|
1
25
|
## 1.35.6 (2024-04-08)
|
|
2
26
|
|
|
3
27
|
|
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ This package is part of the <b>⚡Storm-Ops</b> monorepo. The Storm-Ops packages
|
|
|
16
16
|
|
|
17
17
|
<h3 align="center">💻 Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
|
|
18
18
|
|
|
19
|
-
[](https://prettier.io/)
|
|
20
20
|
[](http://nx.dev/) [](https://nextjs.org/) [](http://commitizen.github.io/cz-cli/)  [](https://docusaurus.io/) 
|
|
21
21
|
|
|
22
22
|
> [!IMPORTANT]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storm-software/config-tools",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.36.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "⚡The Storm-Ops monorepo contains utility applications, tools, and various libraries to create modern and scalable web applications.",
|
|
6
6
|
"repository": {
|
|
@@ -11,8 +11,10 @@
|
|
|
11
11
|
"main": "./index.js",
|
|
12
12
|
"types": "declarations.d.ts",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"
|
|
14
|
+
"c12": "^1.10.0",
|
|
15
|
+
"chalk": "5.3.0",
|
|
15
16
|
"cosmiconfig": "9.0.0",
|
|
17
|
+
"deepmerge": "4.3.1",
|
|
16
18
|
"zod": "3.22.4"
|
|
17
19
|
},
|
|
18
20
|
"publishConfig": {
|
|
@@ -1,35 +1,10 @@
|
|
|
1
|
-
import type { CosmiconfigResult, PublicExplorer, Config } from "cosmiconfig";
|
|
2
1
|
import type { StormConfigInput } from "@storm-software/config";
|
|
3
|
-
import { join } from "node:path";
|
|
4
2
|
import { findWorkspaceRoot } from "../utilities/find-workspace-root";
|
|
5
|
-
import {
|
|
3
|
+
import { loadConfig } from "c12";
|
|
4
|
+
import merge from "deepmerge";
|
|
6
5
|
|
|
7
|
-
let _cosmiconfig: any = undefined;
|
|
8
|
-
let defaultExplorer: PublicExplorer | undefined;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Get the config file for the current Storm workspace
|
|
12
|
-
*
|
|
13
|
-
* @param fileName - The name of the config file to search for
|
|
14
|
-
* @param filePath - The path to search for the config file in
|
|
15
|
-
* @returns The config file for the current Storm workspace
|
|
16
|
-
*/
|
|
17
|
-
export const getConfigFileExplorer = async (
|
|
18
|
-
fileName: string
|
|
19
|
-
): Promise<PublicExplorer | undefined> => {
|
|
20
|
-
if (!_cosmiconfig) {
|
|
21
|
-
const mod = await import("cosmiconfig");
|
|
22
|
-
if (mod?.cosmiconfig) {
|
|
23
|
-
_cosmiconfig = mod.cosmiconfig;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (!_cosmiconfig) {
|
|
27
|
-
return undefined;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return _cosmiconfig(fileName, { cache: true });
|
|
32
|
-
};
|
|
6
|
+
// let _cosmiconfig: any = undefined;
|
|
7
|
+
// let defaultExplorer: PublicExplorer | undefined;
|
|
33
8
|
|
|
34
9
|
/**
|
|
35
10
|
* Get the config file for the current Storm workspace
|
|
@@ -41,36 +16,13 @@ export const getConfigFileExplorer = async (
|
|
|
41
16
|
export const getConfigFileByName = async (
|
|
42
17
|
fileName: string,
|
|
43
18
|
filePath?: string
|
|
44
|
-
): Promise<
|
|
45
|
-
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Get the config file for the current Storm workspace
|
|
50
|
-
*
|
|
51
|
-
* @param fileName - The name of the config file to search for
|
|
52
|
-
* @param filePath - The path to search for the config file in
|
|
53
|
-
* @returns The config file for the current Storm workspace
|
|
54
|
-
*/
|
|
55
|
-
export const getJsonConfigFile = async (
|
|
56
|
-
fileName: string,
|
|
57
|
-
filePath?: string
|
|
58
|
-
): Promise<CosmiconfigResult | undefined> => {
|
|
59
|
-
// const fse = await import("fs-extra/esm");
|
|
60
|
-
|
|
61
|
-
const jsonPath = join(
|
|
62
|
-
filePath ?? process.cwd(),
|
|
63
|
-
fileName.endsWith(".json") ? fileName : `${fileName}.json`
|
|
64
|
-
);
|
|
65
|
-
const isEmpty = !!(await stat(jsonPath).catch((_) => false));
|
|
19
|
+
): Promise<Partial<StormConfigInput> | undefined> => {
|
|
20
|
+
const workspacePath = filePath ? filePath : findWorkspaceRoot(filePath);
|
|
66
21
|
|
|
67
|
-
return
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
isEmpty
|
|
72
|
-
}
|
|
73
|
-
: { config: {} as Config, filepath: jsonPath, isEmpty };
|
|
22
|
+
return loadConfig<Partial<StormConfigInput>>({
|
|
23
|
+
cwd: workspacePath,
|
|
24
|
+
name: fileName
|
|
25
|
+
});
|
|
74
26
|
};
|
|
75
27
|
|
|
76
28
|
/**
|
|
@@ -84,45 +36,33 @@ export const getConfigFile = async (
|
|
|
84
36
|
): Promise<Partial<StormConfigInput> | undefined> => {
|
|
85
37
|
const workspacePath = filePath ? filePath : findWorkspaceRoot(filePath);
|
|
86
38
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
cosmiconfigResult = await getConfigFileByName(additionalFileName, workspacePath);
|
|
106
|
-
if (cosmiconfigResult && !cosmiconfigResult.isEmpty) {
|
|
107
|
-
break;
|
|
39
|
+
let { config, configFile } = await loadConfig<Partial<StormConfigInput>>({
|
|
40
|
+
cwd: workspacePath,
|
|
41
|
+
name: "storm"
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
if (additionalFileNames) {
|
|
45
|
+
const results = await Promise.all(
|
|
46
|
+
additionalFileNames.map(fileName =>
|
|
47
|
+
loadConfig({
|
|
48
|
+
cwd: workspacePath,
|
|
49
|
+
name: fileName
|
|
50
|
+
})
|
|
51
|
+
)
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
for (const result of results) {
|
|
55
|
+
if (result) {
|
|
56
|
+
config = merge(config ?? {}, result.config ?? {});
|
|
108
57
|
}
|
|
109
58
|
}
|
|
110
59
|
}
|
|
111
|
-
// }
|
|
112
60
|
|
|
113
|
-
if (
|
|
114
|
-
!cosmiconfigResult ||
|
|
115
|
-
Object.keys(cosmiconfigResult).length === 0 ||
|
|
116
|
-
cosmiconfigResult.isEmpty ||
|
|
117
|
-
!cosmiconfigResult.filepath
|
|
118
|
-
) {
|
|
61
|
+
if (!config) {
|
|
119
62
|
return undefined;
|
|
120
63
|
}
|
|
121
64
|
|
|
122
|
-
|
|
123
|
-
if (cosmiconfigResult.filepath) {
|
|
124
|
-
config.configFile = cosmiconfigResult.filepath;
|
|
125
|
-
}
|
|
65
|
+
config.configFile = configFile;
|
|
126
66
|
config.runtimeVersion = "0.0.1";
|
|
127
67
|
|
|
128
68
|
return config;
|