ts-init-template 1.0.1 → 1.0.3

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.
Files changed (3) hide show
  1. package/index.js +16 -4
  2. package/package.json +1 -1
  3. package/readme.md +22 -0
package/index.js CHANGED
@@ -21,12 +21,10 @@ try{
21
21
 
22
22
 
23
23
  // Check if package.json exists
24
- const pkgpath = path.join(__dirname, 'package.json')
24
+ const pkgpath = path.join(process.cwd(), 'package.json')
25
25
  try {
26
26
  await fs.access(pkgpath);
27
27
  console.log('package.json exists, proceeding with script execution.');
28
-
29
- console.log(pkgpath);
30
28
  // Read and parse package.json
31
29
  const content = await fs.readFile(pkgpath, 'utf8');
32
30
  const pkg = JSON.parse(content);
@@ -46,6 +44,7 @@ catch (error) {
46
44
  process.exit(1);
47
45
  };
48
46
 
47
+ // Copy the template files
49
48
  try{
50
49
  const templatePath = path.join(__dirname, 'template');
51
50
 
@@ -55,7 +54,20 @@ try{
55
54
  } catch (error) {
56
55
  console.error('❌ Failed to copy files:', error);
57
56
  process.exit(1);
58
- }
57
+ };
58
+
59
+ // Create the src directory if it does not exist
60
+ try {
61
+ const srcPath = path.join(process.cwd(), 'src');
62
+ // Check if the src directory exists
63
+ await fs.access(srcPath);
64
+ console.log('✅ src directory exists.');
65
+ }catch{
66
+ // Create the src directory if it does not exist
67
+ console.log('The src directory does not exist, Creating it now...');
68
+ await fs.mkdir(path.join(process.cwd(), 'src'), { recursive: true });
69
+ console.log('✅ src directory created successfully. You can now add your source files.');
70
+ };
59
71
 
60
72
  console.log('✅ All operations completed successfully!');
61
73
  process.exit(0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-init-template",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "A TS project template for my ts projects. This script will setup all the ts enviroment with 1 command. ",
5
5
  "main": "index.js",
6
6
  "author": "SigismundBT",
package/readme.md ADDED
@@ -0,0 +1,22 @@
1
+ # ts-init-template
2
+
3
+ > A minimal CLI to bootstrap a clean TypeScript project with zero friction.
4
+
5
+ ---
6
+
7
+ ## 🚀 Features
8
+
9
+ - 🛠 Installs required devDependencies
10
+ - 📦 Sets up `tsconfig.json` and `build.js`
11
+ - 🔧 Updates `package.json` (`type`, `scripts`)
12
+ - ⚡ Runs in seconds with a single command
13
+
14
+ ---
15
+
16
+ ## 📦 Usage
17
+
18
+ ```bash
19
+ yarn init
20
+ npx ts-init-template
21
+ yarn build
22
+ yarn start