Skip to content

Commit 980aeff

Browse files
author
Christophe Bougère
committed
renaming command to sls validate stepf
1 parent cc205f2 commit 980aeff

File tree

3 files changed

+22
-18
lines changed

3 files changed

+22
-18
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,10 @@ $ sls invoke stepf --name <stepfunctionname> --data '{"foo":"bar"}'
260260
- --data or -d String data to be passed as an event to your step function.
261261
- --path or -p The path to a json file with input data to be passed to the invoked step function.
262262
263-
### validate-state-machines
263+
### validate
264264
This command allows you to validate the definition of your state machine(s). Validation is done by [asl-validator](https://www.npmjs.com/package/asl-validator).
265265
```
266-
$ sls validate-state-machines [--name <stepfunctionname>]
266+
$ sls validate stepf [--name <stepfunctionname>]
267267
```
268268
269269
#### options

lib/index.js

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,19 @@ class ServerlessStepFunctions {
8282
},
8383
},
8484
},
85-
'validate-state-machines': {
86-
usage: 'Validate state machine definitions',
87-
lifecycleEvents: [
88-
'validate',
89-
],
90-
options: {
91-
name: {
92-
usage: 'The StateMachine name (validate all state machines if not specified)',
93-
shortcut: 'n',
85+
validate: {
86+
commands: {
87+
stepf: {
88+
usage: 'Validate step function state machine definitions',
89+
lifecycleEvents: [
90+
'validate',
91+
],
92+
options: {
93+
name: {
94+
usage: 'The StateMachine name (validate all state machines if not specified)',
95+
shortcut: 'n',
96+
},
97+
},
9498
},
9599
},
96100
},
@@ -100,9 +104,9 @@ class ServerlessStepFunctions {
100104
'invoke:stepf:invoke': () => BbPromise.bind(this)
101105
.then(this.yamlParse)
102106
.then(this.invoke),
103-
'validate-state-machines:validate': () => BbPromise.bind(this)
107+
'validate:stepf:validate': () => BbPromise.bind(this)
104108
.then(this.yamlParse)
105-
.then(this.validateStateMachines),
109+
.then(this.validate),
106110
'package:initialize': () => BbPromise.bind(this)
107111
.then(this.yamlParse),
108112
'package:compileFunctions': () => BbPromise.bind(this)
@@ -152,7 +156,7 @@ class ServerlessStepFunctions {
152156
});
153157
}
154158

155-
validateStateMachines() {
159+
validate() {
156160
this.serverless.cli.consoleLog('Validating state machines definition...');
157161
const stateMachines = (this.options.name && [this.options.name]) ||
158162
Object.keys(this.serverless.service.stepFunctions.stateMachines);

lib/index.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ describe('#index', () => {
369369
});
370370
});
371371

372-
describe('#validateStateMachines()', () => {
372+
describe('#validate()', () => {
373373
let consoleLogStub;
374374

375375
beforeEach(() => {
@@ -397,7 +397,7 @@ describe('#index', () => {
397397
},
398398
},
399399
};
400-
serverlessStepFunctions.validateStateMachines();
400+
serverlessStepFunctions.validate();
401401
// would have thrown if definition was invalid
402402
expect(consoleLogStub.calledTwice).to.equal(true);
403403
});
@@ -419,7 +419,7 @@ describe('#index', () => {
419419
},
420420
},
421421
};
422-
expect(() => serverlessStepFunctions.validateStateMachines())
422+
expect(() => serverlessStepFunctions.validate())
423423
.to.throw(serverlessStepFunctions.serverless.classes.Error, expectedErrorMessage);
424424
expect(consoleLogStub.calledTwice).to.equal(true);
425425
});
@@ -431,7 +431,7 @@ describe('#index', () => {
431431
serverlessStepFunctions.serverless.service.stepFunctions = {
432432
stateMachines: {},
433433
};
434-
expect(() => serverlessStepFunctions.validateStateMachines())
434+
expect(() => serverlessStepFunctions.validate())
435435
.to.throw(serverlessStepFunctions.serverless.classes.Error, expectedErrorMessage);
436436
expect(consoleLogStub.calledOnce).to.equal(true);
437437
});

0 commit comments

Comments
 (0)