Skip to content

Commit 2eca5c4

Browse files
authored
Merge pull request #144 from amtrack/fix/sf-plugin-style
fix: use sf plugin style
2 parents c33c8c5 + 35ce13b commit 2eca5c4

40 files changed

+2354
-2545
lines changed

.github/workflows/default.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,28 @@ jobs:
1414
default:
1515
runs-on: ubuntu-latest
1616
steps:
17-
- uses: actions/checkout@v3
18-
with:
19-
fetch-depth: 0
20-
- uses: actions/setup-node@v3
17+
- uses: actions/checkout@v4
18+
- uses: actions/setup-node@v4
2119
with:
2220
node-version: 18
2321
- name: Install dependencies
2422
run: |
2523
yarn install
26-
yarn global add sfdx-cli
24+
yarn global add @salesforce/cli
2725
- name: Run unit tests
2826
run: yarn test
2927
- name: Authenticate DevHub and create scratch org
3028
env:
3129
SFDX_AUTH_URL_DEVHUB: ${{ secrets.SFDX_AUTH_URL_DEVHUB }}
3230
run: |
33-
sfdx auth:sfdxurl:store -d -a devhub -f /dev/stdin <<< "${SFDX_AUTH_URL_DEVHUB}"
31+
sf org login sfdx-url -d -a devhub -f /dev/stdin <<< "${SFDX_AUTH_URL_DEVHUB}"
3432
yarn develop
3533
- name: Run end-to-end tests
3634
run: yarn test:e2e
3735
- name: Delete scratch org
3836
if: always()
3937
run: |
40-
sfdx force:org:delete -p
38+
sf org delete scratch -p
4139
- name: Release package
4240
run: npx semantic-release
4341
env:

README.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,50 +6,50 @@
66
>
77
> Please submit issues with your feedback about errors, usability and feature requests.
88
9-
> sfdx plugin for generating a package.xml manifest
9+
> sfdx/sf plugin for generating a package.xml manifest
1010
1111
[![Actions Status](https://github.com/amtrack/sfdx-plugin-package-xml/workflows/Test%20and%20Release/badge.svg)](https://github.com/amtrack/sfdx-plugin-package-xml/actions)
1212

1313
## Installation
1414

1515
```console
16-
sfdx plugins:install sfdx-plugin-package-xml@beta
16+
sf plugins install sfdx-plugin-package-xml@beta
1717
```
1818

1919
## Usage
2020

2121
Commands
2222

2323
```console
24-
sfdx force:mdapi:listallmetadata -h
25-
sfdx package.xml:generate -h
24+
sf force mdapi listallmetadata -h
25+
sf package.xml generate -h
2626
```
2727

28-
> :warning: Note: The first command is similar to the official (`force:mdapi:listmetadata`) command.
28+
> :warning: Note: The first command is similar to the official (`sf force mdapi listmetadata`) command.
2929
>
3030
> However our command lists Metadata for **ALL** Metadata Types.
3131
>
3232
> ```diff
33-
> -force:mdapi:listmetadata
34-
> +force:mdapi:listallmetadata
33+
> -force mdapi listmetadata
34+
> +force mdapi listallmetadata
3535
> ```
3636
3737
## Use Cases
3838
39-
Retrieve all Metadata from an org named `acme-dev` (a.k.a "Metadata Backup", a.k.a. "sfdx force:org:pull")
39+
Retrieve all Metadata from an org named `acme-dev` (a.k.a "Metadata Backup", a.k.a. "sf force org pull")
4040
4141
```console
42-
sfdx force:mdapi:listallmetadata -f /tmp/fileproperties.json -u acme-dev
43-
sfdx package.xml:generate -j /tmp/fileproperties.json -f package.xml --apiversion 54.0
44-
sfdx force:source:retrieve -x package.xml -u acme-dev
42+
sf force mdapi listallmetadata -f /tmp/fileproperties.json -o acme-dev
43+
sfdx package.xml:generate -j /tmp/fileproperties.json -f package.xml --api-version 54.0
44+
sf force source retrieve -x package.xml -o acme-dev
4545
```
4646
4747
Explore Metadata in an org named `acme-dev`
4848

4949
```console
50-
sfdx force:mdapi:listallmetadata --names -u acme-dev
50+
sf force mdapi listallmetadata --names -o acme-dev
5151
# include child Metadata such as CustomField and filter for CustomFields on Account
52-
sfdx force:mdapi:listallmetadata --children --names -u acme-dev | grep "CustomField:Account."
52+
sf force mdapi listallmetadata --children --names -o acme-dev | grep "CustomField:Account."
5353
```
5454

5555
## Concept and Implementation
@@ -93,9 +93,9 @@ For convenience you can also write `CustomField` instead of `CustomField:*`.
9393

9494
They are used throughout this plugin, e.g. in the
9595

96-
- output of `sfdx force:mdapi:listallmetadata --names`
97-
- component names (allow rules) in `sfdx force:mdapi:listallmetadata --metadata`
98-
- ignore rules in `sfdx force:mdapi:listallmetadata --ignore` and `sfdx package.xml:generate --ignore`
96+
- output of `sf force mdapi listallmetadata --names`
97+
- component names (allow rules) in `sf force mdapi listallmetadata --metadata`
98+
- ignore rules in `sf force mdapi listallmetadata --ignore` and `sfdx package.xml:generate --ignore`
9999

100100
### Filtering Metadata
101101

@@ -112,15 +112,15 @@ Examples:
112112
1. To **only** list CustomObjects belonging to a Managed Package Unlocked Package:
113113

114114
```console
115-
sfdx force:mdapi:listallmetadata -m "CustomObject" --managed --unlocked --names
116-
sfdx force:mdapi:listallmetadata -m "CustomObject" --no-unmanaged --names
115+
sf force mdapi listallmetadata -m "CustomObject" --managed --unlocked --names
116+
sf force mdapi listallmetadata -m "CustomObject" --no-unmanaged --names
117117
```
118118

119119
2. To list CustomObjects **except** the ones belonging to a Managed Package OR Unlocked Package:
120120

121121
```console
122-
sfdx force:mdapi:listallmetadata -m "CustomObject" --unmanaged --names
123-
sfdx force:mdapi:listallmetadata -m "CustomObject" --no-managed --no-unlocked --names
122+
sf force mdapi listallmetadata -m "CustomObject" --unmanaged --names
123+
sf force mdapi listallmetadata -m "CustomObject" --no-managed --no-unlocked --names
124124
```
125125

126126
### Package.xml
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Report xmlns="http://soap.sforce.com/2006/04/metadata">
3+
<columns>
4+
<field>USERS.NAME</field>
5+
</columns>
6+
<columns>
7+
<field>ACCOUNT.NAME</field>
8+
</columns>
9+
<columns>
10+
<field>TYPE</field>
11+
</columns>
12+
<columns>
13+
<field>RATING</field>
14+
</columns>
15+
<columns>
16+
<field>DUE_DATE</field>
17+
</columns>
18+
<columns>
19+
<field>LAST_UPDATE</field>
20+
</columns>
21+
<columns>
22+
<field>ADDRESS1_STATE</field>
23+
</columns>
24+
<format>Tabular</format>
25+
<name>FooAccountsClassicReport</name>
26+
<params>
27+
<name>co</name>
28+
<value>1</value>
29+
</params>
30+
<reportType>AccountList</reportType>
31+
<scope>user</scope>
32+
<showDetails>true</showDetails>
33+
<showGrandTotal>true</showGrandTotal>
34+
<showSubTotals>true</showSubTotals>
35+
<timeFrameFilter>
36+
<dateColumn>CREATED_DATE</dateColumn>
37+
<interval>INTERVAL_CUSTOM</interval>
38+
<startDate>2020-11-11</startDate>
39+
</timeFrameFilter>
40+
</Report>

package.json

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,24 @@
1212
"@mdapi-issues/listmetadata-recordtype-personaccount": "2.0.2",
1313
"@mdapi-issues/listmetadata-standardvalueset": "2.0.3",
1414
"@mdapi-issues/listmetadata-standardvaluesettranslation-type": "2.0.2",
15-
"@salesforce/command": "5.2.16",
15+
"@salesforce/sf-plugins-core": "4.0.0",
1616
"get-stdin": "8.0.0",
1717
"lodash": "4.17.21",
18-
"picomatch": "2.3.1",
19-
"tslib": "2.4.0"
18+
"picomatch": "2.3.1"
2019
},
2120
"devDependencies": {
22-
"@types/chai": "4.3.5",
23-
"@types/mocha": "10.0.1",
24-
"chai": "4.3.7",
21+
"@salesforce/cli-plugins-testkit": "4.4.10",
22+
"@salesforce/dev-config": "4.1.0",
23+
"@salesforce/prettier-config": "0.0.3",
24+
"@types/chai": "4.3.9",
25+
"@types/mocha": "10.0.3",
26+
"chai": "4.3.10",
2527
"mocha": "10.2.0",
2628
"nyc": "15.1.0",
27-
"oclif": "3.2.24",
29+
"oclif": "4.0.3",
30+
"prettier": "3.0.3",
2831
"ts-node": "10.9.1",
29-
"typescript": "5.0.4"
32+
"typescript": "5.2.2"
3033
},
3134
"engines": {
3235
"node": ">=14.16"
@@ -49,7 +52,8 @@
4952
"license": "MIT",
5053
"oclif": {
5154
"commands": "./lib/commands",
52-
"bin": "sfdx",
55+
"bin": "sf",
56+
"topicSeparator": " ",
5357
"topics": {
5458
"package.xml": {
5559
"description": "explore metadata in an org and generate a package.xml manifest"
@@ -76,7 +80,7 @@
7680
"develop": "bash scripts/develop.sh",
7781
"prepack": "yarn build",
7882
"prepare": "yarn build",
79-
"test": "nyc --reporter=lcov --reporter=text mocha --require ts-node/register \"test/**/*.test.ts\"",
80-
"test:e2e": "mocha --require ts-node/register \"test/**/*.e2e-spec.ts\""
83+
"test": "tsc -p test && nyc --reporter=lcov --reporter=text mocha --require ts-node/register \"test/**/*.test.ts\"",
84+
"test:e2e": "tsc -p test && mocha --require ts-node/register \"test/**/*.e2e-spec.ts\""
8185
}
8286
}

prettier.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const salesforcePrettierConfig = require("@salesforce/prettier-config");
2+
3+
module.exports = {
4+
...salesforcePrettierConfig,
5+
singleQuote: false,
6+
};

renovate.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
{
2-
"extends": [
3-
"config:base",
4-
":semanticCommits"
5-
]
2+
"extends": ["config:base", ":semanticCommits"]
63
}

scripts/develop.sh

Lines changed: 5 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,8 @@
11
#!/usr/bin/env bash
22

3-
set -e
3+
set -eo pipefail
44

5-
CLI_NAME="$(basename "${BASH_SOURCE[0]}")"
6-
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
7-
REPO_NAME="$(basename "$(dirname "${DIR}")")"
8-
DEFAULT_ALIAS="${REPO_NAME}-dev"
9-
10-
_help() {
11-
echo "${CLI_NAME}."
12-
echo ""
13-
echo "> Setup an environment for development."
14-
echo ""
15-
echo "Usage:"
16-
echo " ${CLI_NAME} [-a SETALIAS]"
17-
echo ""
18-
echo "Options:"
19-
echo " -h --help show help"
20-
echo " -a --setalias SETALIAS set an alias for for the created scratch org (default: ${DEFAULT_ALIAS})"
21-
echo ""
22-
echo "Examples:"
23-
echo " View this help text"
24-
echo " $ ${CLI_NAME} -h"
25-
echo ""
26-
echo " Spin up and configure a scratch org"
27-
echo " $ ${CLI_NAME}"
28-
echo ""
29-
echo " Spin up and configure a scratch org with the given alias (one alphanumerical word, may contain '-_')"
30-
echo " $ ${CLI_NAME} -a myfeature"
31-
}
32-
33-
_main() {
34-
alias="${alias:-${DEFAULT_ALIAS}}"
35-
# shellcheck disable=SC2068
36-
sfdx force:org:create -f config/project-scratch-def.json \
37-
-a "$alias" \
38-
-s \
39-
description="${alias}" ${POSITIONAL_ARGS[@]}
40-
sfdx force:source:push -u "$alias"
41-
}
42-
43-
if [[ "$0" == "${BASH_SOURCE[0]}" ]]; then
44-
set -eo pipefail
45-
POSITIONAL_ARGS=()
46-
while [[ "$#" -gt 0 ]]; do case $1 in
47-
-h|--help) _help; exit 0;;
48-
-a|--setalias) alias="$2"; shift 2;;
49-
*) POSITIONAL_ARGS+=("$1"); shift;;
50-
esac; done
51-
_main "${POSITIONAL_ARGS[@]}"
52-
fi
5+
sf org create scratch -f config/project-scratch-def.json \
6+
-a sfdx-plugin-package-xml-dev \
7+
-d
8+
sf project deploy start

sfdx-project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
],
88
"namespace": "",
99
"sfdcLoginUrl": "https://login.salesforce.com",
10-
"sourceApiVersion": "57.0"
10+
"sourceApiVersion": "59.0"
1111
}

src/cli.ts

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,24 @@ import { readFile } from "fs/promises";
22
import type { FileProperties } from "jsforce/api/metadata";
33
import { toMetadataComponentName } from "./metadata-component";
44

5-
export function parseCommaSeparatedValues(
6-
commaSeparatedMetadataComponentNames: string
7-
): Array<string> {
5+
export function parseCommaSeparatedValues(commaSeparatedMetadataComponentNames?: string): string[] {
86
if (!commaSeparatedMetadataComponentNames) {
97
return [];
108
}
119
return clean(commaSeparatedMetadataComponentNames.split(","));
1210
}
13-
export function parseNewLineSeparatedValues(
14-
newLineSeparatedValues: string
15-
): Array<string> {
11+
export function parseNewLineSeparatedValues(newLineSeparatedValues: string): string[] {
1612
if (!newLineSeparatedValues) {
1713
return [];
1814
}
1915
return clean(newLineSeparatedValues.split(/\r?\n/));
2016
}
2117

22-
function clean(values: Array<string>) {
18+
function clean(values: string[]) {
2319
return values.map((x) => x.trim()).filter(Boolean);
2420
}
2521

26-
export function formatFileProperties(
27-
fileProperties: Array<FileProperties>,
28-
outputType: string
29-
): string {
22+
export function formatFileProperties(fileProperties: FileProperties[], outputType: string): string {
3023
let mapFn;
3124
if (outputType.startsWith("name")) {
3225
mapFn = toMetadataComponentName;
@@ -37,9 +30,7 @@ export function formatFileProperties(
3730
return outputType.endsWith("-csv") ? entries.join(",") : entries.join("\n");
3831
}
3932

40-
export async function getNonEmptyLinesFromFile(
41-
filePath: string
42-
): Promise<string[]> {
33+
export async function getNonEmptyLinesFromFile(filePath: string): Promise<string[]> {
4334
if (!filePath) {
4435
return [];
4536
}
@@ -51,9 +42,7 @@ export async function getNonEmptyLinesFromFile(
5142
);
5243
}
5344

54-
export async function getNonEmptyLinesFromFiles(
55-
filePaths: string[]
56-
): Promise<string[]> {
45+
export async function getNonEmptyLinesFromFiles(filePaths?: string[]): Promise<string[]> {
5746
if (!filePaths) {
5847
return [];
5948
}

0 commit comments

Comments
 (0)