repository-provider
Advanced tools
Comparing version 9.0.2 to 9.0.3
@@ -5,6 +5,2 @@ 'use strict'; | ||
var stream = require('stream'); | ||
require('path'); | ||
require('fs'); | ||
function notImplementedError() { | ||
@@ -641,208 +637,2 @@ return new Error("not implemented"); | ||
/** | ||
* Representation of one file or directory entry | ||
* All names are asolute (no leading '/') and build with '/' | ||
* @property {string} name name inside of the container | ||
* | ||
* @param {string} name name inside of the container | ||
*/ | ||
class BaseEntry { | ||
constructor(name) { | ||
if (name[0] === "/" || name.indexOf("\\") >= 0) { | ||
throw new TypeError( | ||
`Names should not contain leading '/' or any '\\': ${name}` | ||
); | ||
} | ||
Object.defineProperties(this, { | ||
name: { value: name } | ||
}); | ||
} | ||
/** | ||
* | ||
* @return {string[]} UTI types | ||
*/ | ||
async getTypes() { | ||
return []; | ||
} | ||
get isCollection() { | ||
return false; | ||
} | ||
get isBlob() { | ||
return false; | ||
} | ||
toJSON() { | ||
return { | ||
name: this.name | ||
}; | ||
} | ||
async equals(other) { | ||
return ( | ||
other !== undefined && | ||
this.name === other.name && | ||
this.isCollection === other.isCollection && | ||
this.isBlob === other.isBlob | ||
); | ||
} | ||
} | ||
const {Readable} = stream; | ||
var toReadableStream = input => ( | ||
new Readable({ | ||
read() { | ||
this.push(input); | ||
this.push(null); | ||
} | ||
}) | ||
); | ||
/** | ||
* Content entries where a stream is the primary data representation | ||
*/ | ||
/** | ||
* Representation of one file or directory entry | ||
* All names are asolute (no leading '/') and build with '/' | ||
* @property {string} name file name inside of the repository | ||
* @property {string|Buffer|Stream} content | ||
* @property {string} type type of the content | ||
* @property {string} mode file permissions | ||
* @property {string} sha sha of the content | ||
* | ||
* @param {string} name file name inside of the repository | ||
* @param {string|Buffer|Stream} content | ||
* @param {string} type type of the content | ||
* @param {string} mode file permissions | ||
* @param {string} sha sha of the content | ||
*/ | ||
class Entry extends BaseEntry { | ||
static get TYPE_BLOB() { | ||
return "blob"; | ||
} | ||
static get TYPE_TREE() { | ||
return "tree"; | ||
} | ||
constructor( | ||
name, | ||
content = undefined, | ||
type = Entry.TYPE_BLOB, | ||
mode = "100644", | ||
sha | ||
) { | ||
super(name); | ||
Object.defineProperties(this, { | ||
content: { | ||
get() { | ||
return content; | ||
}, | ||
set(value) { | ||
content = value; | ||
} | ||
}, | ||
sha: { | ||
get() { | ||
return sha; | ||
}, | ||
set(value) { | ||
sha = value; | ||
} | ||
}, | ||
type: { value: type }, | ||
mode: { value: mode } | ||
}); | ||
} | ||
/** | ||
* Deliver content as string | ||
* @return {string} content | ||
*/ | ||
async getString() { | ||
if (typeof this.content === "string" || this.content instanceof String) { | ||
return this.content; | ||
} | ||
if (Buffer.isBuffer(this.content)) { | ||
return this.content.toString("utf8"); | ||
} | ||
return undefined; | ||
} | ||
async getBuffer() { | ||
if (Buffer.isBuffer(this.content)) { | ||
return this.content; | ||
} | ||
return undefined; | ||
} | ||
/** | ||
* Deliver content as read stream | ||
* @return {ReadableStream} content | ||
*/ | ||
async getReadStream() { | ||
return this.content instanceof stream.Stream | ||
? this.content | ||
: toReadableStream(this.content); | ||
} | ||
toJSON() { | ||
return Object.assign( | ||
{ | ||
type: this.type, | ||
mode: this.mode, | ||
sha: this.sha | ||
}, | ||
super.toJSON() | ||
); | ||
} | ||
/** | ||
* compare meta info against other entry | ||
* @param {Entry} other | ||
* @return {boolean} true if other has the same meta information (name...) | ||
*/ | ||
async equalsMeta(other) { | ||
return ( | ||
other !== undefined && | ||
(this.name === other.name && | ||
this.type === other.type && | ||
this.mode === other.mode) | ||
); | ||
} | ||
/** | ||
* compare content against other entry | ||
* @param {Entry} other | ||
* @return {boolean} true if other has the same content (bitwise) | ||
*/ | ||
async equalsContent(other) { | ||
if (Buffer.isBuffer(this.content)) { | ||
if (Buffer.isBuffer(other.content)) { | ||
return this.content.equals(other.content); | ||
} | ||
} | ||
const [a, b] = await Promise.all([this.getString(), other.getString()]); | ||
return a === b; | ||
} | ||
/** | ||
* compare against other entry | ||
* @param {Entry} other | ||
* @return {boolean} true if other describes the same content | ||
*/ | ||
async equals(other) { | ||
return (await this.equalsMeta(other)) && (await this.equalsContent(other)); | ||
} | ||
} | ||
/** | ||
* Abstract pull request | ||
@@ -1208,3 +998,3 @@ * {@link Repository#addPullRequest} | ||
get entryClass() { | ||
return Entry; | ||
return undefined; | ||
} | ||
@@ -1211,0 +1001,0 @@ |
{ | ||
"name": "repository-provider", | ||
"version": "9.0.2", | ||
"version": "9.0.3", | ||
"publishConfig": { | ||
@@ -32,5 +32,3 @@ "access": "public" | ||
"dependencies": { | ||
"content-entry": "^1.7.1", | ||
"loglevel-mixin": "^2.0.5", | ||
"to-readable-stream": "^1.0.0" | ||
"loglevel-mixin": "^2.0.5" | ||
}, | ||
@@ -42,3 +40,3 @@ "devDependencies": { | ||
"rollup": "^0.68.2", | ||
"rollup-plugin-cleanup": "^3.0.0", | ||
"rollup-plugin-cleanup": "^3.1.0", | ||
"rollup-plugin-commonjs": "^9.2.0", | ||
@@ -48,3 +46,3 @@ "rollup-plugin-executable": "^1.3.0", | ||
"rollup-plugin-node-resolve": "^4.0.0", | ||
"semantic-release": "^15.13.1", | ||
"semantic-release": "^15.13.2", | ||
"travis-deploy-once": "^5.0.11", | ||
@@ -55,3 +53,3 @@ "c8": "^3.2.1", | ||
"engines": { | ||
"node": ">=10.14.2" | ||
"node": ">=10.15.0" | ||
}, | ||
@@ -58,0 +56,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
1
0
78091
2198
- Removedcontent-entry@^1.7.1
- Removedto-readable-stream@^1.0.0
- Removedcontent-entry@1.9.0(transitive)
- Removedto-readable-stream@1.0.0(transitive)