-
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.
feat(init): Adjusted setup and passing initial prompts with inquirer v8.
- Loading branch information
Showing
10 changed files
with
230 additions
and
67 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 |
---|---|---|
|
@@ -7,3 +7,4 @@ | |
/tmp | ||
node_modules | ||
oclif.manifest.json | ||
.history |
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,17 +1,17 @@ | ||
#!/usr/bin/env node | ||
|
||
const oclif = require('@oclif/core') | ||
const oclif = require("@oclif/core"); | ||
|
||
const path = require('path') | ||
const project = path.join(__dirname, '..', 'tsconfig.json') | ||
const path = require("path"); | ||
const project = path.join(__dirname, "..", "tsconfig.json"); | ||
|
||
// In dev mode -> use ts-node and dev plugins | ||
process.env.NODE_ENV = 'development' | ||
process.env.NODE_ENV = "development"; | ||
|
||
require('ts-node').register({project}) | ||
require("ts-node").register({ project }); | ||
|
||
// In dev mode, always show stack traces | ||
oclif.settings.debug = true; | ||
|
||
// Start the CLI | ||
oclif.run().then(oclif.flush).catch(oclif.Errors.handle) | ||
oclif.run().then(oclif.flush).catch(oclif.Errors.handle); |
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,21 @@ | ||
import chalk = require("chalk"); | ||
import { execSync } from "node:child_process"; | ||
|
||
type Prompts = { | ||
src: string; | ||
dest: string; | ||
impression: string; | ||
}; | ||
/** | ||
* Creates story from custom element json file | ||
* | ||
* @param {string} prompts - prompts: Object of the values from the prompt questions; | ||
* @returns NULL | ||
*/ | ||
export const convertComponent = (prompts: Prompts): void => { | ||
try { | ||
execSync(`echo "Converting ${prompts.src} to ${prompts.dest}..."`); | ||
} catch (error) { | ||
throw console.error(`${chalk.red("error")}: ${error}`); | ||
} | ||
}; |
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,64 @@ | ||
import { Command } from "@oclif/core"; | ||
// import inquirer from "inquirer"; | ||
import * as inquirer from "inquirer"; | ||
import { convertComponent } from "./convert-component"; | ||
export default class Convert extends Command { | ||
static description = "Converts an Outline component to InlineJS."; | ||
static examples = ["<%= config.bin %> <%= command.id %>"]; | ||
|
||
public async run(): Promise<void> { | ||
const sourceComponent = await inquirer.prompt([ | ||
{ | ||
name: "source", | ||
message: "What is the name of the original component? Ex: outline-card", | ||
type: "input", | ||
validate: function (input: string) { | ||
if (input && typeof input === "string") { | ||
return true; | ||
} | ||
|
||
return false; | ||
}, | ||
}, | ||
]); | ||
|
||
const destinationComponent = await inquirer.prompt([ | ||
{ | ||
name: "destination", | ||
message: "What is the name of the original component? Ex: inline-card", | ||
type: "input", | ||
validate: function (input: string) { | ||
if (input && typeof input === "string") { | ||
return true; | ||
} | ||
|
||
return false; | ||
}, | ||
}, | ||
]); | ||
|
||
const impression = await inquirer.prompt([ | ||
{ | ||
name: "impression", | ||
message: "How does this tool make you feel.", | ||
type: "list", | ||
choices: [{ name: "good" }, { name: "great" }, { name: "angry" }], | ||
validate: function (input: string) { | ||
if (input && typeof input === "string") { | ||
return true; | ||
} | ||
|
||
return false; | ||
}, | ||
}, | ||
]); | ||
|
||
// const {args, flags} = await this.parse(Init) | ||
const prompts = { | ||
src: sourceComponent.name, | ||
dest: destinationComponent.name, | ||
impression: impression.name, | ||
}; | ||
convertComponent(prompts); | ||
} | ||
} |
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,23 +1,31 @@ | ||
import {Command, Flags} from '@oclif/core' | ||
import { Command, Flags } from "@oclif/core"; | ||
|
||
export default class Hello extends Command { | ||
static description = 'Say hello' | ||
static description = "Say hello"; | ||
|
||
static examples = [ | ||
`$ oex hello friend --from oclif | ||
hello friend from oclif! (./src/commands/hello/index.ts) | ||
`, | ||
] | ||
]; | ||
|
||
static flags = { | ||
from: Flags.string({char: 'f', description: 'Who is saying hello', required: true}), | ||
} | ||
from: Flags.string({ | ||
char: "f", | ||
description: "Who is saying hello", | ||
required: true, | ||
}), | ||
}; | ||
|
||
static args = [{name: 'person', description: 'Person to say hello to', required: true}] | ||
static args = [ | ||
{ name: "person", description: "Person to say hello to", required: true }, | ||
]; | ||
|
||
async run(): Promise<void> { | ||
const {args, flags} = await this.parse(Hello) | ||
const { args, flags } = await this.parse(Hello); | ||
|
||
this.log(`hello ${args.person} from ${flags.from}! (./src/commands/hello/index.ts)`) | ||
this.log( | ||
`hello ${args.person} from ${flags.from}! (./src/commands/hello/index.ts)` | ||
); | ||
} | ||
} |
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,19 +1,19 @@ | ||
import {Command} from '@oclif/core' | ||
import { Command } from "@oclif/core"; | ||
|
||
export default class World extends Command { | ||
static description = 'Say hello world' | ||
static description = "Say hello world"; | ||
|
||
static examples = [ | ||
`<%= config.bin %> <%= command.id %> | ||
hello world! (./src/commands/hello/world.ts) | ||
`, | ||
] | ||
]; | ||
|
||
static flags = {} | ||
static flags = {}; | ||
|
||
static args = [] | ||
static args = []; | ||
|
||
async run(): Promise<void> { | ||
this.log('hello world! (./src/commands/hello/world.ts)') | ||
this.log("hello world! (./src/commands/hello/world.ts)"); | ||
} | ||
} |
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.