add basic integration tests
This commit is contained in:
parent
f67003ccfc
commit
7ddd168b3a
8 changed files with 3093 additions and 75 deletions
|
@ -1,27 +1,5 @@
|
||||||
{
|
{
|
||||||
"parser": "babel-eslint",
|
|
||||||
"extends": [
|
"extends": [
|
||||||
"standard",
|
"standard"
|
||||||
"standard-react"
|
]
|
||||||
],
|
|
||||||
"env": {
|
|
||||||
"es6": true
|
|
||||||
},
|
|
||||||
"plugins": [
|
|
||||||
"react"
|
|
||||||
],
|
|
||||||
"parserOptions": {
|
|
||||||
"sourceType": "module",
|
|
||||||
"allowImportExportEverywhere": true
|
|
||||||
},
|
|
||||||
"rules": {
|
|
||||||
// don't force es6 functions to include space before paren
|
|
||||||
"space-before-function-paren": 0,
|
|
||||||
|
|
||||||
// allow specifying true explicitly for boolean props
|
|
||||||
"react/jsx-boolean-value": 0,
|
|
||||||
|
|
||||||
// allow imports mixed with non-import statements at top of file
|
|
||||||
"import/first": 0
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,3 +18,7 @@ dist
|
||||||
npm-debug.log*
|
npm-debug.log*
|
||||||
yarn-debug.log*
|
yarn-debug.log*
|
||||||
yarn-error.log*
|
yarn-error.log*
|
||||||
|
|
||||||
|
# temp directories created during testing
|
||||||
|
my-test-library
|
||||||
|
nala
|
||||||
|
|
10
packages/create-freesewing-pattern/.travis.yml
Normal file
10
packages/create-freesewing-pattern/.travis.yml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
language: node_js
|
||||||
|
node_js:
|
||||||
|
- 9
|
||||||
|
- 8
|
||||||
|
- 6
|
||||||
|
- 4
|
||||||
|
cache:
|
||||||
|
yarn: true
|
||||||
|
directories:
|
||||||
|
- node_modules
|
|
@ -13,10 +13,15 @@ const pkg = require('../package')
|
||||||
|
|
||||||
module.exports = async (info) => {
|
module.exports = async (info) => {
|
||||||
const {
|
const {
|
||||||
dest,
|
manager,
|
||||||
manager
|
name
|
||||||
} = info
|
} = info
|
||||||
|
|
||||||
|
// handle scoped package names
|
||||||
|
const parts = name.split('/')
|
||||||
|
info.shortName = parts[parts.length - 1]
|
||||||
|
|
||||||
|
const dest = path.join(process.cwd(), info.shortName)
|
||||||
await mkdirp(dest)
|
await mkdirp(dest)
|
||||||
|
|
||||||
const source = path.join(__dirname, '../template')
|
const source = path.join(__dirname, '../template')
|
||||||
|
@ -48,6 +53,8 @@ module.exports = async (info) => {
|
||||||
ora.promise(promise, 'Initializing git repo')
|
ora.promise(promise, 'Initializing git repo')
|
||||||
await promise
|
await promise
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return dest
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.copyTemplateFile = async (opts) => {
|
module.exports.copyTemplateFile = async (opts) => {
|
||||||
|
@ -62,7 +69,10 @@ module.exports.copyTemplateFile = async (opts) => {
|
||||||
const destFilePath = path.join(dest, fileRelativePath)
|
const destFilePath = path.join(dest, fileRelativePath)
|
||||||
const destFileDir = path.parse(destFilePath).dir
|
const destFileDir = path.parse(destFilePath).dir
|
||||||
|
|
||||||
const content = await consolidate.handlebars(file, info)
|
const content = await consolidate.handlebars(file, {
|
||||||
|
...info,
|
||||||
|
yarn: (info.manager === 'yarn')
|
||||||
|
})
|
||||||
|
|
||||||
await mkdirp(destFileDir)
|
await mkdirp(destFileDir)
|
||||||
fs.writeFileSync(destFilePath, content, 'utf8')
|
fs.writeFileSync(destFilePath, content, 'utf8')
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
const { test } = require('ava')
|
||||||
|
const execa = require('execa')
|
||||||
|
const rmfr = require('rmfr')
|
||||||
|
|
||||||
|
const createLibrary = require('./create-library')
|
||||||
|
|
||||||
|
const tests = [
|
||||||
|
{
|
||||||
|
name: 'my-test-library',
|
||||||
|
author: 'nala',
|
||||||
|
description: 'this is a auto-generated test module. please ignore.',
|
||||||
|
repo: 'nala/my-test-library',
|
||||||
|
license: 'MIT',
|
||||||
|
manager: 'yarn'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'my-test-library',
|
||||||
|
author: 'nala',
|
||||||
|
description: 'this is a auto-generated test module. please ignore.',
|
||||||
|
repo: 'nala/my-test-library',
|
||||||
|
license: 'MIT',
|
||||||
|
manager: 'npm'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '@automagical/nala',
|
||||||
|
author: 'superstar-cats',
|
||||||
|
description: 'this is a auto-generated test module. please ignore.',
|
||||||
|
repo: 'superstar-cats/nala',
|
||||||
|
license: 'GPL',
|
||||||
|
manager: 'yarn'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
tests.forEach((info) => {
|
||||||
|
test.serial(`creating "${info.name}" using ${info.manager}`, async (t) => {
|
||||||
|
console.log(`creating "${info.name}" using ${info.manager}...`)
|
||||||
|
// ensure library is created successfully
|
||||||
|
const root = await createLibrary(info)
|
||||||
|
t.truthy(root.indexOf(info.shortName) >= 0)
|
||||||
|
|
||||||
|
// ensure yarn runs successfully
|
||||||
|
let ret = await execa.shell('yarn', { cwd: root })
|
||||||
|
t.is(ret.code, 0)
|
||||||
|
|
||||||
|
// ensure jest tests pass
|
||||||
|
ret = await execa.shell('yarn test', { cwd: root })
|
||||||
|
t.is(ret.code, 0)
|
||||||
|
|
||||||
|
// ensure git is initialized properly
|
||||||
|
ret = await execa.shell('git status', { cwd: root })
|
||||||
|
t.is(ret.code, 0)
|
||||||
|
|
||||||
|
await rmfr(root)
|
||||||
|
})
|
||||||
|
})
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
const inquirer = require('inquirer')
|
const inquirer = require('inquirer')
|
||||||
const isValidNpmName = require('is-valid-npm-name')
|
const isValidNpmName = require('is-valid-npm-name')
|
||||||
const path = require('path')
|
|
||||||
|
|
||||||
module.exports = async (defaults) => {
|
module.exports = async (defaults) => {
|
||||||
const info = await inquirer.prompt([
|
const info = await inquirer.prompt([
|
||||||
|
@ -47,12 +46,5 @@ module.exports = async (defaults) => {
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
|
||||||
// handle scoped package names
|
|
||||||
const parts = info.name.split('/')
|
|
||||||
info.shortName = parts[parts.length - 1]
|
|
||||||
|
|
||||||
info.yarn = (info.manager === 'yarn')
|
|
||||||
info.dest = path.join(process.cwd(), info.shortName)
|
|
||||||
|
|
||||||
return info
|
return info
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,9 @@
|
||||||
"bin": {
|
"bin": {
|
||||||
"create-react-library": "index.js"
|
"create-react-library": "index.js"
|
||||||
},
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "ava -v && standard *.js lib/*.js"
|
||||||
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"react",
|
"react",
|
||||||
"preact",
|
"preact",
|
||||||
|
@ -37,5 +40,10 @@
|
||||||
"p-each-series": "^1.0.0",
|
"p-each-series": "^1.0.0",
|
||||||
"parse-git-config": "^2.0.0",
|
"parse-git-config": "^2.0.0",
|
||||||
"which": "^1.3.0"
|
"which": "^1.3.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"ava": "^0.25.0",
|
||||||
|
"rmfr": "^2.0.0",
|
||||||
|
"standard": "^11.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue