Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't prompt for install + remove prettier plugins #80

Merged
merged 2 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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": "yarn@3.5.0"
}
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
Loading