-
-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
34592cc
commit b6eb5d5
Showing
11 changed files
with
116 additions
and
81 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
module.exports = { | ||
presets: [['@babel/preset-env']], | ||
ignore: ['src/templates'], | ||
}; |
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 |
---|---|---|
@@ -1,21 +1,19 @@ | ||
const gulp = require('gulp'); | ||
const del = require('del'); | ||
const execa = require('execa'); | ||
const gulp = require('gulp'); | ||
|
||
gulp.task('clean', () => del('lib/**', { force: true })); | ||
gulp.task('clean', () => del('lib/**')); | ||
|
||
gulp.task('copy server templates', () => | ||
gulp | ||
.src('./src/templates/server/**/*') | ||
.pipe(gulp.dest('./lib/templates/server')), | ||
); | ||
gulp.task('build', async () => { | ||
const { | ||
exitCode, | ||
} = await execa.command( | ||
'babel src --out-dir lib --copy-files --include-dotfiles', | ||
{ stdio: 'inherit' }, | ||
); | ||
console.log(`The process exited with code ${exitCode}`); | ||
}); | ||
|
||
gulp.task('copy starter templates', () => | ||
gulp | ||
.src('./src/templates/starter-templates/**/*') | ||
.pipe(gulp.dest('./lib/templates/starter-templates')), | ||
); | ||
gulp.task('cleanup', () => del('lib/**/__tests__')); | ||
|
||
gulp.task( | ||
'copy', | ||
gulp.series('copy server templates', 'copy starter templates'), | ||
); | ||
gulp.task('default', gulp.series('clean', 'build', 'cleanup')); |
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,72 @@ | ||
import { ENTER } from 'cli-prompts-test'; | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
|
||
import { copyDirSync, fetchProjectConfig, readFileContent } from '../helpers'; | ||
import { runPromptWithAnswers } from '../../../jest/helpers'; | ||
|
||
const srcPath = path.join(__dirname, 'test-dir'); | ||
const destPath = path.join(__dirname, 'dest-path'); | ||
const genPath = path.join(__dirname, 'my-app'); | ||
|
||
beforeAll(() => { | ||
if (!fs.existsSync(srcPath)) { | ||
fs.mkdirSync(srcPath); | ||
fs.writeFileSync(path.join(srcPath, 'index.js'), '// Test'); | ||
} | ||
if (!fs.existsSync(destPath)) { | ||
fs.mkdirSync(destPath); | ||
} | ||
}); | ||
|
||
afterAll(() => { | ||
// copyDirSync() | ||
fs.rmdirSync(srcPath, { recursive: true }); | ||
fs.rmdirSync(destPath, { recursive: true }); | ||
|
||
// fetchProjectConfig() | ||
fs.rmdirSync(genPath, { recursive: true }); | ||
}); | ||
|
||
test('copyDirSync()', () => { | ||
// Copy source directory to destination path | ||
copyDirSync(srcPath, destPath); | ||
|
||
// Assertions | ||
expect(fs.existsSync(path.join(destPath, 'test-dir'))).toBeTruthy(); | ||
expect( | ||
fs.existsSync(path.join(destPath, 'test-dir', 'index.js')), | ||
).toBeTruthy(); | ||
expect( | ||
fs.readFileSync(path.join(destPath, 'test-dir', 'index.js'), 'utf8'), | ||
).toBe('// Test'); | ||
}); | ||
|
||
test('fetchProjectConfig()', async () => { | ||
await runPromptWithAnswers( | ||
['init', 'my-app'], | ||
[ | ||
ENTER, // Choose Default as the starter template | ||
ENTER, // Requires server directory | ||
], | ||
__dirname, | ||
); | ||
|
||
const projectConfig = { | ||
name: 'my-app', | ||
template: 'Default', | ||
isConfigured: { | ||
client: false, | ||
server: false, | ||
}, | ||
}; | ||
expect(fetchProjectConfig(genPath)).toEqual(projectConfig); | ||
}); | ||
|
||
test('not passing in a path to fetchProjectConfig()', () => { | ||
expect(fetchProjectConfig()).toBe(undefined); | ||
}); | ||
|
||
test('not passing in a file path to readFileContent()', () => { | ||
expect(readFileContent()).toBe(undefined); | ||
}); |
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