@code-essentials/tsconfig 1.2.1 ā 1.2.4
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 +21 -0
- package/cli/setup.js +77 -0
- package/package.json +16 -2
- package/tsconfig.debug.json +0 -9
- package/tsconfig.json +0 -13
- package/tsconfig.prod.json +0 -10
package/README.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
## Install
|
|
4
4
|
|
|
5
|
+
Automatic
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm i -d @code-essentials/tsconfig
|
|
9
|
+
pnpm dlx setup-tsconfig
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Manual install
|
|
13
|
+
|
|
5
14
|
```bash
|
|
6
15
|
pnpm i -d @code-essentials/tsconfig
|
|
7
16
|
cp -r node_modules/@code-essentials/tsconfig/template/* .
|
|
@@ -11,6 +20,18 @@ cp -r node_modules/@code-essentials/tsconfig/template/* .
|
|
|
11
20
|
|
|
12
21
|
2. Copy [tsconfig.json.template](./tsconfig.json.template), [tsconfig.prod.json.template](./tsconfig.prod.json.template), and [tsconfig.debug.json.template](./tsconfig.debug.json.template) into project root, removing `.template`.
|
|
13
22
|
|
|
23
|
+
3. Write the following scripts in your `package.json`
|
|
24
|
+
|
|
25
|
+
```json
|
|
26
|
+
{
|
|
27
|
+
"clean": "rm -rf dist",
|
|
28
|
+
"prebuild": "pnpm run clean",
|
|
29
|
+
"prebuild:debug": "pnpm run clean",
|
|
30
|
+
"build": "tsc -p tsconfig.prod.json",
|
|
31
|
+
"build:debug": "tsc -p tsconfig.debug.json",
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
14
35
|
## License
|
|
15
36
|
|
|
16
37
|
MIT
|
package/cli/setup.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import fs from 'fs/promises';
|
|
6
|
+
import { constants } from 'fs';
|
|
7
|
+
|
|
8
|
+
// --- Configuration ---
|
|
9
|
+
// Assuming this script is located at 'cli/setup.js'
|
|
10
|
+
const SCRIPT_PATH = fileURLToPath(import.meta.url);
|
|
11
|
+
const SCRIPT_DIR = path.dirname(SCRIPT_PATH);
|
|
12
|
+
|
|
13
|
+
// Source directory is two levels up from the script location, then into 'template'
|
|
14
|
+
const SOURCE_DIR = path.resolve(SCRIPT_DIR, '..', 'template');
|
|
15
|
+
|
|
16
|
+
// Destination is the user's current working directory (project root)
|
|
17
|
+
const DEST_DIR = process.cwd();
|
|
18
|
+
// ---------------------
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Recursively copies a directory's contents from source to destination.
|
|
22
|
+
* @param {string} src The source directory path.
|
|
23
|
+
* @param {string} dest The destination directory path.
|
|
24
|
+
*/
|
|
25
|
+
async function copyDir(src, dest) {
|
|
26
|
+
try {
|
|
27
|
+
// 1. Create the destination directory if it doesn't exist
|
|
28
|
+
await fs.mkdir(dest, { recursive: true });
|
|
29
|
+
|
|
30
|
+
// 2. Read the contents of the source directory
|
|
31
|
+
const entries = await fs.readdir(src, { withFileTypes: true });
|
|
32
|
+
|
|
33
|
+
// 3. Process each entry
|
|
34
|
+
for (const entry of entries) {
|
|
35
|
+
const srcPath = path.join(src, entry.name);
|
|
36
|
+
const destPath = path.join(dest, entry.name);
|
|
37
|
+
|
|
38
|
+
if (entry.isDirectory()) {
|
|
39
|
+
// If it's a directory, recurse
|
|
40
|
+
await copyDir(srcPath, destPath);
|
|
41
|
+
} else if (entry.isFile()) {
|
|
42
|
+
// If it's a file, copy it.
|
|
43
|
+
// COPYFILE_EXCL ensures we do not overwrite existing files,
|
|
44
|
+
// which is often desired for config templates.
|
|
45
|
+
await fs.copyFile(srcPath, destPath, constants.COPYFILE_EXCL);
|
|
46
|
+
console.log(`- Created ${path.relative(DEST_DIR, destPath)}`);
|
|
47
|
+
}
|
|
48
|
+
// Ignore symbolic links and other types
|
|
49
|
+
}
|
|
50
|
+
} catch (err) {
|
|
51
|
+
// If a file already exists due to COPYFILE_EXCL, skip it and continue.
|
|
52
|
+
// Otherwise, throw the error.
|
|
53
|
+
if (err.code === 'EEXIST') {
|
|
54
|
+
// Inform the user that a file was skipped
|
|
55
|
+
console.log(`- Skipped ${path.relative(DEST_DIR, dest)} (File already exists)`);
|
|
56
|
+
} else {
|
|
57
|
+
throw err;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async function main() {
|
|
63
|
+
console.log(`š Starting TSConfig setup in: ${DEST_DIR}`);
|
|
64
|
+
console.log(`Source template: ${SOURCE_DIR}`);
|
|
65
|
+
|
|
66
|
+
try {
|
|
67
|
+
await copyDir(SOURCE_DIR, DEST_DIR);
|
|
68
|
+
console.log('\nā
**Setup Complete!** TSConfig template files have been copied.');
|
|
69
|
+
console.log(' Note: Existing files were skipped to prevent accidental overwrites.');
|
|
70
|
+
} catch (error) {
|
|
71
|
+
console.error('\nā **Setup Failed!**');
|
|
72
|
+
console.error('An unexpected error occurred during file copying:', error.message);
|
|
73
|
+
process.exit(1);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
main();
|
package/package.json
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code-essentials/tsconfig",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"files": [
|
|
7
|
+
"template",
|
|
8
|
+
"cli/setup.js"
|
|
9
|
+
],
|
|
10
|
+
"bin": {
|
|
11
|
+
"setup-tsconfig": "cli/setup.js"
|
|
12
|
+
},
|
|
6
13
|
"peerDependencies": {
|
|
7
|
-
"@tsconfig/node24": "^24.0.
|
|
14
|
+
"@tsconfig/node24": "^24.0.3",
|
|
8
15
|
"@tsconfig/strictest": "^2.0.5"
|
|
9
16
|
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@types/node": "^24.10.1"
|
|
19
|
+
},
|
|
10
20
|
"keywords": [],
|
|
11
21
|
"author": {
|
|
12
22
|
"name": "Isaac Valdez",
|
|
@@ -14,6 +24,10 @@
|
|
|
14
24
|
"url": "https://i12345.github.io"
|
|
15
25
|
},
|
|
16
26
|
"license": "MIT",
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "https://github.com/code-essentials/tsconfig.git"
|
|
30
|
+
},
|
|
17
31
|
"scripts": {
|
|
18
32
|
"build": "",
|
|
19
33
|
"test": ""
|
package/tsconfig.debug.json
DELETED
package/tsconfig.json
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": [
|
|
3
|
-
"@tsconfig/node24/tsconfig.json",
|
|
4
|
-
"@tsconfig/strictest/tsconfig.json",
|
|
5
|
-
],
|
|
6
|
-
"compilerOptions": {
|
|
7
|
-
"declaration": true,
|
|
8
|
-
"rootDir": ".",
|
|
9
|
-
"lib": ["ESNext", "Decorators", "DOM"],
|
|
10
|
-
"moduleResolution": "nodenext",
|
|
11
|
-
},
|
|
12
|
-
"exclude": ["node_modules"]
|
|
13
|
-
}
|