rflib-plugin 0.19.10 → 0.20.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/README.md +31 -0
- package/lib/commands/rflib/logging/aura/instrument.js +4 -4
- package/lib/commands/rflib/logging/aura/instrument.js.map +1 -1
- package/lib/commands/rflib/logging/flow/instrument.js +14 -27
- package/lib/commands/rflib/logging/flow/instrument.js.map +1 -1
- package/lib/commands/rflib/logging/lwc/instrument.js +0 -1
- package/lib/commands/rflib/logging/lwc/instrument.js.map +1 -1
- package/lib/commands/rflib/packages/upgrade.d.ts +35 -0
- package/lib/commands/rflib/packages/upgrade.js +187 -0
- package/lib/commands/rflib/packages/upgrade.js.map +1 -0
- package/lib/shared/formatting.js +2 -3
- package/lib/shared/formatting.js.map +1 -1
- package/lib/shared/orgClient.js +2 -2
- package/lib/shared/orgClient.js.map +1 -1
- package/lib/shared/packageClient.d.ts +86 -0
- package/lib/shared/packageClient.js +200 -0
- package/lib/shared/packageClient.js.map +1 -0
- package/messages/rflib.packages.upgrade.md +123 -0
- package/oclif.lock +1539 -2325
- package/oclif.manifest.json +94 -1
- package/package.json +22 -16
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { Connection } from '@salesforce/core';
|
|
2
|
+
/** Human-facing location of the RFLIB source repository. */
|
|
3
|
+
export declare const RFLIB_REPOSITORY_URL = "https://github.com/j-fischer/rflib";
|
|
4
|
+
/** Raw sfdx-project.json of the RFLIB repository; its packageAliases list every released package version. */
|
|
5
|
+
export declare const RFLIB_PROJECT_URL = "https://raw.githubusercontent.com/j-fischer/rflib/master/sfdx-project.json";
|
|
6
|
+
export type PackageVersionNumber = {
|
|
7
|
+
major: number;
|
|
8
|
+
minor: number;
|
|
9
|
+
patch: number;
|
|
10
|
+
build: number;
|
|
11
|
+
};
|
|
12
|
+
export type LatestPackageVersion = {
|
|
13
|
+
name: string;
|
|
14
|
+
version: PackageVersionNumber;
|
|
15
|
+
versionId: string;
|
|
16
|
+
};
|
|
17
|
+
export type InstalledPackage = {
|
|
18
|
+
name: string;
|
|
19
|
+
subscriberPackageId: string;
|
|
20
|
+
version: PackageVersionNumber;
|
|
21
|
+
versionId: string;
|
|
22
|
+
};
|
|
23
|
+
export type PackageComparisonStatus = 'NotInstalled' | 'UpToDate' | 'UpgradeAvailable';
|
|
24
|
+
export type PackageComparison = {
|
|
25
|
+
name: string;
|
|
26
|
+
status: PackageComparisonStatus;
|
|
27
|
+
latestVersion: string;
|
|
28
|
+
latestVersionId: string;
|
|
29
|
+
installedVersion?: string;
|
|
30
|
+
installedVersionId?: string;
|
|
31
|
+
};
|
|
32
|
+
export type PackageInstallStatus = 'SUCCESS' | 'ERROR' | 'IN_PROGRESS' | 'UNKNOWN';
|
|
33
|
+
export type PackageInstallResult = {
|
|
34
|
+
requestId: string;
|
|
35
|
+
status: PackageInstallStatus;
|
|
36
|
+
errors: string[];
|
|
37
|
+
};
|
|
38
|
+
export type InstallPackageOptions = {
|
|
39
|
+
/** Minutes to wait for the installation to finish. 0 submits the request without waiting. */
|
|
40
|
+
waitMinutes: number;
|
|
41
|
+
/** Milliseconds between status checks while waiting. */
|
|
42
|
+
pollIntervalMs?: number;
|
|
43
|
+
/** Invoked with the request status after every status check. */
|
|
44
|
+
onStatus?: (status: PackageInstallStatus) => void;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Formats a package version the way RFLIB package aliases do, e.g. `11.3.1-1`.
|
|
48
|
+
*/
|
|
49
|
+
export declare function formatVersion(version: PackageVersionNumber): string;
|
|
50
|
+
/**
|
|
51
|
+
* Orders two package versions by major, minor, patch, and build number.
|
|
52
|
+
*
|
|
53
|
+
* @returns a negative number if `a` is older, a positive number if `a` is newer, 0 if equal.
|
|
54
|
+
*/
|
|
55
|
+
export declare function compareVersions(a: PackageVersionNumber, b: PackageVersionNumber): number;
|
|
56
|
+
/**
|
|
57
|
+
* Extracts the newest version of every package from an sfdx-project.json definition.
|
|
58
|
+
* Packages are returned in packageDirectories order, which RFLIB keeps in dependency order
|
|
59
|
+
* (RFLIB before RFLIB-FS before RFLIB-TF), so upgrades can be installed sequentially.
|
|
60
|
+
*/
|
|
61
|
+
export declare function parseLatestPackageVersions(project: unknown): LatestPackageVersion[];
|
|
62
|
+
/**
|
|
63
|
+
* Downloads the RFLIB sfdx-project.json and returns the latest version of each package.
|
|
64
|
+
*/
|
|
65
|
+
export declare function fetchLatestPackageVersions(url?: string): Promise<LatestPackageVersion[]>;
|
|
66
|
+
/**
|
|
67
|
+
* Retrieves the packages installed in an org together with their current versions, using the
|
|
68
|
+
* Tooling API. Commands that need to know what is installed (for example, to check that RFLIB is
|
|
69
|
+
* present before running) should reuse this function rather than querying the org themselves.
|
|
70
|
+
*
|
|
71
|
+
* @param conn connection to the org to inspect.
|
|
72
|
+
* @param packageNames optional package names (case-insensitive) to limit the result to, such as the
|
|
73
|
+
* names returned by fetchLatestPackageVersions(). Every installed package is returned when omitted.
|
|
74
|
+
*/
|
|
75
|
+
export declare function getInstalledPackages(conn: Connection, packageNames?: readonly string[]): Promise<InstalledPackage[]>;
|
|
76
|
+
/**
|
|
77
|
+
* Matches each latest package version to the installed package of the same name.
|
|
78
|
+
*/
|
|
79
|
+
export declare function comparePackages(latest: LatestPackageVersion[], installed: InstalledPackage[]): PackageComparison[];
|
|
80
|
+
/**
|
|
81
|
+
* Installs a package version by creating a PackageInstallRequest through the Tooling API,
|
|
82
|
+
* using the same defaults as `sf package install`, and waits for it to finish.
|
|
83
|
+
*
|
|
84
|
+
* @returns the final request status, or IN_PROGRESS if the wait time elapsed first.
|
|
85
|
+
*/
|
|
86
|
+
export declare function installPackageVersion(conn: Connection, versionId: string, options: InstallPackageOptions): Promise<PackageInstallResult>;
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { setTimeout as sleep } from 'node:timers/promises';
|
|
2
|
+
import { SfError } from '@salesforce/core';
|
|
3
|
+
/** Human-facing location of the RFLIB source repository. */
|
|
4
|
+
export const RFLIB_REPOSITORY_URL = 'https://github.com/j-fischer/rflib';
|
|
5
|
+
/** Raw sfdx-project.json of the RFLIB repository; its packageAliases list every released package version. */
|
|
6
|
+
export const RFLIB_PROJECT_URL = 'https://raw.githubusercontent.com/j-fischer/rflib/master/sfdx-project.json';
|
|
7
|
+
const PACKAGE_VERSION_ALIAS = /^(?<name>.+)@(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)-(?<build>\d+)$/;
|
|
8
|
+
const PACKAGE_VERSION_ID = /^04t(?:[a-zA-Z0-9]{12}|[a-zA-Z0-9]{15})$/;
|
|
9
|
+
const DEFAULT_POLL_INTERVAL_MS = 5000;
|
|
10
|
+
const INSTALLED_PACKAGES_QUERY = 'SELECT SubscriberPackageId, SubscriberPackage.Name, SubscriberPackageVersion.Id, ' +
|
|
11
|
+
'SubscriberPackageVersion.MajorVersion, SubscriberPackageVersion.MinorVersion, ' +
|
|
12
|
+
'SubscriberPackageVersion.PatchVersion, SubscriberPackageVersion.BuildNumber ' +
|
|
13
|
+
'FROM InstalledSubscriberPackage';
|
|
14
|
+
/**
|
|
15
|
+
* Formats a package version the way RFLIB package aliases do, e.g. `11.3.1-1`.
|
|
16
|
+
*/
|
|
17
|
+
export function formatVersion(version) {
|
|
18
|
+
return `${version.major}.${version.minor}.${version.patch}-${version.build}`;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Orders two package versions by major, minor, patch, and build number.
|
|
22
|
+
*
|
|
23
|
+
* @returns a negative number if `a` is older, a positive number if `a` is newer, 0 if equal.
|
|
24
|
+
*/
|
|
25
|
+
export function compareVersions(a, b) {
|
|
26
|
+
return a.major - b.major || a.minor - b.minor || a.patch - b.patch || a.build - b.build;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Extracts the newest version of every package from an sfdx-project.json definition.
|
|
30
|
+
* Packages are returned in packageDirectories order, which RFLIB keeps in dependency order
|
|
31
|
+
* (RFLIB before RFLIB-FS before RFLIB-TF), so upgrades can be installed sequentially.
|
|
32
|
+
*/
|
|
33
|
+
export function parseLatestPackageVersions(project) {
|
|
34
|
+
const aliases = project?.packageAliases;
|
|
35
|
+
if (!aliases || typeof aliases !== 'object') {
|
|
36
|
+
throw new SfError('The RFLIB project definition does not contain any package aliases.', 'InvalidProjectDefinition');
|
|
37
|
+
}
|
|
38
|
+
const latestByName = new Map();
|
|
39
|
+
for (const [alias, versionId] of Object.entries(aliases)) {
|
|
40
|
+
const candidate = toLatestPackageVersion(alias, versionId);
|
|
41
|
+
if (candidate && isNewer(candidate, latestByName.get(candidate.name))) {
|
|
42
|
+
latestByName.set(candidate.name, candidate);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return sortByDependencyOrder([...latestByName.values()], project);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Downloads the RFLIB sfdx-project.json and returns the latest version of each package.
|
|
49
|
+
*/
|
|
50
|
+
export async function fetchLatestPackageVersions(url = RFLIB_PROJECT_URL) {
|
|
51
|
+
let response;
|
|
52
|
+
try {
|
|
53
|
+
response = await fetch(url);
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
throw new SfError(`Unable to download the RFLIB project definition from ${url}: ${errorMessage(error)}`, 'ProjectDownloadFailed', ['Check your network connection and proxy settings.']);
|
|
57
|
+
}
|
|
58
|
+
if (!response.ok) {
|
|
59
|
+
throw new SfError(`Unable to download the RFLIB project definition from ${url}: HTTP ${response.status} ${response.statusText}`, 'ProjectDownloadFailed');
|
|
60
|
+
}
|
|
61
|
+
let project;
|
|
62
|
+
try {
|
|
63
|
+
project = await response.json();
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
throw new SfError(`The RFLIB project definition at ${url} is not valid JSON: ${errorMessage(error)}`, 'InvalidProjectDefinition');
|
|
67
|
+
}
|
|
68
|
+
return parseLatestPackageVersions(project);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Retrieves the packages installed in an org together with their current versions, using the
|
|
72
|
+
* Tooling API. Commands that need to know what is installed (for example, to check that RFLIB is
|
|
73
|
+
* present before running) should reuse this function rather than querying the org themselves.
|
|
74
|
+
*
|
|
75
|
+
* @param conn connection to the org to inspect.
|
|
76
|
+
* @param packageNames optional package names (case-insensitive) to limit the result to, such as the
|
|
77
|
+
* names returned by fetchLatestPackageVersions(). Every installed package is returned when omitted.
|
|
78
|
+
*/
|
|
79
|
+
export async function getInstalledPackages(conn, packageNames) {
|
|
80
|
+
const result = await conn.tooling.query(INSTALLED_PACKAGES_QUERY, {
|
|
81
|
+
autoFetch: true,
|
|
82
|
+
});
|
|
83
|
+
const packages = result.records.map(toInstalledPackage);
|
|
84
|
+
if (!packageNames)
|
|
85
|
+
return packages;
|
|
86
|
+
const wanted = new Set(packageNames.map((name) => name.toLowerCase()));
|
|
87
|
+
return packages.filter((pkg) => wanted.has(pkg.name.toLowerCase()));
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Matches each latest package version to the installed package of the same name.
|
|
91
|
+
*/
|
|
92
|
+
export function comparePackages(latest, installed) {
|
|
93
|
+
const installedByName = new Map(installed.map((pkg) => [pkg.name.toLowerCase(), pkg]));
|
|
94
|
+
return latest.map((pkg) => {
|
|
95
|
+
const base = {
|
|
96
|
+
name: pkg.name,
|
|
97
|
+
latestVersion: formatVersion(pkg.version),
|
|
98
|
+
latestVersionId: pkg.versionId,
|
|
99
|
+
};
|
|
100
|
+
const current = installedByName.get(pkg.name.toLowerCase());
|
|
101
|
+
if (!current)
|
|
102
|
+
return { ...base, status: 'NotInstalled' };
|
|
103
|
+
return {
|
|
104
|
+
...base,
|
|
105
|
+
status: compareVersions(current.version, pkg.version) < 0 ? 'UpgradeAvailable' : 'UpToDate',
|
|
106
|
+
installedVersion: formatVersion(current.version),
|
|
107
|
+
installedVersionId: current.versionId,
|
|
108
|
+
};
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Installs a package version by creating a PackageInstallRequest through the Tooling API,
|
|
113
|
+
* using the same defaults as `sf package install`, and waits for it to finish.
|
|
114
|
+
*
|
|
115
|
+
* @returns the final request status, or IN_PROGRESS if the wait time elapsed first.
|
|
116
|
+
*/
|
|
117
|
+
export async function installPackageVersion(conn, versionId, options) {
|
|
118
|
+
if (!PACKAGE_VERSION_ID.test(versionId)) {
|
|
119
|
+
throw new SfError(`Invalid package version ID "${versionId}".`, 'InvalidPackageVersionId');
|
|
120
|
+
}
|
|
121
|
+
const saveResult = (await conn.tooling.create('PackageInstallRequest', {
|
|
122
|
+
SubscriberPackageVersionKey: versionId,
|
|
123
|
+
ApexCompileType: 'all',
|
|
124
|
+
EnableRss: false,
|
|
125
|
+
NameConflictResolution: 'Block',
|
|
126
|
+
PackageInstallSource: 'U',
|
|
127
|
+
SecurityType: 'None',
|
|
128
|
+
UpgradeType: 'mixed-mode',
|
|
129
|
+
}));
|
|
130
|
+
if (!saveResult.success || !saveResult.id) {
|
|
131
|
+
const reasons = (saveResult.errors ?? []).map((e) => (typeof e === 'string' ? e : (e.message ?? ''))).join('; ');
|
|
132
|
+
throw new SfError(`Failed to request the installation of package version ${versionId}: ${reasons || 'Unknown error'}`, 'PackageInstallRequestFailed');
|
|
133
|
+
}
|
|
134
|
+
return waitForInstall(conn, saveResult.id, options);
|
|
135
|
+
}
|
|
136
|
+
async function waitForInstall(conn, requestId, options) {
|
|
137
|
+
const pollIntervalMs = options.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;
|
|
138
|
+
const deadline = Date.now() + Math.max(0, options.waitMinutes) * 60 * 1000;
|
|
139
|
+
for (;;) {
|
|
140
|
+
// eslint-disable-next-line no-await-in-loop
|
|
141
|
+
const request = (await conn.tooling.retrieve('PackageInstallRequest', requestId));
|
|
142
|
+
const status = request.Status ?? 'UNKNOWN';
|
|
143
|
+
options.onStatus?.(status);
|
|
144
|
+
if (status === 'SUCCESS' || status === 'ERROR') {
|
|
145
|
+
const errors = (request.Errors?.errors ?? []).map((e) => e.message ?? '').filter(Boolean);
|
|
146
|
+
return { requestId, status, errors };
|
|
147
|
+
}
|
|
148
|
+
if (Date.now() >= deadline) {
|
|
149
|
+
return { requestId, status: 'IN_PROGRESS', errors: [] };
|
|
150
|
+
}
|
|
151
|
+
// eslint-disable-next-line no-await-in-loop
|
|
152
|
+
await sleep(pollIntervalMs);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function toInstalledPackage(row) {
|
|
156
|
+
const version = row.SubscriberPackageVersion;
|
|
157
|
+
return {
|
|
158
|
+
name: row.SubscriberPackage?.Name ?? '',
|
|
159
|
+
subscriberPackageId: row.SubscriberPackageId,
|
|
160
|
+
versionId: version?.Id ?? '',
|
|
161
|
+
version: {
|
|
162
|
+
major: version?.MajorVersion ?? 0,
|
|
163
|
+
minor: version?.MinorVersion ?? 0,
|
|
164
|
+
patch: version?.PatchVersion ?? 0,
|
|
165
|
+
build: version?.BuildNumber ?? 0,
|
|
166
|
+
},
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
function toLatestPackageVersion(alias, versionId) {
|
|
170
|
+
const groups = PACKAGE_VERSION_ALIAS.exec(alias)?.groups;
|
|
171
|
+
if (!groups || typeof versionId !== 'string' || !PACKAGE_VERSION_ID.test(versionId))
|
|
172
|
+
return undefined;
|
|
173
|
+
return {
|
|
174
|
+
name: groups.name,
|
|
175
|
+
versionId,
|
|
176
|
+
version: {
|
|
177
|
+
major: Number(groups.major),
|
|
178
|
+
minor: Number(groups.minor),
|
|
179
|
+
patch: Number(groups.patch),
|
|
180
|
+
build: Number(groups.build),
|
|
181
|
+
},
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
function isNewer(candidate, current) {
|
|
185
|
+
return !current || compareVersions(candidate.version, current.version) > 0;
|
|
186
|
+
}
|
|
187
|
+
function sortByDependencyOrder(packages, project) {
|
|
188
|
+
const directoryOrder = (project.packageDirectories ?? [])
|
|
189
|
+
.map((dir) => dir.package)
|
|
190
|
+
.filter((name) => typeof name === 'string');
|
|
191
|
+
const rank = (name) => {
|
|
192
|
+
const index = directoryOrder.indexOf(name);
|
|
193
|
+
return index === -1 ? directoryOrder.length : index;
|
|
194
|
+
};
|
|
195
|
+
return packages.sort((a, b) => rank(a.name) - rank(b.name) || a.name.localeCompare(b.name));
|
|
196
|
+
}
|
|
197
|
+
function errorMessage(error) {
|
|
198
|
+
return error instanceof Error ? error.message : String(error);
|
|
199
|
+
}
|
|
200
|
+
//# sourceMappingURL=packageClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packageClient.js","sourceRoot":"","sources":["../../src/shared/packageClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,4DAA4D;AAC5D,MAAM,CAAC,MAAM,oBAAoB,GAAG,oCAAoC,CAAC;AAEzE,6GAA6G;AAC7G,MAAM,CAAC,MAAM,iBAAiB,GAAG,4EAA4E,CAAC;AAE9G,MAAM,qBAAqB,GAAG,yEAAyE,CAAC;AACxG,MAAM,kBAAkB,GAAG,0CAA0C,CAAC;AACtE,MAAM,wBAAwB,GAAG,IAAI,CAAC;AAEtC,MAAM,wBAAwB,GAC5B,mFAAmF;IACnF,gFAAgF;IAChF,8EAA8E;IAC9E,iCAAiC,CAAC;AA8EpC;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,OAA6B;IACzD,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;AAC/E,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,CAAuB,EAAE,CAAuB;IAC9E,OAAO,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,IAAI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AAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AAC9F,CAAC;AAED,SAAS,YAAY,CAAC,KAAc;IAClC,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC","sourcesContent":["import { setTimeout as sleep } from 'node:timers/promises';\nimport type { Connection } from '@salesforce/core';\nimport { SfError } from '@salesforce/core';\n\n/** Human-facing location of the RFLIB source repository. */\nexport const RFLIB_REPOSITORY_URL = 'https://github.com/j-fischer/rflib';\n\n/** Raw sfdx-project.json of the RFLIB repository; its packageAliases list every released package version. */\nexport const RFLIB_PROJECT_URL = 'https://raw.githubusercontent.com/j-fischer/rflib/master/sfdx-project.json';\n\nconst PACKAGE_VERSION_ALIAS = /^(?<name>.+)@(?<major>\\d+)\\.(?<minor>\\d+)\\.(?<patch>\\d+)-(?<build>\\d+)$/;\nconst PACKAGE_VERSION_ID = /^04t(?:[a-zA-Z0-9]{12}|[a-zA-Z0-9]{15})$/;\nconst DEFAULT_POLL_INTERVAL_MS = 5000;\n\nconst INSTALLED_PACKAGES_QUERY =\n 'SELECT SubscriberPackageId, SubscriberPackage.Name, SubscriberPackageVersion.Id, ' +\n 'SubscriberPackageVersion.MajorVersion, SubscriberPackageVersion.MinorVersion, ' +\n 'SubscriberPackageVersion.PatchVersion, SubscriberPackageVersion.BuildNumber ' +\n 'FROM InstalledSubscriberPackage';\n\nexport type PackageVersionNumber = {\n major: number;\n minor: number;\n patch: number;\n build: number;\n};\n\nexport type LatestPackageVersion = {\n name: string;\n version: PackageVersionNumber;\n versionId: string;\n};\n\nexport type InstalledPackage = {\n name: string;\n subscriberPackageId: string;\n version: PackageVersionNumber;\n versionId: string;\n};\n\nexport type PackageComparisonStatus = 'NotInstalled' | 'UpToDate' | 'UpgradeAvailable';\n\nexport type PackageComparison = {\n name: string;\n status: PackageComparisonStatus;\n latestVersion: string;\n latestVersionId: string;\n installedVersion?: string;\n installedVersionId?: string;\n};\n\nexport type PackageInstallStatus = 'SUCCESS' | 'ERROR' | 'IN_PROGRESS' | 'UNKNOWN';\n\nexport type PackageInstallResult = {\n requestId: string;\n status: PackageInstallStatus;\n errors: string[];\n};\n\nexport type InstallPackageOptions = {\n /** Minutes to wait for the installation to finish. 0 submits the request without waiting. */\n waitMinutes: number;\n /** Milliseconds between status checks while waiting. */\n pollIntervalMs?: number;\n /** Invoked with the request status after every status check. */\n onStatus?: (status: PackageInstallStatus) => void;\n};\n\ntype SfdxProjectLite = {\n packageDirectories?: Array<{ package?: unknown }>;\n packageAliases?: Record<string, unknown>;\n};\n\ntype InstalledSubscriberPackageRow = {\n SubscriberPackageId: string;\n SubscriberPackage?: { Name?: string } | null;\n SubscriberPackageVersion?: {\n Id?: string;\n MajorVersion?: number;\n MinorVersion?: number;\n PatchVersion?: number;\n BuildNumber?: number;\n } | null;\n};\n\ntype ToolingSaveResult = {\n success: boolean;\n id?: string;\n errors?: Array<string | { message?: string }>;\n};\n\ntype PackageInstallRequestRow = {\n Status?: PackageInstallStatus;\n Errors?: { errors?: Array<{ message?: string }> } | null;\n};\n\n/**\n * Formats a package version the way RFLIB package aliases do, e.g. `11.3.1-1`.\n */\nexport function formatVersion(version: PackageVersionNumber): string {\n return `${version.major}.${version.minor}.${version.patch}-${version.build}`;\n}\n\n/**\n * Orders two package versions by major, minor, patch, and build number.\n *\n * @returns a negative number if `a` is older, a positive number if `a` is newer, 0 if equal.\n */\nexport function compareVersions(a: PackageVersionNumber, b: PackageVersionNumber): number {\n return a.major - b.major || a.minor - b.minor || a.patch - b.patch || a.build - b.build;\n}\n\n/**\n * Extracts the newest version of every package from an sfdx-project.json definition.\n * Packages are returned in packageDirectories order, which RFLIB keeps in dependency order\n * (RFLIB before RFLIB-FS before RFLIB-TF), so upgrades can be installed sequentially.\n */\nexport function parseLatestPackageVersions(project: unknown): LatestPackageVersion[] {\n const aliases = (project as SfdxProjectLite | null)?.packageAliases;\n if (!aliases || typeof aliases !== 'object') {\n throw new SfError('The RFLIB project definition does not contain any package aliases.', 'InvalidProjectDefinition');\n }\n\n const latestByName = new Map<string, LatestPackageVersion>();\n for (const [alias, versionId] of Object.entries(aliases)) {\n const candidate = toLatestPackageVersion(alias, versionId);\n if (candidate && isNewer(candidate, latestByName.get(candidate.name))) {\n latestByName.set(candidate.name, candidate);\n }\n }\n\n return sortByDependencyOrder([...latestByName.values()], project as SfdxProjectLite);\n}\n\n/**\n * Downloads the RFLIB sfdx-project.json and returns the latest version of each package.\n */\nexport async function fetchLatestPackageVersions(url: string = RFLIB_PROJECT_URL): Promise<LatestPackageVersion[]> {\n let response: Response;\n try {\n response = await fetch(url);\n } catch (error) {\n throw new SfError(\n `Unable to download the RFLIB project definition from ${url}: ${errorMessage(error)}`,\n 'ProjectDownloadFailed',\n ['Check your network connection and proxy settings.'],\n );\n }\n if (!response.ok) {\n throw new SfError(\n `Unable to download the RFLIB project definition from ${url}: HTTP ${response.status} ${response.statusText}`,\n 'ProjectDownloadFailed',\n );\n }\n\n let project: unknown;\n try {\n project = await response.json();\n } catch (error) {\n throw new SfError(\n `The RFLIB project definition at ${url} is not valid JSON: ${errorMessage(error)}`,\n 'InvalidProjectDefinition',\n );\n }\n return parseLatestPackageVersions(project);\n}\n\n/**\n * Retrieves the packages installed in an org together with their current versions, using the\n * Tooling API. Commands that need to know what is installed (for example, to check that RFLIB is\n * present before running) should reuse this function rather than querying the org themselves.\n *\n * @param conn connection to the org to inspect.\n * @param packageNames optional package names (case-insensitive) to limit the result to, such as the\n * names returned by fetchLatestPackageVersions(). Every installed package is returned when omitted.\n */\nexport async function getInstalledPackages(\n conn: Connection,\n packageNames?: readonly string[],\n): Promise<InstalledPackage[]> {\n const result = await conn.tooling.query<InstalledSubscriberPackageRow>(INSTALLED_PACKAGES_QUERY, {\n autoFetch: true,\n });\n const packages = result.records.map(toInstalledPackage);\n if (!packageNames) return packages;\n\n const wanted = new Set(packageNames.map((name) => name.toLowerCase()));\n return packages.filter((pkg) => wanted.has(pkg.name.toLowerCase()));\n}\n\n/**\n * Matches each latest package version to the installed package of the same name.\n */\nexport function comparePackages(latest: LatestPackageVersion[], installed: InstalledPackage[]): PackageComparison[] {\n const installedByName = new Map(installed.map((pkg) => [pkg.name.toLowerCase(), pkg]));\n\n return latest.map((pkg): PackageComparison => {\n const base = {\n name: pkg.name,\n latestVersion: formatVersion(pkg.version),\n latestVersionId: pkg.versionId,\n };\n const current = installedByName.get(pkg.name.toLowerCase());\n if (!current) return { ...base, status: 'NotInstalled' };\n\n return {\n ...base,\n status: compareVersions(current.version, pkg.version) < 0 ? 'UpgradeAvailable' : 'UpToDate',\n installedVersion: formatVersion(current.version),\n installedVersionId: current.versionId,\n };\n });\n}\n\n/**\n * Installs a package version by creating a PackageInstallRequest through the Tooling API,\n * using the same defaults as `sf package install`, and waits for it to finish.\n *\n * @returns the final request status, or IN_PROGRESS if the wait time elapsed first.\n */\nexport async function installPackageVersion(\n conn: Connection,\n versionId: string,\n options: InstallPackageOptions,\n): Promise<PackageInstallResult> {\n if (!PACKAGE_VERSION_ID.test(versionId)) {\n throw new SfError(`Invalid package version ID \"${versionId}\".`, 'InvalidPackageVersionId');\n }\n\n const saveResult = (await conn.tooling.create('PackageInstallRequest', {\n SubscriberPackageVersionKey: versionId,\n ApexCompileType: 'all',\n EnableRss: false,\n NameConflictResolution: 'Block',\n PackageInstallSource: 'U',\n SecurityType: 'None',\n UpgradeType: 'mixed-mode',\n })) as ToolingSaveResult;\n\n if (!saveResult.success || !saveResult.id) {\n const reasons = (saveResult.errors ?? []).map((e) => (typeof e === 'string' ? e : (e.message ?? ''))).join('; ');\n throw new SfError(\n `Failed to request the installation of package version ${versionId}: ${reasons || 'Unknown error'}`,\n 'PackageInstallRequestFailed',\n );\n }\n\n return waitForInstall(conn, saveResult.id, options);\n}\n\nasync function waitForInstall(\n conn: Connection,\n requestId: string,\n options: InstallPackageOptions,\n): Promise<PackageInstallResult> {\n const pollIntervalMs = options.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;\n const deadline = Date.now() + Math.max(0, options.waitMinutes) * 60 * 1000;\n\n for (;;) {\n // eslint-disable-next-line no-await-in-loop\n const request = (await conn.tooling.retrieve('PackageInstallRequest', requestId)) as PackageInstallRequestRow;\n const status = request.Status ?? 'UNKNOWN';\n options.onStatus?.(status);\n\n if (status === 'SUCCESS' || status === 'ERROR') {\n const errors = (request.Errors?.errors ?? []).map((e) => e.message ?? '').filter(Boolean);\n return { requestId, status, errors };\n }\n if (Date.now() >= deadline) {\n return { requestId, status: 'IN_PROGRESS', errors: [] };\n }\n // eslint-disable-next-line no-await-in-loop\n await sleep(pollIntervalMs);\n }\n}\n\nfunction toInstalledPackage(row: InstalledSubscriberPackageRow): InstalledPackage {\n const version = row.SubscriberPackageVersion;\n return {\n name: row.SubscriberPackage?.Name ?? '',\n subscriberPackageId: row.SubscriberPackageId,\n versionId: version?.Id ?? '',\n version: {\n major: version?.MajorVersion ?? 0,\n minor: version?.MinorVersion ?? 0,\n patch: version?.PatchVersion ?? 0,\n build: version?.BuildNumber ?? 0,\n },\n };\n}\n\nfunction toLatestPackageVersion(alias: string, versionId: unknown): LatestPackageVersion | undefined {\n const groups = PACKAGE_VERSION_ALIAS.exec(alias)?.groups;\n if (!groups || typeof versionId !== 'string' || !PACKAGE_VERSION_ID.test(versionId)) return undefined;\n\n return {\n name: groups.name,\n versionId,\n version: {\n major: Number(groups.major),\n minor: Number(groups.minor),\n patch: Number(groups.patch),\n build: Number(groups.build),\n },\n };\n}\n\nfunction isNewer(candidate: LatestPackageVersion, current: LatestPackageVersion | undefined): boolean {\n return !current || compareVersions(candidate.version, current.version) > 0;\n}\n\nfunction sortByDependencyOrder(packages: LatestPackageVersion[], project: SfdxProjectLite): LatestPackageVersion[] {\n const directoryOrder = (project.packageDirectories ?? [])\n .map((dir) => dir.package)\n .filter((name): name is string => typeof name === 'string');\n const rank = (name: string): number => {\n const index = directoryOrder.indexOf(name);\n return index === -1 ? directoryOrder.length : index;\n };\n\n return packages.sort((a, b) => rank(a.name) - rank(b.name) || a.name.localeCompare(b.name));\n}\n\nfunction errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n"]}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# summary
|
|
2
|
+
|
|
3
|
+
Check the RFLIB packages installed in a Salesforce org and upgrade them to the latest released versions.
|
|
4
|
+
|
|
5
|
+
# description
|
|
6
|
+
|
|
7
|
+
Compares the RFLIB packages (RFLIB, RFLIB-FS, RFLIB-TF, RFLIB-PHAROS) installed in the target org with the latest package versions published in the RFLIB GitHub repository (https://github.com/j-fischer/rflib).
|
|
8
|
+
|
|
9
|
+
For every installed package with a newer version available, the command asks whether to install the upgrade and, if confirmed, starts the installation in the target org. Upgrades are installed one at a time in dependency order (RFLIB first), and the remaining upgrades are skipped if an installation does not complete successfully.
|
|
10
|
+
|
|
11
|
+
Packages that are not installed in the target org are only reported; this command never installs a package that isn't already present.
|
|
12
|
+
|
|
13
|
+
Use --dryrun to only report the available upgrades, or --no-prompt to install all available upgrades without asking for confirmation. When --json is specified without --no-prompt, no upgrades are installed.
|
|
14
|
+
|
|
15
|
+
# flags.target-org.summary
|
|
16
|
+
|
|
17
|
+
Username or alias of the target org.
|
|
18
|
+
|
|
19
|
+
# flags.target-org.description
|
|
20
|
+
|
|
21
|
+
The username or alias of the Salesforce org whose installed RFLIB packages should be checked and upgraded.
|
|
22
|
+
|
|
23
|
+
# flags.dryrun.summary
|
|
24
|
+
|
|
25
|
+
Report the available upgrades without installing them.
|
|
26
|
+
|
|
27
|
+
# flags.dryrun.description
|
|
28
|
+
|
|
29
|
+
Compare the installed packages with the latest versions and print the results, without prompting or installing any upgrades.
|
|
30
|
+
|
|
31
|
+
# flags.no-prompt.summary
|
|
32
|
+
|
|
33
|
+
Install all available upgrades without asking for confirmation.
|
|
34
|
+
|
|
35
|
+
# flags.no-prompt.description
|
|
36
|
+
|
|
37
|
+
Skip the confirmation prompt for each upgrade and install every available upgrade. Use this flag in scripts and CI jobs, or together with --json.
|
|
38
|
+
|
|
39
|
+
# flags.wait.summary
|
|
40
|
+
|
|
41
|
+
Number of minutes to wait for each package installation to complete.
|
|
42
|
+
|
|
43
|
+
# flags.wait.description
|
|
44
|
+
|
|
45
|
+
The number of minutes to wait for each package installation to complete before moving on. If the wait time elapses, the installation continues in the org and the remaining upgrades are skipped. Use "sf package install report" with the reported request ID to check its progress. Specify 0 to submit the first installation request without waiting.
|
|
46
|
+
|
|
47
|
+
# info.source
|
|
48
|
+
|
|
49
|
+
Latest RFLIB package versions are published in %s.
|
|
50
|
+
|
|
51
|
+
# info.notInstalled
|
|
52
|
+
|
|
53
|
+
%s is not installed in the target org. The latest version is %s (%s).
|
|
54
|
+
|
|
55
|
+
# info.noInstalledPackages
|
|
56
|
+
|
|
57
|
+
No RFLIB packages are installed in the target org.
|
|
58
|
+
|
|
59
|
+
# info.upToDate
|
|
60
|
+
|
|
61
|
+
All installed RFLIB packages are up to date.
|
|
62
|
+
|
|
63
|
+
# info.dryrun
|
|
64
|
+
|
|
65
|
+
Dry run: no upgrades were installed.
|
|
66
|
+
|
|
67
|
+
# info.jsonWithoutNoPrompt
|
|
68
|
+
|
|
69
|
+
Upgrades are available. Run the command again with --no-prompt to install them when using --json.
|
|
70
|
+
|
|
71
|
+
# prompt.upgrade
|
|
72
|
+
|
|
73
|
+
Upgrade %s from %s to %s
|
|
74
|
+
|
|
75
|
+
# spinner.retrieve
|
|
76
|
+
|
|
77
|
+
Retrieving RFLIB package versions
|
|
78
|
+
|
|
79
|
+
# spinner.install
|
|
80
|
+
|
|
81
|
+
Installing %s %s
|
|
82
|
+
|
|
83
|
+
# status.declined
|
|
84
|
+
|
|
85
|
+
Upgrade declined.
|
|
86
|
+
|
|
87
|
+
# status.upgraded
|
|
88
|
+
|
|
89
|
+
Upgraded to %s.
|
|
90
|
+
|
|
91
|
+
# status.failed
|
|
92
|
+
|
|
93
|
+
Installation failed: %s
|
|
94
|
+
|
|
95
|
+
# status.inProgress
|
|
96
|
+
|
|
97
|
+
Installation is still in progress after the wait time elapsed. Check its status with "sf package install report --request-id %s".
|
|
98
|
+
|
|
99
|
+
# status.skipped
|
|
100
|
+
|
|
101
|
+
Skipped because the upgrade of %s did not complete.
|
|
102
|
+
|
|
103
|
+
# status.notRequested
|
|
104
|
+
|
|
105
|
+
Upgrade available but not installed.
|
|
106
|
+
|
|
107
|
+
# error.upgradeFailed
|
|
108
|
+
|
|
109
|
+
The upgrade of %s did not succeed. %s
|
|
110
|
+
|
|
111
|
+
# examples
|
|
112
|
+
|
|
113
|
+
- Check the RFLIB packages installed in an org and choose which upgrades to install:
|
|
114
|
+
|
|
115
|
+
$ sf rflib packages upgrade --target-org myOrg
|
|
116
|
+
|
|
117
|
+
- Report the available upgrades without installing anything:
|
|
118
|
+
|
|
119
|
+
$ sf rflib packages upgrade --target-org myOrg --dryrun
|
|
120
|
+
|
|
121
|
+
- Install all available upgrades without prompting, waiting up to 60 minutes for each installation:
|
|
122
|
+
|
|
123
|
+
$ sf rflib packages upgrade --target-org myOrg --no-prompt --wait 60
|