virmator 4.2.6 → 4.2.9

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.
@@ -1,8 +1,6 @@
1
- import baseConfig from 'virmator/base-configs/base-vite';
2
- import {UserConfig} from 'vite';
1
+ import {baseViteConfig} from 'virmator/dist/compiled-base-configs/base-vite';
2
+ import {defineConfig} from 'vite';
3
3
 
4
- const viteConfig: UserConfig = {
5
- ...baseConfig,
6
- };
7
-
8
- export default viteConfig;
4
+ export default defineConfig({
5
+ ...baseViteConfig,
6
+ });
@@ -7,6 +7,7 @@
7
7
  "compile": "rm -rf dist && virmator compile",
8
8
  "docs:update": "virmator code-in-markdown",
9
9
  "format": "virmator format",
10
+ "prepack": "npm run compile",
10
11
  "prepublishOnly": "npm run compile && npm run test:all",
11
12
  "preview": "virmator frontend preview",
12
13
  "spellcheck": "virmator spellcheck",
@@ -1,5 +1,5 @@
1
1
  {
2
- "extends": "./node_modules/virmator/base-configs/base-tsconfig.json",
2
+ "extends": "virmator/base-configs/base-tsconfig.json",
3
3
  "compilerOptions": {
4
4
  "outDir": "./dist",
5
5
  "rootDir": "./src"
@@ -9,7 +9,7 @@ var HelpMessageSyntax;
9
9
  HelpMessageSyntax["Markdown"] = "markdown";
10
10
  })(HelpMessageSyntax = exports.HelpMessageSyntax || (exports.HelpMessageSyntax = {}));
11
11
  function generateHelpMessage(packageBinName, commandDefinitions, syntax, cliWrapIfMoreThanThisManyColumns = 100) {
12
- const commandsMessage = (0, augment_vir_1.getObjectTypedKeys)(commandDefinitions)
12
+ const commandsMessage = [...(0, augment_vir_1.getObjectTypedKeys)(commandDefinitions)]
13
13
  .sort()
14
14
  .map((commandName) => {
15
15
  const commandDefinition = commandDefinitions[commandName];
@@ -6,7 +6,7 @@ export declare type DefineCommandInputs<CommandName extends string = string> = R
6
6
  npmDeps: ReadonlyArray<string>;
7
7
  }>;
8
8
  export declare type SharedExecutorInputsAndCommandDefinition<DefineCommandInputsGeneric extends DefineCommandInputs> = DefineCommandInputsGeneric & {
9
- allAvailableSubCommands: (keyof DefineCommandInputsGeneric['subCommandDescriptions'])[];
9
+ allAvailableSubCommands: ReadonlyArray<keyof DefineCommandInputsGeneric['subCommandDescriptions']>;
10
10
  subCommands: SubCommandsMap<DefineCommandInputsGeneric>;
11
11
  };
12
12
  export declare type SubCommandsMap<DefineCommandInputsGeneric extends DefineCommandInputs> = {
@@ -3,4 +3,4 @@ export declare type ExtractSubCommandsOutput<T> = {
3
3
  subCommands: T[];
4
4
  filteredArgs: string[];
5
5
  };
6
- export declare function extractSubCommands<T>(allArgs: string[], availableSubCommands: T[]): ExtractSubCommandsOutput<T>;
6
+ export declare function extractSubCommands<T>(allArgs: ReadonlyArray<string>, availableSubCommands: ReadonlyArray<T>): ExtractSubCommandsOutput<T>;
@@ -15,7 +15,7 @@ function getValidCommandDefinition(binName, commandMapping, givenCommandName) {
15
15
  throw new Error(`Missing command name as first input to ${binName}.${availableCommandsString(commandMapping)}`);
16
16
  }
17
17
  const commandDefinition = commandMapping[givenCommandName];
18
- if (!(0, augment_vir_1.typedHasOwnProperty)(commandMapping, givenCommandName) || !commandDefinition) {
18
+ if (!(0, augment_vir_1.typedHasProperty)(commandMapping, givenCommandName) || !commandDefinition) {
19
19
  throw new Error(`Invalid command "${givenCommandName} for ${binName}.${availableCommandsString(commandMapping)}"`);
20
20
  }
21
21
  return commandDefinition;
@@ -1 +1 @@
1
- export declare function isInTypedArray<T>(input: any, array: T[]): input is T;
1
+ export declare function isInTypedArray<T>(input: any, array: ReadonlyArray<T>): input is T;
@@ -15,7 +15,7 @@ exports.filterObject = filterObject;
15
15
  function deeplyCombineObjects(originalObject, overwriteObject) {
16
16
  return (0, augment_vir_1.getObjectTypedKeys)(overwriteObject).reduce((accum, currentKey) => {
17
17
  const currentNewValue = overwriteObject[currentKey];
18
- const currentOldValue = (0, augment_vir_1.typedHasOwnProperty)(originalObject, currentKey) && originalObject[currentKey];
18
+ const currentOldValue = (0, augment_vir_1.typedHasProperty)(originalObject, currentKey) && originalObject[currentKey];
19
19
  if ((0, augment_vir_1.isObject)(currentOldValue) && (0, augment_vir_1.isObject)(currentNewValue)) {
20
20
  accum[currentKey] = deeplyCombineObjects(currentOldValue, currentNewValue);
21
21
  }
@@ -56,7 +56,7 @@ exports.codeInMarkdownCommandDefinition = (0, define_command_1.defineCommand)({
56
56
  stderr: (stderrInput) => stderrInput.replace('Run without --check to update.', 'Run without the "check" sub-command in order to update.'),
57
57
  };
58
58
  return {
59
- mainCommand: await (0, package_paths_1.getNpmBinPath)('md-code'),
59
+ mainCommand: await (0, package_paths_1.getNpmBinPath)(inputs.repoDir, 'md-code'),
60
60
  logTransforms,
61
61
  args: [
62
62
  subCommand,
@@ -42,7 +42,7 @@ exports.compileCommandDefinition = (0, define_command_1.defineCommand)({
42
42
  inputs.inputSubCommands.includes(inputs.subCommands.check);
43
43
  const resetCommand = shouldNotEmit ? '' : 'rm -rf dist && ';
44
44
  const noEmit = shouldNotEmit ? '--noEmit' : '';
45
- const mainCommand = `${resetCommand}${await (0, package_paths_1.getNpmBinPath)('tsc')}`;
45
+ const mainCommand = `${resetCommand}${await (0, package_paths_1.getNpmBinPath)(inputs.repoDir, 'tsc')}`;
46
46
  return {
47
47
  mainCommand,
48
48
  args: [
@@ -110,7 +110,7 @@ exports.formatCommandDefinition = (0, define_command_1.defineCommand)({
110
110
  .replace('All matched files use Prettier code style!\n', ''),
111
111
  };
112
112
  return {
113
- mainCommand: await (0, package_paths_1.getNpmBinPath)('prettier'),
113
+ mainCommand: await (0, package_paths_1.getNpmBinPath)(inputs.repoDir, 'prettier'),
114
114
  args: [
115
115
  '--color',
116
116
  listDifferentFlag,
@@ -42,8 +42,8 @@ exports.frontendCommandDefinition = (0, define_command_1.defineCommand)({
42
42
  packageDir: package_paths_1.virmatorPackageDir,
43
43
  })}`
44
44
  : '';
45
- const viteBinPath = await (0, package_paths_1.getNpmBinPath)('vite');
46
- const removeOutput = needToBuild ? 'rm -rf dist' : '';
45
+ const viteBinPath = await (0, package_paths_1.getNpmBinPath)(inputs.repoDir, 'vite');
46
+ const removeOutput = needToBuild ? 'rm -rf dist ' : '';
47
47
  const mainCommand = `${removeOutput}${viteBinPath}`;
48
48
  const subCommandArgs = needToBuild
49
49
  ? [
@@ -35,7 +35,7 @@ exports.spellcheckCommandDefinition = (0, define_command_1.defineCommand)({
35
35
  ? ''
36
36
  : `--config ${inputs.configFiles.cspell.copyToPathRelativeToRepoDir}`;
37
37
  return {
38
- mainCommand: await (0, package_paths_1.getNpmBinPath)('cspell'),
38
+ mainCommand: await (0, package_paths_1.getNpmBinPath)(inputs.repoDir, 'cspell'),
39
39
  args: [
40
40
  configArg,
41
41
  '--color',
@@ -52,7 +52,7 @@ exports.testWebCommandDefinition = (0, define_command_1.defineCommand)({
52
52
  ? `--config ${inputs.configFiles.webTestRunner.copyToPathRelativeToRepoDir}`
53
53
  : '';
54
54
  return {
55
- mainCommand: await (0, package_paths_1.getNpmBinPath)('web-test-runner'),
55
+ mainCommand: await (0, package_paths_1.getNpmBinPath)(inputs.repoDir, 'web-test-runner'),
56
56
  logTransforms: {
57
57
  stdout: testWebTransform,
58
58
  },
@@ -13,5 +13,5 @@ export declare const testCommandDefinition: import("../api/command/define-comman
13
13
  readonly required: true;
14
14
  };
15
15
  };
16
- npmDeps: readonly ["@istanbuljs/nyc-config-typescript", "@types/chai", "@types/mocha", "chai", "mocha-spec-reporter-with-file-names", "mocha", "ts-node", "nyc"];
16
+ npmDeps: readonly ["@istanbuljs/nyc-config-typescript", "@types/chai", "@types/mocha", "chai", "istanbul-smart-text-reporter", "mocha-spec-reporter-with-file-names", "mocha", "nyc", "ts-node"];
17
17
  }>;
@@ -24,10 +24,11 @@ exports.testCommandDefinition = (0, define_command_1.defineCommand)({
24
24
  '@types/chai',
25
25
  '@types/mocha',
26
26
  'chai',
27
+ 'istanbul-smart-text-reporter',
27
28
  'mocha-spec-reporter-with-file-names',
28
29
  'mocha',
29
- 'ts-node',
30
30
  'nyc',
31
+ 'ts-node',
31
32
  ],
32
33
  }, ({ commandName, packageBinName }) => {
33
34
  return {
@@ -70,12 +71,12 @@ exports.testCommandDefinition = (0, define_command_1.defineCommand)({
70
71
  ? `--nycrc-path '${inputs.configFiles.nycConfig.copyToPathRelativeToRepoDir}'`
71
72
  : '';
72
73
  return {
73
- mainCommand: await (0, package_paths_1.getNpmBinPath)('nyc'),
74
+ mainCommand: await (0, package_paths_1.getNpmBinPath)(inputs.repoDir, 'nyc'),
74
75
  args: [
75
76
  // force colors in nyc
76
77
  '--colors',
77
78
  nycConfigFlag,
78
- await (0, package_paths_1.getNpmBinPath)('mocha'),
79
+ await (0, package_paths_1.getNpmBinPath)(inputs.repoDir, 'mocha'),
79
80
  configString,
80
81
  ...inputs.filteredInputArgs,
81
82
  ],
@@ -0,0 +1 @@
1
+ export declare const baseViteConfig: import("vite").UserConfigExport;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.baseViteConfig = void 0;
4
+ const vite_1 = require("vite");
5
+ const vite_always_reload_plugin_1 = require("./vite-always-reload-plugin");
6
+ exports.baseViteConfig = (0, vite_1.defineConfig)({
7
+ clearScreen: false,
8
+ plugins: [(0, vite_always_reload_plugin_1.alwaysReloadPlugin)()],
9
+ root: process.cwd(),
10
+ });
@@ -0,0 +1,11 @@
1
+ import { PluginOption } from 'vite';
2
+ /**
3
+ * There are similar plugins out there that try to do this but they aren't aggressive enough. This
4
+ * plugin literally always reloads on save, no questions asked.
5
+ */
6
+ export declare function alwaysReloadPlugin(config?: Partial<{
7
+ exclusions: string[];
8
+ /** Inclusions apply after exclusions so they will override exclusions. */
9
+ inclusions: string[];
10
+ root: string;
11
+ }>): PluginOption;
@@ -1,52 +1,46 @@
1
- import {styles} from 'ansi-colors';
2
- import {existsSync, lstatSync, readlinkSync} from 'fs';
3
- import {relative} from 'path';
4
- import {PluginOption} from 'vite';
5
-
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.alwaysReloadPlugin = void 0;
4
+ const ansi_colors_1 = require("ansi-colors");
5
+ const fs_1 = require("fs");
6
+ const path_1 = require("path");
6
7
  /**
7
8
  * Include actual paths and symlinked target paths if they exist.
8
9
  *
9
10
  * This is needed because when removing files from the watcher, sym links have be removed with the
10
11
  * path to the symlink itself AND the path to the symlink target or the path will still be watched.
11
12
  */
12
- function mapToActualPaths(paths: Readonly<string[]>): Readonly<string[]> {
13
+ function mapToActualPaths(paths) {
13
14
  return paths.reduce((accum, path) => {
14
- if (existsSync(path)) {
15
- if (lstatSync(path).isSymbolicLink()) {
15
+ if ((0, fs_1.existsSync)(path)) {
16
+ if ((0, fs_1.lstatSync)(path).isSymbolicLink()) {
16
17
  console.info('reading symlink from', path);
17
18
  // sym links AND the original path both need to be included
18
- return accum.concat(readlinkSync(path), path);
19
- } else {
19
+ return accum.concat((0, fs_1.readlinkSync)(path), path);
20
+ }
21
+ else {
20
22
  return accum.concat(path);
21
23
  }
22
- } else {
24
+ }
25
+ else {
23
26
  return accum;
24
27
  }
25
- }, [] as string[]);
28
+ }, []);
26
29
  }
27
-
28
30
  /**
29
31
  * There are similar plugins out there that try to do this but they aren't aggressive enough. This
30
32
  * plugin literally always reloads on save, no questions asked.
31
33
  */
32
- export function alwaysReloadPlugin(
33
- config: Partial<{
34
- exclusions: string[];
35
- /** Inclusions apply after exclusions so they will override exclusions. */
36
- inclusions: string[];
37
- root: string;
38
- }> = {},
39
- ): PluginOption {
34
+ function alwaysReloadPlugin(config = {}) {
40
35
  return {
41
36
  name: 'alwaysReloadPlugin',
42
37
  apply: 'serve',
43
- config: () => ({server: {watch: {disableGlobbing: false}}}),
44
- configureServer({watcher, ws, config: {logger}}) {
45
- const {root = process.cwd(), inclusions = [], exclusions = []} = config;
38
+ config: () => ({ server: { watch: { disableGlobbing: false } } }),
39
+ configureServer({ watcher, ws, config: { logger } }) {
40
+ const { root = process.cwd(), inclusions = [], exclusions = [] } = config;
46
41
  let callingAlready = false;
47
42
  let loggedAlready = false;
48
-
49
- const reloadCallback = (path: string) => {
43
+ const reloadCallback = (path) => {
50
44
  if (!loggedAlready) {
51
45
  loggedAlready = true;
52
46
  // log watched stuff so that we can make sure it's not watching too much
@@ -59,12 +53,7 @@ export function alwaysReloadPlugin(
59
53
  type: 'full-reload',
60
54
  path: '*',
61
55
  });
62
- logger.info(
63
- `${styles.green.open}page reload ${styles.dim.open}${relative(root, path)}${
64
- styles.reset.open
65
- }`,
66
- {clear: true, timestamp: true},
67
- );
56
+ logger.info(`${ansi_colors_1.styles.green.open}page reload ${ansi_colors_1.styles.dim.open}${(0, path_1.relative)(root, path)}${ansi_colors_1.styles.reset.open}`, { clear: true, timestamp: true });
68
57
  /**
69
58
  * Debounce reloads calls so that they don't get spammed. If you're saving
70
59
  * faster than this, then what the heck are you doing anyway?
@@ -74,7 +63,6 @@ export function alwaysReloadPlugin(
74
63
  }, 100);
75
64
  }
76
65
  };
77
-
78
66
  if (exclusions.length) {
79
67
  watcher.unwatch(mapToActualPaths(exclusions));
80
68
  // ignore macOS file system metadata stuff
@@ -90,3 +78,4 @@ export function alwaysReloadPlugin(
90
78
  },
91
79
  };
92
80
  }
81
+ exports.alwaysReloadPlugin = alwaysReloadPlugin;
@@ -6,4 +6,4 @@ export declare const virmatorConfigs: {
6
6
  vsCode: string;
7
7
  src: string;
8
8
  };
9
- export declare function getNpmBinPath(command: string): Promise<string>;
9
+ export declare function getNpmBinPath(repoDir: string, command: string): Promise<string>;
@@ -14,17 +14,23 @@ exports.virmatorConfigs = {
14
14
  vsCode: (0, path_1.join)(exports.virmatorConfigsDir, '.vscode'),
15
15
  src: (0, path_1.join)(exports.virmatorConfigsDir, 'src'),
16
16
  };
17
- async function getNpmBinPath(command) {
18
- const joinPath = (0, path_1.join)('node_modules', '.bin', command);
19
- const startSearchDirPath = exports.virmatorPackageDir;
17
+ async function getNpmBinPath(repoDir, command) {
18
+ const topLevelBinPath = (0, path_1.join)('node_modules', '.bin', command);
19
+ const virmatorBinPath = (0, path_1.join)('node_modules', 'virmator', 'node_modules', '.bin', command);
20
+ const startSearchDirPath = repoDir;
20
21
  try {
21
22
  const nodeModulesWithValidBin = await (0, fs_2.recursivelyUpwardsSearchForDir)(startSearchDirPath, (dirPath) => {
22
- return (0, fs_1.existsSync)((0, path_1.join)(dirPath, joinPath));
23
+ return ((0, fs_1.existsSync)((0, path_1.join)(dirPath, topLevelBinPath)) ||
24
+ (0, fs_1.existsSync)((0, path_1.join)(dirPath, virmatorBinPath)));
23
25
  });
24
26
  if (!nodeModulesWithValidBin) {
25
27
  throw new Error(`Search failed to find "${command}" bin path. Started in "${startSearchDirPath}".`);
26
28
  }
27
- const actualBinPath = (0, path_1.join)(nodeModulesWithValidBin, joinPath);
29
+ const foundTopLevelBinPath = (0, path_1.join)(nodeModulesWithValidBin, topLevelBinPath);
30
+ const foundVirmatorBinPath = (0, path_1.join)(nodeModulesWithValidBin, virmatorBinPath);
31
+ const actualBinPath = (0, fs_1.existsSync)(foundVirmatorBinPath)
32
+ ? foundVirmatorBinPath
33
+ : foundTopLevelBinPath;
28
34
  if (!(0, fs_1.existsSync)(actualBinPath)) {
29
35
  throw new Error(`Discovered bin path for "${command}" does not actually exist: "${actualBinPath}". Started at "${startSearchDirPath}".`);
30
36
  }
package/dist/index.d.ts CHANGED
@@ -101,7 +101,7 @@ export declare const virmator: Readonly<{
101
101
  readonly required: true;
102
102
  };
103
103
  };
104
- npmDeps: readonly ["@istanbuljs/nyc-config-typescript", "@types/chai", "@types/mocha", "chai", "mocha-spec-reporter-with-file-names", "mocha", "ts-node", "nyc"];
104
+ npmDeps: readonly ["@istanbuljs/nyc-config-typescript", "@types/chai", "@types/mocha", "chai", "istanbul-smart-text-reporter", "mocha-spec-reporter-with-file-names", "mocha", "nyc", "ts-node"];
105
105
  }> | import("./api/command/define-command").CommandDefinition<{
106
106
  commandName: "test-web";
107
107
  subCommandDescriptions: {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "virmator",
3
- "version": "4.2.6",
3
+ "version": "4.2.9",
4
4
  "description": "Handle all the stuffs in one package.",
5
5
  "keywords": [
6
6
  "automation",
@@ -30,6 +30,7 @@
30
30
  "compile": "rm -rf dist && tsc",
31
31
  "format": "npm run format:base -- --write --list-different",
32
32
  "format:base": "prettier \"./**/*.+(ts|json|html|css|md|js)\"",
33
+ "prepack": "npm run compile",
33
34
  "prepublishOnly": "npm run test:all",
34
35
  "readme:check": "npm run compile && ts-node -r tsconfig-paths/register src/scripts/save-help-message.ts check && md-code --check README.md",
35
36
  "readme:update": "npm run compile && ts-node -r tsconfig-paths/register src/scripts/save-help-message.ts && md-code README.md",
@@ -42,7 +43,7 @@
42
43
  },
43
44
  "dependencies": {
44
45
  "ansi-colors": "^4.1.3",
45
- "augment-vir": "2.5.1",
46
+ "augment-vir": "3.0.2",
46
47
  "semver": "7.3.8",
47
48
  "simple-git": "3.14.1"
48
49
  },
@@ -52,18 +53,18 @@
52
53
  "@types/chai": "4.3.3",
53
54
  "@types/fs-extra": "^9.0.13",
54
55
  "@types/mocha": "10.0.0",
55
- "@types/node": "18.8.4",
56
+ "@types/node": "18.8.5",
56
57
  "@types/semver": "7.3.12",
57
58
  "@web/dev-server-esbuild": "0.3.2",
58
59
  "@web/test-runner": "0.14.0",
59
60
  "@web/test-runner-commands": "0.6.5",
60
61
  "@web/test-runner-playwright": "0.8.10",
61
62
  "ansi-colors": "4.1.3",
62
- "augment-vir": "2.5.1",
63
+ "augment-vir": "3.0.2",
63
64
  "chai": "4.3.6",
64
65
  "cspell": "6.12.0",
65
66
  "fs-extra": "^10.1.0",
66
- "istanbul-smart-text-reporter": "^0.0.0",
67
+ "istanbul-smart-text-reporter": "^0.0.1",
67
68
  "markdown-code-example-inserter": "0.1.11",
68
69
  "mocha": "10.0.0",
69
70
  "mocha-spec-reporter-with-file-names": "^0.0.0",
@@ -1,11 +0,0 @@
1
- import {dirname} from 'path';
2
- import {UserConfig} from 'vite';
3
- import {alwaysReloadPlugin} from './vite-always-reload-plugin';
4
-
5
- const viteConfig: UserConfig = {
6
- clearScreen: false,
7
- plugins: [alwaysReloadPlugin()],
8
- root: dirname(__dirname),
9
- };
10
-
11
- export default viteConfig;