Skip to content
This repository has been archived by the owner on Mar 10, 2021. It is now read-only.

Commit

Permalink
fix(commands): Update to Gluegun 2-style commands
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Updates to Gluegun 2-style commands which are only supported by Ignite CLI 3.0+
  • Loading branch information
ryanlntn committed May 10, 2019
2 parents 95453a5 + 601b510 commit 1c482c6
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 76 deletions.
51 changes: 25 additions & 26 deletions commands/map-callout.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
// @cliDescription Generates a map callout component.
// @cliExample ignite generate map-callout StoreCallout
// Generates a map callout component that can be inserted into any map.
// ----------------------------------------------------------------------------
module.exports = async function (context) {
const { parameters, strings, print, ignite } = context
const { pascalCase, isBlank } = strings
module.exports = {
description: 'Generates a map callout component.',
run: async function (context) {
const { parameters, strings, print, ignite } = context
const { pascalCase, isBlank } = strings

// validation
if (isBlank(parameters.first)) {
print.info(`ignite generate map-callout <name>\n`)
print.info('A name is required.')
return
}
// validation
if (isBlank(parameters.first)) {
print.info(`ignite generate map-callout <name>\n`)
print.info('A name is required.')
return
}

const name = pascalCase(parameters.first)
const name = pascalCase(parameters.first)

// Copies the callout template
// into App/Components/${name}.js.
const copyJobs = [{
template: 'map-callout-component.js.ejs',
target: `App/Components/${name}.js`
}, {
template: 'map-callout-styles.js.ejs',
target: `App/Components/Styles/${name}Styles.js`
}]
// Copies the callout template
// into App/Components/${name}.js.
const copyJobs = [{
template: 'map-callout-component.js.ejs',
target: `App/Components/${name}.js`
}, {
template: 'map-callout-styles.js.ejs',
target: `App/Components/Styles/${name}Styles.js`
}]

// make the templates and pass in props with the third argument here
await ignite.copyBatch(context, copyJobs, { calloutName: name })
}
// make the templates and pass in props with the third argument here
await ignite.copyBatch(context, copyJobs, { calloutName: name })
}
}
33 changes: 16 additions & 17 deletions commands/map-utilities.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
// @cliDescription Generates map utility functions.
// @cliExample ignite generate map-utilities
// Generates a map utilities file in App/Lib
// ----------------------------------------------------------------------------
module.exports = async function (context) {
const { ignite } = context
module.exports = {
description: 'Generates map utility functions.',
run: async function (context) {
const { ignite } = context

// TODO: Detect if Ramda is not installed and error
// or install for them?
// TODO: Detect if Ramda is not installed and error
// or install for them?

// Copies the `MapHelpers.js.ejs` in the templates folder
// into App/Lib/MapHelpers.js.
const copyJobs = [{
template: 'MapHelpers.js.ejs',
target: `App/Lib/MapHelpers.js`
}]
// Copies the `MapHelpers.js.ejs` in the templates folder
// into App/Lib/MapHelpers.js.
const copyJobs = [{
template: 'MapHelpers.js.ejs',
target: `App/Lib/MapHelpers.js`
}]

// make the templates and pass in props with the third argument here
await ignite.copyBatch(context, copyJobs, {})
}
// make the templates and pass in props with the third argument here
await ignite.copyBatch(context, copyJobs, {})
}
}
65 changes: 32 additions & 33 deletions commands/map.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,36 @@
// @cliDescription Generates a map component.
// @cliExample ignite generate map StoreLocator
// Generates a map component that can be inserted into any screen.
// ----------------------------------------------------------------------------
module.exports = async function (context) {
const { parameters, strings, print, ignite } = context
const { pascalCase, isBlank } = strings
module.exports = {
description: 'Generates a map component.',
run: async function (context) {
const { parameters, strings, print, ignite } = context
const { pascalCase, isBlank } = strings

// validation
if (isBlank(parameters.first)) {
print.info(`ignite generate map <name>\n`)
print.info('A name is required.')
return
}
// validation
if (isBlank(parameters.first)) {
print.info(`ignite generate map <name>\n`)
print.info('A name is required.')
return
}

const name = pascalCase(parameters.first)
const calloutName = `${name}Callout`
const name = pascalCase(parameters.first)
const calloutName = `${name}Callout`

// Copies the `map.js.ejs` in the templates folder
// into App/Components/${name}.js.
const copyJobs = [{
template: 'map-component.js.ejs',
target: `App/Components/${name}.js`
}, {
template: 'map-styles.js.ejs',
target: `App/Components/Styles/${name}Styles.js`
}, {
template: 'map-callout-component.js.ejs',
target: `App/Components/${calloutName}.js`
}, {
template: 'map-callout-styles.js.ejs',
target: `App/Components/Styles/${calloutName}Styles.js`
}]
// Copies the `map.js.ejs` in the templates folder
// into App/Components/${name}.js.
const copyJobs = [{
template: 'map-component.js.ejs',
target: `App/Components/${name}.js`
}, {
template: 'map-styles.js.ejs',
target: `App/Components/Styles/${name}Styles.js`
}, {
template: 'map-callout-component.js.ejs',
target: `App/Components/${calloutName}.js`
}, {
template: 'map-callout-styles.js.ejs',
target: `App/Components/Styles/${calloutName}Styles.js`
}]

// make the templates and pass in props with the third argument here
await ignite.copyBatch(context, copyJobs, { name: name, calloutName: calloutName })
}
// make the templates and pass in props with the third argument here
await ignite.copyBatch(context, copyJobs, { name: name, calloutName: calloutName })
}
}

0 comments on commit 1c482c6

Please sign in to comment.