Skip to content

Commit 48daee4

Browse files
committed
♻️ refactor: cli improvement, some renamings
1 parent fa49b8f commit 48daee4

5 files changed

Lines changed: 29 additions & 26 deletions

File tree

cli/index.js

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,33 +21,38 @@ const options = parseArgs(process.argv.slice(2),{
2121
number: ['tNumber'],
2222
});
2323

24-
(() => {
25-
const [command] = options._;
26-
if(command === 'help' || !command) {
27-
console.info('Available commands:');
28-
Object.entries(COMMAND_DESCRIPTION).forEach(([key, value]) => {
29-
console.info(` ${key} - ${value}\n`);
30-
});
31-
32-
return;
33-
}
24+
const showHelp = () => {
25+
console.info('Available commands:');
26+
Object.entries(COMMAND_DESCRIPTION).forEach(([key, value]) => {
27+
console.info(` ${key} - ${value}\n`);
28+
});
29+
};
3430

31+
(() => {
3532
if (options.interactive) {
3633
const importJsx = require('import-jsx');
3734
importJsx('./Components/App');
38-
} else {
35+
process.exit(0);
36+
}
37+
38+
const [command] = options._;
39+
if(command === 'help') {
40+
showHelp();
41+
process.exit(0);
42+
}
43+
44+
if (command) {
3945
if(options.help) {
4046
console.info(HELP_COMMANDS[command]);
41-
return;
47+
process.exit(0);
4248
}
4349
scripts[command](options).then(() => {
4450
console.info(`"${command}" command run successfully.`);
4551
process.exit(0);
4652
}).catch((error) => {
47-
console.error(error, `An error has occured while running transformation (${command}).`);
53+
console.error(error, `An error has occured while running command (${command}).`);
4854
process.exit(1);
4955
});
5056
}
51-
})();
52-
5357

58+
})();

examples/serverless-localstack/data-transformations/UsersExample/v2_add_random_number_field.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,5 @@ const transformDown = async ({ ddb, isDryRun }) => {
2222
module.exports = {
2323
transformUp,
2424
transformDown,
25-
// prepare, // pass this function only if you need preparation data for the transformation
2625
transformationNumber: 2,
2726
};

examples/serverless-localstack/serverless.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@ provider:
1717
PREPARATION_DATA_BUCKET: transformations-preparation-data-${self:provider.stage}
1818

1919
plugins:
20-
- serverless-localstack
21-
- serverless-manifest-plugin
22-
- serverless-dotenv-plugin
23-
- serverless-pseudo-parameters
24-
- dynamo-data-transform
25-
20+
- serverless-localstack
21+
- serverless-manifest-plugin
22+
- serverless-dotenv-plugin
23+
- serverless-pseudo-parameters
24+
- dynamo-data-transform
2625
custom:
2726
localstack:
2827
hostname:

serverless-plugin/commands.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ module.exports = {
3939
},
4040
},
4141
prepare: {
42-
usage: `"sls dynamodt prepare --table {{TABLE_NAME}} --tNumber 1" - ${COMMAND_DESCRIPTION.prepare}`,
42+
usage: `"sls dynamodt prepare --table <table> --tNumber <transformation_number>" - ${COMMAND_DESCRIPTION.prepare}`,
4343
lifecycleEvents: ['prepare'],
4444
options: {
4545
tNumber: COMMAND_OPTIONS.tNumber,
@@ -48,15 +48,15 @@ module.exports = {
4848
},
4949
},
5050
down: {
51-
usage: `sls dynamodt down --table {{TABLE_NAME}} - ${COMMAND_DESCRIPTION.down}`,
51+
usage: `sls dynamodt down --table <table> - ${COMMAND_DESCRIPTION.down}`,
5252
lifecycleEvents: ['rollback'],
5353
options: {
5454
table: COMMAND_OPTIONS.table,
5555
dry: COMMAND_OPTIONS.dry,
5656
},
5757
},
5858
history: {
59-
usage: `sls dynamodt history --table {{TABLE_NAME}} - ${COMMAND_DESCRIPTION.history}`,
59+
usage: `sls dynamodt history --table <table> - ${COMMAND_DESCRIPTION.history}`,
6060
lifecycleEvents: ['history'],
6161
options: {
6262
table: COMMAND_OPTIONS.table,

src/config/transformation-template-file.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const transformDown = async ({ ddb, isDryRun }) => {
2929
module.exports = {
3030
transformUp,
3131
transformDown,
32-
// prepare, // pass this function only if you need preparation data for the transformation
32+
// prepare, // export this function only if you need preparation data for the transformation
3333
transformationNumber: 1,
3434
};
3535

0 commit comments

Comments
 (0)