@salesforce/core 4.0.0-v3.0 → 4.0.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/LICENSE.txt +1 -1
- package/README.md +93 -44
- package/lib/config/aliasesConfig.d.ts +12 -0
- package/lib/config/aliasesConfig.js +28 -0
- package/lib/config/authInfoConfig.d.ts +19 -0
- package/lib/config/authInfoConfig.js +35 -0
- package/lib/config/config.d.ts +181 -48
- package/lib/config/config.js +382 -159
- package/lib/config/configAggregator.d.ts +59 -42
- package/lib/config/configAggregator.js +135 -82
- package/lib/config/configFile.d.ts +2 -2
- package/lib/config/configFile.js +40 -31
- package/lib/config/configGroup.d.ts +9 -9
- package/lib/config/configGroup.js +13 -11
- package/lib/config/configStore.d.ts +9 -9
- package/lib/config/configStore.js +29 -26
- package/lib/config/envVars.d.ts +102 -0
- package/lib/config/envVars.js +457 -0
- package/lib/config/orgUsersConfig.d.ts +8 -0
- package/lib/config/orgUsersConfig.js +12 -0
- package/lib/config/sandboxOrgConfig.d.ts +8 -0
- package/lib/config/sandboxOrgConfig.js +12 -0
- package/lib/config/sandboxProcessCache.d.ts +16 -0
- package/lib/config/sandboxProcessCache.js +38 -0
- package/lib/config/tokensConfig.d.ts +10 -0
- package/lib/config/tokensConfig.js +29 -0
- package/lib/config/ttlConfig.d.ts +34 -0
- package/lib/config/ttlConfig.js +50 -0
- package/lib/crypto/crypto.js +29 -16
- package/lib/crypto/keyChain.js +4 -4
- package/lib/crypto/keyChainImpl.d.ts +5 -3
- package/lib/crypto/keyChainImpl.js +65 -66
- package/lib/crypto/secureBuffer.d.ts +1 -1
- package/lib/crypto/secureBuffer.js +1 -1
- package/lib/deviceOauthService.d.ts +5 -5
- package/lib/deviceOauthService.js +37 -33
- package/lib/exported.d.ts +22 -15
- package/lib/exported.js +49 -25
- package/lib/global.d.ts +17 -3
- package/lib/global.js +46 -13
- package/lib/lifecycleEvents.d.ts +39 -2
- package/lib/lifecycleEvents.js +77 -3
- package/lib/logger.d.ts +21 -11
- package/lib/logger.js +121 -105
- package/lib/messages.d.ts +53 -36
- package/lib/messages.js +89 -97
- package/lib/org/authInfo.d.ts +84 -72
- package/lib/org/authInfo.js +326 -320
- package/lib/org/authRemover.d.ts +16 -23
- package/lib/org/authRemover.js +62 -60
- package/lib/org/connection.d.ts +33 -59
- package/lib/org/connection.js +129 -190
- package/lib/org/index.js +6 -2
- package/lib/org/org.d.ts +263 -38
- package/lib/org/org.js +734 -149
- package/lib/org/orgConfigProperties.d.ts +69 -0
- package/lib/org/orgConfigProperties.js +121 -0
- package/lib/org/permissionSetAssignment.js +6 -15
- package/lib/org/scratchOrgCache.d.ts +20 -0
- package/lib/org/scratchOrgCache.js +33 -0
- package/lib/org/scratchOrgCreate.d.ts +54 -0
- package/lib/org/scratchOrgCreate.js +214 -0
- package/lib/org/scratchOrgErrorCodes.d.ts +10 -0
- package/lib/org/scratchOrgErrorCodes.js +79 -0
- package/lib/org/scratchOrgFeatureDeprecation.d.ts +26 -0
- package/lib/org/scratchOrgFeatureDeprecation.js +105 -0
- package/lib/org/scratchOrgInfoApi.d.ts +68 -0
- package/lib/org/scratchOrgInfoApi.js +416 -0
- package/lib/org/scratchOrgInfoGenerator.d.ts +64 -0
- package/lib/org/scratchOrgInfoGenerator.js +237 -0
- package/lib/org/scratchOrgLifecycleEvents.d.ts +10 -0
- package/lib/org/scratchOrgLifecycleEvents.js +41 -0
- package/lib/org/scratchOrgSettingsGenerator.d.ts +79 -0
- package/lib/org/scratchOrgSettingsGenerator.js +277 -0
- package/lib/org/scratchOrgTypes.d.ts +43 -0
- package/lib/{status/client.js → org/scratchOrgTypes.js} +1 -1
- package/lib/org/user.d.ts +7 -2
- package/lib/org/user.js +78 -54
- package/lib/schema/printer.d.ts +6 -0
- package/lib/schema/printer.js +49 -46
- package/lib/schema/validator.d.ts +12 -10
- package/lib/schema/validator.js +56 -76
- package/lib/{sfdxError.d.ts → sfError.d.ts} +12 -15
- package/lib/{sfdxError.js → sfError.js} +42 -24
- package/lib/{sfdxProject.d.ts → sfProject.d.ts} +75 -35
- package/lib/sfProject.js +651 -0
- package/lib/stateAggregator/accessors/aliasAccessor.d.ts +98 -0
- package/lib/stateAggregator/accessors/aliasAccessor.js +146 -0
- package/lib/stateAggregator/accessors/orgAccessor.d.ts +101 -0
- package/lib/stateAggregator/accessors/orgAccessor.js +240 -0
- package/lib/stateAggregator/accessors/sandboxAccessor.d.ts +8 -0
- package/lib/stateAggregator/accessors/sandboxAccessor.js +28 -0
- package/lib/stateAggregator/accessors/tokenAccessor.d.ts +63 -0
- package/lib/stateAggregator/accessors/tokenAccessor.js +80 -0
- package/lib/stateAggregator/index.d.ts +4 -0
- package/lib/stateAggregator/index.js +27 -0
- package/lib/stateAggregator/stateAggregator.d.ts +25 -0
- package/lib/stateAggregator/stateAggregator.js +46 -0
- package/lib/status/myDomainResolver.d.ts +1 -1
- package/lib/status/myDomainResolver.js +10 -10
- package/lib/status/pollingClient.d.ts +2 -6
- package/lib/status/pollingClient.js +38 -64
- package/lib/status/streamingClient.d.ts +5 -80
- package/lib/status/streamingClient.js +74 -94
- package/lib/status/types.d.ts +89 -0
- package/lib/status/types.js +18 -0
- package/lib/testSetup.d.ts +212 -79
- package/lib/testSetup.js +478 -182
- package/lib/util/cache.d.ts +11 -0
- package/lib/util/cache.js +70 -0
- package/lib/util/checkLightningDomain.d.ts +1 -0
- package/lib/util/checkLightningDomain.js +29 -0
- package/lib/util/directoryWriter.d.ts +12 -0
- package/lib/util/directoryWriter.js +54 -0
- package/lib/util/getJwtAudienceUrl.d.ts +4 -0
- package/lib/util/getJwtAudienceUrl.js +19 -0
- package/lib/util/internal.d.ts +28 -2
- package/lib/util/internal.js +65 -8
- package/lib/util/jsonXmlTools.d.ts +14 -0
- package/lib/util/jsonXmlTools.js +39 -0
- package/lib/util/mapKeys.d.ts +14 -0
- package/lib/util/mapKeys.js +52 -0
- package/lib/util/sfdc.d.ts +51 -63
- package/lib/util/sfdc.js +75 -127
- package/lib/util/sfdcUrl.d.ts +64 -0
- package/lib/util/sfdcUrl.js +197 -0
- package/lib/util/structuredWriter.d.ts +9 -0
- package/lib/util/structuredWriter.js +3 -0
- package/lib/util/zipWriter.d.ts +16 -0
- package/lib/util/zipWriter.js +68 -0
- package/lib/webOAuthServer.d.ts +20 -7
- package/lib/webOAuthServer.js +107 -60
- package/messageTransformer/messageTransformer.ts +93 -0
- package/messages/auth.md +11 -3
- package/messages/config.md +94 -6
- package/messages/connection.md +8 -0
- package/messages/core.json +3 -3
- package/messages/core.md +11 -1
- package/messages/envVars.md +313 -0
- package/messages/org.md +64 -0
- package/messages/scratchOrgCreate.md +23 -0
- package/messages/scratchOrgErrorCodes.md +115 -0
- package/messages/scratchOrgFeatureDeprecation.md +11 -0
- package/messages/scratchOrgInfoApi.md +20 -0
- package/messages/scratchOrgInfoGenerator.md +27 -0
- package/messages/user.md +12 -0
- package/package.json +138 -66
- package/CHANGELOG.md +0 -699
- package/lib/config/aliases.d.ts +0 -56
- package/lib/config/aliases.js +0 -96
- package/lib/config/globalInfoConfig.d.ts +0 -74
- package/lib/config/globalInfoConfig.js +0 -144
- package/lib/config/keychainConfig.d.ts +0 -19
- package/lib/config/keychainConfig.js +0 -43
- package/lib/config/sfdxDataHandler.d.ts +0 -36
- package/lib/config/sfdxDataHandler.js +0 -165
- package/lib/sfdxProject.js +0 -546
- package/lib/status/client.d.ts +0 -15
- package/lib/util/fs.d.ts +0 -198
- package/lib/util/fs.js +0 -374
package/LICENSE.txt
CHANGED
package/README.md
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
[](https://www.npmjs.com/package/@salesforce/core)
|
|
2
2
|
[](https://circleci.com/gh/forcedotcom/sfdx-core)
|
|
3
3
|
|
|
4
|
+
- [Description](#description)
|
|
5
|
+
- [Usage](#usage)
|
|
6
|
+
- [Contributing](#contributing)
|
|
7
|
+
- [Using TestSetup](#using-testsetup)
|
|
8
|
+
- [Mocking Authorizations](#mocking-authorizations)
|
|
9
|
+
- [Mocking Config Files](#mocking-config-files)
|
|
10
|
+
- [Using the Built-in Sinon Sandboxes](#using-the-built-in-sinon-sandboxes)
|
|
11
|
+
- [Testing Expected Failures](#testing-expected-failures)
|
|
12
|
+
- [Testing Log Lines](#testing-log-lines)
|
|
13
|
+
|
|
4
14
|
# Description
|
|
5
15
|
|
|
6
|
-
The @salesforce/core library provides client-side management of Salesforce DX projects, org authentication, connections to Salesforce APIs, and other utilities. Much of the core functionality that powers the
|
|
16
|
+
The @salesforce/core library provides client-side management of Salesforce DX projects, org authentication, connections to Salesforce APIs, and other utilities. Much of the core functionality that powers the Salesforce CLI plugins comes from this library. You can use this functionality in your plugins too.
|
|
7
17
|
|
|
8
18
|
# Usage
|
|
9
19
|
|
|
@@ -13,37 +23,25 @@ See the [API documentation](https://forcedotcom.github.io/sfdx-core/).
|
|
|
13
23
|
|
|
14
24
|
If you are interested in contributing, please take a look at the [CONTRIBUTING](CONTRIBUTING.md) guide.
|
|
15
25
|
|
|
16
|
-
# Related Docs and Repositories
|
|
17
|
-
|
|
18
|
-
- [@salesforce/command](https://github.com/forcedotcom/cli-packages/tree/main/packages/command) - Contains base Salesforce CLI command, `SfdxCommand`.
|
|
19
|
-
- [@salesforce/plugin-generator](https://github.com/forcedotcom/sfdx-plugin-generate) - The generator plug-in for building plug-ins for Salesforce CLI.
|
|
20
|
-
|
|
21
26
|
# Using TestSetup
|
|
22
27
|
|
|
23
28
|
The Salesforce DX Core Library provides a unit testing utility to help with mocking and sand-boxing core components. This feature allows unit tests to execute without needing to make API calls to salesforce.com.
|
|
24
29
|
|
|
25
|
-
## Mocking
|
|
30
|
+
## Mocking Authorizations
|
|
26
31
|
|
|
27
32
|
Here you can mock authorization for a Salesforce scratch org.
|
|
28
33
|
|
|
29
34
|
```typescript
|
|
30
35
|
import { strictEqual } from 'assert';
|
|
31
|
-
import { MockTestOrgData,
|
|
36
|
+
import { MockTestOrgData, TestContext } from '@salesforce/core/lib/testSetup';
|
|
32
37
|
import { AuthInfo } from '@salesforce/core';
|
|
33
38
|
|
|
34
|
-
const $$ = testSetup();
|
|
35
|
-
|
|
36
39
|
describe('Mocking Auth data', () => {
|
|
40
|
+
const $$ = new TestContext();
|
|
37
41
|
it('example', async () => {
|
|
38
42
|
const testData = new MockTestOrgData();
|
|
39
|
-
$$.
|
|
40
|
-
|
|
41
|
-
orgs: {
|
|
42
|
-
[testData.username]: await testData.getConfig(),
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
});
|
|
46
|
-
const auth: AuthInfo = await AuthInfo.create({ username: testData.username });
|
|
43
|
+
await $$.stubAuths(testData);
|
|
44
|
+
const auth = await AuthInfo.create({ username: testData.username });
|
|
47
45
|
strictEqual(auth.getUsername(), testData.username);
|
|
48
46
|
});
|
|
49
47
|
});
|
|
@@ -52,58 +50,86 @@ describe('Mocking Auth data', () => {
|
|
|
52
50
|
After having a valid AuthInfo object you can then create fake connections to a Salesforce.com scratch org. This allows for writing tests that can validate result responses for SOQL queries and REST endpoints.
|
|
53
51
|
|
|
54
52
|
```typescript
|
|
55
|
-
import { AuthInfo, Connection,
|
|
56
|
-
import { MockTestOrgData,
|
|
53
|
+
import { AuthInfo, Connection, SfError } from '@salesforce/core';
|
|
54
|
+
import { MockTestOrgData, TestContext } from '@salesforce/core/lib/testSetup';
|
|
57
55
|
import { AnyJson, ensureJsonMap, JsonMap } from '@salesforce/ts-types';
|
|
58
56
|
import { ensureString } from '@salesforce/ts-types';
|
|
59
57
|
import { deepStrictEqual } from 'assert';
|
|
60
58
|
import { QueryResult } from 'jsforce';
|
|
61
59
|
|
|
62
|
-
const $$ = testSetup();
|
|
63
|
-
|
|
64
60
|
describe('Mocking a force server call', () => {
|
|
61
|
+
const $$ = new TestContext();
|
|
65
62
|
it('example', async () => {
|
|
66
63
|
const records: AnyJson = { records: ['123456', '234567'] };
|
|
67
64
|
const testData = new MockTestOrgData();
|
|
68
|
-
$$.
|
|
69
|
-
contents: {
|
|
70
|
-
orgs: {
|
|
71
|
-
[testData.username]: await testData.getConfig(),
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
});
|
|
65
|
+
await $$.stubAuths(testData);
|
|
75
66
|
$$.fakeConnectionRequest = (request: AnyJson): Promise<AnyJson> => {
|
|
76
|
-
const _request
|
|
67
|
+
const _request = ensureJsonMap(request);
|
|
77
68
|
if (request && ensureString(_request.url).includes('Account')) {
|
|
78
69
|
return Promise.resolve(records);
|
|
79
70
|
} else {
|
|
80
|
-
return Promise.reject(new
|
|
71
|
+
return Promise.reject(new SfError(`Unexpected request: ${_request.url}`));
|
|
81
72
|
}
|
|
82
73
|
};
|
|
83
|
-
const connection
|
|
74
|
+
const connection = await Connection.create({
|
|
84
75
|
authInfo: await AuthInfo.create({ username: testData.username }),
|
|
85
76
|
});
|
|
86
|
-
const result
|
|
77
|
+
const result = await connection.query('select Id From Account');
|
|
87
78
|
deepStrictEqual(result, records);
|
|
88
79
|
});
|
|
89
80
|
});
|
|
90
81
|
```
|
|
91
82
|
|
|
83
|
+
## Mocking Config Files
|
|
84
|
+
|
|
85
|
+
You can mock the contents of various config files
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
import { strictEqual } from 'assert';
|
|
89
|
+
import { MockTestOrgData, TestContext } from '@salesforce/core/lib/testSetup';
|
|
90
|
+
import { StateAggregator, OrgConfigProperties } from '@salesforce/core';
|
|
91
|
+
|
|
92
|
+
describe('Mocking Aliases', () => {
|
|
93
|
+
const $$ = new TestContext();
|
|
94
|
+
it('example', async () => {
|
|
95
|
+
const testData = new MockTestOrgData();
|
|
96
|
+
await $$.stubAliases({ myAlias: testData.username });
|
|
97
|
+
const alias = (await StateAggregator.getInstance()).aliases.get(testData.username);
|
|
98
|
+
strictEqual(alias, 'myAlais');
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
describe('Mocking Config', () => {
|
|
103
|
+
it('example', async () => {
|
|
104
|
+
const testData = new MockTestOrgData();
|
|
105
|
+
await $$.stubConfig({ [OrgConfigProperties.TARGET_ORG]: testData.username });
|
|
106
|
+
const { value } = (await ConfigAggregator.create()).getInfo(OrgConfigProperties.TARGET_ORG);
|
|
107
|
+
strictEqual(value, testData.username);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
describe('Mocking Arbitrary Config Files', () => {
|
|
112
|
+
it('example', async () => {
|
|
113
|
+
// MyConfigFile must extend the ConfigFile class in order for this to work properly.
|
|
114
|
+
$$.setConfigStubContents('MyConfigFile', { contents: { foo: 'bar' } });
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
```
|
|
118
|
+
|
|
92
119
|
## Using the Built-in Sinon Sandboxes
|
|
93
120
|
|
|
94
|
-
sfdx-core uses Sinon as its underlying mocking system. If you're unfamiliar with Sinon and
|
|
121
|
+
sfdx-core uses Sinon as its underlying mocking system. If you're unfamiliar with Sinon and its sandboxing concept you can find more information here:
|
|
95
122
|
https://sinonjs.org/
|
|
96
123
|
Sinon `stub`s and `spy`s must be cleaned up after test invocations. To ease the use of Sinon with sfdx core we've exposed our sandbox in TestSetup. After adding your own `stub`s and/or `spy`s they will automatically be cleaned up after each test using mocha's afterEach method.
|
|
97
124
|
|
|
98
125
|
```typescript
|
|
99
126
|
import { strictEqual } from 'assert';
|
|
100
127
|
|
|
101
|
-
import {
|
|
128
|
+
import { TestContext } from '@salesforce/core/lib/testSetup';
|
|
102
129
|
import * as os from 'os';
|
|
103
130
|
|
|
104
|
-
const $$ = testSetup();
|
|
105
|
-
|
|
106
131
|
describe('Using the built in Sinon sandbox.', () => {
|
|
132
|
+
const $$ = new TestContext();
|
|
107
133
|
it('example', async () => {
|
|
108
134
|
const unsupportedOS = 'LEO';
|
|
109
135
|
$$.SANDBOX.stub(os, 'platform').returns(unsupportedOS);
|
|
@@ -117,13 +143,13 @@ describe('Using the built in Sinon sandbox.', () => {
|
|
|
117
143
|
It's important to have negative tests that ensure proper error handling. With `shouldThrow` it's easy to test for expected async rejections.
|
|
118
144
|
|
|
119
145
|
```typescript
|
|
120
|
-
import {
|
|
146
|
+
import { SfError } from '@salesforce/core';
|
|
121
147
|
import { shouldThrow } from '@salesforce/core/lib/testSetup';
|
|
122
148
|
import { strictEqual } from 'assert';
|
|
123
149
|
|
|
124
150
|
class TestObject {
|
|
125
151
|
public static async method() {
|
|
126
|
-
throw new
|
|
152
|
+
throw new SfError('Error', 'ExpectedError');
|
|
127
153
|
}
|
|
128
154
|
}
|
|
129
155
|
|
|
@@ -138,17 +164,39 @@ describe('Testing for expected errors', () => {
|
|
|
138
164
|
});
|
|
139
165
|
```
|
|
140
166
|
|
|
167
|
+
You can also use `shouldThrowSync` for syncrhonous functions you expect to fail
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
import { SfError } from '@salesforce/core';
|
|
171
|
+
import { shouldThrowSync } from '@salesforce/core/lib/testSetup';
|
|
172
|
+
import { strictEqual } from 'assert';
|
|
173
|
+
|
|
174
|
+
class TestObject {
|
|
175
|
+
public static method() {
|
|
176
|
+
throw new SfError('Error', 'ExpectedError');
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
describe('Testing for expected errors', () => {
|
|
181
|
+
it('example', async () => {
|
|
182
|
+
try {
|
|
183
|
+
shouldThrowSync(() => TestObject.method());
|
|
184
|
+
} catch (e) {
|
|
185
|
+
strictEqual(e.name, 'ExpectedError');
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
```
|
|
190
|
+
|
|
141
191
|
## Testing Log Lines
|
|
142
192
|
|
|
143
193
|
It's also useful to check expected values and content from log lines. TestSetup configures the sfdx-core logger to use an in memory LogLine storage structure. These can be easily accessed from tests.
|
|
144
194
|
|
|
145
195
|
```typescript
|
|
146
196
|
import { Logger, LogLine } from '@salesforce/core';
|
|
147
|
-
import {
|
|
197
|
+
import { TestContext } from '@salesforce/core/lib/testSetup';
|
|
148
198
|
import { strictEqual } from 'assert';
|
|
149
199
|
|
|
150
|
-
const $$ = testSetup();
|
|
151
|
-
|
|
152
200
|
const TEST_STRING = 'foo was here';
|
|
153
201
|
|
|
154
202
|
class TestObject {
|
|
@@ -162,10 +210,11 @@ class TestObject {
|
|
|
162
210
|
}
|
|
163
211
|
|
|
164
212
|
describe('Testing log lines', () => {
|
|
213
|
+
const $$ = new TestContext();
|
|
165
214
|
it('example', async () => {
|
|
166
|
-
const obj
|
|
215
|
+
const obj = new TestObject($$.TEST_LOGGER);
|
|
167
216
|
obj.method();
|
|
168
|
-
const records
|
|
217
|
+
const records = $$.TEST_LOGGER.getBufferedRecords();
|
|
169
218
|
strictEqual(records.length, 1);
|
|
170
219
|
strictEqual(records[0].msg, TEST_STRING);
|
|
171
220
|
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ConfigGroup } from './configGroup';
|
|
2
|
+
import { ConfigContents, ConfigValue } from './configStore';
|
|
3
|
+
/**
|
|
4
|
+
* Different groups of aliases. Currently only support orgs.
|
|
5
|
+
*/
|
|
6
|
+
export declare enum AliasGroup {
|
|
7
|
+
ORGS = "orgs"
|
|
8
|
+
}
|
|
9
|
+
export declare class AliasesConfig extends ConfigGroup<ConfigGroup.Options> {
|
|
10
|
+
static getDefaultOptions(): ConfigGroup.Options;
|
|
11
|
+
protected setMethod(contents: ConfigContents, key: string, value?: ConfigValue): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2022, salesforce.com, inc.
|
|
4
|
+
* All rights reserved.
|
|
5
|
+
* Licensed under the BSD 3-Clause license.
|
|
6
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.AliasesConfig = exports.AliasGroup = void 0;
|
|
10
|
+
const configGroup_1 = require("./configGroup");
|
|
11
|
+
/**
|
|
12
|
+
* Different groups of aliases. Currently only support orgs.
|
|
13
|
+
*/
|
|
14
|
+
var AliasGroup;
|
|
15
|
+
(function (AliasGroup) {
|
|
16
|
+
AliasGroup["ORGS"] = "orgs";
|
|
17
|
+
})(AliasGroup = exports.AliasGroup || (exports.AliasGroup = {}));
|
|
18
|
+
class AliasesConfig extends configGroup_1.ConfigGroup {
|
|
19
|
+
static getDefaultOptions() {
|
|
20
|
+
return { ...configGroup_1.ConfigGroup.getOptions(AliasGroup.ORGS, 'alias.json'), isGlobal: true, isState: true };
|
|
21
|
+
}
|
|
22
|
+
// eslint-disable-next-line class-methods-use-this
|
|
23
|
+
setMethod(contents, key, value) {
|
|
24
|
+
contents[key] = value;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.AliasesConfig = AliasesConfig;
|
|
28
|
+
//# sourceMappingURL=aliasesConfig.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AuthFields } from '../org';
|
|
2
|
+
import { ConfigFile } from './configFile';
|
|
3
|
+
/**
|
|
4
|
+
* An auth config file that stores information such as access tokens, usernames, etc.,
|
|
5
|
+
* in the global sfdx directory (~/.sfdx).
|
|
6
|
+
*
|
|
7
|
+
* ```
|
|
8
|
+
* const authInfo = await AuthInfoConfig.create(AuthInfoConfig.getOptions(username));
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export declare class AuthInfoConfig extends ConfigFile<ConfigFile.Options, AuthFields> {
|
|
12
|
+
protected static encryptedKeys: RegExp[];
|
|
13
|
+
/**
|
|
14
|
+
* Gets the config options for a given org ID.
|
|
15
|
+
*
|
|
16
|
+
* @param username The username for the org.
|
|
17
|
+
*/
|
|
18
|
+
static getOptions(username: string): ConfigFile.Options;
|
|
19
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2022, salesforce.com, inc.
|
|
4
|
+
* All rights reserved.
|
|
5
|
+
* Licensed under the BSD 3-Clause license.
|
|
6
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.AuthInfoConfig = void 0;
|
|
10
|
+
const configFile_1 = require("./configFile");
|
|
11
|
+
/**
|
|
12
|
+
* An auth config file that stores information such as access tokens, usernames, etc.,
|
|
13
|
+
* in the global sfdx directory (~/.sfdx).
|
|
14
|
+
*
|
|
15
|
+
* ```
|
|
16
|
+
* const authInfo = await AuthInfoConfig.create(AuthInfoConfig.getOptions(username));
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
class AuthInfoConfig extends configFile_1.ConfigFile {
|
|
20
|
+
/**
|
|
21
|
+
* Gets the config options for a given org ID.
|
|
22
|
+
*
|
|
23
|
+
* @param username The username for the org.
|
|
24
|
+
*/
|
|
25
|
+
static getOptions(username) {
|
|
26
|
+
return {
|
|
27
|
+
isGlobal: true,
|
|
28
|
+
isState: true,
|
|
29
|
+
filename: `${username}.json`,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.AuthInfoConfig = AuthInfoConfig;
|
|
34
|
+
AuthInfoConfig.encryptedKeys = [/token/i, /password/i, /secret/i];
|
|
35
|
+
//# sourceMappingURL=authInfoConfig.js.map
|