-
Notifications
You must be signed in to change notification settings - Fork 0
/
fs.js
41 lines (34 loc) · 1.32 KB
/
fs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env node
require('dotenv').config();
const fs = require('fs');
const moment = require('moment');
const sgit = require('simple-git');
const git = sgit({ config: [`http.extraHeader=Authorization: Basic ${btoa(process.env.TOKEN)}`] });
const _s = require('scramb');
const prompts = require('prompts');
prompts.override(require('yargs').argv);
const filepath = './data.json';
async function main() {
const res = await prompts([
// { type: 'number', name: 'days', message: 'days to subtract?', initial: 0 },
{ type: 'number', name: 'totalCommit', message: 'how many commits?', initial: 1000 },
{ type: 'confirm', name: 'confirm', message: 'proceed?', initial: true }
]);
if (!res.confirm) return;
let n = JSON.parse(fs.readFileSync(filepath, 'utf8'));
const DATE = moment(n.data).subtract(1, 'd').format();
let dataArr = [];
for (let i = 0; i < res.totalCommit; i++) {
let data = { data: DATE, r: _s.passGen(8).result };
dataArr.push(data);
}
for (let i = 0; i < res.totalCommit; i++) {
if (i === res.totalCommit - 1) {
fs.writeFileSync(filepath, JSON.stringify(dataArr[i]));
}
await git.add('./*').commit(dataArr[i].data, { '--date': dataArr[i].data });
if ([1, 100, 200, 300, 400, 500, 800, 1000].includes(i + 1)) console.log('now', i + 1);
}
await git.push();
}
main();