Merge pull request #635 from datopian/update/cli
Refactor cli app into portal.js
This commit is contained in:
commit
a575061f7a
104
bin/.gitignore
vendored
Normal file
104
bin/.gitignore
vendored
Normal file
@ -0,0 +1,104 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# TypeScript v1 declaration files
|
||||
typings/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and *not* Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
@ -1,9 +1,8 @@
|
||||
# portal-cli-app
|
||||
Simple CLI for displaying and publishing datasets
|
||||
|
||||
## Features
|
||||
|
||||
### Show
|
||||
|
||||
Easily preview data locally.
|
||||
I have a dataset `my-data` with the following content:
|
||||
```
|
||||
@ -18,9 +17,6 @@ cd my-data
|
||||
portal show
|
||||
```
|
||||
I get a nice dataset page like:
|
||||
|
||||
TODO
|
||||
|
||||
The single show command gives me access to the following:
|
||||
|
||||
* Elegant presentation
|
||||
@ -30,54 +26,46 @@ The single show command gives me access to the following:
|
||||
* Data summary
|
||||
|
||||
Show works with:
|
||||
|
||||
* README + csv
|
||||
* Frictionless dataset
|
||||
* Frictionless resource
|
||||
* Pure README with frontmatter
|
||||
|
||||
|
||||
### Deploy [Not implemented yet]
|
||||
|
||||
Easily publish your dataset online.
|
||||
|
||||
If i have a dataset `my_data`:
|
||||
|
||||
```
|
||||
cd my-data
|
||||
portal deploy
|
||||
```
|
||||
|
||||
Gives me a url like:
|
||||
|
||||
`Myusername-my-dataset.datahub.io`
|
||||
|
||||
Deploy: what does it do?
|
||||
|
||||
* Deploys a shareable url with the content of show
|
||||
* Semi-private
|
||||
* Can integrate access control (?)
|
||||
* Semi-private
|
||||
* Can integrate access control (?)
|
||||
* Deploys a data API
|
||||
* [Other integrations e.g. push to google spreadsheets]
|
||||
* Dashboard showing your DataHub/Portal projects
|
||||
|
||||
|
||||
## User Guide
|
||||
|
||||
Install portal-cli-app globally on your computer
|
||||
|
||||
```bash
|
||||
npm install -g git+https://github.com/datopian/portal-experiment.git
|
||||
```
|
||||
|
||||
> Note: It is recommended you install portal-cli-app globally so you can run the portal show command from anywhere in your computer.
|
||||
>Note: It is recommended you install portal-cli-app globally so you can run the portal show command from anywhere in your computer.
|
||||
|
||||
In a folder with your dataset and optionally datapackage.json, run the command:
|
||||
|
||||
```bash
|
||||
portal show
|
||||
```
|
||||
|
||||
You can also specify a folder from directory:
|
||||
|
||||
```bash
|
||||
portal show path=\some\path\dataset
|
||||
```
|
||||
@ -90,4 +78,4 @@ Optional args you can pass yo the show command are:
|
||||
|
||||
```
|
||||
portal show [path=/some/path/dataset | port=4000 | npm=true]
|
||||
```
|
||||
```
|
||||
@ -5,7 +5,7 @@ const chalk = require('chalk')
|
||||
const path = require('path')
|
||||
const figlet = require('figlet')
|
||||
const { exec } = require('child_process');
|
||||
const package = require('../package.json')
|
||||
const package = require('./package.json')
|
||||
const fs = require('fs')
|
||||
|
||||
|
||||
@ -80,9 +80,10 @@ async function run() {
|
||||
const portalGithubRepo = "https://github.com/datopian/portal-experiment.git"
|
||||
const portalLocalRepoDirectory = path.join(datasetPath, 'portal-experiment')
|
||||
|
||||
const cloneRepoCmd = `cd ${datasetPath} &&
|
||||
export PORTAL_DATASET_PATH=${datasetPath} &&
|
||||
git clone ${portalGithubRepo}`
|
||||
const cloneRepoCmd = `cd ${datasetPath} && git clone ${portalGithubRepo}`
|
||||
|
||||
// CD into portalLocalRepoDirectory, create an .env file and write PORTAL_DATASET_PATH={datasetPath} to it
|
||||
const createEnvFileCmd = `cd ${portalLocalRepoDirectory} && touch .env && echo PORTAL_DATASET_PATH=${datasetPath} >> .env`
|
||||
|
||||
const buildNextAppCmd = userArgs.npm ? `cd ${portalLocalRepoDirectory} && npm install && npm run build` :
|
||||
`cd ${portalLocalRepoDirectory} && yarn && yarn build`
|
||||
@ -111,7 +112,11 @@ async function run() {
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'Preparing your app...',
|
||||
title: 'Preparing app environment',
|
||||
task: async () => {await execShellCommand(createEnvFileCmd)},
|
||||
},
|
||||
{
|
||||
title: 'Building app...',
|
||||
task: async () => { await execShellCommand(buildNextAppCmd) }
|
||||
},
|
||||
{
|
||||
28
bin/package.json
Normal file
28
bin/package.json
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"name": "portal-cli-app",
|
||||
"version": "1.0.0",
|
||||
"description": "Simple CLI for displaying and publishing dataset pages",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"chalk": "^4.1.0",
|
||||
"commander": "^6.2.0",
|
||||
"cpy": "^8.1.1",
|
||||
"cross-spawn": "^7.0.3",
|
||||
"figlet": "^1.5.0",
|
||||
"listr": "^0.14.3",
|
||||
"open": "^8.0.2",
|
||||
"ora": "^5.1.0",
|
||||
"prompts": "^2.4.0"
|
||||
},
|
||||
"files": [
|
||||
"bin"
|
||||
],
|
||||
"bin": {
|
||||
"datahub": "index.js"
|
||||
}
|
||||
}
|
||||
1577
bin/yarn.lock
Normal file
1577
bin/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
@ -48,5 +48,12 @@
|
||||
"rollup": "^2.45.2",
|
||||
"rollup-plugin-delete": "^2.0.0",
|
||||
"rollup-plugin-peer-deps-external": "^2.2.4"
|
||||
},
|
||||
"files": [
|
||||
"bin",
|
||||
"dist"
|
||||
],
|
||||
"bin": {
|
||||
"datahub": "bin/index.js"
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user