@hybridly/vite 0.4.4 → 0.5.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/dist/index.cjs CHANGED
@@ -7,7 +7,6 @@ const path = require('node:path');
7
7
  const fs = require('node:fs');
8
8
  const makeDebugger = require('debug');
9
9
  const localPkg = require('local-pkg');
10
- const node_util = require('node:util');
11
10
  const node_child_process = require('node:child_process');
12
11
  const run = require('vite-plugin-run');
13
12
  const utils = require('@hybridly/utils');
@@ -68,7 +67,7 @@ function generateTsConfig(options, config) {
68
67
  types: [
69
68
  "vite/client",
70
69
  "hybridly/client",
71
- ...options.icons !== false && isPackageInstalled("unplugin-icons") ? ["unplugin-icons/types/vue"] : []
70
+ ...options.icons !== false ? ["unplugin-icons/types/vue"] : []
72
71
  ],
73
72
  baseUrl: "..",
74
73
  paths: {
@@ -166,12 +165,11 @@ function write(data, filename) {
166
165
  });
167
166
  }
168
167
 
169
- const shell = node_util.promisify(node_child_process.exec);
170
168
  async function loadConfiguration(options) {
171
169
  try {
172
170
  const php = options.php ?? process.env.PHP_EXECUTABLE_PATH ?? "php";
173
- const { stdout } = await shell(`${php} artisan hybridly:config`);
174
- return JSON.parse(stdout);
171
+ const stdout = node_child_process.execSync(`${php} artisan hybridly:config`);
172
+ return JSON.parse(stdout.toString("utf-8"));
175
173
  } catch (e) {
176
174
  console.error("Could not load configuration from [php artisan].");
177
175
  throw e;
@@ -233,9 +231,9 @@ const initialize = (options, config) => {
233
231
  }
234
232
  if (/.*\.vue$/.test(file)) {
235
233
  const updatedConfig = await loadConfiguration(options);
236
- const pagesOrLayoutsChanged = didPagesOrLayoutsChange(updatedConfig, config);
237
- if (pagesOrLayoutsChanged) {
238
- return await forceRestart("Page or layout changed");
234
+ const viewsOrLayoutsChanged = didViewsOrLayoutsChange(updatedConfig, config);
235
+ if (viewsOrLayoutsChanged) {
236
+ return await forceRestart("View or layout changed");
239
237
  }
240
238
  }
241
239
  }
@@ -261,7 +259,7 @@ const initialize = (options, config) => {
261
259
  }
262
260
  };
263
261
  };
264
- function didPagesOrLayoutsChange(updatedConfig, previousConfig) {
262
+ function didViewsOrLayoutsChange(updatedConfig, previousConfig) {
265
263
  if (!previousConfig) {
266
264
  return false;
267
265
  }
@@ -351,6 +349,8 @@ const HybridlyImports = {
351
349
  "useProperty",
352
350
  "setProperty",
353
351
  "useRefinements",
352
+ "useTable",
353
+ "useBulkSelect",
354
354
  "useProperties",
355
355
  "useBackForward",
356
356
  "useContext",
@@ -374,6 +374,18 @@ function getAutoImportsOptions(options, config) {
374
374
  return;
375
375
  }
376
376
  const presets = ["@vueuse/core", "@vueuse/head", "vue-i18n"];
377
+ const custom = {
378
+ "@unhead/vue": [
379
+ "useHead",
380
+ "useSeoMeta"
381
+ ],
382
+ "@innocenzi/utils": [
383
+ "match",
384
+ "invoke",
385
+ "batchInvoke",
386
+ "asyncInvoke"
387
+ ]
388
+ };
377
389
  return utils.merge(
378
390
  {
379
391
  vueTemplate: true,
@@ -387,6 +399,7 @@ function getAutoImportsOptions(options, config) {
387
399
  "vue",
388
400
  "vue/macros",
389
401
  ...presets.filter((pkg) => isPackageInstalled(pkg)),
402
+ ...Object.entries(custom).filter(([pkg]) => isPackageInstalled(pkg)).map(([pkg, imports]) => ({ [pkg]: imports })),
390
403
  HybridlyImports
391
404
  ]
392
405
  },
@@ -496,6 +509,34 @@ function getVueOptions(options) {
496
509
  );
497
510
  }
498
511
 
512
+ function killSwitch() {
513
+ let _enabled = false;
514
+ return {
515
+ name: "hybridly:build:kill-switch",
516
+ config: ({ mode }) => {
517
+ if (mode === "build") {
518
+ _enabled = true;
519
+ }
520
+ },
521
+ buildEnd: (error) => {
522
+ if (!_enabled) {
523
+ return;
524
+ }
525
+ if (error) {
526
+ console.error("Error when bundling");
527
+ console.error(error);
528
+ process.exit(1);
529
+ }
530
+ },
531
+ closeBundle: () => {
532
+ if (!_enabled) {
533
+ return;
534
+ }
535
+ process.exit(0);
536
+ }
537
+ };
538
+ }
539
+
499
540
  async function plugin(options = {}) {
500
541
  const config = await loadConfiguration(options);
501
542
  return [
@@ -506,7 +547,8 @@ async function plugin(options = {}) {
506
547
  options.vueComponents !== false && vueComponents__default(getVueComponentsOptions(options, config)),
507
548
  options.autoImports !== false && autoimport__default(getAutoImportsOptions(options, config)),
508
549
  options.icons !== false && icons__default(getIconsOptions(options, config)),
509
- options.vue !== false && vue__default(getVueOptions(options))
550
+ options.vue !== false && vue__default(getVueOptions(options)),
551
+ options.killSwitch !== false && killSwitch()
510
552
  ];
511
553
  }
512
554
 
package/dist/index.d.cts CHANGED
@@ -66,6 +66,8 @@ interface ViteOptions {
66
66
  overrideResolvers?: CustomResolvers;
67
67
  /** Whether to write shims. */
68
68
  shims?: boolean;
69
+ /** Enables or disable the kill-switch. */
70
+ killSwitch?: boolean;
69
71
  }
70
72
  interface LayoutOptions {
71
73
  /** Custom RegExp for parsing the template string. */
package/dist/index.d.mts CHANGED
@@ -66,6 +66,8 @@ interface ViteOptions {
66
66
  overrideResolvers?: CustomResolvers;
67
67
  /** Whether to write shims. */
68
68
  shims?: boolean;
69
+ /** Enables or disable the kill-switch. */
70
+ killSwitch?: boolean;
69
71
  }
70
72
  interface LayoutOptions {
71
73
  /** Custom RegExp for parsing the template string. */
package/dist/index.d.ts CHANGED
@@ -66,6 +66,8 @@ interface ViteOptions {
66
66
  overrideResolvers?: CustomResolvers;
67
67
  /** Whether to write shims. */
68
68
  shims?: boolean;
69
+ /** Enables or disable the kill-switch. */
70
+ killSwitch?: boolean;
69
71
  }
70
72
  interface LayoutOptions {
71
73
  /** Custom RegExp for parsing the template string. */
package/dist/index.mjs CHANGED
@@ -3,8 +3,7 @@ import path from 'node:path';
3
3
  import fs from 'node:fs';
4
4
  import makeDebugger from 'debug';
5
5
  import { isPackageExists } from 'local-pkg';
6
- import { promisify } from 'node:util';
7
- import { exec } from 'node:child_process';
6
+ import { execSync } from 'node:child_process';
8
7
  import run from 'vite-plugin-run';
9
8
  import { merge } from '@hybridly/utils';
10
9
  import autoimport from 'unplugin-auto-import/vite';
@@ -51,7 +50,7 @@ function generateTsConfig(options, config) {
51
50
  types: [
52
51
  "vite/client",
53
52
  "hybridly/client",
54
- ...options.icons !== false && isPackageInstalled("unplugin-icons") ? ["unplugin-icons/types/vue"] : []
53
+ ...options.icons !== false ? ["unplugin-icons/types/vue"] : []
55
54
  ],
56
55
  baseUrl: "..",
57
56
  paths: {
@@ -149,12 +148,11 @@ function write(data, filename) {
149
148
  });
150
149
  }
151
150
 
152
- const shell = promisify(exec);
153
151
  async function loadConfiguration(options) {
154
152
  try {
155
153
  const php = options.php ?? process.env.PHP_EXECUTABLE_PATH ?? "php";
156
- const { stdout } = await shell(`${php} artisan hybridly:config`);
157
- return JSON.parse(stdout);
154
+ const stdout = execSync(`${php} artisan hybridly:config`);
155
+ return JSON.parse(stdout.toString("utf-8"));
158
156
  } catch (e) {
159
157
  console.error("Could not load configuration from [php artisan].");
160
158
  throw e;
@@ -216,9 +214,9 @@ const initialize = (options, config) => {
216
214
  }
217
215
  if (/.*\.vue$/.test(file)) {
218
216
  const updatedConfig = await loadConfiguration(options);
219
- const pagesOrLayoutsChanged = didPagesOrLayoutsChange(updatedConfig, config);
220
- if (pagesOrLayoutsChanged) {
221
- return await forceRestart("Page or layout changed");
217
+ const viewsOrLayoutsChanged = didViewsOrLayoutsChange(updatedConfig, config);
218
+ if (viewsOrLayoutsChanged) {
219
+ return await forceRestart("View or layout changed");
222
220
  }
223
221
  }
224
222
  }
@@ -244,7 +242,7 @@ const initialize = (options, config) => {
244
242
  }
245
243
  };
246
244
  };
247
- function didPagesOrLayoutsChange(updatedConfig, previousConfig) {
245
+ function didViewsOrLayoutsChange(updatedConfig, previousConfig) {
248
246
  if (!previousConfig) {
249
247
  return false;
250
248
  }
@@ -334,6 +332,8 @@ const HybridlyImports = {
334
332
  "useProperty",
335
333
  "setProperty",
336
334
  "useRefinements",
335
+ "useTable",
336
+ "useBulkSelect",
337
337
  "useProperties",
338
338
  "useBackForward",
339
339
  "useContext",
@@ -357,6 +357,18 @@ function getAutoImportsOptions(options, config) {
357
357
  return;
358
358
  }
359
359
  const presets = ["@vueuse/core", "@vueuse/head", "vue-i18n"];
360
+ const custom = {
361
+ "@unhead/vue": [
362
+ "useHead",
363
+ "useSeoMeta"
364
+ ],
365
+ "@innocenzi/utils": [
366
+ "match",
367
+ "invoke",
368
+ "batchInvoke",
369
+ "asyncInvoke"
370
+ ]
371
+ };
360
372
  return merge(
361
373
  {
362
374
  vueTemplate: true,
@@ -370,6 +382,7 @@ function getAutoImportsOptions(options, config) {
370
382
  "vue",
371
383
  "vue/macros",
372
384
  ...presets.filter((pkg) => isPackageInstalled(pkg)),
385
+ ...Object.entries(custom).filter(([pkg]) => isPackageInstalled(pkg)).map(([pkg, imports]) => ({ [pkg]: imports })),
373
386
  HybridlyImports
374
387
  ]
375
388
  },
@@ -479,6 +492,34 @@ function getVueOptions(options) {
479
492
  );
480
493
  }
481
494
 
495
+ function killSwitch() {
496
+ let _enabled = false;
497
+ return {
498
+ name: "hybridly:build:kill-switch",
499
+ config: ({ mode }) => {
500
+ if (mode === "build") {
501
+ _enabled = true;
502
+ }
503
+ },
504
+ buildEnd: (error) => {
505
+ if (!_enabled) {
506
+ return;
507
+ }
508
+ if (error) {
509
+ console.error("Error when bundling");
510
+ console.error(error);
511
+ process.exit(1);
512
+ }
513
+ },
514
+ closeBundle: () => {
515
+ if (!_enabled) {
516
+ return;
517
+ }
518
+ process.exit(0);
519
+ }
520
+ };
521
+ }
522
+
482
523
  async function plugin(options = {}) {
483
524
  const config = await loadConfiguration(options);
484
525
  return [
@@ -489,7 +530,8 @@ async function plugin(options = {}) {
489
530
  options.vueComponents !== false && vueComponents(getVueComponentsOptions(options, config)),
490
531
  options.autoImports !== false && autoimport(getAutoImportsOptions(options, config)),
491
532
  options.icons !== false && icons(getIconsOptions(options, config)),
492
- options.vue !== false && vue(getVueOptions(options))
533
+ options.vue !== false && vue(getVueOptions(options)),
534
+ options.killSwitch !== false && killSwitch()
493
535
  ];
494
536
  }
495
537
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hybridly/vite",
3
- "version": "0.4.4",
3
+ "version": "0.5.0",
4
4
  "description": "Vite plugin for Hybridly",
5
5
  "keywords": [
6
6
  "hybridly",
@@ -40,20 +40,20 @@
40
40
  "vue": "^3.2.45"
41
41
  },
42
42
  "dependencies": {
43
- "@vitejs/plugin-vue": "^4.3.3",
43
+ "@vitejs/plugin-vue": "^4.3.4",
44
44
  "fast-glob": "^3.3.1",
45
- "laravel-vite-plugin": "^0.8.0",
45
+ "laravel-vite-plugin": "^0.8.1",
46
46
  "local-pkg": "^0.4.3",
47
47
  "throttle-debounce": "^5.0.0",
48
48
  "unplugin-auto-import": "^0.16.6",
49
- "unplugin-icons": "^0.16.6",
50
- "unplugin-vue-components": "^0.25.1",
51
- "vite-plugin-run": "^0.4.1",
52
- "@hybridly/core": "0.4.4"
49
+ "unplugin-icons": "^0.17.0",
50
+ "unplugin-vue-components": "^0.25.2",
51
+ "vite-plugin-run": "^0.5.1",
52
+ "@hybridly/core": "0.5.0"
53
53
  },
54
54
  "devDependencies": {
55
- "@iconify/json": "^2.2.107",
56
- "rollup": "^3.28.1",
55
+ "@iconify/json": "^2.2.120",
56
+ "rollup": "^3.29.3",
57
57
  "vite": "^4.4.9",
58
58
  "vue": "^3.3.4"
59
59
  },