-
-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve "create" package structure (#146)
* Improve "create" package structure
- Loading branch information
1 parent
fe1658f
commit f21e0c3
Showing
747 changed files
with
1,758 additions
and
8,345 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
|
||
# Get the absolute path of the root directory | ||
ROOT_DIR=$(pwd) | ||
|
||
# Function to recursively remove .git folders | ||
remove_git_folders() { | ||
local dir="$1" | ||
|
||
# Iterate over all directories in the current directory | ||
for subdir in "$dir"/*; do | ||
if [ -d "$subdir" ]; then | ||
# Skip node_modules directories | ||
if [[ $(basename "$subdir") == "node_modules" ]]; then | ||
continue | ||
fi | ||
|
||
# Remove .git directory if it's not the root level | ||
if [[ $(basename "$subdir") == ".git" ]] && [[ "$subdir" != "$ROOT_DIR/.git" ]]; then | ||
echo "Removing $subdir" | ||
rm -rf "$subdir" | ||
fi | ||
|
||
# Recurse into subdirectories | ||
remove_git_folders "$subdir" | ||
fi | ||
done | ||
} | ||
|
||
# Start the recursive removal from the current directory | ||
remove_git_folders "$ROOT_DIR" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
import {useState, type FormEvent} from 'react' | ||
import OpenAI from 'openai' | ||
import chatgptLogo from '../images/chatgpt.png' | ||
import extensionJsLogo from '../images/extension_128.png' | ||
|
||
const openai = new OpenAI({ | ||
apiKey: process.env.EXTENSION_OPENAI_API_KEY!, | ||
dangerouslyAllowBrowser: true | ||
}) | ||
|
||
interface Message { | ||
content: string | ||
role: 'user' | 'assistant' | ||
} | ||
|
||
function ActionApp() { | ||
const [messages, setMessages] = useState<Message[]>([ | ||
{ | ||
content: | ||
'Hello there! This is your ChatGPT extension sample, ' + | ||
'built with React, Tailwind.css, and DaisyUI. ' + | ||
'For it to work, create a .env file with your EXTENSION_OPENAI_API_KEY. ' + | ||
"You can get an API key from OpenAI's website????", | ||
role: 'assistant' | ||
}, | ||
{ | ||
content: 'https://platform.openai.com/api-keys', | ||
role: 'assistant' | ||
} | ||
]) | ||
|
||
const [isTyping, setIsTyping] = useState(false) | ||
|
||
const handleSubmit = async (e: FormEvent<HTMLFormElement>) => { | ||
e.preventDefault() | ||
|
||
const form = e.target as HTMLFormElement | ||
const input = form[0] as HTMLInputElement | ||
|
||
const newMessage: Message = { | ||
content: input.value, | ||
role: 'user' | ||
} | ||
|
||
const newMessages = [...messages, newMessage] | ||
|
||
setMessages(newMessages) | ||
setIsTyping(true) | ||
form.reset() | ||
|
||
const completion = await openai.chat.completions.create({ | ||
model: 'gpt-3.5-turbo', | ||
messages: newMessages | ||
}) | ||
|
||
setMessages([...newMessages, completion.choices[0].message as Message]) | ||
setIsTyping(false) | ||
} | ||
|
||
return ( | ||
<section className="container mx-auto p-5 fixed inset-0"> | ||
<div className="w-full h-full flex flex-col"> | ||
<div className="flex-grow overflow-auto"> | ||
{messages.length && | ||
messages.map((msg, i) => ( | ||
<div | ||
className={`chat ${msg.role === 'assistant' ? 'chat-start' : 'chat-end'}`} | ||
key={'chatKey' + i} | ||
> | ||
<div className="chat-image avatar"> | ||
<div className="w-10 rounded-full"> | ||
<img | ||
src={ | ||
msg.role === 'assistant' ? chatgptLogo : extensionJsLogo | ||
} | ||
alt="avatar" | ||
/> | ||
</div> | ||
</div> | ||
<div className="chat-bubble">{msg.content}</div> | ||
</div> | ||
))} | ||
</div> | ||
|
||
<form className="form-control items-center" onSubmit={handleSubmit}> | ||
<div className="input-group max-w-full w-[800px] relative flex items-center"> | ||
{isTyping && ( | ||
<small className="absolute -top-5 left-0.5 animate-pulse"> | ||
ChatGPT Extension is typing... | ||
</small> | ||
)} | ||
|
||
<input | ||
type="text" | ||
placeholder="Ask ChatGPT a question." | ||
className="input input-bordered flex-grow mr-2.5" | ||
required | ||
/> | ||
<button className="btn btn-square" type="submit"> | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
className="h-6 w-6" | ||
fill="currentColor" | ||
viewBox="0 0 16 16" | ||
> | ||
<path d="M15.854.146a.5.5 0 0 1 .11.54l-5.819 14.547a.75.75 0 0 1-1.329.124l-3.178-4.995L.643 7.184a.75.75 0 0 1 .124-1.33L15.314.037a.5.5 0 0 1 .54.11ZM6.636 10.07l2.761 4.338L14.13 2.576 6.636 10.07Zm6.787-8.201L1.591 6.602l4.339 2.76 7.494-7.493Z" /> | ||
</svg> | ||
</button> | ||
</div> | ||
</form> | ||
</div> | ||
</section> | ||
) | ||
} | ||
|
||
export default ActionApp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Required Extension.js types for TypeScript projects. | ||
// This file is auto-generated and should not be excluded. | ||
// If you need extra types, consider creating a new *.d.ts and | ||
// referencing it in the "include" array of your tsconfig.json file. | ||
// See https://www.typescriptlang.org/tsconfig#include for info. | ||
/// <reference types="../../programs/develop/dist/types/index.d.ts" /> | ||
|
||
// Polyfill types for browser.* APIs. | ||
/// <reference types="../../programs/develop/dist/types/polyfill.d.ts" /> |
File renamed without changes
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"manifest_version": 3, | ||
"version": "0.0.1", | ||
"name": "Action ChatGPT Template", | ||
"description": "An Extension.js example.", | ||
"icons": { | ||
"16": "images/extension_16.png", | ||
"48": "images/extension_48.png", | ||
"128": "images/extension_128.png" | ||
}, | ||
"action": { | ||
"default_icon": { | ||
"16": "images/extension_16.png", | ||
"48": "images/extension_48.png", | ||
"128": "images/extension_128.png" | ||
}, | ||
"default_title": "ChatGPT", | ||
"default_popup": "action/index.html" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,14 @@ | ||
{ | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/cezaraugusto/extension.git", | ||
"directory": "programs/create/templates/chatgpt" | ||
}, | ||
"name": "chatgpt", | ||
"private": true, | ||
"name": "action-chatgpt", | ||
"description": "An Extension.js example.", | ||
"version": "0.0.1", | ||
"author": { | ||
"name": "Cezar Augusto", | ||
"email": "[email protected]", | ||
"url": "https://cezaraugusto.com" | ||
}, | ||
"files": [ | ||
"template", | ||
"template.json" | ||
], | ||
"keywords": [ | ||
"extension", | ||
"browser-extension", | ||
"web-extension", | ||
"template" | ||
], | ||
"license": "MIT", | ||
"dependencies": { | ||
"daisyui": "^4.12.10", | ||
"openai": "^4.54.0", | ||
|
@@ -32,6 +18,7 @@ | |
}, | ||
"devDependencies": { | ||
"@types/react": "^18.0.9", | ||
"@types/react-dom": "^18.0.5" | ||
"@types/react-dom": "^18.0.5", | ||
"typescript": "5.3.3" | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,5 @@ module.exports = { | |
theme: { | ||
extend: {} | ||
}, | ||
plugins: [] | ||
plugins: [require('daisyui')] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,20 @@ | ||
{ | ||
"manifest_version": 3, | ||
"version": "0.0.1", | ||
"name": "action", | ||
"name": "Action Template", | ||
"description": "An Extension.js example.", | ||
"author": "Cezar Augusto", | ||
"icons": { | ||
"16": "images/extension_16.png", | ||
"48": "images/extension_48.png", | ||
"128": "images/extension_128.png" | ||
}, | ||
"action": { | ||
"default_popup": "action/index.html", | ||
"default_title": "Action", | ||
"default_icon": { | ||
"16": "test_16.png", | ||
"48": "test_48.png", | ||
"128": "public/icon.png" | ||
"16": "images/extension_16.png", | ||
"48": "images/extension_48.png", | ||
"128": "images/extension_128.png" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,5 @@ | ||
{ | ||
"private": true, | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/extension-js/extension.git", | ||
"directory": "examples/action" | ||
}, | ||
"name": "action", | ||
"description": "An Extension.js example.", | ||
"version": "0.0.1", | ||
|
@@ -14,10 +8,5 @@ | |
"email": "[email protected]", | ||
"url": "https://cezaraugusto.com" | ||
}, | ||
"keywords": [ | ||
"extension", | ||
"browser-extension", | ||
"web-extension", | ||
"template" | ||
] | ||
"license": "MIT" | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.