@tolki/ts 1.0.3 → 1.0.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.
- package/README.md +787 -100
- package/dist/vite-plugin.d.ts +2 -10
- package/dist/vite-plugin.d.ts.map +1 -1
- package/dist/vite-plugin.js +64 -58
- package/package.json +9 -4
package/dist/vite-plugin.d.ts
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
|
+
import { escapeShellArg } from '@tolki/utils';
|
|
1
2
|
import { Plugin } from 'vite';
|
|
2
|
-
|
|
3
|
-
* Escape a value for safe interpolation into a shell command string.
|
|
4
|
-
*
|
|
5
|
-
* Uses POSIX single-quote wrapping: the only character that requires
|
|
6
|
-
* escaping inside single quotes is the single quote itself.
|
|
7
|
-
*
|
|
8
|
-
* @param value - The raw string to escape.
|
|
9
|
-
* @returns A shell-safe string.
|
|
10
|
-
*/
|
|
11
|
-
export declare function escapeShellArg(value: string): string;
|
|
3
|
+
export { escapeShellArg };
|
|
12
4
|
export interface LaravelTsPublishOptions {
|
|
13
5
|
/**
|
|
14
6
|
* The command to run when a watched PHP file changes.
|
|
@@ -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
|
|
1
|
+
{"version":3,"file":"vite-plugin.d.ts","sourceRoot":"","sources":["../src/vite-plugin.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAyB,MAAM,cAAc,CAAC;AACrE,OAAO,EAEH,KAAK,MAAM,EAGd,MAAM,MAAM,CAAC;AAId,OAAO,EAAE,cAAc,EAAE,CAAC;AAE1B,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;AAcD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,wBAAgB,gBAAgB,CAC5B,OAAO,GAAE,uBAA4B,GACtC,MAAM,CA4PR"}
|
package/dist/vite-plugin.js
CHANGED
|
@@ -1,35 +1,37 @@
|
|
|
1
1
|
import { exec as R } from "node:child_process";
|
|
2
|
-
import { readFile as
|
|
2
|
+
import { readFile as k } from "node:fs/promises";
|
|
3
3
|
import q from "node:path";
|
|
4
|
-
import { promisify as
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
import { promisify as B } from "node:util";
|
|
5
|
+
import { escapeWindowsShellArg as H, escapeShellArg as D } from "@tolki/utils";
|
|
6
|
+
import { escapeShellArg as _ } from "@tolki/utils";
|
|
7
|
+
import { normalizePath as w } from "vite";
|
|
8
|
+
const J = B(R);
|
|
9
|
+
function L(c) {
|
|
10
|
+
return process.platform === "win32" ? H(c) : D(c);
|
|
9
11
|
}
|
|
10
|
-
function
|
|
12
|
+
function X(c = {}) {
|
|
11
13
|
const {
|
|
12
|
-
command:
|
|
13
|
-
filename:
|
|
14
|
-
directory:
|
|
14
|
+
command: a = "php artisan ts:publish",
|
|
15
|
+
filename: x = "laravel-ts-collected-files.json",
|
|
16
|
+
directory: z = "resources/js/types/data/",
|
|
15
17
|
runOnDevStart: P = !1,
|
|
16
18
|
runOnBuildStart: T = !0,
|
|
17
|
-
reload:
|
|
18
|
-
failOnError:
|
|
19
|
-
sourceCommand:
|
|
19
|
+
reload: F = !0,
|
|
20
|
+
failOnError: y,
|
|
21
|
+
sourceCommand: $,
|
|
20
22
|
onBuildOnlyFunctional: M = !0,
|
|
21
|
-
quiet:
|
|
22
|
-
} =
|
|
23
|
-
let t,
|
|
23
|
+
quiet: v = !0
|
|
24
|
+
} = c, f = $ === !1 ? !1 : $ ?? `${a} --source={file}`;
|
|
25
|
+
let t, l;
|
|
24
26
|
const r = /* @__PURE__ */ new Map();
|
|
25
|
-
let u = "",
|
|
27
|
+
let u = "", p = !1;
|
|
26
28
|
const d = [], n = "[laravel-ts-publish]", b = async () => {
|
|
27
29
|
r.clear();
|
|
28
30
|
try {
|
|
29
|
-
const e = await
|
|
30
|
-
for (const
|
|
31
|
-
const
|
|
32
|
-
r.set(
|
|
31
|
+
const e = await k(u, "utf-8"), o = JSON.parse(e);
|
|
32
|
+
for (const i of o) {
|
|
33
|
+
const g = w(q.resolve(t.root, i));
|
|
34
|
+
r.set(g, i);
|
|
33
35
|
}
|
|
34
36
|
} catch (e) {
|
|
35
37
|
if (e instanceof Error && e.code === "ENOENT") {
|
|
@@ -42,40 +44,44 @@ function G(a = {}) {
|
|
|
42
44
|
`${n} Failed to read manifest: ${e instanceof Error ? e.message : String(e)}`
|
|
43
45
|
);
|
|
44
46
|
}
|
|
45
|
-
},
|
|
46
|
-
if (
|
|
47
|
+
}, S = () => {
|
|
48
|
+
if (l)
|
|
47
49
|
for (const e of r.keys())
|
|
48
|
-
|
|
49
|
-
},
|
|
50
|
-
if (
|
|
50
|
+
l.watcher.add(e);
|
|
51
|
+
}, W = () => y !== void 0 ? y : t.command === "build", m = async (e = null, o) => {
|
|
52
|
+
if (p) {
|
|
51
53
|
d.includes(e) || d.push(e);
|
|
52
54
|
return;
|
|
53
55
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
p = !0;
|
|
57
|
+
const i = o ?? a, g = e && f ? f : i;
|
|
58
|
+
let h = e && f ? (
|
|
59
|
+
// A function replacer keeps `$&` and friends in the path literal.
|
|
60
|
+
f.replaceAll(
|
|
61
|
+
"{file}",
|
|
62
|
+
() => L(e)
|
|
63
|
+
)
|
|
64
|
+
) : i;
|
|
65
|
+
v && !g.includes("--quiet") && (h += " --quiet");
|
|
60
66
|
try {
|
|
61
|
-
t.logger.info(`${n} Running: ${
|
|
67
|
+
t.logger.info(`${n} Running: ${h}`, {
|
|
62
68
|
timestamp: !0
|
|
63
|
-
}), await
|
|
69
|
+
}), await J(h, { cwd: t.root }), t.logger.info(`${n} Types published successfully`, {
|
|
64
70
|
timestamp: !0
|
|
65
|
-
}),
|
|
66
|
-
} catch (
|
|
67
|
-
const
|
|
68
|
-
(
|
|
71
|
+
}), F && l && l.ws.send({ type: "full-reload" });
|
|
72
|
+
} catch (s) {
|
|
73
|
+
const O = s instanceof Error ? s.message : String(s), { stdout: j, stderr: N } = s, C = [N?.trim(), j?.trim()].filter(
|
|
74
|
+
(A) => !!A && !O.includes(A)
|
|
69
75
|
).join(`
|
|
70
|
-
`),
|
|
71
|
-
${
|
|
72
|
-
if (
|
|
73
|
-
throw new Error(
|
|
74
|
-
t.logger.error(
|
|
76
|
+
`), E = `${n} Command failed: ${O}${C ? `
|
|
77
|
+
${C}` : ""}`;
|
|
78
|
+
if (W())
|
|
79
|
+
throw new Error(E, { cause: s });
|
|
80
|
+
t.logger.error(E);
|
|
75
81
|
} finally {
|
|
76
|
-
if (
|
|
77
|
-
const
|
|
78
|
-
await m(
|
|
82
|
+
if (p = !1, d.length > 0) {
|
|
83
|
+
const s = d.shift();
|
|
84
|
+
await m(s);
|
|
79
85
|
}
|
|
80
86
|
}
|
|
81
87
|
};
|
|
@@ -83,41 +89,41 @@ ${O}` : ""}`;
|
|
|
83
89
|
name: "@tolki/vite-plugin-laravel-ts-publish",
|
|
84
90
|
enforce: "pre",
|
|
85
91
|
configResolved(e) {
|
|
86
|
-
t = e, u =
|
|
87
|
-
q.resolve(t.root,
|
|
92
|
+
t = e, u = w(
|
|
93
|
+
q.resolve(t.root, z, x)
|
|
88
94
|
);
|
|
89
95
|
},
|
|
90
96
|
configureServer(e) {
|
|
91
|
-
|
|
97
|
+
l = e;
|
|
92
98
|
},
|
|
93
99
|
async buildStart() {
|
|
94
100
|
if (t.command === "build") {
|
|
95
101
|
if (T) {
|
|
96
|
-
let e = M && !
|
|
97
|
-
|
|
102
|
+
let e = M && !a.includes("--only-functional") ? `${a} --only-functional` : a;
|
|
103
|
+
v && !e.includes("--quiet") && (e += " --quiet"), await m(null, e);
|
|
98
104
|
}
|
|
99
105
|
return;
|
|
100
106
|
}
|
|
101
|
-
await b(),
|
|
107
|
+
await b(), S(), r.size > 0 && t.logger.info(
|
|
102
108
|
`${n} Watching ${r.size} PHP file${r.size === 1 ? "" : "s"} for changes`,
|
|
103
109
|
{ timestamp: !0 }
|
|
104
110
|
), P && await m();
|
|
105
111
|
},
|
|
106
112
|
async handleHotUpdate({ file: e }) {
|
|
107
|
-
const o =
|
|
113
|
+
const o = w(e);
|
|
108
114
|
if (o === u)
|
|
109
115
|
return t.logger.info(
|
|
110
116
|
`${n} Manifest changed, reloading watched files`,
|
|
111
117
|
{ timestamp: !0 }
|
|
112
|
-
), await b(),
|
|
118
|
+
), await b(), S(), [];
|
|
113
119
|
if (r.has(o)) {
|
|
114
|
-
const
|
|
115
|
-
return await m(
|
|
120
|
+
const i = r.get(o) ?? null;
|
|
121
|
+
return await m(i), [];
|
|
116
122
|
}
|
|
117
123
|
}
|
|
118
124
|
};
|
|
119
125
|
}
|
|
120
126
|
export {
|
|
121
|
-
|
|
122
|
-
|
|
127
|
+
_ as escapeShellArg,
|
|
128
|
+
X as laravelTsPublish
|
|
123
129
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tolki/ts",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
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",
|
|
@@ -39,13 +39,18 @@
|
|
|
39
39
|
"tolki"
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@tolki/enum": "^1.1.
|
|
43
|
-
"@tolki/types": "^1.
|
|
44
|
-
"@tolki/utils": "^1.6.
|
|
42
|
+
"@tolki/enum": "^1.1.4",
|
|
43
|
+
"@tolki/types": "^1.11.0",
|
|
44
|
+
"@tolki/utils": "^1.6.2"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"vite": "^7.0.0||^8.0.0"
|
|
48
48
|
},
|
|
49
|
+
"peerDependenciesMeta": {
|
|
50
|
+
"vite": {
|
|
51
|
+
"optional": true
|
|
52
|
+
}
|
|
53
|
+
},
|
|
49
54
|
"sideEffects": false,
|
|
50
55
|
"files": [
|
|
51
56
|
"dist"
|