@lipemat/js-boilerplate-shared 0.1.0 → 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/bin/fix-pnp.js +45 -0
- package/bin/fix-pnp.js.map +1 -0
- package/bin/fix-pnp.ts +0 -0
- package/bin/tsconfig.json +13 -0
- package/package.json +3 -2
package/bin/fix-pnp.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* When using PNP loose mode, we get warnings for every module
|
|
4
|
+
* we access, not strictly declared.
|
|
5
|
+
*
|
|
6
|
+
* No built-in way in Yarn to disable the warnings.
|
|
7
|
+
* This script modifies to generate .pnp.js file to suppress
|
|
8
|
+
* all loose module warnings unless the environmental variable
|
|
9
|
+
* it set to display all warnings.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```json
|
|
13
|
+
* {
|
|
14
|
+
* "scripts": {
|
|
15
|
+
* "postinstall": "lipemat-js-boilerplate fix-pnp"
|
|
16
|
+
* }
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
import fs from 'fs';
|
|
21
|
+
const PNP_FILES = [
|
|
22
|
+
'./.pnp.js',
|
|
23
|
+
'./.pnp.cjs',
|
|
24
|
+
'./.pnp.mjs',
|
|
25
|
+
];
|
|
26
|
+
PNP_FILES.forEach(PNP_FILE => {
|
|
27
|
+
if (fs.existsSync(PNP_FILE)) {
|
|
28
|
+
fs.readFile(PNP_FILE, 'utf8', (readError, data) => {
|
|
29
|
+
if (readError) {
|
|
30
|
+
return console.error(readError);
|
|
31
|
+
}
|
|
32
|
+
const result = data.replace(/if \(reference != null\) {/, '// # Warnings suppressed via @lipemat/js-boilerplate/fix-pnp script. \n' +
|
|
33
|
+
'if (! alwaysWarnOnFallback && reference != null) { \n' +
|
|
34
|
+
'dependencyReference = reference; \n' +
|
|
35
|
+
'} else if (alwaysWarnOnFallback && reference != null) {');
|
|
36
|
+
fs.writeFile(PNP_FILE, result, 'utf8', writeError => {
|
|
37
|
+
if (writeError) {
|
|
38
|
+
return console.error(writeError);
|
|
39
|
+
}
|
|
40
|
+
console.debug(`The ${PNP_FILE} file has been adjusted to no longer display warnings for loose modules.`);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=fix-pnp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fix-pnp.js","sourceRoot":"","sources":["fix-pnp.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,MAAM,SAAS,GAAG;IACjB,WAAW;IACX,YAAY;IACZ,YAAY;CACZ,CAAC;AAEF,SAAS,CAAC,OAAO,CAAE,QAAQ,CAAC,EAAE;IAC7B,IAAK,EAAE,CAAC,UAAU,CAAE,QAAQ,CAAE,EAAG,CAAC;QACjC,EAAE,CAAC,QAAQ,CAAE,QAAQ,EAAE,MAAM,EAAE,CAAE,SAAS,EAAE,IAAI,EAAG,EAAE;YACpD,IAAK,SAAS,EAAG,CAAC;gBACjB,OAAO,OAAO,CAAC,KAAK,CAAE,SAAS,CAAE,CAAC;YACnC,CAAC;YAED,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAE,4BAA4B,EAAE,yEAAyE;gBACnI,uDAAuD;gBACvD,qCAAqC;gBACrC,yDAAyD,CAAE,CAAC;YAE7D,EAAE,CAAC,SAAS,CAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE;gBACpD,IAAK,UAAU,EAAG,CAAC;oBAClB,OAAO,OAAO,CAAC,KAAK,CAAE,UAAU,CAAE,CAAC;gBACpC,CAAC;gBACD,OAAO,CAAC,KAAK,CAAE,OAAO,QAAQ,0EAA0E,CAAE,CAAC;YAC5G,CAAC,CAAE,CAAC;QACL,CAAC,CAAE,CAAC;IACL,CAAC;AACF,CAAC,CAAE,CAAC"}
|
package/bin/fix-pnp.ts
CHANGED
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../tsconfig.json",
|
|
3
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
4
|
+
"display": "Build config for TS files required to be transpiled to CommonJS.",
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"sourceMap": true
|
|
7
|
+
},
|
|
8
|
+
"exclude": [
|
|
9
|
+
"../jest",
|
|
10
|
+
"../dev",
|
|
11
|
+
"../node_modules"
|
|
12
|
+
]
|
|
13
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lipemat/js-boilerplate-shared",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Shared utilities for all @lipemat boilerplate packages",
|
|
6
6
|
"engines": {
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"type": "module",
|
|
10
10
|
"files": [
|
|
11
|
+
"bin",
|
|
11
12
|
"config",
|
|
12
13
|
"helpers",
|
|
13
14
|
"lib",
|
|
@@ -22,7 +23,7 @@
|
|
|
22
23
|
},
|
|
23
24
|
"homepage": "https://github.com/lipemat/js-boilerplate-shared#readme",
|
|
24
25
|
"bin": {
|
|
25
|
-
"js-boilerplate-shared__fix-pnp": "bin/fix-pnp.
|
|
26
|
+
"js-boilerplate-shared__fix-pnp": "bin/fix-pnp.js"
|
|
26
27
|
},
|
|
27
28
|
"scripts": {
|
|
28
29
|
"build": "tsc --project ./bin",
|