Skip to content

Commit

Permalink
Revert "Automatically add featureFlags.future flags to the configur…
Browse files Browse the repository at this point in the history
…ation files whenever the `init` command is ran (#2379)"

This reverts commit f72158c.
  • Loading branch information
adamwathan committed Oct 16, 2020
1 parent 638f3e9 commit 9065404
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 30 deletions.
19 changes: 5 additions & 14 deletions __tests__/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import cli from '../src/cli/main'
import * as constants from '../src/constants'
import * as utils from '../src/cli/utils'
import runInTempDirectory from '../jest/runInTempDirectory'
import featureFlags from '../src/featureFlags'

describe('cli', () => {
const inputCssPath = path.resolve(__dirname, 'fixtures/tailwind-input.css')
const customConfigPath = path.resolve(__dirname, 'fixtures/custom-config.js')
const defaultConfigFixture = utils.readFile(constants.defaultConfigStubFile)
const simpleConfigFixture = utils.readFile(constants.simpleConfigStubFile)
const defaultPostCssConfigFixture = utils.readFile(constants.defaultPostCssConfigStubFile)

beforeEach(() => {
Expand All @@ -20,15 +21,15 @@ describe('cli', () => {
it('creates a Tailwind config file', () => {
return runInTempDirectory(() => {
return cli(['init']).then(() => {
expect(utils.exists(constants.defaultConfigFile)).toEqual(true)
expect(utils.readFile(constants.defaultConfigFile)).toEqual(simpleConfigFixture)
})
})
})

it('creates a Tailwind config file and a postcss.config.js file', () => {
return runInTempDirectory(() => {
return cli(['init', '-p']).then(() => {
expect(utils.exists(constants.defaultConfigFile)).toEqual(true)
expect(utils.readFile(constants.defaultConfigFile)).toEqual(simpleConfigFixture)
expect(utils.readFile(constants.defaultPostCssConfigFile)).toEqual(
defaultPostCssConfigFixture
)
Expand All @@ -39,7 +40,7 @@ describe('cli', () => {
it('creates a full Tailwind config file', () => {
return runInTempDirectory(() => {
return cli(['init', '--full']).then(() => {
expect(utils.exists(constants.defaultConfigFile)).toEqual(true)
expect(utils.readFile(constants.defaultConfigFile)).toEqual(defaultConfigFixture)
})
})
})
Expand Down Expand Up @@ -93,15 +94,5 @@ describe('cli', () => {
expect(process.stdout.write.mock.calls[0][0]).not.toContain('-ms-input-placeholder')
})
})

it('creates a Tailwind config file with future flags', () => {
return runInTempDirectory(() => {
return cli(['init']).then(() => {
featureFlags.future.forEach(flag => {
expect(utils.readFile(constants.defaultConfigFile)).toContain(`${flag}: true`)
})
})
})
})
})
})
17 changes: 3 additions & 14 deletions src/cli/commands/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,15 @@ export function run(cliParams, cliOptions) {
return new Promise(resolve => {
utils.header()

const full = cliOptions.full
const file = cliParams[0] || constants.defaultConfigFile
const simplePath = utils.getSimplePath(file)

utils.exists(file) && utils.die(colors.file(simplePath), 'already exists.')

const stubFile = cliOptions.full
? constants.defaultConfigStubFile
: constants.simpleConfigStubFile
const stubFile = full ? constants.defaultConfigStubFile : constants.simpleConfigStubFile

const config = require(stubFile)
const { future: flags } = require('../../featureFlags').default

flags.forEach(flag => {
config.future[`// ${flag}`] = true
})

utils.writeFile(
file,
`module.exports = ${JSON.stringify(config, null, 2).replace(/"([^-_\d"]+)":/g, '$1:')}\n`
)
utils.copyFile(stubFile, file)

utils.log()
utils.log(emoji.yes, 'Created Tailwind config file:', colors.file(simplePath))
Expand Down
5 changes: 4 additions & 1 deletion stubs/defaultConfig.stub.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
module.exports = {
future: {},
future: {
// removeDeprecatedGapUtilities: true,
// purgeLayersByDefault: true,
},
purge: [],
prefix: '',
important: false,
Expand Down
5 changes: 4 additions & 1 deletion stubs/simpleConfig.stub.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
module.exports = {
future: {},
future: {
// removeDeprecatedGapUtilities: true,
// purgeLayersByDefault: true,
},
purge: [],
theme: {
extend: {},
Expand Down

0 comments on commit 9065404

Please sign in to comment.