Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gts

Package Overview
Dependencies
Maintainers
2
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gts - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

build/template/index.ts

4

build/src/init.d.ts
import { Options } from './cli';
import { PackageJson } from '@npm/types';
export interface Bag<T> {
[script: string]: T;
}
export declare function addScripts(packageJson: PackageJson, options: Options): Promise<boolean>;

@@ -14,2 +11,3 @@ export declare function addDependencies(packageJson: PackageJson, options: Options): Promise<boolean>;

};
export declare function installDefaultTemplate(options: Options): Promise<boolean>;
export declare function init(options: Options): Promise<boolean>;

@@ -19,7 +19,11 @@ "use strict";

const cp = require("child_process");
const fs = require("fs");
const inquirer = require("inquirer");
const path = require("path");
const ncp_1 = require("ncp");
const util = require("util");
const util_1 = require("./util");
const chalk_1 = require("chalk");
const pkg = require('../../package.json');
const ncpp = util.promisify(ncp_1.ncp);
const DEFAULT_PACKAGE_JSON = {

@@ -56,3 +60,3 @@ name: '',

let edits = false;
const pkgManager = util_1.getPkgManagerName(options.yarn);
const pkgManager = util_1.getPkgManagerCommand(options.yarn);
const scripts = {

@@ -94,2 +98,3 @@ check: `gts check`,

typescript: pkg.devDependencies.typescript,
'@types/node': pkg.devDependencies['@types/node'],
};

@@ -184,2 +189,28 @@ if (!packageJson.devDependencies) {

}
async function installDefaultTemplate(options) {
const cwd = process.cwd();
const sourceDirName = path.join(__dirname, '../template');
const targetDirName = path.join(cwd, 'src');
try {
fs.mkdirSync(targetDirName);
}
catch (error) {
if (error.code !== 'EEXIST') {
throw error;
}
// Else, continue and populate files into the existing directory.
}
// Only install the template if no ts files exist in target directory.
const files = fs.readdirSync(targetDirName);
const tsFiles = files.filter(file => file.toLowerCase().endsWith('.ts'));
if (tsFiles.length !== 0) {
options.logger.log('Target src directory already has ts files. ' +
'Template files not installed.');
return false;
}
await ncpp(sourceDirName, targetDirName);
options.logger.log('Default template installed.');
return true;
}
exports.installDefaultTemplate = installDefaultTemplate;
async function init(options) {

@@ -214,2 +245,3 @@ let generatedPackageJson = false;

await generatePrettierConfig(options);
await installDefaultTemplate(options);
// Run `npm install` after initial setup so `npm run check` works right away.

@@ -219,3 +251,3 @@ if (!options.dryRun) {

// source files yet.
cp.spawnSync(util_1.getPkgManagerName(options.yarn), ['install', '--ignore-scripts'], { stdio: 'inherit' });
cp.spawnSync(util_1.getPkgManagerCommand(options.yarn), ['install', '--ignore-scripts'], { stdio: 'inherit' });
}

@@ -222,0 +254,0 @@ return true;

@@ -60,14 +60,14 @@ "use strict";

const configuration = tslint_1.Configuration.loadConfigurationFromPath(configPath);
const linter = new tslint_1.Linter({ fix, formatter: 'codeFrame' }, program);
files.forEach(file => {
for (const file of files) {
const sourceFile = program.getSourceFile(file);
if (sourceFile) {
const fileContents = sourceFile.getFullText();
const linter = new tslint_1.Linter({ fix, formatter: 'codeFrame' }, program);
linter.lint(file, fileContents, configuration);
const result = linter.getResult();
if (result.errorCount || result.warningCount) {
options.logger.log(result.output);
return false;
}
}
});
const result = linter.getResult();
if (result.errorCount || result.warningCount) {
options.logger.log(result.output);
return false;
}

@@ -74,0 +74,0 @@ return true;

@@ -18,5 +18,15 @@ /**

import * as fs from 'fs';
export declare const readFilep: (...args: any[]) => Promise<any>;
export declare const rimrafp: (...args: any[]) => Promise<any>;
export declare const writeFileAtomicp: any;
import * as rimraf from 'rimraf';
export declare const readFilep: typeof fs.readFile.__promisify__;
export declare const rimrafp: typeof rimraf.__promisify__;
export declare const writeFileAtomicp: Function;
export declare const ncpp: (arg1: string, arg2: string) => Promise<void>;
export interface Bag<T> {
[script: string]: T;
}
export interface DefaultPackage extends Bag<string> {
gts: string;
typescript: string;
'@types/node': string;
}
export declare function readJsonp(jsonPath: string): Promise<any>;

@@ -51,2 +61,2 @@ export interface ReadFileP {

export declare function isYarnUsed(existsSync?: typeof fs.existsSync): boolean;
export declare function getPkgManagerName(isYarnUsed?: boolean): 'yarn' | 'npm';
export declare function getPkgManagerCommand(isYarnUsed?: boolean): string;

@@ -20,9 +20,12 @@ "use strict";

const path = require("path");
const pify = require("pify");
const rimraf = require("rimraf");
exports.readFilep = pify(fs.readFile);
exports.rimrafp = pify(rimraf);
exports.writeFileAtomicp = pify(require('write-file-atomic'));
const util_1 = require("util");
const ncp = require("ncp");
exports.readFilep = util_1.promisify(fs.readFile);
exports.rimrafp = util_1.promisify(rimraf);
exports.writeFileAtomicp = util_1.promisify(require('write-file-atomic'));
exports.ncpp = util_1.promisify(ncp.ncp);
async function readJsonp(jsonPath) {
return JSON.parse(await exports.readFilep(jsonPath));
const contents = await exports.readFilep(jsonPath, { encoding: 'utf8' });
return JSON.parse(contents);
}

@@ -102,6 +105,6 @@ exports.readJsonp = readJsonp;

exports.isYarnUsed = isYarnUsed;
function getPkgManagerName(isYarnUsed) {
return isYarnUsed ? 'yarn' : 'npm';
function getPkgManagerCommand(isYarnUsed) {
return ((isYarnUsed ? 'yarn' : 'npm') + (process.platform === 'win32' ? '.cmd' : ''));
}
exports.getPkgManagerName = getPkgManagerName;
exports.getPkgManagerCommand = getPkgManagerCommand;
//# sourceMappingURL=util.js.map
{
"name": "gts",
"version": "1.0.0",
"version": "1.1.0",
"description": "Google TypeScript Style",

@@ -16,5 +16,7 @@ "repository": "google/gts",

"build/types",
"build/template",
"prettier.config.js",
"tsconfig-google.json",
"tsconfig.json",
"tslint-rules.json",
"tslint.json"

@@ -25,4 +27,5 @@ ],

"clean": "rimraf ./build/",
"codecov": "nyc report --reporter=json && codecov -f coverage/*.json",
"codecov": "c8 report --reporter=json && codecov -f coverage/*.json",
"compile": "tsc -p .",
"postcompile": "ncp template build/template",
"format-check": "prettier --list-different src/*.ts test/*.ts",

@@ -33,6 +36,8 @@ "format": "prettier --write src/*.ts test/*.ts",

"prepare": "npm run compile",
"test": "nyc mocha build/test",
"test": "c8 mocha build/test",
"pretest": "npm run compile",
"posttest": "npm run lint && npm run format-check && npm run license-check",
"license-check": "jsgl --local ."
"license-check": "jsgl --local .",
"check": "gts check",
"fix": "gts fix"
},

@@ -48,10 +53,10 @@ "engines": {

"diff": "^4.0.1",
"entities": "^1.1.1",
"inquirer": "^6.0.0",
"meow": "^5.0.0",
"pify": "^4.0.0",
"ncp": "^2.0.0",
"prettier": "^1.15.3",
"rimraf": "^2.6.2",
"tslint": "^5.12.0",
"update-notifier": "^2.5.0",
"tslint-config-prettier": "^1.18.0",
"update-notifier": "^3.0.0",
"write-file-atomic": "^2.3.0"

@@ -61,6 +66,5 @@ },

"@npm/types": "^1.0.1",
"@types/cross-spawn": "^6.0.0",
"@types/diff": "^4.0.0",
"@types/entities": "^1.1.0",
"@types/execa": "^0.9.0",
"@types/glob": "^7.0.0",
"@types/fs-extra": "^8.0.0",
"@types/inquirer": "^6.0.0",

@@ -71,17 +75,20 @@ "@types/meow": "^5.0.0",

"@types/node": "^10.0.3",
"@types/pify": "^3.0.2",
"@types/prettier": "^1.15.2",
"@types/rimraf": "^2.0.2",
"@types/sinon": "^7.0.11",
"@types/tmp": "^0.1.0",
"@types/update-notifier": "^2.2.0",
"assert-rejects": "^1.0.0",
"c8": "^5.0.0",
"codecov": "^3.0.1",
"execa": "^1.0.0",
"inline-fixtures": "^1.0.0",
"js-green-licenses": "^0.5.0",
"cross-spawn": "^6.0.5",
"fs-extra": "^8.0.0",
"gts": "^1.0.0",
"inline-fixtures": "^1.1.0",
"js-green-licenses": "^1.0.0",
"mocha": "^6.0.0",
"ncp": "^2.0.0",
"nyc": "^14.0.0",
"sinon": "^7.3.1",
"source-map-support": "^0.5.5",
"tmp": "0.1.0",
"typescript": "~3.4.0"
"typescript": "~3.5.0"
},

@@ -88,0 +95,0 @@ "peerDependencies": {

@@ -11,4 +11,2 @@ # gts

**NOTE: THIS README refers to the master branch which corresponds to the upcoming 1.0 release. To view documentation for the currently released version of this module see: https://github.com/google/gts/tree/v0.9.x.**
[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.

@@ -41,2 +39,3 @@

- `pretest`, `posttest` and `prepare`: convenience integrations.
- If a source folder is not already present it will add a default template project.

@@ -43,0 +42,0 @@ ### Individual files

@@ -12,4 +12,5 @@ {

"exclude": [
"test/fixtures/**/*.*"
"test/fixtures/**/*.*",
"template/**/*.*",
]
}
}
{
"rules": {
"array-type": [true, "array-simple"],
"arrow-return-shorthand": true,
"ban": [true,
{"name": ["it", "skip"]},
{"name": ["it", "only"]},
{"name": ["it", "async", "skip"]},
{"name": ["it", "async", "only"]},
{"name": ["describe", "skip"]},
{"name": ["describe", "only"]},
{"name": "parseInt", "message": "tsstyle#type-coercion"},
{"name": "parseFloat", "message": "tsstyle#type-coercion"},
{"name": "Array", "message": "tsstyle#array-constructor"},
{"name": ["*", "innerText"], "message": "Use .textContent instead. tsstyle#browser-oddities"}
],
"ban-ts-ignore": true,
"ban-types": [true,
["Object", "Use {} instead."],
["String", "Use 'string' instead."],
["Number", "Use 'number' instead."],
["Boolean", "Use 'boolean' instead."]
],
"class-name": true,
"curly": [true, "ignore-same-line"],
"deprecation": true,
"forin": true,
"interface-name": [true, "never-prefix"],
"interface-over-type-literal": true,
"jsdoc-format": true,
"label-position": true,
"member-access": [true, "no-public"],
"new-parens": true,
"no-angle-bracket-type-assertion": true,
"no-any": true,
"no-arg": true,
"no-conditional-assignment": true,
"no-construct": true,
"no-debugger": true,
"no-default-export": true,
"no-duplicate-variable": true,
"no-inferrable-types": true,
"no-namespace": [true, "allow-declarations"],
"no-reference": true,
"no-string-throw": true,
"no-return-await": true,
"no-unsafe-finally": true,
"no-unused-expression": true,
"no-var-keyword": true,
"object-literal-shorthand": true,
"only-arrow-functions": [true, "allow-declarations", "allow-named-functions"],
"prefer-const": true,
"radix": true,
"semicolon": [true, "always", "ignore-bound-class-methods"],
"switch-default": true,
"trailing-comma": [
true,
{
"multiline": {
"objects": "always",
"arrays": "always",
"functions": "never",
"typeLiterals": "ignore"
},
"esSpecCompliant": true
}
],
"triple-equals": [true, "allow-null-check"],
"use-isnan": true,
"variable-name": [
true,
"check-format",
"ban-keywords",
"allow-leading-underscore",
"allow-trailing-underscore"
]
}
}
"extends": [
"./tslint-rules.json",
"tslint-config-prettier"
]
}

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc