Swap-Aggregator-Subgraph/node_modules/gluegun/build/cli/templates/test/kitchen-sink-command.js.ejs
Richa-iitr d211083153 Revert "Revert "added handler""
This reverts commit c36ee8c5ca.
2022-07-03 07:30:05 +05:30

99 lines
3.0 KiB
Plaintext

// from gluegun
const {
filesystem,
semver,
http,
print,
prompt,
strings,
system,
patching
} = require('gluegun')
// from gluegun/*
const { filesystem: filesystemDirect } = require('gluegun/filesystem')
const { semver: semverDirect } = require('gluegun/semver')
const { http: httpDirect } = require('gluegun/http')
const { print: printDirect } = require('gluegun/print')
const { prompt: promptDirect } = require('gluegun/prompt')
const { strings: stringsDirect } = require('gluegun/strings')
const { system: systemDirect } = require('gluegun/system')
const { patching: patchingDirect } = require('gluegun/patching')
module.exports = {
name: 'kitchen',
run: async (toolbox) => {
// smoke test all the things
const asyncs = []
// filesystem smoke test
asyncs.push(filesystem.cwd())
asyncs.push(filesystem.exists(__filename))
asyncs.push(filesystemDirect.cwd())
// semver smoke test
semver.valid('1.2.3') // '1.2.3'
semver.clean(' =v1.2.3 ') // '1.2.3'
semver.satisfies('1.2.3', '1.x || >=2.5.0 || 5.0.0 - 7.2.3') // true
semver.lt('1.2.3', '9.8.7') // true
semverDirect.valid('1.2.3') // '1.2.3'
// http smoke test
const api = http.create({
baseURL: 'https://api.github.com',
headers: { Accept: 'application/vnd.github.v3+json' },
})
asyncs.push(api.get('/repos/skellock/apisauce/commits'))
const apiDirect = httpDirect.create({
baseURL: 'https://api.github.com',
headers: { Accept: 'application/vnd.github.v3+json' },
})
asyncs.push(apiDirect.get('/repos/skellock/apisauce/commits'))
// print smoke test
print.info(print.colors.success(<%- include helloMessage %>))
print.spin('Time for fun!').stop()
print.printHelp(toolbox)
print.table(
[
['First Name', 'Last Name', 'Age'],
['Jamon', 'Holmgren', 35],
['Gant', 'Laborde', 36],
['Steve', 'Kellock', 43],
['Gary', 'Busey', 73],
],
{ format: 'markdown' },
)
printDirect.info(print.colors.success('Hello. I am a chatty plugin.'))
// prompt smoke test (not very thorough, just ensuring it's there)
if (!prompt.ask) throw new Error('no ask?')
if (!prompt.confirm) throw new Error('no confirm?')
if (!prompt.separator) throw new Error('no separator?')
if (!promptDirect.ask) throw new Error('no ask?')
// strings smoke test
strings.identity('hello')
strings.padEnd('hello', 10, '!')
strings.kebabCase('hello there')
strings.upperFirst('hello there')
strings.isSingular('bugs')
strings.addUncountableRule('paper')
stringsDirect.addUncountableRule('paper')
// system smoke test
system.which('npm')
systemDirect.which('npm')
asyncs.push(system.run('node -v', { trim: true }))
// patching smoke test
asyncs.push(patching.exists(__filename, 'Barb'))
asyncs.push(patching.replace(__filename, 'SELF REPLACING STRING', 'REPLACED STRING WHOA'))
asyncs.push(patchingDirect.exists(__filename, 'Barb'))
// run all the asyncs at once yolo
await Promise.all(asyncs)
}
}