Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor file structure, update how commands run
Since the tool is only React Native for now, it didn't seem necessary to have the 'react-native' directory. Moved to 'src'. Also created utility for importing commands for commander
- Loading branch information
1 parent
aa0e634
commit 5ed7cff
Showing
9 changed files
with
49 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
yarn ts-node ./react-native/react-native.ts "$@" | ||
yarn ts-node ./src/cli.ts "$@" |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { program } from "commander"; | ||
import buildAction from "./util/buildAction"; | ||
|
||
console.log("React Native 🎉"); | ||
|
||
export default function runCli() { | ||
program | ||
.name("thoughtbelt") | ||
.description( | ||
"Perform React Native and Expo setup and redundant tasks without your pants falling down!" | ||
) | ||
|
||
.command("eslint") | ||
.description("Configure ESLint") | ||
.action(buildAction(import("./commands/eslint"))); | ||
|
||
program | ||
.command("prettier") | ||
.description("Configure Prettier") | ||
.action(buildAction(import("./commands/prettier"))); | ||
|
||
program.showHelpAfterError().parse(); | ||
} | ||
|
||
runCli(); |
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 @@ | ||
export default function runEslint() { | ||
console.log("ESLint!"); | ||
} |
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 @@ | ||
export default function runPrettier() { | ||
console.log("Prettier!"); | ||
} |
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,17 @@ | ||
type AsyncModule = Promise<{ | ||
default: (...args: unknown[]) => void; | ||
}>; | ||
|
||
/** | ||
* builds the action function that is passed to Commander's | ||
* program.action. | ||
* Eg: program.action( | ||
* buildAction(import('./commands/prettier)) | ||
* ) | ||
*/ | ||
export default function buildAction(asyncModule: AsyncModule) { | ||
return async (...args: unknown[]) => { | ||
const module = await asyncModule; | ||
module.default(args); | ||
}; | ||
} |