@anolilab/prettier-config 3.0.0 → 3.0.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/CHANGELOG.md +7 -0
- package/index.cjs +1 -1
- package/lib/postinstall.js +23 -16
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
### @anolilab/prettier-config [3.0.1](https://github.com/anolilab/javascript-style-guide/compare/@anolilab/prettier-config@3.0.0...@anolilab/prettier-config@3.0.1) (2022-05-11)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* update all deps of the package and fixes found code style issues ([2776ecd](https://github.com/anolilab/javascript-style-guide/commit/2776ecd44d35f1d317abf367e69fef24dbd00335))
|
|
7
|
+
|
|
1
8
|
## @anolilab/prettier-config [3.0.0](https://github.com/anolilab/javascript-style-guide/compare/@anolilab/prettier-config@2.0.6...@anolilab/prettier-config@3.0.0) (2022-02-15)
|
|
2
9
|
|
|
3
10
|
|
package/index.cjs
CHANGED
|
@@ -26,7 +26,7 @@ module.exports = {
|
|
|
26
26
|
arrowParens: "always",
|
|
27
27
|
// format the entire contents of the file
|
|
28
28
|
rangeStart: 0,
|
|
29
|
-
rangeEnd:
|
|
29
|
+
rangeEnd: Number.POSITIVE_INFINITY,
|
|
30
30
|
// no need to write the beginning @prettier of the file
|
|
31
31
|
requirePragma: false,
|
|
32
32
|
// No need to automatically insert @prettier at the beginning of the file
|
package/lib/postinstall.js
CHANGED
|
@@ -1,39 +1,43 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
import { existsSync, writeFile } from "node:fs";
|
|
4
|
+
import { join, resolve } from "node:path";
|
|
5
|
+
import { promisify } from "node:util";
|
|
6
|
+
|
|
7
|
+
import content from "../index.cjs";
|
|
8
|
+
|
|
9
|
+
// eslint-disable-next-line no-undef
|
|
3
10
|
if (process.env.CI) {
|
|
11
|
+
// eslint-disable-next-line no-undef
|
|
4
12
|
process.exit(0);
|
|
5
13
|
}
|
|
6
14
|
|
|
7
|
-
import { writeFile, existsSync } from 'fs';
|
|
8
|
-
import { resolve, join } from 'path';
|
|
9
|
-
import { promisify } from 'util';
|
|
10
|
-
import content from '../index.cjs';
|
|
11
|
-
|
|
12
15
|
const writeFileAsync = promisify(writeFile);
|
|
13
16
|
|
|
14
17
|
// get the path to the host project.
|
|
15
|
-
|
|
18
|
+
// eslint-disable-next-line no-undef
|
|
19
|
+
const projectPath = resolve(process.cwd(), "..", "..", "..");
|
|
16
20
|
|
|
17
|
-
console.log(
|
|
21
|
+
console.log("Configuring @anolilab/prettier-config", projectPath, "\n");
|
|
18
22
|
|
|
19
23
|
/**
|
|
20
24
|
* Writes .prettierrc.cjs if it doesn't exist. Warns if it exists.
|
|
21
25
|
*/
|
|
22
26
|
const writePrettierRc = () => {
|
|
23
|
-
const prettierPath = join(projectPath,
|
|
27
|
+
const prettierPath = join(projectPath, ".prettierrc.cjs");
|
|
24
28
|
|
|
25
|
-
if (existsSync(prettierPath) || existsSync(prettierPath.replace(
|
|
29
|
+
if (existsSync(prettierPath) || existsSync(prettierPath.replace(".cjs", ""))) {
|
|
26
30
|
console.warn(`⚠️ .prettierrc.cjs already exists;
|
|
27
31
|
Make sure that it includes the following for @anolilab/prettier-config to work as it should:
|
|
28
|
-
${JSON.stringify(content,
|
|
32
|
+
${JSON.stringify(content, undefined, 4)}\n`);
|
|
29
33
|
|
|
30
34
|
return Promise.resolve();
|
|
31
35
|
}
|
|
32
36
|
|
|
33
37
|
return writeFileAsync(
|
|
34
38
|
prettierPath,
|
|
35
|
-
`module.exports = ${JSON.stringify(content,
|
|
36
|
-
|
|
39
|
+
`module.exports = ${JSON.stringify(content, undefined, 2).replace("rangeEnd: null,", "rangeEnd: Infinity,")}\n`,
|
|
40
|
+
"utf-8",
|
|
37
41
|
);
|
|
38
42
|
};
|
|
39
43
|
|
|
@@ -41,10 +45,10 @@ ${JSON.stringify(content, null, 4)}\n`);
|
|
|
41
45
|
* Writes .prettierignore if it doesn't exist. Warns if it exists.
|
|
42
46
|
*/
|
|
43
47
|
const writePrettierIgnore = () => {
|
|
44
|
-
const prettierPath = join(projectPath,
|
|
48
|
+
const prettierPath = join(projectPath, ".prettierignore");
|
|
45
49
|
|
|
46
50
|
if (existsSync(prettierPath)) {
|
|
47
|
-
console.warn(
|
|
51
|
+
console.warn("⚠️ .prettierignore already exists");
|
|
48
52
|
|
|
49
53
|
return Promise.resolve();
|
|
50
54
|
}
|
|
@@ -54,15 +58,18 @@ const writePrettierIgnore = () => {
|
|
|
54
58
|
|
|
55
59
|
(async () => {
|
|
56
60
|
try {
|
|
61
|
+
// eslint-disable-next-line compat/compat
|
|
57
62
|
await Promise.all([writePrettierRc(), writePrettierIgnore()]);
|
|
58
63
|
|
|
59
64
|
console.log("😎 Everything went well, have fun!");
|
|
60
65
|
|
|
66
|
+
// eslint-disable-next-line no-undef
|
|
61
67
|
process.exit(0);
|
|
62
|
-
} catch (
|
|
68
|
+
} catch (error) {
|
|
63
69
|
console.log("😬 something went wrong:");
|
|
64
|
-
console.error(
|
|
70
|
+
console.error(error.message);
|
|
65
71
|
|
|
72
|
+
// eslint-disable-next-line no-undef
|
|
66
73
|
process.exit(1);
|
|
67
74
|
}
|
|
68
75
|
})();
|