@alessiofrittoli/type-utils 0.1.0-alpha.4 → 0.1.0-alpha.5

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.0-alpha.4
3
+ Version 0.1.0-alpha.5
4
4
 
5
5
  ## Lightweight TypeScript types utilities
6
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alessiofrittoli/type-utils",
3
- "version": "0.1.0-alpha.4",
3
+ "version": "0.1.0-alpha.5",
4
4
  "description": "Lightweight TypeScript types utilities",
5
5
  "author": {
6
6
  "name": "Alessio Frittoli",
@@ -23,7 +23,7 @@
23
23
  "main": "./dist/index.js",
24
24
  "types": "./dist/index.d.ts",
25
25
  "files": [
26
- "dist"
26
+ "dist", "scripts"
27
27
  ],
28
28
  "scripts": {
29
29
  "build": "eslint && tsup",
@@ -0,0 +1,37 @@
1
+ const fs = require( 'fs' )
2
+ const path = require( 'path' )
3
+ const project = require( '../package.json' )
4
+
5
+
6
+ const tsSetup = () => {
7
+
8
+ console.log( 'EXEC tsSetup' )
9
+
10
+ const projectRoot = process.env.INIT_CWD
11
+
12
+ console.log( 'projectRoot', projectRoot )
13
+
14
+ if ( ! projectRoot ) {
15
+ console.error( 'INIT_CWD is not set. This script must be run during pnpm install.' )
16
+ process.exit( 1 )
17
+ }
18
+
19
+ const typeUtilsRefFile = path.resolve( projectRoot, 'type-utils.d.ts' )
20
+
21
+ const data = [
22
+ `/// <reference types="${ project.name }" />`,
23
+ '// NOTE: This file should not be edited'
24
+ ].join( '\n\n' )
25
+
26
+ try {
27
+ fs.writeFileSync( typeUtilsRefFile, data )
28
+ console.log( '"type-utils.d.ts" has been created at the root of your project.' )
29
+ console.log( 'Please update your tsconfig.json to add this file in your "include" property of your tsconfig.json file.' )
30
+ } catch ( error ) {
31
+ console.error( 'An error occured while creating "type-utils.d.ts" at the root of your project. Some global types may not working as expect.', error )
32
+ process.exit( 1 )
33
+ }
34
+
35
+ }
36
+
37
+ tsSetup()