Comparing version 0.1.1 to 0.1.2
@@ -244,3 +244,63 @@ [ | ||
] | ||
}, { | ||
"name": "angular", | ||
"description": "Google - Angular.Js", | ||
"versions": [ { | ||
"key": "D9089893-23AE-4182-BCBF-3DEEA8900FC1", | ||
"dependencies": [ | ||
{ "name": "angular-ng", "version": "1.0.2" }, | ||
{ "name": "angular-ng-http", "version": "1.0.2" }, | ||
{ "name": "angular-ngResource", "version": "1.0.2" } | ||
], | ||
"version": "1.0.2", | ||
"author": "Nodir Turakulov", | ||
"url": "https://github.com/nodirt/AngularTS/raw/master/angular.d.ts" | ||
} | ||
] | ||
}, { | ||
"name": "angular-ng", | ||
"description": "Google - Angular.Js", | ||
"versions": [ { | ||
"key": "0646B271-1CF1-4803-9B8B-E0E0518B54F0", | ||
"dependencies": [ | ||
{ "name": "angular", "version": "1.0.2" }, | ||
{ "name": "angular-ng-http", "version": "1.0.2" }, | ||
{ "name": "angular-ngResource", "version": "1.0.2" } | ||
], | ||
"version": "1.0.2", | ||
"author": "Nodir Turakulov", | ||
"url": "https://github.com/nodirt/AngularTS/raw/master/angular.ng.d.ts" | ||
} | ||
] | ||
}, { | ||
"name": "angular-ng-http", | ||
"description": "Google - Angular.Js", | ||
"versions": [ { | ||
"key": "0ECCA6AA-B3BA-45E8-AFAB-743F5092F8D1", | ||
"dependencies": [ | ||
{ "name": "angular", "version": "1.0.2" }, | ||
{ "name": "angular-ng", "version": "1.0.2" }, | ||
{ "name": "angular-ngResource", "version": "1.0.2" } | ||
], | ||
"version": "1.0.2", | ||
"author": "Nodir Turakulov", | ||
"url": "https://github.com/nodirt/AngularTS/raw/master/angular.ng.http.d.ts" | ||
} | ||
] | ||
}, { | ||
"name": "angular-ngResource", | ||
"description": "Google - Angular.Js", | ||
"versions": [ { | ||
"key": "CBD9AAC5-AC89-490D-87E4-6F0C5F81E604", | ||
"dependencies": [ | ||
{ "name": "angular", "version": "1.0.2" }, | ||
{ "name": "angular-ng", "version": "1.0.2" }, | ||
{ "name": "angular-ng-http", "version": "1.0.2" } | ||
], | ||
"version": "1.0.2", | ||
"author": "Nodir Turakulov", | ||
"url": "https://github.com/nodirt/AngularTS/raw/master/angular.ngResource.d.ts" | ||
} | ||
] | ||
} | ||
] |
@@ -442,2 +442,5 @@ var Util; | ||
this.usage = "Intall file definition"; | ||
this._cache = []; | ||
this._request = Util.WebRequest.instance(); | ||
this._index = 0; | ||
} | ||
@@ -461,26 +464,57 @@ InstallCommand.prototype.accept = function (args) { | ||
}; | ||
InstallCommand.prototype.save = function (name, version, key, content) { | ||
if(!this.io.directoryExists(this.cfg.localPath)) { | ||
this.io.createDirectory(this.cfg.localPath); | ||
} | ||
this.io.createFile(this.cfg.localPath + "\\" + name + "-" + version + ".d.ts", content); | ||
this.tty.writeLine("└── " + name + "@" + version + " instaled."); | ||
this.io.createFile(this.cfg.localPath + "\\" + name + "-" + version + ".d.key", key); | ||
this.tty.writeLine(" └── " + key + ".key"); | ||
}; | ||
InstallCommand.prototype.find = function (key, libs) { | ||
for(var i = 0; i < libs.length; i++) { | ||
var lib = libs[i]; | ||
if(this.match(lib.name, key)) { | ||
return lib; | ||
} | ||
} | ||
return null; | ||
}; | ||
InstallCommand.prototype.cacheContains = function (name) { | ||
for(var i = 0; i < this._cache.length; i++) { | ||
if(this._cache[i] == name) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}; | ||
InstallCommand.prototype.install = function (targetLib, targetVersion, libs) { | ||
var _this = this; | ||
if(this.cacheContains(targetLib.name + '@' + targetVersion)) { | ||
return; | ||
} | ||
if(targetLib == null) { | ||
this.tty.warn("Lib not found."); | ||
} else { | ||
var version = targetLib.versions[0]; | ||
this._request.getUrl(version.url, function (body) { | ||
_this.save(targetLib.name, version.version, version.key, body); | ||
_this._cache.push(targetLib.name + '@' + version.version); | ||
var deps = (targetLib.versions[0].dependencies) || []; | ||
for(var i = 0; i < deps.length; i++) { | ||
var dep = _this.find(deps[i].name, libs); | ||
_this.install(dep, dep.versions[0].version, libs); | ||
} | ||
}); | ||
} | ||
}; | ||
InstallCommand.prototype.exec = function (args) { | ||
var _this = this; | ||
this.dataSource.all(function (libs) { | ||
var targetLib = null; | ||
_this.tty.writeLine(""); | ||
for(var i = 0; i < libs.length; i++) { | ||
var lib = libs[i]; | ||
if(_this.match(lib.name, args[3])) { | ||
targetLib = lib; | ||
break; | ||
} | ||
} | ||
if(targetLib == null) { | ||
var targetLib = _this.find(args[3], libs); | ||
if(targetLib) { | ||
_this.install(targetLib, targetLib.versions[0].version, libs); | ||
} else { | ||
_this.tty.warn("Lib not found."); | ||
} else { | ||
var version = targetLib.versions[0]; | ||
var request = Util.WebRequest.instance(); | ||
request.getUrl(version.url, function (body) { | ||
if(!_this.io.directoryExists(_this.cfg.localPath)) { | ||
_this.io.createDirectory(_this.cfg.localPath); | ||
} | ||
_this.io.createFile(_this.cfg.localPath + "\\" + targetLib.name + "-" + version.version + ".d.ts", body); | ||
_this.tty.write("└── " + targetLib.name + "@" + version.version + " instaled."); | ||
}); | ||
} | ||
@@ -487,0 +521,0 @@ }); |
{ | ||
"name": "tsd", | ||
"description": "The TypeScript definition package manager.", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"author": "Diullei Gomes", | ||
@@ -6,0 +6,0 @@ "licenses": [ { "type": "MIT", "url": "https://raw.github.com/Diullei/tsd/master/LICENSE.txt" } ], |
@@ -10,3 +10,6 @@ ///<reference path='ICommand.ts'/> | ||
public usage: string = "Intall file definition"; | ||
private args: Array; | ||
private _args: Array; | ||
private _cache: string[] = []; | ||
private _request: Util.WebRequest = Util.WebRequest.instance(); | ||
private _index: number = 0; | ||
@@ -37,31 +40,62 @@ constructor (public tty: ITTY, public dataSource: DataSource.IDataSource, public io: IIO, public cfg: Config) { } | ||
public exec(args: Array): void { | ||
this.dataSource.all((libs) => { | ||
var targetLib: DataSource.Lib = null; | ||
this.tty.writeLine(""); | ||
private save(name: string, version: string, key: string, content: string): void { | ||
if (!this.io.directoryExists(this.cfg.localPath)) { | ||
this.io.createDirectory(this.cfg.localPath); | ||
} | ||
// ├ | ||
this.io.createFile(this.cfg.localPath + "\\" + name + "-" + version + ".d.ts", content); | ||
this.tty.writeLine("└── " + name + "@" + version + " instaled."); | ||
this.io.createFile(this.cfg.localPath + "\\" + name + "-" + version + ".d.key", key); | ||
this.tty.writeLine(" └── " + key + ".key"); | ||
} | ||
for (var i = 0; i < libs.length; i++) { | ||
var lib = <DataSource.Lib>libs[i]; | ||
if (this.match(lib.name, args[3])) { | ||
targetLib = lib; | ||
break; | ||
} | ||
private find(key: string, libs: DataSource.Lib[]): DataSource.Lib { | ||
for (var i = 0; i < libs.length; i++) { | ||
var lib = libs[i]; | ||
if (this.match(lib.name, key)) { | ||
return lib; | ||
} | ||
} | ||
if (targetLib == null) { | ||
this.tty.warn("Lib not found."); | ||
} else { | ||
var version = targetLib.versions[0]; | ||
var request = Util.WebRequest.instance(); | ||
return null; | ||
} | ||
request.getUrl(version.url, (body) => { | ||
private cacheContains(name: string): bool { | ||
for (var i = 0; i < this._cache.length; i++) { | ||
if(this._cache[i] == name) | ||
return true; | ||
} | ||
return false; | ||
} | ||
if (!this.io.directoryExists(this.cfg.localPath)) { | ||
this.io.createDirectory(this.cfg.localPath); | ||
} | ||
this.io.createFile(this.cfg.localPath + "\\" + targetLib.name + "-" + version.version + ".d.ts", body); | ||
private install(targetLib: DataSource.Lib, targetVersion: string, libs: DataSource.Lib[]): void { | ||
if(this.cacheContains(targetLib.name + '@' + targetVersion)) | ||
return; | ||
this.tty.write("└── " + targetLib.name + "@" + version.version + " instaled."); | ||
}); | ||
} | ||
if (targetLib == null) { | ||
this.tty.warn("Lib not found."); | ||
} else { | ||
var version = targetLib.versions[0]; | ||
this._request.getUrl(version.url, (body) => { | ||
this.save(targetLib.name, version.version, version.key, body); | ||
this._cache.push(targetLib.name + '@' + version.version); | ||
var deps = (<DataSource.LibDep[]>targetLib.versions[0].dependencies) || []; | ||
for (var i = 0; i < deps.length; i++) { | ||
var dep: DataSource.Lib = this.find(deps[i].name, libs); | ||
this.install(dep, dep.versions[0].version, libs); | ||
} | ||
}); | ||
} | ||
} | ||
public exec(args: Array): void { | ||
this.dataSource.all((libs) => { | ||
this.tty.writeLine(""); | ||
var targetLib: DataSource.Lib = this.find(args[3], libs); | ||
if(targetLib) | ||
this.install(targetLib, targetLib.versions[0].version, libs); | ||
else | ||
this.tty.warn("Lib not found."); | ||
}); | ||
@@ -68,0 +102,0 @@ } |
@@ -13,3 +13,3 @@ ///<reference path='IDataSource.ts'/> | ||
public all(callback: (data: string) => void ): void { | ||
public all(callback: (data: DataSource.Lib[]) => void ): void { | ||
this._fs.readFile(this.repositoryPath, function (err, data) { | ||
@@ -16,0 +16,0 @@ if (err) throw err; |
@@ -7,2 +7,3 @@ ///<reference path='WebDataSource.ts'/> | ||
export class LibVersion { | ||
public key: string; | ||
public version: string; | ||
@@ -14,2 +15,7 @@ public author: string; | ||
export interface LibDep { | ||
name: string; | ||
version: string; | ||
} | ||
export class Lib { | ||
@@ -27,5 +33,5 @@ public name: string; | ||
export interface IDataSource { | ||
all: (callback: (data: string) => void ) => void; | ||
all: (callback: (data: DataSource.Lib[]) => void ) => void; | ||
find: (keys: string[]) => Lib; | ||
} | ||
} |
@@ -11,3 +11,3 @@ ///<reference path='IDataSource.ts'/> | ||
public all(callback: (data: string) => void ): void { | ||
public all(callback: (data: DataSource.Lib[]) => void ): void { | ||
var request = Util.WebRequest.instance(); | ||
@@ -14,0 +14,0 @@ |
@@ -25,2 +25,5 @@ ///<reference path='TTY.ts'/> | ||
//cfg.repositoryType = RepositoryTypeEnum.FileSystem; | ||
//cfg.uri = "repository.json"; | ||
cfg.localPath = "./d.ts"; | ||
@@ -27,0 +30,0 @@ |
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
63009
1542