feat(repo): migrate to pnpm (#16284)

This commit is contained in:
Miroslav Jonaš 2023-04-25 23:57:36 +02:00 committed by GitHub
parent 8329395a7e
commit 262865841d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
38 changed files with 29424 additions and 171896 deletions

View File

@ -14,19 +14,19 @@ orbs:
# ------------------------- # -------------------------
machine: machine:
pre: pre:
- mkdir ~/.cache/yarn - mkdir ~/.pnpm-store
- mkdir ~/.cache/Cypress - mkdir ~/.cache/Cypress
- mkdir ~/Library/Caches/Homebrew - mkdir ~/Library/Caches/Homebrew
- mkdir /usr/local/Homebrew - mkdir /usr/local/Homebrew
dependencies: dependencies:
cache_directories: cache_directories:
- ~/.cache/yarn - ~/.pnpm-store
- ~/.cache/Cypress - ~/.cache/Cypress
- /usr/local/Homebrew - /usr/local/Homebrew
- ~/Library/Caches/Homebrew - ~/Library/Caches/Homebrew
override: override:
- yarn install - pnpm install
- brew install - brew install
defaults: &defaults defaults: &defaults
@ -52,29 +52,30 @@ executors:
# COMMANDS # COMMANDS
# ------------------------- # -------------------------
commands: commands:
run-yarn-install: run-pnpm-install:
parameters: parameters:
os: os:
type: string type: string
steps: steps:
- restore_cache: - restore_cache:
name: Restore Yarn Package Cache name: Restore pnpm Package Cache
keys: keys:
- node-deps-{{ arch }}-v2-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }} - node-deps-{{ arch }}-v3-{{ checksum "pnpm-lock.yaml" }}
- run: - run:
name: Install dependencies name: Install pnpm package manager
command: yarn install --prefer-offline --frozen-lockfile --non-interactive --cache-folder ~/.cache/yarn command: |
npm install -g @pnpm/exe@8.3.1
- run:
name: Install Dependencies
command: |
pnpm install --frozen-lockfile
- save_cache: - save_cache:
name: Save Yarn Package Cache name: Save pnpm Package Cache
key: node-deps-{{ arch }}-v2-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }} key: node-deps-{{ arch }}-v3-{{ checksum "pnpm-lock.yaml" }}
paths: paths:
- ~/.cache/yarn - ~/.pnpm-store
- ~/.cache/Cypress - ~/.cache/Cypress
install-pnpm: - node_modules
steps:
- run:
name: Install PNPM
command: npm install --prefix=$HOME/.local -g @pnpm/exe@8.3.1
setup: setup:
parameters: parameters:
@ -114,13 +115,8 @@ commands:
- node/install: - node/install:
# Use LTS version # Use LTS version
node-version: '' node-version: ''
- run-yarn-install: - run-pnpm-install:
os: << parameters.os >> os: << parameters.os >>
- when:
condition:
equal: [<< parameters.os >>, linux]
steps:
- install-pnpm
# ------------------------- # -------------------------
# JOBS # JOBS
@ -162,7 +158,7 @@ jobs:
os: << parameters.os >> os: << parameters.os >>
- run: - run:
name: Agent name: Agent
command: npx nx-cloud start-agent command: pnpm nx-cloud start-agent
no_output_timeout: 60m no_output_timeout: 60m
# ------------------------- # -------------------------
@ -184,10 +180,10 @@ jobs:
os: linux os: linux
- nx/set-shas: - nx/set-shas:
main-branch-name: 'master' main-branch-name: 'master'
- run: npx nx-cloud start-ci-run --stop-agents-after="e2e" - run: pnpm nx-cloud start-ci-run --stop-agents-after="e2e"
- run: - run:
name: Check Documentation name: Check Documentation
command: npx nx documentation --no-dte command: pnpm nx documentation --no-dte
no_output_timeout: 20m no_output_timeout: 20m
- run: - run:
name: Run Checks/Lint/Test/Build name: Run Checks/Lint/Test/Build
@ -195,18 +191,18 @@ jobs:
command: | command: |
pids=() pids=()
npx nx-cloud record -- nx format:check --base=$NX_BASE --head=$NX_HEAD & pnpm nx-cloud record -- nx format:check --base=$NX_BASE --head=$NX_HEAD &
pids+=($!) pids+=($!)
npx nx run-many -t check-imports check-commit check-lock-files depcheck --parallel=1 --no-dte & pnpm nx run-many -t check-imports check-commit check-lock-files depcheck --parallel=1 --no-dte &
pids+=($!) pids+=($!)
yarn nx affected --target=lint --base=$NX_BASE --head=$NX_HEAD --parallel=3 & pnpm nx affected --target=lint --base=$NX_BASE --head=$NX_HEAD --parallel=3 &
pids+=($!) pids+=($!)
yarn nx affected --target=test --base=$NX_BASE --head=$NX_HEAD --parallel=1 & pnpm nx affected --target=test --base=$NX_BASE --head=$NX_HEAD --parallel=1 &
pids+=($!) pids+=($!)
(yarn nx affected --target=build --base=$NX_BASE --head=$NX_HEAD --parallel=3 && (pnpm nx affected --target=build --base=$NX_BASE --head=$NX_HEAD --parallel=3 &&
npx nx affected --target=e2e --base=$NX_BASE --head=$NX_HEAD --parallel=1) & pnpm nx affected --target=e2e --base=$NX_BASE --head=$NX_HEAD --parallel=1) &
pids+=($!) pids+=($!)
for pid in "${pids[@]}"; do for pid in "${pids[@]}"; do
@ -221,6 +217,7 @@ jobs:
NX_E2E_CI_CACHE_KEY: e2e-circleci-macos NX_E2E_CI_CACHE_KEY: e2e-circleci-macos
NX_DAEMON: 'true' NX_DAEMON: 'true'
NX_PERF_LOGGING: 'false' NX_PERF_LOGGING: 'false'
SELECTED_PM: 'npm' # explicitly define npm for macOS tests
steps: steps:
- run: - run:
name: Set dynamic nx run variable name: Set dynamic nx run variable
@ -232,7 +229,7 @@ jobs:
- run: - run:
name: Run E2E Tests for macOS name: Run E2E Tests for macOS
command: | command: |
npx nx affected -t e2e-macos --parallel=1 pnpm nx affected -t e2e-macos --parallel=1 --base=$NX_BASE --head=$NX_HEAD
no_output_timeout: 45m no_output_timeout: 45m
# ------------------------- # -------------------------

View File

@ -39,10 +39,15 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Install PNPM
run: |
npm install -g @pnpm/exe@8.3.1
- name: Set node - name: Set node
uses: actions/setup-node@v3 uses: actions/setup-node@v3
with: with:
node-version: ${{ matrix.node_version }} node-version: ${{ matrix.node_version }}
cache: 'pnpm'
- name: Cache node_modules - name: Cache node_modules
id: cache-modules id: cache-modules
@ -54,7 +59,7 @@ jobs:
- name: Install packages - name: Install packages
if: steps.cache-modules.outputs.cache-hit != 'true' if: steps.cache-modules.outputs.cache-hit != 'true'
run: yarn install --prefer-offline --frozen-lockfile --non-interactive run: pnpm install --frozen-lockfile
- name: Homebrew cache directory path - name: Homebrew cache directory path
if: ${{ matrix.os == 'macos-latest' }} if: ${{ matrix.os == 'macos-latest' }}
@ -320,7 +325,6 @@ jobs:
run: mkdir -p outputs run: mkdir -p outputs
- name: Install PNPM - name: Install PNPM
if: ${{ matrix.package_manager == 'pnpm' }}
run: | run: |
npm install -g @pnpm/exe@8.3.1 npm install -g @pnpm/exe@8.3.1
@ -328,6 +332,7 @@ jobs:
uses: actions/setup-node@v3 uses: actions/setup-node@v3
with: with:
node-version: ${{ matrix.node_version }} node-version: ${{ matrix.node_version }}
cache: 'pnpm'
registry-url: http://localhost:4872 registry-url: http://localhost:4872
- name: Cache node_modules - name: Cache node_modules
@ -338,8 +343,7 @@ jobs:
key: ${{ runner.os }}-modules-${{ matrix.node_version }}-${{ github.run_id }} key: ${{ runner.os }}-modules-${{ matrix.node_version }}-${{ github.run_id }}
- name: Install packages - name: Install packages
if: steps.cache-modules.outputs.cache-hit != 'true' run: pnpm install --frozen-lockfile
run: yarn install --prefer-offline --frozen-lockfile --non-interactive
- name: Cleanup - name: Cleanup
if: ${{ matrix.os == 'ubuntu-latest' }} if: ${{ matrix.os == 'ubuntu-latest' }}

View File

@ -30,10 +30,15 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Install PNPM
run: |
npm install -g @pnpm/exe@8.3.1
- name: Set node - name: Set node
uses: actions/setup-node@v3 uses: actions/setup-node@v3
with: with:
node-version: ${{ matrix.node_version }} node-version: ${{ matrix.node_version }}
cache: 'pnpm'
- name: Cache node_modules - name: Cache node_modules
id: cache-modules id: cache-modules
@ -44,7 +49,7 @@ jobs:
- name: Install packages - name: Install packages
if: steps.cache-modules.outputs.cache-hit != 'true' if: steps.cache-modules.outputs.cache-hit != 'true'
run: yarn install --prefer-offline --frozen-lockfile --non-interactive run: pnpm install --frozen-lockfile
- name: Cache Cypress - name: Cache Cypress
id: cache-cypress id: cache-cypress
@ -243,10 +248,15 @@ jobs:
- name: Prepare dir for output - name: Prepare dir for output
run: mkdir -p outputs run: mkdir -p outputs
- name: Install PNPM
run: |
npm install -g @pnpm/exe@8.3.1
- name: Use Node.js ${{ matrix.node_version }} - name: Use Node.js ${{ matrix.node_version }}
uses: actions/setup-node@v3 uses: actions/setup-node@v3
with: with:
node-version: ${{ matrix.node_version }} node-version: ${{ matrix.node_version }}
cache: 'pnpm'
registry-url: http://localhost:4872 registry-url: http://localhost:4872
- name: Cache node_modules - name: Cache node_modules
@ -257,8 +267,7 @@ jobs:
key: ${{ runner.os }}-modules-${{ matrix.node_version }}-${{ github.run_id }} key: ${{ runner.os }}-modules-${{ matrix.node_version }}-${{ github.run_id }}
- name: Install packages - name: Install packages
if: steps.cache-modules.outputs.cache-hit != 'true' run: pnpm install --frozen-lockfile
run: yarn install --prefer-offline --frozen-lockfile --non-interactive
- name: Cache Cypress - name: Cache Cypress
id: cache-cypress id: cache-cypress

View File

@ -18,24 +18,27 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: 8.2
- name: Use Node.js ${{ matrix.node_version }} - name: Use Node.js ${{ matrix.node_version }}
uses: actions/setup-node@v3 uses: actions/setup-node@v3
with: with:
node-version: '18' node-version: '18'
cache: 'pnpm'
registry-url: http://localhost:4872
- name: Yarn cache directory path - name: Cache node_modules
id: yarn-cache-dir-path id: cache-modules
shell: bash
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: Cache yarn
uses: actions/cache@v3 uses: actions/cache@v3
with: with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} lookup-only: true
key: yarn-${{ hashFiles('yarn.lock') }} path: '**/node_modules'
key: pnpm-${{ hashFiles('pnpm-lock.yaml') }}
- name: Install packages - name: Install packages
run: yarn install --prefer-offline --frozen-lockfile --non-interactive run: pnpm install --frozen-lockfile
- name: Download artifact - name: Download artifact
id: download-artifact id: download-artifact

View File

@ -19,9 +19,6 @@ jobs:
- name: Run a security audit - name: Run a security audit
run: npx audit-ci --critical --report-type summary run: npx audit-ci --critical --report-type summary
- name: Check lock file for invalid hosts
run: npx lockfile-lint -s -n -p yarn.lock -a hosts yarn npm
# - name: Run Dependency confusion supply chain check # - name: Run Dependency confusion supply chain check
# run: npx snync -d . # run: npx snync -d .

View File

@ -15,9 +15,9 @@ jobs:
- host: macos-latest - host: macos-latest
target: x86_64-apple-darwin target: x86_64-apple-darwin
build: | build: |
yarn nx -- run-many --target=build-native -- --target=x86_64-apple-darwin pnpm nx -- run-many --target=build-native -- --target=x86_64-apple-darwin
- host: windows-latest - host: windows-latest
build: yarn nx -- run-many --target=build-native -- --target=x86_64-pc-windows-msvc build: pnpm nx -- run-many --target=build-native -- --target=x86_64-pc-windows-msvc
target: x86_64-pc-windows-msvc target: x86_64-pc-windows-msvc
# Windows 32bit (not needed) # Windows 32bit (not needed)
# - host: windows-latest # - host: windows-latest
@ -29,8 +29,8 @@ jobs:
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
build: |- build: |-
set -e && set -e &&
yarn --version && pnpm --version &&
yarn nx -- run-many --target=build-native -- --target=x86_64-unknown-linux-gnu pnpm nx -- run-many --target=build-native -- --target=x86_64-unknown-linux-gnu
- host: ubuntu-latest - host: ubuntu-latest
target: x86_64-unknown-linux-musl target: x86_64-unknown-linux-musl
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
@ -43,56 +43,63 @@ jobs:
export CXX=$(xcrun -f clang++); export CXX=$(xcrun -f clang++);
SYSROOT=$(xcrun --sdk macosx --show-sdk-path); SYSROOT=$(xcrun --sdk macosx --show-sdk-path);
export CFLAGS="-isysroot $SYSROOT -isystem $SYSROOT"; export CFLAGS="-isysroot $SYSROOT -isystem $SYSROOT";
yarn nx -- run-many --target=build-native -- --target=aarch64-apple-darwin pnpm nx -- run-many --target=build-native -- --target=aarch64-apple-darwin
- host: ubuntu-latest - host: ubuntu-latest
target: aarch64-unknown-linux-gnu target: aarch64-unknown-linux-gnu
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64 docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64
build: |- build: |-
set -e && set -e &&
yarn --version && pnpm --version &&
yarn nx -- run-many --target=build-native -- --target=aarch64-unknown-linux-gnu pnpm nx -- run-many --target=build-native -- --target=aarch64-unknown-linux-gnu
- host: ubuntu-latest - host: ubuntu-latest
target: armv7-unknown-linux-gnueabihf target: armv7-unknown-linux-gnueabihf
setup: | setup: |
sudo apt-get update sudo apt-get update
sudo apt-get install gcc-arm-linux-gnueabihf -y sudo apt-get install gcc-arm-linux-gnueabihf -y
build: | build: |
yarn nx -- run-many --target=build-native -- --target=armv7-unknown-linux-gnueabihf pnpm nx -- run-many --target=build-native -- --target=armv7-unknown-linux-gnueabihf
# Android (not needed) # Android (not needed)
# - host: ubuntu-latest # - host: ubuntu-latest
# target: aarch64-linux-android # target: aarch64-linux-android
# build: | # build: |
# yarn nx -- run-many --target=build-native -- --target=aarch64-linux-android # pnpm nx -- run-many --target=build-native -- --target=aarch64-linux-android
# - host: ubuntu-latest # - host: ubuntu-latest
# target: armv7-linux-androideabi # target: armv7-linux-androideabi
# build: | # build: |
# yarn nx -- run-many --target=build-native -- --target=armv7-linux-androideabi # pnpm nx -- run-many --target=build-native -- --target=armv7-linux-androideabi
- host: ubuntu-latest - host: ubuntu-latest
target: aarch64-unknown-linux-musl target: aarch64-unknown-linux-musl
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
build: |- build: |-
set -e && set -e &&
rustup target add aarch64-unknown-linux-musl && rustup target add aarch64-unknown-linux-musl &&
yarn nx -- run-many --target=build-native -- --target=aarch64-unknown-linux-musl pnpm nx -- run-many --target=build-native -- --target=aarch64-unknown-linux-musl
- host: windows-latest - host: windows-latest
target: aarch64-pc-windows-msvc target: aarch64-pc-windows-msvc
build: yarn nx -- run-many --target=build-native -- --target=aarch64-pc-windows-msvc build: pnpm nx -- run-many --target=build-native -- --target=aarch64-pc-windows-msvc
name: stable - ${{ matrix.settings.target }} - node@18 name: stable - ${{ matrix.settings.target }} - node@18
runs-on: ${{ matrix.settings.host }} runs-on: ${{ matrix.settings.host }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: 8.2
- name: Setup node - name: Setup node
uses: actions/setup-node@v3 uses: actions/setup-node@v3
if: ${{ !matrix.settings.docker }} if: ${{ !matrix.settings.docker }}
with: with:
node-version: 18 node-version: 18
check-latest: true check-latest: true
cache: yarn cache: 'pnpm'
- name: Install - name: Install
uses: dtolnay/rust-toolchain@stable uses: dtolnay/rust-toolchain@stable
if: ${{ !matrix.settings.docker }} if: ${{ !matrix.settings.docker }}
with: with:
targets: ${{ matrix.settings.target }} targets: ${{ matrix.settings.target }}
- name: Cache cargo - name: Cache cargo
uses: actions/cache@v3 uses: actions/cache@v3
with: with:
@ -116,7 +123,7 @@ jobs:
run: yarn config set supportedArchitectures.cpu "ia32" run: yarn config set supportedArchitectures.cpu "ia32"
shell: bash shell: bash
- name: Install dependencies - name: Install dependencies
run: yarn install run: pnpm install --frozen-lockfile
timeout-minutes: 30 timeout-minutes: 30
- name: Setup node x86 - name: Setup node x86
uses: actions/setup-node@v3 uses: actions/setup-node@v3
@ -201,14 +208,17 @@ jobs:
- build - build
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: 8.2
- name: Setup node - name: Setup node
uses: actions/setup-node@v3 uses: actions/setup-node@v3
with: with:
node-version: 18 node-version: 18
check-latest: true check-latest: true
cache: yarn cache: 'pnpm'
- name: Install dependencies - name: Install dependencies
run: yarn install run: pnpm install --frozen-lockfile
- name: Download all artifacts - name: Download all artifacts
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3
with: with:
@ -220,7 +230,7 @@ jobs:
run: | run: |
git checkout -b publish/$GITHUB_REF_NAME git checkout -b publish/$GITHUB_REF_NAME
npm config set //registry.npmjs.org/:_authToken=$NPM_TOKEN npm config set //registry.npmjs.org/:_authToken=$NPM_TOKEN
yarn nx-release --local=false $GITHUB_REF_NAME pnpm nx-release --local=false $GITHUB_REF_NAME
env: env:
GH_TOKEN: ${{ github.token }} GH_TOKEN: ${{ github.token }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

View File

@ -3,6 +3,7 @@ tmp
/build /build
node_modules node_modules
/package.json /package.json
/pnpm-lock.yaml
packages/workspace/src/generators/**/files/**/*.json packages/workspace/src/generators/**/files/**/*.json
packages/angular/src/schematics/**/files/**/*.json packages/angular/src/schematics/**/files/**/*.json
packages/angular/src/migrations/**/files/**/*.json packages/angular/src/migrations/**/files/**/*.json

File diff suppressed because one or more lines are too long

View File

@ -1,2 +0,0 @@
--ignore-engines true
yarnPath .yarn/releases/yarn-1.22.19.cjs

View File

@ -109,7 +109,8 @@ describe('react native', () => {
}); });
if (isOSX()) { if (isOSX()) {
it('should pod install', async () => { // TODO(@meeroslav): this test is causing git-hasher to overflow with arguments. Enable when it's fixed.
xit('should pod install', async () => {
expect(async () => { expect(async () => {
await runCLIAsync(`pod-install ${appName}`); await runCLIAsync(`pod-install ${appName}`);
checkFilesExist(`apps/${appName}/ios/Podfile.lock`); checkFilesExist(`apps/${appName}/ios/Podfile.lock`);

View File

@ -284,20 +284,15 @@ export function packageInstall(
const command = `${ const command = `${
mode === 'dev' ? pm.addDev : pm.addProd mode === 'dev' ? pm.addDev : pm.addProd
} ${pkgsWithVersions}${isVerbose() ? ' --verbose' : ''}`; } ${pkgsWithVersions}`;
try { try {
const install = execSync( const install = execSync(command, {
`${mode === 'dev' ? pm.addDev : pm.addProd} ${pkgsWithVersions}${ cwd,
isVerbose() ? ' --verbose' : '' stdio: isVerbose() ? 'inherit' : 'ignore',
}`, env: process.env,
{ encoding: 'utf-8',
cwd, });
stdio: 'pipe',
env: process.env,
encoding: 'utf-8',
}
);
if (isVerbose()) { if (isVerbose()) {
output.log({ output.log({

View File

@ -15,7 +15,7 @@
"e2e-build-package-publish": "ts-node -P ./scripts/tsconfig.e2e.json ./scripts/e2e-build-package-publish.ts", "e2e-build-package-publish": "ts-node -P ./scripts/tsconfig.e2e.json ./scripts/e2e-build-package-publish.ts",
"nx-release": "ts-node -P ./scripts/tsconfig.release.json ./scripts/nx-release", "nx-release": "ts-node -P ./scripts/tsconfig.release.json ./scripts/nx-release",
"prepublishOnly": "node ./scripts/update-package-group.js", "prepublishOnly": "node ./scripts/update-package-group.js",
"version": "npx prettier lerna.json --write", "version": "pnpm prettier lerna.json --write",
"depcheck": "ts-node -P ./scripts/tsconfig.scripts.json ./scripts/depcheck", "depcheck": "ts-node -P ./scripts/tsconfig.scripts.json ./scripts/depcheck",
"local-registry": "./scripts/local-registry.sh", "local-registry": "./scripts/local-registry.sh",
"documentation": "ts-node -P scripts/tsconfig.scripts.json ./scripts/documentation/generators/main.ts && yarn check-documentation-map", "documentation": "ts-node -P scripts/tsconfig.scripts.json ./scripts/documentation/generators/main.ts && yarn check-documentation-map",
@ -43,8 +43,12 @@
"@babel/helper-create-regexp-features-plugin": "^7.14.5", "@babel/helper-create-regexp-features-plugin": "^7.14.5",
"@babel/preset-react": "^7.14.5", "@babel/preset-react": "^7.14.5",
"@babel/preset-typescript": "^7.15.0", "@babel/preset-typescript": "^7.15.0",
"@cypress/react": "^6.0.0",
"@floating-ui/react": "0.19.2", "@floating-ui/react": "0.19.2",
"@jest/reporters": "^29.4.1",
"@jest/test-result": "^29.4.1",
"@jest/types": "^29.4.1",
"@lerna/publish": "6.0.0",
"@lerna/version": "6.0.0",
"@monodon/rust": "1.1.2", "@monodon/rust": "1.1.2",
"@napi-rs/cli": "2.14.0", "@napi-rs/cli": "2.14.0",
"@nestjs/cli": "^9.0.0", "@nestjs/cli": "^9.0.0",
@ -123,10 +127,11 @@
"browserslist": "^4.21.4", "browserslist": "^4.21.4",
"chalk": "^4.1.0", "chalk": "^4.1.0",
"chokidar": "^3.5.1", "chokidar": "^3.5.1",
"cli-cursor": "3.1.0",
"cli-spinners": "2.6.1",
"confusing-browser-globals": "^1.0.9", "confusing-browser-globals": "^1.0.9",
"conventional-changelog-cli": "^2.0.23", "conventional-changelog-cli": "^2.0.23",
"copy-webpack-plugin": "^10.2.4", "copy-webpack-plugin": "^10.2.4",
"core-js": "^3.6.5",
"css-minimizer-webpack-plugin": "^3.4.1", "css-minimizer-webpack-plugin": "^3.4.1",
"cypress": "^12.2.0", "cypress": "^12.2.0",
"cytoscape": "^3.18.2", "cytoscape": "^3.18.2",
@ -151,8 +156,10 @@
"eslint-plugin-storybook": "^0.6.11", "eslint-plugin-storybook": "^0.6.11",
"express": "^4.18.1", "express": "^4.18.1",
"fast-xml-parser": "^4.0.9", "fast-xml-parser": "^4.0.9",
"figures": "3.2.0",
"file-loader": "^6.2.0", "file-loader": "^6.2.0",
"file-type": "^16.2.0", "file-type": "^16.2.0",
"find-cache-dir": "^3.3.2",
"flat": "^5.0.2", "flat": "^5.0.2",
"fork-ts-checker-webpack-plugin": "7.2.13", "fork-ts-checker-webpack-plugin": "7.2.13",
"fs-extra": "^11.1.0", "fs-extra": "^11.1.0",
@ -167,10 +174,13 @@
"is-ci": "^3.0.0", "is-ci": "^3.0.0",
"is-windows": "^1.0.2", "is-windows": "^1.0.2",
"jasmine-core": "~2.99.1", "jasmine-core": "~2.99.1",
"jasmine-marbles": "~0.8.4",
"jasmine-spec-reporter": "~4.2.1", "jasmine-spec-reporter": "~4.2.1",
"jest": "29.4.3", "jest": "29.4.3",
"jest-config": "^29.4.1",
"jest-environment-jsdom": "29.4.3", "jest-environment-jsdom": "29.4.3",
"jest-resolve": "^29.4.1",
"jest-util": "^29.4.1",
"js-tokens": "^4.0.0",
"js-yaml": "4.1.0", "js-yaml": "4.1.0",
"jsonc-eslint-parser": "^2.1.0", "jsonc-eslint-parser": "^2.1.0",
"jsonc-parser": "3.2.0", "jsonc-parser": "3.2.0",
@ -179,8 +189,8 @@
"less": "4.1.3", "less": "4.1.3",
"less-loader": "11.1.0", "less-loader": "11.1.0",
"license-webpack-plugin": "^4.0.2", "license-webpack-plugin": "^4.0.2",
"lines-and-columns": "~2.0.3",
"loader-utils": "2.0.3", "loader-utils": "2.0.3",
"lockfile-lint": "^4.7.6",
"magic-string": "~0.26.2", "magic-string": "~0.26.2",
"markdown-factory": "^0.0.3", "markdown-factory": "^0.0.3",
"memfs": "^3.0.1", "memfs": "^3.0.1",
@ -209,13 +219,13 @@
"react-router-dom": "6.4.3", "react-router-dom": "6.4.3",
"react-test-renderer": "18.2.0", "react-test-renderer": "18.2.0",
"regenerator-runtime": "0.13.7", "regenerator-runtime": "0.13.7",
"resolve.exports": "1.1.0",
"rollup": "^2.56.2", "rollup": "^2.56.2",
"rollup-plugin-copy": "^3.4.0", "rollup-plugin-copy": "^3.4.0",
"rollup-plugin-peer-deps-external": "^2.2.4", "rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-postcss": "^4.0.1", "rollup-plugin-postcss": "^4.0.1",
"rollup-plugin-typescript2": "0.34.1", "rollup-plugin-typescript2": "0.34.1",
"rxjs": "6.6.7", "rxjs": "6.6.7",
"rxjs-for-await": "0.0.2",
"sass": "1.55.0", "sass": "1.55.0",
"sass-loader": "^12.2.0", "sass-loader": "^12.2.0",
"semver": "7.3.4", "semver": "7.3.4",
@ -244,6 +254,7 @@
"typescript": "~4.9.5", "typescript": "~4.9.5",
"unzipper": "^0.10.11", "unzipper": "^0.10.11",
"url-loader": "^4.1.1", "url-loader": "^4.1.1",
"use-sync-external-store": "^1.2.0",
"verdaccio": "^5.0.4", "verdaccio": "^5.0.4",
"vite": "^4.0.1", "vite": "^4.0.1",
"webpack": "^5.75.0", "webpack": "^5.75.0",
@ -321,7 +332,6 @@
"weak-napi": "^2.0.2" "weak-napi": "^2.0.2"
}, },
"resolutions": { "resolutions": {
"**/xmlhttprequest-ssl": "~1.6.2",
"minimist": "^1.2.6", "minimist": "^1.2.6",
"underscore": "^1.12.1" "underscore": "^1.12.1"
}, },

View File

@ -1,6 +1,5 @@
import type { Tree } from '@nx/devkit'; import type { Tree } from '@nx/devkit';
import { joinPathFragments } from '@nx/devkit'; import { joinPathFragments } from '@nx/devkit';
import type { Ignore } from 'ignore';
import ignore from 'ignore'; import ignore from 'ignore';
export function getAllFilesRecursivelyFromDir( export function getAllFilesRecursivelyFromDir(
@ -26,7 +25,7 @@ export function getAllFilesRecursivelyFromDir(
} }
function isPathIgnored(tree: Tree, path: string): boolean { function isPathIgnored(tree: Tree, path: string): boolean {
let ig: Ignore; let ig: ReturnType<typeof ignore>;
if (tree.exists('.gitignore')) { if (tree.exists('.gitignore')) {
ig = ignore(); ig = ignore();
ig.add(tree.read('.gitignore', 'utf-8')); ig.add(tree.read('.gitignore', 'utf-8'));

View File

@ -18,6 +18,7 @@ jest.mock('@nx/devkit', () => {
return { return {
...jest.requireActual('@nx/devkit'), ...jest.requireActual('@nx/devkit'),
createProjectGraphAsync: jest.fn().mockImplementation(() => projectGraph), createProjectGraphAsync: jest.fn().mockImplementation(() => projectGraph),
readTargetOptions: jest.fn().mockImplementation(() => ({})),
}; };
}); });
jest.mock('../../utils/cypress-version'); jest.mock('../../utils/cypress-version');

View File

@ -1,5 +1,5 @@
import type { Tree } from 'nx/src/generators/tree'; import type { Tree } from 'nx/src/generators/tree';
import ignore, { Ignore } from 'ignore'; import ignore from 'ignore';
import { join, relative, sep } from 'path'; import { join, relative, sep } from 'path';
/** /**
@ -11,7 +11,7 @@ export function visitNotIgnoredFiles(
visitor: (path: string) => void visitor: (path: string) => void
): void { ): void {
// TODO (v17): use packages/nx/src/utils/ignore.ts // TODO (v17): use packages/nx/src/utils/ignore.ts
let ig: Ignore; let ig: ReturnType<typeof ignore>;
if (tree.exists('.gitignore')) { if (tree.exists('.gitignore')) {
ig = ignore(); ig = ignore();
ig.add('.git'); ig.add('.git');

View File

@ -1,7 +1,7 @@
import * as minimatch from 'minimatch'; import * as minimatch from 'minimatch';
import * as path from 'path'; import * as path from 'path';
import * as fse from 'fs-extra'; import * as fse from 'fs-extra';
import ignore, { Ignore } from 'ignore'; import ignore from 'ignore';
import * as fg from 'fast-glob'; import * as fg from 'fast-glob';
import { AssetGlob } from './assets'; import { AssetGlob } from './assets';
import { logger } from '@nx/devkit'; import { logger } from '@nx/devkit';
@ -52,7 +52,7 @@ export class CopyAssetsHandler {
private readonly rootDir: string; private readonly rootDir: string;
private readonly outputDir: string; private readonly outputDir: string;
private readonly assetGlobs: AssetEntry[]; private readonly assetGlobs: AssetEntry[];
private readonly ignore: Ignore; private readonly ignore: ReturnType<typeof ignore>;
private readonly callback: (events: FileEvent[]) => void; private readonly callback: (events: FileEvent[]) => void;
constructor(opts: CopyAssetHandlerOptions) { constructor(opts: CopyAssetHandlerOptions) {

View File

@ -4,14 +4,14 @@ import { dirname, join, relative, resolve } from 'path';
import { readCachedProjectGraph } from 'nx/src/project-graph/project-graph'; import { readCachedProjectGraph } from 'nx/src/project-graph/project-graph';
import { getSourceDirOfDependentProjects } from 'nx/src/utils/project-graph-utils'; import { getSourceDirOfDependentProjects } from 'nx/src/utils/project-graph-utils';
import { existsSync, lstatSync, readdirSync, readFileSync } from 'fs'; import { existsSync, lstatSync, readdirSync, readFileSync } from 'fs';
import ignore, { Ignore } from 'ignore'; import ignore from 'ignore';
import { import {
createProjectRootMappings, createProjectRootMappings,
findProjectForPath, findProjectForPath,
} from 'nx/src/project-graph/utils/find-project-for-path'; } from 'nx/src/project-graph/utils/find-project-for-path';
function configureIgnore() { function configureIgnore() {
let ig: Ignore; let ig: ReturnType<typeof ignore>;
const pathToGitIgnore = join(workspaceRoot, '.gitignore'); const pathToGitIgnore = join(workspaceRoot, '.gitignore');
if (existsSync(pathToGitIgnore)) { if (existsSync(pathToGitIgnore)) {
ig = ignore(); ig = ignore();

View File

@ -50,7 +50,7 @@ export const getGlobalEsLintConfiguration = (
unitTestRunner?: string, unitTestRunner?: string,
rootProject?: boolean rootProject?: boolean
) => { ) => {
const config: ESLint.ConfigData = { const config: LinterType.Config = {
root: true, root: true,
ignorePatterns: rootProject ? ['!**/*'] : ['**/*'], ignorePatterns: rootProject ? ['!**/*'] : ['**/*'],
plugins: ['@nx'], plugins: ['@nx'],

View File

@ -17,8 +17,8 @@ jest.mock('child_process', () => {
return { return {
...jest.requireActual<any>('child_process'), ...jest.requireActual<any>('child_process'),
execSync: jest.fn((command: string) => { execSync: jest.fn((command: string) => {
if (command.includes('yarn --version')) { if (command.includes('pnpm --version')) {
return '1.22.0'; return '8.2.0';
} }
return; return;
}), }),

View File

@ -2,7 +2,7 @@ import { workspaceRoot } from '../utils/workspace-root';
import { performance } from 'perf_hooks'; import { performance } from 'perf_hooks';
import { FileData } from '../config/project-graph'; import { FileData } from '../config/project-graph';
import { join, relative } from 'path'; import { join, relative } from 'path';
import { existsSync, readdirSync, readFileSync, statSync } from 'fs'; import { readdirSync, statSync } from 'fs';
import { FileHasherBase } from './file-hasher-base'; import { FileHasherBase } from './file-hasher-base';
import { stripIndents } from '../utils/strip-indents'; import { stripIndents } from '../utils/strip-indents';
import ignore from 'ignore'; import ignore from 'ignore';
@ -10,7 +10,7 @@ import { normalizePath } from '../utils/path';
import { getIgnoreObject } from '../utils/ignore'; import { getIgnoreObject } from '../utils/ignore';
export class NodeBasedFileHasher extends FileHasherBase { export class NodeBasedFileHasher extends FileHasherBase {
ignoredGlobs = getIgnoredGlobs(); ignoredGlobs: ReturnType<typeof ignore> = getIgnoredGlobs();
async init() { async init() {
performance.mark('init hashing:start'); performance.mark('init hashing:start');
@ -71,7 +71,7 @@ function getIgnoredGlobs() {
node_modules node_modules
tmp tmp
dist dist
build build
`); `);
return ig; return ig;
} }

View File

@ -51,7 +51,7 @@ export function calculateFileChanges(
f: string, f: string,
r: void | string r: void | string
) => string = defaultReadFileAtRevision, ) => string = defaultReadFileAtRevision,
ignore = getIgnoreObject() ignore = getIgnoreObject() as ReturnType<typeof ignore>
): FileChange[] { ): FileChange[] {
files = files.filter((f) => !ignore.ignores(f)); files = files.filter((f) => !ignore.ignores(f));

View File

@ -37,7 +37,9 @@ export function getAlwaysIgnore(root?: string) {
return root ? paths.map((x) => joinPathFragments(root, x)) : paths; return root ? paths.map((x) => joinPathFragments(root, x)) : paths;
} }
export function getIgnoreObject(root: string = workspaceRoot) { export function getIgnoreObject(
root: string = workspaceRoot
): ReturnType<typeof ignore> {
const ig = ignore(); const ig = ignore();
ig.add(readFileIfExisting(`${root}/.gitignore`)); ig.add(readFileIfExisting(`${root}/.gitignore`));
ig.add(readFileIfExisting(`${root}/.nxignore`)); ig.add(readFileIfExisting(`${root}/.nxignore`));

View File

@ -45,7 +45,7 @@ describe('migrate-stories-to-6-2 schematic', () => {
describe('angular project', () => { describe('angular project', () => {
beforeEach(async () => { beforeEach(async () => {
overrideCollectionResolutionForTesting({ overrideCollectionResolutionForTesting({
'@nrwl/storybook': joinPathFragments( '@nx/storybook': joinPathFragments(
__dirname, __dirname,
'../../../../generators.json' '../../../../generators.json'
), ),
@ -64,7 +64,7 @@ describe('migrate-stories-to-6-2 schematic', () => {
writeJson(appTree, 'package.json', { writeJson(appTree, 'package.json', {
devDependencies: { devDependencies: {
'@nrwl/storybook': nxVersion, '@nx/storybook': nxVersion,
'@storybook/addon-knobs': storybookVersion, '@storybook/addon-knobs': storybookVersion,
'@storybook/angular': storybookVersion, '@storybook/angular': storybookVersion,
}, },

View File

@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`lib should generate azure CI config 1`] = ` exports[`CI Workflow generator with npm should generate azure CI config 1`] = `
"name: CI "name: CI
trigger: trigger:
@ -28,7 +28,9 @@ jobs:
pool: pool:
vmImage: 'ubuntu-latest' vmImage: 'ubuntu-latest'
steps: steps:
- script: yarn install --frozen-lockfile - script: npm install --prefix=$HOME/.local -g pnpm@8.2.0
displayName: Install PNPM
- script: pnpm install --frozen-lockfile
displayName: NPM Install Dependencies displayName: NPM Install Dependencies
- script: npx nx-cloud start-agent - script: npx nx-cloud start-agent
displayName: Start Nx-Cloud agent displayName: Start Nx-Cloud agent
@ -38,25 +40,27 @@ jobs:
pool: pool:
vmImage: 'ubuntu-latest' vmImage: 'ubuntu-latest'
steps: steps:
- script: yarn install --frozen-lockfile - script: npm install --prefix=$HOME/.local -g pnpm@8.2.0
displayName: Install PNPM
- script: pnpm install --frozen-lockfile
displayName: NPM Install Dependencies displayName: NPM Install Dependencies
- script: yarn nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3 - script: pnpm exec nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3
displayName: Start CI run displayName: Start CI run
- script: yarn nx-cloud record -- yarn nx format:check --base=$(BASE_SHA) --head=$(HEAD_SHA) - script: pnpm exec nx-cloud record -- pnpm exec nx format:check --base=$(BASE_SHA) --head=$(HEAD_SHA)
displayName: Check format displayName: Check format
- script: yarn nx affected --base=$(BASE_SHA) --head=$(HEAD_SHA) --target=lint --parallel=3 - script: pnpm exec nx affected --base=$(BASE_SHA) --head=$(HEAD_SHA) --target=lint --parallel=3
displayName: Run lint displayName: Run lint
- script: yarn nx affected --base=$(BASE_SHA) --head=$(HEAD_SHA) --target=test --parallel=3 --ci --code-coverage - script: pnpm exec nx affected --base=$(BASE_SHA) --head=$(HEAD_SHA) --target=test --parallel=3 --ci --code-coverage
displayName: Run test displayName: Run test
- script: yarn nx affected --base=$(BASE_SHA) --head=$(HEAD_SHA) --target=build --parallel=3 - script: pnpm exec nx affected --base=$(BASE_SHA) --head=$(HEAD_SHA) --target=build --parallel=3
displayName: Run build displayName: Run build
- script: yarn nx-cloud stop-all-agents - script: pnpm exec nx-cloud stop-all-agents
condition: always() condition: always()
displayName: Stop all Nx-Cloud agents displayName: Stop all Nx-Cloud agents
" "
`; `;
exports[`lib should generate bitbucket pipelines config 1`] = ` exports[`CI Workflow generator with npm should generate bitbucket pipelines config 1`] = `
"image: node:16.18 "image: node:16.18
clone: clone:
@ -69,8 +73,10 @@ definitions:
script: script:
- export NX_BRANCH=$BITBUCKET_PR_ID - export NX_BRANCH=$BITBUCKET_PR_ID
- yarn install --frozen-lockfile - npm install --prefix=$HOME/.local -g pnpm@8.2.0
- yarn nx-cloud start-agent
- pnpm install --frozen-lockfile
- pnpm exec nx-cloud start-agent
pipelines: pipelines:
pull-requests: pull-requests:
@ -81,18 +87,20 @@ pipelines:
script: script:
- export NX_BRANCH=$BITBUCKET_PR_ID - export NX_BRANCH=$BITBUCKET_PR_ID
- yarn install --frozen-lockfile - npm install --prefix=$HOME/.local -g pnpm@8.2.0
- yarn nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3
- yarn nx-cloud record -- yarn nx format:check - pnpm install --frozen-lockfile
- yarn nx affected --target=lint & yarn nx affected --target=test & yarn nx affected --target=build - pnpm exec nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3
- yarn nx-cloud stop-all-agents - pnpm exec nx-cloud record -- yarn nx format:check
- pnpm exec nx affected --target=lint & pnpm exec nx affected --target=test & pnpm exec nx affected --target=build
- pnpm exec nx-cloud stop-all-agents
- step: *agent - step: *agent
- step: *agent - step: *agent
- step: *agent - step: *agent
" "
`; `;
exports[`lib should generate circleci CI config 1`] = ` exports[`CI Workflow generator with npm should generate circleci CI config 1`] = `
"version: 2.1 "version: 2.1
orbs: orbs:
@ -107,12 +115,16 @@ jobs:
type: integer type: integer
steps: steps:
- checkout - checkout
- run:
name: Install PNPM
command: npm install --prefix=$HOME/.local -g pnpm@8.2.0
- run: - run:
name: Install dependencies name: Install dependencies
command: yarn install --frozen-lockfile command: pnpm install --frozen-lockfile
- run: - run:
name: Start the agent << parameters.ordinal >> name: Start the agent << parameters.ordinal >>
command: yarn nx-cloud start-agent command: pnpm exec nx-cloud start-agent
no_output_timeout: 60m no_output_timeout: 60m
main: main:
docker: docker:
@ -121,29 +133,33 @@ jobs:
NX_CLOUD_DISTRIBUTED_EXECUTION: 'true' NX_CLOUD_DISTRIBUTED_EXECUTION: 'true'
steps: steps:
- checkout - checkout
- run:
name: Install PNPM
command: npm install --prefix=$HOME/.local -g pnpm@8.2.0
- run: - run:
name: Install dependencies name: Install dependencies
command: yarn install --frozen-lockfile command: pnpm install --frozen-lockfile
- nx/set-shas: - nx/set-shas:
main-branch-name: 'main' main-branch-name: 'main'
- run: - run:
name: Initialize the Nx Cloud distributed CI run name: Initialize the Nx Cloud distributed CI run
command: yarn nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3 command: pnpm exec nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3
- run: - run:
name: Check format name: Check format
command: yarn nx-cloud record -- yarn nx format:check --base=$NX_BASE --head=$NX_HEAD command: pnpm exec nx-cloud record -- pnpm exec nx format:check --base=$NX_BASE --head=$NX_HEAD
- run: - run:
name: Run lint name: Run lint
command: yarn nx affected --base=$NX_BASE --head=$NX_HEAD --target=lint --parallel=3 command: pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=lint --parallel=3
- run: - run:
name: Run test name: Run test
command: yarn nx affected --base=$NX_BASE --head=$NX_HEAD --target=test --parallel=3 --ci --code-coverage command: pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=test --parallel=3 --ci --code-coverage
- run: - run:
name: Run build name: Run build
command: yarn nx affected --base=$NX_BASE --head=$NX_HEAD --target=build --parallel=3 command: pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=build --parallel=3
- run: - run:
name: Stop all agents name: Stop all agents
command: yarn nx-cloud stop-all-agents command: pnpm exec nx-cloud stop-all-agents
when: always when: always
workflows: workflows:
@ -161,7 +177,7 @@ workflows:
" "
`; `;
exports[`lib should generate github CI config 1`] = ` exports[`CI Workflow generator with npm should generate github CI config 1`] = `
"name: CI "name: CI
on: on:
@ -178,13 +194,13 @@ jobs:
main-branch-name: main main-branch-name: main
number-of-agents: 3 number-of-agents: 3
init-commands: | init-commands: |
yarn nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3 pnpm exec nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3
parallel-commands: | parallel-commands: |
yarn nx-cloud record -- yarn nx format:check pnpm exec nx-cloud record -- pnpm exec nx format:check
parallel-commands-on-agents: | parallel-commands-on-agents: |
yarn nx affected --target=lint --parallel=3 pnpm exec nx affected --target=lint --parallel=3
yarn nx affected --target=test --parallel=3 --ci --code-coverage pnpm exec nx affected --target=test --parallel=3 --ci --code-coverage
yarn nx affected --target=build --parallel=3 pnpm exec nx affected --target=build --parallel=3
agents: agents:
name: Nx Cloud - Agents name: Nx Cloud - Agents
@ -194,7 +210,7 @@ jobs:
" "
`; `;
exports[`lib should generate github CI config with custom name 1`] = ` exports[`CI Workflow generator with npm should generate github CI config with custom name 1`] = `
"name: My custom-workflow "name: My custom-workflow
on: on:
@ -211,13 +227,13 @@ jobs:
main-branch-name: main main-branch-name: main
number-of-agents: 3 number-of-agents: 3
init-commands: | init-commands: |
yarn nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3 pnpm exec nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3
parallel-commands: | parallel-commands: |
yarn nx-cloud record -- yarn nx format:check pnpm exec nx-cloud record -- pnpm exec nx format:check
parallel-commands-on-agents: | parallel-commands-on-agents: |
yarn nx affected --target=lint --parallel=3 pnpm exec nx affected --target=lint --parallel=3
yarn nx affected --target=test --parallel=3 --ci --code-coverage pnpm exec nx affected --target=test --parallel=3 --ci --code-coverage
yarn nx affected --target=build --parallel=3 pnpm exec nx affected --target=build --parallel=3
agents: agents:
name: Nx Cloud - Agents name: Nx Cloud - Agents
@ -227,7 +243,7 @@ jobs:
" "
`; `;
exports[`lib should generate gitlab config 1`] = ` exports[`CI Workflow generator with npm should generate gitlab config 1`] = `
"image: node:18 "image: node:18
variables: variables:
CI: 'true' CI: 'true'
@ -236,8 +252,10 @@ variables:
.dte-agent: .dte-agent:
interruptible: true interruptible: true
script: script:
- yarn install --frozen-lockfile - npm install --prefix=$HOME/.local -g pnpm@8.2.0
- yarn nx-cloud start-agent
- pnpm install --frozen-lockfile
- pnpm exec nx-cloud start-agent
# Creating template for a job running DTE (orchestrator) # Creating template for a job running DTE (orchestrator)
.base-pipeline: .base-pipeline:
@ -246,7 +264,9 @@ variables:
- main - main
- merge_requests - merge_requests
before_script: before_script:
- yarn install --frozen-lockfile - npm install --prefix=$HOME/.local -g pnpm@8.2.0
- pnpm install --frozen-lockfile
- NX_HEAD=$CI_COMMIT_SHA - NX_HEAD=$CI_COMMIT_SHA
- NX_BASE=\${CI_MERGE_REQUEST_DIFF_BASE_SHA:-$CI_COMMIT_BEFORE_SHA} - NX_BASE=\${CI_MERGE_REQUEST_DIFF_BASE_SHA:-$CI_COMMIT_BEFORE_SHA}
@ -255,9 +275,9 @@ CI:
stage: affected stage: affected
extends: .base-pipeline extends: .base-pipeline
script: script:
- yarn nx-cloud start-ci-run --stop-agents-after="build" - pnpm exec nx-cloud start-ci-run --stop-agents-after="build"
- yarn nx-cloud record -- yarn nx format:check --base=$NX_BASE --head=$NX_HEAD - pnpm exec nx-cloud record -- pnpm exec nx format:check --base=$NX_BASE --head=$NX_HEAD
- yarn nx affected --base=$NX_BASE --head=$NX_HEAD --target=lint --parallel=3 & yarn nx affected --base=$NX_BASE --head=$NX_HEAD --target=test --parallel=3 --ci --code-coverage & yarn nx affected --base=$NX_BASE --head=$NX_HEAD --target=e2e --parallel=3 --ci --code-coverage & yarn nx affected --base=$NX_BASE --head=$NX_HEAD --target=build --parallel=3 - pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=lint --parallel=3 & pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=test --parallel=3 --ci --code-coverage & pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=e2e --parallel=3 --ci --code-coverage & pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=build --parallel=3
# Create as many agents as you want # Create as many agents as you want
nx-dte-agent1: nx-dte-agent1:
@ -272,4 +292,592 @@ nx-dte-agent3:
" "
`; `;
exports[`lib should throw error is nx cloud is not set 1`] = `"This workspace is not connected to Nx Cloud."`; exports[`CI Workflow generator with npm should throw error is nx cloud is not set 1`] = `"This workspace is not connected to Nx Cloud."`;
exports[`CI Workflow generator with pnpm should generate azure CI config 1`] = `
"name: CI
trigger:
- main
pr:
- main
variables:
CI: 'true'
NX_CLOUD_DISTRIBUTED_EXECUTION: 'true'
\${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
NX_BRANCH: $(System.PullRequest.PullRequestNumber)
TARGET_BRANCH: $[replace(variables['System.PullRequest.TargetBranch'],'refs/heads/','origin/')]
BASE_SHA: $(git merge-base $(TARGET_BRANCH) HEAD)
\${{ if ne(variables['Build.Reason'], 'PullRequest') }}:
NX_BRANCH: $(Build.SourceBranchName)
BASE_SHA: $(git rev-parse HEAD~1)
HEAD_SHA: $(git rev-parse HEAD)
jobs:
- job: agents
strategy:
parallel: 3
displayName: Nx Cloud Agent
pool:
vmImage: 'ubuntu-latest'
steps:
- script: npm install --prefix=$HOME/.local -g pnpm@8.2.0
displayName: Install PNPM
- script: pnpm install --frozen-lockfile
displayName: NPM Install Dependencies
- script: npx nx-cloud start-agent
displayName: Start Nx-Cloud agent
- job: main
displayName: Nx Cloud Main
pool:
vmImage: 'ubuntu-latest'
steps:
- script: npm install --prefix=$HOME/.local -g pnpm@8.2.0
displayName: Install PNPM
- script: pnpm install --frozen-lockfile
displayName: NPM Install Dependencies
- script: pnpm exec nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3
displayName: Start CI run
- script: pnpm exec nx-cloud record -- pnpm exec nx format:check --base=$(BASE_SHA) --head=$(HEAD_SHA)
displayName: Check format
- script: pnpm exec nx affected --base=$(BASE_SHA) --head=$(HEAD_SHA) --target=lint --parallel=3
displayName: Run lint
- script: pnpm exec nx affected --base=$(BASE_SHA) --head=$(HEAD_SHA) --target=test --parallel=3 --ci --code-coverage
displayName: Run test
- script: pnpm exec nx affected --base=$(BASE_SHA) --head=$(HEAD_SHA) --target=build --parallel=3
displayName: Run build
- script: pnpm exec nx-cloud stop-all-agents
condition: always()
displayName: Stop all Nx-Cloud agents
"
`;
exports[`CI Workflow generator with pnpm should generate bitbucket pipelines config 1`] = `
"image: node:16.18
clone:
depth: full
definitions:
steps:
- step: &agent
name: Agent
script:
- export NX_BRANCH=$BITBUCKET_PR_ID
- npm install --prefix=$HOME/.local -g pnpm@8.2.0
- pnpm install --frozen-lockfile
- pnpm exec nx-cloud start-agent
pipelines:
pull-requests:
'**':
- parallel:
- step:
name: CI
script:
- export NX_BRANCH=$BITBUCKET_PR_ID
- npm install --prefix=$HOME/.local -g pnpm@8.2.0
- pnpm install --frozen-lockfile
- pnpm exec nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3
- pnpm exec nx-cloud record -- yarn nx format:check
- pnpm exec nx affected --target=lint & pnpm exec nx affected --target=test & pnpm exec nx affected --target=build
- pnpm exec nx-cloud stop-all-agents
- step: *agent
- step: *agent
- step: *agent
"
`;
exports[`CI Workflow generator with pnpm should generate circleci CI config 1`] = `
"version: 2.1
orbs:
nx: nrwl/nx@1.6.1
jobs:
agent:
docker:
- image: cimg/node:lts-browsers
parameters:
ordinal:
type: integer
steps:
- checkout
- run:
name: Install PNPM
command: npm install --prefix=$HOME/.local -g pnpm@8.2.0
- run:
name: Install dependencies
command: pnpm install --frozen-lockfile
- run:
name: Start the agent << parameters.ordinal >>
command: pnpm exec nx-cloud start-agent
no_output_timeout: 60m
main:
docker:
- image: cimg/node:lts-browsers
environment:
NX_CLOUD_DISTRIBUTED_EXECUTION: 'true'
steps:
- checkout
- run:
name: Install PNPM
command: npm install --prefix=$HOME/.local -g pnpm@8.2.0
- run:
name: Install dependencies
command: pnpm install --frozen-lockfile
- nx/set-shas:
main-branch-name: 'main'
- run:
name: Initialize the Nx Cloud distributed CI run
command: pnpm exec nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3
- run:
name: Check format
command: pnpm exec nx-cloud record -- pnpm exec nx format:check --base=$NX_BASE --head=$NX_HEAD
- run:
name: Run lint
command: pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=lint --parallel=3
- run:
name: Run test
command: pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=test --parallel=3 --ci --code-coverage
- run:
name: Run build
command: pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=build --parallel=3
- run:
name: Stop all agents
command: pnpm exec nx-cloud stop-all-agents
when: always
workflows:
version: 2
ci:
jobs:
- agent:
name: Nx Cloud Agent << matrix.ordinal >>
matrix:
parameters:
ordinal: [1, 2, 3]
- main:
name: Nx Cloud Main
"
`;
exports[`CI Workflow generator with pnpm should generate github CI config 1`] = `
"name: CI
on:
push:
branches:
- main
pull_request:
jobs:
main:
name: Nx Cloud - Main Job
uses: nrwl/ci/.github/workflows/nx-cloud-main.yml@v0.11.3
with:
main-branch-name: main
number-of-agents: 3
init-commands: |
pnpm exec nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3
parallel-commands: |
pnpm exec nx-cloud record -- pnpm exec nx format:check
parallel-commands-on-agents: |
pnpm exec nx affected --target=lint --parallel=3
pnpm exec nx affected --target=test --parallel=3 --ci --code-coverage
pnpm exec nx affected --target=build --parallel=3
agents:
name: Nx Cloud - Agents
uses: nrwl/ci/.github/workflows/nx-cloud-agents.yml@v0.11.3
with:
number-of-agents: 3
"
`;
exports[`CI Workflow generator with pnpm should generate github CI config with custom name 1`] = `
"name: My custom-workflow
on:
push:
branches:
- main
pull_request:
jobs:
main:
name: Nx Cloud - Main Job
uses: nrwl/ci/.github/workflows/nx-cloud-main.yml@v0.11.3
with:
main-branch-name: main
number-of-agents: 3
init-commands: |
pnpm exec nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3
parallel-commands: |
pnpm exec nx-cloud record -- pnpm exec nx format:check
parallel-commands-on-agents: |
pnpm exec nx affected --target=lint --parallel=3
pnpm exec nx affected --target=test --parallel=3 --ci --code-coverage
pnpm exec nx affected --target=build --parallel=3
agents:
name: Nx Cloud - Agents
uses: nrwl/ci/.github/workflows/nx-cloud-agents.yml@v0.11.3
with:
number-of-agents: 3
"
`;
exports[`CI Workflow generator with pnpm should generate gitlab config 1`] = `
"image: node:18
variables:
CI: 'true'
# Creating template for DTE agents
.dte-agent:
interruptible: true
script:
- npm install --prefix=$HOME/.local -g pnpm@8.2.0
- pnpm install --frozen-lockfile
- pnpm exec nx-cloud start-agent
# Creating template for a job running DTE (orchestrator)
.base-pipeline:
interruptible: true
only:
- main
- merge_requests
before_script:
- npm install --prefix=$HOME/.local -g pnpm@8.2.0
- pnpm install --frozen-lockfile
- NX_HEAD=$CI_COMMIT_SHA
- NX_BASE=\${CI_MERGE_REQUEST_DIFF_BASE_SHA:-$CI_COMMIT_BEFORE_SHA}
# Main job running DTE
CI:
stage: affected
extends: .base-pipeline
script:
- pnpm exec nx-cloud start-ci-run --stop-agents-after="build"
- pnpm exec nx-cloud record -- pnpm exec nx format:check --base=$NX_BASE --head=$NX_HEAD
- pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=lint --parallel=3 & pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=test --parallel=3 --ci --code-coverage & pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=e2e --parallel=3 --ci --code-coverage & pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=build --parallel=3
# Create as many agents as you want
nx-dte-agent1:
extends: .dte-agent
stage: affected
nx-dte-agent2:
extends: .dte-agent
stage: affected
nx-dte-agent3:
extends: .dte-agent
stage: affected
"
`;
exports[`CI Workflow generator with pnpm should throw error is nx cloud is not set 1`] = `"This workspace is not connected to Nx Cloud."`;
exports[`CI Workflow generator with yarn should generate azure CI config 1`] = `
"name: CI
trigger:
- main
pr:
- main
variables:
CI: 'true'
NX_CLOUD_DISTRIBUTED_EXECUTION: 'true'
\${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
NX_BRANCH: $(System.PullRequest.PullRequestNumber)
TARGET_BRANCH: $[replace(variables['System.PullRequest.TargetBranch'],'refs/heads/','origin/')]
BASE_SHA: $(git merge-base $(TARGET_BRANCH) HEAD)
\${{ if ne(variables['Build.Reason'], 'PullRequest') }}:
NX_BRANCH: $(Build.SourceBranchName)
BASE_SHA: $(git rev-parse HEAD~1)
HEAD_SHA: $(git rev-parse HEAD)
jobs:
- job: agents
strategy:
parallel: 3
displayName: Nx Cloud Agent
pool:
vmImage: 'ubuntu-latest'
steps:
- script: npm install --prefix=$HOME/.local -g pnpm@8.2.0
displayName: Install PNPM
- script: pnpm install --frozen-lockfile
displayName: NPM Install Dependencies
- script: npx nx-cloud start-agent
displayName: Start Nx-Cloud agent
- job: main
displayName: Nx Cloud Main
pool:
vmImage: 'ubuntu-latest'
steps:
- script: npm install --prefix=$HOME/.local -g pnpm@8.2.0
displayName: Install PNPM
- script: pnpm install --frozen-lockfile
displayName: NPM Install Dependencies
- script: pnpm exec nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3
displayName: Start CI run
- script: pnpm exec nx-cloud record -- pnpm exec nx format:check --base=$(BASE_SHA) --head=$(HEAD_SHA)
displayName: Check format
- script: pnpm exec nx affected --base=$(BASE_SHA) --head=$(HEAD_SHA) --target=lint --parallel=3
displayName: Run lint
- script: pnpm exec nx affected --base=$(BASE_SHA) --head=$(HEAD_SHA) --target=test --parallel=3 --ci --code-coverage
displayName: Run test
- script: pnpm exec nx affected --base=$(BASE_SHA) --head=$(HEAD_SHA) --target=build --parallel=3
displayName: Run build
- script: pnpm exec nx-cloud stop-all-agents
condition: always()
displayName: Stop all Nx-Cloud agents
"
`;
exports[`CI Workflow generator with yarn should generate bitbucket pipelines config 1`] = `
"image: node:16.18
clone:
depth: full
definitions:
steps:
- step: &agent
name: Agent
script:
- export NX_BRANCH=$BITBUCKET_PR_ID
- npm install --prefix=$HOME/.local -g pnpm@8.2.0
- pnpm install --frozen-lockfile
- pnpm exec nx-cloud start-agent
pipelines:
pull-requests:
'**':
- parallel:
- step:
name: CI
script:
- export NX_BRANCH=$BITBUCKET_PR_ID
- npm install --prefix=$HOME/.local -g pnpm@8.2.0
- pnpm install --frozen-lockfile
- pnpm exec nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3
- pnpm exec nx-cloud record -- yarn nx format:check
- pnpm exec nx affected --target=lint & pnpm exec nx affected --target=test & pnpm exec nx affected --target=build
- pnpm exec nx-cloud stop-all-agents
- step: *agent
- step: *agent
- step: *agent
"
`;
exports[`CI Workflow generator with yarn should generate circleci CI config 1`] = `
"version: 2.1
orbs:
nx: nrwl/nx@1.6.1
jobs:
agent:
docker:
- image: cimg/node:lts-browsers
parameters:
ordinal:
type: integer
steps:
- checkout
- run:
name: Install PNPM
command: npm install --prefix=$HOME/.local -g pnpm@8.2.0
- run:
name: Install dependencies
command: pnpm install --frozen-lockfile
- run:
name: Start the agent << parameters.ordinal >>
command: pnpm exec nx-cloud start-agent
no_output_timeout: 60m
main:
docker:
- image: cimg/node:lts-browsers
environment:
NX_CLOUD_DISTRIBUTED_EXECUTION: 'true'
steps:
- checkout
- run:
name: Install PNPM
command: npm install --prefix=$HOME/.local -g pnpm@8.2.0
- run:
name: Install dependencies
command: pnpm install --frozen-lockfile
- nx/set-shas:
main-branch-name: 'main'
- run:
name: Initialize the Nx Cloud distributed CI run
command: pnpm exec nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3
- run:
name: Check format
command: pnpm exec nx-cloud record -- pnpm exec nx format:check --base=$NX_BASE --head=$NX_HEAD
- run:
name: Run lint
command: pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=lint --parallel=3
- run:
name: Run test
command: pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=test --parallel=3 --ci --code-coverage
- run:
name: Run build
command: pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=build --parallel=3
- run:
name: Stop all agents
command: pnpm exec nx-cloud stop-all-agents
when: always
workflows:
version: 2
ci:
jobs:
- agent:
name: Nx Cloud Agent << matrix.ordinal >>
matrix:
parameters:
ordinal: [1, 2, 3]
- main:
name: Nx Cloud Main
"
`;
exports[`CI Workflow generator with yarn should generate github CI config 1`] = `
"name: CI
on:
push:
branches:
- main
pull_request:
jobs:
main:
name: Nx Cloud - Main Job
uses: nrwl/ci/.github/workflows/nx-cloud-main.yml@v0.11.3
with:
main-branch-name: main
number-of-agents: 3
init-commands: |
pnpm exec nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3
parallel-commands: |
pnpm exec nx-cloud record -- pnpm exec nx format:check
parallel-commands-on-agents: |
pnpm exec nx affected --target=lint --parallel=3
pnpm exec nx affected --target=test --parallel=3 --ci --code-coverage
pnpm exec nx affected --target=build --parallel=3
agents:
name: Nx Cloud - Agents
uses: nrwl/ci/.github/workflows/nx-cloud-agents.yml@v0.11.3
with:
number-of-agents: 3
"
`;
exports[`CI Workflow generator with yarn should generate github CI config with custom name 1`] = `
"name: My custom-workflow
on:
push:
branches:
- main
pull_request:
jobs:
main:
name: Nx Cloud - Main Job
uses: nrwl/ci/.github/workflows/nx-cloud-main.yml@v0.11.3
with:
main-branch-name: main
number-of-agents: 3
init-commands: |
pnpm exec nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3
parallel-commands: |
pnpm exec nx-cloud record -- pnpm exec nx format:check
parallel-commands-on-agents: |
pnpm exec nx affected --target=lint --parallel=3
pnpm exec nx affected --target=test --parallel=3 --ci --code-coverage
pnpm exec nx affected --target=build --parallel=3
agents:
name: Nx Cloud - Agents
uses: nrwl/ci/.github/workflows/nx-cloud-agents.yml@v0.11.3
with:
number-of-agents: 3
"
`;
exports[`CI Workflow generator with yarn should generate gitlab config 1`] = `
"image: node:18
variables:
CI: 'true'
# Creating template for DTE agents
.dte-agent:
interruptible: true
script:
- npm install --prefix=$HOME/.local -g pnpm@8.2.0
- pnpm install --frozen-lockfile
- pnpm exec nx-cloud start-agent
# Creating template for a job running DTE (orchestrator)
.base-pipeline:
interruptible: true
only:
- main
- merge_requests
before_script:
- npm install --prefix=$HOME/.local -g pnpm@8.2.0
- pnpm install --frozen-lockfile
- NX_HEAD=$CI_COMMIT_SHA
- NX_BASE=\${CI_MERGE_REQUEST_DIFF_BASE_SHA:-$CI_COMMIT_BEFORE_SHA}
# Main job running DTE
CI:
stage: affected
extends: .base-pipeline
script:
- pnpm exec nx-cloud start-ci-run --stop-agents-after="build"
- pnpm exec nx-cloud record -- pnpm exec nx format:check --base=$NX_BASE --head=$NX_HEAD
- pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=lint --parallel=3 & pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=test --parallel=3 --ci --code-coverage & pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=e2e --parallel=3 --ci --code-coverage & pnpm exec nx affected --base=$NX_BASE --head=$NX_HEAD --target=build --parallel=3
# Create as many agents as you want
nx-dte-agent1:
extends: .dte-agent
stage: affected
nx-dte-agent2:
extends: .dte-agent
stage: affected
nx-dte-agent3:
extends: .dte-agent
stage: affected
"
`;
exports[`CI Workflow generator with yarn should throw error is nx cloud is not set 1`] = `"This workspace is not connected to Nx Cloud."`;

View File

@ -8,80 +8,95 @@ import {
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing'; import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
import { ciWorkflowGenerator } from './ci-workflow'; import { ciWorkflowGenerator } from './ci-workflow';
describe('lib', () => { describe('CI Workflow generator', () => {
let tree: Tree; let tree: Tree;
beforeEach(() => { beforeEach(() => {
tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' }); tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
}); });
it('should generate github CI config', async () => { ['npm', 'yarn', 'pnpm'].forEach((packageManager) => {
setNxCloud(tree); describe(`with ${packageManager}`, () => {
await ciWorkflowGenerator(tree, { ci: 'github' }); beforeEach(() => {
jest.mock('@nx/devkit', () => ({
...jest.requireActual<any>('@nx/devkit'),
detectPackageManager: jest
.fn()
.mockImplementation(() => packageManager),
}));
});
expect(tree.read('.github/workflows/ci.yml', 'utf-8')).toMatchSnapshot(); it('should generate github CI config', async () => {
}); setNxCloud(tree);
await ciWorkflowGenerator(tree, { ci: 'github' });
it('should generate circleci CI config', async () => { expect(
setNxCloud(tree); tree.read('.github/workflows/ci.yml', 'utf-8')
await ciWorkflowGenerator(tree, { ci: 'circleci' }); ).toMatchSnapshot();
});
expect(tree.read('.circleci/config.yml', 'utf-8')).toMatchSnapshot(); it('should generate circleci CI config', async () => {
}); setNxCloud(tree);
await ciWorkflowGenerator(tree, { ci: 'circleci' });
it('should generate azure CI config', async () => { expect(tree.read('.circleci/config.yml', 'utf-8')).toMatchSnapshot();
setNxCloud(tree); });
await ciWorkflowGenerator(tree, { ci: 'azure' });
expect(tree.read('azure-pipelines.yml', 'utf-8')).toMatchSnapshot(); it('should generate azure CI config', async () => {
}); setNxCloud(tree);
await ciWorkflowGenerator(tree, { ci: 'azure' });
it('should generate github CI config with custom name', async () => { expect(tree.read('azure-pipelines.yml', 'utf-8')).toMatchSnapshot();
setNxCloud(tree); });
await ciWorkflowGenerator(tree, {
ci: 'github', it('should generate github CI config with custom name', async () => {
name: 'My custom-workflow', setNxCloud(tree);
await ciWorkflowGenerator(tree, {
ci: 'github',
name: 'My custom-workflow',
});
expect(
tree.read('.github/workflows/my-custom-workflow.yml', 'utf-8')
).toMatchSnapshot();
});
it('should generate bitbucket pipelines config', async () => {
setNxCloud(tree);
await ciWorkflowGenerator(tree, { ci: 'bitbucket-pipelines' });
expect(tree.read('bitbucket-pipelines.yml', 'utf-8')).toMatchSnapshot();
});
it('should prefix nx.json affected defaultBase with origin/ if ci is bitbucket-pipelines', async () => {
setNxCloud(tree);
const nxJson = readJson(tree, 'nx.json');
nxJson.affected.defaultBase = 'my-branch';
writeJson(tree, 'nx.json', nxJson);
await ciWorkflowGenerator(tree, { ci: 'bitbucket-pipelines' });
expect(readJson(tree, 'nx.json').affected.defaultBase).toEqual(
'origin/my-branch'
);
});
it('should generate gitlab config', async () => {
setNxCloud(tree);
await ciWorkflowGenerator(tree, { ci: 'gitlab' });
expect(tree.read('.gitlab-ci.yml', 'utf-8')).toMatchSnapshot();
});
it('should throw error is nx cloud is not set', async () => {
await expect(
ciWorkflowGenerator(tree, {
ci: 'github',
})
).rejects.toThrowErrorMatchingSnapshot();
});
}); });
expect(
tree.read('.github/workflows/my-custom-workflow.yml', 'utf-8')
).toMatchSnapshot();
});
it('should generate bitbucket pipelines config', async () => {
setNxCloud(tree);
await ciWorkflowGenerator(tree, { ci: 'bitbucket-pipelines' });
expect(tree.read('bitbucket-pipelines.yml', 'utf-8')).toMatchSnapshot();
});
it('should prefix nx.json affected defaultBase with origin/ if ci is bitbucket-pipelines', async () => {
setNxCloud(tree);
const nxJson = readJson(tree, 'nx.json');
nxJson.affected.defaultBase = 'my-branch';
writeJson(tree, 'nx.json', nxJson);
await ciWorkflowGenerator(tree, { ci: 'bitbucket-pipelines' });
expect(readJson(tree, 'nx.json').affected.defaultBase).toEqual(
'origin/my-branch'
);
});
it('should generate gitlab config', async () => {
setNxCloud(tree);
await ciWorkflowGenerator(tree, { ci: 'gitlab' });
expect(tree.read('.gitlab-ci.yml', 'utf-8')).toMatchSnapshot();
});
it('should throw error is nx cloud is not set', async () => {
await expect(
ciWorkflowGenerator(tree, {
ci: 'github',
})
).rejects.toThrowErrorMatchingSnapshot();
}); });
}); });

View File

@ -26,7 +26,7 @@ jobs:
vmImage: 'ubuntu-latest' vmImage: 'ubuntu-latest'
steps: steps:
<% if(packageManagerPrefix == 'pnpm exec'){ %> <% if(packageManagerPrefix == 'pnpm exec'){ %>
- script: npm install --prefix=$HOME/.local -g pnpm@6.32.4 - script: npm install --prefix=$HOME/.local -g pnpm@8.2.0
displayName: Install PNPM displayName: Install PNPM
<% } %>- script: <%= packageManagerInstall %> <% } %>- script: <%= packageManagerInstall %>
displayName: NPM Install Dependencies displayName: NPM Install Dependencies
@ -39,7 +39,7 @@ jobs:
vmImage: 'ubuntu-latest' vmImage: 'ubuntu-latest'
steps: steps:
<% if(packageManagerPrefix == 'pnpm exec'){ %> <% if(packageManagerPrefix == 'pnpm exec'){ %>
- script: npm install --prefix=$HOME/.local -g pnpm@6.32.4 - script: npm install --prefix=$HOME/.local -g pnpm@8.2.0
displayName: Install PNPM displayName: Install PNPM
<% } %>- script: <%= packageManagerInstall %> <% } %>- script: <%= packageManagerInstall %>
displayName: NPM Install Dependencies displayName: NPM Install Dependencies

View File

@ -10,7 +10,7 @@ definitions:
script: script:
- export NX_BRANCH=$BITBUCKET_PR_ID - export NX_BRANCH=$BITBUCKET_PR_ID
<% if(packageManagerPrefix == 'pnpm exec'){ %> <% if(packageManagerPrefix == 'pnpm exec'){ %>
- npm install --prefix=$HOME/.local -g pnpm@6.32.4 - npm install --prefix=$HOME/.local -g pnpm@8.2.0
<% } %> <% } %>
- <%= packageManagerInstall %> - <%= packageManagerInstall %>
- <%= packageManagerPrefix %> nx-cloud start-agent - <%= packageManagerPrefix %> nx-cloud start-agent
@ -24,7 +24,7 @@ pipelines:
script: script:
- export NX_BRANCH=$BITBUCKET_PR_ID - export NX_BRANCH=$BITBUCKET_PR_ID
<% if(packageManagerPrefix == 'pnpm exec'){ %> <% if(packageManagerPrefix == 'pnpm exec'){ %>
- npm install --prefix=$HOME/.local -g pnpm@6.32.4 - npm install --prefix=$HOME/.local -g pnpm@8.2.0
<% } %> <% } %>
- <%= packageManagerInstall %> - <%= packageManagerInstall %>
- <%= packageManagerPrefix %> nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3 - <%= packageManagerPrefix %> nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3

View File

@ -15,7 +15,7 @@ jobs:
<% if(packageManagerPrefix == 'pnpm exec'){ %> <% if(packageManagerPrefix == 'pnpm exec'){ %>
- run: - run:
name: Install PNPM name: Install PNPM
command: npm install --prefix=$HOME/.local -g pnpm@6.32.4 command: npm install --prefix=$HOME/.local -g pnpm@8.2.0
<% } %>- run: <% } %>- run:
name: Install dependencies name: Install dependencies
command: <%= packageManagerInstall %> command: <%= packageManagerInstall %>
@ -33,7 +33,7 @@ jobs:
<% if(packageManagerPrefix == 'pnpm exec'){ %> <% if(packageManagerPrefix == 'pnpm exec'){ %>
- run: - run:
name: Install PNPM name: Install PNPM
command: npm install --prefix=$HOME/.local -g pnpm@6.32.4 command: npm install --prefix=$HOME/.local -g pnpm@8.2.0
<% } %>- run: <% } %>- run:
name: Install dependencies name: Install dependencies
command: <%= packageManagerInstall %> command: <%= packageManagerInstall %>

View File

@ -7,7 +7,7 @@ variables:
interruptible: true interruptible: true
script: script:
<% if(packageManagerPrefix == 'pnpm exec'){ %> <% if(packageManagerPrefix == 'pnpm exec'){ %>
- npm install --prefix=$HOME/.local -g pnpm@6.32.4 - npm install --prefix=$HOME/.local -g pnpm@8.2.0
<% } %> <% } %>
- <%= packageManagerInstall %> - <%= packageManagerInstall %>
- <%= packageManagerPrefix %> nx-cloud start-agent - <%= packageManagerPrefix %> nx-cloud start-agent
@ -20,7 +20,7 @@ variables:
- merge_requests - merge_requests
before_script: before_script:
<% if(packageManagerPrefix == 'pnpm exec'){ %> <% if(packageManagerPrefix == 'pnpm exec'){ %>
- npm install --prefix=$HOME/.local -g pnpm@6.32.4 - npm install --prefix=$HOME/.local -g pnpm@8.2.0
<% } %> <% } %>
- <%= packageManagerInstall %> - <%= packageManagerInstall %>
- NX_HEAD=$CI_COMMIT_SHA - NX_HEAD=$CI_COMMIT_SHA

View File

@ -5,7 +5,7 @@ import {
SchematicContext, SchematicContext,
Tree, Tree,
} from '@angular-devkit/schematics'; } from '@angular-devkit/schematics';
import ignore, { Ignore } from 'ignore'; import ignore from 'ignore';
/** /**
* @deprecated This will be removed in v17. Prefer writing Nx Generators with @nx/devkit. This function can be replaced with 'visitNotIgnoredFiles' from @nx/devkit. * @deprecated This will be removed in v17. Prefer writing Nx Generators with @nx/devkit. This function can be replaced with 'visitNotIgnoredFiles' from @nx/devkit.
@ -15,7 +15,7 @@ export function visitNotIgnoredFiles(
dir: Path = normalize('') dir: Path = normalize('')
): Rule { ): Rule {
return (host, context) => { return (host, context) => {
let ig: Ignore | undefined; let ig: ReturnType<typeof ignore> | undefined;
if (host.exists('.gitignore')) { if (host.exists('.gitignore')) {
ig = ignore(); ig = ignore();
ig.add(host.read('.gitignore').toString()); ig.add(host.read('.gitignore').toString());

28521
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -4,32 +4,28 @@ function checkLockFiles() {
const errors = []; const errors = [];
if (fs.existsSync('package-lock.json')) { if (fs.existsSync('package-lock.json')) {
errors.push( errors.push(
'Invalid occurence of "package-lock.json" file. Please remove it and use only "yarn.lock"' 'Invalid occurence of "package-lock.json" file. Please remove it and use only "pnpm-lock.yaml"'
); );
} }
if (fs.existsSync('pnpm-lock.yaml')) { if (fs.existsSync('yarn.lock')) {
errors.push( errors.push(
'Invalid occurence of "pnpm-lock.yaml" file. Please remove it and use only "yarn.lock"' 'Invalid occurence of "yarn.lock" file. Please remove it and use only "pnpm-lock.yaml"'
); );
} }
try { try {
const content = fs.readFileSync('yarn.lock', 'utf-8'); const content = fs.readFileSync('pnpm-lock.yaml', 'utf-8');
if (content.match(/localhost:487/)) { if (content.match(/localhost:487/)) {
errors.push( errors.push(
'The "yarn.lock" has reference to local yarn repository ("localhost:4873"). Please use "registry.yarnpkg.com" in "yarn.lock"' 'The "pnpm-lock.yaml" has reference to local repository ("localhost:4873"). Please use ensure you disable local registry before running "pnpm install"'
);
}
if (content.match(/resolution: \{tarball/)) {
errors.push(
'The "pnpm-lock.yaml" has reference to tarball package. Please use npm registry only'
); );
} }
} catch { } catch {
errors.push('The "yarn.lock" does not exist or cannot be read'); errors.push('The "pnpm-lock.yaml" does not exist or cannot be read');
}
try {
require('child_process').execSync(
'yarn lockfile-lint -s -n -p yarn.lock -a hosts yarn npm',
{ encoding: 'utf-8', stdio: 'pipe' }
);
} catch ({ stderr }) {
const errorLines = stderr.split('\n').slice(0, -4).join('\n');
errors.push(errorLines);
} }
return errors; return errors;
} }

View File

@ -7,7 +7,7 @@ process.env.npm_config_registry = `http://localhost:4872`;
process.env.YARN_REGISTRY = process.env.npm_config_registry; process.env.YARN_REGISTRY = process.env.npm_config_registry;
async function buildPackagePublishAndCleanPorts() { async function buildPackagePublishAndCleanPorts() {
if (!process.env.NX_E2E_SKIP_BUILD_CLEANUP) { if (process.env.NX_E2E_SKIP_BUILD_CLEANUP !== 'true') {
if (!process.env.CI) { if (!process.env.CI) {
console.log( console.log(
stripIndent(` stripIndent(`
@ -29,7 +29,10 @@ async function buildPackagePublishAndCleanPorts() {
remove('./tmp/local-registry'), remove('./tmp/local-registry'),
]); ]);
} }
if (!process.env.NX_E2E_SKIP_BUILD_CLEANUP || !existsSync('./build')) { if (
process.env.NX_E2E_SKIP_BUILD_CLEANUP !== 'true' ||
!existsSync('./build')
) {
try { try {
await updateVersionsAndPublishPackages(); await updateVersionsAndPublishPackages();
} catch (e) { } catch (e) {
@ -46,7 +49,7 @@ async function updateVersionsAndPublishPackages() {
const isVerbose = const isVerbose =
process.env.NX_VERBOSE_LOGGING === 'true' || process.env.NX_VERBOSE_LOGGING === 'true' ||
process.argv.includes('--verbose'); process.argv.includes('--verbose');
const response = execSync(`yarn nx-release major --local`, { const response = execSync(`pnpm nx-release major --local`, {
stdio: isVerbose ? 'inherit' : 'pipe', stdio: isVerbose ? 'inherit' : 'pipe',
encoding: 'utf8', encoding: 'utf8',
}); });

View File

@ -1,7 +1,7 @@
const { exec } = require('child_process'); const { exec } = require('child_process');
const verdacio = exec( const verdacio = exec(
'yarn verdaccio --config ./scripts/local-registry/config.yml' 'pnpm verdaccio --config ./scripts/local-registry/config.yml'
); );
verdacio.unref(); verdacio.unref();

View File

@ -60,7 +60,7 @@ async function generateGraph(directory: string, name: string) {
(async () => { (async () => {
const parsedArgs = yargs const parsedArgs = yargs
.scriptName('yarn generate-graph') .scriptName('pnpm generate-graph')
.strictOptions() .strictOptions()
.option('name', { .option('name', {
type: 'string', type: 'string',

View File

@ -4,7 +4,7 @@ COMMAND=$1
if [[ $COMMAND == "enable" ]]; then if [[ $COMMAND == "enable" ]]; then
echo "Setting registry to local registry" echo "Setting registry to local registry"
echo "To Disable: yarn local-registry disable" echo "To Disable: pnpm local-registry disable"
npm config set registry http://localhost:4873/ --location user npm config set registry http://localhost:4873/ --location user
yarn config set registry http://localhost:4873/ yarn config set registry http://localhost:4873/
fi fi
@ -28,5 +28,5 @@ fi
if [[ $COMMAND == "start" ]]; then if [[ $COMMAND == "start" ]]; then
echo "Starting Local Registry" echo "Starting Local Registry"
VERDACCIO_HANDLE_KILL_SIGNALS=true VERDACCIO_HANDLE_KILL_SIGNALS=true
yarn verdaccio --config ./.verdaccio/config.yml pnpm verdaccio --config ./.verdaccio/config.yml
fi fi

View File

@ -7,8 +7,8 @@ import { join } from 'path';
import { parse } from 'semver'; import { parse } from 'semver';
import * as version from '@lerna/version/index'; import * as version from '@lerna/version';
import * as publish from '@lerna/publish/index'; import * as publish from '@lerna/publish';
const lernaJsonPath = join(__dirname, '../lerna.json'); const lernaJsonPath = join(__dirname, '../lerna.json');
const originalLernaJson = readFileSync(lernaJsonPath); const originalLernaJson = readFileSync(lernaJsonPath);
@ -26,7 +26,7 @@ function hideFromGitIndex(uncommittedFiles: string[]) {
const options = parseArgs(); const options = parseArgs();
if (options.clearLocalRegistry) { if (options.clearLocalRegistry) {
execSync('yarn local-registry clear'); execSync('pnpm local-registry clear');
} }
const currentLatestVersion = execSync('npm view nx version') const currentLatestVersion = execSync('npm view nx version')
@ -43,7 +43,7 @@ function hideFromGitIndex(uncommittedFiles: string[]) {
? 'previous' ? 'previous'
: 'latest'; : 'latest';
const buildCommand = 'yarn build'; const buildCommand = 'pnpm build';
console.log(`> ${buildCommand}`); console.log(`> ${buildCommand}`);
execSync(buildCommand, { execSync(buildCommand, {
stdio: [0, 1, 2], stdio: [0, 1, 2],
@ -150,7 +150,7 @@ function hideFromGitIndex(uncommittedFiles: string[]) {
function parseArgs() { function parseArgs() {
const parsedArgs = yargs const parsedArgs = yargs
.scriptName('yarn nx-release') .scriptName('pnpm nx-release')
.wrap(144) .wrap(144)
.strictOptions() .strictOptions()
.version(false) .version(false)
@ -228,7 +228,7 @@ function parseArgs() {
} }
if (!args.force && registryIsLocalhost) { if (!args.force && registryIsLocalhost) {
throw new Error( throw new Error(
'Registry is still set to localhost! Run "yarn local-registry disable" or pass --force' 'Registry is still set to localhost! Run "pnpm local-registry disable" or pass --force'
); );
} }
} else { } else {

24113
yarn.lock

File diff suppressed because it is too large Load Diff