@tolki/enum 1.0.1 → 1.1.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 +6 -4
- package/dist/enums.d.ts +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -5
- package/dist/php-enums.d.ts +8 -0
- package/dist/php-enums.d.ts.map +1 -0
- package/dist/php-enums.js +10 -0
- package/dist/vite-plugin.d.ts +5 -3
- package/dist/vite-plugin.d.ts.map +1 -1
- package/dist/vite-plugin.js +55 -51
- package/package.json +5 -9
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
|
|
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
|
|
269
|
-
*
|
|
270
|
-
*
|
|
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 '
|
|
1
|
+
import { AsEnum, CaseValue, DefineEnumResult, EnumConst, FromResult } from '../packages/types/src/index.ts';
|
|
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()`
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { cases as
|
|
1
|
+
import { cases as e, defineEnum as m, from as t, tryFrom as f } from "./enums.js";
|
|
2
|
+
import { SortDirection as n } from "./php-enums.js";
|
|
2
3
|
export {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
n as SortDirection,
|
|
5
|
+
e as cases,
|
|
6
|
+
m as defineEnum,
|
|
7
|
+
t as from,
|
|
8
|
+
f as tryFrom
|
|
7
9
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DefineEnumResult } from '../packages/ts/src/index.ts';
|
|
2
|
+
export declare const SortDirection: DefineEnumResult<{
|
|
3
|
+
readonly Ascending: "Ascending";
|
|
4
|
+
readonly Descending: "Descending";
|
|
5
|
+
readonly backed: false;
|
|
6
|
+
readonly _cases: readonly ["Ascending", "Descending"];
|
|
7
|
+
}>;
|
|
8
|
+
//# sourceMappingURL=php-enums.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"php-enums.d.ts","sourceRoot":"","sources":["../src/php-enums.ts"],"names":[],"mappings":";AAEA,eAAO,MAAM,aAAa;;;;;EAKf,CAAC"}
|
package/dist/vite-plugin.d.ts
CHANGED
|
@@ -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
|
|
94
|
-
*
|
|
95
|
-
*
|
|
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
|
|
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"}
|
package/dist/vite-plugin.js
CHANGED
|
@@ -1,71 +1,75 @@
|
|
|
1
|
-
import { exec as
|
|
2
|
-
import { readFile as
|
|
3
|
-
import
|
|
4
|
-
import { promisify as
|
|
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
|
|
7
|
-
function
|
|
6
|
+
const B = A(W);
|
|
7
|
+
function U(q = {}) {
|
|
8
8
|
const {
|
|
9
|
-
command:
|
|
10
|
-
filename:
|
|
11
|
-
directory:
|
|
12
|
-
runOnDevStart:
|
|
13
|
-
runOnBuildStart:
|
|
14
|
-
reload:
|
|
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:
|
|
17
|
+
onBuildOnlyEnums: M = !0,
|
|
18
18
|
quiet: w = !0
|
|
19
|
-
} =
|
|
20
|
-
let
|
|
21
|
-
const
|
|
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]",
|
|
24
|
-
|
|
23
|
+
const f = [], n = "[laravel-ts-publish]", $ = async () => {
|
|
24
|
+
r.clear();
|
|
25
25
|
try {
|
|
26
|
-
const e = await
|
|
26
|
+
const e = await k(u, "utf-8"), o = JSON.parse(e);
|
|
27
27
|
for (const c of o) {
|
|
28
|
-
const
|
|
29
|
-
|
|
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
|
-
|
|
33
|
+
t.logger.warn(
|
|
34
34
|
`${n} Manifest not found: ${u}`
|
|
35
35
|
);
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
|
-
|
|
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
|
|
44
|
+
for (const e of r.keys())
|
|
45
45
|
l.watcher.add(e);
|
|
46
|
-
},
|
|
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
|
|
53
|
-
w && !
|
|
52
|
+
let i = e && y ? y.replaceAll("{file}", e) : o ?? a;
|
|
53
|
+
w && !i.includes("--quiet") && (i += " --quiet");
|
|
54
54
|
try {
|
|
55
|
-
|
|
55
|
+
t.logger.info(`${n} Running: ${i}`, {
|
|
56
56
|
timestamp: !0
|
|
57
|
-
}), await
|
|
57
|
+
}), await B(i, { cwd: t.root }), t.logger.info(`${n} Types published successfully`, {
|
|
58
58
|
timestamp: !0
|
|
59
|
-
}),
|
|
60
|
-
} catch (
|
|
61
|
-
const b =
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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
|
|
68
|
-
await d(
|
|
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
|
-
|
|
77
|
-
|
|
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 (
|
|
85
|
-
if (
|
|
86
|
-
let e =
|
|
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
|
|
92
|
-
`${n} Watching ${
|
|
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
|
-
),
|
|
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
|
|
103
|
+
return t.logger.info(
|
|
100
104
|
`${n} Manifest changed, reloading watched files`,
|
|
101
105
|
{ timestamp: !0 }
|
|
102
|
-
), await
|
|
103
|
-
if (
|
|
104
|
-
const c =
|
|
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
|
-
|
|
115
|
+
U as laravelTsPublish
|
|
112
116
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tolki/enum",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
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",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"schemaVersion": 1,
|
|
19
19
|
"vite": {
|
|
20
20
|
"type": "compatible",
|
|
21
|
-
"versions": "^7.0.0"
|
|
21
|
+
"versions": "^8.0.0||^7.0.0"
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"main": "dist/index.js",
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
"tolki"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@tolki/types": "^1.
|
|
40
|
+
"@tolki/types": "^1.4.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"vite": "^7.0.0"
|
|
43
|
+
"vite": "^8.0.0||^7.0.0"
|
|
44
44
|
},
|
|
45
45
|
"sideEffects": false,
|
|
46
46
|
"files": [
|
|
@@ -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",
|