weloop-kosign 1.1.1 → 1.1.2
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 +11 -0
- package/package.json +1 -1
- package/scripts/cli-remote.js +172 -1
package/README.md
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
A modular component library built with Next.js, similar to shadcn/ui. Install only the components you need directly into your project.
|
|
4
4
|
|
|
5
|
+
**Current Version:** `1.1.2`
|
|
6
|
+
|
|
7
|
+
## What's New in v1.1.2
|
|
8
|
+
|
|
9
|
+
- Added new component pages (kbd, label, menubar, navigation-menu, pagination, popover, progress, radio-group, resizable, scroll-area, select, separator, sheet, skeleton, slider, spinner, switch, tabs, textarea, toast, toggle, toggle-group, tooltip)
|
|
10
|
+
- Added comprehensive sidebar demo pages and examples (13 demo variations)
|
|
11
|
+
- Added installation documentation for Next.js and Vite
|
|
12
|
+
- Updated existing component pages and documentation
|
|
13
|
+
- Reorganized sidebar examples and components structure
|
|
14
|
+
- Improved component organization and file structure
|
|
15
|
+
|
|
5
16
|
## Installation
|
|
6
17
|
|
|
7
18
|
Install components directly - the CLI handles everything automatically:
|
package/package.json
CHANGED
package/scripts/cli-remote.js
CHANGED
|
@@ -8,16 +8,19 @@
|
|
|
8
8
|
* - If running in external projects: uses remote GitLab/GitHub URL
|
|
9
9
|
*
|
|
10
10
|
* Usage (via npx - recommended):
|
|
11
|
+
* npx weloop-kosign@latest init
|
|
11
12
|
* npx weloop-kosign@latest add <component-name>
|
|
12
13
|
* npx weloop-kosign@latest list
|
|
13
14
|
* npx weloop-kosign@latest css [--overwrite]
|
|
14
15
|
*
|
|
15
16
|
* Usage (local development):
|
|
17
|
+
* node scripts/cli-remote.js init [--registry <url|path>]
|
|
16
18
|
* node scripts/cli-remote.js add <component-name> [--registry <url|path>]
|
|
17
19
|
* node scripts/cli-remote.js list [--registry <url|path>]
|
|
18
20
|
* node scripts/cli-remote.js css [--registry <url|path>] [--overwrite]
|
|
19
21
|
*
|
|
20
22
|
* Examples:
|
|
23
|
+
* npx weloop-kosign@latest init
|
|
21
24
|
* npx weloop-kosign@latest add button
|
|
22
25
|
* npx weloop-kosign@latest add button --registry ./registry
|
|
23
26
|
* npx weloop-kosign@latest css
|
|
@@ -1249,6 +1252,168 @@ async function installComponent(componentName, options = {}) {
|
|
|
1249
1252
|
success(`\nSuccessfully installed "${componentName}"`);
|
|
1250
1253
|
}
|
|
1251
1254
|
|
|
1255
|
+
// ============================================================================
|
|
1256
|
+
// INIT COMMAND - Project Initialization
|
|
1257
|
+
// ============================================================================
|
|
1258
|
+
|
|
1259
|
+
/**
|
|
1260
|
+
* Detects the project type (Next.js or Vite)
|
|
1261
|
+
* @returns {string} 'nextjs' or 'vite' or null
|
|
1262
|
+
*/
|
|
1263
|
+
function detectProjectType() {
|
|
1264
|
+
// Check for Next.js
|
|
1265
|
+
if (fs.existsSync(path.join(process.cwd(), 'next.config.js')) ||
|
|
1266
|
+
fs.existsSync(path.join(process.cwd(), 'next.config.mjs')) ||
|
|
1267
|
+
fs.existsSync(path.join(process.cwd(), 'next.config.ts')) ||
|
|
1268
|
+
fs.existsSync(path.join(process.cwd(), 'app')) ||
|
|
1269
|
+
fs.existsSync(path.join(process.cwd(), 'pages'))) {
|
|
1270
|
+
return 'nextjs';
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
// Check for Vite
|
|
1274
|
+
if (fs.existsSync(path.join(process.cwd(), 'vite.config.js')) ||
|
|
1275
|
+
fs.existsSync(path.join(process.cwd(), 'vite.config.ts')) ||
|
|
1276
|
+
fs.existsSync(path.join(process.cwd(), 'vite.config.mjs'))) {
|
|
1277
|
+
return 'vite';
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
return null;
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
/**
|
|
1284
|
+
* Prompts user for configuration using readline
|
|
1285
|
+
* @param {string} question - Question to ask
|
|
1286
|
+
* @param {string} defaultValue - Default value
|
|
1287
|
+
* @returns {Promise<string>} User input
|
|
1288
|
+
*/
|
|
1289
|
+
function prompt(question, defaultValue = '') {
|
|
1290
|
+
return new Promise((resolve) => {
|
|
1291
|
+
const readline = require('readline');
|
|
1292
|
+
const rl = readline.createInterface({
|
|
1293
|
+
input: process.stdin,
|
|
1294
|
+
output: process.stdout
|
|
1295
|
+
});
|
|
1296
|
+
|
|
1297
|
+
const promptText = defaultValue
|
|
1298
|
+
? `${question} › ${defaultValue} `
|
|
1299
|
+
: `${question} › `;
|
|
1300
|
+
|
|
1301
|
+
rl.question(promptText, (answer) => {
|
|
1302
|
+
rl.close();
|
|
1303
|
+
resolve(answer.trim() || defaultValue);
|
|
1304
|
+
});
|
|
1305
|
+
});
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1308
|
+
/**
|
|
1309
|
+
* Initializes the project with components.json configuration
|
|
1310
|
+
* Similar to shadcn/ui init command
|
|
1311
|
+
*/
|
|
1312
|
+
async function initProject() {
|
|
1313
|
+
info('Initializing project...\n');
|
|
1314
|
+
|
|
1315
|
+
// Check if components.json already exists
|
|
1316
|
+
const configPath = path.join(process.cwd(), 'components.json');
|
|
1317
|
+
if (fs.existsSync(configPath)) {
|
|
1318
|
+
warn('components.json already exists.');
|
|
1319
|
+
const overwrite = await prompt('Do you want to overwrite it? (y/N)', 'N');
|
|
1320
|
+
if (overwrite.toLowerCase() !== 'y' && overwrite.toLowerCase() !== 'yes') {
|
|
1321
|
+
info('Skipping initialization.');
|
|
1322
|
+
return;
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
// Detect project type
|
|
1327
|
+
const projectType = detectProjectType();
|
|
1328
|
+
let detectedType = projectType || 'nextjs';
|
|
1329
|
+
|
|
1330
|
+
if (!projectType) {
|
|
1331
|
+
info('Could not detect project type. Defaulting to Next.js.');
|
|
1332
|
+
} else {
|
|
1333
|
+
info(`Detected ${projectType === 'nextjs' ? 'Next.js' : 'Vite'} project.`);
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
// Ask for project type if not detected or user wants to override
|
|
1337
|
+
const useDetected = projectType
|
|
1338
|
+
? await prompt(`Which project type? (Next.js/Vite)`, detectedType === 'nextjs' ? 'Next.js' : 'Vite')
|
|
1339
|
+
: await prompt(`Which project type? (Next.js/Vite)`, 'Next.js');
|
|
1340
|
+
|
|
1341
|
+
const isNextjs = useDetected.toLowerCase().includes('next');
|
|
1342
|
+
const isVite = useDetected.toLowerCase().includes('vite');
|
|
1343
|
+
|
|
1344
|
+
// Detect CSS path
|
|
1345
|
+
let cssPath = 'app/globals.css';
|
|
1346
|
+
if (isVite) {
|
|
1347
|
+
cssPath = 'src/index.css';
|
|
1348
|
+
} else if (fs.existsSync(path.join(process.cwd(), 'app', 'globals.css'))) {
|
|
1349
|
+
cssPath = 'app/globals.css';
|
|
1350
|
+
} else if (fs.existsSync(path.join(process.cwd(), 'styles', 'globals.css'))) {
|
|
1351
|
+
cssPath = 'styles/globals.css';
|
|
1352
|
+
} else {
|
|
1353
|
+
cssPath = await prompt('Where is your global CSS file?', cssPath);
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
// Ask for base color
|
|
1357
|
+
const baseColor = await prompt('Which color would you like to use as base color?', 'neutral');
|
|
1358
|
+
|
|
1359
|
+
// Ask for style
|
|
1360
|
+
const style = await prompt('Which style would you like to use?', 'blue');
|
|
1361
|
+
|
|
1362
|
+
// Create components.json
|
|
1363
|
+
const config = {
|
|
1364
|
+
$schema: 'https://weloop.kosign.dev/schema.json',
|
|
1365
|
+
style: style,
|
|
1366
|
+
rsc: isNextjs,
|
|
1367
|
+
tsx: true,
|
|
1368
|
+
tailwind: {
|
|
1369
|
+
config: 'tailwind.config.ts',
|
|
1370
|
+
css: cssPath,
|
|
1371
|
+
baseColor: baseColor,
|
|
1372
|
+
cssVariables: true,
|
|
1373
|
+
prefix: ''
|
|
1374
|
+
},
|
|
1375
|
+
iconLibrary: 'lucide',
|
|
1376
|
+
aliases: {
|
|
1377
|
+
components: '@/components',
|
|
1378
|
+
utils: '@/lib/utils',
|
|
1379
|
+
ui: '@/components/ui',
|
|
1380
|
+
lib: '@/lib',
|
|
1381
|
+
hooks: '@/hooks'
|
|
1382
|
+
},
|
|
1383
|
+
registry: 'https://gitlab.com/Sophanithchrek/weloop-shadcn-next-app/-/raw/main/registry/index.json'
|
|
1384
|
+
};
|
|
1385
|
+
|
|
1386
|
+
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
1387
|
+
success('Created components.json\n');
|
|
1388
|
+
|
|
1389
|
+
// Install base dependencies
|
|
1390
|
+
info('Installing base dependencies...');
|
|
1391
|
+
const baseDeps = ['clsx', 'tailwind-merge'];
|
|
1392
|
+
const missingBaseDeps = baseDeps.filter(dep => !checkPackageInstalled(dep));
|
|
1393
|
+
|
|
1394
|
+
if (missingBaseDeps.length > 0) {
|
|
1395
|
+
await installPackages(missingBaseDeps);
|
|
1396
|
+
} else {
|
|
1397
|
+
info('Base dependencies already installed.');
|
|
1398
|
+
}
|
|
1399
|
+
|
|
1400
|
+
// Install tw-animate-css
|
|
1401
|
+
if (!checkPackageInstalled('tw-animate-css')) {
|
|
1402
|
+
info('Installing tw-animate-css for animations...');
|
|
1403
|
+
await installPackages(['tw-animate-css']);
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
// Install CSS styles
|
|
1407
|
+
info('\nInstalling CSS styles...');
|
|
1408
|
+
await installCSSStyles(config, DEFAULT_REGISTRY_URL, false, false);
|
|
1409
|
+
|
|
1410
|
+
success('\n✅ Project initialized successfully!');
|
|
1411
|
+
info('\nYou can now add components using:');
|
|
1412
|
+
info(' npx weloop-kosign@latest add <component-name>');
|
|
1413
|
+
info(' pnpm dlx weloop-kosign@latest add <component-name>');
|
|
1414
|
+
info(' yarn weloop-kosign@latest add <component-name>\n');
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1252
1417
|
// ============================================================================
|
|
1253
1418
|
// COMMANDS - CLI Command Handlers
|
|
1254
1419
|
// ============================================================================
|
|
@@ -1315,6 +1480,7 @@ async function main() {
|
|
|
1315
1480
|
if (!command) {
|
|
1316
1481
|
console.log(`
|
|
1317
1482
|
Usage:
|
|
1483
|
+
node scripts/cli-remote.js init [--registry <url>] Initialize project
|
|
1318
1484
|
node scripts/cli-remote.js add <component-name> [--registry <url>] Install a component
|
|
1319
1485
|
node scripts/cli-remote.js list [--registry <url>] List all available components
|
|
1320
1486
|
node scripts/cli-remote.js css [--registry <url>] [--overwrite] Install/update CSS styles
|
|
@@ -1324,6 +1490,7 @@ Options:
|
|
|
1324
1490
|
--overwrite, -f Overwrite existing files
|
|
1325
1491
|
|
|
1326
1492
|
Examples:
|
|
1493
|
+
node scripts/cli-remote.js init
|
|
1327
1494
|
node scripts/cli-remote.js add button
|
|
1328
1495
|
node scripts/cli-remote.js add button --registry https://raw.githubusercontent.com/user/repo/main/registry
|
|
1329
1496
|
node scripts/cli-remote.js list
|
|
@@ -1335,6 +1502,10 @@ Examples:
|
|
|
1335
1502
|
|
|
1336
1503
|
// Route to appropriate command handler
|
|
1337
1504
|
switch (command) {
|
|
1505
|
+
case 'init':
|
|
1506
|
+
await initProject();
|
|
1507
|
+
break;
|
|
1508
|
+
|
|
1338
1509
|
case 'add':
|
|
1339
1510
|
if (!componentName) {
|
|
1340
1511
|
error('Please provide a component name');
|
|
@@ -1357,7 +1528,7 @@ Examples:
|
|
|
1357
1528
|
|
|
1358
1529
|
default:
|
|
1359
1530
|
error(`Unknown command: ${command}`);
|
|
1360
|
-
console.log('Available commands: add, list, css');
|
|
1531
|
+
console.log('Available commands: init, add, list, css');
|
|
1361
1532
|
process.exit(1);
|
|
1362
1533
|
}
|
|
1363
1534
|
}
|