create-awarizon-app 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -4,11 +4,14 @@
4
4
  import * as p from "@clack/prompts";
5
5
  import chalk from "chalk";
6
6
  import { Command } from "commander";
7
- import fs from "fs-extra";
8
- import path from "path";
7
+ import fs2 from "fs-extra";
8
+ import path2 from "path";
9
9
  import { execSync } from "child_process";
10
10
  import { fileURLToPath } from "url";
11
- var __dirname = path.dirname(fileURLToPath(import.meta.url));
11
+
12
+ // src/helpers.ts
13
+ import fs from "fs-extra";
14
+ import path from "path";
12
15
  function detectPackageManager() {
13
16
  const ua = process.env.npm_config_user_agent ?? "";
14
17
  if (ua.startsWith("pnpm")) return "pnpm";
@@ -29,6 +32,9 @@ function devCmd(pm, template) {
29
32
  function toPascalCase(str) {
30
33
  return str.replace(/[-_\s]+(.)/g, (_, c) => c.toUpperCase()).replace(/^(.)/, (c) => c.toUpperCase());
31
34
  }
35
+ function resolveTemplateDir(template, lang) {
36
+ return lang === "js" ? `${template}-js` : template;
37
+ }
32
38
  async function processTemplate(dir, projectName, apiKey) {
33
39
  const pascal = toPascalCase(projectName);
34
40
  const entries = await fs.readdir(dir, { withFileTypes: true });
@@ -43,9 +49,9 @@ async function processTemplate(dir, projectName, apiKey) {
43
49
  }
44
50
  }
45
51
  }
46
- function resolveTemplateDir(template, lang) {
47
- return lang === "js" ? `${template}-js` : template;
48
- }
52
+
53
+ // src/index.ts
54
+ var __dirname = path2.dirname(fileURLToPath(import.meta.url));
49
55
  var program = new Command();
50
56
  program.name("create-awarizon-app").description("Scaffold a new project with the Awarizon Web3 SDK").version("1.0.0").argument("[project-name]", "Directory name for the new project").option("-t, --template <template>", "Template: nextjs | react | expo").option("-l, --lang <lang>", "Language: ts | js (default: ts, expo always ts)").option("-k, --api-key <key>", "Your Awarizon API key (awz_live_...)").option("--skip-install", "Skip running npm install after scaffolding").option("--pm <pm>", "Package manager: npm | pnpm | yarn | bun").action(async (nameArg, opts) => {
51
57
  console.log("");
@@ -109,23 +115,23 @@ program.name("create-awarizon-app").description("Scaffold a new project with the
109
115
  apiKey = (res ?? "").trim();
110
116
  }
111
117
  const pm = opts.pm ?? detectPackageManager();
112
- const dest = path.resolve(process.cwd(), projectName);
113
- if (await fs.pathExists(dest)) {
118
+ const dest = path2.resolve(process.cwd(), projectName);
119
+ if (await fs2.pathExists(dest)) {
114
120
  p.log.error(`Directory "${projectName}" already exists.`);
115
121
  process.exit(1);
116
122
  }
117
123
  const templateKey = resolveTemplateDir(template, lang);
118
- const templateDir = path.join(__dirname, "..", "templates", templateKey);
119
- if (!await fs.pathExists(templateDir)) {
124
+ const templateDir = path2.join(__dirname, "..", "templates", templateKey);
125
+ if (!await fs2.pathExists(templateDir)) {
120
126
  p.log.error(`Template "${templateKey}" not found. This is a bug \u2014 please report it.`);
121
127
  process.exit(1);
122
128
  }
123
129
  const spinner2 = p.spinner();
124
130
  spinner2.start("Copying template\u2026");
125
- await fs.copy(templateDir, dest);
126
- const gitignoreSrc = path.join(dest, "_gitignore");
127
- if (await fs.pathExists(gitignoreSrc)) {
128
- await fs.rename(gitignoreSrc, path.join(dest, ".gitignore"));
131
+ await fs2.copy(templateDir, dest);
132
+ const gitignoreSrc = path2.join(dest, "_gitignore");
133
+ if (await fs2.pathExists(gitignoreSrc)) {
134
+ await fs2.rename(gitignoreSrc, path2.join(dest, ".gitignore"));
129
135
  }
130
136
  await processTemplate(dest, projectName, apiKey);
131
137
  spinner2.stop("Template copied.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-awarizon-app",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Scaffold a new project with the Awarizon Web3 SDK",
5
5
  "keywords": [
6
6
  "awarizon",
@@ -20,11 +20,6 @@
20
20
  "dist",
21
21
  "templates"
22
22
  ],
23
- "scripts": {
24
- "build": "tsup",
25
- "dev": "tsup --watch",
26
- "clean": "rimraf dist"
27
- },
28
23
  "dependencies": {
29
24
  "@clack/prompts": "^0.9.1",
30
25
  "chalk": "^5.3.0",
@@ -37,9 +32,16 @@
37
32
  "@types/node": "^20.0.0",
38
33
  "rimraf": "^5.0.0",
39
34
  "tsup": "^8.0.0",
40
- "typescript": "^5.5.0"
35
+ "typescript": "^5.5.0",
36
+ "vitest": "^2.0.0"
41
37
  },
42
38
  "engines": {
43
39
  "node": ">=18"
40
+ },
41
+ "scripts": {
42
+ "build": "tsup",
43
+ "dev": "tsup --watch",
44
+ "test": "vitest run",
45
+ "clean": "rimraf dist"
44
46
  }
45
- }
47
+ }
@@ -1,17 +1,17 @@
1
1
  import { Stack } from 'expo-router'
2
+ import { AwarizonWeb3 } from '@awarizon/web3'
2
3
  import { AwarizonProvider } from '@awarizon/react-native'
3
4
 
5
+ // Create the SDK instance once at the module level.
6
+ // apiKey: from EXPO_PUBLIC_AWARIZON_API_KEY in .env
7
+ const awarizon = new AwarizonWeb3({
8
+ chain: 'base',
9
+ apiKey: process.env.EXPO_PUBLIC_AWARIZON_API_KEY!,
10
+ })
11
+
4
12
  export default function RootLayout() {
5
13
  return (
6
- /*
7
- AwarizonProvider makes the SDK available throughout the app.
8
- chain: EVM network — base, ethereum, polygon, etc.
9
- apiKey: from EXPO_PUBLIC_AWARIZON_API_KEY in .env
10
- */
11
- <AwarizonProvider
12
- chain="base"
13
- apiKey={process.env.EXPO_PUBLIC_AWARIZON_API_KEY!}
14
- >
14
+ <AwarizonProvider awarizon={awarizon}>
15
15
  <Stack
16
16
  screenOptions={{
17
17
  headerStyle: { backgroundColor: '#000' },
@@ -1,4 +1,4 @@
1
- {
1
+ {
2
2
  "name": "{{project-name}}",
3
3
  "version": "1.0.0",
4
4
  "main": "expo-router/entry",
@@ -9,7 +9,7 @@
9
9
  "web": "expo start --web"
10
10
  },
11
11
  "dependencies": {
12
- "@awarizon/react-native": "^1.0.2",
12
+ "@awarizon/react-native": "^1.2.0",
13
13
  "@awarizon/web3": "^1.3.1",
14
14
  "@expo/vector-icons": "^14.0.2",
15
15
  "expo": "~51.0.0",
@@ -33,3 +33,4 @@
33
33
  "typescript": "^5.3.3"
34
34
  }
35
35
  }
36
+
@@ -1,17 +1,17 @@
1
1
  import { Stack } from 'expo-router'
2
+ import { AwarizonWeb3 } from '@awarizon/web3'
2
3
  import { AwarizonProvider } from '@awarizon/react-native'
3
4
 
5
+ // Create the SDK instance once at the module level.
6
+ // apiKey: from EXPO_PUBLIC_AWARIZON_API_KEY in .env
7
+ const awarizon = new AwarizonWeb3({
8
+ chain: 'base',
9
+ apiKey: process.env.EXPO_PUBLIC_AWARIZON_API_KEY,
10
+ })
11
+
4
12
  export default function RootLayout() {
5
13
  return (
6
- /*
7
- AwarizonProvider makes the SDK available throughout the app.
8
- chain: EVM network — base, ethereum, polygon, etc.
9
- apiKey: from EXPO_PUBLIC_AWARIZON_API_KEY in .env
10
- */
11
- <AwarizonProvider
12
- chain="base"
13
- apiKey={process.env.EXPO_PUBLIC_AWARIZON_API_KEY}
14
- >
14
+ <AwarizonProvider awarizon={awarizon}>
15
15
  <Stack
16
16
  screenOptions={{
17
17
  headerStyle: { backgroundColor: '#000' },
@@ -1,4 +1,4 @@
1
- {
1
+ {
2
2
  "name": "{{project-name}}",
3
3
  "version": "1.0.0",
4
4
  "main": "expo-router/entry",
@@ -9,7 +9,7 @@
9
9
  "web": "expo start --web"
10
10
  },
11
11
  "dependencies": {
12
- "@awarizon/react-native": "^1.0.2",
12
+ "@awarizon/react-native": "^1.2.0",
13
13
  "@awarizon/web3": "^1.3.1",
14
14
  "@expo/vector-icons": "^14.0.2",
15
15
  "expo": "~51.0.0",
@@ -31,3 +31,4 @@
31
31
  "@babel/core": "^7.24.0"
32
32
  }
33
33
  }
34
+
@@ -1,5 +1,5 @@
1
1
  import type { Metadata } from 'next'
2
- import { AwarizonProvider } from '@awarizon/react'
2
+ import { Providers } from '@/components/Providers'
3
3
  import './globals.css'
4
4
 
5
5
  export const metadata: Metadata = {
@@ -11,18 +11,7 @@ export default function RootLayout({ children }: { children: React.ReactNode })
11
11
  return (
12
12
  <html lang="en">
13
13
  <body>
14
- {/*
15
- AwarizonProvider makes the SDK available to all Client Components.
16
- chain: the EVM network to connect to (base, ethereum, polygon, etc.)
17
- apiKey: your Awarizon API key — get one at awarizon.com/dashboard/api-keys
18
- */}
19
- <AwarizonProvider
20
- chain="base"
21
- apiKey={process.env.NEXT_PUBLIC_AWARIZON_API_KEY!}
22
- walletConnectProjectId={process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID}
23
- >
24
- {children}
25
- </AwarizonProvider>
14
+ <Providers>{children}</Providers>
26
15
  </body>
27
16
  </html>
28
17
  )
@@ -0,0 +1,18 @@
1
+ 'use client'
2
+
3
+ import type { ReactNode } from 'react'
4
+ import { AwarizonWeb3 } from '@awarizon/web3'
5
+ import { AwarizonProvider } from '@awarizon/react'
6
+
7
+ // Created once at module level — survives across re-renders without re-instantiation.
8
+ // chain: EVM network — base, ethereum, polygon, etc.
9
+ // apiKey: from NEXT_PUBLIC_AWARIZON_API_KEY in .env.local
10
+ const awarizon = new AwarizonWeb3({
11
+ chain: 'base',
12
+ apiKey: process.env.NEXT_PUBLIC_AWARIZON_API_KEY!,
13
+ walletConnectProjectId: process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID,
14
+ })
15
+
16
+ export function Providers({ children }: { children: ReactNode }) {
17
+ return <AwarizonProvider awarizon={awarizon}>{children}</AwarizonProvider>
18
+ }
@@ -1,4 +1,4 @@
1
- {
1
+ {
2
2
  "name": "{{project-name}}",
3
3
  "version": "0.1.0",
4
4
  "private": true,
@@ -9,7 +9,7 @@
9
9
  "lint": "next lint"
10
10
  },
11
11
  "dependencies": {
12
- "@awarizon/react": "^1.4.1",
12
+ "@awarizon/react": "^1.6.0",
13
13
  "@awarizon/web3": "^1.3.1",
14
14
  "next": "14.2.5",
15
15
  "react": "^18",
@@ -27,3 +27,4 @@
27
27
  "tailwindcss": "^3.4.4"
28
28
  }
29
29
  }
30
+
@@ -1,4 +1,4 @@
1
- import { AwarizonProvider } from '@awarizon/react'
1
+ import { Providers } from '@/components/Providers'
2
2
  import './globals.css'
3
3
 
4
4
  /** @type {import('next').Metadata} */
@@ -11,18 +11,7 @@ export default function RootLayout({ children }) {
11
11
  return (
12
12
  <html lang="en">
13
13
  <body>
14
- {/*
15
- AwarizonProvider makes the SDK available to all Client Components.
16
- chain: the EVM network to connect to (base, ethereum, polygon, etc.)
17
- apiKey: your Awarizon API key — get one at awarizon.com/dashboard/api-keys
18
- */}
19
- <AwarizonProvider
20
- chain="base"
21
- apiKey={process.env.NEXT_PUBLIC_AWARIZON_API_KEY}
22
- walletConnectProjectId={process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID}
23
- >
24
- {children}
25
- </AwarizonProvider>
14
+ <Providers>{children}</Providers>
26
15
  </body>
27
16
  </html>
28
17
  )
@@ -0,0 +1,18 @@
1
+ 'use client'
2
+
3
+ import { AwarizonWeb3 } from '@awarizon/web3'
4
+ import { AwarizonProvider } from '@awarizon/react'
5
+
6
+ // Created once at module level — survives across re-renders without re-instantiation.
7
+ // chain: EVM network — base, ethereum, polygon, etc.
8
+ // apiKey: from NEXT_PUBLIC_AWARIZON_API_KEY in .env.local
9
+ const awarizon = new AwarizonWeb3({
10
+ chain: 'base',
11
+ apiKey: process.env.NEXT_PUBLIC_AWARIZON_API_KEY,
12
+ walletConnectProjectId: process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID,
13
+ })
14
+
15
+ /** @param {{ children: import('react').ReactNode }} props */
16
+ export function Providers({ children }) {
17
+ return <AwarizonProvider awarizon={awarizon}>{children}</AwarizonProvider>
18
+ }
@@ -1,4 +1,4 @@
1
- {
1
+ {
2
2
  "name": "{{project-name}}",
3
3
  "version": "0.1.0",
4
4
  "private": true,
@@ -9,7 +9,7 @@
9
9
  "lint": "next lint"
10
10
  },
11
11
  "dependencies": {
12
- "@awarizon/react": "^1.4.1",
12
+ "@awarizon/react": "^1.6.0",
13
13
  "@awarizon/web3": "^1.3.1",
14
14
  "next": "14.2.5",
15
15
  "react": "^18",
@@ -23,3 +23,4 @@
23
23
  "tailwindcss": "^3.4.4"
24
24
  }
25
25
  }
26
+
@@ -1,4 +1,4 @@
1
- {
1
+ {
2
2
  "name": "{{project-name}}",
3
3
  "version": "0.1.0",
4
4
  "private": true,
@@ -10,7 +10,7 @@
10
10
  "lint": "eslint ."
11
11
  },
12
12
  "dependencies": {
13
- "@awarizon/react": "^1.4.1",
13
+ "@awarizon/react": "^1.6.0",
14
14
  "@awarizon/web3": "^1.3.1",
15
15
  "react": "^18.3.1",
16
16
  "react-dom": "^18.3.1"
@@ -26,3 +26,4 @@
26
26
  "tailwindcss": "^3.4.4"
27
27
  }
28
28
  }
29
+
@@ -1,21 +1,22 @@
1
1
  import { StrictMode } from 'react'
2
2
  import { createRoot } from 'react-dom/client'
3
+ import { AwarizonWeb3 } from '@awarizon/web3'
3
4
  import { AwarizonProvider } from '@awarizon/react'
4
5
  import App from './App'
5
6
  import './index.css'
6
7
 
8
+ // Create the SDK instance once at the module level.
9
+ // chain: EVM network — base, ethereum, polygon, arbitrum, etc.
10
+ // apiKey: from VITE_AWARIZON_API_KEY in .env
11
+ const awarizon = new AwarizonWeb3({
12
+ chain: 'base',
13
+ apiKey: import.meta.env.VITE_AWARIZON_API_KEY,
14
+ walletConnectProjectId: import.meta.env.VITE_WALLETCONNECT_PROJECT_ID,
15
+ })
16
+
7
17
  createRoot(document.getElementById('root')!).render(
8
18
  <StrictMode>
9
- {/*
10
- AwarizonProvider wraps your app once.
11
- chain: EVM network — base, ethereum, polygon, arbitrum, etc.
12
- apiKey: from VITE_AWARIZON_API_KEY in .env
13
- */}
14
- <AwarizonProvider
15
- chain="base"
16
- apiKey={import.meta.env.VITE_AWARIZON_API_KEY}
17
- walletConnectProjectId={import.meta.env.VITE_WALLETCONNECT_PROJECT_ID}
18
- >
19
+ <AwarizonProvider awarizon={awarizon}>
19
20
  <App />
20
21
  </AwarizonProvider>
21
22
  </StrictMode>,
@@ -1,4 +1,4 @@
1
- {
1
+ {
2
2
  "name": "{{project-name}}",
3
3
  "version": "0.1.0",
4
4
  "private": true,
@@ -10,7 +10,7 @@
10
10
  "lint": "eslint ."
11
11
  },
12
12
  "dependencies": {
13
- "@awarizon/react": "^1.4.1",
13
+ "@awarizon/react": "^1.6.0",
14
14
  "@awarizon/web3": "^1.3.1",
15
15
  "react": "^18.3.1",
16
16
  "react-dom": "^18.3.1"
@@ -23,3 +23,4 @@
23
23
  "tailwindcss": "^3.4.4"
24
24
  }
25
25
  }
26
+
@@ -1,21 +1,22 @@
1
1
  import { StrictMode } from 'react'
2
2
  import { createRoot } from 'react-dom/client'
3
+ import { AwarizonWeb3 } from '@awarizon/web3'
3
4
  import { AwarizonProvider } from '@awarizon/react'
4
5
  import App from './App'
5
6
  import './index.css'
6
7
 
8
+ // Create the SDK instance once at the module level.
9
+ // chain: EVM network — base, ethereum, polygon, arbitrum, etc.
10
+ // apiKey: from VITE_AWARIZON_API_KEY in .env
11
+ const awarizon = new AwarizonWeb3({
12
+ chain: 'base',
13
+ apiKey: import.meta.env.VITE_AWARIZON_API_KEY,
14
+ walletConnectProjectId: import.meta.env.VITE_WALLETCONNECT_PROJECT_ID,
15
+ })
16
+
7
17
  createRoot(document.getElementById('root')).render(
8
18
  <StrictMode>
9
- {/*
10
- AwarizonProvider wraps your app once.
11
- chain: EVM network — base, ethereum, polygon, arbitrum, etc.
12
- apiKey: from VITE_AWARIZON_API_KEY in .env
13
- */}
14
- <AwarizonProvider
15
- chain="base"
16
- apiKey={import.meta.env.VITE_AWARIZON_API_KEY}
17
- walletConnectProjectId={import.meta.env.VITE_WALLETCONNECT_PROJECT_ID}
18
- >
19
+ <AwarizonProvider awarizon={awarizon}>
19
20
  <App />
20
21
  </AwarizonProvider>
21
22
  </StrictMode>,