2020-12-06 18:24:20 +00:00
|
|
|
#!/usr/bin/env node
|
2020-11-28 13:33:56 +00:00
|
|
|
import yargs from 'yargs';
|
2020-11-21 15:41:31 +00:00
|
|
|
|
2021-09-18 22:20:34 +00:00
|
|
|
import { newEnvironment } from './build/environment';
|
|
|
|
import { buildRepository } from './build/repository/build';
|
|
|
|
import { newRepository } from './build/repository/create';
|
|
|
|
import { watchRepository } from './build/watch';
|
2020-11-28 13:59:54 +00:00
|
|
|
|
2020-11-28 13:33:56 +00:00
|
|
|
const yar = yargs.scriptName('squeebot')
|
|
|
|
.command('new [name] [path]', 'create a new Squeebot environment', (y) => {
|
|
|
|
y.positional('name', {
|
|
|
|
describe: 'The name of the new environment',
|
|
|
|
})
|
|
|
|
.positional('path', {
|
|
|
|
describe: 'The path to create a new Squeebot environment at (default: working directory)',
|
|
|
|
});
|
|
|
|
}, (v) => newEnvironment(v.name as string, v.path as string))
|
|
|
|
.command('repository', 'manage repositories', (y) => {
|
|
|
|
y.command('new [name] [path]', 'create a new repository', (yi) => {
|
|
|
|
yi.positional('name', {
|
|
|
|
demandOption: 'The repository requires a name',
|
|
|
|
describe: 'The name of the new repository',
|
|
|
|
})
|
|
|
|
.positional('path', {
|
|
|
|
describe: 'The path to create the new Squeebot plugin repository at (default: working directory)',
|
|
|
|
})
|
|
|
|
.option('t', {
|
|
|
|
alias: 'no-typescript',
|
|
|
|
describe: 'Do not include typescript in the development environment',
|
|
|
|
type: 'boolean',
|
|
|
|
});
|
|
|
|
}, (v) => newRepository(v.name as string, v.path as string, v.t !== true));
|
|
|
|
y.command('build [path]', 'build a repository of plugins and generate the index file', (yi) => {
|
|
|
|
yi.positional('path', {
|
|
|
|
describe: 'The path of the repository',
|
|
|
|
})
|
|
|
|
.option('p', {
|
|
|
|
alias: 'no-output',
|
|
|
|
describe: 'Do not create an output directory, just build',
|
|
|
|
type: 'boolean',
|
|
|
|
})
|
|
|
|
.option('d', {
|
|
|
|
alias: 'deploy',
|
|
|
|
describe: 'Deploy the output directory as configured',
|
|
|
|
nargs: 1,
|
|
|
|
type: 'string',
|
|
|
|
})
|
2020-11-28 13:59:54 +00:00
|
|
|
.option('w', {
|
|
|
|
alias: 'watch',
|
|
|
|
describe: 'Watch files for changes',
|
|
|
|
type: 'boolean',
|
|
|
|
})
|
2020-11-28 13:33:56 +00:00
|
|
|
.option('o', {
|
|
|
|
alias: 'deploy-only',
|
|
|
|
describe: 'Deploy only, without rebuilding',
|
|
|
|
type: 'boolean',
|
|
|
|
});
|
2020-11-28 13:59:54 +00:00
|
|
|
}, (v) => {
|
|
|
|
const dargs = [
|
|
|
|
v.path,
|
|
|
|
v.p !== true,
|
|
|
|
v.d,
|
|
|
|
v.o === true,
|
|
|
|
];
|
|
|
|
|
|
|
|
if (v.w) {
|
|
|
|
return watchRepository(
|
|
|
|
dargs[0] as string,
|
|
|
|
dargs[1] as boolean,
|
|
|
|
dargs[2] as string,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
buildRepository(
|
|
|
|
dargs[0] as string,
|
|
|
|
dargs[1] as boolean,
|
|
|
|
dargs[2] as string,
|
|
|
|
dargs[3] as boolean,
|
|
|
|
);
|
|
|
|
});
|
2020-11-28 13:33:56 +00:00
|
|
|
})
|
|
|
|
.argv;
|