Skip to content

Commit

Permalink
refactors version indication, removes version test, adds catch all, a…
Browse files Browse the repository at this point in the history
…dds donation link
  • Loading branch information
markschellhas committed Mar 1, 2024
1 parent 7b5ff8f commit 5a3ea24
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 64 deletions.
38 changes: 24 additions & 14 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,23 @@ import {
import { spawn } from 'child_process';
import { destroyButtonTemplate } from './lib/templates/component_templates.js';
import { CONSOLE_COLOR, styledBy } from './lib/helpers.js';
import { create } from 'domain';

import { readFileSync } from 'fs';

let pjson;
try {
const pkgPath = new URL('./package.json', import.meta.url);
const pkgData = readFileSync(pkgPath);
pjson = JSON.parse(pkgData);
} catch (err) {
console.error('Error reading package.json:', err);
}


const prog = sade('chic');

prog
.version('1.4.0')
.version(pjson.version);

prog
.command('new <name>')
Expand Down Expand Up @@ -113,8 +124,9 @@ prog
`)
console.log('\x1b[36m%s\x1b[0m', `To start the server run: chic s`);
console.log('\x1b[36m%s\x1b[0m', `More info: https://chicjs.org`);
console.log('\x1b[36m%s\x1b[0m', `----------------------------------------`);
console.log(CONSOLE_COLOR.GREEN, `--------------------`);
console.log(CONSOLE_COLOR.GREEN, `Donate to support us: https://ko-fi.com/sveltesafari`);
console.log(CONSOLE_COLOR.GREEN, `--------------------`);
}
});
}
Expand Down Expand Up @@ -247,17 +259,15 @@ prog

// if command not found, show help
prog
.command('*')
.command('*', '', { default: true })
.action(() => {
console.log(CONSOLE_COLOR.GREEN, `
Welcome to chic.js!
--------------------
`);
// show version:
console.log(CONSOLE_COLOR.BLUE, `Version: ${prog.version()}`);
// show author:
console.log(CONSOLE_COLOR.BLUE, `Author: ${prog.author}`);
prog.outputHelp();
console.log(CONSOLE_COLOR.BLUE, `Chic.js`);
console.log(CONSOLE_COLOR.BLUE, `Version: ${pjson.version}`);
console.log(CONSOLE_COLOR.BLUE, `Author: Mark Schellhas`);
console.log(CONSOLE_COLOR.BLUE, `For help, run chic --help`);
console.log(CONSOLE_COLOR.GREEN, `--------------------`);
console.log(CONSOLE_COLOR.GREEN, `Donate to support this project: https://ko-fi.com/sveltesafari`);
console.log(CONSOLE_COLOR.GREEN, `--------------------`);
});

prog.parse(process.argv);
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chic.js",
"version": "1.4.0",
"version": "1.4.1",
"description": "CLI for rapidly scaffolding SvelteKit apps",
"main": "index.js",
"bin": {
Expand All @@ -18,7 +18,9 @@
"chic",
"chic.js",
"svelte",
"sveltekit"
"sveltekit",
"Mark Schellhas",
"Svelte Safari"
],
"author": "Mark Schellhas",
"license": "MIT",
Expand Down
48 changes: 0 additions & 48 deletions test/checklist.test.js

This file was deleted.

0 comments on commit 5a3ea24

Please sign in to comment.