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

Add --skip-git option to init cli command #1531

Merged
merged 2 commits into from Dec 6, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/eleven-ducks-sneeze.md
@@ -0,0 +1,5 @@
---
"@graphprotocol/graph-cli": minor
---

Add `--skip-git` option to `init` cli command
33 changes: 25 additions & 8 deletions packages/cli/src/commands/init.ts
Expand Up @@ -86,6 +86,10 @@
summary: 'Skip installing dependencies.',
default: false,
}),
'skip-git': Flags.boolean({
summary: 'Skip initializing a Git repository.',
default: false,
}),
'start-block': Flags.string({
helpGroup: 'Scaffold from contract',
description: 'Block number to start indexing from.',
Expand All @@ -107,8 +111,8 @@
summary: 'Network the contract is deployed to.',
dependsOn: ['from-contract'],
options: [
...availableNetworks.get('ethereum')!,

Check warning on line 114 in packages/cli/src/commands/init.ts

View workflow job for this annotation

GitHub Actions / Lint

Forbidden non-null assertion
...availableNetworks.get('near')!,

Check warning on line 115 in packages/cli/src/commands/init.ts

View workflow job for this annotation

GitHub Actions / Lint

Forbidden non-null assertion
...availableNetworks.get('cosmos')!,
],
}),
Expand All @@ -131,6 +135,7 @@
'from-example': fromExample,
'index-events': indexEvents,
'skip-install': skipInstall,
'skip-git': skipGit,
network,
abi: abiPath,
'start-block': startBlock,
Expand Down Expand Up @@ -186,6 +191,7 @@
directory,
subgraphName,
skipInstall,
skipGit,
},
{ commands },
);
Expand Down Expand Up @@ -247,6 +253,7 @@
startBlock,
spkgPath,
skipInstall,
skipGit,
},
{ commands, addContract: false },
);
Expand All @@ -273,6 +280,7 @@
subgraphName: answers.subgraphName,
directory: answers.directory,
skipInstall,
skipGit,
},
{ commands },
);
Expand Down Expand Up @@ -322,6 +330,7 @@
startBlock: answers.startBlock,
spkgPath: answers.spkgPath,
skipInstall,
skipGit,
},
{ commands, addContract: true },
);
Expand Down Expand Up @@ -919,12 +928,14 @@
subgraphName,
directory,
skipInstall,
skipGit,
}: {
fromExample: string | boolean;
allowSimpleName?: boolean;
subgraphName: string;
directory: string;
skipInstall: boolean;
skipGit: boolean;
},
{
commands,
Expand Down Expand Up @@ -1031,10 +1042,12 @@
}

// Initialize a fresh Git repository
const repo = await initRepository(directory);
if (repo !== true) {
this.exit(1);
return;
if (!skipGit) {
const repo = await initRepository(directory);
if (repo !== true) {
this.exit(1);
return;
}
}

// Install dependencies
Expand Down Expand Up @@ -1072,6 +1085,7 @@
startBlock,
spkgPath,
skipInstall,
skipGit,
}: {
protocolInstance: Protocol;
allowSimpleName: boolean | undefined;
Expand All @@ -1086,6 +1100,7 @@
startBlock?: string;
spkgPath?: string;
skipInstall: boolean;
skipGit: boolean;
},
{
commands,
Expand Down Expand Up @@ -1163,10 +1178,12 @@
}

// Initialize a fresh Git repository
const repo = await initRepository(directory);
if (repo !== true) {
this.exit(1);
return;
if (!skipGit) {
const repo = await initRepository(directory);
if (repo !== true) {
this.exit(1);
return;
}
}

if (!skipInstall) {
Expand Down