promptlineapp 1.5.0 → 1.6.0
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/README.md +1 -1
- package/bin/cli.js +153 -9
- package/package.json +1 -1
package/README.md
CHANGED
package/bin/cli.js
CHANGED
|
@@ -2059,13 +2059,26 @@ ${c.bold}Documentation:${c.reset} ${c.cyan}https://docs.promptlineops.com${c.res
|
|
|
2059
2059
|
function parseArgs() {
|
|
2060
2060
|
const args = process.argv.slice(2);
|
|
2061
2061
|
const options = {
|
|
2062
|
+
command: 'new', // 'new' or 'get'
|
|
2062
2063
|
name: null,
|
|
2064
|
+
source: null, // Git URL for 'get' command
|
|
2063
2065
|
preset: null,
|
|
2064
2066
|
yes: false,
|
|
2065
2067
|
help: false,
|
|
2066
2068
|
version: false,
|
|
2067
2069
|
};
|
|
2068
2070
|
|
|
2071
|
+
// Detect 'get' command
|
|
2072
|
+
if (args[0] === 'get') {
|
|
2073
|
+
options.command = 'get';
|
|
2074
|
+
options.source = args[1];
|
|
2075
|
+
// Optional: destination name as third argument
|
|
2076
|
+
if (args[2] && !args[2].startsWith('-')) {
|
|
2077
|
+
options.name = args[2];
|
|
2078
|
+
}
|
|
2079
|
+
return options;
|
|
2080
|
+
}
|
|
2081
|
+
|
|
2069
2082
|
for (let i = 0; i < args.length; i++) {
|
|
2070
2083
|
const arg = args[i];
|
|
2071
2084
|
|
|
@@ -2085,23 +2098,138 @@ function parseArgs() {
|
|
|
2085
2098
|
return options;
|
|
2086
2099
|
}
|
|
2087
2100
|
|
|
2101
|
+
// Get project from Git repository
|
|
2102
|
+
async function getProject(gitUrl, destName) {
|
|
2103
|
+
const { execSync } = require('child_process');
|
|
2104
|
+
|
|
2105
|
+
printLogo();
|
|
2106
|
+
|
|
2107
|
+
// Extract repo name from URL if destName not provided
|
|
2108
|
+
if (!destName) {
|
|
2109
|
+
// Handle various URL formats
|
|
2110
|
+
// https://github.com/user/repo.git -> repo
|
|
2111
|
+
// git@github.com:user/repo.git -> repo
|
|
2112
|
+
const match = gitUrl.match(/\/([^\/]+?)(\.git)?$/) || gitUrl.match(/:([^\/]+?)(\.git)?$/);
|
|
2113
|
+
destName = match ? match[1] : 'promptline-app';
|
|
2114
|
+
}
|
|
2115
|
+
|
|
2116
|
+
// Validate destination name
|
|
2117
|
+
const validated = validatePackageName(destName);
|
|
2118
|
+
if (!validated.valid) {
|
|
2119
|
+
error(`Invalid project name "${destName}": ${validated.error}`);
|
|
2120
|
+
process.exit(1);
|
|
2121
|
+
}
|
|
2122
|
+
|
|
2123
|
+
const targetDir = path.resolve(process.cwd(), destName);
|
|
2124
|
+
|
|
2125
|
+
// Check if directory exists
|
|
2126
|
+
if (fs.existsSync(targetDir)) {
|
|
2127
|
+
error(`Directory "${destName}" already exists.`);
|
|
2128
|
+
process.exit(1);
|
|
2129
|
+
}
|
|
2130
|
+
|
|
2131
|
+
console.log(`${c.cyan}→${c.reset} Cloning from ${c.dim}${gitUrl}${c.reset}`);
|
|
2132
|
+
console.log(`${c.cyan}→${c.reset} Destination: ${c.green}${destName}${c.reset}\n`);
|
|
2133
|
+
|
|
2134
|
+
try {
|
|
2135
|
+
// Clone with depth 1 for speed, stdio inherit for git auth prompts
|
|
2136
|
+
execSync(`git clone --depth 1 "${gitUrl}" "${destName}"`, {
|
|
2137
|
+
stdio: 'inherit',
|
|
2138
|
+
cwd: process.cwd()
|
|
2139
|
+
});
|
|
2140
|
+
|
|
2141
|
+
// Remove .git directory
|
|
2142
|
+
const gitDir = path.join(targetDir, '.git');
|
|
2143
|
+
if (fs.existsSync(gitDir)) {
|
|
2144
|
+
fs.rmSync(gitDir, { recursive: true });
|
|
2145
|
+
}
|
|
2146
|
+
success('Removed .git directory');
|
|
2147
|
+
|
|
2148
|
+
// Initialize fresh git repo
|
|
2149
|
+
try {
|
|
2150
|
+
execSync('git init', { cwd: targetDir, stdio: 'pipe' });
|
|
2151
|
+
success('Initialized new git repository');
|
|
2152
|
+
} catch (e) {
|
|
2153
|
+
// Git init is optional
|
|
2154
|
+
}
|
|
2155
|
+
|
|
2156
|
+
// Detect project structure for instructions
|
|
2157
|
+
const hasDevRuntime = fs.existsSync(path.join(targetDir, 'dev-runtime'));
|
|
2158
|
+
const hasDev = fs.existsSync(path.join(targetDir, 'dev'));
|
|
2159
|
+
const hasPackageJson = fs.existsSync(path.join(targetDir, 'package.json'));
|
|
2160
|
+
const hasDevRuntimePackage = fs.existsSync(path.join(targetDir, 'dev-runtime', 'package.json'));
|
|
2161
|
+
|
|
2162
|
+
// Success message with appropriate instructions
|
|
2163
|
+
console.log(`
|
|
2164
|
+
${c.green}╔═══════════════════════════════════════════════════════════╗
|
|
2165
|
+
║ ║
|
|
2166
|
+
║ ${c.bold}Success!${c.reset}${c.green} Project ready in ${c.bold}${destName}${c.reset}${c.green} ║
|
|
2167
|
+
║ ║
|
|
2168
|
+
╚═══════════════════════════════════════════════════════════════╝${c.reset}
|
|
2169
|
+
|
|
2170
|
+
${c.bold}Next steps:${c.reset}
|
|
2171
|
+
|
|
2172
|
+
${c.cyan}cd ${destName}${c.reset}`);
|
|
2173
|
+
|
|
2174
|
+
if (hasDevRuntime && hasDevRuntimePackage) {
|
|
2175
|
+
console.log(`
|
|
2176
|
+
${c.dim}# This project has a dev-runtime environment${c.reset}
|
|
2177
|
+
${c.cyan}cd dev-runtime${c.reset}
|
|
2178
|
+
${c.cyan}npm install${c.reset}
|
|
2179
|
+
${c.cyan}npm run dev${c.reset}`);
|
|
2180
|
+
} else if (hasDev || hasPackageJson) {
|
|
2181
|
+
console.log(`
|
|
2182
|
+
${c.cyan}npm install${c.reset}
|
|
2183
|
+
${c.cyan}npm run dev${c.reset}`);
|
|
2184
|
+
} else {
|
|
2185
|
+
console.log(`
|
|
2186
|
+
${c.dim}# Check the project README for setup instructions${c.reset}`);
|
|
2187
|
+
}
|
|
2188
|
+
|
|
2189
|
+
console.log(`
|
|
2190
|
+
${c.bold}Key files:${c.reset}
|
|
2191
|
+
|
|
2192
|
+
${c.yellow}promptline.yaml${c.reset} Main configuration
|
|
2193
|
+
${c.yellow}public/${c.reset} Public pages
|
|
2194
|
+
${c.yellow}private/${c.reset} Admin/dashboard pages
|
|
2195
|
+
|
|
2196
|
+
${c.bold}Documentation:${c.reset} ${c.cyan}https://docs.promptlineops.com${c.reset}
|
|
2197
|
+
`);
|
|
2198
|
+
|
|
2199
|
+
} catch (err) {
|
|
2200
|
+
error(`Failed to clone repository: ${err.message}`);
|
|
2201
|
+
// Cleanup on failure
|
|
2202
|
+
if (fs.existsSync(targetDir)) {
|
|
2203
|
+
fs.rmSync(targetDir, { recursive: true });
|
|
2204
|
+
}
|
|
2205
|
+
process.exit(1);
|
|
2206
|
+
}
|
|
2207
|
+
}
|
|
2208
|
+
|
|
2088
2209
|
function showHelp() {
|
|
2089
2210
|
console.log(`
|
|
2090
|
-
${c.bold}
|
|
2211
|
+
${c.bold}promptlineapp${c.reset} - Create and get PromptLine applications
|
|
2091
2212
|
|
|
2092
2213
|
${c.bold}Usage:${c.reset}
|
|
2093
|
-
npx
|
|
2214
|
+
npx promptlineapp <app-name> [options] Create new app from scratch
|
|
2215
|
+
npx promptlineapp get <git-url> [name] Get existing app from Git
|
|
2094
2216
|
|
|
2095
|
-
${c.bold}
|
|
2217
|
+
${c.bold}Create options:${c.reset}
|
|
2096
2218
|
-p, --preset <preset> Template preset (full-app, api)
|
|
2097
2219
|
-y, --yes Skip prompts, use defaults
|
|
2220
|
+
|
|
2221
|
+
${c.bold}General:${c.reset}
|
|
2098
2222
|
-h, --help Show this help
|
|
2099
2223
|
-v, --version Show version
|
|
2100
2224
|
|
|
2101
2225
|
${c.bold}Examples:${c.reset}
|
|
2102
|
-
|
|
2103
|
-
npx
|
|
2104
|
-
npx
|
|
2226
|
+
${c.dim}# Create new app from scratch${c.reset}
|
|
2227
|
+
npx promptlineapp my-app
|
|
2228
|
+
npx promptlineapp my-api --preset api
|
|
2229
|
+
|
|
2230
|
+
${c.dim}# Get existing use case from Git${c.reset}
|
|
2231
|
+
npx promptlineapp get https://github.com/promptline/claude-realestate.git
|
|
2232
|
+
npx promptlineapp get git@github.com:promptline/menumind.git my-restaurant
|
|
2105
2233
|
|
|
2106
2234
|
${c.bold}Presets:${c.reset}
|
|
2107
2235
|
full-app Complete app with pages, dashboard & AI (default)
|
|
@@ -2128,13 +2256,29 @@ async function main() {
|
|
|
2128
2256
|
process.exit(0);
|
|
2129
2257
|
}
|
|
2130
2258
|
|
|
2259
|
+
// Route by command
|
|
2260
|
+
if (options.command === 'get') {
|
|
2261
|
+
if (!options.source) {
|
|
2262
|
+
printLogo();
|
|
2263
|
+
error('Please specify a Git URL:');
|
|
2264
|
+
console.log(`\n ${c.cyan}npx promptlineapp get${c.reset} ${c.green}<git-url>${c.reset} [name]\n`);
|
|
2265
|
+
console.log('For example:');
|
|
2266
|
+
console.log(` ${c.cyan}npx promptlineapp get${c.reset} ${c.green}https://github.com/promptline/claude-realestate.git${c.reset}\n`);
|
|
2267
|
+
console.log(`Run ${c.cyan}npx promptlineapp --help${c.reset} for more options.`);
|
|
2268
|
+
process.exit(1);
|
|
2269
|
+
}
|
|
2270
|
+
await getProject(options.source, options.name);
|
|
2271
|
+
return;
|
|
2272
|
+
}
|
|
2273
|
+
|
|
2274
|
+
// Default: create new app
|
|
2131
2275
|
if (!options.name) {
|
|
2132
2276
|
printLogo();
|
|
2133
2277
|
error('Please specify a project name:');
|
|
2134
|
-
console.log(`\n ${c.cyan}npx
|
|
2278
|
+
console.log(`\n ${c.cyan}npx promptlineapp${c.reset} ${c.green}<app-name>${c.reset}\n`);
|
|
2135
2279
|
console.log('For example:');
|
|
2136
|
-
console.log(` ${c.cyan}npx
|
|
2137
|
-
console.log(`Run ${c.cyan}npx
|
|
2280
|
+
console.log(` ${c.cyan}npx promptlineapp${c.reset} ${c.green}my-restaurant-app${c.reset}\n`);
|
|
2281
|
+
console.log(`Run ${c.cyan}npx promptlineapp --help${c.reset} for more options.`);
|
|
2138
2282
|
process.exit(1);
|
|
2139
2283
|
}
|
|
2140
2284
|
|