Skip to content

Commit

Permalink
feat: init
Browse files Browse the repository at this point in the history
  • Loading branch information
zivyangll committed Sep 18, 2019
0 parents commit 30828b8
Show file tree
Hide file tree
Showing 15 changed files with 536 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
coverage
node_modules
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ['antife', 'prettier'],
};
217 changes: 217 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
# Created by https://www.gitignore.io/api/vim,node,code,webstorm,sublimetext

### Code ###
# Visual Studio Code - https://code.visualstudio.com/
.settings/
.vscode/
tsconfig.json
jsconfig.json

### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# 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

# 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/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless

### SublimeText ###
# Cache files for Sublime Text
*.tmlanguage.cache
*.tmPreferences.cache
*.stTheme.cache

# Workspace files are user-specific
*.sublime-workspace

# Project files should be checked into the repository, unless a significant
# proportion of contributors will probably not be using Sublime Text
# *.sublime-project

# SFTP configuration file
sftp-config.json

# Package control specific files
Package Control.last-run
Package Control.ca-list
Package Control.ca-bundle
Package Control.system-ca-bundle
Package Control.cache/
Package Control.ca-certs/
Package Control.merged-ca-bundle
Package Control.user-ca-bundle
oscrypto-ca-bundle.crt
bh_unicode_properties.cache

# Sublime-github package stores a github token in this file
# https://packagecontrol.io/packages/sublime-github
GitHub.sublime-settings

### Vim ###
# Swap
[._]*.s[a-v][a-z]
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]

# Session
Session.vim

# Temporary
.netrwhist
*~
# Auto-generated tag files
tags
# Persistent undo
[._]*.un~

### WebStorm ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/modules.xml
# .idea/*.iml
# .idea/modules

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### WebStorm Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721

# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr

# Sonarlint plugin
.idea/sonarlint


# End of https://www.gitignore.io/api/vim,node,code,webstorm,sublimetext
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "es5"
}
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
sudo: false
language: node_js
node_js:
- '8'
script:
- npm run ci
after_success:
- npm i codecov && codecov
Empty file added CHANGELOG.md
Empty file.
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# datahub-import-json

[![NPM version][npm-image]][npm-url]
[![Build status][travis-image]][travis-url]
[![Coverage status][codecov-image]][codecov-url]
[![Dependency status][daviddm-image]][daviddm-url]

> Upload all files below the mock file to DataHub
## Installment

```bash
$ npm i datahub-import-json -g
```

## Usage

```bash
$ datahub-import-json test-project -d /Users/xxx/mock -s http://127.0.0.1:5678
```

## Configuration

```bash
$ datahub-import-json projectName
```

| param | description | default |
| -- | -- | -- |
| -s | DataHub server address | http://127.0.0.1:5678 |
| -d | mock data directory path | - |
| --mockSuffix | set mock file suffix | .json |
| --interfaceSuffix | DataHub interface suffix | .json |

---

## License

[MIT](http://opensource.org/licenses/MIT)

[npm-image]: https://img.shields.io/npm/v/datahub-import-json.svg?style=flat-square&logo=npm
[npm-url]: https://npmjs.org/package/datahub-import-json
[travis-image]: https://img.shields.io/travis/zivyangll/datahub-import-json/master.svg?style=flat-square&logo=travis
[travis-url]: https://travis-ci.org/zivyangll/datahub-import-json
[codecov-image]: https://img.shields.io/codecov/c/github/zivyangll/datahub-import-json/master.svg?style=flat-square&logo=javascript
[codecov-url]: https://codecov.io/gh/zivyangll/datahub-import-json
[daviddm-image]: https://img.shields.io/david/zivyangll/datahub-import-json.svg?style=flat-square
[daviddm-url]: https://david-dm.org/zivyangll/datahub-import-json
42 changes: 42 additions & 0 deletions bin/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env node

const cli = require('cac')();
const updateNotifier = require('update-notifier');
const pkg = require('../package.json');
const datahubImportJson = require('../lib/index');

updateNotifier({
pkg,
updateCheckInterval: 5000, // 5s
}).notify();

cli
.command('<projectName>', 'Generate a new project to Datahub')
.option('-d, --mock-dir <mockDir>', 'mock dir')
.option('-s, --server <server>', 'DataHub server address', {
default: 'http://127.0.0.1:5678',
})
.option('--mockSuffix <mockSuffix>', 'set mock file suffix', {
default: '.json',
})
.option('--interfaceSuffix <interfaceSuffix>', 'DataHub interface suffix', {
default: '.json',
})
.action(async (projectName, options) => {
console.log('==============options============');
console.log(options);
console.log('=================================');

datahubImportJson({
projectName,
...options,
});
});

cli.on('command:!', () => {
if (!cli.args.length) cli.outputHelp();
});

cli.help();
cli.version(require('../package').version);
cli.parse();
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./lib/index');

0 comments on commit 30828b8

Please sign in to comment.