Salesforce DX 学习
-
登录到开发中心
sfdx force:auth:web:login -d -a DevHub
-a 创建别名 -d 设置为默认组织 -
创建文件夹
mkdir folderName
cd folderName
-
clone
git clone https://github.com/dreamhouseapp/dreamhouse-sfdx.git
-
删除scratch
sfdx force:org:delete
-
一个scratch 配置
{ "orgName": "Dreamhouse", "edition": "Developer", "hasSampleData": "false", "settings": { "orgPreferenceSettings": { "s1DesktopEnabled": true, "selfSetPasswordInApi": true, "s1EncryptedStoragePref2": false } } }
-
创建Scratch Org 并设置为默认
sfdx force:org:create -s -f config/project-scratch-def.json -a dreamhouse-org
-
打开指定org
sfdx force:org:open -u xxx
-
将元数据推送到Scratch
sfdx force:source:push
-
分配权限
sfdx force:user:permset:assign -n xxxx
-
导入样本数据
sfdx force:data:tree:import --plan data/sample-data-plan.json
创建一个包
需要在sfdx中设置DevHub为默认,同时需要开启package


sfdx force:package:create --name dreamhouse --description "My Package" --packagetype Unlocked --path force-app --nonamespace --targetdevhubusername DevHub
- --name is the package name. This name is an alias you can use when running subsequent packaging commands.
- --path is the directory that contains the contents of the package.
- --packagetype indicates which kind of package you’re creating, in this case, unlocked.
- 创建版本:
sfdx force:package:version:create -p dreamhouse -d force-app -k test1234 --wait 10 -v DevHub
- -p is the package alias that maps to the package ID.
- -d is the directory that contains the contents of the package.
- -k is the installation key that protects your package from being installed by unauthorized individuals.
- 转换成正式版本:
sfdx force:package:version:promote -p dreamhouse@1.0.0-1 -v DevHub
- 安装到Org中:
sfdx force:package:install --wait 10 --publishwait 10 --package dreamhouse@1.0.0-1 -k test1234 -r -u MyScratchOrg