MCPcopy
hub / github.com/deepnote/deepnote / createConvertAction

Function createConvertAction

packages/cli/src/commands/convert.ts:38–71  ·  view source on GitHub ↗
(_program: Command)

Source from the content-addressed store, hash-verified

36}
37
38export function createConvertAction(_program: Command): (inputPath: string, options: ConvertOptions) => Promise<void> {
39 return async (inputPath, options) => {
40 try {
41 debug(`Converting: ${inputPath}`)
42 debug(`Options: ${JSON.stringify(options)}`)
43 const result = await convertFile(inputPath, options)
44
45 // Handle --open flag: open the converted .deepnote file in Deepnote Cloud
46 if (options.open) {
47 const c = getChalk()
48 if (result.outputFormat !== 'deepnote') {
49 output(c.yellow('Warning: --open is only available when converting to .deepnote format'))
50 } else if (result.outputIsDirectory) {
51 output(
52 c.yellow(
53 'Warning: --open is not supported when converting a directory; open a file with `deepnote open <file>`'
54 )
55 )
56 } else {
57 const quiet = getOutputConfig().quiet
58 const openResult = await openDeepnoteFileInCloud(result.outputPath, { quiet })
59 if (!quiet) {
60 output(`${c.green('✓')} Opened in Deepnote Cloud`)
61 output(`${c.dim('URL:')} ${openResult.url}`)
62 }
63 }
64 }
65 } catch (error) {
66 const message = error instanceof Error ? error.message : String(error)
67 logError(message)
68 process.exit(ExitCode.Error)
69 }
70 }
71}
72
73async function convertFile(inputPath: string, options: ConvertOptions): Promise<ConvertResult> {
74 const { absolutePath, isDirectory, extension: ext } = await resolvePath(inputPath)

Callers 2

registerCommandsFunction · 0.90
convert.test.tsFile · 0.90

Calls 6

debugFunction · 0.90
getChalkFunction · 0.90
outputFunction · 0.90
getOutputConfigFunction · 0.90
openDeepnoteFileInCloudFunction · 0.90
convertFileFunction · 0.85

Tested by

no test coverage detected