Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch source to ESM, migrate from Jest to UVU, drop Node 16 #72

Merged
merged 4 commits into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"plugins": ["jest", "prettier"],
"extends": [
"eslint:recommended",
"plugin:jest/recommended",
"plugin:prettier/recommended"
],
"parserOptions": {
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
pull-requests: write
steps:
- name: '🚚 Checkout'
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: '🔏 Yarn Lock Changes'
uses: ./
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [16, 18, 20]
node: [18, 20, 21]
name: Testing on Node ${{ matrix.node }}
steps:
- name: '🚚 Checkout'
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: '🔧 Setup Node'
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: '📦️ Install dependencies'
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea
.yarn
node_modules
tests/ci/**/.yarnrc.yml
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Yarn Lock Changes
# Please use `main` as version before the stable release will be published as `v1`.
uses: Simek/yarn-lock-changes@main
Expand All @@ -36,6 +36,13 @@ jobs:
groupByType: false
```

> [!note]
> For Node 16 support, you can use the `v0.11` version tag in your workflow, instead of pointing to `main`:
> ```yml
> - name: Yarn Lock Changes
> uses: Simek/yarn-lock-changes@v0.11
> ```

### 🔌 Inputs

| Input | Required | Default | Description |
Expand Down
2 changes: 1 addition & 1 deletion assets/added.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/downgraded.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/removed.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/updated.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 0 additions & 3 deletions babel.config.js

This file was deleted.

10 changes: 3 additions & 7 deletions dist/index.js

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions jest.config.js

This file was deleted.

23 changes: 10 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,24 @@
"build": "ncc build ./src/action.js -m --target es2021",
"lint": "eslint .",
"optimize": "svgo -f ./assets",
"test": "jest"
"test": "uvu tests -i .cjs -i testUtils"
},
"dependencies": {
"@actions/core": "^1.10.1",
"@actions/github": "^5.1.1",
"js-base64": "^3.7.5",
"@actions/github": "^6.0.0",
"js-base64": "^3.7.6",
"markdown-table": "^3.0.3",
"semver": "^7.5.4"
},
"devDependencies": {
"@babel/core": "^7.23.2",
"@babel/preset-env": "^7.23.2",
"@vercel/ncc": "^0.38.1",
"@yarnpkg/lockfile": "^1.1.0",
"babel-jest": "^29.7.0",
"eslint": "^8.52.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-jest": "^27.4.3",
"eslint-plugin-prettier": "^5.0.1",
"jest": "^29.7.0",
"prettier": "^3.0.3",
"svgo": "^3.0.2"
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jest": "^27.6.3",
"eslint-plugin-prettier": "^5.1.3",
"prettier": "^3.2.4",
"svgo": "^3.2.0",
"uvu": "^0.5.6"
}
}
16 changes: 8 additions & 8 deletions src/action.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const { debug, getBooleanInput, getInput, setFailed, warning } = require('@actions/core');
const { context, getOctokit } = require('@actions/github');
const fs = require('fs');
const { Base64 } = require('js-base64');
const path = require('path');

const { STATUS, countStatuses, diffLocks, parseLock } = require('./utils');
const { createTable, createSummary } = require('./comment');
import { debug, getBooleanInput, getInput, setFailed, warning } from '@actions/core';
import { context, getOctokit } from '@actions/github';
import { Base64 } from 'js-base64';
import fs from 'node:fs';
import path from 'node:path';

import { createTable, createSummary } from './comment.mjs';
import { STATUS, countStatuses, diffLocks, parseLock } from './utils.mjs';

const getCommentId = async (octokit, oktokitParams, issueNumber, commentHeader) => {
const currentComments = await octokit.rest.issues.listComments({
Expand Down
4 changes: 2 additions & 2 deletions src/comment.js → src/comment.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { markdownTable } = require('markdown-table');
import { markdownTable }from 'markdown-table';

const { STATUS_ORDER, countStatuses } = require('./utils');
import { STATUS_ORDER, countStatuses } from './utils.mjs';

const ASSETS_URL = {
ADDED: 'https://git.io/J38HP',
Expand Down
8 changes: 4 additions & 4 deletions src/utils.js → src/utils.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const { warning } = require('@actions/core');
import { warning } from '@actions/core';

const semverCompare = require('semver/functions/compare');
const semverCoerce = require('semver/functions/coerce');
const semverValid = require('semver/functions/valid');
import semverCompare from 'semver/functions/compare.js';
import semverCoerce from 'semver/functions/coerce.js';
import semverValid from 'semver/functions/valid.js';

export const STATUS = {
ADDED: 'ADDED',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const lockfile = require('@yarnpkg/lockfile');
import lockfile from '@yarnpkg/lockfile';
import { test } from 'uvu';
import { is } from 'uvu/assert';

const { getTestLockContent } = require('../testUtils');
const { parseLock } = require('../../src/utils');
import { getTestLockContent } from '../testUtils.mjs';
import { parseLock }from '../../src/utils.mjs';

test('naive performance test', () => {
const contentA = getTestLockContent('classic-downgrade', 'a.lock');
Expand All @@ -25,5 +27,7 @@ test('naive performance test', () => {
const internalEnd = performance.now();
console.timeEnd('Internal parser');

expect(end - start).toBeGreaterThan(internalEnd - internalStart);
is((end - start) > (internalEnd - internalStart), true);
});

test.run();
File renamed without changes.
Loading
Loading