@salesforce/plugin-deploy-retrieve 1.0.6 → 1.1.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/CHANGELOG.md +10 -0
- package/README.md +211 -1
- package/lib/commands/deploy/metadata.d.ts +36 -0
- package/lib/commands/deploy/metadata.js +123 -0
- package/lib/commands/deploy/metadata.js.map +1 -0
- package/lib/commands/deploy.js +3 -3
- package/lib/commands/deploy.js.map +1 -1
- package/lib/commands/retrieve/metadata.d.ts +29 -0
- package/lib/commands/retrieve/metadata.js +134 -0
- package/lib/commands/retrieve/metadata.js.map +1 -0
- package/lib/hooks/deploy.d.ts +4 -0
- package/lib/hooks/deploy.js +17 -0
- package/lib/hooks/deploy.js.map +1 -0
- package/lib/utils/componentSetBuilder.d.ts +28 -0
- package/lib/utils/componentSetBuilder.js +123 -0
- package/lib/utils/componentSetBuilder.js.map +1 -0
- package/lib/utils/config.d.ts +1 -0
- package/lib/utils/config.js +18 -0
- package/lib/utils/config.js.map +1 -0
- package/lib/utils/metadataDeployer.d.ts +30 -0
- package/lib/utils/metadataDeployer.js +178 -0
- package/lib/utils/metadataDeployer.js.map +1 -0
- package/lib/utils/orgs.d.ts +4 -0
- package/lib/utils/orgs.js +39 -0
- package/lib/utils/orgs.js.map +1 -0
- package/lib/utils/output.d.ts +18 -0
- package/lib/utils/output.js +152 -0
- package/lib/utils/output.js.map +1 -0
- package/lib/utils/progressBar.d.ts +8 -0
- package/lib/utils/progressBar.js +55 -0
- package/lib/utils/progressBar.js.map +1 -0
- package/lib/utils/requiredFlagValidator.d.ts +3 -0
- package/lib/utils/requiredFlagValidator.js +19 -0
- package/lib/utils/requiredFlagValidator.js.map +1 -0
- package/lib/utils/testLevel.d.ts +6 -0
- package/lib/utils/testLevel.js +17 -0
- package/lib/utils/testLevel.js.map +1 -0
- package/messages/deploy.metadata.md +114 -0
- package/messages/metadata.transfer.md +27 -0
- package/messages/required.flag.md +3 -0
- package/messages/retrieve.metadata.md +100 -0
- package/oclif.manifest.json +1 -1
- package/package.json +20 -11
- package/schemas/deploy-metadata.json +98 -0
- package/schemas/hooks/sf-deploy.json +106 -0
- package/schemas/retrieve-metadata.json +69 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2021, 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
|
+
const core_1 = require("@salesforce/core");
|
|
10
|
+
const metadataDeployer_1 = require("../utils/metadataDeployer");
|
|
11
|
+
const hook = async function () {
|
|
12
|
+
const project = await core_1.SfdxProject.resolve();
|
|
13
|
+
const packageDirectories = project.getPackageDirectories();
|
|
14
|
+
return [new metadataDeployer_1.MetadataDeployer(packageDirectories)];
|
|
15
|
+
};
|
|
16
|
+
exports.default = hook;
|
|
17
|
+
//# sourceMappingURL=deploy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deploy.js","sourceRoot":"","sources":["../../src/hooks/deploy.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAEH,2CAA+C;AAE/C,gEAA6D;AAE7D,MAAM,IAAI,GAAoC,KAAK;IACjD,MAAM,OAAO,GAAG,MAAM,kBAAW,CAAC,OAAO,EAAE,CAAC;IAC5C,MAAM,kBAAkB,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC;IAC3D,OAAO,CAAC,IAAI,mCAAgB,CAAC,kBAAkB,CAAC,CAAC,CAAC;AACpD,CAAC,CAAC;AAEF,kBAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ComponentSet } from '@sf/sdr';
|
|
2
|
+
export declare type ManifestOption = {
|
|
3
|
+
manifestPath: string;
|
|
4
|
+
directoryPaths: string[];
|
|
5
|
+
};
|
|
6
|
+
export declare type MetadataOption = {
|
|
7
|
+
metadataEntries: string[];
|
|
8
|
+
directoryPaths: string[];
|
|
9
|
+
};
|
|
10
|
+
export declare type ComponentSetOptions = {
|
|
11
|
+
packagenames?: string[];
|
|
12
|
+
sourcepath?: string[];
|
|
13
|
+
manifest?: ManifestOption;
|
|
14
|
+
metadata?: MetadataOption;
|
|
15
|
+
apiversion?: string;
|
|
16
|
+
sourceapiversion?: string;
|
|
17
|
+
};
|
|
18
|
+
export declare class ComponentSetBuilder {
|
|
19
|
+
/**
|
|
20
|
+
* Builds a ComponentSet that can be used for source conversion,
|
|
21
|
+
* deployment, or retrieval, using all specified options.
|
|
22
|
+
*
|
|
23
|
+
* @see https://github.com/forcedotcom/source-deploy-retrieve/blob/develop/src/collections/componentSet.ts
|
|
24
|
+
*
|
|
25
|
+
* @param options: options for creating a ComponentSet
|
|
26
|
+
*/
|
|
27
|
+
static build(options: ComponentSetOptions): Promise<ComponentSet>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2021, 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.ComponentSetBuilder = void 0;
|
|
10
|
+
const path = require("path");
|
|
11
|
+
const sdr_1 = require("@sf/sdr");
|
|
12
|
+
const core_1 = require("@salesforce/core");
|
|
13
|
+
class ComponentSetBuilder {
|
|
14
|
+
/**
|
|
15
|
+
* Builds a ComponentSet that can be used for source conversion,
|
|
16
|
+
* deployment, or retrieval, using all specified options.
|
|
17
|
+
*
|
|
18
|
+
* @see https://github.com/forcedotcom/source-deploy-retrieve/blob/develop/src/collections/componentSet.ts
|
|
19
|
+
*
|
|
20
|
+
* @param options: options for creating a ComponentSet
|
|
21
|
+
*/
|
|
22
|
+
static async build(options) {
|
|
23
|
+
var _a, _b;
|
|
24
|
+
const logger = core_1.Logger.childFromRoot('createComponentSet');
|
|
25
|
+
let componentSet;
|
|
26
|
+
const { sourcepath, manifest, metadata, packagenames, apiversion, sourceapiversion } = options;
|
|
27
|
+
try {
|
|
28
|
+
if (sourcepath) {
|
|
29
|
+
logger.debug(`Building ComponentSet from sourcepath: ${sourcepath.toString()}`);
|
|
30
|
+
const fsPaths = [];
|
|
31
|
+
sourcepath.forEach((filepath) => {
|
|
32
|
+
if (!core_1.fs.fileExistsSync(filepath)) {
|
|
33
|
+
throw new core_1.SfdxError(`The sourcepath "${filepath}" is not a valid source file path.`);
|
|
34
|
+
}
|
|
35
|
+
fsPaths.push(path.resolve(filepath));
|
|
36
|
+
});
|
|
37
|
+
componentSet = sdr_1.ComponentSet.fromSource({ fsPaths });
|
|
38
|
+
}
|
|
39
|
+
// Return empty ComponentSet and use packageNames in the library via `.retrieve` options
|
|
40
|
+
if (packagenames) {
|
|
41
|
+
logger.debug(`Building ComponentSet for packagenames: ${packagenames.toString()}`);
|
|
42
|
+
componentSet !== null && componentSet !== void 0 ? componentSet : (componentSet = new sdr_1.ComponentSet());
|
|
43
|
+
}
|
|
44
|
+
// Resolve manifest with source in package directories.
|
|
45
|
+
if (manifest) {
|
|
46
|
+
logger.debug(`Building ComponentSet from manifest: ${manifest.manifestPath}`);
|
|
47
|
+
const directoryPaths = options.manifest.directoryPaths;
|
|
48
|
+
logger.debug(`Searching in packageDir: ${directoryPaths.join(', ')} for matching metadata`);
|
|
49
|
+
componentSet = await sdr_1.ComponentSet.fromManifest({
|
|
50
|
+
manifestPath: manifest.manifestPath,
|
|
51
|
+
resolveSourcePaths: options.manifest.directoryPaths,
|
|
52
|
+
forceAddWildcards: true,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
// Resolve metadata entries with source in package directories.
|
|
56
|
+
if (metadata) {
|
|
57
|
+
logger.debug(`Building ComponentSet from metadata: ${metadata.metadataEntries.toString()}`);
|
|
58
|
+
const registry = new sdr_1.RegistryAccess();
|
|
59
|
+
const compSetFilter = new sdr_1.ComponentSet();
|
|
60
|
+
componentSet !== null && componentSet !== void 0 ? componentSet : (componentSet = new sdr_1.ComponentSet());
|
|
61
|
+
// Build a Set of metadata entries
|
|
62
|
+
metadata.metadataEntries.forEach((rawEntry) => {
|
|
63
|
+
const splitEntry = rawEntry.split(':');
|
|
64
|
+
// The registry will throw if it doesn't know what this type is.
|
|
65
|
+
registry.getTypeByName(splitEntry[0]);
|
|
66
|
+
const entry = {
|
|
67
|
+
type: splitEntry[0],
|
|
68
|
+
fullName: splitEntry.length === 1 ? '*' : splitEntry[1],
|
|
69
|
+
};
|
|
70
|
+
// Add to the filtered ComponentSet for resolved source paths,
|
|
71
|
+
// and the unfiltered ComponentSet to build the correct manifest.
|
|
72
|
+
compSetFilter.add(entry);
|
|
73
|
+
componentSet.add(entry);
|
|
74
|
+
});
|
|
75
|
+
const directoryPaths = options.metadata.directoryPaths;
|
|
76
|
+
logger.debug(`Searching for matching metadata in directories: ${directoryPaths.join(', ')}`);
|
|
77
|
+
const resolvedComponents = sdr_1.ComponentSet.fromSource({ fsPaths: directoryPaths, include: compSetFilter });
|
|
78
|
+
componentSet.forceIgnoredPaths = resolvedComponents.forceIgnoredPaths;
|
|
79
|
+
for (const comp of resolvedComponents) {
|
|
80
|
+
componentSet.add(comp);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
catch (e) {
|
|
85
|
+
if (e.message.includes('Missing metadata type definition in registry for id')) {
|
|
86
|
+
// to remain generic to catch missing metadata types regardless of parameters, split on '
|
|
87
|
+
// example message : Missing metadata type definition in registry for id 'NonExistentType'
|
|
88
|
+
const issueType = e.message.split("'")[1];
|
|
89
|
+
throw new core_1.SfdxError(`The specified metadata type is unsupported: [${issueType}]`);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
throw e;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// This is only for debug output of matched files based on the command flags.
|
|
96
|
+
// It will log up to 20 file matches.
|
|
97
|
+
if (logger.debugEnabled && componentSet.size) {
|
|
98
|
+
logger.debug(`Matching metadata files (${componentSet.size}):`);
|
|
99
|
+
const components = componentSet.getSourceComponents().toArray();
|
|
100
|
+
for (let i = 0; i < componentSet.size; i++) {
|
|
101
|
+
if ((_a = components[i]) === null || _a === void 0 ? void 0 : _a.content) {
|
|
102
|
+
logger.debug(components[i].content);
|
|
103
|
+
}
|
|
104
|
+
else if ((_b = components[i]) === null || _b === void 0 ? void 0 : _b.xml) {
|
|
105
|
+
logger.debug(components[i].xml);
|
|
106
|
+
}
|
|
107
|
+
if (i > 18) {
|
|
108
|
+
logger.debug(`(showing 20 of ${componentSet.size} matches)`);
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (apiversion) {
|
|
114
|
+
componentSet.apiVersion = apiversion;
|
|
115
|
+
}
|
|
116
|
+
if (sourceapiversion) {
|
|
117
|
+
componentSet.sourceApiVersion = sourceapiversion;
|
|
118
|
+
}
|
|
119
|
+
return componentSet;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
exports.ComponentSetBuilder = ComponentSetBuilder;
|
|
123
|
+
//# sourceMappingURL=componentSetBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"componentSetBuilder.js","sourceRoot":"","sources":["../../src/utils/componentSetBuilder.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,6BAA6B;AAC7B,iCAAuD;AACvD,2CAAyD;AAmBzD,MAAa,mBAAmB;IAC9B;;;;;;;OAOG;IACI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,OAA4B;;QACpD,MAAM,MAAM,GAAG,aAAM,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C,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;iBACjC;gBAED,IAAI,CAAC,GAAG,EAAE,EAAE;oBACV,MAAM,CAAC,KAAK,CAAC,kBAAkB,YAAY,CAAC,IAAI,WAAW,CAAC,CAAC;oBAC7D,MAAM;iBACP;aACF;SACF;QAED,IAAI,UAAU,EAAE;YACd,YAAY,CAAC,UAAU,GAAG,UAAU,CAAC;SACtC;QAED,IAAI,gBAAgB,EAAE;YACpB,YAAY,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;SAClD;QAED,OAAO,YAAY,CAAC;IACtB,CAAC;CACF;AAnHD,kDAmHC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const resolveRestDeploy: () => string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveRestDeploy = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
6
|
+
* All rights reserved.
|
|
7
|
+
* Licensed under the BSD 3-Clause license.
|
|
8
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
9
|
+
*/
|
|
10
|
+
const core_1 = require("@salesforce/core");
|
|
11
|
+
const resolveRestDeploy = function () {
|
|
12
|
+
const restDeploy = (core_1.ConfigAggregator.getValue(core_1.SfdxPropertyKeys.REST_DEPLOY).value === 'true' ? true : false)
|
|
13
|
+
? 'REST'
|
|
14
|
+
: 'SOAP';
|
|
15
|
+
return restDeploy;
|
|
16
|
+
};
|
|
17
|
+
exports.resolveRestDeploy = resolveRestDeploy;
|
|
18
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,2CAAsE;AAE/D,MAAM,iBAAiB,GAAG;IAC/B,MAAM,UAAU,GAAG,CAAC,uBAAgB,CAAC,QAAQ,CAAC,uBAAgB,CAAC,WAAW,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;QAC1G,CAAC,CAAC,MAAM;QACR,CAAC,CAAC,MAAM,CAAC;IACX,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AALW,QAAA,iBAAiB,qBAK5B"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { NamedPackageDir } from '@salesforce/core';
|
|
2
|
+
import { Deployable, Deployer } from '@salesforce/sf-plugins-core';
|
|
3
|
+
import { TestLevel } from './testLevel';
|
|
4
|
+
export interface MetadataDeployOptions extends Deployer.Options {
|
|
5
|
+
testLevel?: TestLevel;
|
|
6
|
+
username?: string;
|
|
7
|
+
directories?: string[];
|
|
8
|
+
}
|
|
9
|
+
export declare class DeployablePackage extends Deployable {
|
|
10
|
+
pkg: NamedPackageDir;
|
|
11
|
+
private parent;
|
|
12
|
+
constructor(pkg: NamedPackageDir, parent: Deployer);
|
|
13
|
+
getName(): string;
|
|
14
|
+
getType(): string;
|
|
15
|
+
getPath(): string;
|
|
16
|
+
getParent(): Deployer;
|
|
17
|
+
}
|
|
18
|
+
export declare class MetadataDeployer extends Deployer {
|
|
19
|
+
private packages;
|
|
20
|
+
static NAME: string;
|
|
21
|
+
deployables: DeployablePackage[];
|
|
22
|
+
private testLevel;
|
|
23
|
+
private username;
|
|
24
|
+
constructor(packages: NamedPackageDir[]);
|
|
25
|
+
getName(): string;
|
|
26
|
+
setup(flags: Deployer.Flags, options: MetadataDeployOptions): Promise<MetadataDeployOptions>;
|
|
27
|
+
deploy(): Promise<void>;
|
|
28
|
+
promptForUsername(): Promise<string>;
|
|
29
|
+
promptForTestLevel(): Promise<TestLevel>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2021, 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.MetadataDeployer = exports.DeployablePackage = void 0;
|
|
10
|
+
const os_1 = require("os");
|
|
11
|
+
const chalk_1 = require("chalk");
|
|
12
|
+
const kit_1 = require("@salesforce/kit");
|
|
13
|
+
const core_1 = require("@salesforce/core");
|
|
14
|
+
const sf_plugins_core_1 = require("@salesforce/sf-plugins-core");
|
|
15
|
+
const componentSetBuilder_1 = require("./componentSetBuilder");
|
|
16
|
+
const output_1 = require("./output");
|
|
17
|
+
const testLevel_1 = require("./testLevel");
|
|
18
|
+
const progressBar_1 = require("./progressBar");
|
|
19
|
+
const config_1 = require("./config");
|
|
20
|
+
core_1.Messages.importMessagesDirectory(__dirname);
|
|
21
|
+
const messages = core_1.Messages.loadMessages('@salesforce/plugin-deploy-retrieve', 'deploy.metadata');
|
|
22
|
+
const compareOrgs = (a, b) => {
|
|
23
|
+
// scratch orgs before other orgs
|
|
24
|
+
if (a.isScratchOrg && !b.isScratchOrg) {
|
|
25
|
+
// all scratch orgs come before non-scratch orgs
|
|
26
|
+
return -1;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
// sort scratch orgs by timestamp - descending
|
|
30
|
+
if (a.isScratchOrg && b.isScratchOrg) {
|
|
31
|
+
const aTimestamp = new Date(a.timestamp);
|
|
32
|
+
const bTimestamp = new Date(b.timestamp);
|
|
33
|
+
return bTimestamp.getTime() - aTimestamp.getTime();
|
|
34
|
+
}
|
|
35
|
+
// dev hubs after scratch but before remaining orgs
|
|
36
|
+
if (a.isDevHub && !b.isScratchOrg && !b.isDevHub) {
|
|
37
|
+
return -1;
|
|
38
|
+
}
|
|
39
|
+
// not a scratch org and not a devhub means "other" sorts last
|
|
40
|
+
if (!a.isDevHub) {
|
|
41
|
+
return 1;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// orgs are equal by type - sort by name ascending
|
|
45
|
+
return a.username.localeCompare(b.username);
|
|
46
|
+
};
|
|
47
|
+
class DeployablePackage extends sf_plugins_core_1.Deployable {
|
|
48
|
+
constructor(pkg, parent) {
|
|
49
|
+
super();
|
|
50
|
+
this.pkg = pkg;
|
|
51
|
+
this.parent = parent;
|
|
52
|
+
}
|
|
53
|
+
getName() {
|
|
54
|
+
return this.pkg.name;
|
|
55
|
+
}
|
|
56
|
+
getType() {
|
|
57
|
+
return 'Salesforce App';
|
|
58
|
+
}
|
|
59
|
+
getPath() {
|
|
60
|
+
return this.pkg.path;
|
|
61
|
+
}
|
|
62
|
+
getParent() {
|
|
63
|
+
return this.parent;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.DeployablePackage = DeployablePackage;
|
|
67
|
+
class MetadataDeployer extends sf_plugins_core_1.Deployer {
|
|
68
|
+
constructor(packages) {
|
|
69
|
+
super();
|
|
70
|
+
this.packages = packages;
|
|
71
|
+
this.testLevel = testLevel_1.TestLevel.NoTestRun;
|
|
72
|
+
this.deployables = this.packages.map((pkg) => new DeployablePackage(pkg, this));
|
|
73
|
+
}
|
|
74
|
+
getName() {
|
|
75
|
+
return MetadataDeployer.NAME;
|
|
76
|
+
}
|
|
77
|
+
async setup(flags, options) {
|
|
78
|
+
var _a;
|
|
79
|
+
if (flags.interactive) {
|
|
80
|
+
this.testLevel = await this.promptForTestLevel();
|
|
81
|
+
this.username = await this.promptForUsername();
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
if ((_a = options.directories) === null || _a === void 0 ? void 0 : _a.length) {
|
|
85
|
+
const directories = options.directories || [];
|
|
86
|
+
const selected = this.deployables.filter((d) => directories.includes(d.getPath()));
|
|
87
|
+
this.selectDeployables(selected);
|
|
88
|
+
}
|
|
89
|
+
this.testLevel = options.testLevel || (await this.promptForTestLevel());
|
|
90
|
+
this.username = options.username || (await this.promptForUsername());
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
testLevel: this.testLevel,
|
|
94
|
+
username: this.username,
|
|
95
|
+
apps: this.deployables.map((d) => d.getPath()),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
async deploy() {
|
|
99
|
+
const directories = this.deployables.map((d) => d.pkg.fullPath);
|
|
100
|
+
const name = this.deployables.map((p) => chalk_1.cyan.bold(p.getPath())).join(', ');
|
|
101
|
+
this.log(`${os_1.EOL}Deploying ${name} to ${this.username} using ${(0, config_1.resolveRestDeploy)()} API`);
|
|
102
|
+
const componentSet = await componentSetBuilder_1.ComponentSetBuilder.build({ sourcepath: directories });
|
|
103
|
+
const deploy = await componentSet.deploy({
|
|
104
|
+
usernameOrConnection: this.username,
|
|
105
|
+
apiOptions: { testLevel: this.testLevel },
|
|
106
|
+
});
|
|
107
|
+
new progressBar_1.DeployProgress(deploy).start();
|
|
108
|
+
const result = await deploy.pollStatus(500, kit_1.Duration.minutes(33).seconds);
|
|
109
|
+
(0, output_1.displaySuccesses)(result);
|
|
110
|
+
(0, output_1.displayFailures)(result);
|
|
111
|
+
(0, output_1.displayTestResults)(result, this.testLevel);
|
|
112
|
+
}
|
|
113
|
+
async promptForUsername() {
|
|
114
|
+
var _a;
|
|
115
|
+
const aliasOrUsername = (_a = core_1.ConfigAggregator.getValue(core_1.OrgConfigProperties.TARGET_ORG)) === null || _a === void 0 ? void 0 : _a.value;
|
|
116
|
+
const globalInfo = await core_1.GlobalInfo.getInstance();
|
|
117
|
+
const allAliases = globalInfo.aliases.getAll();
|
|
118
|
+
if (!aliasOrUsername) {
|
|
119
|
+
const authorizations = (await core_1.AuthInfo.listAllAuthorizations((orgAuth) => !orgAuth.error && orgAuth.isExpired !== true)).map((orgAuth) => {
|
|
120
|
+
const org = globalInfo.orgs.get(orgAuth.username);
|
|
121
|
+
const timestamp = org.timestamp ? new Date(org.timestamp) : new Date();
|
|
122
|
+
return { ...orgAuth, timestamp };
|
|
123
|
+
});
|
|
124
|
+
if (authorizations.length > 0) {
|
|
125
|
+
const newestAuths = authorizations.sort(compareOrgs);
|
|
126
|
+
const options = newestAuths.map((auth) => ({
|
|
127
|
+
name: auth.username,
|
|
128
|
+
aliases: Object.entries(allAliases)
|
|
129
|
+
.filter(([, usernameOrAlias]) => usernameOrAlias === auth.username)
|
|
130
|
+
.map(([alias]) => alias)
|
|
131
|
+
.join(', '),
|
|
132
|
+
isScratchOrg: auth.isScratchOrg ? 'Yes' : 'No',
|
|
133
|
+
value: auth.username,
|
|
134
|
+
}));
|
|
135
|
+
const columns = { name: 'Org', aliases: 'Aliases', isScratchOrg: 'Scratch Org' };
|
|
136
|
+
const { username } = await this.prompt([
|
|
137
|
+
{
|
|
138
|
+
name: 'username',
|
|
139
|
+
message: 'Select the org you want to deploy to:',
|
|
140
|
+
type: 'list',
|
|
141
|
+
choices: (0, sf_plugins_core_1.generateTableChoices)(columns, options, false),
|
|
142
|
+
},
|
|
143
|
+
]);
|
|
144
|
+
return username;
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
throw messages.createError('errors.NoOrgsToSelect');
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
return globalInfo.aliases.resolveUsername(aliasOrUsername);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
async promptForTestLevel() {
|
|
155
|
+
const { testLevel } = await this.prompt([
|
|
156
|
+
{
|
|
157
|
+
name: 'testLevel',
|
|
158
|
+
message: 'Select the test level you would like to run:',
|
|
159
|
+
type: 'list',
|
|
160
|
+
loop: false,
|
|
161
|
+
pageSize: 4,
|
|
162
|
+
choices: [
|
|
163
|
+
{ name: "Don't run tests", value: testLevel_1.TestLevel.NoTestRun, short: "Don't run tests" },
|
|
164
|
+
{ name: 'Run local tests', value: testLevel_1.TestLevel.RunLocalTests, short: 'Run local tests' },
|
|
165
|
+
{
|
|
166
|
+
name: 'Run all tests in environment',
|
|
167
|
+
value: testLevel_1.TestLevel.RunAllTestsInOrg,
|
|
168
|
+
short: 'Run all tests in environment',
|
|
169
|
+
},
|
|
170
|
+
],
|
|
171
|
+
},
|
|
172
|
+
]);
|
|
173
|
+
return testLevel;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
exports.MetadataDeployer = MetadataDeployer;
|
|
177
|
+
MetadataDeployer.NAME = 'Salesforce Apps';
|
|
178
|
+
//# sourceMappingURL=metadataDeployer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadataDeployer.js","sourceRoot":"","sources":["../../src/utils/metadataDeployer.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,2BAAyB;AACzB,iCAA6B;AAC7B,yCAA2C;AAC3C,2CAQ0B;AAC1B,iEAAyF;AAEzF,+DAA4D;AAC5D,qCAAiF;AACjF,2CAAwC;AACxC,+CAA+C;AAC/C,qCAA6C;AAE7C,eAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AAC5C,MAAM,QAAQ,GAAG,eAAQ,CAAC,YAAY,CAAC,oCAAoC,EAAE,iBAAiB,CAAC,CAAC;AAIhG,MAAM,WAAW,GAAG,CAAC,CAAuB,EAAE,CAAuB,EAAU,EAAE;IAC/E,iCAAiC;IACjC,IAAI,CAAC,CAAC,YAAY,IAAI,CAAC,CAAC,CAAC,YAAY,EAAE;QACrC,gDAAgD;QAChD,OAAO,CAAC,CAAC,CAAC;KACX;SAAM;QACL,8CAA8C;QAC9C,IAAI,CAAC,CAAC,YAAY,IAAI,CAAC,CAAC,YAAY,EAAE;YACpC,MAAM,UAAU,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;YACzC,MAAM,UAAU,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;YACzC,OAAO,UAAU,CAAC,OAAO,EAAE,GAAG,UAAU,CAAC,OAAO,EAA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
+
* 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.getSourceApiVersion = exports.getPackageDirs = exports.resolveTargetOrg = void 0;
|
|
10
|
+
const core_1 = require("@salesforce/core");
|
|
11
|
+
const ts_types_1 = require("@salesforce/ts-types");
|
|
12
|
+
const resolveTargetOrg = async (targetOrg) => {
|
|
13
|
+
const configuredTargetOrg = getConfigValue(core_1.OrgConfigProperties.TARGET_ORG);
|
|
14
|
+
const aliasOrUsername = targetOrg || configuredTargetOrg;
|
|
15
|
+
if (!aliasOrUsername) {
|
|
16
|
+
throw new core_1.SfdxError('no target environment specified', 'NoTargetEnv', [
|
|
17
|
+
'specify target environment with the --target-org flag',
|
|
18
|
+
'set the default environment with "sf config set target-org"',
|
|
19
|
+
]);
|
|
20
|
+
}
|
|
21
|
+
return (await core_1.GlobalInfo.getInstance()).aliases.resolveUsername(aliasOrUsername);
|
|
22
|
+
};
|
|
23
|
+
exports.resolveTargetOrg = resolveTargetOrg;
|
|
24
|
+
const getPackageDirs = async () => {
|
|
25
|
+
const project = await core_1.SfdxProject.resolve();
|
|
26
|
+
return project.getUniquePackageDirectories().map((pDir) => pDir.fullPath);
|
|
27
|
+
};
|
|
28
|
+
exports.getPackageDirs = getPackageDirs;
|
|
29
|
+
const getConfigValue = (key) => {
|
|
30
|
+
var _a;
|
|
31
|
+
return (_a = core_1.ConfigAggregator.getValue(key)) === null || _a === void 0 ? void 0 : _a.value;
|
|
32
|
+
};
|
|
33
|
+
const getSourceApiVersion = async () => {
|
|
34
|
+
const project = await core_1.SfdxProject.resolve();
|
|
35
|
+
const projectConfig = await project.resolveProjectConfig();
|
|
36
|
+
return (0, ts_types_1.getString)(projectConfig, 'sourceApiVersion');
|
|
37
|
+
};
|
|
38
|
+
exports.getSourceApiVersion = getSourceApiVersion;
|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AoB,EAAE,CAAC;IAC3D,OAAO,IAAA,oBAAS,EAAC,aAAa,EAAE,kBAAkB,CAAC,CAAC;AACtD,CAAC,CAAC;AAJW,QAAA,mBAAmB,uBAI9B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DeployResult, FileResponse, RetrieveResult } from '@sf/sdr';
|
|
2
|
+
import { Failures, Successes } from '@sf/sdr/lib/src/client/types';
|
|
3
|
+
import { TestLevel } from './testLevel';
|
|
4
|
+
export declare type PackageRetrieval = {
|
|
5
|
+
name: string;
|
|
6
|
+
path: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function asRelativePaths(fileResponses: FileResponse[]): FileResponse[];
|
|
9
|
+
/**
|
|
10
|
+
* Sorts file responds by type, then by filePath, then by fullName
|
|
11
|
+
*/
|
|
12
|
+
export declare function sortFileResponses(fileResponses: FileResponse[]): FileResponse[];
|
|
13
|
+
export declare function sortTestResults(results?: Failures[] | Successes[]): Failures[] | Successes[];
|
|
14
|
+
export declare function toArray<T>(entryOrArray: T | T[] | undefined): T[];
|
|
15
|
+
export declare function displaySuccesses(result: DeployResult | RetrieveResult): void;
|
|
16
|
+
export declare function displayPackages(result: RetrieveResult, packages: PackageRetrieval[]): void;
|
|
17
|
+
export declare function displayTestResults(result: DeployResult, testLevel: TestLevel): void;
|
|
18
|
+
export declare function displayFailures(result: DeployResult | RetrieveResult): void;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2021, 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.displayFailures = exports.displayTestResults = exports.displayPackages = exports.displaySuccesses = exports.toArray = exports.sortTestResults = exports.sortFileResponses = exports.asRelativePaths = void 0;
|
|
10
|
+
const os = require("os");
|
|
11
|
+
const path = require("path");
|
|
12
|
+
const core_1 = require("@oclif/core");
|
|
13
|
+
const chalk_1 = require("chalk");
|
|
14
|
+
const sdr_1 = require("@sf/sdr");
|
|
15
|
+
const types_1 = require("@sf/sdr/lib/src/client/types");
|
|
16
|
+
const ts_types_1 = require("@salesforce/ts-types");
|
|
17
|
+
const testLevel_1 = require("./testLevel");
|
|
18
|
+
function info(message) {
|
|
19
|
+
return (0, chalk_1.blue)((0, chalk_1.bold)(message));
|
|
20
|
+
}
|
|
21
|
+
function error(message) {
|
|
22
|
+
return (0, chalk_1.red)((0, chalk_1.bold)(message));
|
|
23
|
+
}
|
|
24
|
+
function table(responses, columns, options) {
|
|
25
|
+
// Interfaces cannot be casted to Record<string, unknown> so we have to cast to unknown first
|
|
26
|
+
// See https://github.com/microsoft/TypeScript/issues/15300
|
|
27
|
+
core_1.CliUx.ux.table(responses, columns, options);
|
|
28
|
+
}
|
|
29
|
+
function asRelativePaths(fileResponses) {
|
|
30
|
+
fileResponses.forEach((file) => {
|
|
31
|
+
if (file.filePath) {
|
|
32
|
+
file.filePath = path.relative(process.cwd(), file.filePath);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
return fileResponses;
|
|
36
|
+
}
|
|
37
|
+
exports.asRelativePaths = asRelativePaths;
|
|
38
|
+
/**
|
|
39
|
+
* Sorts file responds by type, then by filePath, then by fullName
|
|
40
|
+
*/
|
|
41
|
+
function sortFileResponses(fileResponses) {
|
|
42
|
+
return fileResponses.sort((i, j) => {
|
|
43
|
+
if (i.type === j.type && i.filePath && j.filePath) {
|
|
44
|
+
if (i.filePath === j.filePath) {
|
|
45
|
+
return i.fullName > j.fullName ? 1 : -1;
|
|
46
|
+
}
|
|
47
|
+
return (i === null || i === void 0 ? void 0 : i.filePath) > (j === null || j === void 0 ? void 0 : j.filePath) ? 1 : -1;
|
|
48
|
+
}
|
|
49
|
+
return i.type > j.type ? 1 : -1;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
exports.sortFileResponses = sortFileResponses;
|
|
53
|
+
function sortTestResults(results = []) {
|
|
54
|
+
return results.sort((a, b) => {
|
|
55
|
+
if (a.methodName === b.methodName) {
|
|
56
|
+
return a.name.localeCompare(b.name);
|
|
57
|
+
}
|
|
58
|
+
return a.methodName.localeCompare(b.methodName);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
exports.sortTestResults = sortTestResults;
|
|
62
|
+
function toArray(entryOrArray) {
|
|
63
|
+
if (entryOrArray) {
|
|
64
|
+
return Array.isArray(entryOrArray) ? entryOrArray : [entryOrArray];
|
|
65
|
+
}
|
|
66
|
+
return [];
|
|
67
|
+
}
|
|
68
|
+
exports.toArray = toArray;
|
|
69
|
+
function displaySuccesses(result) {
|
|
70
|
+
var _a;
|
|
71
|
+
const fileResponses = asRelativePaths((_a = result.getFileResponses()) !== null && _a !== void 0 ? _a : []);
|
|
72
|
+
const successes = sortFileResponses(fileResponses.filter((f) => f.state !== 'Failed'));
|
|
73
|
+
if (!successes.length)
|
|
74
|
+
return;
|
|
75
|
+
const columns = {
|
|
76
|
+
state: { header: 'State' },
|
|
77
|
+
fullName: { header: 'Name' },
|
|
78
|
+
type: { header: 'Type' },
|
|
79
|
+
filePath: { header: 'Path' },
|
|
80
|
+
};
|
|
81
|
+
const title = result instanceof sdr_1.DeployResult ? 'Deployed Source' : 'Retrieved Source';
|
|
82
|
+
const options = { title: info(title) };
|
|
83
|
+
core_1.CliUx.ux.log();
|
|
84
|
+
table(successes, columns, options);
|
|
85
|
+
}
|
|
86
|
+
exports.displaySuccesses = displaySuccesses;
|
|
87
|
+
function displayPackages(result, packages) {
|
|
88
|
+
if (packages === null || packages === void 0 ? void 0 : packages.length) {
|
|
89
|
+
const columns = {
|
|
90
|
+
name: { header: 'Package Name' },
|
|
91
|
+
path: { header: 'Converted Location' },
|
|
92
|
+
};
|
|
93
|
+
const title = 'Retrieved Packages';
|
|
94
|
+
const options = { title: info(title) };
|
|
95
|
+
core_1.CliUx.ux.log();
|
|
96
|
+
table(packages, columns, options);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.displayPackages = displayPackages;
|
|
100
|
+
function displayTestResults(result, testLevel) {
|
|
101
|
+
var _a, _b, _c, _d;
|
|
102
|
+
if (testLevel === testLevel_1.TestLevel.NoTestRun) {
|
|
103
|
+
core_1.CliUx.ux.log();
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if ((_a = result === null || result === void 0 ? void 0 : result.response) === null || _a === void 0 ? void 0 : _a.numberTestErrors) {
|
|
107
|
+
const failures = toArray((_c = (_b = result.response.details) === null || _b === void 0 ? void 0 : _b.runTestResult) === null || _c === void 0 ? void 0 : _c.failures);
|
|
108
|
+
const failureCount = (_d = result.response.details.runTestResult) === null || _d === void 0 ? void 0 : _d.numFailures;
|
|
109
|
+
const tests = sortTestResults(failures);
|
|
110
|
+
core_1.CliUx.ux.log();
|
|
111
|
+
core_1.CliUx.ux.log(error(`Test Failures [${failureCount}]`));
|
|
112
|
+
for (const test of tests) {
|
|
113
|
+
const testName = (0, chalk_1.underline)(`${test.name}.${test.methodName}`);
|
|
114
|
+
const stackTrace = test.stackTrace.replace(/\n/g, `${os.EOL} `);
|
|
115
|
+
core_1.CliUx.ux.log(`• ${testName}`);
|
|
116
|
+
core_1.CliUx.ux.log(` ${(0, chalk_1.dim)('message')}: ${test.message}`);
|
|
117
|
+
core_1.CliUx.ux.log(` ${(0, chalk_1.dim)('stacktrace')}: ${os.EOL} ${stackTrace}`);
|
|
118
|
+
core_1.CliUx.ux.log();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
core_1.CliUx.ux.log();
|
|
122
|
+
core_1.CliUx.ux.log(info('Test Results Summary'));
|
|
123
|
+
const passing = (0, ts_types_1.get)(result, 'response.numberTestsCompleted', 0);
|
|
124
|
+
const failing = (0, ts_types_1.get)(result, 'response.numberTestErrors', 0);
|
|
125
|
+
const total = (0, ts_types_1.get)(result, 'response.numberTestsTotal', 0);
|
|
126
|
+
const time = (0, ts_types_1.get)(result, 'response.details.runTestResult.totalTime', 0);
|
|
127
|
+
core_1.CliUx.ux.log(`Passing: ${passing}`);
|
|
128
|
+
core_1.CliUx.ux.log(`Failing: ${failing}`);
|
|
129
|
+
core_1.CliUx.ux.log(`Total: ${total}`);
|
|
130
|
+
if (time)
|
|
131
|
+
core_1.CliUx.ux.log(`Time: ${time}`);
|
|
132
|
+
}
|
|
133
|
+
exports.displayTestResults = displayTestResults;
|
|
134
|
+
function displayFailures(result) {
|
|
135
|
+
var _a;
|
|
136
|
+
if (result.response.status === types_1.RequestStatus.Succeeded)
|
|
137
|
+
return;
|
|
138
|
+
const fileResponses = asRelativePaths((_a = result.getFileResponses()) !== null && _a !== void 0 ? _a : []);
|
|
139
|
+
const failures = sortFileResponses(fileResponses.filter((f) => f.state === 'Failed'));
|
|
140
|
+
if (!failures.length)
|
|
141
|
+
return;
|
|
142
|
+
const columns = {
|
|
143
|
+
problemType: { header: 'Type' },
|
|
144
|
+
fullName: { header: 'Name' },
|
|
145
|
+
error: { header: 'Problem' },
|
|
146
|
+
};
|
|
147
|
+
const options = { title: error(`Component Failures [${failures.length}]`) };
|
|
148
|
+
core_1.CliUx.ux.log();
|
|
149
|
+
table(failures, columns, options);
|
|
150
|
+
}
|
|
151
|
+
exports.displayFailures = displayFailures;
|
|
152
|
+
//# sourceMappingURL=output.js.map
|