This repository has been archived by the owner on Apr 30, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* TSD allow multple definition installations by using: `tsd install lib [lib...]` * You can define repository url and other configuration in a config file * Repository directory structure is mirrored in local folder. * some bug fix
- Loading branch information
Showing
15 changed files
with
452 additions
and
220 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,41 @@ | |||
///<reference path='ICommand.ts'/> | |||
///<reference path='../Config.ts'/> | |||
///<reference path='../System/IO/FileManager.ts'/> | |||
|
|||
module Command { | |||
|
|||
export class CreateLocalConfigCommand implements ICommand { | |||
|
|||
public shortcut: string = "ncfg"; | |||
public usage: string = "Create a local config file."; | |||
private args: Array; | |||
|
|||
public accept(args: Array): bool { | |||
return args[2] == this.shortcut; | |||
} | |||
|
|||
private saveConfigFile(): void { | |||
var sw = System.IO.FileManager.handle.createFile(Config.FILE_NAME); | |||
sw.write('{\n' | |||
+ ' "localPath": "d.ts",\n' | |||
+ ' "repositoryType": "1",\n' | |||
+ ' "uri": "https://github.com/Diullei/tsd/raw/master/deploy/repository.json"\n' | |||
+ '}'); | |||
sw.flush(); | |||
sw.close(); | |||
} | |||
|
|||
public exec(args: Array): void { | |||
if (System.IO.FileManager.handle.fileExists(Config.FILE_NAME)) { | |||
throw new Error("There is already a configuration file in this folder."); | |||
} else { | |||
this.saveConfigFile(); | |||
} | |||
System.Console.writeLine("configuration file created successfully."); | |||
} | |||
|
|||
public toString(): string { | |||
return this.shortcut + " " + this.usage; | |||
} | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,23 +1,36 @@ | |||
///<reference path='System/IO/FileManager.ts'/> | ///<reference path='System/IO/FileManager.ts'/> | ||
|
|
||
declare var unescape; | |||
|
|||
enum RepositoryTypeEnum { | enum RepositoryTypeEnum { | ||
FileSystem, | FileSystem, | ||
Web | Web | ||
} | } | ||
|
|
||
class Config { | class Config { | ||
public static FILE_NAME = 'tsd-config.json'; | |||
|
|||
public repositoryType: RepositoryTypeEnum; | public repositoryType: RepositoryTypeEnum; | ||
public uri: string; | public uri: string; | ||
public localPath: string; | public localPath: string; | ||
|
|
||
private static isNull(cfg: Object, key: string, alternativeValue: any): any { | |||
return cfg[key] ? cfg[key] : alternativeValue; | |||
} | |||
|
|||
private static tryGetConfigFile() { | |||
var cfg = {}; | |||
try { | |||
cfg = JSON.parse(System.IO.FileManager.handle.readFile(Config.FILE_NAME)); | |||
} catch (e) { | |||
} | |||
return cfg; | |||
} | |||
|
|||
public load() { | public load() { | ||
try{ | var cfg = Config.tryGetConfigFile(); | ||
var cfgStr = System.IO.FileManager.handle.readFile('tsd-config.json'); | this.localPath = Config.isNull(cfg, 'localPath', 'd.ts'); | ||
var cfg = JSON.parse(cfgStr); | this.repositoryType = Config.isNull(cfg, 'repositoryType', RepositoryTypeEnum.Web); | ||
this.localPath = cfg.localPath; | this.uri = Config.isNull(cfg, 'uri', "https://github.com/Diullei/tsd/raw/master/deploy/repository.json"); | ||
}catch(e){ | |||
console.log(e); | |||
this.localPath = "d.ts"; | |||
} | |||
} | } | ||
} | } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,55 @@ | |||
// parseUri 1.2.2 | |||
// (c) Steven Levithan <stevenlevithan.com> | |||
// MIT License | |||
|
|||
interface UriParsedObject { | |||
anchor: string; | |||
query: string; | |||
file: string; | |||
directory: string; | |||
path: string; | |||
relative: string; | |||
port: string; | |||
host: string; | |||
password: string; | |||
user: string; | |||
iserInfo: string; | |||
authority: string; | |||
protocol: string; | |||
source: string; | |||
queryKey: Object; | |||
} | |||
|
|||
var Uri = <{ parseUri: (str: string) => UriParsedObject; }><any>(function () { | |||
|
|||
var options = { | |||
strictMode: false, | |||
key: ["source", "protocol", "authority", "userInfo", "user", "password", "host", "port", "relative", "path", "directory", "file", "query", "anchor"], | |||
q: { | |||
name: "queryKey", | |||
parser: /(?:^|&)([^&=]*)=?([^&]*)/g | |||
}, | |||
parser: { | |||
strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, | |||
loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/ | |||
} | |||
}; | |||
|
|||
function parseUri(str) { | |||
var o = options, | |||
m = o.parser[o.strictMode ? "strict" : "loose"].exec(str), | |||
uri = {}, | |||
i = 14; | |||
|
|||
while (i--) uri[o.key[i]] = m[i] || ""; | |||
|
|||
uri[o.q.name] = {}; | |||
uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) { | |||
if ($1) uri[o.q.name][$1] = $2; | |||
}); | |||
|
|||
return uri; | |||
}; | |||
|
|||
return { parseUri: parseUri }; | |||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.