xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

pnpm All In One

pnpm All In One

Version: 7.x

bash shell

# Linux / macOS
$ curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm

# Node.js is not preinstalled
$ curl -fsSL https://get.pnpm.io/install.sh | sh -

install

https://pnpm.io/installation

# Homebrew
$ brew install pnpm

# npm
$ npm install -g pnpm

# npx
$ npx pnpm add -g pnpm

#/Users/xgqfrms-mbp/.nvm/versions/node/v12.18.0/pnpm-global/5:

$ pnpm -v
# 6.32.3


$ pnpm -h

Version 6.32.3
Usage: pnpm [command] [flags]
       pnpm [ -h | --help | -v | --version ]

Manage your dependencies:
      add                  Installs a package and any packages that it depends
                           on. By default, any new package is installed as a
                           prod dependency
      import               Generates a pnpm-lock.yaml from an npm
                           package-lock.json (or npm-shrinkwrap.json) file
   i, install              Install all dependencies for a project
  it, install-test         Runs a pnpm install followed immediately by a pnpm
                           test
  ln, link                 Connect the local project to another one
      prune                Removes extraneous packages
  rb, rebuild              Rebuild a package
  rm, remove               Removes packages from node_modules and from the
                           project's package.json
      unlink               Unlinks a package. Like yarn unlink but pnpm
                           re-installs the dependency after removing the
                           external link
  up, update               Updates packages to their latest version based on the
                           specified range

Review your dependencies:
      audit                Checks for known security issues with the installed
                           packages
  ls, list                 Print all the versions of packages that are
                           installed, as well as their dependencies, in a
                           tree-structure
      outdated             Check for outdated packages

Run your scripts:
      exec                 Executes a shell command in scope of a project
      run                  Runs a defined package script
      start                Runs an arbitrary command specified in the package's
                           "start" property of its "scripts" object
   t, test                 Runs a package's "test" script, if one was provided

Other:
      pack
      publish              Publishes a package to the registry
      root

Manage your store:
      store add            Adds new packages to the pnpm store directly. Does not
                           modify any projects or files outside the store
      store prune          Removes unreferenced (extraneous, orphan) packages from
                           the store
      store status         Checks for modified packages in the store


https://pnpm.io/installation#compatibility

https://github.com/pnpm/pnpm

https://pnpm.io/

CI/CD

.gitlab-ci.yml

stages:
  - build

build:
  stage: build
  image: node:14.16.0-buster
  before_script:
    - curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm@6
    - pnpm config set store-dir .pnpm-store
  script:
    - pnpm install # install dependencies
  cache:
    key: "$CI_COMMIT_REF_SLUG"
    paths:
      - .pnpm-store

.github/workflows/NAME.yml


name: pnpm Example Workflow
on:
  push:
jobs:
  build:
    runs-on: ubuntu-20.04
    strategy:
      matrix:
        node-version: [15]
    steps:
    - uses: actions/checkout@v2
    - uses: pnpm/action-setup@v2.0.1
      with:
        version: 6.20.3
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v2
      with:
        node-version: ${{ matrix.node-version }}
        cache: 'pnpm'
    - name: Install dependencies
      run: pnpm install

.travis.yml

cache:
  npm: false
  directories:
    - "~/.pnpm-store"
before_install:
  - curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm@6
  - pnpm config set store-dir ~/.pnpm-store
install:
  - pnpm install

https://pnpm.io/continuous-integration

demo

$ pnpm create vite

$ yarn create vite

$ npm create vite@latest

https://vitejs.dev/guide/#scaffolding-your-first-vite-project

monorepo

https://en.wikipedia.org/wiki/Monorepo

https://www.toptal.com/front-end/guide-to-monorepos

  1. yarn workspaces

  2. lerna

https://lerna.js.org/

https://github.com/lerna/lerna

git

git submodule

https://www.atlassian.com/git/tutorials/monorepos

https://git-scm.com/docs/git-submodule

https://git-scm.com/book/en/v2/Git-Tools-Submodules

refs



©xgqfrms 2012-2020

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2021-12-07 10:34  xgqfrms  阅读(145)  评论(4编辑  收藏  举报