Document the generate-fixtures asset store (fixtures.assets, $cwa->asset(), prune-fixture-assets)

已关闭
#242 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
45/100
Issue 类型
文档
描述清晰度
基本清楚
活跃度
活跃
技术栈
php, yaml
领域
api, documentation

调研方向

Start in content/4.api/ and find the existing generate-fixtures and scaffold pages, then read the config and command details in the issue body and in components-web-app/api-components-bundle#466. Add a section that covers the fixtures.assets config keys, the one-off --assets-store and --assets-dir options, the .assets.json manifest, the prune-fixture-assets command and the load-time error. Done when each bullet in the issue has a matching passage and the page matches the merged #466 behaviour.

由索引模型根据 Issue 内容生成。

描述

components-web-app/api-components-bundle#466 (for components-web-app/api-components-bundle#462) adds a fixture asset store to generate-fixtures. The API bundle's fixture docs (content/4.api/, the generate-fixtures / scaffold pages) should cover the following.

What to document

  • Why it exists. Without it, generate-fixtures writes a readable copy of every uploaded file to assets/ beside the scaffold. That is still the default. For a large site you can instead keep the files in a store and commit only a small manifest.

  • Configuration

    silverback_api_components:
      fixtures:
        assets:
          store: local | flysystem      # an env var works, e.g. '%env(FIXTURE_ASSETS_STORE)%'
          path: ...                     # local: the folder; default is assets/ beside the scaffold class
          adapter: gcloud               # flysystem: one of the app's filesystem adapter aliases (required)
          prefix: fixtures/             # flysystem: folder within the adapter
    

    Generating and loading both read this config. Generating needs write access to the store, and loading needs read access.

  • What gets generated

    • Each file is stored once under its SHA-256.
    • The class refers to it as $cwa->asset('<hash>').
    • The class gets a <ClassName>.assets.json manifest beside it, listing name, mime type, size and source fields. Commit the manifest with the class.
    • The same content uploaded under another name is written as $cwa->asset('<hash>', name: '…').
  • One-off options: --assets-store local|flysystem and --assets-dir <folder> (a local folder).

  • Loading: doctrine:fixtures:load resolves each hash through the configured store and stores the file under its manifest name. A missing or changed asset fails the load with a message naming the store.

  • Pruning

    • Generating into a local store deletes the assets the new manifest no longer lists. Give each scaffold its own local folder.
    • silverback:api-components:prune-fixture-assets <manifest>... [--dry-run] deletes from the store the assets that none of the given manifests lists. List every manifest a branch or deployment still loads.
    • Only hash-named files directly under the prefix are ever touched.
  • Hand-written scaffolds can call $cwa->asset() too, with a manifest beside the class.

  • Not built yet: an export-time --max-dimension downscale (see #462).

主要语言
TypeScript
星标
0
派生
0
平均合并
1 小时 20 分钟
30 天内合并 PR
1

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

components-web-app/docs 的其他 Issue

查看 components-web-app/docs 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。