typings-core
Advanced tools
Comparing version 0.2.16 to 0.3.0
import Promise = require('any-promise'); | ||
import { CompiledOutput } from './lib/compile'; | ||
import { Emitter } from './interfaces'; | ||
import { InstallResult } from './install'; | ||
export interface BundleOptions { | ||
@@ -11,2 +11,2 @@ name?: string; | ||
} | ||
export declare function bundle(options: BundleOptions): Promise<CompiledOutput>; | ||
export declare function bundle(options: BundleOptions): Promise<InstallResult>; |
@@ -31,3 +31,3 @@ "use strict"; | ||
}) | ||
.then(function () { return output; }); | ||
.then(function () { return ({ tree: output.tree }); }); | ||
}); | ||
@@ -34,0 +34,0 @@ } |
import Promise = require('any-promise'); | ||
import { CompiledOutput } from './lib/compile'; | ||
import { parseDependencyExpression, buildDependencyExpression } from './utils/parse'; | ||
import { DependencyTree, Emitter } from './interfaces'; | ||
export { parseDependencyExpression, buildDependencyExpression }; | ||
export interface InstallDependencyOptions { | ||
@@ -17,6 +18,7 @@ save?: boolean; | ||
} | ||
export declare function install(options: InstallOptions): Promise<{ | ||
export interface InstallResult { | ||
tree: DependencyTree; | ||
}>; | ||
export declare function installDependencyRaw(raw: string, options: InstallDependencyOptions): Promise<CompiledOutput>; | ||
name?: string; | ||
} | ||
export declare function install(options: InstallOptions): Promise<InstallResult>; | ||
export interface InstallExpression { | ||
@@ -26,2 +28,5 @@ name: string; | ||
} | ||
export declare function installDependency(expression: InstallExpression, options: InstallDependencyOptions): Promise<CompiledOutput>; | ||
export declare function installDependencyRaw(raw: string, options: InstallDependencyOptions): Promise<InstallResult>; | ||
export declare function installDependenciesRaw(raw: string[], options: InstallDependencyOptions): Promise<InstallResult[]>; | ||
export declare function installDependency(expression: InstallExpression, options: InstallDependencyOptions): Promise<InstallResult>; | ||
export declare function installDependencies(expressions: InstallExpression[], options: InstallDependencyOptions): Promise<InstallResult[]>; |
@@ -12,2 +12,4 @@ "use strict"; | ||
var parse_1 = require('./utils/parse'); | ||
exports.parseDependencyExpression = parse_1.parseDependencyExpression; | ||
exports.buildDependencyExpression = parse_1.buildDependencyExpression; | ||
function install(options) { | ||
@@ -24,3 +26,3 @@ var cwd = options.cwd, production = options.production; | ||
var tree_1 = deps[name]; | ||
queue.push(installDependencyTree(tree_1, { cwd: cwd, name: name, ambient: ambient, emitter: emitter, meta: true })); | ||
queue.push(compile_1.default(tree_1, { cwd: cwd, name: name, ambient: ambient, emitter: emitter, meta: true })); | ||
} | ||
@@ -34,15 +36,7 @@ } | ||
return Promise.all(queue) | ||
.then(function (installed) { | ||
if (installed.length === 0) { | ||
var _a = path_2.getTypingsLocation({ cwd: cwd }), typingsDir = _a.typingsDir, mainDtsFile_1 = _a.mainDtsFile, browserDtsFile_1 = _a.browserDtsFile; | ||
return fs_1.mkdirp(typingsDir) | ||
.then(function () { | ||
return Promise.all([ | ||
fs_1.touch(mainDtsFile_1, {}), | ||
fs_1.touch(browserDtsFile_1, {}) | ||
]); | ||
}); | ||
} | ||
}) | ||
.then(function () { return ({ tree: tree }); }); | ||
.then(function (results) { | ||
return Promise.all(results.map(function (x) { return writeResult(x); })) | ||
.then(function () { return writeBundle(results, options); }) | ||
.then(function () { return ({ tree: tree }); }); | ||
}); | ||
}); | ||
@@ -52,13 +46,35 @@ } | ||
function installDependencyRaw(raw, options) { | ||
return installDependenciesRaw([raw], options).then(function (x) { return x[0]; }); | ||
} | ||
exports.installDependencyRaw = installDependencyRaw; | ||
function installDependenciesRaw(raw, options) { | ||
return new Promise(function (resolve) { | ||
return resolve(installDependency(parse_1.parseDependencyExpression(raw, options), options)); | ||
var expressions = raw.map(function (x) { return parse_1.parseDependencyExpression(x, options); }); | ||
return resolve(installDependencies(expressions, options)); | ||
}); | ||
} | ||
exports.installDependencyRaw = installDependencyRaw; | ||
exports.installDependenciesRaw = installDependenciesRaw; | ||
function installDependency(expression, options) { | ||
return installDependencies([expression], options).then(function (x) { return x[0]; }); | ||
} | ||
exports.installDependency = installDependency; | ||
function installDependencies(expressions, options) { | ||
var emitter = options.emitter || new events_1.EventEmitter(); | ||
return find_1.findProject(options.cwd) | ||
.then(function (cwd) { return installTo(expression, extend(options, { cwd: cwd })); }, function () { return installTo(expression, options); }); | ||
.then(function (cwd) { return extend(options, { cwd: cwd, emitter: emitter }); }, function () { return extend(options, { emitter: emitter }); }) | ||
.then(function (options) { | ||
return Promise.all(expressions.map(function (x) { return compileDependency(x, options); })) | ||
.then(function (results) { | ||
return Promise.all(results.map(function (x) { return writeResult(x); })) | ||
.then(function () { return writeBundle(results, options); }) | ||
.then(function () { return writeToConfig(results, options); }) | ||
.then(function () { return results.map(function (_a) { | ||
var name = _a.name, tree = _a.tree; | ||
return ({ name: name, tree: tree }); | ||
}); }); | ||
}); | ||
}); | ||
} | ||
exports.installDependency = installDependency; | ||
function installTo(expression, options) { | ||
exports.installDependencies = installDependencies; | ||
function compileDependency(expression, options) { | ||
var dependency = parse_1.parseDependency(expression.location); | ||
@@ -68,3 +84,5 @@ var cwd = options.cwd, ambient = options.ambient; | ||
return checkTypings(dependency, options) | ||
.then(function () { return dependencies_1.resolveDependency(dependency, { cwd: cwd, emitter: emitter, dev: false, peer: false, ambient: false }); }) | ||
.then(function () { | ||
return dependencies_1.resolveDependency(dependency, { cwd: cwd, emitter: emitter, dev: false, peer: false, ambient: false }); | ||
}) | ||
.then(function (tree) { | ||
@@ -75,3 +93,6 @@ var name = expression.name || dependency.meta.name || tree.name; | ||
} | ||
return installDependencyTree(tree, { | ||
if (tree.postmessage) { | ||
emitter.emit('postmessage', { name: name, message: tree.postmessage }); | ||
} | ||
return compile_1.default(tree, { | ||
cwd: cwd, | ||
@@ -82,46 +103,38 @@ name: name, | ||
meta: true | ||
}) | ||
.then(function (result) { | ||
return writeToConfig(name, tree.raw, options) | ||
.then(function () { | ||
if (tree.postmessage) { | ||
emitter.emit('postmessage', { name: name, message: tree.postmessage }); | ||
} | ||
return result; | ||
}); | ||
}); | ||
}); | ||
} | ||
function installDependencyTree(tree, options) { | ||
return compile_1.default(tree, options).then(function (result) { return writeDependency(result, options); }); | ||
} | ||
function writeToConfig(name, raw, options) { | ||
function writeToConfig(results, options) { | ||
if (options.save || options.saveDev || options.savePeer) { | ||
return fs_1.transformConfig(options.cwd, function (config) { | ||
if (options.save) { | ||
if (options.ambient) { | ||
config.ambientDependencies = extend(config.ambientDependencies, (_a = {}, _a[name] = raw, _a)); | ||
for (var _i = 0, results_1 = results; _i < results_1.length; _i++) { | ||
var _a = results_1[_i], name = _a.name, tree = _a.tree; | ||
var raw = tree.raw; | ||
if (options.save) { | ||
if (options.ambient) { | ||
config.ambientDependencies = extend(config.ambientDependencies, (_b = {}, _b[name] = raw, _b)); | ||
} | ||
else { | ||
config.dependencies = extend(config.dependencies, (_c = {}, _c[name] = raw, _c)); | ||
} | ||
} | ||
else { | ||
config.dependencies = extend(config.dependencies, (_b = {}, _b[name] = raw, _b)); | ||
else if (options.saveDev) { | ||
if (options.ambient) { | ||
config.ambientDevDependencies = extend(config.ambientDevDependencies, (_d = {}, _d[name] = raw, _d)); | ||
} | ||
else { | ||
config.devDependencies = extend(config.devDependencies, (_e = {}, _e[name] = raw, _e)); | ||
} | ||
} | ||
} | ||
else if (options.saveDev) { | ||
if (options.ambient) { | ||
config.ambientDevDependencies = extend(config.ambientDevDependencies, (_c = {}, _c[name] = raw, _c)); | ||
else if (options.savePeer) { | ||
if (options.ambient) { | ||
throw new TypeError('Unable to use `savePeer` with the `ambient` flag'); | ||
} | ||
else { | ||
config.peerDependencies = extend(config.peerDependencies, (_f = {}, _f[name] = raw, _f)); | ||
} | ||
} | ||
else { | ||
config.devDependencies = extend(config.devDependencies, (_d = {}, _d[name] = raw, _d)); | ||
} | ||
} | ||
else if (options.savePeer) { | ||
if (options.ambient) { | ||
return Promise.reject(new TypeError('Unable to use `savePeer` with the `ambient` flag')); | ||
} | ||
else { | ||
config.peerDependencies = extend(config.peerDependencies, (_e = {}, _e[name] = raw, _e)); | ||
} | ||
} | ||
return config; | ||
var _a, _b, _c, _d, _e; | ||
var _b, _c, _d, _e, _f; | ||
}); | ||
@@ -131,13 +144,25 @@ } | ||
} | ||
function writeDependency(output, options) { | ||
var location = path_2.getDependencyLocation(options); | ||
function create(path, file, contents, dtsFile) { | ||
return fs_1.mkdirp(path) | ||
.then(function () { return fs_1.writeFile(file, contents); }) | ||
.then(function () { return fs_1.transformDtsFile(dtsFile, function (typings) { return typings.concat([file]); }); }); | ||
} | ||
function writeBundle(results, options) { | ||
var bundle = path_2.getTypingsLocation(options); | ||
var locations = results.map(function (x) { return path_2.getDependencyLocation(x); }); | ||
return fs_1.mkdirp(bundle.typings) | ||
.then(function () { | ||
if (locations.length === 0) { | ||
return Promise.all([ | ||
fs_1.touch(bundle.main), | ||
fs_1.touch(bundle.browser) | ||
]); | ||
} | ||
return Promise.all([ | ||
fs_1.transformDtsFile(bundle.main, function (x) { return x.concat(locations.map(function (x) { return x.main; })); }), | ||
fs_1.transformDtsFile(bundle.browser, function (x) { return x.concat(locations.map(function (x) { return x.browser; })); }) | ||
]); | ||
}); | ||
} | ||
function writeResult(result) { | ||
var location = path_2.getDependencyLocation(result); | ||
return Promise.all([ | ||
create(location.mainPath, location.mainFile, output.main, location.mainDtsFile), | ||
create(location.browserPath, location.browserFile, output.browser, location.browserDtsFile) | ||
]).then(function () { return output; }); | ||
fs_1.mkdirpAndWriteFile(location.main, result.main), | ||
fs_1.mkdirpAndWriteFile(location.browser, result.browser) | ||
]); | ||
} | ||
@@ -144,0 +169,0 @@ function checkTypings(dependency, options) { |
@@ -6,13 +6,14 @@ import { Browser } from './config'; | ||
location: string; | ||
meta: { | ||
name?: string; | ||
path?: string; | ||
org?: string; | ||
repo?: string; | ||
sha?: string; | ||
version?: string; | ||
tag?: string; | ||
source?: string; | ||
}; | ||
meta: DependencyMeta; | ||
} | ||
export interface DependencyMeta { | ||
name?: string; | ||
path?: string; | ||
org?: string; | ||
repo?: string; | ||
sha?: string; | ||
version?: string; | ||
tag?: string; | ||
source?: string; | ||
} | ||
export interface DependencyTree { | ||
@@ -19,0 +20,0 @@ name?: string; |
@@ -15,3 +15,3 @@ import { EventEmitter } from 'events'; | ||
on(event: 'badlocation', listener: (e: BadLocationEvent) => any): this; | ||
on(event: 'deprecated', listener: (e: DeprecatedEvent) => any): this; | ||
on(event: 'prune', listener: (e: PruneEvent) => any): this; | ||
on(event: string, listener: Function): this; | ||
@@ -28,3 +28,3 @@ emit(event: 'reference', e: ReferenceEvent): boolean; | ||
emit(event: 'badlocation', e: BadLocationEvent): boolean; | ||
emit(event: 'deprecated', e: DeprecatedEvent): boolean; | ||
emit(event: 'prune', e: PruneEvent): boolean; | ||
emit(event: string, ...args: any[]): boolean; | ||
@@ -42,3 +42,4 @@ } | ||
raw: string; | ||
parent?: DependencyTree; | ||
name: string; | ||
parent: DependencyTree; | ||
} | ||
@@ -80,6 +81,6 @@ export interface ResolvedEvent extends ResolveEvent { | ||
} | ||
export interface DeprecatedEvent { | ||
raw: string; | ||
date: Date; | ||
parent: DependencyTree; | ||
export interface PruneEvent { | ||
name: string; | ||
ambient: boolean; | ||
browser: boolean; | ||
} |
@@ -10,3 +10,4 @@ import Promise = require('any-promise'); | ||
} | ||
export interface CompiledOutput { | ||
export interface CompileResult { | ||
cwd: string; | ||
name: string; | ||
@@ -16,3 +17,4 @@ tree: DependencyTree; | ||
browser: string; | ||
ambient: boolean; | ||
} | ||
export default function compile(tree: DependencyTree, options: Options): Promise<CompiledOutput>; | ||
export default function compile(tree: DependencyTree, options: Options): Promise<CompileResult>; |
@@ -14,6 +14,6 @@ "use strict"; | ||
function compile(tree, options) { | ||
var name = options.name; | ||
var name = options.name, cwd = options.cwd, ambient = options.ambient; | ||
var readFiles = {}; | ||
if (tree.ambient && !options.ambient) { | ||
return Promise.reject(new error_1.default(("Unable to compile \"" + options.name + "\", the typings are meant to be installed as ") + | ||
if (tree.ambient && !ambient) { | ||
return Promise.reject(new error_1.default(("Unable to compile \"" + name + "\", the typings are meant to be installed as ") + | ||
"ambient but attempted to be compiled as an external module")); | ||
@@ -39,3 +39,5 @@ } | ||
main: main, | ||
browser: browser | ||
browser: browser, | ||
cwd: cwd, | ||
ambient: ambient | ||
}; | ||
@@ -162,6 +164,6 @@ }); | ||
var importedPath = importPath(path, path_3.pathFromDefinition(path), options); | ||
if (has(options.imported, importedPath)) { | ||
if (has(imported, importedPath)) { | ||
return Promise.resolve(null); | ||
} | ||
options.imported[importedPath] = true; | ||
imported[importedPath] = true; | ||
emitter.emit('compile', { name: name, path: path, tree: tree, browser: browser }); | ||
@@ -168,0 +170,0 @@ function loadByModuleName(path) { |
@@ -6,10 +6,12 @@ import Promise = require('any-promise'); | ||
emitter: Emitter; | ||
name?: string; | ||
dev?: boolean; | ||
peer?: boolean; | ||
ambient?: boolean; | ||
parent?: DependencyTree; | ||
} | ||
export declare function resolveAllDependencies(options: Options): Promise<DependencyTree>; | ||
export declare function resolveDependency(dependency: Dependency, options: Options, parent?: DependencyTree): Promise<DependencyTree>; | ||
export declare function resolveDependency(dependency: Dependency, options: Options): Promise<DependencyTree>; | ||
export declare function resolveBowerDependencies(options: Options): Promise<DependencyTree>; | ||
export declare function resolveNpmDependencies(options: Options): Promise<DependencyTree>; | ||
export declare function resolveTypeDependencies(options: Options): Promise<DependencyTree>; |
@@ -40,6 +40,6 @@ "use strict"; | ||
exports.resolveAllDependencies = resolveAllDependencies; | ||
function resolveDependency(dependency, options, parent) { | ||
function resolveDependency(dependency, options) { | ||
var type = dependency.type, location = dependency.location, raw = dependency.raw, meta = dependency.meta; | ||
if (type === 'registry') { | ||
return resolveDependencyRegistry(dependency, options, parent); | ||
return resolveDependencyRegistry(dependency, options); | ||
} | ||
@@ -51,15 +51,15 @@ if (type === 'github' || type === 'bitbucket') { | ||
} | ||
return resolveDependencyInternally(type, location, raw, options, parent); | ||
return resolveDependencyInternally(type, location, raw, options); | ||
} | ||
exports.resolveDependency = resolveDependency; | ||
function resolveDependencyInternally(type, location, raw, options, parent) { | ||
function resolveDependencyInternally(type, location, raw, options) { | ||
if (type === 'npm') { | ||
return resolveNpmDependency(location, raw, options, parent); | ||
return resolveNpmDependency(location, raw, options); | ||
} | ||
if (type === 'bower') { | ||
return resolveBowerDependency(location, raw, options, parent); | ||
return resolveBowerDependency(location, raw, options); | ||
} | ||
return resolveFileDependency(location, raw, options, parent); | ||
return resolveFileDependency(location, raw, options); | ||
} | ||
function resolveDependencyRegistry(dependency, options, parent) { | ||
function resolveDependencyRegistry(dependency, options) { | ||
var location = dependency.location, meta = dependency.meta; | ||
@@ -70,17 +70,8 @@ return fs_1.readJsonFrom(location) | ||
var raw = "registry:" + meta.source + "/" + meta.name + "#" + entry.tag; | ||
if (entry.deprecated) { | ||
options.emitter.emit('deprecated', { | ||
parent: parent, | ||
raw: dependency.raw, | ||
date: new Date(entry.deprecated) | ||
}); | ||
} | ||
return resolveDependencyInternally(type, location, raw, options, parent); | ||
return resolveDependencyInternally(type, location, raw, options); | ||
}, function (error) { | ||
if (error.code === 'EINVALIDSTATUS' && error.status === 404) { | ||
var prompt = parent ? '' : options.ambient ? | ||
'Have you checked for regular typings without using ambient? ' : | ||
'Did you want to install ambient typings with the ambient flag? '; | ||
var message = ("Unable to find \"" + meta.name + "\" for \"" + meta.source + "\" in the registry. ") + | ||
prompt + "If you can contribute these typings, please help us: " + | ||
var message = ("Unable to find \"" + meta.name + "\" (\"" + meta.source + "\") in the registry. ") + | ||
"Did you want to try searching another source?" + | ||
"Also, if you want contribute these typings, please help us: " + | ||
"https://github.com/typings/registry"; | ||
@@ -92,14 +83,14 @@ return Promise.reject(new error_1.default(message, error)); | ||
} | ||
function resolveNpmDependency(name, raw, options, parent) { | ||
return find_1.findUp(options.cwd, path_1.join('node_modules', name)) | ||
function resolveNpmDependency(pkgName, raw, options) { | ||
return find_1.findUp(options.cwd, path_1.join('node_modules', pkgName)) | ||
.then(function (modulePath) { | ||
if (path_2.isDefinition(modulePath)) { | ||
return resolveFileDependency(modulePath, raw, options, parent); | ||
return resolveFileDependency(modulePath, raw, options); | ||
} | ||
return resolveNpmDependencyFrom(modulePath, raw, options, parent); | ||
return resolveNpmDependencyFrom(modulePath, raw, options); | ||
}, function (error) { | ||
return Promise.reject(resolveError(raw, error, parent)); | ||
return Promise.reject(resolveError(raw, error, options)); | ||
}); | ||
} | ||
function resolveBowerDependency(name, raw, options, parent) { | ||
function resolveBowerDependency(name, raw, options) { | ||
return resolveBowerComponentPath(options.cwd) | ||
@@ -109,10 +100,11 @@ .then(function (componentPath) { | ||
if (path_2.isDefinition(modulePath)) { | ||
return resolveFileDependency(modulePath, raw, options, parent); | ||
return resolveFileDependency(modulePath, raw, options); | ||
} | ||
return resolveBowerDependencyFrom(modulePath, raw, componentPath, options, parent); | ||
return resolveBowerDependencyFrom(modulePath, raw, componentPath, options); | ||
}, function (error) { | ||
return Promise.reject(resolveError(raw, error, parent)); | ||
return Promise.reject(resolveError(raw, error, options)); | ||
}); | ||
} | ||
function resolveFileDependency(location, raw, options, parent) { | ||
function resolveFileDependency(location, raw, options) { | ||
var name = options.name, parent = options.parent; | ||
var src; | ||
@@ -129,5 +121,5 @@ if (path_2.isHttp(location)) { | ||
if (!path_2.isDefinition(src)) { | ||
return resolveTypeDependencyFrom(src, raw, options, parent); | ||
return resolveTypeDependencyFrom(src, raw, options); | ||
} | ||
options.emitter.emit('resolve', { src: src, raw: raw, parent: parent }); | ||
options.emitter.emit('resolve', { name: name, src: src, raw: raw, parent: parent }); | ||
var tree = extend(DEFAULT_DEPENDENCY, { | ||
@@ -139,3 +131,3 @@ typings: src, | ||
}); | ||
options.emitter.emit('resolved', { src: src, tree: tree, raw: raw, parent: parent }); | ||
options.emitter.emit('resolved', { name: name, src: src, tree: tree, raw: raw, parent: parent }); | ||
return Promise.resolve(tree); | ||
@@ -155,5 +147,6 @@ } | ||
exports.resolveBowerDependencies = resolveBowerDependencies; | ||
function resolveBowerDependencyFrom(src, raw, componentPath, options, parent) { | ||
function resolveBowerDependencyFrom(src, raw, componentPath, options) { | ||
var name = options.name, parent = options.parent; | ||
checkCircularDependency(parent, src); | ||
options.emitter.emit('resolve', { src: src, raw: raw, parent: parent }); | ||
options.emitter.emit('resolve', { name: name, src: src, raw: raw, parent: parent }); | ||
return fs_1.readJson(src) | ||
@@ -176,6 +169,8 @@ .then(function (bowerJson) { | ||
var devDependencyMap = extend(options.dev ? bowerJson.devDependencies : {}); | ||
var dependencyOptions = extend(options, { parent: tree }); | ||
options.emitter.emit('resolved', { name: name, src: src, tree: tree, raw: raw, parent: parent }); | ||
return Promise.all([ | ||
resolveBowerDependencyMap(componentPath, dependencyMap, options, tree), | ||
resolveBowerDependencyMap(componentPath, devDependencyMap, options, tree), | ||
maybeResolveTypeDependencyFrom(path_1.join(src, '..', config_1.CONFIG_FILE), raw, options, parent) | ||
resolveBowerDependencyMap(componentPath, dependencyMap, dependencyOptions), | ||
resolveBowerDependencyMap(componentPath, devDependencyMap, dependencyOptions), | ||
maybeResolveTypeDependencyFrom(path_1.join(src, '..', config_1.CONFIG_FILE), raw, options) | ||
]) | ||
@@ -186,7 +181,6 @@ .then(function (_a) { | ||
tree.devDependencies = devDependencies; | ||
options.emitter.emit('resolved', { src: src, tree: tree, raw: raw, parent: parent }); | ||
return mergeDependencies(tree, typedPackage); | ||
}); | ||
}, function (error) { | ||
return Promise.reject(resolveError(raw, error, parent)); | ||
return Promise.reject(resolveError(raw, error, options)); | ||
}); | ||
@@ -203,9 +197,8 @@ } | ||
} | ||
function resolveBowerDependencyMap(componentPath, dependencies, options, parent) { | ||
function resolveBowerDependencyMap(componentPath, dependencies, options) { | ||
var keys = Object.keys(dependencies); | ||
var cwd = options.cwd, emitter = options.emitter; | ||
return Promise.all(keys.map(function (name) { | ||
var modulePath = path_1.resolve(componentPath, name, 'bower.json'); | ||
var resolveOptions = { dev: false, ambient: false, peer: false, cwd: cwd, emitter: emitter }; | ||
return resolveBowerDependencyFrom(modulePath, "bower:" + name, componentPath, resolveOptions, parent); | ||
var resolveOptions = extend(options, { name: name, dev: false, ambient: false, peer: false }); | ||
return resolveBowerDependencyFrom(modulePath, "bower:" + name, componentPath, resolveOptions); | ||
})) | ||
@@ -223,5 +216,6 @@ .then(function (results) { return zipObject(keys, results); }); | ||
exports.resolveNpmDependencies = resolveNpmDependencies; | ||
function resolveNpmDependencyFrom(src, raw, options, parent) { | ||
function resolveNpmDependencyFrom(src, raw, options) { | ||
var name = options.name, parent = options.parent; | ||
checkCircularDependency(parent, src); | ||
options.emitter.emit('resolve', { src: src, raw: raw, parent: parent }); | ||
options.emitter.emit('resolve', { name: name, src: src, raw: raw, parent: parent }); | ||
return fs_1.readJson(src) | ||
@@ -245,7 +239,9 @@ .then(function (packageJson) { | ||
var peerDependencyMap = extend(options.peer ? packageJson.peerDependencies : {}); | ||
var dependencyOptions = extend(options, { parent: tree }); | ||
options.emitter.emit('resolved', { name: name, src: src, tree: tree, raw: raw, parent: parent }); | ||
return Promise.all([ | ||
resolveNpmDependencyMap(src, dependencyMap, options, tree), | ||
resolveNpmDependencyMap(src, devDependencyMap, options, tree), | ||
resolveNpmDependencyMap(src, peerDependencyMap, options, tree), | ||
maybeResolveTypeDependencyFrom(path_1.join(src, '..', config_1.CONFIG_FILE), raw, options, parent) | ||
resolveNpmDependencyMap(src, dependencyMap, dependencyOptions), | ||
resolveNpmDependencyMap(src, devDependencyMap, dependencyOptions), | ||
resolveNpmDependencyMap(src, peerDependencyMap, dependencyOptions), | ||
maybeResolveTypeDependencyFrom(path_1.join(src, '..', config_1.CONFIG_FILE), raw, options) | ||
]) | ||
@@ -257,15 +253,14 @@ .then(function (_a) { | ||
tree.peerDependencies = peerDependencies; | ||
options.emitter.emit('resolved', { src: src, tree: tree, raw: raw, parent: parent }); | ||
return mergeDependencies(tree, typedPackage); | ||
}); | ||
}, function (error) { | ||
return Promise.reject(resolveError(raw, error, parent)); | ||
return Promise.reject(resolveError(raw, error, options)); | ||
}); | ||
} | ||
function resolveNpmDependencyMap(src, dependencies, options, parent) { | ||
function resolveNpmDependencyMap(src, dependencies, options) { | ||
var cwd = path_1.dirname(src); | ||
var keys = Object.keys(dependencies); | ||
return Promise.all(keys.map(function (name) { | ||
var resolveOptions = { dev: false, peer: false, ambient: false, cwd: cwd, emitter: options.emitter }; | ||
return resolveNpmDependency(path_1.join(name, 'package.json'), "npm:" + name, resolveOptions, parent); | ||
var resolveOptions = extend(options, { name: name, cwd: cwd, dev: false, peer: false, ambient: false }); | ||
return resolveNpmDependency(path_1.join(name, 'package.json'), "npm:" + name, resolveOptions); | ||
})) | ||
@@ -283,5 +278,6 @@ .then(function (results) { return zipObject(keys, results); }); | ||
exports.resolveTypeDependencies = resolveTypeDependencies; | ||
function resolveTypeDependencyFrom(src, raw, options, parent) { | ||
function resolveTypeDependencyFrom(src, raw, options) { | ||
var name = options.name, parent = options.parent; | ||
checkCircularDependency(parent, src); | ||
options.emitter.emit('resolve', { src: src, raw: raw, parent: parent }); | ||
options.emitter.emit('resolve', { name: name, src: src, raw: raw, parent: parent }); | ||
return fs_1.readConfigFrom(src) | ||
@@ -308,5 +304,7 @@ .then(function (config) { | ||
var ambientDevDependencyMap = extend(ambient && dev ? config.ambientDevDependencies : {}); | ||
var dependencyOptions = extend(options, { parent: tree }); | ||
options.emitter.emit('resolved', { name: name, src: src, tree: tree, raw: raw, parent: parent }); | ||
if (parent == null && config.ambientDependencies) { | ||
options.emitter.emit('ambientdependencies', { | ||
name: config.name, | ||
name: name, | ||
raw: raw, | ||
@@ -317,7 +315,7 @@ dependencies: config.ambientDependencies | ||
return Promise.all([ | ||
resolveTypeDependencyMap(src, dependencyMap, options, tree), | ||
resolveTypeDependencyMap(src, devDependencyMap, options, tree), | ||
resolveTypeDependencyMap(src, peerDependencyMap, options, tree), | ||
resolveTypeDependencyMap(src, ambientDependencyMap, options, tree), | ||
resolveTypeDependencyMap(src, ambientDevDependencyMap, options, tree), | ||
resolveTypeDependencyMap(src, dependencyMap, dependencyOptions), | ||
resolveTypeDependencyMap(src, devDependencyMap, dependencyOptions), | ||
resolveTypeDependencyMap(src, peerDependencyMap, dependencyOptions), | ||
resolveTypeDependencyMap(src, ambientDependencyMap, dependencyOptions), | ||
resolveTypeDependencyMap(src, ambientDevDependencyMap, dependencyOptions), | ||
]) | ||
@@ -331,18 +329,17 @@ .then(function (_a) { | ||
tree.ambientDevDependencies = ambientDevDependencies; | ||
options.emitter.emit('resolved', { src: src, tree: tree, raw: raw, parent: parent }); | ||
return tree; | ||
}); | ||
}, function (error) { | ||
return Promise.reject(resolveError(raw, error, parent)); | ||
return Promise.reject(resolveError(raw, error, options)); | ||
}); | ||
} | ||
function maybeResolveTypeDependencyFrom(src, raw, options, parent) { | ||
return resolveTypeDependencyFrom(src, raw, options, parent).catch(function () { return extend(DEFAULT_DEPENDENCY); }); | ||
function maybeResolveTypeDependencyFrom(src, raw, options) { | ||
return resolveTypeDependencyFrom(src, raw, options).catch(function () { return extend(DEFAULT_DEPENDENCY); }); | ||
} | ||
function resolveTypeDependencyMap(src, dependencies, options, parent) { | ||
function resolveTypeDependencyMap(src, dependencies, options) { | ||
var cwd = path_1.dirname(src); | ||
var keys = Object.keys(dependencies); | ||
return Promise.all(keys.map(function (name) { | ||
var resolveOptions = { dev: false, ambient: false, peer: false, cwd: cwd, emitter: options.emitter }; | ||
return resolveDependency(parse_1.parseDependency(dependencies[name]), resolveOptions, parent); | ||
var resolveOptions = extend(options, { name: name, cwd: cwd, dev: false, ambient: false, peer: false }); | ||
return resolveDependency(parse_1.parseDependency(dependencies[name]), resolveOptions); | ||
})) | ||
@@ -359,6 +356,7 @@ .then(function (results) { return zipObject(keys, results); }); | ||
} | ||
function resolveError(raw, cause, parent) { | ||
function resolveError(raw, cause, options) { | ||
var name = options.name; | ||
var message = "Unable to resolve " + (raw == null ? 'typings' : "\"" + raw + "\""); | ||
if (parent != null && parent.raw != null) { | ||
message += " from \"" + parent.raw + "\""; | ||
if (name != null) { | ||
message += " from \"" + name + "\""; | ||
} | ||
@@ -365,0 +363,0 @@ return new error_1.default(message, cause); |
@@ -10,2 +10,3 @@ export * from './install'; | ||
export * from './view'; | ||
export * from './prune'; | ||
export declare const VERSION: any; |
@@ -13,3 +13,4 @@ "use strict"; | ||
__export(require('./view')); | ||
__export(require('./prune')); | ||
exports.VERSION = require('../package.json').version; | ||
//# sourceMappingURL=typings.js.map |
@@ -11,2 +11,3 @@ import Promise = require('any-promise'); | ||
} | ||
export declare function uninstallDependency(name: string, options: UninstallDependencyOptions): Promise<void>; | ||
export declare function uninstallDependency(name: string, options: UninstallDependencyOptions): Promise<any>; | ||
export declare function uninstallDependencies(names: string[], options: UninstallDependencyOptions): Promise<any>; |
"use strict"; | ||
var extend = require('xtend'); | ||
var Promise = require('any-promise'); | ||
var promise_finally_1 = require('promise-finally'); | ||
var events_1 = require('events'); | ||
@@ -10,57 +9,75 @@ var fs_1 = require('./utils/fs'); | ||
function uninstallDependency(name, options) { | ||
return uninstallDependencies([name], options); | ||
} | ||
exports.uninstallDependency = uninstallDependency; | ||
function uninstallDependencies(names, options) { | ||
var emitter = options.emitter || new events_1.EventEmitter(); | ||
function uninstall(name, options) { | ||
return removeDependency(name, options).then(function () { return writeToConfig(name, options); }); | ||
} | ||
return find_1.findProject(options.cwd) | ||
.then(function (cwd) { return uninstall(name, extend({ emitter: emitter }, options, { cwd: cwd })); }, function () { return uninstall(name, extend({ emitter: emitter }, options)); }); | ||
.then(function (cwd) { return extend(options, { cwd: cwd, emitter: emitter }); }, function () { return extend(options, { emitter: emitter }); }) | ||
.then(function (options) { | ||
return Promise.all(names.map(function (x) { return uninstallFrom(x, options); })) | ||
.then(function () { return writeBundle(names, options); }) | ||
.then(function () { return writeToConfig(names, options); }) | ||
.then(function () { return undefined; }); | ||
}); | ||
} | ||
exports.uninstallDependency = uninstallDependency; | ||
function writeToConfig(name, options) { | ||
if (options.save || options.saveDev) { | ||
exports.uninstallDependencies = uninstallDependencies; | ||
function uninstallFrom(name, options) { | ||
var cwd = options.cwd, ambient = options.ambient, emitter = options.emitter; | ||
var location = path_1.getDependencyLocation({ name: name, cwd: cwd, ambient: ambient }); | ||
return Promise.all([ | ||
fs_1.rmUntil(location.main, { cwd: cwd, emitter: emitter }), | ||
fs_1.rmUntil(location.browser, { cwd: cwd, emitter: emitter }) | ||
]); | ||
} | ||
function writeToConfig(names, options) { | ||
if (options.save || options.saveDev || options.savePeer) { | ||
return fs_1.transformConfig(options.cwd, function (config) { | ||
if (options.save) { | ||
if (options.ambient) { | ||
if (config.ambientDependencies && config.ambientDependencies[name]) { | ||
delete config.ambientDependencies[name]; | ||
for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { | ||
var name = names_1[_i]; | ||
if (options.save) { | ||
if (options.ambient) { | ||
if (config.ambientDependencies && config.ambientDependencies[name]) { | ||
delete config.ambientDependencies[name]; | ||
} | ||
else { | ||
return Promise.reject(new TypeError("Typings for \"" + name + "\" are not listed in ambient dependencies")); | ||
} | ||
} | ||
else { | ||
return Promise.reject(new TypeError("Typings for \"" + name + "\" are not listed in ambient dependencies")); | ||
if (config.dependencies && config.dependencies[name]) { | ||
delete config.dependencies[name]; | ||
} | ||
else { | ||
return Promise.reject(new TypeError("Typings for \"" + name + "\" are not listed in dependencies")); | ||
} | ||
} | ||
} | ||
else { | ||
if (config.dependencies && config.dependencies[name]) { | ||
delete config.dependencies[name]; | ||
if (options.saveDev) { | ||
if (options.ambient) { | ||
if (config.ambientDevDependencies && config.ambientDevDependencies[name]) { | ||
delete config.ambientDevDependencies[name]; | ||
} | ||
else { | ||
return Promise.reject(new TypeError("Typings for \"" + name + "\" are not listed in ambient dev dependencies")); | ||
} | ||
} | ||
else { | ||
return Promise.reject(new TypeError("Typings for \"" + name + "\" are not listed in dependencies")); | ||
if (config.devDependencies && config.devDependencies[name]) { | ||
delete config.devDependencies[name]; | ||
} | ||
else { | ||
return Promise.reject(new TypeError("Typings for \"" + name + "\" are not listed in dev dependencies")); | ||
} | ||
} | ||
} | ||
} | ||
if (options.saveDev) { | ||
if (options.ambient) { | ||
if (config.ambientDevDependencies && config.ambientDevDependencies[name]) { | ||
delete config.ambientDevDependencies[name]; | ||
if (options.savePeer) { | ||
if (config.peerDependencies && config.peerDependencies[name]) { | ||
delete config.peerDependencies[name]; | ||
} | ||
else { | ||
return Promise.reject(new TypeError("Typings for \"" + name + "\" are not listed in ambient dev dependencies")); | ||
return Promise.reject(new TypeError("Typings for \"" + name + "\" are not listed in peer dependencies")); | ||
} | ||
} | ||
else { | ||
if (config.devDependencies && config.devDependencies[name]) { | ||
delete config.devDependencies[name]; | ||
} | ||
else { | ||
return Promise.reject(new TypeError("Typings for \"" + name + "\" are not listed in dev dependencies")); | ||
} | ||
} | ||
} | ||
if (options.savePeer) { | ||
if (config.peerDependencies && config.peerDependencies[name]) { | ||
delete config.peerDependencies[name]; | ||
} | ||
else { | ||
return Promise.reject(new TypeError("Typings for \"" + name + "\" are not listed in peer dependencies")); | ||
} | ||
} | ||
return config; | ||
@@ -70,23 +87,13 @@ }); | ||
} | ||
function removeDependency(name, options) { | ||
function writeBundle(names, options) { | ||
var cwd = options.cwd, ambient = options.ambient; | ||
var location = path_1.getDependencyLocation({ name: name, cwd: cwd, ambient: ambient }); | ||
function remove(dir, path, dtsPath) { | ||
return fs_1.isFile(path) | ||
.then(function (exists) { | ||
if (!exists) { | ||
options.emitter.emit('enoent', { path: path }); | ||
} | ||
return promise_finally_1.default(fs_1.rimraf(dir), function () { | ||
return fs_1.transformDtsFile(dtsPath, function (typings) { | ||
return typings.filter(function (x) { return x !== path; }); | ||
}); | ||
}); | ||
}); | ||
} | ||
var bundle = path_1.getTypingsLocation(options); | ||
var locations = names.map(function (name) { return path_1.getDependencyLocation({ name: name, cwd: cwd, ambient: ambient }); }); | ||
var mainLocations = locations.map(function (x) { return x.main; }); | ||
var browserLocations = locations.map(function (x) { return x.browser; }); | ||
return Promise.all([ | ||
remove(location.mainPath, location.mainFile, location.mainDtsFile), | ||
remove(location.browserPath, location.browserFile, location.browserDtsFile) | ||
]).then(function () { return undefined; }); | ||
fs_1.transformDtsFile(bundle.main, function (x) { return x.filter(function (x) { return mainLocations.indexOf(x) === -1; }); }), | ||
fs_1.transformDtsFile(bundle.browser, function (x) { return x.filter(function (x) { return browserLocations.indexOf(x) === -1; }); }) | ||
]); | ||
} | ||
//# sourceMappingURL=uninstall.js.map |
@@ -5,20 +5,28 @@ import * as fs from 'graceful-fs'; | ||
import Touch = require('touch'); | ||
import { ConfigJson } from '../interfaces'; | ||
import { ConfigJson, Emitter } from '../interfaces'; | ||
export declare type Stats = fs.Stats; | ||
export declare type LockOp = (path: string, options?: lockfile.Options) => Promise<void>; | ||
export declare type TouchOp = (path: string, options?: Touch.Options) => Promise<void>; | ||
export declare type StatOp = (path: string) => Promise<Stats>; | ||
export declare type ReadFileOp = (path: string, encoding: string) => Promise<string>; | ||
export declare type WriteFileOp = (path: string, contents: string | Buffer) => Promise<void>; | ||
export declare type MkdirpOp = (path: string) => Promise<string>; | ||
export declare type PathOp = (path: string) => Promise<void>; | ||
export declare type PathOp<T> = (path: string) => Promise<T>; | ||
export declare const touch: TouchOp; | ||
export declare const stat: StatOp; | ||
export declare const stat: PathOp<Stats>; | ||
export declare const readFile: ReadFileOp; | ||
export declare const writeFile: WriteFileOp; | ||
export declare const mkdirp: MkdirpOp; | ||
export declare const unlink: PathOp; | ||
export declare const mkdirp: PathOp<string>; | ||
export declare const unlink: PathOp<void>; | ||
export declare const lock: LockOp; | ||
export declare const unlock: PathOp; | ||
export declare const rimraf: PathOp; | ||
export declare const unlock: PathOp<void>; | ||
export declare const rimraf: PathOp<void>; | ||
export declare const readdir: PathOp<string[]>; | ||
export declare const rmdir: PathOp<void>; | ||
export declare function mkdirpAndWriteFile(path: string, contents: string | Buffer): Promise<void>; | ||
export declare function rmUntil(path: string, options: { | ||
cwd: string; | ||
emitter: Emitter; | ||
}): Promise<void>; | ||
export declare function rmdirUntil(path: string, options: { | ||
cwd: string; | ||
}): Promise<void>; | ||
export declare function isFile(path: string): Promise<boolean>; | ||
@@ -38,2 +46,2 @@ export declare function readJson(path: string, allowEmpty?: boolean): Promise<any>; | ||
export declare function transformConfig(cwd: string, transform: (config: ConfigJson) => ConfigJson): Promise<void>; | ||
export declare function transformDtsFile(path: string, transform: (typings: string[]) => string[]): Promise<void>; | ||
export declare function transformDtsFile(path: string, transform: (typings: string[]) => string[] | Promise<string[]>): Promise<void>; |
@@ -41,2 +41,39 @@ "use strict"; | ||
exports.rimraf = throat(10, thenify(Rimraf)); | ||
exports.readdir = throat(10, thenify(fs.readdir)); | ||
exports.rmdir = throat(10, thenify(fs.rmdir)); | ||
function mkdirpAndWriteFile(path, contents) { | ||
return exports.mkdirp(path_1.dirname(path)).then(function () { return exports.writeFile(path, contents); }); | ||
} | ||
exports.mkdirpAndWriteFile = mkdirpAndWriteFile; | ||
function rmUntil(path, options) { | ||
return isFile(path) | ||
.then(function (exists) { | ||
if (exists) { | ||
return exports.unlink(path); | ||
} | ||
options.emitter.emit('enoent', { path: path }); | ||
}) | ||
.then(function () { return rmdirUntil(path_1.dirname(path), options); }); | ||
} | ||
exports.rmUntil = rmUntil; | ||
function rmdirUntil(path, options) { | ||
if (path === options.cwd) { | ||
return Promise.resolve(); | ||
} | ||
return exports.readdir(path) | ||
.then(function (files) { | ||
if (files.length) { | ||
return; | ||
} | ||
return exports.rmdir(path) | ||
.then(function () { return rmdirUntil(path_1.dirname(path), options); }); | ||
}) | ||
.catch(function (err) { | ||
if (err.code === 'ENOENT') { | ||
return; | ||
} | ||
return Promise.reject(err); | ||
}); | ||
} | ||
exports.rmdirUntil = rmdirUntil; | ||
function isFile(path) { | ||
@@ -98,12 +135,12 @@ return exports.stat(path).then(function (stat) { return stat.isFile(); }, function () { return false; }); | ||
if (self.Url.host === registryURL.host) { | ||
if (store_1.default.get('clientId')) { | ||
self.before(function (req) { | ||
self.before(function (req) { | ||
if (store_1.default.get('clientId')) { | ||
req.set('Typings-Client-Id', store_1.default.get('clientId')); | ||
}); | ||
} | ||
else { | ||
self.after(function (res) { | ||
} | ||
}); | ||
self.after(function (res) { | ||
if (res.get('Typings-Client-Id')) { | ||
store_1.default.set('clientId', res.get('Typings-Client-Id')); | ||
}); | ||
} | ||
} | ||
}); | ||
} | ||
@@ -110,0 +147,0 @@ if (rc_1.default.githubToken && (hostname === 'raw.githubusercontent.com' || hostname === 'api.github.com')) { |
@@ -1,4 +0,4 @@ | ||
import { Dependency } from '../interfaces'; | ||
import { Dependency, DependencyMeta } from '../interfaces'; | ||
export declare function parseDependency(raw: string): Dependency; | ||
export declare function resolveDependency(raw: string, path: string): string; | ||
export declare function resolveDependency(raw: string, filename: string): string; | ||
export declare function parseDependencyExpression(raw: string, options: { | ||
@@ -10,4 +10,5 @@ ambient?: boolean; | ||
}; | ||
export declare function expandRegistry(raw: string, options?: { | ||
export declare function buildDependencyExpression(type: string, meta: DependencyMeta): string; | ||
export declare function expandRegistry(raw: string, options: { | ||
ambient?: boolean; | ||
}): string; |
@@ -147,18 +147,20 @@ "use strict"; | ||
exports.parseDependency = parseDependency; | ||
function resolveDependency(raw, path) { | ||
function resolveDependency(raw, filename) { | ||
var _a = parseDependency(raw), type = _a.type, meta = _a.meta, location = _a.location; | ||
if (type === 'http' || type === 'https') { | ||
return url_1.resolve(location, filename); | ||
} | ||
if (type === 'github' || type === 'bitbucket') { | ||
var org = meta.org, repo = meta.repo, sha = meta.sha; | ||
var resolvedPath = path_2.normalizeSlashes(path_1.join(path_1.dirname(meta.path), path)); | ||
return type + ":" + org + "/" + repo + "/" + resolvedPath + (sha === 'master' ? '' : '#' + sha); | ||
var path = path_1.join(path_1.dirname(meta.path), filename); | ||
return buildDependencyExpression(type, { org: org, repo: repo, sha: sha, path: path }); | ||
} | ||
if (type === 'npm' || type === 'bower') { | ||
var resolvedPath = path_2.normalizeSlashes(path_1.join(path_1.dirname(meta.path), path)); | ||
return type + ":" + meta.name + "/" + resolvedPath; | ||
var name = meta.name; | ||
var path = path_1.join(path_1.dirname(meta.path), filename); | ||
return buildDependencyExpression(type, { name: name, path: path }); | ||
} | ||
if (type === 'http' || type === 'https') { | ||
return url_1.resolve(location, path); | ||
} | ||
if (type === 'file') { | ||
return "file:" + path_2.normalizeSlashes(path_1.join(location, path)); | ||
var path = path_1.join(location, filename); | ||
return buildDependencyExpression(type, { path: path }); | ||
} | ||
@@ -177,4 +179,20 @@ throw new TypeError("Unable to resolve dependency from \"" + raw + "\""); | ||
exports.parseDependencyExpression = parseDependencyExpression; | ||
function buildDependencyExpression(type, meta) { | ||
if (type === 'github' || type === 'bitbucket') { | ||
var org = meta.org, repo = meta.repo, sha = meta.sha; | ||
var resolvedPath = path_2.normalizeSlashes(meta.path); | ||
return type + ":" + org + "/" + repo + "/" + resolvedPath + (sha === 'master' ? '' : '#' + sha); | ||
} | ||
if (type === 'npm' || type === 'bower') { | ||
var path = meta.path; | ||
var resolvedPath = path ? "/" + path_2.normalizeSlashes(path) : ''; | ||
return type + ":" + meta.name + resolvedPath; | ||
} | ||
if (type === 'file') { | ||
return "file:" + path_2.normalizeSlashes(meta.path); | ||
} | ||
throw new TypeError("Unable to expand dependency type: \"" + type + "\""); | ||
} | ||
exports.buildDependencyExpression = buildDependencyExpression; | ||
function expandRegistry(raw, options) { | ||
if (options === void 0) { options = {}; } | ||
if (typeof raw !== 'string') { | ||
@@ -181,0 +199,0 @@ throw new TypeError("Expected registry name to be a string, not " + typeof raw); |
@@ -11,23 +11,31 @@ export declare const EOL: string; | ||
export declare function normalizeToDefinition(path: string): string; | ||
export interface TypingsLocationResult extends LocationResult { | ||
typings: string; | ||
} | ||
export declare function getTypingsLocation(options: { | ||
cwd: string; | ||
}): { | ||
typingsDir: string; | ||
mainDtsFile: string; | ||
browserDtsFile: string; | ||
}; | ||
export interface DefinitionOptions { | ||
}): TypingsLocationResult; | ||
export interface LocationOptions { | ||
cwd: string; | ||
name: string; | ||
ambient?: boolean; | ||
ambient: boolean; | ||
} | ||
export declare function getDependencyLocation(options: DefinitionOptions): { | ||
mainFile: string; | ||
browserFile: string; | ||
mainPath: string; | ||
browserPath: string; | ||
mainDtsFile: string; | ||
browserDtsFile: string; | ||
export interface LocationResult { | ||
main: string; | ||
browser: string; | ||
} | ||
export interface DependencyLocationResult extends LocationResult { | ||
mainDir: string; | ||
browserDir: string; | ||
} | ||
export declare function getDependencyLocation(options: LocationOptions): DependencyLocationResult; | ||
export declare function getInfoFromDependencyLocation(path: string, options: { | ||
cwd: string; | ||
}): { | ||
path: string; | ||
browser: boolean; | ||
ambient: boolean; | ||
name: string; | ||
}; | ||
export declare function detectEOL(contents: string): string; | ||
export declare function normalizeEOL(contents: string, eol: string): string; |
@@ -94,6 +94,6 @@ "use strict"; | ||
function getTypingsLocation(options) { | ||
var typingsDir = path_1.join(options.cwd, config_1.TYPINGS_DIR); | ||
var mainDtsFile = path_1.join(typingsDir, config_1.DTS_MAIN_FILE); | ||
var browserDtsFile = path_1.join(typingsDir, config_1.DTS_BROWSER_FILE); | ||
return { typingsDir: typingsDir, mainDtsFile: mainDtsFile, browserDtsFile: browserDtsFile }; | ||
var typings = path_1.join(options.cwd, config_1.TYPINGS_DIR); | ||
var main = path_1.join(typings, config_1.DTS_MAIN_FILE); | ||
var browser = path_1.join(typings, config_1.DTS_BROWSER_FILE); | ||
return { main: main, browser: browser, typings: typings }; | ||
} | ||
@@ -104,17 +104,17 @@ exports.getTypingsLocation = getTypingsLocation; | ||
var browserDir = options.ambient ? ambientBrowserTypingsDir : browserTypingsDir; | ||
var _a = getTypingsLocation(options), mainDtsFile = _a.mainDtsFile, browserDtsFile = _a.browserDtsFile; | ||
var mainPath = path_1.join(options.cwd, mainDir, options.name); | ||
var browserPath = path_1.join(options.cwd, browserDir, options.name); | ||
var mainFile = path_1.join(mainPath, 'index.d.ts'); | ||
var browserFile = path_1.join(browserPath, 'index.d.ts'); | ||
var main = path_1.join(options.cwd, mainDir, options.name, 'index.d.ts'); | ||
var browser = path_1.join(options.cwd, browserDir, options.name, 'index.d.ts'); | ||
return { mainDir: mainDir, browserDir: browserDir, main: main, browser: browser }; | ||
} | ||
exports.getDependencyLocation = getDependencyLocation; | ||
function getInfoFromDependencyLocation(path, options) { | ||
var parts = path_1.relative(options.cwd, path).split(path_1.sep); | ||
return { | ||
mainFile: mainFile, | ||
browserFile: browserFile, | ||
mainPath: mainPath, | ||
browserPath: browserPath, | ||
mainDtsFile: mainDtsFile, | ||
browserDtsFile: browserDtsFile | ||
path: path, | ||
browser: parts[0] === 'browser', | ||
ambient: parts[1] === 'ambient', | ||
name: parts.slice(2, -1).join('/') | ||
}; | ||
} | ||
exports.getDependencyLocation = getDependencyLocation; | ||
exports.getInfoFromDependencyLocation = getInfoFromDependencyLocation; | ||
function detectEOL(contents) { | ||
@@ -121,0 +121,0 @@ var match = contents.match(/\r\n|\r|\n/); |
@@ -5,3 +5,3 @@ import Promise = require('any-promise'); | ||
} | ||
export declare function viewEntry(raw: string, options?: ViewOptions): Promise<{}>; | ||
export declare function viewVersions(raw: string, options?: ViewOptions): Promise<{}>; | ||
export declare function viewEntry(raw: string, options: ViewOptions): Promise<{}>; | ||
export declare function viewVersions(raw: string, options: ViewOptions): Promise<{}>; |
@@ -8,3 +8,2 @@ "use strict"; | ||
function viewEntry(raw, options) { | ||
if (options === void 0) { options = {}; } | ||
return new Promise(function (resolve) { | ||
@@ -18,3 +17,2 @@ var meta = parse_1.parseDependency(parse_1.expandRegistry(raw, options)).meta; | ||
function viewVersions(raw, options) { | ||
if (options === void 0) { options = {}; } | ||
return new Promise(function (resolve) { | ||
@@ -21,0 +19,0 @@ var meta = parse_1.parseDependency(parse_1.expandRegistry(raw, options)).meta; |
{ | ||
"name": "typings-core", | ||
"version": "0.2.16", | ||
"version": "0.3.0", | ||
"description": "The logic of Typings", | ||
@@ -72,3 +72,3 @@ "main": "dist/typings.js", | ||
"touch": "^1.0.0", | ||
"typescript": "1.8.9", | ||
"typescript": "1.8.10", | ||
"xtend": "^4.0.0", | ||
@@ -82,3 +82,3 @@ "zip-object": "^0.1.0" | ||
"istanbul": "1.0.0-alpha.2", | ||
"nock": "^7.0.2", | ||
"nock": "^8.0.0", | ||
"shelljs": "^0.6.0", | ||
@@ -85,0 +85,0 @@ "tap-diff": "^0.1.1", |
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
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
188264
85
2477
+ Addedtypescript@1.8.10(transitive)
- Removedtypescript@1.8.9(transitive)
Updatedtypescript@1.8.10