-
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.
⚙️ Chore(process.env definition,select,config): change cli select str…
…ucture, fix process.env,config validator
- Loading branch information
1 parent
5c0049a
commit 1eed703
Showing
9 changed files
with
128 additions
and
86 deletions.
There are no files selected for viewing
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
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,47 @@ | ||
import { program } from "commander"; | ||
import * as prompter from "@clack/prompts"; | ||
import chalk from "chalk"; | ||
import logging from "@/utils/logging"; | ||
|
||
program | ||
.command("select") | ||
.description("Select config properties") | ||
.option("-D, --DEBUG", "output extra debugging", false) | ||
.action(({ DEBUG }) => { | ||
process.env.DEBUG = `${DEBUG}`.toUpperCase(); | ||
|
||
prompter | ||
.group( | ||
{ | ||
intro: () => { | ||
prompter.intro(chalk.bgCyan(" Select ")); | ||
}, | ||
choice: async () => | ||
prompter.select({ | ||
message: "What do you want to select?", | ||
initialValue: "app", | ||
options: [ | ||
{ label: "Config", value: "config.ts"}, | ||
{ label: "Profile", value: "profile.ts" } | ||
] | ||
}), | ||
loadModule: async ({ results }) => { | ||
try { | ||
await import(`./options/${results.choice}`); | ||
} catch (err) { | ||
logging.error("Module not found - probably file with option doesnt exist.", err); | ||
process.exit(1); | ||
} | ||
} | ||
}, | ||
{ | ||
onCancel: () => { | ||
console.log(chalk.red("Canceled.")); | ||
process.exit(0); | ||
} | ||
} | ||
) | ||
.catch(e => { | ||
throw e; | ||
}); | ||
}); |
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,27 @@ | ||
import * as prompter from "@clack/prompts"; | ||
import chalk from "chalk"; | ||
import { resolve } from "path"; | ||
import { copyFiles, existFilePrompt } from "@/function"; | ||
|
||
prompter | ||
.group( | ||
{ | ||
intro: () => { | ||
prompter.intro(chalk.bgCyan(" App installation ")); | ||
}, | ||
// configFinder: async () => {}, | ||
// userChoose: async () => {}, | ||
outro: () => { | ||
prompter.outro(chalk.bgGreen(" App has been installed! ")); | ||
} | ||
}, | ||
{ | ||
onCancel: () => { | ||
console.log(chalk.bgRed("Canceled")); | ||
process.exit(0); | ||
} | ||
} | ||
) | ||
.catch(e => { | ||
throw e; | ||
}); |
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,44 @@ | ||
import * as prompter from "@clack/prompts"; | ||
import chalk from "chalk"; | ||
import { resolve } from "path"; | ||
import { copyFiles, existFilePrompt } from "@/function"; | ||
|
||
prompter | ||
.group( | ||
{ | ||
ConfirmProcess: async () => { | ||
prompter.note(`Initialize app at: \n'${chalk.blue(process.env.CONFIGPATH)}'`, chalk.bgGreen(" ACTIONS ")); | ||
const continueAction = await prompter.confirm({ message: "Do you want to continue?" }); | ||
if (prompter.isCancel(continueAction) || !continueAction) { | ||
prompter.cancel("Canceled."); | ||
process.exit(0); | ||
} | ||
}, | ||
Installation: async () => { | ||
const destination = process.env.CONFIGPATH!; | ||
const templatePath = resolve(process.env.PACKAGEPATH!, "./templates/app/installation/"); | ||
|
||
const InstallingProcess = prompter.spinner(); | ||
InstallingProcess.start("App is installing..."); | ||
await existFilePrompt(destination); | ||
const [data, isError] = copyFiles(templatePath, destination, true); | ||
if (isError) { | ||
InstallingProcess.stop(`❌ Error: ${data.message?.user}`, 1); | ||
process.exit(1); | ||
} | ||
InstallingProcess.stop("✅", 0); | ||
}, | ||
outro: async () => { | ||
prompter.outro(chalk.bgGreen(" App has been installed! ")); | ||
} | ||
}, | ||
{ | ||
onCancel: () => { | ||
console.log(chalk.bgRed("Canceled")); | ||
process.exit(0); | ||
} | ||
} | ||
) | ||
.catch(e => { | ||
throw e; | ||
}); |
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