@runeya/runeya 2.0.5 → 2.0.7
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-6LF3EWHR.js → dist-TZCPKLE5.js} +88 -6
- package/dist-TZCPKLE5.js.map +1 -0
- package/index.js +1 -1
- package/package.json +2 -2
- package/dist-6LF3EWHR.js.map +0 -1
|
@@ -778,6 +778,33 @@ var EnvironmentResolver = class {
|
|
|
778
778
|
}
|
|
779
779
|
return { ctx, secretKeys: parentSecretKeys, keySources: parentKeySources };
|
|
780
780
|
}
|
|
781
|
+
/**
|
|
782
|
+
* For service-scoped envs, compute effective parentIds by also including
|
|
783
|
+
* the service-scoped envs of ancestor global environments.
|
|
784
|
+
*
|
|
785
|
+
* Example: "Server (test)" has parentIds=[test-global]. test-global has
|
|
786
|
+
* parentIds=[Local-global]. This method adds "Server (Local)" to the
|
|
787
|
+
* effective parents so service-specific variables from ancestor envs
|
|
788
|
+
* are inherited correctly.
|
|
789
|
+
*/
|
|
790
|
+
async getEffectiveParentIds(environment) {
|
|
791
|
+
if (environment.scope !== "service" || !environment.reference || !environment.activateOn) {
|
|
792
|
+
return environment.parentIds;
|
|
793
|
+
}
|
|
794
|
+
const additionalIds = [];
|
|
795
|
+
for (const parentId of environment.parentIds) {
|
|
796
|
+
const parentEnv = await environmentStore.get(parentId);
|
|
797
|
+
if (!parentEnv || parentEnv.scope !== "global") continue;
|
|
798
|
+
for (const grandparentGlobalId of parentEnv.parentIds) {
|
|
799
|
+
const ancestorServiceEnv = await environmentStore.findServiceEnvironment(environment.reference, grandparentGlobalId);
|
|
800
|
+
if (ancestorServiceEnv && !environment.parentIds.includes(ancestorServiceEnv.id)) {
|
|
801
|
+
additionalIds.push(ancestorServiceEnv.id);
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
if (additionalIds.length === 0) return environment.parentIds;
|
|
806
|
+
return [...environment.parentIds, ...additionalIds];
|
|
807
|
+
}
|
|
781
808
|
async resolveDag(environmentId, visited) {
|
|
782
809
|
if (visited.has(environmentId)) {
|
|
783
810
|
throw new Error(`Circular dependency detected in environment inheritance for ${environmentId}`);
|
|
@@ -787,8 +814,9 @@ var EnvironmentResolver = class {
|
|
|
787
814
|
throw new Error(`Environment "${environmentId}" not found`);
|
|
788
815
|
}
|
|
789
816
|
visited.add(environmentId);
|
|
817
|
+
const effectiveParentIds = await this.getEffectiveParentIds(environment);
|
|
790
818
|
const parentResults = [];
|
|
791
|
-
for (const parentId of
|
|
819
|
+
for (const parentId of effectiveParentIds) {
|
|
792
820
|
const parentVisited = new Set(visited);
|
|
793
821
|
const parentResult = await this.resolveDag(parentId, parentVisited);
|
|
794
822
|
parentResults.push(parentResult);
|
|
@@ -2041,13 +2069,20 @@ var environmentRouter = router({
|
|
|
2041
2069
|
for (const serviceId of project.serviceIds) {
|
|
2042
2070
|
const service = await serviceStore.get(serviceId);
|
|
2043
2071
|
if (!service) continue;
|
|
2072
|
+
const parentServiceEnvIds = [];
|
|
2073
|
+
for (const parentGlobalId of env2.parentIds) {
|
|
2074
|
+
const parentServiceEnv = await environmentStore.findServiceEnvironment(serviceId, parentGlobalId);
|
|
2075
|
+
if (parentServiceEnv) {
|
|
2076
|
+
parentServiceEnvIds.push(parentServiceEnv.id);
|
|
2077
|
+
}
|
|
2078
|
+
}
|
|
2044
2079
|
const svcEnv = await environmentStore.create({
|
|
2045
2080
|
projectId: input.projectId,
|
|
2046
2081
|
name: `${service.name} (${env2.name})`,
|
|
2047
2082
|
scope: "service",
|
|
2048
2083
|
reference: serviceId,
|
|
2049
2084
|
activateOn: env2.id,
|
|
2050
|
-
parentIds: [env2.id],
|
|
2085
|
+
parentIds: [env2.id, ...parentServiceEnvIds],
|
|
2051
2086
|
variables: {}
|
|
2052
2087
|
});
|
|
2053
2088
|
await projectStore.addEnvironment(input.projectId, svcEnv.id);
|
|
@@ -10889,21 +10924,68 @@ var PullEnvError = class extends Error {
|
|
|
10889
10924
|
this.name = "PullEnvError";
|
|
10890
10925
|
}
|
|
10891
10926
|
};
|
|
10892
|
-
async function
|
|
10927
|
+
async function promptPassword() {
|
|
10928
|
+
process.stderr.write("Master password: ");
|
|
10929
|
+
return new Promise((resolve5) => {
|
|
10930
|
+
const stdin = process.stdin;
|
|
10931
|
+
const wasRaw = stdin.isRaw;
|
|
10932
|
+
if (stdin.isTTY) stdin.setRawMode(true);
|
|
10933
|
+
stdin.resume();
|
|
10934
|
+
stdin.setEncoding("utf-8");
|
|
10935
|
+
let input = "";
|
|
10936
|
+
const onData = (ch) => {
|
|
10937
|
+
if (ch === "\r" || ch === "\n") {
|
|
10938
|
+
if (stdin.isTTY) stdin.setRawMode(wasRaw ?? false);
|
|
10939
|
+
stdin.pause();
|
|
10940
|
+
stdin.removeListener("data", onData);
|
|
10941
|
+
process.stderr.write("\n");
|
|
10942
|
+
resolve5(input);
|
|
10943
|
+
} else if (ch === "") {
|
|
10944
|
+
process.exit(1);
|
|
10945
|
+
} else if (ch === "\x7F" || ch === "\b") {
|
|
10946
|
+
input = input.slice(0, -1);
|
|
10947
|
+
} else {
|
|
10948
|
+
input += ch;
|
|
10949
|
+
}
|
|
10950
|
+
};
|
|
10951
|
+
stdin.on("data", onData);
|
|
10952
|
+
});
|
|
10953
|
+
}
|
|
10954
|
+
async function unlockIfNeeded() {
|
|
10893
10955
|
await ensureEncryptionKey();
|
|
10956
|
+
if (hasEncryptionKey()) return;
|
|
10957
|
+
if (await loadFromEnv()) return;
|
|
10958
|
+
if (!await hasEncryptedKeyFile(env.DATA_DIR)) {
|
|
10959
|
+
return;
|
|
10960
|
+
}
|
|
10961
|
+
const masterPassword = process.env["RUNEYA_MASTER_PASSWORD"] || await promptPassword();
|
|
10962
|
+
if (!masterPassword) {
|
|
10963
|
+
throw new PullEnvError("Master password required to decrypt data", 1);
|
|
10964
|
+
}
|
|
10965
|
+
try {
|
|
10966
|
+
const encKey = await readEncryptedKey(env.DATA_DIR, masterPassword);
|
|
10967
|
+
setEncryptionKeyInMemory(encKey);
|
|
10968
|
+
} catch {
|
|
10969
|
+
throw new PullEnvError("Master password incorrect", 1);
|
|
10970
|
+
}
|
|
10971
|
+
}
|
|
10972
|
+
async function pullEnv(opts) {
|
|
10973
|
+
await unlockIfNeeded();
|
|
10894
10974
|
const services = await serviceStore.list();
|
|
10895
10975
|
const service = services.find(
|
|
10896
10976
|
(s) => s.id === opts.service || s.name === opts.service
|
|
10897
10977
|
);
|
|
10898
10978
|
if (!service) {
|
|
10899
|
-
|
|
10979
|
+
const available = services.map((s) => s.name).join(", ");
|
|
10980
|
+
throw new PullEnvError(`service "${opts.service}" not found. Available: ${available || "(none)"}`, 1);
|
|
10900
10981
|
}
|
|
10901
10982
|
const globalEnvs = await environmentStore.listAllGlobal();
|
|
10902
10983
|
const globalEnv = globalEnvs.find(
|
|
10903
10984
|
(e) => e.id === opts.environment || e.name === opts.environment
|
|
10904
10985
|
);
|
|
10905
10986
|
if (!globalEnv) {
|
|
10906
|
-
|
|
10987
|
+
const available = globalEnvs.map((e) => e.name).join(", ");
|
|
10988
|
+
throw new PullEnvError(`environment "${opts.environment}" not found. Available: ${available || "(none)"}`, 1);
|
|
10907
10989
|
}
|
|
10908
10990
|
const { env: env2 } = await environmentResolver.resolveForService({
|
|
10909
10991
|
serviceId: service.id,
|
|
@@ -10981,4 +11063,4 @@ export {
|
|
|
10981
11063
|
createLocalServer,
|
|
10982
11064
|
pullEnv
|
|
10983
11065
|
};
|
|
10984
|
-
//# sourceMappingURL=dist-
|
|
11066
|
+
//# sourceMappingURL=dist-TZCPKLE5.js.map
|