Skip to content

Commit

Permalink
don't prompt for install + remove prettier plugins (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
technophile-04 authored Jul 15, 2024
1 parent af45c2e commit 697fda9
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 316 deletions.
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"lefthook": "^1.6.16",
"prettier": "3.3.2",
"rollup": "3.21.0",
"rollup-plugin-auto-external": "2.0.0",
"tslib": "2.5.0",
Expand All @@ -47,17 +48,14 @@
},
"dependencies": {
"@changesets/cli": "^2.26.2",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"arg": "5.0.2",
"chalk": "5.2.0",
"execa": "7.1.1",
"inquirer": "9.2.0",
"listr2": "^8.2.1",
"merge-packages": "^0.1.6",
"ncp": "2.0.0",
"pkg-install": "1.0.0",
"prettier": "3.3.2",
"prettier-plugin-solidity": "^1.3.1"
"pkg-install": "1.0.0"
},
"packageManager": "[email protected]"
}
4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export async function createProject(options: Options) {
task: () => installPackages(targetDirectory),
skip: () => {
if (!options.install) {
return "Manually skipped";
return "Manually skipped, since `--skip-install` flag was passed";
}
return false;
},
Expand All @@ -50,7 +50,7 @@ export async function createProject(options: Options) {
task: () => prettierFormat(targetDirectory),
skip: () => {
if (!options.install) {
return "`yarn install` was skipped";
return "Can't use source prettier, since `yarn install` was skipped";
}
return false;
},
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export type ExternalExtension = {

type BaseOptions = {
project: string | null;
install: boolean | null;
install: boolean;
dev: boolean;
externalExtension: ExternalExtension | ExternalExtensionNameDev | null;
solidityFramework: SolidityFramework | "none" | null;
Expand Down
12 changes: 1 addition & 11 deletions src/utils/parse-arguments-into-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ const validateExternalExtension = async (
export async function parseArgumentsIntoOptions(rawArgs: Args): Promise<RawOptions> {
const args = arg(
{
"--install": Boolean,
"-i": "--install",

"--skip-install": Boolean,
"--skip": "--skip-install",

Expand All @@ -76,15 +73,8 @@ export async function parseArgumentsIntoOptions(rawArgs: Args): Promise<RawOptio
},
);

const install = args["--install"] ?? null;
const skipInstall = args["--skip-install"] ?? null;

if (install && skipInstall) {
throw new Error('Please select only one of the options: "--install" or "--skip-install".');
}

const hasInstallRelatedFlag = install || skipInstall;

const dev = args["--dev"] ?? false; // info: use false avoid asking user

const help = args["--help"] ?? false;
Expand Down Expand Up @@ -112,7 +102,7 @@ export async function parseArgumentsIntoOptions(rawArgs: Args): Promise<RawOptio

return {
project,
install: hasInstallRelatedFlag ? install || !skipInstall : null,
install: !skipInstall,
dev,
externalExtension: extension,
help,
Expand Down
8 changes: 1 addition & 7 deletions src/utils/prompt-for-missing-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,13 @@ export async function promptForMissingOptions(options: RawOptions): Promise<Opti
choices: [SOLIDITY_FRAMEWORKS.HARDHAT, SOLIDITY_FRAMEWORKS.FOUNDRY, nullExtensionChoice],
default: SOLIDITY_FRAMEWORKS.HARDHAT,
},
{
type: "confirm",
name: "install",
message: "Install packages?",
default: defaultOptions.install,
},
];

const answers = await inquirer.prompt(questions, cliAnswers);

const mergedOptions: Options = {
project: options.project ?? answers.project,
install: options.install ?? answers.install,
install: options.install,
dev: options.dev ?? defaultOptions.dev,
solidityFramework: options.solidityFramework ?? answers.solidityFramework,
externalExtension: options.externalExtension,
Expand Down
Loading

0 comments on commit 697fda9

Please sign in to comment.