create-claudeportal 0.2.0 → 0.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-claudeportal",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Get from npx to a working app in under 5 minutes — Claude Code setup wizard",
5
5
  "bin": {
6
6
  "create-claudeportal": "bin/cli.js"
@@ -44,10 +44,58 @@ async function installTool(toolId, onProgress) {
44
44
  }
45
45
 
46
46
  async function installViaNpm(packageName, onProgress) {
47
+ const os = require('os')
48
+ const path = require('path')
49
+ const fs = require('fs')
50
+
51
+ // Check if npm prefix needs fixing (avoid /usr/local which requires sudo)
52
+ let npmArgs = ['install', '-g', packageName]
53
+ try {
54
+ const { execSync } = require('child_process')
55
+ const currentPrefix = execSync('npm config get prefix', {
56
+ encoding: 'utf8',
57
+ timeout: 5000,
58
+ env: { ...process.env, PATH: getExpandedPath() },
59
+ }).trim()
60
+
61
+ if (currentPrefix === '/usr/local') {
62
+ // Use a user-owned prefix instead
63
+ const userPrefix = path.join(os.homedir(), '.npm-global')
64
+ fs.mkdirSync(path.join(userPrefix, 'bin'), { recursive: true })
65
+ fs.mkdirSync(path.join(userPrefix, 'lib'), { recursive: true })
66
+ npmArgs = ['install', '-g', '--prefix', userPrefix, packageName]
67
+ onProgress(`Using ${userPrefix} to avoid permission issues...`)
68
+
69
+ // Also persist the config for future installs
70
+ try {
71
+ execSync(`npm config set prefix "${userPrefix}"`, {
72
+ timeout: 5000,
73
+ env: { ...process.env, PATH: getExpandedPath() },
74
+ })
75
+ } catch {}
76
+
77
+ // Add to PATH for this process
78
+ const binDir = path.join(userPrefix, 'bin')
79
+ if (!process.env.PATH.includes(binDir)) {
80
+ process.env.PATH = `${binDir}:${process.env.PATH}`
81
+ }
82
+
83
+ // Add to .zshrc if not already there
84
+ const zshrc = path.join(os.homedir(), '.zshrc')
85
+ const pathLine = `export PATH="$HOME/.npm-global/bin:$PATH"`
86
+ try {
87
+ const existing = fs.existsSync(zshrc) ? fs.readFileSync(zshrc, 'utf8') : ''
88
+ if (!existing.includes('.npm-global')) {
89
+ fs.appendFileSync(zshrc, `\n# Added by Claude Portal\n${pathLine}\n`)
90
+ }
91
+ } catch {}
92
+ }
93
+ } catch {}
94
+
47
95
  onProgress(`Installing ${packageName} via npm...`)
48
96
 
49
97
  return new Promise((resolve) => {
50
- const child = spawn('npm', ['install', '-g', packageName], {
98
+ const child = spawn('npm', npmArgs, {
51
99
  env: { ...process.env, PATH: getExpandedPath() },
52
100
  stdio: ['pipe', 'pipe', 'pipe'],
53
101
  timeout: 120000,