Skip to content

Commit

Permalink
Merge pull request #126 from texei/fix-xml2js
Browse files Browse the repository at this point in the history
Fix xml2js
  • Loading branch information
FabienTaillon authored Apr 21, 2023
2 parents 33a7ccb + 18f49bd commit 04afab3
Show file tree
Hide file tree
Showing 8 changed files with 1,023 additions and 820 deletions.
44 changes: 22 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ EXAMPLE
--targetusername texei
```

_See code: [src/commands/texei/contractstatus/value/add.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.2/src/commands/texei/contractstatus/value/add.ts)_
_See code: [src/commands/texei/contractstatus/value/add.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.3/src/commands/texei/contractstatus/value/add.ts)_

## `sfdx texei:cpqsettings:set -f <string> [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`

Expand Down Expand Up @@ -107,7 +107,7 @@ EXAMPLE
sfdx texei:cpqsettings:set
```

_See code: [src/commands/texei/cpqsettings/set.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.2/src/commands/texei/cpqsettings/set.ts)_
_See code: [src/commands/texei/cpqsettings/set.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.3/src/commands/texei/cpqsettings/set.ts)_

## `sfdx texei:data:export -d <string> [-o <string>] [-p <string>] [-a <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`

Expand Down Expand Up @@ -145,7 +145,7 @@ EXAMPLES
sfdx texei:data:export --dataplan ./data/data-plan.json --outputdir ./data --targetusername texei
```

_See code: [src/commands/texei/data/export.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.2/src/commands/texei/data/export.ts)_
_See code: [src/commands/texei/data/export.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.3/src/commands/texei/data/export.ts)_

## `sfdx texei:data:import -d <string> [-a] [-o] [-p <string>] [-i] [-u <string>] [--apiversion <string>] [--verbose] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`

Expand Down Expand Up @@ -191,7 +191,7 @@ EXAMPLE
Data imported!
```

_See code: [src/commands/texei/data/import.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.2/src/commands/texei/data/import.ts)_
_See code: [src/commands/texei/data/import.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.3/src/commands/texei/data/import.ts)_

## `sfdx texei:data:plan:generate -d <string> -o <string> [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`

Expand All @@ -218,7 +218,7 @@ EXAMPLE
$ sfdx texei:data:plan:generate --objects Account,Contact,MyCustomObject__c --outputdir ./data
```

_See code: [src/commands/texei/data/plan/generate.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.2/src/commands/texei/data/plan/generate.ts)_
_See code: [src/commands/texei/data/plan/generate.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.3/src/commands/texei/data/plan/generate.ts)_

## `sfdx texei:debug:lwc:enable [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`

Expand All @@ -245,7 +245,7 @@ EXAMPLE
sfdx texei:debug:lwc:enable --targetusername [email protected]
```

_See code: [src/commands/texei/debug/lwc/enable.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.2/src/commands/texei/debug/lwc/enable.ts)_
_See code: [src/commands/texei/debug/lwc/enable.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.3/src/commands/texei/debug/lwc/enable.ts)_

## `sfdx texei:org:contractfieldhistory:fix [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`

Expand Down Expand Up @@ -273,7 +273,7 @@ EXAMPLE
History tracking fixed.
```

_See code: [src/commands/texei/org/contractfieldhistory/fix.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.2/src/commands/texei/org/contractfieldhistory/fix.ts)_
_See code: [src/commands/texei/org/contractfieldhistory/fix.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.3/src/commands/texei/org/contractfieldhistory/fix.ts)_

## `sfdx texei:org:shape:extract [-d <string>] [-s <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`

Expand Down Expand Up @@ -308,7 +308,7 @@ EXAMPLE
$ sfdx texei:org:shape:extract -u [email protected]
```

_See code: [src/commands/texei/org/shape/extract.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.2/src/commands/texei/org/shape/extract.ts)_
_See code: [src/commands/texei/org/shape/extract.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.3/src/commands/texei/org/shape/extract.ts)_

## `sfdx texei:package:dependencies:install [-k <string>] [-b <string>] [-p <string>] [-s <string>] [-n <string>] [-w <number>] [-r] [-a <string>] [-v <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`

Expand Down Expand Up @@ -371,7 +371,7 @@ EXAMPLE
$ texei:package:dependencies:install -u MyScratchOrg -v MyDevHub -k "1:MyPackage1Key 2: 3:MyPackage3Key" -b "DEV"
```

_See code: [src/commands/texei/package/dependencies/install.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.2/src/commands/texei/package/dependencies/install.ts)_
_See code: [src/commands/texei/package/dependencies/install.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.3/src/commands/texei/package/dependencies/install.ts)_

## `sfdx texei:picklist:create -d <string> -o <string> -a <string> -l <string> [-t <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`

Expand All @@ -398,7 +398,7 @@ EXAMPLE
--label "My Field" --apiname MyField__c
```

_See code: [src/commands/texei/picklist/create.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.2/src/commands/texei/picklist/create.ts)_
_See code: [src/commands/texei/picklist/create.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.3/src/commands/texei/picklist/create.ts)_

## `sfdx texei:picklist:restrict -d <string> [-o] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`

Expand Down Expand Up @@ -433,7 +433,7 @@ EXAMPLE
$ sfdx texei:picklist:restrict -d my-unrestricted-picklists.json
```

_See code: [src/commands/texei/picklist/restrict.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.2/src/commands/texei/picklist/restrict.ts)_
_See code: [src/commands/texei/picklist/restrict.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.3/src/commands/texei/picklist/restrict.ts)_

## `sfdx texei:picklist:unrestrict [-o] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`

Expand Down Expand Up @@ -464,7 +464,7 @@ EXAMPLES
$ sfdx texei:picklist:unrestrict --json > my-unrestricted-picklists.json
```

_See code: [src/commands/texei/picklist/unrestrict.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.2/src/commands/texei/picklist/unrestrict.ts)_
_See code: [src/commands/texei/picklist/unrestrict.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.3/src/commands/texei/picklist/unrestrict.ts)_

## `sfdx texei:profile:clean [-k <string>] [-p <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`

Expand Down Expand Up @@ -497,7 +497,7 @@ EXAMPLES
custom-sfdx-source-folder/main/profiles,source-folder-2/main/profiles/myAdmin.profile-meta.xml
```

_See code: [src/commands/texei/profile/clean.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.2/src/commands/texei/profile/clean.ts)_
_See code: [src/commands/texei/profile/clean.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.3/src/commands/texei/profile/clean.ts)_

## `sfdx texei:sharedactivities:enable [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`

Expand All @@ -524,7 +524,7 @@ EXAMPLE
$ sfdx texei:sharedactivities:enable
```

_See code: [src/commands/texei/sharedactivities/enable.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.2/src/commands/texei/sharedactivities/enable.ts)_
_See code: [src/commands/texei/sharedactivities/enable.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.3/src/commands/texei/sharedactivities/enable.ts)_

## `sfdx texei:sharingcalc:recalculate [-s <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`

Expand Down Expand Up @@ -555,7 +555,7 @@ EXAMPLE
Recalculated Sharing Rules
```

_See code: [src/commands/texei/sharingcalc/recalculate.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.2/src/commands/texei/sharingcalc/recalculate.ts)_
_See code: [src/commands/texei/sharingcalc/recalculate.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.3/src/commands/texei/sharingcalc/recalculate.ts)_

## `sfdx texei:sharingcalc:resume [-s <string>] [-t <number>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`

Expand Down Expand Up @@ -589,7 +589,7 @@ EXAMPLE
Sharing calculations resumed
```

_See code: [src/commands/texei/sharingcalc/resume.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.2/src/commands/texei/sharingcalc/resume.ts)_
_See code: [src/commands/texei/sharingcalc/resume.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.3/src/commands/texei/sharingcalc/resume.ts)_

## `sfdx texei:sharingcalc:suspend [-s <string>] [-t <number>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`

Expand Down Expand Up @@ -623,7 +623,7 @@ EXAMPLE
Sharing calculations suspended
```

_See code: [src/commands/texei/sharingcalc/suspend.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.2/src/commands/texei/sharingcalc/suspend.ts)_
_See code: [src/commands/texei/sharingcalc/suspend.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.3/src/commands/texei/sharingcalc/suspend.ts)_

## `sfdx texei:skinnyprofile:check [-p <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`

Expand All @@ -647,7 +647,7 @@ EXAMPLE
$ texei:skinnyprofile:check
```

_See code: [src/commands/texei/skinnyprofile/check.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.2/src/commands/texei/skinnyprofile/check.ts)_
_See code: [src/commands/texei/skinnyprofile/check.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.3/src/commands/texei/skinnyprofile/check.ts)_

## `sfdx texei:skinnyprofile:retrieve [-t <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`

Expand Down Expand Up @@ -677,7 +677,7 @@ EXAMPLE
$ texei:skinnyprofile:retrieve -u MyScratchOrg
```

_See code: [src/commands/texei/skinnyprofile/retrieve.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.2/src/commands/texei/skinnyprofile/retrieve.ts)_
_See code: [src/commands/texei/skinnyprofile/retrieve.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.3/src/commands/texei/skinnyprofile/retrieve.ts)_

## `sfdx texei:source:customlabel:replace -l <string> -v <string> [-p <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`

Expand All @@ -701,7 +701,7 @@ EXAMPLE
$ texei:source:customlabel:replace --label GreatSalesforceBlog --value https://blog.texei.com
```

_See code: [src/commands/texei/source/customlabel/replace.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.2/src/commands/texei/source/customlabel/replace.ts)_
_See code: [src/commands/texei/source/customlabel/replace.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.3/src/commands/texei/source/customlabel/replace.ts)_

## `sfdx texei:source:layouts:cleanorg [-p <string>] [-v <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`

Expand Down Expand Up @@ -734,7 +734,7 @@ EXAMPLES
$ texei:source:layouts:cleanorg --targetusername myScratchOrg --targetdevhubusername myDevHub
```

_See code: [src/commands/texei/source/layouts/cleanorg.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.2/src/commands/texei/source/layouts/cleanorg.ts)_
_See code: [src/commands/texei/source/layouts/cleanorg.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.3/src/commands/texei/source/layouts/cleanorg.ts)_

## `sfdx texei:user:update [-v <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]`

Expand Down Expand Up @@ -767,5 +767,5 @@ EXAMPLES
sfdx texei:user:update --values "LanguageLocaleKey=en_US UserPermissionsMarketingUser=true" --json
```

_See code: [src/commands/texei/user/update.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.2/src/commands/texei/user/update.ts)_
_See code: [src/commands/texei/user/update.ts](https://github.com/texei/texei-sfdx-plugin/blob/v1.17.3/src/commands/texei/user/update.ts)_
<!-- commandsstop -->
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "texei-sfdx-plugin",
"description": "Texeï's plugin for sfdx",
"version": "1.17.2",
"version": "1.17.3",
"author": "Texeï",
"bugs": "https://github.com/texei/texei-sfdx-plugin/issues",
"dependencies": {
Expand All @@ -17,7 +17,8 @@
"npm-check-updates": "^11.5.1",
"puppeteer": "^9.0.0",
"tslib": "^2.3.1",
"unzipper": "^0.10.5"
"unzipper": "^0.10.5",
"xml2js": "^0.5.0"
},
"devDependencies": {
"@oclif/dev-cli": "^1",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/texei/picklist/unrestrict.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default class Unrestrict extends SfdxCommand {
// https://www.npmjs.com/package/xml2js#user-content-parsing-multiple-files
var parser = new xml2js.Parser({ explicitArray: false });
const parseString = util.promisify(parser.parseString);
const fieldJson = await parseString(fieldData);
const fieldJson = JSON.parse(JSON.stringify(await parseString(fieldData)));
if ((fieldJson.CustomField.type === 'Picklist'
|| fieldJson.CustomField.type === 'MultiselectPicklist')
&& fieldJson.CustomField.valueSet?.valueSetName === undefined
Expand Down
2 changes: 1 addition & 1 deletion src/commands/texei/profile/clean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export default class Clean extends SfdxCommand {
// https://www.npmjs.com/package/xml2js#user-content-parsing-multiple-files
var parser = new xml2js.Parser();
const parseString = util.promisify(parser.parseString);
const profileJson = await parseString(data);
const profileJson = JSON.parse(JSON.stringify(await parseString(data)));

// Removing unwanted nodes
for (const nodeKey in profileJson.Profile) {
Expand Down
4 changes: 2 additions & 2 deletions src/commands/texei/skinnyprofile/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ export default class Retrieve extends SfdxCommand {
// https://www.npmjs.com/package/xml2js#user-content-parsing-multiple-files
var parser = new xml2js.Parser();
const parseString = util.promisify(parser.parseString);
const profileJson = await parseString(data);
const profileJson = JSON.parse(JSON.stringify(await parseString(data)));

// Looking for unwanted nodes
for (const [key, value] of Object.entries(profileJson.Profile)) {
this.debug(`key: ${key} - value: ${value}`);

this.debug(key);
if (profileJson.Profile.hasOwnProperty(key)) {
if (nodesNotAllowed.includes(key)) {
// Could definitely be improved
Expand Down
2 changes: 1 addition & 1 deletion src/commands/texei/skinnyprofile/retrieve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export default class Retrieve extends SfdxCommand {
// https://www.npmjs.com/package/xml2js#user-content-parsing-multiple-files
var parser = new xml2js.Parser();
const parseString = util.promisify(parser.parseString);
const profileJson = await parseString(profile);
const profileJson = JSON.parse(JSON.stringify(await parseString(profile)));

// Removing unwanted nodes
for (const nodeKey in profileJson.Profile) {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/texei/source/customlabel/replace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default class Replace extends SfdxCommand {
// https://www.npmjs.com/package/xml2js#user-content-parsing-multiple-files
var parser = new xml2js.Parser();
const parseString = util.promisify(parser.parseString);
const customLabelJson = await parseString(customLabelFile);
const customLabelJson = JSON.parse(JSON.stringify(await parseString(customLabelFile)));
let labelUpdated = false;

const labelIndex = customLabelJson.CustomLabels.labels.findIndex(label => label.fullName == this.flags.label);
Expand Down
Loading

0 comments on commit 04afab3

Please sign in to comment.