chore: use pnpm for framework monorepo (#7895)

Co-authored-by: Pooya Parsa <pooya@pi0.io>
This commit is contained in:
Daniel Roe 2022-10-17 11:10:05 +01:00 committed by GitHub
parent 9388e65971
commit 74a90c566c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 9413 additions and 16368 deletions

View File

@ -3,12 +3,12 @@ name: CI
on: on:
push: push:
paths-ignore: paths-ignore:
- 'docs/**' - "docs/**"
branches: branches:
- main - main
pull_request: pull_request:
paths-ignore: paths-ignore:
- 'docs/**' - "docs/**"
branches: branches:
- main - main
@ -25,16 +25,17 @@ jobs:
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- run: corepack enable
- uses: actions/setup-node@v3 - uses: actions/setup-node@v3
with: with:
node-version: ${{ matrix.node }} node-version: ${{ matrix.node }}
cache: 'yarn' cache: "pnpm"
- name: Install dependencies - name: Install dependencies
run: yarn --immutable run: pnpm install
- name: Build - name: Build
run: yarn build run: pnpm build
- name: Cache dist - name: Cache dist
uses: actions/cache@v3 uses: actions/cache@v3
@ -54,16 +55,17 @@ jobs:
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- run: corepack enable
- uses: actions/setup-node@v3 - uses: actions/setup-node@v3
with: with:
node-version: ${{ matrix.node }} node-version: ${{ matrix.node }}
cache: 'yarn' cache: "pnpm"
- name: Install dependencies - name: Install dependencies
run: yarn --immutable run: pnpm install
- name: Lint - name: Lint
run: yarn lint run: pnpm lint
typecheck: typecheck:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
@ -77,19 +79,20 @@ jobs:
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- run: corepack enable
- uses: actions/setup-node@v3 - uses: actions/setup-node@v3
with: with:
node-version: ${{ matrix.node }} node-version: ${{ matrix.node }}
cache: 'yarn' cache: "pnpm"
- name: Install dependencies - name: Install dependencies
run: yarn --immutable run: pnpm install
- name: Stub - name: Build (stub)
run: yarn stub run: pnpm build:stub
- name: Typecheck - name: Typecheck
run: yarn typecheck run: pnpm typecheck
test-fixtures: test-fixtures:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
@ -103,25 +106,47 @@ jobs:
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- run: corepack enable
- uses: actions/setup-node@v3 - uses: actions/setup-node@v3
with: with:
node-version: ${{ matrix.node }} node-version: ${{ matrix.node }}
cache: 'yarn' cache: "pnpm"
- name: Install dependencies - name: Install dependencies
run: yarn --immutable run: pnpm install
- name: Stub # https://github.com/vitejs/vite/blob/main/.github/workflows/ci.yml#L62
run: yarn stub # Install playwright's binary under custom directory to cache
- name: Set Playwright path
if: runner.os != 'Windows'
run: echo "PLAYWRIGHT_BROWSERS_PATH=$HOME/.cache/playwright-bin" >> $GITHUB_ENV
- name: Set Playwright path (windows)
if: runner.os == 'Windows'
run: echo "PLAYWRIGHT_BROWSERS_PATH=$HOME\.cache\playwright-bin" >> $env:GITHUB_ENV
- name: Cache Playwright's binary
uses: actions/cache@v3
with:
# Playwright removes unused browsers automatically
# So does not need to add playwright version to key
key: ${{ runner.os }}-playwright-bin-v1
path: ${{ env.PLAYWRIGHT_BROWSERS_PATH }}
- name: Install Playwright
# does not need to explicitly set chromium after https://github.com/microsoft/playwright/issues/14862 is solved
run: pnpm playwright install chromium
- name: Build (stub)
run: pnpm build:stub
- name: Test (unit) - name: Test (unit)
run: yarn test:unit run: pnpm test:unit
- name: Test (fixtures) - name: Test (fixtures)
run: yarn test:fixtures run: pnpm test:fixtures
- name: Test (fixtures with dev) - name: Test (fixtures with dev)
run: yarn test:fixtures:dev run: pnpm test:fixtures:dev
env: env:
NODE_OPTIONS: --max-old-space-size=8192 NODE_OPTIONS: --max-old-space-size=8192
@ -137,19 +162,41 @@ jobs:
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- run: corepack enable
- uses: actions/setup-node@v3 - uses: actions/setup-node@v3
with: with:
node-version: ${{ matrix.node }} node-version: ${{ matrix.node }}
cache: 'yarn' cache: "pnpm"
- name: Install dependencies - name: Install dependencies
run: yarn --immutable run: pnpm install
- name: Stub # https://github.com/vitejs/vite/blob/main/.github/workflows/ci.yml#L62
run: yarn stub # Install playwright's binary under custom directory to cache
- name: Set Playwright path (non-windows)
if: runner.os != 'Windows'
run: echo "PLAYWRIGHT_BROWSERS_PATH=$HOME/.cache/playwright-bin" >> $GITHUB_ENV
- name: Set Playwright path (windows)
if: runner.os == 'Windows'
run: echo "PLAYWRIGHT_BROWSERS_PATH=$HOME\.cache\playwright-bin" >> $env:GITHUB_ENV
- name: Cache Playwright's binary
uses: actions/cache@v3
with:
# Playwright removes unused browsers automatically
# So does not need to add playwright version to key
key: ${{ runner.os }}-playwright-bin-v1
path: ${{ env.PLAYWRIGHT_BROWSERS_PATH }}
- name: Install Playwright
# does not need to explicitly set chromium after https://github.com/microsoft/playwright/issues/14862 is solved
run: pnpm playwright install chromium
- name: Build (stub)
run: pnpm build:stub
- name: Test (fixtures) - name: Test (fixtures)
run: yarn test:fixtures:webpack run: pnpm test:fixtures:webpack
test-types: test-types:
needs: needs:
@ -165,13 +212,14 @@ jobs:
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- run: corepack enable
- uses: actions/setup-node@v3 - uses: actions/setup-node@v3
with: with:
node-version: ${{ matrix.node }} node-version: ${{ matrix.node }}
cache: 'yarn' cache: "pnpm"
- name: Install dependencies - name: Install dependencies
run: yarn --immutable run: pnpm install
- name: Restore dist cache - name: Restore dist cache
uses: actions/cache@v3 uses: actions/cache@v3
@ -180,7 +228,7 @@ jobs:
key: ${{ matrix.os }}-node-v${{ matrix.node }}-${{ github.sha }} key: ${{ matrix.os }}-node-v${{ matrix.node }}-${{ github.sha }}
- name: Test (types) - name: Test (types)
run: yarn test:types run: pnpm test:types
build-release: build-release:
if: | if: |
@ -205,13 +253,14 @@ jobs:
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- run: corepack enable
- uses: actions/setup-node@v3 - uses: actions/setup-node@v3
with: with:
node-version: ${{ matrix.node }} node-version: ${{ matrix.node }}
cache: 'yarn' cache: "pnpm"
- name: Install dependencies - name: Install dependencies
run: yarn --immutable run: pnpm install
- name: Restore dist cache - name: Restore dist cache
uses: actions/cache@v3 uses: actions/cache@v3

View File

@ -19,13 +19,14 @@ jobs:
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- run: corepack enable
- uses: actions/setup-node@v3 - uses: actions/setup-node@v3
with: with:
node-version: ${{ matrix.node }} node-version: ${{ matrix.node }}
cache: "yarn" cache: "pnpm"
- name: Install dependencies - name: Install dependencies
run: yarn --immutable run: pnpm install
- run: node ./scripts/crawl.mjs - run: node ./scripts/crawl.mjs
env: env:

View File

@ -3,14 +3,14 @@ name: Docs
on: on:
push: push:
paths: paths:
- 'docs/**' - "docs/**"
- '.github/workflows/docs.yml' - ".github/workflows/docs.yml"
branches: branches:
- main - main
pull_request: pull_request:
paths: paths:
- 'docs/**' - "docs/**"
- '.github/workflows/docs.yml' - ".github/workflows/docs.yml"
branches: branches:
- main - main
@ -25,13 +25,14 @@ jobs:
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- run: corepack enable
- uses: actions/setup-node@v3 - uses: actions/setup-node@v3
with: with:
node-version: ${{ matrix.node }} node-version: ${{ matrix.node }}
cache: 'yarn' cache: "pnpm"
- name: Install dependencies - name: Install dependencies
run: yarn --immutable run: pnpm install
- name: Lint (docs) - name: Lint (docs)
run: yarn lint:docs run: pnpm lint:docs

7
.gitignore vendored
View File

@ -3,7 +3,8 @@ node_modules
jspm_packages jspm_packages
package-lock.json package-lock.json
# */**/yarn.lock */**/yarn.lock
/.yarn
# Logs # Logs
*.log *.log
@ -13,10 +14,6 @@ package-lock.json
.tmp .tmp
.cache .cache
# Yarn
**/.yarn/cache
**/.yarn/*state*
# Generated dirs # Generated dirs
dist dist
.nuxt .nuxt

View File

@ -1,8 +1,8 @@
tasks: tasks:
- init: | - init: |
npx yarn install npx pnpm install
npx yarn stub npx pnpm build:stub
command: npx yarn play command: npx pnpm play
ports: ports:
- port: 3000 - port: 3000

3
.npmrc Normal file
View File

@ -0,0 +1,3 @@
shamefully-hoist=true
strict-peer-dependencies=false
shell-emulator=true

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,11 +0,0 @@
nmMode: hardlinks-local
nodeLinker: node-modules
plugins:
- path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs
spec: "@yarnpkg/plugin-typescript"
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"
yarnPath: .yarn/releases/yarn-3.2.4.cjs

View File

@ -44,28 +44,9 @@ Nuxt's goal is to make web development intuitive and performant with a great dev
</tbody> </tbody>
</table> </table>
## 💻 Development ## Local Development
- Clone repository Follow the docs to [Set Up Your Local Development Environment](https://v3.nuxtjs.org/community/framework-contribution#set-up-your-local-development-environment) to contribute to the framework and documentation.
- Ensure you have the latest LTS version of Node.js installed
- Install dependencies with `npx yarn install`
- Run `npx yarn stub` to activate passive development
- Open playground with `npx yarn dev`
Learn more about in our documentation on [how to contribute to Nuxt](https://v3.nuxtjs.org/community/contribution).
## 📖 Documentation
We are using [Docus](https://nuxtlabs.com/docus) for documentation (*It is planned to be open sourced in the following weeks*).
We recommend to install the [Docus extension](https://marketplace.visualstudio.com/items?itemName=NuxtLabs.docus) for VS Code.
- Run `npx yarn stub` once in the root directory
- Go into the docs directory: `cd docs`
- Install docs dependencies with `npx yarn install`
- Run `npx yarn dev` to start Docus in development mode
The pages are generated from [docs/content/](./docs/content), you can start editing them to start helping us on documenting Nuxt 3 💚
## License ## License

4
docs/.gitignore vendored
View File

@ -2,3 +2,7 @@ schema
**/*.configuration/nuxt.config.md **/*.configuration/nuxt.config.md
**/*.configuration/nuxt-config.md **/*.configuration/nuxt-config.md
static/sw.js static/sw.js
.yarn/*
!.yarn/releases
!yarn.lock

View File

@ -1 +1,3 @@
nmMode: hardlinks-local
nodeLinker: node-modules
yarnPath: .yarn/releases/yarn-3.2.4.cjs yarnPath: .yarn/releases/yarn-3.2.4.cjs

View File

@ -64,13 +64,13 @@ To contribute to Nuxt, you need to set up a local environment.
1. Ensure using the latest Node.js (16.x) 1. Ensure using the latest Node.js (16.x)
1. Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable` 1. Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable` to have `pnpm` and `yarn`
1. Run `yarn install` to install the dependencies. 1. Run `pnpm install` to install the dependencies.
> If you are adding a dependency, please use `yarn add`. The `yarn.lock` file is the source of truth for all Nuxt dependencies. > If you are adding a dependency, please use `pnpm add`. The `pnpm-lock.yaml` file is the source of truth for all Nuxt dependencies.
1. Run `yarn stub` to activate the passive development system 1. Run `pnpm build:stub` to activate the passive development system
1. Check out a branch where you can work and commit your changes: 1. Check out a branch where you can work and commit your changes:
@ -86,7 +86,11 @@ git checkout -b my-new-branch
### Set Up Documentation Website in Local Environment ### Set Up Documentation Website in Local Environment
1. Follow steps to set up [local development environment](#set-up-your-local-development-environment) We are using [Docus](https://nuxtlabs.com/docus) for documentation.
1. Change to the `docs/` directory using `cd docs/`
1. Install docs dependencies using `yarn install` - Run `pnpm build:stub` once in the root directory
1. Start docs in development mode using `yarn dev` - Go into the docs directory: `cd docs`
- Install docs dependencies using `yarn install`
- Run `yarn dev` to start docs in development mode
We recommend to install the [Docus extension](https://marketplace.visualstudio.com/items?itemName=NuxtLabs.docus) for VS Code.

View File

@ -2,8 +2,12 @@ import { join } from 'pathe'
export default defineNuxtConfig({ export default defineNuxtConfig({
extends: process.env.WEBSITE_THEME ? join(process.env.WEBSITE_THEME, 'theme') : '@nuxt-themes/website', extends: process.env.WEBSITE_THEME ? join(process.env.WEBSITE_THEME, 'theme') : '@nuxt-themes/website',
build: {
transpile: [/content-edge/]
},
nitro: { nitro: {
prerender: { prerender: {
crawlLinks: true,
routes: ['/', '/404.html', '/guide/directory-structure/app.config'] routes: ['/', '/404.html', '/guide/directory-structure/app.config']
} }
} }

View File

@ -3,17 +3,18 @@
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "yarn gendocs && nuxi dev", "dev": "yarn gendocs && nuxi dev",
"build": "yarn gendocs && nuxi generate --force-build", "build": "yarn gendocs && nuxi generate",
"build:ci": "./scripts/make-schema.sh && yarn build", "build:ci": "cd .. && corepack enable && pnpm install && pnpm build:stub && cd docs && yarn build",
"lint:docs": "cd .. && yarn lint:docs",
"lint:docs:fix": "cd .. && yarn lint:docs:fix",
"gendocs": "jiti ./scripts/gen-docs.ts" "gendocs": "jiti ./scripts/gen-docs.ts"
}, },
"dependencies": { "devDependencies": {
"@nuxt-themes/docus": "npm:@nuxt-themes/docus-edge@0.1.0-2a7c428", "@nuxt-themes/docus": "npm:@nuxt-themes/docus-edge@0.1.0-2a7c428",
"@nuxt-themes/website": "0.1.6", "@nuxt-themes/website": "0.1.6",
"jiti": "^1.16.0", "jiti": "^1.16.0",
"nuxt": "^3.0.0-rc.11" "nuxt": "^3.0.0-rc.11",
"pathe": "^0.3.9",
"scule": "^0.3.2",
"untyped": "^0.5.0"
}, },
"packageManager": "yarn@3.2.4" "packageManager": "yarn@3.2.4"
} }

View File

@ -1,7 +0,0 @@
#!/bin/sh
set -e
cd ..
yarn install
cd packages/schema
yarn prepack --stub

View File

@ -3498,6 +3498,9 @@ __metadata:
"@nuxt-themes/website": 0.1.6 "@nuxt-themes/website": 0.1.6
jiti: ^1.16.0 jiti: ^1.16.0
nuxt: ^3.0.0-rc.11 nuxt: ^3.0.0-rc.11
pathe: ^0.3.9
scule: ^0.3.2
untyped: ^0.5.0
languageName: unknown languageName: unknown
linkType: soft linkType: soft
@ -7534,6 +7537,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"pathe@npm:^0.3.9":
version: 0.3.9
resolution: "pathe@npm:0.3.9"
checksum: 9afcbaa79c5f8ec603b6b0a20b9accfcec8de57e26738f4a844de4625cfb07cc733b7234387ef42c7ab23a49b91846b6b51cb247584793842a3179539af463df
languageName: node
linkType: hard
"perfect-debounce@npm:^0.1.3": "perfect-debounce@npm:^0.1.3":
version: 0.1.3 version: 0.1.3
resolution: "perfect-debounce@npm:0.1.3" resolution: "perfect-debounce@npm:0.1.3"

View File

@ -1,24 +0,0 @@
{
"version": "3.0.0-rc.11",
"npmClient": "yarn",
"useWorkspaces": true,
"conventionalCommits": true,
"packages": [
"packages/*"
],
"command": {
"publish": {
"npmClient": "npm"
}
},
"changelog": {
"labels": {
"feat": "New Feature",
"fix": "Bug Fix",
"docs": "Documentation",
"types": "Types",
"perf": "Performance",
"refactor": "Refactor"
}
}
}

View File

@ -1,54 +1,50 @@
{ {
"name": "nuxt-framework", "name": "nuxt-framework",
"private": true, "private": true,
"repository": "nuxt/framework",
"license": "MIT", "license": "MIT",
"type": "module", "type": "module",
"workspaces": [
"packages/*",
"examples/*/*",
"test/fixtures/*",
"playground"
],
"scripts": { "scripts": {
"build": "FORCE_COLOR=1 lerna run prepack --stream --no-prefix", "build": "FORCE_COLOR=1 pnpm --filter './packages/**' prepack",
"changelog": "changelogen", "build:stub": "pnpm --filter './packages/**' prepack --stub",
"cleanup": "rimraf 'packages/**/node_modules' 'examples/**/node_modules' 'node_modules'", "cleanup": "rimraf 'packages/**/node_modules' 'examples/**/node_modules' 'docs/node_modules' 'playground/node_modules' 'node_modules'",
"dev": "yarn run nuxi dev playground", "example": "./scripts/example.sh dev",
"dev:build": "yarn run nuxi build playground", "example:build": "./scripts/example.sh build",
"dev:preview": "yarn run nuxi preview playground",
"example": "yarn workspace example-$0 dev",
"example:build": "yarn workspace example-$0 build",
"lint": "eslint --ext .vue,.ts,.js,.mjs .", "lint": "eslint --ext .vue,.ts,.js,.mjs .",
"lint:docs": "markdownlint ./docs/content && case-police 'docs/content**/*.md'", "lint:docs": "markdownlint ./docs/content && case-police 'docs/content**/*.md'",
"lint:docs:fix": "markdownlint ./docs/content --fix && case-police 'docs/content**/*.md' --fix", "lint:docs:fix": "markdownlint ./docs/content --fix && case-police 'docs/content**/*.md' --fix",
"nuxi": "NUXT_TELEMETRY_DISABLED=1 JITI_ESM_RESOLVE=1 node ./packages/nuxi/bin/nuxi.mjs", "nuxi": "NUXT_TELEMETRY_DISABLED=1 JITI_ESM_RESOLVE=1 nuxi",
"nuxt": "NUXT_TELEMETRY_DISABLED=1 JITI_ESM_RESOLVE=1 node ./packages/nuxi/bin/nuxi.mjs", "nuxt": "NUXT_TELEMETRY_DISABLED=1 JITI_ESM_RESOLVE=1 nuxi",
"play": "echo use yarn dev && exit 1", "play": "pnpm nuxi build playground",
"release": "yarn && yarn lint && FORCE_COLOR=1 lerna publish -m \"chore: release\" && yarn stub", "play:build": "pnpm nuxi build playground",
"stub": "lerna run prepack -- --stub", "play:preview": "pnpm nuxi preview playground",
"test:fixtures": "NUXT_TELEMETRY_DISABLED=1 yarn nuxi prepare test/fixtures/basic && JITI_ESM_RESOLVE=1 vitest run --dir test", "test:fixtures": "NUXT_TELEMETRY_DISABLED=1 pnpm nuxi prepare test/fixtures/basic && JITI_ESM_RESOLVE=1 vitest run --dir test",
"test:fixtures:dev": "NUXT_TELEMETRY_DISABLED=1 NUXT_TEST_DEV=true yarn test:fixtures", "test:fixtures:dev": "NUXT_TELEMETRY_DISABLED=1 NUXT_TEST_DEV=true pnpm test:fixtures",
"test:fixtures:webpack": "NUXT_TELEMETRY_DISABLED=1 TEST_WITH_WEBPACK=1 yarn test:fixtures", "test:fixtures:webpack": "NUXT_TELEMETRY_DISABLED=1 TEST_WITH_WEBPACK=1 pnpm test:fixtures",
"test:types": "yarn run nuxi prepare test/fixtures/basic && cd test/fixtures/basic && npx vue-tsc --noEmit", "test:types": "pnpm nuxi prepare test/fixtures/basic && cd test/fixtures/basic && npx vue-tsc --noEmit",
"test:unit": "JITI_ESM_RESOLVE=1 yarn vitest run --dir packages", "test:unit": "JITI_ESM_RESOLVE=1 vitest run --dir packages",
"typecheck": "tsc --noEmit", "typecheck": "tsc --noEmit"
"version": "yarn && git add yarn.lock"
}, },
"resolutions": { "resolutions": {
"@nuxt/kit": "link:./packages/kit", "@nuxt/kit": "workspace:*",
"@nuxt/schema": "link:./packages/schema", "@nuxt/schema": "workspace:*",
"@nuxt/test-utils": "link:./packages/test-utils", "@nuxt/test-utils": "workspace:*",
"@nuxt/vite-builder": "link:./packages/vite", "@nuxt/vite-builder": "workspace:*",
"@nuxt/webpack-builder": "link:./packages/webpack", "@nuxt/webpack-builder": "workspace:*",
"nuxi": "link:./packages/nuxi", "nuxi": "workspace:*",
"nuxt": "link:./packages/nuxt", "nuxt": "workspace:*",
"nuxt3": "link:./packages/nuxt", "nuxt3": "workspace:nuxt@*",
"unbuild": "^0.9.4",
"vite": "^3.1.8", "vite": "^3.1.8",
"unbuild": "^0.9.4" "vue": "3.2.40"
}, },
"devDependencies": { "devDependencies": {
"@actions/core": "^1.10.0", "@actions/core": "^1.10.0",
"@nuxt/test-utils": "link:./packages/test-utils", "@nuxt/kit": "workspace:*",
"@nuxt/schema": "workspace:*",
"@nuxt/test-utils": "workspace:*",
"@nuxt/vite-builder": "workspace:*",
"@nuxt/webpack-builder": "workspace:*",
"@nuxtjs/eslint-config-typescript": "^11.0.0", "@nuxtjs/eslint-config-typescript": "^11.0.0",
"@types/crawler": "^1.2.2", "@types/crawler": "^1.2.2",
"@types/node": "^16.11.65", "@types/node": "^16.11.65",
@ -64,8 +60,9 @@
"expect-type": "^0.14.2", "expect-type": "^0.14.2",
"globby": "^13.1.2", "globby": "^13.1.2",
"jiti": "^1.16.0", "jiti": "^1.16.0",
"lerna": "^6.0.1",
"markdownlint-cli": "^0.32.2", "markdownlint-cli": "^0.32.2",
"nuxi": "workspace:*",
"nuxt": "workspace:*",
"ohmyfetch": "^0.4.19", "ohmyfetch": "^0.4.19",
"pathe": "^0.3.9", "pathe": "^0.3.9",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
@ -78,7 +75,7 @@
"vitest": "~0.19.1", "vitest": "~0.19.1",
"vue-tsc": "^1.0.8" "vue-tsc": "^1.0.8"
}, },
"packageManager": "yarn@3.2.4", "packageManager": "pnpm@7.12.0",
"engines": { "engines": {
"node": "^14.16.0 || ^16.10.0 || ^17.0.0 || ^18.0.0" "node": "^14.16.0 || ^16.10.0 || ^17.0.0 || ^18.0.0"
} }

View File

@ -5,5 +5,8 @@
"dev": "nuxi dev", "dev": "nuxi dev",
"build": "nuxi build", "build": "nuxi build",
"start": "nuxi preview" "start": "nuxi preview"
},
"dependencies": {
"nuxt": "workspace:*"
} }
} }

9108
pnpm-lock.yaml Normal file

File diff suppressed because it is too large Load Diff

5
pnpm-workspace.yaml Normal file
View File

@ -0,0 +1,5 @@
packages:
- "packages/**"
- "examples/**"
- "playground"
- "text/fixtures/*"

94
scripts/_utils.ts Normal file
View File

@ -0,0 +1,94 @@
import { promises as fsp } from 'node:fs'
import { resolve } from 'pathe'
import { globby } from 'globby'
export interface Dep {
name: string,
range: string,
type: string
}
type ThenArg<T> = T extends PromiseLike<infer U> ? U : T
export type Package = ThenArg<ReturnType<typeof loadPackage>>
export async function loadPackage (dir: string) {
const pkgPath = resolve(dir, 'package.json')
const data = JSON.parse(await fsp.readFile(pkgPath, 'utf-8').catch(() => '{}'))
const save = () => fsp.writeFile(pkgPath, JSON.stringify(data, null, 2) + '\n')
const updateDeps = (reviver: (dep: Dep) => Dep | void) => {
for (const type of ['dependencies', 'devDependencies', 'optionalDependencies', 'peerDependencies']) {
if (!data[type]) { continue }
for (const e of Object.entries(data[type])) {
const dep: Dep = { name: e[0], range: e[1] as string, type }
delete data[type][dep.name]
const updated = reviver(dep) || dep
data[updated.type] = data[updated.type] || {}
data[updated.type][updated.name] = updated.range
}
}
}
return {
dir,
data,
save,
updateDeps
}
}
export async function loadWorkspace (dir: string) {
const workspacePkg = await loadPackage(dir)
const pkgDirs = (await globby(['packages/*'], { onlyDirectories: true })).sort()
const packages: Package[] = []
for (const pkgDir of pkgDirs) {
const pkg = await loadPackage(pkgDir)
if (!pkg.data.name) { continue }
packages.push(pkg)
}
const find = (name: string) => {
const pkg = packages.find(pkg => pkg.data.name === name)
if (!pkg) {
throw new Error('Workspace package not found: ' + name)
}
return pkg
}
const rename = (from: string, to: string) => {
find(from).data._name = find(from).data.name
find(from).data.name = to
for (const pkg of packages) {
pkg.updateDeps((dep) => {
if (dep.name === from && !dep.range.startsWith('npm:')) {
dep.range = 'npm:' + to + '@' + dep.range
}
})
}
}
const setVersion = (name: string, newVersion: string) => {
find(name).data.version = newVersion
for (const pkg of packages) {
pkg.updateDeps((dep) => {
if (dep.name === name) {
dep.range = newVersion
}
})
}
}
const save = () => Promise.all(packages.map(pkg => pkg.save()))
return {
dir,
workspacePkg,
packages,
save,
find,
rename,
setVersion
}
}

View File

@ -1,100 +1,7 @@
import { promises as fsp } from 'node:fs'
import { execSync } from 'node:child_process' import { execSync } from 'node:child_process'
import { $fetch } from 'ohmyfetch' import { $fetch } from 'ohmyfetch'
import { resolve } from 'pathe'
import { globby } from 'globby'
import { inc } from 'semver' import { inc } from 'semver'
import { loadWorkspace } from './_utils'
interface Dep {
name: string,
range: string,
type: string
}
async function loadPackage (dir: string) {
const pkgPath = resolve(dir, 'package.json')
const data = JSON.parse(await fsp.readFile(pkgPath, 'utf-8').catch(() => '{}'))
const save = () => fsp.writeFile(pkgPath, JSON.stringify(data, null, 2) + '\n')
const updateDeps = (reviver: (dep: Dep) => Dep | void) => {
for (const type of ['dependencies', 'devDependencies', 'optionalDependencies', 'peerDependencies']) {
if (!data[type]) { continue }
for (const e of Object.entries(data[type])) {
const dep: Dep = { name: e[0], range: e[1] as string, type }
delete data[type][dep.name]
const updated = reviver(dep) || dep
data[updated.type] = data[updated.type] || {}
data[updated.type][updated.name] = updated.range
}
}
}
return {
dir,
data,
save,
updateDeps
}
}
type ThenArg<T> = T extends PromiseLike<infer U> ? U : T
type Package = ThenArg<ReturnType<typeof loadPackage>>
async function loadWorkspace (dir: string) {
const workspacePkg = await loadPackage(dir)
const pkgDirs = (await globby(workspacePkg.data.workspaces || [], { onlyDirectories: true })).sort()
const packages: Package[] = []
for (const pkgDir of pkgDirs) {
const pkg = await loadPackage(pkgDir)
if (!pkg.data.name) { continue }
packages.push(pkg)
}
const find = (name: string) => {
const pkg = packages.find(pkg => pkg.data.name === name)
if (!pkg) {
throw new Error('Workspace package not found: ' + name)
}
return pkg
}
const rename = (from: string, to: string) => {
find(from).data._name = find(from).data.name
find(from).data.name = to
for (const pkg of packages) {
pkg.updateDeps((dep) => {
if (dep.name === from && !dep.range.startsWith('npm:')) {
dep.range = 'npm:' + to + '@' + dep.range
}
})
}
}
const setVersion = (name: string, newVersion: string) => {
find(name).data.version = newVersion
for (const pkg of packages) {
pkg.updateDeps((dep) => {
if (dep.name === name) {
dep.range = newVersion
}
})
}
}
const save = () => Promise.all(packages.map(pkg => pkg.save()))
return {
dir,
workspacePkg,
packages,
save,
find,
rename,
setVersion
}
}
async function main () { async function main () {
const workspace = await loadWorkspace(process.cwd()) const workspace = await loadWorkspace(process.cwd())

View File

@ -1,12 +0,0 @@
#!/bin/bash
set -e
# Restore all git changes
git restore -s@ -SW -- packages examples
# Bump versions
yarn lerna version --preid rc --no-changelog --exact --no-git-tag-version --no-push -m "chore: release rc"
# Stage
git add --all

19
scripts/bump-rc.ts Normal file
View File

@ -0,0 +1,19 @@
import { inc } from 'semver'
import { loadWorkspace } from './_utils'
async function main () {
const workspace = await loadWorkspace(process.cwd())
for (const pkg of workspace.packages.filter(p => !p.data.private)) {
// TODO: Set release type based on changelog after 3.0.0
const newVersion = inc(pkg.data.version, 'prerelease', 'rc')
workspace.setVersion(pkg.data.name, newVersion!)
}
await workspace.save()
}
main().catch((err) => {
console.error(err)
process.exit(1)
})

3
scripts/example.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
pnpm --filter example-$2 $1

View File

@ -6,17 +6,15 @@ set -xe
git restore -s@ -SW -- packages examples git restore -s@ -SW -- packages examples
# Bump versions to edge # Bump versions to edge
yarn jiti ./scripts/bump-edge pnpm jiti ./scripts/bump-edge
# Resolve yarn pnpm i --frozen-lockfile=false
YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn install
# Update token # Update token
if [[ ! -z ${NODE_AUTH_TOKEN} ]] ; then if [[ ! -z ${NODE_AUTH_TOKEN} ]] ; then
echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" >> ~/.npmrc echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" >> ~/.npmrc
echo "registry=https://registry.npmjs.org/" >> ~/.npmrc echo "registry=https://registry.npmjs.org/" >> ~/.npmrc
echo "always-auth=true" >> ~/.npmrc echo "always-auth=true" >> ~/.npmrc
echo "npmAuthToken: ${NODE_AUTH_TOKEN}" >> ~/.yarnrc.yml
npm whoami npm whoami
fi fi

View File

@ -6,7 +6,7 @@ set -e
git restore -s@ -SW -- packages examples git restore -s@ -SW -- packages examples
# Build all once to ensure things are nice # Build all once to ensure things are nice
yarn build pnpm build
# Release packages # Release packages
for PKG in packages/* ; do for PKG in packages/* ; do

View File

@ -3,5 +3,8 @@
"name": "fixture-bridge", "name": "fixture-bridge",
"scripts": { "scripts": {
"build": "nuxi build" "build": "nuxi build"
},
"dependencies": {
"nuxt": "workspace:*"
} }
} }

14922
yarn.lock

File diff suppressed because it is too large Load Diff