Skip to content
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 project optional #771

Merged
merged 13 commits into from
Aug 15, 2024
Merged

feat: make project optional #771

merged 13 commits into from
Aug 15, 2024

Conversation

cristiand391
Copy link
Member

@cristiand391 cristiand391 commented Aug 12, 2024

DEPENDS ON https://github.com/forcedotcom/packaging/pull/638/files

What does this PR do?

forcedotcom/cli#2932

Allow the following commands to be run outside an sfdx project:

  • package delete
  • package update
  • package version delete
  • package version displayancestry
  • package version list
  • package version promote
  • package version report

What issues does this PR fix or reference?

@W-16286213@

@@ -105,7 +106,7 @@ export class PackageVersionListCommand extends SfCommand<PackageVersionListComma
public async run(): Promise<PackageVersionListCommandResult> {
const { flags } = await this.parse(PackageVersionListCommand);
const connection = flags['target-dev-hub'].getConnection(flags['api-version']);
const project = SfProject.getInstance();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this command didn't have requiresProject = true but this line was enforcing it anyway.

@@ -15,36 +15,46 @@ import { env } from '@salesforce/kit';
import { PackageVersionCreateCommand } from '../../../src/commands/package/version/create.js';
import Package2VersionStatus = PackagingSObjects.Package2VersionStatus;

const pkgVersionCreateErrorResult: Partial<PackageVersionCreateRequestResult> = {
const pkgVersionCreateErrorResult: PackageVersionCreateRequestResult = {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this type changed here:
forcedotcom/packaging#627

@cristiand391 cristiand391 marked this pull request as ready for review August 13, 2024 14:34
@cristiand391 cristiand391 changed the title Cd/no project feat: make project optional Aug 13, 2024
Copy link
Contributor

@mshanemc mshanemc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does package:version:update need a Project? It doesn't look like it's reading the project (flags for tag, branch, etc passed as inputs to the method).

I'm going to ask Vivek about the sfdx-projecet modification commetns.

@@ -19,7 +20,6 @@ export class PackageVersionDeleteCommand extends SfCommand<PackageSaveResult> {
public static readonly examples = messages.getMessages('examples');
public static readonly deprecateAliases = true;
public static readonly aliases = ['force:package:version:delete'];
public static readonly requiresProject = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm...[unrelated to this PR] I would have expected the delete command to remove the packageVersion from my project.

I guess it never has (and this was that whole "delete doesn't really delete, just deprecates" so maybe that's correct?)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so maybe that should happen if there's a project, but it's not required?

@@ -19,7 +20,6 @@ export class PackageDeleteCommand extends SfCommand<PackageSaveResult> {
public static readonly examples = messages.getMessages('examples');
public static readonly deprecateAliases = true;
public static readonly aliases = ['force:package:delete'];
public static readonly requiresProject = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also would have expected this to modify sfdx-project after deleting the pkg

@@ -20,7 +21,6 @@ export class PackageUpdateCommand extends SfCommand<PackageSaveResult> {
public static readonly examples = messages.getMessages('examples');
public static readonly deprecateAliases = true;
public static readonly aliases = ['force:package:update'];
public static readonly requiresProject = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same (I'd expect it to update the packageDirectories description/etc with my changes)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mshanemc - I tested something similar with package version update.

I updated the --version-name and --version-description. Both were updated in the DevHub, but neither impacted sfdx-project.json

} catch (err) {
if (err instanceof Error && err.name === 'InvalidProjectWorkspaceError') {
return undefined;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any swallow all other errors?
What's the logic of checking the error name then?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the logic of checking the error name then?

none, I think I was just following the error msg from SfProject.resolve's jsdoc.
Changed to make it swallow all errors that could come from trying to resolve a project.

@VivekMChawla
Copy link

VivekMChawla commented Aug 14, 2024

why does package:version:update need a Project? It doesn't look like it's reading the project (flags for tag, branch, etc passed as inputs to the method).

I'm going to ask Vivek about the sfdx-projecet modification commetns.

@mshanemc - Perhaps package version update wants to update versionName or versionDescription in the relevant packageDirectory object inside sfdx-project.json?

This would only happen if the --version-name or --version-description flags were used with the command.

I've tested this from inside a project. I updated the --version-name and --version-description. Both were updated in the DevHub, but neither impacted sfdx-project.json.

@mshanemc
Copy link
Contributor

mshanemc commented Aug 15, 2024

qa notes

outside a project (from this repo)

package version list
[FIXED] ❌ I think the aliases column should be empty (or omitted entirely!) when there's no Project. As is, it's listing the IDs.
Screenshot 2024-08-15 at 9 48 13 AM

package version report -p 04tKY000000HDvHYAW
package version report -p foo

Error (ErrorInvalidPackageVersionIdError): The provided alias or ID: [foo] could not be resolved to a valid package version ID (05i) or subscriber package version ID (04t).

💡 I wonder how often the cause of that error is going to be "you're not in the project you think you are" and whether maybe it should say that. [another idea would be to spit out some valid aliases if you think that's what they're trying to do]

displayancestry

@mshanemc
Copy link
Contributor

QA cont

package version delete does
package version promote tries to (I chose one without code coverage, so it throws, but not because of the project and it IS able to find the package version)

@mshanemc mshanemc merged commit 5f674ee into main Aug 15, 2024
13 checks passed
@mshanemc mshanemc deleted the cd/no-project branch August 15, 2024 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants