mirror of
https://github.com/pnpm/pnpm.git
synced 2026-05-04 14:08:44 -04:00
feat: init
This commit is contained in:
11
.editorconfig
Normal file
11
.editorconfig
Normal file
@@ -0,0 +1,11 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
insert_final_newline = true
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
end_of_line = lf
|
||||
|
||||
[*.{ts,js,json}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
3
.gitattributes
vendored
Normal file
3
.gitattributes
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
* text eol=lf
|
||||
|
||||
*.tgz binary
|
||||
19
.gitignore
vendored
Normal file
19
.gitignore
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
|
||||
# Dependency directory
|
||||
node_modules
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
|
||||
fixtures
|
||||
.tmp
|
||||
_docpress
|
||||
|
||||
lib
|
||||
|
||||
# Visual Studio Code configs
|
||||
.vscode/
|
||||
13
.travis.yml
Normal file
13
.travis.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 4
|
||||
- 6
|
||||
- 8
|
||||
|
||||
sudo: false
|
||||
before_install:
|
||||
- npm install -g pnpm
|
||||
install:
|
||||
- pnpm install
|
||||
script:
|
||||
- npm test
|
||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 Zoltan Kochan
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
17
README.md
Normal file
17
README.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# pnpm-list
|
||||
|
||||
[](https://travis-ci.org/pnpm/pnpm-list "See test builds")
|
||||
|
||||
> List installed packages in a symlinked `node_modules`
|
||||
|
||||
## Install
|
||||
|
||||
Install it via npm.
|
||||
|
||||
```
|
||||
npm install pnpm-list
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
37
package.json
Normal file
37
package.json
Normal file
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "pnpm-list",
|
||||
"version": "0.0.0",
|
||||
"description": "List installed packages in a symlinked `node_modules`",
|
||||
"main": "lib/index.js",
|
||||
"typings": "lib/index.d.ts",
|
||||
"files": [
|
||||
"lib"
|
||||
],
|
||||
"scripts": {
|
||||
"prepare": "cd test && pnpm install",
|
||||
"test": "cd test && npm test",
|
||||
"prepublishOnly": "npm run tsc"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/pnpm/pnpm-list.git"
|
||||
},
|
||||
"keywords": [
|
||||
"pnpm",
|
||||
"list",
|
||||
"ls"
|
||||
],
|
||||
"author": "Zoltan Kochan",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/pnpm/pnpm-list/issues"
|
||||
},
|
||||
"homepage": "https://github.com/pnpm/pnpm-list#readme",
|
||||
"dependencies": {
|
||||
"@types/node": "^6.0.81",
|
||||
"pnpm-shrinkwrap": "^3.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^2.4.1"
|
||||
}
|
||||
}
|
||||
188
shrinkwrap.yaml
Normal file
188
shrinkwrap.yaml
Normal file
@@ -0,0 +1,188 @@
|
||||
dependencies:
|
||||
'@types/node': 6.0.81
|
||||
pnpm-shrinkwrap: 3.1.0
|
||||
devDependencies:
|
||||
typescript: 2.4.1
|
||||
packages:
|
||||
/@types/node/6.0.81:
|
||||
resolution:
|
||||
integrity: sha512-KdtXOH8l9O2wwOOX+swjbFx+YW/RJFfI14o6S50+Zy79FK1WFGkzFdDsiuNjrG5L6FaBSKpKzSpWgTvXurbbYg==
|
||||
/@types/node/7.0.34:
|
||||
resolution:
|
||||
integrity: sha512-99ujivDq9tqw3b88xrWqUcHfY3XT+moVhAlMqlN+OdavTxfCRW2X1bRBFcloILRJiIoir+gG3I65jzrpNgF/3g==
|
||||
/@types/ramda/0.0.11:
|
||||
resolution:
|
||||
integrity: sha512-RcraK0229RAIJERTfgoCY/eSbxFEkPlj/TbUUb6aGSS9UfLj1THpt2Uj4uuCJsQrYRQUQB8tFlv7eTTWzE4QjQ==
|
||||
/any-promise/1.3.0:
|
||||
resolution:
|
||||
integrity: sha1-q8av7tzqUugJzcA3au0845Y10X8=
|
||||
/argparse/1.0.9:
|
||||
dependencies:
|
||||
sprintf-js: 1.0.3
|
||||
resolution:
|
||||
integrity: sha1-c9g7wmP4bpf4zE9rrhsOkKfSLIY=
|
||||
/balanced-match/1.0.0:
|
||||
resolution:
|
||||
integrity: sha1-ibTRmasr7kneFk6gK4nORi1xt2c=
|
||||
/bole/3.0.2:
|
||||
dependencies:
|
||||
fast-safe-stringify: 1.1.13
|
||||
individual: 3.0.0
|
||||
resolution:
|
||||
integrity: sha1-vIpIPKlASdqbg3wa0Rzf6+5uBRQ=
|
||||
/brace-expansion/1.1.8:
|
||||
dependencies:
|
||||
balanced-match: 1.0.0
|
||||
concat-map: 0.0.1
|
||||
resolution:
|
||||
integrity: sha1-wHshHHyVLsH479Uad+8NHTmQopI=
|
||||
/concat-map/0.0.1:
|
||||
resolution:
|
||||
integrity: sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=
|
||||
/esprima/4.0.0:
|
||||
resolution:
|
||||
integrity: sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==
|
||||
/fast-safe-stringify/1.1.13:
|
||||
resolution:
|
||||
integrity: sha1-oB6c2cnkkXFcmKdaQtXwu9EH/3Y=
|
||||
/fs.realpath/1.0.0:
|
||||
resolution:
|
||||
integrity: sha1-FQStJSMVjKpA20onh8sBQRmU6k8=
|
||||
/glob/7.1.2:
|
||||
dependencies:
|
||||
fs.realpath: 1.0.0
|
||||
inflight: 1.0.6
|
||||
inherits: 2.0.3
|
||||
minimatch: 3.0.4
|
||||
once: 1.4.0
|
||||
path-is-absolute: 1.0.1
|
||||
resolution:
|
||||
integrity: sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==
|
||||
/graceful-fs/4.1.11:
|
||||
resolution:
|
||||
integrity: sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=
|
||||
/imurmurhash/0.1.4:
|
||||
resolution:
|
||||
integrity: sha1-khi5srkoojixPcT7a21XbyMUU+o=
|
||||
/individual/3.0.0:
|
||||
resolution:
|
||||
integrity: sha1-58pPhfiVewGHNPKFdQ3CLsL5hi0=
|
||||
/inflight/1.0.6:
|
||||
dependencies:
|
||||
once: 1.4.0
|
||||
wrappy: 1.0.2
|
||||
resolution:
|
||||
integrity: sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=
|
||||
/inherits/2.0.3:
|
||||
resolution:
|
||||
integrity: sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=
|
||||
/js-yaml/3.9.0:
|
||||
dependencies:
|
||||
argparse: 1.0.9
|
||||
esprima: 4.0.0
|
||||
resolution:
|
||||
integrity: sha512-0LoUNELX4S+iofCT8f4uEHIiRBR+c2AINyC8qRWfC6QNruLtxVZRJaPcu/xwMgFIgDxF25tGHaDjvxzJCNE9yw==
|
||||
/load-yaml-file/0.1.0:
|
||||
dependencies:
|
||||
graceful-fs: 4.1.11
|
||||
js-yaml: 3.9.0
|
||||
pify: 2.3.0
|
||||
strip-bom: 3.0.0
|
||||
resolution:
|
||||
integrity: sha1-9oAGbmkbPutFAXZy5KOVavW4O4k=
|
||||
/minimatch/3.0.4:
|
||||
dependencies:
|
||||
brace-expansion: 1.1.8
|
||||
resolution:
|
||||
integrity: sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==
|
||||
/minimist/0.0.8:
|
||||
resolution:
|
||||
integrity: sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=
|
||||
/mkdirp-promise/5.0.1:
|
||||
dependencies:
|
||||
mkdirp: 0.5.1
|
||||
resolution:
|
||||
integrity: sha1-6bj2jlUsaKnBcTuEiD96HdA5uKE=
|
||||
/mkdirp/0.5.1:
|
||||
dependencies:
|
||||
minimist: 0.0.8
|
||||
resolution:
|
||||
integrity: sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=
|
||||
/once/1.4.0:
|
||||
dependencies:
|
||||
wrappy: 1.0.2
|
||||
resolution:
|
||||
integrity: sha1-WDsap3WWHUsROsF9nFC6753Xa9E=
|
||||
/path-is-absolute/1.0.1:
|
||||
resolution:
|
||||
integrity: sha1-F0uSaHNVNP+8es5r9TpanhtcX18=
|
||||
/pify/2.3.0:
|
||||
resolution:
|
||||
integrity: sha1-7RQaasBDqEnqWISY59yosVMw6Qw=
|
||||
/pnpm-logger/0.3.0:
|
||||
dependencies:
|
||||
bole: 3.0.2
|
||||
resolution:
|
||||
integrity: sha1-6uzqWgN/BTpkxQvafto8uH9e1mE=
|
||||
/pnpm-shrinkwrap/3.1.0:
|
||||
dependencies:
|
||||
'@types/node': 7.0.34
|
||||
'@types/ramda': 0.0.11
|
||||
js-yaml: 3.9.0
|
||||
load-yaml-file: 0.1.0
|
||||
mkdirp-promise: 5.0.1
|
||||
pnpm-logger: 0.3.0
|
||||
ramda: 0.24.1
|
||||
rimraf-then: 1.0.1
|
||||
thenify: 3.3.0
|
||||
write-file-atomic: 2.1.0
|
||||
resolution:
|
||||
integrity: sha512-mFMdm0fCmh+kwxmGVD8Bl5QO4E7h/SCWdayKRtdzexHon0nN7YNkEz/llj1lHrb99pzQmE4NCI6BEvTYP/XeIg==
|
||||
/ramda/0.24.1:
|
||||
resolution:
|
||||
integrity: sha1-w7d1UZfzW43DUCIoJixMkd22uFc=
|
||||
/rimraf-then/1.0.1:
|
||||
dependencies:
|
||||
any-promise: 1.3.0
|
||||
rimraf: 2.6.1
|
||||
resolution:
|
||||
integrity: sha1-vURYp561YbdUiq7ArDdT70Kf5ws=
|
||||
/rimraf/2.6.1:
|
||||
dependencies:
|
||||
glob: 7.1.2
|
||||
resolution:
|
||||
integrity: sha1-wjOOxkPfeht/5cVPqG9XQopV8z0=
|
||||
/slide/1.1.6:
|
||||
resolution:
|
||||
integrity: sha1-VusCfWW00tzmyy4tMsTUr8nh1wc=
|
||||
/sprintf-js/1.0.3:
|
||||
resolution:
|
||||
integrity: sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=
|
||||
/strip-bom/3.0.0:
|
||||
resolution:
|
||||
integrity: sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=
|
||||
/thenify/3.3.0:
|
||||
dependencies:
|
||||
any-promise: 1.3.0
|
||||
resolution:
|
||||
integrity: sha1-5p44obq+lpsBCCB5eLn2K4hgSDk=
|
||||
/typescript/2.4.1:
|
||||
dev: true
|
||||
resolution:
|
||||
integrity: sha1-w8yxbdqgsjFN4DHn5v7onlujRrw=
|
||||
/wrappy/1.0.2:
|
||||
resolution:
|
||||
integrity: sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=
|
||||
/write-file-atomic/2.1.0:
|
||||
dependencies:
|
||||
graceful-fs: 4.1.11
|
||||
imurmurhash: 0.1.4
|
||||
slide: 1.1.6
|
||||
resolution:
|
||||
integrity: sha512-0TZ20a+xcIl4u0+Mj5xDH2yOWdmQiXlKf9Hm+TgDXjTMsEYb+gDrmb8e8UNAzMCitX8NBqG4Z/FUQIyzv/R1JQ==
|
||||
registry: 'https://registry.npmjs.org/'
|
||||
shrinkwrapVersion: 3
|
||||
specifiers:
|
||||
'@types/node': ^6.0.81
|
||||
pnpm-shrinkwrap: ^3.1.0
|
||||
typescript: ^2.4.1
|
||||
111
src/index.ts
Normal file
111
src/index.ts
Normal file
@@ -0,0 +1,111 @@
|
||||
import {
|
||||
readPrivate,
|
||||
Shrinkwrap,
|
||||
ResolvedPackages,
|
||||
getPkgShortId,
|
||||
} from 'pnpm-shrinkwrap'
|
||||
|
||||
async function list (
|
||||
projectPath: string,
|
||||
opts?: {
|
||||
depth: number,
|
||||
only?: 'dev' | 'prod',
|
||||
}
|
||||
) {
|
||||
const _opts = Object.assign({}, {
|
||||
depth: 0,
|
||||
only: undefined,
|
||||
}, opts)
|
||||
const shrinkwrap = await readPrivate(projectPath, {ignoreIncompatible: false})
|
||||
|
||||
if (!shrinkwrap) return {}
|
||||
|
||||
const topDeps = getTopDependencies(shrinkwrap, _opts)
|
||||
|
||||
if (!topDeps) return []
|
||||
|
||||
const getChildrenTree = getTree.bind(null, {
|
||||
currentDepth: 1,
|
||||
maxDepth: _opts.depth,
|
||||
prod: _opts.only === 'prod',
|
||||
}, shrinkwrap.packages)
|
||||
return Object.keys(topDeps).map(depName => {
|
||||
const shortId = getPkgShortId(topDeps[depName], depName)
|
||||
const pkg = {
|
||||
name: depName,
|
||||
version: topDeps[depName],
|
||||
}
|
||||
const dependencies = getChildrenTree(shortId)
|
||||
if (dependencies.length) {
|
||||
return {
|
||||
pkg,
|
||||
dependencies,
|
||||
}
|
||||
}
|
||||
return {pkg}
|
||||
})
|
||||
}
|
||||
|
||||
function getTopDependencies (
|
||||
shrinkwrap: Shrinkwrap,
|
||||
opts: {
|
||||
only?: 'dev' | 'prod',
|
||||
}
|
||||
) {
|
||||
switch (opts.only) {
|
||||
case 'prod':
|
||||
return shrinkwrap.dependencies
|
||||
case 'dev':
|
||||
return shrinkwrap.devDependencies
|
||||
default:
|
||||
return Object.assign({},
|
||||
shrinkwrap.dependencies,
|
||||
shrinkwrap.devDependencies,
|
||||
shrinkwrap.optionalDependencies
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function getTree (
|
||||
opts: {
|
||||
currentDepth: number,
|
||||
maxDepth: number,
|
||||
prod: boolean,
|
||||
},
|
||||
packages: ResolvedPackages,
|
||||
parentId: string
|
||||
) {
|
||||
if (opts.currentDepth > opts.maxDepth) return []
|
||||
|
||||
const deps = opts.prod
|
||||
? packages[parentId].dependencies
|
||||
: Object.assign({},
|
||||
packages[parentId].dependencies,
|
||||
packages[parentId].optionalDependencies
|
||||
)
|
||||
|
||||
if (!deps) return []
|
||||
|
||||
const getChildrenTree = getTree.bind(null, {
|
||||
currentDepth: opts.currentDepth + 1,
|
||||
maxDepth: opts.maxDepth,
|
||||
prod: opts.prod,
|
||||
}, packages)
|
||||
return Object.keys(deps).map(depName => {
|
||||
const shortId = getPkgShortId(deps[depName], depName)
|
||||
const pkg = {
|
||||
name: depName,
|
||||
version: deps[depName],
|
||||
}
|
||||
const dependencies = getChildrenTree(shortId)
|
||||
if (dependencies.depth) {
|
||||
return {
|
||||
pkg,
|
||||
dependencies,
|
||||
}
|
||||
}
|
||||
return {pkg}
|
||||
})
|
||||
}
|
||||
|
||||
export = list
|
||||
106
test/index.ts
Normal file
106
test/index.ts
Normal file
@@ -0,0 +1,106 @@
|
||||
import test = require('tape')
|
||||
import {installPkgs} from 'supi'
|
||||
import {prepare, testDefaults} from './utils'
|
||||
import getList = require('../src')
|
||||
|
||||
test('one package depth 0', async t => {
|
||||
prepare(t)
|
||||
|
||||
await installPkgs(['rimraf@2.5.1'], testDefaults())
|
||||
await installPkgs(['is-positive@1.0.0'], testDefaults({saveDev: true}))
|
||||
await installPkgs(['is-negative@1.0.0'], testDefaults({saveOptional: true}))
|
||||
|
||||
const list = await getList(process.cwd(), {depth: 0})
|
||||
|
||||
t.deepEqual(list, [
|
||||
{
|
||||
pkg: {
|
||||
name: 'rimraf',
|
||||
version: '2.5.1',
|
||||
}
|
||||
},
|
||||
{
|
||||
pkg: {
|
||||
name: 'is-positive',
|
||||
version: '1.0.0',
|
||||
}
|
||||
},
|
||||
{
|
||||
pkg: {
|
||||
name: 'is-negative',
|
||||
version: '1.0.0',
|
||||
}
|
||||
},
|
||||
])
|
||||
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('one package depth 1', async t => {
|
||||
prepare(t)
|
||||
|
||||
await installPkgs(['rimraf@2.5.1'], testDefaults())
|
||||
|
||||
const list = await getList(process.cwd(), {depth: 1})
|
||||
|
||||
t.deepEqual(list, [
|
||||
{
|
||||
pkg: {
|
||||
name: 'rimraf',
|
||||
version: '2.5.1',
|
||||
},
|
||||
dependencies: [
|
||||
{
|
||||
pkg: {
|
||||
name: 'glob',
|
||||
version: '6.0.4',
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
])
|
||||
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('only prod depth 0', async t => {
|
||||
prepare(t)
|
||||
|
||||
await installPkgs(['rimraf@2.5.1'], testDefaults())
|
||||
await installPkgs(['is-negative'], testDefaults({saveDev: true}))
|
||||
await installPkgs(['is-positive'], testDefaults({saveOptional: true}))
|
||||
|
||||
const list = await getList(process.cwd(), {depth: 0, only: 'prod'})
|
||||
|
||||
t.deepEqual(list, [
|
||||
{
|
||||
pkg: {
|
||||
name: 'rimraf',
|
||||
version: '2.5.1',
|
||||
},
|
||||
}
|
||||
])
|
||||
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('only dev depth 0', async t => {
|
||||
prepare(t)
|
||||
|
||||
await installPkgs(['rimraf@2.5.1'], testDefaults({saveDev: true}))
|
||||
await installPkgs(['is-negative'], testDefaults())
|
||||
await installPkgs(['is-positive'], testDefaults({saveOptional: true}))
|
||||
|
||||
const list = await getList(process.cwd(), {depth: 0, only: 'dev'})
|
||||
|
||||
t.deepEqual(list, [
|
||||
{
|
||||
pkg: {
|
||||
name: 'rimraf',
|
||||
version: '2.5.1',
|
||||
},
|
||||
}
|
||||
])
|
||||
|
||||
t.end()
|
||||
})
|
||||
22
test/package.json
Normal file
22
test/package.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"scripts": {
|
||||
"pnpm-registry-mock": "pnpm-registry-mock",
|
||||
"test:tap": "ts-node index.ts",
|
||||
"test:e2e": "npm-run-all -p -r pnpm-registry-mock test:tap",
|
||||
"pretest": "rimraf ../../.tmp/ && pnpm-registry-mock prepare",
|
||||
"test": "npm run test:e2e"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/mkdirp": "^0.3.29",
|
||||
"@types/tape": "^4.2.30",
|
||||
"mkdirp": "^0.5.1",
|
||||
"npm-run-all": "^4.0.2",
|
||||
"pnpm-logger": "^0.5.0",
|
||||
"pnpm-registry-mock": "^0.13.0",
|
||||
"rimraf": "^2.6.1",
|
||||
"supi": "^0.2.0",
|
||||
"tape": "^4.7.0",
|
||||
"ts-node": "^3.2.0",
|
||||
"write-pkg": "^3.1.0"
|
||||
}
|
||||
}
|
||||
2263
test/shrinkwrap.yaml
Normal file
2263
test/shrinkwrap.yaml
Normal file
File diff suppressed because it is too large
Load Diff
4
test/typings/index.d.ts
vendored
Normal file
4
test/typings/index.d.ts
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
declare module 'write-pkg' {
|
||||
const anything: any;
|
||||
export = anything;
|
||||
}
|
||||
7
test/utils/index.ts
Normal file
7
test/utils/index.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import prepare from './prepare'
|
||||
import testDefaults from './testDefaults'
|
||||
|
||||
export {
|
||||
prepare,
|
||||
testDefaults,
|
||||
}
|
||||
25
test/utils/prepare.ts
Normal file
25
test/utils/prepare.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import mkdirp = require('mkdirp')
|
||||
import fs = require('fs')
|
||||
import path = require('path')
|
||||
import {Test} from 'tape'
|
||||
import writePkg = require('write-pkg')
|
||||
|
||||
// the testing folder should be outside of the project to avoid lookup in the project's node_modules
|
||||
const tmpPath = path.join(__dirname, '..', '..', '..', '.tmp')
|
||||
mkdirp.sync(tmpPath)
|
||||
|
||||
let dirNumber = 0
|
||||
|
||||
export default function prepare (t: Test, pkg?: Object) {
|
||||
process.env.NPM_CONFIG_REGISTRY = 'http://localhost:4873/'
|
||||
process.env.NPM_CONFIG_STORE_PATH = '../.store'
|
||||
process.env.NPM_CONFIG_SILENT = 'true'
|
||||
|
||||
dirNumber++
|
||||
const dirname = dirNumber.toString()
|
||||
const pkgTmpPath = path.join(tmpPath, dirname, 'project')
|
||||
mkdirp.sync(pkgTmpPath)
|
||||
writePkg.sync(pkgTmpPath, Object.assign({name: 'project', version: '0.0.0'}, pkg))
|
||||
process.chdir(pkgTmpPath)
|
||||
t.pass(`create testing package ${dirname}`)
|
||||
}
|
||||
9
test/utils/testDefaults.ts
Normal file
9
test/utils/testDefaults.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import {PnpmOptions} from 'supi'
|
||||
import path = require('path')
|
||||
|
||||
export default function testDefaults (opts?: PnpmOptions): PnpmOptions & {store: string} {
|
||||
return Object.assign({
|
||||
store: path.resolve('..', '.store'),
|
||||
registry: 'http://localhost:4873/',
|
||||
}, opts)
|
||||
}
|
||||
67
tsconfig.json
Normal file
67
tsconfig.json
Normal file
@@ -0,0 +1,67 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"removeComments": false,
|
||||
"preserveConstEnums": true,
|
||||
"sourceMap": true,
|
||||
"declaration": true,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitReturns": true,
|
||||
"suppressImplicitAnyIndexErrors": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"strictNullChecks": true,
|
||||
"target": "es6",
|
||||
"outDir": "lib",
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node"
|
||||
},
|
||||
"filesGlob": [
|
||||
"src/**/*.ts",
|
||||
"typings/**/*.d.ts"
|
||||
],
|
||||
"atom": {
|
||||
"rewriteTsconfig": true
|
||||
},
|
||||
"files": [
|
||||
"src/api/checkCompatibility.ts",
|
||||
"src/api/extendOptions.ts",
|
||||
"src/api/getContext.ts",
|
||||
"src/api/index.ts",
|
||||
"src/api/install.ts",
|
||||
"src/api/link.ts",
|
||||
"src/api/lock.ts",
|
||||
"src/api/prune.ts",
|
||||
"src/api/removeOrphanPkgs.ts",
|
||||
"src/api/storeStatus.ts",
|
||||
"src/api/uninstall.ts",
|
||||
"src/binify.ts",
|
||||
"src/depsToSpecs.ts",
|
||||
"src/err.ts",
|
||||
"src/errorTypes.ts",
|
||||
"src/fs/expandTilde.ts",
|
||||
"src/fs/getPkgDirs.ts",
|
||||
"src/fs/gracefulify.ts",
|
||||
"src/fs/linkIndexedDir.ts",
|
||||
"src/fs/modulesController.ts",
|
||||
"src/fs/readPkg.ts",
|
||||
"src/fs/safeReadPkg.ts",
|
||||
"src/getSaveType.ts",
|
||||
"src/index.ts",
|
||||
"src/install/getIsInstallable.ts",
|
||||
"src/install/installMultiple.ts",
|
||||
"src/install/postInstall.ts",
|
||||
"src/link/index.ts",
|
||||
"src/link/linkBins.ts",
|
||||
"src/link/resolvePeers.ts",
|
||||
"src/logging/logInstallStatus.ts",
|
||||
"src/logging/streamParser.ts",
|
||||
"src/memoize.ts",
|
||||
"src/pnpmPkgJson.ts",
|
||||
"src/removeDeps.ts",
|
||||
"src/removeTopDependency.ts",
|
||||
"src/runScript.ts",
|
||||
"src/safeIsInnerLink.ts",
|
||||
"src/save.ts",
|
||||
"src/types.ts",
|
||||
"test/typings/index.d.ts"
|
||||
]
|
||||
}
|
||||
40
tslint.json
Normal file
40
tslint.json
Normal file
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"rules": {
|
||||
"curly": false,
|
||||
"eofline": false,
|
||||
"align": [true, "parameters"],
|
||||
"class-name": true,
|
||||
"indent": [true, "spaces"],
|
||||
"max-line-length": false,
|
||||
"no-any": true,
|
||||
"no-consecutive-blank-lines": true,
|
||||
"no-trailing-whitespace": true,
|
||||
"no-duplicate-variable": true,
|
||||
"no-var-keyword": true,
|
||||
"no-unused-expression": true,
|
||||
"no-use-before-declare": true,
|
||||
"no-var-requires": true,
|
||||
"no-require-imports": false,
|
||||
"one-line": [true,
|
||||
"check-else",
|
||||
"check-whitespace",
|
||||
"check-open-brace"],
|
||||
"quotemark": [true,
|
||||
"single",
|
||||
"avoid-escape"],
|
||||
"semicolon": false,
|
||||
"typedef-whitespace": [true, {
|
||||
"call-signature": "nospace",
|
||||
"index-signature": "nospace",
|
||||
"parameter": "nospace",
|
||||
"property-declaration": "nospace",
|
||||
"variable-declaration": "nospace"
|
||||
}],
|
||||
"whitespace": [true,
|
||||
"check-branch",
|
||||
"check-decl",
|
||||
"check-operator",
|
||||
"check-separator",
|
||||
"check-type"]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user