Skip to content

Commit 2d35cb0

Browse files
committed
Fix "arcli library" command from failing silently from node_modules presence in source directory, and cleanup destination by default.
1 parent 463b4b9 commit 2d35cb0

File tree

2 files changed

+42
-9
lines changed

2 files changed

+42
-9
lines changed

.core/.cli/commands/reactium/library/actions.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const run = require('gulp-run');
66
const globby = require('globby');
77
const op = require('object-path');
88
const prettier = require('prettier');
9+
const del = require('del');
910

1011
module.exports = spinner => {
1112
const message = text => {
@@ -15,6 +16,25 @@ module.exports = spinner => {
1516
};
1617

1718
return {
19+
no_node_modules: async ({ action, params, props }) => {
20+
const { source } = params;
21+
22+
if (!fs.existsSync(path.resolve(source, 'node_modules'))) return;
23+
24+
message(`Removing node_modules from source directory...`);
25+
26+
return del(path.resolve(source, 'node_modules'));
27+
},
28+
29+
clean: async ({ action, params, props }) => {
30+
const { destination } = params;
31+
32+
message(
33+
`Cleanup destination directory ${chalk.cyan(destination)}...`,
34+
);
35+
36+
return del(destination);
37+
},
1838
buildPackage: ({ action, params, props }) => {
1939
const { destination, newPackage, source } = params;
2040

@@ -61,15 +81,15 @@ module.exports = spinner => {
6181
});
6282
},
6383
create: async ({ action, params, props }) => {
64-
const { source, destination } = params;
84+
const { source, destination, verbosity = 0 } = params;
6585

6686
message(
6787
`Creating library from ${chalk.cyan(path.basename(source))}...`,
6888
);
6989

7090
const babel = new run.Command(
7191
`cross-env NODE_ENV=library babel "${source}" --out-dir "${destination}"`,
72-
{ verbosity: 0 },
92+
{ verbosity },
7393
);
7494

7595
return new Promise(resolve => babel.exec(null, () => resolve()));

.core/.cli/commands/reactium/library/index.js

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ const CONFORM = ({ input, props }) => {
109109
const pkg = op.get(output, 'newPackage', {});
110110

111111
switch (key) {
112+
case 'verbosity':
113+
output[key] = Math.max(Math.min(parseInt(val), 3), 0) || 0;
114+
break;
112115
case 'destination':
113116
case 'source':
114117
output[key] = formatsource(val, props);
@@ -195,13 +198,13 @@ const CONFORM = ({ input, props }) => {
195198
*/
196199
const HELP = () =>
197200
console.log(`
198-
Example:
199-
$ arcli library -s components/MyComponentLibrary -d cwd/lib -n MyComponentLibrary
200-
201-
When specifying the source [-d, --source] the following shortcuts are available:
202-
${chalk.cyan('components/')} The /.src/app/components source.
203-
${chalk.cyan('common-ui/')} The /.src/app/components/common-ui source.
204-
`);
201+
Example:
202+
$ arcli library -s components/MyComponentLibrary -d cwd/lib -n MyComponentLibrary
203+
204+
When specifying the source [-d, --source] the following shortcuts are available:
205+
${chalk.cyan('components/')} The /.src/app/components source.
206+
${chalk.cyan('common-ui/')} The /.src/app/components/common-ui source.
207+
`);
205208

206209
/**
207210
* FLAGS
@@ -213,6 +216,7 @@ const FLAGS = [
213216
'source',
214217
'destination',
215218
'version',
219+
'verbosity',
216220
'main',
217221
'author',
218222
'dependencies',
@@ -275,6 +279,11 @@ const SCHEMA_SOURCE = ({ params, props }) => {
275279
description: chalk.white('Destination:'),
276280
default: path.join('cwd', 'lib', name),
277281
},
282+
verbosity: {
283+
description: chalk.white('Verbosity [0-3] (0):'),
284+
default: 0,
285+
required: false,
286+
},
278287
},
279288
};
280289
};
@@ -469,6 +478,10 @@ const COMMAND = ({ program, props }) =>
469478
.option('-s, --source [source]', 'The library source.')
470479
.option('-d, --destination [destination]', 'The library destination.')
471480
.option('-V, --ver [version]', 'The version of the library.')
481+
.option(
482+
'-T, --verbosity [verbosity]',
483+
'The 0-3 verbosity of output. Default 0.',
484+
)
472485
.option('-m, --main [main]', 'The library entry point or main js file.')
473486
.option('-a, --author [author]', 'The library author.')
474487
.option('--dependencies [dependencies]', 'The library dependencies.')

0 commit comments

Comments
 (0)