@salesforce/packaging 0.0.3 → 0.0.4
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 +2 -0
- package/lib/interfaces/packagingInterfacesAndType.d.ts +35 -0
- package/lib/package/index.d.ts +1 -0
- package/lib/package/index.js +3 -0
- package/lib/package/packageVersionList.d.ts +29 -0
- package/lib/package/packageVersionList.js +92 -0
- package/lib/utils/packageUtils.js +2 -2
- package/package.json +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
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.4](https://github.com/forcedotcom/packaging/compare/v0.0.3...v0.0.4) (2022-06-23)
|
|
6
|
+
|
|
5
7
|
### [0.0.3](https://github.com/forcedotcom/packaging/compare/v0.0.2-test-02...v0.0.3) (2022-06-16)
|
|
6
8
|
|
|
7
9
|
### Bug Fixes
|
|
@@ -54,3 +54,38 @@ export declare type Package2VersionCreateEventData = {
|
|
|
54
54
|
message?: string;
|
|
55
55
|
timeRemaining?: Duration;
|
|
56
56
|
};
|
|
57
|
+
export declare type PackageVersionListResult = {
|
|
58
|
+
Id: string;
|
|
59
|
+
Package2Id: string;
|
|
60
|
+
SubscriberPackageVersionId: string;
|
|
61
|
+
Name: string;
|
|
62
|
+
Package2: {
|
|
63
|
+
[key: string]: unknown;
|
|
64
|
+
Name: string;
|
|
65
|
+
NamespacePrefix: string;
|
|
66
|
+
IsOrgDependent?: boolean;
|
|
67
|
+
};
|
|
68
|
+
Description: string;
|
|
69
|
+
Tag: string;
|
|
70
|
+
Branch: string;
|
|
71
|
+
MajorVersion: string;
|
|
72
|
+
MinorVersion: string;
|
|
73
|
+
PatchVersion: string;
|
|
74
|
+
BuildNumber: string;
|
|
75
|
+
IsReleased: boolean;
|
|
76
|
+
CreatedDate: string;
|
|
77
|
+
LastModifiedDate: string;
|
|
78
|
+
IsPasswordProtected: boolean;
|
|
79
|
+
AncestorId: string;
|
|
80
|
+
ValidationSkipped: boolean;
|
|
81
|
+
CreatedById: string;
|
|
82
|
+
CodeCoverage?: {
|
|
83
|
+
[key: string]: unknown;
|
|
84
|
+
ApexCodeCoveragePercentage: number;
|
|
85
|
+
};
|
|
86
|
+
HasPassedCodeCoverageCheck?: boolean;
|
|
87
|
+
ConvertedFromVersionId?: string;
|
|
88
|
+
ReleaseVersion?: string;
|
|
89
|
+
BuildDurationInSeconds?: number;
|
|
90
|
+
HasMetadataRemoved?: boolean;
|
|
91
|
+
};
|
package/lib/package/index.d.ts
CHANGED
package/lib/package/index.js
CHANGED
|
@@ -14,6 +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
18
|
/*
|
|
18
19
|
* Copyright (c) 2022, salesforce.com, inc.
|
|
19
20
|
* All rights reserved.
|
|
@@ -23,4 +24,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
23
24
|
__exportStar(require("./package"), exports);
|
|
24
25
|
__exportStar(require("./packageVersion2GP"), exports);
|
|
25
26
|
__exportStar(require("./packageList"), exports);
|
|
27
|
+
var packageVersionList_1 = require("./packageVersionList");
|
|
28
|
+
Object.defineProperty(exports, "listPackageVersions", { enumerable: true, get: function () { return packageVersionList_1.listPackageVersions; } });
|
|
26
29
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Connection, SfProject } from '@salesforce/core';
|
|
2
|
+
import { QueryResult } from 'jsforce';
|
|
3
|
+
import { PackageVersionListResult } from '../interfaces';
|
|
4
|
+
export declare const DEFAULT_ORDER_BY_FIELDS = "Package2Id, Branch, MajorVersion, MinorVersion, PatchVersion, BuildNumber";
|
|
5
|
+
export declare function listPackageVersions(options: {
|
|
6
|
+
project: SfProject;
|
|
7
|
+
orderBy: string;
|
|
8
|
+
modifiedLastDays: number;
|
|
9
|
+
createdLastDays: number;
|
|
10
|
+
packages: string[];
|
|
11
|
+
connection: Connection;
|
|
12
|
+
verbose: boolean;
|
|
13
|
+
concise: boolean;
|
|
14
|
+
isReleased: boolean;
|
|
15
|
+
}): Promise<QueryResult<PackageVersionListResult>>;
|
|
16
|
+
export declare function _constructQuery(options: {
|
|
17
|
+
project: SfProject;
|
|
18
|
+
orderBy: string;
|
|
19
|
+
modifiedLastDays: number;
|
|
20
|
+
createdLastDays: number;
|
|
21
|
+
packages: string[];
|
|
22
|
+
connection: Connection;
|
|
23
|
+
verbose: boolean;
|
|
24
|
+
concise: boolean;
|
|
25
|
+
isReleased: boolean;
|
|
26
|
+
}): string;
|
|
27
|
+
export declare function _assembleQueryParts(select: string, where: string[], orderBy?: string): string;
|
|
28
|
+
export declare function _constructWhere(idsOrAliases: string[], createdLastDays: number, lastModLastDays: number, project: SfProject): string[];
|
|
29
|
+
export declare function _getLastDays(paramName: string, lastDays: number): number;
|
|
@@ -0,0 +1,92 @@
|
|
|
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._getLastDays = exports._constructWhere = exports._assembleQueryParts = exports._constructQuery = exports.listPackageVersions = exports.DEFAULT_ORDER_BY_FIELDS = void 0;
|
|
10
|
+
const _ = require("lodash");
|
|
11
|
+
const core_1 = require("@salesforce/core");
|
|
12
|
+
core_1.Messages.importMessagesDirectory(__dirname);
|
|
13
|
+
const messages = core_1.Messages.loadMessages('@salesforce/packaging', 'messages');
|
|
14
|
+
const ts_types_1 = require("@salesforce/ts-types");
|
|
15
|
+
const utils_1 = require("../utils");
|
|
16
|
+
// Stripping CodeCoverage, HasPassedCodeCoverageCheck as they are causing a perf issue in 47.0+ W-6997762
|
|
17
|
+
const DEFAULT_SELECT = 'SELECT Id, Package2Id, SubscriberPackageVersionId, Name, Package2.Name, Package2.NamespacePrefix, ' +
|
|
18
|
+
'Description, Tag, Branch, MajorVersion, MinorVersion, PatchVersion, BuildNumber, IsReleased, ' +
|
|
19
|
+
'CreatedDate, LastModifiedDate, IsPasswordProtected, AncestorId, ValidationSkipped, CreatedById ' +
|
|
20
|
+
'FROM Package2Version';
|
|
21
|
+
const VERBOSE_SELECT = 'SELECT Id, Package2Id, SubscriberPackageVersionId, Name, Package2.Name, Package2.NamespacePrefix, ' +
|
|
22
|
+
'Description, Tag, Branch, MajorVersion, MinorVersion, PatchVersion, BuildNumber, IsReleased, ' +
|
|
23
|
+
'CreatedDate, LastModifiedDate, IsPasswordProtected, CodeCoverage, HasPassedCodeCoverageCheck, AncestorId, ValidationSkipped, ' +
|
|
24
|
+
'ConvertedFromVersionId, Package2.IsOrgDependent, ReleaseVersion, BuildDurationInSeconds, HasMetadataRemoved, CreatedById ' +
|
|
25
|
+
'FROM Package2Version';
|
|
26
|
+
exports.DEFAULT_ORDER_BY_FIELDS = 'Package2Id, Branch, MajorVersion, MinorVersion, PatchVersion, BuildNumber';
|
|
27
|
+
const logger = core_1.Logger.childFromRoot('packageVersionList');
|
|
28
|
+
async function listPackageVersions(options) {
|
|
29
|
+
return options.connection.tooling.query(_constructQuery(options));
|
|
30
|
+
}
|
|
31
|
+
exports.listPackageVersions = listPackageVersions;
|
|
32
|
+
function _constructQuery(options) {
|
|
33
|
+
// construct custom WHERE clause, if applicable
|
|
34
|
+
const where = _constructWhere(options.packages, options.createdLastDays, options.modifiedLastDays, options.project);
|
|
35
|
+
if (options.isReleased) {
|
|
36
|
+
where.push('IsReleased = true');
|
|
37
|
+
}
|
|
38
|
+
return _assembleQueryParts(options.verbose === true ? VERBOSE_SELECT : DEFAULT_SELECT, where, options.orderBy);
|
|
39
|
+
}
|
|
40
|
+
exports._constructQuery = _constructQuery;
|
|
41
|
+
function _assembleQueryParts(select, where, orderBy = exports.DEFAULT_ORDER_BY_FIELDS) {
|
|
42
|
+
// construct ORDER BY clause
|
|
43
|
+
// TODO: validate given fields
|
|
44
|
+
const orderByPart = `ORDER BY ${orderBy ? orderBy : exports.DEFAULT_ORDER_BY_FIELDS}`;
|
|
45
|
+
const wherePart = where.length > 0 ? `WHERE ${where.join(' AND ')}` : '';
|
|
46
|
+
const query = `${select} ${wherePart} ${orderByPart}`;
|
|
47
|
+
logger.debug(query);
|
|
48
|
+
return query;
|
|
49
|
+
}
|
|
50
|
+
exports._assembleQueryParts = _assembleQueryParts;
|
|
51
|
+
// construct custom WHERE clause parts
|
|
52
|
+
function _constructWhere(idsOrAliases, createdLastDays, lastModLastDays, project) {
|
|
53
|
+
const where = [];
|
|
54
|
+
// filter on given package ids
|
|
55
|
+
if ((idsOrAliases === null || idsOrAliases === void 0 ? void 0 : idsOrAliases.length) > 0) {
|
|
56
|
+
// remove dups
|
|
57
|
+
idsOrAliases = _.uniq(idsOrAliases);
|
|
58
|
+
// resolve any aliases
|
|
59
|
+
const packageIds = idsOrAliases.map((idOrAlias) => (0, utils_1.getPackageIdFromAlias)(idOrAlias, project));
|
|
60
|
+
// validate ids
|
|
61
|
+
packageIds.forEach((packageId) => {
|
|
62
|
+
(0, utils_1.validateId)(utils_1.BY_LABEL.PACKAGE_ID, packageId);
|
|
63
|
+
});
|
|
64
|
+
// stash where part
|
|
65
|
+
where.push(`Package2Id IN ('${packageIds.join("','")}')`);
|
|
66
|
+
}
|
|
67
|
+
// filter on created date, days ago: 0 for today, etc
|
|
68
|
+
if ((0, ts_types_1.isNumber)(createdLastDays)) {
|
|
69
|
+
createdLastDays = _getLastDays('createdlastdays', createdLastDays);
|
|
70
|
+
where.push(`CreatedDate = LAST_N_DAYS:${createdLastDays}`);
|
|
71
|
+
}
|
|
72
|
+
// filter on last mod date, days ago: 0 for today, etc
|
|
73
|
+
if ((0, ts_types_1.isNumber)(lastModLastDays)) {
|
|
74
|
+
lastModLastDays = _getLastDays('modifiedlastdays', lastModLastDays);
|
|
75
|
+
where.push(`LastModifiedDate = LAST_N_DAYS:${lastModLastDays}`);
|
|
76
|
+
}
|
|
77
|
+
// exclude deleted
|
|
78
|
+
where.push('IsDeprecated = false');
|
|
79
|
+
return where;
|
|
80
|
+
}
|
|
81
|
+
exports._constructWhere = _constructWhere;
|
|
82
|
+
function _getLastDays(paramName, lastDays) {
|
|
83
|
+
if (isNaN(lastDays)) {
|
|
84
|
+
return 0;
|
|
85
|
+
}
|
|
86
|
+
if (lastDays < 0) {
|
|
87
|
+
throw messages.createError('invalidDaysNumber', [paramName, `${lastDays}`]);
|
|
88
|
+
}
|
|
89
|
+
return lastDays;
|
|
90
|
+
}
|
|
91
|
+
exports._getLastDays = _getLastDays;
|
|
92
|
+
//# sourceMappingURL=packageVersionList.js.map
|
|
@@ -282,7 +282,7 @@ async function getContainerOptions(package2Ids, connection) {
|
|
|
282
282
|
if (!package2Ids || package2Ids.length === 0) {
|
|
283
283
|
return new Map();
|
|
284
284
|
}
|
|
285
|
-
const query =
|
|
285
|
+
const query = "SELECT Id, ContainerOptions FROM Package2 WHERE Id IN ('%IDS%')";
|
|
286
286
|
const records = await queryWithInConditionChunking(query, package2Ids, '%IDS%', connection);
|
|
287
287
|
if (records && records.length > 0) {
|
|
288
288
|
return new Map(records.map((record) => [record.Id, record.ContainerOptions]));
|
|
@@ -618,7 +618,7 @@ exports.convertCamelCaseStringToSentence = convertCamelCaseStringToSentence;
|
|
|
618
618
|
* @returns an array of alias for the given id.
|
|
619
619
|
*/
|
|
620
620
|
function getPackageAliasesFromId(packageId, project) {
|
|
621
|
-
const packageAliases = project.getSfProjectJson().getContents().packageAliases || {};
|
|
621
|
+
const packageAliases = (project === null || project === void 0 ? void 0 : project.getSfProjectJson().getContents().packageAliases) || {};
|
|
622
622
|
// check for a matching alias
|
|
623
623
|
return Object.entries(packageAliases)
|
|
624
624
|
.filter((alias) => alias[1] === packageId)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/packaging",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "packing libraries to Salesforce packaging platform",
|
|
5
5
|
"main": "lib/exported",
|
|
6
6
|
"types": "lib/exported.d.ts",
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"prepack": "sf-prepack",
|
|
20
20
|
"prepare": "sf-install",
|
|
21
21
|
"pretest": "sf-compile-test",
|
|
22
|
-
"test": "sf-test"
|
|
22
|
+
"test": "sf-test",
|
|
23
|
+
"test:nuts": "nyc mocha \"**/*.nut.ts\" --slow 4500 --timeout 600000 --parallel"
|
|
23
24
|
},
|
|
24
25
|
"keywords": [
|
|
25
26
|
"force",
|
|
@@ -52,6 +53,7 @@
|
|
|
52
53
|
"ts-retry-promise": "^0.6.1"
|
|
53
54
|
},
|
|
54
55
|
"devDependencies": {
|
|
56
|
+
"@salesforce/cli-plugins-testkit": "^2.3.0",
|
|
55
57
|
"@salesforce/dev-config": "^3.0.1",
|
|
56
58
|
"@salesforce/dev-scripts": "^2.0.2",
|
|
57
59
|
"@salesforce/prettier-config": "^0.0.2",
|