diff --git a/packages/usdk/cli.js b/packages/usdk/cli.js index 1f63ec4d0..21872ab5e 100644 --- a/packages/usdk/cli.js +++ b/packages/usdk/cli.js @@ -1434,7 +1434,6 @@ export const createProgram = () => { .option(`-hs, --home-space `, `Set the home space`) .option(`-j, --json `, `Agent JSON string to initialize with (e.g '{"name": "Ally", "description": "She is cool"}')`) .option(`-y, --yes`, `Non-interactive mode`) - .option(`-f, --force`, `Overwrite existing files`) .option(`-n, --no-install`, `Do not install dependencies`) .option(`-F, --force-no-confirm`, `Overwrite existing files without confirming\nUseful for headless environments. ${pc.red('WARNING: Data loss can occur. Use at your own risk.')}`) .option(`-s, --source `, `Main source file for the agent. ${pc.red('REQUIRED: Agent Json string must be provided using -j option')}`) diff --git a/packages/usdk/lib/create.mjs b/packages/usdk/lib/create.mjs index b04a5554f..2c93446b9 100644 --- a/packages/usdk/lib/create.mjs +++ b/packages/usdk/lib/create.mjs @@ -354,7 +354,6 @@ export const create = async (args, opts) => { const source = args.source; const features = typeof args.feature === 'string' ? JSON.parse(args.feature) : (args.feature || {}); const yes = args.yes; - const force = !!args.force; const noInstall = !!args.noInstall; const forceNoConfirm = !!args.forceNoConfirm; // opts @@ -403,7 +402,6 @@ export const create = async (args, opts) => { const _prepareDirectory = async () => { console.log(pc.italic('Preparing directory...')); await cleanDir(dstDir, { - force, forceNoConfirm, }); // bootstrap destination directory diff --git a/packages/usdk/lib/directory-util.mjs b/packages/usdk/lib/directory-util.mjs index 98ea70d48..0de6d660e 100644 --- a/packages/usdk/lib/directory-util.mjs +++ b/packages/usdk/lib/directory-util.mjs @@ -5,7 +5,7 @@ import { rimraf } from 'rimraf'; import pc from 'picocolors'; import { isYes } from './isYes.js' -export const cleanDir = async (dstDir, { force, forceNoConfirm } = {}) => { +export const cleanDir = async (dstDir, { forceNoConfirm } = {}) => { const files = await (async () => { try { return await fs.promises.readdir(dstDir); @@ -17,32 +17,28 @@ export const cleanDir = async (dstDir, { force, forceNoConfirm } = {}) => { } } })(); + if (files.length > 0) { - if (force || forceNoConfirm) { - if (!forceNoConfirm) { - const rl = readline.promises.createInterface({ - input: process.stdin, - output: process.stdout, - }); + if (!forceNoConfirm) { + const rl = readline.promises.createInterface({ + input: process.stdin, + output: process.stdout, + }); - const answer = await rl.question(`\nDelete the contents of "${path.resolve(dstDir)}"? ${pc.cyan('y/N')}: `) - rl.close(); - console.log(); + const answer = await rl.question(`\nDelete the contents of "${path.resolve(dstDir)}"? ${pc.cyan('y/N')}: `) + rl.close(); + console.log(); - if (!isYes(answer)) { - throw new Error('aborted'); - } + if (!isYes(answer)) { + throw new Error('Create Aborted'); } - - // Remove all files. - console.log(pc.italic('Removing old files...')); - await Promise.all( - files.map((filePath) => rimraf(path.join(dstDir, filePath))), - ); - console.log(pc.italic('Removed old files...')); - } else { - // throw error - throw new Error('directory is not empty (-f to override)'); } + + // Remove all files. + console.log(pc.italic('Removing old files...')); + await Promise.all( + files.map((filePath) => rimraf(path.join(dstDir, filePath))), + ); + console.log(pc.italic('Removed old files...')); } }; \ No newline at end of file