@dokebi/cli 0.2.3 → 0.2.4

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.
@@ -1,5 +1,6 @@
1
1
  import { lstat, mkdir, mkdtemp, open, readdir, readFile, rename, rm, rmdir, writeFile, } from 'node:fs/promises';
2
2
  import { dirname, join } from 'node:path';
3
+ import { debug, debugEnabled, describeError, reportError } from './diagnostics.js';
3
4
  import { CliError } from './errors.js';
4
5
  import { exists, fingerprint, json, securePath } from './filesystem.js';
5
6
  export class Transaction {
@@ -32,7 +33,10 @@ export class Transaction {
32
33
  return new Transaction(root, await mkdtemp(join(control, 'transaction-')));
33
34
  }
34
35
  catch (cause) {
35
- await handle.close().catch(() => { });
36
+ await handle.close().catch((error) => {
37
+ // The lock is removed below either way; the original failure is what the caller gets.
38
+ reportError('LOCK_CLOSE_FAILED', 'Unable to close .dokebi/lock', error);
39
+ });
36
40
  await rm(lock, { force: true });
37
41
  throw cause;
38
42
  }
@@ -125,6 +129,11 @@ export class Transaction {
125
129
  await afterApply?.();
126
130
  }
127
131
  catch (cause) {
132
+ if (debugEnabled())
133
+ debug('Commit failed; rolling back', {
134
+ changes: journal.length,
135
+ error: describeError(cause),
136
+ });
128
137
  const failures = [];
129
138
  for (const change of [...journal].reverse()) {
130
139
  try {
package/dist/workspace.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { glob, readFile, realpath } from 'node:fs/promises';
2
2
  import { dirname, join, relative, sep } from 'node:path';
3
+ import { isMissing, reportError } from './diagnostics.js';
3
4
  import { CliError } from './errors.js';
4
5
  import { exists, relativePath, securePath } from './filesystem.js';
5
6
  /** `*` matches one path segment, `**` any number; patterns are npm `workspaces` entries. */
@@ -33,8 +34,11 @@ export async function workspaceRootOf(project) {
33
34
  if (!hidden && patternsOf(pkg).some((item) => matches(item, member)))
34
35
  return directory;
35
36
  }
36
- catch {
37
- /* no or unreadable package.json: keep walking up */
37
+ catch (error) {
38
+ // No package.json here: keep walking up. An unreadable or invalid one is reported and
39
+ // skipped the same way, so a broken parent folder does not block the command.
40
+ if (!isMissing(error))
41
+ reportError('WORKSPACE_PACKAGE_INVALID', 'Skipping an unreadable package.json', error);
38
42
  }
39
43
  if (dirname(directory) === directory)
40
44
  return undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dokebi/cli",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public",