-
Notifications
You must be signed in to change notification settings - Fork 141
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
feat(fsapp): add fsapp plugin #2784
feat(fsapp): add fsapp plugin #2784
Conversation
5f917dd
to
7011217
Compare
We should utilize glob to find all files that match env.<env_name>.ts and then use babel to traverse and verify single default export with the correct import of defineEnv. glob(<root_dir>/**/env.*.ts) -> babel.traverse -> verify exports/imports -> bundleRequire -> write envs |
9ae11dd
to
b93a263
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing to notice is that dynamic args is reading from anywhere in node_modules which fails us in a monorepo. We actually should only look at the dependencies and devDependencies installed
fixed in latest |
if ((message as any) instanceof Error) { | ||
const errorStackArr = (message as any).stack.split( | ||
'\n', | ||
) as unknown as Array<string>; | ||
|
||
errorStackArr.shift(); | ||
|
||
FlagshipCodeManager.shared.emit( | ||
'onLog', | ||
chalk.dim('\n' + errorStackArr.join('\n')), | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs to be looked into further
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is no great way to split the stack from the error message, so we may just want to display the stack instead since it includes both - the stack can be useful.
|
||
async function validateEnvFiles(baseDir: string): Promise<string[]> { | ||
const pattern = path.join(baseDir, '**', 'env.*.ts'); | ||
const files = glob.sync(pattern, {ignore: '**/node_modules/**'}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can collect files here but how can we guarantee that these are intended to be env files...we shouldn't just throw an error due to it being named in a particular way but not conforming to a format. this could be a different file used for something else. something to think about
packages/plugin-fsapp/src/index.ts
Outdated
}, | ||
}); | ||
|
||
if (!hasDefaultExport) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should likely only throw an error here if the import does not exist that way we know it's supposed to be a runtime env
6286a8b
to
aaadc71
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me, just some minor nitpicks or questions
packages/cli/src/transformers/transformers-0.72/ios/project-pbxproj.ts
Outdated
Show resolved
Hide resolved
@@ -0,0 +1,464 @@ | |||
/// <reference types="@brandingbrand/code-cli-kit/types" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this file is fairly large, wonder if we should break up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is probably another thing we can do as well, it will minimally help with readability and testing without exporting those functions through the main plugin.
packages/plugin-fsapp/src/index.ts
Outdated
} | ||
|
||
if (!hasDefineEnvImport) { | ||
throw new Error( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this one might be more of a warning, I believe it will still work if they don't use defineEnv
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah I was thinking we need to not necessarily throw an error for certain things but we need a way to know it's an env file
options: PrebuildOptions, | ||
): Promise<void> { | ||
logger.log('Processing environment files for Android...'); | ||
await processAndLinkEnvs(options as any); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like we need to repeat this step in both android and iOS cause we don't know if one or both are running. I wonder if we need to build in another way to run these type of things, though this may be a unique case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah we will add a "universal" or something like that that will run once that has no relation to a particular platform when we move to presets and plugins
packages/plugin-fsapp/src/index.ts
Outdated
* @returns {Promise<void>} A promise that resolves when environment processing is complete. | ||
*/ | ||
async function processAndLinkEnvs( | ||
options: PrebuildOptions & Record<string, string>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be PrebuildOptions & {env?: string}
? so we don't have to cast the call sites to any?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So for now the call sites will still need to be casted because of the explicit nature of the definePlugin where the options are defined as explicitly the prebuild options....going to update the type to be non-breaking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated to allow this.
3f63f1f
to
05888c3
Compare
ba8706a
to
6d77450
Compare
632e384
into
brandingbrand:feature/app-router
Describe your changes
Created a new
@brandingbrand/code-plugin-fsapp
package that handles FSApp environment configuration and native module setup. This plugin extracts FSApp-specific functionality from the core CLI into a dedicated plugin, improving modularity and maintainability.Key changes:
Issue ticket number and link
Type of change
Test Plan
Run comprehensive unit tests for:
Test package installation and configuration:
Ensure environment switching and native modules are properly configured for both iOS and Android platforms.
Checklist before requesting a review