prjct-cli 0.8.3 → 0.8.4
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 +2 -2
- package/scripts/postinstall.js +140 -65
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prjct-cli",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4",
|
|
4
4
|
"description": "Built for Claude - Ship fast, track progress, stay focused. Developer momentum tool for indie hackers.",
|
|
5
5
|
"main": "core/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
},
|
|
13
13
|
"scripts": {
|
|
14
14
|
"postinstall": "node scripts/postinstall.js",
|
|
15
|
-
"update-commands": "node -e \"const installer = require('./core/infrastructure/command-installer');
|
|
15
|
+
"update-commands": "node -e \"const installer = require('./core/infrastructure/command-installer'); installer.syncCommands().then(r => console.log('Commands updated:', r)).catch(e => console.error('Error:', e.message))\"",
|
|
16
16
|
"install-global": "./scripts/install.sh",
|
|
17
17
|
"update": "./scripts/update.sh",
|
|
18
18
|
"test": "vitest run --workspace=vitest.workspace.js",
|
package/scripts/postinstall.js
CHANGED
|
@@ -6,17 +6,21 @@
|
|
|
6
6
|
* Runs automatically after npm install -g prjct-cli
|
|
7
7
|
*
|
|
8
8
|
* 1. Detects if global install
|
|
9
|
-
* 2. Installs
|
|
10
|
-
* 3. Installs/
|
|
11
|
-
* 4.
|
|
9
|
+
* 2. Installs Claude Code CLI if not found (automatic)
|
|
10
|
+
* 3. Installs/syncs commands to ~/.claude/commands/p/
|
|
11
|
+
* 4. Installs/updates global config to ~/.claude/CLAUDE.md
|
|
12
|
+
* 5. Migrates all legacy projects automatically
|
|
13
|
+
* 6. Shows success message with results
|
|
12
14
|
*
|
|
13
|
-
*
|
|
15
|
+
* ZERO MANUAL STEPS - Everything is automatic
|
|
14
16
|
*
|
|
15
|
-
* @version 0.8.
|
|
17
|
+
* @version 0.8.4
|
|
16
18
|
*/
|
|
17
19
|
|
|
18
20
|
const path = require('path')
|
|
21
|
+
const { execSync } = require('child_process')
|
|
19
22
|
const installer = require('../core/infrastructure/command-installer')
|
|
23
|
+
const migrator = require('../core/infrastructure/migrator')
|
|
20
24
|
const { VERSION } = require('../core/utils/version')
|
|
21
25
|
|
|
22
26
|
// Colors for terminal output
|
|
@@ -42,64 +46,65 @@ async function main() {
|
|
|
42
46
|
|
|
43
47
|
console.log('')
|
|
44
48
|
console.log(`${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}`)
|
|
45
|
-
console.log(`${BOLD}${CYAN}🚀 Setting up prjct-cli
|
|
49
|
+
console.log(`${BOLD}${CYAN}🚀 Setting up prjct-cli v${VERSION}${NC}`)
|
|
46
50
|
console.log(`${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}`)
|
|
47
51
|
console.log('')
|
|
48
52
|
|
|
49
|
-
|
|
50
|
-
|
|
53
|
+
const results = {
|
|
54
|
+
claudeInstalled: false,
|
|
55
|
+
commandsAdded: 0,
|
|
56
|
+
commandsUpdated: 0,
|
|
57
|
+
configAction: null,
|
|
58
|
+
projectsMigrated: 0
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Step 1: Ensure Claude Code CLI is installed
|
|
62
|
+
const hasClaude = await hasClaudeCodeCLI()
|
|
63
|
+
|
|
64
|
+
if (!hasClaude) {
|
|
65
|
+
const installed = await installClaudeCode()
|
|
66
|
+
if (installed) {
|
|
67
|
+
results.claudeInstalled = true
|
|
68
|
+
} else {
|
|
69
|
+
// Cannot continue without Claude Code
|
|
70
|
+
showFailureMessage()
|
|
71
|
+
return
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Step 2: Detect Claude directory (for commands)
|
|
51
76
|
const claudeDetected = await installer.detectClaude()
|
|
52
77
|
|
|
53
|
-
if (
|
|
54
|
-
|
|
55
|
-
console.log(`${DIM}Install Claude Code from: https://claude.ai/code${NC}`)
|
|
56
|
-
console.log(`${DIM}Then run: prjct setup${NC}`)
|
|
57
|
-
console.log('')
|
|
58
|
-
} else {
|
|
59
|
-
console.log(`${GREEN}✓${NC} Claude Code found`)
|
|
60
|
-
console.log('')
|
|
61
|
-
|
|
62
|
-
// Step 2: Install/sync commands
|
|
63
|
-
console.log(`${BOLD}[2/3]${NC} Installing commands to ~/.claude...`)
|
|
78
|
+
if (claudeDetected) {
|
|
79
|
+
// Step 3: Sync commands
|
|
64
80
|
const syncResult = await installer.syncCommands()
|
|
65
81
|
|
|
66
82
|
if (syncResult.success) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (added > 0) changes.push(`${added} nuevos`)
|
|
70
|
-
if (updated > 0) changes.push(`${updated} actualizados`)
|
|
71
|
-
if (removed > 0) changes.push(`${removed} eliminados`)
|
|
72
|
-
|
|
73
|
-
if (changes.length > 0) {
|
|
74
|
-
console.log(`${GREEN}✓${NC} ${changes.join(', ')}`)
|
|
75
|
-
} else {
|
|
76
|
-
console.log(`${GREEN}✓${NC} All commands up to date`)
|
|
77
|
-
}
|
|
78
|
-
} else {
|
|
79
|
-
console.log(`${YELLOW}⚠️ ${syncResult.error}${NC}`)
|
|
83
|
+
results.commandsAdded = syncResult.added
|
|
84
|
+
results.commandsUpdated = syncResult.updated
|
|
80
85
|
}
|
|
81
|
-
console.log('')
|
|
82
86
|
|
|
83
|
-
// Step
|
|
84
|
-
console.log(`${BOLD}[3/3]${NC} Installing global configuration...`)
|
|
87
|
+
// Step 4: Install global configuration
|
|
85
88
|
const configResult = await installer.installGlobalConfig()
|
|
86
89
|
|
|
87
90
|
if (configResult.success) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
91
|
+
results.configAction = configResult.action
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Step 5: Migrate legacy projects automatically
|
|
95
|
+
const migrationResult = await migrator.migrateAll({
|
|
96
|
+
deepScan: false,
|
|
97
|
+
cleanupLegacy: true,
|
|
98
|
+
dryRun: false
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
if (migrationResult.successfullyMigrated > 0) {
|
|
102
|
+
results.projectsMigrated = migrationResult.successfullyMigrated
|
|
97
103
|
}
|
|
98
|
-
console.log('')
|
|
99
104
|
}
|
|
100
105
|
|
|
101
|
-
// Show
|
|
102
|
-
|
|
106
|
+
// Show final success message
|
|
107
|
+
showSuccessMessage(results)
|
|
103
108
|
|
|
104
109
|
} catch (error) {
|
|
105
110
|
console.error(`${YELLOW}⚠️ Post-install error: ${error.message}${NC}`)
|
|
@@ -133,9 +138,42 @@ async function detectGlobalInstall() {
|
|
|
133
138
|
}
|
|
134
139
|
|
|
135
140
|
/**
|
|
136
|
-
*
|
|
141
|
+
* Check if Claude Code CLI is installed
|
|
137
142
|
*/
|
|
138
|
-
function
|
|
143
|
+
async function hasClaudeCodeCLI() {
|
|
144
|
+
try {
|
|
145
|
+
execSync('which claude', { stdio: 'ignore' })
|
|
146
|
+
return true
|
|
147
|
+
} catch {
|
|
148
|
+
return false
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Install Claude Code CLI
|
|
154
|
+
*/
|
|
155
|
+
async function installClaudeCode() {
|
|
156
|
+
try {
|
|
157
|
+
console.log(`${YELLOW}📦 Claude Code not found. Installing...${NC}`)
|
|
158
|
+
console.log('')
|
|
159
|
+
execSync('npm install -g @anthropic-ai/claude-code', { stdio: 'inherit' })
|
|
160
|
+
console.log('')
|
|
161
|
+
console.log(`${GREEN}✓${NC} Claude Code installed successfully`)
|
|
162
|
+
console.log('')
|
|
163
|
+
return true
|
|
164
|
+
} catch (error) {
|
|
165
|
+
console.log(`${YELLOW}⚠️ Failed to install Claude Code: ${error.message}${NC}`)
|
|
166
|
+
console.log(`${DIM}Please install manually: npm install -g @anthropic-ai/claude-code${NC}`)
|
|
167
|
+
console.log('')
|
|
168
|
+
return false
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Show success message with results
|
|
174
|
+
*/
|
|
175
|
+
function showSuccessMessage(results) {
|
|
176
|
+
console.log('')
|
|
139
177
|
console.log(`${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}`)
|
|
140
178
|
console.log('')
|
|
141
179
|
console.log(` ${BOLD}${CYAN}██████╗ ██████╗ ██╗ ██████╗████████╗${NC}`)
|
|
@@ -145,32 +183,69 @@ function showAsciiArt() {
|
|
|
145
183
|
console.log(` ${BOLD}${CYAN}██║ ██║ ██║╚█████╔╝╚██████╗ ██║${NC}`)
|
|
146
184
|
console.log(` ${BOLD}${CYAN}╚═╝ ╚═╝ ╚═╝ ╚════╝ ╚═════╝ ╚═╝${NC}`)
|
|
147
185
|
console.log('')
|
|
148
|
-
console.log(`
|
|
186
|
+
console.log(` ${BOLD}${GREEN}v${VERSION} READY!${NC}`)
|
|
187
|
+
console.log('')
|
|
188
|
+
console.log(`${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}`)
|
|
149
189
|
console.log('')
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
190
|
+
|
|
191
|
+
// Show what was done
|
|
192
|
+
if (results.claudeInstalled) {
|
|
193
|
+
console.log(` ${GREEN}✓${NC} Claude Code CLI installed`)
|
|
194
|
+
} else {
|
|
195
|
+
console.log(` ${GREEN}✓${NC} Claude Code CLI found`)
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const totalCommands = results.commandsAdded + results.commandsUpdated
|
|
199
|
+
if (totalCommands > 0) {
|
|
200
|
+
const parts = []
|
|
201
|
+
if (results.commandsAdded > 0) parts.push(`${results.commandsAdded} new`)
|
|
202
|
+
if (results.commandsUpdated > 0) parts.push(`${results.commandsUpdated} updated`)
|
|
203
|
+
console.log(` ${GREEN}✓${NC} Commands synced (${parts.join(', ')})`)
|
|
204
|
+
} else {
|
|
205
|
+
console.log(` ${GREEN}✓${NC} Commands up to date`)
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (results.configAction === 'created') {
|
|
209
|
+
console.log(` ${GREEN}✓${NC} Global config created`)
|
|
210
|
+
} else if (results.configAction === 'updated') {
|
|
211
|
+
console.log(` ${GREEN}✓${NC} Global config updated`)
|
|
212
|
+
} else if (results.configAction === 'appended') {
|
|
213
|
+
console.log(` ${GREEN}✓${NC} Global config merged`)
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if (results.projectsMigrated > 0) {
|
|
217
|
+
console.log(` ${GREEN}✓${NC} ${results.projectsMigrated} projects migrated to global storage`)
|
|
218
|
+
}
|
|
219
|
+
|
|
153
220
|
console.log('')
|
|
154
221
|
console.log(`${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}`)
|
|
155
222
|
console.log('')
|
|
156
|
-
console.log(`${BOLD}
|
|
157
|
-
console.log(
|
|
223
|
+
console.log(`${BOLD}Next steps:${NC}`)
|
|
224
|
+
console.log(` ${DIM}cd your-project${NC}`)
|
|
225
|
+
console.log(` ${GREEN}/p:init${NC}`)
|
|
158
226
|
console.log('')
|
|
159
|
-
console.log(
|
|
160
|
-
console.log(` ${GREEN}cd your-project && prjct init${NC}`)
|
|
227
|
+
console.log(`${BOLD}${MAGENTA}Happy shipping! 🚀${NC}`)
|
|
161
228
|
console.log('')
|
|
162
|
-
|
|
163
|
-
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Show failure message
|
|
233
|
+
*/
|
|
234
|
+
function showFailureMessage() {
|
|
164
235
|
console.log('')
|
|
165
|
-
console.log(
|
|
166
|
-
console.log(` ${GREEN}prjct ship "user login"${NC}`)
|
|
236
|
+
console.log(`${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}`)
|
|
167
237
|
console.log('')
|
|
168
|
-
console.log(`${
|
|
238
|
+
console.log(`${YELLOW}⚠️ Setup incomplete${NC}`)
|
|
169
239
|
console.log('')
|
|
170
|
-
console.log(`
|
|
171
|
-
console.log(` ${DIM}Report issues:${NC} ${CYAN}https://github.com/jlopezlira/prjct-cli/issues${NC}`)
|
|
240
|
+
console.log(`Claude Code is required for prjct-cli.`)
|
|
172
241
|
console.log('')
|
|
173
|
-
console.log(
|
|
242
|
+
console.log(`Please install manually:`)
|
|
243
|
+
console.log(` ${GREEN}npm install -g @anthropic-ai/claude-code${NC}`)
|
|
244
|
+
console.log('')
|
|
245
|
+
console.log(`Then run:`)
|
|
246
|
+
console.log(` ${GREEN}prjct setup${NC}`)
|
|
247
|
+
console.log('')
|
|
248
|
+
console.log(`${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}`)
|
|
174
249
|
console.log('')
|
|
175
250
|
}
|
|
176
251
|
|