diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 68d3ffb9d6..3bbbe17f89 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,4 +1,4 @@ -FROM node:lts +FROM node:lts@sha256:fffa89e023a3351904c04284029105d9e2ac7020886d683775a298569591e5bb RUN apt-get update && \ apt-get install -fy libnss3 libnspr4 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdbus-1-3 libdrm2 libxkbcommon0 libatspi2.0-0 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 libgbm1 libasound2 && \ 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/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index ad059c3630..780ffed438 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -1,6 +1,6 @@ name: "\U0001F41E Bug report" description: Create a report to help us improve Nuxt -labels: ["pending triage", "3.x"] +labels: ["pending triage"] body: - type: markdown attributes: @@ -36,7 +36,7 @@ body: validations: required: true - type: textarea - id: additonal + id: additional attributes: label: Additional context description: If applicable, add any other context about the problem here diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 7b2d765c12..3527bf128b 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,11 +1,8 @@ blank_issues_enabled: true contact_links: - - name: π Nuxt 3 Documentation - url: https://nuxt.com/docs/ - about: Check the documentation for usage of Nuxt 3 - - name: π Nuxt 2 Documentation - url: https://v2.nuxt.com/ - about: Check the documentation for usage of Nuxt 2 + - name: π Nuxt Documentation + url: https://nuxt.com/docs + about: Check the documentation for usage of Nuxt - name: π¬ Discussions url: https://github.com/nuxt/nuxt/discussions about: Use discussions if you have another issue, an idea for improvement or for asking questions. diff --git a/.github/ISSUE_TEMPLATE/feature-request.yml b/.github/ISSUE_TEMPLATE/feature-request.yml index a5614e9304..b155f19563 100644 --- a/.github/ISSUE_TEMPLATE/feature-request.yml +++ b/.github/ISSUE_TEMPLATE/feature-request.yml @@ -1,6 +1,6 @@ name: "π Feature request" description: Suggest a feature that will improve Nuxt -labels: ["pending triage", "3.x"] +labels: ["pending triage"] body: - type: markdown attributes: diff --git a/.github/ISSUE_TEMPLATE/z-bug-report-2.yml b/.github/ISSUE_TEMPLATE/z-bug-report-2.yml deleted file mode 100644 index d4124367b2..0000000000 --- a/.github/ISSUE_TEMPLATE/z-bug-report-2.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: "\U0001F41E Bug report (Nuxt 2)" -description: Create a report to help us improve Nuxt -labels: ["pending triage", "2.x"] -body: - - type: markdown - attributes: - value: | - Please carefully read the contribution docs before creating a bug report - π https://nuxt.com/docs/community/reporting-bugs - - Please use a template below to create a minimal reproduction - π https://stackblitz.com/github/nuxt/starter/tree/v2 - π https://codesandbox.io/s/github/nuxt/starter/v2 - - type: textarea - id: bug-env - attributes: - label: Environment - description: You can use `npx envinfo --system --npmPackages '{nuxt,@nuxt/*}' --binaries --browsers` to fill this section - placeholder: Environment - validations: - required: true - - type: textarea - id: reproduction - attributes: - label: Reproduction - description: Please provide a link to a repo that can reproduce the problem you ran into. A [**minimal reproduction**](https://nuxt.com/docs/community/reporting-bugs#create-a-minimal-reproduction) is required unless you are absolutely sure that the issue is obvious and the provided information is enough to understand the problem. If a report is vague (e.g. just a generic error message) and has no reproduction, it will receive a "need reproduction" label. If no reproduction is provided we might close it. - placeholder: Reproduction - validations: - required: true - - type: textarea - id: bug-description - attributes: - label: Describe the bug - description: A clear and concise description of what the bug is. If you intend to submit a PR for this issue, tell us in the description. Thanks! - placeholder: Bug description - validations: - required: true - - type: textarea - id: additonal - attributes: - label: Additional context - description: If applicable, add any other context about the problem here - - type: textarea - id: logs - attributes: - label: Logs - description: | - Optional if provided reproduction. Please try not to insert an image but copy paste the log text. - render: shell-script diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index f99be3b89d..2618070610 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://www.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/codeql/codeql-config.yml b/.github/codeql/codeql-config.yml new file mode 100644 index 0000000000..1ab482ad65 --- /dev/null +++ b/.github/codeql/codeql-config.yml @@ -0,0 +1,10 @@ +paths: + - 'packages/*/dist/**' + - 'packages/nuxt/bin/**' + - 'packages/schema/schema/**' +paths-ignore: + - 'test/**' + - '**/*.test.js' + - '**/*.test.ts' + - '**/*.test.tsx' + - '**/__tests__/**' diff --git a/.github/workflows/autofix-docs.yml b/.github/workflows/autofix-docs.yml index 8091bf631b..c4350a2356 100644 --- a/.github/workflows/autofix-docs.yml +++ b/.github/workflows/autofix-docs.yml @@ -17,9 +17,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 - run: corepack enable - - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + - uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 with: node-version: 20 cache: "pnpm" @@ -27,7 +27,10 @@ jobs: - name: Install dependencies run: pnpm install + - name: Build (stub) + run: pnpm dev:prepare + - name: Lint (docs) run: pnpm lint:docs:fix - - uses: autofix-ci/action@ea32e3a12414e6d3183163c3424a7d7a8631ad84 + - uses: autofix-ci/action@ff86a557419858bb967097bfc916833f5647fa8c diff --git a/.github/workflows/autofix.yml b/.github/workflows/autofix.yml index 09e2bfd25a..610d3ac48e 100644 --- a/.github/workflows/autofix.yml +++ b/.github/workflows/autofix.yml @@ -13,9 +13,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 - run: corepack enable - - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + - uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 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 - - uses: autofix-ci/action@ea32e3a12414e6d3183163c3424a7d7a8631ad84 + - name: Lint (code) + run: pnpm lint:fix + + - uses: autofix-ci/action@ff86a557419858bb967097bfc916833f5647fa8c diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 23af9bb1a5..e7e84f981a 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 @@ -31,9 +29,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 - run: corepack enable - - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + - uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 with: node-version: 20 cache: "pnpm" @@ -48,7 +46,7 @@ jobs: run: pnpm build - name: Run benchmarks - uses: CodSpeedHQ/action@fce3a2f16d0b352af341dcacb25caadfd9159055 # v2.1.1 + uses: CodSpeedHQ/action@ab07afd34cbbb7a1306e8d14b7cc44e029eee37a # v3.0.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..bda394c562 --- /dev/null +++ b/.github/workflows/cache-cleanup.yml @@ -0,0 +1,38 @@ +# 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 + +permissions: {} + +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 62% rename from .github/workflows/changelogensets.yml rename to .github/workflows/changelog.yml index 92ad691096..1b7e9b7ed9 100644 --- a/.github/workflows/changelogensets.yml +++ b/.github/workflows/changelog.yml @@ -1,30 +1,32 @@ -name: Release +name: changelog on: push: branches: - main - - 2.x + - 3.x -permissions: - pull-requests: write - contents: write +permissions: {} concurrency: group: ${{ github.workflow }}-${{ github.event.number || github.sha }} cancel-in-progress: ${{ github.event_name != 'push' }} jobs: - update-changelog: - if: github.repository_owner == 'nuxt' && !contains(github.event.head_commit.message, 'v3.') + update: + if: github.repository_owner == 'nuxt' && !contains(github.event.head_commit.message, 'v3.') && !contains(github.event.head_commit.message, 'v4.') runs-on: ubuntu-latest + permissions: + pull-requests: write + contents: write + steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 with: fetch-depth: 0 - run: corepack enable - - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + - uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 with: node-version: 20 cache: "pnpm" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e098c0bc10..fe626fbd56 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,12 +7,14 @@ on: - "*.md" branches: - main + - 3.x pull_request: paths-ignore: - "docs/**" - "*.md" branches: - main + - 3.x - "!v[0-9]*" # https://github.com/vitejs/vite/blob/main/.github/workflows/ci.yml @@ -20,8 +22,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 @@ -37,9 +37,9 @@ jobs: timeout-minutes: 10 steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 - run: corepack enable - - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + - uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 with: node-version: 20 cache: "pnpm" @@ -57,7 +57,7 @@ jobs: run: pnpm build - name: Cache dist - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 + uses: actions/upload-artifact@604373da6381bf24206979c74d06a550515601b9 # v4.4.1 with: retention-days: 3 name: dist @@ -70,36 +70,30 @@ jobs: actions: read contents: read security-events: write - needs: - - build steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - run: corepack enable - - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 - with: - node-version: 20 - cache: "pnpm" - - - name: Install dependencies - run: pnpm install + - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 - name: Initialize CodeQL - uses: github/codeql-action/init@379614612a29c9e28f31f39a59013eb8012a51f0 # v3.24.3 + uses: github/codeql-action/init@c36620d31ac7c881962c3d9dd939c40ec9434f2b # v3.26.12 with: - languages: javascript + config: | + paths: + - 'packages/*/src/**' + - 'packages/nuxt/bin/**' + - 'packages/schema/schema/**' + paths-ignore: + - 'test/**' + - '**/*.spec.ts' + - '**/*.test.ts' + - '**/__snapshots__/**' + languages: javascript-typescript queries: +security-and-quality - - name: Restore dist cache - uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2 - with: - name: dist - path: packages - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@379614612a29c9e28f31f39a59013eb8012a51f0 # v3.24.3 + uses: github/codeql-action/analyze@c36620d31ac7c881962c3d9dd939c40ec9434f2b # v3.26.12 with: - category: "/language:javascript" + category: "/language:javascript-typescript" typecheck: runs-on: ${{ matrix.os }} @@ -113,9 +107,9 @@ jobs: module: ["bundler", "node"] steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 - run: corepack enable - - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + - uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 with: node-version: 20 cache: "pnpm" @@ -124,7 +118,7 @@ jobs: run: pnpm install - name: Restore dist cache - uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2 + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: name: dist path: packages @@ -144,9 +138,9 @@ jobs: timeout-minutes: 10 steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 - run: corepack enable - - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + - uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 with: node-version: 20 cache: "pnpm" @@ -168,9 +162,9 @@ jobs: needs: - build steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 - run: corepack enable - - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + - uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 with: node-version: 20 cache: "pnpm" @@ -200,8 +194,17 @@ jobs: builder: ["vite", "webpack"] context: ["async", "default"] manifest: ["manifest-on", "manifest-off"] + payload: ["json", "js"] node: [18] exclude: + - builder: "webpack" + payload: "js" + - manifest: "manifest-off" + payload: "js" + - context: "default" + payload: "js" + - os: windows-latest + payload: "js" - env: "dev" builder: "webpack" - manifest: "manifest-off" @@ -210,9 +213,9 @@ jobs: timeout-minutes: 15 steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 - run: corepack enable - - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + - uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 with: node-version: ${{ matrix.node }} cache: "pnpm" @@ -220,34 +223,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-core | jq --raw-output '.[0].devDependencies["playwright-core"].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-core | jq --raw-output '.[0].devDependencies["playwright-core"].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@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2 + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: name: dist path: packages @@ -259,21 +239,23 @@ jobs: TEST_BUILDER: ${{ matrix.builder }} TEST_MANIFEST: ${{ matrix.manifest }} TEST_CONTEXT: ${{ matrix.context }} - SKIP_BUNDLE_SIZE: ${{ github.event_name != 'push' || matrix.env == 'dev' || matrix.builder == 'webpack' || matrix.context == 'default' || runner.os == 'Windows' }} + TEST_PAYLOAD: ${{ matrix.payload }} + SKIP_BUNDLE_SIZE: ${{ github.event_name != 'push' || matrix.env == 'dev' || matrix.builder == 'webpack' || matrix.context == 'default' || matrix.payload == 'js' || runner.os == 'Windows' }} - - uses: codecov/codecov-action@e0b68c6749509c5f83f984dd99a76a1c1a231044 # v4.0.1 + - uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.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 }} build-release: + concurrency: + group: release permissions: id-token: write if: | github.event_name == 'push' && github.repository == 'nuxt/nuxt' && !contains(github.event.head_commit.message, '[skip-release]') && - !startsWith(github.event.head_commit.message, 'chore') && !startsWith(github.event.head_commit.message, 'docs') needs: - lint @@ -283,11 +265,11 @@ jobs: timeout-minutes: 20 steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 with: fetch-depth: 0 - run: corepack enable - - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + - uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 with: node-version: 20 cache: "pnpm" @@ -296,18 +278,20 @@ jobs: run: pnpm install - name: Restore dist cache - uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2 + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: name: dist path: packages - name: Release Edge - run: ./scripts/release-edge.sh + run: ./scripts/release-edge.sh ${{ github.ref == 'refs/heads/main' && 'latest' || '3x' }} env: NODE_AUTH_TOKEN: ${{secrets.NODE_AUTH_TOKEN}} NPM_CONFIG_PROVENANCE: true release-pr: + concurrency: + group: release permissions: id-token: write pull-requests: write @@ -322,11 +306,11 @@ jobs: timeout-minutes: 20 steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 with: fetch-depth: 0 - run: corepack enable - - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + - uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 with: node-version: 20 cache: "pnpm" @@ -335,7 +319,7 @@ jobs: run: pnpm install - name: Restore dist cache - uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2 + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: name: dist path: packages diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index 9146d1ab4b..705f8d5c2d 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -17,6 +17,6 @@ jobs: runs-on: ubuntu-latest steps: - name: 'Checkout Repository' - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 - name: 'Dependency Review' - uses: actions/dependency-review-action@fd07d42ce87ab09f10c61a2d1a5e59e6c655620a # v4.1.1 + uses: actions/dependency-review-action@5a2ce3f5b92ee19cbb1541a4984c76d921601d7c # v4.3.4 diff --git a/.github/workflows/check-links.yml b/.github/workflows/docs-check-links.yml similarity index 78% rename from .github/workflows/check-links.yml rename to .github/workflows/docs-check-links.yml index 9b8ddaff9c..684644c94b 100644 --- a/.github/workflows/check-links.yml +++ b/.github/workflows/docs-check-links.yml @@ -1,4 +1,4 @@ -name: Check links with Lychee +name: docs on: pull_request: @@ -7,6 +7,7 @@ on: - "*.md" branches: - main + - 3.x # Remove default permissions of GITHUB_TOKEN for security # https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs @@ -18,17 +19,17 @@ 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@2cdf405574d6ef1f33a1d12acccd3ae82f47b3f2 # v4.1.0 with: path: .lycheecache key: cache-lychee-${{ github.sha }} restore-keys: cache-lychee- # check links with Lychee - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 - name: Lychee link checker - uses: lycheeverse/lychee-action@c053181aa0c3d17606addfe97a9075a32723548a # for v1.8.0 + uses: lycheeverse/lychee-action@f87f0a62993c2647717456af92593666acb3a500 # for v1.8.0 with: # arguments with file types to check args: >- diff --git a/.github/workflows/docs-deploy.yml b/.github/workflows/docs-deploy.yml index c4ad6fb3de..206d15e8d2 100644 --- a/.github/workflows/docs-deploy.yml +++ b/.github/workflows/docs-deploy.yml @@ -1,11 +1,11 @@ -name: Deploy docs +name: docs on: push: paths: - "docs/**" branches: - - main + - 3.x # Remove default permissions of GITHUB_TOKEN for security # https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index e71037f7e0..1948fd8ab5 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -1,4 +1,4 @@ -name: Docs +name: docs on: push: @@ -9,6 +9,7 @@ on: # autofix workflow will be triggered instead for PRs branches: - main + - 3.x - "!v[0-9]*" # Remove default permissions of GITHUB_TOKEN for security @@ -20,9 +21,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 - run: corepack enable - - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + - uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 with: node-version: 20 cache: "pnpm" @@ -30,6 +31,9 @@ jobs: - name: Install dependencies run: pnpm install + - name: Build (stub) + run: pnpm dev:prepare + - name: Lint (docs) run: pnpm lint:docs diff --git a/.github/workflows/label-issue.yml b/.github/workflows/label-issue.yml new file mode 100644 index 0000000000..ebc2e3921b --- /dev/null +++ b/.github/workflows/label-issue.yml @@ -0,0 +1,28 @@ +name: chore + +on: + issues: + types: + - opened + +permissions: + issues: write + +jobs: + add-issue-labels: + name: Add labels + runs-on: ubuntu-latest + if: github.repository == 'nuxt/nuxt' + steps: + - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + with: + script: | + // add 'pending triage' label if issue is created with no labels + if (context.payload.issue.labels.length === 0) { + github.rest.issues.addLabels({ + issue_number: context.payload.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + labels: ['pending triage'] + }) + } diff --git a/.github/workflows/label-pr.yml b/.github/workflows/label-pr.yml index 9d462f9f8c..e0469e757f 100644 --- a/.github/workflows/label-pr.yml +++ b/.github/workflows/label-pr.yml @@ -1,4 +1,4 @@ -name: Label PR +name: chore on: pull_request_target: @@ -6,6 +6,9 @@ on: - opened branches: - main + - 3.x + +permissions: {} jobs: add-pr-labels: diff --git a/.github/workflows/lint-sherif.yml b/.github/workflows/lint-sherif.yml new file mode 100644 index 0000000000..00d7bf5a68 --- /dev/null +++ b/.github/workflows/lint-sherif.yml @@ -0,0 +1,36 @@ +name: CI + +on: + push: + paths: + - "**/package.json" + branches: + - main + - 3.x + pull_request: + paths: + - "**/package.json" + branches: + - main + - 3.x + - "!v[0-9]*" + +permissions: + contents: read + +jobs: + lint-monorepo: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + - run: corepack enable + - uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 + with: + node-version: 20 + cache: "pnpm" + + - name: Install dependencies + run: pnpm install + - name: Lint monorepo + run: pnpm sherif -r multiple-dependency-versions diff --git a/.github/workflows/introspect.yml b/.github/workflows/lint-workflows.yml similarity index 59% rename from .github/workflows/introspect.yml rename to .github/workflows/lint-workflows.yml index 5f25bfa3b6..a3d7781132 100644 --- a/.github/workflows/introspect.yml +++ b/.github/workflows/lint-workflows.yml @@ -6,11 +6,13 @@ on: - ".github/workflows/**" branches: - main + - 3.x pull_request: paths: - ".github/workflows/**" branches: - main + - 3.x - "!v[0-9]*" permissions: @@ -21,9 +23,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 # From https://github.com/rhysd/actionlint/blob/main/docs/usage.md#use-actionlint-on-github-actions - name: Check workflow files - run: | - bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/590d3bd9dde0c91f7a66071d40eb84716526e5a6/scripts/download-actionlint.bash) 1.6.25 - ./actionlint -color -shellcheck="" + uses: docker://rhysd/actionlint:1.7.3@sha256:7617f05bd698cd2f1c3aedc05bc733ccec92cca0738f3e8722c32c5b42c70ae6 + with: + args: -color diff --git a/.github/workflows/notify-nuxt-bridge.yml b/.github/workflows/notify-nuxt-bridge.yml index fa97b12b95..b1f67c0509 100644 --- a/.github/workflows/notify-nuxt-bridge.yml +++ b/.github/workflows/notify-nuxt-bridge.yml @@ -4,6 +4,9 @@ on: types: [closed] paths: - "packages/nuxt/src/app/composables/**" + +permissions: {} + jobs: notify: if: github.event.pull_request.merged == true diff --git a/.github/workflows/nuxt2-edge.yml b/.github/workflows/nuxt2-edge.yml deleted file mode 100644 index 5e2df5cce6..0000000000 --- a/.github/workflows/nuxt2-edge.yml +++ /dev/null @@ -1,61 +0,0 @@ -name: nuxt2-nightly - -on: - workflow_dispatch: - schedule: - - cron: '0 0 * * *' - -# https://github.com/vitejs/vite/blob/main/.github/workflows/ci.yml -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 - -permissions: - contents: read - -jobs: - nightly: - if: github.repository_owner == 'nuxt' - runs-on: ubuntu-latest - permissions: - id-token: write - steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - with: - ref: '2.x' - fetch-depth: 0 # All history - - name: fetch tags - run: git fetch --depth=1 origin "+refs/tags/*:refs/tags/*" - - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 - with: - node-version: 18 - registry-url: 'https://registry.npmjs.org' - - name: install - run: yarn --check-files --frozen-lockfile --non-interactive - - name: lint - run: yarn test:lint - - name: audit - run: yarn run audit - - name: build - run: yarn test:fixtures -i - - name: lint app - run: yarn lint:app - - name: test types - run: yarn test:types - - name: test dev - run: yarn test:dev - - name: test unit - run: yarn test:unit - - name: test e2e - run: yarn test:e2e - - name: bump version - run: yarn lerna version --yes --no-changelog --no-git-tag-version --no-push --force-publish "*" --loglevel verbose - - name: build - run: PACKAGE_SUFFIX=edge yarn build - - name: publish - run: ./scripts/workspace-run npm publish -q - env: - NODE_AUTH_TOKEN: ${{secrets.NODE_AUTH_TOKEN}} - NPM_CONFIG_PROVENANCE: true - diff --git a/.github/workflows/release-pr.yml b/.github/workflows/release-pr.yml index 778e5c454b..403ab99d59 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: @@ -14,6 +14,8 @@ permissions: jobs: release-pr: if: github.repository == 'nuxt/nuxt' && github.event.issue.pull_request && github.event.comment.body == '/trigger release' + concurrency: + group: release permissions: id-token: write pull-requests: write @@ -22,20 +24,37 @@ jobs: steps: - name: Ensure action is by maintainer - uses: octokit/request-action@89697eb6635e52c6e1e5559f15b5c91ba5100cb0 # v2.1.9 + uses: octokit/request-action@dad4362715b7fb2ddedf9772c8670824af564f0d # v2.4.0 id: check_role with: route: GET /repos/nuxt/nuxt/collaborators/${{ github.event.comment.user.login }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - name: Get PR Info + id: pr + env: + PR_NUMBER: ${{ github.event.issue.number }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + COMMENT_AT: ${{ github.event.comment.created_at }} + run: | + pr="$(gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/"${GH_REPO}"/pulls/"${PR_NUMBER}")" + head_sha="$(echo "$pr" | jq -r .head.sha)" + updated_at="$(echo "$pr" | jq -r .updated_at)" + + if [[ $(date -d "$updated_at" +%s) -gt $(date -d "$COMMENT_AT" +%s) ]]; then + exit 1 + fi + + echo "head_sha=$head_sha" >> "$GITHUB_OUTPUT" + - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 with: - ref: refs/pull/${{ github.event.issue.number }}/merge - fetch-depth: 0 + ref: ${{ steps.pr.outputs.head_sha }} + fetch-depth: 1 - run: corepack enable - - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + - uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 with: node-version: 20 cache: "pnpm" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000000..1eda613a60 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,42 @@ +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.') || startsWith(github.event.head_commit.message, 'v4.')) + concurrency: + group: release + permissions: + id-token: write + runs-on: ubuntu-latest + timeout-minutes: 20 + steps: + - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + with: + fetch-depth: 0 + - run: corepack enable + - uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 + 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/reproduire.yml b/.github/workflows/reproduire.yml index fd7895b49a..d995f6d302 100644 --- a/.github/workflows/reproduire.yml +++ b/.github/workflows/reproduire.yml @@ -1,4 +1,4 @@ -name: Reproduire +name: chore on: issues: types: [labeled] @@ -10,7 +10,7 @@ jobs: reproduire: runs-on: ubuntu-latest steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 - uses: Hebilicious/reproduire@4b686ae9cbb72dad60f001d278b6e3b2ce40a9ac # v0.0.9-mp with: label: needs reproduction diff --git a/.github/workflows/scorecards.yml b/.github/workflows/scorecards.yml index 160cee1c97..b9cfabd45a 100644 --- a/.github/workflows/scorecards.yml +++ b/.github/workflows/scorecards.yml @@ -2,7 +2,7 @@ # by a third-party and are governed by separate terms of service, privacy # policy, and support documentation. -name: Scorecard supply-chain security +name: ossf on: # For Branch-Protection check. Only the default branch is supported. See # https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection @@ -28,15 +28,16 @@ jobs: id-token: write contents: read actions: read + if: github.event_name == 'push' || github.repository == 'nuxt/nuxt' steps: - name: "Checkout code" - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 with: persist-credentials: false - name: "Run analysis" - uses: ossf/scorecard-action@0864cf19026789058feabb7e87baa5f140aac736 # v2.3.1 + uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0 with: results_file: results.sarif results_format: sarif @@ -58,7 +59,8 @@ 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@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 + uses: actions/upload-artifact@604373da6381bf24206979c74d06a550515601b9 # v4.4.1 + if: github.repository == 'nuxt/nuxt' && success() with: name: SARIF file path: results.sarif @@ -66,6 +68,7 @@ jobs: # Upload the results to GitHub's code scanning dashboard. - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@379614612a29c9e28f31f39a59013eb8012a51f0 # v3.24.3 + uses: github/codeql-action/upload-sarif@c36620d31ac7c881962c3d9dd939c40ec9434f2b # v3.26.12 + if: github.repository == 'nuxt/nuxt' && success() with: sarif_file: results.sarif diff --git a/.github/workflows/semantic-pull-requests.yml b/.github/workflows/semantic-pull-requests.yml index 4ee0a30d46..d563f5045f 100644 --- a/.github/workflows/semantic-pull-requests.yml +++ b/.github/workflows/semantic-pull-requests.yml @@ -1,4 +1,4 @@ -name: Semantic pull request +name: chore on: pull_request_target: @@ -7,12 +7,12 @@ on: - edited - synchronize -permissions: - contents: read +permissions: {} jobs: - main: + semantic-pr: permissions: + contents: read pull-requests: read # for amannn/action-semantic-pull-request to analyze PRs statuses: write # for amannn/action-semantic-pull-request to mark status of analyzed PR if: github.repository == 'nuxt/nuxt' && !startsWith(github.head_ref, 'v') @@ -20,14 +20,16 @@ jobs: name: Semantic pull request steps: - name: Validate PR title - uses: amannn/action-semantic-pull-request@e9fabac35e210fea40ca5b14c0da95a099eff26f # v5.4.0 + uses: amannn/action-semantic-pull-request@0723387faaf9b38adef4775cd42cfd5155ed6017 # v5.5.3 with: scopes: | kit nuxi nuxt + rspack schema test-utils + ui-templates vite webpack deps diff --git a/.github/workflows/stackblitz-link.yml b/.github/workflows/stackblitz-link.yml new file mode 100644 index 0000000000..7da7c03a24 --- /dev/null +++ b/.github/workflows/stackblitz-link.yml @@ -0,0 +1,17 @@ +name: chore +on: + issues: + types: + opened + +permissions: + issues: write + +jobs: + stackblitz: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + - uses: huang-julien/reproduire-sur-stackblitz@9ceccbfbb0f2f9a9a8db2d1f0dd909cf5cfe67aa # v1.0.2 + with: + reproduction-heading: '### Reproduction' diff --git a/.github/workflows/reproduire-close.yml b/.github/workflows/stale.yml similarity index 89% rename from .github/workflows/reproduire-close.yml rename to .github/workflows/stale.yml index 6bf5ca88e6..23dccb624d 100644 --- a/.github/workflows/reproduire-close.yml +++ b/.github/workflows/stale.yml @@ -1,4 +1,4 @@ -name: Close incomplete issues +name: chore on: workflow_dispatch: schedule: @@ -10,6 +10,7 @@ permissions: jobs: stale: runs-on: ubuntu-latest + if: github.event_name == 'workflow_dispatch' || github.repository == 'nuxt/nuxt' steps: - uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e # v9.0.0 with: 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..a1ecadcefc 100644 --- a/.npmrc +++ b/.npmrc @@ -1,3 +1,4 @@ -shamefully-hoist=true -strict-peer-dependencies=false +# TODO: consider resolving webpack loaders to absolute path +public-hoist-pattern[]=*-loader +public-hoist-pattern[]=webpack-* shell-emulator=true diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000000..fc78d099a7 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1 @@ +* @danielroe diff --git a/README.md b/README.md index 1289880ae0..5c5e76cc4c 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@
@@ -13,16 +13,33 @@ 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) +- π [Professional Support](#professional-support) +- π [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,9 +47,10 @@ Use the following command to create a new starter project. This will create a st npx nuxi@latest initHello world
+ + ``` + +5. Create a simple unit test for this newly created component `~/components/HelloWorld.spec.ts` + + ```ts twoslash + import { describe, it, expect } from 'vitest' + import { mount } from '@vue/test-utils' + + import HelloWorld from './HelloWorld.vue' + + describe('HelloWorld', () => { + it('component renders Hello world properly', () => { + const wrapper = mount(HelloWorld) + expect(wrapper.text()).toContain('Hello world') + }) + }) + ``` + +6. Run vitest command + + ::package-managers + ```bash [npm] + npm run test + ``` + ```bash [yarn] + yarn test + ``` + ```bash [pnpm] + pnpm run test + ``` + ```bash [bun] + bun run test + ``` + :: + +Congratulations, you're all set to start unit testing with `@vue/test-utils` in Nuxt! Happy testing! + ## End-To-End Testing -For end-to-end testing, we support [Vitest](https://github.com/vitest-dev/vitest) and [Jest](https://jestjs.io) as test runners. +For end-to-end testing, we support [Vitest](https://github.com/vitest-dev/vitest), [Jest](https://jestjs.io), [Cucumber](https://cucumber.io/) and [Playwright](https://playwright.dev/) as test runners. ### Setup @@ -436,17 +553,22 @@ Please use the options below for the `setup` method. #### Features +- `build`: Whether to run a separate build step. + - Type: `boolean` + - Default: `true` (`false` if `browser` or `server` is disabled, or if a `host` is provided) + - `server`: Whether to launch a server to respond to requests in the test suite. - Type: `boolean` - - Default: `true` + - Default: `true` (`false` if a `host` is provided) - `port`: If provided, set the launched test server port to the value. - Type: `number | undefined` - Default: `undefined` -- `build`: Whether to run a separate build step. - - Type: `boolean` - - Default: `true` (`false` if `browser` or `server` is disabled) +- `host`: If provided, a URL to use as the test target instead of building and running a new server. Useful for running "real" end-to-end tests against a deployed version of your application, or against an already running local server (which may provide a significant reduction in test execution timings). See the [target host end-to-end example below](#target-host-end-to-end-example). + - Type: `string` + - Default: `undefined` + - `browser`: Under the hood, Nuxt test utils uses [`playwright`](https://playwright.dev) to carry out browser testing. If this option is set, a browser will be launched and can be controlled in the subsequent test suite. - Type: `boolean` - Default: `false` @@ -455,9 +577,34 @@ Please use the options below for the `setup` method. - `type`: The type of browser to launch - either `chromium`, `firefox` or `webkit` - `launch`: `object` of options that will be passed to playwright when launching the browser. See [full API reference](https://playwright.dev/docs/api/class-browsertype#browser-type-launch). - `runner`: Specify the runner for the test suite. Currently, [Vitest](https://vitest.dev) is recommended. - - Type: `'vitest' | 'jest'` + - Type: `'vitest' | 'jest' | 'cucumber'` - Default: `'vitest'` +##### Target `host` end-to-end example + +A common use-case for end-to-end testing is running the tests against a deployed application running in the same environment typically used for Production. + +For local development or automated deploy pipelines, testing against a separate local server can be more efficient and is typically faster than allowing the test framework to rebuild between tests. + +To utilize a separate target host for end-to-end tests, simply provide the `host` property of the `setup` function with the desired URL. + +```ts +import { setup, createPage } from '@nuxt/test-utils/e2e' +import { describe, it, expect } from 'vitest' + +describe('login page', async () => { + await setup({ + host: 'http://localhost:8787', + }) + + it('displays the email and password fields', async () => { + const page = await createPage('/login') + expect(await page.getByTestId('email').isVisible()).toBe(true) + expect(await page.getByTestId('password').isVisible()).toBe(true) + }) +}) +``` + ### APIs #### `$fetch(url)` @@ -494,11 +641,11 @@ const pageUrl = url('/page') ### Testing in a Browser -We provide built-in support using Playwright within `@nuxt/test-utils`, but you can also use other test runners for end-to-end browser testing. +We provide built-in support using Playwright within `@nuxt/test-utils`, either programmatically or via the Playwright test runner. #### `createPage(url)` -You can create a configured Playwright browser instance, and (optionally) point it at a path from the running server. You can find out more about the API methods available from [in the Playwright documentation](https://playwright.dev/docs/api/class-page). +Within `vitest`, `jest` or `cucumber`, you can create a configured Playwright browser instance with `createPage`, and (optionally) point it at a path from the running server. You can find out more about the API methods available from [in the Playwright documentation](https://playwright.dev/docs/api/class-page). ```ts twoslash import { createPage } from '@nuxt/test-utils/e2e' @@ -506,3 +653,70 @@ import { createPage } from '@nuxt/test-utils/e2e' const page = await createPage('/page') // you can access all the Playwright APIs from the `page` variable ``` + +#### Testing with Playwright Test Runner + +We also provide first-class support for testing Nuxt within [the Playwright test runner](https://playwright.dev/docs/intro). + +::package-managers +```bash [npm] +npm i --save-dev @playwright/test @nuxt/test-utils +``` +```bash [yarn] +yarn add --dev @playwright/test @nuxt/test-utils +``` +```bash [pnpm] +pnpm add -D @playwright/test @nuxt/test-utils +``` +```bash [bun] +bun add --dev @playwright/test @nuxt/test-utils +``` +:: + +You can provide global Nuxt configuration, with the same configuration details as the `setup()` function mentioned earlier in this section. + +```ts [playwright.config.ts] +import { fileURLToPath } from 'node:url' +import { defineConfig, devices } from '@playwright/test' +import type { ConfigOptions } from '@nuxt/test-utils/playwright' + +export default defineConfig{{ data }}
- +{{ date }}
+{{ date }}