-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcli.js
More file actions
executable file
·187 lines (185 loc) · 5.01 KB
/
cli.js
File metadata and controls
executable file
·187 lines (185 loc) · 5.01 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#!/usr/bin/env node
const commands = require('./commands');
const DEFAULT_HOST_IMAGE = 'syntrocontainer/silverstripe-dev:7.4-apache-buster';
const DEFAULT_DB_IMAGE = 'mysql:8-oracle';
require('yargs') // eslint-disable-line
.option('image-host', {
alias: 'h',
type: 'string',
description: 'The image of the host container',
default: DEFAULT_HOST_IMAGE,
})
.option('image-db', {
alias: 'd',
type: 'string',
description: 'The image of the database container',
default: DEFAULT_DB_IMAGE,
})
.option('tz', {
type: 'string',
description: 'The timezone of the host and db container',
default: 'Europe/Zurich',
})
.option('ss-env-type', {
type: 'string',
description: 'The environment type, either "dev", "test" or "live"',
default: 'dev',
})
.option('ports-host', {
type: 'array',
description: 'Ports to publish from the host container',
default: ['80:80'],
})
.option('ports-db', {
type: 'array',
description: 'Ports to publish from the database container',
default: ['3306:3306'],
})
// .option('use-nfs', {
// type: 'boolean',
// description: 'flag to enable nfs mount on macOS or Windows systems',
// default: false,
// })
// Serve the devenv
.command(
'up',
'start the devenv',
(yargs) => {}, // eslint-disable-line no-unused-vars
(argv) => {
commands.serve(argv);
},
)
.command(
'serve',
'start the devenv (same as up)',
(yargs) => {}, // eslint-disable-line no-unused-vars
(argv) => {
commands.serve(argv);
},
)
// stop the devenv
.command(
'down',
'stop the devenv',
(yargs) => {
yargs.option('volumes', {
alias: 'v',
describe: 'remove volumes',
type: 'boolean',
});
},
(argv) => {
commands.down(argv);
},
)
// pull in container
.command(
'pull',
'pulls newest versions of all containers',
(yargs) => {}, // eslint-disable-line no-unused-vars
(argv) => {
commands.pull(argv);
},
)
// build
.command(
'build',
'build new versions of all containers which require build',
(yargs) => {}, // eslint-disable-line no-unused-vars
(argv) => {
commands.build(argv);
},
)
// execute a command inside the host container
.command(
'run [container]',
'run a command in the desired service container ("host" by default). Specify the command like so: "ssdev run -- composer require silverstripe/framework"',
(yargs) => {
yargs
.positional('container', {
describe: 'the service name to execute the command in',
default: 'host',
type: 'string',
})
.option('--', {
describe: 'the command to run',
})
.demandOption('--', 'Please provide a command using "--"')
// .array('command')
.parserConfiguration({
// 'unknown-options-as-args': true,
'populate--': true,
});
},
(argv) => {
commands.run(argv);
},
)
// execute a command inside the host container
.command(
'exec [container]',
'exec a command in the desired service container ("host" by default). use like so: "ssdev exec composer -- require silverstripe/framework"',
(yargs) => {
yargs
.positional('container', {
describe: 'the service name to execute the command in',
default: 'host',
type: 'string',
})
.option('--', {
describe: 'the command to run',
})
.demandOption('--', 'Please provide a command using "--"')
// .array('command')
.parserConfiguration({
// 'unknown-options-as-args': true,
'populate--': true,
});
},
(argv) => {
commands.exec(argv);
},
)
// Initialize a new project
.command(
'init <path>',
'create a new project using a silverstripe recipe in a new directory',
(yargs) => {
yargs.option('recipe', {
alias: 'r',
describe: 'specify the recipe to be used',
default: 'syntro/ssto:^2',
type: 'string',
}).option('container', {
describe: 'specify the container to be used (must contain a composer installation)',
default: DEFAULT_HOST_IMAGE,
type: 'string',
}).option('ignore-platform-reqs', {
type: 'boolean',
description: 'If set, the flag is added to the composer commant. Use of this flag is discouraged, use the composer "config.platform" key.',
});
yargs.positional('path', {
describe: 'where to place the project',
type: 'string',
});
},
(argv) => {
commands.init(argv);
},
)
// print the generated compose config
.command(
'print',
'Print the generated docker-compose config for use in a file',
(yargs) => {}, // eslint-disable-line no-unused-vars
(argv) => {
commands.print(argv);
},
)
.strict(true)
.help('help')
.scriptName('ssdev')
.epilogue('provided by Syntro GmbH (https://syntro.ch)')
.demandCommand()
.pkgConf('ssdev')
.argv;