Skip to content

Commit

Permalink
Merge branch 'main' into ned/LC-620
Browse files Browse the repository at this point in the history
  • Loading branch information
nedredmond committed Oct 5, 2023
2 parents 5033535 + 82e55df commit aee7973
Show file tree
Hide file tree
Showing 78 changed files with 889 additions and 262 deletions.
2 changes: 0 additions & 2 deletions .changeset/metal-suits-cheat.md

This file was deleted.

2 changes: 0 additions & 2 deletions .changeset/nasty-beans-hang.md

This file was deleted.

6 changes: 0 additions & 6 deletions .changeset/new-flowers-study.md

This file was deleted.

File renamed without changes.
5 changes: 5 additions & 0 deletions .changeset/sour-cooks-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"perseus-build-settings": patch
---

Add build step to replace **lib_version** with each package's published package version
14 changes: 14 additions & 0 deletions .changeset/tiny-tomatoes-knock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
"@khanacademy/kas": patch
"@khanacademy/kmath": patch
"@khanacademy/math-input": patch
"@khanacademy/perseus": patch
"@khanacademy/perseus-core": patch
"@khanacademy/perseus-editor": patch
"@khanacademy/perseus-error": patch
"@khanacademy/perseus-linter": patch
"@khanacademy/pure-markdown": patch
"@khanacademy/simple-markdown": patch
---

Print package name and version when loaded in the page
2 changes: 0 additions & 2 deletions .changeset/yellow-needles-cover.md

This file was deleted.

14 changes: 3 additions & 11 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,12 @@ coverage:
round: down
range: "70...100"

status:
project:
default: on
patch:
default: off
changes:
default: off

comment:
layout: "diff, reach, files, footer"
behavior: default
require_changes: no
require_base: no
require_head: yes
require_changes: false
require_base: false
require_head: true

# https://docs.codecov.com/docs/ignoring-paths
ignore:
Expand Down
55 changes: 52 additions & 3 deletions .github/workflows/node-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ jobs:
id: match
with:
changed-files: ${{ steps.changed.outputs.files }}
files: packages/ # Only look for changes in packages
globs: "!(**/__tests__/*), !(**/__stories__/*), !(**/dist/*)" # Ignore test files
files: "packages/, config/build/" # Only look for changes in packages, build
globs: "!(**/__tests__/*), !(**/__testdata__/*), !(**/__stories__/*), !(**/dist/*)" # Ignore test files
matchAllGlobs: true # Default is to match any of the globs, which ends up matching all files
conjunctive: true # Only match files that match all of the above

- name: Verify changeset entries
uses: Khan/[email protected]
Expand Down Expand Up @@ -136,6 +138,14 @@ jobs:
- name: Run test with coverage
run: yarn cypress:ci

# Upload coverage report as an GitHub artifact so that it can be used
# later in upload_coverage.
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: cypress-coverage
path: ./.nyc_output/out.json

coverage:
name: Jest Coverage
runs-on: ${{ matrix.os }}
Expand All @@ -154,11 +164,50 @@ jobs:
- name: Jest with coverage
run: yarn coverage

# Upload coverage report as an GitHub artifact so that it can be used
# later in upload_coverage.
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: jest-coverage
path: ./coverage/coverage-final.json

upload_coverage:
name: Upload Coverage
runs-on: ubuntu-latest
needs: [cypress, coverage]
steps:
- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }} & Install & cache node_modules
uses: Khan/actions@shared-node-cache-v0
with:
node-version: ${{ matrix.node-version }}

- name: Download Jest Coverage
uses: actions/download-artifact@v2
with:
name: jest-coverage
# path to decompress the artifact into, decompressed file
# will be ./coverage-final.json
path: ./

- name: Download Cypress Coverage
uses: actions/download-artifact@v2
with:
name: cypress-coverage
# path to decompress the artifact into, decompressed file
# will be ./out.json
path: ./

# Upload both coverage files at once. This avoids issues where it Codecov
# shows the results from only one of the reports which would make it appear
# as though coverage dropped a lot.
- name: Upload Coverage
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage/coverage-final.json
files: ./coverage-final.json,./out.json

check_builds:
name: Check builds for changes in size
Expand Down
14 changes: 14 additions & 0 deletions .nycrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"all": true,
"include": [
"packages/*/src/**/*.js",
"packages/*/src/**/*.jsx",
"packages/*/src/**/*.ts",
"packages/*/src/**/*.tsx"
],
"exclude": [
"**/*.stories.tsx",
"**/*.test.ts",
"**/*.test.tsx"
]
}
30 changes: 12 additions & 18 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const babelConfig = require("../babel.config");
const util = require("util");
const path = require("path");
const fs = require("fs");
const glob = require("fast-glob");

module.exports = {
core: {
Expand Down Expand Up @@ -49,23 +49,17 @@ module.exports = {
});

const aliases = {};
fs.readdirSync(path.join(__dirname, "../packages")).forEach((name) => {
if (name.startsWith(".")) {
return;
}
const stat = fs.statSync(path.join(__dirname, "../packages", name));
if (stat.isFile()) {
return;
}
const pkgPath = path.join("../packages", name, "package.json");
const pkgJson = require(pkgPath);
aliases["@khanacademy/" + name] = path.join(
__dirname,
"../packages",
name,
pkgJson.source,
);
});
glob.sync(path.join(__dirname, "../packages/*/package.json")).forEach(
(pkgPath) => {
const pkgJson = require(pkgPath);
aliases[pkgJson.name] = path.join(
__dirname,
"../packages",
path.basename(path.dirname(pkgPath)),
pkgJson.source,
);
},
);
fs.readdirSync(path.join(__dirname, "../vendor")).forEach((name) => {
aliases[name] = path.join(__dirname, "../vendor", name);
});
Expand Down
18 changes: 16 additions & 2 deletions config/build/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const rootDir = ancesdir(__dirname);
*/

// Kahn's algorithm
// https://en.wikipedia.org/wiki/Topological_sorting#Kahn's_algorithm
// https://en.wikipedia.org/wiki/Topological_sorting#Kahn%27s_algorithm
const topoSort = (yarnWorkspacesOutput) => {
const sorted = [];
// the keys are depended on by the values
Expand Down Expand Up @@ -160,7 +160,7 @@ const getFormats = ({configFormats}) =>
*/
const createConfig = (
commandLineArgs,
{name, format, platform, inputFile, file, plugins},
{name, fullName, version, format, platform, inputFile, file, plugins},
) => {
const valueReplacementMappings = {
__IS_BROWSER__: platform === "browser",
Expand Down Expand Up @@ -188,6 +188,16 @@ const createConfig = (
preventAssignment: true,
values: valueReplacementMappings,
}),
// This replace() plugin instance injects the current package
// version and name into the output bundle. This provides useful
// runtime information anywhere that Perseus is used.
replace({
preventAssignment: true,
include: [makePackageBasedPath(name, "src/version.ts")],
values: {
__lib_version__: version,
},
}),
alias({
entries: {
hubble: path.join(rootDir, "vendor", "hubble"),
Expand Down Expand Up @@ -266,6 +276,8 @@ const getPackageInfo = (commandLineArgs, pkgName) => {
if (formats.has("cjs")) {
configs.push({
name: pkgName,
fullName: pkgJson.name,
version: pkgJson.version,
format: "cjs",
platform: "browser",
file: pkgJson.main,
Expand All @@ -275,6 +287,8 @@ const getPackageInfo = (commandLineArgs, pkgName) => {
if (formats.has("esm")) {
configs.push({
name: pkgName,
fullName: pkgJson.name,
version: pkgJson.version,
format: "esm",
platform: "browser",
file: pkgJson.module,
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,11 @@
},
"scripts": {
"gen:parsers": "yarn --cwd packages/kas gen:parsers",
"build": "yarn gen:parsers && rollup -c config/build/rollup.config.js",
"prebuild": "yarn gen:parsers",
"build": "rollup -c config/build/rollup.config.js",
"build:types": "yarn tsc --build tsconfig-build.json",
"build:prodsizecheck": "yarn gen:parsers && rollup -c config/build/rollup.config.js --configEnvironment='production'",
"watch": "rollup -c config/build/rollup.config.js --watch",
"build:prodsizecheck": "yarn build --configEnvironment='production'",
"watch": "yarn build --watch",
"clean": "rm -rf packages/*/dist && rm -rf packages/*/node_modules && rm -rf .nyc_output && rm -f packages/*/*.tsbuildinfo",
"coverage": "cross-env NODE_OPTIONS=--max_old_space_size=8192 yarn run jest --coverage",
"coverage:types": "cross-env NODE_OPTIONS=--max_old_space_size=8192 typescript-coverage-report",
Expand Down
4 changes: 3 additions & 1 deletion packages/kas/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
"gen:parsers": "node src/parser-generator.js",
"test": "bash -c 'yarn --silent --cwd \"../..\" test ${@:0} $($([[ ${@: -1} = -* ]] || [[ ${@: -1} = bash ]]) && echo $PWD)'"
},
"dependencies": {},
"dependencies": {
"@khanacademy/perseus-core": "1.1.0"
},
"devDependencies": {
"jison": "0.4.15",
"perseus-build-settings": "^0.2.0",
Expand Down
2 changes: 2 additions & 0 deletions packages/kas/src/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
export {libVersion} from "./version";

export * from "./nodes";
export {compare} from "./compare";
10 changes: 10 additions & 0 deletions packages/kas/src/version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// This file is processed by a Rollup plugin (replace) to inject the production
// version number during the release build.
// In dev, you'll never see the version number.

import {addLibraryVersionToPerseusDebug} from "@khanacademy/perseus-core";

const libName = "@khanacademy/kas";
export const libVersion = "__lib_version__";

addLibraryVersionToPerseusDebug(libName, libVersion);
4 changes: 3 additions & 1 deletion packages/kas/tsconfig-build.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
"outDir": "./dist",
"rootDir": "src"
},
"references": []
"references": [
{"path": "../perseus-core/tsconfig-build.json"}
]
}
4 changes: 3 additions & 1 deletion packages/kmath/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
"scripts": {
"test": "bash -c 'yarn --silent --cwd \"../..\" test ${@:0} $($([[ ${@: -1} = -* ]] || [[ ${@: -1} = bash ]]) && echo $PWD)'"
},
"dependencies": {},
"dependencies": {
"@khanacademy/perseus-core": "1.1.0"
},
"devDependencies": {
"perseus-build-settings": "^0.2.0",
"underscore": "1.4.4"
Expand Down
2 changes: 2 additions & 0 deletions packages/kmath/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export {libVersion} from "./version";

export * as number from "./number";
export * as vector from "./vector";
export * as point from "./point";
Expand Down
10 changes: 10 additions & 0 deletions packages/kmath/src/version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// This file is processed by a Rollup plugin (replace) to inject the production
// version number during the release build.
// In dev, you'll never see the version number.

import {addLibraryVersionToPerseusDebug} from "@khanacademy/perseus-core";

const libName = "@khanacademy/kmath";
export const libVersion = "__lib_version__";

addLibraryVersionToPerseusDebug(libName, libVersion);
4 changes: 3 additions & 1 deletion packages/kmath/tsconfig-build.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
"outDir": "./dist",
"rootDir": "src",
},
"references": []
"references": [
{"path": "../perseus-core/tsconfig-build.json"}
]
}
18 changes: 18 additions & 0 deletions packages/math-input/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# @khanacademy/math-input

## 14.0.0

### Major Changes

- 14138bb0: Move StatefulKeypadContextProvider into math-input
- 14138bb0: Hoist keypad active state into keypad context

## 13.1.0

### Minor Changes

- 3b19a1bf: Ensured that we're properly calling componentWillUnmount

### Patch Changes

- 7e2ae0ef: Bugfix for fraction button in v2 fraction keypad
- 1dc460c7: Add tests for mobile MathInput

## 13.0.0

### Major Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/math-input/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Khan Academy's new expression editor for the mobile web.",
"author": "Khan Academy",
"license": "MIT",
"version": "13.0.0",
"version": "14.0.0",
"publishConfig": {
"access": "public"
},
Expand Down
Loading

0 comments on commit aee7973

Please sign in to comment.