@owdproject/cli 0.0.1
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 +33 -0
- package/bin/owd.js +121 -0
- package/package.json +36 -0
- package/src/commands/create.js +11 -0
- package/src/commands/generate.js +12 -0
- package/src/commands/installApp.js +9 -0
- package/src/commands/installTheme.js +9 -0
- package/src/commands/start.js +13 -0
- package/src/utils/cloneRepo.js +25 -0
- package/src/utils/installPackage.js +15 -0
- package/src/utils/logging.js +15 -0
package/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Open Web Desktop CLI
|
|
2
|
+
|
|
3
|
+
This command-line interface (CLI) provides a set of tools to easily manage your project.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
To install the CLI globally, run:
|
|
8
|
+
|
|
9
|
+
`npm install -g owd`
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
Once installed, you can use the CLI commands by typing `npx owd` followed by a command.
|
|
14
|
+
|
|
15
|
+
### Available Commands
|
|
16
|
+
|
|
17
|
+
- `npx owd create`: Create a new Open Web Desktop project from a template.
|
|
18
|
+
- `npx owd start`: Start the project in development mode (runs Nuxt.js).
|
|
19
|
+
- `npx owd generate`: Generate the project for static deployment.
|
|
20
|
+
|
|
21
|
+
For more information on each command, use:
|
|
22
|
+
|
|
23
|
+
`npx owd <command> --help`
|
|
24
|
+
|
|
25
|
+
## Features
|
|
26
|
+
|
|
27
|
+
- Easy setup for new Open Web Desktop projects.
|
|
28
|
+
- Allows you to start development mode quickly with `npx owd start`.
|
|
29
|
+
- Generates files for static deployment with `npx owd generate`.
|
|
30
|
+
|
|
31
|
+
## License
|
|
32
|
+
|
|
33
|
+
This project is released under the [MIT License](LICENSE).
|
package/bin/owd.js
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { Command } from 'commander'
|
|
4
|
+
import chalk from 'chalk'
|
|
5
|
+
import gradient from 'gradient-string'
|
|
6
|
+
import inquirer from 'inquirer'
|
|
7
|
+
import { execSync } from 'child_process'
|
|
8
|
+
import fs from 'fs'
|
|
9
|
+
import path from 'path'
|
|
10
|
+
|
|
11
|
+
import {cloneRepo} from '../src/utils/cloneRepo.js'
|
|
12
|
+
import {installPackage} from "../src/utils/installPackage.js";
|
|
13
|
+
|
|
14
|
+
const program = new Command()
|
|
15
|
+
const owdGradient = gradient('#0080ff', '#0A4C92')
|
|
16
|
+
|
|
17
|
+
const logTitle = () => {
|
|
18
|
+
console.log(owdGradient(`\n
|
|
19
|
+
___ __ __ _ ___ _ _
|
|
20
|
+
/___\\_ __ ___ _ __ / / /\\ \\ \\___| |__ / \\___ ___| | _| |_ ___ _ __
|
|
21
|
+
// // '_ \\ / _ \\ '_ \\ \\ \\/ \\/ / _ \\ '_ \\ / /\\ / _ \\/ __| |/ / __/ _ \\| '_ \\
|
|
22
|
+
/ \\_//| |_) | __/ | | | \\ /\\ / __/ |_) | / /_// __/\\__ \\ <| || (_) | |_) |
|
|
23
|
+
\\___/ | .__/ \\___|_| |_| \\/ \\/ \\___|_.__/ /___,' \\___||___/_|\\_\\\\__\\___/| .__/
|
|
24
|
+
|_| |_|
|
|
25
|
+
\n`))
|
|
26
|
+
console.log(chalk.white('Launching Open Web Desktop on your computer'))
|
|
27
|
+
console.log(chalk.white('\n───────────────────────────────────────────────────────────\n'))
|
|
28
|
+
console.log(chalk.white(' ➜ ') + chalk.whiteBright('npx owd create') + chalk.gray(' Create a new project from the template'))
|
|
29
|
+
console.log(chalk.white(' ➜ ') + chalk.whiteBright('npx owd start') + chalk.gray(' Start the dev server for local development'))
|
|
30
|
+
console.log(chalk.white(' ➜ ') + chalk.whiteBright('npx owd generate') + chalk.gray(' Generate project for static deployment'))
|
|
31
|
+
console.log(chalk.white('\n───────────────────────────────────────────────────────────\n'))
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const logServerInfo = () => {
|
|
35
|
+
console.log(`\n ${chalk.red.bold('➜ Local:')} ${chalk.white('http://localhost:3000/')}`)
|
|
36
|
+
console.log(` ${chalk.red.bold('➜ Network:')} ${chalk.white('http://localhost:3000/')} \n`)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
program.command('create')
|
|
40
|
+
.description('Create a new project')
|
|
41
|
+
.action(async () => {
|
|
42
|
+
logTitle()
|
|
43
|
+
console.log(chalk.green('✨ Creating new project\n'))
|
|
44
|
+
|
|
45
|
+
const { projectDir } = await inquirer.prompt([
|
|
46
|
+
{
|
|
47
|
+
type: 'input',
|
|
48
|
+
name: 'projectDir',
|
|
49
|
+
message: 'Enter the directory name for your new project:',
|
|
50
|
+
default: 'owd-client'
|
|
51
|
+
}
|
|
52
|
+
])
|
|
53
|
+
|
|
54
|
+
const targetDir = path.join(process.cwd(), projectDir)
|
|
55
|
+
|
|
56
|
+
if (fs.existsSync(targetDir)) {
|
|
57
|
+
console.log(chalk.red(`Directory ${projectDir} already exists!`))
|
|
58
|
+
return
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
fs.mkdirSync(targetDir, { recursive: true })
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
await cloneRepo(targetDir)
|
|
65
|
+
|
|
66
|
+
process.chdir(targetDir)
|
|
67
|
+
|
|
68
|
+
console.log(chalk.green('Installing dependencies...'))
|
|
69
|
+
execSync('npm install', { stdio: 'inherit' })
|
|
70
|
+
|
|
71
|
+
console.log(chalk.blue('Starting development server...'))
|
|
72
|
+
execSync('npm run dev', { stdio: 'inherit' })
|
|
73
|
+
} catch (error) {
|
|
74
|
+
console.error(error)
|
|
75
|
+
console.log(chalk.red('✖ Error during project setup'))
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
program.command('start')
|
|
80
|
+
.description('Start the project in development mode')
|
|
81
|
+
.action(() => {
|
|
82
|
+
logTitle()
|
|
83
|
+
|
|
84
|
+
try {
|
|
85
|
+
execSync('npx nuxi dev --host --qr=false', { stdio: 'inherit' })
|
|
86
|
+
console.log(chalk.blue('🚀 Starting development server'))
|
|
87
|
+
logServerInfo()
|
|
88
|
+
} catch (error) {
|
|
89
|
+
console.log(chalk.red('✖ Error starting Nuxt server'))
|
|
90
|
+
console.log(chalk.yellow(error.message))
|
|
91
|
+
} finally {
|
|
92
|
+
console.log(chalk.white('👨💻 If you need help, check the logs or visit our docs'))
|
|
93
|
+
}
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
program.command('generate')
|
|
97
|
+
.description('Generate deployment files')
|
|
98
|
+
.action(() => {
|
|
99
|
+
logTitle()
|
|
100
|
+
|
|
101
|
+
try {
|
|
102
|
+
execSync('npx nuxi generate', { stdio: 'inherit' })
|
|
103
|
+
console.log(chalk.green('✅ Static site generated successfully!'))
|
|
104
|
+
} catch (error) {
|
|
105
|
+
console.log(chalk.red('✖ Error generating static site'))
|
|
106
|
+
}
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
export const installAppCommand = (program) => {
|
|
110
|
+
program.command('install:app <source>')
|
|
111
|
+
.description('Install a new application from a Git or NPM source')
|
|
112
|
+
.action((source) => installPackage('Application', source))
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export const installThemeCommand = (program) => {
|
|
116
|
+
program.command('install:theme <source>')
|
|
117
|
+
.description('Install a new theme from a Git or NPM source')
|
|
118
|
+
.action((source) => installPackage('Theme', source))
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
program.parse()
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@owdproject/cli",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "The official CLI for Open Web Desktop",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"cli",
|
|
7
|
+
"open-web-desktop",
|
|
8
|
+
"owd",
|
|
9
|
+
"nuxt",
|
|
10
|
+
"desktop-environment",
|
|
11
|
+
"owd-client",
|
|
12
|
+
"generator"
|
|
13
|
+
],
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"author": {
|
|
16
|
+
"name": "dxlliv",
|
|
17
|
+
"url": "https://github.com/dxlliv"
|
|
18
|
+
},
|
|
19
|
+
"type": "module",
|
|
20
|
+
"main": "index.js",
|
|
21
|
+
"bin": {
|
|
22
|
+
"owd": "./bin/owd.js"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"chalk": "5.4.1",
|
|
29
|
+
"commander": "13.1.0",
|
|
30
|
+
"fs-extra": "11.3.0",
|
|
31
|
+
"gradient-string": "3.0.0",
|
|
32
|
+
"inquirer": "12.5.2",
|
|
33
|
+
"nuxi": "3.23.1",
|
|
34
|
+
"simple-git": "3.27.0"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { logTitle } from '../utils/logging'
|
|
2
|
+
import chalk from 'chalk'
|
|
3
|
+
|
|
4
|
+
export const createCommand = (program) => {
|
|
5
|
+
program.command('create')
|
|
6
|
+
.description('Create a new project')
|
|
7
|
+
.action(() => {
|
|
8
|
+
logTitle()
|
|
9
|
+
console.log(chalk.green('✨ Creating new project'))
|
|
10
|
+
})
|
|
11
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// src/commands/generate.js
|
|
2
|
+
import { logTitle } from '../utils/logging'
|
|
3
|
+
import chalk from 'chalk'
|
|
4
|
+
|
|
5
|
+
export const generateCommand = (program) => {
|
|
6
|
+
program.command('generate')
|
|
7
|
+
.description('Generate deployment files')
|
|
8
|
+
.action(() => {
|
|
9
|
+
logTitle()
|
|
10
|
+
console.log(chalk.yellow('⚡ Generating files'))
|
|
11
|
+
})
|
|
12
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// src/commands/installApp.js
|
|
2
|
+
import { installPackage } from '../utils/installPackage'
|
|
3
|
+
import chalk from 'chalk'
|
|
4
|
+
|
|
5
|
+
export const installAppCommand = (program) => {
|
|
6
|
+
program.command('install app <source>')
|
|
7
|
+
.description('Install a new application from a Git or NPM source')
|
|
8
|
+
.action((source) => installPackage('Application', source))
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// src/commands/installTheme.js
|
|
2
|
+
import { installPackage } from '../utils/installPackage'
|
|
3
|
+
import chalk from 'chalk'
|
|
4
|
+
|
|
5
|
+
export const installThemeCommand = (program) => {
|
|
6
|
+
program.command('install theme <source>')
|
|
7
|
+
.description('Install a new theme from a Git or NPM source')
|
|
8
|
+
.action((source) => installPackage('Theme', source))
|
|
9
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// src/commands/start.js
|
|
2
|
+
import { logTitle, logServerInfo } from '../utils/logging'
|
|
3
|
+
import chalk from 'chalk'
|
|
4
|
+
|
|
5
|
+
export const startCommand = (program) => {
|
|
6
|
+
program.command('start')
|
|
7
|
+
.description('Start the project in development mode')
|
|
8
|
+
.action(() => {
|
|
9
|
+
logTitle()
|
|
10
|
+
console.log(chalk.blue('🚀 Starting development server'))
|
|
11
|
+
logServerInfo()
|
|
12
|
+
})
|
|
13
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import simpleGit from 'simple-git'
|
|
5
|
+
|
|
6
|
+
export const cloneRepo = async (targetPath) => {
|
|
7
|
+
const git = simpleGit()
|
|
8
|
+
const tempDir = path.join(process.cwd(), 'owd-temp')
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
await git.clone('https://github.com/owdproject/client', tempDir)
|
|
12
|
+
|
|
13
|
+
const templatePath = path.join(tempDir, 'template')
|
|
14
|
+
if (fs.existsSync(templatePath)) {
|
|
15
|
+
fs.copySync(templatePath, targetPath)
|
|
16
|
+
} else {
|
|
17
|
+
console.log(chalk.red('Template directory does not exist in the cloned repo!'))
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
fs.removeSync(tempDir)
|
|
21
|
+
} catch (error) {
|
|
22
|
+
console.error(error)
|
|
23
|
+
console.log(chalk.red('✖ Error cloning or copying the template'))
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// src/utils/installPackage.js
|
|
2
|
+
import { execSync } from 'child_process'
|
|
3
|
+
import chalk from 'chalk'
|
|
4
|
+
// import { logTitle } from './logging'
|
|
5
|
+
|
|
6
|
+
export const installPackage = (type, source) => {
|
|
7
|
+
//logTitle()
|
|
8
|
+
console.log(chalk.yellow(`📦 Installing ${type}: ${source}`))
|
|
9
|
+
try {
|
|
10
|
+
execSync(`npm install ${source}`, { stdio: 'inherit' })
|
|
11
|
+
console.log(chalk.green(`✔ ${type} installed successfully`))
|
|
12
|
+
} catch (error) {
|
|
13
|
+
console.log(chalk.red(`✖ Failed to install ${type}`))
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// src/utils/logging.js
|
|
2
|
+
import figlet from 'figlet'
|
|
3
|
+
import gradient from 'gradient-string'
|
|
4
|
+
import chalk from 'chalk'
|
|
5
|
+
|
|
6
|
+
export const logTitle = () => {
|
|
7
|
+
console.log(gradient.pastel.multiline(figlet.textSync('OWD', { horizontalLayout: 'full' })))
|
|
8
|
+
console.log(chalk.red.bold('\n ➜ Main Commands'))
|
|
9
|
+
console.log(chalk.red.bold(' ───────────────────────────────────'))
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const logServerInfo = () => {
|
|
13
|
+
console.log(`\n ${chalk.red.bold('➜ Local:')} ${chalk.white('http://localhost:3000/')}`)
|
|
14
|
+
console.log(` ${chalk.red.bold('➜ Network:')} ${chalk.white('http://localhost:3000/')} \n`)
|
|
15
|
+
}
|