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

@reprex/create-project

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@reprex/create-project - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

7

package.json
{
"name": "@reprex/create-project",
"version": "1.0.0",
"version": "1.1.0",
"author": "SeyyedKhandon@gmail.com",

@@ -19,3 +19,6 @@ "description": "A CLI to bootstrap my new projects",

"ncp": "^2.0.0",
"pkg-install": "^1.0.0"
"pkg-install": "^1.0.0",
"covgen": "^3.1.0",
"gitignore": "^0.6.0",
"spdx-license-list": "^5.0.0"
},

@@ -22,0 +25,0 @@ "publishConfig": {

A simple CLI tool for templating
#try use it:
# try use it:
`npx @reprex/create-project --install`
or
# install it globally:
`npx @reprex/create-project`
```
npm install -g @reprex/create-project
create-project
```

@@ -13,8 +13,7 @@ import arg from 'arg';

'-i': '--install',
}
const option = {
};
const options = {
argv: rawArgs.slice(2),
};
const args = arg(spec, option);
console.log(JSON.stringify(args));
const args = arg(spec, options);
return {

@@ -27,4 +26,5 @@ skipPrompts: args['--yes'] || false,

}
async function promptForMissingOptions(options) {
const defaultTemplate = 'JavaScript';
const defaultTemplate = 'javascript';
if (options.skipPrompts) {

@@ -43,3 +43,3 @@ return {

message: 'Please choose which project template to use',
choices: ['JavaScript', 'TypeScript'],
choices: ['javascript', 'typescript'],
default: defaultTemplate,

@@ -53,3 +53,3 @@ });

name: 'git',
message: 'Initialize a git repository?',
message: 'Should a git be initialized?',
default: false,

@@ -66,2 +66,3 @@ });

}
export async function cli(args) {

@@ -68,0 +69,0 @@ let options = parseArgumentsIntoOptions(args);

import chalk from 'chalk';
import execa from 'execa';
import fs from 'fs';
import gitignore from 'gitignore';
import Listr from 'listr';
import ncp from 'ncp';
import path from 'path';
import { projectInstall } from 'pkg-install';
import license from 'spdx-license-list/licenses/MIT';
import { promisify } from 'util';
import execa from 'execa';
import Listr from 'listr';
import { projectInstall } from 'pkg-install';
const access = promisify(fs.access);
const writeFile = promisify(fs.writeFile);
const copy = promisify(ncp);
const writeGitignore = promisify(gitignore.writeFile);

@@ -19,2 +23,21 @@ async function copyTemplateFiles(options) {

async function createGitignore(options) {
const file = fs.createWriteStream(
path.join(options.targetDirectory, '.gitignore'),
{ flags: 'a' }
);
return writeGitignore({
type: 'Node',
file: file,
});
}
async function createLicense(options) {
const targetPath = path.join(options.targetDirectory, 'LICENSE');
const licenseContent = license.licenseText
.replace('<year>', new Date().getFullYear())
.replace('<copyright holders>', `${options.name} (${options.email})`);
return writeFile(targetPath, licenseContent, 'utf8');
}
async function initGit(options) {

@@ -33,3 +56,5 @@ const result = await execa('git', ['init'], {

...options,
targetDirectory: options.targetDirectory || process.cwd()
targetDirectory: options.targetDirectory || process.cwd(),
email: 'SeyyedKhandon@gmail.com',
name: 'SeyyedKhandon',
};

@@ -51,24 +76,37 @@

const tasks = new Listr([
const tasks = new Listr(
[
{
title: 'Copy project files',
task: () => copyTemplateFiles(options),
},
{
title: 'Create gitignore',
task: () => createGitignore(options),
},
{
title: 'Create License',
task: () => createLicense(options),
},
{
title: 'Initialize git',
task: () => initGit(options),
enabled: () => options.git,
},
{
title: 'Install dependencies',
task: () =>
projectInstall({
cwd: options.targetDirectory,
}),
skip: () =>
!options.runInstall
? 'Pass --install to automatically install dependencies'
: undefined,
},
],
{
title: 'Copy project files',
task: () => copyTemplateFiles(options),
},
{
title: 'Initialize git',
task: () => initGit(options),
enabled: () => options.git,
},
{
title: 'Install dependencies',
task: () =>
projectInstall({
cwd: options.targetDirectory,
}),
skip: () =>
!options.runInstall
? 'Pass --install to automatically install dependencies'
: undefined,
},
]);
exitOnError: false,
}
);

@@ -75,0 +113,0 @@ await tasks.run();

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