-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(kadena-cli): refactor devnet commands to createCommand pattern
- Loading branch information
1 parent
f4282bb
commit bfe0e2b
Showing
23 changed files
with
523 additions
and
716 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
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
This file was deleted.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
packages/tools/kadena-cli/src/devnet/createDevnetCommand.ts
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 { defaultDevnetsPath } from '../constants/devnets.js'; | ||
import { ensureFileExists } from '../utils/filesystem.js'; | ||
import { writeDevnet } from './devnetHelpers.js'; | ||
|
||
import debug from 'debug'; | ||
import path from 'path'; | ||
|
||
import { createCommand } from '../utils/createCommand.js'; | ||
import { globalOptions } from '../utils/globalOptions.js'; | ||
import chalk from 'chalk'; | ||
import { devnetOverwritePrompt } from '../constants/prompts.js'; | ||
|
||
export const createDevnetCommand = createCommand( | ||
'create', | ||
'Create devnet', | ||
[ | ||
globalOptions.devnetName(), | ||
globalOptions.devnetPort(), | ||
globalOptions.devnetUseVolume(), | ||
globalOptions.devnetMountPactFolder(), | ||
globalOptions.devnetVersion(), | ||
], | ||
async (config) => { | ||
debug('devnet-create:action')({config}); | ||
|
||
const filePath = path.join(defaultDevnetsPath, `${config.name}.yaml`); | ||
|
||
if (ensureFileExists(filePath)) { | ||
const overwrite = await devnetOverwritePrompt(config.name); | ||
if (overwrite === 'no') { | ||
console.log(chalk.yellow(`\nThe existing devnet configuration "${config.name}" will not be updated.\n`)); | ||
return; | ||
} | ||
} | ||
|
||
writeDevnet(config); | ||
|
||
console.log(chalk.green(`\nThe devnet configuration "${config.name}" has been saved.\n`)); | ||
}, | ||
); |
107 changes: 0 additions & 107 deletions
107
packages/tools/kadena-cli/src/devnet/createDevnetsCommand.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.