Socket
Socket
Sign inDemoInstall

@definitelytyped/utils

Package Overview
Dependencies
Maintainers
7
Versions
260
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@definitelytyped/utils - npm Package Compare versions

Comparing version 0.0.22 to 0.0.23-next.0

dist/npm.d.ts

1

dist/index.d.ts

@@ -8,2 +8,3 @@ export * from "./assertions";

export * from "./miscellany";
export * from "./npm";
export * from "./process";

@@ -10,0 +11,0 @@ export * from "./progress";

@@ -13,2 +13,3 @@ "use strict";

__export(require("./miscellany"));
__export(require("./npm"));
__export(require("./process"));

@@ -15,0 +16,0 @@ __export(require("./progress"));

/// <reference types="node" />
import "./types/fstream";
import { FS } from "./fs";

@@ -30,5 +31,8 @@ export declare function readFile(path: string): Promise<string>;

export declare function makeHttpRequest(options: FetchOptions): Promise<string>;
export declare function sleep(seconds: number): Promise<void>;
export declare function isDirectory(path: string): Promise<boolean>;
export declare const npmInstallFlags = "--ignore-scripts --no-shrinkwrap --no-package-lock --no-bin-links --no-save";
export declare function downloadAndExtractFile(url: string): Promise<FS>;
export declare function gzip(input: NodeJS.ReadableStream): NodeJS.ReadableStream;
export declare function unGzip(input: NodeJS.ReadableStream): NodeJS.ReadableStream;
export declare function writeTgz(inputDirectory: string, outFileName: string): Promise<void>;
export declare function createTgz(dir: string, onError: (error: Error) => void): NodeJS.ReadableStream;

@@ -13,3 +13,6 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
require("./types/fstream");
const fs_extra_1 = require("fs-extra");
const fstream_1 = require("fstream");
const tar_1 = require("tar");
const tar_stream_1 = __importDefault(require("tar-stream"));

@@ -124,3 +127,3 @@ const https_1 = __importStar(require("https"));

}
await sleep(1);
await miscellany_1.sleep(1);
}

@@ -161,6 +164,2 @@ return doRequest(options, https_1.request, this.agent);

}
async function sleep(seconds) {
return new Promise(resolve => setTimeout(resolve, seconds * 1000));
}
exports.sleep = sleep;
async function isDirectory(path) {

@@ -212,2 +211,49 @@ return (await fs_extra_1.stat(path)).isDirectory();

exports.downloadAndExtractFile = downloadAndExtractFile;
function gzip(input) {
return input.pipe(zlib_1.default.createGzip());
}
exports.gzip = gzip;
function unGzip(input) {
const output = zlib_1.default.createGunzip();
input.pipe(output);
return output;
}
exports.unGzip = unGzip;
function writeTgz(inputDirectory, outFileName) {
return new Promise((resolve, reject) => {
resolve(streamDone(createTgz(inputDirectory, reject).pipe(fs_extra_1.createWriteStream(outFileName))));
});
}
exports.writeTgz = writeTgz;
// To output this for testing:
// `require("./dist/io").createTgz("./src", err => { throw err }).pipe(fs.createWriteStream("foo.tgz"))`
function createTgz(dir, onError) {
return gzip(createTar(dir, onError));
}
exports.createTgz = createTgz;
function createTar(dir, onError) {
const packer = tar_1.Pack({ noProprietary: true, path: dir }).on("error", onError);
return fstream_1.Reader({ path: dir, type: "Directory", filter: addDirectoryExecutablePermission })
.on("error", onError)
.pipe(packer);
}
/**
* Work around a bug where directories bundled on Windows do not have executable permission when extracted on Linux.
* https://github.com/npm/node-tar/issues/7#issuecomment-17572926
*/
function addDirectoryExecutablePermission(entry) {
if (entry.props.type === "Directory") {
entry.props.mode = addExecutePermissionsFromReadPermissions(entry.props.mode);
}
return true;
}
function addExecutePermissionsFromReadPermissions(mode) {
// Constant that gives execute permissions to owner, group, and others. "+x"
const allExecutePermissions = 0o111;
// Moves the bits for read permissions into the place for execute permissions.
// In other words, a component will have execute permissions if it has read permissions.
const readPermissionsAsExecutePermissions = (mode >>> 2) & allExecutePermissions; // tslint:disable-line no-bitwise
// Add these additional execute permissions to the mode.
return mode | readPermissionsAsExecutePermissions; // tslint:disable-line no-bitwise
}
//# sourceMappingURL=io.js.map

@@ -6,1 +6,2 @@ export declare function parseJson(text: string): object;

export declare function unmangleScopedPackage(packageName: string): string | undefined;
export declare function sleep(seconds: number): Promise<void>;

@@ -38,2 +38,6 @@ "use strict";

exports.unmangleScopedPackage = unmangleScopedPackage;
async function sleep(seconds) {
return new Promise(resolve => setTimeout(resolve, seconds * 1000));
}
exports.sleep = sleep;
//# sourceMappingURL=miscellany.js.map

8

package.json
{
"name": "@definitelytyped/utils",
"version": "0.0.22",
"version": "0.0.23-next.0",
"description": "Shared utilities for DefinitelyTyped tools",

@@ -25,2 +25,5 @@ "homepage": "https://github.com/DefinitelyTyped/tools#readme",

"fs-extra": "^8.1.0",
"fstream": "^1.0.12",
"npm-registry-client": "^8.6.0",
"tar": "^2.2.2",
"tar-stream": "^2.1.0"

@@ -31,2 +34,3 @@ },

"@types/fs-extra": "^8.1.0",
"@types/tar": "^4.0.3",
"@types/tar-stream": "^2.1.0"

@@ -37,3 +41,3 @@ },

},
"gitHead": "4e45286d52827c59b675e6eff0d2e248d8402a2a"
"gitHead": "88172254de4e02bd385b77e1d9a9d69f619afa4a"
}

@@ -8,2 +8,3 @@ export * from "./assertions";

export * from "./miscellany";
export * from "./npm";
export * from "./process";

@@ -10,0 +11,0 @@ export * from "./progress";

@@ -0,1 +1,2 @@

import "./types/fstream";
import {

@@ -6,4 +7,7 @@ readFile as readFileWithEncoding,

writeFile as writeFileWithEncoding,
writeJson as writeJsonRaw
writeJson as writeJsonRaw,
createWriteStream
} from "fs-extra";
import { FStreamEntry, Reader } from "fstream";
import { Pack } from "tar";
import tarStream from "tar-stream";

@@ -15,3 +19,3 @@ import https, { Agent, request } from "https";

import { StringDecoder } from "string_decoder";
import { parseJson, withoutStart } from "./miscellany";
import { parseJson, withoutStart, sleep } from "./miscellany";
import { FS, Dir, InMemoryFS } from "./fs";

@@ -166,6 +170,2 @@ import { assertDefined } from "./assertions";

export async function sleep(seconds: number): Promise<void> {
return new Promise<void>(resolve => setTimeout(resolve, seconds * 1000));
}
export async function isDirectory(path: string): Promise<boolean> {

@@ -222,1 +222,52 @@ return (await stat(path)).isDirectory();

}
export function gzip(input: NodeJS.ReadableStream): NodeJS.ReadableStream {
return input.pipe(zlib.createGzip());
}
export function unGzip(input: NodeJS.ReadableStream): NodeJS.ReadableStream {
const output = zlib.createGunzip();
input.pipe(output);
return output;
}
export function writeTgz(inputDirectory: string, outFileName: string): Promise<void> {
return new Promise<void>((resolve, reject) => {
resolve(streamDone(createTgz(inputDirectory, reject).pipe(createWriteStream(outFileName))));
});
}
// To output this for testing:
// `require("./dist/io").createTgz("./src", err => { throw err }).pipe(fs.createWriteStream("foo.tgz"))`
export function createTgz(dir: string, onError: (error: Error) => void): NodeJS.ReadableStream {
return gzip(createTar(dir, onError));
}
function createTar(dir: string, onError: (error: Error) => void): NodeJS.ReadableStream {
const packer = Pack({ noProprietary: true, path: dir }).on("error", onError);
return Reader({ path: dir, type: "Directory", filter: addDirectoryExecutablePermission })
.on("error", onError)
.pipe(packer);
}
/**
* Work around a bug where directories bundled on Windows do not have executable permission when extracted on Linux.
* https://github.com/npm/node-tar/issues/7#issuecomment-17572926
*/
function addDirectoryExecutablePermission(entry: FStreamEntry): boolean {
if (entry.props.type === "Directory") {
entry.props.mode = addExecutePermissionsFromReadPermissions(entry.props.mode);
}
return true;
}
function addExecutePermissionsFromReadPermissions(mode: number): number {
// Constant that gives execute permissions to owner, group, and others. "+x"
const allExecutePermissions = 0o111;
// Moves the bits for read permissions into the place for execute permissions.
// In other words, a component will have execute permissions if it has read permissions.
const readPermissionsAsExecutePermissions = (mode >>> 2) & allExecutePermissions; // tslint:disable-line no-bitwise
// Add these additional execute permissions to the mode.
return mode | readPermissionsAsExecutePermissions; // tslint:disable-line no-bitwise
}

@@ -32,1 +32,5 @@ import crypto from "crypto";

}
export async function sleep(seconds: number): Promise<void> {
return new Promise<void>(resolve => setTimeout(resolve, seconds * 1000));
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc