@voltsproject/volt-cli 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # Volts CLI ⚡
2
+
3
+ A tiny CLI tool for quickly creating new [Volts](https://gitlab.winningsoftware.co.uk/open-source/volts) projects.
4
+
5
+ **Volts** is a pre-configured Electron stack
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install -g @voltsproject/volts-cli
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ To create a new Volts project in your current directory:
16
+
17
+ ```bash
18
+ volt new my-volts-app
19
+ ```
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from 'commander';
3
+ import process from 'node:process';
4
+ import * as fs from 'node:fs';
5
+ import { fileURLToPath } from 'node:url';
6
+ import path from 'node:path';
7
+ import chalk from 'chalk';
8
+ import { exec } from 'node:child_process';
9
+ const program = new Command();
10
+ const getPackageInformation = async () => {
11
+ const contents = fs.readFileSync(path.join(getDirname(), '../../package.json'));
12
+ return JSON.parse(contents.toString());
13
+ };
14
+ const getDirname = () => {
15
+ return path.dirname(fileURLToPath(import.meta.url));
16
+ };
17
+ const runShellCommand = (command) => {
18
+ exec(command, (error, stdout, stderr) => {
19
+ if (error) {
20
+ console.error(chalk.red(`Error: ${error.message}`));
21
+ return;
22
+ }
23
+ if (stderr) {
24
+ console.error(chalk.yellow(`stderr: ${stderr}`));
25
+ }
26
+ console.log(chalk.green(`stdout: ${stdout}`));
27
+ });
28
+ };
29
+ getPackageInformation().then((packageData) => {
30
+ program.version(packageData.version);
31
+ program.command('new')
32
+ .argument('<name>')
33
+ .action((name) => {
34
+ console.log(chalk.blue(`Creating a new project:`) + chalk.bold(` ${name}`));
35
+ runShellCommand(`git clone https://gitlab.winningsoftware.co.uk/open-source/volts.git ${name} && cd ${name} && rm -rf .git && npm install`);
36
+ });
37
+ program.parse(process.argv);
38
+ });
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@voltsproject/volt-cli",
3
+ "version": "0.1.0",
4
+ "description": "A simple CLI tool for creating Volts projects",
5
+ "bin": {
6
+ "volt": "dist/bin/volt.js"
7
+ },
8
+ "scripts": {
9
+ "build": "tsc",
10
+ "postinstall": "npm run build",
11
+ "prepublishOnly": "npm run build"
12
+ },
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
16
+ "author": {
17
+ "name": "Daniel Winning",
18
+ "email": "daniel@winningsoftware.co.uk"
19
+ },
20
+ "license": "MIT",
21
+ "type": "module",
22
+ "dependencies": {
23
+ "chalk": "^5.6.2",
24
+ "commander": "^14.0.3",
25
+ "typescript": "^5.9.3"
26
+ },
27
+ "devDependencies": {
28
+ "@types/node": "^25.2.1"
29
+ }
30
+ }
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from 'commander';
3
+ import process from 'node:process';
4
+ import * as fs from 'node:fs';
5
+ import { fileURLToPath } from 'node:url';
6
+ import path from 'node:path';
7
+ import chalk from 'chalk';
8
+ import { exec } from 'node:child_process';
9
+
10
+ interface IPackage
11
+ {
12
+ version: string;
13
+ }
14
+
15
+ const program: Command = new Command();
16
+
17
+ const getPackageInformation: () => Promise<IPackage> = async (): Promise<IPackage> => {
18
+ const contents = fs.readFileSync(path.join(getDirname(), '../../package.json'));
19
+
20
+ return JSON.parse(contents.toString());
21
+ }
22
+
23
+ const getDirname = () => {
24
+ return path.dirname(fileURLToPath(import.meta.url));
25
+ }
26
+
27
+ const runShellCommand = (command: string): void => {
28
+ exec(command, (error, stdout, stderr) => {
29
+ if (error) {
30
+ console.error(chalk.red(`Error: ${error.message}`));
31
+ return;
32
+ }
33
+ if (stderr) {
34
+ console.error(chalk.yellow(`stderr: ${stderr}`));
35
+ }
36
+ console.log(chalk.green(`stdout: ${stdout}`));
37
+ });
38
+ };
39
+
40
+ getPackageInformation().then((packageData: IPackage) => {
41
+ program.version(packageData.version);
42
+
43
+ program.command('new')
44
+ .argument('<name>')
45
+ .action((name: string) => {
46
+ console.log(chalk.blue(`Creating a new project:`) + chalk.bold(` ${name}`));
47
+ runShellCommand(`git clone https://gitlab.winningsoftware.co.uk/open-source/volts.git ${name} && cd ${name} && rm -rf .git && npm install`);
48
+ });
49
+
50
+ program.parse(process.argv);
51
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "Node16",
4
+ "moduleResolution": "node16",
5
+ "resolveJsonModule": true,
6
+ "esModuleInterop": true,
7
+ "strict": true,
8
+ "skipLibCheck": true,
9
+ "outDir": "./dist",
10
+ "rootDir": "./src"
11
+ }
12
+ }