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: repo template additions #1

Merged
merged 38 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
0142dac
feat: prettier config and prettified files
mmoyaferrer Nov 28, 2023
138757f
feat: add prettier, husky
mmoyaferrer Nov 28, 2023
0739727
feat: add vscode extensions
mmoyaferrer Nov 28, 2023
f0989cf
feat: upgrade usage of husky
mmoyaferrer Nov 28, 2023
30067b0
chore: simplify structure
mmoyaferrer Nov 28, 2023
3980cab
feat: add prettier apex plugin
mmoyaferrer Nov 28, 2023
22115bc
ci: refine pmd usage
mmoyaferrer Nov 29, 2023
69014fa
feat: add incremental deploy recipe
mmoyaferrer Nov 29, 2023
89e2df3
feat: add code analyze recipe
mmoyaferrer Nov 29, 2023
34a83fb
ci: update pmd ruleset path
mmoyaferrer Nov 29, 2023
42a298b
chore: namings
mmoyaferrer Nov 29, 2023
500a01d
feat: sfdmu recipe addition
mmoyaferrer Nov 29, 2023
f02b9a5
chore: sfdmu ignore
mmoyaferrer Nov 29, 2023
00d18a1
chore: refactor to sf style
mmoyaferrer Dec 3, 2023
183b691
chore: ignore post-deploy for validation
mmoyaferrer Dec 3, 2023
7fb0dbd
chore: ignore post-deploy in delta calculation
mmoyaferrer Dec 3, 2023
0f52e3e
chore: wip
mmoyaferrer Dec 3, 2023
e1e313f
chore: sample metadata
mmoyaferrer Dec 3, 2023
896179f
chore: husky fix
mmoyaferrer Dec 3, 2023
cc16fb9
docs: update readme
mmoyaferrer Dec 3, 2023
8a61e2d
feat: add eslint
mmoyaferrer Dec 3, 2023
d0ffac2
docs: update eslint config
mmoyaferrer Dec 3, 2023
33b653f
chore: eslint deps
mmoyaferrer Dec 3, 2023
4e8f403
fix: deps
mmoyaferrer Dec 3, 2023
87e972c
chore: switch to yarn
mmoyaferrer Dec 3, 2023
d4c9609
chore: prettier tabs size 2
mmoyaferrer Dec 4, 2023
d8cdf30
chore: reprettify repo
mmoyaferrer Dec 4, 2023
c36632d
chore: insert using 2 spaces
mmoyaferrer Dec 4, 2023
86a016c
chore: switch to 2 spaces format
mmoyaferrer Dec 4, 2023
a3e82df
Merge branch 'main' into feature/repo-template-additions
mmoyaferrer Dec 4, 2023
7ce46d4
chore: fix
mmoyaferrer Dec 4, 2023
da9fb6c
Merge branch 'main' into feature/repo-template-additions
mmoyaferrer Dec 4, 2023
65ea7d2
chore: fix yarn.lock by simply running yarn
amtrack Dec 5, 2023
2df3618
chore: fix sf deploy commands
amtrack Dec 5, 2023
11b87f7
chore: ignore deltas
mmoyaferrer Dec 5, 2023
2191ca5
update scratch org definition
amtrack Dec 6, 2023
8de5edf
chore: switch to four spaces indent
mmoyaferrer Dec 6, 2023
e34e2b2
chore: wip
mmoyaferrer Dec 6, 2023
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
14 changes: 14 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": ["@salesforce/eslint-config-lwc/recommended"],
"overrides": [
{
"files": ["*.test.js"],
"rules": {
"@lwc/lwc/no-unexpected-wire-adapter-usages": "off"
},
"env": {
"node": true
}
}
]
}
61 changes: 61 additions & 0 deletions .github/workflows/code-analyze.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Salesforce Code Quality

on:
workflow_dispatch:
workflow_call:

jobs:
PMD:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- name: Setup Salesforce CLI
run: |
yarn global add @salesforce/cli
sf plugins:install @salesforce/sfdx-scanner
- name: SF Code Analyzer - PMD
run: |
sf scanner:run --engine pmd --target force-app --pmdconfig=config/pmd/ruleset.xml --format table --severity-threshold 3

RetireJS:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- name: Setup Salesforce CLI
run: |
yarn global add @salesforce/cli
sf plugins:install @salesforce/sfdx-scanner
- name: SF Code Analyzer - RetireJS
run: |
sf scanner:run --engine "retire-js" --target force-app --format table --severity-threshold 3

GraphEngine:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- name: Setup Salesforce CLI
run: |
yarn global add @salesforce/cli
sf plugins:install @salesforce/sfdx-scanner
- name: SF Code Analyzer - Data Flow Analysis
run: |
sf scanner:run:dfa --target force-app --projectdir force-app --format table --severity-threshold 3

ESLint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- name: Setup Salesforce CLI
run: |
yarn global add @salesforce/cli
sf plugins:install @salesforce/sfdx-scanner
- name: Install deps
run: |
yarn install
- name: SF Code Analyzer - ESLint
run: |
sf scanner:run --engine eslint --eslintconfig=.eslintrc.json --target "force-app/**/*.js" --format table --severity-threshold 3
65 changes: 65 additions & 0 deletions .github/workflows/incremental-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Based on https://github.com/mehdisfdc/sfdx-GitHub-actions/blob/main/.github/workflows/main.yml
name: Incremental deployment

on:
workflow_dispatch:
inputs:
validateOnly:
description: 'Perform a validation deployment only'
baseRef:
description: 'Git base ref'
required: true
targetRef:
description: 'Git target ref'
required: true
workflow_call:
inputs:
validateOnly:
description: 'Perform a validation deployment only'
type: boolean
baseRef:
description: 'Git base ref'
type: string
required: true
targetRef:
description: 'Git target ref'
type: string
required: true

jobs:
default:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Salesforce CLI
run: |
yarn global add @salesforce/cli
sf version
- name: Generate delta
run: |
echo y | sf plugins:install sfdx-git-delta
if [ "${{ inputs.validateOnly }}" = "true" ]; then
git merge "${{ inputs.baseRef }}"
fi
mkdir -p deltas
sf sgd source delta --from "${{ inputs.baseRef }}" --to "${{ inputs.targetRef }}" --output deltas --generate-delta --ignore .forceignore
echo "# package.xml"
cat deltas/package/package.xml; echo ""
echo "# destructiveChanges.xml"
cat deltas/destructiveChanges/destructiveChanges.xml; echo ""
- name: Deploy changes to target org
run: |
sf org login sfdx-url --set-default --sfdx-url-file <(echo "${{ secrets.SFDX_AUTH_URL_TARGET_ORG }}")
deployFlags=(
--manifest deltas/package/package.xml
--post-destructive-changes deltas/destructiveChanges/destructiveChanges.xml
--wait 30
--test-level RunLocalTests
--verbose
)
if [ "${{ inputs.validateOnly }}" = "true" ]; then
deployFlags+=( --dry-run )
fi
sf project deploy start "${deployFlags[@]}"
21 changes: 21 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Main

on:
push:
branches:
- main

jobs:
code-analyze:
name: Run Salesforce Code Analyzer
uses: ./.github/workflows/code-analyze.yml
secrets: inherit

incremental-deploy:
name: Deploy delta changes
uses: ./.github/workflows/incremental-deploy.yml
secrets: inherit
with:
# Note: This requires the merged PR to only have a single commit or merge commit
baseRef: 'HEAD~1'
targetRef: 'HEAD'
19 changes: 19 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Pull Request

on:
pull_request:

jobs:
code-analyze:
name: Run Salesforce Code Analyzer
uses: ./.github/workflows/code-analyze.yml
secrets: inherit

incremental-deploy:
name: Validate deployment delta changes
uses: ./.github/workflows/incremental-deploy.yml
secrets: inherit
with:
baseRef: 'origin/${GITHUB_BASE_REF}'
targetRef: 'HEAD'
validateOnly: true
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,11 @@ $RECYCLE.BIN/
**/__pycache__/
**/.venv/
**/venv/

# SFDMU
/data/source/
/data/target/
/data/logs/

# SGD
deltas*
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env sh
. "$(dirname "$0")/_/husky.sh"

npm run precommit
3 changes: 3 additions & 0 deletions .lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'**/*.{auradoc,cls,cmp,component,css,design,html,js,json,md,page,trigger,xml,yaml,yml}': 'prettier --write'
};
5 changes: 2 additions & 3 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@
**/staticresources/**
.localdevserver
.sfdx
.vscode

coverage/
*.md
coverage/
32 changes: 21 additions & 11 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
{
"trailingComma": "none",
"overrides": [
{
"files": "**/lwc/**/*.html",
"options": { "parser": "lwc" }
},
{
"files": "*.{cmp,page,component}",
"options": { "parser": "html" }
}
]
"singleQuote": true,
"printWidth": 120,
"requireConfig": false,
"useTabs": false,
"trailingComma": "none",
"bracketSpacing": true,
"jsxBracketSameLine": false,
"semi": true,
"tabWidth": 4,
"editor.formatOnSave": true,
"overrides": [
{
"files": "**/lwc/**/*.html",
"options": { "parser": "lwc" }
},
{
"files": "*.{cmp,page,component}",
"options": { "parser": "html" }
}
],
"plugins": ["prettier-plugin-apex", "@prettier/plugin-xml"]
}
17 changes: 10 additions & 7 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
{
"recommendations": [
"salesforce.salesforcedx-vscode",
"redhat.vscode-xml",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"financialforce.lana"
]
"recommendations": [
"salesforce.salesforcedx-vscode",
"redhat.vscode-xml",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"financialforce.lana",
"mhutchie.git-graph",
"eamodio.gitlens",
"DavidAnson.vscode-markdownlint"
]
}
28 changes: 14 additions & 14 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Apex Replay Debugger",
"type": "apex-replay",
"request": "launch",
"logFile": "${command:AskForLogFileName}",
"stopOnEntry": true,
"trace": true
}
]
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Apex Replay Debugger",
"type": "apex-replay",
"request": "launch",
"logFile": "${command:AskForLogFileName}",
"stopOnEntry": true,
"trace": true
}
]
}
27 changes: 22 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
{
"search.exclude": {
"**/node_modules": true,
"**/bower_components": true,
"**/.sfdx": true
}
"search.exclude": {
"**/node_modules": true,
"**/bower_components": true,
"**/.sfdx": true
},
"apexPMD.rulesets": ["config/pmd/ruleset.xml"],
"[xml]": {
"editor.defaultFormatter": "redhat.vscode-xml"
},
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.insertSpaces": true,
"editor.detectIndentation": false,
"editor.renderWhitespace": "all",
"editor.tabSize": 4,
"prettier.tabWidth": 4,
"prettier.enable": true,
"prettier.useTabs": false,
"prettier.printWidth": 120,
"prettier.singleQuote": true,
"prettier.semi": true,
"prettier.trailingComma": "none"
}
30 changes: 25 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,29 @@
This repository contains
# This repository contains

- a skeleton SF project created with ```sf project generate```
- a custom Salesforce theme
## Skeleton SF Project

Created with ```sf project generate```, with

- a custom Salesforce theme, a sample Apex class and LWC
- an exemplatory Hutte configuration file (hutte.yml) which applies the custom Salesforce theme after Scratch Org creation, and creates a custom button to run a data import
- a sample data set to demonstrate data import via Hutte custom button
- sample data set to demonstrate data import via Hutte custom button

## Main Hutte Recipes

- [incremental deployment recipe](https://github.com/hutte-recipes/cicd-incremental-deployment)
- [salesforce code analyzer recipe](https://github.com/hutte-recipes/cicd-sf-code-analyzer)
- [sfdmu recipe](https://github.com/hutte-recipes/hutte-sfdmu) (including custom button)

## VSCode Presets

- VSCode pre-build settings for editor, PMD and prettier
- VSCode set of recommended extension for Salesforce development

## Code Quality Tools Configuration

Please check https://docs.hutte.io in order to learn more about setting up and using Hutte.
- Prettier baseline configuration
- PMD baseline configuration
- ESLint baseline configuration
- Precommit Husky hook configured with prettier formating

Please check https://docs.hutte.io in order to learn more about setting up and using Hutte.
2 changes: 2 additions & 0 deletions config/data/Account.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Name,Type,BillingStreet,BillingCity,BillingState,BillingPostalCode,BillingCountry,BillingLatitude,BillingLongitude,BillingGeocodeAccuracy,ShippingStreet,ShippingCity,ShippingState,ShippingPostalCode,ShippingCountry,ShippingLatitude,ShippingLongitude,ShippingGeocodeAccuracy,Phone,Fax,AccountNumber,Website,Sic,Industry,AnnualRevenue,NumberOfEmployees,Ownership,TickerSymbol,Description,Rating,Site,Jigsaw,CleanStatus,AccountSource,DunsNumber,Tradestyle,NaicsCode,NaicsDesc,YearStarted,SicDesc,Parent.Name,OperatingHours.Name
Sample Account for Entitlements,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Pending,,,,,,,,,
Empty file added config/data/Contact.csv
Empty file.
Empty file added config/data/Individual.csv
Empty file.
Empty file.
Empty file added config/data/OperatingHours.csv
Empty file.
15 changes: 15 additions & 0 deletions config/data/export.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"objects": [
{
"query": "SELECT readonly_false FROM Account ORDER BY Name ASC",
"operation": "Upsert",
"externalId": "Name"
},
{
"query": "SELECT readonly_false FROM Contact ORDER BY Email,LastName,FirstName ASC",
"operation": "Upsert",
"externalId": "Email;LastName;FirstName"
}
],
"excludeIdsFromCSVFiles": true
}
2 changes: 2 additions & 0 deletions config/data/target/Account_upsert_target.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Name,Type,BillingStreet,BillingCity,BillingState,BillingPostalCode,BillingCountry,BillingLatitude,BillingLongitude,BillingGeocodeAccuracy,ShippingStreet,ShippingCity,ShippingState,ShippingPostalCode,ShippingCountry,ShippingLatitude,ShippingLongitude,ShippingGeocodeAccuracy,Phone,Fax,AccountNumber,Website,Sic,Industry,AnnualRevenue,NumberOfEmployees,Ownership,TickerSymbol,Description,Rating,Site,Jigsaw,CleanStatus,AccountSource,DunsNumber,Tradestyle,NaicsCode,NaicsDesc,YearStarted,SicDesc,Parent.Name,OperatingHours.Name
Sample Account for Entitlements,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Pending,,,,,,,,,
Empty file.
Empty file.
Empty file.
Loading