From 6f264e06b91ce89e641e3155d08c042da7593cb7 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 20 Jan 2024 11:43:47 +0800 Subject: [PATCH 1/3] feat(cli): allow non-empty directories to be initialized --- src/index.ts | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) 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 }); From 9c1533d51211762bdb8fe9ff406c4182a8535592 Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 22 Jan 2024 15:11:27 +0800 Subject: [PATCH 2/3] chore(devD): add @types/node to devDependencies --- templates/template-react-recoil/package.json | 5 +++-- templates/template-react-ts/package.json | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) 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" } } From f5e5c8976ee0d5d1520e79b28ce98e656dd0b691 Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 22 Jan 2024 15:11:55 +0800 Subject: [PATCH 3/3] feat(crb): create-react-boilerplates@2.3.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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",