@salesforce/sf-plugins-core 1.21.8 → 1.22.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/lib/compatibility.d.ts +4 -0
- package/lib/compatibility.js +9 -1
- package/lib/exported.d.ts +1 -0
- package/lib/exported.js +1 -0
- package/lib/flags/orgFlags.d.ts +28 -0
- package/lib/flags/orgFlags.js +78 -19
- package/package.json +1 -1
package/lib/compatibility.d.ts
CHANGED
|
@@ -36,6 +36,10 @@ export declare const requiredOrgFlagWithDeprecations: import("@oclif/core/lib/in
|
|
|
36
36
|
* @deprecated
|
|
37
37
|
*/
|
|
38
38
|
export declare const requiredHubFlagWithDeprecations: import("@oclif/core/lib/interfaces").OptionFlag<import("@salesforce/core").Org>;
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated
|
|
41
|
+
*/
|
|
42
|
+
export declare const optionalHubFlagWithDeprecations: import("@oclif/core/lib/interfaces").OptionFlag<import("@salesforce/core").Org | undefined>;
|
|
39
43
|
export type ArrayWithDeprecationOptions = {
|
|
40
44
|
multiple?: true;
|
|
41
45
|
parse?: undefined;
|
package/lib/compatibility.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.arrayWithDeprecation = exports.requiredHubFlagWithDeprecations = exports.requiredOrgFlagWithDeprecations = exports.optionalOrgFlagWithDeprecations = exports.loglevel = exports.orgApiVersionFlagWithDeprecations = void 0;
|
|
9
|
+
exports.arrayWithDeprecation = exports.optionalHubFlagWithDeprecations = exports.requiredHubFlagWithDeprecations = exports.requiredOrgFlagWithDeprecations = exports.optionalOrgFlagWithDeprecations = exports.loglevel = exports.orgApiVersionFlagWithDeprecations = void 0;
|
|
10
10
|
const core_1 = require("@oclif/core");
|
|
11
11
|
const core_2 = require("@salesforce/core");
|
|
12
12
|
const orgApiVersion_1 = require("./flags/orgApiVersion");
|
|
@@ -72,6 +72,14 @@ exports.requiredHubFlagWithDeprecations = (0, orgFlags_1.requiredHubFlag)({
|
|
|
72
72
|
deprecateAliases: true,
|
|
73
73
|
required: true,
|
|
74
74
|
});
|
|
75
|
+
/**
|
|
76
|
+
* @deprecated
|
|
77
|
+
*/
|
|
78
|
+
exports.optionalHubFlagWithDeprecations = (0, orgFlags_1.optionalHubFlag)({
|
|
79
|
+
aliases: ['targetdevhubusername'],
|
|
80
|
+
deprecateAliases: true,
|
|
81
|
+
required: false,
|
|
82
|
+
});
|
|
75
83
|
/**
|
|
76
84
|
* @deprecated
|
|
77
85
|
*/
|
package/lib/exported.d.ts
CHANGED
|
@@ -29,5 +29,6 @@ export declare const Flags: {
|
|
|
29
29
|
requiredOrg: import("@oclif/core/lib/interfaces").Definition<import("@salesforce/core").Org, Record<string, unknown>>;
|
|
30
30
|
requiredHub: import("@oclif/core/lib/interfaces").Definition<import("@salesforce/core").Org, Record<string, unknown>>;
|
|
31
31
|
optionalOrg: import("@oclif/core/lib/interfaces").Definition<import("@salesforce/core").Org | undefined, Record<string, unknown>>;
|
|
32
|
+
optionalHub: import("@oclif/core/lib/interfaces").Definition<import("@salesforce/core").Org | undefined, Record<string, unknown>>;
|
|
32
33
|
};
|
|
33
34
|
//# sourceMappingURL=exported.d.ts.map
|
package/lib/exported.js
CHANGED
package/lib/flags/orgFlags.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { Org } from '@salesforce/core';
|
|
2
|
+
export declare function maybeGetOrg(input: string): Promise<Org>;
|
|
3
|
+
export declare function maybeGetOrg(input: undefined): Promise<undefined>;
|
|
4
|
+
export declare function maybeGetOrg(input?: string | undefined): Promise<Org | undefined>;
|
|
5
|
+
export declare const maybeGetHub: (input?: string) => Promise<Org | undefined>;
|
|
6
|
+
export declare const getOrgOrThrow: (input?: string) => Promise<Org>;
|
|
7
|
+
export declare const getHubOrThrow: (aliasOrUsername?: string) => Promise<Org>;
|
|
2
8
|
/**
|
|
3
9
|
* An optional org specified by username or alias
|
|
4
10
|
* Will default to the default org if one is not specified.
|
|
@@ -66,4 +72,26 @@ export declare const requiredOrgFlag: import("@oclif/core/lib/interfaces").Defin
|
|
|
66
72
|
* ```
|
|
67
73
|
*/
|
|
68
74
|
export declare const requiredHubFlag: import("@oclif/core/lib/interfaces").Definition<Org, Record<string, unknown>>;
|
|
75
|
+
/**
|
|
76
|
+
* An optional org that, if present, must be a devHub
|
|
77
|
+
* Will throw if the specified org does not exist
|
|
78
|
+
* Will default to the default dev hub if one is not specified
|
|
79
|
+
* Will NOT throw if no default deb hub exists and none is specified
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
*
|
|
83
|
+
* ```
|
|
84
|
+
* import { Flags } from '@salesforce/sf-plugins-core';
|
|
85
|
+
* public static flags = {
|
|
86
|
+
* // setting length or prefix
|
|
87
|
+
* 'target-org': optionalHubFlag(),
|
|
88
|
+
* // adding properties
|
|
89
|
+
* 'flag2': optionalHubFlag({
|
|
90
|
+
* description: 'flag2 description',
|
|
91
|
+
* char: 'h'
|
|
92
|
+
* }),
|
|
93
|
+
* }
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
export declare const optionalHubFlag: import("@oclif/core/lib/interfaces").Definition<Org | undefined, Record<string, unknown>>;
|
|
69
97
|
//# sourceMappingURL=orgFlags.d.ts.map
|
package/lib/flags/orgFlags.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.requiredHubFlag = exports.requiredOrgFlag = exports.optionalOrgFlag = void 0;
|
|
3
|
+
exports.optionalHubFlag = exports.requiredHubFlag = exports.requiredOrgFlag = exports.optionalOrgFlag = exports.getHubOrThrow = exports.getOrgOrThrow = exports.maybeGetHub = exports.maybeGetOrg = void 0;
|
|
4
4
|
/*
|
|
5
5
|
* Copyright (c) 2020, salesforce.com, inc.
|
|
6
6
|
* All rights reserved.
|
|
@@ -11,7 +11,7 @@ const core_1 = require("@oclif/core");
|
|
|
11
11
|
const core_2 = require("@salesforce/core");
|
|
12
12
|
core_2.Messages.importMessagesDirectory(__dirname);
|
|
13
13
|
const messages = core_2.Messages.loadMessages('@salesforce/sf-plugins-core', 'messages');
|
|
14
|
-
|
|
14
|
+
async function maybeGetOrg(input) {
|
|
15
15
|
try {
|
|
16
16
|
return await core_2.Org.create({ aliasOrUsername: input });
|
|
17
17
|
}
|
|
@@ -23,7 +23,30 @@ const maybeGetOrg = async (input) => {
|
|
|
23
23
|
throw e;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
+
}
|
|
27
|
+
exports.maybeGetOrg = maybeGetOrg;
|
|
28
|
+
const maybeGetHub = async (input) => {
|
|
29
|
+
let org;
|
|
30
|
+
// user provided input, verify the org exits
|
|
31
|
+
if (input) {
|
|
32
|
+
org = await (0, exports.getOrgOrThrow)(input);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
// no input, check config for a default
|
|
36
|
+
const aliasOrUsername = await getDefaultHub(false);
|
|
37
|
+
// if there is a default, verify the org exists
|
|
38
|
+
if (aliasOrUsername) {
|
|
39
|
+
org = await (0, exports.getOrgOrThrow)(aliasOrUsername);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (org) {
|
|
43
|
+
return ensureDevHub(org, org.getUsername());
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
26
48
|
};
|
|
49
|
+
exports.maybeGetHub = maybeGetHub;
|
|
27
50
|
const getOrgOrThrow = async (input) => {
|
|
28
51
|
const org = await maybeGetOrg(input);
|
|
29
52
|
if (!org) {
|
|
@@ -31,21 +54,28 @@ const getOrgOrThrow = async (input) => {
|
|
|
31
54
|
}
|
|
32
55
|
return org;
|
|
33
56
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
// check config for a default
|
|
37
|
-
const config = await core_2.ConfigAggregator.create();
|
|
38
|
-
aliasOrUsername = config.getInfo(core_2.OrgConfigProperties.TARGET_DEV_HUB)?.value;
|
|
39
|
-
if (!aliasOrUsername) {
|
|
40
|
-
throw messages.createError('errors.NoDefaultDevHub');
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
const org = await core_2.Org.create({ aliasOrUsername });
|
|
57
|
+
exports.getOrgOrThrow = getOrgOrThrow;
|
|
58
|
+
const ensureDevHub = async (org, aliasOrUsername) => {
|
|
44
59
|
if (await org.determineIfDevHubOrg()) {
|
|
45
60
|
return org;
|
|
46
61
|
}
|
|
47
|
-
throw messages.createError('errors.NotADevHub', [aliasOrUsername]);
|
|
62
|
+
throw messages.createError('errors.NotADevHub', [aliasOrUsername ?? org.getUsername()]);
|
|
48
63
|
};
|
|
64
|
+
async function getDefaultHub(throwIfNotFound) {
|
|
65
|
+
// check config for a default
|
|
66
|
+
const config = await core_2.ConfigAggregator.create();
|
|
67
|
+
const aliasOrUsername = config.getInfo(core_2.OrgConfigProperties.TARGET_DEV_HUB)?.value;
|
|
68
|
+
if (throwIfNotFound && !aliasOrUsername) {
|
|
69
|
+
throw messages.createError('errors.NoDefaultDevHub');
|
|
70
|
+
}
|
|
71
|
+
return aliasOrUsername;
|
|
72
|
+
}
|
|
73
|
+
const getHubOrThrow = async (aliasOrUsername) => {
|
|
74
|
+
const resolved = aliasOrUsername ?? (await getDefaultHub(true));
|
|
75
|
+
const org = await core_2.Org.create({ aliasOrUsername: resolved, isDevHub: true });
|
|
76
|
+
return ensureDevHub(org, resolved);
|
|
77
|
+
};
|
|
78
|
+
exports.getHubOrThrow = getHubOrThrow;
|
|
49
79
|
/**
|
|
50
80
|
* An optional org specified by username or alias
|
|
51
81
|
* Will default to the default org if one is not specified.
|
|
@@ -97,9 +127,9 @@ exports.optionalOrgFlag = core_1.Flags.custom({
|
|
|
97
127
|
exports.requiredOrgFlag = core_1.Flags.custom({
|
|
98
128
|
char: 'o',
|
|
99
129
|
summary: messages.getMessage('flags.targetOrg.summary'),
|
|
100
|
-
parse: async (input) => getOrgOrThrow(input),
|
|
101
|
-
default: async () => getOrgOrThrow(),
|
|
102
|
-
defaultHelp: async () => (await getOrgOrThrow())?.getUsername(),
|
|
130
|
+
parse: async (input) => (0, exports.getOrgOrThrow)(input),
|
|
131
|
+
default: async () => (0, exports.getOrgOrThrow)(),
|
|
132
|
+
defaultHelp: async () => (await (0, exports.getOrgOrThrow)())?.getUsername(),
|
|
103
133
|
required: true,
|
|
104
134
|
});
|
|
105
135
|
/**
|
|
@@ -127,9 +157,38 @@ exports.requiredOrgFlag = core_1.Flags.custom({
|
|
|
127
157
|
exports.requiredHubFlag = core_1.Flags.custom({
|
|
128
158
|
char: 'v',
|
|
129
159
|
summary: messages.getMessage('flags.targetDevHubOrg.summary'),
|
|
130
|
-
parse: async (input) => getHubOrThrow(input),
|
|
131
|
-
default: async () => getHubOrThrow(),
|
|
132
|
-
defaultHelp: async () => (await getHubOrThrow())?.getUsername(),
|
|
160
|
+
parse: async (input) => (0, exports.getHubOrThrow)(input),
|
|
161
|
+
default: async () => (0, exports.getHubOrThrow)(),
|
|
162
|
+
defaultHelp: async () => (await (0, exports.getHubOrThrow)())?.getUsername(),
|
|
133
163
|
required: true,
|
|
134
164
|
});
|
|
165
|
+
/**
|
|
166
|
+
* An optional org that, if present, must be a devHub
|
|
167
|
+
* Will throw if the specified org does not exist
|
|
168
|
+
* Will default to the default dev hub if one is not specified
|
|
169
|
+
* Will NOT throw if no default deb hub exists and none is specified
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
*
|
|
173
|
+
* ```
|
|
174
|
+
* import { Flags } from '@salesforce/sf-plugins-core';
|
|
175
|
+
* public static flags = {
|
|
176
|
+
* // setting length or prefix
|
|
177
|
+
* 'target-org': optionalHubFlag(),
|
|
178
|
+
* // adding properties
|
|
179
|
+
* 'flag2': optionalHubFlag({
|
|
180
|
+
* description: 'flag2 description',
|
|
181
|
+
* char: 'h'
|
|
182
|
+
* }),
|
|
183
|
+
* }
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
exports.optionalHubFlag = core_1.Flags.custom({
|
|
187
|
+
char: 'v',
|
|
188
|
+
summary: messages.getMessage('flags.targetDevHubOrg.summary'),
|
|
189
|
+
parse: async (input) => (0, exports.maybeGetHub)(input),
|
|
190
|
+
default: async () => (0, exports.maybeGetHub)(),
|
|
191
|
+
defaultHelp: async () => (await (0, exports.maybeGetHub)())?.getUsername(),
|
|
192
|
+
required: false,
|
|
193
|
+
});
|
|
135
194
|
//# sourceMappingURL=orgFlags.js.map
|