@wixc3/engine-runtime-node
Advanced tools
Comparing version 22.1.4 to 22.1.5
@@ -11,3 +11,2 @@ export * from './forked-process'; | ||
export * from './parse-cli-arguments'; | ||
export * from './config-locators'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -23,3 +23,2 @@ "use strict"; | ||
__exportStar(require("./parse-cli-arguments"), exports); | ||
__exportStar(require("./config-locators"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -38,3 +38,2 @@ import io from 'socket.io'; | ||
requiredPaths?: string[]; | ||
basePath?: string; | ||
} | ||
@@ -41,0 +40,0 @@ export declare type LaunchEnvironmentMode = 'forked' | 'same-server' | 'new-server'; |
@@ -35,3 +35,2 @@ "use strict"; | ||
const engine_core_node_1 = require("@wixc3/engine-core-node"); | ||
const config_locators_1 = require("./config-locators"); | ||
class ChildBaseHost extends engine_core_1.BaseHost { | ||
@@ -62,3 +61,2 @@ constructor(parent) { | ||
constructor(socketServer, options, context, socketServerOptions) { | ||
var _a; | ||
this.socketServer = socketServer; | ||
@@ -69,3 +67,2 @@ this.options = options; | ||
this.runningFeatures = new Map(); | ||
this.options.basePath = (_a = this.options.basePath) !== null && _a !== void 0 ? _a : process.cwd(); | ||
} | ||
@@ -143,3 +140,3 @@ async runServerEnvironments({ featureName, configName, runtimeOptions = {}, overrideConfigsMap = new Map(), mode = 'new-server', }) { | ||
config.push(engine_core_1.COM.use({ config: { topology, connectedEnvironments } })); | ||
config.push(...(await this.getConfig(originalConfigName, nodeEnv.name, this.options.basePath)), ...overrideConfigs); | ||
config.push(...(await this.getConfig(originalConfigName)), ...overrideConfigs); | ||
const preparedEnvironment = await this.prepareEnvironment({ | ||
@@ -318,17 +315,24 @@ nodeEnv, | ||
} | ||
async getConfig(configName, envName, basePath) { | ||
async getConfig(configName) { | ||
const config = []; | ||
const { configurations } = this.options; | ||
if (configurations && configName) { | ||
const foundConfig = await (0, config_locators_1.findAllConfigs)({ | ||
basePath, | ||
configurations, | ||
requestedConfigName: configName, | ||
requestedEnvName: envName, | ||
importConfig: async (filePath) => (await Promise.resolve().then(() => __importStar(require(filePath)))).default, | ||
}); | ||
if (!foundConfig.length) { | ||
const configDefinition = configurations.get(configName); | ||
if (!configDefinition) { | ||
const configNames = Array.from(configurations.keys()); | ||
throw new Error(`cannot find config "${configName}". available configurations: ${configNames.join(', ')}`); | ||
} | ||
for (const definition of configDefinition) { | ||
try { | ||
if (Array.isArray(definition)) { | ||
config.push(...definition); | ||
} | ||
else { | ||
config.push(...(await Promise.resolve().then(() => __importStar(require(definition.filePath)))).default); | ||
} | ||
} | ||
catch (e) { | ||
console.error(e); | ||
} | ||
} | ||
} | ||
@@ -335,0 +339,0 @@ return config; |
{ | ||
"name": "@wixc3/engine-runtime-node", | ||
"version": "22.1.4", | ||
"version": "22.1.5", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
@@ -11,2 +11,1 @@ export * from './forked-process'; | ||
export * from './parse-cli-arguments'; | ||
export * from './config-locators'; |
@@ -33,3 +33,2 @@ import type { Socket } from 'net'; | ||
import { IPCHost, LOCAL_ENVIRONMENT_INITIALIZER_ENV_ID } from '@wixc3/engine-core-node'; | ||
import { DefaultConfigFileExports, findAllConfigs } from './config-locators'; | ||
@@ -102,3 +101,2 @@ export interface OverrideConfig { | ||
requiredPaths?: string[]; | ||
basePath?: string; | ||
} | ||
@@ -132,5 +130,3 @@ | ||
private socketServerOptions?: Partial<io.ServerOptions> | ||
) { | ||
this.options.basePath = this.options.basePath ?? process.cwd(); | ||
} | ||
) {} | ||
@@ -223,6 +219,3 @@ public async runServerEnvironments({ | ||
config.push(COM.use({ config: { topology, connectedEnvironments } })); | ||
config.push( | ||
...(await this.getConfig(originalConfigName, nodeEnv.name, this.options.basePath!)), | ||
...overrideConfigs | ||
); | ||
config.push(...(await this.getConfig(originalConfigName)), ...overrideConfigs); | ||
const preparedEnvironment = await this.prepareEnvironment({ | ||
@@ -438,15 +431,8 @@ nodeEnv, | ||
private async getConfig(configName: string | undefined, envName: string, basePath: string) { | ||
private async getConfig(configName: string | undefined) { | ||
const config: TopLevelConfig = []; | ||
const { configurations } = this.options; | ||
if (configurations && configName) { | ||
const foundConfig = await findAllConfigs({ | ||
basePath, | ||
configurations, | ||
requestedConfigName: configName, | ||
requestedEnvName: envName, | ||
importConfig: async (filePath) => ((await import(filePath)) as DefaultConfigFileExports).default, | ||
}); | ||
if (!foundConfig.length) { | ||
const configDefinition = configurations.get(configName); | ||
if (!configDefinition) { | ||
const configNames = Array.from(configurations.keys()); | ||
@@ -457,2 +443,13 @@ throw new Error( | ||
} | ||
for (const definition of configDefinition) { | ||
try { | ||
if (Array.isArray(definition)) { | ||
config.push(...definition); | ||
} else { | ||
config.push(...((await import(definition.filePath)) as { default: TopLevelConfig }).default); | ||
} | ||
} catch (e) { | ||
console.error(e); | ||
} | ||
} | ||
} | ||
@@ -459,0 +456,0 @@ return config; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12
149594
73
2464