@uxf/scripts 11.34.0 → 11.41.6

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.
Files changed (2) hide show
  1. package/package.json +37 -37
  2. package/src/uxf-audit/index.js +54 -11
package/package.json CHANGED
@@ -1,38 +1,38 @@
1
1
  {
2
- "name": "@uxf/scripts",
3
- "version": "11.34.0",
4
- "description": "",
5
- "main": "index.js",
6
- "bin": {
7
- "uxf-audit": "bin/uxf-audit.js",
8
- "uxf-lunch": "bin/uxf-lunch.js",
9
- "uxf-push-notifier": "bin/uxf-push-notifier.js",
10
- "uxf-release": "bin/uxf-release.js",
11
- "uxf-sitemap-check": "bin/uxf-sitemap-check.js",
12
- "uxf-sitemap-meta-export": "bin/uxf-sitemap-meta-export.js",
13
- "uxf-i18n-namespaces-gen": "bin/uxf-i18n-namespaces-gen.js",
14
- "uxf-unused": "bin/uxf-unused.js"
15
- },
16
- "scripts": {
17
- "build": "",
18
- "typecheck": "",
19
- "test": "./node_modules/.bin/eslint ./bin",
20
- "run:mr-notifier": "GOOGLE_WEBHOOK_URL=<<TODO>> GITLAB_TOKEN=<<TODO>> CI_SERVER_URL=https://gitlab.uxf.cz node ./bin/uxf-merge-requests-notifier.js"
21
- },
22
- "publishConfig": {
23
- "access": "public"
24
- },
25
- "repository": {
26
- "type": "git"
27
- },
28
- "author": "",
29
- "license": "ISC",
30
- "dependencies": {
31
- "axios": "1.7.5",
32
- "cheerio": "1.0.0",
33
- "dayjs": "1.11.13",
34
- "fast-glob": "3.3.2",
35
- "madge": "8.0.0",
36
- "yargs": "17.7.2"
37
- }
38
- }
2
+ "name": "@uxf/scripts",
3
+ "version": "11.41.6",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "bin": {
7
+ "uxf-audit": "bin/uxf-audit.js",
8
+ "uxf-lunch": "bin/uxf-lunch.js",
9
+ "uxf-push-notifier": "bin/uxf-push-notifier.js",
10
+ "uxf-release": "bin/uxf-release.js",
11
+ "uxf-sitemap-check": "bin/uxf-sitemap-check.js",
12
+ "uxf-sitemap-meta-export": "bin/uxf-sitemap-meta-export.js",
13
+ "uxf-i18n-namespaces-gen": "bin/uxf-i18n-namespaces-gen.js",
14
+ "uxf-unused": "bin/uxf-unused.js"
15
+ },
16
+ "scripts": {
17
+ "build": "",
18
+ "typecheck": "",
19
+ "test": "./node_modules/.bin/eslint ./bin",
20
+ "run:mr-notifier": "GOOGLE_WEBHOOK_URL=<<TODO>> GITLAB_TOKEN=<<TODO>> CI_SERVER_URL=https://gitlab.uxf.cz node ./bin/uxf-merge-requests-notifier.js"
21
+ },
22
+ "publishConfig": {
23
+ "access": "public"
24
+ },
25
+ "repository": {
26
+ "type": "git"
27
+ },
28
+ "author": "",
29
+ "license": "ISC",
30
+ "dependencies": {
31
+ "axios": "1.7.5",
32
+ "cheerio": "1.0.0",
33
+ "dayjs": "1.11.13",
34
+ "fast-glob": "3.3.2",
35
+ "madge": "8.0.0",
36
+ "yargs": "17.7.2"
37
+ }
38
+ }
@@ -9,24 +9,53 @@ function execute(command) {
9
9
  }
10
10
 
11
11
  function executeJson(command) {
12
- return execute(command).then((output) => JSON.parse(output));
12
+ return execute(command).then((output) =>
13
+ output
14
+ .split("\n")
15
+ .filter((s) => s !== "")
16
+ .map(JSON.parse),
17
+ );
13
18
  }
14
19
 
15
20
  function parsePackageName(name) {
16
21
  if (name.charAt(0) === "@") {
17
22
  const [nameWithoutAt, version] = name.replace("@", "").split("@");
18
23
 
19
- return [`@${nameWithoutAt}`, version];
24
+ return [`@${nameWithoutAt}`, version.replace(/^npm:/, "")];
20
25
  }
21
26
 
22
- return name.split("@");
27
+ const [nameWithoutAt, version] = name.split("@");
28
+ return [nameWithoutAt, version.replace(/^npm:/, "")];
23
29
  }
24
30
 
25
- function getUxfPackagesInfo() {
31
+ function getUxfPackagesInfo(yarnVersion) {
32
+ if (yarnVersion > 1) {
33
+ return executeJson('yarn info "@uxf/*" -AR --json').then((output) => {
34
+ const result = {};
35
+
36
+ output
37
+ .map((info) => {
38
+ const [name, version] = parsePackageName(info.value);
39
+ return {
40
+ name,
41
+ version,
42
+ isError: false,
43
+ };
44
+ })
45
+ .forEach((item) => {
46
+ const isError = result[item.name] !== undefined;
47
+ result[item.name] = item;
48
+ result[item.name].isError = isError;
49
+ });
50
+
51
+ return result;
52
+ });
53
+ }
54
+
26
55
  return executeJson('yarn list --pattern "@uxf" --depth=1 --json').then((output) => {
27
56
  const result = {};
28
57
 
29
- output.data.trees
58
+ output[0].data.trees
30
59
  .map((info) => {
31
60
  const [name, version] = parsePackageName(info.name);
32
61
  return {
@@ -43,9 +72,13 @@ function getUxfPackagesInfo() {
43
72
  });
44
73
  }
45
74
 
46
- function getPackageVersion(packageName) {
75
+ function getPackageVersion(packageName, yarnVersion) {
76
+ if (yarnVersion > 1) {
77
+ return executeJson(`yarn info ${packageName} --json`).then((output) => parsePackageName(output[0].value)[1]);
78
+ }
79
+
47
80
  return executeJson(`yarn list ${packageName} --depth=0 --json`).then((output) => {
48
- return parsePackageName(output.data.trees[0].name)[1];
81
+ return parsePackageName(output[0].data.trees[0].name)[1];
49
82
  });
50
83
  }
51
84
 
@@ -55,15 +88,25 @@ function getNodeVersion() {
55
88
  });
56
89
  }
57
90
 
91
+ function getYarnVersion() {
92
+ return execute("yarn -v").then((output) => {
93
+ return output.trim();
94
+ });
95
+ }
96
+
58
97
  module.exports = async function run() {
98
+ const yarn = await getYarnVersion();
99
+ const yarnVersion = Number(yarn.replace(/\..*/, ""));
100
+
59
101
  console.log(
60
102
  JSON.stringify(
61
103
  {
62
104
  node: await getNodeVersion(),
63
- next: await getPackageVersion("next"),
64
- react: await getPackageVersion("react"),
65
- "react-dom": await getPackageVersion("react-dom"),
66
- packages: await getUxfPackagesInfo(),
105
+ yarn,
106
+ next: await getPackageVersion("next", yarnVersion),
107
+ react: await getPackageVersion("react", yarnVersion),
108
+ "react-dom": await getPackageVersion("react-dom", yarnVersion),
109
+ packages: await getUxfPackagesInfo(yarnVersion),
67
110
  },
68
111
  null,
69
112
  " ",