Skip to content

Commit

Permalink
Core-JS support & Yarn 3 (#694)
Browse files Browse the repository at this point in the history
  • Loading branch information
SleeplessByte committed Jun 9, 2023
1 parent 01fefc5 commit 7b6a1ae
Show file tree
Hide file tree
Showing 13 changed files with 7,912 additions and 4,731 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'Format code'
name: 'javascript-test-runner / format'

on:
issue_comment:
Expand Down Expand Up @@ -60,6 +60,12 @@ jobs:
git clone $HEAD_REPO .
git checkout -b "$HEAD_REF" "origin/$HEAD_REF"
- name: Use Node.js LTS (18.x)
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c
with:
node-version: '18'
- name: Install project development dependencies
run: npm install --no-save
- name: 'Format code'
run: ./bin/format.sh

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
node-version: 18.x

- name: Install project dependencies
run: yarn install --frozen-lockfile --ignore-scripts
run: yarn install --frozen-lockfile

- name: Run exercism/javascript-test-runner ci precheck (lint code)
run: bin/lint.sh
Expand All @@ -39,7 +39,7 @@ jobs:
node-version: ${{ matrix.node-version }}

- name: Install project dependencies
run: yarn install --frozen-lockfile --ignore-scripts
run: yarn install --frozen-lockfile

- name: Build the test-runner (using Node ${{ matrix.node-version }})
run: bin/test.sh
4 changes: 2 additions & 2 deletions .github/workflows/pr.ci.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
node-version: 18.x

- name: Install project dependencies
run: yarn install --frozen-lockfile --ignore-scripts
run: yarn install --frozen-lockfile

- name: Run exercism/javascript ci precheck (lint code)
run: bin/lint.sh
Expand All @@ -41,7 +41,7 @@ jobs:
node-version: ${{ matrix.node-version }}

- name: Install project dependencies
run: yarn install --frozen-lockfile --ignore-scripts
run: yarn install --frozen-lockfile

- name: Build the test-runner (using Node ${{ matrix.node-version }})
run: bin/test.sh
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
node_modules
dist
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

/numbers.js
/numbers.spec.js
Expand All @@ -23,4 +30,4 @@ yarn-error.log
# Fixture development files
/test/fixtures/**/node_modules
/test/fixtures/**/package-lock.json
/test/fixtures/**/results.json
/test/fixtures/**/results.json
874 changes: 874 additions & 0 deletions .yarn/releases/yarn-3.6.0.cjs

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-3.6.0.cjs
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 4.0.0

- Update dependencies including core-js
- Update Yarn to stable (3+)
- Update bin/\* to use Yarn 3
- Update package.json to use Yarn 3
- Fix linting issues

## 3.3.1

- Fix debug logging
Expand Down
46 changes: 35 additions & 11 deletions bin/check-formatting.sh
Original file line number Diff line number Diff line change
@@ -1,27 +1,51 @@
#!/bin/bash
#!/usr/bin/env bash

if [ -z "$EXERCISM_PRETTIER_VERSION" ]; then
echo "Pulling prettier version from package.json"
EXERCISM_PRETTIER_VERSION=$(yarn list --pattern prettier | grep -Po '.*\sprettier@\K.*')
set -uo pipefail

if [ -z "${EXERCISM_PRETTIER_VERSION:-}" ]; then
echo "[format] pulling prettier version from yarn.lock using sed"
EXERCISM_PRETTIER_VERSION="$(yarn info prettier --json --name-only | sed -n -e 's/^"prettier@npm://' -e 's/"//p')"
echo "[format] expected version is now ${EXERCISM_PRETTIER_VERSION:-}"
fi

if [ -z "${EXERCISM_PRETTIER_VERSION:-}" ]; then
echo "Version could not be pulled using sed" >&2
echo "[format] pulling prettier version from yarn.lock using grep"
EXERCISM_PRETTIER_VERSION="$(yarn info prettier --json --name-only | grep -Po '"prettier@npm:\K[^"]+')"
echo "[format] expected version is now ${EXERCISM_PRETTIER_VERSION:-}"
fi

if [ -z "$EXERCISM_PRETTIER_VERSION" ]; then
if [ -z "${EXERCISM_PRETTIER_VERSION:-}" ]; then
echo "Version could not be pulled using grep or sed" >&2
echo ""
echo "---------------------------------------------------"
echo "This script requires the EXERCISM_PRETTIER_VERSION variable to work."
echo "Please see https://exercism.org/docs/building/markdown/style-guide for guidance."
echo "---------------------------------------------------"
echo "This is what yarn list reports:"
echo "$(yarn list prettier)"
echo "$(yarn -v)"
echo ""
echo "This is what yarn why reports:"
echo "$ yarn why prettier"
echo "$(yarn why prettier)"
echo ""
echo "And yarn info reports the following:"
echo "$ yarn info prettier --name-only"
echo "$(yarn info prettier --name-only)"
echo ""
echo "This is the version that can be extracted using grep:"
echo "$ yarn info prettier --json --name-only | grep -Po '"prettier@npm:\K[^"]+'"
echo "└─ $(yarn info prettier --json --name-only | grep -Po '"prettier@npm:\K[^"]+')"
echo ""
echo "This is the version that can be extracted:"
echo "$(yarn list --pattern prettier | grep -Po '.*\sprettier@\K.*')"
echo "This is the version that can be extracted using sed:"
echo "$ yarn info prettier --json --name-only | sed -n -e 's/^"prettier@npm://' -e 's/"//p'"
echo "└─ $(yarn info prettier --json --name-only | sed -n -e 's/^"prettier@npm://' -e 's/"//p')"
echo ""
echo "These files are found in the repo root:"
echo "$(ls -p | grep -v /)"
echo "---------------------------------------------------"
exit 1
else
echo "Running format with prettier@$EXERCISM_PRETTIER_VERSION"
echo "[format] running with prettier@$EXERCISM_PRETTIER_VERSION"
fi

npx "prettier@$EXERCISM_PRETTIER_VERSION" --check "**/*.{js,jsx,ts,tsx,css,sass,scss,html,json,md,yml}"
yarn dlx "prettier@$EXERCISM_PRETTIER_VERSION" --check "**/*.{js,jsx,ts,tsx,css,sass,scss,html,json,md,yml}"
44 changes: 34 additions & 10 deletions bin/format.sh
Original file line number Diff line number Diff line change
@@ -1,27 +1,51 @@
#!/usr/bin/env bash

if [ -z "$EXERCISM_PRETTIER_VERSION" ]; then
echo "Pulling prettier version from package.json"
EXERCISM_PRETTIER_VERSION=$(yarn list --pattern prettier | grep -Po '.*\sprettier@\K.*')
set -uo pipefail

if [ -z "${EXERCISM_PRETTIER_VERSION:-}" ]; then
echo "[format] pulling prettier version from yarn.lock using sed"
EXERCISM_PRETTIER_VERSION="$(yarn info prettier --json --name-only | sed -n -e 's/^"prettier@npm://' -e 's/"//p')"
echo "[format] expected version is now ${EXERCISM_PRETTIER_VERSION:-}"
fi

if [ -z "${EXERCISM_PRETTIER_VERSION:-}" ]; then
echo "Version could not be pulled using sed" >&2
echo "[format] pulling prettier version from yarn.lock using grep"
EXERCISM_PRETTIER_VERSION="$(yarn info prettier --json --name-only | grep -Po '"prettier@npm:\K[^"]+')"
echo "[format] expected version is now ${EXERCISM_PRETTIER_VERSION:-}"
fi

if [ -z "$EXERCISM_PRETTIER_VERSION" ]; then
if [ -z "${EXERCISM_PRETTIER_VERSION:-}" ]; then
echo "Version could not be pulled using grep or sed" >&2
echo ""
echo "---------------------------------------------------"
echo "This script requires the EXERCISM_PRETTIER_VERSION variable to work."
echo "Please see https://exercism.org/docs/building/markdown/style-guide for guidance."
echo "---------------------------------------------------"
echo "This is what yarn list reports:"
echo "$(yarn list prettier)"
echo "$(yarn -v)"
echo ""
echo "This is what yarn why reports:"
echo "$ yarn why prettier"
echo "$(yarn why prettier)"
echo ""
echo "And yarn info reports the following:"
echo "$ yarn info prettier --name-only"
echo "$(yarn info prettier --name-only)"
echo ""
echo "This is the version that can be extracted using grep:"
echo "$ yarn info prettier --json --name-only | grep -Po '"prettier@npm:\K[^"]+'"
echo "└─ $(yarn info prettier --json --name-only | grep -Po '"prettier@npm:\K[^"]+')"
echo ""
echo "This is the version that can be extracted:"
echo "$(yarn list --pattern prettier | grep -Po '.*\sprettier@\K.*')"
echo "This is the version that can be extracted using sed:"
echo "$ yarn info prettier --json --name-only | sed -n -e 's/^"prettier@npm://' -e 's/"//p'"
echo "└─ $(yarn info prettier --json --name-only | sed -n -e 's/^"prettier@npm://' -e 's/"//p')"
echo ""
echo "These files are found in the repo root:"
echo "$(ls -p | grep -v /)"
echo "---------------------------------------------------"
exit 1
else
echo "Running format with prettier@$EXERCISM_PRETTIER_VERSION"
echo "[format] running with prettier@$EXERCISM_PRETTIER_VERSION"
fi

npx "prettier@$EXERCISM_PRETTIER_VERSION" --write "**/*.{js,jsx,ts,tsx,css,sass,scss,html,json,md,yml}"
yarn dlx "prettier@$EXERCISM_PRETTIER_VERSION" --write "**/*.{js,jsx,ts,tsx,css,sass,scss,html,json,md,yml}"
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
Expand Down
63 changes: 31 additions & 32 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@exercism/javascript-test-runner",
"description": "Automated Test runner for exercism solutions in Javascript.",
"author": "Derk-Jan Karrenbeld <derk-jan+github@karrenbeld.info>",
"version": "3.3.1",
"version": "4.0.0",
"license": "AGPL-3.0-or-later",
"repository": {
"type": "git",
Expand All @@ -13,49 +13,48 @@
"doc": "./docs",
"test": "./test"
},
"bin": {
"javascript-test-runner": "bin/run.sh"
},
"bin": "bin/run.sh",
"scripts": {
"execute": "./bin/run.sh",
"execute:dev": "yarn build && yarn execute",
"prebuild": "rimraf ./dist",
"build": "yarn tsc --project ./src/tsconfig.json --outDir ./dist",
"clean": "rimraf ./dist",
"build": "yarn clean && yarn tsc --project ./src/tsconfig.json --outDir ./dist",
"watch": "yarn build -w",
"prepare": "yarn build",
"prepublishOnly": "yarn test:bare && yarn lint",
"prepack": "yarn build",
"prepublish": "yarn test:bare && yarn lint",
"lint": "yarn eslint src --ext ts,js,tsx,jsx,mjs -c .eslintrc.js && yarn eslint test --ext ts,js,tsx,jsx,mjs -c test/.eslintrc.js",
"test": "yarn build && yarn test:bare",
"test:bare": "jest --roots test --testPathIgnorePatterns=\"fixtures/\""
},
"dependencies": {
"@babel/core": "^7.19.3",
"@babel/node": "^7.19.1",
"@babel/preset-env": "^7.19.4",
"@babel/preset-typescript": "^7.18.6",
"@exercism/babel-preset-javascript": "^0.2.1",
"@babel/core": "^7.22.5",
"@babel/node": "^7.22.5",
"@babel/preset-env": "^7.22.5",
"@babel/preset-typescript": "^7.22.5",
"@exercism/babel-preset-javascript": "^0.4.0",
"@exercism/static-analysis": "^0.12.0",
"@typescript-eslint/typescript-estree": "^5.40.1",
"@typescript-eslint/visitor-keys": "^5.40.1",
"babel-jest": "^29.2.1",
"@typescript-eslint/typescript-estree": "^5.59.9",
"@typescript-eslint/visitor-keys": "^5.59.9",
"babel-jest": "^29.5.0",
"chalk": "^4.1.2",
"core-js": "~3.30.0",
"jest": "^29.2.1"
"core-js": "~3.30.2",
"jest": "^29.5.0"
},
"devDependencies": {
"@exercism/eslint-config-tooling": "^0.4.0",
"@tsconfig/node18": "^2.0.0",
"@types/jest": "^29.2.0",
"@types/node": "^20.2.5",
"@typescript-eslint/eslint-plugin": "^5.40.1",
"@typescript-eslint/parser": "^5.40.1",
"eslint": "^8.25.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^27.1.3",
"prettier": "^2.7.1",
"rimraf": "^5.0.0",
"ts-jest": "^29.0.3",
"typescript": "^5.0.2"
}
"@tsconfig/node18": "^2.0.1",
"@types/jest": "^29.5.2",
"@types/node": "^18.16.16",
"@typescript-eslint/eslint-plugin": "^5.59.9",
"@typescript-eslint/parser": "^5.59.9",
"eslint": "^8.42.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^27.2.1",
"prettier": "^2.8.8",
"rimraf": "^5.0.1",
"ts-jest": "^29.1.0",
"typescript": "~5.0.3"
},
"packageManager": "yarn@3.6.0"
}
5 changes: 3 additions & 2 deletions src/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ type ExerciseConfig = {
const OUTPUT_VERSION = 3

export class Output {
private results: Partial<OutputInterface> & Pick<OutputInterface, 'tests'>
private readonly results: Partial<OutputInterface> &
Pick<OutputInterface, 'tests'>
private readonly globalConfig: Config.GlobalConfig
private readonly outputFile: string
private readonly sources: Record<string, ParsedSource>
Expand Down Expand Up @@ -181,7 +182,7 @@ export class Output {
private configFlag(
flag: keyof NonNullable<ExerciseConfig['custom']>
): boolean {
if (!this.config || !this.config.custom) {
if (!this.config?.custom) {
return false
}

Expand Down
Loading

0 comments on commit 7b6a1ae

Please sign in to comment.