Help us understand the problem. What is going on with this article?

Salesforce DX Project Templateを利用した開発をクイックスタートするシェルスクリプト

こんにちは。先日の記事で書いた Salesforce DX Project Template for Remote Development on VS Code を利用して Salesforce のデモを作ることが増えてきました。毎回同じ作業を手動でポチポチやるのが面倒です。

そこで以下のようなスクリプトを作成しました。これを実行するだけで手間をかけずにクイックスタートできるようになりました。主に自分用に用意したものですので、よかったらカスタマイズしてご利用ください。

sfdx-project-template-quickstart.sh
#!/bin/sh

export PROJECT_ROOT=プロジェクトを作成したい場所のパス
export PROJECT_NAME=プロジェクト名
export DEFALT_ORG_ALIAS=デプロイ先の開発環境のエイリアス
export GIT_REMOTE=Gitのリモートリポジトリ

cd ${PROJECT_ROOT}

echo
echo -----------------------------------
echo install vscode-remote-sfdx-project
echo -----------------------------------
git clone https://github.com/takahitomiyamoto/vscode-remote-sfdx-project.git
mv vscode-remote-sfdx-project ${PROJECT_NAME}
rm -rf ${PROJECT_NAME}/.git

echo
echo -----------------------------------
echo install lwc-recipes
echo -----------------------------------
git clone https://github.com/trailheadapps/lwc-recipes
rm -rf ${PROJECT_NAME}/force-app
mv -f lwc-recipes/force-app ${PROJECT_NAME}
mv -f lwc-recipes/data ${PROJECT_NAME}
rm -rf lwc-recipes

cd ${PROJECT_NAME}

echo
echo -----------------------------------
echo set git remote repository
echo -----------------------------------
git init
git remote add origin ${GIT_REMOTE}

echo
echo -----------------------------------
echo install node_modules
echo -----------------------------------
chmod +x ./initNodeModules.sh
./initNodeModules.sh

echo
echo -----------------------------------
echo execute code format and test
echo -----------------------------------
npm run prettier
npm run test

echo
echo -----------------------------------
echo set defaultusername
echo -----------------------------------
sfdx force:config:set defaultusername=${DEFALT_ORG_ALIAS}

echo
echo -----------------------------------
echo deploy lwc-recipes
echo -----------------------------------
sfdx force:source:deploy -u ${DEFALT_ORG_ALIAS} -p force-app

echo
echo -----------------------------------
echo assign permission set
echo -----------------------------------
sfdx force:user:permset:assign -n recipes

echo
echo -----------------------------------
echo import data
echo -----------------------------------
sfdx force:data:tree:import --plan ./data/data-plan.json

echo -----------------------------------
echo open org
echo -----------------------------------
sfdx force:org:open -u ${DEFALT_ORG_ALIAS}
code .

Salesforce 画面と VS Code が立ち上がったら OK です。それでは。

Happy Coding!!

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away