LOCAL YEOMAN GENERATOR
generator-dx >> yo dx
- Salesforce DX Generator
- This is a base Yeoman generator that can give some ideas of how to leverage yeoman with sfdx commands.
- Yeoman Workflow will create an SFDX Project and allow to add some other configurations and org options like Create,Connect,Delete.
- Simply Typeyo dx
and yeoman will walk you through creating your SFDX project with style.
- Additional support to create readme.md and ignore files.
Few simple steps, install Yeoman (we assume you have pre-installed node.js and sfdx cli ).
- Install SFDX
npm install sfdx-cli --global
- Install Yo
npm install -g yo
-
Clone this repository
-
Rename the git folder to
generator-dx
and step inside it / or make sure you change the name attribute inpackage.json
mv source target // will rename the folder
cd generator-dx // step inside
code . // open vs code in current folder ( make sure you installed code in PATH to use this)
- Link required npm modules
npm link
Then call your new workflow generator with:
yo dx
Feel Free to build your own Generator using the generator for generators
npm install -g yo generator-generator
- In case your Devhub is not connect will show alert and you will need to connect a DevHub
yo dx
- will show the main menuyo dx:project
- will create a SFDX project in current folderyo dx:org
- will configure features and create a new scratch orgyo dx:manage
- will allow to Open, Delete, Connect and Configure Default Settingsyo dx:connect
- will allow to connect to DevHub, Production or Sandbox
✔ Pulled defaults successfully
_-----_ ╭──────────────────────────╮
| | │ Welcome to DX │
|--(o)--| │ Connected Orgs : 2 │
`---------´ │ Active Scratch Orgs : 1 │
( _´U`_ ) │ │
/___A___\ /│ Default DevHub : DevHub │
| ~ | │ Default Scratch : DEV │
__'.___.'__ ╰──────────────────────────╯
´ ` |° ´ Y `
? What would you like to do ? (Press
<space>
to select,<a>
to toggle all,<i>
to invert selection)
-˯-˯-˯-˯-˯-˯-˯
❯ ◯ New Project
◯ New Scratch Org
◯ Manage DX
◯ Open Project Folder
-^-^-^-^-^-^-^
◯ Exit
New Project - Create SFDX Project
? Project Name ? (ROOT) /
? App Folder Name ? (force-app)
? Namespace (optional)
? Include Manifest file (y/N)
? Include ReadMe file (y/N)
? Description (optional) Press<enter>
to launch your preferred editor.
- vim Instruction :
- Type
a
to start typing- type
esc
key and then:wq
to exit
🙈 configuring sfdx project options for : MyProject
Run 🏄🏻 : sfdx force:project:create -n `<ProjectName>` -p `<AppFolder>` -t standard
✔ Created project successfully
create MyProject/config/scratch-org-def.json
create MyProject/.forceignore
create MyProject/.gitignore
Your project is ready! - Launch VS Code
New Scratch Org
? Your Scratch Org name
? Admin Email (myemail@gmail.com)
? Add Sample Data (y/N)
? Number of days (30)
? Org Description
? Set as default org (Y/n)
? Choose Edition: (Use arrow keys)
❯ Developer
Enterprise
Group
Professional
? Choose Country: (Use arrow keys)
❯ United States
Israel
France
Australia
? Choose Language: (Use arrow keys)
❯ English
Hebrew
French
? Which features would you like to enable? (Press
<space>
to select,<a>
to toggle all,<i>
to invert selection)
❯ ◉ Communities
◉ PersonAccounts
◯ AuthorApex
◯ MultiCurrency
◯ ServiceCloud
◯ ContactsToMultipleAccounts
✔ created successfully scratch-org-def.json
create sfdx_logs/scratch-org-def.json
⠋ creating scratch org with alias `<OrgAlias>`
HINT : Select Both New Project + New Scratch Org to Automate the process ...
Manage DX - Org Commands
? Select Option : (Use arrow keys)
❯ Open Org
Delete Scratch Org
Connect Org
Configure Defaults
:::: Open Org / Delete Org ::::
? Select Existing Scratch org : (Use arrow keys)
- Dynamic Org list
:::: Configure Defaults ::::
? Change Defaults for : (Use arrow keys)
❯ DevHub
Scratch Org
- Dynamic Devhub and Scratch Org list
sfdx force:project:create
sfdx force:auth:web:login
sfdx force:org:create
sfdx force:user:password:generate
sfdx force:user:display
sfdx force:org:open
sfdx force:config:set
sfdx force:org:delete
- Yeoman has a heart of gold.
- Yeoman is a person with feelings and opinions, but is very easy to work with.
- Yeoman can be too opinionated at times but is easily convinced not to be.
- Feel free to learn more about Yeoman.
yosay - Tell Yo to Say Hello
details: - description: yosay will tell yo what to say using yeoman ASCII image sample: this.log( yosay( 'Hello World' );
chalk.js - Give some colour
details: - description: Will allow to add colours to the input/output sample: this.log( chalk.redBright.underline('Hello World') );
shelljs - Unix shell commands on top of the Node.js API
details: - description: Will allow to run shell commands examples: // get the output of the command silently - shell.exec(' sfdx force:org:list --json', { silent: true } ).stdout; // get list of directories in folder - const folders = shell.ls('-L',this.destinationPath() );- <a href="https://devhints.io/shelljs" target="_blank"> shelljs </a> - cheat sheet
ora - Elegant terminal spinner
details: - description: Will allow to show a spinner for running process require : - const spinner = require('ora'); sample: // Start loading spinner this.loading = new spinner( { spinner:'dots', color : 'yellow' } ).start('Start Spinning...'); // Success - this.loading.succeed('Successfully loaded'); // Failure - this.loading.fail('Failed to load');
Inquirer.js - Dynamic questions and validation of prompt questions
details: - description: Will allow to add logic to questions sample: const questions = [{ type: 'checkbox', name: 'mainMenu', message: 'What would you like to do ?', validate: function(choices) { return choices.length > 0 ? true : chalk.redBright('Must Select at least one option'); }, choices: [ { type: 'separator', line:'-˯-˯-˯-˯-˯-˯-˯' }, { name: 'New Project', value: 'create-project' , checked: false }, { name: 'New Scratch Org', value: 'create-org', checked: false }, { type: 'separator', line: '-^-^-^-^-^-^-^' } ] }, { type: "input", name: "inputName", message: "Please give a name to your project : "), default:'Yuval', when: function(answers) { return answers.mainMenu.includes("create-project"); }, validate: function(value) { return value ? true : 'Please enter a name'; } } ];
mem-fs-editor - helpers working on top of mem-fs
details: - description: Will allow to access file system sample: // read file as Json object - this.fs.readJSON('filePath'); // check if file path exists - this.fs.exists('filePath'); // delete file - this.fs.delete('filePath');