Skip to content

Commit 2384dae

Browse files
Merge pull request #216 from autonomys/feat/auto-drive-create-next-app
Auto Drive Create Next App Example
2 parents 526f97b + b46a60a commit 2384dae

23 files changed

+2067
-19
lines changed

.vscode/auto.code-workspace

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
"name": "Example - Node",
3737
"path": "../examples/node",
3838
},
39+
{
40+
"name": "Example - Auto Drive Create Next App",
41+
"path": "../examples/auto-drive-create-next-app",
42+
},
3943
],
4044
"settings": {
4145
"editor.codeActionsOnSave": {
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.*
7+
.yarn/*
8+
!.yarn/patches
9+
!.yarn/plugins
10+
!.yarn/releases
11+
!.yarn/versions
12+
13+
# testing
14+
/coverage
15+
16+
# next.js
17+
/.next/
18+
/out/
19+
20+
# production
21+
/build
22+
23+
# misc
24+
.DS_Store
25+
*.pem
26+
27+
# debug
28+
npm-debug.log*
29+
yarn-debug.log*
30+
yarn-error.log*
31+
.pnpm-debug.log*
32+
33+
# env files (can opt-in for committing if needed)
34+
.env*
35+
36+
# vercel
37+
.vercel
38+
39+
# typescript
40+
*.tsbuildinfo
41+
next-env.d.ts
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Auto Drive Static Web App
2+
3+
This project is a static web app example built with [Next.js](https://nextjs.org), specifically modified for easy deployment to Auto Drive. It is bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
4+
5+
## Exporting the App for Auto Drive
6+
7+
To export the app as static files for Auto Drive, use the following command with your API key, based on your package manager:
8+
9+
```bash
10+
npm run export -- --auto-drive-api-key=<API_KEY>
11+
# or
12+
yarn export --auto-drive-api-key=<API_KEY>
13+
# or
14+
pnpm export -- --auto-drive-api-key=<API_KEY>
15+
# or
16+
bun export --auto-drive-api-key=<API_KEY>
17+
```
18+
19+
You can create an account and generate an API key on the [Auto Drive website](https://ai3.storage/).
20+
21+
This command executes the `export` script defined in the `package.json`:
22+
23+
```json
24+
"export": "next build && ts-node export.ts"
25+
```
26+
27+
## Getting Started
28+
29+
To start the development server, run:
30+
31+
```bash
32+
npm run dev
33+
# or
34+
yarn dev
35+
# or
36+
pnpm dev
37+
# or
38+
bun dev
39+
```
40+
41+
Open [http://localhost:3000](http://localhost:3000) in your browser to see the result. You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
42+
43+
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
44+
45+
## Learn More
46+
47+
To learn more about Next.js, take a look at the following resources:
48+
49+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
50+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
51+
52+
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { dirname } from "path";
2+
import { fileURLToPath } from "url";
3+
import { FlatCompat } from "@eslint/eslintrc";
4+
5+
const __filename = fileURLToPath(import.meta.url);
6+
const __dirname = dirname(__filename);
7+
8+
const compat = new FlatCompat({
9+
baseDirectory: __dirname,
10+
});
11+
12+
const eslintConfig = [
13+
...compat.extends("next/core-web-vitals", "next/typescript"),
14+
];
15+
16+
export default eslintConfig;
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { createAutoDriveApi, uploadFolderFromFolderPath } from '@autonomys/auto-drive'
2+
import path from 'path'
3+
import { fileURLToPath } from 'url'
4+
5+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
6+
7+
async function uploadBuild() {
8+
const apiKey =
9+
process.env.AUTO_DRIVE_API_KEY ||
10+
process.argv.find((arg) => arg.startsWith('--auto-drive-api-key='))?.split('=')[1]
11+
12+
if (!apiKey) {
13+
console.error(
14+
'Error: AUTO_DRIVE_API_KEY environment variable or --auto-drive-api-key argument is required',
15+
)
16+
process.exit(1)
17+
}
18+
19+
const api = createAutoDriveApi({ apiKey })
20+
const outDir = path.join(__dirname, 'out')
21+
22+
try {
23+
console.log('Starting upload of build files to Auto-Drive...')
24+
const folderCID = await uploadFolderFromFolderPath(api, outDir, {
25+
onProgress: (progress) => {
26+
console.log(`Upload progress: ${Math.round(progress)}%`)
27+
},
28+
})
29+
console.log(`Upload complete! Folder CID: ${folderCID}`)
30+
return folderCID
31+
} catch (error) {
32+
console.error('Error uploading to Auto-Drive:', error)
33+
process.exit(1)
34+
}
35+
}
36+
37+
uploadBuild()
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import type { NextConfig } from "next";
2+
3+
const nextConfig: NextConfig = {
4+
/* config options here */
5+
output: "export",
6+
assetPrefix: "./",
7+
basePath: "",
8+
trailingSlash: true,
9+
};
10+
11+
export default nextConfig;
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "create-next-app",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"dev": "next dev",
7+
"build": "next build",
8+
"start": "npx serve@latest out",
9+
"lint": "next lint",
10+
"export": "next build && node export.mjs"
11+
},
12+
"dependencies": {
13+
"next": "15.1.4",
14+
"react": "^19.0.0",
15+
"react-dom": "^19.0.0"
16+
},
17+
"devDependencies": {
18+
"@autonomys/auto-drive": "workspace:*",
19+
"@eslint/eslintrc": "^3",
20+
"@types/node": "^20",
21+
"@types/react": "^19",
22+
"@types/react-dom": "^19",
23+
"eslint": "^9",
24+
"eslint-config-next": "15.1.4",
25+
"postcss": "^8",
26+
"tailwindcss": "^3.4.1",
27+
"ts-node": "^10.9.2",
28+
"typescript": "^5"
29+
}
30+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/** @type {import('postcss-load-config').Config} */
2+
const config = {
3+
plugins: {
4+
tailwindcss: {},
5+
},
6+
};
7+
8+
export default config;
Binary file not shown.
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Binary file not shown.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@tailwind base;
2+
@tailwind components;
3+
@tailwind utilities;
4+
5+
@font-face {
6+
font-family: "Geist";
7+
src: url("/fonts/geist.ttf") format("ttf");
8+
font-weight: normal;
9+
font-style: normal;
10+
}
11+
12+
@font-face {
13+
font-family: "Geist Mono";
14+
src: url("/fonts/geist-mono.ttf") format("ttf");
15+
font-weight: normal;
16+
font-style: normal;
17+
}
18+
19+
:root {
20+
--background: #ffffff;
21+
--foreground: #171717;
22+
}
23+
24+
@media (prefers-color-scheme: dark) {
25+
:root {
26+
--background: #0a0a0a;
27+
--foreground: #ededed;
28+
}
29+
}
30+
31+
body {
32+
color: var(--foreground);
33+
background: var(--background);
34+
font-family: Arial, Helvetica, sans-serif;
35+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import type { Metadata } from "next";
2+
import "./globals.css";
3+
4+
export const metadata: Metadata = {
5+
title: "Create Next App",
6+
description: "Generated by create next app",
7+
};
8+
9+
export default function RootLayout({
10+
children,
11+
}: Readonly<{
12+
children: React.ReactNode;
13+
}>) {
14+
return (
15+
<html lang="en">
16+
<body className={`antialiased`} style={{ fontFamily: "Geist" }}>
17+
{children}
18+
</body>
19+
</html>
20+
);
21+
}
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import Image from "next/image";
2+
3+
export default function Home() {
4+
return (
5+
<div className="grid grid-rows-[20px_1fr_20px] items-center justify-items-center min-h-screen p-8 pb-20 gap-16 sm:p-20 font-[family-name:var(--font-geist-sans)]">
6+
<main className="flex flex-col gap-8 row-start-2 items-center sm:items-start">
7+
<Image
8+
className="dark:invert"
9+
src="./images/next.svg"
10+
alt="Next.js logo"
11+
width={180}
12+
height={38}
13+
priority
14+
/>
15+
<ol className="list-inside list-decimal text-sm text-center sm:text-left font-[family-name:var(--font-geist-mono)]">
16+
<li className="mb-2">
17+
Get started by editing{" "}
18+
<code className="bg-black/[.05] dark:bg-white/[.06] px-1 py-0.5 rounded font-semibold">
19+
src/app/page.tsx
20+
</code>
21+
.
22+
</li>
23+
<li>Save and see your changes instantly.</li>
24+
</ol>
25+
26+
<div className="flex gap-4 items-center flex-col sm:flex-row">
27+
<a
28+
className="rounded-full border border-solid border-transparent transition-colors flex items-center justify-center bg-foreground text-background gap-2 hover:bg-[#383838] dark:hover:bg-[#ccc] text-sm sm:text-base h-10 sm:h-12 px-4 sm:px-5"
29+
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
30+
target="_blank"
31+
rel="noopener noreferrer"
32+
>
33+
<Image
34+
className="dark:invert"
35+
src="./images/vercel.svg"
36+
alt="Vercel logomark"
37+
width={20}
38+
height={20}
39+
/>
40+
Deploy now
41+
</a>
42+
<a
43+
className="rounded-full border border-solid border-black/[.08] dark:border-white/[.145] transition-colors flex items-center justify-center hover:bg-[#f2f2f2] dark:hover:bg-[#1a1a1a] hover:border-transparent text-sm sm:text-base h-10 sm:h-12 px-4 sm:px-5 sm:min-w-44"
44+
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
45+
target="_blank"
46+
rel="noopener noreferrer"
47+
>
48+
Read our docs
49+
</a>
50+
</div>
51+
</main>
52+
<footer className="row-start-3 flex gap-6 flex-wrap items-center justify-center">
53+
<a
54+
className="flex items-center gap-2 hover:underline hover:underline-offset-4"
55+
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
56+
target="_blank"
57+
rel="noopener noreferrer"
58+
>
59+
<Image
60+
aria-hidden
61+
src="./images/file.svg"
62+
alt="File icon"
63+
width={16}
64+
height={16}
65+
/>
66+
Learn
67+
</a>
68+
<a
69+
className="flex items-center gap-2 hover:underline hover:underline-offset-4"
70+
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
71+
target="_blank"
72+
rel="noopener noreferrer"
73+
>
74+
<Image
75+
aria-hidden
76+
src="./images/window.svg"
77+
alt="Window icon"
78+
width={16}
79+
height={16}
80+
/>
81+
Examples
82+
</a>
83+
<a
84+
className="flex items-center gap-2 hover:underline hover:underline-offset-4"
85+
href="https://nextjs.org?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
86+
target="_blank"
87+
rel="noopener noreferrer"
88+
>
89+
<Image
90+
aria-hidden
91+
src="./images/globe.svg"
92+
alt="Globe icon"
93+
width={16}
94+
height={16}
95+
/>
96+
Go to nextjs.org →
97+
</a>
98+
</footer>
99+
</div>
100+
);
101+
}

0 commit comments

Comments
 (0)