@jknanda78/ts-boilerplate 1.0.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/LICENSE +21 -0
- package/README.md +2 -0
- package/cli.js +76 -0
- package/package.json +25 -0
- package/templates/typescript/.prettierrc +9 -0
- package/templates/typescript/index.ts +7 -0
- package/templates/typescript/nodemon.json +6 -0
- package/templates/typescript/package.json +25 -0
- package/templates/typescript/tsconfig.json +20 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Author | FullStack | Tech Lead | Web Platform | Innovation Enthusiast | UX | Test All | GraphQL | K8s | Mircoservices
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
package/cli.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const os = require('os');
|
|
3
|
+
const styleText = require('node:util').styleText;
|
|
4
|
+
|
|
5
|
+
const projectName = process.argv[2]; // Get the project name from command line arguments
|
|
6
|
+
|
|
7
|
+
// Check if project name is provided
|
|
8
|
+
if (!projectName) {
|
|
9
|
+
console.error('Please provide a project name: npx @jknanda78/ts-boilerplate <project-name>');
|
|
10
|
+
process.exit(1);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
console.info(`Creating boilerplate for project: ${styleText('bgGrey', projectName)} ${os.EOL}`);
|
|
14
|
+
|
|
15
|
+
// Create project directory
|
|
16
|
+
const fs = require('fs');
|
|
17
|
+
const path = require('path');
|
|
18
|
+
|
|
19
|
+
const projectPath = path.join(process.cwd(), projectName);
|
|
20
|
+
|
|
21
|
+
console.info(`Creating project directory at: ${styleText('bgGrey', projectPath)} ${os.EOL}`);
|
|
22
|
+
|
|
23
|
+
if (fs.existsSync(projectPath)) {
|
|
24
|
+
console.error(`Directory ${styleText('bgGrey', projectName)} already exists. Please choose a different project name.`);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
fs.mkdirSync(projectPath);
|
|
29
|
+
|
|
30
|
+
// Copy boilerplate files from a template directory
|
|
31
|
+
const templatePath = path.join(__dirname, 'templates/typescript');
|
|
32
|
+
|
|
33
|
+
console.info(`Copying boilerplate files from: ${styleText('bgGrey', templatePath)} ${os.EOL}`);
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
fs.readdirSync(templatePath).forEach((childItemName) => {
|
|
37
|
+
fs.copyFileSync(path.join(templatePath, childItemName), path.join(projectPath, childItemName));
|
|
38
|
+
});
|
|
39
|
+
} catch (err) {
|
|
40
|
+
console.error(`Template directory not found or inaccessible: ${err.message}`);
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
console.info(`Boilerplate created successfully in ${styleText('bgGrey', projectName)} directory.${os.EOL}`);
|
|
45
|
+
|
|
46
|
+
function proceedWithNpmInstall() {
|
|
47
|
+
console.info(`Proceed to install dependencies... ${os.EOL}`);
|
|
48
|
+
|
|
49
|
+
// npm install
|
|
50
|
+
const { execSync } = require('child_process');
|
|
51
|
+
|
|
52
|
+
try {
|
|
53
|
+
console.log(`Installing dependencies... in ${styleText('bgGrey', projectPath)}`);
|
|
54
|
+
const registryUrl = 'https://registry.npmjs.org/';
|
|
55
|
+
execSync(`npm install --registry=${registryUrl}`, { cwd: projectPath, stdio: 'inherit' });
|
|
56
|
+
console.log(`npm install complete!${os.EOL}`);
|
|
57
|
+
} catch (error) {
|
|
58
|
+
console.error('npm install failed:', error);
|
|
59
|
+
process.exit(1); // Exit with a failure code if the command fails
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
console.info('All set! You can now start working on your project.');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const prompt = require('prompt-sync')();
|
|
66
|
+
|
|
67
|
+
const input = prompt('Do you want to proceed with npm install? yes/no (default: yes): ');
|
|
68
|
+
|
|
69
|
+
if (input.toLowerCase() === 'n' && input.toLowerCase() === 'no') {
|
|
70
|
+
console.info(`Skipping npm install. You can run it later manually. ${os.EOL}`);
|
|
71
|
+
process.exit(0);
|
|
72
|
+
} else if (input.toLowerCase() === 'y' || input.toLowerCase() === 'yes' || input === '') {
|
|
73
|
+
proceedWithNpmInstall();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
process.exit(0);
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jknanda78/ts-boilerplate",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "boilerplate for ts based web applications",
|
|
5
|
+
"main": "cli.ts",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"bin": {
|
|
10
|
+
"@jknanda78/ts-boilerplate": "./cli.js"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/jknanda78/ts-boilerplate.git"
|
|
15
|
+
},
|
|
16
|
+
"author": "Jyoti Kaustuv Nanda",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/jknanda78/ts-boilerplate/issues"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://github.com/jknanda78/ts-boilerplate#readme",
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"prompt-sync": "^4.2.0"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ts-boilerplate",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "TypeScript boilerplate project",
|
|
5
|
+
"main": "index.ts",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "tsc",
|
|
8
|
+
"dev": "ts-node src/index.ts"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {},
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"@types/prettier": "^2.7.3",
|
|
13
|
+
"eslint": "9.39.2",
|
|
14
|
+
"eslint-config-prettier": "^10.1.8",
|
|
15
|
+
"nodemon": "^3.1.9",
|
|
16
|
+
"prettier": "^3.6.2",
|
|
17
|
+
"ts-node": "^10.4.0",
|
|
18
|
+
"ts-node-dev": "2.0.0",
|
|
19
|
+
"tsconfig-paths": "^4.2.0",
|
|
20
|
+
"typescript": "^5.8.2"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [],
|
|
23
|
+
"author": "",
|
|
24
|
+
"license": "MIT"
|
|
25
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"strict": true,
|
|
6
|
+
"esModuleInterop": true,
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
"forceConsistentCasingInFileNames": true,
|
|
9
|
+
"outDir": "./dist",
|
|
10
|
+
"rootDir": ".",
|
|
11
|
+
"paths": {
|
|
12
|
+
"@utils/*": ["./src/utils/*"],
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"include": ["src/**/*"],
|
|
16
|
+
"exclude": [
|
|
17
|
+
"node_modules",
|
|
18
|
+
"**/*.spec.ts"
|
|
19
|
+
]
|
|
20
|
+
}
|