initkit 1.2.3 ā 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.
|
|
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",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"bugs": {
|
|
48
48
|
"url": "https://github.com/shirishshrestha/initkit/issues"
|
|
49
49
|
},
|
|
50
|
-
"homepage": "https://
|
|
50
|
+
"homepage": "https://initkit.shirishshrestha.com.np/",
|
|
51
51
|
"engines": {
|
|
52
52
|
"node": ">=14.0.0"
|
|
53
53
|
},
|
|
@@ -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
|
+
}
|
|
@@ -91,7 +91,7 @@ async function createFeatureBasedStructure(srcPath, config) {
|
|
|
91
91
|
|
|
92
92
|
// Add barrel export
|
|
93
93
|
const ext = config.language === 'typescript' ? 'ts' : 'js';
|
|
94
|
-
await fs.
|
|
94
|
+
await fs.outputFile(
|
|
95
95
|
path.join(srcPath, 'features', feature, `index.${ext}`),
|
|
96
96
|
`// ${feature} feature exports\n// TODO: Export your components and hooks here\n`
|
|
97
97
|
);
|
|
@@ -259,7 +259,7 @@ DATABASE_URL=
|
|
|
259
259
|
API_KEY=
|
|
260
260
|
`;
|
|
261
261
|
|
|
262
|
-
await fs.
|
|
262
|
+
await fs.outputFile(path.join(projectPath, '.env.example'), envExample);
|
|
263
263
|
console.log(chalk.gray(' ā Added .env.example'));
|
|
264
264
|
}
|
|
265
265
|
|
|
@@ -311,7 +311,7 @@ EXPOSE 3000
|
|
|
311
311
|
CMD ["npm", "start"]
|
|
312
312
|
`;
|
|
313
313
|
|
|
314
|
-
await fs.
|
|
314
|
+
await fs.outputFile(path.join(projectPath, 'Dockerfile'), dockerfile);
|
|
315
315
|
|
|
316
316
|
const dockerignore = `node_modules
|
|
317
317
|
.git
|
|
@@ -319,7 +319,7 @@ CMD ["npm", "start"]
|
|
|
319
319
|
npm-debug.log
|
|
320
320
|
`;
|
|
321
321
|
|
|
322
|
-
await fs.
|
|
322
|
+
await fs.outputFile(path.join(projectPath, '.dockerignore'), dockerignore);
|
|
323
323
|
}
|
|
324
324
|
|
|
325
325
|
/**
|
|
@@ -361,7 +361,7 @@ jobs:
|
|
|
361
361
|
run: npm test
|
|
362
362
|
`;
|
|
363
363
|
|
|
364
|
-
await fs.
|
|
364
|
+
await fs.outputFile(path.join(projectPath, '.github', 'workflows', 'ci.yml'), workflow);
|
|
365
365
|
}
|
|
366
366
|
|
|
367
367
|
/**
|
|
@@ -379,7 +379,7 @@ async function generateHuskyFiles(projectPath, _config) {
|
|
|
379
379
|
npm run lint
|
|
380
380
|
`;
|
|
381
381
|
|
|
382
|
-
await fs.
|
|
382
|
+
await fs.outputFile(path.join(projectPath, '.husky', 'pre-commit'), preCommit);
|
|
383
383
|
}
|
|
384
384
|
|
|
385
385
|
export { generateTemplate };
|