-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TASK] create cmslib cli alias and make it executable
- Loading branch information
Showing
8 changed files
with
541 additions
and
399 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env node | ||
import { init } from '../lib/init.js' | ||
init() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { parseArgs } from './utils/arg.js' | ||
import { build } from './cmd/build.js' | ||
import { watch } from './cmd/watch.js' | ||
import { hubspotFetchAll } from './cmd/fetch.js' | ||
import { hubspotFetchModules } from './cmd/fetchModules.js' | ||
import { upload } from './cmd/upload.js' | ||
import { validate } from './cmd/validate.js' | ||
import { lighthouse } from './cmd/lighthouse.js' | ||
import { fields } from './cmd/fields.js' | ||
import { fetchDb, uploadDb } from './cmd/hubdb.js' | ||
|
||
const args = parseArgs() | ||
function init () { | ||
if (args.build) { | ||
build() | ||
} else if (args.watch) { | ||
watch() | ||
} else if (args.fetch) { | ||
hubspotFetchAll() | ||
} else if (args.fetchModules) { | ||
hubspotFetchModules() | ||
} else if (args.upload) { | ||
upload() | ||
} else if (args.validate) { | ||
validate() | ||
} else if (args.lighthouse) { | ||
lighthouse() | ||
} else if (args.fields) { | ||
fields() | ||
} else if (args.fetchDb) { | ||
fetchDb() | ||
} else if (args.uploadDb) { | ||
uploadDb() | ||
} | ||
} | ||
export { init } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import chalk from 'chalk' | ||
import minimist from 'minimist' | ||
|
||
const argOptions = { | ||
boolean: [ | ||
'build', | ||
'watch', | ||
'fetch', | ||
'fetchModules', | ||
'upload', | ||
'validate', | ||
'lighthouse', | ||
'fields', | ||
'fetchDb', | ||
'uploadDb' | ||
], | ||
stopEarly: true, | ||
'--': true, | ||
unknown: (/** @type {any} */ arg) => { | ||
console.error(`${chalk.red('Unknown')} or unexpected option: ${arg}`) | ||
process.exit(1) | ||
} | ||
} | ||
|
||
/** | ||
* #### parse cli args | ||
* @returns {any} cli args | ||
*/ | ||
function parseArgs () { | ||
return minimist(process.argv.slice(2), argOptions) | ||
} | ||
|
||
export { parseArgs } |
Oops, something went wrong.