@storm-software/config-tools 1.190.59 → 1.190.61

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.
@@ -1,40 +0,0 @@
1
- import {
2
- loadStormWorkspaceConfig,
3
- tryLoadStormWorkspaceConfig
4
- } from "./chunk-MPA47MI6.js";
5
- import {
6
- findWorkspaceRoot
7
- } from "./chunk-S4V6UG5D.js";
8
-
9
- // src/get-config.ts
10
- function getConfig(workspaceRoot, skipLogs = false) {
11
- return loadStormWorkspaceConfig(workspaceRoot, skipLogs);
12
- }
13
- function getWorkspaceConfig(skipLogs = true, options = {}) {
14
- let workspaceRoot = options.workspaceRoot;
15
- if (!workspaceRoot) {
16
- workspaceRoot = findWorkspaceRoot(options.cwd);
17
- }
18
- return getConfig(workspaceRoot, skipLogs);
19
- }
20
- async function tryGetWorkspaceConfig(skipLogs = true, options = {}) {
21
- try {
22
- let workspaceRoot = options.workspaceRoot;
23
- if (!workspaceRoot) {
24
- workspaceRoot = findWorkspaceRoot(options.cwd);
25
- }
26
- return tryLoadStormWorkspaceConfig(
27
- workspaceRoot,
28
- skipLogs,
29
- options.useDefault
30
- );
31
- } catch {
32
- return void 0;
33
- }
34
- }
35
-
36
- export {
37
- getConfig,
38
- getWorkspaceConfig,
39
- tryGetWorkspaceConfig
40
- };
@@ -1,165 +0,0 @@
1
- import {
2
- getConfigEnv,
3
- getExtensionEnv
4
- } from "./chunk-TAUBUQTU.js";
5
- import {
6
- setConfigEnv
7
- } from "./chunk-RUM7ZT5L.js";
8
- import {
9
- getConfigFile
10
- } from "./chunk-34ZTLNLC.js";
11
- import {
12
- applyDefaultConfig,
13
- getPackageJsonConfig
14
- } from "./chunk-G6BYLVKW.js";
15
- import {
16
- formatLogMessage,
17
- writeTrace,
18
- writeWarning
19
- } from "./chunk-CHETDXSD.js";
20
- import {
21
- findWorkspaceRoot
22
- } from "./chunk-S4V6UG5D.js";
23
- import {
24
- joinPaths
25
- } from "./chunk-V3GMJ4TX.js";
26
-
27
- // src/create-storm-config.ts
28
- import { workspaceConfigSchema } from "@storm-software/config/schema";
29
- import defu from "defu";
30
- import { existsSync } from "node:fs";
31
- var _extension_cache = /* @__PURE__ */ new WeakMap();
32
- var _static_cache = void 0;
33
- var createStormWorkspaceConfig = async (extensionName, schema, workspaceRoot, skipLogs = false, useDefault = true) => {
34
- let result;
35
- if (!_static_cache?.data || !_static_cache?.timestamp || _static_cache.timestamp < Date.now() - 8e3) {
36
- let _workspaceRoot = workspaceRoot;
37
- if (!_workspaceRoot) {
38
- _workspaceRoot = findWorkspaceRoot();
39
- }
40
- const configEnv = getConfigEnv();
41
- const configFile = await getConfigFile(_workspaceRoot);
42
- if (!configFile) {
43
- if (!skipLogs) {
44
- writeWarning(
45
- "No Storm Workspace configuration file found in the current repository. Please ensure this is the expected behavior - you can add a `storm-workspace.json` file to the root of your workspace if it is not.\n",
46
- { logLevel: "all" }
47
- );
48
- }
49
- if (useDefault === false) {
50
- return void 0;
51
- }
52
- }
53
- const defaultConfig = await getPackageJsonConfig(_workspaceRoot);
54
- const configInput = defu(
55
- configEnv,
56
- configFile,
57
- defaultConfig
58
- );
59
- if (!configInput.variant) {
60
- configInput.variant = existsSync(joinPaths(_workspaceRoot, "nx.json")) || existsSync(joinPaths(_workspaceRoot, ".nx")) || existsSync(joinPaths(_workspaceRoot, "lerna.json")) || existsSync(joinPaths(_workspaceRoot, "turbo.json")) ? "monorepo" : "minimal";
61
- }
62
- try {
63
- const parseResult = await Promise.resolve(
64
- workspaceConfigSchema._zod.parse(
65
- { value: configInput, issues: [] },
66
- { async: true }
67
- )
68
- );
69
- result = applyDefaultConfig(parseResult.value);
70
- result.workspaceRoot ??= _workspaceRoot;
71
- } catch (error) {
72
- throw new Error(
73
- `Failed to parse Storm Workspace configuration${error?.message ? `: ${error.message}` : ""}
74
-
75
- Please ensure your configuration file is valid JSON and matches the expected schema. The current workspace configuration input is: ${formatLogMessage(
76
- configInput
77
- )}`,
78
- {
79
- cause: error
80
- }
81
- );
82
- }
83
- } else {
84
- result = _static_cache.data;
85
- }
86
- if (schema && extensionName) {
87
- result.extensions = {
88
- ...result.extensions,
89
- [extensionName]: createConfigExtension(extensionName, schema)
90
- };
91
- }
92
- _static_cache = {
93
- timestamp: Date.now(),
94
- data: result
95
- };
96
- return result;
97
- };
98
- var createConfigExtension = (extensionName, schema) => {
99
- const extension_cache_key = { extensionName };
100
- if (_extension_cache.has(extension_cache_key)) {
101
- return _extension_cache.get(extension_cache_key);
102
- }
103
- let extension = getExtensionEnv(extensionName);
104
- if (schema) {
105
- extension = schema.parse(extension);
106
- }
107
- _extension_cache.set(extension_cache_key, extension);
108
- return extension;
109
- };
110
- var loadStormWorkspaceConfig = async (workspaceRoot, skipLogs = false) => {
111
- const config = await createStormWorkspaceConfig(
112
- void 0,
113
- void 0,
114
- workspaceRoot,
115
- skipLogs,
116
- true
117
- );
118
- setConfigEnv(config);
119
- if (!skipLogs && !config.skipConfigLogging) {
120
- writeTrace(
121
- `\u2699\uFE0F Using Storm Workspace configuration:
122
- ${formatLogMessage(config)}`,
123
- config
124
- );
125
- }
126
- return config;
127
- };
128
- var tryLoadStormWorkspaceConfig = async (workspaceRoot, skipLogs = true, useDefault = false) => {
129
- try {
130
- const config = await createStormWorkspaceConfig(
131
- void 0,
132
- void 0,
133
- workspaceRoot,
134
- skipLogs,
135
- useDefault
136
- );
137
- if (!config) {
138
- return void 0;
139
- }
140
- setConfigEnv(config);
141
- if (!skipLogs && !config.skipConfigLogging) {
142
- writeTrace(
143
- `\u2699\uFE0F Using Storm Workspace configuration:
144
- ${formatLogMessage(config)}`,
145
- config
146
- );
147
- }
148
- return config;
149
- } catch (error) {
150
- if (!skipLogs) {
151
- writeWarning(
152
- `\u26A0\uFE0F Failed to load Storm Workspace configuration: ${error}`,
153
- { logLevel: "all" }
154
- );
155
- }
156
- return void 0;
157
- }
158
- };
159
-
160
- export {
161
- createStormWorkspaceConfig,
162
- createConfigExtension,
163
- loadStormWorkspaceConfig,
164
- tryLoadStormWorkspaceConfig
165
- };
@@ -1,102 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
-
3
- var _chunkA5XFS6G4cjs = require('./chunk-A5XFS6G4.cjs');
4
-
5
-
6
- var _chunkBDATZ3UBcjs = require('./chunk-BDATZ3UB.cjs');
7
-
8
- // src/utilities/get-default-config.ts
9
-
10
-
11
-
12
- var _config = require('@storm-software/config');
13
- var _fs = require('fs');
14
- var _promises = require('fs/promises');
15
- var _path = require('path');
16
- async function getPackageJsonConfig(root) {
17
- let license = _config.STORM_DEFAULT_LICENSE;
18
- let homepage = void 0;
19
- let support = void 0;
20
- let name = void 0;
21
- let namespace = void 0;
22
- let repository = void 0;
23
- const workspaceRoot = _chunkA5XFS6G4cjs.findWorkspaceRoot.call(void 0, root);
24
- if (_fs.existsSync.call(void 0, _path.join.call(void 0, workspaceRoot, "package.json"))) {
25
- const file = await _promises.readFile.call(void 0,
26
- _chunkBDATZ3UBcjs.joinPaths.call(void 0, workspaceRoot, "package.json"),
27
- "utf8"
28
- );
29
- if (file) {
30
- const packageJson = JSON.parse(file);
31
- if (packageJson.name) {
32
- name = packageJson.name;
33
- }
34
- if (packageJson.namespace) {
35
- namespace = packageJson.namespace;
36
- }
37
- if (packageJson.repository) {
38
- if (typeof packageJson.repository === "string") {
39
- repository = packageJson.repository;
40
- } else if (packageJson.repository.url) {
41
- repository = packageJson.repository.url;
42
- }
43
- }
44
- if (packageJson.license) {
45
- license = packageJson.license;
46
- }
47
- if (packageJson.homepage) {
48
- homepage = packageJson.homepage;
49
- }
50
- if (packageJson.bugs) {
51
- if (typeof packageJson.bugs === "string") {
52
- support = packageJson.bugs;
53
- } else if (packageJson.bugs.url) {
54
- support = packageJson.bugs.url;
55
- }
56
- }
57
- }
58
- }
59
- return {
60
- workspaceRoot,
61
- name,
62
- namespace,
63
- repository,
64
- license,
65
- homepage,
66
- support
67
- };
68
- }
69
- function applyDefaultConfig(config) {
70
- if (!config.support && config.contact) {
71
- config.support = config.contact;
72
- }
73
- if (!config.contact && config.support) {
74
- config.contact = config.support;
75
- }
76
- if (config.homepage) {
77
- if (!config.docs) {
78
- config.docs = `${config.homepage}/docs`;
79
- }
80
- if (!config.license) {
81
- config.license = `${config.homepage}/license`;
82
- }
83
- if (!config.support) {
84
- config.support = `${config.homepage}/support`;
85
- }
86
- if (!config.contact) {
87
- config.contact = `${config.homepage}/contact`;
88
- }
89
- if (!_optionalChain([config, 'access', _ => _.error, 'optionalAccess', _2 => _2.codesFile]) || !_optionalChain([config, 'optionalAccess', _3 => _3.error, 'optionalAccess', _4 => _4.url])) {
90
- config.error ??= { codesFile: _config.STORM_DEFAULT_ERROR_CODES_FILE };
91
- if (config.homepage) {
92
- config.error.url ??= `${config.homepage}/errors`;
93
- }
94
- }
95
- }
96
- return config;
97
- }
98
-
99
-
100
-
101
-
102
- exports.getPackageJsonConfig = getPackageJsonConfig; exports.applyDefaultConfig = applyDefaultConfig;
@@ -1,165 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
-
3
-
4
- var _chunk3RYQHUSVcjs = require('./chunk-3RYQHUSV.cjs');
5
-
6
-
7
- var _chunk3GSCLSH5cjs = require('./chunk-3GSCLSH5.cjs');
8
-
9
-
10
- var _chunkGHMHUDMOcjs = require('./chunk-GHMHUDMO.cjs');
11
-
12
-
13
-
14
- var _chunkP3HKEFX7cjs = require('./chunk-P3HKEFX7.cjs');
15
-
16
-
17
-
18
-
19
- var _chunkMKPGN5UTcjs = require('./chunk-MKPGN5UT.cjs');
20
-
21
-
22
- var _chunkA5XFS6G4cjs = require('./chunk-A5XFS6G4.cjs');
23
-
24
-
25
- var _chunkBDATZ3UBcjs = require('./chunk-BDATZ3UB.cjs');
26
-
27
- // src/create-storm-config.ts
28
- var _schema = require('@storm-software/config/schema');
29
- var _defu = require('defu'); var _defu2 = _interopRequireDefault(_defu);
30
- var _fs = require('fs');
31
- var _extension_cache = /* @__PURE__ */ new WeakMap();
32
- var _static_cache = void 0;
33
- var createStormWorkspaceConfig = async (extensionName, schema, workspaceRoot, skipLogs = false, useDefault = true) => {
34
- let result;
35
- if (!_optionalChain([_static_cache, 'optionalAccess', _ => _.data]) || !_optionalChain([_static_cache, 'optionalAccess', _2 => _2.timestamp]) || _static_cache.timestamp < Date.now() - 8e3) {
36
- let _workspaceRoot = workspaceRoot;
37
- if (!_workspaceRoot) {
38
- _workspaceRoot = _chunkA5XFS6G4cjs.findWorkspaceRoot.call(void 0, );
39
- }
40
- const configEnv = _chunk3RYQHUSVcjs.getConfigEnv.call(void 0, );
41
- const configFile = await _chunkGHMHUDMOcjs.getConfigFile.call(void 0, _workspaceRoot);
42
- if (!configFile) {
43
- if (!skipLogs) {
44
- _chunkMKPGN5UTcjs.writeWarning.call(void 0,
45
- "No Storm Workspace configuration file found in the current repository. Please ensure this is the expected behavior - you can add a `storm-workspace.json` file to the root of your workspace if it is not.\n",
46
- { logLevel: "all" }
47
- );
48
- }
49
- if (useDefault === false) {
50
- return void 0;
51
- }
52
- }
53
- const defaultConfig = await _chunkP3HKEFX7cjs.getPackageJsonConfig.call(void 0, _workspaceRoot);
54
- const configInput = _defu2.default.call(void 0,
55
- configEnv,
56
- configFile,
57
- defaultConfig
58
- );
59
- if (!configInput.variant) {
60
- configInput.variant = _fs.existsSync.call(void 0, _chunkBDATZ3UBcjs.joinPaths.call(void 0, _workspaceRoot, "nx.json")) || _fs.existsSync.call(void 0, _chunkBDATZ3UBcjs.joinPaths.call(void 0, _workspaceRoot, ".nx")) || _fs.existsSync.call(void 0, _chunkBDATZ3UBcjs.joinPaths.call(void 0, _workspaceRoot, "lerna.json")) || _fs.existsSync.call(void 0, _chunkBDATZ3UBcjs.joinPaths.call(void 0, _workspaceRoot, "turbo.json")) ? "monorepo" : "minimal";
61
- }
62
- try {
63
- const parseResult = await Promise.resolve(
64
- _schema.workspaceConfigSchema._zod.parse(
65
- { value: configInput, issues: [] },
66
- { async: true }
67
- )
68
- );
69
- result = _chunkP3HKEFX7cjs.applyDefaultConfig.call(void 0, parseResult.value);
70
- result.workspaceRoot ??= _workspaceRoot;
71
- } catch (error) {
72
- throw new Error(
73
- `Failed to parse Storm Workspace configuration${_optionalChain([error, 'optionalAccess', _3 => _3.message]) ? `: ${error.message}` : ""}
74
-
75
- Please ensure your configuration file is valid JSON and matches the expected schema. The current workspace configuration input is: ${_chunkMKPGN5UTcjs.formatLogMessage.call(void 0,
76
- configInput
77
- )}`,
78
- {
79
- cause: error
80
- }
81
- );
82
- }
83
- } else {
84
- result = _static_cache.data;
85
- }
86
- if (schema && extensionName) {
87
- result.extensions = {
88
- ...result.extensions,
89
- [extensionName]: createConfigExtension(extensionName, schema)
90
- };
91
- }
92
- _static_cache = {
93
- timestamp: Date.now(),
94
- data: result
95
- };
96
- return result;
97
- };
98
- var createConfigExtension = (extensionName, schema) => {
99
- const extension_cache_key = { extensionName };
100
- if (_extension_cache.has(extension_cache_key)) {
101
- return _extension_cache.get(extension_cache_key);
102
- }
103
- let extension = _chunk3RYQHUSVcjs.getExtensionEnv.call(void 0, extensionName);
104
- if (schema) {
105
- extension = schema.parse(extension);
106
- }
107
- _extension_cache.set(extension_cache_key, extension);
108
- return extension;
109
- };
110
- var loadStormWorkspaceConfig = async (workspaceRoot, skipLogs = false) => {
111
- const config = await createStormWorkspaceConfig(
112
- void 0,
113
- void 0,
114
- workspaceRoot,
115
- skipLogs,
116
- true
117
- );
118
- _chunk3GSCLSH5cjs.setConfigEnv.call(void 0, config);
119
- if (!skipLogs && !config.skipConfigLogging) {
120
- _chunkMKPGN5UTcjs.writeTrace.call(void 0,
121
- `\u2699\uFE0F Using Storm Workspace configuration:
122
- ${_chunkMKPGN5UTcjs.formatLogMessage.call(void 0, config)}`,
123
- config
124
- );
125
- }
126
- return config;
127
- };
128
- var tryLoadStormWorkspaceConfig = async (workspaceRoot, skipLogs = true, useDefault = false) => {
129
- try {
130
- const config = await createStormWorkspaceConfig(
131
- void 0,
132
- void 0,
133
- workspaceRoot,
134
- skipLogs,
135
- useDefault
136
- );
137
- if (!config) {
138
- return void 0;
139
- }
140
- _chunk3GSCLSH5cjs.setConfigEnv.call(void 0, config);
141
- if (!skipLogs && !config.skipConfigLogging) {
142
- _chunkMKPGN5UTcjs.writeTrace.call(void 0,
143
- `\u2699\uFE0F Using Storm Workspace configuration:
144
- ${_chunkMKPGN5UTcjs.formatLogMessage.call(void 0, config)}`,
145
- config
146
- );
147
- }
148
- return config;
149
- } catch (error) {
150
- if (!skipLogs) {
151
- _chunkMKPGN5UTcjs.writeWarning.call(void 0,
152
- `\u26A0\uFE0F Failed to load Storm Workspace configuration: ${error}`,
153
- { logLevel: "all" }
154
- );
155
- }
156
- return void 0;
157
- }
158
- };
159
-
160
-
161
-
162
-
163
-
164
-
165
- exports.createStormWorkspaceConfig = createStormWorkspaceConfig; exports.createConfigExtension = createConfigExtension; exports.loadStormWorkspaceConfig = loadStormWorkspaceConfig; exports.tryLoadStormWorkspaceConfig = tryLoadStormWorkspaceConfig;
@@ -1,81 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
-
3
- var _chunkA5XFS6G4cjs = require('./chunk-A5XFS6G4.cjs');
4
-
5
- // src/utilities/apply-workspace-tokens.ts
6
- var applyWorkspaceBaseTokens = async (option, tokenParams) => {
7
- let result = option;
8
- if (!result) {
9
- return result;
10
- }
11
- if (tokenParams) {
12
- const optionKeys = Object.keys(tokenParams);
13
- if (optionKeys.some((optionKey) => result.includes(`{${optionKey}}`))) {
14
- for (const optionKey of optionKeys) {
15
- if (result.includes(`{${optionKey}}`)) {
16
- result = result.replaceAll(
17
- `{${optionKey}}`,
18
- _optionalChain([tokenParams, 'optionalAccess', _ => _[optionKey]]) || ""
19
- );
20
- }
21
- }
22
- }
23
- }
24
- if (tokenParams.config) {
25
- const configKeys = Object.keys(tokenParams.config);
26
- if (configKeys.some((configKey) => result.includes(`{${configKey}}`))) {
27
- for (const configKey of configKeys) {
28
- if (result.includes(`{${configKey}}`)) {
29
- result = result.replaceAll(
30
- `{${configKey}}`,
31
- tokenParams.config[configKey] || ""
32
- );
33
- }
34
- }
35
- }
36
- }
37
- if (result.includes("{workspaceRoot}")) {
38
- result = result.replaceAll(
39
- "{workspaceRoot}",
40
- _nullishCoalesce(_nullishCoalesce(tokenParams.workspaceRoot, () => ( _optionalChain([tokenParams, 'access', _2 => _2.config, 'optionalAccess', _3 => _3.workspaceRoot]))), () => ( _chunkA5XFS6G4cjs.findWorkspaceRoot.call(void 0, )))
41
- );
42
- }
43
- return result;
44
- };
45
- var applyWorkspaceProjectTokens = (option, tokenParams) => {
46
- return applyWorkspaceBaseTokens(option, tokenParams);
47
- };
48
- var applyWorkspaceTokens = async (options, tokenParams, tokenizerFn) => {
49
- if (!options) {
50
- return {};
51
- }
52
- const result = {};
53
- for (const option of Object.keys(options)) {
54
- if (typeof options[option] === "string") {
55
- result[option] = await Promise.resolve(
56
- tokenizerFn(options[option], tokenParams)
57
- );
58
- } else if (Array.isArray(options[option])) {
59
- result[option] = await Promise.all(
60
- options[option].map(
61
- async (item) => typeof item === "string" ? await Promise.resolve(tokenizerFn(item, tokenParams)) : item
62
- )
63
- );
64
- } else if (typeof options[option] === "object") {
65
- result[option] = await applyWorkspaceTokens(
66
- options[option],
67
- tokenParams,
68
- tokenizerFn
69
- );
70
- } else {
71
- result[option] = options[option];
72
- }
73
- }
74
- return result;
75
- };
76
-
77
-
78
-
79
-
80
-
81
- exports.applyWorkspaceBaseTokens = applyWorkspaceBaseTokens; exports.applyWorkspaceProjectTokens = applyWorkspaceProjectTokens; exports.applyWorkspaceTokens = applyWorkspaceTokens;
@@ -1,81 +0,0 @@
1
- import {
2
- findWorkspaceRoot
3
- } from "./chunk-S4V6UG5D.js";
4
-
5
- // src/utilities/apply-workspace-tokens.ts
6
- var applyWorkspaceBaseTokens = async (option, tokenParams) => {
7
- let result = option;
8
- if (!result) {
9
- return result;
10
- }
11
- if (tokenParams) {
12
- const optionKeys = Object.keys(tokenParams);
13
- if (optionKeys.some((optionKey) => result.includes(`{${optionKey}}`))) {
14
- for (const optionKey of optionKeys) {
15
- if (result.includes(`{${optionKey}}`)) {
16
- result = result.replaceAll(
17
- `{${optionKey}}`,
18
- tokenParams?.[optionKey] || ""
19
- );
20
- }
21
- }
22
- }
23
- }
24
- if (tokenParams.config) {
25
- const configKeys = Object.keys(tokenParams.config);
26
- if (configKeys.some((configKey) => result.includes(`{${configKey}}`))) {
27
- for (const configKey of configKeys) {
28
- if (result.includes(`{${configKey}}`)) {
29
- result = result.replaceAll(
30
- `{${configKey}}`,
31
- tokenParams.config[configKey] || ""
32
- );
33
- }
34
- }
35
- }
36
- }
37
- if (result.includes("{workspaceRoot}")) {
38
- result = result.replaceAll(
39
- "{workspaceRoot}",
40
- tokenParams.workspaceRoot ?? tokenParams.config?.workspaceRoot ?? findWorkspaceRoot()
41
- );
42
- }
43
- return result;
44
- };
45
- var applyWorkspaceProjectTokens = (option, tokenParams) => {
46
- return applyWorkspaceBaseTokens(option, tokenParams);
47
- };
48
- var applyWorkspaceTokens = async (options, tokenParams, tokenizerFn) => {
49
- if (!options) {
50
- return {};
51
- }
52
- const result = {};
53
- for (const option of Object.keys(options)) {
54
- if (typeof options[option] === "string") {
55
- result[option] = await Promise.resolve(
56
- tokenizerFn(options[option], tokenParams)
57
- );
58
- } else if (Array.isArray(options[option])) {
59
- result[option] = await Promise.all(
60
- options[option].map(
61
- async (item) => typeof item === "string" ? await Promise.resolve(tokenizerFn(item, tokenParams)) : item
62
- )
63
- );
64
- } else if (typeof options[option] === "object") {
65
- result[option] = await applyWorkspaceTokens(
66
- options[option],
67
- tokenParams,
68
- tokenizerFn
69
- );
70
- } else {
71
- result[option] = options[option];
72
- }
73
- }
74
- return result;
75
- };
76
-
77
- export {
78
- applyWorkspaceBaseTokens,
79
- applyWorkspaceProjectTokens,
80
- applyWorkspaceTokens
81
- };