Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { task, desc, option, fs } from 'foy'
task('build', async ctx => {
// Your build tasks
await ctx.exec('tsc')
await fs.rmrf('lib/test')
})
task('test', async ctx => {
await ctx.exec(`mocha --timeout 100000 -r ts-node/register -r tsconfig-paths/register ./src/test/**/*.test.ts`)
})
task('build:dist', async (ctx) => {
await ctx.exec(`webpack -p --progress --profile`)
})
const MochaCli = `mocha --exit -r tsconfig-paths/register -r ts-node/register`
task('test:e2e', async ctx => {
await ctx.exec(`ts-node ./src/test/e2e/prepare.ts && ${MochaCli} \"src/test/**/*.test.ts\"`)
})
task('test:watch', async (ctx) => {
await ctx.exec(`${MochaCli} -w --watch-extensions ts,tsx`)
})
task('doc', async ctx => {
await ctx.exec([
`typedoc --theme default --mode file --exclude \"**/test/**/*.ts\" --excludeNotExported --excludePrivate --out ./docs/api ./src`
])
})
task('flow', async ctx => {
await ctx.exec(`flow check`)
})
setOption({ loading: false })
task<{ version: string }>(
'preversion', [
// { name: 'flow', async: true },
{ name: 'test', async: true },
{ name: 'build:all', async: true },
],
import { task, desc, option, fs } from 'foy'
task('build', async ctx => {
// Your build tasks
await ctx.exec('tsc')
await fs.rmrf('lib/test')
})
task('test', async ctx => {
await ctx.exec(`mocha --timeout 100000 -r ts-node/register -r tsconfig-paths/register ./src/test/**/*.test.ts`)
})
task('build', async ctx => {
// Your build tasks
await ctx.exec('tsc')
await fs.rmrf('lib/test')
})
],
)
option('-t, --type ', 'Semver versions, patch | major | minor')
task<{ type: 'patch' | 'major' | 'minor' }>('publish', async ctx => {
await ctx.run('preversion', { options: { version: ctx.options.type } })
await ctx.exec(`npm version ${ctx.options.type}`)
await fs.rmrf('./lib/test')
await fs.rmrf('./es/test')
await Promise.all([
ctx.exec(`git push origin master --tags`),
ctx.exec(`npm --registry https://registry.npmjs.org/ publish`),
])
})
task('test', async ctx => {
await ctx.exec(`${MochaCli} \"src/test/unit/*.test.ts\"`)
})
task('test:all', ['test'.async(), 'test:e2e'.async(), 'flow'.async()])
await ctx.fs.rmrf('./lib')
await ctx.exec(`tsc -d`)
let cwd = process.cwd()
await ctx.fs.iter(`./src`, async (file, stat) => {
if (file.endsWith('.js.flow')) {
await ctx.fs.copy(
file,
pathLib
.relative(cwd, file)
.replace('src', 'lib'),
)
}
})
})
task('build:es', async ctx => {
await ctx.fs.rmrf(`es`)
await ctx.exec(`tsc -d -m es6 --outDir ./es`)
})
task('build:dist', async (ctx) => {
await ctx.exec(`webpack -p --progress --profile`)
})
const MochaCli = `mocha --exit -r tsconfig-paths/register -r ts-node/register`
task('test:e2e', async ctx => {
await ctx.exec(`ts-node ./src/test/e2e/prepare.ts && ${MochaCli} \"src/test/**/*.test.ts\"`)
})
task('test:watch', async (ctx) => {
await ctx.exec(`${MochaCli} -w --watch-extensions ts,tsx`)
task('build:es', async ctx => {
await ctx.fs.rmrf(`es`)
await ctx.exec(`tsc -d -m es6 --outDir ./es`)
})
task('build:dist', async (ctx) => {
await ctx.exec(`webpack -p --progress --profile`)
})
const MochaCli = `mocha --exit -r tsconfig-paths/register -r ts-node/register`
task('test:e2e', async ctx => {
await ctx.exec(`ts-node ./src/test/e2e/prepare.ts && ${MochaCli} \"src/test/**/*.test.ts\"`)
})
task('test:watch', async (ctx) => {
await ctx.exec(`${MochaCli} -w --watch-extensions ts,tsx`)
})
task('doc', async ctx => {
await ctx.exec([
`typedoc --theme default --mode file --exclude \"**/test/**/*.ts\" --excludeNotExported --excludePrivate --out ./docs/api ./src`
])
})
task('flow', async ctx => {
await ctx.exec(`flow check`)
})
setOption({ loading: false })
task<{ version: string }>(
'preversion', [
const { task, fs, setGlobalOptions } = require('foy')
const glob = require('glob')
if (process.env.NETLIFY_BUILD_BASE) setGlobalOptions({ loading: false })
task('collect', async ctx => {
const sidebar = {}
const sidebarCfg = []
const componentReadmes = glob.sync('../packages/@(core|app)/src/components/*/readme.md')
componentReadmes.forEach(async path => {
const scope = path.match(/\/packages\/([a-z]+)\//)[1]
const name = path.match(/\/([a-z\-]+)\/readme.md/)[1]
if (!Array.isArray(sidebar[scope])) sidebar[scope] = []
sidebar[scope].push(name)
await fs.copy(path, `components/${scope}/${name}.md`)
})
Object.keys(sidebar).forEach(scope => {
const uppercase = str => str.charAt(0).toUpperCase() + str.slice(1)
const children = []
await ctx.fs.copy(
file,
pathLib
.relative(cwd, file)
.replace('src', 'lib'),
)
}
})
})
task('build:es', async ctx => {
await ctx.fs.rmrf(`es`)
await ctx.exec(`tsc -d -m es6 --outDir ./es`)
})
task('build:dist', async (ctx) => {
await ctx.exec(`webpack -p --progress --profile`)
})
const MochaCli = `mocha --exit -r tsconfig-paths/register -r ts-node/register`
task('test:e2e', async ctx => {
await ctx.exec(`ts-node ./src/test/e2e/prepare.ts && ${MochaCli} \"src/test/**/*.test.ts\"`)
})
task('test:watch', async (ctx) => {
await ctx.exec(`${MochaCli} -w --watch-extensions ts,tsx`)
})
task('doc', async ctx => {
await ctx.exec([
`typedoc --theme default --mode file --exclude \"**/test/**/*.ts\" --excludeNotExported --excludePrivate --out ./docs/api ./src`
import { task, fs, option, setOption, setGlobalOptions } from 'foy'
import * as pathLib from 'path'
setGlobalOptions({ loading: false, strict: true })
task('build', async ctx => {
await ctx.fs.rmrf('./lib')
await ctx.exec(`tsc -d`)
let cwd = process.cwd()
await ctx.fs.iter(`./src`, async (file, stat) => {
if (file.endsWith('.js.flow')) {
await ctx.fs.copy(
file,
pathLib
.relative(cwd, file)
.replace('src', 'lib'),
)
}
})
})
task('build:es', async ctx => {