@lwrjs/core 0.9.0-alpha.12 → 0.9.0-alpha.13
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/build/cjs/context/provider.cjs +2 -1
- package/build/cjs/context/server.cjs +4 -1
- package/build/cjs/index.cjs +28 -23
- package/build/cjs/middleware/view-middleware.cjs +12 -16
- package/build/cjs/tools/plugins/build-server-plugin.cjs +137 -0
- package/build/cjs/{context/services.cjs → tools/plugins/generate-entry-plugin.cjs} +26 -21
- package/build/cjs/tools/server-build.cjs +15 -129
- package/build/cjs/tools/server-warmup.cjs +2 -9
- package/build/cjs/tools/static-generation.cjs +8 -11
- package/build/es/context/provider.js +1 -0
- package/build/es/context/server.js +4 -0
- package/build/es/index.js +36 -25
- package/build/es/middleware/view-middleware.d.ts +2 -2
- package/build/es/middleware/view-middleware.js +12 -16
- package/build/es/tools/plugins/build-server-plugin.d.ts +18 -0
- package/build/es/tools/plugins/build-server-plugin.js +132 -0
- package/build/es/tools/plugins/generate-entry-plugin.d.ts +11 -0
- package/build/es/tools/plugins/generate-entry-plugin.js +45 -0
- package/build/es/tools/server-build.d.ts +5 -6
- package/build/es/tools/server-build.js +22 -152
- package/build/es/tools/server-warmup.js +3 -10
- package/build/es/tools/static-generation.js +10 -12
- package/package.json +28 -27
- package/build/cjs/context/configurations.cjs +0 -82
- package/build/cjs/context/global-data.cjs +0 -54
- package/build/es/context/configurations.d.ts +0 -9
- package/build/es/context/configurations.js +0 -53
- package/build/es/context/global-data.d.ts +0 -3
- package/build/es/context/global-data.js +0 -29
- package/build/es/context/services.d.ts +0 -3
- package/build/es/context/services.js +0 -27
|
@@ -4,7 +4,7 @@ import { join, dirname, extname } from 'path';
|
|
|
4
4
|
import fs from 'fs-extra';
|
|
5
5
|
import { writeResponse } from './utils/stream.js';
|
|
6
6
|
import { createDir, createResourceDir } from './utils/dir.js';
|
|
7
|
-
import {
|
|
7
|
+
import { getRuntimeEnvironment } from '@lwrjs/config';
|
|
8
8
|
export default class SiteGenerator {
|
|
9
9
|
/**
|
|
10
10
|
* Build a static site in the configured directory
|
|
@@ -26,18 +26,16 @@ export default class SiteGenerator {
|
|
|
26
26
|
staticSiteGenerator.outputDir = '__generated_site__';
|
|
27
27
|
}
|
|
28
28
|
const outputDir = join(rootDir, staticSiteGenerator.outputDir);
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
if (!staticSiteGenerator.skipCleanOutputDir) {
|
|
30
|
+
logger.info(`Clearing output directory: ${outputDir}`);
|
|
31
|
+
fs.rmSync(outputDir, { recursive: true, force: true });
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
logger.info(`Reusing existing output directory: ${outputDir}`);
|
|
35
|
+
}
|
|
31
36
|
const urlRewriteMap = new Map();
|
|
32
|
-
const {
|
|
33
|
-
const runtimeEnvironment =
|
|
34
|
-
...explodeMode(serverMode),
|
|
35
|
-
apiVersion,
|
|
36
|
-
basePath,
|
|
37
|
-
lwrVersion,
|
|
38
|
-
debug: false,
|
|
39
|
-
serverMode,
|
|
40
|
-
};
|
|
37
|
+
const { basePath } = config;
|
|
38
|
+
const runtimeEnvironment = getRuntimeEnvironment(config);
|
|
41
39
|
// For each locale, generate all the modules
|
|
42
40
|
await this.generateRoutes(runtimeEnvironment, staticSiteGenerator, routes, basePath, dispatcher, outputDir, urlRewriteMap);
|
|
43
41
|
// Write redirect files
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.9.0-alpha.
|
|
7
|
+
"version": "0.9.0-alpha.13",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -36,30 +36,31 @@
|
|
|
36
36
|
"package.cjs"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@lwrjs/app-service": "0.9.0-alpha.
|
|
40
|
-
"@lwrjs/asset-registry": "0.9.0-alpha.
|
|
41
|
-
"@lwrjs/asset-transformer": "0.9.0-alpha.
|
|
42
|
-
"@lwrjs/base-view-provider": "0.9.0-alpha.
|
|
43
|
-
"@lwrjs/base-view-transformer": "0.9.0-alpha.
|
|
44
|
-
"@lwrjs/client-modules": "0.9.0-alpha.
|
|
45
|
-
"@lwrjs/compiler": "0.9.0-alpha.
|
|
46
|
-
"@lwrjs/config": "0.9.0-alpha.
|
|
47
|
-
"@lwrjs/diagnostics": "0.9.0-alpha.
|
|
48
|
-
"@lwrjs/fs-asset-provider": "0.9.0-alpha.
|
|
49
|
-
"@lwrjs/html-view-provider": "0.9.0-alpha.
|
|
50
|
-
"@lwrjs/loader": "0.9.0-alpha.
|
|
51
|
-
"@lwrjs/lwc-module-provider": "0.9.0-alpha.
|
|
52
|
-
"@lwrjs/markdown-view-provider": "0.9.0-alpha.
|
|
53
|
-
"@lwrjs/module-bundler": "0.9.0-alpha.
|
|
54
|
-
"@lwrjs/module-registry": "0.9.0-alpha.
|
|
55
|
-
"@lwrjs/npm-module-provider": "0.9.0-alpha.
|
|
56
|
-
"@lwrjs/nunjucks-view-provider": "0.9.0-alpha.
|
|
57
|
-
"@lwrjs/o11y": "0.9.0-alpha.
|
|
58
|
-
"@lwrjs/resource-registry": "0.9.0-alpha.
|
|
59
|
-
"@lwrjs/router": "0.9.0-alpha.
|
|
60
|
-
"@lwrjs/server": "0.9.0-alpha.
|
|
61
|
-
"@lwrjs/shared-utils": "0.9.0-alpha.
|
|
62
|
-
"@lwrjs/view-registry": "0.9.0-alpha.
|
|
39
|
+
"@lwrjs/app-service": "0.9.0-alpha.13",
|
|
40
|
+
"@lwrjs/asset-registry": "0.9.0-alpha.13",
|
|
41
|
+
"@lwrjs/asset-transformer": "0.9.0-alpha.13",
|
|
42
|
+
"@lwrjs/base-view-provider": "0.9.0-alpha.13",
|
|
43
|
+
"@lwrjs/base-view-transformer": "0.9.0-alpha.13",
|
|
44
|
+
"@lwrjs/client-modules": "0.9.0-alpha.13",
|
|
45
|
+
"@lwrjs/compiler": "0.9.0-alpha.13",
|
|
46
|
+
"@lwrjs/config": "0.9.0-alpha.13",
|
|
47
|
+
"@lwrjs/diagnostics": "0.9.0-alpha.13",
|
|
48
|
+
"@lwrjs/fs-asset-provider": "0.9.0-alpha.13",
|
|
49
|
+
"@lwrjs/html-view-provider": "0.9.0-alpha.13",
|
|
50
|
+
"@lwrjs/loader": "0.9.0-alpha.13",
|
|
51
|
+
"@lwrjs/lwc-module-provider": "0.9.0-alpha.13",
|
|
52
|
+
"@lwrjs/markdown-view-provider": "0.9.0-alpha.13",
|
|
53
|
+
"@lwrjs/module-bundler": "0.9.0-alpha.13",
|
|
54
|
+
"@lwrjs/module-registry": "0.9.0-alpha.13",
|
|
55
|
+
"@lwrjs/npm-module-provider": "0.9.0-alpha.13",
|
|
56
|
+
"@lwrjs/nunjucks-view-provider": "0.9.0-alpha.13",
|
|
57
|
+
"@lwrjs/o11y": "0.9.0-alpha.13",
|
|
58
|
+
"@lwrjs/resource-registry": "0.9.0-alpha.13",
|
|
59
|
+
"@lwrjs/router": "0.9.0-alpha.13",
|
|
60
|
+
"@lwrjs/server": "0.9.0-alpha.13",
|
|
61
|
+
"@lwrjs/shared-utils": "0.9.0-alpha.13",
|
|
62
|
+
"@lwrjs/view-registry": "0.9.0-alpha.13",
|
|
63
|
+
"chokidar": "^3.5.3",
|
|
63
64
|
"esbuild": "^0.9.7",
|
|
64
65
|
"fs-extra": "^10.1.0",
|
|
65
66
|
"path-to-regexp": "^6.2.0",
|
|
@@ -67,7 +68,7 @@
|
|
|
67
68
|
"ws": "^8.8.1"
|
|
68
69
|
},
|
|
69
70
|
"devDependencies": {
|
|
70
|
-
"@lwrjs/types": "0.9.0-alpha.
|
|
71
|
+
"@lwrjs/types": "0.9.0-alpha.13",
|
|
71
72
|
"@types/ws": "^8.5.3"
|
|
72
73
|
},
|
|
73
74
|
"peerDependencies": {
|
|
@@ -76,5 +77,5 @@
|
|
|
76
77
|
"engines": {
|
|
77
78
|
"node": ">=14.15.4 <19"
|
|
78
79
|
},
|
|
79
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "fa30915a685f6e8c5c2895d0c053d59145780123"
|
|
80
81
|
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
11
|
-
};
|
|
12
|
-
var __exportStar = (target, module2, desc) => {
|
|
13
|
-
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(module2))
|
|
15
|
-
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
16
|
-
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
|
|
17
|
-
}
|
|
18
|
-
return target;
|
|
19
|
-
};
|
|
20
|
-
var __toModule = (module2) => {
|
|
21
|
-
return __exportStar(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
// packages/@lwrjs/core/src/context/configurations.ts
|
|
25
|
-
__markAsModule(exports);
|
|
26
|
-
__export(exports, {
|
|
27
|
-
resolveConfigurations: () => resolveConfigurations
|
|
28
|
-
});
|
|
29
|
-
var import_shared_utils = __toModule(require("@lwrjs/shared-utils"));
|
|
30
|
-
var import_config = __toModule(require("@lwrjs/config"));
|
|
31
|
-
var import_global_data = __toModule(require("./global-data.cjs"));
|
|
32
|
-
var import_services = __toModule(require("./services.cjs"));
|
|
33
|
-
function normalizeRoutesBootstrap({routes, errorRoutes}) {
|
|
34
|
-
[...routes, ...errorRoutes].forEach((route) => {
|
|
35
|
-
if (!route.bootstrap) {
|
|
36
|
-
route.bootstrap = {...import_shared_utils.DEFAULT_LWR_BOOTSTRAP_CONFIG};
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
async function runConfigurationsHook(hookPlugins, appConfig, globalData, runtimeEnvironment) {
|
|
41
|
-
for (const hookPlugin of hookPlugins) {
|
|
42
|
-
await hookPlugin.initConfigs(appConfig, globalData, runtimeEnvironment);
|
|
43
|
-
}
|
|
44
|
-
try {
|
|
45
|
-
(0, import_config.validateLwrAppConfig)(JSON.stringify(appConfig), "post");
|
|
46
|
-
} catch (e) {
|
|
47
|
-
if (process.env.UNSAFE_IGNORE_CONFIG_VALIDATION === "true") {
|
|
48
|
-
import_shared_utils.logger.warn("ignoring config validation errors due to UNSAFE_IGNORE_CONFIG_VALIDATION flag...proceed with caution");
|
|
49
|
-
console.dir(e, {depth: null});
|
|
50
|
-
} else {
|
|
51
|
-
throw e;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
normalizeRoutesBootstrap(appConfig);
|
|
55
|
-
return {
|
|
56
|
-
appConfig,
|
|
57
|
-
globalData,
|
|
58
|
-
runtimeEnvironment
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
async function resolveConfigurations(config) {
|
|
62
|
-
const {
|
|
63
|
-
apiVersion,
|
|
64
|
-
basePath,
|
|
65
|
-
lwrVersion,
|
|
66
|
-
serverMode,
|
|
67
|
-
globalDataDir,
|
|
68
|
-
globalData: globalDataConfig
|
|
69
|
-
} = config;
|
|
70
|
-
const globalData = (0, import_global_data.getGlobalData)(globalDataDir, globalDataConfig);
|
|
71
|
-
const runtimeEnvironment = {
|
|
72
|
-
...(0, import_config.explodeMode)(serverMode),
|
|
73
|
-
apiVersion,
|
|
74
|
-
basePath,
|
|
75
|
-
lwrVersion,
|
|
76
|
-
debug: false,
|
|
77
|
-
serverMode,
|
|
78
|
-
featureFlags: (0, import_shared_utils.getFeatureFlags)()
|
|
79
|
-
};
|
|
80
|
-
const hookProviders = await (0, import_services.getServices)(config.hooks, void 0, config);
|
|
81
|
-
return runConfigurationsHook(hookProviders, config, globalData, runtimeEnvironment);
|
|
82
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
11
|
-
};
|
|
12
|
-
var __exportStar = (target, module2, desc) => {
|
|
13
|
-
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(module2))
|
|
15
|
-
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
16
|
-
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
|
|
17
|
-
}
|
|
18
|
-
return target;
|
|
19
|
-
};
|
|
20
|
-
var __toModule = (module2) => {
|
|
21
|
-
return __exportStar(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
// packages/@lwrjs/core/src/context/global-data.ts
|
|
25
|
-
__markAsModule(exports);
|
|
26
|
-
__export(exports, {
|
|
27
|
-
getGlobalData: () => getGlobalData
|
|
28
|
-
});
|
|
29
|
-
var import_fs = __toModule(require("fs"));
|
|
30
|
-
var import_path = __toModule(require("path"));
|
|
31
|
-
function recursiveJsonCollector(resources, currentPath, collector) {
|
|
32
|
-
for (const resource of resources) {
|
|
33
|
-
const resourcePath = import_path.default.join(currentPath, resource);
|
|
34
|
-
if (resource.endsWith(".json")) {
|
|
35
|
-
const resourceName = import_path.default.basename(resource, ".json");
|
|
36
|
-
const jsonSource = JSON.parse(import_fs.default.readFileSync(resourcePath, "utf-8"));
|
|
37
|
-
collector[resourceName] = jsonSource;
|
|
38
|
-
} else if (import_fs.default.statSync(resourcePath).isDirectory()) {
|
|
39
|
-
const dirContentList = import_fs.default.readdirSync(resourcePath);
|
|
40
|
-
collector[resource] = recursiveJsonCollector(dirContentList, resourcePath, {});
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return collector;
|
|
44
|
-
}
|
|
45
|
-
function getGlobalData(globalDataDir, defaultData = {}) {
|
|
46
|
-
if (!import_fs.default.existsSync(globalDataDir) || !import_fs.default.statSync(globalDataDir).isDirectory()) {
|
|
47
|
-
return defaultData;
|
|
48
|
-
}
|
|
49
|
-
const dirContentList = import_fs.default.readdirSync(globalDataDir);
|
|
50
|
-
return {
|
|
51
|
-
...recursiveJsonCollector(dirContentList, globalDataDir, {}),
|
|
52
|
-
...defaultData
|
|
53
|
-
};
|
|
54
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { NormalizedLwrGlobalConfig, RuntimeEnvironment, GlobalData } from '@lwrjs/types';
|
|
2
|
-
interface Configurations {
|
|
3
|
-
appConfig: NormalizedLwrGlobalConfig;
|
|
4
|
-
globalData: GlobalData;
|
|
5
|
-
runtimeEnvironment: RuntimeEnvironment;
|
|
6
|
-
}
|
|
7
|
-
export declare function resolveConfigurations(config: NormalizedLwrGlobalConfig): Promise<Configurations>;
|
|
8
|
-
export {};
|
|
9
|
-
//# sourceMappingURL=configurations.d.ts.map
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { DEFAULT_LWR_BOOTSTRAP_CONFIG, getFeatureFlags, logger } from '@lwrjs/shared-utils';
|
|
2
|
-
import { explodeMode, validateLwrAppConfig } from '@lwrjs/config';
|
|
3
|
-
import { getGlobalData } from './global-data.js';
|
|
4
|
-
import { getServices } from './services.js';
|
|
5
|
-
// Add missing bootstrap objects to routes
|
|
6
|
-
function normalizeRoutesBootstrap({ routes, errorRoutes }) {
|
|
7
|
-
[...routes, ...errorRoutes].forEach((route) => {
|
|
8
|
-
if (!route.bootstrap) {
|
|
9
|
-
route.bootstrap = { ...DEFAULT_LWR_BOOTSTRAP_CONFIG };
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
async function runConfigurationsHook(hookPlugins, appConfig, globalData, runtimeEnvironment) {
|
|
14
|
-
for (const hookPlugin of hookPlugins) {
|
|
15
|
-
// eslint-disable-next-line no-await-in-loop
|
|
16
|
-
await hookPlugin.initConfigs(appConfig, globalData, runtimeEnvironment);
|
|
17
|
-
}
|
|
18
|
-
try {
|
|
19
|
-
validateLwrAppConfig(JSON.stringify(appConfig), 'post');
|
|
20
|
-
}
|
|
21
|
-
catch (e) {
|
|
22
|
-
// TODO: temporary workaround for https://github.com/salesforce/lwr/issues/825
|
|
23
|
-
if (process.env.UNSAFE_IGNORE_CONFIG_VALIDATION === 'true') {
|
|
24
|
-
logger.warn('ignoring config validation errors due to UNSAFE_IGNORE_CONFIG_VALIDATION flag...proceed with caution');
|
|
25
|
-
console.dir(e, { depth: null });
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
throw e;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
normalizeRoutesBootstrap(appConfig);
|
|
32
|
-
return {
|
|
33
|
-
appConfig,
|
|
34
|
-
globalData,
|
|
35
|
-
runtimeEnvironment,
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
export async function resolveConfigurations(config) {
|
|
39
|
-
const { apiVersion, basePath, lwrVersion, serverMode, globalDataDir, globalData: globalDataConfig, } = config;
|
|
40
|
-
const globalData = getGlobalData(globalDataDir, globalDataConfig);
|
|
41
|
-
const runtimeEnvironment = {
|
|
42
|
-
...explodeMode(serverMode),
|
|
43
|
-
apiVersion,
|
|
44
|
-
basePath,
|
|
45
|
-
lwrVersion,
|
|
46
|
-
debug: false,
|
|
47
|
-
serverMode,
|
|
48
|
-
featureFlags: getFeatureFlags(),
|
|
49
|
-
};
|
|
50
|
-
const hookProviders = await getServices(config.hooks, undefined, config);
|
|
51
|
-
return runConfigurationsHook(hookProviders, config, globalData, runtimeEnvironment);
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=configurations.js.map
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4
|
-
function recursiveJsonCollector(resources, currentPath, collector) {
|
|
5
|
-
for (const resource of resources) {
|
|
6
|
-
const resourcePath = path.join(currentPath, resource);
|
|
7
|
-
if (resource.endsWith('.json')) {
|
|
8
|
-
const resourceName = path.basename(resource, '.json');
|
|
9
|
-
const jsonSource = JSON.parse(fs.readFileSync(resourcePath, 'utf-8'));
|
|
10
|
-
collector[resourceName] = jsonSource;
|
|
11
|
-
}
|
|
12
|
-
else if (fs.statSync(resourcePath).isDirectory()) {
|
|
13
|
-
const dirContentList = fs.readdirSync(resourcePath);
|
|
14
|
-
collector[resource] = recursiveJsonCollector(dirContentList, resourcePath, {});
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
return collector;
|
|
18
|
-
}
|
|
19
|
-
export function getGlobalData(globalDataDir, defaultData = {}) {
|
|
20
|
-
if (!fs.existsSync(globalDataDir) || !fs.statSync(globalDataDir).isDirectory()) {
|
|
21
|
-
return defaultData;
|
|
22
|
-
}
|
|
23
|
-
const dirContentList = fs.readdirSync(globalDataDir);
|
|
24
|
-
return {
|
|
25
|
-
...recursiveJsonCollector(dirContentList, globalDataDir, {}),
|
|
26
|
-
...defaultData,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=global-data.js.map
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { LwrService, NormalizedLwrGlobalConfig, ProviderContext, ServiceConfig } from '@lwrjs/types';
|
|
2
|
-
export declare function getServices<T extends LwrService>(services: ServiceConfig[], providerContext: ProviderContext | undefined, lwrConfig: NormalizedLwrGlobalConfig): Promise<T[]>;
|
|
3
|
-
//# sourceMappingURL=services.d.ts.map
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import libPath from 'path';
|
|
2
|
-
import { resolveFileExtension, transpileTs } from '@lwrjs/shared-utils';
|
|
3
|
-
async function getServiceModule(path, { cacheDir, rootDir }) {
|
|
4
|
-
try {
|
|
5
|
-
if (path.endsWith('.ts')) {
|
|
6
|
-
const fullPath = resolveFileExtension(path);
|
|
7
|
-
path = await transpileTs(fullPath, { rootDir, cacheDir: libPath.join(cacheDir, 'services') });
|
|
8
|
-
}
|
|
9
|
-
const moduleEntry = await import(path);
|
|
10
|
-
return moduleEntry.default || moduleEntry;
|
|
11
|
-
}
|
|
12
|
-
catch (err) {
|
|
13
|
-
console.log(err);
|
|
14
|
-
throw new Error(`Unable to get Service: ${path}`);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
// Parse the service constructors and instantiate them
|
|
18
|
-
export async function getServices(services, providerContext, lwrConfig) {
|
|
19
|
-
return Promise.all(services.map(async (serviceEntry) => {
|
|
20
|
-
const [serviceName, serviceConfig = {}] = Array.isArray(serviceEntry)
|
|
21
|
-
? serviceEntry
|
|
22
|
-
: [serviceEntry];
|
|
23
|
-
const ServiceCtor = await getServiceModule(serviceName, lwrConfig);
|
|
24
|
-
return new ServiceCtor(serviceConfig, providerContext);
|
|
25
|
-
}));
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=services.js.map
|