Skip to content

Commit

Permalink
feat: make vite the default create-fuels template (#3048)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhaiwat10 authored Sep 3, 2024
1 parent 96140a2 commit a0bb25f
Show file tree
Hide file tree
Showing 53 changed files with 1,108 additions and 694 deletions.
5 changes: 5 additions & 0 deletions .changeset/odd-coats-tease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-fuels": patch
---

feat: make vite the default `create-fuels` template
4 changes: 2 additions & 2 deletions apps/create-fuels-counter-guide/.env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
NEXT_PUBLIC_FUEL_NODE_PORT=4000
NEXT_PUBLIC_DAPP_ENVIRONMENT=local
VITE_FUEL_NODE_PORT=4000
VITE_DAPP_ENVIRONMENT=local
1 change: 0 additions & 1 deletion apps/create-fuels-counter-guide/.eslintignore

This file was deleted.

4 changes: 0 additions & 4 deletions apps/create-fuels-counter-guide/.eslintrc.json

This file was deleted.

52 changes: 21 additions & 31 deletions apps/create-fuels-counter-guide/.gitignore
Original file line number Diff line number Diff line change
@@ -1,37 +1,27 @@
# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

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

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

.fuels

Expand Down
2 changes: 1 addition & 1 deletion apps/create-fuels-counter-guide/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-fuels`](https://github.com/FuelLabs/fuels-ts/tree/master/packages/create-fuels).
This is a [Vite](https://vitejs.dev/) project bootstrapped with [`create-fuels`](https://github.com/FuelLabs/fuels-ts/tree/master/packages/create-fuels).

## Getting Started

Expand Down
26 changes: 26 additions & 0 deletions apps/create-fuels-counter-guide/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import tseslint from 'typescript-eslint'

export default tseslint.config({
extends: [js.configs.recommended, ...tseslint.configs.recommended],
files: ['**/*.{ts,tsx}'],
ignores: ['dist'],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
plugins: {
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
},
rules: {
...reactHooks.configs.recommended.rules,
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
})
6 changes: 4 additions & 2 deletions apps/create-fuels-counter-guide/fuels.config.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
// #region fuels-config-file-env
import { createConfig } from 'fuels';
import dotenv from 'dotenv';
import { NODE_URL } from '@/lib';
import { NODE_URL } from './src/lib';

dotenv.config({
path: ['.env.local', '.env'],
});

// If your node is running on a port other than 4000, you can set it here
const fuelCorePort = +(process.env.NEXT_PUBLIC_FUEL_NODE_PORT as string) || 4000;
const fuelCorePort = +(process.env.VITE_FUEL_NODE_PORT as string) || 4000;

export default createConfig({
workspace: './sway-programs', // Path to your Sway workspace
output: './src/sway-api', // Where your generated types will be saved
fuelCorePort,
providerUrl: NODE_URL,
fuelCorePath: 'fuels-core',
forcPath: 'fuels-forc',
});
// #endregion fuels-config-file-env
16 changes: 16 additions & 0 deletions apps/create-fuels-counter-guide/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!doctype html>
<html lang="en">

<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/fuel.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Fuel dApp</title>
</head>

<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>

</html>
6 changes: 0 additions & 6 deletions apps/create-fuels-counter-guide/next.config.js

This file was deleted.

26 changes: 18 additions & 8 deletions apps/create-fuels-counter-guide/package.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,49 @@
{
"name": "create-fuels-counter-guide",
"version": "0.1.0",
"private": true,
"version": "0.1.0",
"type": "module",
"scripts": {
"original:dev": "next dev",
"original:build": "next build",
"test": "vitest",
"original:dev": "vite",
"original:build": "tsc -b && vite build",
"original:start": "next start",
"original:lint": "next lint",
"original:lint": "eslint .",
"fuels:build": "fuels build",
"fuels:dev": "fuels dev",
"postbuild": "run-s fuels:build original:build"
},
"dependencies": {
"@fuels/connectors": "^0.26.0",
"@fuels/react": "^0.26.0",
"fuels": "workspace:*",
"@tanstack/react-query": "^5.52.1",
"@tanstack/react-router": "^1.48.1",
"fuels": "workspace:*",
"@wagmi/connectors": "^5.1.8",
"@wagmi/core": "^2.13.4",
"dotenv": "^16.4.5",
"next": "14.2.7",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-hot-toast": "^2.4.1",
"react-use": "^17.5.1"
},
"devDependencies": {
"@eslint/js": "^9.9.1",
"@tanstack/router-plugin": "^1.47.0",
"@types/node": "^22.2.0",
"@types/react": "^18.3.5",
"@types/react-dom": "^18.3",
"@vitejs/plugin-react-swc": "^3.5.0",
"autoprefixer": "^10.4.20",
"eslint": "^8.57.0",
"eslint-config-next": "14.2.7",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-react-refresh": "^0.4.11",
"globals": "^15.9.0",
"postcss": "^8",
"tailwindcss": "^3.4.10",
"typescript": "~5.4.5"
"typescript": "~5.4.5",
"typescript-eslint": "^8.0.0",
"vite": "^5.4.2",
"vitest": "^1.6.0"
}
}
4 changes: 2 additions & 2 deletions apps/create-fuels-counter-guide/postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
};
}
85 changes: 0 additions & 85 deletions apps/create-fuels-counter-guide/src/app/layout.tsx

This file was deleted.

15 changes: 5 additions & 10 deletions apps/create-fuels-counter-guide/src/components/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import toast, { Toaster } from "react-hot-toast";
import { Link } from "./Link";
import { Button } from "./Button";
import { CURRENT_ENVIRONMENT, NODE_URL, TESTNET_FAUCET_LINK } from "@/lib";
import { CURRENT_ENVIRONMENT, NODE_URL, TESTNET_FAUCET_LINK } from "../lib";
import { useConnectUI, useDisconnect } from "@fuels/react";
import { WalletDisplay } from "./WalletDisplay";
import { useBrowserWallet } from "@/hooks/useBrowserWallet";
import { useActiveWallet } from "@/hooks/useActiveWallet";
import { useFaucet } from "@/hooks/useFaucet";
import Head from "next/head";
import { useBrowserWallet } from "../hooks/useBrowserWallet";
import { useActiveWallet } from "../hooks/useActiveWallet";
import { useFaucet } from "../hooks/useFaucet";
import { bn } from "fuels";

export const Layout = ({ children }: { children: React.ReactNode }) => {
Expand Down Expand Up @@ -73,12 +72,8 @@ export const Layout = ({ children }: { children: React.ReactNode }) => {

return (
<>
<Head>
<title>Fuel App</title>
<link rel="icon" href="/fuel.ico" />
</Head>
<Toaster />
<div className="flex flex-col">
<div className="flex flex-col bg-black text-white">
<nav className="flex justify-between items-center p-4 bg-black text-white gap-6">
<Link href="/">Home</Link>

Expand Down
8 changes: 5 additions & 3 deletions apps/create-fuels-counter-guide/src/components/Link.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Link as ReactRouterLink } from "@tanstack/react-router";

export const Link = ({
href,
children,
Expand All @@ -10,12 +12,12 @@ export const Link = ({
target?: string;
}) => {
return (
<a
href={href}
<ReactRouterLink
to={href}
className={`text-fuel-green hover:underline ${className}`}
target={target}
>
{children}
</a>
</ReactRouterLink>
);
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import toast from "react-hot-toast";
import { useActiveWallet } from "@/hooks/useActiveWallet";
import { useActiveWallet } from "../hooks/useActiveWallet";

const getTruncatedAddress = (address: string) => {
return address.slice(0, 6) + "..." + address.slice(-4);
Expand Down
4 changes: 2 additions & 2 deletions apps/create-fuels-counter-guide/src/hooks/useActiveWallet.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect, useState, createContext, useContext, useMemo } from "react";
import { useEffect, useState, createContext, useContext } from "react";
import { useBrowserWallet } from "./useBrowserWallet";
import { useBurnerWallet } from "./useBurnerWallet";
import { AppWallet } from "@/lib";
import { AppWallet } from "../lib";

/**
* burner -> a burner wallet embedded inside of the template app and stored in local storage
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AppWallet } from "@/lib";
import { AppWallet } from "../lib";
import { useIsConnected, useNetwork, useWallet } from "@fuels/react";
import { BN } from "fuels";
import { useCallback, useState } from "react";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AppWallet, NODE_URL } from "@/lib";
import { AppWallet, NODE_URL } from "../lib";
import { BN, Provider, Wallet, WalletUnlocked } from "fuels";
import { useCallback, useState } from "react";
import useAsync from "react-use/lib/useAsync";
Expand Down
Loading

0 comments on commit a0bb25f

Please sign in to comment.