How to use the supi.install function in supi

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 / 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 / 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-import / src / import.ts View on Github external
// Removing existing pnpm lockfile
  // it should not influence the new one
  await rimraf(path.join(opts.dir, WANTED_LOCKFILE))
  const npmPackageLock = await readNpmLockfile(opts.dir)
  const versionsByPackageNames = {}
  getAllVersionsByPackageNames(npmPackageLock, versionsByPackageNames)
  const preferredVersions = getPreferredVersions(versionsByPackageNames)
  const store = await createOrConnectStoreController(opts)
  const installOpts = {
    ...opts,
    lockfileOnly: true,
    preferredVersions,
    storeController: store.ctrl,
    storeDir: store.dir,
  }
  await install(await readImporterManifestOnly(opts.dir), installOpts)
}
github pnpm / pnpm / test / install / lifecycleScripts.ts View on Github external
test('do not run install scripts if unsafePerm is false', async (t: tape.Test) => {
  const project = prepare(t, {
    name: 'different-name',
    scripts: {
      install: `node -e "process.stdout.write('install')" | json-append output.json`,
      postinstall: `node -e "process.stdout.write('postinstall')" | json-append output.json`,
      preinstall: `node -e "process.stdout.write('preinstall')" | json-append output.json`,
    },
  })
  const opts = await testDefaults({ unsafePerm: false })
  await installPkgs(['json-append@1.1.1'], opts)
  await install(opts)

  const outputExists = await exists('output.json')

  t.false(outputExists, 'no output expected as install scripts should not run')
})
github pnpm / pnpm / test / breakingChanges.ts View on Github external
test("don't fail on non-compatible store when forced", async (t) => {
  const project = prepare(t)
  const opts = await testDefaults({force: true})

  await saveModulesYaml('0.32.0', opts.store)

  await install(opts)

  t.pass('install did not fail')
})
github pnpm / pnpm / test / shrinkwrap.ts View on Github external
tarball: '/i/is-positive/_attachments/is-positive-3.1.0.tgz',
        },
      },
    },
    registry: 'https://npm-registry.compass.com/',
    shrinkwrapMinorVersion: 6,
    shrinkwrapVersion: 3,
    specifiers: {
      'is-positive': '^3.1.0',
    },
  })

  await rimraf(opts.store)
  await rimraf('node_modules')

  await install(opts)

  await project.has('is-positive')
})
github pnpm / pnpm / test / install / shrinkwrapOnly.ts View on Github external
t.deepEqual(await fs.readdir(path.join(opts.store, 'localhost+4873', 'dep-of-pkg-with-1-dep')), ['index-full.json'])
  await project.hasNot('pkg-with-1-dep')

  const pkg = await loadJsonFile('package.json')
  t.ok(pkg.dependencies['pkg-with-1-dep'], 'the new dependency added to package.json')

  const shr = await project.loadShrinkwrap()
  t.ok(shr.dependencies['pkg-with-1-dep'])
  t.ok(shr.packages['/pkg-with-1-dep/100.0.0'])
  t.ok(shr.specifiers['pkg-with-1-dep'])

  const currentShr = await project.loadCurrentShrinkwrap()
  t.notOk(currentShr, 'current shrinkwrap not created')

  t.comment('doing repeat install when shrinkwrap.yaml is available already')
  await install(opts)

  t.deepEqual(await fs.readdir(path.join(opts.store, 'localhost+4873', 'pkg-with-1-dep')), ['index-full.json'])
  t.deepEqual(await fs.readdir(path.join(opts.store, 'localhost+4873', 'dep-of-pkg-with-1-dep')), ['index-full.json'])
  await project.hasNot('pkg-with-1-dep')

  t.notOk(await project.loadCurrentShrinkwrap(), 'current shrinkwrap not created')
})
github pnpm / pnpm / packages / plugin-commands-installation / src / install.ts View on Github external
input = createLatestSpecs(input, manifest)
    }
    delete installOpts.include
  }
  if (opts.workspace) {
    if (!input || !input.length) {
      input = updateToWorkspacePackagesFromManifest(manifest, opts.include, workspacePackages!)
    } else {
      input = createWorkspaceSpecs(input, workspacePackages!)
    }
  }
  if (!input || !input.length) {
    if (invocation === 'add') {
      throw new PnpmError('MISSING_PACKAGE_NAME', '`pnpm add` requires the package name')
    }
    const updatedManifest = await install(manifest, installOpts)
    if (opts.update === true && opts.save !== false) {
      await writeImporterManifest(updatedManifest)
    }
  } else {
    const [updatedImporter] = await mutateModules([
      {
        allowNew: opts.allowNew,
        binsDir: installOpts.bin,
        dependencySelectors: input,
        manifest,
        mutation: 'installSome',
        peer: opts.savePeer,
        pinnedVersion: getPinnedVersion(opts),
        rootDir: installOpts.dir,
        targetDependenciesField: getSaveType(installOpts),
      },