Comparing version 0.5.4 to 0.6.0
@@ -10,28 +10,4 @@ "use strict"; | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [0, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
@@ -54,4 +30,4 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
*/ | ||
var chalk_1 = require("chalk"); | ||
var util_1 = require("./util"); | ||
const chalk_1 = __importDefault(require("chalk")); | ||
const util_1 = require("./util"); | ||
/** | ||
@@ -61,29 +37,22 @@ * Remove files generated by the build. | ||
function clean(options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var tsconfig, outDir, message; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, util_1.getTSConfig(options.targetRootDir)]; | ||
case 1: | ||
tsconfig = (_a.sent()); | ||
if (!(tsconfig.compilerOptions && tsconfig.compilerOptions.outDir)) return [3 /*break*/, 3]; | ||
outDir = tsconfig.compilerOptions.outDir; | ||
if (outDir === '.') { | ||
options.logger.error(chalk_1.default.red('ERROR:') + " " + chalk_1.default.gray('compilerOptions.outDir') + " " + | ||
"cannot use the value '.'. That would delete all of our sources."); | ||
return [2 /*return*/, false]; | ||
} | ||
message = chalk_1.default.red('Removing') + " " + outDir + " ..."; | ||
options.logger.log(message); | ||
return [4 /*yield*/, util_1.rimrafp(outDir)]; | ||
case 2: | ||
_a.sent(); | ||
return [2 /*return*/, true]; | ||
case 3: | ||
options.logger.error(chalk_1.default.red('ERROR:') + " The " + chalk_1.default.gray('clean') + " command" + | ||
(" requires " + chalk_1.default.gray('compilerOptions.outDir') + " to be defined in ") + | ||
"tsconfig.json."); | ||
return [2 /*return*/, false]; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const tsconfig = (yield util_1.getTSConfig(options.targetRootDir)); | ||
if (tsconfig.compilerOptions && tsconfig.compilerOptions.outDir) { | ||
const outDir = tsconfig.compilerOptions.outDir; | ||
if (outDir === '.') { | ||
options.logger.error(`${chalk_1.default.red('ERROR:')} ${chalk_1.default.gray('compilerOptions.outDir')} ` + | ||
`cannot use the value '.'. That would delete all of our sources.`); | ||
return false; | ||
} | ||
}); | ||
const message = `${chalk_1.default.red('Removing')} ${outDir} ...`; | ||
options.logger.log(message); | ||
yield util_1.rimrafp(outDir); | ||
return true; | ||
} | ||
else { | ||
options.logger.error(`${chalk_1.default.red('ERROR:')} The ${chalk_1.default.gray('clean')} command` + | ||
` requires ${chalk_1.default.gray('compilerOptions.outDir')} to be defined in ` + | ||
`tsconfig.json.`); | ||
return false; | ||
} | ||
}); | ||
@@ -90,0 +59,0 @@ } |
@@ -11,38 +11,43 @@ #!/usr/bin/env node | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [0, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var path = require("path"); | ||
var meow = require("meow"); | ||
var updateNotifier = require("update-notifier"); | ||
var init_1 = require("./init"); | ||
var clean_1 = require("./clean"); | ||
var packageJson = require('../../package.json'); | ||
var logger = console; | ||
var cli = meow("\n\tUsage\n\t $ gts <verb> [<file>...] [options]\n\n Verb can be:\n init Adds default npm scripts to your package.json.\n check Checks code for formatting and lint issues.\n fix Fixes formatting and linting issues (if possible).\n clean Removes all files generated by the build.\n\n Options\n --help Prints this help message.\n -y, --yes Assume a yes answer for every prompt.\n -n, --no Assume a no answer for every prompt.\n --dry-run Don't make any acutal changes.\n\n\tExamples\n $ gts init -y\n $ gts check\n $ gts fix\n $ gts fix src/file1.ts src/file2.ts\n $ gts clean\n"); | ||
const path = __importStar(require("path")); | ||
const meow_1 = __importDefault(require("meow")); | ||
const update_notifier_1 = __importDefault(require("update-notifier")); | ||
const init_1 = require("./init"); | ||
const clean_1 = require("./clean"); | ||
const packageJson = require('../../package.json'); | ||
const logger = console; | ||
const cli = meow_1.default(` | ||
Usage | ||
$ gts <verb> [<file>...] [options] | ||
Verb can be: | ||
init Adds default npm scripts to your package.json. | ||
check Checks code for formatting and lint issues. | ||
fix Fixes formatting and linting issues (if possible). | ||
clean Removes all files generated by the build. | ||
Options | ||
--help Prints this help message. | ||
-y, --yes Assume a yes answer for every prompt. | ||
-n, --no Assume a no answer for every prompt. | ||
--dry-run Don't make any acutal changes. | ||
Examples | ||
$ gts init -y | ||
$ gts check | ||
$ gts fix | ||
$ gts fix src/file1.ts src/file2.ts | ||
$ gts clean | ||
`); | ||
function usage(msg) { | ||
@@ -55,59 +60,41 @@ if (msg) { | ||
function run(verb, files) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var options, lint, format, _a, passLint, passFormat, _b; | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: | ||
options = { | ||
dryRun: cli.flags.dryRun || false, | ||
// Paths are relative to the transpiled output files. | ||
gtsRootDir: path.resolve(__dirname, '../..'), | ||
targetRootDir: process.cwd(), | ||
yes: cli.flags.yes || cli.flags.y || false, | ||
no: cli.flags.no || cli.flags.n || false, | ||
logger: logger | ||
}; | ||
if (!(verb === 'init')) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, init_1.init(options)]; | ||
case 1: return [2 /*return*/, _c.sent()]; | ||
case 2: | ||
lint = require('./lint').lint; | ||
format = require('./format').format; | ||
_a = verb; | ||
switch (_a) { | ||
case 'check': return [3 /*break*/, 3]; | ||
case 'fix': return [3 /*break*/, 6]; | ||
case 'clean': return [3 /*break*/, 10]; | ||
} | ||
return [3 /*break*/, 12]; | ||
case 3: return [4 /*yield*/, lint(options, files)]; | ||
case 4: | ||
passLint = _c.sent(); | ||
return [4 /*yield*/, format(options, files)]; | ||
case 5: | ||
passFormat = _c.sent(); | ||
return [2 /*return*/, passLint && passFormat]; | ||
case 6: return [4 /*yield*/, lint(options, files, true)]; | ||
case 7: | ||
_b = (_c.sent()); | ||
if (!_b) return [3 /*break*/, 9]; | ||
return [4 /*yield*/, format(options, files, true)]; | ||
case 8: | ||
_b = (_c.sent()); | ||
_c.label = 9; | ||
case 9: return [2 /*return*/, (_b)]; | ||
case 10: return [4 /*yield*/, clean_1.clean(options)]; | ||
case 11: return [2 /*return*/, _c.sent()]; | ||
case 12: | ||
usage("Unknown verb: " + verb); | ||
return [2 /*return*/, false]; | ||
} | ||
}); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const options = { | ||
dryRun: cli.flags.dryRun || false, | ||
// Paths are relative to the transpiled output files. | ||
gtsRootDir: path.resolve(__dirname, '../..'), | ||
targetRootDir: process.cwd(), | ||
yes: cli.flags.yes || cli.flags.y || false, | ||
no: cli.flags.no || cli.flags.n || false, | ||
logger | ||
}; | ||
// Linting/formatting depend on typescript. We don't want to load the | ||
// typescript module during init, since it might not exist. | ||
// See: https://github.com/google/ts-style/issues/48 | ||
if (verb === 'init') { | ||
return yield init_1.init(options); | ||
} | ||
const lint = require('./lint').lint; | ||
const format = require('./format').format; | ||
switch (verb) { | ||
case 'check': | ||
const passLint = yield lint(options, files); | ||
const passFormat = yield format(options, files); | ||
return passLint && passFormat; | ||
case 'fix': | ||
return ((yield lint(options, files, true)) && | ||
(yield format(options, files, true))); | ||
case 'clean': | ||
return yield clean_1.clean(options); | ||
default: | ||
usage(`Unknown verb: ${verb}`); | ||
return false; | ||
} | ||
}); | ||
} | ||
updateNotifier({ pkg: packageJson }).notify(); | ||
update_notifier_1.default({ pkg: packageJson }).notify(); | ||
if (cli.input.length < 1) { | ||
usage(); | ||
} | ||
run(cli.input[0], cli.input.slice(1)).then(function (success) { | ||
run(cli.input[0], cli.input.slice(1)).then(success => { | ||
if (!success) { | ||
@@ -114,0 +101,0 @@ process.exit(1); |
@@ -10,33 +10,6 @@ "use strict"; | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [0, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var lint_1 = require("./lint"); | ||
var clangFormat = require('clang-format'); | ||
var baseArgs = ['-style', '{Language: JavaScript, BasedOnStyle: Google, ColumnLimit: 80}']; | ||
const lint_1 = require("./lint"); | ||
const clangFormat = require('clang-format'); | ||
const baseArgs = ['-style', '{Language: JavaScript, BasedOnStyle: Google, ColumnLimit: 80}']; | ||
/** | ||
@@ -48,26 +21,24 @@ * Run tslint fix and clang fix with the default configuration | ||
*/ | ||
function format(options, files, fix) { | ||
if (files === void 0) { files = []; } | ||
if (fix === void 0) { fix = false; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var program, srcFiles, result; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
program = lint_1.createProgram(options); | ||
srcFiles = files.length > 0 ? | ||
files : | ||
program.getRootFileNames().filter(function (f) { return !f.endsWith('.d.ts'); }); | ||
if (!fix) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, fixFormat(srcFiles)]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
case 2: return [4 /*yield*/, checkFormat(srcFiles)]; | ||
case 3: | ||
result = _a.sent(); | ||
if (!result) { | ||
options.logger.log('clang-format reported errors... run `gts fix` to address.'); | ||
} | ||
return [2 /*return*/, result]; | ||
function format(options, files = [], fix = false) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const program = lint_1.createProgram(options); | ||
// Obtain a list of source files to format. | ||
// We use program.getRootFileNames to get only the files that match the | ||
// include patterns specified in the given tsconfig.json file (as specified | ||
// through options). This is necessary because we only want to format files | ||
// over which the developer has control (i.e. not auto-generated or | ||
// third-party source files). | ||
const srcFiles = files.length > 0 ? | ||
files : | ||
program.getRootFileNames().filter(f => !f.endsWith('.d.ts')); | ||
if (fix) { | ||
return yield fixFormat(srcFiles); | ||
} | ||
else { | ||
const result = yield checkFormat(srcFiles); | ||
if (!result) { | ||
options.logger.log('clang-format reported errors... run `gts fix` to address.'); | ||
} | ||
}); | ||
return result; | ||
} | ||
}); | ||
@@ -82,5 +53,5 @@ } | ||
function fixFormat(srcFiles) { | ||
return new Promise(function (resolve, reject) { | ||
var args = baseArgs.concat(['-i'], srcFiles); | ||
clangFormat.spawnClangFormat(args, function (err) { | ||
return new Promise((resolve, reject) => { | ||
const args = baseArgs.concat(['-i'], srcFiles); | ||
clangFormat.spawnClangFormat(args, (err) => { | ||
if (err) { | ||
@@ -102,7 +73,7 @@ reject(err); | ||
function checkFormat(srcFiles) { | ||
return new Promise(function (resolve, reject) { | ||
var output = ''; | ||
var args = baseArgs.concat(['-output-replacements-xml'], srcFiles); | ||
var out = clangFormat | ||
.spawnClangFormat(args, function (err) { | ||
return new Promise((resolve, reject) => { | ||
let output = ''; | ||
const args = baseArgs.concat(['-output-replacements-xml'], srcFiles); | ||
const out = clangFormat | ||
.spawnClangFormat(args, (err) => { | ||
if (err) { | ||
@@ -114,6 +85,6 @@ reject(err); | ||
out.setEncoding('utf8'); | ||
out.on('data', function (data) { | ||
out.on('data', (data) => { | ||
output += data; | ||
}); | ||
out.on('end', function () { | ||
out.on('end', () => { | ||
resolve(output.indexOf('<replacement ') === -1 ? true : false); | ||
@@ -120,0 +91,0 @@ }); |
@@ -10,29 +10,12 @@ "use strict"; | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [0, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -54,118 +37,80 @@ /** | ||
*/ | ||
var chalk_1 = require("chalk"); | ||
var cp = require("child_process"); | ||
var inquirer = require("inquirer"); | ||
var util_1 = require("./util"); | ||
var pkg = require('../../package.json'); | ||
const chalk_1 = __importDefault(require("chalk")); | ||
const cp = __importStar(require("child_process")); | ||
const inquirer = __importStar(require("inquirer")); | ||
const util_1 = require("./util"); | ||
const pkg = require('../../package.json'); | ||
function query(message, question, defaultVal, options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var answers; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (options.yes) { | ||
return [2 /*return*/, true]; | ||
} | ||
else if (options.no) { | ||
return [2 /*return*/, false]; | ||
} | ||
if (message) { | ||
options.logger.log(message); | ||
} | ||
return [4 /*yield*/, inquirer.prompt({ type: 'confirm', name: 'query', message: question, default: defaultVal })]; | ||
case 1: | ||
answers = _a.sent(); | ||
return [2 /*return*/, answers.query]; | ||
} | ||
}); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (options.yes) { | ||
return true; | ||
} | ||
else if (options.no) { | ||
return false; | ||
} | ||
if (message) { | ||
options.logger.log(message); | ||
} | ||
const answers = yield inquirer.prompt({ type: 'confirm', name: 'query', message: question, default: defaultVal }); | ||
return answers.query; | ||
}); | ||
} | ||
function addScripts(packageJson, options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var edits, scripts, _i, _a, script, install, existing, target, message; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
edits = false; | ||
scripts = { | ||
check: "gts check", | ||
clean: 'gts clean', | ||
compile: "tsc -p .", | ||
fix: "gts fix", | ||
prepare: "npm run compile", | ||
pretest: "npm run compile", | ||
posttest: "npm run check" | ||
}; | ||
if (!packageJson.scripts) { | ||
packageJson.scripts = {}; | ||
} | ||
_i = 0, _a = Object.keys(scripts); | ||
_b.label = 1; | ||
case 1: | ||
if (!(_i < _a.length)) return [3 /*break*/, 5]; | ||
script = _a[_i]; | ||
install = true; | ||
existing = packageJson.scripts[script]; | ||
target = scripts[script]; | ||
if (!(existing !== target)) return [3 /*break*/, 4]; | ||
if (!existing) return [3 /*break*/, 3]; | ||
message = "package.json already has a script for " + chalk_1.default.bold(script) + ":\n" + | ||
("-" + chalk_1.default.red(existing) + "\n+" + chalk_1.default.green(target)); | ||
return [4 /*yield*/, query(message, 'Replace', false, options)]; | ||
case 2: | ||
install = _b.sent(); | ||
_b.label = 3; | ||
case 3: | ||
if (install) { | ||
packageJson.scripts[script] = scripts[script]; | ||
edits = true; | ||
} | ||
_b.label = 4; | ||
case 4: | ||
_i++; | ||
return [3 /*break*/, 1]; | ||
case 5: return [2 /*return*/, edits]; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let edits = false; | ||
const scripts = { | ||
check: `gts check`, | ||
clean: 'gts clean', | ||
compile: `tsc -p .`, | ||
fix: `gts fix`, | ||
prepare: `npm run compile`, | ||
pretest: `npm run compile`, | ||
posttest: `npm run check` | ||
}; | ||
if (!packageJson.scripts) { | ||
packageJson.scripts = {}; | ||
} | ||
for (const script of Object.keys(scripts)) { | ||
let install = true; | ||
const existing = packageJson.scripts[script]; | ||
const target = scripts[script]; | ||
if (existing !== target) { | ||
if (existing) { | ||
const message = `package.json already has a script for ${chalk_1.default.bold(script)}:\n` + | ||
`-${chalk_1.default.red(existing)}\n+${chalk_1.default.green(target)}`; | ||
install = yield query(message, 'Replace', false, options); | ||
} | ||
if (install) { | ||
packageJson.scripts[script] = scripts[script]; | ||
edits = true; | ||
} | ||
} | ||
}); | ||
} | ||
return edits; | ||
}); | ||
} | ||
function addDependencies(packageJson, options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var edits, deps, _i, _a, dep, install, existing, target, message; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
edits = false; | ||
deps = { 'gts': "^" + pkg.version, 'typescript': '~2.6.1' }; | ||
if (!packageJson.devDependencies) { | ||
packageJson.devDependencies = {}; | ||
} | ||
_i = 0, _a = Object.keys(deps); | ||
_b.label = 1; | ||
case 1: | ||
if (!(_i < _a.length)) return [3 /*break*/, 5]; | ||
dep = _a[_i]; | ||
install = true; | ||
existing = packageJson.devDependencies[dep]; | ||
target = deps[dep]; | ||
if (!(existing !== target)) return [3 /*break*/, 4]; | ||
if (!existing) return [3 /*break*/, 3]; | ||
message = "Already have devDependency for " + chalk_1.default.bold(dep) + ":\n" + | ||
("-" + chalk_1.default.red(existing) + "\n+" + chalk_1.default.green(target)); | ||
return [4 /*yield*/, query(message, 'Overwrite', false, options)]; | ||
case 2: | ||
install = _b.sent(); | ||
_b.label = 3; | ||
case 3: | ||
if (install) { | ||
packageJson.devDependencies[dep] = deps[dep]; | ||
edits = true; | ||
} | ||
_b.label = 4; | ||
case 4: | ||
_i++; | ||
return [3 /*break*/, 1]; | ||
case 5: return [2 /*return*/, edits]; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let edits = false; | ||
const deps = { 'gts': `^${pkg.version}`, 'typescript': '~2.8.0' }; | ||
if (!packageJson.devDependencies) { | ||
packageJson.devDependencies = {}; | ||
} | ||
for (const dep of Object.keys(deps)) { | ||
let install = true; | ||
const existing = packageJson.devDependencies[dep]; | ||
const target = deps[dep]; | ||
if (existing !== target) { | ||
if (existing) { | ||
const message = `Already have devDependency for ${chalk_1.default.bold(dep)}:\n` + | ||
`-${chalk_1.default.red(existing)}\n+${chalk_1.default.green(target)}`; | ||
install = yield query(message, 'Overwrite', false, options); | ||
} | ||
if (install) { | ||
packageJson.devDependencies[dep] = deps[dep]; | ||
edits = true; | ||
} | ||
} | ||
}); | ||
} | ||
return edits; | ||
}); | ||
@@ -175,141 +120,94 @@ } | ||
// TODO: preserve the indent from the input file. | ||
var json = JSON.stringify(object, null, ' '); | ||
return json + "\n"; | ||
const json = JSON.stringify(object, null, ' '); | ||
return `${json}\n`; | ||
} | ||
function writePackageJson(packageJson, options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var preview; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
options.logger.log('Writing package.json...'); | ||
if (!!options.dryRun) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, util_1.writeFileAtomicp('./package.json', formatJson(packageJson))]; | ||
case 1: | ||
_a.sent(); | ||
_a.label = 2; | ||
case 2: | ||
preview = { | ||
scripts: packageJson.scripts, | ||
devDependencies: packageJson.devDependencies | ||
}; | ||
options.logger.dir(preview); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
options.logger.log('Writing package.json...'); | ||
if (!options.dryRun) { | ||
yield util_1.writeFileAtomicp('./package.json', formatJson(packageJson)); | ||
} | ||
const preview = { | ||
scripts: packageJson.scripts, | ||
devDependencies: packageJson.devDependencies | ||
}; | ||
options.logger.dir(preview); | ||
}); | ||
} | ||
function generateTsConfig(options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var existing, err_1, tsconfig, writeTsConfig; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, util_1.readFilep('./tsconfig.json', 'utf8')]; | ||
case 1: | ||
existing = _a.sent(); | ||
return [3 /*break*/, 3]; | ||
case 2: | ||
err_1 = _a.sent(); | ||
if (err_1.code === 'ENOENT') { | ||
/* not found, create it. */ | ||
} | ||
else { | ||
throw new Error("Unknown error reading tsconfig.json: " + err_1.message); | ||
} | ||
return [3 /*break*/, 3]; | ||
case 3: | ||
tsconfig = formatJson({ | ||
extends: './node_modules/gts/tsconfig-google.json', | ||
compilerOptions: { rootDir: '.', outDir: 'build' }, | ||
include: ['src/*.ts', 'src/**/*.ts', 'test/*.ts', 'test/**/*.ts'], | ||
exclude: ['node_modules'] | ||
}); | ||
writeTsConfig = true; | ||
if (!(existing && existing === tsconfig)) return [3 /*break*/, 4]; | ||
options.logger.log('No edits needed in tsconfig.json.'); | ||
return [2 /*return*/]; | ||
case 4: | ||
if (!existing) return [3 /*break*/, 6]; | ||
return [4 /*yield*/, query(chalk_1.default.bold('tsconfig.json') + " already exists", 'Overwrite', false, options)]; | ||
case 5: | ||
writeTsConfig = _a.sent(); | ||
_a.label = 6; | ||
case 6: | ||
if (!writeTsConfig) return [3 /*break*/, 9]; | ||
options.logger.log('Writing tsconfig.json...'); | ||
if (!!options.dryRun) return [3 /*break*/, 8]; | ||
return [4 /*yield*/, util_1.writeFileAtomicp('./tsconfig.json', tsconfig)]; | ||
case 7: | ||
_a.sent(); | ||
_a.label = 8; | ||
case 8: | ||
options.logger.dir(JSON.parse(tsconfig)); | ||
_a.label = 9; | ||
case 9: return [2 /*return*/]; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let existing; | ||
try { | ||
existing = yield util_1.readFilep('./tsconfig.json', 'utf8'); | ||
} | ||
catch (err) { | ||
if (err.code === 'ENOENT') { | ||
/* not found, create it. */ | ||
} | ||
else { | ||
throw new Error(`Unknown error reading tsconfig.json: ${err.message}`); | ||
} | ||
} | ||
const tsconfig = formatJson({ | ||
extends: './node_modules/gts/tsconfig-google.json', | ||
compilerOptions: { rootDir: '.', outDir: 'build' }, | ||
include: ['src/*.ts', 'src/**/*.ts', 'test/*.ts', 'test/**/*.ts'] | ||
}); | ||
let writeTsConfig = true; | ||
if (existing && existing === tsconfig) { | ||
options.logger.log('No edits needed in tsconfig.json.'); | ||
return; | ||
} | ||
else if (existing) { | ||
writeTsConfig = yield query(`${chalk_1.default.bold('tsconfig.json')} already exists`, 'Overwrite', false, options); | ||
} | ||
if (writeTsConfig) { | ||
options.logger.log('Writing tsconfig.json...'); | ||
if (!options.dryRun) { | ||
yield util_1.writeFileAtomicp('./tsconfig.json', tsconfig); | ||
} | ||
options.logger.dir(JSON.parse(tsconfig)); | ||
} | ||
}); | ||
} | ||
function init(options) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var packageJson, err_2, generate, err2_1, addedDeps, addedScripts; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 2, , 8]); | ||
return [4 /*yield*/, util_1.readJsonp('./package.json')]; | ||
case 1: | ||
packageJson = _a.sent(); | ||
return [3 /*break*/, 8]; | ||
case 2: | ||
err_2 = _a.sent(); | ||
if (err_2.code !== 'ENOENT') { | ||
throw new Error("Unable to open package.json file: " + err_2.message); | ||
} | ||
return [4 /*yield*/, query(chalk_1.default.bold('package.json') + " does not exist.", "Generate", true, options)]; | ||
case 3: | ||
generate = _a.sent(); | ||
if (!generate) { | ||
options.logger.log('Please run from a directory with your package.json.'); | ||
return [2 /*return*/, false]; | ||
} | ||
_a.label = 4; | ||
case 4: | ||
_a.trys.push([4, 6, , 7]); | ||
// TODO(ofrobots): add proper error handling. | ||
cp.spawnSync('npm', ['init', '-y']); | ||
return [4 /*yield*/, util_1.readJsonp('./package.json')]; | ||
case 5: | ||
packageJson = _a.sent(); | ||
return [3 /*break*/, 7]; | ||
case 6: | ||
err2_1 = _a.sent(); | ||
throw err2_1; | ||
case 7: return [3 /*break*/, 8]; | ||
case 8: return [4 /*yield*/, addDependencies(packageJson, options)]; | ||
case 9: | ||
addedDeps = _a.sent(); | ||
return [4 /*yield*/, addScripts(packageJson, options)]; | ||
case 10: | ||
addedScripts = _a.sent(); | ||
if (!(addedDeps || addedScripts)) return [3 /*break*/, 12]; | ||
return [4 /*yield*/, writePackageJson(packageJson, options)]; | ||
case 11: | ||
_a.sent(); | ||
return [3 /*break*/, 13]; | ||
case 12: | ||
options.logger.log('No edits needed in package.json.'); | ||
_a.label = 13; | ||
case 13: return [4 /*yield*/, generateTsConfig(options)]; | ||
case 14: | ||
_a.sent(); | ||
// Run `npm install` after initial setup so `npm run check` works right away. | ||
if (!options.dryRun) { | ||
cp.spawnSync('npm', ['install'], { stdio: 'inherit' }); | ||
} | ||
return [2 /*return*/, true]; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let packageJson; | ||
try { | ||
packageJson = yield util_1.readJsonp('./package.json'); | ||
} | ||
catch (err) { | ||
if (err.code !== 'ENOENT') { | ||
throw new Error(`Unable to open package.json file: ${err.message}`); | ||
} | ||
}); | ||
const generate = yield query(`${chalk_1.default.bold('package.json')} does not exist.`, `Generate`, true, options); | ||
if (!generate) { | ||
options.logger.log('Please run from a directory with your package.json.'); | ||
return false; | ||
} | ||
try { | ||
// TODO(ofrobots): add proper error handling. | ||
cp.spawnSync('npm', ['init', '-y']); | ||
packageJson = yield util_1.readJsonp('./package.json'); | ||
} | ||
catch (err2) { | ||
throw err2; | ||
} | ||
} | ||
const addedDeps = yield addDependencies(packageJson, options); | ||
const addedScripts = yield addScripts(packageJson, options); | ||
if (addedDeps || addedScripts) { | ||
yield writePackageJson(packageJson, options); | ||
} | ||
else { | ||
options.logger.log('No edits needed in package.json.'); | ||
} | ||
yield generateTsConfig(options); | ||
// Run `npm install` after initial setup so `npm run check` works right away. | ||
if (!options.dryRun) { | ||
// --ignore-scripts so that compilation doesn't happen because there's no | ||
// source files yet. | ||
cp.spawnSync('npm', ['install', '--ignore-scripts'], { stdio: 'inherit' }); | ||
} | ||
return true; | ||
}); | ||
@@ -316,0 +214,0 @@ } |
"use strict"; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -18,4 +25,4 @@ /** | ||
*/ | ||
var path = require("path"); | ||
var tslint_1 = require("tslint"); | ||
const path = __importStar(require("path")); | ||
const tslint_1 = require("tslint"); | ||
/** | ||
@@ -27,18 +34,16 @@ * Run tslint with the default configuration. Returns true on success. | ||
*/ | ||
function lint(options, files, fix) { | ||
if (files === void 0) { files = []; } | ||
if (fix === void 0) { fix = false; } | ||
var tslintConfigPath = path.join(options.gtsRootDir, 'tslint.json'); | ||
var program = createProgram(options); | ||
var configuration = tslint_1.Configuration.findConfiguration(tslintConfigPath, '').results; | ||
var linter = new tslint_1.Linter({ fix: fix, formatter: 'codeFrame' }, program); | ||
var srcFiles = files.length > 0 ? files : tslint_1.Linter.getFileNames(program); | ||
srcFiles.forEach(function (file) { | ||
var sourceFile = program.getSourceFile(file); | ||
function lint(options, files = [], fix = false) { | ||
const tslintConfigPath = path.join(options.gtsRootDir, 'tslint.json'); | ||
const program = createProgram(options); | ||
const configuration = tslint_1.Configuration.findConfiguration(tslintConfigPath, '').results; | ||
const linter = new tslint_1.Linter({ fix, formatter: 'codeFrame' }, program); | ||
const srcFiles = files.length > 0 ? files : tslint_1.Linter.getFileNames(program); | ||
srcFiles.forEach(file => { | ||
const sourceFile = program.getSourceFile(file); | ||
if (sourceFile) { | ||
var fileContents = sourceFile.getFullText(); | ||
const fileContents = sourceFile.getFullText(); | ||
linter.lint(file, fileContents, configuration); | ||
} | ||
}); | ||
var result = linter.getResult(); | ||
const result = linter.getResult(); | ||
if (result.errorCount || result.warningCount) { | ||
@@ -52,3 +57,3 @@ options.logger.log(result.output); | ||
function createProgram(options) { | ||
var tsconfigPath = path.join(options.targetRootDir, 'tsconfig.json'); | ||
const tsconfigPath = path.join(options.targetRootDir, 'tsconfig.json'); | ||
return tslint_1.Linter.createProgram(tsconfigPath); | ||
@@ -55,0 +60,0 @@ } |
@@ -25,48 +25,23 @@ "use strict"; | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [0, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var fs = require("fs"); | ||
var path = require("path"); | ||
var pify = require("pify"); | ||
var rimraf = require("rimraf"); | ||
exports.readFilep = pify(fs.readFile); | ||
exports.rimrafp = pify(rimraf); | ||
exports.writeFileAtomicp = pify(require('write-file-atomic')); | ||
const fs = __importStar(require("fs")); | ||
const path = __importStar(require("path")); | ||
const pify_1 = __importDefault(require("pify")); | ||
const rimraf_1 = __importDefault(require("rimraf")); | ||
exports.readFilep = pify_1.default(fs.readFile); | ||
exports.rimrafp = pify_1.default(rimraf_1.default); | ||
exports.writeFileAtomicp = pify_1.default(require('write-file-atomic')); | ||
function readJsonp(jsonPath) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _a, _b; | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: | ||
_b = (_a = JSON).parse; | ||
return [4 /*yield*/, exports.readFilep(jsonPath)]; | ||
case 1: return [2 /*return*/, _b.apply(_a, [_c.sent()])]; | ||
} | ||
}); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return JSON.parse(yield exports.readFilep(jsonPath)); | ||
}); | ||
@@ -84,16 +59,8 @@ } | ||
function getTSConfig(rootDir, customReadFilep) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var tsconfigPath, json, contents; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
tsconfigPath = path.join(rootDir, 'tsconfig.json'); | ||
customReadFilep = customReadFilep || exports.readFilep; | ||
return [4 /*yield*/, customReadFilep(tsconfigPath, 'utf8')]; | ||
case 1: | ||
json = _a.sent(); | ||
contents = JSON.parse(json); | ||
return [2 /*return*/, contents]; | ||
} | ||
}); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const tsconfigPath = path.join(rootDir, 'tsconfig.json'); | ||
customReadFilep = customReadFilep || exports.readFilep; | ||
const json = yield customReadFilep(tsconfigPath, 'utf8'); | ||
const contents = JSON.parse(json); | ||
return contents; | ||
}); | ||
@@ -100,0 +67,0 @@ } |
{ | ||
"name": "gts", | ||
"version": "0.5.4", | ||
"version": "0.6.0", | ||
"description": "Google TypeScript Style", | ||
@@ -31,3 +31,4 @@ "repository": "google/ts-style", | ||
"prepare": "npm run compile", | ||
"test": "npm run compile && nyc ava build/test/test*.js", | ||
"test": "nyc ava build/test/test*.js", | ||
"pretest": "npm run compile", | ||
"posttest": "npm run lint && npm run format-check && npm run license-check", | ||
@@ -37,3 +38,3 @@ "license-check": "jsgl --local ." | ||
"engines": { | ||
"node": ">=4" | ||
"node": ">=6" | ||
}, | ||
@@ -44,35 +45,35 @@ "keywords": [], | ||
"dependencies": { | ||
"chalk": "^2.3.0", | ||
"clang-format": "1.2.2", | ||
"inquirer": "^3.2.1", | ||
"meow": "^4.0.0", | ||
"chalk": "^2.4.1", | ||
"clang-format": "1.2.3", | ||
"inquirer": "^5.2.0", | ||
"meow": "^5.0.0", | ||
"pify": "^3.0.0", | ||
"rimraf": "^2.6.1", | ||
"tslint": "^5.8.0", | ||
"update-notifier": "^2.2.0", | ||
"write-file-atomic": "^2.1.0" | ||
"rimraf": "^2.6.2", | ||
"tslint": "^5.9.1", | ||
"update-notifier": "^2.5.0", | ||
"write-file-atomic": "^2.3.0" | ||
}, | ||
"devDependencies": { | ||
"@types/glob": "^5.0.30", | ||
"@types/inquirer": "0.0.36", | ||
"@types/make-dir": "^1.0.1", | ||
"@types/meow": "^4.0.0", | ||
"@types/ncp": "^2.0.0", | ||
"@types/node": "^9.3.0", | ||
"@types/pify": "3.0.0", | ||
"@types/rimraf": "2.0.2", | ||
"@types/tmp": "0.0.33", | ||
"@types/update-notifier": "^2.0.0", | ||
"@types/glob": "^5.0.35", | ||
"@types/inquirer": "^0.0.41", | ||
"@types/make-dir": "^1.0.3", | ||
"@types/meow": "^4.0.1", | ||
"@types/ncp": "^2.0.1", | ||
"@types/node": "^10.0.3", | ||
"@types/pify": "^3.0.2", | ||
"@types/rimraf": "^2.0.2", | ||
"@types/tmp": "^0.0.33", | ||
"@types/update-notifier": "^2.2.0", | ||
"ava": "^0.25.0", | ||
"codecov": "^3.0.0", | ||
"js-green-licenses": "^0.4.0", | ||
"make-dir": "^1.0.0", | ||
"codecov": "^3.0.1", | ||
"js-green-licenses": "^0.5.0", | ||
"make-dir": "^1.2.0", | ||
"ncp": "^2.0.0", | ||
"nyc": "^11.2.1", | ||
"source-map-support": "^0.5.0", | ||
"tmp": "0.0.31", | ||
"typescript": "~2.6.1" | ||
"nyc": "^11.7.1", | ||
"source-map-support": "^0.5.5", | ||
"tmp": "0.0.33", | ||
"typescript": "~2.8.3" | ||
}, | ||
"peerDependencies": { | ||
"typescript": "^2.6.1" | ||
"typescript": "^2.7.1" | ||
}, | ||
@@ -79,0 +80,0 @@ "ava": { |
@@ -10,6 +10,4 @@ # gts - Google TypeScript style | ||
> ***NOTE: This repo is a work-in-progress and is not ready for general use just yet. This is not an official Google product.*** | ||
[gts][npm-url] is Google's TypeScript style guide, and the configuration for our formatter, linter, and automatic code fixer. No lint rules to edit, no configuration to update, no more bike shedding over syntax. To borrow from [standardjs][standardjs-url]: | ||
[gts][npm-url] is Google's TypeScript style guide, and the configuration for our formatter, linter, and automatic code fixer. No lint rules to edit, no configuration to update, no more bike shedding over syntax. To borrow from standardjs: | ||
- **No configuration**. The easiest way to enforce consistent style in your project. Just drop it in. | ||
@@ -60,2 +58,4 @@ - **Automatically format code**. Just run `gts fix` and say goodbye to messy or inconsistent code. | ||
> ***NOTE: This is not an official Google product.*** | ||
[circle-image]: https://circleci.com/gh/google/ts-style.svg?style=svg | ||
@@ -74,3 +74,4 @@ [circle-url]: https://circleci.com/gh/google/ts-style | ||
[snyk-url]: https://snyk.io/test/github/google/ts-style | ||
[standardjs-url]: https://www.npmjs.com/package/standard | ||
[tslint-url]: https://palantir.github.io/tslint/ | ||
{ | ||
"compilerOptions": { | ||
"allowSyntheticDefaultImports": false, | ||
"allowSyntheticDefaultImports": true, | ||
"allowUnreachableCode": false, | ||
"allowUnusedLabels": false, | ||
"declaration": true, | ||
"esModuleInterop": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"lib": ["es2015"], | ||
"lib": ["es2016"], | ||
"module": "commonjs", | ||
"noEmitOnError": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"noEmitOnError": true, | ||
"noImplicitReturns": true, | ||
"pretty": true, | ||
"sourceMap": true, | ||
"strict": true, | ||
"module": "commonjs", | ||
"target": "es5", | ||
"sourceMap": true | ||
"target": "es2016" | ||
}, | ||
@@ -21,2 +22,2 @@ "exclude": [ | ||
] | ||
} | ||
} |
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
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
75
58058
744
+ Addedclang-format@1.2.3(transitive)
+ Addedinquirer@5.2.0(transitive)
+ Addedmeow@5.0.0(transitive)
+ Addedrxjs@5.5.12(transitive)
+ Addedsymbol-observable@1.0.1(transitive)
+ Addedyargs-parser@10.1.0(transitive)
- Removedclang-format@1.2.2(transitive)
- Removedinquirer@3.3.0(transitive)
- Removedmeow@4.0.1(transitive)
- Removedrx-lite@4.0.8(transitive)
- Removedrx-lite-aggregates@4.0.8(transitive)
Updatedchalk@^2.4.1
Updatedclang-format@1.2.3
Updatedinquirer@^5.2.0
Updatedmeow@^5.0.0
Updatedrimraf@^2.6.2
Updatedtslint@^5.9.1
Updatedupdate-notifier@^2.5.0
Updatedwrite-file-atomic@^2.3.0