@devwizard/vite-plugin-enumify 0.1.0 → 0.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
@@ -38,18 +38,18 @@ This plugin is package-manager agnostic and works with npm, pnpm, or yarn. The r
38
38
  Add the plugin to your `vite.config.ts`:
39
39
 
40
40
  ```ts
41
- import { defineConfig } from 'vite';
42
- import laravel from 'laravel-vite-plugin';
43
- import enumify from '@devwizard/vite-plugin-enumify';
41
+ import { defineConfig } from "vite";
42
+ import laravel from "laravel-vite-plugin";
43
+ import enumify from "@devwizard/vite-plugin-enumify";
44
44
 
45
45
  export default defineConfig({
46
- plugins: [
47
- enumify(),
48
- laravel({
49
- input: ['resources/js/app.ts'],
50
- refresh: true,
51
- }),
52
- ],
46
+ plugins: [
47
+ enumify(),
48
+ laravel({
49
+ input: ["resources/js/app.ts"],
50
+ refresh: true,
51
+ }),
52
+ ],
53
53
  });
54
54
  ```
55
55
 
@@ -63,23 +63,23 @@ export default defineConfig({
63
63
 
64
64
  ```ts
65
65
  enumify({
66
- // PHP binary path (default: "php")
67
- artisanBin: 'php',
66
+ // PHP binary path (default: "php")
67
+ artisanBin: "php",
68
68
 
69
- // Path to the artisan file (default: "artisan")
70
- artisanFile: 'artisan',
69
+ // Path to the artisan file (default: "artisan")
70
+ artisanFile: "artisan",
71
71
 
72
- // Command to run (default: "enumify:sync")
73
- syncCommand: 'enumify:sync',
72
+ // Command to run (default: "enumify:sync")
73
+ syncCommand: "enumify:sync",
74
74
 
75
- // Working directory (default: process.cwd())
76
- cwd: process.cwd(),
75
+ // Working directory (default: process.cwd())
76
+ cwd: process.cwd(),
77
77
 
78
- // Enable watch mode in development (default: runtime.watch from config/enumify.php)
79
- watch: true,
78
+ // Enable watch mode in development (default: runtime.watch from config/enumify.php)
79
+ watch: true,
80
80
 
81
- // Additional environment variables
82
- env: {},
81
+ // Additional environment variables
82
+ env: {},
83
83
  });
84
84
  ```
85
85
 
@@ -122,23 +122,23 @@ The plugin generates:
122
122
  ```ts
123
123
  // resources/js/enums/order-status.ts
124
124
  export enum OrderStatus {
125
- Pending = 'pending',
126
- Processing = 'processing',
127
- Shipped = 'shipped',
125
+ Pending = "pending",
126
+ Processing = "processing",
127
+ Shipped = "shipped",
128
128
  }
129
129
 
130
130
  export type OrderStatusValue = `${OrderStatus}`;
131
131
 
132
132
  export const OrderStatusLabels: Record<OrderStatus, string> = {
133
- [OrderStatus.Pending]: 'Pending',
134
- [OrderStatus.Processing]: 'Processing',
135
- [OrderStatus.Shipped]: 'Shipped',
133
+ [OrderStatus.Pending]: "Pending",
134
+ [OrderStatus.Processing]: "Processing",
135
+ [OrderStatus.Shipped]: "Shipped",
136
136
  };
137
137
 
138
138
  export const OrderStatusColors: Record<OrderStatus, string> = {
139
- [OrderStatus.Pending]: 'yellow',
140
- [OrderStatus.Processing]: 'blue',
141
- [OrderStatus.Shipped]: 'green',
139
+ [OrderStatus.Pending]: "yellow",
140
+ [OrderStatus.Processing]: "blue",
141
+ [OrderStatus.Shipped]: "green",
142
142
  };
143
143
  ```
144
144
 
package/dist/index.cjs CHANGED
@@ -52,7 +52,10 @@ function readEnumifyConfig(cwd) {
52
52
  }
53
53
  }
54
54
  function extractStringArray(contents, key) {
55
- const match = new RegExp(`['"]${key}['"]\\s*=>\\s*\\[([\\s\\S]*?)\\]`, "m").exec(contents);
55
+ const match = new RegExp(
56
+ `['"]${key}['"]\\s*=>\\s*\\[([\\s\\S]*?)\\]`,
57
+ "m"
58
+ ).exec(contents);
56
59
  if (!match) {
57
60
  return null;
58
61
  }
@@ -65,11 +68,16 @@ function extractStringArray(contents, key) {
65
68
  return items.length > 0 ? items : null;
66
69
  }
67
70
  function extractString(contents, key) {
68
- const match = new RegExp(`['"]${key}['"]\\s*=>\\s*['"]([^'"]+)['"]`, "m").exec(contents);
71
+ const match = new RegExp(
72
+ `['"]${key}['"]\\s*=>\\s*['"]([^'"]+)['"]`,
73
+ "m"
74
+ ).exec(contents);
69
75
  return match ? match[1] : null;
70
76
  }
71
77
  function extractBoolean(contents, key) {
72
- const match = new RegExp(`['"]${key}['"]\\s*=>\\s*(true|false)`, "mi").exec(contents);
78
+ const match = new RegExp(`['"]${key}['"]\\s*=>\\s*(true|false)`, "mi").exec(
79
+ contents
80
+ );
73
81
  if (!match) {
74
82
  return null;
75
83
  }
@@ -96,7 +104,9 @@ function debounce(fn, delay) {
96
104
  }
97
105
  function enumify(options = {}) {
98
106
  const { options: resolved, config } = resolveOptions(options);
99
- const enumDirs = config.enumPaths.map((enumPath) => toAbsolutePath(resolved.cwd, enumPath));
107
+ const enumDirs = config.enumPaths.map(
108
+ (enumPath) => toAbsolutePath(resolved.cwd, enumPath)
109
+ );
100
110
  const outputDir = toAbsolutePath(resolved.cwd, config.outputPath);
101
111
  let viteConfig = null;
102
112
  let logger = console;
@@ -104,7 +114,12 @@ function enumify(options = {}) {
104
114
  let rerunRequested = false;
105
115
  let initialSyncDone = false;
106
116
  const spawnSync = () => new Promise((resolve, reject) => {
107
- const args = [resolved.artisanFile, resolved.syncCommand, "--force", "--quiet"];
117
+ const args = [
118
+ resolved.artisanFile,
119
+ resolved.syncCommand,
120
+ "--force",
121
+ "--quiet"
122
+ ];
108
123
  const child = child_process.spawn(resolved.artisanBin, args, {
109
124
  cwd: resolved.cwd,
110
125
  env: { ...process.env, ...resolved.env },
@@ -128,12 +143,16 @@ function enumify(options = {}) {
128
143
  do {
129
144
  rerunRequested = false;
130
145
  await spawnSync();
131
- logger.info("[plugin @devwizard/vite-plugin-enumify] Enum types generated successfully");
146
+ logger.info(
147
+ "[plugin @devwizard/vite-plugin-enumify] Enum types generated successfully"
148
+ );
132
149
  } while (rerunRequested);
133
150
  running = false;
134
151
  };
135
152
  const debouncedSync = debounce(() => {
136
- runSync().catch((error) => logger.error(`[enumify] ${error.message}`));
153
+ runSync().catch(
154
+ (error) => logger.error(`[enumify] ${error.message}`)
155
+ );
137
156
  }, WATCH_DEBOUNCE_MS);
138
157
  return {
139
158
  name: "@devwizard/vite-plugin-enumify",
package/dist/index.mjs CHANGED
@@ -43,7 +43,10 @@ function readEnumifyConfig(cwd) {
43
43
  }
44
44
  }
45
45
  function extractStringArray(contents, key) {
46
- const match = new RegExp(`['"]${key}['"]\\s*=>\\s*\\[([\\s\\S]*?)\\]`, "m").exec(contents);
46
+ const match = new RegExp(
47
+ `['"]${key}['"]\\s*=>\\s*\\[([\\s\\S]*?)\\]`,
48
+ "m"
49
+ ).exec(contents);
47
50
  if (!match) {
48
51
  return null;
49
52
  }
@@ -56,11 +59,16 @@ function extractStringArray(contents, key) {
56
59
  return items.length > 0 ? items : null;
57
60
  }
58
61
  function extractString(contents, key) {
59
- const match = new RegExp(`['"]${key}['"]\\s*=>\\s*['"]([^'"]+)['"]`, "m").exec(contents);
62
+ const match = new RegExp(
63
+ `['"]${key}['"]\\s*=>\\s*['"]([^'"]+)['"]`,
64
+ "m"
65
+ ).exec(contents);
60
66
  return match ? match[1] : null;
61
67
  }
62
68
  function extractBoolean(contents, key) {
63
- const match = new RegExp(`['"]${key}['"]\\s*=>\\s*(true|false)`, "mi").exec(contents);
69
+ const match = new RegExp(`['"]${key}['"]\\s*=>\\s*(true|false)`, "mi").exec(
70
+ contents
71
+ );
64
72
  if (!match) {
65
73
  return null;
66
74
  }
@@ -87,7 +95,9 @@ function debounce(fn, delay) {
87
95
  }
88
96
  function enumify(options = {}) {
89
97
  const { options: resolved, config } = resolveOptions(options);
90
- const enumDirs = config.enumPaths.map((enumPath) => toAbsolutePath(resolved.cwd, enumPath));
98
+ const enumDirs = config.enumPaths.map(
99
+ (enumPath) => toAbsolutePath(resolved.cwd, enumPath)
100
+ );
91
101
  const outputDir = toAbsolutePath(resolved.cwd, config.outputPath);
92
102
  let viteConfig = null;
93
103
  let logger = console;
@@ -95,7 +105,12 @@ function enumify(options = {}) {
95
105
  let rerunRequested = false;
96
106
  let initialSyncDone = false;
97
107
  const spawnSync = () => new Promise((resolve, reject) => {
98
- const args = [resolved.artisanFile, resolved.syncCommand, "--force", "--quiet"];
108
+ const args = [
109
+ resolved.artisanFile,
110
+ resolved.syncCommand,
111
+ "--force",
112
+ "--quiet"
113
+ ];
99
114
  const child = spawn(resolved.artisanBin, args, {
100
115
  cwd: resolved.cwd,
101
116
  env: { ...process.env, ...resolved.env },
@@ -119,12 +134,16 @@ function enumify(options = {}) {
119
134
  do {
120
135
  rerunRequested = false;
121
136
  await spawnSync();
122
- logger.info("[plugin @devwizard/vite-plugin-enumify] Enum types generated successfully");
137
+ logger.info(
138
+ "[plugin @devwizard/vite-plugin-enumify] Enum types generated successfully"
139
+ );
123
140
  } while (rerunRequested);
124
141
  running = false;
125
142
  };
126
143
  const debouncedSync = debounce(() => {
127
- runSync().catch((error) => logger.error(`[enumify] ${error.message}`));
144
+ runSync().catch(
145
+ (error) => logger.error(`[enumify] ${error.message}`)
146
+ );
128
147
  }, WATCH_DEBOUNCE_MS);
129
148
  return {
130
149
  name: "@devwizard/vite-plugin-enumify",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devwizard/vite-plugin-enumify",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Vite plugin for Laravel Enumify - auto-sync PHP enums to TypeScript",
5
5
  "keywords": [
6
6
  "vite",
@@ -20,13 +20,13 @@
20
20
  "type": "github",
21
21
  "url": "https://github.com/sponsors/DevWizardHQ"
22
22
  },
23
- "homepage": "https://github.com/devwizardhq/vite-plugin-enumify#readme",
23
+ "homepage": "https://github.com/DevWizardHQ/vite-plugin-enumify#readme",
24
24
  "repository": {
25
25
  "type": "git",
26
- "url": "git+https://github.com/devwizardhq/vite-plugin-enumify.git"
26
+ "url": "git+https://github.com/DevWizardHQ/vite-plugin-enumify.git"
27
27
  },
28
28
  "bugs": {
29
- "url": "https://github.com/devwizardhq/vite-plugin-enumify/issues"
29
+ "url": "https://github.com/DevWizardHQ/vite-plugin-enumify/issues"
30
30
  },
31
31
  "scripts": {
32
32
  "prepublishOnly": "npm run build",