diff --git a/package-lock.json b/package-lock.json index 1ef5e51..e35a80f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "license": "MIT", "dependencies": { "colorette": "^2.0.16", + "degit": "^2.8.4", "execa": "^6.1.0", "find-up": "6.3.0", "ora": "^6.1.0", @@ -1297,6 +1298,17 @@ "clone": "^1.0.2" } }, + "node_modules/degit": { + "version": "2.8.4", + "resolved": "https://registry.npmjs.org/degit/-/degit-2.8.4.tgz", + "integrity": "sha512-vqYuzmSA5I50J882jd+AbAhQtgK6bdKUJIex1JNfEUPENCgYsxugzKVZlFyMwV4i06MmnV47/Iqi5Io86zf3Ng==", + "bin": { + "degit": "degit" + }, + "engines": { + "node": ">=8.0.0" + } + }, "node_modules/detect-file": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/detect-file/-/detect-file-1.0.0.tgz", @@ -5640,6 +5652,11 @@ "clone": "^1.0.2" } }, + "degit": { + "version": "2.8.4", + "resolved": "https://registry.npmjs.org/degit/-/degit-2.8.4.tgz", + "integrity": "sha512-vqYuzmSA5I50J882jd+AbAhQtgK6bdKUJIex1JNfEUPENCgYsxugzKVZlFyMwV4i06MmnV47/Iqi5Io86zf3Ng==" + }, "detect-file": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/detect-file/-/detect-file-1.0.0.tgz", diff --git a/package.json b/package.json index 6184d6b..40552fc 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "homepage": "https://github.com/sern-handler/cli#readme", "dependencies": { "colorette": "^2.0.16", + "degit": "^2.8.4", "execa": "^6.1.0", "find-up": "6.3.0", "ora": "^6.1.0", diff --git a/src/utilities/install.js b/src/utilities/install.js index d25d0bb..bb3d2c2 100644 --- a/src/utilities/install.js +++ b/src/utilities/install.js @@ -5,6 +5,7 @@ import path from 'path'; import { readFile } from 'fs/promises'; import { findUp } from 'find-up'; import ora from 'ora'; +import degit from 'degit'; /** * It installs dependencies from a package.json file @@ -40,12 +41,15 @@ export async function installDeps(choice, name) { * @param {string} name - The name of the project */ export async function cloneRepo(lang, name) { - await execa('git', [ - 'clone', - `https://github.com/sern-handler/templates.git`, // ? See the idea of @Allyedge having templates built in cli - ]); - copyRecursiveSync(`templates/templates/${lang}`, name); - fs.rmSync(`templates/`, { recursive: true, force: true }); + const emitter = degit('sern-handler/templates/templates', { + cache: true, + force: true, + }); + + await emitter.clone('templates'); + + copyRecursiveSync(`templates/${lang}`, name); + fs.rmSync('templates', { recursive: true, force: true }); } /**