Skip to content

Commit

Permalink
fix: boolean attribute and comment xml parsing (#738)
Browse files Browse the repository at this point in the history
Co-authored-by: joernflath <[email protected]>
  • Loading branch information
scolladon and joernflath authored Dec 12, 2023
1 parent bc9833d commit 2ec2a87
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 36 deletions.
3 changes: 2 additions & 1 deletion .github/linters/.cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"**/megalinter.yml",
"**/yarn.lock",
"**/.yarnrc.yml",
"**/src/metadata/**"
"**/src/metadata/**",
"**/src/service/typeHandlerFactory.ts"
],
"language": "en",
"noConfigSearch": true,
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/manual-deprecate-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18
registry-url: 'https://registry.npmjs.org'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/manual-manage-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18
registry-url: 'https://registry.npmjs.org'
Expand Down
18 changes: 8 additions & 10 deletions .github/workflows/on-main-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ jobs:
release_created: ${{ steps.release.outputs.release_created }}
version: ${{ steps.release.outputs.version }}
steps:
- uses: google-github-actions/release-please-action@v3
- uses: google-github-actions/release-please-action@v4
id: release
with:
release-type: node
package-name: sfdx-git-delta
token: ${{ secrets.RELEASE_PAT }}

release:
Expand All @@ -34,10 +32,10 @@ jobs:
if: needs.prepare-release.outputs.release_created == 'true'
steps:
- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18
registry-url: 'https://registry.npmjs.org'
Expand All @@ -61,13 +59,13 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: 'e2e/head'
fetch-depth: 0

- name: Setup node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}

Expand All @@ -91,10 +89,10 @@ jobs:
if: needs.prepare-release.outputs.release_created != 'true'
steps:
- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18

Expand Down Expand Up @@ -124,7 +122,7 @@ jobs:
sfdx plugins
- name: Checkout e2e test subject
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: 'e2e/head'
fetch-depth: 0
Expand Down
26 changes: 13 additions & 13 deletions .github/workflows/on-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ jobs:
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
steps:
- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18

Expand All @@ -50,10 +50,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18

Expand All @@ -74,16 +74,16 @@ jobs:
steps:
# Git Checkout
- name: Checkout Code
uses: actions/checkout@v3
uses: actions/checkout@v4

# MegaLinter
- name: MegaLinter
# You can override MegaLinter flavor used to have faster performances
# More info at https://megalinter.io/flavors/
uses: oxsecurity/megalinter/flavors/javascript@v6
# More info at https://megalinter.io/latest/flavors/
uses: oxsecurity/megalinter/flavors/javascript@v7
env:
# All available variables are described in documentation
# https://megalinter.io/configuration/
# https://megalinter.io/latest/config-file/
APPLY_FIXES: all
VALIDATE_ALL_CODEBASE: true
# ADD CUSTOM ENV VARIABLES HERE TO OVERRIDE VALUES OF .mega-linter.yml AT THE ROOT OF YOUR REPOSITORY
Expand All @@ -100,10 +100,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18

Expand Down Expand Up @@ -137,10 +137,10 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}

Expand Down Expand Up @@ -170,7 +170,7 @@ jobs:
sfdx plugins
- name: Checkout e2e test subject
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: 'e2e/head'
fetch-depth: 0
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/reusable-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18

Expand All @@ -32,7 +32,7 @@ jobs:
continue-on-error: true

- name: Checkout e2e sources
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: 'e2e/head'
fetch-depth: 0
Expand Down
5 changes: 3 additions & 2 deletions .mega-linter.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
# Configuration file for MegaLinter
# See all available variables at https://megalinter.io/configuration/ and in linters documentation
# See all available variables at https://megalinter.io/latest/config-file/ and in linters documentation

APPLY_FIXES: all # all, none, or list of linter keys
# ENABLE: # If you use ENABLE variable, all other languages/formats/tooling-formats will be disabled by default
Expand All @@ -10,7 +10,8 @@ APPLY_FIXES: all # all, none, or list of linter keys
# - SPELL # Uncomment to disable checks of spelling mistakes
DISABLE_LINTERS:
- SPELL_MISSPELL
- TYPESCRIPT_STANDARD
- TYPESCRIPT_PRETTIER
SHOW_ELAPSED_TIME: true
FILEIO_REPORTER: false
JAVASCRIPT_DEFAULT_STYLE: prettier
# DISABLE_ERRORS: true # Uncomment if you want MegaLinter to detect errors but not block CI to pass
7 changes: 7 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"packages": {
".": {
"release-type": "node"
}
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<br />
<div align="center">
<img src="img/SGD_logo.png" width="128">
<img src="img/SGD_logo.png" width="128" alt="SGD logo">
<h1 align="center">SFDX-Git-Delta </h1>

<p align="center">
Expand Down
2 changes: 2 additions & 0 deletions lychee.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
exclude_mail = true
exclude_path = ["CHANGELOG.md"]
12 changes: 10 additions & 2 deletions src/utils/fxpHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { XML_HEADER_TAG_END } from './metadataConstants'
import { Config } from '../types/config'

const XML_PARSER_OPTION = {
commentPropName: '#comment',
ignoreAttributes: false,
ignoreNameSpace: false,
parseTagValue: false,
Expand All @@ -18,15 +19,22 @@ const JSON_PARSER_OPTION = {
...XML_PARSER_OPTION,
format: true,
indentBy: ' ',
suppressBooleanAttributes: false,
suppressEmptyNode: false,
}

export const asArray = (node: string[] | string) => {
return Array.isArray(node) ? node : [node]
}

export const xml2Json = (xmlContent: string) => {
const xmlParser = new XMLParser(XML_PARSER_OPTION)
return xmlParser.parse(xmlContent)
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let jsonContent: any = {}
if (xmlContent) {
const xmlParser = new XMLParser(XML_PARSER_OPTION)
jsonContent = xmlParser.parse(xmlContent)
}
return jsonContent
}

export const parseXmlFileToJson = async (line: string, config: Config) => {
Expand Down

0 comments on commit 2ec2a87

Please sign in to comment.