-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: replace .env with .codeshift.config.toml
fix: always call process.exit with 1
- Loading branch information
Showing
21 changed files
with
191 additions
and
278 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[settings] | ||
baseUrl="xxxxxxxxxxxxxxxxxx" | ||
apiKey="sk-xxxxxxxxxxx" | ||
outputFile="xxxxxxxxxxx" | ||
model="xxxxxxxxxxxx" | ||
tokenUsage=false | ||
stream=false |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -178,3 +178,5 @@ dist | |
# Finder (MacOS) folder config | ||
.DS_Store | ||
|
||
# Codeshift config file | ||
.codeshift.config.toml |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const fs = require("node:fs"); | ||
const path = require("node:path"); | ||
const toml = require("smol-toml"); | ||
|
||
const configFilePath = path.join(process.cwd(), ".codeshift.config.toml"); | ||
|
||
const defaultConfig = `[settings] | ||
baseUrl="xxxxxxxxxxxxxxxxxx" | ||
apiKey="sk-xxxxxxxxxxx" | ||
outputFile="xxxxxxxxxxx" | ||
model="xxxxxxxxxxxx" | ||
tokenUsage=false | ||
stream=true | ||
`; | ||
|
||
let parsedConfig; | ||
|
||
try { | ||
const fileContent = fs.readFileSync(configFilePath, "utf-8"); | ||
parsedConfig = toml.parse(fileContent); | ||
} catch (err) { | ||
// If config file is missing, create it | ||
if (err.code == "ENOENT") { | ||
fs.writeFileSync(configFilePath, defaultConfig); | ||
console.error( | ||
"Existing config not found. Created .codeshift.config.toml. Please set config options.", | ||
); | ||
process.exit(1); | ||
} else { | ||
console.error(`error reading or parsing the config file: ${err.message}`); | ||
process.exit(1); // Exit with an error message if the file exists but is invalid | ||
} | ||
} | ||
|
||
module.exports = parsedConfig.settings; |
Oops, something went wrong.