fscr 6.2.3 → 7.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -30
- package/dist/index.js +502 -185
- package/dist/lib/auth/auth-conf.js +49 -45
- package/dist/lib/cache/README.md +341 -0
- package/dist/lib/cache/cli.js +152 -0
- package/dist/lib/cache/file-watcher.js +193 -0
- package/dist/lib/cache/index.js +422 -0
- package/dist/lib/cache/monitor.js +224 -0
- package/dist/lib/commands/doctor.js +225 -0
- package/dist/lib/completions/completion.js +342 -0
- package/dist/lib/completions/generator.js +152 -0
- package/dist/lib/completions/scripts/bash.sh +108 -0
- package/dist/lib/completions/scripts/fish.sh +105 -0
- package/dist/lib/completions/scripts/powershell.ps1 +168 -0
- package/dist/lib/completions/scripts/zsh.sh +124 -0
- package/dist/lib/diagnostics/cache.js +121 -0
- package/dist/lib/diagnostics/fileSystem.js +236 -0
- package/dist/lib/diagnostics/gitCheck.js +41 -0
- package/dist/lib/diagnostics/nodeVersion.js +68 -0
- package/dist/lib/diagnostics/packageManager.js +64 -0
- package/dist/lib/diagnostics/performance.js +141 -0
- package/dist/lib/encryption/decryptConfig.js +3 -2
- package/dist/lib/encryption/encryption.js +153 -113
- package/dist/lib/generators/generateFScripts.js +16 -13
- package/dist/lib/generators/generateToc.js +23 -14
- package/dist/lib/generators/index.js +1 -1
- package/dist/lib/git/pub.js +27 -31
- package/dist/lib/git/taskRunner.js +79 -69
- package/dist/lib/git/validateNotDev.js +65 -54
- package/dist/lib/optionList.js +69 -57
- package/dist/lib/parsers/parseScriptsMd.cached.js +208 -0
- package/dist/lib/parsers/parseScriptsMd.js +88 -79
- package/dist/lib/parsers/parseScriptsPackage.js +4 -3
- package/dist/lib/performance/cache.js +199 -0
- package/dist/lib/performance/lazy-loader.js +189 -0
- package/dist/lib/performance/monitor.js +303 -0
- package/dist/lib/plugins/deployment/index.js +113 -0
- package/dist/lib/plugins/hooks.js +17 -0
- package/dist/lib/plugins/loader.js +91 -0
- package/dist/lib/plugins/task-notifier/index.js +72 -0
- package/dist/lib/release/bump.js +51 -43
- package/dist/lib/release/commitWithMessage.js +80 -52
- package/dist/lib/release/publish.js +19 -14
- package/dist/lib/release/pushToGit.js +40 -31
- package/dist/lib/release/releasenotes.js +116 -97
- package/dist/lib/release/seeChangedFiles.js +68 -60
- package/dist/lib/release/sort.js +200 -116
- package/dist/lib/release/tree.js +161 -147
- package/dist/lib/release/validateNotDev.js +52 -44
- package/dist/lib/running/index.js +1 -1
- package/dist/lib/running/runCLICommand.js +41 -31
- package/dist/lib/running/runParallel.js +61 -59
- package/dist/lib/running/runSequence.js +55 -53
- package/dist/lib/startScripts.js +129 -114
- package/dist/lib/taskList.js +99 -84
- package/dist/lib/test-files/.fscripts.md +113 -0
- package/dist/lib/test-files/.fscripts.test.md +103 -0
- package/dist/lib/test-files/.fscriptsb.md +107 -0
- package/dist/lib/test-files/.mdtest.md +40 -0
- package/dist/lib/test-files/consoleSample.js +17 -0
- package/dist/lib/test-files/inputSample.js +20 -0
- package/dist/lib/test-files/testConsole.js +1 -0
- package/dist/lib/test-files/testInput.js +2 -0
- package/dist/lib/upgradePackages.js +56 -46
- package/dist/lib/utils/clear.js +16 -13
- package/dist/lib/utils/console.js +27 -21
- package/dist/lib/utils/encryption.js +55 -13
- package/dist/lib/utils/hash.js +128 -0
- package/dist/lib/utils/helpers.js +153 -142
- package/dist/lib/utils/index.js +1 -1
- package/dist/lib/utils/prompt.js +24 -29
- package/package.json +20 -32
- package/dist/lib/codemod/arrow.js +0 -13
- package/dist/lib/codemod/arrow2.js +0 -67
- package/dist/lib/codemod/funcs.js +0 -25
- package/dist/lib/codemod/removeConsole.js +0 -12
- package/dist/lib/codemod/test.js +0 -8
- package/dist/lib/components/App.js +0 -64
- package/dist/lib/components/Selector.js +0 -133
- package/dist/lib/components/TabChanger.js +0 -113
- package/dist/lib/components/Table.js +0 -177
- package/dist/lib/components/Tabs.js +0 -221
- package/dist/lib/generateFScripts.js +0 -25
- package/dist/lib/generateToc.js +0 -30
- package/dist/lib/helpers.js +0 -191
- package/dist/lib/parseScriptsMd.js +0 -85
- package/dist/lib/parseScriptsPackage.js +0 -9
- package/dist/lib/release/index.js +0 -4
- package/dist/lib/run/lib.js +0 -454
- package/dist/lib/run/main-p.js +0 -59
- package/dist/lib/run/main-s.js +0 -56
- package/dist/lib/run/parse-cli-args.js +0 -222
- package/dist/lib/run/run-p.js +0 -30
- package/dist/lib/run/run-s.js +0 -57
- package/dist/lib/runCLICommand.js +0 -30
- package/dist/lib/runParallel.js +0 -20
- package/dist/lib/runSequence.js +0 -38
- package/dist/lib/taskListAutoComplete.js +0 -15
|
@@ -1,135 +1,175 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
|
+
import fcFilepicker from "fc-filepick";
|
|
2
3
|
import inquirer from "inquirer";
|
|
3
|
-
import { encrypt
|
|
4
|
-
import {
|
|
4
|
+
import {decrypt, encrypt} from "../utils/encryption.js";
|
|
5
|
+
import {appendToFile, boxInform, ensureFile, readFile, readJson, writeFile} from "../utils/helpers.js";
|
|
5
6
|
import path from "path";
|
|
7
|
+
|
|
6
8
|
const scriptsDir = process.cwd();
|
|
7
9
|
const rootDir = path.join(scriptsDir, "./");
|
|
8
10
|
const packagePath = path.join(rootDir, "package.json");
|
|
9
11
|
const igPath = path.join(rootDir, ".gitignore");
|
|
10
|
-
const encrypted = {
|
|
11
|
-
encryptedFiles: []
|
|
12
|
-
};
|
|
12
|
+
const encrypted = {encryptedFiles: []};
|
|
13
13
|
|
|
14
14
|
// prettier-ignore
|
|
15
|
-
encrypted.encrypt = async (pass, encryptedFile, decryptedFile) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
15
|
+
encrypted.encrypt = async (pass = null, encryptedFile = null, decryptedFile = null) => {
|
|
16
|
+
if (pass === null) {
|
|
17
|
+
pass = await encrypted.getPass();
|
|
18
|
+
}
|
|
19
|
+
if (decryptedFile === null) {
|
|
20
|
+
decryptedFile = await fcFilepicker.default({type: "file"});
|
|
21
|
+
decryptedFile = path.join(scriptsDir, decryptedFile.split("/").pop());
|
|
22
|
+
encryptedFile = `${decryptedFile}.encrypted`;
|
|
23
|
+
}
|
|
24
|
+
let willEncrypt = true;
|
|
25
|
+
let sureSure = await ensureFile(encryptedFile);
|
|
26
|
+
if (sureSure) {
|
|
27
|
+
console.log(`${chalk.bold.red("FILE ALREADY EXISTS ARE YOU SURE?")}`
|
|
28
|
+
);
|
|
29
|
+
willEncrypt = await new Promise(resolve => {
|
|
30
|
+
inquirer
|
|
31
|
+
.prompt([
|
|
32
|
+
{
|
|
33
|
+
type: "confirm",
|
|
34
|
+
message: chalk.bold.hex("#38be18")(
|
|
35
|
+
`Sure? (y/n): `
|
|
36
|
+
),
|
|
37
|
+
name: "sure"
|
|
38
|
+
}
|
|
39
|
+
])
|
|
40
|
+
.then(({sure}) => {
|
|
41
|
+
resolve(sure);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if (willEncrypt) {
|
|
46
|
+
let toEncrypt = await readFile(decryptedFile);
|
|
47
|
+
const ciphertext = encrypt(toEncrypt, pass);
|
|
48
|
+
await writeFile(encryptedFile, ciphertext.toString());
|
|
49
|
+
}
|
|
50
|
+
|
|
37
51
|
};
|
|
38
52
|
// prettier-ignore
|
|
39
|
-
encrypted.decrypt = async (pass, encryptedFileLocation, decryptedFileLocation) => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
53
|
+
encrypted.decrypt = async (pass = null, encryptedFileLocation = null, decryptedFileLocation = null) => {
|
|
54
|
+
// let encryptedFileLocation = path.join(rootDir,"."+encryptedFile);
|
|
55
|
+
// let decryptedFileLocation = path.join(rootDir,encryptedFile);
|
|
56
|
+
if (pass === null) {
|
|
57
|
+
pass = await encrypted.getPass();
|
|
58
|
+
}
|
|
59
|
+
if (encryptedFileLocation === null) {
|
|
60
|
+
encryptedFileLocation = await fcFilepicker.default({type: "file"});
|
|
61
|
+
encryptedFileLocation = path.join(scriptsDir, encryptedFileLocation.split("/").pop());
|
|
62
|
+
decryptedFileLocation = encryptedFileLocation.replace(".encrypted", "");
|
|
63
|
+
}
|
|
64
|
+
let willEncrypt = true;
|
|
65
|
+
let sureSure = await ensureFile(decryptedFileLocation);
|
|
66
|
+
if (sureSure) {
|
|
67
|
+
console.log(
|
|
68
|
+
`${chalk.bold.red("FILE ALREADY EXISTS ARE YOU SURE?")}`
|
|
69
|
+
);
|
|
70
|
+
willEncrypt = await new Promise(resolve => {
|
|
71
|
+
inquirer
|
|
72
|
+
.prompt([
|
|
73
|
+
{
|
|
74
|
+
type: "confirm",
|
|
75
|
+
message: chalk.bold.hex("#38be18")(
|
|
76
|
+
`Sure wanna override file ${decryptedFileLocation}? (y/n): `
|
|
77
|
+
),
|
|
78
|
+
name: "sure"
|
|
79
|
+
}
|
|
80
|
+
])
|
|
81
|
+
.then(({sure}) => {
|
|
82
|
+
resolve(sure);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
if (willEncrypt) {
|
|
87
|
+
let toDecrypt = await readFile(encryptedFileLocation);
|
|
88
|
+
const decryptedData = decrypt(toDecrypt, pass);
|
|
89
|
+
await writeFile(decryptedFileLocation, decryptedData);
|
|
90
|
+
console.warn(
|
|
91
|
+
`${chalk.bold.green.underline("DECRYPTED FILE:")} ${chalk.bold.dim(path.join(scriptsDir, decryptedFileLocation))}`
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
64
95
|
};
|
|
96
|
+
|
|
65
97
|
encrypted.init = async () => {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
+
try {
|
|
99
|
+
let pass = await encrypted.getPass();
|
|
100
|
+
let toEncrypt = await encrypted.toEncrypt();
|
|
101
|
+
encrypted.packageJson = await readJson(packagePath);
|
|
102
|
+
encrypted.ignore = await readFile(igPath);
|
|
103
|
+
encrypted.ignoredFiles = encrypted.ignore.split("\n");
|
|
104
|
+
if (encrypted.packageJson.fscripts) {
|
|
105
|
+
if (encrypted.packageJson.fscripts.encryptedFiles) {
|
|
106
|
+
encrypted.encryptedFiles = encrypted.packageJson.fscripts.encryptedFiles;
|
|
107
|
+
let filesToAdd = "\n";
|
|
108
|
+
for (const e of encrypted.encryptedFiles) {
|
|
109
|
+
if (encrypted.ignoredFiles.indexOf(e) === -1) {
|
|
110
|
+
filesToAdd += e + "\n";
|
|
111
|
+
}
|
|
112
|
+
let file = e + "";
|
|
113
|
+
let fileSplit = file.split("/");
|
|
114
|
+
let name = fileSplit.pop();
|
|
115
|
+
let encryptedFile = fileSplit.slice();
|
|
116
|
+
let decryptedFile = fileSplit.slice();
|
|
117
|
+
encryptedFile.push("." + name);
|
|
118
|
+
encryptedFile = path.join(rootDir, encryptedFile.join("/"));
|
|
119
|
+
decryptedFile.push(name);
|
|
120
|
+
decryptedFile = path.join(rootDir, decryptedFile.join("/"));
|
|
121
|
+
|
|
122
|
+
if (toEncrypt) {
|
|
123
|
+
await encrypted.encrypt(pass, encryptedFile, decryptedFile);
|
|
124
|
+
} else {
|
|
125
|
+
await encrypted.decrypt(pass, encryptedFile, decryptedFile);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (filesToAdd.trim().length > 0) {
|
|
130
|
+
await appendToFile(igPath, filesToAdd + "\n");
|
|
131
|
+
boxInform(" Added files to .gitignore: ", filesToAdd);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
98
134
|
}
|
|
99
|
-
|
|
135
|
+
} catch (err) {
|
|
136
|
+
console.error(err);
|
|
100
137
|
}
|
|
101
|
-
} catch (err) {
|
|
102
|
-
console.error(err);
|
|
103
|
-
}
|
|
104
138
|
};
|
|
139
|
+
|
|
105
140
|
encrypted.getPass = async () => {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
141
|
+
return await new Promise((resolve) => {
|
|
142
|
+
inquirer
|
|
143
|
+
.prompt([
|
|
144
|
+
{
|
|
145
|
+
type: "password",
|
|
146
|
+
mask: chalk.underline(" ●"),
|
|
147
|
+
message: chalk.bold.hex("#38be18")(
|
|
148
|
+
`Enter a SECRET key (same as pass app) : `
|
|
149
|
+
),
|
|
150
|
+
name: "pass"
|
|
151
|
+
}
|
|
152
|
+
])
|
|
153
|
+
.then(({pass}) => {
|
|
154
|
+
resolve(pass);
|
|
155
|
+
});
|
|
116
156
|
});
|
|
117
|
-
});
|
|
118
157
|
};
|
|
119
158
|
encrypted.toEncrypt = async () => {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
159
|
+
return await new Promise((resolve) => {
|
|
160
|
+
inquirer
|
|
161
|
+
.prompt([
|
|
162
|
+
{
|
|
163
|
+
type: "list",
|
|
164
|
+
message: chalk.bold.hex("#38be18")("Which direction?"),
|
|
165
|
+
choices: ["encrypt", "decrypt"],
|
|
166
|
+
name: "encryptDecrypt"
|
|
167
|
+
}
|
|
168
|
+
])
|
|
169
|
+
.then(async ({encryptDecrypt}) => {
|
|
170
|
+
resolve(encryptDecrypt === "encrypt");
|
|
171
|
+
});
|
|
130
172
|
});
|
|
131
|
-
});
|
|
132
173
|
};
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
};
|
|
174
|
+
|
|
175
|
+
export default {...encrypted};
|
|
@@ -4,22 +4,25 @@ import { appendToFile, writeFile, boxInform, readJson, readFile } from "../utils
|
|
|
4
4
|
import path from "path";
|
|
5
5
|
const projectDir = process.cwd();
|
|
6
6
|
const packagePath = path.join(projectDir, "package.json");
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
7
|
+
|
|
8
|
+
const gen = { scripts: [] };
|
|
10
9
|
let mdfile = `# First category of scripts
|
|
11
10
|
|
|
12
11
|
Welcome to your new amazing fscripts.md file. It replaces the headaches of npm scripts! But so much more.
|
|
13
12
|
`;
|
|
13
|
+
|
|
14
14
|
gen.init = async () => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
try {
|
|
16
|
+
gen.packageJson = await readJson(packagePath);
|
|
17
|
+
Object.keys(gen.packageJson.scripts).forEach(scriptName => {
|
|
18
|
+
mdfile += `\n## ${scriptName}\n\n${
|
|
19
|
+
gen.packageJson.scripts[scriptName]
|
|
20
|
+
}\n\n\`\`\`bash\n${gen.packageJson.scripts[scriptName]}\n\`\`\`\n\n`;
|
|
21
|
+
});
|
|
22
|
+
await writeFile("./sample.fscripts.md", mdfile);
|
|
23
|
+
} catch (err) {
|
|
24
|
+
console.error(err);
|
|
25
|
+
}
|
|
24
26
|
};
|
|
25
|
-
|
|
27
|
+
|
|
28
|
+
export default gen.init;
|
|
@@ -3,30 +3,39 @@ import chalk from "chalk";
|
|
|
3
3
|
import fs from "fs";
|
|
4
4
|
import tocPkg from "markdown-toc";
|
|
5
5
|
const toc = tocPkg.default || tocPkg;
|
|
6
|
+
|
|
6
7
|
import { writeFile } from "../utils/helpers.js";
|
|
7
8
|
// const projectDir = process.cwd();
|
|
8
9
|
|
|
9
10
|
const generateToc = async (fileToLoad = "fscripts.md") => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
const filepath = path.resolve(process.cwd(), fileToLoad);
|
|
12
|
+
|
|
13
|
+
if (!fs.existsSync(filepath)) {
|
|
14
|
+
console.warn(
|
|
15
|
+
`${chalk.bold.red("You're missing the fscripts.md file!")}
|
|
16
|
+
${chalk.green("Please run 'fsr generate' to get started!")}`
|
|
17
|
+
);
|
|
18
|
+
process.exit(0);
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const data = fs.readFileSync(filepath, "utf-8");
|
|
19
23
|
console.warn(`${chalk.bold.green("Located fscripts.md file!")}`);
|
|
24
|
+
|
|
20
25
|
let newFile = ``;
|
|
21
26
|
let tocSplit = data.split("<!-- end toc -->");
|
|
22
27
|
let mdContent = "";
|
|
23
28
|
if (tocSplit.length === 2) {
|
|
24
|
-
|
|
29
|
+
mdContent = tocSplit[1];
|
|
25
30
|
} else {
|
|
26
|
-
|
|
31
|
+
mdContent = data;
|
|
27
32
|
}
|
|
28
|
-
|
|
33
|
+
|
|
34
|
+
// Generate TOC even for empty files
|
|
35
|
+
const tocContent = data === "" ? "" : toc(mdContent).content;
|
|
36
|
+
newFile = tocContent + "\n<!-- end toc -->\n\n" + mdContent.trim();
|
|
37
|
+
|
|
29
38
|
await writeFile(fileToLoad, newFile);
|
|
30
|
-
}
|
|
31
39
|
};
|
|
32
|
-
|
|
40
|
+
|
|
41
|
+
export default generateToc;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default as generateToc } from "./generateToc.js";
|
|
2
|
-
export { default as generateFScripts } from "./generateFScripts.js";
|
|
2
|
+
export { default as generateFScripts } from "./generateFScripts.js";
|
package/dist/lib/git/pub.js
CHANGED
|
@@ -1,42 +1,38 @@
|
|
|
1
1
|
import inquirer from "inquirer";
|
|
2
2
|
import chalk from "chalk";
|
|
3
|
-
import boxen from "boxen";
|
|
4
3
|
import path from "path";
|
|
5
4
|
import { fileURLToPath } from "url";
|
|
6
5
|
const __filename = fileURLToPath(import.meta.url);
|
|
7
6
|
const __dirname = path.dirname(__filename);
|
|
8
|
-
import runTask from "./taskRunner.js";
|
|
9
7
|
import { readJson } from "../utils/helpers.js";
|
|
10
8
|
import simple from "simple-git";
|
|
11
|
-
|
|
12
|
-
const newBranch = async name => {
|
|
13
|
-
await simple().checkoutLocalBranch(name);
|
|
14
|
-
};
|
|
15
|
-
async function pub() {
|
|
16
|
-
// runTask("sh " + path.join(__dirname, "publish.sh") + " --")
|
|
17
|
-
// .then(async () => {
|
|
18
|
-
// })
|
|
19
|
-
// .catch(e => {
|
|
20
|
-
// console.warn("-- Console ERR", e);
|
|
21
|
-
// });
|
|
22
|
-
}
|
|
9
|
+
|
|
23
10
|
import validateNotInDev from "./validateNotDev.js";
|
|
11
|
+
|
|
24
12
|
(async () => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
13
|
+
await validateNotInDev();
|
|
14
|
+
await new Promise(resolve => {
|
|
15
|
+
let pack = readJson(path.resolve(__dirname + "package.json"));
|
|
16
|
+
|
|
17
|
+
inquirer
|
|
18
|
+
.prompt([
|
|
19
|
+
{
|
|
20
|
+
type: "input",
|
|
21
|
+
message: chalk.bold.hex("#38be18")(`What's new this version ${pack.version}: `),
|
|
22
|
+
name: "commitmsg"
|
|
23
|
+
}
|
|
24
|
+
])
|
|
25
|
+
.then(async ({ commitmsg }) => {
|
|
26
|
+
simple()
|
|
27
|
+
.add("./*")
|
|
28
|
+
.commit(`VERSION ${pack.version}\n${commitmsg}`)
|
|
29
|
+
.push(["-u"], () => console.log("done"))
|
|
30
|
+
.addTag(`${pack.version}`, () => console.warn(""))
|
|
31
|
+
.pushTags("origin", () => {
|
|
32
|
+
console.warn("-- Console 3", 3);
|
|
33
|
+
resolve();
|
|
34
|
+
});
|
|
35
|
+
// await require("simple-git")()
|
|
36
|
+
});
|
|
40
37
|
});
|
|
41
|
-
|
|
42
|
-
})();
|
|
38
|
+
})();
|
|
@@ -5,76 +5,86 @@ import prettyMs from "pretty-ms";
|
|
|
5
5
|
import spawn from "cross-spawn";
|
|
6
6
|
import boxen from "boxen";
|
|
7
7
|
import helpers from "../utils/helpers.js";
|
|
8
|
+
|
|
8
9
|
const runTask = async (name, conf = false) => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
let command = conf === false ? name : tasks[name].file ? "node " + tasks[name].file : tasks[name].script;
|
|
20
|
-
console.clear();
|
|
21
|
-
console.log(input ? chalk.hex("#4b5150")(" Running: ") + chalk.bold.underline.hex("#438b34")(name) : boxen(chalk.hex("#717877")(" Running: ") + chalk.bold.underline.hex("#438b34")(name) + chalk.hex("#717877")(" "), {
|
|
22
|
-
padding: 0,
|
|
23
|
-
margin: {
|
|
24
|
-
left: 2,
|
|
25
|
-
top: 0,
|
|
26
|
-
bottom: 0,
|
|
27
|
-
right: 0
|
|
28
|
-
},
|
|
29
|
-
borderStyle: {
|
|
30
|
-
topLeft: chalk.hex("#5a596d")("╔"),
|
|
31
|
-
topRight: chalk.hex("#5a596d")("╗"),
|
|
32
|
-
bottomLeft: chalk.hex("#5a596d")("╚"),
|
|
33
|
-
bottomRight: chalk.hex("#5a596d")("╝"),
|
|
34
|
-
horizontal: chalk.hex("#5a596d")("═"),
|
|
35
|
-
vertical: chalk.hex("#5a596d")("║")
|
|
36
|
-
},
|
|
37
|
-
//"round",
|
|
38
|
-
// dimBorder: true,
|
|
39
|
-
align: "center" //,
|
|
40
|
-
// float: "center"
|
|
41
|
-
}));
|
|
42
|
-
try {
|
|
43
|
-
let pars = command.split(" ");
|
|
44
|
-
output = spawn(pars[0], pars.slice(1, pars.length), {
|
|
45
|
-
cwd: tryPath,
|
|
46
|
-
env: {
|
|
47
|
-
...process.env,
|
|
48
|
-
...{
|
|
49
|
-
FORCE_COLOR: true
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
stdio: input ? "inherit" : "pipe"
|
|
53
|
-
});
|
|
54
|
-
if (!input) {
|
|
55
|
-
output.stdout.on("data", code => {
|
|
56
|
-
code = code + "";
|
|
57
|
-
console.log(`${chalk.bgHex("#181c24").hex("#8c91a7")(moment().format("HH:MM:SS") + ":")} ${code}`.trim());
|
|
58
|
-
});
|
|
59
|
-
output.stderr.on("data", code => {
|
|
60
|
-
code = code + "";
|
|
61
|
-
console.log(`${chalk.bgHex("#181c24").hex("#a72e32")(moment().format("HH:MM:SS") + "ERR :")} ${code}`.trim());
|
|
62
|
-
});
|
|
10
|
+
let output;
|
|
11
|
+
let startTime = Date.now();
|
|
12
|
+
let input = name.slice(-1) === "-";
|
|
13
|
+
let task = {};
|
|
14
|
+
let tasks = [];
|
|
15
|
+
if (conf !== false) {
|
|
16
|
+
conf.set("tasks." + name + ".lastRan", startTime);
|
|
17
|
+
await conf.updateConfigFile();
|
|
18
|
+
tasks = conf.get("tasks");
|
|
63
19
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
20
|
+
let command =
|
|
21
|
+
conf === false ? name : tasks[name].file ? "node " + tasks[name].file : tasks[name].script;
|
|
22
|
+
console.clear();
|
|
23
|
+
console.log(
|
|
24
|
+
input
|
|
25
|
+
? chalk.hex("#4b5150")(" Running: ") + chalk.bold.underline.hex("#438b34")(name)
|
|
26
|
+
: boxen(
|
|
27
|
+
chalk.hex("#717877")(" Running: ") +
|
|
28
|
+
chalk.bold.underline.hex("#438b34")(name) +
|
|
29
|
+
chalk.hex("#717877")(" "),
|
|
30
|
+
{
|
|
31
|
+
padding: 0,
|
|
32
|
+
margin: { left: 2, top: 0, bottom: 0, right: 0 },
|
|
33
|
+
borderStyle: {
|
|
34
|
+
topLeft: chalk.hex("#5a596d")("╔"),
|
|
35
|
+
topRight: chalk.hex("#5a596d")("╗"),
|
|
36
|
+
bottomLeft: chalk.hex("#5a596d")("╚"),
|
|
37
|
+
bottomRight: chalk.hex("#5a596d")("╝"),
|
|
38
|
+
horizontal: chalk.hex("#5a596d")("═"),
|
|
39
|
+
vertical: chalk.hex("#5a596d")("║")
|
|
40
|
+
}, //"round",
|
|
41
|
+
// dimBorder: true,
|
|
42
|
+
align: "center" //,
|
|
43
|
+
// float: "center"
|
|
44
|
+
}
|
|
45
|
+
)
|
|
46
|
+
);
|
|
47
|
+
try {
|
|
48
|
+
let pars = command.split(" ");
|
|
49
|
+
|
|
50
|
+
output = spawn(pars[0], pars.slice(1, pars.length), {
|
|
51
|
+
cwd: tryPath,
|
|
52
|
+
env: { ...process.env, ...{ FORCE_COLOR: true } },
|
|
53
|
+
stdio: input ? "inherit" : "pipe"
|
|
54
|
+
});
|
|
55
|
+
if (!input) {
|
|
56
|
+
output.stdout.on("data", code => {
|
|
57
|
+
code = code + "";
|
|
58
|
+
console.log(
|
|
59
|
+
`${chalk.bgHex("#181c24").hex("#8c91a7")(
|
|
60
|
+
moment().format("HH:MM:SS") + ":"
|
|
61
|
+
)} ${code}`.trim()
|
|
62
|
+
);
|
|
63
|
+
});
|
|
64
|
+
output.stderr.on("data", code => {
|
|
65
|
+
code = code + "";
|
|
66
|
+
console.log(
|
|
67
|
+
`${chalk.bgHex("#181c24").hex("#a72e32")(
|
|
68
|
+
moment().format("HH:MM:SS") + "ERR :"
|
|
69
|
+
)} ${code}`.trim()
|
|
70
|
+
);
|
|
71
|
+
});
|
|
73
72
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
73
|
+
return new Promise((resolve, reject) => {
|
|
74
|
+
output.on("close", code => {
|
|
75
|
+
if (code === 0) {
|
|
76
|
+
let elapsed = Date.now() - startTime;
|
|
77
|
+
console.log(`${chalk.bold.green("Finished in " + prettyMs(elapsed), code)}`);
|
|
78
|
+
resolve();
|
|
79
|
+
} else {
|
|
80
|
+
// console.log(`${chalk.bold.green("Finished in " + prettyMs(elapsed), code)}`);
|
|
81
|
+
reject(`task exited with code ${code}`);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
} catch (error) {
|
|
86
|
+
console.log(`${chalk.red.bold(error)}`);
|
|
87
|
+
}
|
|
79
88
|
};
|
|
80
|
-
|
|
89
|
+
|
|
90
|
+
export default runTask;
|