Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ts-pkg-installer

Package Overview
Dependencies
Maintainers
2
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-pkg-installer - npm Package Compare versions

Comparing version 1.0.14 to 1.1.0

bin/fs.d.ts

1

bin/ts-pkg-installer.d.ts

@@ -6,4 +6,3 @@ /// <reference path="../typings/commander/commander.d.ts" />

/// <reference path="../typings/lodash/lodash.d.ts" />
/// <reference path="../typings/mkdirp/mkdirp.d.ts" />
/// <reference path="../typings/node/node.d.ts" />
/// <reference path="util.d.ts" />

@@ -7,3 +7,2 @@ // ts-pkg-installer.ts

///<reference path="../typings/lodash/lodash.d.ts"/>
///<reference path="../typings/mkdirp/mkdirp.d.ts"/>
///<reference path="../typings/node/node.d.ts"/>

@@ -15,7 +14,6 @@ ///<reference path="./util.ts"/>

var assert = require('assert');
var BluePromise = require('bluebird');
var commander = require('commander');
var debug = require('debug');
var fs = require('fs');
var mkdirp = require('mkdirp');
var fs = require('./fs');
var P = require('bluebird');
var path = require('path');

@@ -25,3 +23,3 @@ // There is no DTS for this package, but we will promisify it later.

var util = require('./util');
BluePromise.longStackTraces();
P.longStackTraces();
// Command-line options, describing the structure of options in commander.

@@ -33,2 +31,3 @@ var Options = (function () {

this.dryRun = options.dryRun || false;
this.selfInstall = options.selfInstall || false;
this.verbose = options.verbose || false;

@@ -41,3 +40,7 @@ }

// Define the CLI.
commander.option('-f, --config-file <path>', 'Config file [' + defaultOptions.configFile + ']', defaultOptions.configFile).option('-n, --dry-run', 'Dry run (display what would happen without taking action)').option('-v, --verbose', 'Verbose logging');
commander
.option('-f, --config-file <path>', 'Config file [' + defaultOptions.configFile + ']', defaultOptions.configFile)
.option('-n, --dry-run', 'Dry run (display what would happen without taking action)')
.option('-s, --self-install', 'Install in module\'s own directory instead of parent')
.option('-v, --verbose', 'Verbose logging');
var debugNamespace = 'ts-pkg-installer';

@@ -75,15 +78,17 @@ var dlog = debug(debugNamespace);

})();
var readPackageJsonAsync = BluePromise.promisify(readPackageJson);
// ## fsExistsAsync
// Special handling for fs.exists, which does not conform to Node.js standards for async interfaces.
// We must first normalize the fs.exists API to give it the node-like callback signature.
function normalizedFsExists(file, callback) {
fs.exists(file, function (exists) {
callback(null, exists);
});
var readPackageJsonAsync = P.promisify(readPackageJson);
// ## mkdirp
// Create a directory, and then dlog the real path created.
function mkdirp(dir) {
return fs.mkdirpP(dir)
.then(function (made) { return fs.realpathP(dir); })
.then(function (realpath) { dlog('Created', realpath); });
}
var fsExistsAsync = BluePromise.promisify(normalizedFsExists);
var fsReadFileAsync = BluePromise.promisify(fs.readFile);
var fsWriteFileAsync = BluePromise.promisify(fs.writeFile);
var mkdirpAsync = BluePromise.promisify(mkdirp);
// ## writeFile
// Write a file, and then dlog the real path written.
function writeFile(filePath, contents) {
return fs.writeFileP(filePath, contents)
.then(function () { return fs.realpathP(filePath); })
.then(function (realpath) { dlog('Wrote', realpath); });
}
// ### DeclarationFileState

@@ -112,18 +117,14 @@ // Maintain a state machine, separating the file into header and body sections.

dlog('main');
return this.readConfigFile().then(function () {
return this.readConfigFile()
.then(function () {
if (_this.shouldRun()) {
return _this.readPackageConfigFile().then(function () {
return _this.determineExportedTypingsSubdir();
}).then(function () {
return _this.wrapMainDeclaration();
}).then(function () {
return _this.copyExportedDeclarations();
}).then(function () {
return _this.readLocalTsdConfigFile();
}).then(function () {
return _this.maybeHaulTypings();
});
return _this.readPackageConfigFile()
.then(function () { return _this.determineExportedTypingsSubdir(); })
.then(function () { return _this.wrapMainDeclaration(); })
.then(function () { return _this.copyExportedDeclarations(); })
.then(function () { return _this.readLocalTsdConfigFile(); })
.then(function () { return _this.maybeHaulTypings(); });
}
else {
return BluePromise.resolve();
return P.resolve();
}

@@ -152,7 +153,8 @@ });

var readFromFile;
return fsExistsAsync(configFile).then(function (exists) {
return fs.existsP(configFile)
.then(function (exists) {
if (exists) {
dlog('Reading config file: ' + configFile);
readFromFile = true;
return fsReadFileAsync(configFile, 'utf8');
return fs.readFileP(configFile, 'utf8');
}

@@ -168,5 +170,6 @@ else {

// Parse an empty JSON object to use the defaults.
return BluePromise.resolve('{}');
return P.resolve('{}');
}
}).then(function (contents) {
})
.then(function (contents) {
if (readFromFile) {

@@ -187,3 +190,7 @@ dlog('Read config file: ' + configFile);

var grandparentDir = path.basename(path.dirname(parentPath));
var should = this.config.force || parentDir === 'node_modules' || (parentDir.charAt(0) === '@' && grandparentDir === 'node_modules');
var should = this.options.selfInstall || this.config.force || parentDir === 'node_modules' ||
(parentDir.charAt(0) === '@' && grandparentDir === 'node_modules');
if (this.options.selfInstall) {
dlog('Always self-install');
}
if (this.config.force) {

@@ -203,6 +210,9 @@ dlog('Forced to run');

dlog('Reading package config file: ' + packageConfigFile);
return fsReadFileAsync(packageConfigFile, 'utf8').then(function (contents) {
return fs.readFileP(packageConfigFile, 'utf8')
.then(function (contents) {
dlog('Read package config file: ' + packageConfigFile);
_this.packageConfig = new PackageConfig(JSON.parse(contents));
}).catch(function (error) {
})
.catch(function (error) {
// Create a more user-friendly error message
throw new Error('Package config file could not be read: ' + packageConfigFile);

@@ -217,7 +227,11 @@ });

TypeScriptPackageInstaller.prototype.exportedTypingsDir = function () {
return this.config.exportedTypingsDir || (this.isPackageScoped() ? path.join('..', '..', '..', 'typings') : path.join('..', '..', 'typings'));
return this.config.exportedTypingsDir ||
(this.options.selfInstall ? 'typings'
: (this.isPackageScoped() ? path.join('..', '..', '..', 'typings') : path.join('..', '..', 'typings')));
};
// Determine the appropriate directory in which to export the TSD config (tsd.json) file.
TypeScriptPackageInstaller.prototype.exportedTsdConfigPath = function () {
return this.config.exportedTsdConfig || (this.isPackageScoped() ? path.join('..', '..', 'tsd.json') : path.join('..', 'tsd.json'));
return this.config.exportedTsdConfig ||
(this.options.selfInstall ? path.join('typings', 'tsd.json')
: (this.isPackageScoped() ? path.join('..', '..', 'tsd.json') : path.join('..', 'tsd.json')));
};

@@ -244,9 +258,13 @@ // Determine where we will write our main declaration file.

dlog('Reading main declaration file: ' + mainDeclarationFile);
return fsReadFileAsync(mainDeclarationFile, 'utf8').then(function (contents) {
return fs.readFileP(mainDeclarationFile, 'utf8')
.then(function (contents) {
dlog('Parsing main declaration file: ' + mainDeclarationFile);
return _this.wrapMainDeclarationContents(contents, mainDeclarationDir);
}).then(function (wrapped) {
})
.then(function (wrapped) {
dlog('Wrapped main declaration file:\n' + wrapped);
_this.wrappedMainDeclaration = wrapped;
}).catch(function (error) {
})
.catch(function (error) {
// Create a more user-friendly error message
throw new Error('Main declaration file could not be wrapped: ' + error.toString());

@@ -290,3 +308,3 @@ });

// Maintain a state machine, separating the file into header and body sections.
var state = 0 /* Header */;
var state = DeclarationFileState.Header;
// We may not be wrapping the main declaration in an ambient external module declaration.

@@ -297,3 +315,3 @@ if (this.config.noWrap) {

var reducer = function (wrapped, line) {
if (state === 0 /* Header */) {
if (state === DeclarationFileState.Header) {
// See if we have a reference path (which is a form of comment).

@@ -318,7 +336,7 @@ var referencePathMatches = line.match(TypeScriptPackageInstaller.referencePathRegex);

}
state = 1 /* Body */;
state = DeclarationFileState.Body;
}
}
}
if (state === 1 /* Body */ && !(_this.config.noWrap)) {
if (state === DeclarationFileState.Body && !(_this.config.noWrap)) {
// See if we have a declaration of some sort.

@@ -338,8 +356,9 @@ var declarationMatches = line.match(declarationRegex);

};
return BluePromise.reduce(lines, reducer, []).then(function (wrapped) {
return P.reduce(lines, reducer, [])
.then(function (wrapped) {
if (!(_this.config.noWrap)) {
// If we're still in the header (i.e. we had no body lines), then emit the module declaration now.
if (state === 0 /* Header */) {
if (state === DeclarationFileState.Header) {
wrapped.push(_this.moduleDeclaration());
state = 1 /* Body */;
state = DeclarationFileState.Body;
}

@@ -374,3 +393,4 @@ // End by closing the module declaration

};
return BluePromise.reduce(lines, reducer, []).then(function (wrapped) {
return P.reduce(lines, reducer, [])
.then(function (wrapped) {
return wrapped.join('\n');

@@ -431,3 +451,4 @@ });

var _this = this;
return this.copyMainModuleDeclaration().then(function () { return _this.copySecondaryDeclarations(); });
return this.copyMainModuleDeclaration()
.then(function () { return _this.copySecondaryDeclarations(); });
};

@@ -442,5 +463,4 @@ // Copy the wrapped main module declaration into typings.

dlog('Creating directory for main declaration file: ' + this.exportedTypingsSubdir);
return this.maybeDo(function () {
return mkdirpAsync(_this.exportedTypingsSubdir);
}).then(function () {
return this.maybeDo(function () { return mkdirp(_this.exportedTypingsSubdir); })
.then(function () {
// Use the same basename.

@@ -450,5 +470,3 @@ var basename = path.basename(_this.determineMainDeclaration());

dlog('Writing main declaration file: ' + mainDeclaration);
return _this.maybeDo(function () {
return fsWriteFileAsync(mainDeclaration, _this.wrappedMainDeclaration);
});
return _this.maybeDo(function () { return writeFile(mainDeclaration, _this.wrappedMainDeclaration); });
});

@@ -462,5 +480,3 @@ };

var promises = _.map(this.config.secondaryDeclarations, function (basename) { return _this.copySecondaryDeclaration(basename); });
return BluePromise.all(promises).then(function () {
return;
});
return P.all(promises).then(function () { return; });
};

@@ -482,15 +498,18 @@ // Copy a single secondary declaration (as-is) into typings.

dlog('Creating directory for secondary declaration file:', destinationDir);
return mkdirpAsync(destinationDir);
}).then(function () {
return mkdirp(destinationDir);
})
.then(function () {
dlog('Copying secondary declaration file:', destinationFile);
return fsReadFileAsync(sourceFile, 'utf8');
}).then(function (contents) {
return fs.readFileP(sourceFile, 'utf8');
})
.then(function (contents) {
dlog('Parsing secondary declaration file:', sourceFile);
return _this.rewriteSecondaryDeclarationContents(contents, sourceDeclarationDir);
}).then(function (wrapped) {
})
.then(function (wrapped) {
dlog('Wrapped secondary declaration file:\n', wrapped);
return _this.maybeDo(function () {
return fsWriteFileAsync(destinationFile, wrapped);
});
}).catch(function (error) {
return _this.maybeDo(function () { return writeFile(destinationFile, wrapped); });
})
.catch(function (error) {
// Create a more user-friendly error message
throw new Error('Secondary declaration file ' + sourceFile + ' could not be wrapped: ' + error.toString());

@@ -503,3 +522,4 @@ });

assert(this.config && this.config.localTsdConfig);
return this.readTsdConfigFile(this.config.localTsdConfig).then(function (config) {
return this.readTsdConfigFile(this.config.localTsdConfig)
.then(function (config) {
_this.localTsdConfig = config;

@@ -512,3 +532,4 @@ });

assert(this.config && this.exportedTsdConfigPath());
return this.readTsdConfigFile(this.exportedTsdConfigPath()).then(function (config) {
return this.readTsdConfigFile(this.exportedTsdConfigPath())
.then(function (config) {
_this.exportedTsdConfig = config;

@@ -520,6 +541,8 @@ });

dlog('Reading TSD config file: ' + path);
return fsReadFileAsync(path, 'utf8').then(function (contents) {
return fs.readFileP(path, 'utf8')
.then(function (contents) {
dlog('Read TSD config file: ' + path);
return new util.TsdConfig(JSON.parse(contents));
}).catch(function (error) {
})
.catch(function (error) {
// It's OK if the file isn't there.

@@ -536,6 +559,7 @@ dlog('Ignoring error reading TSD config file: ' + path + ': ' + error.toString());

dlog('No TSD typings to haul');
return BluePromise.resolve();
return P.resolve();
}
else {
return this.readExportedTsdConfigFile().then(function () {
return this.readExportedTsdConfigFile()
.then(function () {
_this.haulTypings();

@@ -566,5 +590,3 @@ });

dlog('Combined TSD typings:\n' + contents);
return this.maybeDo(function () {
return fsWriteFileAsync(_this.exportedTsdConfigPath(), contents);
});
return this.maybeDo(function () { return writeFile(_this.exportedTsdConfigPath(), contents); });
};

@@ -577,3 +599,3 @@ // Allow conditional execution based on dry run mode.

else {
return BluePromise.resolve();
return P.resolve();
}

@@ -588,3 +610,4 @@ };

var packageJsonFile = path.join(__dirname, '..', 'package.json');
return readPackageJsonAsync(packageJsonFile).then(function (packageJson) {
return readPackageJsonAsync(packageJsonFile)
.then(function (packageJson) {
var version = packageJson.version;

@@ -597,3 +620,4 @@ dlog('Version:', version);

// Determine the version before parsing command-line.
setVersion().then(function () {
setVersion()
.then(function () {
// Parse command line arguments.

@@ -610,3 +634,4 @@ commander.parse(process.argv);

var mgr = new TypeScriptPackageInstaller(options);
mgr.main().catch(function (err) {
mgr.main()
.catch(function (err) {
dlog(err.toString());

@@ -613,0 +638,0 @@ process.stderr.write(__filename + ': ' + err.toString() + '\n');

@@ -7,3 +7,2 @@ // ts-pkg-installer.ts

///<reference path="../typings/lodash/lodash.d.ts"/>
///<reference path="../typings/mkdirp/mkdirp.d.ts"/>
///<reference path="../typings/node/node.d.ts"/>

@@ -20,8 +19,7 @@

import assert = require('assert');
import BluePromise = require('bluebird');
import commander = require('commander');
import debug = require('debug');
import fs = require('fs');
import fs = require('./fs');
import glob = require('glob');
import mkdirp = require('mkdirp');
import P = require('bluebird');
import path = require('path');

@@ -34,3 +32,3 @@

BluePromise.longStackTraces();
P.longStackTraces();

@@ -41,2 +39,3 @@ // Command-line options, describing the structure of options in commander.

dryRun: boolean;
selfInstall: boolean;
verbose: boolean;

@@ -47,2 +46,3 @@

this.dryRun = options.dryRun || false;
this.selfInstall = options.selfInstall || false;
this.verbose = options.verbose || false;

@@ -59,2 +59,3 @@ }

.option('-n, --dry-run', 'Dry run (display what would happen without taking action)')
.option('-s, --self-install', 'Install in module\'s own directory instead of parent')
.option('-v, --verbose', 'Verbose logging');

@@ -137,45 +138,23 @@

// ## readPackageJsonAsync
interface IReadPackageJsonAsync {
(packageFile: string): BluePromise<string>;
interface ReadPackageJson {
(packageFile: string, callback: (err: Error, contents: string) => void): void;
}
var readPackageJsonAsync: IReadPackageJsonAsync = <IReadPackageJsonAsync> BluePromise.promisify(readPackageJson);
var readPackageJsonAsync = P.promisify(<ReadPackageJson>readPackageJson);
// ## fsExistsAsync
// Special handling for fs.exists, which does not conform to Node.js standards for async interfaces.
// We must first normalize the fs.exists API to give it the node-like callback signature.
function normalizedFsExists(file: string, callback: (error: Error, result: boolean) => void) {
fs.exists(file, (exists: boolean): void => {
callback(null, exists);
});
// ## mkdirp
// Create a directory, and then dlog the real path created.
function mkdirp(dir: string): P<void> {
return fs.mkdirpP(dir)
.then((made: string) => fs.realpathP(dir))
.then((realpath: string) => { dlog('Created', realpath); });
}
// Next, we wrap the normalized API with bluebird to make it return a promise.
interface IFsExistsAsync {
(file: string): BluePromise<boolean>;
// ## writeFile
// Write a file, and then dlog the real path written.
function writeFile(filePath: string, contents: string): P<void> {
return fs.writeFileP(filePath, contents)
.then(() => fs.realpathP(filePath))
.then((realpath: string) => { dlog('Wrote', realpath); });
}
var fsExistsAsync: IFsExistsAsync = <IFsExistsAsync> BluePromise.promisify(normalizedFsExists);
// ## fsReadFileAsync
// fs.readFile conforms to Node.js standards, so we only need to define the interface to make up for the deficiency in
// the bluebird TSD.
interface IFsReadFileAsync {
(file: string, encoding: string): BluePromise<string>;
}
var fsReadFileAsync: IFsReadFileAsync = <IFsReadFileAsync> BluePromise.promisify(fs.readFile);
// ## fsWriteFileAsync
// fs.writeFile conforms to Node.js standards, so we only need to define the interface to make up for the deficiency in
// the bluebird TSD.
interface IFsWriteFileAsync {
(file: string, contents: string): BluePromise<void>;
}
var fsWriteFileAsync: IFsWriteFileAsync = <IFsWriteFileAsync> BluePromise.promisify(fs.writeFile);
// ## mkdirp
interface IMkDirP {
(path: string): BluePromise<void>;
}
var mkdirpAsync: IMkDirP = <IMkDirP> BluePromise.promisify(mkdirp);
// ### DeclarationFileState

@@ -211,3 +190,3 @@ // Maintain a state machine, separating the file into header and body sections.

// Main entry point to install a TypeScript package as an NPM postinstall script.
main(): BluePromise<void> {
main(): P<void> {
dlog('main');

@@ -225,3 +204,3 @@

} else {
return BluePromise.resolve();
return P.resolve();
}

@@ -250,11 +229,11 @@ });

// Read the configuration file for this utility.
private readConfigFile(): BluePromise<void> {
private readConfigFile(): P<void> {
var configFile = this.options.configFile;
var readFromFile: boolean;
return fsExistsAsync(configFile)
.then((exists: boolean): BluePromise<string> => {
return fs.existsP(configFile)
.then((exists: boolean): P<string> => {
if (exists) {
dlog('Reading config file: ' + configFile);
readFromFile = true;
return fsReadFileAsync(configFile, 'utf8');
return fs.readFileP(configFile, 'utf8');
} else {

@@ -271,3 +250,3 @@ dlog('Config file not found: ' + configFile);

// Parse an empty JSON object to use the defaults.
return BluePromise.resolve('{}');
return P.resolve('{}');
}

@@ -292,4 +271,7 @@ })

var grandparentDir: string = path.basename(path.dirname(parentPath));
var should: boolean = this.config.force || parentDir === 'node_modules' ||
var should: boolean = this.options.selfInstall || this.config.force || parentDir === 'node_modules' ||
(parentDir.charAt(0) === '@' && grandparentDir === 'node_modules');
if (this.options.selfInstall) {
dlog('Always self-install');
}
if (this.config.force) {

@@ -305,7 +287,7 @@ dlog('Forced to run');

// Read the package configuration.
private readPackageConfigFile(): BluePromise<void> {
private readPackageConfigFile(): P<void> {
assert(this.config && this.config.packageConfig);
var packageConfigFile: string = this.config.packageConfig;
dlog('Reading package config file: ' + packageConfigFile);
return fsReadFileAsync(packageConfigFile, 'utf8')
return fs.readFileP(packageConfigFile, 'utf8')
.then((contents: string): void => {

@@ -329,3 +311,4 @@ dlog('Read package config file: ' + packageConfigFile);

return this.config.exportedTypingsDir ||
(this.isPackageScoped() ? path.join('..', '..', '..', 'typings') : path.join('..', '..', 'typings'));
(this.options.selfInstall ? 'typings'
: (this.isPackageScoped() ? path.join('..', '..', '..', 'typings') : path.join('..', '..', 'typings')));
}

@@ -336,3 +319,4 @@

return this.config.exportedTsdConfig ||
(this.isPackageScoped() ? path.join('..', '..', 'tsd.json') : path.join('..', 'tsd.json'));
(this.options.selfInstall ? path.join('typings', 'tsd.json')
: (this.isPackageScoped() ? path.join('..', '..', 'tsd.json') : path.join('..', 'tsd.json')));
}

@@ -353,3 +337,3 @@

// Wrap the main declaration file, by default based on the "main" JS file from package.json.
private wrapMainDeclaration(): BluePromise<void> {
private wrapMainDeclaration(): P<void> {
assert(this.config);

@@ -365,4 +349,4 @@ assert(this.config.typingsSubdir);

dlog('Reading main declaration file: ' + mainDeclarationFile);
return fsReadFileAsync(mainDeclarationFile, 'utf8')
.then((contents: string): BluePromise<string> => {
return fs.readFileP(mainDeclarationFile, 'utf8')
.then((contents: string): P<string> => {
dlog('Parsing main declaration file: ' + mainDeclarationFile);

@@ -410,3 +394,3 @@ return this.wrapMainDeclarationContents(contents, mainDeclarationDir);

// - *referencePathDir*: Directory to resolve related reference paths.
private wrapMainDeclarationContents(contents: string, referencePathDir: string): BluePromise<string> {
private wrapMainDeclarationContents(contents: string, referencePathDir: string): P<string> {
// Process each line in the main declaration file.

@@ -476,3 +460,3 @@ var lines: string[] = contents.split('\n');

return BluePromise.reduce(lines, reducer, [])
return P.reduce(lines, reducer, [])
.then((wrapped: string[]): string => {

@@ -499,3 +483,3 @@

// - *referencePathDir*: Directory to resolve related reference paths.
private rewriteSecondaryDeclarationContents(contents: string, referencePathDir: string): BluePromise<string> {
private rewriteSecondaryDeclarationContents(contents: string, referencePathDir: string): P<string> {
// Process each line in the main declaration file.

@@ -522,3 +506,3 @@ var lines: string[] = contents.split('\n');

return BluePromise.reduce(lines, reducer, [])
return P.reduce(lines, reducer, [])
.then((wrapped: string[]): string => {

@@ -591,3 +575,3 @@ return wrapped.join('\n');

// Copy exported declarations into typings.
private copyExportedDeclarations(): BluePromise<void> {
private copyExportedDeclarations(): P<void> {
return this.copyMainModuleDeclaration()

@@ -598,3 +582,3 @@ .then(() => this.copySecondaryDeclarations());

// Copy the wrapped main module declaration into typings.
private copyMainModuleDeclaration(): BluePromise<void> {
private copyMainModuleDeclaration(): P<void> {
assert(this.config);

@@ -606,4 +590,4 @@ assert(this.exportedTypingsSubdir);

dlog('Creating directory for main declaration file: ' + this.exportedTypingsSubdir);
return this.maybeDo((): BluePromise<void> => { return mkdirpAsync(this.exportedTypingsSubdir); })
.then((): BluePromise<void> => {
return this.maybeDo((): P<void> => mkdirp(this.exportedTypingsSubdir))
.then((): P<void> => {
// Use the same basename.

@@ -613,5 +597,3 @@ var basename: string = path.basename(this.determineMainDeclaration());

dlog('Writing main declaration file: ' + mainDeclaration);
return this.maybeDo((): BluePromise<void> => {
return fsWriteFileAsync(mainDeclaration, this.wrappedMainDeclaration);
});
return this.maybeDo((): P<void> => writeFile(mainDeclaration, this.wrappedMainDeclaration));
});

@@ -621,14 +603,14 @@ }

// Copy the secondary declarations (as-is) into typings.
private copySecondaryDeclarations(): BluePromise<void> {
private copySecondaryDeclarations(): P<void> {
assert(this.config);
assert(_.isArray(this.config.secondaryDeclarations));
var promises: BluePromise<void>[] =
var promises: P<void>[] =
_.map(this.config.secondaryDeclarations,
(basename: string): BluePromise<void> => this.copySecondaryDeclaration(basename));
return BluePromise.all(promises).then(() => { return; });
(basename: string): P<void> => this.copySecondaryDeclaration(basename));
return P.all(promises).then(() => { return; });
}
// Copy a single secondary declaration (as-is) into typings.
private copySecondaryDeclaration(sourceFile: string): BluePromise<void> {
private copySecondaryDeclaration(sourceFile: string): P<void> {
// Determine the directory containing the file, so that we will be able to resolve relative reference paths.

@@ -650,19 +632,17 @@ var mainDeclarationDir: string = this.determineMainDeclarationDir();

return this.maybeDo(
(): BluePromise<void> => {
(): P<void> => {
dlog('Creating directory for secondary declaration file:', destinationDir);
return mkdirpAsync(destinationDir);
return mkdirp(destinationDir);
})
.then((): BluePromise<string> => {
.then((): P<string> => {
dlog('Copying secondary declaration file:', destinationFile);
return fsReadFileAsync(sourceFile, 'utf8');
return fs.readFileP(sourceFile, 'utf8');
})
.then((contents: string): BluePromise<string> => {
.then((contents: string): P<string> => {
dlog('Parsing secondary declaration file:', sourceFile);
return this.rewriteSecondaryDeclarationContents(contents, sourceDeclarationDir);
})
.then((wrapped: string): BluePromise<void> => {
.then((wrapped: string): P<void> => {
dlog('Wrapped secondary declaration file:\n', wrapped);
return this.maybeDo((): BluePromise<void> => {
return fsWriteFileAsync(destinationFile, wrapped);
});
return this.maybeDo((): P<void> => writeFile(destinationFile, wrapped));
})

@@ -676,3 +656,3 @@ .catch((error: any): void => {

// Read the local TSD configuration.
private readLocalTsdConfigFile(): BluePromise<void> {
private readLocalTsdConfigFile(): P<void> {
assert(this.config && this.config.localTsdConfig);

@@ -686,3 +666,3 @@ return this.readTsdConfigFile(this.config.localTsdConfig)

// Read the exported TSD configuration (if any).
private readExportedTsdConfigFile(): BluePromise<void> {
private readExportedTsdConfigFile(): P<void> {
assert(this.config && this.exportedTsdConfigPath());

@@ -696,5 +676,5 @@ return this.readTsdConfigFile(this.exportedTsdConfigPath())

// Read the specified TSD configuration. Return null if file does not exist.
private readTsdConfigFile(path: string): BluePromise<util.TsdConfig> {
private readTsdConfigFile(path: string): P<util.TsdConfig> {
dlog('Reading TSD config file: ' + path);
return fsReadFileAsync(path, 'utf8')
return fs.readFileP(path, 'utf8')
.then((contents: string): util.TsdConfig => {

@@ -712,7 +692,7 @@ dlog('Read TSD config file: ' + path);

// Incorporate typings from our own dependencies (if any).
private maybeHaulTypings(): BluePromise<void> {
private maybeHaulTypings(): P<void> {
// If we have no typings, we don't have anything to do.
if (!this.localTsdConfig) {
dlog('No TSD typings to haul');
return BluePromise.resolve();
return P.resolve();
} else {

@@ -727,3 +707,3 @@ return this.readExportedTsdConfigFile()

// Incorporate typings from our own dependencies.
private haulTypings(): BluePromise<void> {
private haulTypings(): P<void> {
assert(this.localTsdConfig);

@@ -750,13 +730,11 @@ // If we have no existing exported typings, we can trivially export ours.

dlog('Combined TSD typings:\n' + contents);
return this.maybeDo((): BluePromise<void> => {
return fsWriteFileAsync(this.exportedTsdConfigPath(), contents);
});
return this.maybeDo((): P<void> => writeFile(this.exportedTsdConfigPath(), contents));
}
// Allow conditional execution based on dry run mode.
private maybeDo(action: () => BluePromise<void>): BluePromise<void> {
private maybeDo(action: () => P<void>): P<void> {
if (!this.options.dryRun) {
return action();
} else {
return BluePromise.resolve();
return P.resolve();
}

@@ -767,3 +745,3 @@ }

// Set the version of this tool based on package.json.
function setVersion(): BluePromise<void> {
function setVersion(): P<void> {
var packageJsonFile: string = path.join(__dirname, '..', 'package.json');

@@ -770,0 +748,0 @@ return readPackageJsonAsync(packageJsonFile)

@@ -25,3 +25,3 @@ // util.ts

export interface ITsdPackageMap {
[dtsFile: string]: TsdPackage
[dtsFile: string]: TsdPackage;
}

@@ -28,0 +28,0 @@

{
"name": "ts-pkg-installer",
"version": "1.0.14",
"version": "1.1.0",
"description": "TypeScript package installer",

@@ -23,21 +23,21 @@ "main": "bin/ts-pkg-installer.js",

"devDependencies": {
"chai": "=2.1.0",
"cucumber": "=0.4.7",
"chai": "=3.2.0",
"cucumber": "=0.5.2",
"groc": "=0.8.0",
"mocha": "=2.1.0",
"mocha": "=2.2.5",
"ncp": "=2.0.0",
"rimraf": "=2.2.8",
"tsd": "=0.6.0-beta.5",
"tslint": "=2.1.1",
"typescript": "=1.4.1"
"rimraf": "=2.4.2",
"tsd": "=0.6.1",
"tslint": "=2.4.2",
"typescript": "=1.5.3"
},
"dependencies": {
"bluebird": "=2.9.12",
"commander": "=2.6.0",
"debug": "=2.1.1",
"lodash": "=3.3.1",
"mkdirp": "=0.5.0",
"read-package-json": "=1.3.2",
"source-map-support": "=0.2.9"
"bluebird": "=2.9.34",
"commander": "=2.8.1",
"debug": "=2.2.0",
"lodash": "=3.10.1",
"mkdirp": "=0.5.1",
"read-package-json": "=2.0.0",
"source-map-support": "=0.3.2"
}
}

@@ -9,38 +9,38 @@ {

"node/node.d.ts": {
"commit": "ca32947b75a2b1203779dac7154ffbc232746e4d"
"commit": "e95958ac847d9a343bdc8d7cbc796a5f6da29f71"
},
"commander/commander.d.ts": {
"commit": "ca32947b75a2b1203779dac7154ffbc232746e4d"
"commit": "e95958ac847d9a343bdc8d7cbc796a5f6da29f71"
},
"debug/debug.d.ts": {
"commit": "ca32947b75a2b1203779dac7154ffbc232746e4d"
"commit": "e95958ac847d9a343bdc8d7cbc796a5f6da29f71"
},
"glob/glob.d.ts": {
"commit": "ca32947b75a2b1203779dac7154ffbc232746e4d"
"commit": "e95958ac847d9a343bdc8d7cbc796a5f6da29f71"
},
"minimatch/minimatch.d.ts": {
"commit": "ca32947b75a2b1203779dac7154ffbc232746e4d"
"commit": "e95958ac847d9a343bdc8d7cbc796a5f6da29f71"
},
"mocha/mocha.d.ts": {
"commit": "ca32947b75a2b1203779dac7154ffbc232746e4d"
"commit": "e95958ac847d9a343bdc8d7cbc796a5f6da29f71"
},
"chai/chai.d.ts": {
"commit": "ca32947b75a2b1203779dac7154ffbc232746e4d"
"commit": "e95958ac847d9a343bdc8d7cbc796a5f6da29f71"
},
"bluebird/bluebird.d.ts": {
"commit": "ca32947b75a2b1203779dac7154ffbc232746e4d"
"commit": "e95958ac847d9a343bdc8d7cbc796a5f6da29f71"
},
"rimraf/rimraf.d.ts": {
"commit": "6959dc430e4aeb24a1e392c6f824ef723d9ca85c"
"commit": "e95958ac847d9a343bdc8d7cbc796a5f6da29f71"
},
"mkdirp/mkdirp.d.ts": {
"commit": "6959dc430e4aeb24a1e392c6f824ef723d9ca85c"
"commit": "e95958ac847d9a343bdc8d7cbc796a5f6da29f71"
},
"ncp/ncp.d.ts": {
"commit": "9872b853d6facd11ab4eba733b2408e249d85082"
"commit": "e95958ac847d9a343bdc8d7cbc796a5f6da29f71"
},
"lodash/lodash.d.ts": {
"commit": "ec6e0ae9525a165ca94d751932dd387078800c1e"
"commit": "e95958ac847d9a343bdc8d7cbc796a5f6da29f71"
}
}
}

@@ -16,3 +16,3 @@ {

"indent": [true, 4],
"interface-name": true,
"interface-name": false,
"jsdoc-format": true,

@@ -19,0 +19,0 @@ "label-position": true,

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