-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Expand file tree
/
Copy pathindex.js
More file actions
123 lines (113 loc) · 3.67 KB
/
index.js
File metadata and controls
123 lines (113 loc) · 3.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
const chalk = require('chalk')
const boxen = require('boxen')
const profileFunctions = require('./common').commonProfileFunctions()
/**
* @typedef {{
* name: string,
* hostPlatform: string,
* hostDesktop: string,
* portWssPlatform: number,
* portWssDesktop: number,
* portWssNetwork: number,
* portWssDashboard: number,
* portHttpPlatform: number,
* portHttpNetwork: number,
* portHttpDesktop: number,
* storeData: string,
* storeLogs: string,
* storeWorkspaces: string,
* }} Profile
*/
/**
* @param {string} message
* @returns {string}
*/
function stdBoxedMessage(message) {
return boxen(message, {
borderColor: 'yellow',
title: 'Welcome to Superalgos Ecosystem App Management',
titleAlignment: 'center',
padding: 1,
margin: 1
})
}
/**
* @param {string} profileName
* @returns {Profile}
*/
function getProfile(profileName) {
const documentPath = profileFunctions.getProfileDocumentPath()
const existingProfiles = profileFunctions.getProfileDocument(documentPath)
return existingProfiles.find(p => p.name === profileName)
}
function profileCommands() {
const thisObject = {
name: 'profile',
description: chalk.bold('Use this command to manage your Superalgos profiles'),
options: options,
runner: runner
}
const message = `
USAGE:
${chalk.red('superalgos profile')} ${chalk.italic.red('[command] [options]')}
COMMANDS:
- ${chalk.red('create')}
- OPTIONS:
${chalk.italic.red('--hostPlatform')}
${chalk.italic.red('--hostDesktop')}
${chalk.italic.red('--portWssPlatform')}
${chalk.italic.red('--portWssDesktop')}
${chalk.italic.red('--portWssDashboard')}
${chalk.italic.red('--portWssNetwork')}
${chalk.italic.red('--portHttpPlatform')}
${chalk.italic.red('--portHttpDesktop')}
${chalk.italic.red('--portHttpNetwork')}
${chalk.italic.red('--storeData')}
${chalk.italic.red('--storeLogs')}
${chalk.italic.red('--storeWorkspaces')}
- ${chalk.red('delete')}
- OPTIONS:
${chalk.italic.red('--name')}
- ${chalk.red('describe')}
- OPTIONS:
${chalk.italic.red('--name')}
- ${chalk.red('list')}
- OPTIONS:
${chalk.italic.red('--prefix')}
${chalk.italic.red('--limit')}
${chalk.italic.red('--offset')}
- ${chalk.red('update')}
- OPTIONS:
${chalk.italic.red('--name')}
${chalk.italic.red('--hostPlatform')}
${chalk.italic.red('--hostDesktop')}
${chalk.italic.red('--portWssPlatform')}
${chalk.italic.red('--portWssDesktop')}
${chalk.italic.red('--portWssDashboard')}
${chalk.italic.red('--portWssNetwork')}
${chalk.italic.red('--portHttpPlatform')}
${chalk.italic.red('--portHttpDesktop')}
${chalk.italic.red('--portHttpNetwork')}
${chalk.italic.red('--storeData')}
${chalk.italic.red('--storeLogs')}
${chalk.italic.red('--storeWorkspaces')}
`
return thisObject
function options(cmd) {
const commands = [
require('./create/create').createCommand(),
require('./delete/delete').deleteCommand(),
require('./describe/describe').describeCommand(),
require('./list/list').listCommand(),
require('./update/update').updateCommand()
]
return commands.reduce((builder, c) =>
builder.command(c.name, c.description, c.options, c.runner).help(),
cmd)
}
function runner() {
console.log(stdBoxedMessage(message))
}
}
exports.getProfile = getProfile
exports.commands = [profileCommands()]