How to use @pnpm/tarball-fetcher - 4 common examples

To help you get started, we’ve selected a few @pnpm/tarball-fetcher examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pnpm / pnpm / test / download.ts View on Github external
///
import { existsSync } from 'fs'
import fs = require('mz/fs')
import test = require('tape')
import nock = require('nock')
import createFetcher from '@pnpm/tarball-fetcher'
import path = require('path')
import tempy = require('tempy')
import { streamParser, LogBase } from '@pnpm/logger'
import ssri = require('ssri')

const tarballPath = path.join(__dirname, 'tars', 'babel-helper-hoist-variables-6.24.1.tgz')
const tarballSize = 1279
const tarballIntegrity = 'sha1-HssnaJydJVE+rbyZFKc/VAi+enY='
const registry = 'http://example.com/'
const fetch = createFetcher({
  registry,
  rawNpmConfig: {
    registry,
  },
  fetchRetries: 1,
  fetchRetryMintimeout: 0,
  fetchRetryMaxtimeout: 100,
})

test('fail when tarball size does not match content-length', async t => {
  const scope = nock(registry)
    .get('/foo.tgz')
    .times(2)
    .replyWithFile(200, tarballPath, {
      'Content-Length': (1024 * 1024).toString(),
    })
github pnpm / pnpm / test / download.ts View on Github external
registry,
    {
      reqheaders: {
        'authorization': 'Bearer ofjergrg349gj3f2'
      }
    }
  )
  .get('/foo.tgz')
  .replyWithFile(200, tarballPath, {
    'Content-Length': tarballSize.toString(),
  })

  process.chdir(tempy.directory())
  t.comment(`testing in ${process.cwd()}`)

  const fetch = createFetcher({
    alwaysAuth: true,
    registry,
    rawNpmConfig: {
      registry,
      '//example.com/:_authToken': 'ofjergrg349gj3f2',
    },
    fetchRetries: 1,
    fetchRetryMintimeout: 0,
    fetchRetryMaxtimeout: 100,
  })

  const unpackTo = path.resolve('unpacked')
  const cachedTarballLocation = path.resolve('cached')
  const resolution = {
    registry,
    tarball: 'http://example.com/foo.tgz',
github pnpm / pnpm / packages / tarball-fetcher / example / index.js View on Github external
'use strict'
const createFetcher = require('@pnpm/tarball-fetcher').default

process.chdir(__dirname)

const registry = 'https://registry.npmjs.org/'
const fetch = createFetcher({
  registry,
  rawConfig: {
    registry,
  },
})

const resolution = {
  tarball: 'https://registry.npmjs.org/is-positive/-/is-positive-1.0.0.tgz',
}
fetch.tarball(resolution, 'dist/unpacked', {
  cachedTarballLocation: 'dist/cache.tgz',
  prefix: process.cwd(),
})
.then(index => console.log(Object.keys(index)))
.catch(err => {
  console.error(err)
github pnpm / pnpm / packages / server / example / server.js View on Github external
async function main() {
  const registry = 'https://registry.npmjs.org/'
  const rawConfig = { registry }
  const store = '.store'
  const resolve = createResolver({
    rawConfig,
    store,
    metaCache: new Map(),
  })
  const fetchers = createFetcher({
    alwaysAuth: true,
    registry,
    strictSsl: true,
    rawConfig,
  })
  const storeCtrl = await createStore(resolve, fetchers, {
    networkConcurrency: 1,
    store,
  })

  const port = 5813
  const hostname = '127.0.0.1';
  const server = createServer(storeCtrl, {
    port,
    hostname,
  })

@pnpm/tarball-fetcher

Fetcher for packages hosted as tarballs

MIT
Latest version published 8 days ago

Package Health Score

57 / 100
Full package analysis

Popular @pnpm/tarball-fetcher functions