diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index a5708e8235..469ac12b19 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -2,7 +2,7 @@ // https://containers.dev/implementors/json_reference/ { "name": "nuxt-devcontainer", - "dockerFile": "Dockerfile", + "build": { "dockerfile": "Dockerfile" }, "features": {}, "customizations": { "vscode": { diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 513682b8ec..0000000000 --- a/.eslintrc +++ /dev/null @@ -1,168 +0,0 @@ -{ - "$schema": "https://json.schemastore.org/eslintrc", - "ignorePatterns": [ - "dist", - "public", - "node_modules", - "packages/schema/schema" - ], - "globals": { - "NodeJS": true, - "$fetch": true - }, - "plugins": ["jsdoc", "import", "unicorn", "no-only-tests"], - "extends": [ - "plugin:jsdoc/recommended", - "@nuxt/eslint-config", - "plugin:import/typescript" - ], - "rules": { - "sort-imports": [ - "error", - { - "ignoreDeclarationSort": true - } - ], - "no-only-tests/no-only-tests": "error", - "unicorn/prefer-node-protocol": "error", - "no-console": "warn", - "vue/one-component-per-file": "off", - "vue/require-default-prop": "off", - - // Vue stylistic rules from `@antfu/eslint-config` - "vue/array-bracket-spacing": ["error", "never"], - "vue/arrow-spacing": ["error", { "after": true, "before": true }], - "vue/block-spacing": ["error", "always"], - "vue/block-tag-newline": [ - "error", - { - "multiline": "always", - "singleline": "always" - } - ], - "vue/brace-style": ["error", "stroustrup", { "allowSingleLine": true }], - "vue/comma-dangle": ["error", "always-multiline"], - "vue/comma-spacing": ["error", { "after": true, "before": false }], - "vue/comma-style": ["error", "last"], - "vue/html-comment-content-spacing": [ - "error", - "always", - { - "exceptions": ["-"] - } - ], - "vue/key-spacing": ["error", { "afterColon": true, "beforeColon": false }], - "vue/keyword-spacing": ["error", { "after": true, "before": true }], - "vue/object-curly-newline": "off", - "vue/object-curly-spacing": ["error", "always"], - "vue/object-property-newline": [ - "error", - { "allowMultiplePropertiesPerLine": true } - ], - "vue/operator-linebreak": ["error", "before"], - "vue/padding-line-between-blocks": ["error", "always"], - "vue/quote-props": ["error", "consistent-as-needed"], - "vue/space-in-parens": ["error", "never"], - "vue/template-curly-spacing": "error", - - "jsdoc/require-jsdoc": "off", - "jsdoc/require-param": "off", - "jsdoc/require-returns": "off", - "jsdoc/require-param-type": "off", - "import/order": [ - "error", - { - "pathGroups": [ - { - "pattern": "#vue-router", - "group": "external" - } - ] - } - ], - "import/no-restricted-paths": [ - "error", - { - "zones": [ - { - "from": "packages/nuxt/src/!(core)/**/*", - "target": "packages/nuxt/src/core", - "message": "core should not directly import from modules." - }, - { - "from": "packages/nuxt/src/!(app)/**/*", - "target": "packages/nuxt/src/app", - "message": "app should not directly import from modules." - }, - { - "from": "packages/nuxt/src/app/**/index.ts", - "target": "packages/nuxt/src", - "message": "should not import from barrel/index files" - }, - { - "from": "packages/nitro", - "target": "packages/!(nitro)/**/*", - "message": "nitro should not directly import other packages." - } - ] - } - ], - "@typescript-eslint/consistent-type-imports": [ - "error", - { - "disallowTypeAnnotations": false - } - ], - "@typescript-eslint/ban-ts-comment": [ - "error", - { - "ts-expect-error": "allow-with-description", - "ts-ignore": true - } - ], - "@typescript-eslint/prefer-ts-expect-error": "error", - "@typescript-eslint/no-unused-vars": [ - "error", - { - "argsIgnorePattern": "^_", - "varsIgnorePattern": "^_", - "ignoreRestSiblings": true - } - ], - "jsdoc/check-tag-names": [ - "error", - { - "definedTags": ["__NO_SIDE_EFFECTS__"] - } - ] - }, - "overrides": [ - { - "files": ["packages/schema/**"], - "rules": { - "jsdoc/valid-types": "off", - "jsdoc/check-tag-names": [ - "error", - { - "definedTags": ["experimental"] - } - ] - } - }, - { - "files": ["packages/nuxt/src/app/**", "test/**", "**/runtime/**"], - "rules": { - "no-console": "off" - } - } - ], - "settings": { - "jsdoc": { - "ignoreInternal": true, - "tagNamePreference": { - "warning": "warning", - "note": "note" - } - } - } -} diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 7b2d765c12..ff8f4c2377 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,10 +1,10 @@ blank_issues_enabled: true contact_links: - name: πŸ“š Nuxt 3 Documentation - url: https://nuxt.com/docs/ + url: https://nuxt.com/docs about: Check the documentation for usage of Nuxt 3 - name: πŸ“š Nuxt 2 Documentation - url: https://v2.nuxt.com/ + url: https://v2.nuxt.com about: Check the documentation for usage of Nuxt 2 - name: πŸ’¬ Discussions url: https://github.com/nuxt/nuxt/discussions diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index f99be3b89d..8cba9c0e73 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,37 +1,19 @@ - - ### πŸ”— Linked issue - - -### ❓ Type of change - - - -- [ ] πŸ“– Documentation (updates to the documentation, readme or JSdoc annotations) -- [ ] 🐞 Bug fix (a non-breaking change that fixes an issue) -- [ ] πŸ‘Œ Enhancement (improving an existing functionality like performance) -- [ ] ✨ New feature (a non-breaking change that adds functionality) -- [ ] 🧹 Chore (updates to the build process or auxiliary tools and libraries) -- [ ] ⚠️ Breaking change (fix or feature that would cause existing functionality to change) + ### πŸ“š Description - - - + -### πŸ“ Checklist + - - +- Check that there isn't already a PR that solves the problem the same way. If you find a duplicate, please help us reviewing it. +- Read the contribution docs at https://nuxt.com/docs/community/contribution +- Ensure that PR title follows conventional commits (https://conventionalcommits.org) +- Update the corresponding documentation if needed. +- Include relevant tests that fail without this PR but pass with it. -- [ ] I have linked an issue or discussion. -- [ ] I have added tests (if possible). -- [ ] I have updated the documentation accordingly. +Thank you for contributing to Nuxt! +-----------------------------------------------------------------------> diff --git a/.github/reproduire/needs-reproduction.md b/.github/reproduire/needs-reproduction.md index 79ad109255..dbbd6ec1b2 100644 --- a/.github/reproduire/needs-reproduction.md +++ b/.github/reproduire/needs-reproduction.md @@ -27,6 +27,6 @@ Please ensure that the reproduction is as **minimal** as possible. See more deta You might also find these other articles interesting and/or helpful: - [The Importance of Reproductions](https://antfu.me/posts/why-reproductions-are-required) -- [How to Generate a Minimal, Complete, and Verifiable Example](https://stackoverflow.com/help/mcve) +- [How to Generate a Minimal, Complete, and Verifiable Example](https://stackoverflow.com/help/minimal-reproducible-example) diff --git a/.github/workflows/autofix-docs.yml b/.github/workflows/autofix-docs.yml index ecfb0ae5b0..8091bf631b 100644 --- a/.github/workflows/autofix-docs.yml +++ b/.github/workflows/autofix-docs.yml @@ -19,7 +19,7 @@ jobs: steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - run: corepack enable - - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 + - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: node-version: 20 cache: "pnpm" diff --git a/.github/workflows/autofix.yml b/.github/workflows/autofix.yml index 83375565de..ff99ac81c3 100644 --- a/.github/workflows/autofix.yml +++ b/.github/workflows/autofix.yml @@ -15,7 +15,7 @@ jobs: steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - run: corepack enable - - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 + - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: node-version: 20 cache: "pnpm" @@ -26,9 +26,6 @@ jobs: - name: Build (stub) run: pnpm dev:prepare - - name: Lint (code) - run: pnpm lint:fix - - name: Test (unit) run: pnpm test:unit -u @@ -52,4 +49,7 @@ jobs: if: ${{ !contains(github.head_ref, 'renovate') }} run: pnpm vitest run bundle -u + - name: Lint (code) + run: pnpm lint:fix + - uses: autofix-ci/action@ea32e3a12414e6d3183163c3424a7d7a8631ad84 diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index a2363b2c8d..492c58ed3f 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -15,8 +15,6 @@ env: # 7 GiB by default on GitHub, setting to 6 GiB # https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources NODE_OPTIONS: --max-old-space-size=6144 - # install playwright binary manually (because pnpm only runs install script once) - PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "1" # Remove default permissions of GITHUB_TOKEN for security # https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs @@ -33,7 +31,7 @@ jobs: steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - run: corepack enable - - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 + - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: node-version: 20 cache: "pnpm" @@ -48,7 +46,7 @@ jobs: run: pnpm build - name: Run benchmarks - uses: CodSpeedHQ/action@5ef3186765fa3fafd8b2729b064025d19626050c # v2.0.3 + uses: CodSpeedHQ/action@1dbf41f0ae41cebfe61e084e535aebe533409b4d # v2.3.0 with: run: pnpm vitest bench token: ${{ secrets.CODSPEED_TOKEN }} diff --git a/.github/workflows/cache-cleanup.yml b/.github/workflows/cache-cleanup.yml new file mode 100644 index 0000000000..b71b0e9baa --- /dev/null +++ b/.github/workflows/cache-cleanup.yml @@ -0,0 +1,36 @@ +# From https://github.com/actions/cache/blob/main/tips-and-workarounds.md#force-deletion-of-caches-overriding-default-cache-eviction-policy + +name: cache +on: + pull_request: + types: + - closed + +jobs: + cleanup: + runs-on: ubuntu-latest + permissions: + # `actions:write` permission is required to delete caches + # See also: https://docs.github.com/en/rest/actions/cache?apiVersion=2022-11-28#delete-a-github-actions-cache-for-a-repository-using-a-cache-id + actions: write + contents: read + steps: + - name: Cleanup + run: | + gh extension install actions/gh-actions-cache + + echo "Fetching list of cache keys" + cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 ) + + ## Setting this to not fail the workflow while deleting cache keys. + set +e + echo "Deleting caches..." + for cacheKey in $cacheKeysForPR + do + gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm + done + echo "Done" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REPO: ${{ github.repository }} + BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge diff --git a/.github/workflows/changelogensets.yml b/.github/workflows/changelog.yml similarity index 87% rename from .github/workflows/changelogensets.yml rename to .github/workflows/changelog.yml index cd1a328327..515b3735e9 100644 --- a/.github/workflows/changelogensets.yml +++ b/.github/workflows/changelog.yml @@ -1,4 +1,4 @@ -name: Release +name: changelog on: push: @@ -15,7 +15,7 @@ concurrency: cancel-in-progress: ${{ github.event_name != 'push' }} jobs: - update-changelog: + update: if: github.repository_owner == 'nuxt' && !contains(github.event.head_commit.message, 'v3.') runs-on: ubuntu-latest @@ -24,7 +24,7 @@ jobs: with: fetch-depth: 0 - run: corepack enable - - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 + - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: node-version: 20 cache: "pnpm" diff --git a/.github/workflows/check-links.yml b/.github/workflows/check-links.yml index a127927d94..d0c46d085b 100644 --- a/.github/workflows/check-links.yml +++ b/.github/workflows/check-links.yml @@ -18,7 +18,7 @@ jobs: steps: # Cache lychee results (e.g. to avoid hitting rate limits) - name: Restore lychee cache - uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0 + uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 with: path: .lycheecache key: cache-lychee-${{ github.sha }} @@ -28,7 +28,7 @@ jobs: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: Lychee link checker - uses: lycheeverse/lychee-action@8c9a282bef269f1ba1f727d1f79c5b8139bf3a5a # for v1.8.0 + uses: lycheeverse/lychee-action@1e92115388e88fdc331019d99c8ab8dfe97ddd13 # for v1.8.0 with: # arguments with file types to check args: >- diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c6761c3794..92f0483071 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,8 +20,6 @@ env: # 7 GiB by default on GitHub, setting to 6 GiB # https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources NODE_OPTIONS: --max-old-space-size=6144 - # install playwright binary manually (because pnpm only runs install script once) - PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "1" # Remove default permissions of GITHUB_TOKEN for security # https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs @@ -39,7 +37,7 @@ jobs: steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - run: corepack enable - - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 + - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: node-version: 20 cache: "pnpm" @@ -57,7 +55,7 @@ jobs: run: pnpm build - name: Cache dist - uses: actions/upload-artifact@694cdabd8bdb0f10b2cea11669e1bf5453eed0a6 # v4.2.0 + uses: actions/upload-artifact@1746f4ab65b179e0ea60a494b83293b640dd5bba # v4.3.2 with: retention-days: 3 name: dist @@ -76,7 +74,7 @@ jobs: steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - run: corepack enable - - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 + - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: node-version: 20 cache: "pnpm" @@ -85,19 +83,19 @@ jobs: run: pnpm install - name: Initialize CodeQL - uses: github/codeql-action/init@0b21cf2492b6b02c465a3e5d7c473717ad7721ba # v3.23.1 + uses: github/codeql-action/init@c7f9125735019aa87cfc361530512d50ea439c71 # v3.25.1 with: languages: javascript queries: +security-and-quality - name: Restore dist cache - uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1 + uses: actions/download-artifact@8caf195ad4b1dee92908e23f56eeb0696f1dd42d # v4.1.5 with: name: dist path: packages - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@0b21cf2492b6b02c465a3e5d7c473717ad7721ba # v3.23.1 + uses: github/codeql-action/analyze@c7f9125735019aa87cfc361530512d50ea439c71 # v3.25.1 with: category: "/language:javascript" @@ -115,7 +113,7 @@ jobs: steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - run: corepack enable - - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 + - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: node-version: 20 cache: "pnpm" @@ -124,7 +122,7 @@ jobs: run: pnpm install - name: Restore dist cache - uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1 + uses: actions/download-artifact@8caf195ad4b1dee92908e23f56eeb0696f1dd42d # v4.1.5 with: name: dist path: packages @@ -134,6 +132,9 @@ jobs: env: MODULE_RESOLUTION: ${{ matrix.module }} + - name: Typecheck (docs) + run: pnpm typecheck:docs + lint: # autofix workflow will be triggered instead for PRs if: github.event_name == 'push' @@ -143,7 +144,7 @@ jobs: steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - run: corepack enable - - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 + - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: node-version: 20 cache: "pnpm" @@ -167,7 +168,7 @@ jobs: steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - run: corepack enable - - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 + - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: node-version: 20 cache: "pnpm" @@ -209,7 +210,7 @@ jobs: steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - run: corepack enable - - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 + - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: node-version: ${{ matrix.node }} cache: "pnpm" @@ -217,34 +218,11 @@ jobs: - name: Install dependencies run: pnpm install - # Install playwright's binary under custom directory to cache - - name: (non-windows) Set Playwright path and Get playwright version - if: runner.os != 'Windows' - run: | - echo "PLAYWRIGHT_BROWSERS_PATH=$HOME/.cache/playwright-bin" >> $GITHUB_ENV - PLAYWRIGHT_VERSION="$(pnpm ls --depth 0 --json -w playwright | jq --raw-output '.[0].unsavedDependencies["playwright"].version')" - echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV - - - name: (windows) Set Playwright path and Get playwright version - if: runner.os == 'Windows' - run: | - echo "PLAYWRIGHT_BROWSERS_PATH=$HOME\.cache\playwright-bin" >> $env:GITHUB_ENV - $env:PLAYWRIGHT_VERSION="$(pnpm ls --depth 0 --json -w playwright | jq --raw-output '.[0].unsavedDependencies[\"playwright\"].version')" - echo "PLAYWRIGHT_VERSION=$env:PLAYWRIGHT_VERSION" >> $env:GITHUB_ENV - - - name: Cache Playwright's binary - uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0 - with: - key: ${{ runner.os }}-playwright-bin-v1-${{ env.PLAYWRIGHT_VERSION }} - path: ${{ env.PLAYWRIGHT_BROWSERS_PATH }} - restore-keys: | - ${{ runner.os }}-playwright-bin-v1- - - name: Install Playwright run: pnpm playwright-core install chromium - name: Restore dist cache - uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1 + uses: actions/download-artifact@8caf195ad4b1dee92908e23f56eeb0696f1dd42d # v4.1.5 with: name: dist path: packages @@ -258,7 +236,7 @@ jobs: TEST_CONTEXT: ${{ matrix.context }} SKIP_BUNDLE_SIZE: ${{ github.event_name != 'push' || matrix.env == 'dev' || matrix.builder == 'webpack' || matrix.context == 'default' || runner.os == 'Windows' }} - - uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4 + - uses: codecov/codecov-action@84508663e988701840491b86de86b666e8a86bed # v4.3.0 if: github.event_name != 'push' && matrix.env == 'built' && matrix.builder == 'vite' && matrix.context == 'default' && matrix.os == 'ubuntu-latest' && matrix.manifest == 'manifest-on' with: token: ${{ secrets.CODECOV_TOKEN }} @@ -284,7 +262,7 @@ jobs: with: fetch-depth: 0 - run: corepack enable - - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 + - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: node-version: 20 cache: "pnpm" @@ -293,7 +271,7 @@ jobs: run: pnpm install - name: Restore dist cache - uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1 + uses: actions/download-artifact@8caf195ad4b1dee92908e23f56eeb0696f1dd42d # v4.1.5 with: name: dist path: packages @@ -323,7 +301,7 @@ jobs: with: fetch-depth: 0 - run: corepack enable - - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 + - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: node-version: 20 cache: "pnpm" @@ -332,7 +310,7 @@ jobs: run: pnpm install - name: Restore dist cache - uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1 + uses: actions/download-artifact@8caf195ad4b1dee92908e23f56eeb0696f1dd42d # v4.1.5 with: name: dist path: packages diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index 3fee4d6b42..b818d2f085 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -19,4 +19,4 @@ jobs: - name: 'Checkout Repository' uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: 'Dependency Review' - uses: actions/dependency-review-action@4901385134134e04cec5fbe5ddfe3b2c5bd5d976 # v4.0.0 + uses: actions/dependency-review-action@5bbc3ba658137598168acb2ab73b21c432dd411b # v4.2.5 diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index a2a48b23e2..e71037f7e0 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -22,7 +22,7 @@ jobs: steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - run: corepack enable - - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 + - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: node-version: 20 cache: "pnpm" @@ -32,3 +32,9 @@ jobs: - name: Lint (docs) run: pnpm lint:docs + + - name: Build Nuxt + run: pnpm build + + - name: Typecheck (docs) + run: pnpm typecheck:docs diff --git a/.github/workflows/label-pr.yml b/.github/workflows/label-pr.yml index 8429de7f03..9d462f9f8c 100644 --- a/.github/workflows/label-pr.yml +++ b/.github/workflows/label-pr.yml @@ -6,34 +6,68 @@ on: - opened branches: - main - - 2.x jobs: - add-pr-label: - name: Add PR label + add-pr-labels: + name: Add PR labels runs-on: ubuntu-latest permissions: pull-requests: write if: github.repository == 'nuxt/nuxt' steps: - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + env: + PULL_REQUEST_TITLE: ${{ github.event.pull_request.title }} with: script: | - const baseName = "${{ github.event.pull_request.base.label }}" - const PRNumber = "${{ github.event.pull_request.number }}" + const labelsToAdd = [] - if(baseName === "nuxt:2.x") { + const pullRequest = { + number: ${{ github.event.pull_request.number }}, + title: process.env.PULL_REQUEST_TITLE, + labelsNames: ${{ toJson(github.event.pull_request.labels.*.name) }} + } + + // Select label based on the name of the base branch + const baseBranchLabelName = '3.x' + + if (!pullRequest.labelsNames.includes(baseBranchLabelName)) { + labelsToAdd.push(baseBranchLabelName) + } + + // Select label based on the type in PR title + const pullRequestTypeToLabelName = { + chore: 'chore', + ci: 'chore', + docs: 'documentation', + feat: 'enhancement', + fix: 'bug', + perf: 'performance', + refactor: 'refactor', + test: 'test' + } + + for (const [pullRequestType, labelName] of Object.entries( + pullRequestTypeToLabelName + )) { + if ( + pullRequest.title.startsWith(pullRequestType) && + !pullRequest.labelsNames.includes( + pullRequestTypeToLabelName[pullRequestType] + ) + ) { + labelsToAdd.push(labelName) + + break + } + } + + // Add selected labels + if (labelsToAdd.length > 0) { github.rest.issues.addLabels({ - issue_number: PRNumber, + issue_number: pullRequest.number, owner: context.repo.owner, repo: context.repo.repo, - labels: ["2.x"] - }) - } else if(baseName === "nuxt:main") { - github.rest.issues.addLabels({ - issue_number: PRNumber, - owner: context.repo.owner, - repo: context.repo.repo, - labels: ["3.x"] + labels: labelsToAdd }) } diff --git a/.github/workflows/notify-nuxt-bridge.yml b/.github/workflows/notify-nuxt-bridge.yml index 50f06c6ab5..fa97b12b95 100644 --- a/.github/workflows/notify-nuxt-bridge.yml +++ b/.github/workflows/notify-nuxt-bridge.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest steps: - name: repository dispatch - uses: peter-evans/repository-dispatch@bf47d102fdb849e755b0b0023ea3e81a44b6f570 #v2.1.2 + uses: peter-evans/repository-dispatch@ff45666b9427631e3450c54a1bcbee4d9ff4d7c0 # v3.0.0 with: token: ${{ secrets.BRIDGE_GITHUB_TOKEN }} repository: ${{ matrix.repo }} diff --git a/.github/workflows/nuxt2-edge.yml b/.github/workflows/nuxt2-edge.yml index c7887254fc..5e2df5cce6 100644 --- a/.github/workflows/nuxt2-edge.yml +++ b/.github/workflows/nuxt2-edge.yml @@ -27,7 +27,7 @@ jobs: fetch-depth: 0 # All history - name: fetch tags run: git fetch --depth=1 origin "+refs/tags/*:refs/tags/*" - - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 + - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: node-version: 18 registry-url: 'https://registry.npmjs.org' diff --git a/.github/workflows/release-pr.yml b/.github/workflows/release-pr.yml index b87ef81207..b8d810b3f8 100644 --- a/.github/workflows/release-pr.yml +++ b/.github/workflows/release-pr.yml @@ -1,4 +1,4 @@ -name: release +name: release-pr on: issue_comment: @@ -22,7 +22,7 @@ jobs: steps: - name: Ensure action is by maintainer - uses: octokit/request-action@89697eb6635e52c6e1e5559f15b5c91ba5100cb0 # v2.1.9 + uses: octokit/request-action@21d174fc38ff59af9cf4d7e07347d29df6dbaa99 # v2.3.0 id: check_role with: route: GET /repos/nuxt/nuxt/collaborators/${{ github.event.comment.user.login }} @@ -35,7 +35,7 @@ jobs: fetch-depth: 0 - run: corepack enable - - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 + - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: node-version: 20 cache: "pnpm" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000000..3aec93b443 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,40 @@ +name: release + +on: + push: + tags: + - "v*" + +# Remove default permissions of GITHUB_TOKEN for security +# https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs +permissions: {} + +jobs: + release: + if: github.repository == 'nuxt/nuxt' && startsWith(github.event.head_commit.message, 'v3.') + permissions: + id-token: write + runs-on: ubuntu-latest + timeout-minutes: 20 + steps: + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-depth: 0 + - run: corepack enable + - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + with: + node-version: 20 + registry-url: "https://registry.npmjs.org/" + cache: "pnpm" + + - name: Install dependencies + run: pnpm install + + - name: Build (stub) + run: pnpm dev:prepare + + - name: Release + run: ./scripts/release.sh + env: + NODE_AUTH_TOKEN: ${{secrets.RELEASE_NODE_AUTH_TOKEN}} + NPM_CONFIG_PROVENANCE: true diff --git a/.github/workflows/scorecards.yml b/.github/workflows/scorecards.yml index 3808d28beb..dfb81b2547 100644 --- a/.github/workflows/scorecards.yml +++ b/.github/workflows/scorecards.yml @@ -58,7 +58,7 @@ jobs: # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF # format to the repository Actions tab. - name: "Upload artifact" - uses: actions/upload-artifact@694cdabd8bdb0f10b2cea11669e1bf5453eed0a6 # v4.2.0 + uses: actions/upload-artifact@1746f4ab65b179e0ea60a494b83293b640dd5bba # v4.3.2 with: name: SARIF file path: results.sarif @@ -66,6 +66,6 @@ jobs: # Upload the results to GitHub's code scanning dashboard. - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@0b21cf2492b6b02c465a3e5d7c473717ad7721ba # v3.23.1 + uses: github/codeql-action/upload-sarif@c7f9125735019aa87cfc361530512d50ea439c71 # v3.25.1 with: sarif_file: results.sarif diff --git a/.gitignore b/.gitignore index 35388c4fd2..815f0415e7 100644 --- a/.gitignore +++ b/.gitignore @@ -73,3 +73,5 @@ Temporary Items fixtures-temp .pnpm-store +eslint-typegen.d.ts +.eslintcache diff --git a/.npmrc b/.npmrc index e2ad808f8d..8fb0b90fee 100644 --- a/.npmrc +++ b/.npmrc @@ -1,3 +1,2 @@ shamefully-hoist=true -strict-peer-dependencies=false shell-emulator=true diff --git a/README.md b/README.md index 67990c4eee..c054f7cfff 100644 --- a/README.md +++ b/README.md @@ -13,16 +13,32 @@ Nuxt is a free and open-source framework with an intuitive and extendable way to create type-safe, performant and production-grade full-stack web applications and websites with Vue.js. It provides a number of features that make it easy to build fast, SEO-friendly, and scalable web applications, including: -- Server-side rendering, Static Site Generation or Hybrid Rendering -- Automatic routing with code-splitting -- State management -- SEO Optimization -- Auto imports -- Extensible with [180+ modules](https://nuxt.com/modules) +- Server-side rendering, Static Site Generation, Hybrid Rendering and Edge-Side Rendering +- Automatic routing with code-splitting and pre-fetching +- Data fetching and state management +- SEO Optimization and Meta tags definition +- Auto imports of components, composables and utils +- TypeScript with zero configuration +- Go fullstack with our server/ directory +- Extensible with [200+ modules](https://nuxt.com/modules) - Deployment to a variety of [hosting platforms](https://nuxt.com/deploy) - ...[and much more](https://nuxt.com) πŸš€ -## Getting Started +### Table of Contents + +- πŸš€ [Getting Started](#getting-started) +- πŸ’» [ Vue Development](#vue-development) +- πŸ“– [Documentation](#documentation) +- 🧩 [Modules](#modules) +- ❀️ [Contribute](#contribute) +- 🏠 [Local Development](#local-development) +- ⛰️ [Nuxt 2](#nuxt-2) +- πŸ”— [Follow us](#follow-us) +- βš–οΈ [License](#license) + +--- + +## πŸš€ Getting Started Use the following command to create a new starter project. This will create a starter project with all the necessary files and dependencies: @@ -30,16 +46,17 @@ Use the following command to create a new starter project. This will create a st npx nuxi@latest init ``` -Discover also [nuxt.new](https://nuxt.new): Open a Nuxt starter on CodeSandbox, StackBlitz or locally to get up and running in a few seconds. +> [!TIP] +> Discover also [nuxt.new](https://nuxt.new): Open a Nuxt starter on CodeSandbox, StackBlitz or locally to get up and running in a few seconds. -## Vue Development +## πŸ’» Vue Development Simple, intuitive and powerful, Nuxt lets you write Vue components in a way that makes sense. Every repetitive task is automated, so you can focus on writing your full-stack Vue application with confidence. Example of an `app.vue`: ```vue - @@ -421,7 +421,7 @@ For proper syntax highlighting in SFC, you can use the postcss lang attribute. ```vue ``` @@ -430,7 +430,7 @@ By default, Nuxt comes with the following plugins already pre-configured: - [postcss-import](https://github.com/postcss/postcss-import): Improves the `@import` rule - [postcss-url](https://github.com/postcss/postcss-url): Transforms `url()` statements - [autoprefixer](https://github.com/postcss/autoprefixer): Automatically adds vendor prefixes -- [cssnano](https://cssnano.co): Minification and purge +- [cssnano](https://cssnano.github.io/cssnano): Minification and purge ## Leveraging Layouts For Multiple Styles @@ -458,14 +458,14 @@ Use different styles for different layouts. Nuxt isn't opinionated when it comes to styling and provides you with a wide variety of options. You can use any styling tool that you want, such as popular libraries like [UnoCSS](https://unocss.dev) or [Tailwind CSS](https://tailwindcss.com). -The community and the Nuxt team have developed plenty of Nuxt modules to makes the integration easier. +The community and the Nuxt team have developed plenty of Nuxt modules to make the integration easier. You can discover them on the [modules section](/modules) of the website. Here are a few modules to help you get started: - [UnoCSS](/modules/unocss): Instant on-demand atomic CSS engine - [Tailwind CSS](/modules/tailwindcss): Utility-first CSS framework - [Fontaine](https://github.com/nuxt-modules/fontaine): Font metric fallback -- [Pinceau](https://pinceau.dev): Adaptable styling framework +- [Pinceau](https://github.com/Tahul/pinceau): Adaptable styling framework - [Nuxt UI](https://ui.nuxt.com): A UI Library for Modern Web Apps - [Panda CSS](https://panda-css.com/docs/installation/nuxt): CSS-in-JS engine that generates atomic CSS at build time @@ -489,7 +489,7 @@ Nuxt comes with the same `` element that Vue has, and also has suppo We would recommend using [Fontaine](https://github.com/nuxt-modules/fontaine) to reduce your [CLS](https://web.dev/cls). If you need something more advanced, consider creating a Nuxt module to extend the build process or the Nuxt runtime. -::callout +::tip Always remember to take advantage of the various tools and techniques available in the Web ecosystem at large to make styling your application easier and more efficient. Whether you're using native CSS, a preprocessor, postcss, a UI library or a module, Nuxt has got you covered. Happy styling! :: diff --git a/docs/1.getting-started/5.routing.md b/docs/1.getting-started/5.routing.md index 0601cc11a3..e39d5d446b 100644 --- a/docs/1.getting-started/5.routing.md +++ b/docs/1.getting-started/5.routing.md @@ -71,7 +71,7 @@ When a [``](/docs/api/components/nuxt-link) enters the viewport on the The [`useRoute()`](/docs/api/composables/use-route) composable can be used in a ` diff --git a/docs/1.getting-started/5.seo-meta.md b/docs/1.getting-started/5.seo-meta.md index 29ec6d2d48..a1ebb2f457 100644 --- a/docs/1.getting-started/5.seo-meta.md +++ b/docs/1.getting-started/5.seo-meta.md @@ -6,9 +6,9 @@ navigation.icon: i-ph-file-search-duotone ## Defaults -Out-of-the-box, Nuxt provides sane defaults, which you can override if needed. +Out-of-the-box, Nuxt provides sensible defaults, which you can override if needed. -```ts [nuxt.config.ts] +```ts twoslash [nuxt.config.ts] export default defineNuxtConfig({ app: { head: { @@ -21,7 +21,7 @@ export default defineNuxtConfig({ Providing an [`app.head`](/docs/api/nuxt-config#head) property in your [`nuxt.config.ts`](/docs/guide/directory-structure/nuxt-config) allows you to customize the head for your entire app. -::callout +::important This method does not allow you to provide reactive data. We recommend to use `useHead()` in `app.vue`. :: @@ -29,12 +29,12 @@ Shortcuts are available to make configuration easier: `charset` and `viewport`. ## `useHead` -The [`useHead`](/docs/api/composables/use-head) composable function allows you to manage your head tags in a programmatic and reactive way, +The [`useHead`](/docs/api/composables/use-head) composable function allows you to manage your head tags programmatically and reactively, powered by [Unhead](https://unhead.unjs.io). As with all composables, it can only be used with a components `setup` and lifecycle hooks. -```vue [app.vue] +```vue twoslash [app.vue] ``` - - ```vue [useSeoMeta] + + ```vue twoslash [useSeoMeta] - +