@salesforce/plugin-lightning-dev 2.2.0 → 2.2.1
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/README.md +2 -2
- package/lib/lwc-dev-server/index.js +13 -55
- package/lib/lwc-dev-server/index.js.map +1 -1
- package/npm-shrinkwrap.json +595 -211
- package/oclif.lock +144 -57
- package/oclif.manifest.json +1 -1
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -200,7 +200,7 @@ EXAMPLES
|
|
|
200
200
|
$ sf lightning dev app --target-org myOrg --device-type ios --device-id "iPhone 15 Pro Max"
|
|
201
201
|
```
|
|
202
202
|
|
|
203
|
-
_See code: [src/commands/lightning/dev/app.ts](https://github.com/salesforcecli/plugin-lightning-dev/blob/2.2.
|
|
203
|
+
_See code: [src/commands/lightning/dev/app.ts](https://github.com/salesforcecli/plugin-lightning-dev/blob/2.2.1/src/commands/lightning/dev/app.ts)_
|
|
204
204
|
|
|
205
205
|
## `sf lightning dev site`
|
|
206
206
|
|
|
@@ -244,6 +244,6 @@ EXAMPLES
|
|
|
244
244
|
$ sf lightning dev site --name "Partner Central" --target-org myOrg
|
|
245
245
|
```
|
|
246
246
|
|
|
247
|
-
_See code: [src/commands/lightning/dev/site.ts](https://github.com/salesforcecli/plugin-lightning-dev/blob/2.2.
|
|
247
|
+
_See code: [src/commands/lightning/dev/site.ts](https://github.com/salesforcecli/plugin-lightning-dev/blob/2.2.1/src/commands/lightning/dev/site.ts)_
|
|
248
248
|
|
|
249
249
|
<!-- commandsstop -->
|
|
@@ -4,60 +4,18 @@
|
|
|
4
4
|
* Licensed under the BSD 3-Clause license.
|
|
5
5
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
6
|
*/
|
|
7
|
-
import { existsSync, lstatSync, readFileSync } from 'node:fs';
|
|
8
|
-
import path from 'node:path';
|
|
9
7
|
import process from 'node:process';
|
|
10
|
-
import {
|
|
11
|
-
import { Lifecycle } from '@salesforce/core';
|
|
8
|
+
import { startLwcDevServer } from '@lwc/lwc-dev-server';
|
|
9
|
+
import { Lifecycle, SfProject } from '@salesforce/core';
|
|
10
|
+
import { glob } from 'glob';
|
|
12
11
|
import { ConfigUtils, LOCAL_DEV_SERVER_DEFAULT_HTTP_PORT, LOCAL_DEV_SERVER_DEFAULT_WORKSPACE, } from '../shared/configUtils.js';
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
function mapLogLevel(cliLogLevel) {
|
|
21
|
-
switch (cliLogLevel) {
|
|
22
|
-
case 10:
|
|
23
|
-
return LogLevel.verbose;
|
|
24
|
-
case 20:
|
|
25
|
-
return LogLevel.debug;
|
|
26
|
-
case 30:
|
|
27
|
-
return LogLevel.info;
|
|
28
|
-
case 40:
|
|
29
|
-
return LogLevel.warn;
|
|
30
|
-
case 50:
|
|
31
|
-
return LogLevel.error;
|
|
32
|
-
case 60:
|
|
33
|
-
return LogLevel.silent;
|
|
34
|
-
default:
|
|
35
|
-
return LogLevel.error;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
async function createLWCServerConfig(logger, rootDir, token, clientType, serverPorts, certData, workspace) {
|
|
39
|
-
const sfdxConfig = path.resolve(rootDir, 'sfdx-project.json');
|
|
40
|
-
if (!existsSync(sfdxConfig) || !lstatSync(sfdxConfig).isFile()) {
|
|
41
|
-
throw new Error(`sfdx-project.json not found in ${rootDir}`);
|
|
42
|
-
}
|
|
43
|
-
const sfdxConfigJson = readFileSync(sfdxConfig, 'utf-8');
|
|
44
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
45
|
-
const { packageDirectories } = JSON.parse(sfdxConfigJson);
|
|
46
|
-
const namespacePaths = [];
|
|
47
|
-
for (const dir of packageDirectories) {
|
|
48
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
49
|
-
if (dir.path) {
|
|
50
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-argument
|
|
51
|
-
const resolvedDir = path.resolve(rootDir, dir.path, 'main', 'default');
|
|
52
|
-
if (existsSync(resolvedDir) && lstatSync(resolvedDir).isDirectory()) {
|
|
53
|
-
logger.debug(`Adding ${resolvedDir} to namespace paths`);
|
|
54
|
-
namespacePaths.push(resolvedDir);
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
logger.warn(`Skipping ${resolvedDir} because it does not exist or is not a directory`);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
12
|
+
async function createLWCServerConfig(rootDir, token, clientType, serverPorts, certData, workspace) {
|
|
13
|
+
const project = await SfProject.resolve();
|
|
14
|
+
const packageDirs = project.getPackageDirectories();
|
|
15
|
+
const projectJson = await project.resolveProjectConfig();
|
|
16
|
+
const { namespace } = projectJson;
|
|
17
|
+
// e.g. lwc folders in force-app/main/default/lwc, package-dir/lwc
|
|
18
|
+
const namespacePaths = (await Promise.all(packageDirs.map((dir) => glob(`${dir.fullPath}/**/lwc`)))).flat();
|
|
61
19
|
const ports = serverPorts ??
|
|
62
20
|
(await ConfigUtils.getLocalDevServerPorts()) ?? {
|
|
63
21
|
httpPort: LOCAL_DEV_SERVER_DEFAULT_HTTP_PORT,
|
|
@@ -71,9 +29,9 @@ async function createLWCServerConfig(logger, rootDir, token, clientType, serverP
|
|
|
71
29
|
// use custom workspace if any is provided, or fetch from config file (if any), otherwise use the default workspace
|
|
72
30
|
workspace: workspace ?? (await ConfigUtils.getLocalDevServerWorkspace()) ?? LOCAL_DEV_SERVER_DEFAULT_WORKSPACE,
|
|
73
31
|
identityToken: token,
|
|
74
|
-
logLevel: mapLogLevel(logger.getLevel()),
|
|
75
32
|
lifecycle: Lifecycle.getInstance(),
|
|
76
33
|
clientType,
|
|
34
|
+
namespace: typeof namespace === 'string' && namespace.trim().length > 0 ? namespace.trim() : undefined,
|
|
77
35
|
};
|
|
78
36
|
if (certData?.pemCertificate && certData.pemPrivateKey) {
|
|
79
37
|
serverConfig.https = {
|
|
@@ -85,9 +43,9 @@ async function createLWCServerConfig(logger, rootDir, token, clientType, serverP
|
|
|
85
43
|
return serverConfig;
|
|
86
44
|
}
|
|
87
45
|
export async function startLWCServer(logger, rootDir, token, clientType, serverPorts, certData, workspace) {
|
|
88
|
-
const config = await createLWCServerConfig(
|
|
46
|
+
const config = await createLWCServerConfig(rootDir, token, clientType, serverPorts, certData, workspace);
|
|
89
47
|
logger.trace(`Starting LWC Dev Server with config: ${JSON.stringify(config)}`);
|
|
90
|
-
let lwcDevServer = await startLwcDevServer(config);
|
|
48
|
+
let lwcDevServer = await startLwcDevServer(config, logger);
|
|
91
49
|
const cleanup = () => {
|
|
92
50
|
if (lwcDevServer) {
|
|
93
51
|
logger.trace('Stopping LWC Dev Server');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lwc-dev-server/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lwc-dev-server/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAA2B,iBAAiB,EAAa,MAAM,qBAAqB,CAAC;AAC5F,OAAO,EAAE,SAAS,EAAU,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAEhE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EACL,WAAW,EACX,kCAAkC,EAClC,kCAAkC,GACnC,MAAM,0BAA0B,CAAC;AAElC,KAAK,UAAU,qBAAqB,CAClC,OAAe,EACf,KAAa,EACb,UAAkB,EAClB,WAAqD,EACrD,QAA6B,EAC7B,SAAqB;IAErB,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,OAAO,EAAE,CAAC;IAC1C,MAAM,WAAW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