@salesforce/sf-plugins-core 1.21.7 → 1.22.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/lib/compatibility.d.ts +4 -0
- package/lib/compatibility.js +9 -1
- package/lib/deployer.d.ts +1 -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 +66 -19
- package/lib/util.d.ts +1 -7
- package/lib/util.js +2 -1
- 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/deployer.d.ts
CHANGED
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,18 @@ const maybeGetOrg = async (input) => {
|
|
|
23
23
|
throw e;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
+
}
|
|
27
|
+
exports.maybeGetOrg = maybeGetOrg;
|
|
28
|
+
const maybeGetHub = async (input) => {
|
|
29
|
+
const org = await maybeGetOrg(input ?? (await getDefaultHub(false)));
|
|
30
|
+
if (org) {
|
|
31
|
+
return ensureDevHub(org, input ?? org.getUsername());
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
26
36
|
};
|
|
37
|
+
exports.maybeGetHub = maybeGetHub;
|
|
27
38
|
const getOrgOrThrow = async (input) => {
|
|
28
39
|
const org = await maybeGetOrg(input);
|
|
29
40
|
if (!org) {
|
|
@@ -31,21 +42,28 @@ const getOrgOrThrow = async (input) => {
|
|
|
31
42
|
}
|
|
32
43
|
return org;
|
|
33
44
|
};
|
|
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 });
|
|
45
|
+
exports.getOrgOrThrow = getOrgOrThrow;
|
|
46
|
+
const ensureDevHub = async (org, aliasOrUsername) => {
|
|
44
47
|
if (await org.determineIfDevHubOrg()) {
|
|
45
48
|
return org;
|
|
46
49
|
}
|
|
47
|
-
throw messages.createError('errors.NotADevHub', [aliasOrUsername]);
|
|
50
|
+
throw messages.createError('errors.NotADevHub', [aliasOrUsername ?? org.getUsername()]);
|
|
51
|
+
};
|
|
52
|
+
async function getDefaultHub(throwIfNotFound) {
|
|
53
|
+
// check config for a default
|
|
54
|
+
const config = await core_2.ConfigAggregator.create();
|
|
55
|
+
const aliasOrUsername = config.getInfo(core_2.OrgConfigProperties.TARGET_DEV_HUB)?.value;
|
|
56
|
+
if (throwIfNotFound && !aliasOrUsername) {
|
|
57
|
+
throw messages.createError('errors.NoDefaultDevHub');
|
|
58
|
+
}
|
|
59
|
+
return aliasOrUsername;
|
|
60
|
+
}
|
|
61
|
+
const getHubOrThrow = async (aliasOrUsername) => {
|
|
62
|
+
const resolved = aliasOrUsername ?? (await getDefaultHub(true));
|
|
63
|
+
const org = await core_2.Org.create({ aliasOrUsername: resolved, isDevHub: true });
|
|
64
|
+
return ensureDevHub(org, resolved);
|
|
48
65
|
};
|
|
66
|
+
exports.getHubOrThrow = getHubOrThrow;
|
|
49
67
|
/**
|
|
50
68
|
* An optional org specified by username or alias
|
|
51
69
|
* Will default to the default org if one is not specified.
|
|
@@ -97,9 +115,9 @@ exports.optionalOrgFlag = core_1.Flags.custom({
|
|
|
97
115
|
exports.requiredOrgFlag = core_1.Flags.custom({
|
|
98
116
|
char: 'o',
|
|
99
117
|
summary: messages.getMessage('flags.targetOrg.summary'),
|
|
100
|
-
parse: async (input) => getOrgOrThrow(input),
|
|
101
|
-
default: async () => getOrgOrThrow(),
|
|
102
|
-
defaultHelp: async () => (await getOrgOrThrow())?.getUsername(),
|
|
118
|
+
parse: async (input) => (0, exports.getOrgOrThrow)(input),
|
|
119
|
+
default: async () => (0, exports.getOrgOrThrow)(),
|
|
120
|
+
defaultHelp: async () => (await (0, exports.getOrgOrThrow)())?.getUsername(),
|
|
103
121
|
required: true,
|
|
104
122
|
});
|
|
105
123
|
/**
|
|
@@ -127,9 +145,38 @@ exports.requiredOrgFlag = core_1.Flags.custom({
|
|
|
127
145
|
exports.requiredHubFlag = core_1.Flags.custom({
|
|
128
146
|
char: 'v',
|
|
129
147
|
summary: messages.getMessage('flags.targetDevHubOrg.summary'),
|
|
130
|
-
parse: async (input) => getHubOrThrow(input),
|
|
131
|
-
default: async () => getHubOrThrow(),
|
|
132
|
-
defaultHelp: async () => (await getHubOrThrow())?.getUsername(),
|
|
148
|
+
parse: async (input) => (0, exports.getHubOrThrow)(input),
|
|
149
|
+
default: async () => (0, exports.getHubOrThrow)(),
|
|
150
|
+
defaultHelp: async () => (await (0, exports.getHubOrThrow)())?.getUsername(),
|
|
133
151
|
required: true,
|
|
134
152
|
});
|
|
153
|
+
/**
|
|
154
|
+
* An optional org that, if present, must be a devHub
|
|
155
|
+
* Will throw if the specified org does not exist
|
|
156
|
+
* Will default to the default dev hub if one is not specified
|
|
157
|
+
* Will NOT throw if no default deb hub exists and none is specified
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
*
|
|
161
|
+
* ```
|
|
162
|
+
* import { Flags } from '@salesforce/sf-plugins-core';
|
|
163
|
+
* public static flags = {
|
|
164
|
+
* // setting length or prefix
|
|
165
|
+
* 'target-org': optionalHubFlag(),
|
|
166
|
+
* // adding properties
|
|
167
|
+
* 'flag2': optionalHubFlag({
|
|
168
|
+
* description: 'flag2 description',
|
|
169
|
+
* char: 'h'
|
|
170
|
+
* }),
|
|
171
|
+
* }
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
exports.optionalHubFlag = core_1.Flags.custom({
|
|
175
|
+
char: 'v',
|
|
176
|
+
summary: messages.getMessage('flags.targetDevHubOrg.summary'),
|
|
177
|
+
parse: async (input) => (0, exports.maybeGetHub)(input),
|
|
178
|
+
default: async () => (0, exports.maybeGetHub)(),
|
|
179
|
+
defaultHelp: async () => (await (0, exports.maybeGetHub)())?.getUsername(),
|
|
180
|
+
required: false,
|
|
181
|
+
});
|
|
135
182
|
//# sourceMappingURL=orgFlags.js.map
|
package/lib/util.d.ts
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { EnvironmentVariable, OrgConfigProperties, SfdxPropertyKeys } from '@salesforce/core';
|
|
2
|
-
|
|
3
|
-
header: string;
|
|
4
|
-
body: Array<{
|
|
5
|
-
name: string;
|
|
6
|
-
description: string;
|
|
7
|
-
} | undefined>;
|
|
8
|
-
};
|
|
2
|
+
import { HelpSection } from '@oclif/core';
|
|
9
3
|
/**
|
|
10
4
|
* Function to build a help section for command help.
|
|
11
5
|
* Takes a string to be used as section header text and an array of enums
|
package/lib/util.js
CHANGED
|
@@ -42,10 +42,11 @@ function toHelpSection(header, ...vars) {
|
|
|
42
42
|
return Object.entries(v).map(([name, description]) => ({ name, description }));
|
|
43
43
|
}
|
|
44
44
|
})
|
|
45
|
-
.filter(
|
|
45
|
+
.filter(isHelpSectionBodyEntry);
|
|
46
46
|
return { header, body };
|
|
47
47
|
}
|
|
48
48
|
exports.toHelpSection = toHelpSection;
|
|
49
|
+
const isHelpSectionBodyEntry = (entry) => typeof entry === 'object' && entry !== null && 'name' in entry && 'description' in entry;
|
|
49
50
|
function parseVarArgs(args, argv) {
|
|
50
51
|
const final = {};
|
|
51
52
|
const argVals = Object.values(args);
|