Visual Studio Code の Salesforce 対応
Visual Studio Code は、優れた開発環境に必要な多くの機能を備えています。このステップでは、Salesforce CLI と Visual Studio Code 用 Salesforce 拡張機能をインストールし、Trailhead Playground を設定して、IDE の機能を拡張します。
Salesforce CLI を使用して、Salesforce アプリケーションのライフサイクル全体を制御できます。CLI では、開発およびテスト環境の作成や接続が簡単にでき、組織とバージョン管理システム間でメタデータとコードを同期できます。
- 次の適切なリンクを使用して、CLI をダウンロードします。
- インストーラを使用して、CLI をインストールします。
- CLI が正しくインストールされたことを確認します。macOS のターミナルアプリケーションまたは Windows のコマンドプロンプトを開き、
sfdx
と入力します。
オペレーティングシステム |
インストーラへのリンク |
macOS |
https://sfdc.co/sfdx_cli_osx |
Windows 32-bit |
https://sfdc.co/sfdx_cli_win |
Windows 64-bit |
https://sfdc.co/sfdx_cli_win64 |
Debian/Ubuntu 64 |
https://sfdc.co/sfdx_cli_linux マニフェストにあるいずれかの URL からアーカイブをダウンロードして抽出し、./install スクリプトを実行します。 |
Debian/Ubuntu x86 |
https://sfdc.co/sfdx_cli_linux_x86 マニフェストにあるいずれかの URL からアーカイブをダウンロードして抽出し、./install スクリプトを実行します。 |
次のように表示されます。
Salesforce CLI VERSION sfdx-cli/7.58.2 darwin-x64 node-v14.3.0 USAGE $ sfdx [COMMAND] COMMANDS autocmplt display autocomplete installation instructions autocomplete display autocomplete installation instructions commands list all the commands force tools for the Salesforce developer help display help for sfdx plugins add/remove/create CLI plug-ins update update the sfdx CLI which show which plugin a command is in TOPICS Run help for each topic below to view subcommands autocmplt display autocomplete installation instructions autocomplete display autocomplete installation instructions cmdt commands for custom metadata commands list all the commands dependency Sample command line utilities around the Salesforce Dependencies API implemented as SFDX plugin. force tools for the Salesforce developer plugins add/remove/create CLI plug-ins shane get an access token from an email and a .pem file, either passed in or from environment variables
Salesforce CLI をインストールできたので、Salesforce Extension Pack をインストールして、Visual Studio Code を強化できます。この Extension Pack では、必要な Salesforce 拡張機能すべてが一度にインストールされるため、1 つずつ選択する手間がかかりません。
この拡張機能によって、VS Code 全体で Salesforce ツールと深く統合されます。さまざまな場所 (VS Code のメニュー、ショートカット、右クリックコンテキストメニュー) から Salesforce CLI を呼び出すことができます。
作業時に次のような新機能が表示されます。
- Apex 用言語サービス
- Visualforce 用言語サービス
- Lightning コンポーネント (Aura コンポーネントと Lightning Web コンポーネント) 用言語サービス
- アクティビティバーの Apex テストおよび Replay Debugger 用のインテグレーション
- Visual Studio Code を起動します。
- 左のツールバーで、[Extensions (拡張機能)] をクリックします。
- 検索項目に
Salesforce Extension Pack
と入力します。 -
Salesforce Extension Pack
をクリックします。 -
[Install (インストール)] をクリックします。
- Visual Studio Code を閉じて再起動し、インストールを完了します。
- 新しい Trailhead Playground を作成するには、このステップの最後にあるドロップダウンをクリックして [Create a Trailhead Playground (Trailhead Playground を作成)] を選択します。
- Trailhead Playground を作成したら、[Launch (起動)] をクリックします。
-
[Setup (設定)] をクリックします。
- [Quick Find (クイック検索)] ボックスに
Users
(ユーザ) と入力し、[Users (ユーザ)] を選択します。 - ユーザのリストから自分の名前を見つけます。
- 自分の名前の隣にあるチェックボックスをオンにしますユーザ名をメモします。これが Trailhead Playground のユーザ名です。
-
[Reset Password(s) (パスワードのリセット)]、[OK] の順にクリックします。ユーザ名に関連付けられているメールアドレス宛に、パスワードのリセットメールが送信されます。メールが届かない場合はスパムフォルダを確認してください。
- メール内のリンクをクリックします。
- パスワードを設定します。
設定の確認は行いません。[Verify Step (ステップを確認)] をクリックして、プロジェクトの次のステップへ進んでください。