Socket
Socket
Sign inDemoInstall

groundwork

Package Overview
Dependencies
59
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.0 to 0.2.0

7

lib/bin.js

@@ -59,9 +59,12 @@ #!/usr/bin/env node

spinner = ora_1.default("Fetching " + chalk_1.default.cyan(src) + "...").start();
return [4 /*yield*/, groundwork.fetch()];
return [4 /*yield*/, groundwork.parse()];
case 1:
_a.sent();
return [4 /*yield*/, groundwork.fetch()];
case 2:
_a.sent();
spinner.succeed();
spinner.start("Laying ground work...");
return [4 /*yield*/, groundwork.extract()];
case 2:
case 3:
_a.sent();

@@ -68,0 +71,0 @@ spinner.succeed();

@@ -48,2 +48,3 @@ "use strict";

var https_1 = require("https");
var core_1 = require("@octokit/core");
var mkdirp_1 = __importDefault(require("mkdirp"));

@@ -54,16 +55,64 @@ var tar_1 = __importDefault(require("tar"));

if (force === void 0) { force = false; }
this.src = src;
this.dest = dest;
this.force = force;
var cacheDir = path_1.join(os_1.homedir(), '.groundwork');
var _a = this.parse(src), repo = _a.repo, hash = _a.hash;
this.tarFile = path_1.join(cacheDir, repo, hash + ".tar.gz");
this.tarUrl = "https://codeload.github.com/" + repo + "/tar.gz/" + hash;
this.client = new core_1.Octokit();
this.cacheDir = path_1.join(os_1.homedir(), '.groundwork');
}
Groundwork.prototype.parse = function (src) {
var info = url_1.parse(src);
return {
repo: info.pathname,
hash: (info.hash || '#master').slice(1),
};
Groundwork.prototype.getLatestRelease = function (src) {
return __awaiter(this, void 0, void 0, function () {
var release, err_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, this.client.request("GET /repos/" + src + "/releases/latest")];
case 1:
release = (_a.sent()).data;
return [2 /*return*/, release.tag_name];
case 2:
err_1 = _a.sent();
return [2 /*return*/, this.getDefaultBranch(src)];
case 3: return [2 /*return*/];
}
});
});
};
Groundwork.prototype.getDefaultBranch = function (src) {
return __awaiter(this, void 0, void 0, function () {
var release, err_2;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, this.client.request("GET /repos/" + src)];
case 1:
release = (_a.sent()).data;
return [2 /*return*/, release.default_branch];
case 2:
err_2 = _a.sent();
throw err_2;
case 3: return [2 /*return*/];
}
});
});
};
Groundwork.prototype.parse = function () {
return __awaiter(this, void 0, void 0, function () {
var _a, repo, branch, release, hash;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = url_1.parse(this.src), repo = _a.pathname, branch = _a.hash;
return [4 /*yield*/, this.getLatestRelease(repo)];
case 1:
release = _b.sent();
hash = (branch || "#" + release).slice(1);
this.tarFile = path_1.join(this.cacheDir, repo, hash + ".tar.gz");
this.tarUrl = "https://codeload.github.com/" + repo + "/tar.gz/" + hash;
return [2 /*return*/];
}
});
});
};
Groundwork.prototype.fetch = function () {

@@ -70,0 +119,0 @@ return __awaiter(this, void 0, void 0, function () {

{
"name": "groundwork",
"description": "Scaffold out any project quickly",
"version": "0.1.0",
"version": "0.2.0",
"repository": "aniftyco/groundwork",
"bin": {
"groundwork": "lib/bin.js"
},
"main": "lib/index.js",
"author": {

@@ -15,6 +19,12 @@ "name": "Nifty Development, LLC",

"url": "https://twitter.com/joshmanders"
},
{
"name": "Geoff Selby",
"url": "https://twitter.com/geoff_selby"
}
],
"scripts": {
"build": "tsc"
"prepublishOnly": "npm run build",
"build": "rimraf lib && tsc",
"test": "jest"
},

@@ -24,25 +34,54 @@ "files": [

],
"bin": "lib/bin.js",
"eslintConfig": {
"extends": "nifty",
"rules": {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-misused-promises": "off"
}
},
"prettier": {
"printWidth": 120,
"singleQuote": true
},
"jest": {
"testEnvironment": "node",
"moduleFileExtensions": [
"ts",
"js"
],
"transform": {
"^.+\\.ts$": "ts-jest"
},
"globals": {
"ts-jest": {
"tsConfig": "./tests/tsconfig.json"
}
}
},
"devDependencies": {
"@types/chalk": "^2.2.0",
"@types/jest": "^26.0.5",
"@types/minimist": "^1.2.0",
"@types/jest": "^26.0.19",
"@types/minimist": "^1.2.1",
"@types/mkdirp": "^1.0.1",
"@types/node": "^12.12.51",
"@types/node": "^14.14.14",
"@types/ora": "^3.2.0",
"@types/tar": "^4.0.3",
"eslint": "^7.5.0",
"eslint-config-nifty": "^3.0.0-rc.8",
"jest": "^26.1.0",
"prettier": "^2.0.5",
"ts-jest": "^26.1.3",
"typescript": "^3.9.7"
"@types/tar": "^4.0.4",
"eslint": "^7.16.0",
"eslint-config-nifty": "^3.2.2",
"jest": "^26.6.3",
"prettier": "^2.2.1",
"rimraf": "^3.0.2",
"ts-jest": "^26.4.4",
"typescript": "^4.1.3"
},
"dependencies": {
"@octokit/core": "^3.2.4",
"chalk": "^4.1.0",
"minimist": "^1.2.5",
"mkdirp": "^1.0.4",
"ora": "^4.0.5",
"tar": "^6.0.2"
"ora": "^5.1.0",
"tar": "^6.0.5"
}
}

@@ -11,3 +11,3 @@ # Groundwork

When first ran, this will fetch and cache `$CACHE/org/repo/master.tar.gz` tarball and extract it to `$PWD/path/`.
When first ran, this will fetch and cache `$CACHE/org/repo/{version}.tar.gz` tarball and extract it to `$PWD/path/`. If there are no tagged releases, Groundwork will fallback to the default branch of the repo.

@@ -14,0 +14,0 @@ You can pass a hash to the template to specify a commit/branch/tag to scaffold from, for example

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc