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

@qwikdev/create-roadplan

Package Overview
Dependencies
Maintainers
5
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@qwikdev/create-roadplan - npm Package Compare versions

Comparing version 0.0.0 to 0.0.1

docs/cli.gif

85

lib/index.js
#! /usr/bin/env node
import { cancel, confirm, intro, isCancel, log, outro, text } from "@clack/prompts";
import { cancel, confirm, intro, isCancel, log, outro, spinner, text } from "@clack/prompts";
import { exec, spawn } from "child_process";
import { cpSync, existsSync, mkdirSync } from "fs";
import { gray } from 'kleur/colors';
import path from "path";
import { gray, red } from 'kleur/colors';
import fs from 'node:fs';
import os from 'node:os';
import { join } from 'node:path';
import path, { resolve } from "path";
import { fileURLToPath } from "url";

@@ -11,2 +14,50 @@ import detectPackageManager from 'which-pm-runs';

const __dirname = path.dirname(__filename);
export function resolveRelativeDir(dir) {
// check if the outDir start with home ~
if (dir.startsWith('~/')) {
return resolve(os.homedir(), dir);
}
else {
return resolve(process.cwd(), dir);
}
}
export function runCommand(cmd, args, cwd) {
let child;
const install = new Promise((resolve) => {
try {
child = spawn(cmd, args, {
cwd,
stdio: 'ignore',
});
child.on('error', (e) => {
if (e) {
if (e.message) {
log.error(red(String(e.message)) + `\n\n`);
}
else {
log.error(red(String(e)) + `\n\n`);
}
}
resolve(false);
});
child.on('close', (code) => {
if (code === 0) {
resolve(true);
}
else {
resolve(false);
}
});
}
catch (e) {
resolve(false);
}
});
const abort = async () => {
if (child) {
child.kill('SIGINT');
}
};
return { abort, install };
}
export const isPackageManagerInstalled = (packageManager) => {

@@ -75,2 +126,3 @@ return new Promise((resolve) => {

cpSync(templatePath, projectNameAnswer, { recursive: true });
const outDir = resolveRelativeDir(projectNameAnswer.trim());
const runDepInstallAnswer = await confirm({

@@ -84,4 +136,31 @@ message: `Would you like to install ${packageManager} dependencies?`,

}
const gitInitAnswer = await confirm({
message: `Initialize a new git repository?`,
initialValue: true,
});
log.step("Installing dependencies...");
await installDependencies(packageManager, projectNameAnswer);
const s = spinner();
if (gitInitAnswer) {
if (fs.existsSync(join(outDir, '.git'))) {
log.info(`Git has already been initialized before. Skipping...`);
}
else {
s.start('Git initializing...');
try {
const res = [];
res.push(await runCommand('git', ['init'], outDir).install);
res.push(await runCommand('git', ['add', '-A'], outDir).install);
res.push(await runCommand('git', ['commit', '-m', 'Initial commit ⚡️'], outDir).install);
if (res.some((r) => r === false)) {
throw '';
}
s.stop('Git initialized 🎲');
}
catch (e) {
s.stop('Git failed to initialize');
log.error(red(`Git failed to initialize. You can do this manually by running: git init`));
}
}
}
outro("RoadPlan starter creation completed successfully!");

@@ -88,0 +167,0 @@ }

{
"name": "@qwikdev/create-roadplan",
"description": "Interactive CLI for create RoadPlan starter",
"version": "0.0.0",
"description": "Interactive CLI for create a Qwik documentation starter",
"version": "0.0.1",
"author": "QwikDev",
"license": "MIT",
"homepage": "https://roadplan.pages.dev/",
"repository": {
"type": "git",
"url": "https://github.com/QwikDev/RoadPlan.git",
"directory": "packages/create-roadplan"
},
"bugs": "https://github.com/QwikDev/RoadPlan/issues",
"keywords": [
"qwik",
"docs",
"CLI",
"generator",
"starters",
"template"
],
"type": "module",

@@ -6,0 +23,0 @@ "bin": {

template/public/images/logos/fastify-black.svg

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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