fscr 6.2.1 → 6.2.3
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/dist/index.js +41 -24
- package/dist/lib/generateToc.js +6 -12
- package/dist/lib/generators/generateToc.js +6 -12
- package/dist/lib/parseScriptsMd.js +3 -11
- package/dist/lib/parsers/parseScriptsMd.js +0 -6
- package/dist/lib/running/runParallel.js +43 -25
- package/dist/lib/running/runSequence.js +41 -24
- package/package.json +1 -2
package/dist/index.js
CHANGED
|
@@ -92,32 +92,49 @@ const runCmd = async (app, argsList = []) => {
|
|
|
92
92
|
script,
|
|
93
93
|
lang
|
|
94
94
|
} = taskData;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
95
|
+
if (lang === "javascript") {
|
|
96
|
+
// For JavaScript, use the script as-is without parsing
|
|
97
|
+
await runCLICommand({
|
|
98
|
+
task: {
|
|
99
|
+
name: task
|
|
100
|
+
},
|
|
101
|
+
script: {
|
|
102
|
+
lang: lang,
|
|
103
|
+
env: {},
|
|
104
|
+
type: "node",
|
|
105
|
+
full: script,
|
|
106
|
+
rest: []
|
|
107
|
+
}
|
|
108
|
+
});
|
|
105
109
|
} else {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
110
|
+
// For bash scripts, parse command and environment variables
|
|
111
|
+
let pars = script.split(" ");
|
|
112
|
+
let type = pars[0];
|
|
113
|
+
let env = {};
|
|
114
|
+
if (pars[0].includes("=")) {
|
|
115
|
+
let envs = type.split("=");
|
|
116
|
+
env[envs[0]] = envs[1];
|
|
117
|
+
type = pars[1];
|
|
118
|
+
pars.shift();
|
|
119
|
+
pars.shift();
|
|
120
|
+
script = pars.join(" ");
|
|
121
|
+
} else {
|
|
122
|
+
pars.shift();
|
|
123
|
+
script = pars.join(" ");
|
|
119
124
|
}
|
|
120
|
-
|
|
125
|
+
await runCLICommand({
|
|
126
|
+
task: {
|
|
127
|
+
name: task
|
|
128
|
+
},
|
|
129
|
+
script: {
|
|
130
|
+
lang: lang,
|
|
131
|
+
env: env,
|
|
132
|
+
type: type,
|
|
133
|
+
full: script,
|
|
134
|
+
rest: script.split(" ")
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
121
138
|
}).example(`${taskName("$0 run start:web")}`, `${textDescription("Run task 'start:web'")}`)
|
|
122
139
|
|
|
123
140
|
/**
|
package/dist/lib/generateToc.js
CHANGED
|
@@ -1,27 +1,21 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import chalk from "chalk";
|
|
3
|
-
import
|
|
3
|
+
import fs from "fs";
|
|
4
4
|
import tocPkg from "markdown-toc";
|
|
5
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
6
|
import { writeFile } from "./utils/helpers.js";
|
|
12
7
|
// const projectDir = process.cwd();
|
|
13
8
|
|
|
14
9
|
const generateToc = async () => {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
data
|
|
18
|
-
} = joyRead.loadSync(["fscripts.md"]);
|
|
19
|
-
if (!filepath) {
|
|
10
|
+
const filepath = path.resolve(process.cwd(), "fscripts.md");
|
|
11
|
+
if (!fs.existsSync(filepath)) {
|
|
20
12
|
console.warn(`${chalk.bold.red("You're missing the fscripts.md file!")}
|
|
21
13
|
${chalk.green("Please run 'fsr generate' to get started!")}`);
|
|
22
14
|
process.exit(0);
|
|
23
15
|
return null;
|
|
24
|
-
}
|
|
16
|
+
}
|
|
17
|
+
const data = fs.readFileSync(filepath, "utf-8");
|
|
18
|
+
if (data) {
|
|
25
19
|
console.warn(`${chalk.bold.green("Located fscripts.md file!")}`);
|
|
26
20
|
let newFile = ``;
|
|
27
21
|
let tocSplit = data.split("<!-- end toc -->");
|
|
@@ -1,27 +1,21 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import chalk from "chalk";
|
|
3
|
-
import
|
|
3
|
+
import fs from "fs";
|
|
4
4
|
import tocPkg from "markdown-toc";
|
|
5
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
6
|
import { writeFile } from "../utils/helpers.js";
|
|
12
7
|
// const projectDir = process.cwd();
|
|
13
8
|
|
|
14
9
|
const generateToc = async (fileToLoad = "fscripts.md") => {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
data
|
|
18
|
-
} = joyRead.loadSync([fileToLoad]);
|
|
19
|
-
if (!filepath) {
|
|
10
|
+
const filepath = path.resolve(process.cwd(), fileToLoad);
|
|
11
|
+
if (!fs.existsSync(filepath)) {
|
|
20
12
|
console.warn(`${chalk.bold.red("You're missing the fscripts.md file!")}
|
|
21
13
|
${chalk.green("Please run 'fsr generate' to get started!")}`);
|
|
22
14
|
process.exit(0);
|
|
23
15
|
return null;
|
|
24
|
-
}
|
|
16
|
+
}
|
|
17
|
+
const data = fs.readFileSync(filepath, "utf-8");
|
|
18
|
+
if (data) {
|
|
25
19
|
console.warn(`${chalk.bold.green("Located fscripts.md file!")}`);
|
|
26
20
|
let newFile = ``;
|
|
27
21
|
let tocSplit = data.split("<!-- end toc -->");
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import JoyCon from "joycon";
|
|
2
1
|
import path from "path";
|
|
3
2
|
import chalk from "chalk";
|
|
4
|
-
|
|
5
|
-
// Stop reading at parent dir
|
|
6
|
-
// i.e. Only read file from process.cwd()
|
|
7
|
-
stopDir: path.dirname(process.cwd())
|
|
8
|
-
});
|
|
3
|
+
import fs from "fs";
|
|
9
4
|
const flattenObject = (obj, prefix = "") => Object.keys(obj).reduce((acc, k) => {
|
|
10
5
|
const pre = prefix.length ? prefix + "." : "";
|
|
11
6
|
if (typeof obj[k] === "object") Object.assign(acc, flattenObject(obj[k], pre + k));else acc[pre + k] = obj[k];
|
|
@@ -70,11 +65,8 @@ let parse = function (mdContent) {
|
|
|
70
65
|
};
|
|
71
66
|
};
|
|
72
67
|
const parseScriptFile = async () => {
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
data
|
|
76
|
-
} = joyRead.loadSync(["fscripts.md"]);
|
|
77
|
-
if (!filepath) {
|
|
68
|
+
const data = await fs.readFileSync(path.resolve(process.cwd(), "fscripts.md"), "utf-8");
|
|
69
|
+
if (!data) {
|
|
78
70
|
// console.warn(
|
|
79
71
|
// `${chalk.bold.red("You're missing the fscripts.md file!")}
|
|
80
72
|
// ${chalk.green("Please run 'fsr generate' to get started!")}`
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import JoyCon from "joycon";
|
|
2
1
|
import path from "path";
|
|
3
2
|
import chalk from "chalk";
|
|
4
3
|
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
4
|
const flattenObject = (obj, prefix = "") => Object.keys(obj).reduce((acc, k) => {
|
|
11
5
|
const pre = prefix.length ? prefix + "." : "";
|
|
12
6
|
if (typeof obj[k] === "object") Object.assign(acc, flattenObject(obj[k], pre + k));else acc[pre + k] = obj[k];
|
|
@@ -12,33 +12,51 @@ const runParallel = async (tasks, FcScripts) => {
|
|
|
12
12
|
script,
|
|
13
13
|
lang
|
|
14
14
|
} = taskData;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
15
|
+
if (lang === "javascript") {
|
|
16
|
+
// For JavaScript, use the script as-is without parsing
|
|
17
|
+
await runCLICommand({
|
|
18
|
+
task: {
|
|
19
|
+
name: taskName
|
|
20
|
+
},
|
|
21
|
+
script: {
|
|
22
|
+
lang: lang,
|
|
23
|
+
env: {},
|
|
24
|
+
type: "node",
|
|
25
|
+
full: script,
|
|
26
|
+
rest: []
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
resolve();
|
|
25
30
|
} else {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
// For bash scripts, parse command and environment variables
|
|
32
|
+
let pars = script.split(" ");
|
|
33
|
+
let type = pars[0];
|
|
34
|
+
let env = {};
|
|
35
|
+
if (pars[0].includes("=")) {
|
|
36
|
+
let envs = type.split("=");
|
|
37
|
+
env[envs[0]] = envs[1];
|
|
38
|
+
type = pars[1];
|
|
39
|
+
pars.shift();
|
|
40
|
+
pars.shift();
|
|
41
|
+
script = pars.join(" ");
|
|
42
|
+
} else {
|
|
43
|
+
pars.shift();
|
|
44
|
+
script = pars.join(" ");
|
|
39
45
|
}
|
|
40
|
-
|
|
41
|
-
|
|
46
|
+
await runCLICommand({
|
|
47
|
+
task: {
|
|
48
|
+
name: taskName
|
|
49
|
+
},
|
|
50
|
+
script: {
|
|
51
|
+
lang: lang,
|
|
52
|
+
env: env,
|
|
53
|
+
type: type,
|
|
54
|
+
full: script,
|
|
55
|
+
rest: script.split(" ")
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
resolve();
|
|
59
|
+
}
|
|
42
60
|
}
|
|
43
61
|
});
|
|
44
62
|
});
|
|
@@ -11,32 +11,49 @@ const runSequence = async (tasks, FcScripts) => {
|
|
|
11
11
|
script,
|
|
12
12
|
lang
|
|
13
13
|
} = taskData;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
if (lang === "javascript") {
|
|
15
|
+
// For JavaScript, use the script as-is without parsing
|
|
16
|
+
await runCLICommand({
|
|
17
|
+
task: {
|
|
18
|
+
name: taskName
|
|
19
|
+
},
|
|
20
|
+
script: {
|
|
21
|
+
lang: lang,
|
|
22
|
+
env: {},
|
|
23
|
+
type: "node",
|
|
24
|
+
full: script,
|
|
25
|
+
rest: []
|
|
26
|
+
}
|
|
27
|
+
});
|
|
24
28
|
} else {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
29
|
+
// For bash scripts, parse command and environment variables
|
|
30
|
+
let pars = script.split(" ");
|
|
31
|
+
let type = pars[0];
|
|
32
|
+
let env = {};
|
|
33
|
+
if (pars[0].includes("=")) {
|
|
34
|
+
let envs = type.split("=");
|
|
35
|
+
env[envs[0]] = envs[1];
|
|
36
|
+
type = pars[1];
|
|
37
|
+
pars.shift();
|
|
38
|
+
pars.shift();
|
|
39
|
+
script = pars.join(" ");
|
|
40
|
+
} else {
|
|
41
|
+
pars.shift();
|
|
42
|
+
script = pars.join(" ");
|
|
38
43
|
}
|
|
39
|
-
|
|
44
|
+
await runCLICommand({
|
|
45
|
+
task: {
|
|
46
|
+
name: taskName
|
|
47
|
+
},
|
|
48
|
+
script: {
|
|
49
|
+
lang: lang,
|
|
50
|
+
env: env,
|
|
51
|
+
type: type,
|
|
52
|
+
full: script,
|
|
53
|
+
rest: script.split(" ")
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
40
57
|
}
|
|
41
58
|
}
|
|
42
59
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fscr",
|
|
3
|
-
"version": "6.2.
|
|
3
|
+
"version": "6.2.3",
|
|
4
4
|
"description": "Runs the fscripts.md file",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -69,7 +69,6 @@
|
|
|
69
69
|
"ink-select-input": "^6.2.0",
|
|
70
70
|
"inquirer": "^12.9.6",
|
|
71
71
|
"is-builtin-module": "^5.0.0",
|
|
72
|
-
"joycon": "^3.1.1",
|
|
73
72
|
"json-colorz": "^0.2.7",
|
|
74
73
|
"markdown-toc": "^1.2.0",
|
|
75
74
|
"marked": "^16.3.0",
|