Skip to content

Commit

Permalink
Add --skip-git option to init cli command (#1531)
Browse files Browse the repository at this point in the history
* Add --skip-git option to init cli command

* Create eleven-ducks-sneeze.md

---------

Co-authored-by: Saihajpreet Singh <saihajpreet.singh@gmail.com>
  • Loading branch information
travs and saihaj committed Dec 6, 2023
1 parent d03370a commit b168be1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
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 @@ export default class InitCommand extends Command {
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 Down Expand Up @@ -131,6 +135,7 @@ export default class InitCommand extends Command {
'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 @@ export default class InitCommand extends Command {
directory,
subgraphName,
skipInstall,
skipGit,
},
{ commands },
);
Expand Down Expand Up @@ -247,6 +253,7 @@ export default class InitCommand extends Command {
startBlock,
spkgPath,
skipInstall,
skipGit,
},
{ commands, addContract: false },
);
Expand All @@ -273,6 +280,7 @@ export default class InitCommand extends Command {
subgraphName: answers.subgraphName,
directory: answers.directory,
skipInstall,
skipGit,
},
{ commands },
);
Expand Down Expand Up @@ -322,6 +330,7 @@ export default class InitCommand extends Command {
startBlock: answers.startBlock,
spkgPath: answers.spkgPath,
skipInstall,
skipGit,
},
{ commands, addContract: true },
);
Expand Down Expand Up @@ -919,12 +928,14 @@ async function initSubgraphFromExample(
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 @@ async function initSubgraphFromExample(
}

// 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 @@ async function initSubgraphFromContract(
startBlock,
spkgPath,
skipInstall,
skipGit,
}: {
protocolInstance: Protocol;
allowSimpleName: boolean | undefined;
Expand All @@ -1086,6 +1100,7 @@ async function initSubgraphFromContract(
startBlock?: string;
spkgPath?: string;
skipInstall: boolean;
skipGit: boolean;
},
{
commands,
Expand Down Expand Up @@ -1163,10 +1178,12 @@ async function initSubgraphFromContract(
}

// 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

0 comments on commit b168be1

Please sign in to comment.