virmator 2.0.5 → 3.0.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/.github/workflows/virmator-build-for-gh-pages.yml +24 -0
- package/.github/workflows/virmator-tagged-release.yml +6 -4
- package/.github/workflows/virmator-tests.yml +4 -3
- package/.mocharc.js +9 -0
- package/.prettierignore +2 -3
- package/README.md +67 -82
- package/configs/.cspell.json +4 -0
- package/configs/.gitattributes +1 -0
- package/configs/.mocharc.js +8 -0
- package/configs/.prettierignore +6 -0
- package/configs/.prettierrc.js +13 -0
- package/{.cspell.json → configs/.virmator/.cspell-base.json} +5 -0
- package/configs/.virmator/mocharc-base.js +15 -0
- package/configs/.virmator/prettierrc-base.js +62 -0
- package/{tsconfig.json → configs/.virmator/tsconfig-base.json} +12 -8
- package/configs/.virmator/vite-always-reload-plugin.ts +90 -0
- package/configs/.virmator/vite-base.ts +11 -0
- package/configs/.virmator/vite.config.ts +8 -0
- package/configs/.virmator/web-test-runner-base.mjs +29 -0
- package/configs/.virmator/web-test-runner.config.mjs +8 -0
- package/{.vscode → configs/.vscode}/settings.json +13 -0
- package/configs/gitignore.txt +6 -0
- package/configs/npmignore.txt +13 -0
- package/configs/package.json +16 -0
- package/configs/src/global.d.ts +5 -0
- package/configs/tsconfig.json +3 -0
- package/dist/api/virmator-wrapper.d.ts +5 -0
- package/dist/api/virmator-wrapper.js +9 -0
- package/dist/augments/array.d.ts +1 -0
- package/dist/augments/array.js +7 -0
- package/dist/augments/fs.d.ts +5 -0
- package/dist/augments/fs.js +30 -0
- package/dist/augments/json.d.ts +1 -0
- package/dist/augments/json.js +12 -0
- package/dist/augments/object.d.ts +1 -0
- package/dist/augments/object.js +14 -0
- package/dist/augments/regexp.d.ts +1 -0
- package/dist/augments/regexp.js +7 -0
- package/dist/augments/test.d.ts +2 -0
- package/dist/augments/test.js +8 -0
- package/dist/augments/type.d.ts +1 -0
- package/dist/augments/type.js +2 -0
- package/dist/cli/all-cli-command-definitions.d.ts +54 -0
- package/dist/cli/all-cli-command-definitions.js +76 -0
- package/dist/cli/cli-color.d.ts +8 -0
- package/dist/cli/cli-color.js +12 -0
- package/dist/cli/cli-command/cli-command-help.d.ts +8 -0
- package/dist/cli/cli-command/cli-command-help.js +2 -0
- package/dist/cli/{commands/description-printing.d.ts → cli-command/cli-command-to-help-message.d.ts} +3 -2
- package/dist/cli/{commands/description-printing.js → cli-command/cli-command-to-help-message.js} +55 -21
- package/dist/cli/cli-command/define-cli-command.d.ts +41 -0
- package/dist/cli/cli-command/define-cli-command.js +29 -0
- package/dist/cli/cli-command/run-shell-command.d.ts +8 -0
- package/dist/cli/cli-command/run-shell-command.js +23 -0
- package/dist/cli/cli-command-implementations/code-in-markdown.command.d.ts +6 -0
- package/dist/cli/cli-command-implementations/code-in-markdown.command.js +67 -0
- package/dist/cli/cli-command-implementations/compile.command.d.ts +6 -0
- package/dist/cli/cli-command-implementations/compile.command.js +44 -0
- package/dist/cli/cli-command-implementations/format.command.d.ts +6 -0
- package/dist/cli/cli-command-implementations/format.command.js +116 -0
- package/dist/cli/cli-command-implementations/frontend.command.d.ts +7 -0
- package/dist/cli/cli-command-implementations/frontend.command.js +45 -0
- package/dist/cli/cli-command-implementations/init.command.d.ts +4 -0
- package/dist/cli/cli-command-implementations/init.command.js +31 -0
- package/dist/cli/cli-command-implementations/spellcheck.command.d.ts +4 -0
- package/dist/cli/cli-command-implementations/spellcheck.command.js +40 -0
- package/dist/cli/cli-command-implementations/test-web.command.d.ts +4 -0
- package/dist/cli/cli-command-implementations/test-web.command.js +50 -0
- package/dist/cli/cli-command-implementations/test.command.d.ts +4 -0
- package/dist/cli/cli-command-implementations/test.command.js +53 -0
- package/dist/cli/cli-command-implementations/update-configs.command.d.ts +4 -0
- package/dist/cli/cli-command-implementations/update-configs.command.js +31 -0
- package/dist/cli/cli-flags/cli-flag-name.d.ts +4 -0
- package/dist/cli/cli-flags/cli-flag-name.js +8 -0
- package/dist/cli/cli-flags/cli-flag-values.d.ts +4 -0
- package/dist/cli/cli-flags/cli-flag-values.js +19 -0
- package/dist/cli/cli-messages.d.ts +6 -0
- package/dist/cli/cli-messages.js +19 -0
- package/dist/cli/cli.js +27 -20
- package/dist/cli/config/combine-text-config.d.ts +2 -0
- package/dist/cli/config/combine-text-config.js +27 -0
- package/dist/cli/config/config-files.d.ts +133 -0
- package/dist/cli/config/config-files.js +138 -0
- package/dist/cli/config/copy-config.d.ts +25 -13
- package/dist/cli/config/copy-config.js +86 -86
- package/dist/cli/config/create-default-package-json.d.ts +1 -16
- package/dist/cli/config/create-default-package-json.js +37 -12
- package/dist/cli/is-global.d.ts +1 -0
- package/dist/cli/is-global.js +10 -0
- package/dist/cli/parse-arguments.d.ts +8 -0
- package/dist/cli/parse-arguments.js +42 -0
- package/dist/cli/run-cli-command.d.ts +13 -0
- package/dist/cli/run-cli-command.js +52 -0
- package/dist/cli/run-command.test-helper.d.ts +28 -0
- package/dist/cli/run-command.test-helper.js +87 -0
- package/dist/errors/virmator-cli.error.d.ts +3 -0
- package/dist/errors/virmator-cli.error.js +10 -0
- package/dist/errors/virmator-config-file.error.d.ts +4 -0
- package/dist/errors/virmator-config-file.error.js +11 -0
- package/dist/errors/virmator-invalid-command.error.d.ts +5 -0
- package/dist/errors/virmator-invalid-command.error.js +11 -0
- package/dist/errors/virmator-invalid-flags.error.d.ts +5 -0
- package/dist/errors/virmator-invalid-flags.error.js +13 -0
- package/dist/file-paths/virmator-package-paths.d.ts +11 -0
- package/dist/file-paths/virmator-package-paths.js +31 -0
- package/dist/file-paths/virmator-test-file-paths.d.ts +17 -7
- package/dist/index.d.ts +1 -2
- package/dist/index.js +0 -4
- package/dist/logging.d.ts +10 -0
- package/dist/logging.js +9 -0
- package/package.json +28 -22
- package/.prettierrc.js +0 -40
- package/dist/augments/ansi-regex.d.ts +0 -1
- package/dist/augments/ansi-regex.js +0 -27
- package/dist/augments/string.d.ts +0 -1
- package/dist/augments/string.js +0 -8
- package/dist/cli/cli-util/cli-color.d.ts +0 -8
- package/dist/cli/cli-util/cli-color.js +0 -35
- package/dist/cli/cli-util/cli-command-name.d.ts +0 -11
- package/dist/cli/cli-util/cli-command-name.js +0 -15
- package/dist/cli/cli-util/cli-flags.d.ts +0 -18
- package/dist/cli/cli-util/cli-flags.js +0 -63
- package/dist/cli/cli-util/cli-messages.d.ts +0 -7
- package/dist/cli/cli-util/cli-messages.js +0 -19
- package/dist/cli/cli-util/get-all-command-output.d.ts +0 -7
- package/dist/cli/cli-util/get-all-command-output.js +0 -21
- package/dist/cli/cli-util/shell-command-wrapper.d.ts +0 -8
- package/dist/cli/cli-util/shell-command-wrapper.js +0 -25
- package/dist/cli/cli-util/update-configs.d.ts +0 -3
- package/dist/cli/cli-util/update-configs.js +0 -54
- package/dist/cli/commands/all-cli-commands.d.ts +0 -13
- package/dist/cli/commands/all-cli-commands.js +0 -99
- package/dist/cli/commands/cli-command.d.ts +0 -35
- package/dist/cli/commands/cli-command.js +0 -40
- package/dist/cli/commands/implementations/code-in-markdown.command.d.ts +0 -3
- package/dist/cli/commands/implementations/code-in-markdown.command.js +0 -54
- package/dist/cli/commands/implementations/compile.command.d.ts +0 -3
- package/dist/cli/commands/implementations/compile.command.js +0 -49
- package/dist/cli/commands/implementations/format.command.d.ts +0 -16
- package/dist/cli/commands/implementations/format.command.js +0 -143
- package/dist/cli/commands/implementations/init.command.d.ts +0 -3
- package/dist/cli/commands/implementations/init.command.js +0 -55
- package/dist/cli/commands/implementations/spellcheck.command.d.ts +0 -3
- package/dist/cli/commands/implementations/spellcheck.command.js +0 -35
- package/dist/cli/commands/implementations/test.command.d.ts +0 -3
- package/dist/cli/commands/implementations/test.command.js +0 -49
- package/dist/cli/commands/implementations/update-all-configs.command.d.ts +0 -3
- package/dist/cli/commands/implementations/update-all-configs.command.js +0 -46
- package/dist/cli/commands/implementations/update-bare-configs.command.d.ts +0 -3
- package/dist/cli/commands/implementations/update-bare-configs.command.js +0 -46
- package/dist/cli/commands/run-command.d.ts +0 -3
- package/dist/cli/commands/run-command.js +0 -65
- package/dist/cli/config/config-key.d.ts +0 -35
- package/dist/cli/config/config-key.js +0 -25
- package/dist/cli/config/config-paths.d.ts +0 -3
- package/dist/cli/config/config-paths.js +0 -69
- package/dist/cli/config/config-read.d.ts +0 -7
- package/dist/cli/config/config-read.js +0 -91
- package/dist/cli/config/extendable-config.d.ts +0 -12
- package/dist/cli/config/extendable-config.js +0 -45
- package/dist/errors/cli-command-error.d.ts +0 -4
- package/dist/errors/cli-command-error.js +0 -12
- package/dist/errors/cli-flag-error.d.ts +0 -4
- package/dist/errors/cli-flag-error.js +0 -12
- package/dist/errors/config-file-error.d.ts +0 -3
- package/dist/errors/config-file-error.js +0 -7
- package/dist/exportable-jest-config/jest-config.d.ts +0 -3
- package/dist/exportable-jest-config/jest-config.js +0 -23
- package/dist/exportable-jest-config/jest-setup.d.ts +0 -1
- package/dist/exportable-jest-config/jest-setup.js +0 -11
- package/dist/file-paths/virmator-repo-paths.d.ts +0 -5
- package/dist/file-paths/virmator-repo-paths.js +0 -19
- package/dist/jest/jest-config.d.ts +0 -3
- package/dist/jest/jest-config.js +0 -13
- package/extender-configs/.cspell.json +0 -3
- package/extender-configs/.prettierrc.js +0 -3
- package/extender-configs/tsconfig.json +0 -3
- package/separate-configs/.prettierignore +0 -3
- package/separate-configs/gitignore.txt +0 -4
- package/separate-configs/jest/jest-config.ts +0 -24
- package/separate-configs/jest/jest-setup.ts +0 -12
- package/separate-configs/npmignore.txt +0 -20
- package/separate-configs/package.json +0 -9
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
name: build-for-gh-pages
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build-for-gh-pages:
|
|
10
|
+
runs-on: 'ubuntu-latest'
|
|
11
|
+
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v3
|
|
14
|
+
- uses: actions/setup-node@v3
|
|
15
|
+
with:
|
|
16
|
+
node-version: 16.x
|
|
17
|
+
- name: build
|
|
18
|
+
run: |
|
|
19
|
+
npm ci
|
|
20
|
+
npm run build
|
|
21
|
+
- uses: 'JamesIves/github-pages-deploy-action@4'
|
|
22
|
+
with:
|
|
23
|
+
branch: 'gh-pages'
|
|
24
|
+
folder: 'dist'
|
|
@@ -11,9 +11,9 @@ jobs:
|
|
|
11
11
|
runs-on: 'ubuntu-latest'
|
|
12
12
|
|
|
13
13
|
steps:
|
|
14
|
-
- uses: actions/checkout@
|
|
15
|
-
- name: Use Node.js
|
|
16
|
-
uses: actions/setup-node@
|
|
14
|
+
- uses: actions/checkout@v3
|
|
15
|
+
- name: Use Node.js
|
|
16
|
+
uses: actions/setup-node@v3
|
|
17
17
|
with:
|
|
18
18
|
node-version: 16.x
|
|
19
19
|
- name: run test
|
|
@@ -25,7 +25,9 @@ jobs:
|
|
|
25
25
|
run: |
|
|
26
26
|
tagName="${GITHUB_REF#refs/*/}"
|
|
27
27
|
originalTarName="$(npm pack)"
|
|
28
|
-
|
|
28
|
+
packageNameWithoutFileExtension="${originalTarName%.tgz}"
|
|
29
|
+
tagNameWithoutV="${tagName##v}"
|
|
30
|
+
packageName="${packageNameWithoutFileExtension%-$tagNameWithoutV}"
|
|
29
31
|
newTarName="$packageName-$tagName.tgz"
|
|
30
32
|
mv "$originalTarName" "$newTarName"
|
|
31
33
|
echo ::set-output name=tarName::"$newTarName"
|
|
@@ -12,14 +12,15 @@ jobs:
|
|
|
12
12
|
fail-fast: false
|
|
13
13
|
matrix:
|
|
14
14
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
15
|
-
node-version: [
|
|
15
|
+
node-version: [16.x, 18.x]
|
|
16
16
|
steps:
|
|
17
|
-
- uses: actions/checkout@
|
|
17
|
+
- uses: actions/checkout@v3
|
|
18
18
|
- name: Use Node.js ${{ matrix.node-version }}
|
|
19
|
-
uses: actions/setup-node@
|
|
19
|
+
uses: actions/setup-node@v3
|
|
20
20
|
with:
|
|
21
21
|
node-version: ${{ matrix.node-version }}
|
|
22
22
|
- name: run test
|
|
23
23
|
run: |
|
|
24
24
|
npm ci
|
|
25
|
+
npx playwright install --with-deps
|
|
25
26
|
npm run test:full
|
package/.mocharc.js
ADDED
package/.prettierignore
CHANGED
package/README.md
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
[](https://github.com/electrovir/virmator/actions/workflows/virmator-tests.yml)
|
|
2
|
-
|
|
3
1
|
# virmator
|
|
4
2
|
|
|
5
3
|
Centralize and automate all the things! So I don't have to copy pasta configs in every single project.
|
|
@@ -10,17 +8,17 @@ Centralize and automate all the things! So I don't have to copy pasta configs in
|
|
|
10
8
|
npm -i D virmator
|
|
11
9
|
```
|
|
12
10
|
|
|
13
|
-
#
|
|
11
|
+
# Help
|
|
14
12
|
|
|
15
13
|
```bash
|
|
16
14
|
npx virmator --help
|
|
17
15
|
```
|
|
18
16
|
|
|
19
|
-
|
|
17
|
+
Below is full documentation for the cli, which is generated via the cli's `help` message:
|
|
20
18
|
|
|
21
19
|
<!-- usage below -->
|
|
22
20
|
|
|
23
|
-
|
|
21
|
+
# virmator usage
|
|
24
22
|
|
|
25
23
|
```
|
|
26
24
|
[npx] virmator [--flags] command subCommand
|
|
@@ -28,148 +26,135 @@ Output from the help command:
|
|
|
28
26
|
|
|
29
27
|
`npx` is needed when the command is run directly from the terminal (not scoped within an npm script) unless the package has been globally installed (which will work just fine but I wouldn't recommend, simply because I prefer explicit dependencies).
|
|
30
28
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
### `--extendable-config`
|
|
29
|
+
# Available flags
|
|
34
30
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
### `--help`
|
|
31
|
+
## `--help`
|
|
38
32
|
|
|
39
33
|
Prints this help message.
|
|
40
34
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
Prevents a command from overwriting its relevant config file (if one exists, which they usually do).
|
|
44
|
-
|
|
45
|
-
### `--silent`
|
|
35
|
+
## `--silent`
|
|
46
36
|
|
|
47
37
|
Turns off most logging.
|
|
48
38
|
|
|
49
|
-
|
|
39
|
+
# Available commands
|
|
50
40
|
|
|
51
|
-
|
|
41
|
+
## code-in-markdown
|
|
52
42
|
|
|
53
43
|
Insert code snippets into markdown files. This uses the markdown-code-example-inserter package to expand code link comments inside of markdown files to actual markdown code blocks. See that package's README for more details but the basics are that you need a comment that looks like the following in your markdown file for this to do anything: `<!-- example-link: path/to/file.ts -->`
|
|
54
44
|
|
|
55
45
|
By default this command parses all markdown files in the repo (ignoring node_modules). Specific markdown files can be parsed by giving virmator extra parameters.
|
|
56
46
|
|
|
57
|
-
|
|
47
|
+
To check if files are up-to-date (rather than actually updating them), use the "check" sub-command.
|
|
48
|
+
|
|
49
|
+
### Examples
|
|
58
50
|
|
|
59
51
|
- default experience (usually all you need): `virmator code-in-markdown`
|
|
52
|
+
- checking if files are up-to-date: `virmator code-in-markdown check`
|
|
60
53
|
- override files to check to a single file: `virmator code-in-markdown only/this/one/file.md`
|
|
61
54
|
- override files to check to a group of files: `virmator code-in-markdown "only/this/dir/*.md"`
|
|
62
55
|
|
|
63
|
-
###
|
|
56
|
+
### check
|
|
57
|
+
|
|
58
|
+
Check that markdown files have their examples inserted and are up-to-date.
|
|
59
|
+
|
|
60
|
+
## compile
|
|
64
61
|
|
|
65
62
|
compile typescript files
|
|
66
63
|
Pass any extra tsc flags to this command.
|
|
67
64
|
|
|
68
|
-
|
|
65
|
+
### Examples
|
|
69
66
|
|
|
70
67
|
- no extra flags: `virmator compile`
|
|
71
68
|
- one extra flag: `virmator compile --noEmit`
|
|
72
69
|
|
|
73
|
-
###
|
|
70
|
+
### check
|
|
74
71
|
|
|
75
|
-
|
|
72
|
+
Run type checking without emitting compiled files.
|
|
76
73
|
|
|
77
|
-
|
|
74
|
+
## format
|
|
78
75
|
|
|
79
|
-
|
|
80
|
-
write: overwrites files to fix formatting.
|
|
81
|
-
check: checks the formatting, does not write to files
|
|
76
|
+
Formats source files with Prettier.
|
|
82
77
|
|
|
83
|
-
|
|
78
|
+
### file extensions:
|
|
84
79
|
|
|
85
|
-
If only specific file extensions should be formatted, add the "--
|
|
80
|
+
If only specific file extensions should be formatted, add the "--file-types" argument to this command. All following arguments will be treated as file extensions to be formatted. For example, the following command will format files only if they have the extension ".md" or ".json": virmator format --file-types md json
|
|
86
81
|
|
|
87
|
-
|
|
82
|
+
### Prettier flags:
|
|
88
83
|
|
|
89
|
-
Any other arguments encountered between the operation command (if provided) and the "--
|
|
84
|
+
Any other arguments encountered between the operation command (if provided) and the "--file-types" marker are treated as extra arguments to Prettier and will be passed along.
|
|
90
85
|
|
|
91
|
-
|
|
86
|
+
### Examples
|
|
92
87
|
|
|
93
88
|
- checks formatting for files: `virmator format check`
|
|
94
|
-
- checks formatting only for .md files: `virmator format check --
|
|
95
|
-
- checks formatting only for .md and .json files: `virmator format check --
|
|
89
|
+
- checks formatting only for .md files: `virmator format check --file-types md`
|
|
90
|
+
- checks formatting only for .md and .json files: `virmator format check --file-types md json`
|
|
96
91
|
- fixes formatting for files:
|
|
97
92
|
|
|
98
93
|
```
|
|
99
94
|
virmator format
|
|
100
|
-
|
|
95
|
+
virmator format
|
|
101
96
|
```
|
|
102
97
|
|
|
103
98
|
- examples with extra Prettier flags:
|
|
104
99
|
```
|
|
105
100
|
virmator format --ignore-path .prettierignore
|
|
106
|
-
|
|
107
|
-
|
|
101
|
+
virmator format --ignore-path .prettierignore
|
|
102
|
+
virmator format --ignore-path .prettierignore --file-types md json
|
|
108
103
|
```
|
|
109
104
|
|
|
110
|
-
###
|
|
105
|
+
### check
|
|
111
106
|
|
|
112
|
-
|
|
107
|
+
check formatting without overwriting files.
|
|
108
|
+
|
|
109
|
+
## frontend
|
|
110
|
+
|
|
111
|
+
Runs a frontend. Currently uses vite.
|
|
112
|
+
|
|
113
|
+
### build
|
|
114
|
+
|
|
115
|
+
Builds and bundles the frontend for deployment.
|
|
116
|
+
|
|
117
|
+
### preview
|
|
113
118
|
|
|
114
|
-
|
|
119
|
+
Builds and previews the built output.
|
|
115
120
|
|
|
116
|
-
|
|
117
|
-
If no package.json file is found, one is created and initialized.
|
|
118
|
-
Pass --force to this command to overwrite current package.json scripts.
|
|
121
|
+
## help
|
|
119
122
|
|
|
120
|
-
|
|
123
|
+
Prints this help output.
|
|
121
124
|
|
|
122
|
-
|
|
125
|
+
## init
|
|
123
126
|
|
|
124
|
-
|
|
127
|
+
Initialize a repo with all virmator config files.
|
|
125
128
|
|
|
126
|
-
|
|
129
|
+
## spellcheck
|
|
127
130
|
|
|
128
|
-
|
|
131
|
+
Spellcheck code with cspell. By default this spellchecks every file in the entire repo (except for those ignored in the config file), including .dot files. If any arguments are passed to this command, the default cspell args that this command applies are ignored, you'll have to supply them via your args.
|
|
129
132
|
|
|
130
|
-
|
|
131
|
-
- `virmator test "./**/single-file.js"`
|
|
132
|
-
- `virmator test "./dist/**/!(*.type).test.js"`
|
|
133
|
+
## test
|
|
133
134
|
|
|
134
|
-
|
|
135
|
+
Test all .test.ts files with Mocha and Chai. By default this command tests all ".test.ts" files in the current directory (recursively) that are not ".type.test.ts" files. To override this behavior, override the "spec" property in .mocharc.js.
|
|
135
136
|
|
|
136
|
-
|
|
137
|
+
This command is meant to run Node.js tests. For running web-based testing, see the test-web command.
|
|
137
138
|
|
|
138
|
-
|
|
139
|
+
Note that the below single file examples only work because the base Mocha config from virmator is setup to handle them. (So if you don't use that config, the examples may not work properly.)
|
|
139
140
|
|
|
140
|
-
|
|
141
|
-
JestConfig
|
|
142
|
-
JestSetup
|
|
143
|
-
PackageJson
|
|
144
|
-
Prettier
|
|
145
|
-
PrettierIgnore
|
|
146
|
-
TsConfig
|
|
147
|
-
GitAttributes
|
|
148
|
-
GitHubActionsTaggedRelease
|
|
149
|
-
GitHubActionsTest
|
|
150
|
-
GitIgnore
|
|
151
|
-
NpmIgnore
|
|
152
|
-
VsCodeSettings
|
|
141
|
+
### Examples
|
|
153
142
|
|
|
154
|
-
|
|
143
|
+
- Test all .test.ts and .test.tsx files: `virmator test`
|
|
144
|
+
- Test a single file: `virmator test ./path/to/single/file.js`
|
|
145
|
+
- Test multiple files: `virmator test "./**/single-file.js"`
|
|
155
146
|
|
|
156
|
-
|
|
157
|
-
- update only Cspell and GitIgnore files: `virmator update-all-configs Cspell GitIgnore`
|
|
147
|
+
## test-web
|
|
158
148
|
|
|
159
|
-
|
|
149
|
+
Runs tests within browsers rather than inside of Node.js. Test files fed into this command cannot be mixed with test files run by the "virmator test" command, as the run-time environment is quite different (Node.js vs browser). However, just like the test command, this command will all ".test.ts" files in the current directory (recursively) that are not ".type.test.ts" files. To override this behavior, override the "files" property in web-test-runner.config.mjs.
|
|
160
150
|
|
|
161
|
-
|
|
151
|
+
By default this command runs all tests three times: in Chromium (Chrome), Firefox, and Webkit (Safari) using playwright.
|
|
162
152
|
|
|
163
|
-
|
|
153
|
+
### Examples
|
|
164
154
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
GitHubActionsTest
|
|
168
|
-
GitIgnore
|
|
169
|
-
NpmIgnore
|
|
170
|
-
VsCodeSettings
|
|
155
|
+
- Test all .test.ts and .test.tsx files: `virmator test-web`
|
|
156
|
+
- Test a specific file: `virmator test-web path/to/file.test.ts`
|
|
171
157
|
|
|
172
|
-
|
|
158
|
+
## update-configs
|
|
173
159
|
|
|
174
|
-
|
|
175
|
-
- update only GitIgnore and NpmIgnore files: `virmator update-bare-configs GitIgnore NpmIgnore,`
|
|
160
|
+
Update all existing configuration files that virmator is able to update. (Like base config files.)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
* text=auto eol=lf
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const baseConfig = require('./.virmator/prettierrc-base.js');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @typedef {import('prettier-plugin-multiline-arrays').MultilineArrayOptions} MultilineOptions
|
|
5
|
+
*
|
|
6
|
+
* @typedef {import('prettier').Options} PrettierOptions
|
|
7
|
+
* @type {PrettierOptions & MultilineOptions}
|
|
8
|
+
*/
|
|
9
|
+
const prettierConfig = {
|
|
10
|
+
...baseConfig,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
module.exports = prettierConfig;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
+
"globRoot": "..",
|
|
2
3
|
"ignorePaths": [
|
|
3
4
|
".DS_Store",
|
|
4
5
|
".git/",
|
|
5
6
|
"dist/",
|
|
7
|
+
"coverage/",
|
|
6
8
|
"node_modules/",
|
|
7
9
|
"package-lock.json",
|
|
8
10
|
".cspell-base.json",
|
|
@@ -26,6 +28,8 @@
|
|
|
26
28
|
"entrypoint",
|
|
27
29
|
"entrypoints",
|
|
28
30
|
"esbenp",
|
|
31
|
+
"esbuild",
|
|
32
|
+
"esbuild",
|
|
29
33
|
"estree",
|
|
30
34
|
"fleek",
|
|
31
35
|
"gitattributes",
|
|
@@ -37,6 +41,7 @@
|
|
|
37
41
|
"locationchange",
|
|
38
42
|
"marvinpinto",
|
|
39
43
|
"mmultiline",
|
|
44
|
+
"mocharc",
|
|
40
45
|
"monospace",
|
|
41
46
|
"msapplication",
|
|
42
47
|
"mstile",
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const allTestFiles = 'src/**/!(*.type).test.ts?(x)';
|
|
2
|
+
const isTestingOtherFiles = process.argv.some((arg) => arg.match(/\.tsx?$/));
|
|
3
|
+
|
|
4
|
+
/** @type {import('mocha').MochaOptions} */
|
|
5
|
+
const mochaConfig = {
|
|
6
|
+
checkLeaks: true,
|
|
7
|
+
color: true,
|
|
8
|
+
parallel: true,
|
|
9
|
+
require: 'ts-node/register',
|
|
10
|
+
slow: '1500', // ms
|
|
11
|
+
timeout: '60000', // ms
|
|
12
|
+
...(isTestingOtherFiles ? {} : {spec: allTestFiles}),
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
module.exports = mochaConfig;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
function toPosixPath(input) {
|
|
5
|
+
return input.replace(/\\/g, '/').replace(/^\w+:/, '');
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const posixDirname = path.posix.dirname(toPosixPath(__dirname));
|
|
9
|
+
|
|
10
|
+
function findClosestNodeModulesPath(dirPath = __dirname) {
|
|
11
|
+
const currentAttempt = path.join(dirPath, 'node_modules');
|
|
12
|
+
if (fs.existsSync(currentAttempt)) {
|
|
13
|
+
return currentAttempt;
|
|
14
|
+
} else if (dirPath === '/') {
|
|
15
|
+
throw new Error(`Could not find node_modules directory.`);
|
|
16
|
+
} else {
|
|
17
|
+
return findClosestNodeModulesPath(path.dirname(dirPath));
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const nodeModules = toPosixPath(findClosestNodeModulesPath());
|
|
22
|
+
|
|
23
|
+
const plugins = [
|
|
24
|
+
'prettier-plugin-toml',
|
|
25
|
+
'prettier-plugin-sort-json',
|
|
26
|
+
'prettier-plugin-packagejson',
|
|
27
|
+
'prettier-plugin-multiline-arrays',
|
|
28
|
+
'prettier-plugin-organize-imports',
|
|
29
|
+
'prettier-plugin-jsdoc',
|
|
30
|
+
].map((pluginName) => {
|
|
31
|
+
// account for installations where node_modules is flattened and installations where it's nested
|
|
32
|
+
const flattenedPath = path.posix.join(nodeModules, pluginName);
|
|
33
|
+
const nestedPath = path.posix.join(nodeModules, 'virmator', 'node_modules', pluginName);
|
|
34
|
+
|
|
35
|
+
if (fs.existsSync(flattenedPath)) {
|
|
36
|
+
return path.posix.resolve(posixDirname, flattenedPath);
|
|
37
|
+
} else {
|
|
38
|
+
return path.posix.resolve(posixDirname, nestedPath);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @typedef {import('prettier-plugin-multiline-arrays').MultilineArrayOptions} MultilineOptions
|
|
44
|
+
*
|
|
45
|
+
* @typedef {import('prettier').Options} PrettierOptions
|
|
46
|
+
* @type {PrettierOptions & MultilineOptions}
|
|
47
|
+
*/
|
|
48
|
+
const prettierConfig = {
|
|
49
|
+
arrowParens: 'always',
|
|
50
|
+
bracketSpacing: false,
|
|
51
|
+
endOfLine: 'lf',
|
|
52
|
+
htmlWhitespaceSensitivity: 'ignore',
|
|
53
|
+
jsonRecursiveSort: true,
|
|
54
|
+
bracketSameLine: false,
|
|
55
|
+
plugins,
|
|
56
|
+
printWidth: 100,
|
|
57
|
+
singleQuote: true,
|
|
58
|
+
tabWidth: 4,
|
|
59
|
+
trailingComma: 'all',
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
module.exports = prettierConfig;
|
|
@@ -1,31 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"alwaysStrict": true,
|
|
4
|
-
"baseUrl": ".",
|
|
5
4
|
"declaration": true,
|
|
6
5
|
"esModuleInterop": true,
|
|
7
6
|
"exactOptionalPropertyTypes": true,
|
|
8
7
|
"forceConsistentCasingInFileNames": true,
|
|
8
|
+
"isolatedModules": true,
|
|
9
9
|
"module": "CommonJS",
|
|
10
10
|
"moduleResolution": "Node",
|
|
11
|
+
"noEmitOnError": true,
|
|
12
|
+
"noErrorTruncation": true,
|
|
11
13
|
"noImplicitAny": true,
|
|
12
14
|
"noImplicitOverride": true,
|
|
13
15
|
"noImplicitReturns": true,
|
|
14
16
|
"noImplicitThis": true,
|
|
15
17
|
"noUncheckedIndexedAccess": true,
|
|
16
|
-
"outDir": "dist",
|
|
17
|
-
"
|
|
18
|
+
"outDir": "../dist",
|
|
19
|
+
"pretty": true,
|
|
20
|
+
"resolveJsonModule": true,
|
|
21
|
+
"rootDir": "../src",
|
|
18
22
|
"skipDefaultLibCheck": true,
|
|
19
23
|
"skipLibCheck": true,
|
|
20
24
|
"strict": true,
|
|
21
|
-
"target": "
|
|
25
|
+
"target": "ES2019",
|
|
22
26
|
"useUnknownInCatchVariables": true
|
|
23
27
|
},
|
|
24
28
|
"exclude": [
|
|
25
|
-
"dist",
|
|
26
|
-
"node_modules",
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
+
"../dist",
|
|
30
|
+
"../node_modules",
|
|
31
|
+
"../test-files",
|
|
32
|
+
"../.virmator"
|
|
29
33
|
],
|
|
30
34
|
"ts-node": {
|
|
31
35
|
"compilerOptions": {
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import {existsSync, lstatSync, readlinkSync} from 'fs';
|
|
3
|
+
import {relative} from 'path';
|
|
4
|
+
import {PluginOption} from 'vite';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Include actual paths and symlinked target paths if they exist.
|
|
8
|
+
*
|
|
9
|
+
* This is needed because when removing files from the watcher, sym links have be removed with the
|
|
10
|
+
* path to the symlink itself AND the path to the symlink target or the path will still be watched.
|
|
11
|
+
*/
|
|
12
|
+
function mapToActualPaths(paths: Readonly<string[]>): Readonly<string[]> {
|
|
13
|
+
return paths.reduce((accum, path) => {
|
|
14
|
+
if (existsSync(path)) {
|
|
15
|
+
if (lstatSync(path).isSymbolicLink()) {
|
|
16
|
+
console.info('reading symlink from', path);
|
|
17
|
+
// sym links AND the original path both need to be included
|
|
18
|
+
return accum.concat(readlinkSync(path), path);
|
|
19
|
+
} else {
|
|
20
|
+
return accum.concat(path);
|
|
21
|
+
}
|
|
22
|
+
} else {
|
|
23
|
+
return accum;
|
|
24
|
+
}
|
|
25
|
+
}, [] as string[]);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* There are similar plugins out there that try to do this but they aren't aggressive enough. This
|
|
30
|
+
* plugin literally always reloads on save, no questions asked.
|
|
31
|
+
*/
|
|
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 {
|
|
40
|
+
return {
|
|
41
|
+
name: 'alwaysReloadPlugin',
|
|
42
|
+
apply: 'serve',
|
|
43
|
+
config: () => ({server: {watch: {disableGlobbing: false}}}),
|
|
44
|
+
configureServer({watcher, ws, config: {logger}}) {
|
|
45
|
+
const {root = process.cwd(), inclusions = [], exclusions = []} = config;
|
|
46
|
+
let callingAlready = false;
|
|
47
|
+
let loggedAlready = false;
|
|
48
|
+
|
|
49
|
+
const reloadCallback = (path: string) => {
|
|
50
|
+
if (!loggedAlready) {
|
|
51
|
+
loggedAlready = true;
|
|
52
|
+
// log watched stuff so that we can make sure it's not watching too much
|
|
53
|
+
// console.info({watched: watcher.getWatched()});
|
|
54
|
+
}
|
|
55
|
+
// prevent duplicate calls cause the watcher is very eager to call callbacks multiple times in a row
|
|
56
|
+
if (!callingAlready) {
|
|
57
|
+
callingAlready = true;
|
|
58
|
+
ws.send({
|
|
59
|
+
type: 'full-reload',
|
|
60
|
+
path: '*',
|
|
61
|
+
});
|
|
62
|
+
logger.info(
|
|
63
|
+
`${chalk.green('page reload')} ${chalk.dim(relative(root, path))}`,
|
|
64
|
+
{clear: true, timestamp: true},
|
|
65
|
+
);
|
|
66
|
+
/**
|
|
67
|
+
* Debounce reloads calls so that they don't get spammed. If you're saving
|
|
68
|
+
* faster than this, then what the heck are you doing anyway?
|
|
69
|
+
*/
|
|
70
|
+
setTimeout(() => {
|
|
71
|
+
callingAlready = false;
|
|
72
|
+
}, 100);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
if (exclusions.length) {
|
|
77
|
+
watcher.unwatch(mapToActualPaths(exclusions));
|
|
78
|
+
// ignore macOS file system metadata stuff
|
|
79
|
+
watcher.unwatch('./**/.DS_Store');
|
|
80
|
+
}
|
|
81
|
+
if (inclusions.length) {
|
|
82
|
+
watcher.add(inclusions);
|
|
83
|
+
}
|
|
84
|
+
if (!watcher.listeners('change').includes(reloadCallback)) {
|
|
85
|
+
watcher.on('change', reloadCallback);
|
|
86
|
+
watcher.on('add', reloadCallback);
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
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;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {esbuildPlugin} from '@web/dev-server-esbuild';
|
|
2
|
+
import {playwrightLauncher} from '@web/test-runner-playwright';
|
|
3
|
+
import mochaConfig from './mocharc-base.js';
|
|
4
|
+
|
|
5
|
+
/** @type {import('@web/test-runner').TestRunnerConfig} */
|
|
6
|
+
const webTestRunnerConfig = {
|
|
7
|
+
browsers: [
|
|
8
|
+
playwrightLauncher({product: 'chromium'}),
|
|
9
|
+
playwrightLauncher({product: 'firefox'}),
|
|
10
|
+
playwrightLauncher({product: 'webkit'}),
|
|
11
|
+
],
|
|
12
|
+
// 2 minutes cause GitHub Actions be slow
|
|
13
|
+
browserStartTimeout: 120000,
|
|
14
|
+
concurrentBrowsers: 3,
|
|
15
|
+
coverage: true,
|
|
16
|
+
files: [
|
|
17
|
+
mochaConfig.spec,
|
|
18
|
+
],
|
|
19
|
+
nodeResolve: true,
|
|
20
|
+
plugins: [esbuildPlugin({ts: true})],
|
|
21
|
+
testFramework: {
|
|
22
|
+
config: {
|
|
23
|
+
// // uncomment for debugging
|
|
24
|
+
// timeout: 100000,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default webTestRunnerConfig;
|