@salesforce/plugin-lightning-dev 1.0.26-alpha.0
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/LICENSE.txt +12 -0
- package/README.md +225 -0
- package/lib/commands/lightning/dev/app.d.ts +29 -0
- package/lib/commands/lightning/dev/app.js +288 -0
- package/lib/commands/lightning/dev/app.js.map +1 -0
- package/lib/commands/lightning/dev/site.d.ts +12 -0
- package/lib/commands/lightning/dev/site.js +77 -0
- package/lib/commands/lightning/dev/site.js.map +1 -0
- package/lib/configMeta.d.ts +28 -0
- package/lib/configMeta.js +74 -0
- package/lib/configMeta.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +8 -0
- package/lib/index.js.map +1 -0
- package/lib/lwc-dev-server/index.d.ts +7 -0
- package/lib/lwc-dev-server/index.js +102 -0
- package/lib/lwc-dev-server/index.js.map +1 -0
- package/lib/shared/configUtils.d.ts +27 -0
- package/lib/shared/configUtils.js +108 -0
- package/lib/shared/configUtils.js.map +1 -0
- package/lib/shared/experience/expSite.d.ts +70 -0
- package/lib/shared/experience/expSite.js +200 -0
- package/lib/shared/experience/expSite.js.map +1 -0
- package/lib/shared/orgUtils.d.ts +14 -0
- package/lib/shared/orgUtils.js +36 -0
- package/lib/shared/orgUtils.js.map +1 -0
- package/lib/shared/previewUtils.d.ts +126 -0
- package/lib/shared/previewUtils.js +397 -0
- package/lib/shared/previewUtils.js.map +1 -0
- package/lib/shared/prompt.d.ts +4 -0
- package/lib/shared/prompt.js +25 -0
- package/lib/shared/prompt.js.map +1 -0
- package/messages/lightning.dev.app.md +171 -0
- package/messages/lightning.dev.site.md +37 -0
- package/messages/shared.utils.md +27 -0
- package/npm-shrinkwrap.json +29260 -0
- package/oclif.lock +15886 -0
- package/oclif.manifest.json +174 -0
- package/package.json +226 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023, salesforce.com, inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* Licensed under the BSD 3-Clause license.
|
|
5
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
*/
|
|
7
|
+
import fs from 'node:fs';
|
|
8
|
+
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
9
|
+
import { Messages } from '@salesforce/core';
|
|
10
|
+
import { expDev } from '@lwrjs/api';
|
|
11
|
+
import { PromptUtils } from '../../../shared/prompt.js';
|
|
12
|
+
import { ExperienceSite } from '../../../shared/experience/expSite.js';
|
|
13
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
14
|
+
const messages = Messages.loadMessages('@salesforce/plugin-lightning-dev', 'lightning.dev.site');
|
|
15
|
+
export default class LightningDevSite extends SfCommand {
|
|
16
|
+
static summary = messages.getMessage('summary');
|
|
17
|
+
static description = messages.getMessage('description');
|
|
18
|
+
static examples = messages.getMessages('examples');
|
|
19
|
+
static flags = {
|
|
20
|
+
name: Flags.string({
|
|
21
|
+
summary: messages.getMessage('flags.name.summary'),
|
|
22
|
+
char: 'n',
|
|
23
|
+
required: false,
|
|
24
|
+
}),
|
|
25
|
+
debug: Flags.boolean({
|
|
26
|
+
summary: messages.getMessage('flags.debug.summary'),
|
|
27
|
+
}),
|
|
28
|
+
'target-org': Flags.optionalOrg({ summary: messages.getMessage('flags.target-org.summary') }),
|
|
29
|
+
};
|
|
30
|
+
async run() {
|
|
31
|
+
const { flags } = await this.parse(LightningDevSite);
|
|
32
|
+
try {
|
|
33
|
+
const org = flags['target-org'];
|
|
34
|
+
let siteName = flags.name;
|
|
35
|
+
// If user doesn't specify a site, prompt the user for one
|
|
36
|
+
if (!siteName) {
|
|
37
|
+
const allSites = await ExperienceSite.getAllExpSites(org);
|
|
38
|
+
siteName = await PromptUtils.promptUserToSelectSite(allSites);
|
|
39
|
+
}
|
|
40
|
+
const selectedSite = new ExperienceSite(org, siteName);
|
|
41
|
+
let siteZip;
|
|
42
|
+
if (!selectedSite.isSiteSetup()) {
|
|
43
|
+
this.log(`[local-dev] initializing: ${siteName}`);
|
|
44
|
+
siteZip = await selectedSite.downloadSite();
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
// If local-dev is already setup, check if an updated site has been published to download
|
|
48
|
+
const updateAvailable = await selectedSite.isUpdateAvailable();
|
|
49
|
+
if (updateAvailable) {
|
|
50
|
+
const shouldUpdate = await PromptUtils.promptUserToConfirmUpdate(siteName);
|
|
51
|
+
if (shouldUpdate) {
|
|
52
|
+
this.log(`[local-dev] updating: ${siteName}`);
|
|
53
|
+
siteZip = await selectedSite.downloadSite();
|
|
54
|
+
// delete oldSitePath recursive
|
|
55
|
+
const oldSitePath = selectedSite.getExtractDirectory();
|
|
56
|
+
if (fs.existsSync(oldSitePath)) {
|
|
57
|
+
fs.rmdirSync(oldSitePath, { recursive: true });
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// Start the dev server
|
|
63
|
+
await expDev({
|
|
64
|
+
open: true,
|
|
65
|
+
port: 3000,
|
|
66
|
+
logLevel: 'error',
|
|
67
|
+
mode: 'dev',
|
|
68
|
+
siteZip,
|
|
69
|
+
siteDir: selectedSite.getSiteDirectory(),
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
catch (e) {
|
|
73
|
+
this.log('Local Development setup failed', e);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=site.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"site.js","sourceRoot":"","sources":["../../../../src/commands/lightning/dev/site.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC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,EAAE,OAAO;gBACjB,IAAI,EAAE,KAAK;gBACX,OAAO;gBACP,OAAO,EAAE,YAAY,CAAC,gBAAgB,EAAE;aACzC,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,IAAI,CAAC,GAAG,CAAC,gCAAgC,EAAE,CAAC,CAAC,CAAC;QAChD,CAAC;IACH,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ConfigPropertyMeta } from '@salesforce/core';
|
|
2
|
+
export type SerializedSSLCertificateData = {
|
|
3
|
+
derCertificate: string;
|
|
4
|
+
pemCertificate: string;
|
|
5
|
+
pemPrivateKey: string;
|
|
6
|
+
pemPublicKey: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const enum ConfigVars {
|
|
9
|
+
/**
|
|
10
|
+
* The identity data is a data structure that links the local web server's
|
|
11
|
+
* identity token to the user's configured Salesforce orgs.
|
|
12
|
+
*/
|
|
13
|
+
LOCAL_WEB_SERVER_IDENTITY_DATA = "local-web-server-identity-data",
|
|
14
|
+
/**
|
|
15
|
+
* The SSL certificate data to be used by local dev server
|
|
16
|
+
*/
|
|
17
|
+
LOCAL_DEV_SERVER_HTTPS_CERT_DATA = "local-dev-server-certificate-data",
|
|
18
|
+
/**
|
|
19
|
+
* The port number of the local dev server.
|
|
20
|
+
*/
|
|
21
|
+
LOCAL_DEV_SERVER_PORT = "local-dev-server-port",
|
|
22
|
+
/**
|
|
23
|
+
* The Workspace name of the local dev server.
|
|
24
|
+
*/
|
|
25
|
+
LOCAL_DEV_SERVER_WORKSPACE = "local-dev-server-workspace"
|
|
26
|
+
}
|
|
27
|
+
declare const _default: ConfigPropertyMeta[];
|
|
28
|
+
export default _default;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024, salesforce.com, inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* Licensed under the BSD 3-Clause license.
|
|
5
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
*/
|
|
7
|
+
import { Workspace } from '@lwc/lwc-dev-server';
|
|
8
|
+
import { Messages } from '@salesforce/core';
|
|
9
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
10
|
+
const messages = Messages.loadMessages('@salesforce/plugin-lightning-dev', 'shared.utils');
|
|
11
|
+
const IDENTITY_DATA_DESC = messages.getMessage('config-utils.data-desc');
|
|
12
|
+
const LOCAL_DEV_SERVER_CERT_DESC = messages.getMessage('config-utils.cert-desc');
|
|
13
|
+
const LOCAL_DEV_SERVER_CERT_ERROR_MESSAGE = messages.getMessage('config-utils.cert-error-message');
|
|
14
|
+
const LOCAL_DEV_SERVER_PORT_DESC = messages.getMessage('config-utils.port-desc');
|
|
15
|
+
const LOCAL_DEV_SERVER_PORT_ERROR_MESSAGE = messages.getMessage('config-utils.port-error-message');
|
|
16
|
+
const LOCAL_DEV_SERVER_WORKSPACE_DESC = messages.getMessage('config-utils.workspace-desc');
|
|
17
|
+
const LOCAL_DEV_SERVER_WORKSPACE_ERROR_MESSAGE = messages.getMessage('config-utils.workspace-error-message');
|
|
18
|
+
export default [
|
|
19
|
+
{
|
|
20
|
+
key: "local-web-server-identity-data" /* ConfigVars.LOCAL_WEB_SERVER_IDENTITY_DATA */,
|
|
21
|
+
description: IDENTITY_DATA_DESC,
|
|
22
|
+
hidden: true,
|
|
23
|
+
encrypted: true,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
key: "local-dev-server-certificate-data" /* ConfigVars.LOCAL_DEV_SERVER_HTTPS_CERT_DATA */,
|
|
27
|
+
description: LOCAL_DEV_SERVER_CERT_DESC,
|
|
28
|
+
input: {
|
|
29
|
+
validator: (value) => {
|
|
30
|
+
const data = value;
|
|
31
|
+
if (!data?.derCertificate || !data?.pemCertificate || !data?.pemPrivateKey) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
return true;
|
|
35
|
+
},
|
|
36
|
+
failedMessage: LOCAL_DEV_SERVER_CERT_ERROR_MESSAGE,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
key: "local-dev-server-port" /* ConfigVars.LOCAL_DEV_SERVER_PORT */,
|
|
41
|
+
description: LOCAL_DEV_SERVER_PORT_DESC,
|
|
42
|
+
input: {
|
|
43
|
+
validator: (value) => {
|
|
44
|
+
if (!value) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
const parsedPort = parseInt(value, 10);
|
|
48
|
+
if (isNaN(parsedPort) || parsedPort < 1 || parsedPort > 65_535) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
return true;
|
|
52
|
+
},
|
|
53
|
+
failedMessage: LOCAL_DEV_SERVER_PORT_ERROR_MESSAGE,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
key: "local-dev-server-workspace" /* ConfigVars.LOCAL_DEV_SERVER_WORKSPACE */,
|
|
58
|
+
description: LOCAL_DEV_SERVER_WORKSPACE_DESC,
|
|
59
|
+
input: {
|
|
60
|
+
validator: (value) => {
|
|
61
|
+
if (!value) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
const workspace = value;
|
|
65
|
+
if (workspace === Workspace.SfCli || workspace === Workspace.Mrt) {
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
return false;
|
|
69
|
+
},
|
|
70
|
+
failedMessage: LOCAL_DEV_SERVER_WORKSPACE_ERROR_MESSAGE,
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
];
|
|
74
|
+
//# sourceMappingURL=configMeta.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configMeta.js","sourceRoot":"","sources":["../src/configMeta.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAmC,QAA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BAA0B;QACvC,KAAK,EAAE;YACL,SAAS,EAAE,CAAC,KAAkB,EAAW,EAAE;gBACzC,IAAI,CAAC,KAAK,EAAE,CAAC;oBACX,OAAO,KAAK,CAAC;gBACf,CAAC;gBAED,MAAM,UAAU,GAAG,QAAQ,CAAC,KAAe,EAAE,EAAE,CAAC,CAAC;gBAEjD,IAAI,KAAK,CAAC,UAAU,CAAC,IAAI,UAAU,GAAG,CAAC,IAAI,UAAU,GAAG,MAAM,EAAE,CAAC;oBAC/D,OAAO,KAAK,CAAC;gBACf,CAAC;gBACD,OAAO,IAAI,CAAC;YACd,CAAC;YACD,aAAa,EAAE,mCAAmC;SACnD;KACF;IACD;QACE,GAAG,0EAAuC;QAC1C,WAAW,EAAE,+BAA+B;QAC5C,KAAK,EAAE;YACL,SAAS,EAAE,CAAC,KAAkB,EAAW,EAAE;gBACzC,IAAI,CAAC,KAAK,EAAE,CAAC;oBACX,OAAO,KAAK,CAAC;gBACf,CAAC;gBAED,MAAM,SAAS,GAAG,KAAkB,CAAC;gBAErC,IAAI,SAAS,KAAK,SAAS,CAAC,KAAK,IAAI,SAAS,KAAK,SAAS,CAAC,GAAG,EAAE,CAAC;oBACjE,OAAO,IAAI,CAAC;gBACd,CAAC;gBACD,OAAO,KAAK,CAAC;YACf,CAAC;YACD,aAAa,EAAE,wCAAwC;SACxD;KACF;CACsB,CAAC"}
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021, salesforce.com, inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* Licensed under the BSD 3-Clause license.
|
|
5
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
*/
|
|
7
|
+
export default {};
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { LWCServer, Workspace } from '@lwc/lwc-dev-server';
|
|
2
|
+
import { Logger } from '@salesforce/core';
|
|
3
|
+
import { SSLCertificateData } from '@salesforce/lwc-dev-mobile-core';
|
|
4
|
+
export declare function startLWCServer(logger: Logger, rootDir: string, token: string, serverPorts?: {
|
|
5
|
+
httpPort: number;
|
|
6
|
+
httpsPort: number;
|
|
7
|
+
}, certData?: SSLCertificateData, workspace?: Workspace): Promise<LWCServer>;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023, salesforce.com, inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* Licensed under the BSD 3-Clause license.
|
|
5
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
*/
|
|
7
|
+
import { existsSync, lstatSync, readFileSync } from 'node:fs';
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
import process from 'node:process';
|
|
10
|
+
import { LogLevel, startLwcDevServer } from '@lwc/lwc-dev-server';
|
|
11
|
+
import { ConfigUtils, LOCAL_DEV_SERVER_DEFAULT_HTTP_PORT, LOCAL_DEV_SERVER_DEFAULT_WORKSPACE, } from '../shared/configUtils.js';
|
|
12
|
+
/**
|
|
13
|
+
* Map sf cli log level to lwc dev server log level
|
|
14
|
+
* https://github.com/salesforcecli/cli/wiki/Code-Your-Plugin#logging-levels
|
|
15
|
+
*
|
|
16
|
+
* @param cliLogLevel
|
|
17
|
+
* @returns number
|
|
18
|
+
*/
|
|
19
|
+
function mapLogLevel(cliLogLevel) {
|
|
20
|
+
switch (cliLogLevel) {
|
|
21
|
+
case 10:
|
|
22
|
+
return LogLevel.verbose;
|
|
23
|
+
case 20:
|
|
24
|
+
return LogLevel.debug;
|
|
25
|
+
case 30:
|
|
26
|
+
return LogLevel.info;
|
|
27
|
+
case 40:
|
|
28
|
+
return LogLevel.warn;
|
|
29
|
+
case 50:
|
|
30
|
+
return LogLevel.error;
|
|
31
|
+
case 60:
|
|
32
|
+
return LogLevel.silent;
|
|
33
|
+
default:
|
|
34
|
+
return LogLevel.error;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
async function createLWCServerConfig(logger, rootDir, token, serverPorts, certData, workspace) {
|
|
38
|
+
const sfdxConfig = path.resolve(rootDir, 'sfdx-project.json');
|
|
39
|
+
if (!existsSync(sfdxConfig) || !lstatSync(sfdxConfig).isFile()) {
|
|
40
|
+
throw new Error(`sfdx-project.json not found in ${rootDir}`);
|
|
41
|
+
}
|
|
42
|
+
const sfdxConfigJson = readFileSync(sfdxConfig, 'utf-8');
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
44
|
+
const { packageDirectories } = JSON.parse(sfdxConfigJson);
|
|
45
|
+
const namespacePaths = [];
|
|
46
|
+
for (const dir of packageDirectories) {
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
48
|
+
if (dir.path) {
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-argument
|
|
50
|
+
const resolvedDir = path.resolve(rootDir, dir.path, 'main', 'default');
|
|
51
|
+
if (existsSync(resolvedDir) && lstatSync(resolvedDir).isDirectory()) {
|
|
52
|
+
logger.debug(`Adding ${resolvedDir} to namespace paths`);
|
|
53
|
+
namespacePaths.push(resolvedDir);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
logger.warn(`Skipping ${resolvedDir} because it does not exist or is not a directory`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const ports = serverPorts ??
|
|
61
|
+
(await ConfigUtils.getLocalDevServerPorts()) ?? {
|
|
62
|
+
httpPort: LOCAL_DEV_SERVER_DEFAULT_HTTP_PORT,
|
|
63
|
+
httpsPort: LOCAL_DEV_SERVER_DEFAULT_HTTP_PORT + 1,
|
|
64
|
+
};
|
|
65
|
+
const serverConfig = {
|
|
66
|
+
rootDir,
|
|
67
|
+
// use custom port if any is provided, or fetch from config file (if any), otherwise use the default port
|
|
68
|
+
port: ports.httpPort,
|
|
69
|
+
paths: namespacePaths,
|
|
70
|
+
// use custom workspace if any is provided, or fetch from config file (if any), otherwise use the default workspace
|
|
71
|
+
workspace: workspace ?? (await ConfigUtils.getLocalDevServerWorkspace()) ?? LOCAL_DEV_SERVER_DEFAULT_WORKSPACE,
|
|
72
|
+
identityToken: token,
|
|
73
|
+
logLevel: mapLogLevel(logger.getLevel()),
|
|
74
|
+
};
|
|
75
|
+
if (certData?.pemCertificate && certData.pemPrivateKey) {
|
|
76
|
+
serverConfig.https = {
|
|
77
|
+
cert: certData.pemCertificate,
|
|
78
|
+
key: certData.pemPrivateKey,
|
|
79
|
+
port: ports.httpsPort,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
return serverConfig;
|
|
83
|
+
}
|
|
84
|
+
export async function startLWCServer(logger, rootDir, token, serverPorts, certData, workspace) {
|
|
85
|
+
const config = await createLWCServerConfig(logger, rootDir, token, serverPorts, certData, workspace);
|
|
86
|
+
logger.trace(`Starting LWC Dev Server with config: ${JSON.stringify(config)}`);
|
|
87
|
+
let lwcDevServer = await startLwcDevServer(config);
|
|
88
|
+
const cleanup = () => {
|
|
89
|
+
if (lwcDevServer) {
|
|
90
|
+
logger.trace('Stopping LWC Dev Server');
|
|
91
|
+
lwcDevServer.stopServer();
|
|
92
|
+
lwcDevServer = null;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
[
|
|
96
|
+
'exit', // normal exit flow
|
|
97
|
+
'SIGINT', // when a user presses ctrl+c
|
|
98
|
+
'SIGTERM', // when a user kills the process
|
|
99
|
+
].forEach((signal) => process.on(signal, cleanup));
|
|
100
|
+
return lwcDevServer;
|
|
101
|
+
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from '@lwc/lwc-dev-server';
|
|
2
|
+
import { SSLCertificateData } from '@salesforce/lwc-dev-mobile-core';
|
|
3
|
+
import { Config } from '@salesforce/core';
|
|
4
|
+
export type IdentityTokenService = {
|
|
5
|
+
saveTokenToServer(token: string): Promise<string>;
|
|
6
|
+
};
|
|
7
|
+
export declare const LOCAL_DEV_SERVER_DEFAULT_HTTP_PORT = 8081;
|
|
8
|
+
export declare const LOCAL_DEV_SERVER_DEFAULT_WORKSPACE = Workspace.SfCli;
|
|
9
|
+
export type LocalWebServerIdentityData = {
|
|
10
|
+
identityToken: string;
|
|
11
|
+
usernameToServerEntityIdMap: Record<string, string>;
|
|
12
|
+
};
|
|
13
|
+
export declare class ConfigUtils {
|
|
14
|
+
#private;
|
|
15
|
+
static getLocalConfig(): Promise<Config>;
|
|
16
|
+
static getGlobalConfig(): Promise<Config>;
|
|
17
|
+
static getOrCreateIdentityToken(username: string, tokenService: IdentityTokenService): Promise<string>;
|
|
18
|
+
static writeIdentityData(identityData: LocalWebServerIdentityData): Promise<void>;
|
|
19
|
+
static getCertData(): Promise<SSLCertificateData | undefined>;
|
|
20
|
+
static writeCertData(data: SSLCertificateData): Promise<void>;
|
|
21
|
+
static getLocalDevServerPorts(): Promise<{
|
|
22
|
+
httpPort: number;
|
|
23
|
+
httpsPort: number;
|
|
24
|
+
} | undefined>;
|
|
25
|
+
static getLocalDevServerWorkspace(): Promise<Workspace | undefined>;
|
|
26
|
+
static getIdentityData(): Promise<LocalWebServerIdentityData | undefined>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024, salesforce.com, inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* Licensed under the BSD 3-Clause license.
|
|
5
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
*/
|
|
7
|
+
import { Workspace } from '@lwc/lwc-dev-server';
|
|
8
|
+
import { CryptoUtils } from '@salesforce/lwc-dev-mobile-core';
|
|
9
|
+
import { Config, ConfigAggregator } from '@salesforce/core';
|
|
10
|
+
import configMeta from './../configMeta.js';
|
|
11
|
+
export const LOCAL_DEV_SERVER_DEFAULT_HTTP_PORT = 8081;
|
|
12
|
+
export const LOCAL_DEV_SERVER_DEFAULT_WORKSPACE = Workspace.SfCli;
|
|
13
|
+
export class ConfigUtils {
|
|
14
|
+
static #localConfig;
|
|
15
|
+
static #globalConfig;
|
|
16
|
+
static async getLocalConfig() {
|
|
17
|
+
if (this.#localConfig) {
|
|
18
|
+
return this.#localConfig;
|
|
19
|
+
}
|
|
20
|
+
this.#localConfig = await Config.create({ isGlobal: false });
|
|
21
|
+
Config.addAllowedProperties(configMeta);
|
|
22
|
+
return this.#localConfig;
|
|
23
|
+
}
|
|
24
|
+
static async getGlobalConfig() {
|
|
25
|
+
if (this.#globalConfig) {
|
|
26
|
+
return this.#globalConfig;
|
|
27
|
+
}
|
|
28
|
+
this.#globalConfig = await Config.create({ isGlobal: true });
|
|
29
|
+
Config.addAllowedProperties(configMeta);
|
|
30
|
+
return this.#globalConfig;
|
|
31
|
+
}
|
|
32
|
+
static async getOrCreateIdentityToken(username, tokenService) {
|
|
33
|
+
let identityData = await this.getIdentityData();
|
|
34
|
+
if (!identityData) {
|
|
35
|
+
const token = CryptoUtils.generateIdentityToken();
|
|
36
|
+
const entityId = await tokenService.saveTokenToServer(token);
|
|
37
|
+
identityData = {
|
|
38
|
+
identityToken: token,
|
|
39
|
+
usernameToServerEntityIdMap: {},
|
|
40
|
+
};
|
|
41
|
+
identityData.usernameToServerEntityIdMap[username] = entityId;
|
|
42
|
+
await this.writeIdentityData(identityData);
|
|
43
|
+
return token;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
let entityId = identityData.usernameToServerEntityIdMap[username];
|
|
47
|
+
if (!entityId) {
|
|
48
|
+
entityId = await tokenService.saveTokenToServer(identityData.identityToken);
|
|
49
|
+
identityData.usernameToServerEntityIdMap[username] = entityId;
|
|
50
|
+
await this.writeIdentityData(identityData);
|
|
51
|
+
}
|
|
52
|
+
return identityData.identityToken;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
static async writeIdentityData(identityData) {
|
|
56
|
+
const config = await this.getLocalConfig();
|
|
57
|
+
// TODO: JSON needs to be stringified in order for config.write to encrypt. When config.write()
|
|
58
|
+
// can encrypt JSON data to write it into config we shall remove stringify().
|
|
59
|
+
config.set("local-web-server-identity-data" /* ConfigVars.LOCAL_WEB_SERVER_IDENTITY_DATA */, JSON.stringify(identityData));
|
|
60
|
+
await config.write();
|
|
61
|
+
}
|
|
62
|
+
static async getCertData() {
|
|
63
|
+
const config = await this.getGlobalConfig();
|
|
64
|
+
const serializedData = config.get("local-dev-server-certificate-data" /* ConfigVars.LOCAL_DEV_SERVER_HTTPS_CERT_DATA */);
|
|
65
|
+
if (serializedData) {
|
|
66
|
+
const deserializedData = {
|
|
67
|
+
derCertificate: Buffer.from(serializedData.derCertificate, 'base64'),
|
|
68
|
+
pemCertificate: serializedData.pemCertificate,
|
|
69
|
+
pemPrivateKey: serializedData.pemPrivateKey,
|
|
70
|
+
pemPublicKey: serializedData.pemPublicKey,
|
|
71
|
+
};
|
|
72
|
+
return deserializedData;
|
|
73
|
+
}
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
static async writeCertData(data) {
|
|
77
|
+
const config = await this.getGlobalConfig();
|
|
78
|
+
const serializedData = {
|
|
79
|
+
derCertificate: data.derCertificate.toString('base64'),
|
|
80
|
+
pemCertificate: data.pemCertificate,
|
|
81
|
+
pemPrivateKey: data.pemPrivateKey,
|
|
82
|
+
pemPublicKey: data.pemPublicKey,
|
|
83
|
+
};
|
|
84
|
+
config.set("local-dev-server-certificate-data" /* ConfigVars.LOCAL_DEV_SERVER_HTTPS_CERT_DATA */, serializedData);
|
|
85
|
+
await config.write();
|
|
86
|
+
}
|
|
87
|
+
static async getLocalDevServerPorts() {
|
|
88
|
+
const config = await this.getLocalConfig();
|
|
89
|
+
const ports = config.get("local-dev-server-port" /* ConfigVars.LOCAL_DEV_SERVER_PORT */);
|
|
90
|
+
return ports;
|
|
91
|
+
}
|
|
92
|
+
static async getLocalDevServerWorkspace() {
|
|
93
|
+
const config = await this.getLocalConfig();
|
|
94
|
+
const configWorkspace = config.get("local-dev-server-workspace" /* ConfigVars.LOCAL_DEV_SERVER_WORKSPACE */);
|
|
95
|
+
return configWorkspace;
|
|
96
|
+
}
|
|
97
|
+
static async getIdentityData() {
|
|
98
|
+
const config = await ConfigAggregator.create({ customConfigMeta: configMeta });
|
|
99
|
+
// Need to reload to make sure the values read are decrypted
|
|
100
|
+
await config.reload();
|
|
101
|
+
const identityJson = config.getPropertyValue("local-web-server-identity-data" /* ConfigVars.LOCAL_WEB_SERVER_IDENTITY_DATA */);
|
|
102
|
+
if (identityJson) {
|
|
103
|
+
return JSON.parse(identityJson);
|
|
104
|
+
}
|
|
105
|
+
return undefined;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=configUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configUtils.js","sourceRoot":"","sources":["../../src/shared/configUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAsB,MAAM,iCAAiC,CAAC;AAClF,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,UAAwD,MAAM,oBAAoB,CAAC;AAM1F,MAAM,CAAC,MAAM,kCAAkC,GAAG,IAAI,CAAC;AACvD,MAAM,CAAC,MAAM,kCAAkC,GAAG,SAAS,CAAC,KAAK,CAAC;AAOlE,MAAM,OAAO,WAAW;IACtB,MAAM,CAAC,YAAY,CAAS;IAC5B,MAAM,CAAC,aAAa,CAAS;IAEtB,MAAM,CAAC,KAAK,CAAC,cAA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
|
|
6
|
+
export type SiteMetadataCache = {
|
|
7
|
+
[key: string]: SiteMetadata;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Experience Site class.
|
|
11
|
+
* https://developer.salesforce.com/docs/platform/lwc/guide/get-started-test-components.html#enable-local-dev
|
|
12
|
+
*
|
|
13
|
+
* @param {string} siteName - The name of the experience site.
|
|
14
|
+
* @param {string} status - The status of the experience site.
|
|
15
|
+
* @param {string} bundleName - The static resource bundle name.
|
|
16
|
+
* @param {string} bundleLastModified - The lastModifiedDate of the static resource.
|
|
17
|
+
*/
|
|
18
|
+
export declare class ExperienceSite {
|
|
19
|
+
siteDisplayName: string;
|
|
20
|
+
siteName: string;
|
|
21
|
+
private org;
|
|
22
|
+
private metadataCache;
|
|
23
|
+
constructor(org: Org, siteName: string);
|
|
24
|
+
/**
|
|
25
|
+
* Get an experience site bundle by site name.
|
|
26
|
+
*
|
|
27
|
+
* @param conn - Salesforce connection object.
|
|
28
|
+
* @param siteName - The name of the experience site.
|
|
29
|
+
* @returns - The experience site.
|
|
30
|
+
*
|
|
31
|
+
* @param siteName
|
|
32
|
+
* @returns
|
|
33
|
+
*/
|
|
34
|
+
static getLocalExpSite(siteName: string): ExperienceSite;
|
|
35
|
+
/**
|
|
36
|
+
* Fetches all experience site bundles that are published to MRT.
|
|
37
|
+
*
|
|
38
|
+
* @param {Connection} conn - Salesforce connection object.
|
|
39
|
+
* @returns {Promise<ExperienceSite[]>} - List of experience sites.
|
|
40
|
+
*/
|
|
41
|
+
static getAllPublishedExpSites(org: Org): Promise<ExperienceSite[]>;
|
|
42
|
+
/**
|
|
43
|
+
* Fetches all current experience sites
|
|
44
|
+
*
|
|
45
|
+
* @param {Connection} conn - Salesforce connection object.
|
|
46
|
+
* @returns {Promise<string[]>} - List of experience sites.
|
|
47
|
+
*/
|
|
48
|
+
static getAllExpSites(org: Org): Promise<string[]>;
|
|
49
|
+
isUpdateAvailable(): Promise<boolean>;
|
|
50
|
+
isSiteSetup(): boolean;
|
|
51
|
+
isSitePublished(): Promise<boolean>;
|
|
52
|
+
isSiteDownloaded(): boolean;
|
|
53
|
+
saveMetadata(metadata: SiteMetadata): void;
|
|
54
|
+
getLocalMetadata(): SiteMetadata | undefined;
|
|
55
|
+
getRemoteMetadata(): Promise<SiteMetadata | undefined>;
|
|
56
|
+
/**
|
|
57
|
+
* Get the local site directory path
|
|
58
|
+
*
|
|
59
|
+
* @returns the path to the site
|
|
60
|
+
*/
|
|
61
|
+
getSiteDirectory(): string;
|
|
62
|
+
getExtractDirectory(): string;
|
|
63
|
+
getSiteZipPath(metadata: SiteMetadata): string;
|
|
64
|
+
/**
|
|
65
|
+
* Download and return the site resource bundle
|
|
66
|
+
*
|
|
67
|
+
* @returns path of downloaded site zip
|
|
68
|
+
*/
|
|
69
|
+
downloadSite(): Promise<string>;
|
|
70
|
+
}
|