hereby 1.8.8 → 1.8.9
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/loadHerebyfile.js +16 -17
- package/dist/cli/utils.js +15 -6
- package/package.json +13 -13
|
@@ -3,30 +3,29 @@ import path from "node:path";
|
|
|
3
3
|
import { pathToFileURL } from "node:url";
|
|
4
4
|
import pc from "picocolors";
|
|
5
5
|
import { Task } from "../index.js";
|
|
6
|
-
import { UserError } from "./utils.js";
|
|
6
|
+
import { findUp, UserError } from "./utils.js";
|
|
7
7
|
const herebyfileRegExp = /^herebyfile\.m?js$/i;
|
|
8
8
|
export function findHerebyfile(dir) {
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
const matching = entries.filter((e) => herebyfileRegExp.test(e));
|
|
9
|
+
const result = findUp(dir, (dir) => {
|
|
10
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
11
|
+
const matching = entries.filter((e) => herebyfileRegExp.test(e.name));
|
|
13
12
|
if (matching.length > 1) {
|
|
14
|
-
throw new UserError(`Found more than one Herebyfile: ${matching.join(", ")}`);
|
|
13
|
+
throw new UserError(`Found more than one Herebyfile: ${matching.map((e) => e.name).join(", ")}`);
|
|
15
14
|
}
|
|
16
15
|
if (matching.length === 1) {
|
|
17
|
-
const candidate =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
throw new UserError(`${matching[0]} is not a file.`);
|
|
16
|
+
const candidate = matching[0];
|
|
17
|
+
if (!candidate.isFile()) {
|
|
18
|
+
throw new UserError(`${candidate.name} is not a file.`);
|
|
21
19
|
}
|
|
22
|
-
return candidate;
|
|
20
|
+
return path.join(dir, candidate.name);
|
|
23
21
|
}
|
|
24
|
-
if (entries.
|
|
25
|
-
|
|
22
|
+
if (entries.some((e) => e.name === "package.json")) {
|
|
23
|
+
return false; // TODO: Is this actually desirable? What about monorepos?
|
|
26
24
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
return undefined;
|
|
26
|
+
});
|
|
27
|
+
if (result) {
|
|
28
|
+
return result;
|
|
30
29
|
}
|
|
31
30
|
throw new UserError("Unable to find Herebyfile.");
|
|
32
31
|
}
|
|
@@ -58,7 +57,7 @@ export async function loadHerebyfile(herebyfilePath) {
|
|
|
58
57
|
// We check this here by walking the DAG, as some dependencies may not be
|
|
59
58
|
// exported and therefore would not be seen by the above loop.
|
|
60
59
|
checkTaskInvariants(exportedTasks);
|
|
61
|
-
const tasks = new Map([...exportedTasks
|
|
60
|
+
const tasks = new Map([...exportedTasks].map((task) => [task.options.name, task]));
|
|
62
61
|
return { tasks, defaultTask };
|
|
63
62
|
}
|
|
64
63
|
function checkTaskInvariants(tasks) {
|
package/dist/cli/utils.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import os from "node:os";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import { fileURLToPath } from "node:url";
|
|
5
4
|
export function compareTaskNames(a, b) {
|
|
6
5
|
return compareStrings(a.options.name, b.options.name);
|
|
7
6
|
}
|
|
@@ -17,6 +16,18 @@ export function simplifyPath(p) {
|
|
|
17
16
|
}
|
|
18
17
|
return p;
|
|
19
18
|
}
|
|
19
|
+
export function findUp(p, predicate) {
|
|
20
|
+
const root = path.parse(p).root;
|
|
21
|
+
while (true) {
|
|
22
|
+
const result = predicate(p);
|
|
23
|
+
if (result !== undefined)
|
|
24
|
+
return result;
|
|
25
|
+
if (p === root)
|
|
26
|
+
break;
|
|
27
|
+
p = path.dirname(p);
|
|
28
|
+
}
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
20
31
|
/**
|
|
21
32
|
* UserError is a special error that, when caught in the CLI will be printed
|
|
22
33
|
* as a message only, without stacktrace. Use this instead of process.exit.
|
|
@@ -49,11 +60,9 @@ export async function real() {
|
|
|
49
60
|
process.exitCode = code;
|
|
50
61
|
},
|
|
51
62
|
version: async () => {
|
|
52
|
-
const
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
const { version } = JSON.parse(packageJson);
|
|
56
|
-
return version;
|
|
63
|
+
const packageJsonURL = new URL("../../package.json", import.meta.url);
|
|
64
|
+
const packageJson = await fs.promises.readFile(packageJsonURL, "utf8");
|
|
65
|
+
return JSON.parse(packageJson).version;
|
|
57
66
|
},
|
|
58
67
|
resolve: async (specifier, parent) => {
|
|
59
68
|
const { resolve } = await import("import-meta-resolve");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hereby",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.9",
|
|
4
4
|
"description": "A simple task runner",
|
|
5
5
|
"repository": "github:jakebailey/hereby",
|
|
6
6
|
"type": "module",
|
|
@@ -48,26 +48,26 @@
|
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@ava/typescript": "^3.0.1",
|
|
51
|
-
"@changesets/cli": "^2.
|
|
51
|
+
"@changesets/cli": "^2.27.1",
|
|
52
52
|
"@tsconfig/node12": "^12.1.0",
|
|
53
|
-
"@types/command-line-usage": "^5.0.
|
|
54
|
-
"@types/minimist": "^1.2.
|
|
55
|
-
"@types/node": "^20.
|
|
56
|
-
"@types/tmp": "^0.2.
|
|
57
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
58
|
-
"@typescript-eslint/parser": "^6.
|
|
53
|
+
"@types/command-line-usage": "^5.0.4",
|
|
54
|
+
"@types/minimist": "^1.2.5",
|
|
55
|
+
"@types/node": "^20.10.6",
|
|
56
|
+
"@types/tmp": "^0.2.6",
|
|
57
|
+
"@typescript-eslint/eslint-plugin": "^6.17.0",
|
|
58
|
+
"@typescript-eslint/parser": "^6.17.0",
|
|
59
59
|
"ava": "~5.0.1",
|
|
60
60
|
"c8": "^8.0.1",
|
|
61
|
-
"dprint": "^0.
|
|
62
|
-
"eslint": "^8.
|
|
61
|
+
"dprint": "^0.45.0",
|
|
62
|
+
"eslint": "^8.56.0",
|
|
63
63
|
"eslint-plugin-ava": "^14.0.0",
|
|
64
64
|
"eslint-plugin-simple-import-sort": "^10.0.0",
|
|
65
|
-
"eslint-plugin-unicorn": "^
|
|
65
|
+
"eslint-plugin-unicorn": "^50.0.1",
|
|
66
66
|
"execa": "^6.1.0",
|
|
67
|
-
"moq.ts": "^10.0
|
|
67
|
+
"moq.ts": "^10.1.0",
|
|
68
68
|
"rimraf": "^5.0.5",
|
|
69
69
|
"tmp": "^0.2.1",
|
|
70
|
-
"typescript": "^5.
|
|
70
|
+
"typescript": "^5.3.3"
|
|
71
71
|
},
|
|
72
72
|
"overrides": {
|
|
73
73
|
"ava": {
|