Skip to content

Commit

Permalink
feat: add blobs-migrate recipe (#6418)
Browse files Browse the repository at this point in the history
* feat: add `blobs-migrate` recipe

* chore: update `@netlify/blobs`

* refactor: check for delete errors

* chore: fix test

* chore: simplify test

* chore: update snapshot

* chore: pin version
  • Loading branch information
eduardoboucas committed Mar 7, 2024
1 parent 86b7781 commit 1638c69
Show file tree
Hide file tree
Showing 8 changed files with 275 additions and 130 deletions.
250 changes: 140 additions & 110 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -72,7 +72,7 @@
"dependencies": {
"@bugsnag/js": "7.20.2",
"@fastify/static": "6.10.2",
"@netlify/blobs": "6.5.0",
"@netlify/blobs": "7.0.0",
"@netlify/build": "29.36.1",
"@netlify/build-info": "7.13.0",
"@netlify/config": "20.12.1",
Expand Down
17 changes: 13 additions & 4 deletions src/commands/recipes/recipes.ts
Expand Up @@ -11,11 +11,18 @@ import { getRecipe, listRecipes } from './common.js'

const SUGGESTION_TIMEOUT = 1e4

// @ts-expect-error TS(7031) FIXME: Binding element 'config' implicitly has an 'any' t... Remove this comment to see the full error message
export const runRecipe = async ({ config, recipeName, repositoryRoot }) => {
interface RunRecipeOptions {
args: string[]
command?: BaseCommand
config: unknown
recipeName: string
repositoryRoot: string
}

export const runRecipe = async ({ args, command, config, recipeName, repositoryRoot }: RunRecipeOptions) => {
const recipe = await getRecipe(recipeName)

return recipe.run({ config, repositoryRoot })
return recipe.run({ args, command, config, repositoryRoot })
}

export const recipesCommand = async (recipeName: string, options: OptionValues, command: BaseCommand): Promise<any> => {
Expand All @@ -26,8 +33,10 @@ export const recipesCommand = async (recipeName: string, options: OptionValues,
return command.help()
}

const args = command.args.slice(1)

try {
return await runRecipe({ config, recipeName: sanitizedRecipeName, repositoryRoot })
return await runRecipe({ args, command, config, recipeName: sanitizedRecipeName, repositoryRoot })
} catch (error) {
if (
// The ESM loader throws this instead of MODULE_NOT_FOUND
Expand Down
2 changes: 1 addition & 1 deletion src/lib/blobs/blobs.ts
@@ -1,7 +1,7 @@
import { Buffer } from 'buffer'
import path from 'path'

import { BlobsServer } from '@netlify/blobs'
import { BlobsServer } from '@netlify/blobs/server'
import { v4 as uuidv4 } from 'uuid'

import { log, NETLIFYDEVLOG } from '../../utils/command-helpers.js'
Expand Down
2 changes: 1 addition & 1 deletion src/lib/edge-functions/editor-helper.ts
Expand Up @@ -40,5 +40,5 @@ export const promptEditorHelper = async ({ NETLIFYDEVLOG, chalk, config, log, re
return
}

await runRecipe({ config, recipeName: 'vscode', repositoryRoot })
await runRecipe({ args: [], config, recipeName: 'vscode', repositoryRoot })
}

2 comments on commit 1638c69

@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,315
  • Package size: 287 MB
  • Number of ts-expect-error directives: 1,179

@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,315
  • Package size: 287 MB
  • Number of ts-expect-error directives: 1,179

Please sign in to comment.