@simplysf/simply-package 2.9.0 → 2.10.1
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 +33 -199
- package/lib/commands/simply/package/version/get.d.ts +31 -0
- package/lib/commands/simply/package/version/get.js +100 -0
- package/lib/commands/simply/package/version/get.js.map +1 -0
- package/lib/common/packageVersionLookup.d.ts +56 -0
- package/lib/common/packageVersionLookup.js +141 -0
- package/lib/common/packageVersionLookup.js.map +1 -0
- package/messages/simply.package.version.get.md +55 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -23,6 +23,7 @@ This package is part of the [`@simplysf/simply`](https://github.com/SimplySF/sim
|
|
|
23
23
|
- [`sf simply package dependencies install`](#sf-simply-package-dependencies-install)
|
|
24
24
|
- [`sf simply package dependencies manage`](#sf-simply-package-dependencies-manage)
|
|
25
25
|
- [`sf simply package version cleanup`](#sf-simply-package-version-cleanup)
|
|
26
|
+
- [`sf simply package version get`](#sf-simply-package-version-get)
|
|
26
27
|
|
|
27
28
|
## `sf simply package dependencies install`
|
|
28
29
|
|
|
@@ -156,7 +157,7 @@ FLAG DESCRIPTIONS
|
|
|
156
157
|
Packages not listed here use --retry-attempts.
|
|
157
158
|
```
|
|
158
159
|
|
|
159
|
-
_See code: [lib/commands/simply/package/dependencies/install.js](https://github.com/SimplySF/simply-node/blob/@simplysf/simply-package@2.
|
|
160
|
+
_See code: [lib/commands/simply/package/dependencies/install.js](https://github.com/SimplySF/simply-node/blob/@simplysf/simply-package@2.9.0/packages/simply-package/lib/commands/simply/package/dependencies/install.js)_
|
|
160
161
|
|
|
161
162
|
## `sf simply package dependencies manage`
|
|
162
163
|
|
|
@@ -215,7 +216,7 @@ FLAG DESCRIPTIONS
|
|
|
215
216
|
version without interactive prompts. Mutually exclusive with --update-to-latest.
|
|
216
217
|
```
|
|
217
218
|
|
|
218
|
-
_See code: [lib/commands/simply/package/dependencies/manage.js](https://github.com/SimplySF/simply-node/blob/@simplysf/simply-package@2.
|
|
219
|
+
_See code: [lib/commands/simply/package/dependencies/manage.js](https://github.com/SimplySF/simply-node/blob/@simplysf/simply-package@2.9.0/packages/simply-package/lib/commands/simply/package/dependencies/manage.js)_
|
|
219
220
|
|
|
220
221
|
## `sf simply package version cleanup`
|
|
221
222
|
|
|
@@ -269,234 +270,67 @@ FLAG DESCRIPTIONS
|
|
|
269
270
|
does not match this matcher is deleted. Mutually exclusive with --matcher.
|
|
270
271
|
```
|
|
271
272
|
|
|
272
|
-
_See code: [lib/commands/simply/package/version/cleanup.js](https://github.com/SimplySF/simply-node/blob/@simplysf/simply-package@2.
|
|
273
|
-
<!-- commandsstop -->
|
|
273
|
+
_See code: [lib/commands/simply/package/version/cleanup.js](https://github.com/SimplySF/simply-node/blob/@simplysf/simply-package@2.9.0/packages/simply-package/lib/commands/simply/package/version/cleanup.js)_
|
|
274
274
|
|
|
275
|
-
|
|
276
|
-
- [`sf simply package dependencies manage`](#sf-simply-package-dependencies-manage)
|
|
277
|
-
- [`sf simply package version cleanup`](#sf-simply-package-version-cleanup)
|
|
275
|
+
## `sf simply package version get`
|
|
278
276
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
Install package dependencies for a Salesforce project.
|
|
277
|
+
Get a package version from sfdx-project.json.
|
|
282
278
|
|
|
283
279
|
```
|
|
284
280
|
USAGE
|
|
285
|
-
$ sf simply package
|
|
286
|
-
<value>] [-i All|Delta|Upgrade] [-k <value>...] [-r] [--output-file <value>] [-b <value>] [-s AllUsers|AdminsOnly]
|
|
287
|
-
[-v <value>] [-t DeprecateOnly|Mixed|Delete] [-w <value>]
|
|
281
|
+
$ sf simply package version get -p <value> [--json] [--flags-dir <value>] [-d <value>]
|
|
288
282
|
|
|
289
283
|
FLAGS
|
|
290
|
-
-
|
|
291
|
-
|
|
292
|
-
<options: all|package>
|
|
293
|
-
-b, --publish-wait=<value> Maximum number of minutes to wait for the Subscriber Package Version ID to become
|
|
294
|
-
available in the target org before canceling the install request.
|
|
295
|
-
-i, --install-type=<option> [default: Upgrade] Install all packages, only deltas, or only newer versions.
|
|
296
|
-
<options: All|Delta|Upgrade>
|
|
297
|
-
-k, --installation-key=<value>... Installation key for key-protected packages
|
|
298
|
-
-o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
|
|
299
|
-
configuration variable is already set.
|
|
300
|
-
-r, --no-prompt Don't prompt for confirmation.
|
|
301
|
-
-s, --security-type=<option> [default: AdminsOnly] Security access type for the installed package. (deprecation
|
|
302
|
-
notice: The default --security-type value will change from AllUsers to AdminsOnly
|
|
303
|
-
in v47.0 or later.)
|
|
304
|
-
<options: AllUsers|AdminsOnly>
|
|
305
|
-
-t, --upgrade-type=<option> [default: Mixed] Upgrade type for the package installation; available only for
|
|
306
|
-
unlocked packages.
|
|
307
|
-
<options: DeprecateOnly|Mixed|Delete>
|
|
308
|
-
-v, --target-dev-hub=<value> Username or alias of the Dev Hub org.
|
|
309
|
-
-w, --wait=<value> Number of minutes to wait for installation status.
|
|
310
|
-
-z, --branch=<value> Package branch to consider when specifiying a Package/VersionNumber combination
|
|
311
|
-
--api-version=<value> Override the api version used for api requests made by this command
|
|
312
|
-
--output-file=<value> Path to write a JSON install report to.
|
|
284
|
+
-d, --directory=<value> Package directory to search.
|
|
285
|
+
-p, --package=<value> (required) Package name or alias to look up.
|
|
313
286
|
|
|
314
287
|
GLOBAL FLAGS
|
|
315
288
|
--flags-dir=<value> Import flag values from a directory.
|
|
316
289
|
--json Format output as json.
|
|
317
290
|
|
|
318
291
|
DESCRIPTION
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
Installs all specified package dependencies in a Salesforce DX project using the sfdx-project.json definition.
|
|
292
|
+
Get a package version from sfdx-project.json.
|
|
322
293
|
|
|
323
|
-
|
|
324
|
-
|
|
294
|
+
Reads the version a package is declared at in your project's sfdx-project.json and prints it, so a script doesn't have
|
|
295
|
+
to parse the project file itself.
|
|
325
296
|
|
|
326
|
-
|
|
297
|
+
Both dependencies and the project's own package are searched. A dependency declared as an alias (test-package@0.1.0+2)
|
|
298
|
+
resolves to the version portion of the alias; a dependency declared as a package name plus a versionNumber resolves to
|
|
299
|
+
that versionNumber; a dependency declared as a raw ID resolves through packageAliases. A package directory that builds
|
|
300
|
+
the package resolves to that directory's versionNumber.
|
|
327
301
|
|
|
328
|
-
|
|
302
|
+
The version is returned exactly as it appears in the project file — no normalizing between the 0.1.0+2, 57.0.0-3, and
|
|
303
|
+
1.2.3.LATEST forms, since each means something to the tool that consumes it.
|
|
329
304
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
FLAG DESCRIPTIONS
|
|
333
|
-
-a, --apex-compile=all|package
|
|
334
|
-
|
|
335
|
-
Compile all Apex in the org and package, or only Apex in the package; unlocked packages only.
|
|
336
|
-
|
|
337
|
-
Applies to unlocked packages only. Specifies whether to compile all Apex in the org and package, or only the Apex in
|
|
338
|
-
the package.
|
|
339
|
-
|
|
340
|
-
For package installs into production orgs, or any org that has Apex Compile on Deploy enabled, the platform compiles
|
|
341
|
-
all Apex in the org after the package install or upgrade operation completes.
|
|
342
|
-
|
|
343
|
-
This approach assures that package installs and upgrades don’t impact the performance of an org, and is done even if
|
|
344
|
-
--apex-compile package is specified.
|
|
345
|
-
|
|
346
|
-
-i, --install-type=All|Delta|Upgrade Install all packages, only deltas, or only newer versions.
|
|
347
|
-
|
|
348
|
-
If 'All' is specified, then all packages specified in package dependencies are installed, regardless of if the
|
|
349
|
-
version already is installed in the org. If 'Delta' is specified, then only packages that differ from what is
|
|
350
|
-
installed in the org will be installed. If 'Upgrade' is specified, then a package is installed only if it isn't
|
|
351
|
-
already installed, or if its semantic version (major.minor.patch.build) is newer than the version currently
|
|
352
|
-
installed in the org; packages with an installed version that is the same as or newer than the target version are
|
|
353
|
-
skipped.
|
|
354
|
-
|
|
355
|
-
-k, --installation-key=<value>... Installation key for key-protected packages
|
|
356
|
-
|
|
357
|
-
Installation key for key-protected packages in the key:value format of SubscriberPackageVersionId:Key
|
|
358
|
-
|
|
359
|
-
-r, --no-prompt Don't prompt for confirmation.
|
|
360
|
-
|
|
361
|
-
Allows the following without an explicit confirmation response: 1) Remote Site Settings and Content Security Policy
|
|
362
|
-
websites to send or receive data, and 2) --upgrade-type Delete to proceed.
|
|
363
|
-
|
|
364
|
-
-t, --upgrade-type=DeprecateOnly|Mixed|Delete
|
|
365
|
-
|
|
366
|
-
Upgrade type for the package installation; available only for unlocked packages.
|
|
367
|
-
|
|
368
|
-
For package upgrades, specifies whether to mark all removed components as deprecated (DeprecateOnly), to delete
|
|
369
|
-
removed components that can be safely deleted and deprecate the others (Mixed), or to delete all removed components,
|
|
370
|
-
except for custom objects and custom fields, that don't have dependencies (Delete). The default is Mixed. Can
|
|
371
|
-
specify DeprecateOnly or Delete only for unlocked package upgrades.
|
|
372
|
-
|
|
373
|
-
-z, --branch=<value> Package branch to consider when specifiying a Package/VersionNumber combination
|
|
374
|
-
|
|
375
|
-
For dependencies specified by Package/VersionNumber combination, you can specify the branch group of builds to work
|
|
376
|
-
from by entering the branch build name. If not specified, the builds from NULL branch will be considered.
|
|
377
|
-
|
|
378
|
-
--output-file=<value> Path to write a JSON install report to.
|
|
379
|
-
|
|
380
|
-
When specified, a JSON report of the install outcome for every resolved dependency is written to this path, in
|
|
381
|
-
addition to the normal terminal output you can continue to monitor as the command runs. Each entry includes the
|
|
382
|
-
package name, the SubscriberPackageVersionId already installed in the org (if any), the SubscriberPackageVersionId
|
|
383
|
-
that was attempted, and the decision made (Skipped, Installed, Installing, or Failed).
|
|
384
|
-
```
|
|
385
|
-
|
|
386
|
-
_See code: [lib/commands/simply/package/dependencies/install.js](https://github.com/SimplySF/simply-node/blob/@simplysf/simply-package@2.8.1/packages/simply-package/lib/commands/simply/package/dependencies/install.js)_
|
|
387
|
-
|
|
388
|
-
## `sf simply package dependencies manage`
|
|
389
|
-
|
|
390
|
-
Manage package dependency versions for a Salesforce project.
|
|
391
|
-
|
|
392
|
-
```
|
|
393
|
-
USAGE
|
|
394
|
-
$ sf simply package dependencies manage -v <value> [--json] [--flags-dir <value>] [-b <value>] [--update-to-released |
|
|
395
|
-
--update-to-latest] [--api-version <value>]
|
|
396
|
-
|
|
397
|
-
FLAGS
|
|
398
|
-
-b, --branch=<value> Package branch to consider when evaluating version options.
|
|
399
|
-
-v, --target-dev-hub=<value> (required) Username or alias of the Dev Hub org. Not required if the `target-dev-hub`
|
|
400
|
-
configuration variable is already set.
|
|
401
|
-
--api-version=<value> Override the api version used for api requests made by this command
|
|
402
|
-
--update-to-latest Automatically set all dependencies to the latest non-pinned build.
|
|
403
|
-
--update-to-released Automatically update all dependencies to the latest released version.
|
|
404
|
-
|
|
405
|
-
GLOBAL FLAGS
|
|
406
|
-
--flags-dir=<value> Import flag values from a directory.
|
|
407
|
-
--json Format output as json.
|
|
408
|
-
|
|
409
|
-
DESCRIPTION
|
|
410
|
-
Manage package dependency versions for a Salesforce project.
|
|
411
|
-
|
|
412
|
-
Interactively updates package dependency versions in sfdx-project.json by querying the Dev Hub for available versions.
|
|
413
|
-
Supports interactive selection or automatic update to the latest released or latest build version.
|
|
414
|
-
|
|
415
|
-
Project-level configuration (in sfdx-project.json) is read from the following keys:
|
|
416
|
-
|
|
417
|
-
- plugins.simply.dependencies.ignore — array of Package2Ids or aliases to leave unchanged
|
|
418
|
-
- plugins.simply.package.brancheswithreleasedversions — array of branch names that contain released versions
|
|
305
|
+
This command reads the project file only. It never contacts an org or a Dev Hub, so it can run in a pipeline before
|
|
306
|
+
any authentication step.
|
|
419
307
|
|
|
420
308
|
EXAMPLES
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
$ sf simply package dependencies manage --target-dev-hub myDevHub --branch my-feature-branch
|
|
424
|
-
|
|
425
|
-
$ sf simply package dependencies manage --target-dev-hub myDevHub --update-to-released
|
|
426
|
-
|
|
427
|
-
$ sf simply package dependencies manage --target-dev-hub myDevHub --update-to-latest
|
|
428
|
-
|
|
429
|
-
FLAG DESCRIPTIONS
|
|
430
|
-
-b, --branch=<value> Package branch to consider when evaluating version options.
|
|
431
|
-
|
|
432
|
-
When specified, the command will include the latest build on this branch as a selectable option for each dependency.
|
|
433
|
-
|
|
434
|
-
--update-to-latest Automatically set all dependencies to the latest non-pinned build.
|
|
435
|
-
|
|
436
|
-
When specified, all dependencies managed by the Dev Hub are automatically set to a non-pinned X.Y.Z.LATEST version
|
|
437
|
-
number without interactive prompts. Mutually exclusive with --update-to-released.
|
|
438
|
-
|
|
439
|
-
--update-to-released Automatically update all dependencies to the latest released version.
|
|
440
|
-
|
|
441
|
-
When specified, all dependencies managed by the Dev Hub are automatically updated to the latest released package
|
|
442
|
-
version without interactive prompts. Mutually exclusive with --update-to-latest.
|
|
443
|
-
```
|
|
309
|
+
Get the version of a dependency:
|
|
444
310
|
|
|
445
|
-
|
|
311
|
+
$ sf simply package version get --package test-package
|
|
446
312
|
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
Cleanup package versions.
|
|
450
|
-
|
|
451
|
-
```
|
|
452
|
-
USAGE
|
|
453
|
-
$ sf simply package version cleanup -p <value> -v <value> [--json] [--flags-dir <value>] [--api-version <value>] [-s <value> | -x
|
|
454
|
-
<value>]
|
|
455
|
-
|
|
456
|
-
FLAGS
|
|
457
|
-
-p, --package=<value> (required) Package Id
|
|
458
|
-
-s, --matcher=<value> MAJOR.MINOR.PATCH to select on
|
|
459
|
-
-v, --target-dev-hub=<value> (required) Username or alias of the Dev Hub org. Not required if the `target-dev-hub`
|
|
460
|
-
configuration variable is already set.
|
|
461
|
-
-x, --exclude-matcher=<value> MAJOR.MINOR.PATCH to exclude on
|
|
462
|
-
--api-version=<value> Override the api version used for api requests made by this command
|
|
463
|
-
|
|
464
|
-
GLOBAL FLAGS
|
|
465
|
-
--flags-dir=<value> Import flag values from a directory.
|
|
466
|
-
--json Format output as json.
|
|
467
|
-
|
|
468
|
-
DESCRIPTION
|
|
469
|
-
Cleanup package versions.
|
|
313
|
+
Get the version of the package the project itself builds:
|
|
470
314
|
|
|
471
|
-
|
|
472
|
-
on. Does not delete released package versions.
|
|
315
|
+
$ sf simply package version get --package my-package
|
|
473
316
|
|
|
474
|
-
|
|
475
|
-
provided instead, every unreleased version that does _not_ match MAJOR.MINOR.PATCH is deleted. Exactly one of
|
|
476
|
-
--matcher or --exclude-matcher must be specified.
|
|
317
|
+
Get a dependency's version from one package directory:
|
|
477
318
|
|
|
478
|
-
|
|
479
|
-
$ sf simply package version cleanup --package 0Hoxx00000000CqCAI --matcher 2.10.0 --target-dev-hub myDevHub
|
|
480
|
-
|
|
481
|
-
$ sf simply package version cleanup --package 0Hoxx00000000CqCAI --exclude-matcher 2.10.0 --target-dev-hub myDevHub
|
|
319
|
+
$ sf simply package version get --package test-package --directory force-app
|
|
482
320
|
|
|
483
321
|
FLAG DESCRIPTIONS
|
|
484
|
-
-
|
|
485
|
-
|
|
486
|
-
The 0Ht Package Id that you wish to cleanup versions for.
|
|
487
|
-
|
|
488
|
-
-s, --matcher=<value> MAJOR.MINOR.PATCH to select on
|
|
322
|
+
-d, --directory=<value> Package directory to search.
|
|
489
323
|
|
|
490
|
-
The
|
|
491
|
-
|
|
324
|
+
The path of a single package directory to search, matching a "path" value in packageDirectories. Use this when the
|
|
325
|
+
same package is declared at different versions in more than one package directory.
|
|
492
326
|
|
|
493
|
-
-
|
|
327
|
+
-p, --package=<value> Package name or alias to look up.
|
|
494
328
|
|
|
495
|
-
The
|
|
496
|
-
|
|
329
|
+
The package name as it appears in sfdx-project.json, without a version suffix. For a dependency declared as
|
|
330
|
+
"test-package@0.1.0+2", pass "test-package".
|
|
497
331
|
```
|
|
498
332
|
|
|
499
|
-
_See code: [lib/commands/simply/package/version/
|
|
333
|
+
_See code: [lib/commands/simply/package/version/get.js](https://github.com/SimplySF/simply-node/blob/@simplysf/simply-package@2.9.0/packages/simply-package/lib/commands/simply/package/version/get.js)_
|
|
500
334
|
<!-- commandsstop -->
|
|
501
335
|
|
|
502
336
|
## Configuration Files
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
+
import { PackageVersionSource } from '../../../../common/packageVersionLookup.js';
|
|
3
|
+
/** The version a package is declared at in `sfdx-project.json`, and where that declaration lives. */
|
|
4
|
+
export type PackageVersionGetResult = {
|
|
5
|
+
package: string;
|
|
6
|
+
version: string;
|
|
7
|
+
source: PackageVersionSource;
|
|
8
|
+
packageDirectory: string;
|
|
9
|
+
subscriberPackageVersionId?: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Reads a package's version out of `sfdx-project.json` — either a dependency's version or the
|
|
13
|
+
* version the project's own package is at. Local only: no org, Dev Hub, or auth involved.
|
|
14
|
+
*/
|
|
15
|
+
export default class PackageVersionGet extends SfCommand<PackageVersionGetResult> {
|
|
16
|
+
static readonly summary: string;
|
|
17
|
+
static readonly description: string;
|
|
18
|
+
static readonly examples: string[];
|
|
19
|
+
static readonly requiresProject = true;
|
|
20
|
+
static readonly flags: {
|
|
21
|
+
package: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
22
|
+
directory: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
23
|
+
'flags-dir': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* @returns The declared version of `--package`, and where in the project file it was declared.
|
|
27
|
+
* @throws {SfError} If the package isn't declared, is declared without a resolvable version, or
|
|
28
|
+
* is declared at conflicting versions in more than one package directory.
|
|
29
|
+
*/
|
|
30
|
+
run(): Promise<PackageVersionGetResult>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2026, Clay Chipps.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { Messages } from '@salesforce/core';
|
|
17
|
+
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
18
|
+
import { findPackageVersions, } from '../../../../common/packageVersionLookup.js';
|
|
19
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
20
|
+
const messages = Messages.loadMessages('@simplysf/simply-package', 'simply.package.version.get');
|
|
21
|
+
/**
|
|
22
|
+
* Reads a package's version out of `sfdx-project.json` — either a dependency's version or the
|
|
23
|
+
* version the project's own package is at. Local only: no org, Dev Hub, or auth involved.
|
|
24
|
+
*/
|
|
25
|
+
export default class PackageVersionGet extends SfCommand {
|
|
26
|
+
static summary = messages.getMessage('summary');
|
|
27
|
+
static description = messages.getMessage('description');
|
|
28
|
+
static examples = messages.getMessages('examples');
|
|
29
|
+
static requiresProject = true;
|
|
30
|
+
static flags = {
|
|
31
|
+
...SfCommand.baseFlags,
|
|
32
|
+
package: Flags.string({
|
|
33
|
+
summary: messages.getMessage('flags.package.summary'),
|
|
34
|
+
description: messages.getMessage('flags.package.description'),
|
|
35
|
+
char: 'p',
|
|
36
|
+
required: true,
|
|
37
|
+
}),
|
|
38
|
+
directory: Flags.string({
|
|
39
|
+
summary: messages.getMessage('flags.directory.summary'),
|
|
40
|
+
description: messages.getMessage('flags.directory.description'),
|
|
41
|
+
char: 'd',
|
|
42
|
+
}),
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* @returns The declared version of `--package`, and where in the project file it was declared.
|
|
46
|
+
* @throws {SfError} If the package isn't declared, is declared without a resolvable version, or
|
|
47
|
+
* is declared at conflicting versions in more than one package directory.
|
|
48
|
+
*/
|
|
49
|
+
async run() {
|
|
50
|
+
const { flags } = await this.parse(PackageVersionGet);
|
|
51
|
+
const projectJson = await this.project.retrieveSfProjectJson();
|
|
52
|
+
const project = projectJson.getContents();
|
|
53
|
+
const matches = findPackageVersions(project, flags.package, { directory: flags.directory });
|
|
54
|
+
if (matches.length === 0) {
|
|
55
|
+
throw messages.createError('errors.packageNotFound', [flags.package, describeSearchScope(project, flags)]);
|
|
56
|
+
}
|
|
57
|
+
const versionedMatches = matches.filter((match) => match.version);
|
|
58
|
+
if (versionedMatches.length === 0) {
|
|
59
|
+
throw messages.createError('errors.noVersionFound', [flags.package, matches[0].packageDirectory]);
|
|
60
|
+
}
|
|
61
|
+
const distinctVersions = new Set(versionedMatches.map((match) => match.version));
|
|
62
|
+
if (distinctVersions.size > 1) {
|
|
63
|
+
throw messages.createError('errors.ambiguousMatch', [flags.package, describeMatches(versionedMatches)]);
|
|
64
|
+
}
|
|
65
|
+
const match = versionedMatches[0];
|
|
66
|
+
const result = {
|
|
67
|
+
package: match.package,
|
|
68
|
+
version: match.version,
|
|
69
|
+
source: match.source,
|
|
70
|
+
packageDirectory: match.packageDirectory,
|
|
71
|
+
...(match.subscriberPackageVersionId
|
|
72
|
+
? { subscriberPackageVersionId: match.subscriberPackageVersionId }
|
|
73
|
+
: undefined),
|
|
74
|
+
};
|
|
75
|
+
// Nothing but the version, so `$(sf simply package version get -p foo)` is directly usable.
|
|
76
|
+
// SfCommand.log is a no-op under --json, so this doesn't disturb the JSON output.
|
|
77
|
+
this.log(result.version);
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* @param project - The parsed `sfdx-project.json` contents.
|
|
83
|
+
* @param flags - The command's parsed flags.
|
|
84
|
+
* @returns A description of which package directories were searched, for the not-found error.
|
|
85
|
+
*/
|
|
86
|
+
function describeSearchScope(project, flags) {
|
|
87
|
+
if (flags.directory) {
|
|
88
|
+
return `package directory '${flags.directory}'`;
|
|
89
|
+
}
|
|
90
|
+
const paths = project.packageDirectories.map((directory) => directory.path ?? '<unnamed>');
|
|
91
|
+
return `package directories: ${paths.join(', ')}`;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* @param matches - The conflicting matches.
|
|
95
|
+
* @returns A `version (directory)` list, for the ambiguity error.
|
|
96
|
+
*/
|
|
97
|
+
function describeMatches(matches) {
|
|
98
|
+
return matches.map((match) => `${match.version} (${match.packageDirectory})`).join(', ');
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=get.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get.js","sourceRoot":"","sources":["../../../../../src/commands/simply/package/version/get.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,EACL,mBAAmB,GAGpB,MAAM,4CAA4C,CAAC;AAEpD,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,0BAA0B,EAAE,4BAA4B,CAAC,CAAC;AAWjG;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,SAAkC;IACxE,MAAM,CAAU,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IACzD,MAAM,CAAU,WAAW,GAAG,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IACjE,MAAM,CAAU,QAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IAC5D,MAAM,CAAU,eAAe,GAAG,IAAI,CAAC;I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AC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,IAAI,WAAW,CAAC,CAAC;IAE3F,OAAO,wBAAwB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;AACpD,CAAC;AAED;;;GAGG;AACH,SAAS,eAAe,CAAC,OAA8B;IACrD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,OAAQ,KAAK,KAAK,CAAC,gBAAgB,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5F,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { SfdxProject } from '@simplysf/simply-core';
|
|
2
|
+
/** Where in `sfdx-project.json` a version was declared. */
|
|
3
|
+
export type PackageVersionSource = 'dependency' | 'packageDirectory';
|
|
4
|
+
/** One place a package name is declared in `sfdx-project.json`, and the version found there. */
|
|
5
|
+
export type PackageVersionMatch = {
|
|
6
|
+
/** The name matched on, as written in the project file. */
|
|
7
|
+
package: string;
|
|
8
|
+
/** The declared version, or `undefined` if the declaration carries no resolvable version. */
|
|
9
|
+
version?: string;
|
|
10
|
+
source: PackageVersionSource;
|
|
11
|
+
/** The `path` of the package directory the declaration was found in. */
|
|
12
|
+
packageDirectory: string;
|
|
13
|
+
/** The `04t` the declaration resolves to, when one is knowable from `packageAliases`. */
|
|
14
|
+
subscriberPackageVersionId?: string;
|
|
15
|
+
};
|
|
16
|
+
/** Narrows which package directories {@link findPackageVersions} looks at. */
|
|
17
|
+
export type FindPackageVersionsOptions = {
|
|
18
|
+
/** Only search the package directory with this `path`. */
|
|
19
|
+
directory?: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Split a package reference into its name and version parts.
|
|
23
|
+
*
|
|
24
|
+
* Splits on the *last* `@`, matching how `sfdx-project.json` aliases are written and how
|
|
25
|
+
* `simply-cicd`'s dependabot updater already parses them, so a name that itself contains an `@`
|
|
26
|
+
* (a scoped-style `@ns/pkg`) keeps its name intact.
|
|
27
|
+
*
|
|
28
|
+
* @param value - A package reference, e.g. `test-package@0.1.0+2`, `test-package`, or an ID.
|
|
29
|
+
* @returns The name, plus the version if the reference carried one.
|
|
30
|
+
*/
|
|
31
|
+
export declare function splitPackageAlias(value: string): {
|
|
32
|
+
name: string;
|
|
33
|
+
version?: string;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Find every place `packageName` is declared in a project, and the version declared with it.
|
|
37
|
+
*
|
|
38
|
+
* A package can be declared four ways, all of which are searched:
|
|
39
|
+
* 1. A dependency whose `package` is a versioned alias — `test-package@0.1.0+2`.
|
|
40
|
+
* 2. A dependency whose `package` is a bare name plus a sibling `versionNumber`.
|
|
41
|
+
* 3. A dependency whose `package` is a raw ID, where `packageAliases` maps a versioned alias for
|
|
42
|
+
* `packageName` onto that same ID.
|
|
43
|
+
* 4. A package directory that *builds* `packageName`, i.e. the project's own package version.
|
|
44
|
+
*
|
|
45
|
+
* Matches are returned rather than resolved to a single answer because "the same package declared
|
|
46
|
+
* at two different versions in two directories" is a real project state, and only the caller knows
|
|
47
|
+
* whether that's an error or a list to display.
|
|
48
|
+
*
|
|
49
|
+
* @param project - The parsed `sfdx-project.json` contents.
|
|
50
|
+
* @param packageName - The package name or alias to look up.
|
|
51
|
+
* @param options - Narrows which package directories are searched.
|
|
52
|
+
* @returns Every match, in package-directory order, dependencies before the directory's own
|
|
53
|
+
* package. A match with no `version` means the package is declared but its version isn't
|
|
54
|
+
* knowable from the project file alone.
|
|
55
|
+
*/
|
|
56
|
+
export declare function findPackageVersions(project: SfdxProject, packageName: string, options?: FindPackageVersionsOptions): PackageVersionMatch[];
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2026, Clay Chipps.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { isSubscriberPackageVersionId } from './packageUtils.js';
|
|
17
|
+
/**
|
|
18
|
+
* Split a package reference into its name and version parts.
|
|
19
|
+
*
|
|
20
|
+
* Splits on the *last* `@`, matching how `sfdx-project.json` aliases are written and how
|
|
21
|
+
* `simply-cicd`'s dependabot updater already parses them, so a name that itself contains an `@`
|
|
22
|
+
* (a scoped-style `@ns/pkg`) keeps its name intact.
|
|
23
|
+
*
|
|
24
|
+
* @param value - A package reference, e.g. `test-package@0.1.0+2`, `test-package`, or an ID.
|
|
25
|
+
* @returns The name, plus the version if the reference carried one.
|
|
26
|
+
*/
|
|
27
|
+
export function splitPackageAlias(value) {
|
|
28
|
+
const lastAtIndex = value.lastIndexOf('@');
|
|
29
|
+
// An `@` at index 0 is part of the name (`@ns/pkg`), not a version separator.
|
|
30
|
+
if (lastAtIndex <= 0) {
|
|
31
|
+
return { name: value };
|
|
32
|
+
}
|
|
33
|
+
return { name: value.slice(0, lastAtIndex), version: value.slice(lastAtIndex + 1) || undefined };
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Find every place `packageName` is declared in a project, and the version declared with it.
|
|
37
|
+
*
|
|
38
|
+
* A package can be declared four ways, all of which are searched:
|
|
39
|
+
* 1. A dependency whose `package` is a versioned alias — `test-package@0.1.0+2`.
|
|
40
|
+
* 2. A dependency whose `package` is a bare name plus a sibling `versionNumber`.
|
|
41
|
+
* 3. A dependency whose `package` is a raw ID, where `packageAliases` maps a versioned alias for
|
|
42
|
+
* `packageName` onto that same ID.
|
|
43
|
+
* 4. A package directory that *builds* `packageName`, i.e. the project's own package version.
|
|
44
|
+
*
|
|
45
|
+
* Matches are returned rather than resolved to a single answer because "the same package declared
|
|
46
|
+
* at two different versions in two directories" is a real project state, and only the caller knows
|
|
47
|
+
* whether that's an error or a list to display.
|
|
48
|
+
*
|
|
49
|
+
* @param project - The parsed `sfdx-project.json` contents.
|
|
50
|
+
* @param packageName - The package name or alias to look up.
|
|
51
|
+
* @param options - Narrows which package directories are searched.
|
|
52
|
+
* @returns Every match, in package-directory order, dependencies before the directory's own
|
|
53
|
+
* package. A match with no `version` means the package is declared but its version isn't
|
|
54
|
+
* knowable from the project file alone.
|
|
55
|
+
*/
|
|
56
|
+
export function findPackageVersions(project, packageName, options = {}) {
|
|
57
|
+
const aliases = project.packageAliases ?? {};
|
|
58
|
+
const directories = options.directory
|
|
59
|
+
? project.packageDirectories.filter((directory) => directory.path === options.directory)
|
|
60
|
+
: project.packageDirectories;
|
|
61
|
+
return directories.flatMap((directory) => [
|
|
62
|
+
...findDependencyMatches(directory, packageName, aliases),
|
|
63
|
+
...findOwnPackageMatch(directory, packageName),
|
|
64
|
+
]);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* @param directory - The package directory to search.
|
|
68
|
+
* @param packageName - The package name or alias to look up.
|
|
69
|
+
* @param aliases - The project's `packageAliases` map.
|
|
70
|
+
* @returns Matches among `directory`'s declared dependencies.
|
|
71
|
+
*/
|
|
72
|
+
function findDependencyMatches(directory, packageName, aliases) {
|
|
73
|
+
const packageDirectory = directory.path ?? '';
|
|
74
|
+
return (directory.dependencies ?? []).flatMap((dependency) => {
|
|
75
|
+
if (!dependency.package) {
|
|
76
|
+
return [];
|
|
77
|
+
}
|
|
78
|
+
const { name, version } = splitPackageAlias(dependency.package);
|
|
79
|
+
if (name === packageName) {
|
|
80
|
+
return [
|
|
81
|
+
{
|
|
82
|
+
package: dependency.package,
|
|
83
|
+
version: version ?? dependency.versionNumber,
|
|
84
|
+
source: 'dependency',
|
|
85
|
+
packageDirectory,
|
|
86
|
+
subscriberPackageVersionId: subscriberVersionIdFor(dependency.package, aliases),
|
|
87
|
+
},
|
|
88
|
+
];
|
|
89
|
+
}
|
|
90
|
+
// The dependency is written as a raw ID: recover the version from whichever versioned alias
|
|
91
|
+
// for this package points at that same ID.
|
|
92
|
+
const aliasForId = Object.keys(aliases).find((alias) => aliases[alias] === dependency.package && splitPackageAlias(alias).name === packageName);
|
|
93
|
+
if (!aliasForId) {
|
|
94
|
+
return [];
|
|
95
|
+
}
|
|
96
|
+
return [
|
|
97
|
+
{
|
|
98
|
+
package: aliasForId,
|
|
99
|
+
version: splitPackageAlias(aliasForId).version ?? dependency.versionNumber,
|
|
100
|
+
source: 'dependency',
|
|
101
|
+
packageDirectory,
|
|
102
|
+
subscriberPackageVersionId: isSubscriberPackageVersionId(dependency.package) ? dependency.package : undefined,
|
|
103
|
+
},
|
|
104
|
+
];
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* @param directory - The package directory to search.
|
|
109
|
+
* @param packageName - The package name or alias to look up.
|
|
110
|
+
* @returns A single match if this directory builds `packageName`, otherwise nothing.
|
|
111
|
+
*/
|
|
112
|
+
function findOwnPackageMatch(directory, packageName) {
|
|
113
|
+
if (!directory.package) {
|
|
114
|
+
return [];
|
|
115
|
+
}
|
|
116
|
+
const { name, version } = splitPackageAlias(directory.package);
|
|
117
|
+
if (name !== packageName) {
|
|
118
|
+
return [];
|
|
119
|
+
}
|
|
120
|
+
return [
|
|
121
|
+
{
|
|
122
|
+
package: directory.package,
|
|
123
|
+
version: directory.versionNumber ?? version,
|
|
124
|
+
source: 'packageDirectory',
|
|
125
|
+
packageDirectory: directory.path ?? '',
|
|
126
|
+
},
|
|
127
|
+
];
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* @param reference - A dependency's `package` value.
|
|
131
|
+
* @param aliases - The project's `packageAliases` map.
|
|
132
|
+
* @returns The `04t` `reference` denotes, either directly or through an alias, if any.
|
|
133
|
+
*/
|
|
134
|
+
function subscriberVersionIdFor(reference, aliases) {
|
|
135
|
+
if (isSubscriberPackageVersionId(reference)) {
|
|
136
|
+
return reference;
|
|
137
|
+
}
|
|
138
|
+
const resolved = aliases[reference];
|
|
139
|
+
return resolved && isSubscriberPackageVersionId(resolved) ? resolved : undefined;
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=packageVersionLookup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packageVersionLookup.js","sourceRoot":"","sources":["../../src/common/packageVersionLookup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,4BAA4B,EAAE,MAAM,mBAAmB,CAAC;AAwBjE;;;;;;;;;GASG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAa;IAC7C,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAE3C,8EAA8E;IAC9E,IAAI,WAAW,IAAI,CAAC,EAAE,CAAC;QACrB,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;IACzB,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,GAAG,CAAC,CAAC,IAAI,SAAS,EAAE,CAAC;AACnG,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,mBAAmB,CACjC,OAAoB,EACpB,WAAmB,EACnB,UAAsC,EAAE;IAExC,MAAM,OAAO,GAAG,OAAO,CAAC,cAAc,IAAI,EAAE,CAAC;IAC7C,MAAM,WAAW,GAAG,OAAO,CAAC,SAAS;QACnC,CAAC,CAAC,OAAO,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,KAAK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CAAC,CAAC,CAAC,SAAS,CAAC;AACnF,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# summary
|
|
2
|
+
|
|
3
|
+
Get a package version from sfdx-project.json.
|
|
4
|
+
|
|
5
|
+
# description
|
|
6
|
+
|
|
7
|
+
Reads the version a package is declared at in your project's sfdx-project.json and prints it, so a script doesn't have to parse the project file itself.
|
|
8
|
+
|
|
9
|
+
Both dependencies and the project's own package are searched. A dependency declared as an alias (test-package@0.1.0+2) resolves to the version portion of the alias; a dependency declared as a package name plus a versionNumber resolves to that versionNumber; a dependency declared as a raw ID resolves through packageAliases. A package directory that builds the package resolves to that directory's versionNumber.
|
|
10
|
+
|
|
11
|
+
The version is returned exactly as it appears in the project file — no normalizing between the 0.1.0+2, 57.0.0-3, and 1.2.3.LATEST forms, since each means something to the tool that consumes it.
|
|
12
|
+
|
|
13
|
+
This command reads the project file only. It never contacts an org or a Dev Hub, so it can run in a pipeline before any authentication step.
|
|
14
|
+
|
|
15
|
+
# flags.package.summary
|
|
16
|
+
|
|
17
|
+
Package name or alias to look up.
|
|
18
|
+
|
|
19
|
+
# flags.package.description
|
|
20
|
+
|
|
21
|
+
The package name as it appears in sfdx-project.json, without a version suffix. For a dependency declared as "test-package@0.1.0+2", pass "test-package".
|
|
22
|
+
|
|
23
|
+
# flags.directory.summary
|
|
24
|
+
|
|
25
|
+
Package directory to search.
|
|
26
|
+
|
|
27
|
+
# flags.directory.description
|
|
28
|
+
|
|
29
|
+
The path of a single package directory to search, matching a "path" value in packageDirectories. Use this when the same package is declared at different versions in more than one package directory.
|
|
30
|
+
|
|
31
|
+
# examples
|
|
32
|
+
|
|
33
|
+
- Get the version of a dependency:
|
|
34
|
+
|
|
35
|
+
<%= config.bin %> <%= command.id %> --package test-package
|
|
36
|
+
|
|
37
|
+
- Get the version of the package the project itself builds:
|
|
38
|
+
|
|
39
|
+
<%= config.bin %> <%= command.id %> --package my-package
|
|
40
|
+
|
|
41
|
+
- Get a dependency's version from one package directory:
|
|
42
|
+
|
|
43
|
+
<%= config.bin %> <%= command.id %> --package test-package --directory force-app
|
|
44
|
+
|
|
45
|
+
# errors.packageNotFound
|
|
46
|
+
|
|
47
|
+
No package named '%s' is declared in %s.
|
|
48
|
+
|
|
49
|
+
# errors.noVersionFound
|
|
50
|
+
|
|
51
|
+
The package '%s' is declared in '%s', but without a version. Add a version to its alias (name@version) or a versionNumber to the dependency.
|
|
52
|
+
|
|
53
|
+
# errors.ambiguousMatch
|
|
54
|
+
|
|
55
|
+
The package '%s' is declared at more than one version: %s. Use --directory to choose one package directory.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simplysf/simply-package",
|
|
3
3
|
"description": "Utilities for working with packages",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.10.1",
|
|
5
5
|
"author": "@ClayChipps",
|
|
6
6
|
"homepage": "https://github.com/SimplySF/simply-node",
|
|
7
7
|
"bugs": "https://github.com/SimplySF/simply-node/issues",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"@salesforce/packaging": "^4.22.16",
|
|
78
78
|
"@salesforce/sf-plugins-core": "^12.2.16",
|
|
79
79
|
"@salesforce/ts-types": "^2.0.12",
|
|
80
|
-
"@simplysf/simply-core": "^1.
|
|
80
|
+
"@simplysf/simply-core": "^1.4.0",
|
|
81
81
|
"@simplysf/simply-plugin-kit": "^1.0.4",
|
|
82
82
|
"zod": "^4.1.12"
|
|
83
83
|
},
|
|
@@ -225,5 +225,5 @@
|
|
|
225
225
|
"output": []
|
|
226
226
|
}
|
|
227
227
|
},
|
|
228
|
-
"gitHead": "
|
|
228
|
+
"gitHead": "714cbc02c9cac7b8eb745a5be607e281af238751"
|
|
229
229
|
}
|