Skip to content

Commit b780ad2

Browse files
committed
Merge branch 'master' of https://github.com/datahq/datahub-cli
2 parents 8c3e519 + f3d5a89 commit b780ad2

File tree

4 files changed

+53
-45
lines changed

4 files changed

+53
-45
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ data push # upload the dataset onto a DataHub
1111
> "As a result you'll got a link to share:
1212
http://datahub.io/user-name/data-package-name
1313
```
14-
That's it! Your data is online. You can make your data public or private, add some pretty graphics, and many more. Please read http://datahub.io/docs for details.
14+
That's it! Your data is online. You can make your data unlisted or private, add some pretty graphics, and many more. Please read http://datahub.io/docs for details.
1515
1616
With `data-cli` you can also:
1717
* Get data from online sources
@@ -46,7 +46,7 @@ Mydataset Mydataset
4646
your data is published!
4747
🔗 https://datahub.io/myname/mydataset/v/1 (copied to clipboard)
4848
```
49-
**Note:** by default, findability flag for your dataset is set to `--unlisted`, meaning nobody else is able to see it, except you. Use `--public` flag to make it publicly available
49+
**Note:** by default, findability flag for your dataset is set to `--public`. Use `--unlisted` flag if you want it to not appear in the search results.
5050
5151
### [data get](https://github.com/datahq/data-cli/blob/master/docs/get.md)
5252

bin/data-push.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const info = require('../lib/utils/output/info.js')
2222

2323
const argv = minimist(process.argv.slice(2), {
2424
string: ['push', 'sheets'],
25-
boolean: ['help', 'test', 'debug', 'interactive', 'published', 'private', 'zip', 'sqlite'],
25+
boolean: ['help', 'test', 'debug', 'interactive', 'unlisted', 'private', 'zip', 'sqlite'],
2626
alias: {help: 'h', interactive: 'i', sheets: 'sheet'}
2727
})
2828

@@ -91,9 +91,9 @@ Promise.resolve().then(async () => {
9191
ownerid: config.get('profile') ? config.get('profile').id : config.get('id'),
9292
owner: config.get('profile') ? config.get('profile').username : config.get('username')
9393
}
94-
let findability = 'unlisted'
95-
if (argv.published || argv.publish || argv.public) {
96-
findability = 'published'
94+
let findability = 'published'
95+
if (argv.unlisted) {
96+
findability = 'unlisted'
9797
}
9898
if (argv.private) {
9999
findability = 'private'
@@ -146,7 +146,7 @@ Promise.resolve().then(async () => {
146146
})
147147
}
148148
})
149-
149+
150150
const res = await datahub.push(dataset, options)
151151
// Analytics:
152152
if (process.env.datahub !== 'dev') {
@@ -168,7 +168,7 @@ Promise.resolve().then(async () => {
168168
// Print success message and provide URL to showcase page:
169169
let revisionId = res.flow_id.split('/').pop()
170170
const message = '\n🙌 your data is published!\n'
171-
const url = urljoin(config.get('domain'), datahubConfigs.owner, dataset.descriptor.name,'v',revisionId,'?source=cli')
171+
const url = urljoin(config.get('domain'), datahubConfigs.owner, dataset.descriptor.name, 'v', revisionId)
172172
let copied = ' (copied to clipboard)'
173173
try {
174174
await copyToClipboard(url)

docs/push.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
11

22
■ data push [PATH]
3-
3+
44
`PATH` (optional) is the path to the data file or data package.
55

66
## Options:
77

88
-h, --help Output usage information.
9-
10-
--format Explicitely set the format for a file. Useful when a file does not have conventional
9+
10+
--format Explicitly set the format for a file. Useful when a file does not have conventional
1111
naming. E.g., `--format=csv`
12-
12+
1313
-i, --interactive Enable interactive mode. Useful when pushing a single file.
14-
15-
--schedule Setup a schedule so the DataHub will automatically re-import the remote file on
16-
a regular basis. E.g., `every 90s`, `every 5m`, `every 2d`. The number is always
17-
an integer, selector is `s/m/h/d/w` (second -> week) and you can’t schedule for
14+
15+
--schedule Setup a schedule so the DataHub will automatically re-import the remote file on
16+
a regular basis. E.g., `every 90s`, `every 5m`, `every 2d`. The number is always
17+
an integer, selector is `s/m/h/d/w` (second -> week) and you can’t schedule for
1818
less than 60 seconds.
19-
20-
--sheets Set which sheets should be processed when pushing Excel files. By default, only
19+
20+
--sheets Set which sheets should be processed when pushing Excel files. By default, only
2121
the first sheet is processed. You can use `--sheets=all` option to push "all" sheets.
22-
You also can list sheet numbers, e.g., `--sheets=1,2`. If you wanted to push only
22+
You also can list sheet numbers, e.g., `--sheets=1,2`. If you wanted to push only
2323
the second sheet, you would do `--sheets=2`. Sheet number starts from 1.
2424

2525
### findability options:
2626

2727
This options define the dataset visibility on the DataHub.io site:
2828

29-
--unlisted (default) Other users will not see the dataset in the search results.
30-
You will see the dataset in the search results.
29+
--public (default) Everybody can see the dataset in the search results.
3130
Everybody can access the dataset by the URL link.
3231

33-
--public Everybody can see the dataset in the search results.
32+
--unlisted Other users will not see the dataset in the search results.
33+
You will see the dataset in the search results.
3434
Everybody can access the dataset by the URL link.
3535

3636
--private Other users cannot access the dataset.
@@ -47,14 +47,14 @@ Uploads Data Package to DataHub with path (core/finance-vix/ should have datapac
4747

4848
■ data push core/finance-vix/
4949

50-
By default, all pushed datasets are unlisted. To make them published:
50+
By default, all pushed datasets are public. To make them unlisted:
51+
52+
■ data push core/finance-vix/ --unlisted
5153

52-
■ data push core/finance-vix/ --published
53-
5454
Uploads a file from URL to DataHub on weekly basis and sets file format as CSV:
5555

5656
■ data push URL --schedule="every 1w" --format=csv
57-
57+
5858
Uploads a Excel file and processes only the second sheet:
5959

6060
■ data push myExcel.xlsx --sheets=2

test/push/push.test.js

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -256,17 +256,17 @@ test('push command for empty files: no ext, html, txt, json', async t => {
256256
let args = '--name=empty-no-extension'
257257
let result = await runcli('push', path_, args)
258258
let stdout = result.stdout.split('\n')
259-
let hasErrorMessage = stdout.find(item => item.includes('You can not push empty files, please add some data and try again'))
260-
let hasPathToFile = stdout.find(item => item.includes('test/fixtures/test-data/files/empty-files/'))
261-
t.truthy(hasErrorMessage)
262-
t.truthy(hasPathToFile)
259+
let hasPublishedMessage = stdout.find(item => item.includes('your data is published!'))
260+
let hasURLtoShowcase = stdout.find(item => item.includes('https://datahub.io/test/empty-no-extension/v/'))
261+
t.truthy(hasPublishedMessage)
262+
t.truthy(hasURLtoShowcase)
263263

264264
path_ = 'test/fixtures/test-data/files/empty-files/empty.html'
265265
args = '--name=empty-html'
266266
result = await runcli('push', path_, args)
267267
stdout = result.stdout.split('\n')
268-
let hasPublishedMessage = stdout.find(item => item.includes('your data is published!'))
269-
let hasURLtoShowcase = stdout.find(item => item.includes('https://datahub.io/test/empty-html/v/'))
268+
hasPublishedMessage = stdout.find(item => item.includes('your data is published!'))
269+
hasURLtoShowcase = stdout.find(item => item.includes('https://datahub.io/test/empty-html/v/'))
270270
t.truthy(hasPublishedMessage)
271271
t.truthy(hasURLtoShowcase)
272272
let whatsInClipboard = await clipboardy.read()
@@ -276,10 +276,10 @@ test('push command for empty files: no ext, html, txt, json', async t => {
276276
args = '--name=empty-txt'
277277
result = await runcli('push', path_, args)
278278
stdout = result.stdout.split('\n')
279-
hasErrorMessage = stdout.find(item => item.includes('You can not push empty files, please add some data and try again'))
280-
hasPathToFile = stdout.find(item => item.includes('test/fixtures/test-data/files/empty-files/'))
281-
t.truthy(hasErrorMessage)
282-
t.truthy(hasPathToFile)
279+
hasPublishedMessage = stdout.find(item => item.includes('your data is published!'))
280+
hasURLtoShowcase = stdout.find(item => item.includes('https://datahub.io/test/empty-txt/v/'))
281+
t.truthy(hasPublishedMessage)
282+
t.truthy(hasURLtoShowcase)
283283

284284
path_ = 'test/fixtures/test-data/files/empty-files/empty.json'
285285
args = '--name=empty-json'
@@ -318,8 +318,10 @@ test('push command fails for zero byte files', async t => {
318318
let args = '--name=zero'
319319
let result = await runcli('push', path_, args)
320320
let stdout = result.stdout.split('\n')
321-
let hasErrorMsg = stdout.find(item => item.includes('> You can not push empty files, please add some data and try again'))
322-
t.truthy(hasErrorMsg)
321+
let hasPublishedMessage = stdout.find(item => item.includes('your data is published!'))
322+
let hasURLtoShowcase = stdout.find(item => item.includes('https://datahub.io/test/zero/v/'))
323+
t.truthy(hasPublishedMessage)
324+
t.truthy(hasURLtoShowcase)
323325

324326
path_ = 'test/fixtures/test-data/files/zero-files/zero.csv'
325327
result = await runcli('push', path_, args)
@@ -329,25 +331,31 @@ test('push command fails for zero byte files', async t => {
329331
path_ = 'test/fixtures/test-data/files/zero-files/zero.html'
330332
result = await runcli('push', path_, args)
331333
stdout = result.stdout.split('\n')
332-
hasErrorMsg = stdout.find(item => item.includes('> You can not push empty files, please add some data and try again'))
333-
t.truthy(hasErrorMsg)
334+
hasPublishedMessage = stdout.find(item => item.includes('your data is published!'))
335+
hasURLtoShowcase = stdout.find(item => item.includes('https://datahub.io/test/zero/v/'))
336+
t.truthy(hasPublishedMessage)
337+
t.truthy(hasURLtoShowcase)
334338

335339
path_ = 'test/fixtures/test-data/files/zero-files/zero.txt'
336340
result = await runcli('push', path_, args)
337341
stdout = result.stdout.split('\n')
338-
hasErrorMsg = stdout.find(item => item.includes('> You can not push empty files, please add some data and try again'))
339-
t.truthy(hasErrorMsg)
342+
hasPublishedMessage = stdout.find(item => item.includes('your data is published!'))
343+
hasURLtoShowcase = stdout.find(item => item.includes('https://datahub.io/test/zero/v/'))
344+
t.truthy(hasPublishedMessage)
345+
t.truthy(hasURLtoShowcase)
340346

341347
path_ = 'test/fixtures/test-data/files/zero-files/zero.json'
342348
result = await runcli('push', path_, args)
343349
stdout = result.stdout.split('\n')
344-
hasErrorMsg = stdout.find(item => item.includes('> You can not push empty files, please add some data and try again'))
345-
t.truthy(hasErrorMsg)
350+
hasPublishedMessage = stdout.find(item => item.includes('your data is published!'))
351+
hasURLtoShowcase = stdout.find(item => item.includes('https://datahub.io/test/zero/v/'))
352+
t.truthy(hasPublishedMessage)
353+
t.truthy(hasURLtoShowcase)
346354

347355
path_ = 'test/fixtures/test-data/files/zero-files/zero.xls'
348356
result = await runcli('push', path_, args)
349357
stdout = result.stdout.split('\n')
350-
hasErrorMsg = stdout.find(item => item.includes('> You can not push empty files, please add some data and try again'))
358+
let hasErrorMsg = stdout.find(item => item.includes('You can not push empty files, please add some data and try again'))
351359
t.truthy(hasErrorMsg)
352360
})
353361

0 commit comments

Comments
 (0)