How to use the @pnpm/server.connectStoreController function in @pnpm/server

To help you get started, we’ve selected a few @pnpm/server 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 / packages / store-connection-manager / src / index.ts View on Github external
const connectionInfoDir = serverConnectionInfoDir(storeDir)
  const serverJsonPath = path.join(connectionInfoDir, 'server.json')
  let serverJson = await tryLoadServerJson({ serverJsonPath, shouldRetryOnNoent: false })
  if (serverJson !== null) {
    if (serverJson.pnpmVersion !== packageManager.version) {
      logger.warn({
        message: `The store server runs on pnpm v${serverJson.pnpmVersion}. It is recommended to connect with the same version (current is v${packageManager.version})`,
        prefix: opts.dir,
      })
    }
    logger.info({
      message: 'A store server is running. All store manipulations are delegated to it.',
      prefix: opts.dir,
    })
    return {
      ctrl: await connectStoreController(serverJson.connectionOptions), // tslint:disable-line
      dir: storeDir,
    }
  }
  if (opts.useRunningStoreServer) {
    throw new PnpmError('NO_STORE_SERVER', 'No store server is running.')
  }
  if (opts.useStoreServer) {
    runServerInBackground(storeDir)
    serverJson = await tryLoadServerJson({ serverJsonPath, shouldRetryOnNoent: true })
    logger.info({
      message: 'A store server has been started. To stop it, use \`pnpm server stop\`',
      prefix: opts.dir,
    })
    return {
      ctrl: await connectStoreController(serverJson!.connectionOptions), // tslint:disable-line
      dir: storeDir,
github pnpm / pnpm / packages / store-connection-manager / src / index.ts View on Github external
ctrl: await connectStoreController(serverJson.connectionOptions), // tslint:disable-line
      dir: storeDir,
    }
  }
  if (opts.useRunningStoreServer) {
    throw new PnpmError('NO_STORE_SERVER', 'No store server is running.')
  }
  if (opts.useStoreServer) {
    runServerInBackground(storeDir)
    serverJson = await tryLoadServerJson({ serverJsonPath, shouldRetryOnNoent: true })
    logger.info({
      message: 'A store server has been started. To stop it, use \`pnpm server stop\`',
      prefix: opts.dir,
    })
    return {
      ctrl: await connectStoreController(serverJson!.connectionOptions), // tslint:disable-line
      dir: storeDir,
    }
  }
  return createNewStoreController(Object.assign(opts, {
    storeDir,
  }))
}
github pnpm / pnpm / packages / server / example / client.js View on Github external
async function main () {
  const registry = 'https://registry.npmjs.org/'
  const prefix = process.cwd()
  const storeCtrl = await connectStoreController({remotePrefix: 'http://localhost:5813'})
  const response = await storeCtrl.requestPackage(
    {alias: 'is-positive', pref: '1.0.0'},
    {
      downloadPriority: 0,
      offline: false,
      prefix,
      registry,
      verifyStoreIntegrity: false,
    }
  )

  console.log(response)
  console.log(await response.fetchingManifest)
  console.log(await response['fetchingFiles'])

  await storeCtrl.updateConnections(prefix, {addDependencies: [response.id], removeDependencies: []})
github pnpm / pnpm / packages / plugin-commands-server / src / stop.ts View on Github external
opts: {
    storeDir?: string,
    dir: string,
  },
) => {
  const storeDir = await storePath(opts.dir, opts.storeDir)
  const connectionInfoDir = serverConnectionInfoDir(storeDir)
  const serverJson = await tryLoadServerJson({
    serverJsonPath: path.join(connectionInfoDir, 'server.json'),
    shouldRetryOnNoent: false,
  })
  if (serverJson === null) {
    globalInfo(`Nothing to stop. No server is running for the store at ${storeDir}`)
    return
  }
  const storeController = await connectStoreController(serverJson.connectionOptions)
  await storeController.stop()

  if (await serverGracefullyStops(serverJson.pid)) {
    globalInfo('Server gracefully stopped')
    return
  }
  globalWarn('Graceful shutdown failed')
  await kill(serverJson.pid, 'SIGINT')
  globalInfo('Server process terminated')
}

@pnpm/server

A pnpm installer server

MIT
Latest version published 7 days ago

Package Health Score

61 / 100
Full package analysis