mirror of
https://github.com/qlik-oss/nebula.js.git
synced 2025-12-19 17:58:43 -05:00
fix(cli-sense): apply default when using javascript api (#633)
This commit is contained in:
@@ -1,51 +1,13 @@
|
|||||||
const buildLegacy = require('./lib/build-legacy');
|
const init = require('./lib/init-config');
|
||||||
const build = require('./lib/build');
|
const sense = require('./lib/sense');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
command: 'sense',
|
command: 'sense',
|
||||||
desc: 'Build a nebula visualization as a Qlik Sense extension',
|
desc: 'Build a nebula visualization as a Qlik Sense extension',
|
||||||
builder(yargs) {
|
builder(yargs) {
|
||||||
yargs.option('ext', {
|
init(yargs);
|
||||||
type: 'string',
|
|
||||||
required: false,
|
|
||||||
desc: 'Extension definition',
|
|
||||||
});
|
|
||||||
yargs.option('meta', {
|
|
||||||
type: 'string',
|
|
||||||
required: false,
|
|
||||||
desc: 'Extension meta information',
|
|
||||||
});
|
|
||||||
yargs.option('output', {
|
|
||||||
type: 'string',
|
|
||||||
required: false,
|
|
||||||
default: '<name>-ext',
|
|
||||||
desc: 'Destination directory',
|
|
||||||
});
|
|
||||||
yargs.option('minify', {
|
|
||||||
type: 'boolean',
|
|
||||||
required: false,
|
|
||||||
default: true,
|
|
||||||
desc: 'Minify and uglify code',
|
|
||||||
});
|
|
||||||
yargs.option('sourcemap', {
|
|
||||||
type: 'boolean',
|
|
||||||
required: false,
|
|
||||||
default: false,
|
|
||||||
desc: 'Generate sourcemaps',
|
|
||||||
});
|
|
||||||
yargs.option('partial', {
|
|
||||||
type: 'boolean',
|
|
||||||
required: false,
|
|
||||||
default: false,
|
|
||||||
desc: 'Generate partial extension',
|
|
||||||
hidden: true,
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
handler(argv) {
|
handler(argv) {
|
||||||
if (argv.partial) {
|
sense(argv);
|
||||||
build(argv);
|
|
||||||
} else {
|
|
||||||
buildLegacy(argv);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
11
commands/sense/lib/api-entry.js
Normal file
11
commands/sense/lib/api-entry.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
const extend = require('extend');
|
||||||
|
const yargs = require('yargs');
|
||||||
|
const initConfig = require('./init-config');
|
||||||
|
const sense = require('./sense');
|
||||||
|
|
||||||
|
module.exports = (argv) => {
|
||||||
|
// not runnning via command line, run the config to inject default values
|
||||||
|
const defaultBuildConfig = initConfig(yargs([])).argv;
|
||||||
|
const senseConfig = extend(true, {}, defaultBuildConfig, argv);
|
||||||
|
sense(senseConfig);
|
||||||
|
};
|
||||||
39
commands/sense/lib/init-config.js
Normal file
39
commands/sense/lib/init-config.js
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
const options = {
|
||||||
|
ext: {
|
||||||
|
type: 'string',
|
||||||
|
required: false,
|
||||||
|
desc: 'Extension definition',
|
||||||
|
},
|
||||||
|
meta: {
|
||||||
|
type: 'string',
|
||||||
|
required: false,
|
||||||
|
desc: 'Extension meta information',
|
||||||
|
},
|
||||||
|
output: {
|
||||||
|
type: 'string',
|
||||||
|
required: false,
|
||||||
|
default: '<name>-ext',
|
||||||
|
desc: 'Destination directory',
|
||||||
|
},
|
||||||
|
minify: {
|
||||||
|
type: 'boolean',
|
||||||
|
required: false,
|
||||||
|
default: true,
|
||||||
|
desc: 'Minify and uglify code',
|
||||||
|
},
|
||||||
|
sourcemap: {
|
||||||
|
type: 'boolean',
|
||||||
|
required: false,
|
||||||
|
default: false,
|
||||||
|
desc: 'Generate sourcemaps',
|
||||||
|
},
|
||||||
|
partial: {
|
||||||
|
type: 'boolean',
|
||||||
|
required: false,
|
||||||
|
default: false,
|
||||||
|
desc: 'Generate partial extension',
|
||||||
|
hidden: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = (yargs) => yargs.options(options);
|
||||||
11
commands/sense/lib/sense.js
Normal file
11
commands/sense/lib/sense.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
const buildLegacy = require('./build-legacy');
|
||||||
|
const build = require('./build');
|
||||||
|
|
||||||
|
function sense(argv) {
|
||||||
|
if (argv.partial) {
|
||||||
|
build(argv);
|
||||||
|
} else {
|
||||||
|
buildLegacy(argv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
module.exports = sense;
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/qlik-oss/nebula.js.git"
|
"url": "https://github.com/qlik-oss/nebula.js.git"
|
||||||
},
|
},
|
||||||
"main": "lib/build.js",
|
"main": "lib/api-entry.js",
|
||||||
"files": [
|
"files": [
|
||||||
"command.js",
|
"command.js",
|
||||||
"lib",
|
"lib",
|
||||||
@@ -34,6 +34,7 @@
|
|||||||
"@rollup/plugin-commonjs": "19.0.0",
|
"@rollup/plugin-commonjs": "19.0.0",
|
||||||
"@rollup/plugin-node-resolve": "13.0.0",
|
"@rollup/plugin-node-resolve": "13.0.0",
|
||||||
"@rollup/plugin-replace": "2.4.2",
|
"@rollup/plugin-replace": "2.4.2",
|
||||||
|
"extend": "3.0.2",
|
||||||
"fs-extra": "10.0.0",
|
"fs-extra": "10.0.0",
|
||||||
"node-event-emitter": "0.0.1",
|
"node-event-emitter": "0.0.1",
|
||||||
"rollup": "2.50.6",
|
"rollup": "2.50.6",
|
||||||
|
|||||||
Reference in New Issue
Block a user