Skip to content

Commit

Permalink
init work for create command
Browse files Browse the repository at this point in the history
  • Loading branch information
bjohansebas committed Nov 29, 2024
1 parent 22418fc commit 0f8a39c
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
const yargs = require('yargs/yargs')
const dotenv = require('dotenv')
const path = require('path')
const initStatusboard = require('./commands/create')

const SHARED_OPTIONS = {
db: {
Expand Down Expand Up @@ -81,8 +82,8 @@ module.exports = (create, builder, argv) => {

let cli = yargs()

.command('create', 'Create a StatusBoard', {}, async (argv) => {
console.log('Coming soon!')
.command('create [directory]', 'Create a StatusBoard', {}, async (argv) => {
await initStatusboard(argv)
})

.command('build', 'Index and build board', SHARED_OPTIONS, async (argv) => {
Expand Down
54 changes: 54 additions & 0 deletions lib/commands/create.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
const inquirer = require("inquirer");
const path = require("node:path");
const createPackageJson = require("create-package-json");

async function create(opts) {
const { directory } = opts;
let projectPath = directory;

if (!projectPath) {
const res = await inquirer.prompt([
{
type: "input",
name: "path",
message: "Where would you like to create your project?",
default: "statusboard",
},
]);

projectPath = res.path.trim();
}

const appPath = path.resolve(projectPath);
let projectName = path.basename(appPath);

const pkg = await createPackageJson(
{
name: projectName,
description: '"A dashboard for project status',
version: "1.0.0",
dependencies: ["@pkgjs/statusboard"],
author: null,
keywords: null,
repository: null,
type: "commonjs",
private: true,
cwd: appPath,
license: "MIT",
main: "config.js",
devDependencies: null,
scrips: {
build: "statusboard build -C ./config",
buildsite: "npm run clean && statusboard site -C ./config",
buildindex: "statusboard index -C ./config",
clean: "rm -rf build/css build/js",
},
},
{}
);

console.log(pkg);
console.log(projectPath, projectName);
}

module.exports = create;
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"@wesleytodd/buildjs": "0.0.8",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
"cptmpl": "0.0.4",
"create-package-json": "^1.1.0",
"dotenv": "^8.0.0",
"es5-lit-element": "^2.2.1",
"express": "^4.17.1",
Expand Down

0 comments on commit 0f8a39c

Please sign in to comment.