diff --git a/build/index.js b/build/index.js index 4e142c6..bca9327 100644 --- a/build/index.js +++ b/build/index.js @@ -1,5 +1,20 @@ #!/usr/bin/env node "use strict"; +var __assign = + (this && this.__assign) || + function() { + __assign = + Object.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; + }; + return __assign.apply(this, arguments); + }; var __awaiter = (this && this.__awaiter) || function(thisArg, _arguments, P, generator) { @@ -137,6 +152,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); var execa_1 = __importDefault(require("execa")); var init_package_json_1 = __importDefault(require("init-package-json")); var path_1 = __importDefault(require("path")); +var fs_1 = __importDefault(require("fs")); var HOME = process.env.HOME || "."; // a path to a promzard module. In the event that this file is // not found, one will be provided for you. @@ -157,6 +173,13 @@ init_package_json_1.default(dir, initFile, configData, function(_er, _data) { var _this = this; // the data's already been written to {dir}/package.json // now you can do stuff with it + var packageFile = path_1.default.resolve(dir, "package.json"); + var husky = { + hooks: { + "pre-commit": "pretty-quick --staged" + } + }; + fs_1.default.writeFileSync(packageFile, __assign({ husky: husky }, _data)); (function() { return __awaiter(_this, void 0, void 0, function() { return __generator(this, function(_a) { @@ -175,6 +198,18 @@ init_package_json_1.default(dir, initFile, configData, function(_er, _data) { _a.sent(); return [4 /*yield*/, execa_1.default("tsc", ["--init"])]; case 2: + _a.sent(); + return [ + 4 /*yield*/, + execa_1.default("npm", [ + "install", + "prettier", + "pretty-quick", + "husky", + "--save-dev" + ]) + ]; + case 3: _a.sent(); return [2 /*return*/]; } diff --git a/build/index.js.map b/build/index.js.map index 76d9874..2f3d81b 100644 --- a/build/index.js.map +++ b/build/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,gDAA0B;AAC1B,wEAAqC;AACr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IAAI,EAAE,WAAW,CAAC,CAAC;AAEjD,kCAAkC;AAClC,IAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;AAE1B,gEAAgE;AAChE,mEAAmE;AACnE,YAAY;AACZ,IAAM,UAAU,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;AAE/C,uEAAuE;AACvE,oEAAoE;AACpE,YAAY;AACZ,6CAA6C;AAC7C,0CAA0C;AAC1C,4CAA4C;AAE5C,2BAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAS,GAAG,EAAE,KAAK;IAAnB,iBAgB/B;IAfC,wDAAwD;IACxD,+BAA+B;IAC/B,IAAM,WAAW,GAAG,cAAI,CAAC,OAAO,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;IACtD,IAAM,KAAK,GAAG;QACZ,OAAO,EAAE;YACP,YAAY,EAAE,uBAAuB;SACtC;KACF,CAAA;IACD,YAAE,CAAC,aAAa,CAAC,WAAW,aAAG,KAAK,OAAA,IAAK,KAAK,EAAE,CAAC;IAEjD,CAAC;;;wBACC,qBAAM,eAAK,CAAC,KAAK,EAAE,CAAC,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,CAAC,CAAC,EAAA;;oBAA1E,SAA0E,CAAC;oBAC3E,qBAAM,eAAK,CAAC,KAAK,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAA;;oBAA9B,SAA8B,CAAC;oBAC/B,qBAAM,eAAK,CAAC,KAAK,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,cAAc,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC,EAAA;;oBAAlF,SAAkF,CAAC;;;;SACpF,CAAC,EAAE,CAAC;AACP,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 05c873d..91583ed 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,6 +2,7 @@ import execa from "execa"; import init from "init-package-json"; import path from "path"; +import fs from "fs"; const HOME = process.env.HOME || "."; // a path to a promzard module. In the event that this file is @@ -26,8 +27,23 @@ const configData = { yes: true, silent: true }; init(dir, initFile, configData, function(_er, _data) { // the data's already been written to {dir}/package.json // now you can do stuff with it + const packageFile = path.resolve(dir, "package.json"); + const husky = { + hooks: { + "pre-commit": "pretty-quick --staged" + } + }; + fs.writeFileSync(packageFile, { husky, ..._data }); + (async () => { await execa("npm", ["install", "typescript", "@types/node", "--save-dev"]); await execa("tsc", ["--init"]); + await execa("npm", [ + "install", + "prettier", + "pretty-quick", + "husky", + "--save-dev" + ]); })(); });