Skip to content
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
32 changes: 32 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: Node.js CI

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x, 16.x, 18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: yarn
# no --if-present support in yarn
# - run: yarn run build --if-present
- run: yarn test
3 changes: 2 additions & 1 deletion .xo-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"space": true,
"rules": {
"unicorn/prefer-spread": "off",
"unicorn/no-array-reduce": "off"
"unicorn/no-array-reduce": "off",
"unicorn/prefer-module": "off"
}
}
Empty file removed coverage.lcov
Empty file.
28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "human-object-diff",
"description": "Human Readable Difference Between Two Objects",
"version": "2.0.2",
"author": "Spencer Snyder <sasnyde2@gmail.com> (http://spencersnyder.io/)",
"author": "Spencer Snyder <sasnyde2@gmail.com> (https://spencersnyder.io/)",
"bugs": {
"url": "https://github.com/Spence-S/human-object-diff/issues",
"email": "sasnyde2@gmail.com"
Expand All @@ -13,28 +13,28 @@
]
},
"contributors": [
"Spencer Snyder <sasnyde2@gmail.com> (http://spencersnyder.io/)"
"Spencer Snyder <sasnyde2@gmail.com> (https://spencersnyder.io/)"
],
"dependencies": {
"date-fns": "^2.19.0",
"date-fns": "^2.29.3",
"deep-diff": "^1.0.2",
"fast-deep-equal": "^3.1.3",
"humanize-string": "^2.1.0",
"titleize": "^2.1.0"
},
"devDependencies": {
"@commitlint/cli": "^12.0.1",
"@commitlint/config-conventional": "^12.0.1",
"ava": "^3.15.0",
"codecov": "^3.8.1",
"@commitlint/cli": "^17.5.0",
"@commitlint/config-conventional": "^17.4.4",
"ava": "^5.2.0",
"codecov": "^3.8.2",
"cross-env": "^7.0.3",
"eslint": "^7.23.0",
"eslint-config-xo-lass": "1.0.5",
"eslint": "^8.36.0",
"eslint-config-xo-lass": "^2.0.1",
"xo": "^0.53.1",
"fixpack": "^4.0.0",
"husky": "^4.3.0",
"lint-staged": "^10.5.4",
"nyc": "^15.1.0",
"xo": "^0.38.2"
"husky": "^8.0.3",
"lint-staged": "^13.2.0",
"nyc": "^15.1.0"
},
"engines": {
"node": ">=8.3"
Expand All @@ -61,7 +61,7 @@
"fixpack"
]
},
"main": "index.js",
"main": "src/index.js",
"prettier": {
"singleQuote": true,
"bracketSpacing": true,
Expand Down
6 changes: 3 additions & 3 deletions src/diff/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const isArray = require('./utils/is-array');
const appendDotPath = require('./utils/append-dot-path');
const isObject = require('./utils/is-object');
const isArray = require('./utils/is-array.js');
const appendDotPath = require('./utils/append-dot-path.js');
const isObject = require('./utils/is-object.js');

class Diff {
constructor(diff) {
Expand Down
8 changes: 4 additions & 4 deletions src/engine/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const deepdiff = require('deep-diff');
const preProcessArrayDiffs = require('./utils/array-preprocessor');
const DiffSentence = require('../sentence');
const Diff = require('../diff');
const getPrefilter = require('./utils/get-prefilter');
const DiffSentence = require('../sentence/index.js');
const Diff = require('../diff/index.js');
const preProcessArrayDiffs = require('./utils/array-preprocessor.js');
const getPrefilter = require('./utils/get-prefilter.js');

function humanReadableDiff(lhs, rhs) {
const arrayDiffs = [];
Expand Down
12 changes: 4 additions & 8 deletions src/engine/utils/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,10 @@ module.exports = {
templates: {
N: '"FIELD", with a value of "NEWVALUE" (at DOTPATH) was added',
D: '"FIELD", with a value of "OLDVALUE" (at DOTPATH) was removed',
E:
'"FIELD", with a value of "OLDVALUE" (at DOTPATH) was changed to "NEWVALUE"',
I:
'Array "FIELD" (at DOTPATH), had a value of "NEWVALUE" inserted at index INDEX',
R:
'Array "FIELD" (at DOTPATH), had a value of "OLDVALUE" removed at index INDEX',
AE:
'Array "FIELD" (at DOTPATH), had a value of "OLDVALUE" changed to "NEWVALUE" at index INDEX',
E: '"FIELD", with a value of "OLDVALUE" (at DOTPATH) was changed to "NEWVALUE"',
I: 'Array "FIELD" (at DOTPATH), had a value of "NEWVALUE" inserted at index INDEX',
R: 'Array "FIELD" (at DOTPATH), had a value of "OLDVALUE" removed at index INDEX',
AE: 'Array "FIELD" (at DOTPATH), had a value of "OLDVALUE" changed to "NEWVALUE" at index INDEX',
NS: '"FIELD" (at DOTPATH) was added',
DS: '"FIELD" (at DOTPATH) was removed',
ES: '"FIELD" (at DOTPATH) was changed',
Expand Down
4 changes: 2 additions & 2 deletions index.js → src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const diff = require('./src/engine');
const defaults = require('./src/engine/utils/defaults');
const diff = require('./engine/index.js');
const defaults = require('./engine/utils/defaults.js');

class DiffEngine {
constructor(config = {}) {
Expand Down
8 changes: 4 additions & 4 deletions src/sentence/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const getNewVal = require('./utils/get-new-val');
const getField = require('./utils/get-field');
const getDotpath = require('./utils/get-dot-path');
const getOldVal = require('./utils/get-old-val');
const getNewVal = require('./utils/get-new-val.js');
const getField = require('./utils/get-field.js');
const getDotpath = require('./utils/get-dot-path.js');
const getOldVal = require('./utils/get-old-val.js');

class DiffSentence {
constructor(diff, config, templates) {
Expand Down
2 changes: 1 addition & 1 deletion src/sentence/utils/get-field.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const humanize = require('./humanize');
const humanize = require('./humanize.js');

function getField() {
let propertyIndex = this.diff.path.length - 1;
Expand Down
2 changes: 1 addition & 1 deletion src/sentence/utils/get-new-val.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const formatPropertyValue = require('./format-property-value');
const formatPropertyValue = require('./format-property-value.js');

function getNewValue() {
let formatted;
Expand Down
2 changes: 1 addition & 1 deletion src/sentence/utils/get-old-val.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const formatPropertyValue = require('./format-property-value');
const formatPropertyValue = require('./format-property-value.js');

function getOldValue() {
let formatted = '';
Expand Down
2 changes: 1 addition & 1 deletion test/arrays.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const test = require('ava');
const HRDiff = require('..');
const HRDiff = require('../src/index.js');

test.beforeEach((t) => {
t.context.hr = new HRDiff().diff;
Expand Down
2 changes: 1 addition & 1 deletion test/custom-templates.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const test = require('ava');
const HR = require('..');
const HR = require('../src/index.js');

test.beforeEach((t) => {
const templates = {
Expand Down
2 changes: 1 addition & 1 deletion test/ignore-arrays.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const test = require('ava');
const HR = require('..');
const HR = require('../src/index.js');

test.beforeEach((t) => {
t.context.hr = new HR({ ignoreArrays: true }).diff;
Expand Down
2 changes: 1 addition & 1 deletion test/prefilter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const test = require('ava');
const HR = require('..');
const HR = require('../src/index.js');

test.beforeEach((t) => {
t.context.hr = (config) => new HR(config).diff;
Expand Down
2 changes: 1 addition & 1 deletion test/sensitive-paths.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const test = require('ava');
const HR = require('..');
const HR = require('../src/index.js');

test.beforeEach((t) => {
const sensitivePaths = ['foo', 'bar', 'biz', 'arr', 'arr2', 'arr3'];
Expand Down
2 changes: 1 addition & 1 deletion test/test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const test = require('ava');
const HR = require('..');
const HR = require('../src/index.js');

test.beforeEach((t) => {
t.context.hr = new HR().diff;
Expand Down
Loading