virmator 6.3.4 → 6.4.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 CHANGED
@@ -171,3 +171,11 @@ run web tests with code coverage calculations
171
171
  ## update-configs
172
172
 
173
173
  Update all existing configuration files that virmator is able to update. (Like base config files.)
174
+
175
+ ## upgrade-deps
176
+
177
+ Upgrade all packages using npm-check-updates and config/ncu.config.ts.
178
+
179
+ ### Examples
180
+
181
+ - Run command: `virmator upgrade-deps`
@@ -86,6 +86,7 @@ const baseConfig = {
86
86
  'nycrc',
87
87
  'openlogin',
88
88
  'opentype',
89
+ 'outfile',
89
90
  'packagejson',
90
91
  'parens',
91
92
  'pdfs',
@@ -0,0 +1,11 @@
1
+ import {RunOptions} from 'npm-check-updates';
2
+
3
+ export const ncuConfig: RunOptions = {
4
+ color: true,
5
+ upgrade: true,
6
+ root: true,
7
+ // exclude these
8
+ reject: [],
9
+ // include only these
10
+ filter: [],
11
+ };
@@ -17,5 +17,5 @@ export default webTestRunnerConfig;
17
17
 
18
18
  // check if the current file is being run directly as a script
19
19
  if (import.meta.url === pathToFileURL(process.argv[1]).href) {
20
- console.info(JSON.stringify(webTestRunnerConfig));
20
+ console.info(JSON.stringify(webTestRunnerConfig, null, 4));
21
21
  }
@@ -1,4 +1,4 @@
1
- import { IsAny } from 'type-fest/source/internal';
1
+ import { IsAny } from 'type-fest';
2
2
  import { CreateDescriptionsCallback } from './command-description';
3
3
  import { CommandExecutor, CommandExecutorDefinition } from './command-executor';
4
4
  import { DefineCommandInputs, SharedExecutorInputsAndCommandDefinition } from './define-command-inputs';
@@ -16,10 +16,6 @@ exports.nonCommandConfigs = [
16
16
  copyToPathRelativeToRepoDir: '.nvmrc',
17
17
  updateExistingConfigFileCallback: (newContents) => newContents,
18
18
  },
19
- {
20
- copyFromInternalPath: (0, path_1.join)(package_paths_1.virmatorConfigsDir, '.ncurc.js'),
21
- copyToPathRelativeToRepoDir: '.ncurc.js',
22
- },
23
19
  {
24
20
  copyFromInternalPath: (0, path_1.join)(package_paths_1.virmatorConfigsDir, 'LICENSE-MIT'),
25
21
  copyToPathRelativeToRepoDir: 'LICENSE-MIT',
@@ -0,0 +1,58 @@
1
+ export declare const upgradeDepsCommandDefinition: {
2
+ commandName: "upgrade-deps";
3
+ subCommandDescriptions: {};
4
+ configFiles: {
5
+ readonly ncuConfig: {
6
+ readonly copyFromInternalPath: string;
7
+ readonly copyToPathRelativeToRepoDir: string;
8
+ };
9
+ };
10
+ npmDeps: readonly ["npm-check-updates"];
11
+ } & {
12
+ allAvailableSubCommands: readonly never[];
13
+ subCommands: import("..").SubCommandsMap<{
14
+ commandName: "upgrade-deps";
15
+ subCommandDescriptions: {};
16
+ configFiles: {
17
+ readonly ncuConfig: {
18
+ readonly copyFromInternalPath: string;
19
+ readonly copyToPathRelativeToRepoDir: string;
20
+ };
21
+ };
22
+ npmDeps: readonly ["npm-check-updates"];
23
+ }>;
24
+ } & {
25
+ executor: import("..").CommandExecutor<{
26
+ commandName: "upgrade-deps";
27
+ subCommandDescriptions: {};
28
+ configFiles: {
29
+ readonly ncuConfig: {
30
+ readonly copyFromInternalPath: string;
31
+ readonly copyToPathRelativeToRepoDir: string;
32
+ };
33
+ };
34
+ npmDeps: readonly ["npm-check-updates"];
35
+ }>;
36
+ createDescription: import("..").CreateDescriptionsCallback<{
37
+ commandName: "upgrade-deps";
38
+ subCommandDescriptions: {};
39
+ configFiles: {
40
+ readonly ncuConfig: {
41
+ readonly copyFromInternalPath: string;
42
+ readonly copyToPathRelativeToRepoDir: string;
43
+ };
44
+ };
45
+ npmDeps: readonly ["npm-check-updates"];
46
+ }>;
47
+ extend: import("../api/command/define-command").ExtendCallback<{
48
+ commandName: "upgrade-deps";
49
+ subCommandDescriptions: {};
50
+ configFiles: {
51
+ readonly ncuConfig: {
52
+ readonly copyFromInternalPath: string;
53
+ readonly copyToPathRelativeToRepoDir: string;
54
+ };
55
+ };
56
+ npmDeps: readonly ["npm-check-updates"];
57
+ }>;
58
+ };
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.upgradeDepsCommandDefinition = void 0;
4
+ const common_1 = require("@augment-vir/common");
5
+ const node_js_1 = require("@augment-vir/node-js");
6
+ const esbuild_1 = require("esbuild");
7
+ const promises_1 = require("fs/promises");
8
+ const npm_check_updates_1 = require("npm-check-updates");
9
+ const path_1 = require("path");
10
+ const define_command_1 = require("../api/command/define-command");
11
+ const package_paths_1 = require("./../file-paths/package-paths");
12
+ exports.upgradeDepsCommandDefinition = (0, define_command_1.defineCommand)({
13
+ commandName: 'upgrade-deps',
14
+ subCommandDescriptions: {},
15
+ configFiles: {
16
+ ncuConfig: {
17
+ copyFromInternalPath: (0, path_1.join)(package_paths_1.virmatorConfigsDir, 'configs', 'ncu.config.ts'),
18
+ copyToPathRelativeToRepoDir: (0, path_1.join)('configs', 'ncu.config.ts'),
19
+ },
20
+ },
21
+ npmDeps: [
22
+ 'npm-check-updates',
23
+ ],
24
+ }, ({ commandName, packageBinName }) => {
25
+ return {
26
+ sections: [
27
+ {
28
+ title: '',
29
+ content: `Upgrade all packages using npm-check-updates and config/ncu.config.ts.`,
30
+ },
31
+ ],
32
+ examples: [
33
+ {
34
+ title: 'Run command',
35
+ content: `${packageBinName} ${commandName}`,
36
+ },
37
+ ],
38
+ };
39
+ }, async (inputs) => {
40
+ const tempFilePath = (0, path_1.join)(__dirname, `config-output-${Date.now()}-${(0, node_js_1.randomString)()}.cjs`);
41
+ try {
42
+ const configPath = (0, path_1.join)(inputs.repoDir, inputs.configFiles.ncuConfig.copyToPathRelativeToRepoDir);
43
+ await (0, esbuild_1.build)({
44
+ entryPoints: [configPath],
45
+ outfile: tempFilePath,
46
+ write: true,
47
+ target: ['node18'],
48
+ platform: 'node',
49
+ bundle: true,
50
+ format: 'cjs',
51
+ });
52
+ const repoPackageJson = await (0, node_js_1.readPackageJson)(inputs.repoDir);
53
+ const loadedConfig = require(tempFilePath);
54
+ const config = loadedConfig.ncuConfig;
55
+ await (0, npm_check_updates_1.run)({
56
+ ...config,
57
+ cwd: inputs.repoDir,
58
+ json: false,
59
+ workspaces: !!repoPackageJson.workspaces,
60
+ format: [],
61
+ }, {
62
+ cli: true,
63
+ });
64
+ return { success: true };
65
+ }
66
+ catch (error) {
67
+ console.error((0, common_1.extractErrorMessage)(error));
68
+ return { success: false };
69
+ }
70
+ finally {
71
+ try {
72
+ await (0, promises_1.unlink)(tempFilePath);
73
+ }
74
+ catch (error) { }
75
+ }
76
+ });
package/dist/index.d.ts CHANGED
@@ -607,6 +607,63 @@ export declare const virmator: Readonly<{
607
607
  configFiles: {};
608
608
  npmDeps: readonly [];
609
609
  }>;
610
+ }) | ({
611
+ commandName: "upgrade-deps";
612
+ subCommandDescriptions: {};
613
+ configFiles: {
614
+ readonly ncuConfig: {
615
+ readonly copyFromInternalPath: string;
616
+ readonly copyToPathRelativeToRepoDir: string;
617
+ };
618
+ };
619
+ npmDeps: readonly ["npm-check-updates"];
620
+ } & {
621
+ allAvailableSubCommands: readonly never[];
622
+ subCommands: import("./api/command/define-command-inputs").SubCommandsMap<{
623
+ commandName: "upgrade-deps";
624
+ subCommandDescriptions: {};
625
+ configFiles: {
626
+ readonly ncuConfig: {
627
+ readonly copyFromInternalPath: string;
628
+ readonly copyToPathRelativeToRepoDir: string;
629
+ };
630
+ };
631
+ npmDeps: readonly ["npm-check-updates"];
632
+ }>;
633
+ } & {
634
+ executor: import("./api/command/command-executor").CommandExecutor<{
635
+ commandName: "upgrade-deps";
636
+ subCommandDescriptions: {};
637
+ configFiles: {
638
+ readonly ncuConfig: {
639
+ readonly copyFromInternalPath: string;
640
+ readonly copyToPathRelativeToRepoDir: string;
641
+ };
642
+ };
643
+ npmDeps: readonly ["npm-check-updates"];
644
+ }>;
645
+ createDescription: import("./api/command/command-description").CreateDescriptionsCallback<{
646
+ commandName: "upgrade-deps";
647
+ subCommandDescriptions: {};
648
+ configFiles: {
649
+ readonly ncuConfig: {
650
+ readonly copyFromInternalPath: string;
651
+ readonly copyToPathRelativeToRepoDir: string;
652
+ };
653
+ };
654
+ npmDeps: readonly ["npm-check-updates"];
655
+ }>;
656
+ extend: import("./api/command/define-command").ExtendCallback<{
657
+ commandName: "upgrade-deps";
658
+ subCommandDescriptions: {};
659
+ configFiles: {
660
+ readonly ncuConfig: {
661
+ readonly copyFromInternalPath: string;
662
+ readonly copyToPathRelativeToRepoDir: string;
663
+ };
664
+ };
665
+ npmDeps: readonly ["npm-check-updates"];
666
+ }>;
610
667
  }))[]>;
611
668
  extend: <CommandDefinitionsGeneric extends readonly import("./api/command/define-command").AnyCommandDefinition[]>(inputs: Readonly<{
612
669
  packageBinName: string;
package/dist/index.js CHANGED
@@ -26,6 +26,7 @@ const spellcheck_command_1 = require("./commands/spellcheck.command");
26
26
  const test_web_command_1 = require("./commands/test-web.command");
27
27
  const test_command_1 = require("./commands/test.command");
28
28
  const update_configs_command_1 = require("./commands/update-configs.command");
29
+ const upgrade_deps_command_1 = require("./commands/upgrade-deps.command");
29
30
  const package_paths_1 = require("./file-paths/package-paths");
30
31
  __exportStar(require("./api/command/command-description"), exports);
31
32
  __exportStar(require("./api/command/command-executor"), exports);
@@ -57,5 +58,6 @@ exports.virmator = (0, create_virmator_1.createVirmator)({
57
58
  test_command_1.testCommandDefinition,
58
59
  test_web_command_1.testWebCommandDefinition,
59
60
  update_configs_command_1.updateConfigsCommandDefinition,
61
+ upgrade_deps_command_1.upgradeDepsCommandDefinition,
60
62
  ],
61
63
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "virmator",
3
- "version": "6.3.4",
3
+ "version": "6.4.1",
4
4
  "description": "Handle common package configs, commands, and dependencies.",
5
5
  "keywords": [
6
6
  "automation",
@@ -35,7 +35,7 @@
35
35
  "format": "npm run format:base -- --write --list-different",
36
36
  "format:base": "prettier \"./**/*.+(ts|json|html|css|md|js)\"",
37
37
  "publish": "virmator publish \"npm run test:all\"",
38
- "test": "test-as-package mocha --config mocha.config.js",
38
+ "test": "npm run compile && test-as-package mocha --config mocha.config.js",
39
39
  "test:all": "npm ci && npm run compile && npm run test && npm ci && npm run test:spelling -- --no-progress && npm run test:format && npm run docs:check",
40
40
  "test:format": "npm run format:base -- --check",
41
41
  "test:help": "ts-node src/cli/cli.ts --help",
@@ -48,9 +48,10 @@
48
48
  "ansi-colors": "^4.1.3",
49
49
  "glob": "^8.1.0",
50
50
  "glob-promise": "^6.0.2",
51
+ "npm-check-updates": "^16.10.7",
51
52
  "semver": "^7.3.8",
52
53
  "simple-git": "^3.17.0",
53
- "type-fest": "^3.7.2"
54
+ "type-fest": "^3.8.0"
54
55
  },
55
56
  "devDependencies": {
56
57
  "@electrovir/nyc": "15.1.0-fix0",
@@ -62,13 +63,14 @@
62
63
  "@types/mocha": "^10.0.1",
63
64
  "@types/node": "^18.15.11",
64
65
  "@types/semver": "^7.3.13",
65
- "@web/dev-server-esbuild": "^0.3.5",
66
- "@web/test-runner": "^0.15.2",
67
- "@web/test-runner-commands": "^0.6.5",
66
+ "@web/dev-server-esbuild": "^0.3.6",
67
+ "@web/test-runner": "^0.15.3",
68
+ "@web/test-runner-commands": "^0.6.6",
68
69
  "@web/test-runner-playwright": "^0.9.0",
69
- "@web/test-runner-visual-regression": "^0.7.0",
70
+ "@web/test-runner-visual-regression": "^0.7.1",
70
71
  "chai": "^4.3.7",
71
72
  "cspell": "^6.31.1",
73
+ "esbuild": "^0.17.15",
72
74
  "fs-extra": "^11.1.1",
73
75
  "istanbul-smart-text-reporter": "^1.1.1",
74
76
  "markdown-code-example-inserter": "^0.3.0",
@@ -87,7 +89,7 @@
87
89
  "ts-node": "^10.9.1",
88
90
  "tsconfig-paths": "^4.2.0",
89
91
  "typescript": "^5.0.3",
90
- "virmator": "^6.3.3",
92
+ "virmator": "^6.4.0",
91
93
  "vite": "^4.2.1",
92
94
  "vite-tsconfig-paths": "^4.0.8"
93
95
  },
package/configs/.ncurc.js DELETED
@@ -1,4 +0,0 @@
1
- module.exports = {
2
- upgrade: true,
3
- root: true,
4
- };