@athenna/tsconfig 4.8.1 → 4.9.0

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/package-lock.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@athenna/tsconfig",
3
- "version": "4.8.1",
3
+ "version": "4.9.0",
4
4
  "lockfileVersion": 1,
5
5
  "requires": true,
6
6
  "dependencies": {
@@ -111,6 +111,17 @@
111
111
  "typescript": "^4.4.3"
112
112
  },
113
113
  "dependencies": {
114
+ "chalk": {
115
+ "version": "4.1.2",
116
+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
117
+ "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
118
+ "dev": true,
119
+ "optional": true,
120
+ "requires": {
121
+ "ansi-styles": "^4.1.0",
122
+ "supports-color": "^7.1.0"
123
+ }
124
+ },
114
125
  "typescript": {
115
126
  "version": "4.9.5",
116
127
  "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz",
@@ -143,6 +154,19 @@
143
154
  "optional": true,
144
155
  "requires": {
145
156
  "chalk": "^4.0.0"
157
+ },
158
+ "dependencies": {
159
+ "chalk": {
160
+ "version": "4.1.2",
161
+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
162
+ "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
163
+ "dev": true,
164
+ "optional": true,
165
+ "requires": {
166
+ "ansi-styles": "^4.1.0",
167
+ "supports-color": "^7.1.0"
168
+ }
169
+ }
146
170
  }
147
171
  },
148
172
  "@cspotcode/source-map-support": {
@@ -545,16 +569,6 @@
545
569
  "dev": true,
546
570
  "optional": true
547
571
  },
548
- "chalk": {
549
- "version": "4.1.2",
550
- "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
551
- "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
552
- "dev": true,
553
- "requires": {
554
- "ansi-styles": "^4.1.0",
555
- "supports-color": "^7.1.0"
556
- }
557
- },
558
572
  "chardet": {
559
573
  "version": "0.7.0",
560
574
  "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz",
@@ -1364,6 +1378,18 @@
1364
1378
  "strip-ansi": "^6.0.0",
1365
1379
  "through": "^2.3.6",
1366
1380
  "wrap-ansi": "^7.0.0"
1381
+ },
1382
+ "dependencies": {
1383
+ "chalk": {
1384
+ "version": "4.1.2",
1385
+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
1386
+ "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
1387
+ "dev": true,
1388
+ "requires": {
1389
+ "ansi-styles": "^4.1.0",
1390
+ "supports-color": "^7.1.0"
1391
+ }
1392
+ }
1367
1393
  }
1368
1394
  },
1369
1395
  "is-arrayish": {
@@ -1506,8 +1532,7 @@
1506
1532
  "lodash": {
1507
1533
  "version": "4.17.21",
1508
1534
  "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
1509
- "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
1510
- "dev": true
1535
+ "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
1511
1536
  },
1512
1537
  "lodash.map": {
1513
1538
  "version": "4.6.0",
@@ -1523,6 +1548,18 @@
1523
1548
  "requires": {
1524
1549
  "chalk": "^4.1.0",
1525
1550
  "is-unicode-supported": "^0.1.0"
1551
+ },
1552
+ "dependencies": {
1553
+ "chalk": {
1554
+ "version": "4.1.2",
1555
+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
1556
+ "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
1557
+ "dev": true,
1558
+ "requires": {
1559
+ "ansi-styles": "^4.1.0",
1560
+ "supports-color": "^7.1.0"
1561
+ }
1562
+ }
1526
1563
  }
1527
1564
  },
1528
1565
  "longest": {
@@ -1687,6 +1724,18 @@
1687
1724
  "log-symbols": "^4.1.0",
1688
1725
  "strip-ansi": "^6.0.0",
1689
1726
  "wcwidth": "^1.0.1"
1727
+ },
1728
+ "dependencies": {
1729
+ "chalk": {
1730
+ "version": "4.1.2",
1731
+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
1732
+ "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
1733
+ "dev": true,
1734
+ "requires": {
1735
+ "ansi-styles": "^4.1.0",
1736
+ "supports-color": "^7.1.0"
1737
+ }
1738
+ }
1690
1739
  }
1691
1740
  },
1692
1741
  "os-tmpdir": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@athenna/tsconfig",
3
- "version": "4.8.1",
3
+ "version": "4.9.0",
4
4
  "description": "Exports the base TypeScript configuration for Athena applications and packages.",
5
5
  "license": "MIT",
6
6
  "author": "João Lenon <lenon@athenna.io>",
@@ -25,6 +25,8 @@
25
25
  ".": "./src/index.js",
26
26
  "./package": "./package.json",
27
27
  "./package.json": "./package.json",
28
+ "./tsc": "./src/tsc.js",
29
+ "./copyfiles": "./src/copyfiles.js",
28
30
  "./tsconfig.app.json": "./tsconfig.app.json",
29
31
  "./tsconfig.app-slim.json": "./tsconfig.app-slim.json",
30
32
  "./tsconfig.base.json": "./tsconfig.base.json",
@@ -34,6 +36,7 @@
34
36
  "dependencies": {
35
37
  "copyfiles": "^2.4.1",
36
38
  "cross-env": "^7.0.3",
39
+ "lodash": "^4.17.21",
37
40
  "reflect-metadata": "^0.1.13",
38
41
  "rimraf": "^5.0.5",
39
42
  "ts-node": "^10.9.1",
package/src/build.js CHANGED
@@ -7,32 +7,23 @@
7
7
  * file that was distributed with this source code.
8
8
  */
9
9
 
10
- import copyfiles from 'copyfiles'
11
10
 
12
11
  import { tsc } from './tsc.js'
13
12
  import { rimraf } from 'rimraf'
13
+ import { copyfiles } from './copyfiles.js'
14
+ import { META_FILES, TS_CONFIG_PATH, BUILD_FOLDER_NAME } from './constants.js'
14
15
 
15
16
  /**
16
- * Delete old build folder.
17
+ * Delete old `BUILD_FOLDER_NAME` folder.
17
18
  */
18
- rimraf('build')
19
+ await rimraf(BUILD_FOLDER_NAME)
19
20
 
20
21
  /**
21
- * Run tsc compiler.
22
+ * Compile the application using tsc.
22
23
  */
23
- await tsc()
24
+ await tsc(TS_CONFIG_PATH)
24
25
 
25
26
  /**
26
- * Copy default files to build folder.
27
+ * Copy `META_FILES` to `BUILD_FOLDER_NAME` folder.
27
28
  */
28
- copyfiles([
29
- 'templates',
30
- 'configurer',
31
- 'package.json',
32
- 'package-lock.json',
33
- 'LICENSE.md',
34
- 'README.md',
35
- 'build'
36
- ], '', (err) => {
37
- if (err) throw err
38
- })
29
+ await copyfiles(META_FILES, BUILD_FOLDER_NAME)
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Files that will be copied to the `BUILD_FOLDER_NAME` folder.
3
+ */
4
+ export const META_FILES = [
5
+ 'templates/**/*',
6
+ 'configurer/**/*',
7
+ 'package.json',
8
+ 'package-lock.json',
9
+ 'LICENSE.md',
10
+ 'README.md'
11
+ ]
12
+
13
+ /**
14
+ * Path to tsconfig file that will be used by `tsc` compiler.
15
+ */
16
+ export const TS_CONFIG_PATH = 'node_modules/@athenna/tsconfig/tsconfig.lib-build.json'
17
+
18
+ /**
19
+ * Build folder name that files will be copied to.
20
+ */
21
+ export const BUILD_FOLDER_NAME = 'build'
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @athenna/tsconfig
3
+ *
4
+ * (c) João Lenon <lenon@athenna.io>
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+
10
+ import copyfilesSync from 'copyfiles'
11
+
12
+ /**
13
+ * Promisified version of copyfiles.
14
+ *
15
+ * @param {string[]} files
16
+ * @param {string} dest
17
+ * @return {Promise<void>}
18
+ */
19
+ export function copyfiles(files, dest) {
20
+ return new Promise((resolve, reject) => {
21
+ copyfilesSync(files.push(dest), '', (err) => {
22
+ if (err) {
23
+ return reject(err)
24
+ }
25
+
26
+ resolve()
27
+ })
28
+ })
29
+ }
package/src/tsc.js CHANGED
@@ -7,8 +7,27 @@
7
7
  * file that was distributed with this source code.
8
8
  */
9
9
 
10
- export async function tsc() {
11
- process.argv.push('--project', 'node_modules/@athenna/tsconfig/tsconfig.lib-build.json')
10
+ import lodash from 'lodash'
12
11
 
13
- await import('typescript/lib/tsc.js')
12
+ /**
13
+ * Run tsc compiler "programmatically".
14
+ *
15
+ * @param {string} tsConfigPath
16
+ * @return {Promise<void>}
17
+ */
18
+ export async function tsc(tsConfigPath) {
19
+ const originalArgv = lodash.cloneDeep(process.argv)
20
+ const originalExit = lodash.cloneDeep(process.exit)
21
+
22
+ process.exit = () => {}
23
+
24
+ process.argv = process.argv.slice(0, 2)
25
+ process.argv.push('--project', tsConfigPath)
26
+
27
+ try {
28
+ await import('typescript/lib/tsc.js')
29
+ } finally {
30
+ process.argv = originalArgv
31
+ process.exit = originalExit
32
+ }
14
33
  }