@lorion-org/runtime-config-node 1.0.0-beta.0 → 1.0.0-beta.5
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 +21 -21
- package/README.md +27 -27
- package/dist/index.cjs +106 -14
- package/dist/index.d.cts +13 -2
- package/dist/index.d.ts +13 -2
- package/dist/index.js +107 -15
- package/package.json +9 -4
- package/src/index.ts +1063 -0
- package/examples/env-assignments.ts +0 -21
- package/examples/load-runtime-config-tree.ts +0 -17
- package/examples/query-runtime-config-tree.ts +0 -53
- package/examples/source-and-scope-files.ts +0 -24
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
loadRuntimeConfigShellAssignments,
|
|
3
|
-
writeRuntimeConfigFragment,
|
|
4
|
-
} from '@lorion-org/runtime-config-node';
|
|
5
|
-
|
|
6
|
-
writeRuntimeConfigFragment('./var', 'billing', {
|
|
7
|
-
public: {
|
|
8
|
-
apiBase: '/api/billing',
|
|
9
|
-
},
|
|
10
|
-
private: {
|
|
11
|
-
token: 'billing-token',
|
|
12
|
-
},
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
const assignments = loadRuntimeConfigShellAssignments('./var', {
|
|
16
|
-
prefix: 'APP',
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
console.log(assignments);
|
|
20
|
-
// APP_PUBLIC_BILLING_API_BASE='"/api/billing"'
|
|
21
|
-
// APP_PRIVATE_BILLING_TOKEN='"billing-token"'
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { projectSectionedRuntimeConfig } from '@lorion-org/runtime-config';
|
|
2
|
-
import { loadRuntimeConfigTree, writeRuntimeConfigFragment } from '@lorion-org/runtime-config-node';
|
|
3
|
-
|
|
4
|
-
writeRuntimeConfigFragment('./var', 'billing', {
|
|
5
|
-
public: {
|
|
6
|
-
apiBase: '/api/billing',
|
|
7
|
-
},
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
const fragments = loadRuntimeConfigTree('./var');
|
|
11
|
-
const runtimeConfig = projectSectionedRuntimeConfig(fragments);
|
|
12
|
-
|
|
13
|
-
console.log(runtimeConfig.public);
|
|
14
|
-
// { billingApiBase: '/api/billing' }
|
|
15
|
-
|
|
16
|
-
console.log(runtimeConfig.private);
|
|
17
|
-
// {}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getRuntimeConfigScopeView,
|
|
3
|
-
getRuntimeConfigValue,
|
|
4
|
-
listRuntimeConfigFragments,
|
|
5
|
-
projectRuntimeConfigTree,
|
|
6
|
-
writeRuntimeConfigFragment,
|
|
7
|
-
} from '@lorion-org/runtime-config-node';
|
|
8
|
-
|
|
9
|
-
writeRuntimeConfigFragment('./var', 'billing', {
|
|
10
|
-
public: {
|
|
11
|
-
apiBase: '/api/billing',
|
|
12
|
-
},
|
|
13
|
-
private: {
|
|
14
|
-
token: 'billing-token',
|
|
15
|
-
},
|
|
16
|
-
contexts: {
|
|
17
|
-
tenantA: {
|
|
18
|
-
public: {
|
|
19
|
-
apiBase: '/tenant-a/billing',
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
const listResult = listRuntimeConfigFragments('./var');
|
|
26
|
-
console.log(listResult.scopes);
|
|
27
|
-
// [{ scopeId: 'billing', publicKeys: ['apiBase'], privateKeys: ['token'], contextIds: ['tenantA'], ... }]
|
|
28
|
-
|
|
29
|
-
const projectResult = projectRuntimeConfigTree('./var', {
|
|
30
|
-
contextOutputKey: '__tenants',
|
|
31
|
-
});
|
|
32
|
-
console.log(projectResult.runtimeConfig.public);
|
|
33
|
-
// {
|
|
34
|
-
// billingApiBase: '/api/billing',
|
|
35
|
-
// __tenants: {
|
|
36
|
-
// tenantA: {
|
|
37
|
-
// billingApiBase: '/tenant-a/billing',
|
|
38
|
-
// },
|
|
39
|
-
// },
|
|
40
|
-
// }
|
|
41
|
-
|
|
42
|
-
const valueResult = getRuntimeConfigValue('./var', 'billing', 'apiBase', {
|
|
43
|
-
contextId: 'tenantA',
|
|
44
|
-
contextOutputKey: '__tenants',
|
|
45
|
-
});
|
|
46
|
-
console.log(valueResult.value);
|
|
47
|
-
// /tenant-a/billing
|
|
48
|
-
|
|
49
|
-
const scopeResult = getRuntimeConfigScopeView('./var', 'billing', {
|
|
50
|
-
visibility: 'private',
|
|
51
|
-
});
|
|
52
|
-
console.log(scopeResult.config);
|
|
53
|
-
// { token: 'billing-token' }
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
readRuntimeConfigScopeJson,
|
|
3
|
-
resolveRuntimeConfigPublicFilePath,
|
|
4
|
-
resolveRuntimeConfigSource,
|
|
5
|
-
writeRuntimeConfigScopeJson,
|
|
6
|
-
} from '@lorion-org/runtime-config-node';
|
|
7
|
-
|
|
8
|
-
const source = resolveRuntimeConfigSource({
|
|
9
|
-
defaultVarDir: './var',
|
|
10
|
-
env: process.env,
|
|
11
|
-
envKey: 'APP_VAR_DIR',
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
writeRuntimeConfigScopeJson(source, 'billing', 'settings.json', {
|
|
15
|
-
apiBase: '/api/billing',
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
const settings = readRuntimeConfigScopeJson(source, 'billing', 'settings.json');
|
|
19
|
-
console.log(settings);
|
|
20
|
-
// { apiBase: '/api/billing' }
|
|
21
|
-
|
|
22
|
-
const logoPath = resolveRuntimeConfigPublicFilePath(source, 'billing/logo.svg');
|
|
23
|
-
console.log(logoPath);
|
|
24
|
-
// /absolute/project/path/var/runtime-config/public/billing/logo.svg
|