fscr 5.4.1 → 6.1.2

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.
Files changed (66) hide show
  1. package/bin +1 -1
  2. package/dist/index.js +193 -49
  3. package/dist/lib/auth/auth-conf.js +63 -0
  4. package/dist/lib/codemod/arrow.js +13 -0
  5. package/dist/lib/codemod/arrow2.js +67 -0
  6. package/dist/lib/codemod/funcs.js +25 -0
  7. package/dist/lib/codemod/removeConsole.js +12 -0
  8. package/dist/lib/codemod/test.js +8 -0
  9. package/dist/lib/components/App.js +64 -0
  10. package/dist/lib/components/Selector.js +133 -0
  11. package/dist/lib/components/TabChanger.js +113 -0
  12. package/dist/lib/components/Table.js +177 -0
  13. package/dist/lib/components/Tabs.js +221 -0
  14. package/dist/lib/encryption/decryptConfig.js +81 -0
  15. package/dist/lib/encryption/encryption.js +135 -0
  16. package/dist/lib/generateFScripts.js +25 -0
  17. package/dist/lib/generateToc.js +36 -0
  18. package/dist/lib/generators/generateFScripts.js +25 -0
  19. package/dist/lib/generators/generateToc.js +38 -0
  20. package/dist/lib/generators/index.js +2 -0
  21. package/dist/lib/git/files.js +26 -0
  22. package/dist/lib/git/pub.js +42 -0
  23. package/dist/lib/git/taskRunner.js +80 -0
  24. package/dist/lib/git/validateNotDev.js +71 -0
  25. package/dist/lib/helpers.js +191 -0
  26. package/dist/lib/optionList.js +61 -0
  27. package/dist/lib/parseScriptsMd.js +93 -0
  28. package/dist/lib/parseScriptsPackage.js +9 -0
  29. package/dist/lib/parsers/parseScriptsMd.js +96 -0
  30. package/dist/lib/parsers/parseScriptsPackage.js +9 -0
  31. package/dist/lib/release/bump.js +52 -0
  32. package/dist/lib/release/commitWithMessage.js +65 -0
  33. package/dist/lib/release/index.js +4 -0
  34. package/dist/lib/release/publish.js +23 -0
  35. package/dist/lib/release/publish.sh +1 -0
  36. package/dist/lib/release/pushToGit.js +43 -0
  37. package/dist/lib/release/releasenotes.js +158 -0
  38. package/dist/lib/release/seeChangedFiles.js +89 -0
  39. package/dist/lib/release/sort.js +136 -0
  40. package/dist/lib/release/tree.js +163 -0
  41. package/dist/lib/release/validateNotDev.js +63 -0
  42. package/dist/lib/run/lib.js +454 -0
  43. package/dist/lib/run/main-p.js +59 -0
  44. package/dist/lib/run/main-s.js +56 -0
  45. package/dist/lib/run/parse-cli-args.js +222 -0
  46. package/dist/lib/run/run-p.js +30 -0
  47. package/dist/lib/run/run-s.js +57 -0
  48. package/dist/lib/runCLICommand.js +30 -0
  49. package/dist/lib/runParallel.js +20 -0
  50. package/dist/lib/runSequence.js +38 -0
  51. package/dist/lib/running/index.js +3 -0
  52. package/dist/lib/running/runCLICommand.js +38 -0
  53. package/dist/lib/running/runParallel.js +33 -0
  54. package/dist/lib/running/runSequence.js +43 -0
  55. package/dist/lib/startScripts.js +134 -0
  56. package/dist/lib/taskList.js +93 -0
  57. package/dist/lib/taskListAutoComplete.js +10 -0
  58. package/dist/lib/upgradePackages.js +65 -0
  59. package/dist/lib/utils/clear.js +18 -0
  60. package/dist/lib/utils/console.js +33 -0
  61. package/dist/lib/utils/encryption.js +18 -0
  62. package/dist/lib/utils/helpers.js +228 -0
  63. package/dist/lib/utils/index.js +2 -0
  64. package/dist/lib/utils/prompt.js +34 -0
  65. package/package.json +8 -7
  66. /package/dist/{index.html → lib/auth/index.html} +0 -0
@@ -0,0 +1,81 @@
1
+ const encrypt = require("./encryption");
2
+ (async () => {
3
+ await encrypt.init();
4
+ })();
5
+ const inquirer = require("inquirer");
6
+ const path = require("path");
7
+ const spawn = require("cross-spawn");
8
+ const argv = require("yargs").argv;
9
+ const clipboardy = require("clipboardy");
10
+ const chalk = require("chalk");
11
+ const cgf = require("changed-git-files");
12
+ const projectDir = process.cwd();
13
+ const packagePath = path.join(projectDir, "./");
14
+ (async () => {
15
+ if (argv.interactive) {
16
+ inquirer.prompt({
17
+ type: "list",
18
+ name: "typeInc",
19
+ message: "Type on increment",
20
+ choices: ["patch", "minor", "major", "semver"],
21
+ default: "patch"
22
+ }).then(async ({
23
+ typeInc
24
+ }) => {
25
+ // spawn.sync("yarn", ["start", ...process.argv.slice(2)], {
26
+ // stdio: "inherit",
27
+ // env: Object.assign({}, process.env, {
28
+ // PATH: `${path.resolve("node_modules/.bin")}:${process.env.PATH}`
29
+ // })
30
+ // });
31
+ let commitMsg = await bump(typeInc);
32
+ await clipboardy.write(commitMsg);
33
+ console.log(chalk.bold.green(`Commit message copied to clipboard:\n`) + chalk.bgWhite.black(`${commitMsg}`));
34
+ const packageVersion = require(path.join(packagePath, "package.json")).version;
35
+ await require("simple-git")().fetch().add("./packages/*").commit(commitMsg).addTag(packageVersion).pushTags().push(["-u", "--set-upstream"]);
36
+ });
37
+ }
38
+ if (argv.package) {
39
+ await runAsync(`yarn version --cwd=packages/${argv.package} --no-git-tag-version --patch --no-commit-hooks`);
40
+ }
41
+ })();
42
+ async function message(title) {
43
+ return new Promise(resolve => {
44
+ inquirer.prompt({
45
+ type: `text`,
46
+ name: `commitMessage`,
47
+ message: title
48
+ }).then(({
49
+ commitMessage
50
+ }) => {
51
+ resolve(commitMessage);
52
+ });
53
+ });
54
+ }
55
+ async function bump(type = "patch") {
56
+ let defaultCommitMsg = ``;
57
+ return new Promise(resolve => {
58
+ cgf(async function (err, results) {
59
+ let updatedPackages = [];
60
+ results.forEach(path => {
61
+ let segments = path.filename.split("/");
62
+ if (segments[0] === "packages") {
63
+ if (!updatedPackages.includes(segments[1])) {
64
+ updatedPackages.push(segments[1]);
65
+ }
66
+ }
67
+ });
68
+ await runAsync(`yarn version --no-git-tag-version --${type} --no-commit-hooks`);
69
+ for (let index = 0; index < updatedPackages.length; index++) {
70
+ await runAsync(`yarn version --${type} --no-git-tag-version --no-commit-hooks --cwd=packages/${updatedPackages[index]}`);
71
+ let packVer = require(path.join(packagePath, "./packages/" + updatedPackages[index] + "/package.json")).version;
72
+ defaultCommitMsg += ` [${updatedPackages[index]}]:${packVer}\n`;
73
+ let whatsNew = `${"Package: " + chalk.cyan(updatedPackages[index])} -- ${chalk.green("New version: " + packVer)}\n${chalk.bold.underline.cyan("What's changed?")}`;
74
+ defaultCommitMsg += ` - ${await message(whatsNew)}\n\n`;
75
+ }
76
+ const packageVersion = require(path.join(packagePath, "package.json")).version;
77
+ defaultCommitMsg = `Version:${packageVersion}\n- ${await message("Overall change summary:")}\n\n` + defaultCommitMsg;
78
+ resolve(defaultCommitMsg);
79
+ });
80
+ });
81
+ }
@@ -0,0 +1,135 @@
1
+ import chalk from "chalk";
2
+ import inquirer from "inquirer";
3
+ import { encrypt, decrypt } from "../utils/encryption.js";
4
+ import { appendToFile, ensureFile, writeFile, boxInform, readJson, readFile } from "../utils/helpers.js";
5
+ import path from "path";
6
+ const scriptsDir = process.cwd();
7
+ const rootDir = path.join(scriptsDir, "./");
8
+ const packagePath = path.join(rootDir, "package.json");
9
+ const igPath = path.join(rootDir, ".gitignore");
10
+ const encrypted = {
11
+ encryptedFiles: []
12
+ };
13
+
14
+ // prettier-ignore
15
+ encrypted.encrypt = async (pass, encryptedFile, decryptedFile) => {
16
+ let willEncrypt = true;
17
+ let sureSure = await ensureFile(encryptedFile);
18
+ if (sureSure) {
19
+ console.log(`${chalk.bold.red("FILE ALREADY EXISTS ARE YOU SURE?")}`);
20
+ willEncrypt = await new Promise(resolve => {
21
+ inquirer.prompt([{
22
+ type: "confirm",
23
+ message: chalk.bold.hex("#38be18")(`Sure? (y/n): `),
24
+ name: "sure"
25
+ }]).then(({
26
+ sure
27
+ }) => {
28
+ resolve(sure);
29
+ });
30
+ });
31
+ }
32
+ if (willEncrypt) {
33
+ let toEncrypt = await readFile(decryptedFile);
34
+ const ciphertext = encrypt(toEncrypt, pass);
35
+ await writeFile(encryptedFile, ciphertext.toString());
36
+ }
37
+ };
38
+ // prettier-ignore
39
+ encrypted.decrypt = async (pass, encryptedFileLocation, decryptedFileLocation) => {
40
+ // let encryptedFileLocation = path.join(rootDir,"."+encryptedFile);
41
+ // let decryptedFileLocation = path.join(rootDir,encryptedFile);
42
+ let willEncrypt = true;
43
+ let sureSure = await ensureFile(decryptedFileLocation);
44
+ if (sureSure) {
45
+ console.log(`${chalk.bold.red("FILE ALREADY EXISTS ARE YOU SURE?")}`);
46
+ willEncrypt = await new Promise(resolve => {
47
+ inquirer.prompt([{
48
+ type: "confirm",
49
+ message: chalk.bold.hex("#38be18")(`Sure wanna override file ${decryptedFileLocation}? (y/n): `),
50
+ name: "sure"
51
+ }]).then(({
52
+ sure
53
+ }) => {
54
+ resolve(sure);
55
+ });
56
+ });
57
+ }
58
+ if (willEncrypt) {
59
+ let toDecrypt = await readFile(encryptedFileLocation);
60
+ const decryptedData = decrypt(toDecrypt, pass);
61
+ await writeFile(decryptedFileLocation, decryptedData);
62
+ console.warn(`${chalk.bold.green.underline("DECRYPTED FILE:")} ${chalk.bold.dim(path.join(scriptsDir, decryptedFileLocation))}`);
63
+ }
64
+ };
65
+ encrypted.init = async () => {
66
+ try {
67
+ let pass = await encrypted.getPass();
68
+ let toEncrypt = await encrypted.toEncrypt();
69
+ encrypted.packageJson = await readJson(packagePath);
70
+ encrypted.ignore = await readFile(igPath);
71
+ encrypted.ignoredFiles = encrypted.ignore.split("\n");
72
+ if (encrypted.packageJson.fscripts) {
73
+ if (encrypted.packageJson.fscripts.encryptedFiles) {
74
+ encrypted.encryptedFiles = encrypted.packageJson.fscripts.encryptedFiles;
75
+ let filesToAdd = "\n";
76
+ for (const e of encrypted.encryptedFiles) {
77
+ if (encrypted.ignoredFiles.indexOf(e) === -1) {
78
+ filesToAdd += e + "\n";
79
+ }
80
+ let file = e + "";
81
+ let fileSplit = file.split("/");
82
+ let name = fileSplit.pop();
83
+ let encryptedFile = fileSplit.slice();
84
+ let decryptedFile = fileSplit.slice();
85
+ encryptedFile.push("." + name);
86
+ encryptedFile = path.join(rootDir, encryptedFile.join("/"));
87
+ decryptedFile.push(name);
88
+ decryptedFile = path.join(rootDir, decryptedFile.join("/"));
89
+ if (toEncrypt) {
90
+ await encrypted.encrypted(pass, encryptedFile, decryptedFile);
91
+ } else {
92
+ await encrypted.decrypt(pass, encryptedFile, decryptedFile);
93
+ }
94
+ }
95
+ if (filesToAdd.trim().length > 0) {
96
+ await appendToFile(igPath, filesToAdd + "\n");
97
+ boxInform(" Added files to .gitignore: ", filesToAdd);
98
+ }
99
+ }
100
+ }
101
+ } catch (err) {
102
+ console.error(err);
103
+ }
104
+ };
105
+ encrypted.getPass = async () => {
106
+ return await new Promise(resolve => {
107
+ inquirer.prompt([{
108
+ type: "password",
109
+ mask: chalk.underline(" ●"),
110
+ message: chalk.bold.hex("#38be18")(`Enter a SECRET key (same as pass app) : `),
111
+ name: "pass"
112
+ }]).then(({
113
+ pass
114
+ }) => {
115
+ resolve(pass);
116
+ });
117
+ });
118
+ };
119
+ encrypted.toEncrypt = async () => {
120
+ return await new Promise(resolve => {
121
+ inquirer.prompt([{
122
+ type: "list",
123
+ message: chalk.bold.hex("#38be18")("Which direction?"),
124
+ choices: ["encrypt", "decrypt"],
125
+ name: "encryptDecrypt"
126
+ }]).then(async ({
127
+ encryptDecrypt
128
+ }) => {
129
+ resolve(encryptDecrypt === "encrypt");
130
+ });
131
+ });
132
+ };
133
+ export default {
134
+ ...encrypted
135
+ };
@@ -0,0 +1,25 @@
1
+ import chalk from "chalk";
2
+ import inquirer from "inquirer";
3
+ import { appendToFile, writeFile, boxInform, readJson, readFile } from "./utils/helpers.js";
4
+ import path from "path";
5
+ const projectDir = process.cwd();
6
+ const packagePath = path.join(projectDir, "package.json");
7
+ const gen = {
8
+ scripts: []
9
+ };
10
+ let mdfile = `# First category of scripts
11
+
12
+ Welcome to your new amazing fscripts.md file. It replaces the headaches of npm scripts! But so much more.
13
+ `;
14
+ gen.init = async () => {
15
+ try {
16
+ gen.packageJson = await readJson(packagePath);
17
+ Object.keys(gen.packageJson.scripts).forEach(scriptName => {
18
+ mdfile += `\n## ${scriptName}\n\n${gen.packageJson.scripts[scriptName]}\n\n\`\`\`bash\n${gen.packageJson.scripts[scriptName]}\n\`\`\`\n\n`;
19
+ });
20
+ await writeFile("./sample.fscripts.md", mdfile);
21
+ } catch (err) {
22
+ console.error(err);
23
+ }
24
+ };
25
+ export default gen.init;
@@ -0,0 +1,36 @@
1
+ import path from "path";
2
+ import chalk from "chalk";
3
+ import JoyCon from "joycon";
4
+ import tocPkg from "markdown-toc";
5
+ const toc = tocPkg.default || tocPkg;
6
+ const joyRead = new JoyCon({
7
+ // Stop reading at parent dir
8
+ // i.e. Only read file from process.cwd()
9
+ stopDir: path.dirname(process.cwd())
10
+ });
11
+ import { writeFile } from "./utils/helpers.js";
12
+ // const projectDir = process.cwd();
13
+
14
+ const generateToc = async () => {
15
+ const {
16
+ path: filepath,
17
+ data
18
+ } = joyRead.loadSync(["fscripts.md"]);
19
+ if (!filepath) {
20
+ console.warn(`${chalk.bold.red("You're missing the fscripts.md file!")}
21
+ ${chalk.green("Please run 'fsr generate' to get started!")}`);
22
+ process.exit(0);
23
+ return null;
24
+ } else {
25
+ console.warn(`${chalk.bold.green("Located fscripts.md file!")}`);
26
+ let newFile = ``;
27
+ let tocSplit = data.split("<!-- end toc -->");
28
+ if (tocSplit.length === 2) {
29
+ newFile = toc(tocSplit[1]).content + "\n<!-- end toc -->\n\n" + tocSplit[1].trim();
30
+ } else {
31
+ newFile = toc(data).content + "\n<!-- end toc -->\n\n" + data.trim();
32
+ }
33
+ await writeFile("./fscripts.md", newFile);
34
+ }
35
+ };
36
+ export default generateToc;
@@ -0,0 +1,25 @@
1
+ import chalk from "chalk";
2
+ import inquirer from "inquirer";
3
+ import { appendToFile, writeFile, boxInform, readJson, readFile } from "../utils/helpers.js";
4
+ import path from "path";
5
+ const projectDir = process.cwd();
6
+ const packagePath = path.join(projectDir, "package.json");
7
+ const gen = {
8
+ scripts: []
9
+ };
10
+ let mdfile = `# First category of scripts
11
+
12
+ Welcome to your new amazing fscripts.md file. It replaces the headaches of npm scripts! But so much more.
13
+ `;
14
+ gen.init = async () => {
15
+ try {
16
+ gen.packageJson = await readJson(packagePath);
17
+ Object.keys(gen.packageJson.scripts).forEach(scriptName => {
18
+ mdfile += `\n## ${scriptName}\n\n${gen.packageJson.scripts[scriptName]}\n\n\`\`\`bash\n${gen.packageJson.scripts[scriptName]}\n\`\`\`\n\n`;
19
+ });
20
+ await writeFile("./sample.fscripts.md", mdfile);
21
+ } catch (err) {
22
+ console.error(err);
23
+ }
24
+ };
25
+ export default gen.init;
@@ -0,0 +1,38 @@
1
+ import path from "path";
2
+ import chalk from "chalk";
3
+ import JoyCon from "joycon";
4
+ import tocPkg from "markdown-toc";
5
+ const toc = tocPkg.default || tocPkg;
6
+ const joyRead = new JoyCon({
7
+ // Stop reading at parent dir
8
+ // i.e. Only read file from process.cwd()
9
+ stopDir: path.dirname(process.cwd())
10
+ });
11
+ import { writeFile } from "../utils/helpers.js";
12
+ // const projectDir = process.cwd();
13
+
14
+ const generateToc = async (fileToLoad = "fscripts.md") => {
15
+ const {
16
+ path: filepath,
17
+ data
18
+ } = joyRead.loadSync([fileToLoad]);
19
+ if (!filepath) {
20
+ console.warn(`${chalk.bold.red("You're missing the fscripts.md file!")}
21
+ ${chalk.green("Please run 'fsr generate' to get started!")}`);
22
+ process.exit(0);
23
+ return null;
24
+ } else {
25
+ console.warn(`${chalk.bold.green("Located fscripts.md file!")}`);
26
+ let newFile = ``;
27
+ let tocSplit = data.split("<!-- end toc -->");
28
+ let mdContent = "";
29
+ if (tocSplit.length === 2) {
30
+ mdContent = tocSplit[1];
31
+ } else {
32
+ mdContent = data;
33
+ }
34
+ newFile = toc(mdContent).content + "\n<!-- end toc -->\n\n" + mdContent.trim();
35
+ await writeFile(fileToLoad, newFile);
36
+ }
37
+ };
38
+ export default generateToc;
@@ -0,0 +1,2 @@
1
+ export { default as generateToc } from "./generateToc.js";
2
+ export { default as generateFScripts } from "./generateFScripts.js";
@@ -0,0 +1,26 @@
1
+ import inquirer from "inquirer";
2
+ import inquirerFuzzyPath from "inquirer-fuzzy-path";
3
+ inquirer.registerPrompt("fuzzypath", inquirerFuzzyPath);
4
+ (async () => {
5
+ return inquirer.prompt([{
6
+ type: "fuzzypath",
7
+ name: "path",
8
+ excludePath: nodePath => nodePath.startsWith("node_modules") || nodePath.startsWith(".git") || nodePath.startsWith(".idea"),
9
+ // excludePath :: (String) -> Bool
10
+ // excludePath to exclude some paths from the file-system scan
11
+ // itemType: "any",
12
+ itemType: "directory" | "file",
13
+ //'any' | | 'file'
14
+ // specify the type of nodes to display
15
+ // default value: 'any'
16
+ // example: itemType: 'file' - hides directories from the item list
17
+ // rootPath: "app",
18
+ // rootPath :: String
19
+ // Root search directory
20
+ message: "Select a target directory for your component:",
21
+ // default: "./",
22
+ suggestOnly: false
23
+ // suggestOnly :: Bool
24
+ // Restrict prompt answer to available choices or use them as suggestions
25
+ }]);
26
+ })();
@@ -0,0 +1,42 @@
1
+ import inquirer from "inquirer";
2
+ import chalk from "chalk";
3
+ import boxen from "boxen";
4
+ import path from "path";
5
+ import { fileURLToPath } from "url";
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = path.dirname(__filename);
8
+ import runTask from "./taskRunner.js";
9
+ import { readJson } from "../utils/helpers.js";
10
+ import simple from "simple-git";
11
+ // pub();
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
+ }
23
+ import validateNotInDev from "./validateNotDev.js";
24
+ (async () => {
25
+ await validateNotInDev();
26
+ await new Promise(resolve => {
27
+ let pack = readJson(path.resolve(__dirname + "package.json"));
28
+ inquirer.prompt([{
29
+ type: "input",
30
+ message: chalk.bold.hex("#38be18")(`What's new this version ${pack.version}: `),
31
+ name: "commitmsg"
32
+ }]).then(async ({
33
+ commitmsg
34
+ }) => {
35
+ simple().add("./*").commit(`VERSION ${pack.version}\n${commitmsg}`).push(["-u"], () => console.log("done")).addTag(`${pack.version}`, () => console.warn("")).pushTags("origin", () => {
36
+ console.warn("-- Console 3", 3);
37
+ resolve();
38
+ });
39
+ // await require("simple-git")()
40
+ });
41
+ });
42
+ })();
@@ -0,0 +1,80 @@
1
+ import moment from "moment-mini";
2
+ const tryPath = process.cwd();
3
+ import chalk from "chalk";
4
+ import prettyMs from "pretty-ms";
5
+ import spawn from "cross-spawn";
6
+ import boxen from "boxen";
7
+ import helpers from "../utils/helpers.js";
8
+ const runTask = async (name, conf = false) => {
9
+ let output;
10
+ let startTime = Date.now();
11
+ let input = name.slice(-1) === "-";
12
+ let task = {};
13
+ let tasks = [];
14
+ if (conf !== false) {
15
+ conf.set("tasks." + name + ".lastRan", startTime);
16
+ await conf.updateConfigFile();
17
+ tasks = conf.get("tasks");
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
+ });
63
+ }
64
+ return new Promise((resolve, reject) => {
65
+ output.on("close", code => {
66
+ if (code === 0) {
67
+ let elapsed = Date.now() - startTime;
68
+ console.log(`${chalk.bold.green("Finished in " + prettyMs(elapsed), code)}`);
69
+ resolve();
70
+ } else {
71
+ // console.log(`${chalk.bold.green("Finished in " + prettyMs(elapsed), code)}`);
72
+ reject(`task exited with code ${code}`);
73
+ }
74
+ });
75
+ });
76
+ } catch (error) {
77
+ console.log(`${chalk.red.bold(error)}`);
78
+ }
79
+ };
80
+ export default runTask;
@@ -0,0 +1,71 @@
1
+ import inquirer from "inquirer";
2
+ import chalk from "chalk";
3
+ import boxen from "boxen";
4
+ import { boxInform } from "../utils/helpers.js";
5
+ import git from "git-state";
6
+ import simple from "simple-git";
7
+ const pathToCwd = process.cwd();
8
+ const newBranch = async name => {
9
+ // const last = await new Promise(rzz => {
10
+ // git.isGit(pathToCwd, function(exists) {
11
+ // if (!exists) return;
12
+
13
+ //
14
+ // git.commit(pathToCwd, function(err, result) {
15
+ // if (err) throw err;
16
+ // rzz(result);
17
+ // });
18
+ // });
19
+ // });
20
+
21
+ try {
22
+ // logInfo(command);
23
+ childProcess.execSync(`git -c core.quotepath=false -c log.showSignature=false checkout -b ${name}`, {
24
+ stdio: "inherit",
25
+ env: Object.assign({}, process.env, {
26
+ FORCE_COLOR: true,
27
+ PATH: `${path.resolve("node_modules")}:${process.env.PATH}`
28
+ })
29
+ });
30
+ } catch (e) {}
31
+
32
+ // await simple().checkoutLocalBranch(name);
33
+ // await simple().checkoutBranch(name, "origin");
34
+ boxInform(chalk.green(`New branch ${name} created`, "", 5));
35
+ };
36
+ async function pub() {
37
+ return new Promise(resolve => {
38
+ inquirer.prompt([{
39
+ type: "input",
40
+ message: chalk.bold.hex("#38be18")(`Name new feature branch (or type cancel):`),
41
+ name: "branchname"
42
+ }]).then(async ({
43
+ branchname
44
+ }) => {
45
+ if (branchname !== "Development") await newBranch(branchname);
46
+ resolve();
47
+ });
48
+ });
49
+ }
50
+ const validateNotInDev = async () => {
51
+ await new Promise(async resolve => {
52
+ const {
53
+ default: git
54
+ } = await import("simple-git/promise");
55
+ let statusSummary = await git(__dirname).status();
56
+ if (statusSummary.current === "Development") {
57
+ console.clear();
58
+ console.log(boxen(chalk.bold.underline.red("DO NO MAKE CHANGES IN DEV!"), {
59
+ padding: 2
60
+ }));
61
+ await new Promise(resolve1 => setTimeout(() => {
62
+ resolve1();
63
+ }, 1000));
64
+ await pub();
65
+ resolve();
66
+ } else {
67
+ resolve();
68
+ }
69
+ });
70
+ };
71
+ export default validateNotInDev;