1 | # salesforcedx-templates
|
2 |
|
3 | This repository provides a series of commands, templates, and generators for various metadata types. It is bundled with the [salesforcedx plugin](https://www.npmjs.com/package/salesforcedx).
|
4 |
|
5 | [![CircleCI](https://circleci.com/gh/forcedotcom/salesforcedx-templates/tree/master.svg?style=shield)](https://circleci.com/gh/forcedotcom/salesforcedx-templates/tree/master)
|
6 | [![Codecov](https://codecov.io/gh/forcedotcom/salesforcedx-templates/branch/master/graph/badge.svg)](https://codecov.io/gh/forcedotcom/salesforcedx-templates)
|
7 | [![Known Vulnerabilities](https://snyk.io/test/github/forcedotcom/salesforcedx-templates/badge.svg)](https://snyk.io/test/github/forcedotcom/salesforcedx-templates)
|
8 | [![License](https://img.shields.io/npm/l/salesforcedx-templates.svg)](https://github.com/forcedotcom/salesforcedx-templates/blob/master/package.json)
|
9 |
|
10 |
|
11 | ## Getting Started
|
12 |
|
13 | To use, install the [Salesforce CLI](https://developer.salesforce.com/tools/sfdxcli) and run the following commands.
|
14 |
|
15 | ```
|
16 | Verify the CLI is installed
|
17 | $ sfdx (-v | --version)
|
18 | Install the salesforcedx plugin
|
19 | $ sfdx plugins:install salesforcedx
|
20 | To run a command
|
21 | $ sfdx [command]
|
22 | ```
|
23 |
|
24 | To build the plugin locally, make sure to have yarn installed and run the following commands:
|
25 |
|
26 | ```
|
27 | Clone the repository
|
28 | $ git clone git@github.com:forcedotcom/salesforcedx-templates.git
|
29 | Install the dependencies and compile
|
30 | $ yarn install
|
31 | $ yarn prepack
|
32 | Link your plugin to the sfdx cli
|
33 | $ sfdx plugins:link .
|
34 | To verify
|
35 | $ sfdx plugins
|
36 | salesforcedx-templates 0.0.0 (link) /Users/a.jha/Documents/repos/salesforcedx-templates
|
37 | ```
|
38 |
|
39 | ## Commands
|
40 |
|
41 | - [`sfdx force:apex:class:create`](https://github.com/forcedotcom/salesforcedx-templates/blob/master/COMMANDS.md#sfdx-forceapexclasscreate)
|
42 | - [`sfdx force:apex:trigger:create`](https://github.com/forcedotcom/salesforcedx-templates/blob/master/COMMANDS.md#sfdx-forceapextriggercreate)
|
43 | - [`sfdx force:lightning:app:create`](https://github.com/forcedotcom/salesforcedx-templates/blob/master/COMMANDS.md#sfdx-forcelightningappcreate)
|
44 | - [`sfdx force:lightning:component:create`](https://github.com/forcedotcom/salesforcedx-templates/blob/master/COMMANDS.md#sfdx-forcelightningcomponentcreate)
|
45 | - [`sfdx force:lightning:event:create`](https://github.com/forcedotcom/salesforcedx-templates/blob/master/COMMANDS.md#sfdx-forcelightningeventcreate)
|
46 | - [`sfdx force:lightning:interface:create`](https://github.com/forcedotcom/salesforcedx-templates/blob/master/COMMANDS.md#sfdx-forcelightninginterfacecreate)
|
47 | - [`sfdx force:lightning:test:create`](https://github.com/forcedotcom/salesforcedx-templates/blob/master/COMMANDS.md#sfdx-forcelightningtestcreate)
|
48 | - [`sfdx force:project:create`](https://github.com/forcedotcom/salesforcedx-templates/blob/master/COMMANDS.md#sfdx-forceprojectcreate)
|
49 | - [`sfdx force:visualforce:component:create`](https://github.com/forcedotcom/salesforcedx-templates/blob/master/COMMANDS.md#sfdx-forcevisualforcecomponentcreate)
|
50 | - [`sfdx force:visualforce:page:create`](https://github.com/forcedotcom/salesforcedx-templates/blob/master/COMMANDS.md#sfdx-forcevisualforcepagecreate)
|
51 |
|
52 |
|
53 | ## Debugging your plugin
|
54 |
|
55 | We recommend using the Visual Studio Code (VS Code) IDE for your plugin development. Included in the `.vscode` directory of this plugin is a `launch.json` config file, which allows you to attach a debugger to the node process when running your commands.
|
56 |
|
57 | To debug the `hello:org` command:
|
58 |
|
59 | If you linked your plugin to the sfdx cli, call your command with the `dev-suspend` switch:
|
60 |
|
61 | ```sh-session
|
62 | $ sfdx hello:org -u myOrg@example.com --dev-suspend
|
63 | ```
|
64 |
|
65 | Alternatively, to call your command using the `bin/run` script, set the `NODE_OPTIONS` environment variable to `--inspect-brk` when starting the debugger:
|
66 |
|
67 | ```sh-session
|
68 | $ NODE_OPTIONS=--inspect-brk bin/run hello:org -u myOrg@example.com
|
69 | ```
|
70 |
|
71 | 2. Set some breakpoints in your command code
|
72 | 3. Click on the Debug icon in the Activity Bar on the side of VS Code to open up the Debug view.
|
73 | 4. In the upper left hand corner of VS Code, verify that the "Attach to Remote" launch configuration has been chosen.
|
74 | 5. Hit the green play button to the left of the "Attach to Remote" launch configuration window. The debugger should now be suspended on the first line of the program.
|
75 | 6. Hit the green play button at the top middle of VS Code (this play button will be to the right of the play button that you clicked in step #5).
|
76 | <br><img src=".images/vscodeScreenshot.png" width="480" height="278"><br>
|
77 | Congrats, you are debugging!
|