File tree Expand file tree Collapse file tree 4 files changed +47
-5
lines changed Expand file tree Collapse file tree 4 files changed +47
-5
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " algolia-index-update-scripts" ,
3
- "version" : " 0.1 .0" ,
4
- "description" : " This project reindexes algolia with the latest API documentation." ,
3
+ "version" : " 1.0 .0" ,
4
+ "description" : " This project reindexes algolia with the latest API & Guides documentation." ,
5
5
"main" : " index.js" ,
6
6
"scripts" : {
7
- "seed:api" : " node ./build/api.js" ,
8
7
"build" : " webpack" ,
9
- "start" : " yarn run build && yarn run seed" ,
8
+ "cli" : " node ./build/index.js" ,
9
+ "start" : " yarn run build && yarn run cli" ,
10
10
"test" : " "
11
11
},
12
12
"repository" : {
24
24
"babel-plugin-transform-object-rest-spread" : " ^6.26.0" ,
25
25
"bluebird" : " ^3.5.1" ,
26
26
"chalk" : " ^2.2.0" ,
27
+ "commander" : " ^2.17.1" ,
27
28
"dotenv" : " ^4.0.0" ,
28
29
"file-system" : " ^2.2.2" ,
29
30
"json-loader" : " ^0.5.7" ,
Original file line number Diff line number Diff line change
1
+ // Dependencies
2
+ import program from 'commander' ;
3
+ import packageJson from '../package.json' ;
4
+ // Library
5
+ import { run as runGuides } from './guides' ;
6
+ import { run as runApi } from './api' ;
7
+
8
+
9
+ program
10
+ . version ( packageJson . version , '-v, --version' )
11
+ . description ( packageJson . description )
12
+ . option ( '-p, --project <project>' , 'Project name. Accepts "api" or "guides"' ) ;
13
+
14
+ program . on ( '--help' , function ( ) {
15
+ console . log ( `
16
+ Examples:
17
+ $ yarn start -p api
18
+ $ yarn start -p guides
19
+ ` ) ;
20
+ } ) ;
21
+
22
+ program . parse ( process . argv ) ;
23
+
24
+ function cli ( ) {
25
+ switch ( program . project ) {
26
+ case 'guides' :
27
+ return runGuides ( ) ;
28
+ case 'api' :
29
+ return runApi ( ) ;
30
+ default :
31
+ throw new Error ( 'Invalid --project property' ) ;
32
+ }
33
+ }
34
+
35
+ cli ( ) ;
Original file line number Diff line number Diff line change @@ -2,7 +2,9 @@ const path = require('path');
2
2
3
3
module . exports = {
4
4
entry : {
5
- api : './src/api.js'
5
+ index : './src/index.js' ,
6
+ api : './src/api.js' ,
7
+ guides : './src/guides.js'
6
8
} ,
7
9
output : {
8
10
path : path . resolve ( __dirname , 'build' ) ,
Original file line number Diff line number Diff line change @@ -906,6 +906,10 @@ combined-stream@^1.0.5, combined-stream@~1.0.5:
906
906
dependencies :
907
907
delayed-stream "~1.0.0"
908
908
909
+ commander@^2.17.1 :
910
+ version "2.17.1"
911
+ resolved "https://registry.yarnpkg.com/commander/-/commander-2.17.1.tgz#bd77ab7de6de94205ceacc72f1716d29f20a77bf"
912
+
909
913
commondir@^1.0.1 :
910
914
version "1.0.1"
911
915
resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b"
You can’t perform that action at this time.
0 commit comments