create-sks-admin 0.1.1 → 0.2.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/bin/cli.js +80 -29
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -4,6 +4,7 @@ import { execSync } from 'child_process'
|
|
|
4
4
|
import fs from 'fs'
|
|
5
5
|
import path from 'path'
|
|
6
6
|
import { fileURLToPath } from 'url'
|
|
7
|
+
import prompts from 'prompts'
|
|
7
8
|
|
|
8
9
|
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
9
10
|
|
|
@@ -13,6 +14,7 @@ const colors = {
|
|
|
13
14
|
blue: (t) => `\x1b[34m${t}\x1b[0m`,
|
|
14
15
|
yellow: (t) => `\x1b[33m${t}\x1b[0m`,
|
|
15
16
|
red: (t) => `\x1b[31m${t}\x1b[0m`,
|
|
17
|
+
cyan: (t) => `\x1b[36m${t}\x1b[0m`,
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
const log = {
|
|
@@ -27,7 +29,7 @@ const projectName = process.argv[2] || 'sks-admin-test'
|
|
|
27
29
|
|
|
28
30
|
console.log(`
|
|
29
31
|
╔═══════════════════════════════════════╗
|
|
30
|
-
║ @sks/create-admin CLI ║
|
|
32
|
+
║ ${colors.cyan('@sks/create-admin CLI')} ║
|
|
31
33
|
║ Creating: ${projectName.padEnd(22)}║
|
|
32
34
|
╚═══════════════════════════════════════╝
|
|
33
35
|
`)
|
|
@@ -50,6 +52,30 @@ if (isCurrentDir) {
|
|
|
50
52
|
}
|
|
51
53
|
}
|
|
52
54
|
|
|
55
|
+
// Ask for token
|
|
56
|
+
console.log('')
|
|
57
|
+
console.log(colors.yellow('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'))
|
|
58
|
+
console.log(colors.yellow(' Premium Admin Panel Components'))
|
|
59
|
+
console.log(colors.yellow('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'))
|
|
60
|
+
console.log('')
|
|
61
|
+
|
|
62
|
+
const response = await prompts({
|
|
63
|
+
type: 'password',
|
|
64
|
+
name: 'token',
|
|
65
|
+
message: 'Enter access token (or press Enter to skip):',
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
const hasToken = response.token && response.token.trim().length > 0
|
|
69
|
+
const authToken = response.token?.trim()
|
|
70
|
+
|
|
71
|
+
if (hasToken) {
|
|
72
|
+
log.success('Token received - Premium components will be installed')
|
|
73
|
+
} else {
|
|
74
|
+
log.info('No token - Basic template will be created')
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
console.log('')
|
|
78
|
+
|
|
53
79
|
try {
|
|
54
80
|
// Step 1: Create Next.js app
|
|
55
81
|
log.info('Creating Next.js app...')
|
|
@@ -62,24 +88,40 @@ try {
|
|
|
62
88
|
// Step 2: Navigate to project
|
|
63
89
|
process.chdir(projectPath)
|
|
64
90
|
|
|
65
|
-
// Step 3: Create .npmrc for GitHub Packages
|
|
91
|
+
// Step 3: Create .npmrc for GitHub Packages (with token if provided)
|
|
66
92
|
log.info('Configuring npm registry...')
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
93
|
+
if (hasToken) {
|
|
94
|
+
fs.writeFileSync(
|
|
95
|
+
'.npmrc',
|
|
96
|
+
`@sks:registry=https://npm.pkg.github.com
|
|
97
|
+
//npm.pkg.github.com/:_authToken=${authToken}
|
|
71
98
|
`
|
|
72
|
-
|
|
99
|
+
)
|
|
100
|
+
} else {
|
|
101
|
+
fs.writeFileSync(
|
|
102
|
+
'.npmrc',
|
|
103
|
+
`@sks:registry=https://npm.pkg.github.com
|
|
104
|
+
# Add your token here to install premium packages:
|
|
105
|
+
# //npm.pkg.github.com/:_authToken=YOUR_TOKEN
|
|
106
|
+
`
|
|
107
|
+
)
|
|
108
|
+
}
|
|
73
109
|
log.success('.npmrc created')
|
|
74
110
|
|
|
75
|
-
// Step 4: Install @sks packages
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
111
|
+
// Step 4: Install @sks packages only if token provided
|
|
112
|
+
let packagesInstalled = false
|
|
113
|
+
if (hasToken) {
|
|
114
|
+
log.info('Installing @sks premium packages...')
|
|
115
|
+
try {
|
|
116
|
+
execSync('npm install @sks/admin-core @sks/admin-ui', { stdio: 'inherit' })
|
|
117
|
+
log.success('@sks packages installed')
|
|
118
|
+
packagesInstalled = true
|
|
119
|
+
} catch {
|
|
120
|
+
log.warn('Could not install @sks packages - token may be invalid')
|
|
121
|
+
log.info('Check your token and run: npm install @sks/admin-core @sks/admin-ui')
|
|
122
|
+
}
|
|
123
|
+
} else {
|
|
124
|
+
log.info('Skipping premium packages (no token)')
|
|
83
125
|
}
|
|
84
126
|
|
|
85
127
|
// Step 5: Create lib/dal.ts
|
|
@@ -175,20 +217,29 @@ export default function AdminLayout({
|
|
|
175
217
|
log.success('Boilerplate files created')
|
|
176
218
|
|
|
177
219
|
// Done!
|
|
178
|
-
console.log(
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
${
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
220
|
+
console.log('')
|
|
221
|
+
console.log(colors.green('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'))
|
|
222
|
+
console.log(colors.green(' ✓ Project created successfully!'))
|
|
223
|
+
console.log(colors.green('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'))
|
|
224
|
+
console.log('')
|
|
225
|
+
|
|
226
|
+
console.log(colors.blue('Next steps:'))
|
|
227
|
+
console.log(` cd ${isCurrentDir ? '.' : projectName}`)
|
|
228
|
+
console.log(' npm run dev')
|
|
229
|
+
console.log('')
|
|
230
|
+
console.log(colors.blue('Admin panel:'))
|
|
231
|
+
console.log(' http://localhost:3000/admin')
|
|
232
|
+
console.log('')
|
|
233
|
+
|
|
234
|
+
if (packagesInstalled) {
|
|
235
|
+
console.log(colors.green('Premium packages installed! Full admin panel ready.'))
|
|
236
|
+
} else {
|
|
237
|
+
console.log(colors.yellow('To unlock premium features:'))
|
|
238
|
+
console.log(' 1. Get your access token from admin')
|
|
239
|
+
console.log(' 2. Run: npx create-sks-admin my-app')
|
|
240
|
+
console.log(' 3. Enter token when prompted')
|
|
241
|
+
}
|
|
242
|
+
console.log('')
|
|
192
243
|
|
|
193
244
|
} catch (error) {
|
|
194
245
|
log.error('Failed to create project')
|