よく利用するSFDX CLI命令をご紹介させていただきたいです。
以下の命令はちゃんと覚えてもいいと思います。
①Projectを作成します。
sfdx force:project:Create –projectname mywork
②Dev Hub有効化になるSF環境をログインします。
sfdx force:auth:web:login -d -a MyDev
③Scratch Orgを作成します。
sfdx force:org:create -s -f config/project-scratch-def.json -a MyScratch
何も指定いない場合、usernameとかadminEmailとか、利用期間(7)もデフォルト値がありますので。
sfdx force:org:create -s -f config/project-scratch-def.json -a MyScratch -d 10
sfdx force:org:create -s -f config/project-scratch-def.json -a MyScratch -d 20 adminEmail=123@qq.com edition=Developer username=admin@zc.com
もしScratchを作成できないみたいエラーメッセージを発生した場合がございましたら、
先程、②のDev Hub有効化のSF環境をログインしてから、App Launcher, select Active Scratch Org、
Scratch Limitがあると思いますので、削除しても大丈夫ですね。
④ScratchOrgの情報をクリアします。
sfdx force:data:soql:query -q “SELECT ID, Name, Status FROM ScratchOrgInfo WHERE CreatedBy.Name = ‘Chao Zhang’ AND CreatedDate = TODAY” -u MyDev
Accountの情報をクリアします。
sfdx force:data:soql:query -q “SELECT ID, Name FROM Account” -u MyDev
⑤Accountの情報をエクスポートします。
sfdx force:data:tree:export -q “Select iD,Name from Account” -u MyDev
Workspaceの中にAccount.json が取得します。
以下のようなファイルです。
Account.json
{
"records": [
{
"attributes": {
"type": "Account",
"referenceId": "AccountRef18"
},
"Name": "Test333",
"BillingState": "北海道"
},
{
"attributes": {
"type": "Account",
"referenceId": "AccountRef19"
},
"Name": "Test555",
"BillingState": "青森県"
}
]
}
⑥Accountの情報をインポートします。
sfdx force:data:tree:import -f Account.json -u MyDev
sfdx force:data:tree:import -f config/data/Account.json -u MyDev //ディレクトリがある場合
Account.json
実際の画面を確認します。インポート致しました。
⑦MyScratchをログインします。
sfdx force:org:open -u MyScratch
ローカルとリモートとの変化
sfdx force:source:status
MyScratch環境でAccountにカスタム項目Testを作成しました。またsfdx force:source:status
⑧ScratchからローカルにPullし、ローカルからScratchにPushします。
sfdx force:source:pull
sfdx force:source:push
⑨User情報をクリアします。
sfdx force:user:display
sfdx force:user:list
sfdx force:user:display –targetusername MyScratch
⑩
sfdx force:user:create –setalias qa-user –definitionfile config/project-user-def.json
project-user-def.json
環境で確認します。
sfdx force:user:list
sfdx force:user:display –targetusername qa-user
⑪UserのPasswordを生成します。Passwordを見えます。
sfdx force:user:password:generate –targetusername MyScratch
sfdx force:user:password:generate –targetusername MyScratch –onbehalfof qa-user,xxxUser
sfdx force:user:display -u user1@zc.com
sfdx force:user:display -u admin@zc.com
⑫SFDXすべての命令
sfdx force –help
sfdx force:doc:commands:list
意識を持っていますか?
ポイントは:
例えば、sfdx force:user:display は どのパラメータはありますでしょうか?どういう使えばいいでしょうか?
その際にはsfdx force:user:display –helpで調査していいんじゃないですか。
老子曰く、「授人以魚 不如授人以漁」
和訳すると、
人に授ける(さずける)に魚を以って(もって)するは、漁を以って(もって)するに如かず(しかず)。この言葉を、今の時代の意味に訳すと下記となります。
「ある人に魚を一匹与えれば、その人は一日食える。
しかし、
魚の取り方を教えれば、その人は一生を通して食える。」魚を与えるより漁の方法を教える方がいい
Give me a fish and I will eat today; teach me to fish and I will eat all my life.
人に魚を与えれば、一日の糧となる。人に魚を捕ることを教えれば、一生食べていくことができる。
sfdx force:doc:commands:list
WARNING: The command "DocListCommand" has been deprecated and will be removed in v49.0 or later. Use "sfdx commands" instead.
=== Commands
force:alias:list # list username aliases for the Salesforce CLI
force:alias:set # set username aliases for the Salesforce CLI
force:analytics:template:create # add an Analytics template to your workspace
force:apex:class:create # create an Apex class
force:apex:execute # execute anonymous Apex code
force:apex:log:get # fetch the last debug log
force:apex:log:list # list debug logs
force:apex:log:tail # start debug logging and display logs
force:apex:test:report # display test results
force:apex:test:run # invoke Apex tests
force:apex:trigger:create # create an Apex trigger
force:auth:device:login # authorize an org using a device code
force:auth:jwt:grant # authorize an org using the JWT flow
force:auth:list # list auth connection information
force:auth:logout # log out from authorized orgs
force:auth:sfdxurl:store # authorize an org using an SFDX auth URL
force:auth:web:login # authorize an org using the web login flow
force:cmdt:create # creates a new custom metadata type in the current project
force:cmdt:field:create # generate a custom metadata field based on the field type provided
force:cmdt:generate # generates a custom metadata type and all its records for the provided sObject
force:cmdt:record:create # create a new record for a given custom metadata type in the current project
force:cmdt:record:insert # create new custom metadata type records from a CSV file
force:community:create # creates a community using a template
force:community:publish # publishes a Lightning community to make it live
force:community:template:list # retrieves the list of templates available in your org
force:config:get # get config var values for given names
force:config:list # list config vars for the Salesforce CLI
force:config:set # set config vars for the Salesforce CLI
force:data:bulk:delete # bulk delete records from a csv file
force:data:bulk:status # view the status of a bulk data load job or batch
force:data:bulk:upsert # bulk upsert records from a CSV file
force:data:record:create # create a record
force:data:record:delete # delete a record
force:data:record:get # view a record
force:data:record:update # update a record
force:data:soql:query # execute a SOQL query
force:data:tree:export # export data from an org into sObject tree format for force:data:tree:import consumption
force:data:tree:import # import data into an org using SObject Tree Save API
force:lightning:app:create # create a Lightning app
force:lightning:component:create # create a bundle for an Aura component or a Lightning web component
force:lightning:event:create # create a Lightning event
force:lightning:interface:create # create a Lightning interface
force:lightning:lint # analyze (lint) Aura component code
force:lightning:lwc:test:create # creates a Lightning web component test file with boilerplate code inside a __tests__ directory.
force:lightning:lwc:test:run # invokes Lightning Web Components Jest unit tests.
force:lightning:lwc:test:setup # install Jest unit testing tools for Lightning Web Components.
force:lightning:test:create # create a Lightning test
force:lightning:test:install # (deprecated) install Lightning Testing Service unmanaged package in your org
force:lightning:test:run # (deprecated) invoke Aura component tests
force:limits:api:display # display current org’s limits
force:mdapi:convert # convert metadata from the Metadata API format into the source format
force:mdapi:deploy # deploy metadata to an org using Metadata API
force:mdapi:deploy:cancel # cancel a metadata deployment
force:mdapi:deploy:report # check the status of a metadata deployment
force:mdapi:describemetadata # display the metadata types enabled for your org
force:mdapi:listmetadata # display properties of metadata components of a specified type
force:mdapi:retrieve # retrieve metadata from an org using Metadata API
force:mdapi:retrieve:report # check the status of a metadata retrieval
force:org:clone # clone a sandbox org
force:org:create # create a scratch or sandbox org
force:org:delete # mark a scratch or sandbox org for deletion
force:org:display # get org description
force:org:list # list all orgs you’ve created or authenticated to
force:org:open # open an org in your browser
force:org:shape:create # Create a scratch org configuration (shape) based on the specified source org
force:org:shape:delete # delete all org shapes for a target org
force:org:shape:list # list all org shapes you’ve created
force:org:snapshot:create # snapshot a scratch org
force:org:snapshot:delete # delete a scratch org snapshot
force:org:snapshot:get # get details about a scratch org snapshot
force:org:snapshot:list # list scratch org snapshots
force:org:status # report sandbox org creation status and authenticate to org
force:package1:version:create # create a first-generation package version in the release org
force:package1:version:create:get # retrieve the status of a package version creation request
force:package1:version:display # display details about a first-generation package version
force:package1:version:list # list package versions for the specified first-generation package or for the org
force:package:create # create a package
force:package:hammertest:list # list the statuses of running and completed ISV Hammer tests
force:package:hammertest:report # display the status or results of a ISV Hammer test
force:package:hammertest:run # run ISV Hammer
force:package:install # install a package in the target org
force:package:install:report # retrieve the status of a package installation request
force:package:installed:list # list the org’s installed packages
force:package:list # list all packages in the Dev Hub org
force:package:uninstall # uninstall a second-generation package from the target org
force:package:uninstall:report # retrieve status of package uninstall request
force:package:update # update package details
force:package:version:create # create a package version
force:package:version:create:list # list package version creation requests
force:package:version:create:report # retrieve details about a package version creation request
force:package:version:list # list all package versions in the Dev Hub org
force:package:version:promote # promote a package version to released
force:package:version:report # retrieve details about a package version in the Dev Hub org
force:package:version:update # update a package version
force:project:create # create a Salesforce DX project
force:project:upgrade # update project config files to the latest format
force:schema:sobject:describe # describe an object
force:schema:sobject:list # list all objects of a specified category
force:source:convert # convert source into Metadata API format
force:source:delete # delete source from your project and from a non-source-tracked org
force:source:deploy # deploy source to an org
force:source:deploy:cancel # cancel a source deployment
force:source:deploy:report # check the status of a metadata deployment
force:source:open # edit a Lightning Page with Lightning App Builder
force:source:pull # pull source from the scratch org to the project
force:source:push # push source to a scratch org from the project
force:source:retrieve # retrieve source from an org
force:source:status # list local changes and/or changes in a scratch org
force:source:tracking:clear # clear local tracking information
force:source:tracking:reset # reset local and remote tracking
force:user:create # create a user for a scratch org
force:user:display # displays information about a user of a scratch org
force:user:list # lists all users of a scratch org
force:user:password:generate # generate a password for scratch org users
force:user:permset:assign # assign a permission set to one or more users of an org
force:visualforce:component:create # create a Visualforce component
force:visualforce:page:create # create a Visualforce page
たくさんの命令の例は以下の通りです。
sfdx commands
それから、また追加する予定なので、何か問題がございましたら、
コメントありがとうございます。
以上となります。
ご参考になれば幸いです。
Latest posts by zchao (see all)
- Auraでアクションボタン作成して画面のチェックボックス項目一括処理 - 2021年4月12日
- デフォルト項目値を含むレコード作成実例説明(defaultFieldValues) - 2021年1月9日
- Salesforce のノーコード・ローコード開発 - 2020年12月31日
转载请注明:zchao博客之家 » LWC勉強ー単純にSFDX CLI命令で実行Scratch/Sandbox/本番環境(006)