virmator 7.0.0 → 7.0.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.
@@ -5,7 +5,10 @@ export const ncuConfig: RunOptions = {
5
5
  upgrade: true,
6
6
  root: true,
7
7
  // exclude these
8
- reject: [],
8
+ reject: [
9
+ /** Not ready for v3. */
10
+ 'prettier',
11
+ ],
9
12
  // include only these
10
13
  filter: [],
11
14
  };
@@ -7,5 +7,4 @@ export declare function alwaysReloadPlugin(config?: Partial<{
7
7
  exclusions: string[];
8
8
  /** Inclusions apply after exclusions so they will override exclusions. */
9
9
  inclusions: string[];
10
- root: string;
11
10
  }>): PluginOption;
@@ -36,16 +36,25 @@ function alwaysReloadPlugin(config = {}) {
36
36
  name: 'alwaysReloadPlugin',
37
37
  apply: 'serve',
38
38
  config: () => ({ server: { watch: { disableGlobbing: false } } }),
39
- configureServer({ watcher, ws, config: { logger } }) {
40
- const { root = process.cwd(), inclusions = [], exclusions = [] } = config;
39
+ handleHotUpdate() {
40
+ return [];
41
+ },
42
+ configureServer({ watcher, ws, config: { logger, publicDir = '', root = process.cwd() } }) {
43
+ const { inclusions = [], exclusions = [] } = config;
41
44
  let callingAlready = false;
42
- let loggedAlready = false;
43
- const reloadCallback = (path) => {
44
- if (!loggedAlready) {
45
- loggedAlready = true;
46
- // log watched stuff so that we can make sure it's not watching too much
47
- // console.info({watched: watcher.getWatched()});
45
+ const oldInfoLog = logger.info;
46
+ function customInfoLog(message, options) {
47
+ /**
48
+ * Ignore vite's built-in extra page reload logging as this will duplicate our
49
+ * messages.
50
+ */
51
+ if (message.startsWith('page reload')) {
52
+ return;
48
53
  }
54
+ oldInfoLog(message, options);
55
+ }
56
+ logger.info = customInfoLog;
57
+ function reloadCallback(path) {
49
58
  // prevent duplicate calls cause the watcher is very eager to call callbacks multiple times in a row
50
59
  if (!callingAlready) {
51
60
  callingAlready = true;
@@ -53,28 +62,38 @@ function alwaysReloadPlugin(config = {}) {
53
62
  type: 'full-reload',
54
63
  path: '*',
55
64
  });
56
- logger.info(`${node_js_1.logColors.success}page reload ${node_js_1.logColors.faint}${(0, path_1.relative)(root, path)}${node_js_1.logColors.reset}`, { clear: true, timestamp: true });
65
+ logger.info(`${node_js_1.logColors.success}page reload ${node_js_1.logColors.faint}${(0, path_1.relative)(process.cwd(), path)}${node_js_1.logColors.reset}`, {
66
+ clear: true,
67
+ timestamp: true,
68
+ });
57
69
  /**
58
- * Debounce reloads calls so that they don't get spammed. If you're saving
59
- * faster than this, then what the heck are you doing anyway?
70
+ * Debounce reloads calls so that they don't get spammed. If you're actually
71
+ * intentionally saving faster than this, then what the heck are you doing?
60
72
  */
61
73
  setTimeout(() => {
62
74
  callingAlready = false;
63
75
  }, 100);
64
76
  }
65
- };
77
+ }
78
+ watcher.add(root);
66
79
  if (exclusions.length) {
67
80
  watcher.unwatch(mapToActualPaths(exclusions));
68
- // ignore macOS file system metadata stuff
69
81
  }
82
+ // ignore macOS file system metadata stuff
70
83
  watcher.unwatch('./**/.DS_Store');
71
84
  if (inclusions.length) {
72
- watcher.add(inclusions);
85
+ watcher.add(mapToActualPaths(inclusions));
86
+ }
87
+ if (publicDir) {
88
+ watcher.add(publicDir);
73
89
  }
74
90
  if (!watcher.listeners('change').includes(reloadCallback)) {
75
91
  watcher.on('change', reloadCallback);
76
92
  watcher.on('add', reloadCallback);
93
+ watcher.on('unlink', reloadCallback);
77
94
  }
95
+ // // for debugging. Note that this isn't actually reliable, test the actual reloads.
96
+ // console.info({watched: watcher.getWatched()});
78
97
  },
79
98
  };
80
99
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "virmator",
3
- "version": "7.0.0",
3
+ "version": "7.0.2",
4
4
  "description": "Handle common package configs, commands, and dependencies.",
5
5
  "keywords": [
6
6
  "automation",