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

fix: include a .gitignore file in the create-fuels template #1616

Merged
merged 1 commit into from
Jan 8, 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: 6 additions & 0 deletions .changeset/cold-worms-heal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"create-fuels": patch
"nextjs": patch
---

fix: include a `.gitignore` file in the template copied over by create-fuels
3 changes: 2 additions & 1 deletion packages/create-fuels/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import chalk from 'chalk';
import { execSync } from 'child_process';
import { Command } from 'commander';
import { existsSync } from 'fs';
import { cp, mkdir } from 'fs/promises';
import { cp, mkdir, rename } from 'fs/promises';
import { join } from 'path';
import prompts from 'prompts';

Expand Down Expand Up @@ -64,6 +64,7 @@ export const runScaffoldCli = async (
await mkdir(projectPath);

await cp(join(__dirname, '../templates/nextjs'), projectPath, { recursive: true });
await rename(join(projectPath, 'gitignore'), join(projectPath, '.gitignore'));

if (shouldInstallDeps) {
process.chdir(projectPath);
Expand Down
7 changes: 7 additions & 0 deletions packages/create-fuels/test/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ test('create-fuels extracts the template to the specified directory', async () =
// check if the template was extracted to the test-project directory.
// compare the templates/nextjs folder with the test-project folder recursively
const originalTemplateFiles = await fs.readdir(join(__dirname, '../templates/nextjs'));

// remove the gitignore file from the array because it is not copied to the test-project folder
const gitIgnoreIndex = originalTemplateFiles.indexOf('gitignore');
if (gitIgnoreIndex > -1) {
originalTemplateFiles.splice(gitIgnoreIndex, 1);
}

const testProjectFiles = await fs.readdir('test-project');

expect(originalTemplateFiles).toEqual(testProjectFiles);
Expand Down
4 changes: 3 additions & 1 deletion templates/nextjs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@ yarn-error.log*
next-env.d.ts

.fuels
sway-api
src/sway-api
sway-contracts/out
.turbo
39 changes: 39 additions & 0 deletions templates/nextjs/gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts

.fuels
src/sway-api
sway-contracts/out
.turbo
Loading