hereby 1.8.7 → 1.8.8

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 CHANGED
@@ -11,7 +11,7 @@
11
11
 
12
12
  `hereby` is a simple task runner.
13
13
 
14
- ```
14
+ ```console
15
15
  $ npm i -D hereby
16
16
  $ yarn add -D hereby
17
17
  ```
@@ -73,7 +73,7 @@ export const bundle = task({
73
73
 
74
74
  Given the above Herebyfile:
75
75
 
76
- ```
76
+ ```console
77
77
  $ hereby build # Run the "build" task
78
78
  $ hereby test # Run the "test" task, which depends on "build".
79
79
  $ hereby # Run the default exported task.
@@ -84,7 +84,7 @@ $ hereby test bundle # Run the "test" and "bundle" tasks in parallel.
84
84
 
85
85
  `hereby` also supports a handful of flags:
86
86
 
87
- ```
87
+ ```console
88
88
  -h, --help Display this usage guide.
89
89
  --herebyfile path A path to a Herebyfile. Optional.
90
90
  -T, --tasks Print a listing of the available tasks.
@@ -125,7 +125,7 @@ anyway).
125
125
  To run tasks in a specific order and more than once, run `hereby` multiple
126
126
  times:
127
127
 
128
- ```
128
+ ```console
129
129
  $ hereby build
130
130
  $ hereby clean
131
131
  $ hereby build
@@ -2,13 +2,13 @@ import commandLineUsage from "command-line-usage";
2
2
  import pc from "picocolors";
3
3
  import { compareTaskNames } from "./utils.js";
4
4
  export function formatTasks(format, tasks, defaultTask) {
5
- tasks = tasks.filter(isTaskVisible).sort(compareTaskNames);
5
+ const visibleTasks = [...tasks].filter(isTaskVisible).sort(compareTaskNames);
6
6
  if (format === "simple") {
7
- return tasks.map((task) => task.options.name).join("\n");
7
+ return visibleTasks.map((task) => task.options.name).join("\n");
8
8
  }
9
9
  return commandLineUsage({
10
10
  header: "Available tasks",
11
- content: tasks.map((task) => {
11
+ content: visibleTasks.map((task) => {
12
12
  var _a;
13
13
  const name = task === defaultTask
14
14
  ? `${pc.green(task.options.name)} (default)`
package/dist/cli/index.js CHANGED
@@ -35,7 +35,7 @@ async function mainWorker(d) {
35
35
  d.log(getUsage());
36
36
  return;
37
37
  }
38
- let herebyfilePath = (_a = args.herebyfile) !== null && _a !== void 0 ? _a : (await findHerebyfile(d.cwd()));
38
+ let herebyfilePath = (_a = args.herebyfile) !== null && _a !== void 0 ? _a : findHerebyfile(d.cwd());
39
39
  herebyfilePath = path.resolve(d.cwd(), herebyfilePath);
40
40
  if (await reexec(d, herebyfilePath)) {
41
41
  return;
@@ -47,7 +47,7 @@ async function mainWorker(d) {
47
47
  d.chdir(path.dirname(herebyfilePath));
48
48
  const herebyfile = await loadHerebyfile(herebyfilePath);
49
49
  if (args.printTasks) {
50
- d.log(formatTasks(args.printTasks, herebyfile.tasks, herebyfile.defaultTask));
50
+ d.log(formatTasks(args.printTasks, herebyfile.tasks.values(), herebyfile.defaultTask));
51
51
  return;
52
52
  }
53
53
  const tasks = await selectTasks(d, herebyfile, herebyfilePath, args.run);
@@ -79,14 +79,13 @@ export async function selectTasks(d, herebyfile, herebyfilePath, taskNames) {
79
79
  }
80
80
  return [herebyfile.defaultTask];
81
81
  }
82
- const allTasks = new Map(herebyfile.tasks.map((task) => [task.options.name, task]));
83
82
  const tasks = [];
84
83
  for (const name of taskNames) {
85
- const task = allTasks.get(name);
84
+ const task = herebyfile.tasks.get(name);
86
85
  if (!task) {
87
86
  let message = `Task "${name}" does not exist or is not exported from ${d.simplifyPath(herebyfilePath)}.`;
88
87
  const { closest, distance } = await import("fastest-levenshtein");
89
- const candidate = closest(name, [...allTasks.keys()]);
88
+ const candidate = closest(name, [...herebyfile.tasks.keys()]);
90
89
  if (distance(name, candidate) < name.length * 0.4) {
91
90
  message += ` Did you mean "${candidate}"?`;
92
91
  }
@@ -4,29 +4,29 @@ import { pathToFileURL } from "node:url";
4
4
  import pc from "picocolors";
5
5
  import { Task } from "../index.js";
6
6
  import { UserError } from "./utils.js";
7
- function isHerebyfile(p) {
8
- p = p.toLowerCase();
9
- return p === "herebyfile.mjs" || p === "herebyfile.js";
10
- }
11
- export async function findHerebyfile(dir) {
7
+ const herebyfileRegExp = /^herebyfile\.m?js$/i;
8
+ export function findHerebyfile(dir) {
12
9
  const root = path.parse(dir).root;
13
- for (; dir !== root; dir = path.dirname(dir)) {
14
- const entries = await fs.promises.readdir(dir);
15
- const matching = entries.filter(isHerebyfile);
10
+ while (true) {
11
+ const entries = fs.readdirSync(dir);
12
+ const matching = entries.filter((e) => herebyfileRegExp.test(e));
16
13
  if (matching.length > 1) {
17
14
  throw new UserError(`Found more than one Herebyfile: ${matching.join(", ")}`);
18
15
  }
19
16
  if (matching.length === 1) {
20
17
  const candidate = path.join(dir, matching[0]);
21
- const stat = await fs.promises.stat(candidate);
18
+ const stat = fs.statSync(candidate);
22
19
  if (!stat.isFile()) {
23
20
  throw new UserError(`${matching[0]} is not a file.`);
24
21
  }
25
22
  return candidate;
26
23
  }
27
24
  if (entries.includes("package.json")) {
28
- break;
25
+ break; // TODO: Is this actually desirable? What about monorepos?
29
26
  }
27
+ if (dir === root)
28
+ break;
29
+ dir = path.dirname(dir);
30
30
  }
31
31
  throw new UserError("Unable to find Herebyfile.");
32
32
  }
@@ -55,14 +55,11 @@ export async function loadHerebyfile(herebyfilePath) {
55
55
  if (exportedTasks.size === 0) {
56
56
  throw new UserError("No tasks found. Did you forget to export your tasks?");
57
57
  }
58
- const tasks = [...exportedTasks.values()];
59
58
  // We check this here by walking the DAG, as some dependencies may not be
60
59
  // exported and therefore would not be seen by the above loop.
61
- checkTaskInvariants(tasks);
62
- return {
63
- tasks,
64
- defaultTask,
65
- };
60
+ checkTaskInvariants(exportedTasks);
61
+ const tasks = new Map([...exportedTasks.values()].map((task) => [task.options.name, task]));
62
+ return { tasks, defaultTask };
66
63
  }
67
64
  function checkTaskInvariants(tasks) {
68
65
  const checkedTasks = new Set();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hereby",
3
- "version": "1.8.7",
3
+ "version": "1.8.8",
4
4
  "description": "A simple task runner",
5
5
  "repository": "github:jakebailey/hereby",
6
6
  "type": "module",
@@ -48,23 +48,24 @@
48
48
  },
49
49
  "devDependencies": {
50
50
  "@ava/typescript": "^3.0.1",
51
+ "@changesets/cli": "^2.26.2",
51
52
  "@tsconfig/node12": "^12.1.0",
52
- "@types/command-line-usage": "^5.0.2",
53
- "@types/minimist": "^1.2.2",
54
- "@types/node": "^20.5.9",
55
- "@types/tmp": "^0.2.3",
56
- "@typescript-eslint/eslint-plugin": "^6.6.0",
57
- "@typescript-eslint/parser": "^6.6.0",
53
+ "@types/command-line-usage": "^5.0.3",
54
+ "@types/minimist": "^1.2.4",
55
+ "@types/node": "^20.8.10",
56
+ "@types/tmp": "^0.2.5",
57
+ "@typescript-eslint/eslint-plugin": "^6.9.1",
58
+ "@typescript-eslint/parser": "^6.9.1",
58
59
  "ava": "~5.0.1",
59
60
  "c8": "^8.0.1",
60
- "dprint": "^0.40.2",
61
- "eslint": "^8.48.0",
61
+ "dprint": "^0.42.5",
62
+ "eslint": "^8.52.0",
62
63
  "eslint-plugin-ava": "^14.0.0",
63
64
  "eslint-plugin-simple-import-sort": "^10.0.0",
64
- "eslint-plugin-unicorn": "^48.0.1",
65
+ "eslint-plugin-unicorn": "^49.0.0",
65
66
  "execa": "^6.1.0",
66
- "moq.ts": "^10.0.6",
67
- "rimraf": "^5.0.1",
67
+ "moq.ts": "^10.0.8",
68
+ "rimraf": "^5.0.5",
68
69
  "tmp": "^0.2.1",
69
70
  "typescript": "^5.2.2"
70
71
  },
@@ -101,17 +102,5 @@
101
102
  "html",
102
103
  "lcov"
103
104
  ]
104
- },
105
- "release-it": {
106
- "npm": {
107
- "publish": false
108
- },
109
- "git": {
110
- "commitMessage": "Release v${version}",
111
- "tagName": "v${version}"
112
- },
113
- "hooks": {
114
- "before:init": "npm run build && npm run test"
115
- }
116
105
  }
117
106
  }