@tolki/enum 1.1.0 → 1.1.2

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
@@ -151,7 +151,7 @@ By default, the plugin will work in the following way:
151
151
  5. It will call the publish command on `vite build` before bundling, with `--only-enums` appended by default (since model interfaces are type-only and erased at compile time).
152
152
  6. It will throw an error if the publish command fails on `vite build`.
153
153
  7. When a single PHP file changes during `vite dev`, it will use `--source` to republish only that file instead of running a full publish.
154
- 8. It will append `--quiet` to every command by default, suppressing all console output since the plugin only needs the exit code.
154
+ 8. It will append `--quiet` to every command by default, suppressing normal console output since the plugin determines success from the exit code. When the command fails, its captured error output is included in the plugin's error message.
155
155
 
156
156
  #### Single-File Republishing
157
157
 
@@ -265,9 +265,11 @@ export default defineConfig({
265
265
  /**
266
266
  * Whether to append `--quiet` to every artisan command the plugin runs.
267
267
  *
268
- * The plugin only needs the exit code to determine success or failure;
269
- * all stdout is ignored. Passing `--quiet` suppresses console output
270
- * and Laravel Prompts rendering, which speeds up execution.
268
+ * The plugin determines success or failure from the exit code, so
269
+ * passing `--quiet` suppresses normal console output and Laravel
270
+ * Prompts rendering, which speeds up execution. When the command
271
+ * fails, its captured error output is still surfaced in the plugin's
272
+ * failure message.
271
273
  */
272
274
  quiet: true,
273
275
  }),
package/dist/enums.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AsEnum, CaseValue, DefineEnumResult, EnumConst, FromResult } from '../../types/src/index.ts';
1
+ import { AsEnum, CaseValue, DefineEnumResult, EnumConst, FromResult } from '@tolki/types';
2
2
  export type { AsEnum, CaseValue, DefineEnumResult, EnumConst, FromResult };
3
3
  /**
4
4
  * Creates an enum instance from a case value similar to PHP's `BackedEnum::from()`
@@ -1,4 +1,4 @@
1
- import { DefineEnumResult } from 'packages/types/src';
1
+ import { DefineEnumResult } from '@tolki/ts';
2
2
  export declare const SortDirection: DefineEnumResult<{
3
3
  readonly Ascending: "Ascending";
4
4
  readonly Descending: "Descending";
@@ -90,9 +90,11 @@ export interface LaravelTsPublishOptions {
90
90
  /**
91
91
  * Whether to append `--quiet` to every artisan command the plugin runs.
92
92
  *
93
- * The plugin only needs the exit code to determine success or failure;
94
- * all stdout is ignored. Passing `--quiet` suppresses console output
95
- * and Laravel Prompts rendering, which speeds up execution.
93
+ * The plugin determines success or failure from the exit code, so
94
+ * passing `--quiet` suppresses normal console output and Laravel
95
+ * Prompts rendering, which speeds up execution. When the command
96
+ * fails, its captured error output is still surfaced in the plugin's
97
+ * failure message.
96
98
  *
97
99
  * @default true
98
100
  */
@@ -1 +1 @@
1
- {"version":3,"file":"vite-plugin.d.ts","sourceRoot":"","sources":["../src/vite-plugin.ts"],"names":[],"mappings":"AAKA,OAAO,EAEH,KAAK,MAAM,EAGd,MAAM,MAAM,CAAC;AAId,MAAM,WAAW,uBAAuB;IACpC;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;;;;OAOG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;;;;;;;;;;;OAcG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAC/B;;;;;;;;;;OAUG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;;;;;;OAQG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,wBAAgB,gBAAgB,CAC5B,OAAO,GAAE,uBAA4B,GACtC,MAAM,CAkOR"}
1
+ {"version":3,"file":"vite-plugin.d.ts","sourceRoot":"","sources":["../src/vite-plugin.ts"],"names":[],"mappings":"AAKA,OAAO,EAEH,KAAK,MAAM,EAGd,MAAM,MAAM,CAAC;AAId,MAAM,WAAW,uBAAuB;IACpC;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;;;;OAOG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;;;;;;;;;;;OAcG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAC/B;;;;;;;;;;OAUG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;;;;;;;;OAUG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,wBAAgB,gBAAgB,CAC5B,OAAO,GAAE,uBAA4B,GACtC,MAAM,CAmPR"}
@@ -1,71 +1,75 @@
1
- import { exec as F } from "node:child_process";
2
- import { readFile as M } from "node:fs/promises";
3
- import C from "node:path";
4
- import { promisify as N } from "node:util";
1
+ import { exec as W } from "node:child_process";
2
+ import { readFile as k } from "node:fs/promises";
3
+ import S from "node:path";
4
+ import { promisify as A } from "node:util";
5
5
  import { normalizePath as g } from "vite";
6
- const R = N(F);
7
- function H(E = {}) {
6
+ const B = A(W);
7
+ function U(q = {}) {
8
8
  const {
9
- command: s = "php artisan ts:publish",
10
- filename: O = "laravel-ts-collected-files.json",
11
- directory: S = "resources/js/types/data/",
12
- runOnDevStart: q = !1,
13
- runOnBuildStart: z = !0,
14
- reload: P = !0,
9
+ command: a = "php artisan ts:publish",
10
+ filename: z = "laravel-ts-collected-files.json",
11
+ directory: P = "resources/js/types/data/",
12
+ runOnDevStart: T = !1,
13
+ runOnBuildStart: x = !0,
14
+ reload: F = !0,
15
15
  failOnError: p,
16
16
  sourceCommand: h,
17
- onBuildOnlyEnums: T = !0,
17
+ onBuildOnlyEnums: M = !0,
18
18
  quiet: w = !0
19
- } = E, y = h === !1 ? !1 : h ?? `${s} --source="{file}"`;
20
- let r, l;
21
- const t = /* @__PURE__ */ new Map();
19
+ } = q, y = h === !1 ? !1 : h ?? `${a} --source="{file}"`;
20
+ let t, l;
21
+ const r = /* @__PURE__ */ new Map();
22
22
  let u = "", m = !1;
23
- const f = [], n = "[laravel-ts-publish]", v = async () => {
24
- t.clear();
23
+ const f = [], n = "[laravel-ts-publish]", $ = async () => {
24
+ r.clear();
25
25
  try {
26
- const e = await M(u, "utf-8"), o = JSON.parse(e);
26
+ const e = await k(u, "utf-8"), o = JSON.parse(e);
27
27
  for (const c of o) {
28
- const a = g(C.resolve(r.root, c));
29
- t.set(a, c);
28
+ const i = g(S.resolve(t.root, c));
29
+ r.set(i, c);
30
30
  }
31
31
  } catch (e) {
32
32
  if (e instanceof Error && e.code === "ENOENT") {
33
- r.logger.warn(
33
+ t.logger.warn(
34
34
  `${n} Manifest not found: ${u}`
35
35
  );
36
36
  return;
37
37
  }
38
- r.logger.error(
38
+ t.logger.error(
39
39
  `${n} Failed to read manifest: ${e instanceof Error ? e.message : String(e)}`
40
40
  );
41
41
  }
42
- }, $ = () => {
42
+ }, v = () => {
43
43
  if (l)
44
- for (const e of t.keys())
44
+ for (const e of r.keys())
45
45
  l.watcher.add(e);
46
- }, x = () => p !== void 0 ? p : r.command === "build", d = async (e = null, o) => {
46
+ }, j = () => p !== void 0 ? p : t.command === "build", d = async (e = null, o) => {
47
47
  if (m) {
48
48
  f.includes(e) || f.push(e);
49
49
  return;
50
50
  }
51
51
  m = !0;
52
- let a = e && y ? y.replaceAll("{file}", e) : o ?? s;
53
- w && !a.includes("--quiet") && (a += " --quiet");
52
+ let i = e && y ? y.replaceAll("{file}", e) : o ?? a;
53
+ w && !i.includes("--quiet") && (i += " --quiet");
54
54
  try {
55
- r.logger.info(`${n} Running: ${a}`, {
55
+ t.logger.info(`${n} Running: ${i}`, {
56
56
  timestamp: !0
57
- }), await R(a, { cwd: r.root }), r.logger.info(`${n} Types published successfully`, {
57
+ }), await B(i, { cwd: t.root }), t.logger.info(`${n} Types published successfully`, {
58
58
  timestamp: !0
59
- }), P && l && l.ws.send({ type: "full-reload" });
60
- } catch (i) {
61
- const b = `${n} Command failed: ${i instanceof Error ? i.message : String(i)}`;
62
- if (x())
63
- throw new Error(b, { cause: i });
64
- r.logger.error(b);
59
+ }), F && l && l.ws.send({ type: "full-reload" });
60
+ } catch (s) {
61
+ const b = s instanceof Error ? s.message : String(s), { stdout: N, stderr: R } = s, C = [R?.trim(), N?.trim()].filter(
62
+ (O) => !!O && !b.includes(O)
63
+ ).join(`
64
+ `), E = `${n} Command failed: ${b}${C ? `
65
+ ${C}` : ""}`;
66
+ if (j())
67
+ throw new Error(E, { cause: s });
68
+ t.logger.error(E);
65
69
  } finally {
66
70
  if (m = !1, f.length > 0) {
67
- const i = f.shift();
68
- await d(i);
71
+ const s = f.shift();
72
+ await d(s);
69
73
  }
70
74
  }
71
75
  };
@@ -73,40 +77,40 @@ function H(E = {}) {
73
77
  name: "@tolki/vite-plugin-laravel-ts-publish",
74
78
  enforce: "pre",
75
79
  configResolved(e) {
76
- r = e, u = g(
77
- C.resolve(r.root, S, O)
80
+ t = e, u = g(
81
+ S.resolve(t.root, P, z)
78
82
  );
79
83
  },
80
84
  configureServer(e) {
81
85
  l = e;
82
86
  },
83
87
  async buildStart() {
84
- if (r.command === "build") {
85
- if (z) {
86
- let e = T && !s.includes("--only-enums") ? `${s} --only-enums` : s;
88
+ if (t.command === "build") {
89
+ if (x) {
90
+ let e = M && !a.includes("--only-enums") ? `${a} --only-enums` : a;
87
91
  w && !e.includes("--quiet") && (e += " --quiet"), await d(null, e);
88
92
  }
89
93
  return;
90
94
  }
91
- await v(), $(), t.size > 0 && r.logger.info(
92
- `${n} Watching ${t.size} PHP file${t.size === 1 ? "" : "s"} for changes`,
95
+ await $(), v(), r.size > 0 && t.logger.info(
96
+ `${n} Watching ${r.size} PHP file${r.size === 1 ? "" : "s"} for changes`,
93
97
  { timestamp: !0 }
94
- ), q && await d();
98
+ ), T && await d();
95
99
  },
96
100
  async handleHotUpdate({ file: e }) {
97
101
  const o = g(e);
98
102
  if (o === u)
99
- return r.logger.info(
103
+ return t.logger.info(
100
104
  `${n} Manifest changed, reloading watched files`,
101
105
  { timestamp: !0 }
102
- ), await v(), $(), [];
103
- if (t.has(o)) {
104
- const c = t.get(o) ?? null;
106
+ ), await $(), v(), [];
107
+ if (r.has(o)) {
108
+ const c = r.get(o) ?? null;
105
109
  return await d(c), [];
106
110
  }
107
111
  }
108
112
  };
109
113
  }
110
114
  export {
111
- H as laravelTsPublish
115
+ U as laravelTsPublish
112
116
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tolki/enum",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "A set of enum utilities for the Laravel TypeScript Publish PHP package.",
5
5
  "author": "Abraham Arango <https://github.com/abetwothree>",
6
6
  "license": "MIT",
@@ -37,7 +37,7 @@
37
37
  "tolki"
38
38
  ],
39
39
  "dependencies": {
40
- "@tolki/types": "^1.2.0"
40
+ "@tolki/types": "^1.5.0"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "vite": "^8.0.0||^7.0.0"
@@ -64,11 +64,7 @@
64
64
  }
65
65
  },
66
66
  "tolki": {
67
- "docs": [
68
- "enums/index.md",
69
- "enums/enum-utilities-list.md",
70
- "enums/enum-vite-plugin.md"
71
- ]
67
+ "docs": []
72
68
  },
73
69
  "scripts": {
74
70
  "build": "vite build",