( dirPath: string, inputFormat: SourceNotebookFormat, options: ConvertOptions )
| 230 | } |
| 231 | |
| 232 | async function convertDirectoryToDeepnote( |
| 233 | dirPath: string, |
| 234 | inputFormat: SourceNotebookFormat, |
| 235 | options: ConvertOptions |
| 236 | ): Promise<ConvertResult> { |
| 237 | const outputDir = options.output ? resolve(process.cwd(), options.output) : dirPath |
| 238 | const projectName = options.name ?? basename(dirPath) |
| 239 | const projectId = randomUUID() |
| 240 | |
| 241 | const quiet = getOutputConfig().quiet |
| 242 | const spinner = quiet ? null : ora(`Converting ${INPUT_FORMAT_NAMES[inputFormat]} to Deepnote files...`).start() |
| 243 | |
| 244 | try { |
| 245 | const result = await convertDirectoryToDeepnoteCore({ |
| 246 | inputDir: dirPath, |
| 247 | format: inputFormat, |
| 248 | outputDir, |
| 249 | projectName, |
| 250 | projectId, |
| 251 | }) |
| 252 | |
| 253 | spinner?.succeed( |
| 254 | `${result.outputFiles.length} Deepnote file${result.outputFiles.length === 1 ? '' : 's'} saved to ${getChalk().bold(outputDir)}` |
| 255 | ) |
| 256 | |
| 257 | return { |
| 258 | success: true, |
| 259 | inputPath: dirPath, |
| 260 | outputPath: outputDir, |
| 261 | inputFormat, |
| 262 | outputFormat: 'deepnote', |
| 263 | outputIsDirectory: true, |
| 264 | } |
| 265 | } catch (error) { |
| 266 | spinner?.fail('Conversion failed') |
| 267 | throw error |
| 268 | } |
| 269 | } |
no test coverage detected