(options: ConvertSingleFileOptions)
| 275 | } |
| 276 | |
| 277 | async function convertSingleFileToDeepnote(options: ConvertSingleFileOptions): Promise<string> { |
| 278 | const { absolutePath, formatName, converter, resolveProjectName, resolveOutputPath, singleFile } = options |
| 279 | const spinner = ora(`Converting the ${formatName} to a Deepnote project...`).start() |
| 280 | |
| 281 | try { |
| 282 | const ext = extname(absolutePath) |
| 283 | const filenameWithoutExtension = basename(absolutePath, ext) |
| 284 | const projectName = resolveProjectName(filenameWithoutExtension) |
| 285 | |
| 286 | const outputFilename = `${filenameWithoutExtension}.deepnote` |
| 287 | const outputPath = await resolveOutputPath(outputFilename) |
| 288 | |
| 289 | // Read and convert file to DeepnoteFile (no file I/O yet) |
| 290 | const deepnoteFile = await converter(absolutePath, { projectName }) |
| 291 | |
| 292 | // Write file (handles snapshot splitting in memory) |
| 293 | const { snapshotPath } = await writeDeepnoteFile({ |
| 294 | file: deepnoteFile, |
| 295 | outputPath, |
| 296 | projectName, |
| 297 | singleFile, |
| 298 | }) |
| 299 | |
| 300 | if (snapshotPath) { |
| 301 | spinner.succeed( |
| 302 | `The Deepnote project has been saved to ${chalk.bold(outputPath)}\nSnapshot saved to ${chalk.bold(snapshotPath)}` |
| 303 | ) |
| 304 | } else { |
| 305 | spinner.succeed(`The Deepnote project has been saved to ${chalk.bold(outputPath)}`) |
| 306 | } |
| 307 | |
| 308 | return outputPath |
| 309 | } catch (error) { |
| 310 | spinner.fail('Conversion failed') |
| 311 | throw error |
| 312 | } |
| 313 | } |
| 314 | |
| 315 | interface ConvertToDeepnoteOptions { |
| 316 | absolutePath: string |
no test coverage detected