-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.js
19 lines (17 loc) · 1011 Bytes
/
cli.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env node
const tap = require('tap')
const { readFileSync, existsSync } = require('fs')
const checkName = require('npm-name')
const semver = require('semver')
const isReachable = require('is-reachable')
const pckgjson = JSON.parse(readFileSync('package.json').toString())
const registryURL = 'https://registry.npmjs.org/'
// console.log(JSON.stringify())
const { names, keyWords, devDeps, scripts } = require('./requirements.json')
tap.equal(names.map(name => existsSync(name)).every(bool => bool === true), true)
tap.equal(keyWords.every(r => Object.keys(pckgjson).includes(r)), true)
tap.equal(scripts.every(r => Object.keys(pckgjson.scripts).includes(r)), true)
tap.equal(devDeps.every(r => Object.keys(pckgjson.devDependencies).includes(r)), true)
tap.equal(semver.valid(pckgjson.version), pckgjson.version)
tap.test('Is registry reachable', async t => t.equal(await isReachable(registryURL), true))
tap.test('Package Name Validation ', async t => t.equal(await checkName(pckgjson.name), true))