@alessiofrittoli/type-utils 0.1.0-alpha.5 → 0.1.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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Type Utils ❇️
|
|
2
2
|
|
|
3
|
-
Version 0.1.
|
|
3
|
+
Version 0.1.1
|
|
4
4
|
|
|
5
5
|
## Lightweight TypeScript types utilities
|
|
6
6
|
|
|
@@ -55,6 +55,12 @@ Please make sure to add it in the array of the "include" property in your `tscon
|
|
|
55
55
|
|
|
56
56
|
You can skip this process if `*.ts` is already in your "include" array.
|
|
57
57
|
|
|
58
|
+
⚠️ If the `type-utils.d.ts` file creation fails you run the following command to manually execute the script:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
node node_modules/@alessiofrittoli/type-utils/scripts/postinstall/index.js
|
|
62
|
+
```
|
|
63
|
+
|
|
58
64
|
---
|
|
59
65
|
|
|
60
66
|
### [ESLint](https://www.npmjs.com/package/eslint)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alessiofrittoli/type-utils",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Lightweight TypeScript types utilities",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Alessio Frittoli",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"scripts": {
|
|
29
29
|
"build": "eslint && tsup",
|
|
30
30
|
"lint": "eslint",
|
|
31
|
-
"postinstall": "node
|
|
31
|
+
"postinstall": "node scripts/postinstall/index.js"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@eslint/js": "^9.15.0",
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const tsSetup = require( './ts-setup.js' )
|
|
2
|
+
|
|
3
|
+
/** @type {(() => void | Promise<void>)[]} */
|
|
4
|
+
const scripts = [ tsSetup ]
|
|
5
|
+
|
|
6
|
+
const executePostInstall = async () => {
|
|
7
|
+
await Promise.all( scripts.map( async script => {
|
|
8
|
+
await script()
|
|
9
|
+
} ) )
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
executePostInstall()
|
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
const fs = require( 'fs' )
|
|
2
2
|
const path = require( 'path' )
|
|
3
|
-
const project = require( '
|
|
3
|
+
const project = require( '../../package.json' )
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
const tsSetup = () => {
|
|
7
|
-
|
|
8
|
-
console.log( 'EXEC tsSetup' )
|
|
9
|
-
|
|
10
|
-
const projectRoot = process.env.INIT_CWD
|
|
11
7
|
|
|
12
|
-
|
|
8
|
+
const projectRoot = process.env.INIT_CWD || process.cwd()
|
|
13
9
|
|
|
14
|
-
if ( ! projectRoot ) {
|
|
10
|
+
if ( ! projectRoot || projectRoot.endsWith( project.name ) ) {
|
|
15
11
|
console.error( 'INIT_CWD is not set. This script must be run during pnpm install.' )
|
|
16
12
|
process.exit( 1 )
|
|
17
13
|
}
|
|
18
14
|
|
|
19
|
-
const
|
|
15
|
+
const tsconfigPath = path.resolve( projectRoot, 'type-utils.d.ts' )
|
|
20
16
|
|
|
21
17
|
const data = [
|
|
22
18
|
`/// <reference types="${ project.name }" />`,
|
|
@@ -24,7 +20,7 @@ const tsSetup = () => {
|
|
|
24
20
|
].join( '\n\n' )
|
|
25
21
|
|
|
26
22
|
try {
|
|
27
|
-
fs.writeFileSync(
|
|
23
|
+
fs.writeFileSync( tsconfigPath, data )
|
|
28
24
|
console.log( '"type-utils.d.ts" has been created at the root of your project.' )
|
|
29
25
|
console.log( 'Please update your tsconfig.json to add this file in your "include" property of your tsconfig.json file.' )
|
|
30
26
|
} catch ( error ) {
|
|
@@ -34,4 +30,4 @@ const tsSetup = () => {
|
|
|
34
30
|
|
|
35
31
|
}
|
|
36
32
|
|
|
37
|
-
tsSetup
|
|
33
|
+
module.exports = tsSetup
|