How to use supi - 10 common examples

To help you get started, we’ve selected a few supi 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 / install / global.ts View on Github external
test('global installation', async (t) => {
  prepare(t)
  const globalPrefix = path.resolve('..', 'global')
  const opts = await testDefaults({global: true, prefix: globalPrefix})
  await installPkgs(['is-positive'], opts)

  // there was an issue when subsequent installations were removing everything installed prior
  // https://github.com/pnpm/pnpm/issues/808
  await installPkgs(['is-negative'], opts)

  const isPositive = require(path.join(globalPrefix, LAYOUT_VERSION, 'node_modules', 'is-positive'))
  t.ok(typeof isPositive === 'function', 'isPositive() is available')

  const isNegative = require(path.join(globalPrefix, LAYOUT_VERSION, 'node_modules', 'is-negative'))
  t.ok(typeof isNegative === 'function', 'isNegative() is available')
})
github pnpm / pnpm / test / install / sideEffects.ts View on Github external
test('readonly side effects cache', async (t) => {
  const project = prepare(t)

  const opts1 = await testDefaults({sideEffectsCache: true, verifyStoreIntegrity: false})
  await installPkgs(['runas@3.1.1'], opts1)

  // Modify the side effects cache to make sure we are using it
  const cacheBuildDir = path.join(opts1.store, 'localhost+4873', 'runas', '3.1.1', 'side_effects', `${process.platform}-${process.arch}-node-${process.version.split('.')[0]}`, 'package', 'build')
  await fs.writeFile(path.join(cacheBuildDir, 'new-file.txt'), 'some new content')

  await rimraf('node_modules')
  const opts2 = await testDefaults({sideEffectsCacheReadonly: true, verifyStoreIntegrity: false}, {}, {}, {packageImportMethod: 'copy'})
  await installPkgs(['runas@3.1.1'], opts2)

  t.ok(await exists(path.join('node_modules', 'runas', 'build', 'new-file.txt')), 'side effects cache correctly used')

  await rimraf('node_modules')
  // changing version to make sure we don't create the cache
  await await installPkgs(['runas@3.1.0'], opts2)

  t.ok(await exists(path.join('node_modules', 'runas', 'build')), 'build folder created')
github pnpm / pnpm / test / install / sideEffects.ts View on Github external
test('readonly side effects cache', async (t) => {
  const project = prepare(t)

  const opts1 = await testDefaults({sideEffectsCache: true, verifyStoreIntegrity: false})
  await installPkgs(['runas@3.1.1'], opts1)

  // Modify the side effects cache to make sure we are using it
  const cacheBuildDir = path.join(opts1.store, 'localhost+4873', 'runas', '3.1.1', 'side_effects', `${process.platform}-${process.arch}-node-${process.version.split('.')[0]}`, 'package', 'build')
  await fs.writeFile(path.join(cacheBuildDir, 'new-file.txt'), 'some new content')

  await rimraf('node_modules')
  const opts2 = await testDefaults({sideEffectsCacheReadonly: true, verifyStoreIntegrity: false}, {}, {}, {packageImportMethod: 'copy'})
  await installPkgs(['runas@3.1.1'], opts2)

  t.ok(await exists(path.join('node_modules', 'runas', 'build', 'new-file.txt')), 'side effects cache correctly used')

  await rimraf('node_modules')
  // changing version to make sure we don't create the cache
  await await installPkgs(['runas@3.1.0'], opts2)

  t.ok(await exists(path.join('node_modules', 'runas', 'build')), 'build folder created')
  t.notOk(await exists(path.join(opts2.store, 'localhost+4873', 'runas', '3.1.0', 'side_effects', `${process.platform}-${process.arch}-node-${process.version.split('.')[0]}`, 'package', 'build')), 'cache folder not created')
})
github pnpm / pnpm / test / install / store.ts View on Github external
test('repeat install with corrupted `store.json` should work', async (t: tape.Test) => {
  const project = prepare(t)

  const opts = await testDefaults()
  await installPkgs(['is-negative@1.0.0'], opts)

  await rimraf('node_modules')

  // When a package reference is missing from `store.json`
  // we assume that it is not in the store.
  // The package is downloaded and in case there is a folder
  // in the store, it is overwritten.
  await writeJsonFile(path.join(opts.store, '2', 'store.json'), {})

  await install(opts)

  const m = project.requireModule('is-negative')
  t.ok(m)
})
github pnpm / pnpm / test / link.ts View on Github external
test('relative link', async (t: tape.Test) => {
  const project = prepare(t, {
    dependencies: {
      'hello-world-js-bin': '*',
    },
  })

  const linkedPkgName = 'hello-world-js-bin'
  const linkedPkgPath = path.resolve('..', linkedPkgName)

  await ncp(pathToLocalPkg(linkedPkgName), linkedPkgPath)
  await link([`../${linkedPkgName}`], path.join(process.cwd(), 'node_modules'), await testDefaults())

  await project.isExecutable('.bin/hello-world-js-bin')

  // The linked package has been installed successfully as well with bins linked
  // to node_modules/.bin
  const linkedProject = assertProject(t, linkedPkgPath)
  await linkedProject.isExecutable('.bin/cowsay')

  const wantedShrinkwrap = await project.loadShrinkwrap()
  t.equal(wantedShrinkwrap.dependencies['hello-world-js-bin'], 'link:../hello-world-js-bin', 'link added to wanted shrinkwrap')
  t.equal(wantedShrinkwrap.specifiers['hello-world-js-bin'], '*', 'specifier of linked dependency added to shrinkwrap.yaml')

  const currentShrinkwrap = await project.loadCurrentShrinkwrap()
  t.equal(currentShrinkwrap.dependencies['hello-world-js-bin'], 'link:../hello-world-js-bin', 'link added to wanted shrinkwrap')
})
github pnpm / pnpm / test / link.ts View on Github external
test('global link', async (t: tape.Test) => {
  const project = prepare(t)
  const projectPath = process.cwd()

  const linkedPkgName = 'hello-world-js-bin'
  const linkedPkgPath = path.resolve('..', linkedPkgName)

  await ncp(pathToLocalPkg(linkedPkgName), linkedPkgPath)

  process.chdir(linkedPkgPath)
  const globalPrefix = path.resolve('..', 'global')
  const globalBin = path.resolve('..', 'global', 'bin')
  await linkToGlobal(process.cwd(), await testDefaults({globalPrefix, globalBin}))

  await isExecutable(t, path.join(globalBin, 'hello-world-js-bin'))

  // bins of dependencies should not be linked, see issue https://github.com/pnpm/pnpm/issues/905
  t.notOk(await exists(path.join(globalBin, 'cowsay')), 'cowsay not linked')
  t.notOk(await exists(path.join(globalBin, 'cowthink')), 'cowthink not linked')

  process.chdir(projectPath)

  await linkFromGlobal([linkedPkgName], process.cwd(), await testDefaults({globalPrefix}))

  await project.isExecutable('.bin/hello-world-js-bin')
})
github pnpm / pnpm / test / install / auth.ts View on Github external
await installPkgs(['@private/foo'], opts)

  await project.has('@private/foo')

  // should work when a shrinkwrap is available
  await rimraf('node_modules')
  await rimraf(path.join('..', '.store'))

  // Recreating options to have a new storeController with clean cache
  opts = await testDefaults({}, {
    rawNpmConfig,
    registry: 'https://registry.npmjs.org/',
  }, {
    rawNpmConfig,
  })
  await installPkgs(['@private/foo'], opts)

  await project.has('@private/foo')
})
github pnpm / pnpm / test / install / auth.ts View on Github external
await installPkgs(['needs-auth'], opts)

  await rimraf('node_modules')
  await rimraf(path.join('..', '.registry'))
  await rimraf(path.join('..', '.store'))

  // Recreating options to clean store cache
  opts = await testDefaults({
    registry: 'http://127.0.0.1:4873',
  }, {
    rawNpmConfig,
    registry: 'http://127.0.0.1:4873',
  }, {
    rawNpmConfig,
  })
  await install(opts)

  const m = project.requireModule('needs-auth')

  t.ok(typeof m === 'function', 'needs-auth() is available')
})
github pnpm / pnpm / packages / plugin-commands-installation / src / recursive.ts View on Github external
async function unlink (manifest: ImporterManifest, opts: any) { // tslint:disable-line:no-any
  return mutateModules(
    [
      {
        manifest,
        mutation: 'unlink',
        rootDir: opts.dir,
      },
    ],
    opts,
  )
}
github pnpm / pnpm / packages / plugin-commands-recursive / src / recursive.ts View on Github external
async function unlinkPkgs (dependencyNames: string[], manifest: ImporterManifest, opts: any) { // tslint:disable-line:no-any
  return mutateModules(
    [
      {
        dependencyNames,
        manifest,
        mutation: 'unlinkSome',
        rootDir: opts.dir,
      },
    ],
    opts,
  )
}