@appsys-sas/devtool-config 0.0.0-stage → 1.0.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 +201 -0
- package/lib/index.d.ts +90 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +332 -0
- package/lib/index.js.map +1 -0
- package/package.json +36 -3
- package/schema/config.schema.json +792 -0
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
export type RawConfig = Record<string, unknown>;
|
|
2
|
+
/**
|
|
3
|
+
* Gives the sections declaring no path the `sectionPath` of the configuration, the workspace itself by
|
|
4
|
+
* default, then resolves the paths of the sections from the workspace, leaving them relative without one.
|
|
5
|
+
* @param config The merged configuration.
|
|
6
|
+
* @param workspace The workspace, null when none is declared.
|
|
7
|
+
*/
|
|
8
|
+
export declare function resolveSectionPaths(config: RawConfig, workspace: string | null): void;
|
|
9
|
+
/**
|
|
10
|
+
* Merges a configuration file over another.
|
|
11
|
+
* @param a The configuration merged into, changed.
|
|
12
|
+
* @param b The configuration merged over it.
|
|
13
|
+
* @returns The merged configuration.
|
|
14
|
+
*/
|
|
15
|
+
export declare function mergeConfig<T extends RawConfig>(a: T, b: RawConfig): T;
|
|
16
|
+
/** The files declaring each setting of a configuration, by {@link configSourceKey}, in the order they are merged. */
|
|
17
|
+
export type ConfigSources = Record<string, string[]>;
|
|
18
|
+
/**
|
|
19
|
+
* Names a setting of a configuration among its sources.
|
|
20
|
+
* @param settingPath The keys leading to the setting, list indexes included.
|
|
21
|
+
* @returns The key of the setting.
|
|
22
|
+
*/
|
|
23
|
+
export declare function configSourceKey(settingPath: (string | number)[]): string;
|
|
24
|
+
/**
|
|
25
|
+
* Loads a YAML config file and its includes.
|
|
26
|
+
* @param filePath Path of the YAML config file to load.
|
|
27
|
+
* @param baseDirectory Directory relative paths are resolved from, the file directory by default.
|
|
28
|
+
* @param sources Receives the file declaring each setting.
|
|
29
|
+
* @returns The merged raw configuration object.
|
|
30
|
+
*/
|
|
31
|
+
export declare function loadConfigFile(filePath: string, baseDirectory?: string, sources?: ConfigSources): Promise<RawConfig>;
|
|
32
|
+
/** The environment variable naming the configuration folder. */
|
|
33
|
+
export declare const CONFIG_FOLDER_VARIABLE = "ADT_CONFIG_FOLDER";
|
|
34
|
+
/**
|
|
35
|
+
* Gives the configuration folder: the one named by `ADT_CONFIG_FOLDER`, else `~/.config/appsys/devtool`.
|
|
36
|
+
* @returns The absolute path of the folder.
|
|
37
|
+
*/
|
|
38
|
+
export declare function resolveConfigFolder(): string;
|
|
39
|
+
/**
|
|
40
|
+
* Gives the cache folder of a configuration: its `adt.cacheDir`, else `~/.cache/appsys/devtool`.
|
|
41
|
+
* @param config The merged configuration.
|
|
42
|
+
* @returns The absolute path of the folder.
|
|
43
|
+
*/
|
|
44
|
+
export declare function resolveCacheFolder(config: RawConfig): string;
|
|
45
|
+
/** How the devtool names and shows itself. */
|
|
46
|
+
export interface AppIdentity {
|
|
47
|
+
/** The identifier, such as the name of its MCP server. */
|
|
48
|
+
name: string;
|
|
49
|
+
/** The name shown to people, such as the name of its app. */
|
|
50
|
+
displayName: string;
|
|
51
|
+
/** The image of its icon, null for the default one. */
|
|
52
|
+
icon: string | null;
|
|
53
|
+
}
|
|
54
|
+
/** A setting of the identity left at its default, and why. */
|
|
55
|
+
export interface AppIdentityProblem {
|
|
56
|
+
setting: string;
|
|
57
|
+
message: string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Gives how a configuration names and shows the devtool: `adt.displayName`, `adt.name` (by default the
|
|
61
|
+
* identifier of the display name) and `adt.icon`, an invalid setting keeping its default.
|
|
62
|
+
* @param config The merged configuration.
|
|
63
|
+
* @returns The identity and the settings left at their default.
|
|
64
|
+
*/
|
|
65
|
+
export declare function resolveAppIdentity(config: RawConfig): {
|
|
66
|
+
identity: AppIdentity;
|
|
67
|
+
problems: AppIdentityProblem[];
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Lists the default configuration files: the shared configuration of the configuration folder, then the personal
|
|
71
|
+
* overrides.
|
|
72
|
+
* @param folder The configuration folder.
|
|
73
|
+
* @returns The configuration paths, in merge order.
|
|
74
|
+
*/
|
|
75
|
+
export declare function resolveDefaultConfigPaths(folder?: string): string[];
|
|
76
|
+
/**
|
|
77
|
+
* Loads and merges configuration files, each overriding the previous ones. Relative paths are resolved from the
|
|
78
|
+
* directory of the first file, the configuration folder, but those of the sections, `sectionPath` for the sections
|
|
79
|
+
* declaring none, resolved from the `workspace` of the merged configuration and left relative without one.
|
|
80
|
+
* @param configPaths Paths of the configuration files; missing files are skipped.
|
|
81
|
+
* @returns The merged configuration, the files loaded, the files declaring each setting, and the personal override
|
|
82
|
+
* among the paths (`*.local.yml`, loaded last), null when none is given.
|
|
83
|
+
*/
|
|
84
|
+
export declare function loadMergedConfig(configPaths?: string[]): Promise<{
|
|
85
|
+
config: RawConfig;
|
|
86
|
+
loadedPaths: string[];
|
|
87
|
+
sources: ConfigSources;
|
|
88
|
+
localPath: string | null;
|
|
89
|
+
}>;
|
|
90
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAwF/C;;;;;GAKG;AACH,w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AACH,wBAAgB,yBAAyB,CAAE,MAAM,SAAwB,GAAG,MAAM,EAAE,CAEnF;AAED;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CAAE,WAAW,WAA8B,GAAG,OAAO,CAAC;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,WAAW,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,aAAa,CAAC;IAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC,CAuB1L"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { glob } from 'glob';
|
|
5
|
+
import { loadAll, YAMLException } from 'js-yaml';
|
|
6
|
+
import cloneDeep from 'lodash.clonedeep';
|
|
7
|
+
import mergeWith from 'lodash.mergewith';
|
|
8
|
+
const ENV_VAR_PATTERN = /\$(\{([A-Za-z_][A-Za-z0-9_]*)\}|([A-Za-z_][A-Za-z0-9_]*))/g;
|
|
9
|
+
function resolveHomePath(input) {
|
|
10
|
+
if (input.startsWith('~/')) {
|
|
11
|
+
return path.join(os.homedir(), input.slice(2));
|
|
12
|
+
}
|
|
13
|
+
return input;
|
|
14
|
+
}
|
|
15
|
+
function expandEnvVars(input) {
|
|
16
|
+
const withHome = resolveHomePath(input);
|
|
17
|
+
return withHome.replace(ENV_VAR_PATTERN, (_, _full, bracedName, plainName) => {
|
|
18
|
+
const varName = bracedName ?? plainName;
|
|
19
|
+
if (!varName) {
|
|
20
|
+
return _;
|
|
21
|
+
}
|
|
22
|
+
const value = process.env[varName];
|
|
23
|
+
return typeof value === 'string' ? value : _;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
function expandEnvVarsDeep(value) {
|
|
27
|
+
if (typeof value === 'string') {
|
|
28
|
+
return expandEnvVars(value);
|
|
29
|
+
}
|
|
30
|
+
if (Array.isArray(value)) {
|
|
31
|
+
return value.map(item => expandEnvVarsDeep(item));
|
|
32
|
+
}
|
|
33
|
+
if (typeof value === 'object' && value !== null) {
|
|
34
|
+
const output = {};
|
|
35
|
+
for (const [key, item] of Object.entries(value)) {
|
|
36
|
+
output[key] = expandEnvVarsDeep(item);
|
|
37
|
+
}
|
|
38
|
+
return output;
|
|
39
|
+
}
|
|
40
|
+
return value;
|
|
41
|
+
}
|
|
42
|
+
function resolveConfigPath(cwd, input) {
|
|
43
|
+
if (path.isAbsolute(input) || input.trimStart().startsWith('-----BEGIN ')) {
|
|
44
|
+
return input;
|
|
45
|
+
}
|
|
46
|
+
return path.resolve(cwd, input);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Resolves a path setting of a record from a directory, leaving other values untouched.
|
|
50
|
+
* @param record The record holding the setting.
|
|
51
|
+
* @param key The name of the setting.
|
|
52
|
+
* @param cwd Directory the relative path is resolved from.
|
|
53
|
+
*/
|
|
54
|
+
function resolvePathSetting(record, key, cwd) {
|
|
55
|
+
if (typeof record === 'object' && record !== null) {
|
|
56
|
+
const settings = record;
|
|
57
|
+
if (typeof settings[key] === 'string') {
|
|
58
|
+
settings[key] = resolveConfigPath(cwd, settings[key]);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Resolves the paths a configuration file gives relative to the configuration folder: the cache, the icon, the
|
|
64
|
+
* certificates of the load balancers, the environment folder and the workspace.
|
|
65
|
+
* @param config The configuration of the file.
|
|
66
|
+
* @param cwd The configuration folder.
|
|
67
|
+
*/
|
|
68
|
+
function resolveFolderPaths(config, cwd) {
|
|
69
|
+
resolvePathSetting(config, 'workspace', cwd);
|
|
70
|
+
resolvePathSetting(config.adt, 'cacheDir', cwd);
|
|
71
|
+
resolvePathSetting(config.adt, 'icon', cwd);
|
|
72
|
+
resolvePathSetting(config.environment, 'folder', cwd);
|
|
73
|
+
if (typeof config.loadBalancers === 'object' && config.loadBalancers !== null) {
|
|
74
|
+
for (const certificate of Object.values(config.loadBalancers)) {
|
|
75
|
+
resolvePathSetting(certificate, 'crt', cwd);
|
|
76
|
+
resolvePathSetting(certificate, 'key', cwd);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Gives the sections declaring no path the `sectionPath` of the configuration, the workspace itself by
|
|
82
|
+
* default, then resolves the paths of the sections from the workspace, leaving them relative without one.
|
|
83
|
+
* @param config The merged configuration.
|
|
84
|
+
* @param workspace The workspace, null when none is declared.
|
|
85
|
+
*/
|
|
86
|
+
export function resolveSectionPaths(config, workspace) {
|
|
87
|
+
if (typeof config.sections !== 'object' || config.sections === null) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const fallback = typeof config.sectionPath === 'string' ? config.sectionPath : '.';
|
|
91
|
+
for (const sectionValue of Object.values(config.sections)) {
|
|
92
|
+
if (typeof sectionValue !== 'object' || sectionValue === null) {
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
const section = sectionValue;
|
|
96
|
+
if (typeof section.path !== 'string') {
|
|
97
|
+
section.path = fallback;
|
|
98
|
+
}
|
|
99
|
+
if (workspace !== null) {
|
|
100
|
+
section.path = resolveConfigPath(workspace, section.path);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
async function pathExists(fullPath) {
|
|
105
|
+
try {
|
|
106
|
+
await fs.stat(fullPath);
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Merges one value of a configuration file over another: `include` lists are joined, and an item of a
|
|
115
|
+
* list written as a text, the short form of `{ path }`, takes the settings of the item over it.
|
|
116
|
+
* @param left The value merged into.
|
|
117
|
+
* @param right The value merged over it.
|
|
118
|
+
* @param key The key or index of the value.
|
|
119
|
+
* @param holder What holds the value merged into.
|
|
120
|
+
* @returns The merged value, undefined to merge it the default way.
|
|
121
|
+
*/
|
|
122
|
+
function mergeValue(left, right, key, holder) {
|
|
123
|
+
if (Array.isArray(left) && Array.isArray(right) && key === 'include') {
|
|
124
|
+
return left.concat(right);
|
|
125
|
+
}
|
|
126
|
+
if (Array.isArray(holder) && typeof left === 'string' && typeof right === 'object' && right !== null && !Array.isArray(right)) {
|
|
127
|
+
return mergeWith({ path: left }, right, mergeValue);
|
|
128
|
+
}
|
|
129
|
+
return undefined;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Merges a configuration file over another.
|
|
133
|
+
* @param a The configuration merged into, changed.
|
|
134
|
+
* @param b The configuration merged over it.
|
|
135
|
+
* @returns The merged configuration.
|
|
136
|
+
*/
|
|
137
|
+
export function mergeConfig(a, b) {
|
|
138
|
+
return mergeWith(a, cloneDeep(b), mergeValue);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Names a setting of a configuration among its sources.
|
|
142
|
+
* @param settingPath The keys leading to the setting, list indexes included.
|
|
143
|
+
* @returns The key of the setting.
|
|
144
|
+
*/
|
|
145
|
+
export function configSourceKey(settingPath) {
|
|
146
|
+
return JSON.stringify(settingPath.map(String));
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Records a file as declaring every setting it holds.
|
|
150
|
+
* @param value The content of the file, or of one of its settings.
|
|
151
|
+
* @param file The file.
|
|
152
|
+
* @param sources The sources receiving the file.
|
|
153
|
+
* @param prefix The keys leading to the value.
|
|
154
|
+
*/
|
|
155
|
+
function recordSources(value, file, sources, prefix = []) {
|
|
156
|
+
if (typeof value !== 'object' || value === null) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
for (const [key, child] of Object.entries(value)) {
|
|
160
|
+
const settingPath = [...prefix, key];
|
|
161
|
+
(sources[configSourceKey(settingPath)] ??= []).push(file);
|
|
162
|
+
recordSources(child, file, sources, settingPath);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Parses the single YAML document of a file.
|
|
167
|
+
* @param content The content of the file.
|
|
168
|
+
* @param filename The file, named in error messages.
|
|
169
|
+
* @returns The value of the document, undefined when the file holds none.
|
|
170
|
+
* @throws {YAMLException} When the content is invalid or holds several documents.
|
|
171
|
+
*/
|
|
172
|
+
function parseYamlDocument(content, filename) {
|
|
173
|
+
const documents = loadAll(content, { filename });
|
|
174
|
+
if (documents.length > 1) {
|
|
175
|
+
throw new YAMLException(`expected a single document in "${filename}", but found more`);
|
|
176
|
+
}
|
|
177
|
+
return documents[0];
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Loads a YAML config file, expands environment variables, merges its includes recursively, and normalizes relative paths.
|
|
181
|
+
* @param filePath Path of the YAML config file to load.
|
|
182
|
+
* @param seen Set of already loaded absolute file paths used to prevent include cycles.
|
|
183
|
+
* @param baseDirectory Directory relative paths are resolved from; includes are resolved from the file directory.
|
|
184
|
+
* @param sources Receives the file declaring each setting, the file before its includes; `include` is not a setting.
|
|
185
|
+
* @returns The merged raw configuration object.
|
|
186
|
+
*/
|
|
187
|
+
async function loadConfigFileInternal(filePath, seen, baseDirectory, sources) {
|
|
188
|
+
const resolvedFilePath = path.resolve(filePath);
|
|
189
|
+
if (seen.has(resolvedFilePath)) {
|
|
190
|
+
return {};
|
|
191
|
+
}
|
|
192
|
+
seen.add(resolvedFilePath);
|
|
193
|
+
const fileContent = await fs.readFile(resolvedFilePath, { encoding: 'utf-8' });
|
|
194
|
+
const loaded = parseYamlDocument(fileContent, resolvedFilePath);
|
|
195
|
+
const { include, ...config } = expandEnvVarsDeep(typeof loaded === 'object' && loaded ? loaded : {});
|
|
196
|
+
const cwd = path.dirname(resolvedFilePath);
|
|
197
|
+
const includes = Array.isArray(include) ? include.filter((item) => typeof item === 'string') : [];
|
|
198
|
+
recordSources(config, resolvedFilePath, sources);
|
|
199
|
+
for (const includeItem of includes) {
|
|
200
|
+
const includeGlob = expandEnvVars(includeItem);
|
|
201
|
+
const files = (await glob(includeGlob, { cwd, absolute: true })).sort((a, b) => a.localeCompare(b));
|
|
202
|
+
for (const includePath of files) {
|
|
203
|
+
mergeConfig(config, await loadConfigFileInternal(includePath, seen, baseDirectory, sources));
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
resolveFolderPaths(config, baseDirectory);
|
|
207
|
+
return config;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Loads a YAML config file and its includes.
|
|
211
|
+
* @param filePath Path of the YAML config file to load.
|
|
212
|
+
* @param baseDirectory Directory relative paths are resolved from, the file directory by default.
|
|
213
|
+
* @param sources Receives the file declaring each setting.
|
|
214
|
+
* @returns The merged raw configuration object.
|
|
215
|
+
*/
|
|
216
|
+
export async function loadConfigFile(filePath, baseDirectory = path.dirname(path.resolve(filePath)), sources = {}) {
|
|
217
|
+
return loadConfigFileInternal(filePath, new Set(), baseDirectory, sources);
|
|
218
|
+
}
|
|
219
|
+
/** The environment variable naming the configuration folder. */
|
|
220
|
+
export const CONFIG_FOLDER_VARIABLE = 'ADT_CONFIG_FOLDER';
|
|
221
|
+
/**
|
|
222
|
+
* Gives the configuration folder: the one named by `ADT_CONFIG_FOLDER`, else `~/.config/appsys/devtool`.
|
|
223
|
+
* @returns The absolute path of the folder.
|
|
224
|
+
*/
|
|
225
|
+
export function resolveConfigFolder() {
|
|
226
|
+
const folder = process.env[CONFIG_FOLDER_VARIABLE]?.trim();
|
|
227
|
+
return path.resolve(resolveHomePath(folder || '~/.config/appsys/devtool'));
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Gives the `adt` settings of a configuration.
|
|
231
|
+
* @param config The merged configuration.
|
|
232
|
+
* @returns Its settings, empty when it has none.
|
|
233
|
+
*/
|
|
234
|
+
function adtOf(config) {
|
|
235
|
+
return typeof config.adt === 'object' && config.adt !== null ? config.adt : {};
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Gives the cache folder of a configuration: its `adt.cacheDir`, else `~/.cache/appsys/devtool`.
|
|
239
|
+
* @param config The merged configuration.
|
|
240
|
+
* @returns The absolute path of the folder.
|
|
241
|
+
*/
|
|
242
|
+
export function resolveCacheFolder(config) {
|
|
243
|
+
const adt = adtOf(config);
|
|
244
|
+
return typeof adt.cacheDir === 'string' && adt.cacheDir.trim() ? adt.cacheDir : path.join(os.homedir(), '.cache/appsys/devtool');
|
|
245
|
+
}
|
|
246
|
+
const DEFAULT_DISPLAY_NAME = 'AppSys Devtool';
|
|
247
|
+
const NAME_PATTERN = /^[a-z0-9][a-z0-9_-]*$/;
|
|
248
|
+
const ICON_EXTENSIONS = ['.svg', '.png', '.jpg', '.jpeg', '.icns'];
|
|
249
|
+
/**
|
|
250
|
+
* Turns a display name into an identifier: lowercase, without accents, words joined by hyphens.
|
|
251
|
+
* @param displayName The display name.
|
|
252
|
+
* @returns The identifier, empty when the name holds no letter nor digit.
|
|
253
|
+
*/
|
|
254
|
+
function slugOf(displayName) {
|
|
255
|
+
return displayName
|
|
256
|
+
.normalize('NFD')
|
|
257
|
+
.replace(/[̀-ͯ]/g, '')
|
|
258
|
+
.toLowerCase()
|
|
259
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
260
|
+
.replace(/^-+|-+$/g, '');
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Gives how a configuration names and shows the devtool: `adt.displayName`, `adt.name` (by default the
|
|
264
|
+
* identifier of the display name) and `adt.icon`, an invalid setting keeping its default.
|
|
265
|
+
* @param config The merged configuration.
|
|
266
|
+
* @returns The identity and the settings left at their default.
|
|
267
|
+
*/
|
|
268
|
+
export function resolveAppIdentity(config) {
|
|
269
|
+
const adt = adtOf(config);
|
|
270
|
+
const problems = [];
|
|
271
|
+
let displayName = DEFAULT_DISPLAY_NAME;
|
|
272
|
+
if (typeof adt.displayName === 'string' && adt.displayName.trim() && !adt.displayName.includes('/')) {
|
|
273
|
+
displayName = adt.displayName.trim();
|
|
274
|
+
}
|
|
275
|
+
else if (adt.displayName !== undefined) {
|
|
276
|
+
problems.push({ setting: 'adt.displayName', message: 'must be a text without /' });
|
|
277
|
+
}
|
|
278
|
+
let name = slugOf(displayName) || slugOf(DEFAULT_DISPLAY_NAME);
|
|
279
|
+
if (typeof adt.name === 'string' && NAME_PATTERN.test(adt.name)) {
|
|
280
|
+
name = adt.name;
|
|
281
|
+
}
|
|
282
|
+
else if (adt.name !== undefined) {
|
|
283
|
+
problems.push({ setting: 'adt.name', message: 'must hold lowercase letters, digits, - and _ only' });
|
|
284
|
+
}
|
|
285
|
+
let icon = null;
|
|
286
|
+
if (typeof adt.icon === 'string' && ICON_EXTENSIONS.includes(path.extname(adt.icon).toLowerCase())) {
|
|
287
|
+
icon = adt.icon;
|
|
288
|
+
}
|
|
289
|
+
else if (adt.icon !== undefined) {
|
|
290
|
+
problems.push({ setting: 'adt.icon', message: `must be a ${ICON_EXTENSIONS.join(', ')} file` });
|
|
291
|
+
}
|
|
292
|
+
return { identity: { name, displayName, icon }, problems };
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Lists the default configuration files: the shared configuration of the configuration folder, then the personal
|
|
296
|
+
* overrides.
|
|
297
|
+
* @param folder The configuration folder.
|
|
298
|
+
* @returns The configuration paths, in merge order.
|
|
299
|
+
*/
|
|
300
|
+
export function resolveDefaultConfigPaths(folder = resolveConfigFolder()) {
|
|
301
|
+
return [path.join(folder, 'config.yml'), path.join(folder, 'config.local.yml')];
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Loads and merges configuration files, each overriding the previous ones. Relative paths are resolved from the
|
|
305
|
+
* directory of the first file, the configuration folder, but those of the sections, `sectionPath` for the sections
|
|
306
|
+
* declaring none, resolved from the `workspace` of the merged configuration and left relative without one.
|
|
307
|
+
* @param configPaths Paths of the configuration files; missing files are skipped.
|
|
308
|
+
* @returns The merged configuration, the files loaded, the files declaring each setting, and the personal override
|
|
309
|
+
* among the paths (`*.local.yml`, loaded last), null when none is given.
|
|
310
|
+
*/
|
|
311
|
+
export async function loadMergedConfig(configPaths = resolveDefaultConfigPaths()) {
|
|
312
|
+
const loadedPaths = [];
|
|
313
|
+
const sources = {};
|
|
314
|
+
const result = {};
|
|
315
|
+
const baseDirectory = configPaths.length ? path.dirname(path.resolve(resolveHomePath(configPaths[0]))) : process.cwd();
|
|
316
|
+
const absolutePaths = configPaths.map(configPath => path.resolve(resolveHomePath(configPath)));
|
|
317
|
+
for (const absolutePath of absolutePaths) {
|
|
318
|
+
if (!(await pathExists(absolutePath))) {
|
|
319
|
+
continue;
|
|
320
|
+
}
|
|
321
|
+
mergeConfig(result, await loadConfigFile(absolutePath, baseDirectory, sources));
|
|
322
|
+
loadedPaths.push(absolutePath);
|
|
323
|
+
}
|
|
324
|
+
resolveSectionPaths(result, typeof result.workspace === 'string' ? result.workspace : null);
|
|
325
|
+
return {
|
|
326
|
+
config: result,
|
|
327
|
+
loadedPaths,
|
|
328
|
+
sources,
|
|
329
|
+
localPath: absolutePaths.filter(configPath => configPath.endsWith('.local.yml')).at(-1) ?? null
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAA;AACjC,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAChD,OAAO,SAAS,MAAM,kBAAkB,CAAA;AACxC,OAAO,SAAS,MAAM,kBAAkB,CAAA;AAIxC,MAAM,eAAe,GAAG,4DAA4D,CAAA;AAEpF,SAAS,eAAe,CAAE,KAAa;IACrC,IAAI,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,EAA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