express-ts-starter-ys-v1 1.0.2 → 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 (2) hide show
  1. package/bin/cli.js +62 -0
  2. package/package.json +4 -1
package/bin/cli.js ADDED
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env node
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+
5
+ const targetDir = process.cwd();
6
+ const templateDir = path.join(__dirname, '..');
7
+
8
+ console.log("Setting up your Express TS starter project...");
9
+
10
+ const filesToCopy = ['src', 'tsconfig.json', '.gitignore'];
11
+
12
+ function copyRecursiveSync(src, dest) {
13
+ const exists = fs.existsSync(src);
14
+ const stats = exists && fs.statSync(src);
15
+ const isDirectory = exists && stats.isDirectory();
16
+ if (isDirectory) {
17
+ fs.mkdirSync(dest, { recursive: true });
18
+ fs.readdirSync(src).forEach(function (childItemName) {
19
+ copyRecursiveSync(path.join(src, childItemName),
20
+ path.join(dest, childItemName));
21
+ });
22
+ } else {
23
+ if (exists) {
24
+ fs.copyFileSync(src, dest);
25
+ }
26
+ }
27
+ }
28
+
29
+ filesToCopy.forEach(file => {
30
+ const srcPath = path.join(templateDir, file);
31
+ const destPath = path.join(targetDir, file);
32
+
33
+ if (fs.existsSync(srcPath)) {
34
+ console.log(`Copying ${file}...`);
35
+ copyRecursiveSync(srcPath, destPath);
36
+ }
37
+ });
38
+
39
+ // Optionally, create a new package.json for the user
40
+ const userPackageJsonPath = path.join(targetDir, 'package.json');
41
+ if (!fs.existsSync(userPackageJsonPath)) {
42
+ console.log("Creating package.json...");
43
+ const templatePackage = require(path.join(templateDir, 'package.json'));
44
+
45
+ const newPackage = {
46
+ name: "my-express-app",
47
+ version: "1.0.0",
48
+ main: "dist/server.js",
49
+ scripts: templatePackage.scripts,
50
+ dependencies: templatePackage.dependencies,
51
+ devDependencies: templatePackage.devDependencies
52
+ };
53
+
54
+ // Remove prepublishOnly script since it's not needed for the user
55
+ delete newPackage.scripts.prepublishOnly;
56
+
57
+ fs.writeFileSync(userPackageJsonPath, JSON.stringify(newPackage, null, 2));
58
+ }
59
+
60
+ console.log("\nDone! Next steps:");
61
+ console.log("1. Run 'npm install' to install dependencies");
62
+ console.log("2. Run 'npm run dev' to start the development server");
package/package.json CHANGED
@@ -1,7 +1,10 @@
1
1
  {
2
2
  "name": "express-ts-starter-ys-v1",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "",
5
+ "bin": {
6
+ "create-express-ys": "./bin/cli.js"
7
+ },
5
8
  "main": "dist/server.js",
6
9
  "types": "dist/server.d.ts",
7
10
  "scripts": {