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: convert project to use a new source behavior #1015

Merged
merged 23 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
9a48e5c
feat(wip): decompose command
mshanemc May 15, 2024
752ca32
feat: convert a project to use a new sourceBehaviorOption
mshanemc May 17, 2024
d0cc74f
chore: snapshot/schema
mshanemc May 17, 2024
af5efd6
feat: error for behavior change with no matching types
mshanemc May 17, 2024
cb156f0
refactor: rename the command from design
mshanemc May 20, 2024
a6aad08
chore: ut a function
mshanemc May 20, 2024
0463142
test: add a nut, fix bugs that uncovers
mshanemc May 21, 2024
3085af4
chore: bump sdr for renamed prop
mshanemc May 21, 2024
0d6b613
feat: normalize paths for consistency
mshanemc May 21, 2024
eeea4df
test: more nut for preset conversion
mshanemc May 21, 2024
88c02df
Merge remote-tracking branch 'origin/main' into sm/presets-conversion…
mshanemc May 21, 2024
68a6548
test: remove redundant nut
mshanemc May 21, 2024
bd5e7d8
test: win ut only
mshanemc May 21, 2024
da93e05
refactor: calc preset dir once
mshanemc May 21, 2024
e42b798
test: windows ut again
mshanemc May 21, 2024
eaf7a2b
test: restore full test suite
mshanemc May 21, 2024
cb32aa1
fix: edit the messages for "project convert source-behavior" (#1018)
jshackell-sfdc May 24, 2024
87fc4d1
Merge remote-tracking branch 'origin/main' into sm/presets-conversion…
mshanemc May 24, 2024
eefa739
fix: change behavior shortchar
mshanemc May 24, 2024
bfdff8d
chore: snapshot/schema
mshanemc May 24, 2024
845baa5
chore: main conflicts
iowillhoit May 28, 2024
6f95895
Update messages/convert.source-behavior.md
mshanemc May 28, 2024
5490000
chore: pr suggestions
mshanemc May 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
needs: yarn-lockfile-check
uses: salesforcecli/github-workflows/.github/workflows/unitTestsLinux.yml@main
windows-unit-tests:
needs: linux-unit-tests
# needs: linux-unit-tests
mshanemc marked this conversation as resolved.
Show resolved Hide resolved
uses: salesforcecli/github-workflows/.github/workflows/unitTestsWindows.yml@main
nuts:
needs: linux-unit-tests
# needs: linux-unit-tests
mshanemc marked this conversation as resolved.
Show resolved Hide resolved
uses: salesforcecli/github-workflows/.github/workflows/nut.yml@main
secrets: inherit
strategy:
Expand Down
8 changes: 8 additions & 0 deletions command-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@
],
"plugin": "@salesforce/plugin-deploy-retrieve"
},
{
"alias": [],
"command": "project:convert:source-behavior",
"flagAliases": [],
"flagChars": ["b", "o"],
"flags": ["behavior", "dry-run", "flags-dir", "json", "preserve-temp-dir", "target-org"],
"plugin": "@salesforce/plugin-deploy-retrieve"
},
{
"alias": ["force:source:delete"],
"command": "project:delete:source",
Expand Down
70 changes: 70 additions & 0 deletions messages/convert.source-behavior.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# summary

Enable a behavior of your project source files, and then update your Salesforce DX project to implement the behavior.

# description

Specifically, this command updates the "sourceBehaviorOption" option in the "sfdx-project.json" file and then converts the associated local source files in your project as needed.

For example, run this command with the "--behavior decomposePermissionSet" flag to start decomposing permission sets when you deploy or retrieve them. Decomposing means breaking up the monolithic metadata API format XML file that corresponds to a metadata component into smaller XML files and directories based on its subtypes. Permission sets are not decomposed by default; you must opt-in to start decomposing them by using this command. When the command finishes, your "sfdx-project.json" file is updated to always decompose permission sets, and the existing permission set files in your local package directories are converted into the new decomposed format. You run this command only once for a given behavior change.
mshanemc marked this conversation as resolved.
Show resolved Hide resolved

For more information about the possible values for the --behavior flag, see the "sourceBehaviorOptions" section in the https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_ws_config.htm topic.
Copy link
Contributor

Choose a reason for hiding this comment

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

Just confirming this is going to be updated (cc @jshackell-sfdc)

Copy link
Contributor

@jshackell-sfdc jshackell-sfdc May 28, 2024

Choose a reason for hiding this comment

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

My initial thought when I reviewed the help was to NOT include the Beta label in the --help because then we have to remember to update it for GA. But if you think it's better to show it now, then that's fine. I realize that the example wouldn't work in its original form until GA...

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, the command does tell you what the correct behavior names are in the error message:

> sf project convert source-behavior --behavior decomposePermissionSet
Warning: This command is currently in beta. Any aspect of this command can change without advanced notice. Don't use beta commands in your scripts.
Error (2): Expected --behavior=decomposePermissionSet to be one of: decomposeCustomLabelsBeta, decomposePermissionSetBeta, decomposeSharingRulesBeta, decomposeWorkflowBeta
See more help with --help

...but the See more help with --help would be confusing if we don't update them to the correct names (with Beta)

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh sorry, and by "this", I meant the https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_ws_config.htm docs page. It does not currently have a sourceBehaviorOptions section

Copy link
Contributor

Choose a reason for hiding this comment

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

I checked in an update with that new section last week, it should show up tomorrow. Cross your fingers!


# flags.behavior.summary

Behavior to enable; the values correspond to the possible values of the "sourceBehaviorOption" option in the "sfdx-project.json" file.

# examples

- Update your Salesforce DX project to decompose custom labels:

<%= config.bin %> <%= command.id %> --behavior decomposeCustomLabels
mshanemc marked this conversation as resolved.
Show resolved Hide resolved

- Display what the command would do, but don't change any existing files:

<%= config.bin %> <%= command.id %> --behavior decomposeCustomLabels --dry-run
mshanemc marked this conversation as resolved.
Show resolved Hide resolved

- Keep the temporary directory that contains the interim metadata API formatted files:

<%= config.bin %> <%= command.id %> --behavior decomposeCustomLabels --dry-run --preserve-temp-dir
mshanemc marked this conversation as resolved.
Show resolved Hide resolved

# flags.dry-run.summary

Display what the command would do, but don't make any actual changes.

# flags.dry-run.description

Doesn't modify the existing files in your project, including the "sfdx-project.json" file. Instead, the command lists the files that would be deleted, explains the modifications to the "sfdx-project.json" file, and outputs the resulting modifications to a new directory named `DRY-RUN-RESULTS` for review.

# flags.preserve-temp-dir.summary

Don't delete the metadata API format temporary directory that this command creates. Useful for debugging.

# error.trackingNotSupported

Your project has a default org (target-org) that uses source tracking. This operation will cause changes to the local project source files that can't be properly tracked.

# error.trackingNotSupported.actions

- Retrieve any changes or data you need from the org that you haven't already retrieved.
- Delete the org ("sf org delete scratch" or "sf org delete sandbox").
- Run this command again.
- Create a new org ("sf org create scratch" or "sf org create sandbox") and deploy the modified source.

# error.packageDirectoryNeedsMainDefault

The package directory %s doesn't have a main/default structure.
This command moves metadata into a main/default structure, but your package directories aren't ready for it.

# error.packageDirectoryNeedsMainDefault.actions

- Update %s to have all its metadata inside a main/default directory structure.
- Run the command again.

# success.dryRun

Files were created in %s outside your package directories for you to inspect.

# error.noTargetTypes

The project doesn't contain any package directories with metadata that matches the specified behavior %s.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"@salesforce/cli-plugins-testkit": "^5.3.6",
"@salesforce/dev-scripts": "^9.1.2",
"@salesforce/plugin-command-reference": "^3.0.86",
"@salesforce/schemas": "^1.9.0",
"@salesforce/source-testkit": "^2.2.10",
"@salesforce/ts-sinon": "^1.4.19",
"cross-env": "^7.0.3",
Expand Down Expand Up @@ -75,7 +76,7 @@
"description": "Commands to retrieve metadata from a Salesforce org"
},
"convert": {
"description": "Commands to convert metadata from one format to another."
"description": "Commands to change the format of your project source files."
},
"delete": {
"description": "Commands to delete metadata from a Salesforce org."
Expand Down
31 changes: 31 additions & 0 deletions schemas/project-convert-source__behavior.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$ref": "#/definitions/SourceBehaviorResult",
"definitions": {
"SourceBehaviorResult": {
"type": "object",
"properties": {
"sourceBehaviorOptions": {
"type": "array",
"items": {
"type": "string"
}
},
"deletedFiles": {
"type": "array",
"items": {
"type": "string"
}
},
"createdFiles": {
"type": "array",
"items": {
"type": "string"
}
}
},
"required": ["sourceBehaviorOptions", "deletedFiles", "createdFiles"],
"additionalProperties": false
}
}
}
10 changes: 5 additions & 5 deletions schemas/project-delete-source.json
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@
},
"FileResponseSuccess": {
"type": "object",
"additionalProperties": false,
"properties": {
"fullName": {
"type": "string"
Expand All @@ -459,11 +460,11 @@
"enum": ["Created", "Changed", "Unchanged", "Deleted"]
}
},
"required": ["fullName", "state", "type"],
"additionalProperties": false
"required": ["fullName", "state", "type"]
},
"FileResponseFailure": {
"type": "object",
"additionalProperties": false,
"properties": {
"fullName": {
"type": "string"
Expand Down Expand Up @@ -492,11 +493,11 @@
"enum": ["Warning", "Error"]
}
},
"required": ["error", "fullName", "problemType", "state", "type"],
"additionalProperties": false
"required": ["error", "fullName", "problemType", "state", "type"]
},
"MetadataApiDeployStatus": {
"type": "object",
"additionalProperties": false,
"properties": {
"id": {
"type": "string"
Expand Down Expand Up @@ -598,7 +599,6 @@
"status",
"success"
],
"additionalProperties": false,
"description": "Raw response returned from a checkDeployStatus call to the Metadata API"
},
"CoverageResultsFileInfo": {
Expand Down
8 changes: 4 additions & 4 deletions schemas/project-deploy-cancel.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
},
"FileResponseSuccess": {
"type": "object",
"additionalProperties": false,
"properties": {
"fullName": {
"type": "string"
Expand All @@ -157,11 +158,11 @@
"enum": ["Created", "Changed", "Unchanged", "Deleted"]
}
},
"required": ["fullName", "state", "type"],
"additionalProperties": false
"required": ["fullName", "state", "type"]
},
"FileResponseFailure": {
"type": "object",
"additionalProperties": false,
"properties": {
"fullName": {
"type": "string"
Expand Down Expand Up @@ -190,8 +191,7 @@
"enum": ["Warning", "Error"]
}
},
"required": ["error", "fullName", "problemType", "state", "type"],
"additionalProperties": false
"required": ["error", "fullName", "problemType", "state", "type"]
},
"RequestStatus": {
"type": "string",
Expand Down
8 changes: 4 additions & 4 deletions schemas/project-deploy-quick.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
},
"FileResponseSuccess": {
"type": "object",
"additionalProperties": false,
"properties": {
"fullName": {
"type": "string"
Expand All @@ -157,11 +158,11 @@
"enum": ["Created", "Changed", "Unchanged", "Deleted"]
}
},
"required": ["fullName", "state", "type"],
"additionalProperties": false
"required": ["fullName", "state", "type"]
},
"FileResponseFailure": {
"type": "object",
"additionalProperties": false,
"properties": {
"fullName": {
"type": "string"
Expand Down Expand Up @@ -190,8 +191,7 @@
"enum": ["Warning", "Error"]
}
},
"required": ["error", "fullName", "problemType", "state", "type"],
"additionalProperties": false
"required": ["error", "fullName", "problemType", "state", "type"]
},
"RequestStatus": {
"type": "string",
Expand Down
8 changes: 4 additions & 4 deletions schemas/project-deploy-report.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
},
"FileResponseSuccess": {
"type": "object",
"additionalProperties": false,
"properties": {
"fullName": {
"type": "string"
Expand All @@ -157,11 +158,11 @@
"enum": ["Created", "Changed", "Unchanged", "Deleted"]
}
},
"required": ["fullName", "state", "type"],
"additionalProperties": false
"required": ["fullName", "state", "type"]
},
"FileResponseFailure": {
"type": "object",
"additionalProperties": false,
"properties": {
"fullName": {
"type": "string"
Expand Down Expand Up @@ -190,8 +191,7 @@
"enum": ["Warning", "Error"]
}
},
"required": ["error", "fullName", "problemType", "state", "type"],
"additionalProperties": false
"required": ["error", "fullName", "problemType", "state", "type"]
},
"RequestStatus": {
"type": "string",
Expand Down
8 changes: 4 additions & 4 deletions schemas/project-deploy-resume.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
},
"FileResponseSuccess": {
"type": "object",
"additionalProperties": false,
"properties": {
"fullName": {
"type": "string"
Expand All @@ -157,11 +158,11 @@
"enum": ["Created", "Changed", "Unchanged", "Deleted"]
}
},
"required": ["fullName", "state", "type"],
"additionalProperties": false
"required": ["fullName", "state", "type"]
},
"FileResponseFailure": {
"type": "object",
"additionalProperties": false,
"properties": {
"fullName": {
"type": "string"
Expand Down Expand Up @@ -190,8 +191,7 @@
"enum": ["Warning", "Error"]
}
},
"required": ["error", "fullName", "problemType", "state", "type"],
"additionalProperties": false
"required": ["error", "fullName", "problemType", "state", "type"]
},
"RequestStatus": {
"type": "string",
Expand Down
8 changes: 4 additions & 4 deletions schemas/project-deploy-start.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
},
"FileResponseSuccess": {
"type": "object",
"additionalProperties": false,
"properties": {
"fullName": {
"type": "string"
Expand All @@ -157,11 +158,11 @@
"enum": ["Created", "Changed", "Unchanged", "Deleted"]
}
},
"required": ["fullName", "state", "type"],
"additionalProperties": false
"required": ["fullName", "state", "type"]
},
"FileResponseFailure": {
"type": "object",
"additionalProperties": false,
"properties": {
"fullName": {
"type": "string"
Expand Down Expand Up @@ -190,8 +191,7 @@
"enum": ["Warning", "Error"]
}
},
"required": ["error", "fullName", "problemType", "state", "type"],
"additionalProperties": false
"required": ["error", "fullName", "problemType", "state", "type"]
},
"RequestStatus": {
"type": "string",
Expand Down
8 changes: 4 additions & 4 deletions schemas/project-deploy-validate.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
},
"FileResponseSuccess": {
"type": "object",
"additionalProperties": false,
"properties": {
"fullName": {
"type": "string"
Expand All @@ -157,11 +158,11 @@
"enum": ["Created", "Changed", "Unchanged", "Deleted"]
}
},
"required": ["fullName", "state", "type"],
"additionalProperties": false
"required": ["fullName", "state", "type"]
},
"FileResponseFailure": {
"type": "object",
"additionalProperties": false,
"properties": {
"fullName": {
"type": "string"
Expand Down Expand Up @@ -190,8 +191,7 @@
"enum": ["Warning", "Error"]
}
},
"required": ["error", "fullName", "problemType", "state", "type"],
"additionalProperties": false
"required": ["error", "fullName", "problemType", "state", "type"]
},
"RequestStatus": {
"type": "string",
Expand Down
Loading
Loading