Comparing version 0.2.6 to 0.3.0
@@ -1,2 +0,1 @@ | ||
/// <reference path='../typings/node.d.ts' /> | ||
"use strict"; | ||
@@ -23,3 +22,3 @@ var ts = require('typescript'); | ||
module: ts.ModuleKind.CommonJS, | ||
experimentalDecorators: true | ||
experimentalDecorators: true, | ||
}); | ||
@@ -26,0 +25,0 @@ if (compileError) |
@@ -1,2 +0,1 @@ | ||
/// <reference path='../typings/node.d.ts' /> | ||
"use strict"; | ||
@@ -3,0 +2,0 @@ var ts = require('typescript'); |
@@ -1,3 +0,1 @@ | ||
/// <reference path='../typings/node.d.ts' /> | ||
/// <reference path='../typings/colors.d.ts' /> | ||
"use strict"; | ||
@@ -12,2 +10,3 @@ var readline = require('node-color-readline'); | ||
var service_1 = require('./service'); | ||
var util_1 = require('./util'); | ||
var Module = require('module'); | ||
@@ -81,60 +80,3 @@ require('colors'); | ||
context = vm.createContext(); | ||
for (var g in global) { | ||
context[g] = global[g]; | ||
} | ||
// generate helper, adapted from TypeScript compiler | ||
context['__extends'] = function (d, b) { | ||
for (var p in b) | ||
if (b.hasOwnProperty(p)) | ||
d[p] = b[p]; | ||
var __ = function () { this.constructor = d; }; | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
context['__assign'] = function (t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) | ||
if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
// emit output for the __decorate helper function | ||
context['__decorate'] = function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") | ||
r = Reflect.decorate(decorators, target, key, desc); | ||
else | ||
for (var i = decorators.length - 1; i >= 0; i--) | ||
if (d = decorators[i]) | ||
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
// emit output for the __metadata helper function | ||
context['__metadata'] = function (k, v) { | ||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") | ||
return Reflect.metadata(k, v); | ||
}; | ||
// emit output for the __param helper function | ||
context['__param'] = function (paramIndex, decorator) { | ||
return function (target, key) { decorator(target, key, paramIndex); }; | ||
}; | ||
context['__awaiter'] = function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { | ||
step(generator.next(value)); | ||
} | ||
catch (e) { | ||
reject(e); | ||
} } | ||
function rejected(value) { try { | ||
step(generator.throw(value)); | ||
} | ||
catch (e) { | ||
reject(e); | ||
} } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments)).next()); | ||
}); | ||
}; | ||
util_1.assign(context, global); | ||
context.console = new console_1.Console(process.stdout); | ||
@@ -178,3 +120,3 @@ context.global = context; | ||
function printHelp() { | ||
console.log("\ntsun repl commands\n:type symbol print the type of an identifier\n:detail symbol print details of identifier\n:source symbol print source of identifier\n:clear clear all the code\n:print print code input so far\n:help print this manual\n:paste enter paste mode".blue); | ||
console.log("\ntsun repl commands\n:type symbol print the type of an identifier\n:clear clear all the code\n:print print code input so far\n:help print this manual\n:paste enter paste mode".blue); | ||
if (argv.dere) { | ||
@@ -222,3 +164,3 @@ console.log(':baka Who would like some pervert like you, baka~'.blue); | ||
} | ||
function replLoop(prompt, code) { | ||
function replLoop(_, code) { | ||
code = multilineBuffer + '\n' + code; | ||
@@ -249,3 +191,3 @@ var diagnostics = service_1.testSyntacticError(code); | ||
rl.on('line', addLine); | ||
rl.once('close', function (d) { | ||
rl.once('close', function () { | ||
console.log('evaluating...'.cyan); | ||
@@ -265,3 +207,4 @@ rl.removeListener('line', addLine); | ||
var pager = process.env.PAGER; | ||
var text = decl[0].parent.getFullText(); | ||
var parent_1 = decl[0].parent; | ||
var text = parent_1 ? parent_1.getFullText() : ''; | ||
if (!pager || text.split('\n').length < 24) { | ||
@@ -296,6 +239,6 @@ console.log(text); | ||
rl.question(prompt, function (code) { | ||
if (/^:(type|detail)/.test(code)) { | ||
if (/^:(type)/.test(code)) { | ||
var identifier = code.split(' ')[1]; | ||
if (!identifier) { | ||
console.log(':type|detail command need names!'.red); | ||
console.log(':type command need names!'.red); | ||
return repl(prompt); | ||
@@ -302,0 +245,0 @@ } |
@@ -1,9 +0,7 @@ | ||
/// <reference path='../typings/node.d.ts' /> | ||
/// <reference path='../typings/colors.d.ts' /> | ||
/// <reference path='../typings/diff.d.ts' /> | ||
"use strict"; | ||
var ts = require('typescript'); | ||
var path = require('path'); | ||
var fs = require('fs'); | ||
var fs_1 = require('fs'); | ||
var diff = require('diff'); | ||
var util_1 = require('./util'); | ||
// codes has been accepted by service, as opposed to codes in buffer and user input | ||
@@ -17,3 +15,3 @@ // if some action fails to compile, acceptedCodes will be rolled-back | ||
var fileName = path.join(searchPath, "tsconfig.json"); | ||
if (fs.existsSync(fileName)) { | ||
if (fs_1.existsSync(fileName)) { | ||
return fileName; | ||
@@ -29,8 +27,16 @@ } | ||
} | ||
var CWD = process.cwd(); | ||
var DEFAULT_OPTIONS = { | ||
module: ts.ModuleKind.CommonJS, | ||
target: ts.ScriptTarget.ES5, | ||
newLine: ts.NewLineKind.LineFeed, | ||
experimentalDecorators: true, | ||
emitDecoratorMetadata: true, | ||
noUnusedLocals: false, | ||
configFilePath: path.join(CWD, 'tsconfig.json'), | ||
}; | ||
// these option must be set in repl environment | ||
var OVERRIDE_OPTIONS = { | ||
module: ts.ModuleKind.CommonJS, | ||
noEmitHelpers: true, | ||
experimentalDecorators: true | ||
noUnusedLocals: false | ||
}; | ||
@@ -42,3 +48,3 @@ function compileOption() { | ||
} | ||
var configText = fs.readFileSync(configFile, 'utf8'); | ||
var configText = fs_1.readFileSync(configFile, 'utf8'); | ||
var result = ts.parseConfigFileTextToJson(configFile, configText); | ||
@@ -48,9 +54,9 @@ if (result.error) { | ||
} | ||
var optionsRet = ts.convertCompilerOptionsFromJson(result.config.compilerOptions, path.dirname(configFile)); | ||
if (optionsRet.errors.length) { | ||
var optionOrError = ts.convertCompilerOptionsFromJson(result.config.compilerOptions, path.dirname(configFile)); | ||
if (optionOrError.errors.length) { | ||
return function () { return DEFAULT_OPTIONS; }; | ||
} | ||
var options = optionsRet.options; | ||
options['noEmitHelpers'] = true; | ||
options['module'] = ts.ModuleKind.CommonJS; | ||
var options = optionOrError.options; | ||
// override some impossible option | ||
util_1.assign(options, OVERRIDE_OPTIONS); | ||
return function () { return options; }; | ||
@@ -64,3 +70,3 @@ } | ||
getScriptVersion: function (fileName) { | ||
return fileName === DUMMY_FILE && versionCounter.toString(); | ||
return fileName === DUMMY_FILE ? versionCounter.toString() : '1'; | ||
}, | ||
@@ -71,18 +77,21 @@ getScriptSnapshot: function (fileName) { | ||
? exports.acceptedCodes | ||
: fs.readFileSync(fileName).toString(); | ||
: fs_1.readFileSync(fileName).toString(); | ||
return ts.ScriptSnapshot.fromString(text); | ||
} | ||
catch (e) { | ||
return undefined; | ||
} | ||
}, | ||
getCurrentDirectory: function () { return process.cwd(); }, | ||
getDefaultLibFileName: function (options) { return path.join(__dirname, '../../node_modules/typescript/lib/lib.core.es6.d.ts'); } | ||
getCurrentDirectory: function () { return CWD; }, | ||
getDirectories: ts.sys.getDirectories, | ||
directoryExists: ts.sys.directoryExists, | ||
getDefaultLibFileName: function (options) { return ts.getDefaultLibFilePath(options); } | ||
}; | ||
var service = ts.createLanguageService(serviceHost, ts.createDocumentRegistry()); | ||
var service = ts.createLanguageService(serviceHost); | ||
exports.getDeclarations = (function () { | ||
var declarations = {}; | ||
var declFiles = getDeclarationFiles().concat(path.join(__dirname, '../../node_modules/typescript/lib/lib.core.es6.d.ts')); | ||
var declFiles = getDeclarationFiles(); | ||
for (var _i = 0, declFiles_1 = declFiles; _i < declFiles_1.length; _i++) { | ||
var file = declFiles_1[_i]; | ||
var text = fs.readFileSync(file, 'utf8'); | ||
var text = fs_1.readFileSync(file, 'utf8'); | ||
declarations[file] = collectDeclaration(ts.createSourceFile(file, text, ts.ScriptTarget.Latest)); | ||
@@ -99,6 +108,6 @@ } | ||
function getDeclarationFiles() { | ||
var libPaths = [path.resolve(__dirname, '../../typings/node.d.ts')]; | ||
var libPaths = [path.resolve(__dirname, '../../node_modules/@types/node/index.d.ts')]; | ||
try { | ||
var typings = path.join(process.cwd(), './typings'); | ||
var dirs = fs.readdirSync(typings); | ||
var dirs = fs_1.readdirSync(typings); | ||
for (var _i = 0, dirs_1 = dirs; _i < dirs_1.length; _i++) { | ||
@@ -109,3 +118,3 @@ var dir = dirs_1[_i]; | ||
var p = path.join(typings, dir); | ||
if (fs.statSync(p).isFile()) { | ||
if (fs_1.statSync(p).isFile()) { | ||
libPaths.push(p); | ||
@@ -112,0 +121,0 @@ } |
@@ -1,3 +0,5 @@ | ||
/// <reference path='./typings/node.d.ts' /> | ||
"use strict"; | ||
var tslib = require('tslib'); | ||
var util_1 = require('./src/util'); | ||
util_1.assign(global, tslib); | ||
require('./src/register'); | ||
@@ -4,0 +6,0 @@ var executor_1 = require('./src/executor'); |
{ | ||
"name": "tsun", | ||
"version": "0.2.6", | ||
"preferGlobal": true, | ||
"version": "0.3.0", | ||
"description": "TSUN: a repl for TypeScript Upgraded Node", | ||
@@ -12,6 +13,11 @@ "bin": "./bin/tsun", | ||
"temp": "^0.8.1", | ||
"typescript": "1.8.10" | ||
"tslib": "^1.0.0", | ||
"@types/node": "^6.0.41", | ||
"typescript": "^2.0.3" | ||
}, | ||
"files": [ | ||
"bin" | ||
], | ||
"scripts": { | ||
"prepublish": "tsc -m commonjs --outdir ./bin tsun.ts" | ||
"prepublish": "tsc" | ||
}, | ||
@@ -31,3 +37,7 @@ "keywords": [ | ||
"homepage": "https://github.com/HerringtonDarkholme/typescript-repl", | ||
"bugs": "https://github.com/HerringtonDarkholme/typescript-repl/issues" | ||
"bugs": "https://github.com/HerringtonDarkholme/typescript-repl/issues", | ||
"devDependencies": { | ||
"@types/colors": "^0.6.33", | ||
"@types/diff": "0.0.31" | ||
} | ||
} |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
27549
8
2
9
648
3
+ Added@types/node@^6.0.41
+ Addedtslib@^1.0.0
+ Added@types/node@6.14.13(transitive)
+ Addedtslib@1.14.1(transitive)
+ Addedtypescript@2.9.2(transitive)
- Removedtypescript@1.8.10(transitive)
Updatedtypescript@^2.0.3