Skip to content

Commit

Permalink
feat: pass accountId to resolveConfig (#6733)
Browse files Browse the repository at this point in the history
* feat: pass accountId to

* feat: pass accountId to resolveConfig

* fix: revert package-lock change

---------

Co-authored-by: Netlify Bot <[email protected]>
  • Loading branch information
lemusthelroy and netlify-bot authored Jun 26, 2024
1 parent 37d8193 commit 6ce285e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/commands/base-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ export default class BaseCommand extends Command {

featureFlags: FeatureFlags = {}
siteId?: string
accountId?: string

/**
* IMPORTANT this function will be called for each command!
Expand Down Expand Up @@ -575,6 +576,7 @@ export default class BaseCommand extends Command {
try {
const site = await api.getSite({ siteId: actionCommand.siteId, feature_flags: 'cli' })
actionCommand.featureFlags = site.feature_flags
actionCommand.accountId = site.account_id
} catch {
// if the site is not found, that could mean that the user passed a site name, not an ID
}
Expand Down Expand Up @@ -685,6 +687,7 @@ export default class BaseCommand extends Command {

try {
return await resolveConfig({
accountId: this.accountId,
config: config.configFilePath,
packagePath: config.packagePath,
repositoryRoot: config.repositoryRoot,
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/commands/build/build-program.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ vi.mock('@netlify/config', async (importOriginal) => {

const siteInfo = {
account_slug: 'test-account',
account_id: 'account_id',
id: 'site_id',
name: 'site-name',
feature_flags: { test_flag: true },
Expand Down Expand Up @@ -72,6 +73,7 @@ describe('command/build', () => {

await createBuildCommand(new BaseCommand('netlify')).parseAsync(['', '', 'build'])
expect(configOptions.featureFlags).toEqual(siteInfo.feature_flags)
expect(configOptions.accountId).toEqual(siteInfo.account_id)

await createBuildCommand(new BaseCommand('netlify')).parseAsync(['', '', 'build', '--offline'])
expect(configOptions.featureFlags, 'should not call API in offline mode').toEqual({})
Expand Down

2 comments on commit 6ce285e

@github-actions
Copy link

Choose a reason for hiding this comment

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

📊 Benchmark results

  • Dependency count: 1,213
  • Package size: 313 MB
  • Number of ts-expect-error directives: 977

@github-actions
Copy link

Choose a reason for hiding this comment

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

📊 Benchmark results

  • Dependency count: 1,213
  • Package size: 313 MB
  • Number of ts-expect-error directives: 977

Please sign in to comment.