quidproquo-deploy-webpack 0.0.246 → 0.0.247

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.
@@ -6,9 +6,9 @@ const getSrcLoaderForQpqConfig_1 = require("./getSrcLoaderForQpqConfig");
6
6
  function getModuleLoaderSrcForService(qpqConfig, serviceNameVariableName, moduleNameVariableName) {
7
7
  const serviceName = quidproquo_core_1.qpqCoreUtils.getApplicationModuleName(qpqConfig);
8
8
  const result = `
9
- if (${serviceNameVariableName} === String.raw\`${serviceName}\`) {
10
- ${(0, getSrcLoaderForQpqConfig_1.getSrcLoaderForQpqConfig)(qpqConfig, moduleNameVariableName)}
11
- }
9
+ if (${serviceNameVariableName} === String.raw\`${serviceName}\`) {
10
+ ${(0, getSrcLoaderForQpqConfig_1.getSrcLoaderForQpqConfig)(qpqConfig, moduleNameVariableName)}
11
+ }
12
12
  `;
13
13
  return result;
14
14
  }
@@ -6,17 +6,17 @@ const getSrcLoaderForQpqConfig_1 = require("./getSrcLoaderForQpqConfig");
6
6
  const getQpqDyanmicLoaderSrcFromQpqConfigs = (qpqConfigs) => {
7
7
  const result = `
8
8
  export const qpqConfig = ${JSON.stringify(qpqConfigs[0], null, 2)};
9
- export const qpqConfigs = ${JSON.stringify(qpqConfigs, null, 2)};
9
+ export const qpqConfigs = ${JSON.stringify(qpqConfigs, null, 2)};
10
10
 
11
- export const qpqDynamicModuleLoader = async (moduleName) => {
12
- ${(0, getSrcLoaderForQpqConfig_1.getSrcLoaderForQpqConfig)(qpqConfigs[0], 'moduleName')}
11
+ export const qpqDynamicModuleLoader = async (qpqFunctionRuntime) => {
12
+ ${(0, getSrcLoaderForQpqConfig_1.getSrcLoaderForQpqConfig)(qpqConfigs[0], 'qpqFunctionRuntime')}
13
13
 
14
14
  // This will never get hit
15
15
  return null;
16
16
  };
17
17
 
18
- export const qpqDynamicModuleLoaderForService = async (serviceName, moduleName) => {
19
- ${qpqConfigs.map((qpqConfig) => (0, getModuleLoaderSrcForService_1.getModuleLoaderSrcForService)(qpqConfig, 'serviceName', 'moduleName')).join('')}
18
+ export const qpqDynamicModuleLoaderForService = async (serviceName, qpqFunctionRuntime) => {
19
+ ${qpqConfigs.map((qpqConfig) => (0, getModuleLoaderSrcForService_1.getModuleLoaderSrcForService)(qpqConfig, 'serviceName', 'qpqFunctionRuntime')).join('')}
20
20
 
21
21
  // This will never get hit
22
22
  return null;
@@ -1,2 +1,2 @@
1
- export function getSrcLoaderForQpqConfig(qpqConfig: any, moduleNameVariableName: any): string;
1
+ export function getSrcLoaderForQpqConfig(qpqConfig: any, qpqFunctionRuntimeVariableName: any): string;
2
2
  export function getFullSrcPathFromQpqFunctionRuntime(qpqFunctionRuntime: any, qpqConfig: any): string;
@@ -16,38 +16,38 @@ const getFullSrcPathFromQpqFunctionRuntime = (qpqFunctionRuntime, qpqConfig) =>
16
16
  return path_1.default.join(configRoot, srcPath);
17
17
  };
18
18
  exports.getFullSrcPathFromQpqFunctionRuntime = getFullSrcPathFromQpqFunctionRuntime;
19
- function getSrcLoaderForQpqConfig(qpqConfig, moduleNameVariableName) {
20
- const uniqueSrcFiles = [...new Set([...quidproquo_core_1.qpqCoreUtils.getAllSrcEntries(qpqConfig), ...quidproquo_webserver_1.qpqWebServerUtils.getAllSrcEntries(qpqConfig)])];
21
- const caseStatements = [
22
- ...uniqueSrcFiles.map((e) => {
23
- const fullPath = (0, exports.getFullSrcPathFromQpqFunctionRuntime)(e, qpqConfig);
24
- const method = quidproquo_core_1.qpqCoreUtils.getStoryNameFromQpqFunctionRuntime(e);
25
- const srcPath = fullPath.replace(/\\/g, '/');
26
- return `case String.raw\`${e}\`: {
27
- const module = await require('${srcPath}');
28
- if (!module) {
29
- throw new Error('Unable to dynamically load module');
30
- }
31
-
32
- const story = module['${method}'];
33
- if (!story) {
34
- throw new Error(\`Unable to dynamically load story: [${method}]\`);
35
- }
19
+ function getSrcLoaderForQpqConfig(qpqConfig, qpqFunctionRuntimeVariableName) {
20
+ const allQpqFunctionRuntimes = [...quidproquo_core_1.qpqCoreUtils.getAllSrcEntries(qpqConfig), ...quidproquo_webserver_1.qpqWebServerUtils.getAllSrcEntries(qpqConfig)];
21
+ const ifStatements = allQpqFunctionRuntimes.map((qpqFunctionRuntime) => {
22
+ const fullPath = (0, exports.getFullSrcPathFromQpqFunctionRuntime)(qpqFunctionRuntime, qpqConfig);
23
+ const method = quidproquo_core_1.qpqCoreUtils.getStoryNameFromQpqFunctionRuntime(qpqFunctionRuntime);
24
+ const srcPath = path_1.default.posix.join(fullPath.replace(/\\/g, '/')); // Ensure proper path format
25
+ return `
26
+ if (typeof ${qpqFunctionRuntimeVariableName} === '${typeof qpqFunctionRuntime}' && !!${qpqFunctionRuntimeVariableName}) {
27
+ if (
28
+ ${typeof qpqFunctionRuntime === 'string'
29
+ ? `(${qpqFunctionRuntimeVariableName} === String.raw\`${qpqFunctionRuntime}\`)`
30
+ : `(
31
+ ${qpqFunctionRuntimeVariableName}.basePath === String.raw\`${qpqFunctionRuntime.basePath}\` &&
32
+ ${qpqFunctionRuntimeVariableName}.relativePath === String.raw\`${qpqFunctionRuntime.relativePath}\` &&
33
+ ${qpqFunctionRuntimeVariableName}.functionName === String.raw\`${qpqFunctionRuntime.functionName}\`
34
+ )`}
35
+ ) {
36
+ const module = await require('${srcPath}');
37
+ if (!module) {
38
+ throw new Error('Unable to dynamically load module');
39
+ }
36
40
 
37
- return story;
38
- }`;
39
- }),
40
- `default: {
41
- console.log("Can't find module from list");
41
+ const story = module['${method}'];
42
+ if (!story) {
43
+ throw new Error(\`Unable to dynamically load story: [${method}]\`);
44
+ }
42
45
 
43
- throw new Error('Unable to dynamically load module, no matching file path, path must match exactly what is in qpqConfig.');
44
- }`,
45
- ];
46
- const result = `
47
- switch (${moduleNameVariableName}) {
48
- ${caseStatements.join('\n')}
49
- }
46
+ return story;
47
+ }
48
+ }
50
49
  `;
51
- return result;
50
+ });
51
+ return ifStatements.join('\n');
52
52
  }
53
53
  exports.getSrcLoaderForQpqConfig = getSrcLoaderForQpqConfig;
@@ -3,9 +3,9 @@ import { getSrcLoaderForQpqConfig } from './getSrcLoaderForQpqConfig';
3
3
  export function getModuleLoaderSrcForService(qpqConfig, serviceNameVariableName, moduleNameVariableName) {
4
4
  const serviceName = qpqCoreUtils.getApplicationModuleName(qpqConfig);
5
5
  const result = `
6
- if (${serviceNameVariableName} === String.raw\`${serviceName}\`) {
7
- ${getSrcLoaderForQpqConfig(qpqConfig, moduleNameVariableName)}
8
- }
6
+ if (${serviceNameVariableName} === String.raw\`${serviceName}\`) {
7
+ ${getSrcLoaderForQpqConfig(qpqConfig, moduleNameVariableName)}
8
+ }
9
9
  `;
10
10
  return result;
11
11
  }
@@ -3,17 +3,17 @@ import { getSrcLoaderForQpqConfig } from './getSrcLoaderForQpqConfig';
3
3
  export const getQpqDyanmicLoaderSrcFromQpqConfigs = (qpqConfigs) => {
4
4
  const result = `
5
5
  export const qpqConfig = ${JSON.stringify(qpqConfigs[0], null, 2)};
6
- export const qpqConfigs = ${JSON.stringify(qpqConfigs, null, 2)};
6
+ export const qpqConfigs = ${JSON.stringify(qpqConfigs, null, 2)};
7
7
 
8
- export const qpqDynamicModuleLoader = async (moduleName) => {
9
- ${getSrcLoaderForQpqConfig(qpqConfigs[0], 'moduleName')}
8
+ export const qpqDynamicModuleLoader = async (qpqFunctionRuntime) => {
9
+ ${getSrcLoaderForQpqConfig(qpqConfigs[0], 'qpqFunctionRuntime')}
10
10
 
11
11
  // This will never get hit
12
12
  return null;
13
13
  };
14
14
 
15
- export const qpqDynamicModuleLoaderForService = async (serviceName, moduleName) => {
16
- ${qpqConfigs.map((qpqConfig) => getModuleLoaderSrcForService(qpqConfig, 'serviceName', 'moduleName')).join('')}
15
+ export const qpqDynamicModuleLoaderForService = async (serviceName, qpqFunctionRuntime) => {
16
+ ${qpqConfigs.map((qpqConfig) => getModuleLoaderSrcForService(qpqConfig, 'serviceName', 'qpqFunctionRuntime')).join('')}
17
17
 
18
18
  // This will never get hit
19
19
  return null;
@@ -1,2 +1,2 @@
1
- export function getSrcLoaderForQpqConfig(qpqConfig: any, moduleNameVariableName: any): string;
1
+ export function getSrcLoaderForQpqConfig(qpqConfig: any, qpqFunctionRuntimeVariableName: any): string;
2
2
  export function getFullSrcPathFromQpqFunctionRuntime(qpqFunctionRuntime: any, qpqConfig: any): string;
@@ -9,37 +9,37 @@ export const getFullSrcPathFromQpqFunctionRuntime = (qpqFunctionRuntime, qpqConf
9
9
  const configRoot = qpqCoreUtils.getApplicationConfigRoot(qpqConfig);
10
10
  return path.join(configRoot, srcPath);
11
11
  };
12
- export function getSrcLoaderForQpqConfig(qpqConfig, moduleNameVariableName) {
13
- const uniqueSrcFiles = [...new Set([...qpqCoreUtils.getAllSrcEntries(qpqConfig), ...qpqWebServerUtils.getAllSrcEntries(qpqConfig)])];
14
- const caseStatements = [
15
- ...uniqueSrcFiles.map((e) => {
16
- const fullPath = getFullSrcPathFromQpqFunctionRuntime(e, qpqConfig);
17
- const method = qpqCoreUtils.getStoryNameFromQpqFunctionRuntime(e);
18
- const srcPath = fullPath.replace(/\\/g, '/');
19
- return `case String.raw\`${e}\`: {
20
- const module = await require('${srcPath}');
21
- if (!module) {
22
- throw new Error('Unable to dynamically load module');
23
- }
24
-
25
- const story = module['${method}'];
26
- if (!story) {
27
- throw new Error(\`Unable to dynamically load story: [${method}]\`);
28
- }
12
+ export function getSrcLoaderForQpqConfig(qpqConfig, qpqFunctionRuntimeVariableName) {
13
+ const allQpqFunctionRuntimes = [...qpqCoreUtils.getAllSrcEntries(qpqConfig), ...qpqWebServerUtils.getAllSrcEntries(qpqConfig)];
14
+ const ifStatements = allQpqFunctionRuntimes.map((qpqFunctionRuntime) => {
15
+ const fullPath = getFullSrcPathFromQpqFunctionRuntime(qpqFunctionRuntime, qpqConfig);
16
+ const method = qpqCoreUtils.getStoryNameFromQpqFunctionRuntime(qpqFunctionRuntime);
17
+ const srcPath = path.posix.join(fullPath.replace(/\\/g, '/')); // Ensure proper path format
18
+ return `
19
+ if (typeof ${qpqFunctionRuntimeVariableName} === '${typeof qpqFunctionRuntime}' && !!${qpqFunctionRuntimeVariableName}) {
20
+ if (
21
+ ${typeof qpqFunctionRuntime === 'string'
22
+ ? `(${qpqFunctionRuntimeVariableName} === String.raw\`${qpqFunctionRuntime}\`)`
23
+ : `(
24
+ ${qpqFunctionRuntimeVariableName}.basePath === String.raw\`${qpqFunctionRuntime.basePath}\` &&
25
+ ${qpqFunctionRuntimeVariableName}.relativePath === String.raw\`${qpqFunctionRuntime.relativePath}\` &&
26
+ ${qpqFunctionRuntimeVariableName}.functionName === String.raw\`${qpqFunctionRuntime.functionName}\`
27
+ )`}
28
+ ) {
29
+ const module = await require('${srcPath}');
30
+ if (!module) {
31
+ throw new Error('Unable to dynamically load module');
32
+ }
29
33
 
30
- return story;
31
- }`;
32
- }),
33
- `default: {
34
- console.log("Can't find module from list");
34
+ const story = module['${method}'];
35
+ if (!story) {
36
+ throw new Error(\`Unable to dynamically load story: [${method}]\`);
37
+ }
35
38
 
36
- throw new Error('Unable to dynamically load module, no matching file path, path must match exactly what is in qpqConfig.');
37
- }`,
38
- ];
39
- const result = `
40
- switch (${moduleNameVariableName}) {
41
- ${caseStatements.join('\n')}
42
- }
39
+ return story;
40
+ }
41
+ }
43
42
  `;
44
- return result;
43
+ });
44
+ return ifStatements.join('\n');
45
45
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quidproquo-deploy-webpack",
3
- "version": "0.0.246",
3
+ "version": "0.0.247",
4
4
  "description": "",
5
5
  "main": "./lib/commonjs/webpack.config.js",
6
6
  "module": "./lib/esm/webpack.config.js",
@@ -33,11 +33,11 @@
33
33
  "homepage": "https://github.com/joe-coady/quidproquo#readme",
34
34
  "dependencies": {
35
35
  "path-browserify": "^1.0.1",
36
- "quidproquo-actionprocessor-awslambda": "0.0.246",
37
- "quidproquo-actionprocessor-node": "0.0.246",
38
- "quidproquo-core": "0.0.246",
39
- "quidproquo-deploy-awscdk": "0.0.246",
40
- "quidproquo-webserver": "0.0.246",
36
+ "quidproquo-actionprocessor-awslambda": "0.0.247",
37
+ "quidproquo-actionprocessor-node": "0.0.247",
38
+ "quidproquo-core": "0.0.247",
39
+ "quidproquo-deploy-awscdk": "0.0.247",
40
+ "quidproquo-webserver": "0.0.247",
41
41
  "webpack-virtual-modules": "^0.6.2"
42
42
  },
43
43
  "devDependencies": {
@@ -48,7 +48,7 @@
48
48
  "@types/node": "^20.2.1",
49
49
  "@types/prettier": "2.6.0",
50
50
  "babel-loader": "^9.1.2",
51
- "quidproquo-tsconfig": "0.0.246",
51
+ "quidproquo-tsconfig": "0.0.247",
52
52
  "ts-node": "^10.9.1",
53
53
  "typescript": "^5.0.4"
54
54
  },