@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 +12 -14
- package/bin/cli.js +29 -15
- package/package.json +1 -1
- package/tsconfig.json +2 -1
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
|
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
|
-
- `
|
29
|
-
- `
|
30
|
-
- `
|
31
|
-
- `
|
32
|
-
- `
|
33
|
-
- `
|
34
|
-
- `
|
35
|
-
- `
|
36
|
-
- `
|
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
|
-
|
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 =
|
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
|
-
|
88
|
+
if (fs.existsSync(directory)) {
|
89
|
+
const files = fs.readdirSync(directory);
|
77
90
|
|
78
|
-
|
79
|
-
|
91
|
+
files.forEach((file) => {
|
92
|
+
const filePath = path.join(directory, file);
|
80
93
|
|
81
|
-
|
94
|
+
const stat = fs.statSync(filePath);
|
82
95
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
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
|
-
|
89
|
-
|
90
|
-
});
|
103
|
+
});
|
104
|
+
}
|
91
105
|
} catch (err) {
|
92
106
|
console.error(`Error: ${err.message}`);
|
93
107
|
}
|
package/package.json
CHANGED