Skip to content

Commit d15720d

Browse files
authored
feat: add new sf crud-mdapi read command (#117)
The new `sf crud-mdapi read` command replaces `sf force source read` which is now deprecated and will be removed in the next major release (`v2`). - **new flags**: `--output-dir` and `--manifest` - **renamed flag**: `--sourcepath` (`-p`) is now `--source-dir` (`-d`) - **changed flag**: `--metadata` can now be specified multiple times instead of only once as comma-separated string - the global sf flag `--flags-dir` is now supported - Metadata like `CustomObjectTranslation` is now **decomposed** into multiple files (e.g. `.objectTranslation-meta.xml`, `.fieldTranslation-meta.xml`) Please see the [Migration Guide](https://github.com/amtrack/sfdx-plugin-source-read/wiki/Migration#sf-crud-mdapi-read).
1 parent a741f07 commit d15720d

38 files changed

Lines changed: 3344 additions & 1597 deletions

File tree

.github/workflows/default.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,12 @@ jobs:
2222
npm install --global @salesforce/cli
2323
- name: Run tests
2424
run: npm run test
25-
- name: Run E2E tests
25+
- name: Run E2E tests in Developer Edition
2626
env:
27-
SFDX_AUTH_URL_DEVHUB: ${{ secrets.SFDX_AUTH_URL_DEVHUB }}
27+
SFDX_AUTH_URL_DEVED: ${{ secrets.SFDX_AUTH_URL_DEVED }}
2828
run: |
29-
echo "${SFDX_AUTH_URL_DEVHUB}" | sf org login sfdx-url --set-default-dev-hub --alias devhub --sfdx-url-stdin
30-
sf org create scratch -f config/project-scratch-def.json --set-default
29+
echo "${SFDX_AUTH_URL_DEVED}" | sf org login sfdx-url --set-default --alias deved --sfdx-url-stdin
3130
npm run test:e2e
32-
- name: Delete scratch org
33-
if: always()
34-
run: |
35-
sf org delete scratch --no-prompt
3631
- name: Release package
3732
run: npx semantic-release
3833
env:

README.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@
44
55
For certain Metadata Types there is a different behaviour of the [file-based](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_retrieve.htm) vs. [CRUD-based](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_readMetadata.htm) Metadata API.
66

7-
This plugin provides a `sf force source read` command to read Metadata using the "CRUD-based" Metadata API similar to `sf force source retrieve` (which uses the "file-based" Metadata API).
7+
And additionally the file-based Metadata API even behaves differently for source-tracked vs. non-source-tracked orgs.
8+
9+
> [!IMPORTANT]
10+
> The CRUD-based Metadata API can be of great help when working with non-source-tracked orgs.
11+
>
12+
> Read more about about this in my [mdapi-issues/retrieve-behavior-scratch-org](https://github.com/mdapi-issues/retrieve-behavior-scratch-org) repository.
13+
14+
This plugin provides a `sf crud-mdapi read` (formerly `sf force source read`) command to read Metadata using the "CRUD-based" Metadata API similar to `sf project retrieve start` (which uses the "file-based" Metadata API).
815

916
> [!NOTE]
1017
> This plugin simply returns the unfiltered response from the CRUD-based Metadata API.
@@ -20,11 +27,11 @@ sf plugins install sfdx-plugin-source-read
2027
## Usage
2128

2229
```console
23-
sf force source read -m "Profile:Admin"
24-
sf force source read -p force-app/main/default/profiles/Admin.profile-meta.xml
25-
sf force source read -m "RecordType:Account.Business"
26-
sf force source read -p force-app/main/default/objects/Account/recordTypes/Business.recordType-meta.xml
27-
sf force source read -m "CustomObjectTranslation:Task-de"
30+
sf crud-mdapi read --metadata "Profile:Admin" --metadata "Profile:Standard"
31+
sf crud-mdapi read --source-dir force-app/main/default/profiles/Admin.profile-meta.xml
32+
sf crud-mdapi read --metadata "RecordType:Account.Business"
33+
sf crud-mdapi read --source-dir force-app/main/default/objects/Account/recordTypes/Business.recordType-meta.xml
34+
sf crud-mdapi read --metadata "CustomObjectTranslation:Task-de"
2835
```
2936

3037
## Example

bin/dev.cmd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@echo off
2+
3+
node --loader ts-node/esm --no-warnings=ExperimentalWarning "%~dp0\dev" %*

bin/dev.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env -S node --loader ts-node/esm --no-warnings=ExperimentalWarning
2+
// eslint-disable-next-line node/shebang
3+
async function main() {
4+
const { execute } = await import("@oclif/core");
5+
await execute({ development: true, dir: import.meta.url });
6+
}
7+
8+
await main();

bin/run.cmd

100644100755
File mode changed.
File renamed without changes.

config/project-scratch-def.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,9 @@
33
"edition": "Developer",
44
"language": "en_US",
55
"features": [],
6-
"settings": {}
6+
"settings": {
7+
"languageSettings": {
8+
"enableTranslationWorkbench": true
9+
}
10+
}
711
}

0 commit comments

Comments
 (0)