@onsever/create-express-ts-app 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/README.md CHANGED
@@ -11,26 +11,24 @@ This is a starter template for [Express](https://expressjs.com/) web framework f
11
11
  - Linting support with [ESLint](https://eslint.org/)
12
12
  - Logging support with [Pino](https://getpino.io/)
13
13
 
14
- ## Getting Started
15
-
16
- Please make sure you have [pnpm](https://pnpm.io/) installed.
17
-
18
14
  ## Usage
19
15
 
20
- To use this template, run the following command:
16
+ To use this template, run one of the following commands:
21
17
 
22
18
  ```bash
23
19
  npx @onsever/create-express-ts-app <project-name>
20
+ npx @onsever/create-express-ts-app .
21
+ npx @onsever/create-express-ts-app ./
24
22
  ```
25
23
 
26
24
  ## Commands
27
25
 
28
- - `pnpm build` - Build the project
29
- - `pnpm start` - Start the server in production mode
30
- - `pnpm dev` - Start the server in development mode with live reload
31
- - `pnpm lint:check` - Check for linting errors
32
- - `pnpm lint:fix` - Fix linting errors
33
- - `pnpm prettier:check` - Check for formatting errors
34
- - `pnpm prettier:fix` - Fix formatting errors
35
- - `pnpm test` - Run tests
36
- - `pnpm test:watch` - Run tests in watch mode
26
+ - `npm run build` - Build the project
27
+ - `npm run start` - Start the server in production mode
28
+ - `npm run dev` - Start the server in development mode with live reload
29
+ - `npm run lint:check` - Check for linting errors
30
+ - `npm run lint:fix` - Fix linting errors
31
+ - `npm run prettier:check` - Check for formatting errors
32
+ - `npm run prettier:fix` - Fix formatting errors
33
+ - `npm run test` - Run tests
34
+ - `npm run test:watch` - Run tests in watch mode
package/bin/cli.js CHANGED
@@ -14,10 +14,22 @@ const runCommand = (command) => {
14
14
  return true;
15
15
  };
16
16
 
17
- const projectName = process.argv[2];
17
+ let projectName;
18
+ const targetArgument = process.argv[2];
19
+ const directoryName = path.resolve(path.dirname(''));
20
+
21
+ console.log(directoryName);
22
+
23
+ if (targetArgument === '.' || targetArgument === './') {
24
+ projectName = directoryName.slice(directoryName.lastIndexOf('/') + 1);
25
+ } else {
26
+ projectName = targetArgument;
27
+ }
28
+
29
+ console.log(projectName);
18
30
 
19
31
  if (!projectName) {
20
- console.error('Please specify a project name.');
32
+ console.error('Please specify a project name or provide a valid directory path.');
21
33
  process.exit(1);
22
34
  }
23
35
 
@@ -31,10 +43,10 @@ if (!checkedOut) process.exit(1);
31
43
 
32
44
  console.log(`Installing dependencies for ${projectName}...`);
33
45
 
34
- const installedDeps = runCommand(installDepsCommand);
46
+ const installedDeps = runCommand(`cd ${projectName} && ${installDepsCommand}`);
35
47
  if (!installedDeps) process.exit(1);
36
48
 
37
- const packageJsonPath = `${projectName}/package.json`;
49
+ const packageJsonPath = path.join(projectName, 'package.json');
38
50
  try {
39
51
  const packageJsonData = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
40
52
 
@@ -73,21 +85,23 @@ console.log(`cd ${projectName} && pnpm dev`);
73
85
 
74
86
  function removeGitKeepsSync(directory) {
75
87
  try {
76
- const files = fs.readdirSync(directory);
88
+ if (fs.existsSync(directory)) {
89
+ const files = fs.readdirSync(directory);
77
90
 
78
- files.forEach((file) => {
79
- const filePath = path.join(directory, file);
91
+ files.forEach((file) => {
92
+ const filePath = path.join(directory, file);
80
93
 
81
- const stat = fs.statSync(filePath);
94
+ const stat = fs.statSync(filePath);
82
95
 
83
- if (stat.isDirectory()) {
84
- const gitKeepPath = path.join(filePath, '.gitkeep');
85
- if (fs.existsSync(gitKeepPath)) {
86
- fs.unlinkSync(gitKeepPath);
96
+ if (stat.isDirectory()) {
97
+ const gitKeepPath = path.join(filePath, '.gitkeep');
98
+ if (fs.existsSync(gitKeepPath)) {
99
+ fs.unlinkSync(gitKeepPath);
100
+ }
101
+ removeGitKeepsSync(filePath);
87
102
  }
88
- removeGitKeepsSync(filePath);
89
- }
90
- });
103
+ });
104
+ }
91
105
  } catch (err) {
92
106
  console.error(`Error: ${err.message}`);
93
107
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onsever/create-express-ts-app",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "This is a starter template for Express.js with TypeScript that includes Jest, Prettier, ESLint, and more.",
5
5
  "bin": "./bin/cli.js",
6
6
  "main": "main.js",
package/tsconfig.json CHANGED
@@ -38,5 +38,6 @@
38
38
  "@utils/*": ["./src/utils/*"],
39
39
  "@root/*": ["./src/*"]
40
40
  }
41
- }
41
+ },
42
+ "exclude": ["node_modules", "build", "jest.config.ts", "tests"]
42
43
  }