Skip to content

Commit

Permalink
Merge branch 'main' into npm-registry-fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
raineorshine committed Mar 27, 2024
2 parents c6b5863 + 9ac6902 commit 377a47f
Show file tree
Hide file tree
Showing 67 changed files with 6,446 additions and 2,210 deletions.
30 changes: 13 additions & 17 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:

env:
FORCE_COLOR: 2
NODE_COV: 18
NODE_COV: 20

permissions:
contents: read
Expand All @@ -28,42 +28,38 @@ jobs:
strategy:
fail-fast: false
matrix:
node: [16, 18, 20]
node: [18, 20]
os: [ubuntu-latest, windows-latest]

steps:
- name: Clone repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: npm

# node v14 cannot install from current package-lock.json, so use npm install instea of npm ci.
# Cannot read property 'chalk' of undefined
# Regression: e88617964a009dbb9f5e973f64ff76ad289df68c
- name: Install npm dependencies
run: npm i
if: 'matrix.node == 14'

- name: Install npm dependencies
run: npm ci
if: 'matrix.node != 14'

- name: Build
run: npm run build

- name: Run tests
run: npm run test
- name: E2E Tests
run: npm run test:e2e
if: startsWith(matrix.os, 'ubuntu') && matrix.node == env.NODE_COV

- name: Unit Tests
run: npm run test:unit
if: (!(startsWith(matrix.os, 'ubuntu') && matrix.node == env.NODE_COV))

- name: Run tests with coverage
run: npx c8 -- npm test
- name: Tests with coverage
run: npx c8 -- npm run test:unit
if: startsWith(matrix.os, 'ubuntu') && matrix.node == env.NODE_COV

- name: Run Coveralls
- name: Coveralls
uses: coverallsapp/[email protected]
if: startsWith(matrix.os, 'ubuntu') && matrix.node == env.NODE_COV
with:
Expand Down
24 changes: 8 additions & 16 deletions .husky/post-commit → .hooks/post-commit
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

#!/usr/bin/env bash
SHORT_SHA=$(git rev-parse HEAD)
LINT_LOG="$TMPDIR"/lint."$SHORT_SHA".log

Expand All @@ -13,18 +11,14 @@ strip() {
notify() {
# if osascript is not supported, do nothing
if [ -f /usr/bin/osascript ]; then
# get '<SHORT_SHA> <FIRST_LINE_OF_COMMIT_MSG>'
COMMIT_INFO=$(git log --oneline -n 1 --format="%h %s")

# read back in the lint errors
# TODO: update for each tye of error
ERRORS=$(cat "$LINT_LOG" | sed 1,4d)
ERRORS=$(sed 1,4d "$LINT_LOG")

# Trigger apple- or OSA-script on supported platforms
/usr/bin/osascript -e "display notification \"$ERRORS\" with title \"ncu: $COMMIT_INFO: $*\""
/usr/bin/osascript -e "display notification \"$ERRORS\" with title \"$*\""
fi

# always clean up the lint output, and do not clag-up TMPDIR
# clean up
rm "$LINT_LOG"
}

Expand All @@ -37,9 +31,7 @@ if [ -z "$branch" ]; then
exit 0
fi

# Lint asynchrously, not blocking the terminal and piping all output to a file.
# IFF lint fails trigger a pop-up (on supported platforms) with at least the
# first error shown.
# We pipe output so that the terminal (tmux, vim, emacs etc.) isn't borked by
# stray output.
npm run lint:src | strip &> "$LINT_LOG" || notify "Lint Error" &
# Lint in the background, not blocking the terminal and piping all output to a file.
# If the lint fails, trigger a notification (on supported platforms) with at least the first error shown.
# We pipe output so that the terminal (tmux, vim, emacs etc.) isn't borked by stray output.
npm run lint:src | strip &>"$LINT_LOG" || notify "Lint Error" &
9 changes: 9 additions & 0 deletions .hooks/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh
fail=0

npm run lint || fail=1
npm run prettier -- --check || fail=1

if [ "$fail" -ne 0 ]; then
exit 1
fi
1 change: 0 additions & 1 deletion .husky/.gitignore

This file was deleted.

5 changes: 0 additions & 5 deletions .husky/pre-push

This file was deleted.

18 changes: 2 additions & 16 deletions .ncurc.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,13 @@
module.exports = {
format: 'group',
reject: [
// ESM only modules
// https://github.com/microsoft/TypeScript/issues/46452
// esm only modules
'find-up',
'get-stdin',
'globby',
/* pin to 4.0.0 to match make-fetch-happen/cacache. */
'chai',
'p-map',
'remote-git-tags',
'untildify',
// Broken in v6.0.0
// Working upgrade is in branch 'hosted-git-info', but hold off on merging due to node engine requirements: ^14.17.0 || ^16.13.0 || >=18.0.0
// https://github.com/npm/hosted-git-info/releases/tag/v6.0.0
'hosted-git-info',
// Removed support for node v14 in v0.35.0
'makdownlint-cli',
// manually keep in alignment with pacote's version of make-fetch-happen
'make-fetch-happen',
// major changes required to upgrade to v3
'spawn-please',
// v0.60.0 breaks cli option description output
// https://github.com/YousefED/typescript-json-schema/issues/568
'typescript-json-schema',
],
}
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
script-shell = bash
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ Options that take no arguments can be negated by prefixing them with `--no-`, e.
</tr>
<tr>
<td>--deprecated</td>
<td>Include deprecated packages.</td>
<td>Include deprecated packages. (default: true)</td>
</tr>
<tr>
<td><a href="#doctor">-d, --doctor</a></td>
Expand Down Expand Up @@ -344,7 +344,7 @@ Options that take no arguments can be negated by prefixing them with `--no-`, e.
</tr>
<tr>
<td><a href="#target">-t, --target &lt;value&gt;</a></td>
<td>Determines the version to upgrade to: latest, newest, greatest, minor, patch, semver, @[tag], or [function]. (default: latest)</td>
<td>Determines the version to upgrade to: latest, newest, greatest, minor, patch, semver, <code>@[tag]<code>, or [function]. (default: latest)</td>
</tr>
<tr>
<td>--timeout &lt;ms&gt;</td>
Expand Down Expand Up @@ -444,7 +444,9 @@ Usage:
ncu --filter [p]
ncu -f [p]

Include only package names matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function.
Include only package names matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function. Only included packages will be checked with `--peer`.

`--filter` runs _before_ new versions are fetched, in contrast to `--filterResults` which runs _after_.

The predicate function is only available in .ncurc.js or when importing npm-check-updates as a module, not on the command line.

Expand All @@ -467,7 +469,7 @@ filterFunction: (name, semver) => {

Filters out upgrades based on a user provided function.

`filterResults` runs _after_ new versions are fetched, in contrast to `filter` and `filterVersion`, which run _before_. This allows you to filter out upgrades with `filterResults` based on how the version has changed (e.g. a major version change).
`filterResults` runs _after_ new versions are fetched, in contrast to `filter`, `reject`, `filterVersion`, and `rejectVersion`, which run _before_. This allows you to filter out upgrades with `filterResults` based on how the version has changed (e.g. a major version change).

Only available in .ncurc.js or when importing npm-check-updates as a module.

Expand Down Expand Up @@ -589,7 +591,6 @@ Specifies the package manager to use when looking up versions.
<tr><td>yarn</td><td>System-installed yarn. Automatically used if yarn.lock is present.</td></tr>
<tr><td>pnpm</td><td>System-installed pnpm. Automatically used if pnpm-lock.yaml is present.</td></tr>
<tr><td>bun</td><td>System-installed bun. Automatically used if bun.lockb is present.</td></tr>
<tr><td>staticRegistry</td><td>Deprecated. Use --registryType json.</td></tr>
</table>
## peer
Expand Down Expand Up @@ -675,7 +676,9 @@ Usage:
ncu --reject [p]
ncu -x [p]
The inverse of `--filter`. Exclude package names matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function.
The inverse of `--filter`. Exclude package names matching the given string, wildcard, glob, comma-or-space-delimited list, /regex/, or predicate function. This will also exclude them from the `--peer` check.
`--reject` runs _before_ new versions are fetched, in contrast to `--filterResults` which runs _after_.
The predicate function is only available in .ncurc.js or when importing npm-check-updates as a module, not on the command line.
Expand Down Expand Up @@ -711,7 +714,7 @@ The predicate function is only available in .ncurc.js or when importing npm-chec
(See: https://git.coolaj86.com/coolaj86/semver-utils.js#semverutils-parse-semverstring)
@returns True if the package should be excluded, false if it should be included.
*/
filterVersionFunction: (name, semver) => {
rejectVersionFunction: (name, semver) => {
if (name.startsWith('@myorg/') && parseInt(semver[0]?.major) > 5) {
return true
}
Expand Down
Loading

0 comments on commit 377a47f

Please sign in to comment.