@tolki/ts 1.0.0 → 1.0.1

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
@@ -4480,7 +4480,7 @@ By default, the plugin will work in the following way:
4480
4480
  5. It will call the publish command on `vite build` before bundling, with `--only-functional` appended by default (since TypeScript interfaces are type-only and erased at compile time).
4481
4481
  6. It will throw an error if the publish command fails on `vite build`.
4482
4482
  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.
4483
- 8. It will append `--quiet` to every command by default, suppressing all console output since the plugin only needs the exit code.
4483
+ 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.
4484
4484
 
4485
4485
  #### Single-File Republishing
4486
4486
 
@@ -4594,9 +4594,11 @@ export default defineConfig({
4594
4594
  /**
4595
4595
  * Whether to append `--quiet` to every artisan command the plugin runs.
4596
4596
  *
4597
- * The plugin only needs the exit code to determine success or failure;
4598
- * all stdout is ignored. Passing `--quiet` suppresses console output
4599
- * and Laravel Prompts rendering, which speeds up execution.
4597
+ * The plugin determines success or failure from the exit code, so
4598
+ * passing `--quiet` suppresses normal console output and Laravel
4599
+ * Prompts rendering, which speeds up execution. When the command
4600
+ * fails, its captured error output is still surfaced in the plugin's
4601
+ * failure message.
4600
4602
  */
4601
4603
  quiet: true,
4602
4604
  }),
@@ -101,9 +101,11 @@ export interface LaravelTsPublishOptions {
101
101
  /**
102
102
  * Whether to append `--quiet` to every artisan command the plugin runs.
103
103
  *
104
- * The plugin only needs the exit code to determine success or failure;
105
- * all stdout is ignored. Passing `--quiet` suppresses console output
106
- * and Laravel Prompts rendering, which speeds up execution.
104
+ * The plugin determines success or failure from the exit code, so
105
+ * passing `--quiet` suppresses normal console output and Laravel
106
+ * Prompts rendering, which speeds up execution. When the command
107
+ * fails, its captured error output is still surfaced in the plugin's
108
+ * failure message.
107
109
  *
108
110
  * @default true
109
111
  */
@@ -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;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAUpD;AAED,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;;;;;;;;;;;;;;;OAeG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAC/B;;;;;;;;;;OAUG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC;;;;;;;;OAQG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,wBAAgB,gBAAgB,CAC5B,OAAO,GAAE,uBAA4B,GACtC,MAAM,CAsOR"}
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;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAUpD;AAED,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;;;;;;;;;;;;;;;OAeG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAC/B;;;;;;;;;;OAUG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC;;;;;;;;;;OAUG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,wBAAgB,gBAAgB,CAC5B,OAAO,GAAE,uBAA4B,GACtC,MAAM,CAuPR"}
@@ -1,77 +1,81 @@
1
- import { exec as x } from "node:child_process";
2
- import { readFile as A } from "node:fs/promises";
3
- import S from "node:path";
4
- import { promisify as M } from "node:util";
1
+ import { exec as R } from "node:child_process";
2
+ import { readFile as W } from "node:fs/promises";
3
+ import q from "node:path";
4
+ import { promisify as k } from "node:util";
5
5
  import { normalizePath as p } from "vite";
6
- const N = M(x);
7
- function R(i) {
8
- return i === "" ? "''" : /^[\w@%+=:,./-]+$/.test(i) ? i : "'" + i.replace(/'/g, "'\\''") + "'";
6
+ const B = k(R);
7
+ function H(a) {
8
+ return a === "" ? "''" : /^[\w@%+=:,./-]+$/.test(a) ? a : "'" + a.replace(/'/g, "'\\''") + "'";
9
9
  }
10
- function D(i = {}) {
10
+ function G(a = {}) {
11
11
  const {
12
12
  command: l = "php artisan ts:publish",
13
- filename: E = "laravel-ts-collected-files.json",
14
- directory: O = "resources/js/types/data/",
15
- runOnDevStart: q = !1,
16
- runOnBuildStart: z = !0,
17
- reload: F = !0,
13
+ filename: z = "laravel-ts-collected-files.json",
14
+ directory: F = "resources/js/types/data/",
15
+ runOnDevStart: P = !1,
16
+ runOnBuildStart: T = !0,
17
+ reload: x = !0,
18
18
  failOnError: h,
19
19
  sourceCommand: w,
20
- onBuildOnlyFunctional: P = !0,
20
+ onBuildOnlyFunctional: M = !0,
21
21
  quiet: y = !0
22
- } = i, $ = w === !1 ? !1 : w ?? `${l} --source={file}`;
23
- let r, c;
24
- const t = /* @__PURE__ */ new Map();
22
+ } = a, $ = w === !1 ? !1 : w ?? `${l} --source={file}`;
23
+ let t, c;
24
+ const r = /* @__PURE__ */ new Map();
25
25
  let u = "", g = !1;
26
26
  const d = [], n = "[laravel-ts-publish]", b = async () => {
27
- t.clear();
27
+ r.clear();
28
28
  try {
29
- const e = await A(u, "utf-8"), o = JSON.parse(e);
29
+ const e = await W(u, "utf-8"), o = JSON.parse(e);
30
30
  for (const f of o) {
31
- const a = p(S.resolve(r.root, f));
32
- t.set(a, f);
31
+ const s = p(q.resolve(t.root, f));
32
+ r.set(s, f);
33
33
  }
34
34
  } catch (e) {
35
35
  if (e instanceof Error && e.code === "ENOENT") {
36
- r.logger.warn(
36
+ t.logger.warn(
37
37
  `${n} Manifest not found: ${u}`
38
38
  );
39
39
  return;
40
40
  }
41
- r.logger.error(
41
+ t.logger.error(
42
42
  `${n} Failed to read manifest: ${e instanceof Error ? e.message : String(e)}`
43
43
  );
44
44
  }
45
45
  }, v = () => {
46
46
  if (c)
47
- for (const e of t.keys())
47
+ for (const e of r.keys())
48
48
  c.watcher.add(e);
49
- }, T = () => h !== void 0 ? h : r.command === "build", m = async (e = null, o) => {
49
+ }, j = () => h !== void 0 ? h : t.command === "build", m = async (e = null, o) => {
50
50
  if (g) {
51
51
  d.includes(e) || d.push(e);
52
52
  return;
53
53
  }
54
54
  g = !0;
55
- let a = e && $ ? $.replaceAll(
55
+ let s = e && $ ? $.replaceAll(
56
56
  "{file}",
57
- R(e)
57
+ H(e)
58
58
  ) : o ?? l;
59
- y && !a.includes("--quiet") && (a += " --quiet");
59
+ y && !s.includes("--quiet") && (s += " --quiet");
60
60
  try {
61
- r.logger.info(`${n} Running: ${a}`, {
61
+ t.logger.info(`${n} Running: ${s}`, {
62
62
  timestamp: !0
63
- }), await N(a, { cwd: r.root }), r.logger.info(`${n} Types published successfully`, {
63
+ }), await B(s, { cwd: t.root }), t.logger.info(`${n} Types published successfully`, {
64
64
  timestamp: !0
65
- }), F && c && c.ws.send({ type: "full-reload" });
66
- } catch (s) {
67
- const C = `${n} Command failed: ${s instanceof Error ? s.message : String(s)}`;
68
- if (T())
69
- throw new Error(C, { cause: s });
70
- r.logger.error(C);
65
+ }), x && c && c.ws.send({ type: "full-reload" });
66
+ } catch (i) {
67
+ const C = i instanceof Error ? i.message : String(i), { stdout: A, stderr: N } = i, O = [N?.trim(), A?.trim()].filter(
68
+ (E) => !!E && !C.includes(E)
69
+ ).join(`
70
+ `), S = `${n} Command failed: ${C}${O ? `
71
+ ${O}` : ""}`;
72
+ if (j())
73
+ throw new Error(S, { cause: i });
74
+ t.logger.error(S);
71
75
  } finally {
72
76
  if (g = !1, d.length > 0) {
73
- const s = d.shift();
74
- await m(s);
77
+ const i = d.shift();
78
+ await m(i);
75
79
  }
76
80
  }
77
81
  };
@@ -79,41 +83,41 @@ function D(i = {}) {
79
83
  name: "@tolki/vite-plugin-laravel-ts-publish",
80
84
  enforce: "pre",
81
85
  configResolved(e) {
82
- r = e, u = p(
83
- S.resolve(r.root, O, E)
86
+ t = e, u = p(
87
+ q.resolve(t.root, F, z)
84
88
  );
85
89
  },
86
90
  configureServer(e) {
87
91
  c = e;
88
92
  },
89
93
  async buildStart() {
90
- if (r.command === "build") {
91
- if (z) {
92
- let e = P && !l.includes("--only-functional") ? `${l} --only-functional` : l;
94
+ if (t.command === "build") {
95
+ if (T) {
96
+ let e = M && !l.includes("--only-functional") ? `${l} --only-functional` : l;
93
97
  y && !e.includes("--quiet") && (e += " --quiet"), await m(null, e);
94
98
  }
95
99
  return;
96
100
  }
97
- await b(), v(), t.size > 0 && r.logger.info(
98
- `${n} Watching ${t.size} PHP file${t.size === 1 ? "" : "s"} for changes`,
101
+ await b(), v(), r.size > 0 && t.logger.info(
102
+ `${n} Watching ${r.size} PHP file${r.size === 1 ? "" : "s"} for changes`,
99
103
  { timestamp: !0 }
100
- ), q && await m();
104
+ ), P && await m();
101
105
  },
102
106
  async handleHotUpdate({ file: e }) {
103
107
  const o = p(e);
104
108
  if (o === u)
105
- return r.logger.info(
109
+ return t.logger.info(
106
110
  `${n} Manifest changed, reloading watched files`,
107
111
  { timestamp: !0 }
108
112
  ), await b(), v(), [];
109
- if (t.has(o)) {
110
- const f = t.get(o) ?? null;
113
+ if (r.has(o)) {
114
+ const f = r.get(o) ?? null;
111
115
  return await m(f), [];
112
116
  }
113
117
  }
114
118
  };
115
119
  }
116
120
  export {
117
- R as escapeShellArg,
118
- D as laravelTsPublish
121
+ H as escapeShellArg,
122
+ G as laravelTsPublish
119
123
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tolki/ts",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "A set of TypeScript utilities for the Laravel TypeScript Publish PHP package.",
5
5
  "author": "Abraham Arango <https://github.com/abetwothree>",
6
6
  "license": "MIT",