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

feat(build): add account id constant to plugins #5811

Merged
merged 5 commits into from
Aug 23, 2024

Conversation

JGAntunes
Copy link
Contributor

@JGAntunes JGAntunes commented Aug 22, 2024

🎉 Thanks for submitting a pull request! 🎉

Summary

Follow up to FRP-1269 - https://linear.app/netlify/issue/FRP-1269/information-request-is-the-account-id-available-for-build-plugins - after exposing the account_id within the siteInfo object from @netlify/config we still need to expose to the plugin executions. This adds ACCOUNT_ID as a undocumented constant we can use internally for now.

Validated this locally through some plugin executions that logged the constants object also:

$> node ~/workspace/netlify/build/packages/build/lib/core/bin.js --debug=true --site-id="d51b3ebf-013f-45fc-b959-b6e48c73be2d" --token=<some-token> --offline=false .


Netlify Build
────────────────────────────────────────────────────────────────
(...)
/plugin (onPreBuild event)
────────────────────────────────────────────────────────────────

{
  "CONFIG_PATH": "netlify.toml",
  "FUNCTIONS_DIST": ".netlify/functions/",
  "EDGE_FUNCTIONS_DIST": ".netlify/edge-functions-dist/",
  "CACHE_DIR": ".netlify/cache",
  "IS_LOCAL": true,
  "NETLIFY_BUILD_VERSION": "29.53.1",
  "SITE_ID": "d51b3ebf-013f-45fc-b959-b6e48c73be2d",
  "ACCOUNT_ID": "5e21500276ee6f05945b848b",
  
  (...)
  
  
$> node ~/workspace/netlify/build/packages/build/lib/core/bin.js --debug=true --account-id="i-am-an-account-id-yall" --offline=true --mode=buildbot .

Netlify Build
────────────────────────────────────────────────────────────────

(...)
/plugin (onPreBuild event)
────────────────────────────────────────────────────────────────
{
  "CONFIG_PATH": "netlify.toml",
  "FUNCTIONS_DIST": ".netlify/functions/",
  "EDGE_FUNCTIONS_DIST": ".netlify/edge-functions-dist/",
  "CACHE_DIR": ".netlify/cache",
  "IS_LOCAL": false,
  "NETLIFY_BUILD_VERSION": "29.53.1",
  "ACCOUNT_ID": "i-am-an-account-id-yall",
  "NETLIFY_API_HOST": "api.netlify.com",
  "INTERNAL_FUNCTIONS_SRC": ".netlify/functions-internal",
  "INTERNAL_EDGE_FUNCTIONS_SRC": ".netlify/edge-functions",
  "PUBLISH_DIR": "."
}

For us to review and ship your PR efficiently, please perform the following steps:

  • Open a bug/issue before writing your code 🧑‍💻. This ensures
    we can discuss the changes and get feedback from everyone that should be involved. If you`re fixing a typo or
    something that`s on fire 🔥 (e.g. incident related), you can skip this step.
  • Read the contribution guidelines 📖. This ensures
    your code follows our style guide and passes our tests.
  • Update or add tests (if any source code was changed or added) 🧪
  • Update or add documentation (if features were changed or added) 📝
  • Make sure the status checks below are successful ✅

A picture of a cute animal (not mandatory, but encouraged)

@JGAntunes JGAntunes self-assigned this Aug 22, 2024
@JGAntunes JGAntunes requested review from a team as code owners August 22, 2024 11:12
Copy link
Contributor

This pull request adds or modifies JavaScript (.js, .cjs, .mjs) files.
Consider converting them to TypeScript.

@@ -120,7 +128,7 @@ const parseSource = (source: string) => {

// Parses a JS/TS source and returns the resulting AST. If there is a parsing
// error, it will get swallowed and `null` will be returned.
export const safelyParseSource = (source: string) => {
export const safelyParseSource = (source: string): Program | null => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is an unrelated change I had to do to make the CI happy. All the jobs installing deps without lockfile were failing because of tsc errors:

@JGAntunes JGAntunes requested a review from pieh August 22, 2024 15:23
@JGAntunes JGAntunes merged commit 91d6e49 into main Aug 23, 2024
38 checks passed
@JGAntunes JGAntunes deleted the feat/add-account-id-constant branch August 23, 2024 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants