@tolki/ts 1.0.4 → 1.1.0
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 +550 -139
- package/dist/enums.d.ts +1 -1
- package/dist/enums.d.ts.map +1 -1
- package/dist/enums.js +1 -7
- package/dist/index.js +3 -16
- package/dist/routes.js +201 -258
- package/dist/vite-plugin.js +76 -127
- package/package.json +7 -4
package/dist/vite-plugin.js
CHANGED
|
@@ -1,129 +1,78 @@
|
|
|
1
|
-
import { exec as
|
|
2
|
-
import { readFile as
|
|
3
|
-
import
|
|
4
|
-
import { promisify as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function
|
|
10
|
-
|
|
1
|
+
import { exec as e } from "node:child_process";
|
|
2
|
+
import { readFile as t } from "node:fs/promises";
|
|
3
|
+
import n from "node:path";
|
|
4
|
+
import { promisify as r } from "node:util";
|
|
5
|
+
import { escapeShellArg as i, escapeWindowsShellArg as a } from "@tolki/utils";
|
|
6
|
+
import { normalizePath as o } from "vite";
|
|
7
|
+
// src/vite-plugin.ts
|
|
8
|
+
var s = r(e);
|
|
9
|
+
function c(e) {
|
|
10
|
+
return process.platform === "win32" ? a(e) : i(e);
|
|
11
11
|
}
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
${C}` : ""}`;
|
|
78
|
-
if (W())
|
|
79
|
-
throw new Error(E, { cause: s });
|
|
80
|
-
t.logger.error(E);
|
|
81
|
-
} finally {
|
|
82
|
-
if (p = !1, d.length > 0) {
|
|
83
|
-
const s = d.shift();
|
|
84
|
-
await m(s);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
return {
|
|
89
|
-
name: "@tolki/vite-plugin-laravel-ts-publish",
|
|
90
|
-
enforce: "pre",
|
|
91
|
-
configResolved(e) {
|
|
92
|
-
t = e, u = w(
|
|
93
|
-
q.resolve(t.root, z, x)
|
|
94
|
-
);
|
|
95
|
-
},
|
|
96
|
-
configureServer(e) {
|
|
97
|
-
l = e;
|
|
98
|
-
},
|
|
99
|
-
async buildStart() {
|
|
100
|
-
if (t.command === "build") {
|
|
101
|
-
if (T) {
|
|
102
|
-
let e = M && !a.includes("--only-functional") ? `${a} --only-functional` : a;
|
|
103
|
-
v && !e.includes("--quiet") && (e += " --quiet"), await m(null, e);
|
|
104
|
-
}
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
await b(), S(), r.size > 0 && t.logger.info(
|
|
108
|
-
`${n} Watching ${r.size} PHP file${r.size === 1 ? "" : "s"} for changes`,
|
|
109
|
-
{ timestamp: !0 }
|
|
110
|
-
), P && await m();
|
|
111
|
-
},
|
|
112
|
-
async handleHotUpdate({ file: e }) {
|
|
113
|
-
const o = w(e);
|
|
114
|
-
if (o === u)
|
|
115
|
-
return t.logger.info(
|
|
116
|
-
`${n} Manifest changed, reloading watched files`,
|
|
117
|
-
{ timestamp: !0 }
|
|
118
|
-
), await b(), S(), [];
|
|
119
|
-
if (r.has(o)) {
|
|
120
|
-
const i = r.get(o) ?? null;
|
|
121
|
-
return await m(i), [];
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
};
|
|
12
|
+
function l(e = {}) {
|
|
13
|
+
let { command: r = "php artisan ts:publish", filename: i = "laravel-ts-collected-files.json", directory: a = "resources/js/types/data/", runOnDevStart: l = !1, runOnBuildStart: u = !0, reload: d = !0, failOnError: f, sourceCommand: p, onBuildOnlyFunctional: m = !0, quiet: h = !0 } = e, g = p === !1 ? !1 : p ?? `${r} --source={file}`, _, v, y = /* @__PURE__ */ new Map(), b = "", x = !1, S = [], C = "[laravel-ts-publish]", w = async () => {
|
|
14
|
+
y.clear();
|
|
15
|
+
try {
|
|
16
|
+
let e = await t(b, "utf-8"), r = JSON.parse(e);
|
|
17
|
+
for (let e of r) {
|
|
18
|
+
let t = o(n.resolve(_.root, e));
|
|
19
|
+
y.set(t, e);
|
|
20
|
+
}
|
|
21
|
+
} catch (e) {
|
|
22
|
+
if (e instanceof Error && e.code === "ENOENT") {
|
|
23
|
+
_.logger.warn(`${C} Manifest not found: ${b}`);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
_.logger.error(`${C} Failed to read manifest: ${e instanceof Error ? e.message : String(e)}`);
|
|
27
|
+
}
|
|
28
|
+
}, T = () => {
|
|
29
|
+
if (v) for (let e of y.keys()) v.watcher.add(e);
|
|
30
|
+
}, E = () => f === void 0 ? _.command === "build" : f, D = async (e = null, t) => {
|
|
31
|
+
if (x) {
|
|
32
|
+
S.includes(e) || S.push(e);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
x = !0;
|
|
36
|
+
let n = t ?? r, i = e && g ? g : n, a = e && g ? g.replaceAll("{file}", () => c(e)) : n;
|
|
37
|
+
h && !i.includes("--quiet") && (a += " --quiet");
|
|
38
|
+
try {
|
|
39
|
+
_.logger.info(`${C} Running: ${a}`, { timestamp: !0 }), await s(a, { cwd: _.root }), _.logger.info(`${C} Types published successfully`, { timestamp: !0 }), d && v && v.ws.send({ type: "full-reload" });
|
|
40
|
+
} catch (e) {
|
|
41
|
+
let t = e instanceof Error ? e.message : String(e), { stdout: n, stderr: r } = e, i = [r?.trim(), n?.trim()].filter((e) => !!e && !t.includes(e)).join("\n"), a = `${C} Command failed: ${t}${i ? `\n${i}` : ""}`;
|
|
42
|
+
if (E()) throw Error(a, { cause: e });
|
|
43
|
+
_.logger.error(a);
|
|
44
|
+
} finally {
|
|
45
|
+
if (x = !1, S.length > 0) {
|
|
46
|
+
let e = S.shift();
|
|
47
|
+
await D(e);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
return {
|
|
52
|
+
name: "@tolki/vite-plugin-laravel-ts-publish",
|
|
53
|
+
enforce: "pre",
|
|
54
|
+
configResolved(e) {
|
|
55
|
+
_ = e, b = o(n.resolve(_.root, a, i));
|
|
56
|
+
},
|
|
57
|
+
configureServer(e) {
|
|
58
|
+
v = e;
|
|
59
|
+
},
|
|
60
|
+
async buildStart() {
|
|
61
|
+
if (_.command === "build") {
|
|
62
|
+
if (u) {
|
|
63
|
+
let e = m && !r.includes("--only-functional") ? `${r} --only-functional` : r;
|
|
64
|
+
h && !e.includes("--quiet") && (e += " --quiet"), await D(null, e);
|
|
65
|
+
}
|
|
66
|
+
} else await w(), T(), y.size > 0 && _.logger.info(`${C} Watching ${y.size} PHP file${y.size === 1 ? "" : "s"} for changes`, { timestamp: !0 }), l && await D();
|
|
67
|
+
},
|
|
68
|
+
async handleHotUpdate({ file: e }) {
|
|
69
|
+
let t = o(e);
|
|
70
|
+
if (t === b) return _.logger.info(`${C} Manifest changed, reloading watched files`, { timestamp: !0 }), await w(), T(), [];
|
|
71
|
+
if (y.has(t)) {
|
|
72
|
+
let e = y.get(t) ?? null;
|
|
73
|
+
return await D(e), [];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
};
|
|
125
77
|
}
|
|
126
|
-
export {
|
|
127
|
-
_ as escapeShellArg,
|
|
128
|
-
X as laravelTsPublish
|
|
129
|
-
};
|
|
78
|
+
export { i as escapeShellArg, l as laravelTsPublish };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tolki/ts",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
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,9 +39,12 @@
|
|
|
39
39
|
"tolki"
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@tolki/enum": "^1.
|
|
43
|
-
"@tolki/types": "^1.
|
|
44
|
-
"@tolki/utils": "^1.6.
|
|
42
|
+
"@tolki/enum": "^1.2.0",
|
|
43
|
+
"@tolki/types": "^1.12.0",
|
|
44
|
+
"@tolki/utils": "^1.6.3"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"vite": "^8.3.5"
|
|
45
48
|
},
|
|
46
49
|
"peerDependencies": {
|
|
47
50
|
"vite": "^7.0.0||^8.0.0"
|