Skip to content

Commit

Permalink
fix: use 4 as indent for json, added confirmation before init
Browse files Browse the repository at this point in the history
  • Loading branch information
rmocanu-ionos committed Feb 12, 2024
1 parent 96fbeab commit b0947cf
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
29 changes: 24 additions & 5 deletions src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Codex } from '../services/codex'
import BaseCommand from '../base/base-command'
import { flags } from '@oclif/command'
import renderers from '../renderers'
import ui from '../services/ui'
import config from '../services/config'

export default class Init extends BaseCommand {
static description = 'initialize a codex project in S3'
Expand All @@ -27,10 +29,27 @@ export default class Init extends BaseCommand {
}]

async run() {
const codex = new Codex()
await codex.init({
specUrl: this.args.url,
format: this.flags.format
})
ui.warning(`bucket ${config.get('s3.bucket')} will be reset`)

const { Toggle } = require('enquirer')

const prompt = new Toggle({
message: `Are you sure you want to re-init the current bucket (${config.get('s3.bucket')})?`,
enabled: 'Yes',
disabled: 'No'
});

const answer = await prompt.run()

if (answer) {
const codex = new Codex()
await codex.init({
specUrl: this.args.url,
format: this.flags.format
})
} else {
ui.info('bailing out')
}
return
}
}
2 changes: 1 addition & 1 deletion src/renderers/json-renderer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const DEFAULT_INDENT = 2
export const DEFAULT_INDENT = 4

export default {
marshal: function (object: any, indent: number = DEFAULT_INDENT): string {
Expand Down

0 comments on commit b0947cf

Please sign in to comment.