Salesforce中DX​学习的示例分析

这篇文章给大家介绍Salesforce中DX学习的示例分析,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。

Salesforce DX 学习

  1. 登录到开发中心 sfdx force:auth:web:login -d -a DevHub -a 创建别名 -d 设置为默认组织

  2. 创建文件夹 mkdir folderName cd folderName

  3. clone
    git clone https://github.com/dreamhouseapp/dreamhouse-sfdx.git

  4. 删除scratch
    sfdx force:org:delete

  5. 一个scratch 配置

     {
       "orgName": "Dreamhouse",
       "edition": "Developer",
       "hasSampleData": "false",
       "settings": {
         "orgPreferenceSettings": {
           "s1DesktopEnabled": true,
           "selfSetPasswordInApi": true,
           "s1EncryptedStoragePref2": false
         }
       }
     }


  6. 创建Scratch Org 并设置为默认 sfdx force:org:create -s -f config/project-scratch-def.json -a dreamhouse-org

  7. 打开指定org sfdx force:org:open -u xxx

  8. 将元数据推送到Scratch sfdx force:source:push

  9. 分配权限 sfdx force:user:permset:assign -n xxxx

  10. 导入样本数据 sfdx force:data:tree:import --plan data/sample-data-plan.json

创建一个包

需要在sfdx中设置DevHub为默认,同时需要开启package Salesforce中DX​学习的示例分析Salesforce中DX​学习的示例分析

  1. 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
    Salesforce中DX​学习的示例分析

  • 关于Salesforce中DX学习的示例分析就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。