-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: make SfProject
optional
#638
Conversation
SfProject
optional
this.options.project.getPackageIdFromAlias(this.options.packageAliasOrId) ?? this.options.packageAliasOrId; | ||
packageId = this.options.project | ||
? this.options.project.getPackageIdFromAlias(this.options.packageAliasOrId) ?? this.options.packageAliasOrId | ||
: this.options.packageAliasOrId; | ||
if (packageId === this.options.packageAliasOrId) { | ||
throw messages.createError('packageAliasNotFound', [this.options.packageAliasOrId]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the constructor will fail if you pass an alias without project or an invalid alias with a project instance.
options?: PackageVersionListOptions | ||
): Promise<PackageVersionListResult[]> { | ||
// resolve/verify packages | ||
const packages = options?.packages?.map((pkg) => { | ||
const id = project.getPackageIdFromAlias(pkg) ?? pkg; | ||
const id = project ? project.getPackageIdFromAlias(pkg) ?? pkg : pkg; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these IDs are validated below
QA for that last commit: from the plugin using the prerel, ✅ ran with an alias and got the good helpful error message about the missing project |
This PR updates some packaging classes to make
SfProject
optional.See: salesforcecli/plugin-packaging#771
Most of these classes were taking an
SfProject
instance along with a possible package ID or alias (defined in sfdx-project.json). By makingSfProject
optional, consumers of the library can call it without having to create a dummy sfdx-project.Note for review:
there are classes/methods that do need a project b/c they write stuff on it after a package operation, most of these aren't affected by this change (
PackageVersion.updateProjectWithPackageVersion
was updated to throw if there's no project).QA:
Check the plugin-packaging PR linked above, with this branch linked (or the prerelease) you should be able to use the listed commands outside a project.
@W-16286213@