Skip to content

Commit

Permalink
refactor: split dev blob upload into separate step
Browse files Browse the repository at this point in the history
  • Loading branch information
ndhoule committed Mar 28, 2024
1 parent 95d9f0e commit 1086316
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
18 changes: 18 additions & 0 deletions packages/build/src/plugins_core/dev_blobs_upload/index.ts
@@ -0,0 +1,18 @@
import { uploadBlobs } from '../blobs_upload/index.js'
import { type CoreStep, type CoreStepCondition } from '../types.js'

const condition: CoreStepCondition = async (...args) => {
const {
constants: { IS_LOCAL },
} = args[0]
return IS_LOCAL && ((await uploadBlobs.condition?.(...args)) ?? true)
}

export const devUploadBlobs: CoreStep = {
event: 'onDev',
coreStep: uploadBlobs.coreStep,
coreStepId: 'dev_blobs_upload',
coreStepName: 'Uploading blobs',
coreStepDescription: () => 'Uploading blobs to development deploy store',
condition,
}
14 changes: 2 additions & 12 deletions packages/build/src/steps/get.ts
Expand Up @@ -4,6 +4,7 @@ import { uploadBlobs } from '../plugins_core/blobs_upload/index.js'
import { buildCommandCore } from '../plugins_core/build_command.js'
import { deploySite } from '../plugins_core/deploy/index.js'
import { applyDeployConfig } from '../plugins_core/deploy_config/index.js'
import { devUploadBlobs } from '../plugins_core/dev_blobs_upload/index.js'
import { bundleEdgeFunctions } from '../plugins_core/edge_functions/index.js'
import { bundleFunctions } from '../plugins_core/functions/index.js'
import { preCleanup } from '../plugins_core/pre_cleanup/index.js'
Expand Down Expand Up @@ -39,18 +40,7 @@ export const getDevSteps = function (command, steps, eventHandlers?: any[]) {

const eventSteps = getEventSteps(eventHandlers)

const sortedSteps = sortSteps(
[
preDevCleanup,
...steps,
// Trigger the uploadBlobs step during development to allow users to test file-based blob
// uploads locally and to allow frameworks to capture file-based blobs written by frameworks
{ ...uploadBlobs, event: 'onDev' },
eventSteps,
devCommandStep,
],
DEV_EVENTS,
)
const sortedSteps = sortSteps([preDevCleanup, ...steps, devUploadBlobs, eventSteps, devCommandStep], DEV_EVENTS)
const events = getEvents(sortedSteps)

return { steps: sortedSteps, events }
Expand Down

0 comments on commit 1086316

Please sign in to comment.