mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-23 09:31:52 -04:00
refactor: move @pnpm/tarball-resolver to the monorepo
This commit is contained in:
21
packages/tarball-resolver/LICENSE
Normal file
21
packages/tarball-resolver/LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017-2019 Zoltan Kochan <z@kochan.io>
|
||||
|
||||
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.
|
||||
37
packages/tarball-resolver/README.md
Normal file
37
packages/tarball-resolver/README.md
Normal file
@@ -0,0 +1,37 @@
|
||||
# @pnpm/tarball-resolver
|
||||
|
||||
> Resolver for tarball dependencies
|
||||
|
||||
<!--@shields('npm')-->
|
||||
[](https://www.npmjs.com/package/@pnpm/tarball-resolver)
|
||||
<!--/@-->
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
npm i -S @pnpm/tarball-resolver
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
<!--@example('./example.js')-->
|
||||
```js
|
||||
'use strict'
|
||||
const resolveFromTarball = require('@pnpm/tarball-resolver').default
|
||||
|
||||
resolveFromTarball({pref: 'http://registry.npmjs.org/is-array/-/is-array-1.0.1.tgz'})
|
||||
.then(resolveResult => console.log(JSON.stringify(resolveResult, null, 2)))
|
||||
//> {
|
||||
// "id": "registry.npmjs.org/is-array/-/is-array-1.0.1",
|
||||
// "normalizedPref": "http://registry.npmjs.org/is-array/-/is-array-1.0.1.tgz",
|
||||
// "resolution": {
|
||||
// "tarball": "http://registry.npmjs.org/is-array/-/is-array-1.0.1.tgz"
|
||||
// },
|
||||
// "resolvedVia": "url"
|
||||
// }
|
||||
```
|
||||
<!--/@-->
|
||||
|
||||
## License
|
||||
|
||||
[MIT](./LICENSE) © [Zoltan Kochan](https://www.kochan.io/)
|
||||
5
packages/tarball-resolver/example.js
Normal file
5
packages/tarball-resolver/example.js
Normal file
@@ -0,0 +1,5 @@
|
||||
'use strict'
|
||||
const resolveFromTarball = require('@pnpm/tarball-resolver').default
|
||||
|
||||
resolveFromTarball({pref: 'http://registry.npmjs.org/is-array/-/is-array-1.0.1.tgz'})
|
||||
.then(resolveResult => console.log(JSON.stringify(resolveResult, null, 2)))
|
||||
50
packages/tarball-resolver/package.json
Normal file
50
packages/tarball-resolver/package.json
Normal file
@@ -0,0 +1,50 @@
|
||||
{
|
||||
"name": "@pnpm/tarball-resolver",
|
||||
"version": "1.0.1",
|
||||
"description": "Resolver for tarball dependencies",
|
||||
"main": "lib/index.js",
|
||||
"typings": "lib/index.d.ts",
|
||||
"files": [
|
||||
"lib"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "tslint -c tslint.json --project .",
|
||||
"tsc": "rimraf lib && tsc",
|
||||
"test": "npm run tsc && npm run lint && ts-node test --type-check && mos t",
|
||||
"md": "mos",
|
||||
"prepublishOnly": "npm run tsc"
|
||||
},
|
||||
"repository": "https://github.com/pnpm/pnpm/blob/master/packages/tarball-resolver",
|
||||
"author": "Zoltan Kochan <z@kochan.io> (https://www.kochan.io/)",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/pnpm/pnpm/issues"
|
||||
},
|
||||
"homepage": "https://github.com/pnpm/pnpm/blob/master/packages/tarball-resolver#readme",
|
||||
"dependencies": {
|
||||
"@pnpm/resolver-base": "^2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@pnpm/tarball-resolver": "link:",
|
||||
"@pnpm/tslint-config": "0.0.0",
|
||||
"@types/tape": "^4.2.31",
|
||||
"mos": "^2.0.0-alpha.3",
|
||||
"mos-plugin-readme": "^1.0.4",
|
||||
"rimraf": "^2.6.2",
|
||||
"tape": "^4.8.0",
|
||||
"ts-node": "^8.0.2",
|
||||
"tslint": "^5.8.0",
|
||||
"typescript": "^3.0.0"
|
||||
},
|
||||
"mos": {
|
||||
"plugins": [
|
||||
"readme"
|
||||
],
|
||||
"installation": {
|
||||
"useShortAlias": true
|
||||
}
|
||||
}
|
||||
}
|
||||
23
packages/tarball-resolver/src/index.ts
Normal file
23
packages/tarball-resolver/src/index.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { ResolveResult } from '@pnpm/resolver-base'
|
||||
|
||||
export default async function resolveTarball (
|
||||
wantedDependency: {pref: string},
|
||||
): Promise<ResolveResult | null> {
|
||||
if (!wantedDependency.pref.startsWith('http:') && !wantedDependency.pref.startsWith('https:')) {
|
||||
return null
|
||||
}
|
||||
|
||||
return {
|
||||
id: wantedDependency.pref
|
||||
.replace(/^.*:\/\/(git@)?/, '')
|
||||
.replace(/\.tgz$/, ''),
|
||||
// TODO BREAKING CHANGE: uncomment the following: (or never remove extensions)
|
||||
// .replace(/\.tar.gz$/, ''),
|
||||
// .replace(/\.tar$/, ''),
|
||||
normalizedPref: wantedDependency.pref,
|
||||
resolution: {
|
||||
tarball: wantedDependency.pref,
|
||||
},
|
||||
resolvedVia: 'url',
|
||||
}
|
||||
}
|
||||
47
packages/tarball-resolver/test/index.ts
Normal file
47
packages/tarball-resolver/test/index.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import test = require('tape')
|
||||
import resolveFromTarball from '@pnpm/tarball-resolver'
|
||||
|
||||
test('tarball from npm registry', async t => {
|
||||
const resolutionResult = await resolveFromTarball({pref: 'http://registry.npmjs.org/is-array/-/is-array-1.0.1.tgz'})
|
||||
|
||||
t.deepEqual(resolutionResult, {
|
||||
id: 'registry.npmjs.org/is-array/-/is-array-1.0.1',
|
||||
normalizedPref: 'http://registry.npmjs.org/is-array/-/is-array-1.0.1.tgz',
|
||||
resolution: {
|
||||
tarball: 'http://registry.npmjs.org/is-array/-/is-array-1.0.1.tgz',
|
||||
},
|
||||
resolvedVia: 'url',
|
||||
})
|
||||
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('tarball not from npm registry', async t => {
|
||||
const resolutionResult = await resolveFromTarball({pref: 'https://github.com/hegemonic/taffydb/tarball/master'})
|
||||
|
||||
t.deepEqual(resolutionResult, {
|
||||
id: 'github.com/hegemonic/taffydb/tarball/master',
|
||||
normalizedPref: 'https://github.com/hegemonic/taffydb/tarball/master',
|
||||
resolution: {
|
||||
tarball: 'https://github.com/hegemonic/taffydb/tarball/master',
|
||||
},
|
||||
resolvedVia: 'url',
|
||||
})
|
||||
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('tarballs from GitHub (is-negative)', async t => {
|
||||
const resolutionResult = await resolveFromTarball({pref: 'https://github.com/kevva/is-negative/archive/1d7e288222b53a0cab90a331f1865220ec29560c.tar.gz'})
|
||||
|
||||
t.deepEqual(resolutionResult, {
|
||||
id: 'github.com/kevva/is-negative/archive/1d7e288222b53a0cab90a331f1865220ec29560c.tar.gz',
|
||||
normalizedPref: 'https://github.com/kevva/is-negative/archive/1d7e288222b53a0cab90a331f1865220ec29560c.tar.gz',
|
||||
resolution: {
|
||||
tarball: 'https://github.com/kevva/is-negative/archive/1d7e288222b53a0cab90a331f1865220ec29560c.tar.gz',
|
||||
},
|
||||
resolvedVia: 'url',
|
||||
})
|
||||
|
||||
t.end()
|
||||
})
|
||||
24
packages/tarball-resolver/tsconfig.json
Normal file
24
packages/tarball-resolver/tsconfig.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"removeComments": false,
|
||||
"preserveConstEnums": true,
|
||||
"sourceMap": true,
|
||||
"declaration": true,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitReturns": true,
|
||||
"suppressImplicitAnyIndexErrors": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"strictNullChecks": true,
|
||||
"target": "es2017",
|
||||
"outDir": "lib",
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node"
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.ts",
|
||||
"typings/**/*.d.ts"
|
||||
],
|
||||
"atom": {
|
||||
"rewriteTsconfig": true
|
||||
}
|
||||
}
|
||||
3
packages/tarball-resolver/tslint.json
Normal file
3
packages/tarball-resolver/tslint.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "@pnpm/tslint-config"
|
||||
}
|
||||
36
pnpm-lock.yaml
generated
36
pnpm-lock.yaml
generated
@@ -196,7 +196,7 @@ importers:
|
||||
'@pnpm/git-resolver': 'link:../git-resolver'
|
||||
'@pnpm/local-resolver': 'link:../local-resolver'
|
||||
'@pnpm/npm-resolver': 'link:../npm-resolver'
|
||||
'@pnpm/tarball-resolver': 1.0.1
|
||||
'@pnpm/tarball-resolver': 'link:../tarball-resolver'
|
||||
devDependencies:
|
||||
'@pnpm/default-resolver': 'link:'
|
||||
'@pnpm/logger': 2.1.0
|
||||
@@ -2032,6 +2032,32 @@ importers:
|
||||
tslint: 5.13.1
|
||||
typescript: 3.3.3333
|
||||
unpack-stream: 4.0.2
|
||||
packages/tarball-resolver:
|
||||
dependencies:
|
||||
'@pnpm/resolver-base': 'link:../resolver-base'
|
||||
devDependencies:
|
||||
'@pnpm/tarball-resolver': 'link:'
|
||||
'@pnpm/tslint-config': 'link:../../utils/tslint-config'
|
||||
'@types/tape': 4.2.33
|
||||
mos: 2.0.0-alpha.3
|
||||
mos-plugin-readme: 1.0.4
|
||||
rimraf: 2.6.3
|
||||
tape: 4.10.1
|
||||
ts-node: 8.0.2_typescript@3.3.3333
|
||||
tslint: 5.13.1_typescript@3.3.3333
|
||||
typescript: 3.3.3333
|
||||
specifiers:
|
||||
'@pnpm/resolver-base': ^2.0.0
|
||||
'@pnpm/tarball-resolver': 'link:'
|
||||
'@pnpm/tslint-config': 0.0.0
|
||||
'@types/tape': ^4.2.31
|
||||
mos: ^2.0.0-alpha.3
|
||||
mos-plugin-readme: ^1.0.4
|
||||
rimraf: ^2.6.2
|
||||
tape: ^4.8.0
|
||||
ts-node: ^8.0.2
|
||||
tslint: ^5.8.0
|
||||
typescript: ^3.0.0
|
||||
packages/types:
|
||||
devDependencies:
|
||||
'@pnpm/tslint-config': 'link:../../utils/tslint-config'
|
||||
@@ -2528,14 +2554,6 @@ packages:
|
||||
node: '>=4'
|
||||
resolution:
|
||||
integrity: sha512-sGNnrjzNgzizIAiVIuXBQYWY8XvNBGUFbjEftIzKuXB/++Dr/JVinjLijm6iql7WDHolEf90pMNcBkL8Ni139w==
|
||||
/@pnpm/tarball-resolver/1.0.1:
|
||||
dependencies:
|
||||
'@pnpm/resolver-base': 2.1.0
|
||||
dev: false
|
||||
engines:
|
||||
node: '>=6'
|
||||
resolution:
|
||||
integrity: sha512-OFe7/5RZ+/mEBpsH+gMMNIY73uEwCDdcCaSR2KzeNj+ydbthoIsSKzoXrfbCcMwEL8Nf4Ztk498VutR/qxp+yA==
|
||||
/@pnpm/types/2.0.0:
|
||||
engines:
|
||||
node: '>=6'
|
||||
|
||||
Reference in New Issue
Block a user