From 2523bf7be3d4d1cd24fd646f1d8770c896898b3e Mon Sep 17 00:00:00 2001
From: loic <910041@gmail.com>
Date: Sun, 14 Apr 2024 01:21:11 +0800
Subject: [PATCH] Minor changes
---
src/cli.ts | 12 +---
.../__eslintrc.cjs => default/.eslintrc.cjs} | 0
.../{three/__gitignore => default/gitignore} | 0
templates/default/index.html | 12 ++++
templates/default/package.json | 23 +++++++
templates/default/src/App.css | 42 ++++++++++++
templates/default/src/App.jsx | 11 +++
templates/default/src/index.css | 68 +++++++++++++++++++
templates/default/src/main.jsx | 10 +++
templates/default/vite.config.js | 7 ++
templates/three/.eslintrc.cjs | 18 +++++
templates/three/gitignore | 24 +++++++
12 files changed, 216 insertions(+), 11 deletions(-)
rename templates/{three/__eslintrc.cjs => default/.eslintrc.cjs} (100%)
rename templates/{three/__gitignore => default/gitignore} (100%)
create mode 100644 templates/default/index.html
create mode 100644 templates/default/package.json
create mode 100644 templates/default/src/App.css
create mode 100644 templates/default/src/App.jsx
create mode 100644 templates/default/src/index.css
create mode 100644 templates/default/src/main.jsx
create mode 100644 templates/default/vite.config.js
create mode 100644 templates/three/.eslintrc.cjs
create mode 100644 templates/three/gitignore
diff --git a/src/cli.ts b/src/cli.ts
index 4916e57..6dc8d1e 100644
--- a/src/cli.ts
+++ b/src/cli.ts
@@ -6,20 +6,10 @@ import { resolve } from 'path';
const templateRoot = resolve(__dirname, '..', 'templates');
const caveat = `
-This is a caveat!
-You can change this in \`src/cli.ts\`.
+Done!
`;
create('create-gfx', {
templateRoot,
- extra: {
- architecture: {
- type: 'list',
- describe: 'choose your fave os',
- choices: ['macOS', 'Windows', 'Linux'],
- prompt: 'if-no-arg',
- },
- },
- after: ({ answers }) => console.log(`Ok you chose ${answers.architecture}.`),
caveat,
});
diff --git a/templates/three/__eslintrc.cjs b/templates/default/.eslintrc.cjs
similarity index 100%
rename from templates/three/__eslintrc.cjs
rename to templates/default/.eslintrc.cjs
diff --git a/templates/three/__gitignore b/templates/default/gitignore
similarity index 100%
rename from templates/three/__gitignore
rename to templates/default/gitignore
diff --git a/templates/default/index.html b/templates/default/index.html
new file mode 100644
index 0000000..eb98514
--- /dev/null
+++ b/templates/default/index.html
@@ -0,0 +1,12 @@
+
+
+
+
+
+ My R3F App
+
+
+
+
+
+
diff --git a/templates/default/package.json b/templates/default/package.json
new file mode 100644
index 0000000..6abef19
--- /dev/null
+++ b/templates/default/package.json
@@ -0,0 +1,23 @@
+{
+ "name": "three",
+ "private": true,
+ "version": "0.0.0",
+ "type": "module",
+ "scripts": {
+ "dev": "vite",
+ "build": "vite build",
+ "lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
+ "preview": "vite preview"
+ },
+ "dependencies": {
+ "react": "^18.2.0",
+ "react-dom": "^18.2.0"
+ },
+ "devDependencies": {
+ "@vitejs/plugin-react-swc": "^3.5.0",
+ "eslint": "^8.57.0",
+ "eslint-plugin-react-hooks": "^4.6.0",
+ "eslint-plugin-react-refresh": "^0.4.6",
+ "vite": "^5.2.0"
+ }
+}
diff --git a/templates/default/src/App.css b/templates/default/src/App.css
new file mode 100644
index 0000000..b9d355d
--- /dev/null
+++ b/templates/default/src/App.css
@@ -0,0 +1,42 @@
+#root {
+ max-width: 1280px;
+ margin: 0 auto;
+ padding: 2rem;
+ text-align: center;
+}
+
+.logo {
+ height: 6em;
+ padding: 1.5em;
+ will-change: filter;
+ transition: filter 300ms;
+}
+.logo:hover {
+ filter: drop-shadow(0 0 2em #646cffaa);
+}
+.logo.react:hover {
+ filter: drop-shadow(0 0 2em #61dafbaa);
+}
+
+@keyframes logo-spin {
+ from {
+ transform: rotate(0deg);
+ }
+ to {
+ transform: rotate(360deg);
+ }
+}
+
+@media (prefers-reduced-motion: no-preference) {
+ a:nth-of-type(2) .logo {
+ animation: logo-spin infinite 20s linear;
+ }
+}
+
+.card {
+ padding: 2em;
+}
+
+.read-the-docs {
+ color: #888;
+}
diff --git a/templates/default/src/App.jsx b/templates/default/src/App.jsx
new file mode 100644
index 0000000..e84237a
--- /dev/null
+++ b/templates/default/src/App.jsx
@@ -0,0 +1,11 @@
+import { useState } from 'react'
+import './App.css'
+
+function App() {
+ return (
+ <>
+ >
+ )
+}
+
+export default App
diff --git a/templates/default/src/index.css b/templates/default/src/index.css
new file mode 100644
index 0000000..6119ad9
--- /dev/null
+++ b/templates/default/src/index.css
@@ -0,0 +1,68 @@
+:root {
+ font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
+ line-height: 1.5;
+ font-weight: 400;
+
+ color-scheme: light dark;
+ color: rgba(255, 255, 255, 0.87);
+ background-color: #242424;
+
+ font-synthesis: none;
+ text-rendering: optimizeLegibility;
+ -webkit-font-smoothing: antialiased;
+ -moz-osx-font-smoothing: grayscale;
+}
+
+a {
+ font-weight: 500;
+ color: #646cff;
+ text-decoration: inherit;
+}
+a:hover {
+ color: #535bf2;
+}
+
+body {
+ margin: 0;
+ display: flex;
+ place-items: center;
+ min-width: 320px;
+ min-height: 100vh;
+}
+
+h1 {
+ font-size: 3.2em;
+ line-height: 1.1;
+}
+
+button {
+ border-radius: 8px;
+ border: 1px solid transparent;
+ padding: 0.6em 1.2em;
+ font-size: 1em;
+ font-weight: 500;
+ font-family: inherit;
+ background-color: #1a1a1a;
+ cursor: pointer;
+ transition: border-color 0.25s;
+}
+button:hover {
+ border-color: #646cff;
+}
+button:focus,
+button:focus-visible {
+ outline: 4px auto -webkit-focus-ring-color;
+}
+
+@media (prefers-color-scheme: light) {
+ :root {
+ color: #213547;
+ background-color: #ffffff;
+ }
+ a:hover {
+ color: #747bff;
+ }
+ button {
+ background-color: #f9f9f9;
+ }
+}
diff --git a/templates/default/src/main.jsx b/templates/default/src/main.jsx
new file mode 100644
index 0000000..3d7150d
--- /dev/null
+++ b/templates/default/src/main.jsx
@@ -0,0 +1,10 @@
+import React from 'react'
+import ReactDOM from 'react-dom/client'
+import App from './App.tsx'
+import './index.css'
+
+ReactDOM.createRoot(document.getElementById('root')!).render(
+
+
+ ,
+)
diff --git a/templates/default/vite.config.js b/templates/default/vite.config.js
new file mode 100644
index 0000000..861b04b
--- /dev/null
+++ b/templates/default/vite.config.js
@@ -0,0 +1,7 @@
+import { defineConfig } from 'vite'
+import react from '@vitejs/plugin-react-swc'
+
+// https://vitejs.dev/config/
+export default defineConfig({
+ plugins: [react()],
+})
diff --git a/templates/three/.eslintrc.cjs b/templates/three/.eslintrc.cjs
new file mode 100644
index 0000000..d6c9537
--- /dev/null
+++ b/templates/three/.eslintrc.cjs
@@ -0,0 +1,18 @@
+module.exports = {
+ root: true,
+ env: { browser: true, es2020: true },
+ extends: [
+ 'eslint:recommended',
+ 'plugin:@typescript-eslint/recommended',
+ 'plugin:react-hooks/recommended',
+ ],
+ ignorePatterns: ['dist', '.eslintrc.cjs'],
+ parser: '@typescript-eslint/parser',
+ plugins: ['react-refresh'],
+ rules: {
+ 'react-refresh/only-export-components': [
+ 'warn',
+ { allowConstantExport: true },
+ ],
+ },
+}
diff --git a/templates/three/gitignore b/templates/three/gitignore
new file mode 100644
index 0000000..a547bf3
--- /dev/null
+++ b/templates/three/gitignore
@@ -0,0 +1,24 @@
+# Logs
+logs
+*.log
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+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?