|
2 | 2 | # Using package manager scripts |
3 | 3 |
|
4 | 4 | This repository is designed to work with the [pnpm](https://pnpm.io/) package |
5 | | -manager, and precludes installation of packages with other package managers. |
| 5 | +manager, and so precludes installation of packages with other package managers. |
6 | 6 | It also sets up a number of utility "scripts" that you can run via the package |
7 | 7 | manager to manipulate and execute the project's code. This page documents all |
8 | 8 | of the available scripts. |
9 | | -*/ |
| 9 | + **/ |
10 | 10 | { |
11 | 11 | name: 'frontscope', |
12 | 12 | version: '0.3.0', |
13 | 13 | scripts: { |
14 | | - 'help:help': 'echo Prints a list of available scripts and a reminder about how to get more help.', |
15 | | - help: "echo Available scripts -- execute \\`pnpm help:SCRIPTNAME\\` for help on SCRIPTNAME: && (pnpm run | grep '^\\s\\s\\S' | grep -v 'help\\|only\\|postinstall\\|prepare')", |
16 | | - 'help:dev': 'run-s -s help:dev:*', |
17 | | - 'help:dev:1': 'echo Compiles frontscope and starts a server running it.', |
18 | | - 'help:dev:2': 'echo Note the server will hot-reload the code from any', |
19 | | - 'help:dev:3': 'echo source files as they change, to ease development.', |
| 14 | + /** md |
| 15 | +### pnpm dev |
| 16 | +
|
| 17 | +Compiles frontscope and starts a server running it. Note the server will |
| 18 | +hot-reload the code from any source files as they change, to ease development. |
| 19 | +The documentation pages are not available in this server. |
| 20 | + **/ |
20 | 21 | dev: 'pnpm typecheck && vite', |
21 | | - 'help:doc:serve': 'run-s -s help:doc:serve:*', |
22 | | - 'help:doc:serve:1': "echo This is like the 'dev' script, but for the", |
23 | | - 'help:doc:serve:2': 'echo embedded documentation rather than the', |
24 | | - 'help:doc:serve:3': 'echo Numberscope interface itself.', |
| 22 | + /** md |
| 23 | +### pnpm doc:serve |
| 24 | +
|
| 25 | +This is like the 'dev' script, but for the embedded documentation rather |
| 26 | +than the Numberscope interface itself. So Numberscope visualizers will not |
| 27 | +be available, but the documentation pages will hot-reload as doc files are |
| 28 | +changed. |
| 29 | + **/ |
25 | 30 | 'doc:serve': '.venv/bin/mkdocs serve', |
26 | | - 'help:build': 'run-s -s help:build:*', |
27 | | - 'help:build:1': 'echo Compiles frontscope and minifies the result,', |
28 | | - 'help:build:2': 'echo producing a bundle ready for installation', |
29 | | - 'help:build:3': 'echo on a server.', |
| 31 | + /** md |
| 32 | +### pnpm build |
| 33 | +
|
| 34 | +Compiles frontscope and minifies the result, producing a bundle ready for |
| 35 | +preview or installation on a server. |
| 36 | + **/ |
30 | 37 | build: 'pnpm typecheck && vite build && .venv/bin/mkdocs build', |
31 | | - 'help:preview': 'run-s -s help:build:*', |
32 | | - 'help:preview:1': 'echo Serves the most recently built files -- the', |
33 | | - 'help:preview:2': "echo contents of the 'dist/' directory -- for you", |
34 | | - 'help:preview:3': "echo to preview. This script differs from 'dev' in", |
35 | | - 'help:preview:4': "echo that there isn't any hot module reload. It is", |
36 | | - 'help:preview:5': 'echo closer to what you will run in production.', |
| 38 | + /** md |
| 39 | +### pnpm preview |
| 40 | +
|
| 41 | +Serves the most recently built files (i.e., the contents of the `dist/` |
| 42 | +directory) for you to preview. This script differs from 'dev' in that there |
| 43 | +isn't any hot module reload. On the other hand, it is closer to what you will |
| 44 | +run in production, and both the Numberscope interface and the documentation |
| 45 | +pages are available. |
| 46 | + **/ |
37 | 47 | preview: 'vite preview', |
38 | | - 'help:test:unit': 'echo Runs unit tests.', |
| 48 | + /** md |
| 49 | +### pnpm test:unit |
| 50 | +
|
| 51 | +Runs unit tests. |
| 52 | + **/ |
39 | 53 | 'test:unit': 'vitest run', |
40 | | - 'help:typecheck': 'run-s -s help:typecheck:*', |
41 | | - 'help:typecheck:1': 'echo Checks for TypeScript errors in both .vue', |
42 | | - 'help:typecheck:2': 'echo and .ts files.', |
| 54 | + /** md |
| 55 | +### pnpm typecheck |
| 56 | +
|
| 57 | +Checks for TypeScript errors in both .vue and .ts files. |
| 58 | + **/ |
43 | 59 | typecheck: 'vue-tsc --noEmit -p tsconfig.vitest.json --composite false', |
44 | | - 'help:lint': 'run-s -s help:lintx:*', |
45 | | - 'help:lintx:01': 'echo If you would like to format your code before you', |
46 | | - 'help:lintx:02': 'echo make a commit with git -- which has hooks to do', |
47 | | - 'help:lintx:03': 'echo automatic formatting -- you can call this script', |
48 | | - 'help:lintx:04': "echo at any time. It runs 'prettier' and", |
49 | | - 'help:lintx:05': "echo 'eslint --fix' on the project files. Note that", |
50 | | - 'help:lintx:06': 'echo this operation does not simply _check_ the', |
51 | | - 'help:lintx:07': 'echo formatting of your files, it _formats_ them!', |
52 | | - 'help:lintx:08': 'echo At least, if possible -- there are some', |
53 | | - 'help:lintx:09': 'echo formatting/code errors that it does not know how', |
54 | | - 'help:lintx:10': 'echo to fix. These will simply be reported as errors.', |
55 | | - 'help:lintx:11': 'echo If any such issues are present at the time of a', |
56 | | - 'help:lintx:12': 'echo of a commit, presuming the standard git hooks', |
57 | | - 'help:lintx:13': 'echo this project sets up are in place, the commit', |
58 | | - 'help:lintx:14': 'echo will be rejected.', |
| 60 | + /** md |
| 61 | +### pnpm lint |
| 62 | +
|
| 63 | +If you would like to format your code before you make a commit with git (which |
| 64 | +has hooks to do automatic formatting), you can call this script at any time. |
| 65 | +It runs [prettier](https://prettier.io/) and `eslint --fix` |
| 66 | +(see https://eslint.org/) on the project files. Note that this operation does |
| 67 | +not simply _check_ the formatting of your files, it automatically _reformats_ |
| 68 | +them when it finds problems! |
| 69 | +
|
| 70 | +At least, if possible -- there are some formatting/code errors that it does |
| 71 | +not know how to fix. These will simply be reported as errors. If any such |
| 72 | +issues are present at the time of a commit, presuming the standard git hooks |
| 73 | +this project sets up are in place, the commit will be rejected. |
| 74 | + **/ |
59 | 75 | lint: 'prettier-eslint --write "**/*.*" && pnpm lint:check', |
60 | | - 'help:lint:check': 'run-s -s help:lint:check:*', |
61 | | - 'help:lint:check:01': "echo This is like the 'lint' script but only", |
62 | | - 'help:lint:check:02': 'echo reports problems; does not modify any of', |
63 | | - 'help:lint:check:03': 'echo your source files. Note that this script', |
64 | | - 'help:lint:check:04': 'echo might not report any errors but then a run', |
65 | | - 'help:lint:check:05': "echo of the 'lint' script might modify files.", |
66 | | - 'help:lint:check:06': "echo That can happen because 'prettier' does not", |
67 | | - 'help:lint:check:07': "echo have a 'diagnostic' mode in which it", |
68 | | - 'help:lint:check:08': 'echo reports discrepancies with its preferred', |
69 | | - 'help:lint:check:09': 'echo formatting, while some formatting not', |
70 | | - 'help:lint:check:10': 'echo preferred by prettier is nevertheless', |
71 | | - 'help:lint:check:11': 'echo acceptable to eslint.', |
| 76 | + /** md |
| 77 | +### pnpm lint:check |
| 78 | +
|
| 79 | +This is like the 'lint' script but only reports problems; it does not modify |
| 80 | +any of your source files. Note that this script might not report any errors |
| 81 | +but then a run of the 'lint' script might modify files. That behavior can |
| 82 | +occur because 'prettier' does not have a 'diagnostic' mode in which it |
| 83 | +reports discrepancies with its preferred formatting, while some formatting |
| 84 | +_not_ preferred by prettier is nevertheless acceptable to eslint. |
| 85 | + **/ |
72 | 86 | 'lint:check': 'eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --ignore-path .gitignore', |
73 | | - 'help:lint:list': 'run-s -s help:lint:list:*', |
74 | | - 'help:lint:list:1': "echo This is like the 'lint' script but only", |
75 | | - 'help:lint:list:2': 'echo _lists_ the files that would be changed.', |
76 | | - 'help:lint:list:3': 'echo It does not modify any source files or report', |
77 | | - 'help:lint:list:4': 'echo what the problems were or report any problems', |
78 | | - 'help:lint:list:5': 'echo that the tools do not know how to fix.', |
| 87 | + /** md |
| 88 | +### pnpm lint:list |
| 89 | +
|
| 90 | +This is like the 'lint' script but only _lists_ the files that would be |
| 91 | +changed. It does not modify any source files or report what the problems |
| 92 | +were or report any problems that the tools do not know how to fix. |
| 93 | + **/ |
79 | 94 | 'lint:list': 'prettier-eslint --list-different "**/*.*"', |
80 | | - 'help:lint:staged': 'echo Only for internal use in the pre-commit hook.', |
| 95 | + // Nothing below here is "advertised" for command-line use |
| 96 | + // The following is only for internal use in the pre-commit hook: |
81 | 97 | 'lint:staged': 'lint-staged', |
82 | | - '//only lifecycle scripts below here': 'echo', |
| 98 | + // And the remainder are life-cycle scripts: |
83 | 99 | prepare: 'husky install', |
84 | 100 | preinstall: 'npx only-allow pnpm', |
85 | 101 | postinstall: 'python3 -m venv .venv && .venv/bin/pip install -U pip && .venv/bin/pip install -r requirements.txt', |
@@ -107,7 +123,6 @@ of the available scripts. |
107 | 123 | jsdom: '^19.0.0', |
108 | 124 | 'lint-staged': '^13.0.3', |
109 | 125 | mathjs: '^10.5.3', |
110 | | - 'npm-run-all': '^4.1.5', |
111 | 126 | prettier: '^2.7.1', |
112 | 127 | 'prettier-eslint': '^15.0.1', |
113 | 128 | 'prettier-eslint-cli': '^6.0.1', |
|
0 commit comments