Comparing version 1.1.1 to 1.2.1
{ | ||
"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" | ||
} | ||
} |
119
prod/bin.js
"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
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
55459
16
147
79
3
11
2
+ Addedenquirer@^2.3.6
+ Addedfs-extra@^9.0.1
+ Addedlistr2@^3.2.2
+ Addedaggregate-error@3.1.0(transitive)
+ Addedansi-colors@4.1.3(transitive)
+ Addedansi-escapes@4.3.2(transitive)
+ Addedansi-regex@5.0.1(transitive)
+ Addedansi-styles@4.3.0(transitive)
+ Addedastral-regex@2.0.0(transitive)
+ Addedat-least-node@1.0.0(transitive)
+ Addedclean-stack@2.2.0(transitive)
+ Addedcli-cursor@3.1.0(transitive)
+ Addedcli-truncate@2.1.0(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedcolorette@2.0.20(transitive)
+ Addedemoji-regex@8.0.0(transitive)
+ Addedenquirer@2.4.1(transitive)
+ Addedfs-extra@9.1.0(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedindent-string@4.0.0(transitive)
+ Addedis-fullwidth-code-point@3.0.0(transitive)
+ Addedjsonfile@6.1.0(transitive)
+ Addedlistr2@3.14.0(transitive)
+ Addedlog-update@4.0.0(transitive)
+ Addedmimic-fn@2.1.0(transitive)
+ Addedonetime@5.1.2(transitive)
+ Addedp-map@4.0.0(transitive)
+ Addedrestore-cursor@3.1.0(transitive)
+ Addedrfdc@1.4.1(transitive)
+ Addedrxjs@7.8.1(transitive)
+ Addedsignal-exit@3.0.7(transitive)
+ Addedslice-ansi@3.0.04.0.0(transitive)
+ Addedstring-width@4.2.3(transitive)
+ Addedstrip-ansi@6.0.1(transitive)
+ Addedthrough@2.3.8(transitive)
+ Addedtslib@2.8.1(transitive)
+ Addedtype-fest@0.21.3(transitive)
+ Addeduniversalify@2.0.1(transitive)
+ Addedwrap-ansi@6.2.07.0.0(transitive)
- Removedfs@0.0.1-security
- Removedpath@^0.12.7
- Removedfs@0.0.1-security(transitive)
- Removedinherits@2.0.3(transitive)
- Removedpath@0.12.7(transitive)
- Removedprocess@0.11.10(transitive)
- Removedutil@0.10.4(transitive)