Skip to content

Commit dfbe8cf

Browse files
authored
Merge pull request #735 from particle-iot/fix/publish
Remove `--private` and `--public` args from `publish`
2 parents 75de28d + 461b2ad commit dfbe8cf

File tree

6 files changed

+10
-58
lines changed

6 files changed

+10
-58
lines changed

src/cli/publish.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,6 @@ module.exports = ({ commandProcessor, root }) => {
22
commandProcessor.createCommand(root, 'publish', 'Publish an event to the cloud', {
33
params: '<event> [data]',
44
options: {
5-
'private': {
6-
boolean: true,
7-
default: true,
8-
description: 'Publish to the private stream'
9-
},
10-
'public': {
11-
boolean: true,
12-
description: 'Publish to the public stream'
13-
},
145
'product': {
156
description: 'Publish to the given Product ID or Slug\'s stream'
167
}

src/cli/publish.test.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,9 @@ describe('Publish Command-Line Interface', () => {
2525
});
2626

2727
it('Parses options', () => {
28-
const argv = commandProcessor.parse(root, ['publish', 'my-event', '--private', '--public', '--product', '12345']);
28+
const argv = commandProcessor.parse(root, ['publish', 'my-event', '--product', '12345']);
2929
expect(argv.clierror).to.equal(undefined);
3030
expect(argv.params).to.eql({ event: 'my-event', data: undefined });
31-
expect(argv.private).to.equal(true);
32-
expect(argv.public).to.equal(true);
3331
expect(argv.product).to.equal('12345');
3432
});
3533

@@ -56,8 +54,6 @@ describe('Publish Command-Line Interface', () => {
5654
'Usage: particle publish [options] <event> [data]',
5755
'',
5856
'Options:',
59-
' --private Publish to the private stream [boolean] [default: true]',
60-
' --public Publish to the public stream [boolean]',
6157
' --product Publish to the given Product ID or Slug\'s stream [string]',
6258
'',
6359
'Examples:',

src/cmd/api.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,13 @@ module.exports = class ParticleApi {
209209
);
210210
}
211211

212-
publishEvent(name, data, isPrivate, product){
212+
publishEvent(name, data, product){
213213
return this._wrap(
214214
this.api.publishEvent({
215215
name,
216216
data,
217217
product,
218-
isPrivate,
218+
isPrivate: true,
219219
auth: this.accessToken
220220
})
221221
);

src/cmd/publish.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,14 @@ module.exports = class PublishCommand extends CLICommandBase {
1111
super(...args);
1212
}
1313

14-
publishEvent({ private: isPrivate, public: isPublic, product, params: { event, data } }){
15-
isPrivate = (isPublic && !product) ? false : isPrivate; // `isPrivate: true` by default see: src/cli/publish.js
16-
const visibility = isPrivate ? 'private' : 'public';
17-
let epilogue = `${visibility} event: ${event}`;
14+
publishEvent({ product, params: { event, data } }){
15+
let epilogue = `private event: ${event}`;
1816

1917
if (product){
2018
epilogue += ` to product: ${product}`;
2119
}
2220

23-
const publishEvent = createAPI().publishEvent(event, data, isPrivate, product);
21+
const publishEvent = createAPI().publishEvent(event, data, product);
2422
return this.ui.showBusySpinnerUntilResolved(`Publishing ${epilogue}`, publishEvent)
2523
.then(() => this.ui.stdout.write(`Published ${epilogue}${os.EOL}${os.EOL}`))
2624
.catch(error => {

src/lib/api-client.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ module.exports = class ApiClient {
946946
});
947947
}
948948

949-
publishEvent(eventName, data, setPrivate){
949+
publishEvent(eventName, data){
950950
const { request, _access_token: token } = this;
951951
let self = this;
952952

@@ -959,7 +959,7 @@ module.exports = class ApiClient {
959959
name: eventName,
960960
data: data,
961961
access_token: token,
962-
private: setPrivate
962+
private: true
963963
}
964964
};
965965

@@ -977,11 +977,7 @@ module.exports = class ApiClient {
977977
return reject(body);
978978
}
979979

980-
console.log(
981-
`Published ${setPrivate ? 'private' : 'public'}`,
982-
'event:',
983-
eventName
984-
);
980+
console.log(`Published private event: ${eventName}`);
985981
console.log('');
986982
resolve(body);
987983
});

test/e2e/publish.e2e.js

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ describe('Publish Commands', () => {
1515
' -q, --quiet Decreases how much logging to display [count]',
1616
'',
1717
'Options:',
18-
' --private Publish to the private stream [boolean] [default: true]',
19-
' --public Publish to the public stream [boolean]',
2018
' --product Publish to the given Product ID or Slug\'s stream [string]',
2119
'',
2220
'Examples:',
@@ -66,24 +64,6 @@ describe('Publish Commands', () => {
6664
expect(exitCode).to.equal(0);
6765
});
6866

69-
it('Publishes a private event', async () => {
70-
const args = ['publish', eventName, '--private'];
71-
const { stdout, stderr, exitCode } = await cli.run(args);
72-
73-
expect(stdout).to.include(`Published private event: ${eventName}${os.EOL}`);
74-
expect(stderr).to.equal('');
75-
expect(exitCode).to.equal(0);
76-
});
77-
78-
it('Publishes a public event', async () => {
79-
const args = ['publish', eventName, '--public'];
80-
const { stdout, stderr, exitCode } = await cli.run(args);
81-
82-
expect(stdout).to.include(`Published public event: ${eventName}${os.EOL}`);
83-
expect(stderr).to.equal('');
84-
expect(exitCode).to.equal(0);
85-
});
86-
8767
it('Publishes a product event', async () => {
8868
const args = ['publish', eventName, '--product', PRODUCT_01_ID];
8969
const { stdout, stderr, exitCode } = await cli.run(args);
@@ -94,16 +74,7 @@ describe('Publish Commands', () => {
9474
});
9575

9676
it('Publishes a private product event', async () => {
97-
const args = ['publish', eventName, '--product', PRODUCT_01_ID, '--private'];
98-
const { stdout, stderr, exitCode } = await cli.run(args);
99-
100-
expect(stdout).to.include(`Published private event: ${eventName} to product: ${PRODUCT_01_ID}${os.EOL}`);
101-
expect(stderr).to.equal('');
102-
expect(exitCode).to.equal(0);
103-
});
104-
105-
it('Ignores `--public` flag when publishing a product event', async () => {
106-
const args = ['publish', eventName, '--product', PRODUCT_01_ID, '--public'];
77+
const args = ['publish', eventName, '--product', PRODUCT_01_ID];
10778
const { stdout, stderr, exitCode } = await cli.run(args);
10879

10980
expect(stdout).to.include(`Published private event: ${eventName} to product: ${PRODUCT_01_ID}${os.EOL}`);

0 commit comments

Comments
 (0)