fscr 5.4.1 → 6.1.1
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/bin +1 -1
- package/dist/index.js +196 -49
- package/dist/lib/auth/auth-conf.js +63 -0
- package/dist/lib/codemod/arrow.js +13 -0
- package/dist/lib/codemod/arrow2.js +67 -0
- package/dist/lib/codemod/funcs.js +25 -0
- package/dist/lib/codemod/removeConsole.js +12 -0
- package/dist/lib/codemod/test.js +8 -0
- package/dist/lib/components/App.js +64 -0
- package/dist/lib/components/Selector.js +133 -0
- package/dist/lib/components/TabChanger.js +113 -0
- package/dist/lib/components/Table.js +177 -0
- package/dist/lib/components/Tabs.js +221 -0
- package/dist/lib/encryption/decryptConfig.js +81 -0
- package/dist/lib/encryption/encryption.js +135 -0
- package/dist/lib/generateFScripts.js +25 -0
- package/dist/lib/generateToc.js +36 -0
- package/dist/lib/generators/generateFScripts.js +25 -0
- package/dist/lib/generators/generateToc.js +38 -0
- package/dist/lib/generators/index.js +2 -0
- package/dist/lib/git/files.js +26 -0
- package/dist/lib/git/pub.js +42 -0
- package/dist/lib/git/taskRunner.js +80 -0
- package/dist/lib/git/validateNotDev.js +71 -0
- package/dist/lib/helpers.js +191 -0
- package/dist/lib/optionList.js +61 -0
- package/dist/lib/parseScriptsMd.js +93 -0
- package/dist/lib/parseScriptsPackage.js +9 -0
- package/dist/lib/parsers/parseScriptsMd.js +96 -0
- package/dist/lib/parsers/parseScriptsPackage.js +9 -0
- package/dist/lib/release/bump.js +52 -0
- package/dist/lib/release/commitWithMessage.js +65 -0
- package/dist/lib/release/index.js +4 -0
- package/dist/lib/release/publish.js +23 -0
- package/dist/lib/release/publish.sh +1 -0
- package/dist/lib/release/pushToGit.js +43 -0
- package/dist/lib/release/releasenotes.js +158 -0
- package/dist/lib/release/seeChangedFiles.js +89 -0
- package/dist/lib/release/sort.js +136 -0
- package/dist/lib/release/tree.js +163 -0
- package/dist/lib/release/validateNotDev.js +63 -0
- package/dist/lib/run/lib.js +454 -0
- package/dist/lib/run/main-p.js +59 -0
- package/dist/lib/run/main-s.js +56 -0
- package/dist/lib/run/parse-cli-args.js +222 -0
- package/dist/lib/run/run-p.js +30 -0
- package/dist/lib/run/run-s.js +57 -0
- package/dist/lib/runCLICommand.js +30 -0
- package/dist/lib/runParallel.js +20 -0
- package/dist/lib/runSequence.js +38 -0
- package/dist/lib/running/index.js +3 -0
- package/dist/lib/running/runCLICommand.js +38 -0
- package/dist/lib/running/runParallel.js +33 -0
- package/dist/lib/running/runSequence.js +43 -0
- package/dist/lib/startScripts.js +135 -0
- package/dist/lib/taskList.js +93 -0
- package/dist/lib/taskListAutoComplete.js +10 -0
- package/dist/lib/upgradePackages.js +65 -0
- package/dist/lib/utils/clear.js +18 -0
- package/dist/lib/utils/console.js +33 -0
- package/dist/lib/utils/encryption.js +18 -0
- package/dist/lib/utils/helpers.js +228 -0
- package/dist/lib/utils/index.js +2 -0
- package/dist/lib/utils/prompt.js +34 -0
- package/package.json +9 -7
- /package/dist/{index.html → lib/auth/index.html} +0 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import fs from "fs-extra";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import boxen from "boxen";
|
|
4
|
+
const ONE_SIXTH = 1 / 6;
|
|
5
|
+
const ONE_THIRD = 1 / 3;
|
|
6
|
+
const TWO_THIRDS = 2 / 3;
|
|
7
|
+
const utils = {};
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Output json file
|
|
11
|
+
* @param f - file name with directory
|
|
12
|
+
* @return {boolean}
|
|
13
|
+
* @example
|
|
14
|
+
const file = "/tmp/this/path/does/not/exist/file.json";
|
|
15
|
+
removeFile(file);
|
|
16
|
+
*/
|
|
17
|
+
utils.emptyDir = async f => {
|
|
18
|
+
try {
|
|
19
|
+
await fs.emptyDir(f);
|
|
20
|
+
// console.log(`${chalk.green.underline("Directory")} ${chalk.bold(f)} emptied!`);
|
|
21
|
+
} catch (err) {
|
|
22
|
+
console.error(err);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const desiredMode = 0o2775;
|
|
26
|
+
const defaultOptions = {
|
|
27
|
+
mode: desiredMode
|
|
28
|
+
};
|
|
29
|
+
utils.ensureDir = async (directory, options = defaultOptions) => {
|
|
30
|
+
try {
|
|
31
|
+
await fs.ensureDir(directory, options);
|
|
32
|
+
} catch (err) {
|
|
33
|
+
console.error(err);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
utils.ensureFile = async f => {
|
|
37
|
+
try {
|
|
38
|
+
await fs.ensureFile(f);
|
|
39
|
+
} catch (err) {
|
|
40
|
+
console.error(err);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Ensure path exists with dirs
|
|
46
|
+
* @param f the file path
|
|
47
|
+
* @return {boolean}
|
|
48
|
+
* @example
|
|
49
|
+
const file = ".fsr/config.json";
|
|
50
|
+
pathExists(file);
|
|
51
|
+
*/
|
|
52
|
+
utils.pathExists = async f => {
|
|
53
|
+
const exists = await fs.pathExists(f);
|
|
54
|
+
return exists;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Read json file
|
|
59
|
+
* @param f - file name with directory
|
|
60
|
+
* @return {Promise<void>}
|
|
61
|
+
* @example
|
|
62
|
+
const file = "/tmp/this/path/does/not/exist/file.json";
|
|
63
|
+
outputJson(file);
|
|
64
|
+
*/
|
|
65
|
+
utils.readJson = async f => {
|
|
66
|
+
try {
|
|
67
|
+
const packageObj = await fs.readJson(f);
|
|
68
|
+
// console.log(`${chalk.green.underline("File")} ${chalk.bold(f)} read!`);
|
|
69
|
+
return packageObj;
|
|
70
|
+
} catch (err) {
|
|
71
|
+
console.error(err);
|
|
72
|
+
return {};
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
utils.readFile = async f => {
|
|
76
|
+
try {
|
|
77
|
+
let fl = await fs.readFileSync(f, "utf8");
|
|
78
|
+
return fl;
|
|
79
|
+
} catch (err) {
|
|
80
|
+
console.error(err);
|
|
81
|
+
return {};
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
utils.removeFile = async f => {
|
|
85
|
+
try {
|
|
86
|
+
// console.log(`${chalk.green.underline("File")} ${chalk.bold(f)} removed!`);
|
|
87
|
+
return await fs.remove(f);
|
|
88
|
+
} catch (err) {
|
|
89
|
+
console.error(`File ${f} NOT REMOVED! ${err}`);
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Write file
|
|
96
|
+
* @param f - file name with directory
|
|
97
|
+
* @param contents - text inside the file
|
|
98
|
+
* @return {Promise<void>}
|
|
99
|
+
* @example
|
|
100
|
+
const file = "/tmp/this/path/does/not/exist/file.json";
|
|
101
|
+
writeFile(file);
|
|
102
|
+
*/
|
|
103
|
+
utils.writeFile = async (f, contents = "") => {
|
|
104
|
+
try {
|
|
105
|
+
return fs.writeFileSync(f, contents, "utf-8");
|
|
106
|
+
// console.log(`${chalk.green.underline("File")} ${chalk.bold(f)} written!`);
|
|
107
|
+
} catch (err) {
|
|
108
|
+
console.error(err);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
utils.writeJson = async (f, json = {}) => {
|
|
112
|
+
try {
|
|
113
|
+
await fs.writeJson(f, json);
|
|
114
|
+
// console.log(`${chalk.green.underline("File")} ${chalk.bold(f)} written!`);
|
|
115
|
+
} catch (err) {
|
|
116
|
+
console.error(err);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
utils.chainAsync = fns => {
|
|
120
|
+
let curr = 0;
|
|
121
|
+
const last = fns[fns.length - 1];
|
|
122
|
+
const next = () => {
|
|
123
|
+
const fn = fns[curr++];
|
|
124
|
+
fn === last ? fn() : fn(next);
|
|
125
|
+
};
|
|
126
|
+
next();
|
|
127
|
+
};
|
|
128
|
+
utils.appendToFile = async (f, contents = "") => {
|
|
129
|
+
try {
|
|
130
|
+
await fs.appendFileSync(f, contents);
|
|
131
|
+
} catch (err) {
|
|
132
|
+
console.error(err);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
utils.boxInform = async (msg, secondary = "", padding = 0, margin = {
|
|
136
|
+
left: 2,
|
|
137
|
+
top: 0,
|
|
138
|
+
bottom: 0,
|
|
139
|
+
right: 0
|
|
140
|
+
}) => {
|
|
141
|
+
console.log(boxen(chalk.hex("#717877")(msg) + "\n" + chalk.bold.underline.hex("#438b34")(secondary) + chalk.hex("#717877")(" "), {
|
|
142
|
+
padding,
|
|
143
|
+
margin,
|
|
144
|
+
borderStyle: {
|
|
145
|
+
topLeft: chalk.hex("#5a596d")("╔"),
|
|
146
|
+
topRight: chalk.hex("#5a596d")("╗"),
|
|
147
|
+
bottomLeft: chalk.hex("#5a596d")("╚"),
|
|
148
|
+
bottomRight: chalk.hex("#5a596d")("╝"),
|
|
149
|
+
horizontal: chalk.hex("#5a596d")("═"),
|
|
150
|
+
vertical: chalk.hex("#5a596d")("║")
|
|
151
|
+
},
|
|
152
|
+
//"round",
|
|
153
|
+
align: "center" //,
|
|
154
|
+
}));
|
|
155
|
+
};
|
|
156
|
+
const hue2rgb = (p, q, t) => {
|
|
157
|
+
if (t < 0) {
|
|
158
|
+
t += 1;
|
|
159
|
+
}
|
|
160
|
+
if (t > 1) {
|
|
161
|
+
t -= 1;
|
|
162
|
+
}
|
|
163
|
+
if (t < ONE_SIXTH) {
|
|
164
|
+
return p + (q - p) * 6 * t;
|
|
165
|
+
}
|
|
166
|
+
if (t < 0.5) {
|
|
167
|
+
return q;
|
|
168
|
+
}
|
|
169
|
+
if (t < TWO_THIRDS) {
|
|
170
|
+
return p + (q - p) * (TWO_THIRDS - t) * 6;
|
|
171
|
+
}
|
|
172
|
+
return p;
|
|
173
|
+
};
|
|
174
|
+
const hsl2rgb = (h, s, l) => {
|
|
175
|
+
if (s === 0) {
|
|
176
|
+
return new Array(3).fill(l);
|
|
177
|
+
}
|
|
178
|
+
const q = l < 0.5 ? l * s + l : l + s - l * s;
|
|
179
|
+
const p = 2 * l - q;
|
|
180
|
+
return [hue2rgb(p, q, h + ONE_THIRD), hue2rgb(p, q, h), hue2rgb(p, q, h - ONE_THIRD)];
|
|
181
|
+
};
|
|
182
|
+
utils.rainbowGradient = (len, saturation = 1, lightness = 0.5) => {
|
|
183
|
+
const gradient = [];
|
|
184
|
+
for (let x = 0; x < len; x++) {
|
|
185
|
+
gradient.push(hsl2rgb(x / len, saturation, lightness).map(c => Math.round(c * 255)));
|
|
186
|
+
}
|
|
187
|
+
return gradient;
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
// utils.emptyDir = async () => {};
|
|
191
|
+
export default utils;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const separator = " ~ ";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import enquirerPkg from "enquirer";
|
|
4
|
+
const {
|
|
5
|
+
prompt
|
|
6
|
+
} = enquirerPkg;
|
|
7
|
+
const optionList = async () => {
|
|
8
|
+
let choiceCategories = [{
|
|
9
|
+
name: "start",
|
|
10
|
+
message: "Choose category then task to run"
|
|
11
|
+
}, {
|
|
12
|
+
name: "list",
|
|
13
|
+
message: "Select any task with text autocompletion"
|
|
14
|
+
}, {
|
|
15
|
+
name: "scripts",
|
|
16
|
+
message: "Choose a script from package.json"
|
|
17
|
+
}, {
|
|
18
|
+
name: "upgrade",
|
|
19
|
+
message: "Upgrade all your packages except ones specified by 'ignore-upgrade':[]"
|
|
20
|
+
}, {
|
|
21
|
+
name: "remote",
|
|
22
|
+
message: "Get remote configuration with your fc email"
|
|
23
|
+
}, {
|
|
24
|
+
name: "bump",
|
|
25
|
+
message: "Bump package.json and beautify it!"
|
|
26
|
+
}, {
|
|
27
|
+
name: "encryption",
|
|
28
|
+
message: "Encrypt/Decrypt secret files"
|
|
29
|
+
}, {
|
|
30
|
+
name: "clear",
|
|
31
|
+
message: "Clear recent task history"
|
|
32
|
+
}, {
|
|
33
|
+
name: "generate",
|
|
34
|
+
message: "Generate a sample fscripts.md file from the package.json"
|
|
35
|
+
}, {
|
|
36
|
+
name: "toc",
|
|
37
|
+
message: "Generate updated Table of Contents on top of the fscripts.md file"
|
|
38
|
+
}, {
|
|
39
|
+
name: "--help",
|
|
40
|
+
message: "See full help documentation"
|
|
41
|
+
}];
|
|
42
|
+
try {
|
|
43
|
+
let {
|
|
44
|
+
answer
|
|
45
|
+
} = await prompt({
|
|
46
|
+
type: "select",
|
|
47
|
+
name: `answer`,
|
|
48
|
+
choiceMessage: e => {
|
|
49
|
+
// return JSON.stringify(e)
|
|
50
|
+
// return e.message;
|
|
51
|
+
return `${chalk.bold.underline(e.name)}${chalk.reset(": \n ")}${chalk.gray.italic(e.message)}`;
|
|
52
|
+
},
|
|
53
|
+
message: `${chalk.cyan.bold.underline("What category do you want to run?")}`,
|
|
54
|
+
choices: choiceCategories
|
|
55
|
+
});
|
|
56
|
+
return answer;
|
|
57
|
+
} catch (e) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
export default optionList;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import JoyCon from "joycon";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
const joyRead = new JoyCon({
|
|
5
|
+
// Stop reading at parent dir
|
|
6
|
+
// i.e. Only read file from process.cwd()
|
|
7
|
+
stopDir: path.dirname(process.cwd())
|
|
8
|
+
});
|
|
9
|
+
const flattenObject = (obj, prefix = "") => Object.keys(obj).reduce((acc, k) => {
|
|
10
|
+
const pre = prefix.length ? prefix + "." : "";
|
|
11
|
+
if (typeof obj[k] === "object") Object.assign(acc, flattenObject(obj[k], pre + k));else acc[pre + k] = obj[k];
|
|
12
|
+
return acc;
|
|
13
|
+
}, {});
|
|
14
|
+
import marked from "marked";
|
|
15
|
+
let parse = function (mdContent) {
|
|
16
|
+
let js = marked.lexer(mdContent);
|
|
17
|
+
js = js.filter(e => e.type !== "space");
|
|
18
|
+
|
|
19
|
+
// let firstHeading = js.findIndex(e => e.type === "heading" && e.depth === 1); //?
|
|
20
|
+
let listMe = js.slice();
|
|
21
|
+
let tempItem = {};
|
|
22
|
+
let currentCategory = "";
|
|
23
|
+
let currentTask = "";
|
|
24
|
+
let taskOrder = 0;
|
|
25
|
+
listMe.forEach((item, indx) => {
|
|
26
|
+
if (item.type === "heading" && item.depth === 1) {
|
|
27
|
+
taskOrder = 0;
|
|
28
|
+
currentCategory = item.text;
|
|
29
|
+
tempItem[currentCategory] = {
|
|
30
|
+
name: item.text,
|
|
31
|
+
tasks: {},
|
|
32
|
+
description: ""
|
|
33
|
+
};
|
|
34
|
+
let descriptor = js[indx + 1];
|
|
35
|
+
if (descriptor.type === "paragraph") {
|
|
36
|
+
tempItem[currentCategory].description = descriptor.text;
|
|
37
|
+
}
|
|
38
|
+
} else if (item.type === "heading" && item.depth === 2) {
|
|
39
|
+
currentTask = item.text;
|
|
40
|
+
tempItem[currentCategory].tasks[currentTask] = {
|
|
41
|
+
script: "",
|
|
42
|
+
name: currentTask,
|
|
43
|
+
description: "",
|
|
44
|
+
order: taskOrder
|
|
45
|
+
};
|
|
46
|
+
taskOrder++;
|
|
47
|
+
let descriptor = js[indx + 1];
|
|
48
|
+
let code = js[indx + 2];
|
|
49
|
+
if (descriptor.type === "paragraph" && code.type === "code") {
|
|
50
|
+
tempItem[currentCategory].tasks[currentTask].description = descriptor.text;
|
|
51
|
+
tempItem[currentCategory].tasks[currentTask].script = code.text;
|
|
52
|
+
} else if (descriptor.type === "code") {
|
|
53
|
+
tempItem[currentCategory].tasks[currentTask].script = descriptor.text;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
let allTasks = [];
|
|
58
|
+
let categories = Object.keys(tempItem).map(catName => {
|
|
59
|
+
let ts = tempItem[catName].tasks;
|
|
60
|
+
let tasksArr = Object.keys(ts).map(tn => ts[tn]);
|
|
61
|
+
allTasks = [...allTasks, ...tasksArr];
|
|
62
|
+
return {
|
|
63
|
+
name: catName,
|
|
64
|
+
...tempItem[catName]
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
return {
|
|
68
|
+
categories,
|
|
69
|
+
allTasks
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
const parseScriptFile = async () => {
|
|
73
|
+
const {
|
|
74
|
+
path: filepath,
|
|
75
|
+
data
|
|
76
|
+
} = joyRead.loadSync(["fscripts.md"]);
|
|
77
|
+
if (!filepath) {
|
|
78
|
+
// console.warn(
|
|
79
|
+
// `${chalk.bold.red("You're missing the fscripts.md file!")}
|
|
80
|
+
// ${chalk.green("Please run 'fsr generate' to get started!")}`
|
|
81
|
+
// );
|
|
82
|
+
//
|
|
83
|
+
// process.exit(0);
|
|
84
|
+
// return null;
|
|
85
|
+
return false;
|
|
86
|
+
} else {
|
|
87
|
+
// console.warn(`${chalk.bold.green("Located fscripts.md file!")}`);
|
|
88
|
+
let newContent = data.split("<!-- end toc -->");
|
|
89
|
+
newContent = newContent[newContent.length === 2 ? 1 : 0];
|
|
90
|
+
return parse(newContent);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
export default parseScriptFile;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
const projectPath = path.join(process.cwd(), "./package.json");
|
|
4
|
+
import { readJson } from "./utils/helpers.js";
|
|
5
|
+
const parseScriptFile = async () => {
|
|
6
|
+
const packageFile = await readJson(projectPath);
|
|
7
|
+
return packageFile.scripts;
|
|
8
|
+
};
|
|
9
|
+
export default parseScriptFile;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import JoyCon from "joycon";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
import fs from "fs";
|
|
5
|
+
const joyRead = new JoyCon({
|
|
6
|
+
// Stop reading at parent dir
|
|
7
|
+
// i.e. Only read file from process.cwd()
|
|
8
|
+
stopDir: path.dirname(process.cwd())
|
|
9
|
+
});
|
|
10
|
+
const flattenObject = (obj, prefix = "") => Object.keys(obj).reduce((acc, k) => {
|
|
11
|
+
const pre = prefix.length ? prefix + "." : "";
|
|
12
|
+
if (typeof obj[k] === "object") Object.assign(acc, flattenObject(obj[k], pre + k));else acc[pre + k] = obj[k];
|
|
13
|
+
return acc;
|
|
14
|
+
}, {});
|
|
15
|
+
import marked from "marked";
|
|
16
|
+
let parse = function (mdContent) {
|
|
17
|
+
let js = marked.lexer(mdContent);
|
|
18
|
+
js = js.filter(e => e.type !== "space");
|
|
19
|
+
|
|
20
|
+
// let firstHeading = js.findIndex(e => e.type === "heading" && e.depth === 1); //?
|
|
21
|
+
let listMe = js.slice();
|
|
22
|
+
let tempItem = {};
|
|
23
|
+
let currentCategory = "";
|
|
24
|
+
let currentTask = "";
|
|
25
|
+
let taskOrder = 0;
|
|
26
|
+
listMe.forEach((item, indx) => {
|
|
27
|
+
if (item.type === "heading" && item.depth === 1) {
|
|
28
|
+
taskOrder = 0;
|
|
29
|
+
currentCategory = item.text;
|
|
30
|
+
tempItem[currentCategory] = {
|
|
31
|
+
name: item.text,
|
|
32
|
+
tasks: {},
|
|
33
|
+
description: ""
|
|
34
|
+
};
|
|
35
|
+
let descriptor = js[indx + 1];
|
|
36
|
+
if (descriptor.type === "paragraph") {
|
|
37
|
+
tempItem[currentCategory].description = descriptor.text;
|
|
38
|
+
}
|
|
39
|
+
} else if (item.type === "heading" && item.depth === 2) {
|
|
40
|
+
currentTask = item.text;
|
|
41
|
+
tempItem[currentCategory].tasks[currentTask] = {
|
|
42
|
+
script: "",
|
|
43
|
+
name: currentTask,
|
|
44
|
+
description: "",
|
|
45
|
+
order: taskOrder
|
|
46
|
+
};
|
|
47
|
+
taskOrder++;
|
|
48
|
+
let descriptor = js[indx + 1];
|
|
49
|
+
let code = js[indx + 2];
|
|
50
|
+
if (descriptor.type === "paragraph" && code.type === "code") {
|
|
51
|
+
tempItem[currentCategory].tasks[currentTask].description = descriptor.text;
|
|
52
|
+
tempItem[currentCategory].tasks[currentTask].lang = code.lang;
|
|
53
|
+
tempItem[currentCategory].tasks[currentTask].script = code.text;
|
|
54
|
+
} else if (descriptor.type === "code") {
|
|
55
|
+
// if (descriptor.lang === "javascript") {
|
|
56
|
+
// console.info("Console --- ", descriptor);
|
|
57
|
+
// }
|
|
58
|
+
tempItem[currentCategory].tasks[currentTask].lang = descriptor.lang;
|
|
59
|
+
tempItem[currentCategory].tasks[currentTask].script = descriptor.text;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
let allTasks = [];
|
|
64
|
+
let categories = Object.keys(tempItem).map(catName => {
|
|
65
|
+
let ts = tempItem[catName].tasks;
|
|
66
|
+
let tasksArr = Object.keys(ts).map(tn => ts[tn]);
|
|
67
|
+
allTasks = [...allTasks, ...tasksArr];
|
|
68
|
+
return {
|
|
69
|
+
name: catName,
|
|
70
|
+
...tempItem[catName]
|
|
71
|
+
};
|
|
72
|
+
});
|
|
73
|
+
return {
|
|
74
|
+
categories,
|
|
75
|
+
allTasks
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
const parseScriptFile = async () => {
|
|
79
|
+
const data = await fs.readFileSync(path.resolve(process.cwd(), "fscripts.md"), "utf-8");
|
|
80
|
+
if (!data) {
|
|
81
|
+
// console.warn(
|
|
82
|
+
// `${chalk.bold.red("You're missing the fscripts.md file!")}
|
|
83
|
+
// ${chalk.green("Please run 'fsr generate' to get started!")}`
|
|
84
|
+
// );
|
|
85
|
+
//
|
|
86
|
+
// process.exit(0);
|
|
87
|
+
// return null;
|
|
88
|
+
return false;
|
|
89
|
+
} else {
|
|
90
|
+
// console.warn(`${chalk.bold.green("Located fscripts.md file!")}`);
|
|
91
|
+
let newContent = data.split("<!-- end toc -->");
|
|
92
|
+
newContent = newContent[newContent.length === 2 ? 1 : 0];
|
|
93
|
+
return parse(newContent);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
export default parseScriptFile;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
const projectPath = path.join(process.cwd(), "./package.json");
|
|
4
|
+
import { readJson } from "../utils/helpers.js";
|
|
5
|
+
const parseScriptFile = async () => {
|
|
6
|
+
const packageFile = await readJson(projectPath);
|
|
7
|
+
return packageFile.scripts;
|
|
8
|
+
};
|
|
9
|
+
export default parseScriptFile;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import prompt from "../utils/prompt.js";
|
|
4
|
+
import fs from "fs";
|
|
5
|
+
let packagePath = path.resolve(process.cwd(), "package.json");
|
|
6
|
+
import { execSync } from "child_process";
|
|
7
|
+
const runAsync = async command => {
|
|
8
|
+
return execSync(command);
|
|
9
|
+
};
|
|
10
|
+
if (!fs.existsSync(packagePath)) {
|
|
11
|
+
console.error("Cannot find package.json file in the current directory");
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
const bump = async (typeParam = null) => {
|
|
15
|
+
let type = "patch";
|
|
16
|
+
if (!typeParam) {
|
|
17
|
+
type = await prompt({
|
|
18
|
+
type: "list",
|
|
19
|
+
message: chalk.green.bold.underline("How big of a bump is this?"),
|
|
20
|
+
choices: ["patch", "minor", "major"]
|
|
21
|
+
});
|
|
22
|
+
} else {
|
|
23
|
+
type = typeParam;
|
|
24
|
+
}
|
|
25
|
+
let gitTag = await prompt({
|
|
26
|
+
type: "confirm",
|
|
27
|
+
message: chalk.green.bold.underline("Add git tag?"),
|
|
28
|
+
default: false
|
|
29
|
+
});
|
|
30
|
+
await runAsync(`yarn version --${type} ${gitTag ? "--no-git-tag-version" : ""} --no-commit-hooks`);
|
|
31
|
+
const packageJson = await fs.readFileSync(packagePath);
|
|
32
|
+
const {
|
|
33
|
+
version
|
|
34
|
+
} = JSON.parse(packageJson);
|
|
35
|
+
if (gitTag) {
|
|
36
|
+
let description = await prompt({
|
|
37
|
+
type: "input",
|
|
38
|
+
message: chalk.green.bold.underline("Describe what was changed (optional):"),
|
|
39
|
+
default: ""
|
|
40
|
+
});
|
|
41
|
+
let commitMessage = `VERSION ${version}`;
|
|
42
|
+
if (description && description.trim()) {
|
|
43
|
+
commitMessage += `\n\n${description.trim()}`;
|
|
44
|
+
}
|
|
45
|
+
await runAsync(`git add .`);
|
|
46
|
+
await runAsync(`git commit -m "${commitMessage}"`);
|
|
47
|
+
await runAsync(`git tag -a v${version} -m "VERSION ${version}"`);
|
|
48
|
+
await runAsync(`git push origin --tags`);
|
|
49
|
+
}
|
|
50
|
+
console.log(chalk.green.underline(`\nNew version: ${version}\n`));
|
|
51
|
+
};
|
|
52
|
+
export default bump;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import inquirer from "inquirer";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import { readJson } from "../utils/helpers.js";
|
|
4
|
+
import seeChangedFiles from "./seeChangedFiles.js";
|
|
5
|
+
import bump from "./bump.js";
|
|
6
|
+
import validateNotDev from "./validateNotDev.js";
|
|
7
|
+
import simple from "simple-git";
|
|
8
|
+
async function pub() {
|
|
9
|
+
await validateNotDev();
|
|
10
|
+
await bump();
|
|
11
|
+
let pack = await readJson("package.json");
|
|
12
|
+
await seeChangedFiles();
|
|
13
|
+
let commitMsg = "";
|
|
14
|
+
const type = await new Promise(resolve => {
|
|
15
|
+
inquirer.prompt([{
|
|
16
|
+
type: "list",
|
|
17
|
+
message: chalk.green.bold.underline("What type of change is this?"),
|
|
18
|
+
choices: ["refactor", "fix", "improvement", "docs", "style", "php", "test", "build", "ci", "chore", "revert"],
|
|
19
|
+
name: "retType"
|
|
20
|
+
}]).then(async ({
|
|
21
|
+
retType
|
|
22
|
+
}) => {
|
|
23
|
+
resolve(retType);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
commitMsg += `[${type}] `;
|
|
27
|
+
inquirer.prompt([{
|
|
28
|
+
type: "input",
|
|
29
|
+
message: chalk.bold.hex("#38be18")(`TITLE: What's new this version ${pack.version}: `),
|
|
30
|
+
name: "commitTitle"
|
|
31
|
+
}]).then(({
|
|
32
|
+
commitTitle
|
|
33
|
+
}) => {
|
|
34
|
+
commitMsg += commitTitle + `\t\tVERSION ${pack.version}`;
|
|
35
|
+
inquirer.prompt([{
|
|
36
|
+
type: "message",
|
|
37
|
+
message: chalk.bold.hex("#38be18")(`Explain in detail!`),
|
|
38
|
+
name: "commitDescription"
|
|
39
|
+
}]).then(async ({
|
|
40
|
+
commitDescription
|
|
41
|
+
}) => {
|
|
42
|
+
commitMsg += "\n" + commitDescription;
|
|
43
|
+
simple().add("./*").commit(`${commitMsg}`).addRemote("origin", "https://github.com/agrublev/freedcamp-script-runner.git").push(["-u", "origin", "Development"], () => console.log("done"));
|
|
44
|
+
|
|
45
|
+
// .commit(`${commitMsg}`)
|
|
46
|
+
// .addRemote("origin", "https://github.com/agrublev/freedcamp-script-runner.git")
|
|
47
|
+
// .push(["-u", "origin", "Tztt"], () => console.log("done"));
|
|
48
|
+
|
|
49
|
+
// .push(["-u", "origin"], () => console.log("done"))
|
|
50
|
+
// .addTag(`${pack.version}`, () => console.warn("-- Console TAGGED", 52))
|
|
51
|
+
// .pushTags();
|
|
52
|
+
try {
|
|
53
|
+
// logInfo(command);
|
|
54
|
+
childProcess.execSync("git push -u origin Treat", {
|
|
55
|
+
stdio: "inherit",
|
|
56
|
+
env: Object.assign({}, process.env, {
|
|
57
|
+
FORCE_COLOR: true,
|
|
58
|
+
PATH: `${path.resolve("node_modules")}:${process.env.PATH}`
|
|
59
|
+
})
|
|
60
|
+
});
|
|
61
|
+
} catch (e) {}
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
pub();
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import childProcess from "child_process";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { fileURLToPath } from "url";
|
|
4
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
5
|
+
const __dirname = path.dirname(__filename);
|
|
6
|
+
import { boxInform } from "../utils/helpers.js";
|
|
7
|
+
import chalk from "chalk";
|
|
8
|
+
async function pub() {
|
|
9
|
+
let command = `sh ${path.resolve(__dirname, "publish.sh")}`;
|
|
10
|
+
try {
|
|
11
|
+
childProcess.execSync(command, {
|
|
12
|
+
stdio: "inherit",
|
|
13
|
+
env: Object.assign({}, process.env, {
|
|
14
|
+
FORCE_COLOR: true,
|
|
15
|
+
PATH: `${path.resolve("node_modules")}:${process.env.PATH}`
|
|
16
|
+
})
|
|
17
|
+
});
|
|
18
|
+
boxInform(chalk.green.bold.underline("PUBLISHED"), "https://www.npmjs.com/package/fscripts", 3);
|
|
19
|
+
} catch (e) {
|
|
20
|
+
console.error(`${command} - ${e}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
pub();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
npm publish
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { spawn } from "child-process-promise";
|
|
2
|
+
import prompt from "console-prompt";
|
|
3
|
+
const gitTarget = "origin";
|
|
4
|
+
let gitTargetBranch = "Development";
|
|
5
|
+
const runGitPush = gitParams => {
|
|
6
|
+
const gitPromise = spawn("git", gitParams);
|
|
7
|
+
const {
|
|
8
|
+
childProcess
|
|
9
|
+
} = gitPromise;
|
|
10
|
+
childProcess.stdout.pipe(process.stdout);
|
|
11
|
+
childProcess.stderr.pipe(process.stderr);
|
|
12
|
+
return gitPromise;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// Git command to get the current branch name: git rev-parse --abbrev-ref HEAD
|
|
16
|
+
|
|
17
|
+
const push = () => {
|
|
18
|
+
spawn("git", ["rev-parse", "--abbrev-ref", "HEAD"], {
|
|
19
|
+
capture: ["stdout", "stderr"]
|
|
20
|
+
}).then(result => {
|
|
21
|
+
const currGitBranch = result.stdout.toString().trim();
|
|
22
|
+
if (!currGitBranch) {
|
|
23
|
+
console.error("Current git branch is undefined!");
|
|
24
|
+
process.exit(2);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// if (gitTargetBranch === undefined) {
|
|
28
|
+
gitTargetBranch = currGitBranch;
|
|
29
|
+
// }
|
|
30
|
+
|
|
31
|
+
console.log(`Push current git branch [${currGitBranch}] to ${gitTargetBranch} of: \n` + `${gitTarget}`);
|
|
32
|
+
const gitParams = ["push"];
|
|
33
|
+
gitParams.push(`${gitTarget}`);
|
|
34
|
+
gitParams.push(`${currGitBranch}:${gitTargetBranch}`);
|
|
35
|
+
console.log(`The exact command is:
|
|
36
|
+
git ${gitParams.join(" ")}`);
|
|
37
|
+
return runGitPush(gitParams);
|
|
38
|
+
}).catch(error => {
|
|
39
|
+
const err = error.stderr ? error.stderr : error;
|
|
40
|
+
console.error("Execution Errors:", err);
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
export default push;
|