-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
project validation add migrate file script remove logs
- Loading branch information
Showing
11 changed files
with
168 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { savedFileMigrator } from '@@/model' | ||
import * as fs from 'fs/promises' | ||
import { join } from 'path' | ||
import { tmpdir } from 'os' | ||
import { nanoid } from 'nanoid' | ||
import { execa } from 'execa' | ||
|
||
const args = process.argv.slice(2) | ||
if (args.length !== 1) { | ||
console.error('Usage: node script.ts <filepath>') | ||
process.exit(1) | ||
} | ||
|
||
const filePath = args[0] | ||
|
||
async function migrateFile() { | ||
try { | ||
// const tmpFile = join(tmpdir(), nanoid() + '.json') | ||
|
||
const data = await fs.readFile(filePath, 'utf8') | ||
const json = JSON.parse(data) | ||
const migratedData = await savedFileMigrator.migrate(json) | ||
const str = JSON.stringify(migratedData, null, 2) | ||
console.log('data', data) | ||
console.log('str', str) | ||
await fs.writeFile(filePath, str, 'utf8') | ||
console.log('File successfully migrated to the latest version of the model.') | ||
|
||
// await execa('delta', [filePath, tmpFile], { | ||
// env: { | ||
// DELTA_FEATURES: '+side-by-side' | ||
// } | ||
// }) | ||
} catch (error) { | ||
console.error(`Error migrating the file: ${error}`) | ||
process.exit(1) | ||
} | ||
} | ||
|
||
await migrateFile() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.