Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[request] Command to only re-build theme.json (or no-op) #2139

Closed
3 tasks done
strarsis opened this issue Mar 4, 2023 · 3 comments
Closed
3 tasks done

[request] Command to only re-build theme.json (or no-op) #2139

strarsis opened this issue Mar 4, 2023 · 3 comments
Labels

Comments

@strarsis
Copy link

strarsis commented Mar 4, 2023

Agreement

The feature

A separate bud command (or from its theme.json extension) that re-generates the theme.json
(or no-op if the theme.json generation by bud is not enabled).

E.g. something like bud build theme.json or bud build-themejson maybe?
Or is there already a sub-command or other flag/option that can be used to only build the theme.json?

Use case

The wp i18n CLI tool can (and should) also scan the theme.json for source translation strings
(as of colors, font-sizes, template parts, etc.).
When the translate:pot script of Sage theme is invoked, the theme.json should first be re-build
(if generation is enabled, otherwise just no-op), for the theme.json to be scanned being up-to-date.
A full rebuild otherwise can be too time consuming and also distracting,
as only the theme.json is (currently) relevant for scanning of translation source strings.

Notes

Related issue (Sage theme): roots/sage#3076 (comment)

@strarsis strarsis changed the title [request] Command to only build the `` [request] Command to only re-build theme.json (or no-op) Mar 4, 2023
@kellymears
Copy link
Contributor

kellymears commented Mar 5, 2023

For now, my inclination is to not add complexity and continue to treat it as a build artifact (like entrypoints.json or manifest.json).

It is relatively easy to add as a bespoke script. Maybe build-scripts/pre-translate.js:

import {factory} from '@roots/bud';

const bud = await factory();
await bud.extensions.add(`@roots/bud-wordpress-theme-json`)

//
const {path, ...json} = bud.wpjson.options
await bud.fs.json.write(path, json);

Then add it to scripts in package.json:

// ...
"scripts": {
  "translate": "node ./build-scripts/pre-translate.js && wp translate ..."
}
// ...

Not super ideal but I think this is a very particular need. Especially if there is js to translate, since that necessitates a build anyway?

Willing to revisit this in the future or entertain follow up. I do think there is something to making it easier to generically script with bud.js. I've tried to make it simple but it's been secondary to the cli since that's how nearly 100% of users interface with it.

@strarsis
Copy link
Author

strarsis commented Mar 7, 2023

Yes, this approach looks good.

Would it make sense to have a npm package as bud extension that adds a sub-command?

that necessitates a build anyway?
No, it indeed scans the original JavaScript source files in resources/.

kodiakhq bot pushed a commit that referenced this issue Mar 21, 2023
- improve: reuse cli instance
- make instantiating with node api simpler
- upgrade to ink 4
- docs: add pnpm install instructions

refers:

- #2139 

## Type of change

**PATCH: backwards compatible change**



This PR includes breaking changes to the following core packages:

- none

This PR includes breaking changes to the follow extensions:

- none

## Dependencies

### Adds

- none

### Removes

- none
@github-actions
Copy link

github-actions bot commented May 7, 2023

Message to comment on stale issues. If none provided, will not mark issues stale

@github-actions github-actions bot added the stale label May 7, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants