Skip to content

Commit

Permalink
feat: generate git ignore (#1629)
Browse files Browse the repository at this point in the history
  • Loading branch information
saihaj committed Apr 15, 2024
1 parent 0d72873 commit 3801671
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/happy-cats-fail.md
@@ -0,0 +1,5 @@
---
'@graphprotocol/graph-cli': minor
---

generate gitignore file
37 changes: 37 additions & 0 deletions packages/cli/src/scaffold/get-git-ignore.ts
@@ -0,0 +1,37 @@
export const getGitIgnore = () => {
return `# Graph CLI generated artifacts
build/
generated/
# Dependency directories
node_modules/
jspm_packages/
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# dotenv environment variables file
.env
# Testing
coverage
coverage.json
# Typechain
typechain
typechain-types
# Hardhat files
cache
`;
};
7 changes: 7 additions & 0 deletions packages/cli/src/scaffold/index.ts
Expand Up @@ -5,6 +5,7 @@ import Protocol from '../protocols';
import ABI from '../protocols/ethereum/abi';
import { version } from '../version';
import { getDockerFile } from './get-docker-file';
import { getGitIgnore } from './get-git-ignore';
import { generateEventIndexingHandlers } from './mapping';
import { abiEvents, generateEventType, generateExampleEntityType } from './schema';
import { generateTestsFiles } from './tests';
Expand Down Expand Up @@ -159,6 +160,10 @@ dataSources:
return await prettier.format(getDockerFile(), { parser: 'yaml' });
}

generateGitIgnoreFile() {
return getGitIgnore();
}

async generateMappings() {
return this.protocol.getMappingScaffold()
? { [`${strings.kebabCase(this.contractName)}.ts`]: await this.generateMapping() }
Expand Down Expand Up @@ -206,6 +211,7 @@ dataSources:
'subgraph.yaml': await this.generateManifest(),
'schema.graphql': await this.generateSchema(),
'package.json': await this.generatePackageJsonForSubstreams(),
'.gitignore': await this.generateGitIgnoreFile(),
};
}
return {
Expand All @@ -214,6 +220,7 @@ dataSources:
'schema.graphql': await this.generateSchema(),
'tsconfig.json': await this.generateTsConfig(),
'docker-compose.yml': await this.generateDockerFileConfig(),
'.gitignore': await this.generateGitIgnoreFile(),
src: await this.generateMappings(),
abis: await this.generateABIs(),
tests: await this.generateTests(),
Expand Down

0 comments on commit 3801671

Please sign in to comment.