Switch npm to Yarn (#1522)

* Add testUrl to jest config

* Switch npm to Yarn
This commit is contained in:
ylemkimon
2018-07-30 03:36:27 +09:00
committed by Kevin Barabash
parent 702b3c807f
commit a76c4b9a2f
16 changed files with 8010 additions and 13106 deletions

View File

@@ -2,7 +2,7 @@
"linters": {
"katex-linter": {
"type": "script-and-regex",
"script-and-regex.script": "npm run test:lint || true",
"script-and-regex.script": "yarn run test:lint || true",
"script-and-regex.regex": "/^(?P<file>\\S+): line (?P<line>\\d+), col \\d+, (?P<message>.*)$/m"
}
}

View File

@@ -5,27 +5,27 @@ checkout_submodule: &checkout_submodule
git submodule sync
git submodule update --init --recursive
npm_cache_key: &npm_cache_key
npm-deps-v1-{{ checksum "package.json" }}
node_modules_cache_key: &node_modules_cache_key
yarn-deps-v1-{{ checksum "yarn.lock" }}
restore_npm_cache: &restore_npm_cache
restore_node_modules_cache: &restore_node_modules_cache
restore_cache:
keys:
- *npm_cache_key
- npm-deps-v1-
- *node_modules_cache_key
- yarn-deps-v1-
npm_install: &npm_install
yarn_install: &yarn_install
run:
name: Install npm dependencies
command: npm install
name: Install dependencies
command: yarn install
screenshotter: &screenshotter
steps:
- checkout
- *checkout_submodule
- *restore_npm_cache
- *npm_install
- *restore_node_modules_cache
- *yarn_install
- run:
name: Verify screenshots and generate diffs and new screenshots
@@ -55,23 +55,23 @@ jobs:
- checkout
- *checkout_submodule
- *restore_npm_cache
- *npm_install
- *restore_node_modules_cache
- *yarn_install
- save_cache:
key: *npm_cache_key
key: *node_modules_cache_key
paths:
- node_modules
- run:
name: Run tests
command: npm test -- -- --coverage
command: yarn test --coverage
- run:
name: Upload code coverage reports to Codecov
command: ./node_modules/.bin/codecov
- run:
name: Build KaTeX
command: npm run build
command: yarn run build
- store_artifacts:
path: dist/katex.js

View File

@@ -58,7 +58,7 @@ single file. The goal is to have all functions use this new system.
## Testing
Local testing can be done by running the webpack-dev-server using configuration
`webpack.dev.js`. Run `npm install` to install dependencies, and then `npm start`
`webpack.dev.js`. Run `yarn install` to install dependencies, and then `yarn start`
to start the server.
This will host an interactive editor at
@@ -68,13 +68,13 @@ changes.
webpack-dev-server 2.8.0 introduced a change which included ES6 keywords `const`
and `let` within the scripts being served to the browser, and therefore doesn't
support IE 9 and 10. If you want to test in IE 9 and 10, install version 2.7.1
by running `npm install webpack-dev-server@2.7.1`.
by running `yarn add webpack-dev-server@2.7.1`.
#### Jest tests
The JavaScript parser and some of the HTML and MathML tree
builders are tested with Jest. These tests can be run using node with
`npm run test:jest`. If you need to debug the tests see
`yarn run test:jest`. If you need to debug the tests see
[https://facebook.github.io/jest/docs/troubleshooting.html](https://facebook.github.io/jest/docs/troubleshooting.html)
The interactive editor can also be used for debugging tests in the browser by
@@ -88,9 +88,9 @@ tests when you submit a pull request, in case you forget.
If you make any changes to Parser.js, add Jest tests to ensure they work.
Some tests verify the structure of the output tree using [snapshot testing](https://facebook.github.io/jest/docs/en/snapshot-testing.html).
Those snapshots can be updated by running `npm run test:jest:update`.
Those snapshots can be updated by running `yarn run test:jest:update`.
Also, test code coverage can be collected by `npm run test:jest:coverage`.
Also, test code coverage can be collected by `yarn run test:jest:coverage`.
You can view the report in `coverage/lcov-report/index.html`.
#### Screenshot tests
@@ -126,7 +126,7 @@ try to test in IE 9, using [modern.ie](http://modern.ie) VMs.
## Building
KaTeX is built using webpack with configuration `webpack.config.js`. Run
`npm run build` to build the project.
`yarn run build` to build the project.
## Style guide
@@ -141,12 +141,12 @@ Code
In general, try to make your code blend in with the surrounding code.
The code can be linted by running `npm run test:lint`, which lints JavaScript
The code can be linted by running `yarn run test:lint`, which lints JavaScript
files using ESLint and stylesheets using stylelint. They must pass to commit
the changes.
Some files have flowtype annotations and can be checked for type errors using
Flow by running `npm run test:flow`. See [Flow](https://flow.org/) for more details.
Flow by running `yarn run test:flow`. See [Flow](https://flow.org/) for more details.
## Pull Requests
@@ -160,7 +160,7 @@ Flow by running `npm run test:flow`. See [Flow](https://flow.org/) for more deta
The fonts for KaTeX live in a submodule stored in `submodules/katex-fonts`.
When you first clone the KaTeX repository, use
`git submodule update --init --recursive` to download the corresponding
fonts repository. After running `npm install`, you should have Git hooks that
fonts repository. After running `yarn install`, you should have Git hooks that
will automatically run this command after switching to branches
where `submodules/katex-fonts` point to different commits.

4
cli.js
View File

@@ -2,7 +2,7 @@
// Simple CLI for KaTeX.
// Reads TeX from stdin, outputs HTML to stdout.
// To run this from the repository, you must first build KaTeX by running
// `npm install` and `npm run build`.
// `yarn install` and `yarn run build`.
/* eslint no-console:0 */
@@ -12,7 +12,7 @@ try {
} catch (e) {
console.error(
"KaTeX could not import, likely because dist/katex.js is missing.");
console.error("Please run 'npm install' and 'npm run build' before running");
console.error("Please run 'yarn install' and 'yarn run build' before running");
console.error("cli.js from the KaTeX repository.");
console.error();
throw e;

View File

@@ -29,7 +29,7 @@ before the close body tag:
```
See [index.html](index.html) for an example.
(To run this example from a clone of the repository, run `npm start`
(To run this example from a clone of the repository, run `yarn start`
in the root KaTeX directory, and then visit
http://localhost:7936/contrib/auto-render/index.html
with your web browser.)

View File

@@ -1,5 +1,5 @@
<!DOCTYPE html>
<!--To run this example from a clone of the repository, run `npm start`
<!--To run this example from a clone of the repository, run `yarn start`
in the root KaTeX directory and then visit with your web browser:
http://localhost:7936/contrib/auto-render/index.html
-->

View File

@@ -26,7 +26,7 @@ will just get the usual HTML copy/paste behavior.
```
See [index.html](index.html) for an example.
(To run this example from a clone of the repository, run `npm start`
(To run this example from a clone of the repository, run `yarn start`
in the root KaTeX directory, and then visit
http://localhost:7936/contrib/copy-tex/index.html
with your web browser.)

View File

@@ -1,5 +1,5 @@
<!DOCTYPE html>
<!--To run this example from a clone of the repository, run `npm start`
<!--To run this example from a clone of the repository, run `yarn start`
in the root KaTeX directory and then visit with your web browser:
http://localhost:7936/contrib/copy-tex/index.html
-->

View File

@@ -8,7 +8,7 @@ installed and running.
If all you want is (re)create
all the snapshots for all the browsers, then you can do so by:
npm run test:screenshots:update
yarn run test:screenshots:update
It will fetch all required selenium docker images, and use them to
take screenshots.
@@ -32,7 +32,7 @@ For Chrome, simply replace both occurrences of `firefox` with `chrome`.
It is possible to run `screenshotter.js` without the use of Docker:
npm install selenium-webdriver
yarn add selenium-webdriver
node dockers/Screenshotter/screenshotter.js
This will generate screenshots using the Firefox installed on your system.
@@ -69,7 +69,7 @@ Examples:
You can verify screenshots by running:
npm run test:screenshots
yarn run test:screenshots
or passing `--verify` option to `screenshotter.js` or `screenshotter.sh`.
See above for more details.

View File

@@ -30,7 +30,7 @@ the even larger overhead of setting up docker and creating the initial
image, then you may instead execute the commands
cd dockers/texcmp
npm install
yarn install
node texcmp.js
from the root of your KaTeX directory tree. Required tools include the

View File

@@ -14,7 +14,8 @@ npx katex
> Above uses the `npx` command to run the locally installed executable.
You can execute with the relative path: `./node_modules/.bin/katex`
> To use CLI from local clone, you need to build the project first.
See [Building from Source](node.md#building-from-source) for more details.
> To use CLI from local clone, you need to build the project first by
running `yarn run build`. See [Building from Source](node.md#building-from-source)
for more details.
## Options

View File

@@ -36,7 +36,7 @@ Based on this information and what you want to support with your website, you mi
For example, if you wanted to create a trimmed down version of KaTeX, you could only include the `woff` files and gain the most support with the least number of files. To do this:
1. Set `@use-ttf`, and `@use-woff2` to `false` at the top of [fonts.less](https://github.com/KaTeX/katex-fonts/blob/master/fonts.less).
2. Rebuild KaTeX by running `npm run build` from the top-level directory.
2. Rebuild KaTeX by running `yarn run build` from the top-level directory.
3. Include only the `build/fonts/*.woff2` files in your distribution.
## Location of font files
@@ -44,5 +44,5 @@ For example, if you wanted to create a trimmed down version of KaTeX, you could
The default build of KaTeX expects the KaTeX fonts to be located in a directory called `fonts` which is a sibling of the `katex.min.css` stylesheet. This can be changed as such:
1. At the top of the [fonts.less](https://github.com/KaTeX/katex-fonts/blob/master/fonts.less) file, set `@font-folder` to the location of your fonts. You can use relative or absolute paths, so setting it to `"/fonts"` would cause it to search for the fonts in a root `fonts` folder, while `"../fonts"` would search in a `fonts` directory one level above the `katex.min.css` file.
2. Rebuild KaTeX by running `npm run build` from the top-level directory.
2. Rebuild KaTeX by running `yarn run build` from the top-level directory.
3. Use the newly generated `build/katex.min.css` file, and place the fonts where you indicated.

13050
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -62,24 +62,24 @@
},
"bin": "cli.js",
"scripts": {
"test": "npm run prestart && npm run test:lint && npm run test:flow && npm run test:jest",
"test": "yarn run prestart && yarn run test:lint && yarn run test:flow && yarn run test:jest",
"test:lint": "eslint katex.js katex.webpack.js cli.js webpack.*.js src static test contrib dockers website && stylelint src/katex.less",
"test:flow": "flow",
"test:jest": "jest",
"test:jest:watch": "jest --watch",
"test:jest:update": "jest --updateSnapshot",
"test:jest:coverage": "jest --coverage",
"test:screenshots": "npm run test:screenshots:update -- --verify",
"test:screenshots:update": "npm run prestart && dockers/Screenshotter/screenshotter.sh",
"test:perf": "npm run prestart && NODE_ENV=test node test/perf-test.js",
"test:screenshots": "yarn run test:screenshots:update --verify",
"test:screenshots:update": "yarn run prestart && dockers/Screenshotter/screenshotter.sh",
"test:perf": "yarn run prestart && NODE_ENV=test node test/perf-test.js",
"clean": "rm -rf dist/ node_modules/",
"clean-install": "npm run clean && npm i",
"clean-install": "yarn run clean && yarn install",
"prestart": "node check-node-version.js && check-dependencies && node src/unicodeMake.js > src/unicodeSymbols.js",
"start": "webpack-dev-server --hot --config webpack.dev.js",
"analyze": "webpack --config webpack.analyze.js",
"build": "npm run prestart && rimraf dist/ && mkdirp dist && cp README.md dist && webpack",
"watch": "npm run build -- --watch",
"dist": "npm test && npm run build && npm run dist:zip",
"build": "yarn run prestart && rimraf dist/ && mkdirp dist && cp README.md dist && webpack",
"watch": "yarn run build --watch",
"dist": "yarn test && yarn run build && yarn run dist:zip",
"dist:zip": "cd dist && tar czf ../katex.tar.gz * && zip -rq ../katex.zip *"
},
"dependencies": {
@@ -87,7 +87,7 @@
},
"husky": {
"hooks": {
"pre-commit": "npm run test:lint",
"pre-commit": "yarn run test:lint",
"post-merge": "git submodule update --init --recursive",
"post-checkout": "git submodule update --init --recursive"
}
@@ -104,6 +104,7 @@
"testMatch": [
"**/test/*-spec.js"
],
"testURL": "http://localhost/",
"transform": {
"^.+\\.js$": "babel-jest"
}

View File

@@ -38,7 +38,7 @@ while [ $# -gt 0 ]; do
--dry-run|-n|--just-print)
DRY_RUN=true
git() { echo "git $*"; }
npm() { echo "npm $*"; }
yarn() { echo "yarn $*"; }
;;
-h|-\?|--help)
usage 0
@@ -74,10 +74,6 @@ if ! command git diff --stat --exit-code HEAD; then
echo "Please make sure you have no uncommitted changes" >&2
: $((++INSANE))
fi
if ! command npm owner ls katex | grep -q "^$(command npm whoami) <"; then
echo "You don't seem do be logged into npm, use \`npm login\`" >&2
: $((++INSANE))
fi
if [[ $BRANCH != @(v*|master) ]]; then
echo "'$BRANCH' does not look like a release branch to me" >&2
: $((++INSANE))
@@ -110,7 +106,7 @@ rm -f package.json.bak
# Build generated files and add them to the repository (for bower)
git clean -fdx dist
npm run dist
yarn run dist
sed -i.bak -E '/^\/dist\/$/d' .gitignore
rm -f .gitignore.bak
git add .gitignore dist/
@@ -127,7 +123,7 @@ git tag -a "v$VERSION" -m "v$VERSION"
git push origin "v$VERSION"
# Update npm (bower and cdnjs update automatically)
npm publish
yarn publish
if [ ! -z "$NEXT_VERSION" ]; then
# Go back to original branch to bump
@@ -158,7 +154,7 @@ echo "Don't forget to upload katex.tar.gz and katex.zip to the release!"
if [[ ${DRY_RUN} ]]; then
echo ""
echo "This was a dry run."
echo "Operations using git or npm were printed not executed."
echo "Operations using git or yarn were printed not executed."
echo "Some files got modified, though, so you might want to undo "
echo "these changes now, e.g. using \`git checkout -- .\` or similar."
echo ""

7956
yarn.lock Normal file

File diff suppressed because it is too large Load Diff