initkit 1.2.4 → 1.2.5

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": "initkit",
3
- "version": "1.2.4",
3
+ "version": "1.2.5",
4
4
  "type": "module",
5
5
  "description": "A modern CLI tool for scaffolding production-ready web projects with live npm version fetching, multiple frameworks, and best practices built-in",
6
6
  "main": "src/index.js",
@@ -23,6 +23,9 @@ export async function bootstrapWithOfficialCLI(projectPath, config) {
23
23
  case 'backend':
24
24
  return bootstrapBackend(projectPath, config);
25
25
 
26
+ case 'library':
27
+ return bootstrapLibrary(projectPath, config);
28
+
26
29
  default:
27
30
  throw new Error(`Unsupported project type: ${projectType}`);
28
31
  }
@@ -302,3 +305,134 @@ export async function bootstrapFastify(projectPath, config) {
302
305
 
303
306
  await execCommand(command, { cwd: parentDir });
304
307
  }
308
+
309
+ /**
310
+ * Bootstrap Library/Package project
311
+ * Creates a basic npm package structure with TypeScript/JavaScript support
312
+ *
313
+ * @param {string} projectPath - Absolute path to project
314
+ * @param {Object} config - Configuration object
315
+ */
316
+ export async function bootstrapLibrary(projectPath, config) {
317
+ const { language = 'typescript', packageManager = 'npm' } = config;
318
+ const projectName = path.basename(projectPath);
319
+
320
+ console.log(chalk.cyan(`\nšŸ“¦ Creating Library/Package project...`));
321
+ console.log(
322
+ chalk.gray(` Language: ${language === 'typescript' ? 'TypeScript' : 'JavaScript'}`)
323
+ );
324
+ console.log(chalk.gray(` Package Manager: ${packageManager}\n`));
325
+
326
+ // Create basic directory structure
327
+ const fsExtra = await import('fs-extra');
328
+ const fs = fsExtra.default;
329
+
330
+ // Create project directory
331
+ await fs.ensureDir(projectPath);
332
+
333
+ // Create src directory
334
+ await fs.ensureDir(path.join(projectPath, 'src'));
335
+
336
+ // Create package.json
337
+ const packageJson = {
338
+ name: projectName,
339
+ version: '0.1.0',
340
+ description: 'A new library/package',
341
+ main: language === 'typescript' ? 'dist/index.js' : 'src/index.js',
342
+ types: language === 'typescript' ? 'dist/index.d.ts' : undefined,
343
+ scripts: {
344
+ ...(language === 'typescript' && {
345
+ build: 'tsc',
346
+ 'build:watch': 'tsc --watch',
347
+ prepublishOnly: 'npm run build',
348
+ }),
349
+ test: 'echo "Error: no test specified" && exit 1',
350
+ },
351
+ keywords: [],
352
+ author: '',
353
+ license: 'MIT',
354
+ };
355
+
356
+ await fs.outputFile(path.join(projectPath, 'package.json'), JSON.stringify(packageJson, null, 2));
357
+
358
+ // Create basic entry file
359
+ const ext = language === 'typescript' ? 'ts' : 'js';
360
+ const indexContent =
361
+ language === 'typescript'
362
+ ? `/**
363
+ * Main entry point for the library
364
+ */
365
+
366
+ export function hello(name: string): string {
367
+ return \`Hello, \${name}!\`;
368
+ }
369
+
370
+ export default {
371
+ hello,
372
+ };
373
+ `
374
+ : `/**
375
+ * Main entry point for the library
376
+ */
377
+
378
+ export function hello(name) {
379
+ return \`Hello, \${name}!\`;
380
+ }
381
+
382
+ export default {
383
+ hello,
384
+ };
385
+ `;
386
+
387
+ await fs.outputFile(path.join(projectPath, 'src', `index.${ext}`), indexContent);
388
+
389
+ // Create TypeScript config if needed
390
+ if (language === 'typescript') {
391
+ const tsconfig = {
392
+ compilerOptions: {
393
+ target: 'ES2020',
394
+ module: 'ESNext',
395
+ moduleResolution: 'node',
396
+ declaration: true,
397
+ outDir: './dist',
398
+ rootDir: './src',
399
+ strict: true,
400
+ esModuleInterop: true,
401
+ skipLibCheck: true,
402
+ forceConsistentCasingInFileNames: true,
403
+ },
404
+ include: ['src/**/*'],
405
+ exclude: ['node_modules', 'dist'],
406
+ };
407
+
408
+ await fs.outputFile(path.join(projectPath, 'tsconfig.json'), JSON.stringify(tsconfig, null, 2));
409
+ }
410
+
411
+ // Create README
412
+ const readme = `# ${projectName}
413
+
414
+ A new library/package
415
+
416
+ ## Installation
417
+
418
+ \`\`\`bash
419
+ npm install ${projectName}
420
+ \`\`\`
421
+
422
+ ## Usage
423
+
424
+ \`\`\`${language === 'typescript' ? 'typescript' : 'javascript'}
425
+ import { hello } from '${projectName}';
426
+
427
+ console.log(hello('World')); // Hello, World!
428
+ \`\`\`
429
+
430
+ ## License
431
+
432
+ MIT
433
+ `;
434
+
435
+ await fs.outputFile(path.join(projectPath, 'README.md'), readme);
436
+
437
+ console.log(chalk.green('āœ“ Library project structure created'));
438
+ }