3
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

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

Last updated at Posted at 2019-09-15

こんにちは。先日の記事で書いた 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 ${LWC_RECIPES_DUMMY_URL}
rm -rf ${PROJECT_NAME}/force-app
mv -f ${LWC_RECIPES_DUMMY}/force-app ${PROJECT_NAME}
mv -f ${LWC_RECIPES_DUMMY}/data ${PROJECT_NAME}
rm -rf ${LWC_RECIPES_DUMMY}

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 create scratch org
echo -----------------------------------
sfdx force:org:create -a ${DEFALT_ORG_ALIAS} -f config/project-scratch-def.json -s

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!!

3
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?