1
0
mirror of https://github.com/owncloud/ocis.git synced 2026-10-23 23:29:02 +03:00
Files
ocis/web/nx.json
Matteo 30ff89b1de [full-ci] chore(web): adopt Nx as task orchestrator for web/ (#13039)
feat(web): adopt Nx as task orchestrator for web/

Introduces Nx on top of the existing pnpm workspace, so lint/typecheck/
test can be scoped to only the projects affected by a change instead of
running against the whole monorepo on every PR.

- Phase 0: add nx (^23.2.1) as a workspace devDependency, nx.json with a
  targetDefaults entry for test:unit (cache: true), ignore .nx/cache and
  .nx/workspace-data. No behavior change to any existing script.
- Phase 1: register @nx/vitest's inference plugin so every package with
  a vitest.config.ts gets a real, cached "test" target read directly
  from its own config, not just the packages that happened to already
  declare a "test:unit" npm script. Excludes vite.config.common.ts,
  the root vite.config.ts and vite.cern.config.ts from the plugin's
  default glob - none of them are test configs, and loading them as one
  aborts the whole project graph. defaultBase: "master" (bare `nx
  affected` defaults to a branch named "main"). testMode: "run" so `nx
  run <project>:test` doesn't default to vitest's watch mode locally.
- Phase 2a: register @nx/eslint/plugin for a per-project "lint" target
  on every project (root `lint` script untouched).
- Phase 2b: register @nx/vite/plugin's typecheckTargetName for a
  per-project "typecheck" target on projects with their own real
  vite.config.ts (design-system, web-client, web-pkg, web-test-helpers).
  The ~20 web-app-*/web-runtime projects only have a vitest.config.ts
  and aren't covered; root `pnpm run check:types` (whole-repo vue-tsc)
  stays the one check that covers everything.
- Phase 3 (CI): adds a `full-run` output to detect-web-changes - true for
  push to master/stable-* or a `[full-ci]` PR title (unchanged behavior),
  false for a normal PR, which instead runs `nx affected -t lint` / `nx
  affected -t test --base=<PR base sha>`. Added fetch-depth: 0 to
  web-build-test's checkout, needed for `nx affected --base=<sha>` to
  find that commit. Check types and the full-run unit-test path
  deliberately stay whole-repo (see inline comments for why).

Also:
- removes design-system's broken "lint": "lint:stylelint" alias (needed
  the "lint" name free for the new per-project target; it was never
  callable as written - "lint:stylelint" isn't a binary - and nothing
  called it).
- makes the design system's webfontloader import fire-and-forget so an
  in-flight rejection at test teardown doesn't surface as an unhandled
  rejection under vitest's per-project runs.
- pin `typescript` via `pnpm.overrides`. Adding nx's own devDependencies
  makes pnpm re-resolve the workspace's peer graph, and today's registry
  now has a typescript 6.x that some peer ranges accept - without the
  pin, half the vue-peer-dependent packages (pinia, vue-router,
  vue3-gettext, focus-trap-vue, ...) fork into a second, incompatible
  module instance. Same pin as the dependency-cycle fix, for an
  unrelated reason; needed independently here since this branch changes
  package.json on its own.

nx's `dependsOn: ["^target"]` errors outright on a circular task graph,
so this only works once the pre-existing web-pkg/design-system/
web-test-helpers dependency cycle is fixed - see
fix(web): break web-pkg/design-system/web-test-helpers dependency cycle,
which this PR targets rather than master.

Verified: nx run-many -t test / lint / typecheck succeed for all
projects; nx show projects --affected --files=... resolves correctly for
shared config changes; nx affected -t lint --base=<sha> matches pnpm
lint; root pnpm lint/check:types/check:format/test:unit/build all still
pass unchanged (380 files / 3128 tests).
2026-10-02 08:58:49 +02:00

50 lines
1.5 KiB
JSON

{
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"defaultBase": "master",
"namedInputs": {
"default": ["{projectRoot}/**/*", "sharedGlobals"],
"sharedGlobals": [
"{workspaceRoot}/nx.json",
"{workspaceRoot}/pnpm-lock.yaml",
"{workspaceRoot}/pnpm-workspace.yaml",
"{workspaceRoot}/tsconfig.json",
"{workspaceRoot}/eslint.config.js",
"{workspaceRoot}/vite.config.common.ts",
"{workspaceRoot}/vitest.config.ts",
"{workspaceRoot}/tests/unit/**/*"
]
},
"plugins": [
{
"plugin": "@nx/vitest",
"exclude": ["vite.config.ts", "vite.config.common.ts", "vite.cern.config.ts"],
"options": {
"testMode": "run"
}
},
"@nx/eslint/plugin",
{
"plugin": "@nx/vite/plugin",
"exclude": ["vite.config.ts", "vite.config.common.ts", "vite.cern.config.ts"],
"options": {
"buildTargetName": "nx-vite-build-unused",
"serveTargetName": "nx-vite-serve-unused",
"devTargetName": "nx-vite-dev-unused",
"previewTargetName": "nx-vite-preview-unused",
"serveStaticTargetName": "nx-vite-serve-static-unused",
"watchDepsTargetName": "nx-vite-watch-deps-unused",
"buildDepsTargetName": "nx-vite-build-deps-unused",
"typecheckTargetName": "typecheck"
}
}
],
"targetDefaults": {
"test": {
"cache": true,
"inputs": ["default", "^default"],
"outputs": []
}
},
"analytics": false
}