UNPKG

1.43 kBJavaScriptView Raw
1#!/usr/bin/env node
2
3/* eslint-disable quotes */
4
5'use strict';
6
7const program = require('commander');
8const getVisitor = require('../lib/visitor').getVisitor;
9const notifier = require('../lib/update-notifier');
10const { autoExit } = require('../lib/unref-timeout');
11
12program
13 .name('fun package')
14 .usage('[options]')
15 .description('packages the local artifacts to oss. In order that you can deploy your application directly through a template file')
16 .option('-t, --template <template>', 'The template file path')
17 .option('-b, --oss-bucket <bucket>', 'The name of the oss bucket where Fun uploads local artifacts')
18 .option('-o, --output-template-file <filename>', 'The output path of the packaged template file')
19 .parse(process.argv);
20
21if (program.args.length > 1) {
22 console.error();
23 console.error(" error: unexpected argument '%s'", program.args[1]);
24 program.help();
25}
26
27notifier.notify();
28
29getVisitor().then(visitor => {
30
31 visitor.pageview('/fun/package').send();
32
33 require('../lib/commands/package')(program)
34 .then(() => {
35 visitor.event({
36 ec: 'package',
37 ea: 'package',
38 el: 'success',
39 dp: '/fun/package'
40 }).send();
41
42 autoExit();
43 })
44 .catch(error => {
45 visitor.event({
46 ec: 'package',
47 ea: 'package',
48 el: 'error',
49 dp: '/fun/package'
50 }).send();
51
52 require('../lib/exception-handler')(error);
53 });
54});