Skip to content

Instantly share code, notes, and snippets.

View vyuvalv's full-sized avatar
🏠
Working from home

Yuval Vardi vyuvalv

🏠
Working from home
View GitHub Profile
@vyuvalv
vyuvalv / Hello World SFDX Generator
Last active November 3, 2019 10:46
Sample of `Hello world` Generator main file js
const Generator = require('yeoman-generator'); // this
const yosay = require('yosay'); // yeoman ascii image
const chalk = require('chalk'); // color text
const shell = require('shelljs'); // shell commands
module.exports = class extends Generator {
initializing() {
// Use this.log instead of console.log
this.log( yosay( chalk.red("Hello World") ) );
@vyuvalv
vyuvalv / yeoman prompting
Created October 28, 2019 15:27
Prompting questions on yeoman
async prompting() {
const menuQuestions = await this.prompt([ {
type: 'checkbox',
name: 'mainMenu',
message: 'What would you like to do?',
choices: [
{
name: ’option1',
value: ’option1',
checked: true
@vyuvalv
vyuvalv / Yo Scaffold Scratch org Template
Last active November 3, 2019 10:45
Writing Files using Yeoman Template
// this.props holds the answers values
writing() {
// Setting Features Selected
let features = this.props.orgFeatures.join("\",\"");
// Copy and populate scratch org defitnition file from a template
this.fs.copyTpl(
this.templatePath('config/scratch-org-def.json'),
this.destinationPath( this.props.projectName + '/config/scratch-org-def.json'),
@vyuvalv
vyuvalv / Scratch org definition template ES6
Last active November 3, 2019 10:46
ES6 Definition Template for yeoman
{
"country": "<%= orgLocal %>",
"language": "<%= orgLanguage %>",
"orgName": "<%= orgName %>",
"edition": "<%= orgEdition %>",
"adminEmail": "<%= adminEmail %>",
"hasSampleData": <%= hasSampleData %>,
"features": ["<%- orgFeatures %>"],
"settings": {
@vyuvalv
vyuvalv / Yeoman ComposeWith
Created October 28, 2019 15:57
Compose a workflow with multiple generators
# Main App
// will pass input parameters to the sub generator
this.composeWith(require.resolve('../org-commands/org-create'),{
devhubName : DevHub,
orgName : OrgName
});
# Sub Generator
module.exports = class extends Generator {
@vyuvalv
vyuvalv / Bash Script with SFDX Commands
Last active November 3, 2019 10:41
Bash script file example with SFDX commands
alias dxcreate='sfdx force:org:create -d 30 -f config/project-scratch-def.json --setdefaultusername -a '
alias dxpush='sfdx force:source:push -u '
alias dxpull='sfdx force:source:pull -u '
alias dxlist='sfdx force:org:list'
alias dxdelete='sfdx force:org:delete -u '
alias dxopen='sfdx force:org:open -u '
alias dxconnect='sfdx force:auth:web:login -a '
alias dxconnectSB='sfdx force:auth:web:login -r https://test.salesforce.com -a '
@vyuvalv
vyuvalv / initializing with Spinner And Default Orgs
Last active November 5, 2019 20:34
Will Initialize the generator with spinner, pull defaults and yosay image success
const Generator = require('yeoman-generator'); // this
const yosay = require('yosay'); // Yeoman Image
const chalk = require('chalk'); // color text
const shell = require('shelljs'); // shell commands
const spinner = require('ora'); // spinner
module.exports = class extends Generator {
initializing() {
@vyuvalv
vyuvalv / Prompt with Dynamic Questions
Last active November 5, 2019 20:21
Prompt Questions with Validate and Conditional Render questions
prompting() {
// asking questions
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');
@vyuvalv
vyuvalv / SFDX Command with Yo Input parameters
Created November 3, 2019 10:53
Build and Run SFDX Commands with Yo parameters
// command builder
let sfdxCommand = ' sfdx force:org:create';
sfdxCommand += ' -d ' + this.props.numberOfDays; // --durationdays
sfdxCommand += ' -a ' + this.props.scratchOrgName; // --setalias
// will receieve this.options as input parameters from constructor
sfdxCommand += ' -f ' + this.options.projectFolder + '/config/scratch-org-def.json'; // --definitionfile
sfdxCommand += ' -v ' + this.options.devhubOrg; // -v | --targetdevhubusername
// will only assign as default if user wish to
@vyuvalv
vyuvalv / designToXml
Created December 8, 2019 12:16
Aura => LWC Design Attributes Migration
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>47.0</apiVersion>
<isExposed>true</isExposed>
<masterLabel> The Name of the component in builder </masterLabel>
<description> *** Some Description *** </description>
<targets> // ALL Interaces
<target>lightning__RecordPage</target>
<target>lightning__AppPage</target>
<target>lightning__HomePage</target>