@comet/cli 8.20.3 → 8.21.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/lib/commands/site-configs.js +26 -4
- package/package.json +2 -2
|
@@ -116,7 +116,7 @@ exports.injectSiteConfigsCommand = new commander_1.Command("inject-site-configs"
|
|
|
116
116
|
.option("--base64", "use base64 encoding")
|
|
117
117
|
.option("-f, --site-config-file <file>", "Path to ts-file which provides a default export with (env: string) => SiteConfig[]")
|
|
118
118
|
.action(function (options) { return __awaiter(void 0, void 0, void 0, function () {
|
|
119
|
-
var configFile, getSiteConfigs, str, getUrlFromDomain, replacerFunctions;
|
|
119
|
+
var configFile, getSiteConfigs, siteConfigsCache, getCachedSiteConfigs, str, getUrlFromDomain, replacerFunctions;
|
|
120
120
|
return __generator(this, function (_a) {
|
|
121
121
|
switch (_a.label) {
|
|
122
122
|
case 0:
|
|
@@ -124,6 +124,23 @@ exports.injectSiteConfigsCommand = new commander_1.Command("inject-site-configs"
|
|
|
124
124
|
return [4 /*yield*/, Promise.resolve("".concat(configFile)).then(function (s) { return __importStar(require(s)); })];
|
|
125
125
|
case 1:
|
|
126
126
|
getSiteConfigs = (_a.sent()).default;
|
|
127
|
+
siteConfigsCache = new Map();
|
|
128
|
+
getCachedSiteConfigs = function (env) { return __awaiter(void 0, void 0, void 0, function () {
|
|
129
|
+
var cached;
|
|
130
|
+
return __generator(this, function (_a) {
|
|
131
|
+
switch (_a.label) {
|
|
132
|
+
case 0:
|
|
133
|
+
cached = siteConfigsCache.get(env);
|
|
134
|
+
if (!!cached) return [3 /*break*/, 2];
|
|
135
|
+
return [4 /*yield*/, getSiteConfigs(env)];
|
|
136
|
+
case 1:
|
|
137
|
+
cached = _a.sent();
|
|
138
|
+
siteConfigsCache.set(env, cached);
|
|
139
|
+
_a.label = 2;
|
|
140
|
+
case 2: return [2 /*return*/, cached];
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}); };
|
|
127
144
|
console.log("inject-site-configs: Replace site-configs in ".concat(options.inFile));
|
|
128
145
|
str = fs_1.default.readFileSync((0, path_1.resolve)(process.cwd(), options.inFile)).toString();
|
|
129
146
|
getUrlFromDomain = function (domain) {
|
|
@@ -151,7 +168,7 @@ exports.injectSiteConfigsCommand = new commander_1.Command("inject-site-configs"
|
|
|
151
168
|
var siteConfigs, ret;
|
|
152
169
|
return __generator(this, function (_a) {
|
|
153
170
|
switch (_a.label) {
|
|
154
|
-
case 0: return [4 /*yield*/,
|
|
171
|
+
case 0: return [4 /*yield*/, getCachedSiteConfigs(env)];
|
|
155
172
|
case 1:
|
|
156
173
|
siteConfigs = _a.sent();
|
|
157
174
|
console.log("inject-site-configs: - ".concat(substr, " (").concat(siteConfigs.length, " sites)"));
|
|
@@ -175,7 +192,7 @@ exports.injectSiteConfigsCommand = new commander_1.Command("inject-site-configs"
|
|
|
175
192
|
var siteConfigs, filteredSiteConfigs;
|
|
176
193
|
return __generator(this, function (_a) {
|
|
177
194
|
switch (_a.label) {
|
|
178
|
-
case 0: return [4 /*yield*/,
|
|
195
|
+
case 0: return [4 /*yield*/, getCachedSiteConfigs(env)];
|
|
179
196
|
case 1:
|
|
180
197
|
siteConfigs = _a.sent();
|
|
181
198
|
console.log("inject-site-domains: - ".concat(substr, " (").concat(siteConfigs.length, " sites)"));
|
|
@@ -208,12 +225,17 @@ var resolveOpReferences = function (input) {
|
|
|
208
225
|
throw new Error("inject-site-configs: Config contains 1Password references (op://) but the 1Password CLI (op) is not installed. " +
|
|
209
226
|
"Install from https://developer.1password.com/docs/cli/");
|
|
210
227
|
}
|
|
228
|
+
var opCache = new Map();
|
|
211
229
|
var result = input;
|
|
212
230
|
for (var _i = 0, opRefs_1 = opRefs; _i < opRefs_1.length; _i++) {
|
|
213
231
|
var ref = opRefs_1[_i];
|
|
214
232
|
var opUri = ref.replace("{{ ", "").replace(" }}", "");
|
|
215
233
|
try {
|
|
216
|
-
var secret =
|
|
234
|
+
var secret = opCache.get(opUri);
|
|
235
|
+
if (!secret) {
|
|
236
|
+
secret = (0, child_process_1.execSync)("op read \"".concat(opUri, "\""), { encoding: "utf-8" }).trim();
|
|
237
|
+
opCache.set(opUri, secret);
|
|
238
|
+
}
|
|
217
239
|
console.log("inject-site-configs: - Resolved ".concat(ref));
|
|
218
240
|
result = result.replace(ref, secret);
|
|
219
241
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@comet/cli",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.21.0",
|
|
4
4
|
"description": "A collection of CLI tools for Comet projects",
|
|
5
5
|
"repository": {
|
|
6
6
|
"directory": "packages/cli",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"rimraf": "^6.1.2",
|
|
33
33
|
"typescript": "^5.9.3",
|
|
34
34
|
"vitest": "^4.0.16",
|
|
35
|
-
"@comet/eslint-config": "8.
|
|
35
|
+
"@comet/eslint-config": "8.21.0"
|
|
36
36
|
},
|
|
37
37
|
"engines": {
|
|
38
38
|
"node": ">=22.0.0"
|