diff --git a/package.json b/package.json index 4d24de3..f4f10ca 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "create-react-boilerplates", - "version": "2.2.0", + "version": "2.3.0", "type": "module", "bin": { "create-react-boilerplates": "index.js", diff --git a/src/index.ts b/src/index.ts index ac5ef01..97586dc 100644 --- a/src/index.ts +++ b/src/index.ts @@ -47,17 +47,32 @@ async function init() { }, { type: () => - !fs.existsSync(targetDir) || isEmpty(targetDir) ? null : "confirm", + !fs.existsSync(targetDir) || isEmpty(targetDir) ? null : "select", name: "overwrite", message: () => (targetDir === "." ? "Current directory" : `Target directory "${targetDir}"`) + - ` is not empty. Remove existing files and continue?`, + ` is not empty. Please select the steps to perform:`, + initial: 0, + choices: [ + { + title: "Cancel operation", + value: 1, + }, + { + title: "Ignore files and continue", + value: 2, + }, + { + title: "Delete the current file and continue", + value: 3, + }, + ], }, { - type: (_, { overwrite }: { overwrite?: boolean }) => { - if (overwrite === false) { + type: (_, { overwrite }: { overwrite?: number }) => { + if (overwrite === 1) { throw new Error(red("✖") + " Operation cancelled"); } @@ -105,7 +120,7 @@ async function init() { const root = path.join(cwd, targetDir); - if (overwrite) { + if (overwrite === 3) { emptyDir(root); } else if (!fs.existsSync(root)) { fs.mkdirSync(root, { recursive: true }); diff --git a/templates/template-react-recoil/package.json b/templates/template-react-recoil/package.json index 2cc41d2..fcb0705 100644 --- a/templates/template-react-recoil/package.json +++ b/templates/template-react-recoil/package.json @@ -18,6 +18,8 @@ "recoil": "^0.7.7" }, "devDependencies": { + "@sj-distributor/eslint-plugin-react": "^0.7.1", + "@types/node": "^20.11.5", "@types/ramda": "^0.29.3", "@types/react": "^18.0.26", "@types/react-dom": "^18.0.10", @@ -39,7 +41,6 @@ "tailwindcss": "^3.3.5", "typescript": "^5.1.6", "typescript-plugin-css-modules": "^5.0.1", - "vite": "^4.4.10", - "@sj-distributor/eslint-plugin-react": "^0.7.1" + "vite": "^4.4.10" } } diff --git a/templates/template-react-ts/package.json b/templates/template-react-ts/package.json index e7d9e60..2c6b64e 100644 --- a/templates/template-react-ts/package.json +++ b/templates/template-react-ts/package.json @@ -17,6 +17,8 @@ "react-router-dom": "^6.19.0" }, "devDependencies": { + "@sj-distributor/eslint-plugin-react": "^0.7.1", + "@types/node": "^20.11.5", "@types/ramda": "^0.29.3", "@types/react": "^18.0.26", "@types/react-dom": "^18.0.10", @@ -38,7 +40,6 @@ "tailwindcss": "^3.3.5", "typescript": "^5.1.6", "typescript-plugin-css-modules": "^5.0.1", - "vite": "^4.4.10", - "@sj-distributor/eslint-plugin-react": "^0.7.1" + "vite": "^4.4.10" } }