-
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.
Merge pull request #24 from gandalf-network/staging
Staging -> Prod [ Interactive CLI + ESM Support ]
- Loading branch information
Showing
14 changed files
with
254 additions
and
79 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,25 +1,61 @@ | ||
#!/usr/bin/env node | ||
|
||
import { Command } from 'commander'; | ||
import inquirer from 'inquirer'; | ||
import generate from './scripts/generate'; | ||
|
||
const program = new Command(); | ||
|
||
program | ||
.name("Eye Of Sauron") | ||
.version("1.0.0") | ||
.description('A CLI tool for generating prebuilt functions to access the Gandalf Network') | ||
.description('A CLI tool for generating prebuilt functions to access the Gandalf Network'); | ||
|
||
program | ||
.command('generate') | ||
.alias('g') | ||
.description('Generate the prebuilt funtions') | ||
.description('Generate the prebuilt functions') | ||
.option('-f, --folder <folder>', 'Set the destination folder for the generated files') | ||
.option('-j, --javascript', 'Use when generating Javascript files') | ||
.action(async (options) => { | ||
const folder = options.folder ? options.folder: 'eyeofsauron' | ||
const generateJSFiles = options.javascript | ||
await generate(folder, generateJSFiles); | ||
.option('-ts, --typescript', 'Initialize as a TypeScript project.') | ||
.option('-esm, --esModules', 'Initialize as an ESModules JavaScript project. i.e [ import Eye, { Source } from "./eyeofsauron/index.js" ]') | ||
.option('-c, --commonJS', 'Initialize as a CommonJS JavaScript project. i.e [ const Eye = require("./eyeofsauron").default ]') | ||
.allowUnknownOption() | ||
.action(async (cliFlags) => { | ||
let { folder, typescript, commonJS } = cliFlags; | ||
let generateJSFiles = !typescript | ||
let generateESMFiles = generateJSFiles && !commonJS | ||
|
||
if (!folder) { | ||
const answers = await inquirer.prompt([ | ||
{ | ||
type: 'input', | ||
name: 'folder', | ||
message: 'Set the destination folder for the generated files:', | ||
default: 'eyeofsauron', | ||
}, | ||
{ | ||
type: 'list', | ||
name: 'language', | ||
message: 'Select the language for generating the files:', | ||
choices: ['javascript', 'typescript'], | ||
default: 'javascript', | ||
}, | ||
{ | ||
type: 'list', | ||
name: 'moduleSystem', | ||
message: 'Select the Javascript Module system for generating the JS files:', | ||
choices: ['ESModules', 'CommonJS'], | ||
default: 'ESModules', | ||
when: (answers) => answers.language === 'javascript', | ||
}, | ||
]); | ||
|
||
folder = answers.folder; | ||
generateJSFiles = answers.language === 'javascript' | ||
generateESMFiles = generateJSFiles && answers.moduleSystem === 'ESModules'; | ||
} | ||
|
||
await generate(folder, generateJSFiles, generateESMFiles); | ||
}); | ||
|
||
program.parse(process.argv); | ||
program.parse(process.argv); |
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 |
---|---|---|
@@ -1 +1 @@ | ||
export const WATSON_URL = process.env.WATSON_URL as string; | ||
export const WATSON_URL = "http://localhost:8080/public/gql" as string; |
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
Oops, something went wrong.