promptlineapp 1.9.2 → 1.10.1
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/bin/cli.js +119 -16
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -2120,7 +2120,7 @@ ${c.bold}Documentation:${c.reset} ${c.cyan}https://docs.promptlineops.com${c.res
|
|
|
2120
2120
|
function parseArgs() {
|
|
2121
2121
|
const args = process.argv.slice(2);
|
|
2122
2122
|
const options = {
|
|
2123
|
-
command: 'new', // 'new' or '
|
|
2123
|
+
command: 'new', // 'new', 'get', or 'update'
|
|
2124
2124
|
name: null,
|
|
2125
2125
|
source: null, // Git URL for 'get' command
|
|
2126
2126
|
preset: null,
|
|
@@ -2140,6 +2140,12 @@ function parseArgs() {
|
|
|
2140
2140
|
return options;
|
|
2141
2141
|
}
|
|
2142
2142
|
|
|
2143
|
+
// Detect 'update' command
|
|
2144
|
+
if (args[0] === 'update') {
|
|
2145
|
+
options.command = 'update';
|
|
2146
|
+
return options;
|
|
2147
|
+
}
|
|
2148
|
+
|
|
2143
2149
|
for (let i = 0; i < args.length; i++) {
|
|
2144
2150
|
const arg = args[i];
|
|
2145
2151
|
|
|
@@ -2320,7 +2326,13 @@ export const sdk = {
|
|
|
2320
2326
|
getNavigationState: () => undefined
|
|
2321
2327
|
}
|
|
2322
2328
|
|
|
2323
|
-
export const initSDK = () =>
|
|
2329
|
+
export const initSDK = () => {
|
|
2330
|
+
// Attach SDK to window for SDKService compatibility
|
|
2331
|
+
if (typeof window !== 'undefined') {
|
|
2332
|
+
(window as any).sdk = sdk
|
|
2333
|
+
}
|
|
2334
|
+
return sdk
|
|
2335
|
+
}
|
|
2324
2336
|
export default sdk
|
|
2325
2337
|
`,
|
|
2326
2338
|
|
|
@@ -2791,25 +2803,13 @@ async function getProject(gitUrl, destName) {
|
|
|
2791
2803
|
console.log(`${c.cyan}→${c.reset} Destination: ${c.green}${destName}${c.reset}\n`);
|
|
2792
2804
|
|
|
2793
2805
|
try {
|
|
2794
|
-
// Clone
|
|
2795
|
-
execSync(`git clone
|
|
2806
|
+
// Clone (full history for push capability)
|
|
2807
|
+
execSync(`git clone "${gitUrl}" "${destName}"`, {
|
|
2796
2808
|
stdio: 'inherit',
|
|
2797
2809
|
cwd: process.cwd()
|
|
2798
2810
|
});
|
|
2799
|
-
|
|
2800
|
-
// Remove .git
|
|
2801
|
-
const gitDir = path.join(targetDir, '.git');
|
|
2802
|
-
if (fs.existsSync(gitDir)) {
|
|
2803
|
-
fs.rmSync(gitDir, { recursive: true });
|
|
2804
|
-
}
|
|
2805
2811
|
success('Cloned repository');
|
|
2806
2812
|
|
|
2807
|
-
// Init fresh git
|
|
2808
|
-
try {
|
|
2809
|
-
execSync('git init', { cwd: targetDir, stdio: 'pipe' });
|
|
2810
|
-
success('Initialized new git repository');
|
|
2811
|
-
} catch (e) {}
|
|
2812
|
-
|
|
2813
2813
|
// Detect structure
|
|
2814
2814
|
const hasDevRuntime = fs.existsSync(path.join(targetDir, 'dev-runtime'));
|
|
2815
2815
|
const hasPromptlineYaml = fs.existsSync(path.join(targetDir, 'promptline.yaml'));
|
|
@@ -2967,6 +2967,100 @@ ${c.bold}Documentation:${c.reset} ${c.cyan}https://docs.promptlineops.com${c.res
|
|
|
2967
2967
|
}
|
|
2968
2968
|
}
|
|
2969
2969
|
|
|
2970
|
+
// Update existing project with latest SDK and DevAdmin
|
|
2971
|
+
async function updateProject() {
|
|
2972
|
+
printLogo();
|
|
2973
|
+
|
|
2974
|
+
const cwd = process.cwd();
|
|
2975
|
+
|
|
2976
|
+
// Check if we're in a promptline project
|
|
2977
|
+
const hasDevRuntime = fs.existsSync(path.join(cwd, 'dev-runtime'));
|
|
2978
|
+
const hasPromptlineYaml = fs.existsSync(path.join(cwd, 'promptline.yaml'));
|
|
2979
|
+
|
|
2980
|
+
if (!hasDevRuntime) {
|
|
2981
|
+
error('Not in a PromptLine project directory.');
|
|
2982
|
+
console.log(`\nRun this command from a project with a ${c.cyan}dev-runtime/${c.reset} folder.`);
|
|
2983
|
+
process.exit(1);
|
|
2984
|
+
}
|
|
2985
|
+
|
|
2986
|
+
console.log(`${c.cyan}→${c.reset} Updating PromptLine dev files...\n`);
|
|
2987
|
+
|
|
2988
|
+
// Parse bindings from promptline.yaml
|
|
2989
|
+
let bindings = [];
|
|
2990
|
+
if (hasPromptlineYaml) {
|
|
2991
|
+
try {
|
|
2992
|
+
const yamlContent = fs.readFileSync(path.join(cwd, 'promptline.yaml'), 'utf8');
|
|
2993
|
+
bindings = parseBindingsFromYaml(yamlContent);
|
|
2994
|
+
success(`Detected ${bindings.length} AI bindings from promptline.yaml`);
|
|
2995
|
+
} catch (e) {
|
|
2996
|
+
console.log(`${c.yellow}!${c.reset} Could not parse promptline.yaml: ${e.message}`);
|
|
2997
|
+
}
|
|
2998
|
+
}
|
|
2999
|
+
|
|
3000
|
+
const srcDir = path.join(cwd, 'dev-runtime', 'src');
|
|
3001
|
+
|
|
3002
|
+
// Backup and update sdk-mock
|
|
3003
|
+
const sdkPath = path.join(srcDir, 'sdk-mock.tsx');
|
|
3004
|
+
if (fs.existsSync(sdkPath)) {
|
|
3005
|
+
const backupPath = path.join(srcDir, 'sdk-mock.backup.tsx');
|
|
3006
|
+
fs.copyFileSync(sdkPath, backupPath);
|
|
3007
|
+
console.log(`${c.dim} Backed up sdk-mock.tsx${c.reset}`);
|
|
3008
|
+
}
|
|
3009
|
+
fs.writeFileSync(sdkPath, devTemplates.sdkHybrid(bindings));
|
|
3010
|
+
success('Updated sdk-mock.tsx');
|
|
3011
|
+
|
|
3012
|
+
// Backup and update DevAdmin
|
|
3013
|
+
const devAdminPath = path.join(srcDir, 'DevAdmin.tsx');
|
|
3014
|
+
if (fs.existsSync(devAdminPath)) {
|
|
3015
|
+
const backupPath = path.join(srcDir, 'DevAdmin.backup.tsx');
|
|
3016
|
+
fs.copyFileSync(devAdminPath, backupPath);
|
|
3017
|
+
console.log(`${c.dim} Backed up DevAdmin.tsx${c.reset}`);
|
|
3018
|
+
}
|
|
3019
|
+
fs.writeFileSync(devAdminPath, devTemplates.devAdmin(bindings));
|
|
3020
|
+
success('Updated DevAdmin.tsx');
|
|
3021
|
+
|
|
3022
|
+
// Update vite.config.ts proxy
|
|
3023
|
+
const viteConfigPath = path.join(cwd, 'dev-runtime', 'vite.config.ts');
|
|
3024
|
+
if (fs.existsSync(viteConfigPath)) {
|
|
3025
|
+
let viteContent = fs.readFileSync(viteConfigPath, 'utf8');
|
|
3026
|
+
if (!viteContent.includes('/api/promptline')) {
|
|
3027
|
+
const hasExistingProxy = /server:\s*\{[^}]*proxy:\s*\{/.test(viteContent);
|
|
3028
|
+
if (hasExistingProxy) {
|
|
3029
|
+
const proxyEntries = `
|
|
3030
|
+
// PromptLine API Proxy (added by npx promptlineapp update)
|
|
3031
|
+
'/api/promptline-local': {
|
|
3032
|
+
target: 'https://app.local.promptlineops.com',
|
|
3033
|
+
changeOrigin: true,
|
|
3034
|
+
rewrite: (path) => path.replace(/^\\/api\\/promptline-local/, '/api/v1/live'),
|
|
3035
|
+
secure: false
|
|
3036
|
+
},
|
|
3037
|
+
'/api/promptline': {
|
|
3038
|
+
target: 'https://app.promptlineops.com',
|
|
3039
|
+
changeOrigin: true,
|
|
3040
|
+
rewrite: (path) => path.replace(/^\\/api\\/promptline/, '/api/v1/live'),
|
|
3041
|
+
secure: false
|
|
3042
|
+
},`;
|
|
3043
|
+
viteContent = viteContent.replace(/(proxy:\s*\{)/, '$1' + proxyEntries);
|
|
3044
|
+
} else if (viteContent.includes('server:')) {
|
|
3045
|
+
viteContent = viteContent.replace(/server:\s*\{/, 'server: {' + devTemplates.viteProxyConfig);
|
|
3046
|
+
}
|
|
3047
|
+
fs.writeFileSync(viteConfigPath, viteContent);
|
|
3048
|
+
success('Updated vite.config.ts proxy');
|
|
3049
|
+
} else {
|
|
3050
|
+
console.log(`${c.dim} vite.config.ts proxy already configured${c.reset}`);
|
|
3051
|
+
}
|
|
3052
|
+
}
|
|
3053
|
+
|
|
3054
|
+
console.log(`
|
|
3055
|
+
${c.green}✓${c.reset} Update complete!
|
|
3056
|
+
|
|
3057
|
+
${c.bold}Restart the dev server:${c.reset}
|
|
3058
|
+
${c.cyan}npm run dev${c.reset}
|
|
3059
|
+
|
|
3060
|
+
${c.dim}Note: Your endpoint configurations in localStorage are preserved.${c.reset}
|
|
3061
|
+
`);
|
|
3062
|
+
}
|
|
3063
|
+
|
|
2970
3064
|
function showHelp() {
|
|
2971
3065
|
console.log(`
|
|
2972
3066
|
${c.bold}promptlineapp${c.reset} - Create and get PromptLine applications
|
|
@@ -2974,6 +3068,7 @@ ${c.bold}promptlineapp${c.reset} - Create and get PromptLine applications
|
|
|
2974
3068
|
${c.bold}Usage:${c.reset}
|
|
2975
3069
|
npx promptlineapp <app-name> [options] Create new app from scratch
|
|
2976
3070
|
npx promptlineapp get <git-url> [name] Get existing app from Git
|
|
3071
|
+
npx promptlineapp update Update dev files in current project
|
|
2977
3072
|
|
|
2978
3073
|
${c.bold}Create options:${c.reset}
|
|
2979
3074
|
-p, --preset <preset> Template preset (full-app, api)
|
|
@@ -2992,6 +3087,9 @@ ${c.bold}Examples:${c.reset}
|
|
|
2992
3087
|
npx promptlineapp get https://github.com/promptline/claude-realestate.git
|
|
2993
3088
|
npx promptlineapp get git@github.com:promptline/menumind.git my-restaurant
|
|
2994
3089
|
|
|
3090
|
+
${c.dim}# Update existing project with latest SDK${c.reset}
|
|
3091
|
+
cd my-project && npx promptlineapp update
|
|
3092
|
+
|
|
2995
3093
|
${c.bold}Presets:${c.reset}
|
|
2996
3094
|
full-app Complete app with pages, dashboard & AI (default)
|
|
2997
3095
|
api Backend-focused, minimal frontend
|
|
@@ -3032,6 +3130,11 @@ async function main() {
|
|
|
3032
3130
|
return;
|
|
3033
3131
|
}
|
|
3034
3132
|
|
|
3133
|
+
if (options.command === 'update') {
|
|
3134
|
+
await updateProject();
|
|
3135
|
+
return;
|
|
3136
|
+
}
|
|
3137
|
+
|
|
3035
3138
|
// Default: create new app
|
|
3036
3139
|
if (!options.name) {
|
|
3037
3140
|
printLogo();
|