refactor: run build directly on catalyst core application#2517
refactor: run build directly on catalyst core application#2517matthewvolk wants to merge 5 commits intocanaryfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
3 Skipped Deployments
|
| }), | ||
| }; | ||
|
|
||
| const wranglerConfig = { |
There was a problem hiding this comment.
Are we moving away from templates then? For preview, I need to create a copy of wranger.jsonc too and want to make sure we have one source of truth.
There was a problem hiding this comment.
I'm not opinionated on this, and I agree that my only requirement is that we have a single source of truth. If we want, I can read wrangler.jsonc from fs, and pass that to the build function from OpenNext... keep in mind, we also need to modify certain fields in wrangler.jsonc, so maybe we make a lib function to handle reading/writing/etc. the file. The file can have the config as an object, and then methods to write to wrangler.jsonc using fs, both using the same object as a source of truth?
There was a problem hiding this comment.
It's fine either way by me, just feel like we should delete the other templates if we're not using them?
| return createConsola({ level: options.verbose ? LogLevels.verbose : LogLevels.info }); | ||
| } | ||
|
|
||
| export function createExec(options: BuildCommandOptions, exec: Exec = _execa) { |
There was a problem hiding this comment.
Not sure if these abstraction are worth it, can you provide your reasoning? Maybe they need to be lib utilities?
There was a problem hiding this comment.
I'm cool with lib utils - I'm trying to follow some of the principles in this article, so this abstraction does a couple things:
- Helps asserts behavior (“verbose uses inherit”), not which process lib (execa, child_process, etc.) we called.
- It also encodes the
--verbosepolicy onexecin a single place. Other commands can usecreateExecand get--verboselogging options for free. No drift across different call sites.
If you still think it's too early of an abstraction, let's discuss; I'm not set in stone by any means, and open to inlining it if you think it's better
There was a problem hiding this comment.
Been thinking about this all day.
- How are you asserting the behavior? Just curious, seems to be it would look the same with or without the abstraction. I understand we don't want to test implementation details, only outputs, but how do we test the output of the command?
- I agree, but thinking about
startas an example, we wouldn't really want to hide it away, thinking this is only required here for the moment?
0a35e37 to
573e99b
Compare
|
289a874 to
0014f5f
Compare
0014f5f to
837c9e8
Compare
837c9e8 to
ec9bd6a
Compare
677f182 to
3f329db
Compare
3f329db to
34ca26e
Compare
| }), | ||
| }; | ||
|
|
||
| const wranglerConfig = { |
There was a problem hiding this comment.
It's fine either way by me, just feel like we should delete the other templates if we're not using them?
| }; | ||
|
|
||
| export function resolveFramework(options: Options, getConfig: Config, logger: Logger) { | ||
| const config = getConfig(); |
There was a problem hiding this comment.
Missing rootDir being passed to this function.
Which brings up another talking point, do we care about the rootDir option for commands? I know some of them have it, others don't. For my tests, adding this rootDir option was valuable.
| import { getProjectConfig } from '../../lib/project-config'; | ||
| import { resolveFramework } from '../../lib/resolve-framework'; | ||
|
|
||
| import { opennextBuild } from './opennext-build'; |
There was a problem hiding this comment.
openNextBuild or opennextBuild? 🤔
| return createConsola({ level: options.verbose ? LogLevels.verbose : LogLevels.info }); | ||
| } | ||
|
|
||
| export function createExec(options: BuildCommandOptions, exec: Exec = _execa) { |
There was a problem hiding this comment.
Been thinking about this all day.
- How are you asserting the behavior? Just curious, seems to be it would look the same with or without the abstraction. I understand we don't want to test implementation details, only outputs, but how do we test the output of the command?
- I agree, but thinking about
startas an example, we wouldn't really want to hide it away, thinking this is only required here for the moment?
|
|
||
| try { | ||
| const openNextConfig = { | ||
| buildCommand: 'dotenv -e .env.local -- node ./scripts/generate.cjs && next build', |
There was a problem hiding this comment.
| buildCommand: 'dotenv -e .env.local -- node ./scripts/generate.cjs && next build', | |
| buildCommand: 'next build', |
| `wrangler@${WRANGLER_VERSION}`, | ||
| 'deploy', | ||
| '--config', | ||
| join(process.cwd(), '.bigcommerce', 'wrangler.jsonc'), |
There was a problem hiding this comment.
Is process.cwd() necessary since we define the cwd below?
|
Fixed by #2527 |
What/Why?
Previously,
buildwas running inside of a temporary directory in an effort to abstract away Cloudflare-related configuration files (wrangler.jsonc,open-next.config.ts) and dependencies (@opennextjs/cloudflare). The only artifact that we copied from this temporary directory back into the original Catalyst project was a singleworker.jsfile.Unfortunately, we discovered that the
opennextjs-cloudflare previewcommand needs access to some of the intermediary files that were being deleted when the temporary folder was deleted at the end ofbuild. So, we had to change course. We are now installing Cloudflare-related dependencies in the CLI (instead of core) and using anesbuildplugin to resolve imports pointing to these dependencies. To make this work, we had to resort to patching@opennextjs/cloudflare, but have started a conversation with Cloudflare to see if we can more reliable support.Testing
Updated test suite
Migration
N/A
JIRA: CATALYST-1421