hereby 1.7.1 → 1.8.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/dist/cli/formatTasks.js +12 -13
- package/dist/cli/index.js +4 -4
- package/dist/cli/loadHerebyfile.js +2 -0
- package/dist/cli/parseArgs.js +12 -16
- package/dist/cli/utils.js +4 -5
- package/package.json +3 -3
package/dist/cli/formatTasks.js
CHANGED
|
@@ -1,36 +1,35 @@
|
|
|
1
1
|
import commandLineUsage from "command-line-usage";
|
|
2
2
|
import pc from "picocolors";
|
|
3
|
-
import {
|
|
3
|
+
import { compareStrings, compareTaskNames } from "./utils.js";
|
|
4
4
|
export function formatTasks(format, tasks, defaultTask) {
|
|
5
|
-
tasks =
|
|
6
|
-
.filter((task) => !task.options.hiddenFromTaskList)
|
|
7
|
-
.sort(taskSorter);
|
|
5
|
+
tasks = tasks.filter(isTaskVisible).sort(compareTaskNames);
|
|
8
6
|
if (format === "simple") {
|
|
9
7
|
return tasks.map((task) => task.options.name).join("\n");
|
|
10
8
|
}
|
|
11
|
-
|
|
12
|
-
sections.push({
|
|
9
|
+
return commandLineUsage({
|
|
13
10
|
header: "Available tasks",
|
|
14
11
|
content: tasks.map((task) => {
|
|
15
12
|
var _a;
|
|
16
13
|
const name = task === defaultTask
|
|
17
14
|
? `${pc.green(task.options.name)} (default)`
|
|
18
15
|
: pc.blue(task.options.name);
|
|
19
|
-
|
|
16
|
+
let descriptionParts;
|
|
20
17
|
if (task.options.description) {
|
|
21
|
-
descriptionParts
|
|
18
|
+
descriptionParts = [task.options.description];
|
|
22
19
|
}
|
|
23
|
-
const deps = (_a = task.options.dependencies) === null || _a === void 0 ? void 0 : _a.filter(
|
|
20
|
+
const deps = (_a = task.options.dependencies) === null || _a === void 0 ? void 0 : _a.filter(isTaskVisible);
|
|
24
21
|
if (deps && deps.length > 0) {
|
|
25
22
|
const depNames = deps
|
|
26
23
|
.map((task) => task.options.name)
|
|
27
|
-
.sort(
|
|
24
|
+
.sort(compareStrings)
|
|
28
25
|
.map((v) => pc.blue(v));
|
|
29
|
-
descriptionParts.push(`Depends on: ${depNames.join(", ")}`);
|
|
26
|
+
(descriptionParts !== null && descriptionParts !== void 0 ? descriptionParts : (descriptionParts = [])).push(`Depends on: ${depNames.join(", ")}`);
|
|
30
27
|
}
|
|
31
|
-
return { name, description: descriptionParts.join("\n") };
|
|
28
|
+
return { name, description: descriptionParts === null || descriptionParts === void 0 ? void 0 : descriptionParts.join("\n") };
|
|
32
29
|
}),
|
|
33
30
|
});
|
|
34
|
-
|
|
31
|
+
}
|
|
32
|
+
function isTaskVisible(task) {
|
|
33
|
+
return !task.options.hiddenFromTaskList;
|
|
35
34
|
}
|
|
36
35
|
//# sourceMappingURL=formatTasks.js.map
|
package/dist/cli/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { findHerebyfile, loadHerebyfile } from "./loadHerebyfile.js";
|
|
|
5
5
|
import { getUsage, parseArgs } from "./parseArgs.js";
|
|
6
6
|
import { reexec } from "./reexec.js";
|
|
7
7
|
import { Runner } from "./runner.js";
|
|
8
|
-
import { ExitCodeError, UserError } from "./utils.js";
|
|
8
|
+
import { compareTaskNames, ExitCodeError, UserError } from "./utils.js";
|
|
9
9
|
export async function main(d) {
|
|
10
10
|
try {
|
|
11
11
|
await mainWorker(d);
|
|
@@ -46,7 +46,7 @@ async function mainWorker(d) {
|
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
48
|
const tasks = await selectTasks(d, herebyfile, herebyfilePath, args.run);
|
|
49
|
-
const taskNames = tasks.map((
|
|
49
|
+
const taskNames = tasks.map((task) => pc.blue(task.options.name)).join(", ");
|
|
50
50
|
d.log(`Using ${pc.yellow(d.simplifyPath(herebyfilePath))} to run ${taskNames}`);
|
|
51
51
|
const start = Date.now();
|
|
52
52
|
let errored = false;
|
|
@@ -72,7 +72,7 @@ export async function selectTasks(d, herebyfile, herebyfilePath, taskNames) {
|
|
|
72
72
|
for (const task of herebyfile.tasks) {
|
|
73
73
|
allTasks.set(task.options.name, task);
|
|
74
74
|
}
|
|
75
|
-
if (taskNames
|
|
75
|
+
if (taskNames.length > 0) {
|
|
76
76
|
const tasks = [];
|
|
77
77
|
for (const name of taskNames) {
|
|
78
78
|
const task = allTasks.get(name);
|
|
@@ -87,7 +87,7 @@ export async function selectTasks(d, herebyfile, herebyfilePath, taskNames) {
|
|
|
87
87
|
}
|
|
88
88
|
tasks.push(task);
|
|
89
89
|
}
|
|
90
|
-
return tasks;
|
|
90
|
+
return tasks.sort(compareTaskNames);
|
|
91
91
|
}
|
|
92
92
|
if (!herebyfile.defaultTask) {
|
|
93
93
|
throw new UserError(`No default task has been exported from ${d.simplifyPath(herebyfilePath)}; please specify a task name.`);
|
|
@@ -30,6 +30,8 @@ export async function findHerebyfile(dir) {
|
|
|
30
30
|
throw new UserError("Unable to find Herebyfile.");
|
|
31
31
|
}
|
|
32
32
|
export async function loadHerebyfile(herebyfilePath) {
|
|
33
|
+
// Note: calling pathToFileURL is required on Windows to disambiguate URLs
|
|
34
|
+
// from drive letters.
|
|
33
35
|
const herebyfile = await import(pathToFileURL(herebyfilePath).toString());
|
|
34
36
|
const exportedTasks = new Set();
|
|
35
37
|
let defaultTask;
|
package/dist/cli/parseArgs.js
CHANGED
|
@@ -1,24 +1,20 @@
|
|
|
1
|
-
import commandLineArgs from "command-line-args";
|
|
2
1
|
import commandLineUsage from "command-line-usage";
|
|
2
|
+
import minimist from "minimist";
|
|
3
3
|
export function parseArgs(argv) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
{ name: "version", type: Boolean },
|
|
15
|
-
], {
|
|
16
|
-
argv,
|
|
17
|
-
stopAtFirstUnknown: true,
|
|
4
|
+
let parseUnknownAsTask = true;
|
|
5
|
+
const options = minimist(argv, {
|
|
6
|
+
"--": true,
|
|
7
|
+
string: ["herebyfile"],
|
|
8
|
+
boolean: ["tasks", "tasks-simple", "help", "version"],
|
|
9
|
+
alias: {
|
|
10
|
+
"h": "help",
|
|
11
|
+
"T": "tasks",
|
|
12
|
+
},
|
|
13
|
+
unknown: (name) => parseUnknownAsTask && (parseUnknownAsTask = !name.startsWith("-")),
|
|
18
14
|
});
|
|
19
15
|
return {
|
|
20
16
|
help: options["help"],
|
|
21
|
-
run: options["
|
|
17
|
+
run: options["_"],
|
|
22
18
|
herebyfile: options["herebyfile"],
|
|
23
19
|
printTasks: options["tasks"] ? "normal" : (options["tasks-simple"] ? "simple" : undefined),
|
|
24
20
|
version: options["version"],
|
package/dist/cli/utils.js
CHANGED
|
@@ -2,12 +2,11 @@ import fs from "node:fs";
|
|
|
2
2
|
import os from "node:os";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
|
-
export function
|
|
6
|
-
return
|
|
7
|
-
}
|
|
8
|
-
export function stringSorter(a, b) {
|
|
9
|
-
return a.localeCompare(b);
|
|
5
|
+
export function compareTaskNames(a, b) {
|
|
6
|
+
return compareStrings(a.options.name, b.options.name);
|
|
10
7
|
}
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
9
|
+
export const compareStrings = new Intl.Collator(undefined, { numeric: true }).compare;
|
|
11
10
|
// Exported for testing.
|
|
12
11
|
export function simplifyPath(p) {
|
|
13
12
|
let homedir = os.homedir();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hereby",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "A simple task runner",
|
|
5
5
|
"repository": "github:jakebailey/hereby",
|
|
6
6
|
"type": "module",
|
|
@@ -38,18 +38,18 @@
|
|
|
38
38
|
"./dist/index.d.ts"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"command-line-args": "^5.2.1",
|
|
42
41
|
"command-line-usage": "^6.1.3",
|
|
43
42
|
"fastest-levenshtein": "^1.0.16",
|
|
44
43
|
"import-meta-resolve": "^2.2.1",
|
|
44
|
+
"minimist": "^1.2.7",
|
|
45
45
|
"picocolors": "^1.0.0",
|
|
46
46
|
"pretty-ms": "^8.0.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@ava/typescript": "^3.0.1",
|
|
50
50
|
"@tsconfig/node12": "^1.0.11",
|
|
51
|
-
"@types/command-line-args": "^5.2.0",
|
|
52
51
|
"@types/command-line-usage": "^5.0.2",
|
|
52
|
+
"@types/minimist": "^1.2.2",
|
|
53
53
|
"@types/node": "^14.18.36",
|
|
54
54
|
"@types/tmp": "^0.2.3",
|
|
55
55
|
"@typescript-eslint/eslint-plugin": "^5.48.2",
|