@salesforce/packaging 0.0.5 → 0.0.6
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 +8 -0
- package/lib/constants.d.ts +21 -0
- package/lib/constants.js +40 -0
- package/lib/interfaces/packagingInterfacesAndType.d.ts +76 -0
- package/lib/interfaces/packagingSObjects.d.ts +2 -1
- package/lib/interfaces/packagingSObjects.js +0 -6
- package/lib/package/index.d.ts +3 -0
- package/lib/package/index.js +6 -1
- package/lib/package/packageConvert.d.ts +11 -0
- package/lib/package/packageConvert.js +78 -0
- package/lib/package/packageCreate.d.ts +26 -0
- package/lib/package/packageCreate.js +115 -0
- package/lib/package/packageDelete.d.ts +3 -0
- package/lib/package/packageDelete.js +26 -0
- package/lib/package/packageVersion.d.ts +8 -0
- package/lib/package/packageVersion.js +27 -0
- package/lib/package/packageVersionCreate.d.ts +70 -0
- package/lib/package/packageVersionCreate.js +781 -0
- package/lib/package/packageVersionCreateRequest.d.ts +4 -0
- package/lib/package/packageVersionCreateRequest.js +85 -0
- package/lib/package/packageVersionList.d.ts +4 -24
- package/lib/package/packageVersionList.js +4 -5
- package/lib/package/profileApi.d.ts +55 -0
- package/lib/package/profileApi.js +275 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +1 -0
- package/lib/utils/packageUtils.d.ts +7 -6
- package/lib/utils/packageUtils.js +49 -11
- package/lib/utils/srcDevUtils.d.ts +12 -0
- package/lib/utils/srcDevUtils.js +62 -0
- package/lib/utils/versionNumber.d.ts +1 -0
- package/lib/utils/versionNumber.js +5 -0
- package/messages/messages.md +17 -0
- package/package.json +7 -4
- package/lib/package/packageVersionCreateRequestApi.d.ts +0 -17
- package/lib/package/packageVersionCreateRequestApi.js +0 -92
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.0.6](https://github.com/forcedotcom/packaging/compare/v0.0.5...v0.0.6) (2022-07-08)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
- add pkg create and delete apis ([dedc609](https://github.com/forcedotcom/packaging/commit/dedc609398da3aa2e23e9108b54a535a95e75bf8))
|
|
10
|
+
- add pkg create and delete apis ([a1e37e2](https://github.com/forcedotcom/packaging/commit/a1e37e28e7886c451364413d0a47f3bfbda2b822))
|
|
11
|
+
- bump version top 0.0.6 ([8d800f9](https://github.com/forcedotcom/packaging/commit/8d800f9264333362cfd0dae03c92d60f314aa098))
|
|
12
|
+
|
|
5
13
|
### [0.0.5](https://github.com/forcedotcom/packaging/compare/v0.0.4...v0.0.5) (2022-07-06)
|
|
6
14
|
|
|
7
15
|
### [0.0.4](https://github.com/forcedotcom/packaging/compare/v0.0.3...v0.0.4) (2022-06-23)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const consts: {
|
|
2
|
+
DEFAULT_USER_DIR_MODE: string;
|
|
3
|
+
DEFAULT_USER_FILE_MODE: string;
|
|
4
|
+
DEFAULT_STREAM_TIMEOUT_MINUTES: number;
|
|
5
|
+
MIN_STREAM_TIMEOUT_MINUTES: number;
|
|
6
|
+
DEFAULT_SRC_WAIT_MINUTES: number;
|
|
7
|
+
DEFAULT_MDAPI_WAIT_MINUTES: number;
|
|
8
|
+
DEFAULT_MDAPI_RETRIEVE_WAIT_MINUTES: number;
|
|
9
|
+
DEFAULT_MDAPI_POLL_INTERVAL_MINUTES: number;
|
|
10
|
+
DEFAULT_MDAPI_POLL_INTERVAL_MILLISECONDS: number;
|
|
11
|
+
MIN_SRC_WAIT_MINUTES: number;
|
|
12
|
+
MIN_SRC_DEPLOY_WAIT_MINUTES: number;
|
|
13
|
+
WORKSPACE_CONFIG_FILENAME: string;
|
|
14
|
+
OLD_WORKSPACE_CONFIG_FILENAME: string;
|
|
15
|
+
DEFAULT_DEV_HUB_USERNAME: string;
|
|
16
|
+
DEFAULT_USERNAME: string;
|
|
17
|
+
ACKNOWLEDGED_USAGE_COLLECTION_FILENAME: string;
|
|
18
|
+
PACKAGE_VERSION_INFO_FILE_ZIP: string;
|
|
19
|
+
INSTANCE_URL_TOKEN: string;
|
|
20
|
+
PACKAGE2_DESCRIPTOR_FILE: string;
|
|
21
|
+
};
|
package/lib/constants.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
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.consts = void 0;
|
|
10
|
+
/* --------------------------------------------------------------------------------------------------------------------
|
|
11
|
+
* WARNING: This file has been deprecated and should now be considered locked against further changes. Its contents
|
|
12
|
+
* have been partially or wholly superseded by functionality included in the @salesforce/core npm package, and exists
|
|
13
|
+
* now to service prior uses in this repository only until they can be ported to use the new @salesforce/core library.
|
|
14
|
+
*
|
|
15
|
+
* If you need or want help deciding where to add new functionality or how to migrate to the new library, please
|
|
16
|
+
* contact the CLI team at alm-cli@salesforce.com.
|
|
17
|
+
* ----------------------------------------------------------------------------------------------------------------- */
|
|
18
|
+
exports.consts = {
|
|
19
|
+
DEFAULT_USER_DIR_MODE: '700',
|
|
20
|
+
DEFAULT_USER_FILE_MODE: '600',
|
|
21
|
+
DEFAULT_STREAM_TIMEOUT_MINUTES: 6,
|
|
22
|
+
MIN_STREAM_TIMEOUT_MINUTES: 2,
|
|
23
|
+
DEFAULT_SRC_WAIT_MINUTES: 33,
|
|
24
|
+
DEFAULT_MDAPI_WAIT_MINUTES: 0,
|
|
25
|
+
DEFAULT_MDAPI_RETRIEVE_WAIT_MINUTES: -1,
|
|
26
|
+
DEFAULT_MDAPI_POLL_INTERVAL_MINUTES: 0.1,
|
|
27
|
+
DEFAULT_MDAPI_POLL_INTERVAL_MILLISECONDS: 0.1 * 60 * 1000,
|
|
28
|
+
MIN_SRC_WAIT_MINUTES: 1,
|
|
29
|
+
MIN_SRC_DEPLOY_WAIT_MINUTES: 0,
|
|
30
|
+
WORKSPACE_CONFIG_FILENAME: 'sfdx-project.json',
|
|
31
|
+
OLD_WORKSPACE_CONFIG_FILENAME: 'sfdx-workspace.json',
|
|
32
|
+
DEFAULT_DEV_HUB_USERNAME: 'defaultdevhubusername',
|
|
33
|
+
DEFAULT_USERNAME: 'defaultusername',
|
|
34
|
+
ACKNOWLEDGED_USAGE_COLLECTION_FILENAME: 'acknowledgedUsageCollection.json',
|
|
35
|
+
PACKAGE_VERSION_INFO_FILE_ZIP: 'package-version-info.zip',
|
|
36
|
+
// tokens to be replaced on source:push
|
|
37
|
+
INSTANCE_URL_TOKEN: '__SFDX_INSTANCE_URL__',
|
|
38
|
+
PACKAGE2_DESCRIPTOR_FILE: 'package2-descriptor.json',
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { Duration } from '@salesforce/kit';
|
|
2
|
+
import { Connection, SfProject } from '@salesforce/core';
|
|
3
|
+
import { SaveResult } from 'jsforce';
|
|
4
|
+
import { ProfileApi } from '../package/profileApi';
|
|
2
5
|
import { PackagingSObjects } from './packagingSObjects';
|
|
3
6
|
import Package2VersionStatus = PackagingSObjects.Package2VersionStatus;
|
|
4
7
|
export interface IPackage {
|
|
@@ -89,3 +92,76 @@ export declare type PackageVersionListResult = {
|
|
|
89
92
|
BuildDurationInSeconds?: number;
|
|
90
93
|
HasMetadataRemoved?: boolean;
|
|
91
94
|
};
|
|
95
|
+
export declare type PackageType = 'Managed' | 'Unlocked';
|
|
96
|
+
export declare type PackageCreateOptions = {
|
|
97
|
+
name: string;
|
|
98
|
+
description: string;
|
|
99
|
+
noNamespace: boolean;
|
|
100
|
+
orgDependent: boolean;
|
|
101
|
+
packageType: PackageType;
|
|
102
|
+
errorNotificationUsername: string;
|
|
103
|
+
path: string;
|
|
104
|
+
};
|
|
105
|
+
export declare type PackageVersionQueryOptions = {
|
|
106
|
+
project: SfProject;
|
|
107
|
+
orderBy: string;
|
|
108
|
+
modifiedLastDays: number;
|
|
109
|
+
createdLastDays: number;
|
|
110
|
+
packages: string[];
|
|
111
|
+
connection: Connection;
|
|
112
|
+
verbose: boolean;
|
|
113
|
+
concise: boolean;
|
|
114
|
+
isReleased: boolean;
|
|
115
|
+
};
|
|
116
|
+
export declare type PackageSaveResult = SaveResult;
|
|
117
|
+
export declare type PackageVersionCreateRequestOptions = {
|
|
118
|
+
path: string;
|
|
119
|
+
preserve: boolean;
|
|
120
|
+
definitionfile?: string;
|
|
121
|
+
codecoverage?: boolean;
|
|
122
|
+
branch?: string;
|
|
123
|
+
skipancestorcheck?: boolean;
|
|
124
|
+
};
|
|
125
|
+
export declare type MDFolderForArtifactOptions = {
|
|
126
|
+
packageName?: string;
|
|
127
|
+
sourceDir?: string;
|
|
128
|
+
outputDir?: string;
|
|
129
|
+
manifest?: string;
|
|
130
|
+
sourcePaths?: string[];
|
|
131
|
+
metadataPaths?: string[];
|
|
132
|
+
deploydir?: string;
|
|
133
|
+
};
|
|
134
|
+
export declare type PackageVersionOptions = {
|
|
135
|
+
connection: Connection;
|
|
136
|
+
project: SfProject;
|
|
137
|
+
};
|
|
138
|
+
export declare type PackageVersionCreateOptions = PackageVersionOptions & {
|
|
139
|
+
branch: string;
|
|
140
|
+
buildinstance: string;
|
|
141
|
+
codecoverage: boolean;
|
|
142
|
+
definitionfile: string;
|
|
143
|
+
installationkey: string;
|
|
144
|
+
installationkeybypass: boolean;
|
|
145
|
+
package: string;
|
|
146
|
+
path: string;
|
|
147
|
+
postinstallscript: string;
|
|
148
|
+
postinstallurl: string;
|
|
149
|
+
preserve: boolean;
|
|
150
|
+
releasenotesurl: string;
|
|
151
|
+
skipancestorcheck: boolean;
|
|
152
|
+
skipvalidation: boolean;
|
|
153
|
+
sourceorg: string;
|
|
154
|
+
tag: string;
|
|
155
|
+
uninstallscript: string;
|
|
156
|
+
validateschema: boolean;
|
|
157
|
+
versiondescription: string;
|
|
158
|
+
versionname: string;
|
|
159
|
+
versionnumber: string;
|
|
160
|
+
wait: Duration;
|
|
161
|
+
profileApi?: ProfileApi;
|
|
162
|
+
};
|
|
163
|
+
export declare type PackageVersionCreateRequestQueryOptions = {
|
|
164
|
+
createdlastdays?: number;
|
|
165
|
+
connection?: Connection;
|
|
166
|
+
status?: string;
|
|
167
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PackageType } from './packagingInterfacesAndType';
|
|
1
2
|
export declare namespace PackagingSObjects {
|
|
2
3
|
type Package2 = {
|
|
3
4
|
Id: string;
|
|
@@ -11,7 +12,7 @@ export declare namespace PackagingSObjects {
|
|
|
11
12
|
Name: string;
|
|
12
13
|
Description: string;
|
|
13
14
|
NamespacePrefix: string;
|
|
14
|
-
ContainerOptions:
|
|
15
|
+
ContainerOptions: PackageType;
|
|
15
16
|
IsDeprecated: boolean;
|
|
16
17
|
IsOrgDependent: boolean;
|
|
17
18
|
ConvertedFromPackageId: string;
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PackagingSObjects = 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
4
|
var PackagingSObjects;
|
|
11
5
|
(function (PackagingSObjects) {
|
|
12
6
|
let Package2VersionStatus;
|
package/lib/package/index.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export * from './package';
|
|
2
2
|
export * from './packageVersion2GP';
|
|
3
3
|
export * from './packageList';
|
|
4
|
+
export * from './packageVersionCreateRequest';
|
|
4
5
|
export { listPackageVersions } from './packageVersionList';
|
|
6
|
+
export { createPackage } from './packageCreate';
|
|
7
|
+
export { deletePackage } from './packageDelete';
|
package/lib/package/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.listPackageVersions = void 0;
|
|
17
|
+
exports.deletePackage = exports.createPackage = exports.listPackageVersions = void 0;
|
|
18
18
|
/*
|
|
19
19
|
* Copyright (c) 2022, salesforce.com, inc.
|
|
20
20
|
* All rights reserved.
|
|
@@ -24,6 +24,11 @@ exports.listPackageVersions = void 0;
|
|
|
24
24
|
__exportStar(require("./package"), exports);
|
|
25
25
|
__exportStar(require("./packageVersion2GP"), exports);
|
|
26
26
|
__exportStar(require("./packageList"), exports);
|
|
27
|
+
__exportStar(require("./packageVersionCreateRequest"), exports);
|
|
27
28
|
var packageVersionList_1 = require("./packageVersionList");
|
|
28
29
|
Object.defineProperty(exports, "listPackageVersions", { enumerable: true, get: function () { return packageVersionList_1.listPackageVersions; } });
|
|
30
|
+
var packageCreate_1 = require("./packageCreate");
|
|
31
|
+
Object.defineProperty(exports, "createPackage", { enumerable: true, get: function () { return packageCreate_1.createPackage; } });
|
|
32
|
+
var packageDelete_1 = require("./packageDelete");
|
|
33
|
+
Object.defineProperty(exports, "deletePackage", { enumerable: true, get: function () { return packageDelete_1.deletePackage; } });
|
|
29
34
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Connection, Org, SfProject } from '@salesforce/core';
|
|
2
|
+
import { Duration } from '@salesforce/kit';
|
|
3
|
+
import { Package2VersionCreateRequestResult } from '../interfaces';
|
|
4
|
+
declare type ConvertPackageOptions = {
|
|
5
|
+
installationKey: string;
|
|
6
|
+
installationKeyBypass: boolean;
|
|
7
|
+
wait: Duration;
|
|
8
|
+
buildInstance: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function convertPackage(pkg: string, org: Org, connection: Connection, project: SfProject, options: ConvertPackageOptions): Promise<Package2VersionCreateRequestResult>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,78 @@
|
|
|
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.convertPackage = void 0;
|
|
10
|
+
const path = require("path");
|
|
11
|
+
const util = require("util");
|
|
12
|
+
const os = require("os");
|
|
13
|
+
const fs = require("fs");
|
|
14
|
+
const kit_1 = require("@salesforce/kit");
|
|
15
|
+
const testSetup_1 = require("@salesforce/core/lib/testSetup");
|
|
16
|
+
const pkgUtils = require("../utils/packageUtils");
|
|
17
|
+
const constants_1 = require("../constants");
|
|
18
|
+
const srcDevUtil = require("../utils/srcDevUtils");
|
|
19
|
+
const packageVersionCreateRequest_1 = require("./packageVersionCreateRequest");
|
|
20
|
+
async function convertPackage(pkg, org, connection, project, options) {
|
|
21
|
+
let maxRetries = 0;
|
|
22
|
+
const branch = 'main';
|
|
23
|
+
if (options.wait) {
|
|
24
|
+
maxRetries = (60 / pkgUtils.POLL_INTERVAL_SECONDS) * options.wait.seconds;
|
|
25
|
+
}
|
|
26
|
+
const packageId = await pkgUtils.findOrCreatePackage2(pkg, connection);
|
|
27
|
+
const request = await createPackageVersionCreateRequest(context, packageId);
|
|
28
|
+
const createResult = await connection.tooling.create('Package2VersionCreateRequest', request);
|
|
29
|
+
if (!createResult.success) {
|
|
30
|
+
const errStr = createResult.errors && createResult.errors.length ? createResult.errors.join(', ') : createResult.errors;
|
|
31
|
+
throw new Error(`Failed to create request${createResult.id ? ` [${createResult.id}]` : ''}: ${errStr}`);
|
|
32
|
+
}
|
|
33
|
+
let results;
|
|
34
|
+
if (options.wait) {
|
|
35
|
+
results = await pkgUtils.pollForStatusWithInterval(createResult.id, maxRetries, packageId, branch, project, connection, new kit_1.Duration(pkgUtils.POLL_INTERVAL_SECONDS, kit_1.Duration.Unit.SECONDS));
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
results = await (0, packageVersionCreateRequest_1.byId)(packageId, connection);
|
|
39
|
+
}
|
|
40
|
+
return util.isArray(results) ? results[0] : results;
|
|
41
|
+
}
|
|
42
|
+
exports.convertPackage = convertPackage;
|
|
43
|
+
/**
|
|
44
|
+
* Convert the list of command line options to a JSON object that can be used to create an Package2VersionCreateRequest entity.
|
|
45
|
+
*
|
|
46
|
+
* @param context: command context
|
|
47
|
+
* @param packageId: package2 id to create a package version for
|
|
48
|
+
* @returns {{Package2Id: string, Package2VersionMetadata: *, Tag: *, Branch: number}}
|
|
49
|
+
* @private
|
|
50
|
+
*/
|
|
51
|
+
async function createPackageVersionCreateRequest(context, packageId) {
|
|
52
|
+
const uniqueId = (0, testSetup_1.uniqid)({ template: `${packageId}-%s` });
|
|
53
|
+
const packageVersTmpRoot = path.join(os.tmpdir(), uniqueId);
|
|
54
|
+
const packageVersBlobDirectory = path.join(packageVersTmpRoot, 'package-version-info');
|
|
55
|
+
const packageVersBlobZipFile = path.join(packageVersTmpRoot, constants_1.consts.PACKAGE_VERSION_INFO_FILE_ZIP);
|
|
56
|
+
const packageDescriptorJson = {
|
|
57
|
+
id: packageId,
|
|
58
|
+
};
|
|
59
|
+
await fs.promises.mkdir(packageVersTmpRoot, { recursive: true });
|
|
60
|
+
await fs.promises.mkdir(packageVersBlobDirectory, { recursive: true });
|
|
61
|
+
await fs.promises.writeFile(path.join(packageVersBlobDirectory, constants_1.consts.PACKAGE2_DESCRIPTOR_FILE), JSON.stringify(packageDescriptorJson, undefined, 2));
|
|
62
|
+
// Zip the Version Info and package.zip files into another zip
|
|
63
|
+
await srcDevUtil.zipDir(packageVersBlobDirectory, packageVersBlobZipFile);
|
|
64
|
+
return createRequestObject(packageId, context, packageVersTmpRoot, packageVersBlobZipFile);
|
|
65
|
+
}
|
|
66
|
+
async function createRequestObject(packageId, options, packageVersTmpRoot, packageVersBlobZipFile) {
|
|
67
|
+
const zipFileBase64 = (await fs.promises.readFile(packageVersBlobZipFile)).toString('base64');
|
|
68
|
+
const requestObject = {
|
|
69
|
+
Package2Id: packageId,
|
|
70
|
+
VersionInfo: zipFileBase64,
|
|
71
|
+
InstallKey: options.installationkey,
|
|
72
|
+
Instance: options.buildinstance,
|
|
73
|
+
IsConversionRequest: true,
|
|
74
|
+
};
|
|
75
|
+
await fs.promises.unlink(packageVersTmpRoot);
|
|
76
|
+
return requestObject;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=packageConvert.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Connection, NamedPackageDir, PackageDir, SfProject } from '@salesforce/core';
|
|
2
|
+
import { PackageCreateOptions, PackagingSObjects } from '../interfaces';
|
|
3
|
+
declare type Package2Request = Pick<PackagingSObjects.Package2, 'Name' | 'Description' | 'NamespacePrefix' | 'ContainerOptions' | 'IsOrgDependent' | 'PackageErrorUsername'>;
|
|
4
|
+
export declare function _createPackage2RequestFromContext(project: SfProject, options: PackageCreateOptions): Package2Request;
|
|
5
|
+
/**
|
|
6
|
+
* Generate packageDirectory json entry for this package that can be written to sfdx-project.json
|
|
7
|
+
*
|
|
8
|
+
* @param project
|
|
9
|
+
* @param packageId the 0Ho id of the package to create the entry for
|
|
10
|
+
* @private
|
|
11
|
+
*/
|
|
12
|
+
export declare function _generatePackageDirEntry(project: SfProject, options: PackageCreateOptions): PackageDir[] | NamedPackageDir[];
|
|
13
|
+
/**
|
|
14
|
+
* Generate package alias json entry for this package that can be written to sfdx-project.json
|
|
15
|
+
*
|
|
16
|
+
* @param context
|
|
17
|
+
* @param packageId the 0Ho id of the package to create the alias entry for
|
|
18
|
+
* @private
|
|
19
|
+
*/
|
|
20
|
+
export declare function _generatePackageAliasEntry(project: SfProject, options: PackageCreateOptions, packageId: string): {
|
|
21
|
+
[key: string]: string;
|
|
22
|
+
};
|
|
23
|
+
export declare function createPackage(connection: Connection, project: SfProject, options: PackageCreateOptions): Promise<{
|
|
24
|
+
Id: string;
|
|
25
|
+
}>;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2020, 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.createPackage = exports._generatePackageAliasEntry = exports._generatePackageDirEntry = exports._createPackage2RequestFromContext = void 0;
|
|
10
|
+
const core_1 = require("@salesforce/core");
|
|
11
|
+
const ts_types_1 = require("@salesforce/ts-types");
|
|
12
|
+
const pkgUtils = require("../utils/packageUtils");
|
|
13
|
+
core_1.Messages.importMessagesDirectory(__dirname);
|
|
14
|
+
const messages = core_1.Messages.loadMessages('@salesforce/packaging', 'messages');
|
|
15
|
+
function _createPackage2RequestFromContext(project, options) {
|
|
16
|
+
const namespace = options.noNamespace ? '' : project.getSfProjectJson().getContents().namespace || '';
|
|
17
|
+
return {
|
|
18
|
+
Name: options.name,
|
|
19
|
+
Description: options.description,
|
|
20
|
+
NamespacePrefix: namespace,
|
|
21
|
+
ContainerOptions: options.packageType,
|
|
22
|
+
IsOrgDependent: options.orgDependent,
|
|
23
|
+
PackageErrorUsername: options.errorNotificationUsername,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
exports._createPackage2RequestFromContext = _createPackage2RequestFromContext;
|
|
27
|
+
/**
|
|
28
|
+
* Generate packageDirectory json entry for this package that can be written to sfdx-project.json
|
|
29
|
+
*
|
|
30
|
+
* @param project
|
|
31
|
+
* @param packageId the 0Ho id of the package to create the entry for
|
|
32
|
+
* @private
|
|
33
|
+
*/
|
|
34
|
+
function _generatePackageDirEntry(project, options) {
|
|
35
|
+
var _a, _b;
|
|
36
|
+
let packageDirs = project.getPackageDirectories();
|
|
37
|
+
if (!packageDirs) {
|
|
38
|
+
packageDirs = [];
|
|
39
|
+
}
|
|
40
|
+
// add an entry if it doesn't exist
|
|
41
|
+
// or update an existing entry if it matches path but has no package or id attribute (W-5092620)
|
|
42
|
+
let packageDir = project.getPackage(options.name) ||
|
|
43
|
+
project
|
|
44
|
+
.getPackageDirectories()
|
|
45
|
+
// TODO: I don't understand where id is coming from, because it is not in sfdx-project.json schema
|
|
46
|
+
.find((pd) => pd.path === options.path && !pd.id && !pd.package);
|
|
47
|
+
if (packageDir) {
|
|
48
|
+
// update existing entry
|
|
49
|
+
packageDir.package = options.name;
|
|
50
|
+
(_a = packageDir.versionName) !== null && _a !== void 0 ? _a : (packageDir.versionName = pkgUtils.DEFAULT_PACKAGE_DIR.versionName);
|
|
51
|
+
(_b = packageDir.versionNumber) !== null && _b !== void 0 ? _b : (packageDir.versionNumber = pkgUtils.DEFAULT_PACKAGE_DIR.versionNumber);
|
|
52
|
+
// set as default if this is the only entry or no other entry is the default
|
|
53
|
+
if (!Reflect.getOwnPropertyDescriptor(packageDir, 'default')) {
|
|
54
|
+
packageDir.default = !pkgUtils.getConfigPackageDirectory(packageDirs, 'default', true);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
// add new entry
|
|
59
|
+
packageDir = pkgUtils.DEFAULT_PACKAGE_DIR;
|
|
60
|
+
packageDir.package = options.name;
|
|
61
|
+
// set as default if this is the only entry or no other entry is the default
|
|
62
|
+
packageDir.default = !pkgUtils.getConfigPackageDirectory(packageDirs, 'default', true);
|
|
63
|
+
packageDir.path = options.path;
|
|
64
|
+
packageDirs.push(packageDir);
|
|
65
|
+
}
|
|
66
|
+
return packageDirs;
|
|
67
|
+
}
|
|
68
|
+
exports._generatePackageDirEntry = _generatePackageDirEntry;
|
|
69
|
+
/**
|
|
70
|
+
* Generate package alias json entry for this package that can be written to sfdx-project.json
|
|
71
|
+
*
|
|
72
|
+
* @param context
|
|
73
|
+
* @param packageId the 0Ho id of the package to create the alias entry for
|
|
74
|
+
* @private
|
|
75
|
+
*/
|
|
76
|
+
function _generatePackageAliasEntry(project, options, packageId) {
|
|
77
|
+
const packageAliases = project.getSfProjectJson().getContents().packageAliases || {};
|
|
78
|
+
const packageName = options.name;
|
|
79
|
+
packageAliases[packageName] = packageId;
|
|
80
|
+
return packageAliases;
|
|
81
|
+
}
|
|
82
|
+
exports._generatePackageAliasEntry = _generatePackageAliasEntry;
|
|
83
|
+
async function createPackage(connection, project, options) {
|
|
84
|
+
// strip trailing slash from path param
|
|
85
|
+
options.path = options.path.replace(/\/$/, '');
|
|
86
|
+
const request = _createPackage2RequestFromContext(project, options);
|
|
87
|
+
let packageId = null;
|
|
88
|
+
const createResult = await connection.tooling
|
|
89
|
+
.sobject('Package2')
|
|
90
|
+
.create(request)
|
|
91
|
+
.catch((err) => {
|
|
92
|
+
const error = (0, ts_types_1.isString)(err) ? err : err.message;
|
|
93
|
+
throw core_1.SfError.wrap(error);
|
|
94
|
+
});
|
|
95
|
+
if (!createResult.success) {
|
|
96
|
+
throw pkgUtils.combineSaveErrors('Package2', 'create', createResult.errors);
|
|
97
|
+
}
|
|
98
|
+
packageId = createResult.id;
|
|
99
|
+
const queryResult = await connection.tooling.query(`SELECT Id FROM Package2 WHERE Id='${packageId}'`);
|
|
100
|
+
if (!(queryResult === null || queryResult === void 0 ? void 0 : queryResult.records[0])) {
|
|
101
|
+
throw messages.createError('unableToFindPackageWithId', [packageId]);
|
|
102
|
+
}
|
|
103
|
+
const record = queryResult.records[0];
|
|
104
|
+
if (!process.env.SFDX_PROJECT_AUTOUPDATE_DISABLE_FOR_PACKAGE_CREATE) {
|
|
105
|
+
const packageDirectory = _generatePackageDirEntry(project, options);
|
|
106
|
+
const packageAliases = _generatePackageAliasEntry(project, options, record.Id);
|
|
107
|
+
const projectJson = project.getSfProjectJson();
|
|
108
|
+
projectJson.set('packageDirectories', packageDirectory);
|
|
109
|
+
projectJson.set('packageAliases', packageAliases);
|
|
110
|
+
await projectJson.write();
|
|
111
|
+
}
|
|
112
|
+
return { Id: record.Id };
|
|
113
|
+
}
|
|
114
|
+
exports.createPackage = createPackage;
|
|
115
|
+
//# sourceMappingURL=packageCreate.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
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.deletePackage = void 0;
|
|
10
|
+
const pkgUtils = require("../utils/packageUtils");
|
|
11
|
+
const utils_1 = require("../utils");
|
|
12
|
+
async function deletePackage(idOrAlias, project, connection, undelete) {
|
|
13
|
+
const packageId = pkgUtils.getPackageIdFromAlias(idOrAlias, project);
|
|
14
|
+
pkgUtils.validateId(pkgUtils.BY_LABEL.PACKAGE_ID, packageId);
|
|
15
|
+
const request = {};
|
|
16
|
+
request.Id = packageId;
|
|
17
|
+
const isUndelete = undelete;
|
|
18
|
+
request.IsDeprecated = !isUndelete;
|
|
19
|
+
const updateResult = await connection.tooling.update('Package2', request);
|
|
20
|
+
if (!updateResult.success) {
|
|
21
|
+
throw (0, utils_1.combineSaveErrors)('Package2', 'update', updateResult.errors);
|
|
22
|
+
}
|
|
23
|
+
return updateResult;
|
|
24
|
+
}
|
|
25
|
+
exports.deletePackage = deletePackage;
|
|
26
|
+
//# sourceMappingURL=packageDelete.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Package2VersionCreateRequestResult, PackageVersionCreateOptions, PackageVersionOptions } from '../interfaces';
|
|
2
|
+
export declare class PackageVersion {
|
|
3
|
+
private options;
|
|
4
|
+
private readonly project;
|
|
5
|
+
private readonly connection;
|
|
6
|
+
protected constructor(options: PackageVersionOptions);
|
|
7
|
+
createPackageVersion(options: PackageVersionCreateOptions): Promise<Partial<Package2VersionCreateRequestResult>>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2020, 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.PackageVersion = void 0;
|
|
10
|
+
const core_1 = require("@salesforce/core");
|
|
11
|
+
const packageVersionCreate_1 = require("./packageVersionCreate");
|
|
12
|
+
core_1.Messages.importMessagesDirectory(__dirname);
|
|
13
|
+
// const messages = Messages.loadMessages('@salesforce/packaging', 'messages');
|
|
14
|
+
// const logger = Logger.childFromRoot('packageVersionCreate');
|
|
15
|
+
class PackageVersion {
|
|
16
|
+
constructor(options) {
|
|
17
|
+
this.options = options;
|
|
18
|
+
this.connection = this.options.connection;
|
|
19
|
+
this.project = this.options.project;
|
|
20
|
+
}
|
|
21
|
+
async createPackageVersion(options) {
|
|
22
|
+
const pvc = new packageVersionCreate_1.PackageVersionCreate(options);
|
|
23
|
+
return pvc.createPackageVersion(options);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.PackageVersion = PackageVersion;
|
|
27
|
+
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Connection } from '@salesforce/core';
|
|
2
|
+
import { Package2VersionCreateRequestResult, PackageVersionCreateOptions } from '../interfaces';
|
|
3
|
+
export declare class PackageVersionCreate {
|
|
4
|
+
private options;
|
|
5
|
+
private apiVersionFromPackageXml;
|
|
6
|
+
private packageDirs;
|
|
7
|
+
private readonly project;
|
|
8
|
+
private readonly connection;
|
|
9
|
+
constructor(options: PackageVersionCreateOptions);
|
|
10
|
+
createPackageVersion(options: PackageVersionCreateOptions): Promise<Partial<Package2VersionCreateRequestResult>>;
|
|
11
|
+
listRequest(createdlastdays?: number, status?: string): Promise<Package2VersionCreateRequestResult[]>;
|
|
12
|
+
listRequestById(id: string, connection: Connection): Promise<Package2VersionCreateRequestResult[]>;
|
|
13
|
+
rejectWithInstallKeyError(): Promise<never>;
|
|
14
|
+
private generateMDFolderForArtifact;
|
|
15
|
+
private validateDependencyValues;
|
|
16
|
+
/**
|
|
17
|
+
* A dependency in the workspace config file may be specified using either a subscriber package version id (04t)
|
|
18
|
+
* or a package Id (0Ho) + a version number. Additionally, a build number may be the actual build number, or a
|
|
19
|
+
* keyword: LATEST or RELEASED (meaning the latest or released build number for a given major.minor.patch).
|
|
20
|
+
*
|
|
21
|
+
* This method resolves a package Id + version number to a subscriber package version id (04t)
|
|
22
|
+
* and adds it as a SubscriberPackageVersionId parameter in the dependency object.
|
|
23
|
+
*/
|
|
24
|
+
private retrieveSubscriberPackageVersionId;
|
|
25
|
+
private resolveBuildNumber;
|
|
26
|
+
private createRequestObject;
|
|
27
|
+
private getPackageDescriptorJsonFromPackageId;
|
|
28
|
+
/**
|
|
29
|
+
* Convert the list of command line options to a JSON object that can be used to create an Package2VersionCreateRequest entity.
|
|
30
|
+
*
|
|
31
|
+
* @param options
|
|
32
|
+
* @param packageId
|
|
33
|
+
* @param versionNumberString
|
|
34
|
+
* @returns {{Package2Id: (*|p|boolean), Package2VersionMetadata: *, Tag: *, Branch: number}}
|
|
35
|
+
* @private
|
|
36
|
+
*/
|
|
37
|
+
private createPackageVersionCreateRequestFromOptions;
|
|
38
|
+
private resolveApexTestPermissions;
|
|
39
|
+
private resolveUnpackagedMetadata;
|
|
40
|
+
private getPackagePropertyFromPackage;
|
|
41
|
+
private getPackageValuePropertyFromDirectory;
|
|
42
|
+
/**
|
|
43
|
+
* Returns the property value that corresponds to the propertyToLookup. This value found for a particular
|
|
44
|
+
* package directory element that matches the knownProperty and knownValue. In other words, we locate a package
|
|
45
|
+
* directory element whose knownProperty matches the knownValue, then we grab the value for the propertyToLookup
|
|
46
|
+
* and return it.
|
|
47
|
+
*
|
|
48
|
+
* @param packageDirs The list of all the package directories from the sfdx-project.json
|
|
49
|
+
* @param propertyToLookup The property ID whose value we want to find
|
|
50
|
+
* @param knownProperty The JSON property in the packageDirectories that is already known
|
|
51
|
+
* @param knownValue The value that corresponds to the knownProperty in the packageDirectories JSON
|
|
52
|
+
* @param knownFlag The flag details e.g. short/long name, etc. Only used for the error message
|
|
53
|
+
* @param options
|
|
54
|
+
*/
|
|
55
|
+
private getConfigPackageDirectoriesValue;
|
|
56
|
+
private packageVersionCreate;
|
|
57
|
+
private resolveCanonicalPackageProperty;
|
|
58
|
+
private validateVersionNumber;
|
|
59
|
+
private resolveUserLicenses;
|
|
60
|
+
private resolveOrgDependentPollingTime;
|
|
61
|
+
private validateFlagsForPackageType;
|
|
62
|
+
/**
|
|
63
|
+
* Cleans invalid attribute(s) from the packageDescriptorJSON
|
|
64
|
+
*/
|
|
65
|
+
private cleanPackageDescriptorJson;
|
|
66
|
+
/**
|
|
67
|
+
* Sets default or override values for packageDescriptorJSON attribs
|
|
68
|
+
*/
|
|
69
|
+
private setPackageDescriptorJsonValues;
|
|
70
|
+
}
|