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
package/dist/index.js
CHANGED
|
@@ -12,198 +12,515 @@ import validateNotInDev from "./lib/git/validateNotDev.js";
|
|
|
12
12
|
import encrypt from "./lib/encryption/encryption.js";
|
|
13
13
|
import { clear } from "./lib/utils/index.js";
|
|
14
14
|
import authConfig from "./lib/auth/auth-conf.js";
|
|
15
|
+
import doctor from "./lib/commands/doctor.js";
|
|
16
|
+
import completion from "./lib/completions/completion.js";
|
|
17
|
+
import * as cacheCommands from "./lib/cache/cli.js";
|
|
18
|
+
import { loadPlugins, registerPluginCommands } from "./lib/plugins/loader.js";
|
|
19
|
+
import { fireHook } from "./lib/plugins/hooks.js";
|
|
15
20
|
import { spawn } from "child_process";
|
|
16
21
|
import yargs from "yargs";
|
|
22
|
+
|
|
17
23
|
import "./lib/utils/console.js";
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* RUN
|
|
27
|
+
* @param app
|
|
28
|
+
* @param argsList
|
|
29
|
+
* @returns {Promise<unknown>}
|
|
30
|
+
*/
|
|
18
31
|
const runCmd = async (app, argsList = []) => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return new Promise(resolve => {
|
|
31
|
-
shell.on("close", code => {
|
|
32
|
-
resolve();
|
|
32
|
+
let shell;
|
|
33
|
+
|
|
34
|
+
shell = spawn(app, argsList, {
|
|
35
|
+
stdio: "inherit",
|
|
36
|
+
cwd: process.cwd(),
|
|
37
|
+
env: { ...process.env, ...{ FORCE_COLOR: true } }
|
|
38
|
+
});
|
|
39
|
+
return new Promise((resolve) => {
|
|
40
|
+
shell.on("close", (code) => {
|
|
41
|
+
resolve();
|
|
42
|
+
});
|
|
33
43
|
});
|
|
34
|
-
});
|
|
35
44
|
};
|
|
45
|
+
|
|
36
46
|
(async () => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
47
|
+
clear();
|
|
48
|
+
const { commands: pluginCommands, runnablePlugins } = await loadPlugins();
|
|
49
|
+
const yargsInstance = yargs(process.argv.slice(2))
|
|
50
|
+
.usage("Usage: $0 <command> [options]")
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* fsr
|
|
54
|
+
* branch --
|
|
55
|
+
*/
|
|
56
|
+
.command(
|
|
57
|
+
"branch",
|
|
58
|
+
"Create new branch instead of Development",
|
|
59
|
+
(yargs) => {},
|
|
60
|
+
async function () {
|
|
61
|
+
await validateNotInDev();
|
|
62
|
+
}
|
|
63
|
+
)
|
|
64
|
+
.example(`${taskName("$0")}`, `${textDescription("Validates branch and creates new")}`)
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* fsr
|
|
68
|
+
* start --
|
|
69
|
+
*/
|
|
70
|
+
.usage("$0 <task> name:of:task")
|
|
71
|
+
.command(
|
|
72
|
+
"start",
|
|
73
|
+
"Choose category then task to run",
|
|
74
|
+
(yargs) => {},
|
|
75
|
+
async () => {
|
|
76
|
+
await startScripts(); // if ((await startScripts()) === false) {
|
|
77
|
+
// await startPackageScripts();
|
|
78
|
+
// }
|
|
79
|
+
}
|
|
80
|
+
)
|
|
81
|
+
.example(`${taskName("$0 start")}`, `${textDescription("Open a task selection selector")}`)
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* fsr
|
|
85
|
+
* scripts --
|
|
86
|
+
*/
|
|
87
|
+
.command(
|
|
88
|
+
"scripts",
|
|
89
|
+
"Choose a script from package.json",
|
|
90
|
+
(yargs) => {},
|
|
91
|
+
async function () {
|
|
92
|
+
await startPackageScripts();
|
|
93
|
+
}
|
|
94
|
+
)
|
|
95
|
+
.example(
|
|
96
|
+
`${taskName("$0 scripts")}`,
|
|
97
|
+
`${textDescription("Choose a script from package.json")}`
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* fsr
|
|
102
|
+
* list --
|
|
103
|
+
*/
|
|
104
|
+
.command(
|
|
105
|
+
"list",
|
|
106
|
+
"Select any task with text autocompletion",
|
|
107
|
+
() => {},
|
|
108
|
+
async function (argv) {
|
|
109
|
+
await startScripts(false);
|
|
110
|
+
// const tasks = await scriptsParsed().allTasks;
|
|
111
|
+
}
|
|
112
|
+
)
|
|
113
|
+
.example(`${taskName("$0 list")}`, `${textDescription("Show you all tasks you can run")}`)
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* fsr
|
|
117
|
+
* run --
|
|
118
|
+
*/
|
|
119
|
+
.command(
|
|
120
|
+
"run [task]",
|
|
121
|
+
"Run a specific task",
|
|
122
|
+
(yargs) => {
|
|
123
|
+
yargs.positional("task", {
|
|
124
|
+
describe: "name of task to start",
|
|
125
|
+
default: ""
|
|
126
|
+
});
|
|
127
|
+
},
|
|
128
|
+
async function (argv) {
|
|
129
|
+
let { task } = argv;
|
|
130
|
+
const parsed = await parseScriptFile();
|
|
131
|
+
if (!parsed) {
|
|
132
|
+
console.error(`${chalk.bold.underline.red("No fscripts.md file found")}`);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const { allTasks } = parsed;
|
|
136
|
+
const taskData = allTasks.find((t) => t.name === task);
|
|
137
|
+
if (!taskData) {
|
|
138
|
+
console.error(`${chalk.bold.underline.red("Task not found")}`);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
let { script, lang } = taskData;
|
|
142
|
+
|
|
143
|
+
if (lang === "javascript") {
|
|
144
|
+
// For JavaScript, use the script as-is without parsing
|
|
145
|
+
await runCLICommand({
|
|
146
|
+
task: { name: task },
|
|
147
|
+
script: {
|
|
148
|
+
lang: lang,
|
|
149
|
+
env: {},
|
|
150
|
+
type: "node",
|
|
151
|
+
full: script,
|
|
152
|
+
rest: []
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
} else {
|
|
156
|
+
// For bash scripts, parse command and environment variables
|
|
157
|
+
let pars = script.split(" ");
|
|
158
|
+
let type = pars[0];
|
|
159
|
+
let env = {};
|
|
160
|
+
if (pars[0].includes("=")) {
|
|
161
|
+
let envs = type.split("=");
|
|
162
|
+
env[envs[0]] = envs[1];
|
|
163
|
+
type = pars[1];
|
|
164
|
+
pars.shift();
|
|
165
|
+
pars.shift();
|
|
166
|
+
script = pars.join(" ");
|
|
167
|
+
} else {
|
|
168
|
+
pars.shift();
|
|
169
|
+
script = pars.join(" ");
|
|
170
|
+
}
|
|
171
|
+
await runCLICommand({
|
|
172
|
+
task: { name: task },
|
|
173
|
+
script: {
|
|
174
|
+
lang: lang,
|
|
175
|
+
env: env,
|
|
176
|
+
type: type,
|
|
177
|
+
full: script,
|
|
178
|
+
rest: script.split(" ")
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
)
|
|
184
|
+
.example(`${taskName("$0 run start:web")}`, `${textDescription("Run task 'start:web'")}`)
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* fsr
|
|
188
|
+
* upgrade --
|
|
189
|
+
*/
|
|
190
|
+
.command(
|
|
191
|
+
"upgrade",
|
|
192
|
+
"Upgrade all your packages except ones specified by 'ignore-upgrade':[]",
|
|
193
|
+
() => {},
|
|
194
|
+
async function (argv) {
|
|
195
|
+
let task = argv._[1];
|
|
196
|
+
await upgradePackages();
|
|
197
|
+
}
|
|
198
|
+
)
|
|
199
|
+
.example(`${taskName("$0 upgrade")}`, `${textDescription("Upgraded!")}`)
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* fsr
|
|
203
|
+
* bump --
|
|
204
|
+
*/
|
|
205
|
+
.command(
|
|
206
|
+
"bump",
|
|
207
|
+
"Bump package.json and beautify it!",
|
|
208
|
+
() => {},
|
|
209
|
+
async function (argv) {
|
|
210
|
+
let type = argv.type;
|
|
211
|
+
let skipGit = argv.skipGit;
|
|
212
|
+
await bump(type, skipGit === "true");
|
|
213
|
+
}
|
|
214
|
+
)
|
|
215
|
+
.example(`${taskName("$0 bump")}`, `${textDescription("BUMPED AND PRETTY!")}`)
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* fsr
|
|
219
|
+
* run-s --
|
|
220
|
+
*/
|
|
221
|
+
.command(
|
|
222
|
+
"run-s",
|
|
223
|
+
"Run a set of tasks one after another",
|
|
224
|
+
() => {},
|
|
225
|
+
async function (argv) {
|
|
226
|
+
let tasks = argv._.slice();
|
|
227
|
+
tasks.shift();
|
|
228
|
+
const FcScripts = await parseScriptFile();
|
|
229
|
+
await runSequence(tasks, FcScripts);
|
|
230
|
+
}
|
|
231
|
+
)
|
|
232
|
+
.example(
|
|
233
|
+
`${taskName("$0 run-s start:web start:desktop")}`,
|
|
234
|
+
`${textDescription("Run task 'start:web' and afterwards 'start:desktop'")}`
|
|
235
|
+
)
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* fsr
|
|
239
|
+
* run-p --
|
|
240
|
+
*/
|
|
241
|
+
.command(
|
|
242
|
+
"run-p",
|
|
243
|
+
"Run tasks in parallel",
|
|
244
|
+
() => {},
|
|
245
|
+
async function (argv) {
|
|
246
|
+
let tasks = argv._.slice();
|
|
247
|
+
tasks.shift();
|
|
248
|
+
|
|
249
|
+
const FcScripts = await parseScriptFile();
|
|
250
|
+
await runParallel(tasks, FcScripts);
|
|
251
|
+
}
|
|
252
|
+
)
|
|
253
|
+
.example(
|
|
254
|
+
`${taskName("$0 run-p start:web start:desktop")}`,
|
|
255
|
+
`${textDescription("Run task 'start:web' and at the same time 'start:desktop'")}`
|
|
256
|
+
)
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* fsr
|
|
260
|
+
* remote config --
|
|
261
|
+
*/
|
|
262
|
+
.command(
|
|
263
|
+
"remote",
|
|
264
|
+
"Get remote configuration",
|
|
265
|
+
() => {},
|
|
266
|
+
async function (argv) {
|
|
267
|
+
await authConfig().catch(console.error);
|
|
268
|
+
}
|
|
269
|
+
)
|
|
270
|
+
.example(`${taskName("$0 remote")}`, `${textDescription("Get remote config")}`)
|
|
271
|
+
/**
|
|
272
|
+
* fsr
|
|
273
|
+
* encryption --
|
|
274
|
+
*/
|
|
275
|
+
.command(
|
|
276
|
+
"encryption",
|
|
277
|
+
"Encrypt/Decrypt secret files",
|
|
278
|
+
() => {},
|
|
279
|
+
async function (argv) {
|
|
280
|
+
await encrypt.init();
|
|
281
|
+
}
|
|
282
|
+
)
|
|
283
|
+
/**
|
|
284
|
+
* fsr
|
|
285
|
+
* encrypt --
|
|
286
|
+
*/
|
|
287
|
+
.command(
|
|
288
|
+
"encrypt",
|
|
289
|
+
"Encrypt a secret file/s",
|
|
290
|
+
() => {},
|
|
291
|
+
async function (argv) {
|
|
292
|
+
await encrypt.encrypt();
|
|
293
|
+
}
|
|
294
|
+
)
|
|
295
|
+
/**
|
|
296
|
+
* fsr
|
|
297
|
+
* decrypt --
|
|
298
|
+
*/
|
|
299
|
+
.command(
|
|
300
|
+
"decrypt",
|
|
301
|
+
"Decrypt a secret file/s",
|
|
302
|
+
() => {},
|
|
303
|
+
async function (argv) {
|
|
304
|
+
await encrypt.decrypt();
|
|
305
|
+
}
|
|
306
|
+
)
|
|
307
|
+
.example(
|
|
308
|
+
`${taskName("$0 encryption")}`,
|
|
309
|
+
`${textDescription("Encrypt/Decrypt secret files")}`
|
|
310
|
+
)
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* fsr
|
|
314
|
+
* clear --
|
|
315
|
+
*/
|
|
316
|
+
.command(
|
|
317
|
+
"clear",
|
|
318
|
+
"Clear recent task history",
|
|
319
|
+
() => {},
|
|
320
|
+
async function (argv) {
|
|
321
|
+
await clearRecent();
|
|
322
|
+
}
|
|
323
|
+
)
|
|
324
|
+
.example(`${taskName("$0 clear")}`, `${textDescription("Clear your recently run tasks")}`)
|
|
325
|
+
.example(`${taskName("$0 config")}`, `${textDescription("Update a config value")}`)
|
|
326
|
+
.command(
|
|
327
|
+
"generate",
|
|
328
|
+
"Generate a sample fscripts.md file from the package.json",
|
|
329
|
+
() => {},
|
|
330
|
+
async function (argv) {
|
|
331
|
+
await generateFScripts();
|
|
332
|
+
}
|
|
333
|
+
)
|
|
334
|
+
.example(
|
|
335
|
+
`${taskName("$0 generate")}`,
|
|
336
|
+
`${textDescription(
|
|
337
|
+
"Generates a sample.fscripts.md you can use as template for your fscripts file"
|
|
338
|
+
)}`
|
|
339
|
+
)
|
|
340
|
+
.command(
|
|
341
|
+
"toc",
|
|
342
|
+
"Generate updated Table of Contents on top of the fscripts.md file",
|
|
343
|
+
() => {},
|
|
344
|
+
async function (argv) {
|
|
345
|
+
let mdFile = argv._[1];
|
|
346
|
+
await generateToc(mdFile);
|
|
347
|
+
}
|
|
348
|
+
)
|
|
349
|
+
.example(
|
|
350
|
+
`${taskName("$0 toc")}`,
|
|
351
|
+
`${textDescription(
|
|
352
|
+
"Generate updated Table of Contents on top of the fscripts.md file"
|
|
353
|
+
)}`
|
|
354
|
+
)
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* fsr
|
|
358
|
+
* doctor --
|
|
359
|
+
*/
|
|
360
|
+
.command(
|
|
361
|
+
"doctor",
|
|
362
|
+
"Run diagnostics and check system health",
|
|
363
|
+
(yargs) => {
|
|
364
|
+
yargs
|
|
365
|
+
.option("fix", {
|
|
366
|
+
alias: "f",
|
|
367
|
+
type: "boolean",
|
|
368
|
+
description: "Automatically fix issues when possible",
|
|
369
|
+
default: false
|
|
370
|
+
})
|
|
371
|
+
.option("json", {
|
|
372
|
+
type: "boolean",
|
|
373
|
+
description: "Output results in JSON format",
|
|
374
|
+
default: false
|
|
375
|
+
})
|
|
376
|
+
.option("verbose", {
|
|
377
|
+
alias: "v",
|
|
378
|
+
type: "boolean",
|
|
379
|
+
description: "Show verbose output",
|
|
380
|
+
default: false
|
|
381
|
+
});
|
|
382
|
+
},
|
|
383
|
+
async function (argv) {
|
|
384
|
+
await doctor(argv);
|
|
385
|
+
}
|
|
386
|
+
)
|
|
387
|
+
.example(`${taskName("$0 doctor")}`, `${textDescription("Run system diagnostics")}`)
|
|
388
|
+
.example(
|
|
389
|
+
`${taskName("$0 doctor --fix")}`,
|
|
390
|
+
`${textDescription("Run diagnostics and auto-fix issues")}`
|
|
391
|
+
)
|
|
392
|
+
.example(
|
|
393
|
+
`${taskName("$0 doctor --json")}`,
|
|
394
|
+
`${textDescription("Output results as JSON")}`
|
|
395
|
+
)
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* fsr
|
|
399
|
+
* cache --
|
|
400
|
+
*/
|
|
401
|
+
.command(
|
|
402
|
+
"cache <action>",
|
|
403
|
+
"Manage cache system",
|
|
404
|
+
(yargs) => {
|
|
405
|
+
yargs
|
|
406
|
+
.positional("action", {
|
|
407
|
+
describe: "Cache action to perform",
|
|
408
|
+
choices: ["stats", "clear", "list", "benchmark", "export"]
|
|
409
|
+
})
|
|
410
|
+
.option("verbose", {
|
|
411
|
+
alias: "v",
|
|
412
|
+
type: "boolean",
|
|
413
|
+
description: "Show verbose output",
|
|
414
|
+
default: false
|
|
415
|
+
})
|
|
416
|
+
.option("limit", {
|
|
417
|
+
alias: "l",
|
|
418
|
+
type: "number",
|
|
419
|
+
description: "Limit number of entries to display",
|
|
420
|
+
default: 10
|
|
421
|
+
})
|
|
422
|
+
.option("output", {
|
|
423
|
+
alias: "o",
|
|
424
|
+
type: "string",
|
|
425
|
+
description: "Output file path for export"
|
|
426
|
+
});
|
|
427
|
+
},
|
|
428
|
+
async function (argv) {
|
|
429
|
+
const { action, verbose, limit, output } = argv;
|
|
430
|
+
|
|
431
|
+
switch (action) {
|
|
432
|
+
case "stats":
|
|
433
|
+
await cacheCommands.showCacheStats({ verbose });
|
|
434
|
+
break;
|
|
435
|
+
case "clear":
|
|
436
|
+
await cacheCommands.clearCache();
|
|
437
|
+
break;
|
|
438
|
+
case "list":
|
|
439
|
+
await cacheCommands.listCacheEntries({ limit });
|
|
440
|
+
break;
|
|
441
|
+
case "benchmark":
|
|
442
|
+
await cacheCommands.benchmarkCache();
|
|
443
|
+
break;
|
|
444
|
+
case "export":
|
|
445
|
+
await cacheCommands.exportCacheStats(output);
|
|
446
|
+
break;
|
|
447
|
+
default:
|
|
448
|
+
console.log(chalk.yellow(`Unknown cache action: ${action}`));
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
)
|
|
452
|
+
.example(`${taskName("$0 cache stats")}`, `${textDescription("Show cache statistics")}`)
|
|
453
|
+
.example(`${taskName("$0 cache clear")}`, `${textDescription("Clear all cache entries")}`)
|
|
454
|
+
.example(`${taskName("$0 cache list")}`, `${textDescription("List cached entries")}`)
|
|
455
|
+
.example(`${taskName("$0 cache benchmark")}`, `${textDescription("Run cache performance benchmark")}`)
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* fsr
|
|
459
|
+
* completion --
|
|
460
|
+
*/
|
|
461
|
+
.command(
|
|
462
|
+
"completion [action]",
|
|
463
|
+
"Manage shell completions",
|
|
464
|
+
(yargs) => {
|
|
465
|
+
yargs
|
|
466
|
+
.positional("action", {
|
|
467
|
+
describe: "Action to perform (install, uninstall, status, generate)",
|
|
468
|
+
type: "string",
|
|
469
|
+
choices: ["install", "uninstall", "status", "generate"]
|
|
470
|
+
})
|
|
471
|
+
.option("shell", {
|
|
472
|
+
alias: "s",
|
|
473
|
+
type: "string",
|
|
474
|
+
description: "Target shell (bash, zsh, fish, powershell)",
|
|
475
|
+
choices: ["bash", "zsh", "fish", "powershell"]
|
|
476
|
+
})
|
|
477
|
+
.option("force", {
|
|
478
|
+
alias: "f",
|
|
479
|
+
type: "boolean",
|
|
480
|
+
description: "Force reinstall completions",
|
|
481
|
+
default: false
|
|
482
|
+
});
|
|
483
|
+
},
|
|
484
|
+
async function (argv) {
|
|
485
|
+
await completion(argv);
|
|
486
|
+
}
|
|
487
|
+
)
|
|
488
|
+
.example(
|
|
489
|
+
`${taskName("$0 completion install")}`,
|
|
490
|
+
`${textDescription("Install completions for your shell")}`
|
|
491
|
+
)
|
|
492
|
+
.example(
|
|
493
|
+
`${taskName("$0 completion status")}`,
|
|
494
|
+
`${textDescription("Check completion installation status")}`
|
|
495
|
+
)
|
|
496
|
+
.example(
|
|
497
|
+
`${taskName("$0 completion --shell zsh")}`,
|
|
498
|
+
`${textDescription("Install completions for zsh")}`
|
|
499
|
+
)
|
|
500
|
+
.help();
|
|
501
|
+
|
|
502
|
+
registerPluginCommands(yargsInstance, pluginCommands);
|
|
503
|
+
yargsInstance.strict();
|
|
504
|
+
|
|
505
|
+
const argv = yargsInstance.argv;
|
|
506
|
+
|
|
507
|
+
if (argv && argv._ && argv._.length === 0) {
|
|
508
|
+
const pluginChoices = runnablePlugins.map((p) => ({ name: `plugin:${p.name}`, message: p.description }));
|
|
509
|
+
const choice = await optionList(pluginChoices);
|
|
510
|
+
|
|
511
|
+
const pluginMatch = runnablePlugins.find((p) => `plugin:${p.name}` === choice);
|
|
512
|
+
if (pluginMatch) {
|
|
513
|
+
const start = Date.now();
|
|
514
|
+
try {
|
|
515
|
+
await pluginMatch.run();
|
|
516
|
+
await fireHook("post-task", { taskName: pluginMatch.name, duration: Date.now() - start, success: true });
|
|
517
|
+
} catch (err) {
|
|
518
|
+
await fireHook("task-error", { taskName: pluginMatch.name, duration: Date.now() - start, error: err });
|
|
519
|
+
}
|
|
520
|
+
} else if (choice) {
|
|
521
|
+
await runCmd("yarn", ["fsr", choice]);
|
|
522
|
+
} else {
|
|
523
|
+
console.log(chalk.green.bold("See you soon!"));
|
|
135
524
|
}
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
}).example(`${taskName("$0 run start:web")}`, `${textDescription("Run task 'start:web'")}`)
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* fsr
|
|
142
|
-
* upgrade --
|
|
143
|
-
*/.command("upgrade", "Upgrade all your packages except ones specified by 'ignore-upgrade':[]", () => {}, async function (argv) {
|
|
144
|
-
let task = argv._[1];
|
|
145
|
-
await upgradePackages();
|
|
146
|
-
}).example(`${taskName("$0 upgrade")}`, `${textDescription("Upgraded!")}`)
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* fsr
|
|
150
|
-
* bump --
|
|
151
|
-
*/.command("bump", "Bump package.json and beautify it!", () => {}, async function (argv) {
|
|
152
|
-
let type = argv.type;
|
|
153
|
-
await bump(type);
|
|
154
|
-
}).example(`${taskName("$0 bump")}`, `${textDescription("BUMPED AND PRETTY!")}`)
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* fsr
|
|
158
|
-
* run-s --
|
|
159
|
-
*/.command("run-s", "Run a set of tasks one after another", () => {}, async function (argv) {
|
|
160
|
-
let tasks = argv._.slice();
|
|
161
|
-
tasks.shift();
|
|
162
|
-
const FcScripts = await parseScriptFile();
|
|
163
|
-
await runSequence(tasks, FcScripts);
|
|
164
|
-
}).example(`${taskName("$0 run-s start:web start:desktop")}`, `${textDescription("Run task 'start:web' and afterwards 'start:desktop'")}`)
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* fsr
|
|
168
|
-
* run-p --
|
|
169
|
-
*/.command("run-p", "Run tasks in parallel", () => {}, async function (argv) {
|
|
170
|
-
let tasks = argv._.slice();
|
|
171
|
-
tasks.shift();
|
|
172
|
-
const FcScripts = await parseScriptFile();
|
|
173
|
-
await runParallel(tasks, FcScripts);
|
|
174
|
-
}).example(`${taskName("$0 run-p start:web start:desktop")}`, `${textDescription("Run task 'start:web' and at the same time 'start:desktop'")}`)
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* fsr
|
|
178
|
-
* remote config --
|
|
179
|
-
*/.command("remote", "Get remote configuration", () => {}, async function (argv) {
|
|
180
|
-
await authConfig().catch(console.error);
|
|
181
|
-
}).example(`${taskName("$0 remote")}`, `${textDescription("Get remote config")}`)
|
|
182
|
-
/**
|
|
183
|
-
* fsr
|
|
184
|
-
* encryption --
|
|
185
|
-
*/.command("encryption", "Encrypt/Decrypt secret files", () => {}, async function (argv) {
|
|
186
|
-
await encrypt.init();
|
|
187
|
-
}).example(`${taskName("$0 encryption")}`, `${textDescription("Encrypt/Decrypt secret files")}`)
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* fsr
|
|
191
|
-
* clear --
|
|
192
|
-
*/.command("clear", "Clear recent task history", () => {}, async function (argv) {
|
|
193
|
-
await clearRecent();
|
|
194
|
-
}).example(`${taskName("$0 clear")}`, `${textDescription("Clear your recently run tasks")}`).example(`${taskName("$0 config")}`, `${textDescription("Update a config value")}`).command("generate", "Generate a sample fscripts.md file from the package.json", () => {}, async function (argv) {
|
|
195
|
-
await generateFScripts();
|
|
196
|
-
}).example(`${taskName("$0 generate")}`, `${textDescription("Generates a sample.fscripts.md you can use as template for your fscripts file")}`).command("toc", "Generate updated Table of Contents on top of the fscripts.md file", () => {}, async function (argv) {
|
|
197
|
-
let mdFile = argv._[1];
|
|
198
|
-
await generateToc(mdFile);
|
|
199
|
-
}).example(`${taskName("$0 toc")}`, `${textDescription("Generate updated Table of Contents on top of the fscripts.md file")}`).help();
|
|
200
|
-
const argv = yargsInstance.argv;
|
|
201
|
-
if (argv && argv._ && argv._.length === 0) {
|
|
202
|
-
const choice = await optionList();
|
|
203
|
-
if (choice) {
|
|
204
|
-
await runCmd("yarn", ["fsr", choice]);
|
|
205
|
-
} else {
|
|
206
|
-
console.log(chalk.green.bold("See you soon!"));
|
|
207
525
|
}
|
|
208
|
-
}
|
|
209
526
|
})();
|