-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.ts
executable file
·118 lines (115 loc) · 3.78 KB
/
app.ts
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
#!/usr/bin/env node
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
import deployCommand from './src/commands/deploy.js';
import versionCommand from './src/commands/version.js';
import {configDelCommand, configGetCommand, configSetCommand} from "./src/commands/config.js";
import {loadThemeCommand, switchThemeCommand, themeUpdateCommand} from "./src/commands/theme.js";
yargs(hideBin(process.argv)).version(false)
// @ts-ignore
.command('deploy [site] [version]', 'deploy a single site', (yargs) => {
return yargs
.positional('site', {
describe: 'site to deploy',
type: 'string',
})
.positional('version', {
describe: 'biblys version to deploy',
type: 'string',
})
}, async ({ site, version }: { site: string, version: string }) => {
await deployCommand(site, version);
})
// @ts-ignore
.command('version [site]', 'display a site\'s current version', (yargs) => {
return yargs
.positional('site', {
describe: 'site to get version from',
type: 'string',
})
}, async ({ site }: { site: string }) => {
await versionCommand(site);
})
// @ts-ignore
.command('config:get [site] [path]', 'get a config option\'s value', (yargs) => {
return yargs
.positional('site', {
describe: 'site to read config option for',
type: 'string',
})
.positional('path', {
describe: 'path to config option to get',
type: 'string',
})
.option('bare', {
describe: 'display raw value without message',
type: "boolean",
default: false,
})
}, async ({ site, path, bare }: { site: string, path: string, bare: boolean }) => {
await configGetCommand(site, path, bare);
})
// @ts-ignore
.command('config:set [site] [updates...]', 'set a config option\'s value', (yargs) => {
return yargs
.positional('site', {
describe: 'site to update config option for',
type: 'string',
})
// @ts-ignore
.positional('updates', {
describe: 'options to updates [path]=[new value] [path]=[new value] …',
type: 'array',
})
}, async ({ site, updates }: { site: string, updates: string }) => {
await configSetCommand(site, updates);
})
// @ts-ignore
.command('config:del [site] [path]', 'delete a config option', (yargs) => {
return yargs
.positional('site', {
describe: 'site to read config option for',
type: 'string',
})
.positional('path', {
describe: 'path to config option to delete',
type: 'string',
})
}, async ({ site, path }: { site: string, path: string }) => {
await configDelCommand(site, path);
})
// @ts-ignore
.command('theme:update [site]', 'deploys a site\'s theme\' last version', (yargs) => {
return yargs
.positional('site', {
describe: 'site to update themes',
type: 'string',
})
}, async ({ site }: { site: string }) => {
await themeUpdateCommand(site);
})
// @ts-ignore
.command('theme:switch [current] [target]', `replaces current site's theme with another`, (yargs) => {
return yargs
.positional('current', {
describe: 'current site name',
type: 'string',
})
.positional('target', {
describe: 'target site name',
type: 'string',
})
}, async ({ current, target }: { current: string, target: string }) => {
await switchThemeCommand(current, target);
})
// @ts-ignore
.command('theme:load [target]', `loads target site's theme to replace current site's`, (yargs) => {
return yargs
.positional('target', {
describe: 'target site name',
type: 'string',
})
}, async ({ target }: { target: string }) => {
await loadThemeCommand(target);
})
.parse()