Skip to content

[break] refactor(config): split config into project (settings/) and local (profiles/) scopes#774

Open
bofeng-song wants to merge 7 commits into
cocos:mainfrom
bofeng-song:feat/config-scope-settings-profiles
Open

[break] refactor(config): split config into project (settings/) and local (profiles/) scopes#774
bofeng-song wants to merge 7 commits into
cocos:mainfrom
bofeng-song:feat/config-scope-settings-profiles

Conversation

@bofeng-song

Copy link
Copy Markdown
Contributor

Summary

Personal, per-machine scene state (camera views, gizmo / scene-view display preferences) was previously written to a committed <project>/cocos.config.json, leaking local preferences into version control.

This PR introduces a local configuration scope alongside project, following the Cocos Creator directory convention:

Scope File Versioned
project / committed <project>/settings/cocos.config.json yes
local / personal <project>/profiles/cocos.config.json gitignored

Both remain single consolidated files grouped by module name (cli's own key names — no Creator key-name interop).

Changes

  • Scope model — add 'local' to ConfigurationScope and a SaveLocal message type.
  • BaseConfiguration — add a local bucket; scoped get / set / remove; merged reads resolve default <- project <- local.
  • ConfigurationManager — load and save both files; relocate a legacy root cocos.config.json into settings/ and remove it; adjust the $schema path for the new settings/ location.
  • Scene routing — personal keys (camera, gizmo, sceneView, camera-infos, camera-uuids) now use the local scope; tick stays in project.
  • SceneConfig — migrate personal keys from the project bucket to local on init (existing projects self-heal).
  • lib/configuration — expose saveLocal / getLocalConfigPath / onDidSaveLocal to mirror the existing save / getConfigPath / onDidSave surface.
  • Housekeeping — ignore profiles/cocos.config.json; relocate the test fixture config into settings/; update the DTS snapshot.

Migration behavior

On load, a project that only has a legacy root cocos.config.json is relocated to settings/cocos.config.json (root file removed), and its personal keys are split out into profiles/cocos.config.json. Existing camera views / display preferences continue to resolve.

Testing

  • npx tsc -b — clean.
  • npx jest src/core/configuration/test/manager.test.ts src/core/scene/test/scene-configs.test.ts — 31 passed.
  • npx jest --roots packages/cocos-cli-types --testPathPattern dts-snapshot — 9 passed (snapshot updated).

…ofiles/) scopes

Personal, per-machine scene state (camera views, gizmo / scene-view display
preferences) was written to a committed <project>/cocos.config.json, leaking
local preferences into version control.

Introduce a 'local' configuration scope alongside 'project', following the
Cocos Creator directory convention:
- project / committed         -> <project>/settings/cocos.config.json
- local / personal (gitignore)-> <project>/profiles/cocos.config.json

- Add 'local' to ConfigurationScope and a SaveLocal message type.
- BaseConfiguration: add a local bucket; scoped get/set/remove; merged reads
  resolve default <- project <- local.
- ConfigurationManager: load and save both files; relocate a legacy root
  cocos.config.json into settings/ and remove it; adjust the $schema path for
  the new settings/ location.
- Route scene personal keys (camera, gizmo, sceneView, camera-infos,
  camera-uuids) to the local scope; tick stays in project.
- SceneConfig: migrate personal keys from the project bucket to local on init.
- lib/configuration: expose saveLocal / getLocalConfigPath / onDidSaveLocal.
- Ignore profiles/cocos.config.json; relocate the test fixture config into
  settings/ and update the DTS snapshot.
@bofeng-song
bofeng-song requested review from knoxHuang and star-e July 20, 2026 07:15
…rameter

Replace the separate saveLocal / getLocalConfigPath / onDidSaveLocal helpers
on lib/configuration with an optional `scope` parameter on save, getConfigPath
and onDidSave. The parameter defaults to 'project', so existing call sites keep
their current behavior; pass 'local' to target profiles/cocos.config.json.

Update the DTS snapshot accordingly.
@bofeng-song bofeng-song changed the title refactor(config): split config into project (settings/) and local (profiles/) scopes [break] refactor(config): split config into project (settings/) and local (profiles/) scopes Jul 20, 2026
Comment thread tests/fixtures/projects/asset-operation/settings/cocos.config.json

@knoxHuang knoxHuang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the latest head. The fixture path regression is fixed, the relevant tests and typecheck pass, and I found no additional functional issues. Approval is independent of the still-running CI checks.

@bofeng-song bofeng-song reopened this Jul 20, 2026
…tures

The project scope config now lives in <project>/settings/cocos.config.json,
but the e2e project manager treated the whole `settings` directory as Cocos
cache: it deleted it from the source fixture and excluded it from the copied
test project. As a result the temp build project had no builder config, so the
build produced no output and builder-query-default-build-config fell back to a
default template.

Narrow the cache entry to `settings/v2` (the actual Creator scene cache) so the
committed settings/cocos.config.json is preserved and copied, and normalize the
copy-filter path separators so the nested cache dir also matches on Windows.
@bofeng-song bofeng-song reopened this Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants