ts-init-template 1.0.0 → 1.0.1
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/index.js
CHANGED
@@ -9,53 +9,52 @@ const __dirname = import.meta.dirname
|
|
9
9
|
const execAsync = promisify(exec);
|
10
10
|
//install dependencies
|
11
11
|
try{
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
const { stdout, stderr } = await execAsync('yarn add -D typescript ts-node @types/node fast-glob esbuild');
|
13
|
+
console.log('Dependencies installed successfully:', stdout);
|
14
|
+
if(stderr){
|
15
|
+
console.error('Error during installation:', stderr);
|
16
|
+
};
|
17
17
|
} catch (error) {
|
18
|
-
|
19
|
-
|
18
|
+
console.error('❌ Failed to install dependencies:', error);
|
19
|
+
process.exit(1);
|
20
20
|
};
|
21
21
|
|
22
22
|
|
23
23
|
// Check if package.json exists
|
24
24
|
const pkgpath = path.join(__dirname, 'package.json')
|
25
25
|
try {
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
await fs.writeFile(pkgpath, JSON.stringify(pkg, null, 2));
|
44
|
-
console.log('✅ package.json updated.');
|
45
|
-
|
26
|
+
await fs.access(pkgpath);
|
27
|
+
console.log('package.json exists, proceeding with script execution.');
|
28
|
+
|
29
|
+
console.log(pkgpath);
|
30
|
+
// Read and parse package.json
|
31
|
+
const content = await fs.readFile(pkgpath, 'utf8');
|
32
|
+
const pkg = JSON.parse(content);
|
33
|
+
pkg.type = 'module';
|
34
|
+
pkg.scripts = {
|
35
|
+
...pkg.scripts,
|
36
|
+
build: "node build.js",
|
37
|
+
start: "node dist/index.js"
|
38
|
+
}
|
39
|
+
|
40
|
+
// Add or update the package.json properties
|
41
|
+
await fs.writeFile(pkgpath, JSON.stringify(pkg, null, 2));
|
42
|
+
console.log('✅ package.json updated.');
|
46
43
|
}
|
47
44
|
catch (error) {
|
48
|
-
|
49
|
-
|
45
|
+
console.error('❌ package.json not found:', error);
|
46
|
+
process.exit(1);
|
50
47
|
};
|
51
48
|
|
52
49
|
try{
|
53
|
-
|
54
|
-
|
55
|
-
|
50
|
+
const templatePath = path.join(__dirname, 'template');
|
51
|
+
|
52
|
+
await fs.copyFile(path.join(templatePath, 'build.js'), path.join(process.cwd(), 'build.js'));
|
53
|
+
await fs.copyFile(path.join(templatePath, 'tsconfig.json'), path.join(process.cwd(), 'tsconfig.json'));
|
54
|
+
console.log('Files "build.js" and "tsconfig.json" copied successfully');
|
56
55
|
} catch (error) {
|
57
|
-
|
58
|
-
|
56
|
+
console.error('❌ Failed to copy files:', error);
|
57
|
+
process.exit(1);
|
59
58
|
}
|
60
59
|
|
61
60
|
console.log('✅ All operations completed successfully!');
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "ts-init-template",
|
3
|
-
"version": "1.0.
|
4
|
-
"description": "A
|
3
|
+
"version": "1.0.1",
|
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",
|
7
7
|
"license": "MIT",
|
File without changes
|
File without changes
|