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

deps: @npmcli/[email protected] [email protected] #4141

Merged
merged 1 commit into from
Dec 8, 2021
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
4 changes: 2 additions & 2 deletions node_modules/@npmcli/arborist/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@npmcli/arborist",
"version": "4.1.0",
"version": "4.1.1",
"description": "Manage node_modules trees",
"dependencies": {
"@isaacs/string-locale-compare": "^1.1.0",
Expand All @@ -24,7 +24,7 @@
"npm-pick-manifest": "^6.1.0",
"npm-registry-fetch": "^11.0.0",
"pacote": "^12.0.2",
"parse-conflict-json": "^1.1.1",
"parse-conflict-json": "^2.0.1",
"proc-log": "^1.0.0",
"promise-all-reject-late": "^1.0.0",
"promise-call-limit": "^1.0.1",
Expand Down
110 changes: 110 additions & 0 deletions node_modules/just-diff-apply/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/*
const obj1 = {a: 3, b: 5};
diffApply(obj1,
[
{ "op": "remove", "path": ['b'] },
{ "op": "replace", "path": ['a'], "value": 4 },
{ "op": "add", "path": ['c'], "value": 5 }
]
);
obj1; // {a: 4, c: 5}

// using converter to apply jsPatch standard paths
// see http://jsonpatch.com
import {diff, jsonPatchPathConverter} from 'just-diff'
const obj2 = {a: 3, b: 5};
diffApply(obj2, [
{ "op": "remove", "path": '/b' },
{ "op": "replace", "path": '/a', "value": 4 }
{ "op": "add", "path": '/c', "value": 5 }
], jsonPatchPathConverter);
obj2; // {a: 4, c: 5}

// arrays
const obj3 = {a: 4, b: [1, 2, 3]};
diffApply(obj3, [
{ "op": "replace", "path": ['a'], "value": 3 }
{ "op": "replace", "path": ['b', 2], "value": 4 }
{ "op": "add", "path": ['b', 3], "value": 9 }
]);
obj3; // {a: 3, b: [1, 2, 4, 9]}

// nested paths
const obj4 = {a: 4, b: {c: 3}};
diffApply(obj4, [
{ "op": "replace", "path": ['a'], "value": 5 }
{ "op": "remove", "path": ['b', 'c']}
{ "op": "add", "path": ['b', 'd'], "value": 4 }
]);
obj4; // {a: 5, b: {d: 4}}
*/

var REMOVE = 'remove';
var REPLACE = 'replace';
var ADD = 'add';

function diffApply(obj, diff, pathConverter) {
if (!obj || typeof obj != 'object') {
throw new Error('base object must be an object or an array');
}

if (!Array.isArray(diff)) {
throw new Error('diff must be an array');
}

var diffLength = diff.length;
for (var i = 0; i < diffLength; i++) {
var thisDiff = diff[i];
var subObject = obj;
var thisOp = thisDiff.op;
var thisPath = thisDiff.path;
if (pathConverter) {
thisPath = pathConverter(thisPath);
if (!Array.isArray(thisPath)) {
throw new Error('pathConverter must return an array');
}
} else {
if (!Array.isArray(thisPath)) {
throw new Error(
'diff path must be an array, consider supplying a path converter'
);
}
}
var pathCopy = thisPath.slice();
var lastProp = pathCopy.pop();
if (lastProp == null) {
return false;
}
var thisProp;
while ((thisProp = pathCopy.shift()) != null) {
if (!(thisProp in subObject)) {
subObject[thisProp] = {};
}
subObject = subObject[thisProp];
}
if (thisOp === REMOVE || thisOp === REPLACE) {
if (!subObject.hasOwnProperty(lastProp)) {
throw new Error(
['expected to find property', thisDiff.path, 'in object', obj].join(
' '
)
);
}
}
if (thisOp === REMOVE) {
Array.isArray(subObject)
? subObject.splice(lastProp, 1)
: delete subObject[lastProp];
}
if (thisOp === REPLACE || thisOp === ADD) {
subObject[lastProp] = thisDiff.value;
}
}
return subObject;
}

function jsonPatchPathConverter(stringPath) {
return stringPath.split('/').slice(1);
}

export {diffApply, jsonPatchPathConverter};
12 changes: 10 additions & 2 deletions node_modules/just-diff-apply/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
{
"name": "just-diff-apply",
"version": "3.0.0",
"version": "4.0.1",
"description": "Apply a diff to an object. Optionally supports jsonPatch protocol",
"main": "index.js",
"module": "index.mjs",
"exports": {
".": {
"require": "./index.js",
"default": "./index.mjs"
}
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"build": "rollup -c"
},
"repository": "https://github.com/angus-c/just",
"keywords": [
Expand Down
3 changes: 3 additions & 0 deletions node_modules/just-diff-apply/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const createRollupConfig = require('../../config/createRollupConfig');

module.exports = createRollupConfig(__dirname);
146 changes: 146 additions & 0 deletions node_modules/just-diff/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
/*
const obj1 = {a: 4, b: 5};
const obj2 = {a: 3, b: 5};
const obj3 = {a: 4, c: 5};

diff(obj1, obj2);
[
{ "op": "replace", "path": ['a'], "value": 3 }
]

diff(obj2, obj3);
[
{ "op": "remove", "path": ['b'] },
{ "op": "replace", "path": ['a'], "value": 4 }
{ "op": "add", "path": ['c'], "value": 5 }
]

// using converter to generate jsPatch standard paths
// see http://jsonpatch.com
import {diff, jsonPatchPathConverter} from 'just-diff'
diff(obj1, obj2, jsonPatchPathConverter);
[
{ "op": "replace", "path": '/a', "value": 3 }
]

diff(obj2, obj3, jsonPatchPathConverter);
[
{ "op": "remove", "path": '/b' },
{ "op": "replace", "path": '/a', "value": 4 }
{ "op": "add", "path": '/c', "value": 5 }
]

// arrays
const obj4 = {a: 4, b: [1, 2, 3]};
const obj5 = {a: 3, b: [1, 2, 4]};
const obj6 = {a: 3, b: [1, 2, 4, 5]};

diff(obj4, obj5);
[
{ "op": "replace", "path": ['a'], "value": 3 }
{ "op": "replace", "path": ['b', 2], "value": 4 }
]

diff(obj5, obj6);
[
{ "op": "add", "path": ['b', 3], "value": 5 }
]

// nested paths
const obj7 = {a: 4, b: {c: 3}};
const obj8 = {a: 4, b: {c: 4}};
const obj9 = {a: 5, b: {d: 4}};

diff(obj7, obj8);
[
{ "op": "replace", "path": ['b', 'c'], "value": 4 }
]

diff(obj8, obj9);
[
{ "op": "replace", "path": ['a'], "value": 5 }
{ "op": "remove", "path": ['b', 'c']}
{ "op": "add", "path": ['b', 'd'], "value": 4 }
]
*/

function diff(obj1, obj2, pathConverter) {
if (!obj1 || typeof obj1 != 'object' || !obj2 || typeof obj2 != 'object') {
throw new Error('both arguments must be objects or arrays');
}

pathConverter ||
(pathConverter = function(arr) {
return arr;
});

function getDiff(obj1, obj2, basePath, diffs) {
var obj1Keys = Object.keys(obj1);
var obj1KeysLength = obj1Keys.length;
var obj2Keys = Object.keys(obj2);
var obj2KeysLength = obj2Keys.length;
var path;

for (var i = 0; i < obj1KeysLength; i++) {
var key = Array.isArray(obj1) ? Number(obj1Keys[i]) : obj1Keys[i];
if (!(key in obj2)) {
path = basePath.concat(key);
diffs.remove.push({
op: 'remove',
path: pathConverter(path),
});
}
}

for (var i = 0; i < obj2KeysLength; i++) {
var key = Array.isArray(obj2) ? Number(obj2Keys[i]) : obj2Keys[i];
var obj1AtKey = obj1[key];
var obj2AtKey = obj2[key];
if (!(key in obj1)) {
path = basePath.concat(key);
var obj2Value = obj2[key];
diffs.add.push({
op: 'add',
path: pathConverter(path),
value: obj2Value,
});
} else if (obj1AtKey !== obj2AtKey) {
if (
Object(obj1AtKey) !== obj1AtKey ||
Object(obj2AtKey) !== obj2AtKey
) {
path = pushReplace(path, basePath, key, diffs, pathConverter, obj2);
} else {
if (
!Object.keys(obj1AtKey).length &&
!Object.keys(obj2AtKey).length &&
String(obj1AtKey) != String(obj2AtKey)
) {
path = pushReplace(path, basePath, key, diffs, pathConverter, obj2);
} else {
getDiff(obj1[key], obj2[key], basePath.concat(key), diffs);
}
}
}
}

return diffs.remove.reverse().concat(diffs.replace).concat(diffs.add);
}
return getDiff(obj1, obj2, [], {remove: [], replace: [], add: []});
}

function pushReplace(path, basePath, key, diffs, pathConverter, obj2) {
path = basePath.concat(key);
diffs.replace.push({
op: 'replace',
path: pathConverter(path),
value: obj2[key],
});
return path;
}

function jsonPatchPathConverter(arrayPath) {
return [''].concat(arrayPath).join('/');
}

export {diff, jsonPatchPathConverter};
2 changes: 1 addition & 1 deletion node_modules/just-diff/index.tests.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import diffObj = require('./index');
import * as diffObj from './index'

const {diff, jsonPatchPathConverter} = diffObj;
const obj1 = {a: 2, b: 3};
Expand Down
14 changes: 11 additions & 3 deletions node_modules/just-diff/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
{
"name": "just-diff",
"version": "3.1.1",
"version": "5.0.1",
"description": "Return an object representing the diffs between two objects. Supports jsonPatch protocol",
"main": "index.js",
"module": "index.mjs",
"exports": {
".": {
"require": "./index.js",
"default": "./index.mjs"
}
},
"types": "index.d.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"build": "rollup -c"
},
"repository": "https://github.com/angus-c/just",
"keywords": [
Expand All @@ -20,4 +28,4 @@
"bugs": {
"url": "https://github.com/angus-c/just/issues"
}
}
}
3 changes: 3 additions & 0 deletions node_modules/just-diff/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const createRollupConfig = require('../../config/createRollupConfig');

module.exports = createRollupConfig(__dirname);
15 changes: 0 additions & 15 deletions node_modules/parse-conflict-json/LICENSE

This file was deleted.

20 changes: 20 additions & 0 deletions node_modules/parse-conflict-json/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!-- This file is automatically added by @npmcli/template-oss. Do not edit. -->

ISC License

Copyright npm, Inc.

Permission to use, copy, modify, and/or distribute this
software for any purpose with or without fee is hereby
granted, provided that the above copyright notice and this
permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND NPM DISCLAIMS ALL
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
EVENT SHALL NPM BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
USE OR PERFORMANCE OF THIS SOFTWARE.
Loading