mirror of
https://github.com/f/awesome-chatgpt-prompts.git
synced 2026-02-12 15:52:47 +00:00
chore(prompts.chat): bump version to 0.1.0 and add 'new' command in CLI
This commit is contained in:
4
packages/prompts.chat/package-lock.json
generated
4
packages/prompts.chat/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "prompts.chat",
|
||||
"version": "0.0.9",
|
||||
"version": "0.1.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "prompts.chat",
|
||||
"version": "0.0.9",
|
||||
"version": "0.1.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"clipboardy": "^4.0.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "prompts.chat",
|
||||
"version": "0.0.9",
|
||||
"version": "0.1.0",
|
||||
"description": "Developer toolkit for AI prompts - build, validate, parse, and connect to prompts.chat",
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
|
||||
@@ -5,6 +5,7 @@ import clipboardy from 'clipboardy';
|
||||
import { PromptList } from './components/PromptList.js';
|
||||
import { PromptDetail } from './components/PromptDetail.js';
|
||||
import type { Prompt } from './api.js';
|
||||
import { createNew } from './new.js';
|
||||
|
||||
type View = 'list' | 'detail';
|
||||
|
||||
@@ -99,16 +100,17 @@ function App() {
|
||||
|
||||
const cli = meow(`
|
||||
Usage
|
||||
$ prompts-chat
|
||||
$ prompts-chat [command] [options]
|
||||
|
||||
Commands
|
||||
(default) Launch interactive TUI
|
||||
new <dir> Create a new prompts.chat instance
|
||||
|
||||
Options
|
||||
--help Show this help
|
||||
--version Show version
|
||||
|
||||
Navigation
|
||||
Navigation (TUI)
|
||||
↑/↓ or j/k Navigate list
|
||||
Enter Select prompt
|
||||
/ Search prompts
|
||||
@@ -122,13 +124,29 @@ const cli = meow(`
|
||||
|
||||
Examples
|
||||
$ npx prompts.chat
|
||||
$ npx prompts.chat new my-prompts
|
||||
$ prompts-chat
|
||||
`, {
|
||||
importMeta: import.meta,
|
||||
flags: {},
|
||||
});
|
||||
|
||||
function main() {
|
||||
async function main() {
|
||||
const [command, ...args] = cli.input;
|
||||
|
||||
// Handle 'new' command
|
||||
if (command === 'new') {
|
||||
const directory = args[0];
|
||||
if (!directory) {
|
||||
console.error('\n❌ Please specify a directory name.\n');
|
||||
console.error(' Usage: npx prompts.chat new <directory>\n');
|
||||
process.exit(1);
|
||||
}
|
||||
await createNew({ directory });
|
||||
return;
|
||||
}
|
||||
|
||||
// Default: Launch interactive TUI
|
||||
console.clear();
|
||||
|
||||
const { waitUntilExit } = render(<App />, {
|
||||
|
||||
116
packages/prompts.chat/src/cli/new.ts
Normal file
116
packages/prompts.chat/src/cli/new.ts
Normal file
@@ -0,0 +1,116 @@
|
||||
import { spawn, execSync } from 'child_process';
|
||||
import { existsSync, rmSync, readdirSync } from 'fs';
|
||||
import { join, resolve } from 'path';
|
||||
|
||||
const REPO = 'f/awesome-chatgpt-prompts';
|
||||
|
||||
interface NewOptions {
|
||||
directory: string;
|
||||
}
|
||||
|
||||
function removeFiles(baseDir: string): void {
|
||||
const toRemove = [
|
||||
'.github',
|
||||
'.claude',
|
||||
'packages',
|
||||
];
|
||||
|
||||
// Remove directories
|
||||
for (const item of toRemove) {
|
||||
const itemPath = join(baseDir, item);
|
||||
if (existsSync(itemPath)) {
|
||||
console.log(` Removing ${item}/`);
|
||||
rmSync(itemPath, { recursive: true, force: true });
|
||||
}
|
||||
}
|
||||
|
||||
// Remove scripts/generate* and scripts/rebuild* files
|
||||
const scriptsDir = join(baseDir, 'scripts');
|
||||
if (existsSync(scriptsDir)) {
|
||||
const files = readdirSync(scriptsDir);
|
||||
for (const file of files) {
|
||||
if (file.startsWith('generate') || file.startsWith('rebuild')) {
|
||||
const filePath = join(scriptsDir, file);
|
||||
console.log(` Removing scripts/${file}`);
|
||||
rmSync(filePath, { force: true });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function runSetup(baseDir: string): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const setupScript = join(baseDir, 'scripts', 'setup.js');
|
||||
|
||||
if (!existsSync(setupScript)) {
|
||||
console.log('\n⚠ Setup script not found, skipping interactive setup.');
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('\n🚀 Starting interactive setup...\n');
|
||||
|
||||
const child = spawn('node', [setupScript], {
|
||||
cwd: baseDir,
|
||||
stdio: 'inherit',
|
||||
});
|
||||
|
||||
child.on('close', (code) => {
|
||||
if (code === 0) {
|
||||
resolve();
|
||||
} else {
|
||||
reject(new Error(`Setup exited with code ${code}`));
|
||||
}
|
||||
});
|
||||
|
||||
child.on('error', (err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export async function createNew(options: NewOptions): Promise<void> {
|
||||
const targetDir = resolve(process.cwd(), options.directory);
|
||||
|
||||
if (existsSync(targetDir)) {
|
||||
const files = readdirSync(targetDir);
|
||||
if (files.length > 0) {
|
||||
console.error(`\n❌ Directory "${options.directory}" already exists and is not empty.`);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
console.log('\n📦 Creating new prompts.chat instance...\n');
|
||||
|
||||
// Use degit to clone the repo
|
||||
try {
|
||||
console.log(` Cloning ${REPO}...`);
|
||||
execSync(`npx degit ${REPO} "${targetDir}"`, { stdio: 'inherit' });
|
||||
} catch (error) {
|
||||
console.error('\n❌ Failed to clone repository. Make sure you have internet connection.');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Remove unnecessary files
|
||||
console.log('\n🧹 Cleaning up files...\n');
|
||||
removeFiles(targetDir);
|
||||
|
||||
// Install dependencies
|
||||
console.log('\n📥 Installing dependencies...\n');
|
||||
try {
|
||||
execSync('npm install', { cwd: targetDir, stdio: 'inherit' });
|
||||
} catch (error) {
|
||||
console.error('\n⚠ Failed to install dependencies. You can run "npm install" manually.');
|
||||
}
|
||||
|
||||
// Run the setup script
|
||||
try {
|
||||
await runSetup(targetDir);
|
||||
} catch (error) {
|
||||
console.error('\n⚠ Setup failed:', (error as Error).message);
|
||||
}
|
||||
|
||||
console.log('\n✅ Done! Your prompts.chat instance is ready.\n');
|
||||
console.log(` cd ${options.directory}`);
|
||||
console.log(' npm run dev\n');
|
||||
}
|
||||
@@ -65,7 +65,10 @@ export default defineConfig({
|
||||
changeRequests: ${config.features.changeRequests},
|
||||
categories: ${config.features.categories},
|
||||
tags: ${config.features.tags},
|
||||
comments: ${config.features.comments},
|
||||
aiSearch: ${config.features.aiSearch},
|
||||
aiGeneration: ${config.features.aiGeneration},
|
||||
mcp: ${config.features.mcp},
|
||||
},
|
||||
|
||||
// Homepage customization (clone branding mode)
|
||||
@@ -189,6 +192,7 @@ async function main() {
|
||||
options: [
|
||||
{ value: 'github', label: 'GitHub OAuth', hint: 'Most popular for developers' },
|
||||
{ value: 'google', label: 'Google OAuth', hint: 'Widely used' },
|
||||
{ value: 'apple', label: 'Apple Sign In', hint: 'Sign in with Apple' },
|
||||
{ value: 'azure', label: 'Microsoft Azure AD', hint: 'Enterprise SSO' },
|
||||
{ value: 'credentials', label: 'Email/Password', hint: 'Traditional auth' },
|
||||
],
|
||||
@@ -266,9 +270,12 @@ async function main() {
|
||||
{ value: 'changeRequests', label: 'Change Requests', hint: 'Version control system' },
|
||||
{ value: 'categories', label: 'Categories', hint: 'Organize prompts by category' },
|
||||
{ value: 'tags', label: 'Tags', hint: 'Tag-based organization' },
|
||||
{ value: 'comments', label: 'Comments', hint: 'Allow comments on prompts' },
|
||||
{ value: 'aiSearch', label: 'AI Search', hint: 'Requires OPENAI_API_KEY' },
|
||||
{ value: 'aiGeneration', label: 'AI Generation', hint: 'AI-powered prompt generation (requires OPENAI_API_KEY)' },
|
||||
{ value: 'mcp', label: 'MCP Support', hint: 'Model Context Protocol features & API keys' },
|
||||
],
|
||||
initialValues: ['privatePrompts', 'changeRequests', 'categories', 'tags'],
|
||||
initialValues: ['privatePrompts', 'changeRequests', 'categories', 'tags', 'comments'],
|
||||
required: false,
|
||||
});
|
||||
|
||||
@@ -279,7 +286,10 @@ async function main() {
|
||||
changeRequests: features.includes('changeRequests'),
|
||||
categories: features.includes('categories'),
|
||||
tags: features.includes('tags'),
|
||||
comments: features.includes('comments'),
|
||||
aiSearch: features.includes('aiSearch'),
|
||||
aiGeneration: features.includes('aiGeneration'),
|
||||
mcp: features.includes('mcp'),
|
||||
};
|
||||
|
||||
// === SPONSORS ===
|
||||
@@ -393,8 +403,12 @@ async function main() {
|
||||
envVars.push('AUTH_AZURE_AD_CLIENT_SECRET - Azure AD client secret');
|
||||
envVars.push('AUTH_AZURE_AD_ISSUER - Azure AD issuer URL');
|
||||
}
|
||||
if (config.features.aiSearch) {
|
||||
envVars.push('OPENAI_API_KEY - OpenAI API key for semantic search');
|
||||
if (config.auth.providers.includes('apple')) {
|
||||
envVars.push('AUTH_APPLE_ID - Apple Services ID');
|
||||
envVars.push('AUTH_APPLE_SECRET - Apple secret key');
|
||||
}
|
||||
if (config.features.aiSearch || config.features.aiGeneration) {
|
||||
envVars.push('OPENAI_API_KEY - OpenAI API key for AI features');
|
||||
}
|
||||
|
||||
p.note(envVars.join('\n'), 'Required environment variables');
|
||||
|
||||
Reference in New Issue
Block a user