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: generate types for create fuels users when extracted #3175

Merged
merged 38 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
e9cfe5c
fix: remove typegen artifacts from create-fuels gitignore
Dhaiwat10 Sep 16, 2024
7dfdeaf
add changeset
Dhaiwat10 Sep 16, 2024
34bb78f
add comment to gitignore
Dhaiwat10 Sep 17, 2024
e92413d
Merge branch 'master' into dp/create-fuels-type-artifacts
Dhaiwat10 Sep 17, 2024
235959f
push typegen files at runtime
Dhaiwat10 Sep 18, 2024
9e97e13
Update rewriteTemplateFiles.ts
Dhaiwat10 Sep 18, 2024
b056021
debug
Dhaiwat10 Sep 18, 2024
240f40c
debug
Dhaiwat10 Sep 18, 2024
bd589c1
debug
Dhaiwat10 Sep 18, 2024
12e1446
debug
Dhaiwat10 Sep 18, 2024
a036baa
debug
Dhaiwat10 Sep 18, 2024
35d0ff7
debug
Dhaiwat10 Sep 18, 2024
2798000
debug
Dhaiwat10 Sep 18, 2024
14adcd4
debug
Dhaiwat10 Sep 18, 2024
a1ce0bc
debug
Dhaiwat10 Sep 18, 2024
cb08ac5
debug
Dhaiwat10 Sep 18, 2024
c2c93d8
fix tests
Dhaiwat10 Sep 18, 2024
f5f3f92
fix changeset
Dhaiwat10 Sep 18, 2024
8d43732
disable pr release
Dhaiwat10 Sep 18, 2024
b7c6510
remove build artifacts
Dhaiwat10 Sep 18, 2024
b1e2ccf
Merge branch 'master' into dp/create-fuels-type-artifacts
Dhaiwat10 Sep 18, 2024
5fa7fc8
properly mock
Dhaiwat10 Sep 19, 2024
d714751
add comments in gitgnore instead of removing completely
Dhaiwat10 Sep 19, 2024
df3471b
disable pr release
Dhaiwat10 Sep 19, 2024
0439601
Merge branch 'master' into dp/create-fuels-type-artifacts
Dhaiwat10 Sep 19, 2024
a7d878e
Update templates/nextjs/.gitignore
Dhaiwat10 Sep 24, 2024
eae239a
update gitignore
Dhaiwat10 Sep 24, 2024
08ca8a4
update gitignore
Dhaiwat10 Sep 24, 2024
c3bfcfd
update gitignore
Dhaiwat10 Sep 24, 2024
57b0c1e
update gitignore write logic
Dhaiwat10 Sep 24, 2024
2488955
Merge branch 'master' into dp/create-fuels-type-artifacts
Dhaiwat10 Sep 24, 2024
413f315
Merge branch 'master' into dp/create-fuels-type-artifacts
Dhaiwat10 Sep 25, 2024
aa2873b
fix lint issue
Dhaiwat10 Sep 25, 2024
9367c60
enable pr release
Dhaiwat10 Sep 25, 2024
2af43a6
disable pr release
Dhaiwat10 Sep 25, 2024
713a06a
enable pr release again, and add some debug logic
Dhaiwat10 Sep 25, 2024
a591c68
fix gitignore regex
Dhaiwat10 Sep 25, 2024
6b3e4fe
disable pr release
Dhaiwat10 Sep 25, 2024
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
5 changes: 5 additions & 0 deletions .changeset/spotty-worms-float.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-fuels": patch
---

fix: generate types for `create fuels` users when extracted
11 changes: 9 additions & 2 deletions packages/create-fuels/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,18 +139,25 @@ export const runScaffoldCli = async ({

fileCopySpinner.succeed('Copied template files!');

// Remove typegen files from gitignore
const gitignorePath = join(projectPath, '.gitignore');
const gitignoreContents = readFileSync(gitignorePath, 'utf-8');
const newGitIgnoreContents = gitignoreContents.replace(/^(src\/sway-api\/.+)$/gm, '# $1');
writeFileSync(gitignorePath, newGitIgnoreContents);

if (opts.install) {
const installDepsSpinner = ora({
text: 'Installing dependencies..',
color: 'green',
}).start();

process.chdir(projectPath);
execSync(packageManager.install, { stdio: verboseEnabled ? 'inherit' : 'pipe' });

installDepsSpinner.succeed('Installed dependencies!');
}

// Generate typegen files
execSync(packageManager.run('prebuild'), { stdio: verboseEnabled ? 'inherit' : 'pipe' });
Dhaiwat10 marked this conversation as resolved.
Show resolved Hide resolved

log();
log();
log(chalk.green(`⚡️ Success! Created a fullstack Fuel dapp at ${projectPath}`));
Expand Down
10 changes: 10 additions & 0 deletions packages/create-fuels/test/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,18 @@ import {
resetFilesystem,
} from './utils/bootstrapProject';
import { generateArgv } from './utils/generateArgs';
import { mockExecSync } from './utils/mockExecSync';
import { mockLogger } from './utils/mockLogger';
import { filterOriginalTemplateFiles, getAllFiles } from './utils/templateFiles';

vi.mock('child_process', async () => {
const mod = await vi.importActual('child_process');
return {
__esModule: true,
...mod,
};
});

/**
* @group node
*/
Expand All @@ -28,6 +37,7 @@ describe('CLI', { timeout: 15_000 }, () => {
beforeEach(() => {
paths = bootstrapProject(__filename);
copyTemplate(paths.templateSource, paths.templateRoot);
mockExecSync();
});

afterEach(() => {
Expand Down
12 changes: 12 additions & 0 deletions packages/create-fuels/test/utils/mockExecSync.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import chalk from 'chalk';
import * as childProcessMod from 'child_process';

export const mockExecSync = () => {
vi.spyOn(childProcessMod, 'execSync').mockImplementationOnce((command) => {
if (command.includes('prebuild')) {
return chalk('Skipping prebuild command');
}
// Allow other execSync calls to proceed normally
return childProcessMod.execSync(command);
});
};
15 changes: 9 additions & 6 deletions templates/nextjs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,16 @@ yarn-error.log*

.fuels

src/sway-api/contracts
src/sway-api/predicates
src/sway-api/scripts
src/sway-api/index.ts

sway-programs/**/out
.turbo

test-results
playwright-report
playwright-report

Dhaiwat10 marked this conversation as resolved.
Show resolved Hide resolved
# Uncomment the lines below if you don't wish
# to commit the generated files to git

src/sway-api/contracts
src/sway-api/predicates
src/sway-api/scripts
src/sway-api/index.ts
15 changes: 9 additions & 6 deletions templates/nextjs/gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,16 @@ next-env.d.ts

.fuels

src/sway-api/contracts
src/sway-api/predicates
src/sway-api/scripts
src/sway-api/index.ts

Dhaiwat10 marked this conversation as resolved.
Show resolved Hide resolved
sway-programs/**/out
.turbo

test-results
playwright-report
playwright-report

Dhaiwat10 marked this conversation as resolved.
Show resolved Hide resolved
# Uncomment the lines below if you don't wish
# to commit the generated files to git

src/sway-api/contracts
src/sway-api/predicates
src/sway-api/scripts
src/sway-api/index.ts
15 changes: 9 additions & 6 deletions templates/vite/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ dist-ssr

.fuels

src/sway-api/contracts
src/sway-api/predicates
src/sway-api/scripts
src/sway-api/index.ts

sway-programs/**/out
.turbo

test-results
playwright-report
playwright-report

Dhaiwat10 marked this conversation as resolved.
Show resolved Hide resolved
# Uncomment the lines below if you don't wish
# to commit the generated files to git

src/sway-api/contracts
src/sway-api/predicates
src/sway-api/scripts
src/sway-api/index.ts
15 changes: 9 additions & 6 deletions templates/vite/gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ dist-ssr

.fuels

src/sway-api/contracts
src/sway-api/predicates
src/sway-api/scripts
src/sway-api/index.ts

sway-programs/**/out
.turbo

test-results
playwright-report
playwright-report

Dhaiwat10 marked this conversation as resolved.
Show resolved Hide resolved
# Uncomment the lines below if you don't wish
# to commit the generated files to git

src/sway-api/contracts
src/sway-api/predicates
src/sway-api/scripts
src/sway-api/index.ts