/base.js (2775b7af64daafde69cd3c4909a7cefef1b11263) (1982 bytes) (mode 100644) (type blob)
const shell = require("shelljs"),
fs = require("fs"),
path = require("path"),
ansi = require("ansi"),
cursor = ansi(process.stdout),
homedir = require("os").homedir(),
rcPath = getRCFilePath(),
exec = shell.exec,
{ COPYFILE_EXCL } = fs.constants;
function getRCFilePath() {
try {
fs.accessSync(path.join(homedir, ".zshrc"));
return ".zshrc";
} catch (err) {
try {
fs.accessSync(path.join(homedir, ".bashrc"));
return ".bashrc";
} catch (err) {
console.error("No bash file found");
throw err;
}
}
}
function cloneRepo(url, dest) {
return exec(`git clone ${url} --depth=1 --single-branch ${dest}`);
}
function installFile(fileName) {
const src = path.join(__dirname, fileName),
dst = path.join(homedir, `.${fileName}`);
fs.symlink(src, dst, (err) => {
if (err) {
if (err.code == "EEXIST") {
console.log(`${fileName} already installed`);
} else {
throw err;
}
} else {
console.log(`installing ${fileName}`);
}
});
}
function sourceOnSession(scriptName) {
const scriptPath = path.join(__dirname, scriptName);
let bashRC = fs.readFileSync(rcPath, "utf8");
if (!bashRC.match(scriptName)) {
console.log(`installing ${scriptName}`);
bashRC += `\n. ${scriptPath}`;
fs.writeFileSync(rcPath, bashRC);
} else {
console.log(`${scriptName} already installed`);
}
}
module.exports = {
sourceOnSession,
installFile,
cloneRepo,
exec: shell.exec,
tryAndRunScript: function (name) {
try {
fs.accessSync(`./${name}.js`);
const result = shell.exec(`./${name}.js`);
if (result.code) {
return false;
}
} catch (err) {
console.log(`Skippking ${name} step`);
}
return true;
},
print: function (message) {
cursor.green().write(message).reset().write("\n");
},
stagedFiles: function () {
return shell.exec(`git diff --staged --name-only`).stdout.split("\n");
},
};
Mode |
Type |
Size |
Ref |
File |
100644 |
blob |
22 |
3a347e0e18799b9ca6947a047a1fac8ba65a4083 |
.gitignore |
100644 |
blob |
57 |
53c96310c475eeabc923002d22b12481321a1a3c |
.huskyrc |
100644 |
blob |
232 |
9d06e0b4b68686582edc9ebce3485e9a84149d3b |
README.md |
100644 |
blob |
1982 |
2775b7af64daafde69cd3c4909a7cefef1b11263 |
base.js |
040000 |
tree |
- |
02cfb94ecf2a1c4852d702ccaa51538b8208cea6 |
blueprint |
100644 |
blob |
117 |
dddb23dbee0d00f884f5122718c2430e1528d42a |
editorconfig |
100755 |
blob |
521 |
cbfc512d1033ac292b7274e0b66a57c4a97d081b |
format.js |
100644 |
blob |
442 |
325ff7dfe345aa3879d9cf8624dd83057e94d5d7 |
gitconfig |
100755 |
blob |
493 |
ffd346f7297c21f2d0618219ac790b247672d510 |
install.js |
100755 |
blob |
128 |
ab0d0ee57db9ab42b5888b47f661de0e1fb281ce |
installJrnl.js |
100755 |
blob |
339 |
245612d1bb394c3f09a1974556ae45fe02742420 |
lint.js |
100644 |
blob |
288 |
2a557c2fc756e429ab31d0eec89e98bd50618681 |
marks_bashrc |
100644 |
blob |
19146 |
6ab24c86ec741ab08a5ad069ecb912ef6430608b |
package-lock.json |
100644 |
blob |
443 |
d0443e7a229c67c59abbe01767eaca145fd95b7c |
package.json |
100755 |
blob |
392 |
feded203040f85876c03557e7032bee51a87db6a |
pre-commit.js |
100755 |
blob |
858 |
996aeb15efcec98d86ed250bcb302c1a9cf7b361 |
templates.js |
100644 |
blob |
65 |
0ad6279abbb0afdfa9e4363f89e3ea9e9d837400 |
vimrc |
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"
Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/mucbuc/configs
Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/mucbuc/configs
Clone this repository using git:
git clone git://git.rocketgit.com/user/mucbuc/configs
You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a
merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main