1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | 'use strict';
|
14 |
|
15 | const { getOrCreateLogger } = require('./log-common.js');
|
16 | const yargsBuild = require('./yargs-build.js');
|
17 |
|
18 | module.exports = function pack() {
|
19 | let executor;
|
20 |
|
21 | return {
|
22 | set executor(value) {
|
23 | executor = value;
|
24 | },
|
25 | command: 'package [files..]',
|
26 | desc: 'Create Adobe I/O runtime packages',
|
27 | builder: (yargs) => {
|
28 | yargsBuild(yargs)
|
29 | .option('force', {
|
30 | describe: 'Forces creation of packages even if the sources are not modified.',
|
31 | type: 'boolean',
|
32 | default: false,
|
33 | })
|
34 | .option('minify', {
|
35 | describe: 'Enables minification of the final action bundle.',
|
36 | type: 'boolean',
|
37 | default: false,
|
38 | })
|
39 | .option('target', {
|
40 | alias: 'o',
|
41 | default: '.hlx/build',
|
42 | type: 'string',
|
43 | describe: 'Target directory for packaged actions',
|
44 | })
|
45 | .group(['force', 'minify', 'target'], 'Package options')
|
46 | .help();
|
47 | },
|
48 | handler: async (argv) => {
|
49 | if (!executor) {
|
50 |
|
51 | const PackageCommand = require('./package.cmd');
|
52 | executor = new PackageCommand(getOrCreateLogger(argv));
|
53 | }
|
54 |
|
55 | await executor
|
56 | .withTarget(argv.target)
|
57 | .withFiles(argv.files)
|
58 | .withOnlyModified(!argv.force)
|
59 | .withMinify(argv.minify)
|
60 | .withCustomPipeline(argv.customPipeline)
|
61 | .run();
|
62 | },
|
63 | };
|
64 | };
|