MCPcopy
hub / github.com/deepnote/deepnote / convertSingleFileToDeepnote

Function convertSingleFileToDeepnote

packages/cli/src/commands/convert.ts:199–230  ·  view source on GitHub ↗

Converts one source notebook to a single-notebook `.deepnote` file.

(
  absolutePath: string,
  inputFormat: SourceNotebookFormat,
  options: ConvertOptions
)

Source from the content-addressed store, hash-verified

197
198/** Converts one source notebook to a single-notebook `.deepnote` file. */
199async function convertSingleFileToDeepnote(
200 absolutePath: string,
201 inputFormat: SourceNotebookFormat,
202 options: ConvertOptions
203): Promise<ConvertResult> {
204 const quiet = getOutputConfig().quiet
205 const spinner = quiet ? null : ora(`Converting ${INPUT_FORMAT_NAMES[inputFormat]} to Deepnote project...`).start()
206
207 try {
208 const ext = extname(absolutePath)
209 const filenameWithoutExtension = basename(absolutePath, ext)
210 const projectName = options.name ?? filenameWithoutExtension
211 const outputFilename = `${filenameWithoutExtension}.deepnote`
212 const outputPath = options.output ? resolve(process.cwd(), options.output) : resolve(process.cwd(), outputFilename)
213
214 await runToDeepnoteConversion(inputFormat, absolutePath, { projectName, outputPath })
215
216 spinner?.succeed(`Deepnote project saved to ${getChalk().bold(outputPath)}`)
217
218 return {
219 success: true,
220 inputPath: absolutePath,
221 outputPath,
222 inputFormat,
223 outputFormat: 'deepnote',
224 outputIsDirectory: false,
225 }
226 } catch (error) {
227 spinner?.fail('Conversion failed')
228 throw error
229 }
230}
231
232async function convertDirectoryToDeepnote(
233 dirPath: string,

Callers 1

convertToDeepnoteFunction · 0.70

Calls 4

getOutputConfigFunction · 0.90
runToDeepnoteConversionFunction · 0.90
getChalkFunction · 0.90
startMethod · 0.80

Tested by

no test coverage detected