Merge branch 'main' into code-quality

This commit is contained in:
Jacob Nguyen
2022-05-11 11:41:59 -05:00
committed by GitHub
3 changed files with 31 additions and 6 deletions

17
package-lock.json generated
View File

@@ -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",

View File

@@ -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",

View File

@@ -1,10 +1,12 @@
import { execa } from 'execa';
import { redBright } from 'colorette';
import fs from 'fs';
import os from 'os';
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
@@ -44,14 +46,19 @@ 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
]);
const isCached = fs.existsSync(
path.join(os.homedir(), '.degit/github/sern-handler/templates')
);
const emitter = degit('sern-handler/templates/templates', {
cache: isCached,
force: true,
});
copyRecursiveSync(`templates/templates/${lang}`, name);
await emitter.clone('templates');
fs.rmSync(`templates/`, { recursive: true, force: true });
copyRecursiveSync(`templates/${lang}`, name);
fs.rmSync('templates', { recursive: true, force: true });
}
/**