test: fix typings to make ts-node happy

This commit is contained in:
Zoltan Kochan
2018-04-17 22:53:48 +03:00
parent 2fa09b9db6
commit 9c9d79cbbe
16 changed files with 55 additions and 28 deletions

View File

@@ -87,6 +87,7 @@
"@pnpm/default-resolver": "^0.1.5",
"@pnpm/logger": "^1.0.0",
"@pnpm/store-path": "^1.0.0",
"@types/is-windows": "^0.2.0",
"@types/mkdirp": "^0.5.1",
"@types/sinon": "^4.1.2",
"@types/tape": "^4.2.30",

View File

@@ -52,6 +52,7 @@ dependencies:
resolve-link-target: 1.0.1
rimraf-then: 1.0.1
semver: 5.5.0
supi: 'link:../__package_previews__/supi/supi'
symlink-dir: 1.1.2
util.promisify: 1.0.0
validate-npm-package-name: 3.0.0
@@ -66,6 +67,7 @@ devDependencies:
'@pnpm/default-resolver': 0.1.5
'@pnpm/logger': 1.0.1
'@pnpm/store-path': 1.0.3
'@types/is-windows': 0.2.0
'@types/mkdirp': 0.5.2
'@types/sinon': 4.3.1
'@types/tape': 4.2.32
@@ -678,6 +680,10 @@ packages:
dev: true
resolution:
integrity: sha512-epDhsJAVxJsWfeqpzEDFhLnhHMbHie/VMFY+2Hvt5p7FemeW5ELM+6gcVYL/ZsUwdu3zrWpDE3VUTddXW+EMYg==
/@types/is-windows/0.2.0:
dev: true
resolution:
integrity: sha1-byTuSHMdMRaOpRBhDW3RXl/Jxv8=
/@types/js-yaml/3.11.1:
dev: false
resolution:
@@ -5490,6 +5496,7 @@ specifiers:
'@pnpm/types': ^1.7.0
'@types/byline': ^4.2.31
'@types/common-tags': ^1.2.5
'@types/is-windows': ^0.2.0
'@types/load-json-file': ^2.0.5
'@types/mkdirp': ^0.5.1
'@types/mz': ^0.0.32

View File

View File

@@ -17,7 +17,8 @@ test('API', (t) => {
// maybe a new property should be introduced
// this seems illogical as even though all save types are false,
// the dependency will be saved
test.skip('install fails when all saving types are false', async (t: test.Test) => {
// tslint:disable-next-line:no-string-literal
test['skip']('install fails when all saving types are false', async (t: test.Test) => {
try {
await pnpm.install(await testDefaults({save: false, saveDev: false, saveOptional: false}))
t.fail('installation should have failed')

View File

@@ -12,7 +12,7 @@ import {
} from '../utils'
const test = promisifyTape(tape)
test.only = promisifyTape(tape.only)
test['only'] = promisifyTape(tape.only) // tslint:disable-line:no-string-literal
test('installing aliased dependency', async (t: tape.Test) => {
const project = prepare(t)

View File

@@ -25,7 +25,7 @@ test('a package that need authentication', async (t: tape.Test) => {
username: 'foo',
},
}, (err: Error, d: object) => err ? reject(err) : resolve(d))
})
}) as {token: string}
let rawNpmConfig = {
'//localhost:4873/:_authToken': data.token,
@@ -104,7 +104,7 @@ test('a scoped package that need authentication specific to scope', async (t: ta
username: 'foo',
},
}, (err: Error, d: object) => err ? reject(err) : resolve(d))
})
}) as {token: string}
const rawNpmConfig = {
'//localhost:4873/:_authToken': data.token,
@@ -150,7 +150,7 @@ test('a package that need authentication reuses authorization tokens for tarball
username: 'foo',
},
}, (err: Error, d: object) => err ? reject(err) : resolve(d))
})
}) as {token: string}
const rawNpmConfig = {
'//127.0.0.1:4873/:_authToken': data.token,
@@ -184,7 +184,7 @@ test('a package that need authentication reuses authorization tokens for tarball
username: 'foo',
},
}, (err: Error, d: object) => err ? reject(err) : resolve(d))
})
}) as {token: string}
const rawNpmConfig = {
'//127.0.0.1:4873/:_authToken': data.token,

View File

@@ -1,4 +1,4 @@
import {addDistTag} from 'pnpm-registry-mock'
import pnpmRegistryMock = require('pnpm-registry-mock')
import {install, installPkgs} from 'supi'
import tape = require('tape')
import promisifyTape from 'tape-promise'
@@ -8,6 +8,7 @@ import {
} from '../utils'
const test = promisifyTape(tape)
const addDistTag = pnpmRegistryMock.addDistTag
test('prefer version ranges specified for top dependencies', async (t: tape.Test) => {
const project = prepare(t, {

View File

@@ -141,7 +141,8 @@ test('installation fails if lifecycle script fails', async (t: tape.Test) => {
// TODO: unskip
// For some reason this fails on CI environments
test.skip('creates env for scripts', async (t: tape.Test) => {
// tslint:disable-next-line:no-string-literal
test['skip']('creates env for scripts', async (t: tape.Test) => {
const project = prepare(t, {
scripts: {
install: `node -e "process.stdout.write(process.env.INIT_CWD)" | json-append output.json`,

View File

@@ -416,7 +416,8 @@ test("don't refetch package to store if it has been modified and verify-store-in
})
// TODO: decide what to do with this case
test.skip('relink package to project if the dependency is not linked from store', async (t: tape.Test) => {
// tslint:disable-next-line:no-string-literal
test['skip']('relink package to project if the dependency is not linked from store', async (t: tape.Test) => {
const project = prepare(t)
await installPkgs(['magic-hook@2.0.0'], await testDefaults({save: true, saveExact: true}))

View File

@@ -164,7 +164,8 @@ test('peer dependencies are linked when running two separate named installations
t.equal(deepRequireCwd(['abc-grand-parent-with-c', 'abc-parent-with-ab', 'abc', 'peer-c', './package.json']).version, '1.0.0')
})
test.skip('peer dependencies are linked', async (t: tape.Test) => {
// tslint:disable-next-line:no-string-literal
test['skip']('peer dependencies are linked', async (t: tape.Test) => {
const project = prepare(t, {
dependencies: {
'abc-grand-parent-with-c': '*',

View File

@@ -126,7 +126,8 @@ test('flatten by alias', async (t: tape.Test) => {
await project.hasNot('dep-of-pkg-with-1-dep')
const modules = await project.loadModules()
t.deepEqual(modules.hoistedAliases, {'localhost+4873/dep-of-pkg-with-1-dep/100.1.0': [ 'dep' ]}, '.modules.yaml updated correctly')
t.ok(modules)
t.deepEqual(modules!.hoistedAliases, {'localhost+4873/dep-of-pkg-with-1-dep/100.1.0': [ 'dep' ]}, '.modules.yaml updated correctly')
})
test('should remove aliased flattened dependencies', async (t) => {
@@ -146,7 +147,8 @@ test('should remove aliased flattened dependencies', async (t) => {
t.ok(caught, 'dep removed correctly')
const modules = await project.loadModules()
t.deepEqual(modules.hoistedAliases, {}, '.modules.yaml updated correctly')
t.ok(modules)
t.deepEqual(modules!.hoistedAliases, {}, '.modules.yaml updated correctly')
})
test('should update .modules.yaml when pruning if we are flattening', async (t) => {
@@ -163,7 +165,8 @@ test('should update .modules.yaml when pruning if we are flattening', async (t)
await prune(await testDefaults({shamefullyFlatten: true}))
const modules = await project.loadModules()
t.deepEqual(modules.hoistedAliases, {}, '.modules.yaml updated correctly')
t.ok(modules)
t.deepEqual(modules!.hoistedAliases, {}, '.modules.yaml updated correctly')
})
test('should reflatten after pruning', async (t) => {

View File

@@ -12,7 +12,7 @@ import {
} from '../utils'
const test = promisifyTape(tape)
test.only = promisifyTape(tape.only)
test['only'] = promisifyTape(tape.only) // tslint:disable-line:no-string-literal
test('caching side effects of native package', async (t) => {
const project = prepare(t)

View File

@@ -18,7 +18,7 @@ test('rebuilds dependencies', async (t: tape.Test) => {
await installPkgs(['pre-and-postinstall-scripts-example', 'zkochan/install-scripts-example'], await testDefaults({saveDev: true, ignoreScripts: true}))
let modules = await project.loadModules()
t.deepEqual(modules.pendingBuilds, [
t.deepEqual(modules!.pendingBuilds, [
'/pre-and-postinstall-scripts-example/1.0.0',
'github.com/zkochan/install-scripts-example/26950260310939009680b6a377a0efd0925df9ba',
])
@@ -26,7 +26,8 @@ test('rebuilds dependencies', async (t: tape.Test) => {
await rebuild(await testDefaults())
modules = await project.loadModules()
t.equal(modules.pendingBuilds.length, 0)
t.ok(modules)
t.equal(modules!.pendingBuilds.length, 0)
{
const generatedByPreinstall = project.requireModule('pre-and-postinstall-scripts-example/generated-by-preinstall')
@@ -67,7 +68,7 @@ test('rebuild with pending option', async (t: tape.Test) => {
await installPkgs(['zkochan/install-scripts-example'], await testDefaults({ignoreScripts: true}))
let modules = await project.loadModules()
t.deepEqual(modules.pendingBuilds, [
t.deepEqual(modules!.pendingBuilds, [
'/pre-and-postinstall-scripts-example/1.0.0',
'github.com/zkochan/install-scripts-example/26950260310939009680b6a377a0efd0925df9ba',
])
@@ -81,7 +82,8 @@ test('rebuild with pending option', async (t: tape.Test) => {
await rebuild(await testDefaults({rawNpmConfig: {pending: true}}))
modules = await project.loadModules()
t.equal(modules.pendingBuilds.length, 0)
t.ok(modules)
t.equal(modules!.pendingBuilds.length, 0)
{
const generatedByPreinstall = project.requireModule('pre-and-postinstall-scripts-example/generated-by-preinstall')
@@ -106,7 +108,8 @@ test('rebuild dependencies in correct order', async (t: tape.Test) => {
await installPkgs(['with-postinstall-a'], await testDefaults({ignoreScripts: true}))
let modules = await project.loadModules()
t.doesNotEqual(modules.pendingBuilds.length, 0)
t.ok(modules)
t.doesNotEqual(modules!.pendingBuilds.length, 0)
await project.hasNot('.localhost+4873/with-postinstall-b/1.0.0/node_modules/with-postinstall-b/output.json')
await project.hasNot('with-postinstall-a/output.json')
@@ -114,7 +117,8 @@ test('rebuild dependencies in correct order', async (t: tape.Test) => {
await rebuild(await testDefaults({rawNpmConfig: {pending: true}}))
modules = await project.loadModules()
t.equal(modules.pendingBuilds.length, 0)
t.ok(modules)
t.equal(modules!.pendingBuilds.length, 0)
t.ok(+project.requireModule('.localhost+4873/with-postinstall-b/1.0.0/node_modules/with-postinstall-b/output.json')[0] < +project.requireModule('with-postinstall-a/output.json')[0])
})

View File

@@ -23,8 +23,8 @@ import {
} from './utils'
const test = promisifyTape(tape)
test.only = promisifyTape(tape.only)
test.skip = promisifyTape(tape.skip)
test['only'] = promisifyTape(tape.only) // tslint:disable-line:no-string-literal
test['skip'] = promisifyTape(tape.skip) // tslint:disable-line:no-string-literal
const SHRINKWRAP_WARN_LOG = {
level: 'warn',
@@ -38,7 +38,8 @@ test('shrinkwrap file has correct format', async (t: tape.Test) => {
await installPkgs(['pkg-with-1-dep', '@rstacruz/tap-spec@4.1.1', 'kevva/is-negative#1d7e288222b53a0cab90a331f1865220ec29560c'], await testDefaults({save: true}))
const modules = await project.loadModules()
t.equal(modules.pendingBuilds.length, 0)
t.ok(modules)
t.equal(modules!.pendingBuilds.length, 0)
const shr = await project.loadShrinkwrap()
const id = '/pkg-with-1-dep/100.0.0'
@@ -531,7 +532,8 @@ test('repeat install with no inner shrinkwrap should not rewrite packages in nod
// Skipped because the npm-registry.compass.com server was down
// might be a good idea to mock it
test.skip('installing from shrinkwrap when using npm enterprise', async (t: tape.Test) => {
// tslint:disable-next-line:no-string-literal
test['skip']('installing from shrinkwrap when using npm enterprise', async (t: tape.Test) => {
const project = prepare(t)
const opts = await testDefaults({registry: 'https://npm-registry.compass.com/'})
@@ -710,7 +712,9 @@ test('pendingBuilds gets updated if install removes packages', async (t: tape.Te
await install(await testDefaults({ ignoreScripts: true }))
const modules2 = await project.loadModules()
t.ok(modules1.pendingBuilds.length > modules2.pendingBuilds.length, 'pendingBuilds gets updated when install removes packages')
t.ok(modules1)
t.ok(modules2)
t.ok(modules1!.pendingBuilds.length > modules2!.pendingBuilds.length, 'pendingBuilds gets updated when install removes packages')
})
test('dev properties are correctly updated on named install', async (t: tape.Test) => {

View File

@@ -84,7 +84,8 @@ test('keep dependencies used by others', async (t: tape.Test) => {
const shr = await project.loadShrinkwrap()
t.notOk(R.isEmpty(shr.packages))
R.toPairs(shr.packages).forEach((pair) => t.ok(pair[1].dev, `${pair[0]} is dev`))
// tslint:disable-next-line:no-string-literal
R.toPairs(shr.packages).forEach((pair) => t.ok(pair[1]['dev'], `${pair[0]} is dev`))
await storePrune(await testDefaults())

View File

@@ -166,10 +166,12 @@ test('pendingBuilds gets updated after uninstall', async (t: tape.Test) => {
await installPkgs(['pre-and-postinstall-scripts-example', 'with-postinstall-b'], await testDefaults({save: true, ignoreScripts: true}))
const modules1 = await project.loadModules()
t.equal(modules1.pendingBuilds.length, 2, 'installPkgs should update pendingBuilds')
t.ok(modules1)
t.equal(modules1!.pendingBuilds.length, 2, 'installPkgs should update pendingBuilds')
await uninstall(['with-postinstall-b'], await testDefaults({save: true}))
const modules2 = await project.loadModules()
t.equal(modules2.pendingBuilds.length, 1, 'uninstall should update pendingBuilds')
t.ok(modules2)
t.equal(modules2!.pendingBuilds.length, 1, 'uninstall should update pendingBuilds')
})