-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathconfigMeta.ts
More file actions
120 lines (107 loc) · 3.82 KB
/
Copy pathconfigMeta.ts
File metadata and controls
120 lines (107 loc) · 3.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
* Copyright 2025, Salesforce, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Workspace } from '@lwc/lwc-dev-server';
import { ConfigPropertyMeta, ConfigValue, Messages } from '@salesforce/core';
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('@salesforce/plugin-lightning-dev', 'shared.utils');
const IDENTITY_DATA_DESC = messages.getMessage('config-utils.data-desc');
const LOCAL_DEV_SERVER_CERT_DESC = messages.getMessage('config-utils.cert-desc');
const LOCAL_DEV_SERVER_CERT_ERROR_MESSAGE = messages.getMessage('config-utils.cert-error-message');
const LOCAL_DEV_SERVER_PORT_DESC = messages.getMessage('config-utils.port-desc');
const LOCAL_DEV_SERVER_PORT_ERROR_MESSAGE = messages.getMessage('config-utils.port-error-message');
const LOCAL_DEV_SERVER_WORKSPACE_DESC = messages.getMessage('config-utils.workspace-desc');
const LOCAL_DEV_SERVER_WORKSPACE_ERROR_MESSAGE = messages.getMessage('config-utils.workspace-error-message');
export type SerializedSSLCertificateData = {
derCertificate: string;
pemCertificate: string;
pemPrivateKey: string;
pemPublicKey: string;
};
export const enum ConfigVars {
/**
* The identity data is a data structure that links the local web server's
* identity token to the user's configured Salesforce orgs.
*/
LOCAL_WEB_SERVER_IDENTITY_DATA = 'local-web-server-identity-data',
/**
* The SSL certificate data to be used by local dev server
*/
LOCAL_DEV_SERVER_HTTPS_CERT_DATA = 'local-dev-server-certificate-data',
/**
* The port number of the local dev server.
*/
LOCAL_DEV_SERVER_PORT = 'local-dev-server-port',
/**
* The Workspace name of the local dev server.
*/
LOCAL_DEV_SERVER_WORKSPACE = 'local-dev-server-workspace',
}
export default [
{
key: ConfigVars.LOCAL_WEB_SERVER_IDENTITY_DATA,
description: IDENTITY_DATA_DESC,
hidden: true,
encrypted: true,
},
{
key: ConfigVars.LOCAL_DEV_SERVER_HTTPS_CERT_DATA,
description: LOCAL_DEV_SERVER_CERT_DESC,
input: {
validator: (value: ConfigValue): boolean => {
const data = value as SerializedSSLCertificateData;
if (!data?.derCertificate || !data?.pemCertificate || !data?.pemPrivateKey) {
return false;
}
return true;
},
failedMessage: LOCAL_DEV_SERVER_CERT_ERROR_MESSAGE,
},
},
{
key: ConfigVars.LOCAL_DEV_SERVER_PORT,
description: LOCAL_DEV_SERVER_PORT_DESC,
input: {
validator: (value: ConfigValue): boolean => {
if (!value) {
return false;
}
const parsedPort = parseInt(value as string, 10);
if (isNaN(parsedPort) || parsedPort < 1 || parsedPort > 65_535) {
return false;
}
return true;
},
failedMessage: LOCAL_DEV_SERVER_PORT_ERROR_MESSAGE,
},
},
{
key: ConfigVars.LOCAL_DEV_SERVER_WORKSPACE,
description: LOCAL_DEV_SERVER_WORKSPACE_DESC,
input: {
validator: (value: ConfigValue): boolean => {
if (!value) {
return false;
}
const workspace = value as Workspace;
if (workspace === Workspace.SfCli || workspace === Workspace.Mrt) {
return true;
}
return false;
},
failedMessage: LOCAL_DEV_SERVER_WORKSPACE_ERROR_MESSAGE,
},
},
] as ConfigPropertyMeta[];