-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: programmatic netlify.toml support & copying (#11)
- Loading branch information
1 parent
e553e85
commit f9ab430
Showing
15 changed files
with
204 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[context.production] | ||
environment = { FOO = "bar" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
foobar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
barfoo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module.exports = { | ||
rootDir: __dirname, | ||
buildModules: [ | ||
{ handler: require('../../../') } | ||
], | ||
netlifyFiles: { | ||
netlifyToml: () => { | ||
return { | ||
build: { | ||
environment: { | ||
BAR: 'baz' | ||
} | ||
} | ||
|
||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
foobar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
barfoo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module.exports = { | ||
rootDir: __dirname, | ||
buildModules: [ | ||
{ handler: require('../../../') } | ||
], | ||
netlifyFiles: { | ||
netlifyToml: { | ||
build: { | ||
environment: { | ||
BAR: 'baz' | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const { join, resolve } = require('path') | ||
const { existsSync, readFileSync } = require('fs') | ||
const { generate, loadConfig } = require('@nuxtjs/module-test-utils') | ||
|
||
describe('programmatically-func', () => { | ||
let nuxt | ||
|
||
beforeAll(async () => { | ||
({ nuxt } = await generate(loadConfig(__dirname, 'programmatically-func'))) | ||
}, 90000) | ||
|
||
afterAll(async () => { | ||
await nuxt.close() | ||
}) | ||
|
||
test('it has all files in generate folder', () => { | ||
const distBasePath = resolve(nuxt.options.rootDir, nuxt.options.generate.dir) | ||
const headersPath = join(distBasePath, '_headers') | ||
const redirectsPath = join(distBasePath, '_redirects') | ||
const tomlPath = join(distBasePath, 'netlify.toml') | ||
|
||
expect(existsSync(headersPath)).toBe(true) | ||
expect(existsSync(redirectsPath)).toBe(true) | ||
expect(existsSync(tomlPath)).toBe(true) | ||
}) | ||
test('it created netlify.toml correctly', () => { | ||
const distBasePath = resolve(nuxt.options.rootDir, nuxt.options.generate.dir) | ||
const tomlPath = join(distBasePath, 'netlify.toml') | ||
const data = readFileSync(tomlPath, 'utf8') | ||
const dataArr = data.split(/\n/).map(str => str.trim()).filter(str => str) | ||
expect(dataArr).toEqual(['[build.environment]', 'BAR = "baz"']) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const { join, resolve } = require('path') | ||
const { existsSync, readFileSync } = require('fs') | ||
const { generate, loadConfig } = require('@nuxtjs/module-test-utils') | ||
|
||
describe('programmatically', () => { | ||
let nuxt | ||
|
||
beforeAll(async () => { | ||
({ nuxt } = await generate(loadConfig(__dirname, 'programmatically'))) | ||
}, 90000) | ||
|
||
afterAll(async () => { | ||
await nuxt.close() | ||
}) | ||
|
||
test('it has all files in generate folder', () => { | ||
const distBasePath = resolve(nuxt.options.rootDir, nuxt.options.generate.dir) | ||
const headersPath = join(distBasePath, '_headers') | ||
const redirectsPath = join(distBasePath, '_redirects') | ||
const tomlPath = join(distBasePath, 'netlify.toml') | ||
|
||
expect(existsSync(headersPath)).toBe(true) | ||
expect(existsSync(redirectsPath)).toBe(true) | ||
expect(existsSync(tomlPath)).toBe(true) | ||
}) | ||
test('it created netlify.toml correctly', () => { | ||
const distBasePath = resolve(nuxt.options.rootDir, nuxt.options.generate.dir) | ||
const tomlPath = join(distBasePath, 'netlify.toml') | ||
const data = readFileSync(tomlPath, 'utf8') | ||
const dataArr = data.split(/\n/).map(str => str.trim()).filter(str => str) | ||
expect(dataArr).toEqual(['[build.environment]', 'BAR = "baz"']) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters