@lwrjs/core 0.10.0-alpha.20 → 0.10.0-alpha.22

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.
@@ -102,10 +102,12 @@ function createConfigMiddleware(routes, context, viewHandler) {
102
102
  return;
103
103
  }
104
104
  const url = (0, import_shared_utils.decodeViewPath)(encodedViewPath);
105
+ const originalUrl = req.originalUrl;
105
106
  const requestPath = route.path;
106
107
  const params = (0, import_shared_utils.extractRequestParams)(requestPath, url, req.params);
107
108
  const viewRequest = {
108
109
  url,
110
+ originalUrl,
109
111
  params,
110
112
  query: req.query,
111
113
  requestPath
@@ -396,11 +396,24 @@ var SiteGenerator = class {
396
396
  try {
397
397
  const assetSrcFile = asset.file;
398
398
  const assetSrcDir = asset.dir;
399
+ const isRootConfig = asset.root;
399
400
  const urlPath = asset.urlPath;
400
401
  const assetsPath = (0, import_path.join)(outputDir, basePath ? basePath + urlPath : urlPath);
401
402
  if (assetSrcDir && import_fs_extra.default.existsSync(assetSrcDir)) {
402
- import_fs_extra.default.copySync(assetSrcDir, assetsPath);
403
- this.addAssetsToMetadata(assetsPath, siteConfig);
403
+ if (isRootConfig) {
404
+ const files = import_fs_extra.default.readdirSync(assetSrcDir);
405
+ for (const file of files) {
406
+ const filePath = (0, import_path.join)(assetSrcDir, file);
407
+ if (import_fs_extra.default.statSync(filePath).isFile()) {
408
+ const fileDestPath = (0, import_path.join)(assetsPath, file);
409
+ import_fs_extra.default.copySync(filePath, fileDestPath);
410
+ this.addAssetToMetadata(fileDestPath, siteConfig);
411
+ }
412
+ }
413
+ } else {
414
+ import_fs_extra.default.copySync(assetSrcDir, assetsPath);
415
+ this.addAssetsToMetadata(assetsPath, siteConfig);
416
+ }
404
417
  } else if (assetSrcFile && import_fs_extra.default.existsSync(assetSrcFile)) {
405
418
  import_fs_extra.default.copySync(assetSrcFile, assetsPath);
406
419
  this.addAssetToMetadata(assetsPath, siteConfig);
@@ -408,7 +421,8 @@ var SiteGenerator = class {
408
421
  import_shared_utils.logger.warn("[SSG] Could not find assets to copy at path: " + assetsPath);
409
422
  }
410
423
  } catch (e) {
411
- import_shared_utils.logger.error("[SSG] Error occurred processing asset config: " + JSON.stringify(asset), e);
424
+ import_shared_utils.logger.error("[SSG] Error occurred processing asset config: " + JSON.stringify(asset));
425
+ import_shared_utils.logger.error(e);
412
426
  }
413
427
  }
414
428
  await siteConfig.siteMetadata?.persistSiteMetadata();
@@ -82,10 +82,12 @@ function createConfigMiddleware(routes, context, viewHandler) {
82
82
  }
83
83
  // decode the resolved view path and extract any params.
84
84
  const url = decodeViewPath(encodedViewPath);
85
+ const originalUrl = req.originalUrl;
85
86
  const requestPath = route.path;
86
87
  const params = extractRequestParams(requestPath, url, req.params);
87
88
  const viewRequest = {
88
89
  url,
90
+ originalUrl,
89
91
  params,
90
92
  query: req.query,
91
93
  requestPath,
@@ -554,11 +554,27 @@ export default class SiteGenerator {
554
554
  try {
555
555
  const assetSrcFile = asset.file;
556
556
  const assetSrcDir = asset.dir;
557
+ const isRootConfig = asset.root;
557
558
  const urlPath = asset.urlPath;
558
559
  const assetsPath = join(outputDir, basePath ? basePath + urlPath : urlPath);
559
560
  if (assetSrcDir && fs.existsSync(assetSrcDir)) {
560
- fs.copySync(assetSrcDir, assetsPath);
561
- this.addAssetsToMetadata(assetsPath, siteConfig);
561
+ // If this is a root folder we do not want to recurse sub directories.
562
+ if (isRootConfig) {
563
+ const files = fs.readdirSync(assetSrcDir);
564
+ for (const file of files) {
565
+ const filePath = join(assetSrcDir, file);
566
+ if (fs.statSync(filePath).isFile()) {
567
+ const fileDestPath = join(assetsPath, file);
568
+ fs.copySync(filePath, fileDestPath);
569
+ this.addAssetToMetadata(fileDestPath, siteConfig);
570
+ }
571
+ }
572
+ }
573
+ else {
574
+ // else copy the source to the ssg root and then add the ssg paths to the metadata
575
+ fs.copySync(assetSrcDir, assetsPath);
576
+ this.addAssetsToMetadata(assetsPath, siteConfig);
577
+ }
562
578
  }
563
579
  else if (assetSrcFile && fs.existsSync(assetSrcFile)) {
564
580
  fs.copySync(assetSrcFile, assetsPath);
@@ -569,7 +585,8 @@ export default class SiteGenerator {
569
585
  }
570
586
  }
571
587
  catch (e) {
572
- logger.error('[SSG] Error occurred processing asset config: ' + JSON.stringify(asset), e);
588
+ logger.error('[SSG] Error occurred processing asset config: ' + JSON.stringify(asset));
589
+ logger.error(e);
573
590
  }
574
591
  }
575
592
  await siteConfig.siteMetadata?.persistSiteMetadata();
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.10.0-alpha.20",
7
+ "version": "0.10.0-alpha.22",
8
8
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
@@ -39,32 +39,31 @@
39
39
  "build": "tsc -b"
40
40
  },
41
41
  "dependencies": {
42
- "@locker/compiler": "0.19.5",
43
- "@lwrjs/app-service": "0.10.0-alpha.20",
44
- "@lwrjs/asset-registry": "0.10.0-alpha.20",
45
- "@lwrjs/asset-transformer": "0.10.0-alpha.20",
46
- "@lwrjs/base-view-provider": "0.10.0-alpha.20",
47
- "@lwrjs/base-view-transformer": "0.10.0-alpha.20",
48
- "@lwrjs/client-modules": "0.10.0-alpha.20",
49
- "@lwrjs/config": "0.10.0-alpha.20",
50
- "@lwrjs/diagnostics": "0.10.0-alpha.20",
51
- "@lwrjs/fs-asset-provider": "0.10.0-alpha.20",
52
- "@lwrjs/html-view-provider": "0.10.0-alpha.20",
53
- "@lwrjs/instrumentation": "0.10.0-alpha.20",
54
- "@lwrjs/loader": "0.10.0-alpha.20",
55
- "@lwrjs/lwc-module-provider": "0.10.0-alpha.20",
56
- "@lwrjs/markdown-view-provider": "0.10.0-alpha.20",
57
- "@lwrjs/module-bundler": "0.10.0-alpha.20",
58
- "@lwrjs/module-registry": "0.10.0-alpha.20",
59
- "@lwrjs/npm-module-provider": "0.10.0-alpha.20",
60
- "@lwrjs/nunjucks-view-provider": "0.10.0-alpha.20",
61
- "@lwrjs/o11y": "0.10.0-alpha.20",
62
- "@lwrjs/resource-registry": "0.10.0-alpha.20",
63
- "@lwrjs/router": "0.10.0-alpha.20",
64
- "@lwrjs/server": "0.10.0-alpha.20",
65
- "@lwrjs/shared-utils": "0.10.0-alpha.20",
66
- "@lwrjs/static": "0.10.0-alpha.20",
67
- "@lwrjs/view-registry": "0.10.0-alpha.20",
42
+ "@lwrjs/app-service": "0.10.0-alpha.22",
43
+ "@lwrjs/asset-registry": "0.10.0-alpha.22",
44
+ "@lwrjs/asset-transformer": "0.10.0-alpha.22",
45
+ "@lwrjs/base-view-provider": "0.10.0-alpha.22",
46
+ "@lwrjs/base-view-transformer": "0.10.0-alpha.22",
47
+ "@lwrjs/client-modules": "0.10.0-alpha.22",
48
+ "@lwrjs/config": "0.10.0-alpha.22",
49
+ "@lwrjs/diagnostics": "0.10.0-alpha.22",
50
+ "@lwrjs/fs-asset-provider": "0.10.0-alpha.22",
51
+ "@lwrjs/html-view-provider": "0.10.0-alpha.22",
52
+ "@lwrjs/instrumentation": "0.10.0-alpha.22",
53
+ "@lwrjs/loader": "0.10.0-alpha.22",
54
+ "@lwrjs/lwc-module-provider": "0.10.0-alpha.22",
55
+ "@lwrjs/markdown-view-provider": "0.10.0-alpha.22",
56
+ "@lwrjs/module-bundler": "0.10.0-alpha.22",
57
+ "@lwrjs/module-registry": "0.10.0-alpha.22",
58
+ "@lwrjs/npm-module-provider": "0.10.0-alpha.22",
59
+ "@lwrjs/nunjucks-view-provider": "0.10.0-alpha.22",
60
+ "@lwrjs/o11y": "0.10.0-alpha.22",
61
+ "@lwrjs/resource-registry": "0.10.0-alpha.22",
62
+ "@lwrjs/router": "0.10.0-alpha.22",
63
+ "@lwrjs/server": "0.10.0-alpha.22",
64
+ "@lwrjs/shared-utils": "0.10.0-alpha.22",
65
+ "@lwrjs/static": "0.10.0-alpha.22",
66
+ "@lwrjs/view-registry": "0.10.0-alpha.22",
68
67
  "chokidar": "^3.5.3",
69
68
  "esbuild": "^0.9.7",
70
69
  "fs-extra": "^11.1.1",
@@ -74,11 +73,11 @@
74
73
  "ws": "^8.8.1"
75
74
  },
76
75
  "devDependencies": {
77
- "@lwrjs/types": "0.10.0-alpha.20",
76
+ "@lwrjs/types": "0.10.0-alpha.22",
78
77
  "@types/ws": "^8.5.3"
79
78
  },
80
79
  "peerDependencies": {
81
- "lwc": "2.x"
80
+ "lwc": "2.x || 3.x"
82
81
  },
83
82
  "engines": {
84
83
  "node": ">=16.0.0"
@@ -86,5 +85,5 @@
86
85
  "volta": {
87
86
  "extends": "../../../package.json"
88
87
  },
89
- "gitHead": "45a867fc54e98f77dd442ccd5f668e23027b9246"
88
+ "gitHead": "ef991388d9158dbca91656d7ec7c0a641b477f4f"
90
89
  }