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

tsprogen

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tsprogen - npm Package Compare versions

Comparing version 1.1.1 to 1.2.1

.editorconfig

23

package.json
{
"name": "tsprogen",
"version": "1.1.1",
"version": "1.2.1",
"description": "A CLI project generator for setting up TypeScript + Node projects.",

@@ -10,4 +10,5 @@ "main": "./prod/bin.js",

"scripts": {
"prebuild": "rm -rf ./prod",
"build": "tsc",
"postbuild": "copyfiles -f src/* -e src/*.ts prod",
"postbuild": "copyfiles -fa src/template/**/* prod/template",
"lint": "eslint src",

@@ -28,17 +29,19 @@ "lint:fix": "eslint src --fix",

"devDependencies": {
"@types/node": "^14.14.2",
"@typescript-eslint/eslint-plugin": "^4.5.0",
"@typescript-eslint/parser": "^4.5.0",
"@types/fs-extra": "^9.0.2",
"@types/node": "^14.14.6",
"@typescript-eslint/eslint-plugin": "^4.6.0",
"@typescript-eslint/parser": "^4.6.0",
"copyfiles": "^2.4.0",
"eslint": "^7.12.0",
"eslint-config-prettier": "^6.14.0",
"eslint": "^7.12.1",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-prettier": "^3.1.4",
"husky": "^4.3.0",
"prettier": "^2.1.2",
"typescript": "^4.0.3"
"typescript": "^4.0.5"
},
"dependencies": {
"fs": "0.0.1-security",
"path": "^0.12.7"
"enquirer": "^2.3.6",
"fs-extra": "^9.0.1",
"listr2": "^3.2.2"
}
}
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
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) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -6,54 +15,80 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
fs_1.default.readFile(path_1.default.join(__dirname, "./readme-copy.md"), "utf-8", (err, data) => {
if (err) {
return console.log(err);
const fs_extra_1 = __importDefault(require("fs-extra"));
const os_1 = __importDefault(require("os"));
const child_process_1 = require("child_process");
const util_1 = require("util");
const listr2_1 = require("listr2");
const execAsync = util_1.promisify(child_process_1.exec);
const createProject = () => __awaiter(void 0, void 0, void 0, function* () {
try {
const templateDir = `${__dirname}/template`;
const targetDir = process.cwd();
if (!fs_extra_1.default.pathExists(targetDir)) {
yield fs_extra_1.default.mkdir(targetDir);
}
yield fs_extra_1.default.copy(templateDir, targetDir, {
errorOnExist: true,
overwrite: false,
});
}
fs_1.default.writeFile(path_1.default.join(process.cwd() + "/README.md"), data, (err) => {
if (err) {
return console.log(err);
}
console.log("Readme generated");
});
catch (err) {
throw new Error(`Failed to copy template files: ${err.message}`);
}
});
fs_1.default.readFile(path_1.default.join(__dirname, "./package-copy.json"), "utf-8", (err, data) => {
if (err) {
return console.log(err);
}
fs_1.default.writeFile(path_1.default.join(process.cwd() + "/package.json"), data, (err) => {
if (err) {
return console.log(err);
}
console.log("Package.json generated");
const promptConfig = (ctx, task) => __awaiter(void 0, void 0, void 0, function* () {
ctx.config = {
packageManager: yield task.prompt([
{
type: "autocomplete",
name: "packageManager",
message: "What package manager would you like to use?",
default: "npm",
choices: ["pnpm", "npm", "yarn"],
},
]),
};
yield fs_extra_1.default.writeFile(configFile, JSON.stringify(ctx.config), {
encoding: "utf-8",
});
});
fs_1.default.mkdir(path_1.default.join(process.cwd() + "/src"), (err) => {
if (err) {
return console.log(err);
const configFile = `${os_1.default.homedir()}/.config/tsprogen.json`;
const getConfig = (ctx, task) => __awaiter(void 0, void 0, void 0, function* () {
if (!(yield fs_extra_1.default.pathExists(configFile))) {
yield promptConfig(ctx, task);
}
console.log("src directory generated");
});
fs_1.default.writeFile(path_1.default.join(process.cwd() + "/src/index.ts"), "console.log('index.ts works!');", (err) => {
if (err) {
return console.log(err);
ctx.config = JSON.parse(yield fs_extra_1.default.readFile(configFile, { encoding: "utf-8" }));
if (!ctx.config.packageManager ||
(ctx.config.packageManager &&
!["npm", "pnpm", "yarn"].includes(ctx.config.packageManager.trim()))) {
yield promptConfig(ctx, task);
}
console.log("index.ts generated");
});
fs_1.default.readFile(path_1.default.join(__dirname + "/../tsconfig.json"), "utf-8", (err, data) => {
if (err) {
return console.log(err);
const installDependencies = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
if (!["npm", "pnpm", "yarn"].includes(ctx.config.packageManager.trim())) {
throw new Error(`Install error: Invalid package manager in ${configFile}`);
}
fs_1.default.writeFile(path_1.default.join(process.cwd() + "/tsconfig.json"), data, (err) => {
if (err) {
return console.log(err);
}
console.log("tsconfig.json generated");
const { stderr } = yield execAsync(`${ctx.config.packageManager.trim()} install`, {
cwd: process.cwd(),
});
});
fs_1.default.writeFile(path_1.default.join(process.cwd() + "/.gitignore"), "/node_modules/", (err) => {
if (err) {
return console.log(err);
if (stderr) {
throw new Error(`Install error: ${stderr}`);
}
console.log(".gitignore generated");
});
const tasks = new listr2_1.Listr([
{
title: "Retrieve Config",
task: getConfig,
},
{
title: "Create Project Files",
task: createProject,
},
{
title: "Install Dependencies",
task: installDependencies,
},
], { concurrent: 1 });
// Run all project tasks
tasks.run().catch(() => {
// do nothing
});
# TSProGen
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#contributors-)
[![All Contributors](https://img.shields.io/badge/all_contributors-3-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

@@ -47,7 +47,14 @@

## Feedback, Bugs, and Contributions
## Feedback and Bugs
If you have feedback or a bug report, you can create a GitHub issue or [contact me directly](https://contact.nhcarrigan.com).
If you have feedback or a bug report, please feel free to open a GitHub issue!
If you would like to contribute to the project, you may create a Pull Request containing your proposed changes and I will review it as soon as I am able!
## Contributing
If you would like to contribute to the project, you may create a Pull Request containing your proposed changes and we will review it as soon as we are able! Please review our [contributing guidelines](CONTRIBUTING.md) first.
## Code of Conduct
Before interacting with our community, please read our [Code of Conduct](CODE_OF_CONDUCT.md).
## Contributors ✨

@@ -64,2 +71,3 @@

<td align="center"><a href="https://github.com/SkyWolf369"><img src="https://avatars3.githubusercontent.com/u/41835930?v=4" width="100px;" alt=""/><br /><sub><b>SkyWolf</b></sub></a><br /><a href="#projectManagement-SkyWolf369" title="Project Management">📆</a></td>
<td align="center"><a href="https://theoparis.com/about"><img src="https://avatars0.githubusercontent.com/u/11761863?v=4" width="100px;" alt=""/><br /><sub><b>Theo Paris</b></sub></a><br /><a href="https://github.com/nhcarrigan/TSProGen/commits?author=creepinson" title="Code">💻</a></td>
</tr>

@@ -66,0 +74,0 @@ </table>

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