Skip to content

Commit

Permalink
Merge pull request #37 from SFDO-Community-Sprints/wi-36-cliscript
Browse files Browse the repository at this point in the history
Update dx scripts for issue #36 convert to sf cli
  • Loading branch information
iandrosov authored Dec 19, 2023
2 parents a0355e0 + bb4d8da commit 0530983
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 3 deletions.
2 changes: 1 addition & 1 deletion config/project-scratch-def.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"orgName": "Salesforce Impact Labs",
"edition": "Developer",
"features": ["EnableSetPasswordInApi","AuthorApex"],
"features": ["EnableSetPasswordInApi","AuthorApex", "EinsteinHawkingC2CEnabled", "EinsteinGPT"],
"settings": {
"lightningExperienceSettings": {
"enableS1DesktopEnabled": true
Expand Down
3 changes: 2 additions & 1 deletion scripts/dx/dxorg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
##########################################################################################
#
# Author: Igor Androsov 2022
#
# SFDX is DEPRECTAED
##########################################################################################

# Create new Scratch org environment for development testing and load test data
Expand All @@ -13,6 +13,7 @@ ORG_ALIAS="$1"
# Get input for ORG active days with default to 30 days
ACTIVEDAYS="${2:-30}"

echo "--- THIS IS SFDX SCRIPT DEPRECATED START USING SF CLI ---"
echo "--- START DEPLOYMENT FOR: $ORG_ALIAS"
echo "--- New ORG will be active for: $ACTIVEDAYS"
# Set user alias from org name
Expand Down
1 change: 1 addition & 0 deletions scripts/dx/dxtest
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

ORG_ALIAS="$1"

echo "--- THIS IS SFDX SCRIPT DEPRECATED START USING SF CLI ---"
echo "--- START UNIT TESTS FOR: $ORG_ALIAS"

# Run Tests - optional step
Expand Down
1 change: 1 addition & 0 deletions scripts/dx/dxuser
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ ORG_ALIAS="$1"
# Get input for ORG active days with default to 30 days
ACTIVEDAYS="${2:-30}"

echo "--- THIS IS SFDX SCRIPT DEPRECATED START USING SF CLI ---"
echo "--- START DEPLOYMENT FOR: $ORG_ALIAS"
echo "--- New ORG will be active for: $ACTIVEDAYS"
# Set user alias from org name
Expand Down
3 changes: 2 additions & 1 deletion scripts/dx/gitissuescmd
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/sh

# This script is geenrated from exported issues to import to new repository
# THIS SCRIPT IS HERE ONLY FOR REFERENCE How To export/oimport GitHub issues DO NOT RUN
# This script is generated from exported issues to import to new repository
# GitHub does not provide automated methods to export/import or transfer issue on different organizations.
# using GitHub gh CLI gh - commands to do this
# Example CLI command to export all Open issues as JSON to a file, then use create to add issues from file
Expand Down
46 changes: 46 additions & 0 deletions scripts/dx/sforg
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/sh

##########################################################################################
#
# Author: Igor Androsov 2023
#
##########################################################################################

# Create new Scratch org environment for development testing and load test data
# Set input prameter values

ORG_ALIAS="$1"
# Get input for ORG active days with default to 30 days
ACTIVEDAYS="${2:-30}"

echo "--- START DEPLOYMENT FOR: $ORG_ALIAS"
echo "--- New ORG will be active for: $ACTIVEDAYS"
# Set user alias from org name
TESTUSER="${ORG_ALIAS}-user"

# Create new scratch org 30 days max
sf org create scratch --target-dev-hub labsDevHub --alias $ORG_ALIAS --definition-file config/project-scratch-def.json --set-default --duration-days $ACTIVEDAYS || { echo 'Scratch org create failed' ; exit 1; }

# Create test user
# sfdx force:user:create --setalias $TESTUSER --definitionfile config/user-def.json || { echo 'Scratch org User create failed' ; exit 1; }
# sfdx force:user:display -u $TESTUSER

# Push source
echo "--- PUSH SOURCE FOR: $ORG_ALIAS"
sf project deploy start --target-org $ORG_ALIAS || { echo 'Source push failed' ; exit 1; }

# Assign Permission Set to users
echo "--- ASSIGN PERMISSIONS FOR: $ORG_ALIAS"
sf org assign permset --name GGW_User_Permissions --target-org $ORG_ALIAS || { echo 'User permission failed' ; exit 1; }

# Push sample data
echo "--- INSERT SAMPLE DATA FOR: $ORG_ALIAS"
sf data import tree --plan test-data/export-section-GGW_Section__c-plan.json --target-org $ORG_ALIAS

# sfdx force:data:tree:import --target-org $ORG_ALIAS --plan test-data/export-section-GGW_Section__c-plan.json
#sfdx force:data:tree:import -u ggw --plan test-data/export-section-GGW_Section__c-plan.json
# Run Tests - optional step

# Open new org
#sf org open --target-org $ORG_ALIAS
echo "--- END DEPLOYMENT FOR: $ORG_ALIAS"
23 changes: 23 additions & 0 deletions scripts/dx/sftest
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/sh

##########################################################################################
#
# Author: Igor Androsov 2023
#
# Script to run APEX Unit Tests for project
# For more details on sfdx testing refer to:
# https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_testing.htm
##########################################################################################

# Run all unit tests on new Scratch org environment asynchronous
# Set input prameter values org alias

ORG_ALIAS="$1"

echo "--- START UNIT TESTS FOR: $ORG_ALIAS"

# Run Tests - optional step
# --- DEPRECTAED CLI OPTIONS change to new version of sfdx
sf apex run test --code-coverage --detailed-coverage --result-format human --target-org $ORG_ALIAS

echo "--- END UNIT TESTS FOR: $ORG_ALIAS"
33 changes: 33 additions & 0 deletions scripts/dx/sfuser
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/sh

##########################################################################################
#
# Author: Igor Androsov 2023
#
# IMPORTANT! Before exec this script update the QA user email address to allow password
# resets. Replace placeholder value <PLACE USER EMAIL HERE> in config/user-def.json file with
# correct user email.
##########################################################################################

# Create new QA User for Scratch org environment for testing and avlidation
# Required existing scratch org set with alias
# Set input prameter values

ORG_ALIAS="$1"
# Get input for ORG active days with default to 30 days
ACTIVEDAYS="${2:-30}"

echo "--- START DEPLOYMENT FOR: $ORG_ALIAS"
echo "--- New ORG will be active for: $ACTIVEDAYS"
# Set user alias from org name
TESTUSER="${ORG_ALIAS}-user"

# Create test user
sf org create user --set-alias $TESTUSER --definition-file config/user-def.json --target-org $ORG_ALIAS || { echo 'Scratch org User create failed' ; exit 1; }
sfdx force:user:display -u $TESTUSER

# Assign Permission Set to users
sf org assign permset --name GGW_User_Permissions --onbehalfof $TESTUSER --target-org $ORG_ALIAS || { echo 'User permission failed' ; exit 1; }

# Open new org
#sf org open -u $ORG_ALIAS

0 comments on commit 0530983

Please sign in to comment.