Skip to content

Commit 9524e84

Browse files
author
John Dillick
committed
Fix argument handling for actinium update. Add -y,--confirm option to reactium and actinium update.
1 parent f7fbc96 commit 9524e84

File tree

7 files changed

+14
-49
lines changed

7 files changed

+14
-49
lines changed

arcli.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env node
1+
#!/usr/bin/env node --no-warnings
22

33
'use strict';
44

commands/actinium/update/index.js

+4-43
Original file line numberDiff line numberDiff line change
@@ -37,45 +37,6 @@ const DESC = 'Actinium: Update core';
3737
*/
3838
const CANCELED = 'Actinium update canceled!';
3939

40-
/**
41-
* confirm({ props:Object, params:Object }) Function
42-
* @description Prompts the user to confirm the operation
43-
* @since 2.0.0
44-
*/
45-
const CONFIRM = ({ props, params, msg }) => {
46-
const { prompt } = props;
47-
48-
msg = msg || chalk.white('Proceed?');
49-
50-
return new Promise((resolve, reject) => {
51-
prompt.get(
52-
{
53-
properties: {
54-
confirmed: {
55-
description: `${msg} ${chalk.cyan('(Y/N):')}`,
56-
type: 'string',
57-
required: true,
58-
pattern: /^y|n|Y|N/,
59-
message: ` `,
60-
before: val => {
61-
return String(val).toUpperCase() === 'Y';
62-
},
63-
},
64-
},
65-
},
66-
(error, input = {}) => {
67-
const confirmed = op.get(input, 'confirmed', false);
68-
if (error || confirmed === false) {
69-
reject(error);
70-
} else {
71-
params['confirmed'] = true;
72-
resolve(params);
73-
}
74-
},
75-
);
76-
});
77-
};
78-
7940
/**
8041
* conform(input:Object) Function
8142
* @description Reduces the input object.
@@ -110,7 +71,7 @@ Example:
11071
* @description Array of flags passed from the commander options.
11172
* @since 2.0.18
11273
*/
113-
const FLAGS = ['overwrite'];
74+
const FLAGS = ['confirm'];
11475

11576
/**
11677
* FLAGS_TO_PARAMS Function
@@ -138,7 +99,7 @@ const FLAGS_TO_PARAMS = ({ opt = {} }) =>
13899
const SCHEMA = () => {
139100
return {
140101
properties: {
141-
overwrite: {
102+
confirm: {
142103
description: `${chalk.white(
143104
'Are you sure you want to update?',
144105
)} ${chalk.cyan('(Y/N):')}`,
@@ -196,8 +157,8 @@ const COMMAND = ({ program, props }) =>
196157
program
197158
.command(NAME)
198159
.description(DESC)
199-
.action(opt => ACTION({ opt, props }))
200-
.option('-o, --overwrite [overwrite]', 'Overwrite existing files.')
160+
.action((action, opt) => ACTION({ opt, props }))
161+
.option('-y, --confirm', 'Skip confirmation.')
201162
.on('--help', HELP);
202163

203164
/**

commands/cli/command/template/generator.js.hbs

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ module.exports = ({ params, props }) => {
2323
})
2424
.catch(error => {
2525
spinner.fail('error!');
26+
console.error(error);
2627
return error;
2728
});
2829
};

commands/reactium/install/generator.js

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ module.exports = ({ params, props }) => {
3636
return success;
3737
}).catch((error) => {
3838
spinner.fail('Reactium install error!');
39+
console.error(error);
3940
return error;
4041
});
4142
};

commands/reactium/update/generator.js

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ module.exports = ({ params, props }) => {
3030
return success;
3131
}).catch((error) => {
3232
spinner.fail('Reactium update error!');
33+
console.error(error);
3334
return error;
3435
});
3536
};

commands/reactium/update/index.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ const HELP = () => {
119119
*/
120120
const SCHEMA = {
121121
properties: {
122-
overwrite: {
122+
confirm: {
123123
description: `${chalk.white('Are you sure you want to update?')} ${chalk.cyan('(Y/N):')}`,
124124
before: (val) => {
125125
return (String(val).toLowerCase() === 'y');
@@ -164,10 +164,10 @@ const ACTION = ({ action, opt, props }) => {
164164
params['core'] = true;
165165
}
166166

167-
const { overwrite } = params;
167+
const { confirm } = params;
168168

169-
// Exit if overwrite or confirm !== true
170-
if (!overwrite) {
169+
// Exit if confirm !== true
170+
if (!confirm) {
171171
prompt.stop();
172172
message(CANCELED);
173173
return;
@@ -193,6 +193,7 @@ const COMMAND = ({ program, props }) => program.command(NAME)
193193
.option('-o, --overwrite [overwrite]', 'Overwrite the current directory.')
194194
.option('-e, --empty [empty]', 'Update without demo site and components.')
195195
.option('-c, --core [core]', 'Update the Reactium core only.')
196+
.option('-y, --confirm', 'Skip confirmation.')
196197
.on('--help', HELP);
197198

198199

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)