Skip to content

Commit

Permalink
add a wrapped version of copyBath to prettier transform the files
Browse files Browse the repository at this point in the history
also prettify entity patches and code not fixed by prettier
  • Loading branch information
ruddell committed Sep 10, 2019
1 parent da5aaf1 commit 17fbd6e
Show file tree
Hide file tree
Showing 9 changed files with 177 additions and 106 deletions.
3 changes: 2 additions & 1 deletion boilerplate/app/modules/entities/entities-screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import React from 'react'
import { ScrollView, Text } from 'react-native'
import { connect } from 'react-redux'
// Styles
/*eslint-disable no-unused-vars*/
/* eslint-disable no-unused-vars */
import RoundedButton from '../../shared/components/rounded-button/rounded-button'
import {
loginScreen,
// ignite-jhipster-entity-screen-import-needle
} from '../../navigation/layouts'
/* eslint-enable */
Expand Down
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"insight": "0.10.3",
"jhipster-core": "4.3.0",
"pluralize": "8.0.0",
"prettier": "1.18.2",
"ramda": "0.26.1",
"rimraf": "3.0.0",
"semver": "6.3.0"
Expand Down
9 changes: 4 additions & 5 deletions src/boilerplate/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ const semver = require('semver')
* The files portion of the entity generator
*/
module.exports = async function (context, props, jhipsterConfig) {
const { filesystem, ignite, print, strings } = context
const { filesystem, print, strings } = context
const { camelCase, upperFirst } = strings
const { copyBatch } = require('../lib/copy-batch')
const spinner = print.spin(`using the ${print.colors.blue('JHipster')} boilerplate`).succeed()
const { patchInFile } = require('../lib/patch-in-file')

Expand Down Expand Up @@ -169,7 +170,7 @@ module.exports = async function (context, props, jhipsterConfig) {
}
]

await ignite.copyBatch(context, templates, props, {
await copyBatch(context, templates, props, {
quiet: true,
directory: `${__dirname}/../../boilerplate`
})
Expand All @@ -184,7 +185,7 @@ module.exports = async function (context, props, jhipsterConfig) {
if (!isMonolith) {
oauth2Files.push({ template: 'OAuth2SsoConfiguration.java.ejs', target: `${jhipsterPathPrefix}${props.jhipsterDirectory}/src/main/java/${props.packageFolder}/config/OAuth2SsoConfiguration.java` })
}
await ignite.copyBatch(context, oauth2Files, props, {
await copyBatch(context, oauth2Files, props, {
quiet: true,
directory: `${__dirname}/../../templates/jhipster/oauth2`
})
Expand Down Expand Up @@ -213,7 +214,6 @@ module.exports = async function (context, props, jhipsterConfig) {
await patchInFile(context, 'android/app/build.gradle', {
before: 'applicationId',
insert: androidAuthRedirectContent,
match: androidAuthRedirectContent
})
} else {
// remove OAuth2 files if not enabled
Expand All @@ -230,7 +230,6 @@ module.exports = async function (context, props, jhipsterConfig) {
await patchInFile(context, 'app/shared/reducers/index.js', {
before: 'ignite-jhipster-redux-store-import-needle',
insert: ` chat: require('../../modules/chat/chat.reducer').reducer,`,
match: ` chat: require('../../modules/chat/chat.reducer').reducer,`
})

// TODO CHAT SCREEN
Expand Down
6 changes: 6 additions & 0 deletions src/boilerplate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,12 @@ async function install (context) {
await importEntityJdl.run(context)
}

// run prettier to pass lint on generation
spinner.text = `▸ running prettier on generated code`
spinner.start()
// install any missing dependencies
await system.run(`${useNpm ? 'npm' : 'yarn'} run prettier`, { stdio: 'ignore' })

const perfDuration = parseInt(((new Date()).getTime() - perfStart) / 10) / 100
spinner.succeed(`ignited ${print.colors.yellow(name)} in ${perfDuration}s`)

Expand Down
Loading

0 comments on commit 17fbd6e

Please sign in to comment.