@uxf/scripts 11.13.0 → 11.14.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.
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ require("../src/uxf-audit/index")()
3
+ .then((exitCode) => {
4
+ process.exitCode = exitCode;
5
+ })
6
+ .catch((e) => {
7
+ console.error(e);
8
+ process.exitCode = 1;
9
+ });
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@uxf/scripts",
3
- "version": "11.13.0",
3
+ "version": "11.14.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
7
+ "uxf-audit": "bin/uxf-audit.js",
7
8
  "uxf-lunch": "bin/uxf-lunch.js",
8
9
  "uxf-release": "bin/uxf-release.js",
9
10
  "uxf-sitemap-check": "bin/uxf-sitemap-check.js",
@@ -0,0 +1,72 @@
1
+ const exec = require("child_process").exec;
2
+
3
+ function execute(command) {
4
+ return new Promise((resolve) => {
5
+ exec(command, function (error, stdout, stderr) {
6
+ resolve(stdout);
7
+ });
8
+ });
9
+ }
10
+
11
+ function executeJson(command) {
12
+ return execute(command).then((output) => JSON.parse(output));
13
+ }
14
+
15
+ function parsePackageName(name) {
16
+ if (name.charAt(0) === "@") {
17
+ const [nameWithoutAt, version] = name.replace("@", "").split("@");
18
+
19
+ return [`@${nameWithoutAt}`, version];
20
+ }
21
+
22
+ return name.split("@");
23
+ }
24
+
25
+ function getUxfPackagesInfo() {
26
+ return executeJson('yarn list --pattern "@uxf" --depth=1 --json').then((output) => {
27
+ const result = {};
28
+
29
+ output.data.trees
30
+ .map((info) => {
31
+ const [name, version] = parsePackageName(info.name);
32
+ return {
33
+ name,
34
+ version,
35
+ isError: info.children.length > 0,
36
+ };
37
+ })
38
+ .forEach((item) => {
39
+ result[item.name] = item;
40
+ });
41
+
42
+ return result;
43
+ });
44
+ }
45
+
46
+ function getPackageVersion(packageName) {
47
+ return executeJson(`yarn list ${packageName} --depth=0 --json`).then((output) => {
48
+ return parsePackageName(output.data.trees[0].name)[1];
49
+ });
50
+ }
51
+
52
+ function getNodeVersion() {
53
+ return execute("node -v").then((output) => {
54
+ return output.replace("v", "").trim();
55
+ });
56
+ }
57
+
58
+ module.exports = async function run() {
59
+ console.log(
60
+ JSON.stringify(
61
+ {
62
+ node: await getNodeVersion(),
63
+ next: await getPackageVersion("next"),
64
+ react: await getPackageVersion("react"),
65
+ "react-dom": await getPackageVersion("react-dom"),
66
+ packages: await getUxfPackagesInfo(),
67
+ },
68
+ null,
69
+ " ",
70
+ ),
71
+ );
72
+ };