Converts one source notebook to a single-notebook `.deepnote` file.
( absolutePath: string, inputFormat: SourceNotebookFormat, options: ConvertOptions )
| 197 | |
| 198 | /** Converts one source notebook to a single-notebook `.deepnote` file. */ |
| 199 | async 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 | |
| 232 | async function convertDirectoryToDeepnote( |
| 233 | dirPath: string, |
no test coverage detected