express-scaffolding-typescript 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/bin/cli.ts
ADDED
package/lib/{cli.js → cli.ts}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { resolve } from "node:path";
|
|
2
|
-
import expressGenTs from "./express-scaffolding-typescript.
|
|
2
|
+
import expressGenTs from "./express-scaffolding-typescript.ts";
|
|
3
3
|
|
|
4
4
|
/******************************************************************************
|
|
5
5
|
Run
|
|
@@ -19,7 +19,7 @@ if (useYarnIdx > -1) {
|
|
|
19
19
|
|
|
20
20
|
// Setup destination
|
|
21
21
|
let destination = "express-scaffolding-ts";
|
|
22
|
-
if (args.length > 0) {
|
|
22
|
+
if (args.length > 0 && args[0]) {
|
|
23
23
|
destination = args[0];
|
|
24
24
|
}
|
|
25
25
|
destination = resolve(process.cwd(), destination);
|
|
@@ -38,7 +38,7 @@ const DEV_DEPENDENCIES = [
|
|
|
38
38
|
|
|
39
39
|
// "ncp" options
|
|
40
40
|
const ncpOpts = {
|
|
41
|
-
filter: (fileName) => {
|
|
41
|
+
filter: (fileName: string) => {
|
|
42
42
|
return !relative(PROJECT_FOLDER_PATH, fileName)
|
|
43
43
|
.split(/[\\/]/)
|
|
44
44
|
.some((entry) => EXCLUDED_TEMPLATE_ENTRIES.has(entry));
|
|
@@ -52,7 +52,7 @@ const ncpOpts = {
|
|
|
52
52
|
/**
|
|
53
53
|
* Entry point
|
|
54
54
|
*/
|
|
55
|
-
async function expressGenTs(destination, useYarn) {
|
|
55
|
+
async function expressGenTs(destination: string, useYarn: boolean) {
|
|
56
56
|
await copyProjectFiles(destination);
|
|
57
57
|
updatePackageJson(destination);
|
|
58
58
|
await renameGitignoreFile(destination);
|
|
@@ -62,22 +62,20 @@ async function expressGenTs(destination, useYarn) {
|
|
|
62
62
|
/**
|
|
63
63
|
* Copy project files
|
|
64
64
|
*/
|
|
65
|
-
function copyProjectFiles(destination) {
|
|
65
|
+
function copyProjectFiles(destination: string) {
|
|
66
66
|
const source = PROJECT_FOLDER_PATH;
|
|
67
|
-
return /** @type {Promise<void>} */ (
|
|
68
|
-
|
|
69
|
-
return
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
})
|
|
73
|
-
);
|
|
67
|
+
return /** @type {Promise<void>} */ new Promise<void>((res, rej) => {
|
|
68
|
+
return ncp(source, destination, ncpOpts, (err) => {
|
|
69
|
+
return err ? rej(err) : res();
|
|
70
|
+
});
|
|
71
|
+
});
|
|
74
72
|
}
|
|
75
73
|
|
|
76
74
|
/**
|
|
77
75
|
* Set update the package.json file.
|
|
78
76
|
*/
|
|
79
|
-
function updatePackageJson(destination) {
|
|
80
|
-
|
|
77
|
+
function updatePackageJson(destination: string) {
|
|
78
|
+
const file = editJsonFile(destination + "/package.json", {
|
|
81
79
|
autosave: true,
|
|
82
80
|
});
|
|
83
81
|
file.set("name", basename(destination));
|
|
@@ -88,7 +86,7 @@ function updatePackageJson(destination) {
|
|
|
88
86
|
/**
|
|
89
87
|
* Because npm does not allow .gitignore to be published.
|
|
90
88
|
*/
|
|
91
|
-
async function renameGitignoreFile(destination) {
|
|
89
|
+
async function renameGitignoreFile(destination: string) {
|
|
92
90
|
const source = join(destination, "gitignore");
|
|
93
91
|
if (!existsSync(source)) {
|
|
94
92
|
return;
|
|
@@ -99,11 +97,11 @@ async function renameGitignoreFile(destination) {
|
|
|
99
97
|
/**
|
|
100
98
|
* Download the dependencies.
|
|
101
99
|
*/
|
|
102
|
-
function downloadNodeModules(destination, useYarn) {
|
|
100
|
+
function downloadNodeModules(destination: string, useYarn: boolean) {
|
|
103
101
|
const options = { cwd: destination };
|
|
104
102
|
// Setup dependencies string
|
|
105
|
-
|
|
106
|
-
|
|
103
|
+
const depStr = DEPENDENCIES.join(" ");
|
|
104
|
+
const devDepStr = DEV_DEPENDENCIES.join(" ");
|
|
107
105
|
// Setup download command
|
|
108
106
|
let downloadLibCmd, downloadDepCmd;
|
|
109
107
|
if (useYarn) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "express-scaffolding-typescript",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Scaffold new Express.js application with TypeScript",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"express"
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"author": "Qiuyi Hong",
|
|
10
10
|
"type": "module",
|
|
11
|
-
"main": "lib/express-scaffolding-typescript.
|
|
11
|
+
"main": "lib/express-scaffolding-typescript.ts",
|
|
12
12
|
"bin": {
|
|
13
|
-
"express-scaffolding-typescript": "bin/cli.
|
|
13
|
+
"express-scaffolding-typescript": "bin/cli.ts"
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
16
|
"bin",
|
|
@@ -20,18 +20,20 @@
|
|
|
20
20
|
"lib": "lib"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
|
-
"start": "
|
|
24
|
-
"lint": "eslint bin lib/*.
|
|
25
|
-
"test": "
|
|
23
|
+
"start": "tsx bin/cli.ts",
|
|
24
|
+
"lint": "eslint bin lib/*.ts test eslint.config.mjs",
|
|
25
|
+
"test": "tsx --test"
|
|
26
26
|
},
|
|
27
27
|
"repository": {
|
|
28
28
|
"type": "git",
|
|
29
29
|
"url": "https://github.com/Qiuyi-Hong/express-scaffolding-typescript.git"
|
|
30
30
|
},
|
|
31
31
|
"homepage": "https://github.com/Qiuyi-Hong/express-scaffolding-typescript#readme",
|
|
32
|
-
|
|
33
32
|
"devDependencies": {
|
|
34
33
|
"@eslint/js": "^10.0.1",
|
|
34
|
+
"@types/edit-json-file": "^1.7.4",
|
|
35
|
+
"@types/ncp": "^2.0.8",
|
|
36
|
+
"@types/node": "^26.1.0",
|
|
35
37
|
"eslint": "^10.6.0",
|
|
36
38
|
"eslint-config-prettier": "^10.1.8",
|
|
37
39
|
"eslint-plugin-prettier": "^5.5.6",
|
|
@@ -42,6 +44,7 @@
|
|
|
42
44
|
},
|
|
43
45
|
"dependencies": {
|
|
44
46
|
"edit-json-file": "^1.8.1",
|
|
45
|
-
"ncp": "^2.0.0"
|
|
47
|
+
"ncp": "^2.0.0",
|
|
48
|
+
"tsx": "^4.22.4"
|
|
46
49
|
}
|
|
47
50
|
}
|
package/bin/cli.js
DELETED