-
Notifications
You must be signed in to change notification settings - Fork 368
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
refactor: cleanup createSiteAddon function #1336
Conversation
src/commands/functions/create.js
Outdated
const addonCreated = await createSiteAddon(api.accessToken, addonName, siteId, siteData, this.log) | ||
if (addonCreated) { | ||
if (addonDidInstall) { | ||
const { addEnvVariables } = require('../../utils/dev') |
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.
Do we have a good reason to dynamically load require()
here (I think not)?
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.
Definitely not
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'm actually not sure why this is there. Looks it's only relevant when calling addonDidInstall
a bit after and addEnvVariables
is also called after installAddons
.
// const manifest = await getAddonManifest(addonName, accessToken); | ||
|
||
const configValues = rawFlags | ||
// if (manifest.config) { |
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.
🧹
|
||
/** main section - shamelessly adapted from CLI. we can extract and dedupe later. */ | ||
/** but we can DRY things up later. */ |
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.
:)
Related to #310 and #1331
Wanted to fix #1331, but couldn't do it since the addons code doesn't allow getting the env variables easily at the moment:
I going to do some refactoring first so we can have
cli/src/utils/dev.js
Line 25 in b88cf6d
process.env
I removed a bunch of outdated comments from
utils/addons.js
and did some code cleanup.Note that part of that function is duplicated from:
cli/src/commands/addons/create.js
Line 155 in b88cf6d
I follow up in another PR.
Also changed some code in
functions/create.js
to useasync/await
instead of promise nesting and added a missingawait
The code itself is used when running
netlify functions:create
and will add missing addons depending on the function template.For example if you install a
fauna
template it adds thefauna
addon