@uxf/scripts 11.34.0 → 11.41.5

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 +52 -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.5",
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,51 @@ 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/*" --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, // TODO
43
+ };
44
+ })
45
+ .forEach((item) => {
46
+ result[item.name] = item;
47
+ });
48
+
49
+ return result;
50
+ });
51
+ }
52
+
26
53
  return executeJson('yarn list --pattern "@uxf" --depth=1 --json').then((output) => {
27
54
  const result = {};
28
55
 
29
- output.data.trees
56
+ output[0].data.trees
30
57
  .map((info) => {
31
58
  const [name, version] = parsePackageName(info.name);
32
59
  return {
@@ -43,9 +70,13 @@ function getUxfPackagesInfo() {
43
70
  });
44
71
  }
45
72
 
46
- function getPackageVersion(packageName) {
73
+ function getPackageVersion(packageName, yarnVersion) {
74
+ if (yarnVersion > 1) {
75
+ return executeJson(`yarn info ${packageName} --json`).then((output) => parsePackageName(output[0].value)[1]);
76
+ }
77
+
47
78
  return executeJson(`yarn list ${packageName} --depth=0 --json`).then((output) => {
48
- return parsePackageName(output.data.trees[0].name)[1];
79
+ return parsePackageName(output[0].data.trees[0].name)[1];
49
80
  });
50
81
  }
51
82
 
@@ -55,15 +86,25 @@ function getNodeVersion() {
55
86
  });
56
87
  }
57
88
 
89
+ function getYarnVersion() {
90
+ return execute("yarn -v").then((output) => {
91
+ return output.trim();
92
+ });
93
+ }
94
+
58
95
  module.exports = async function run() {
96
+ const yarn = await getYarnVersion();
97
+ const yarnVersion = Number(yarn.replace(/\..*/, ""));
98
+
59
99
  console.log(
60
100
  JSON.stringify(
61
101
  {
62
102
  node: await getNodeVersion(),
63
- next: await getPackageVersion("next"),
64
- react: await getPackageVersion("react"),
65
- "react-dom": await getPackageVersion("react-dom"),
66
- packages: await getUxfPackagesInfo(),
103
+ yarn,
104
+ next: await getPackageVersion("next", yarnVersion),
105
+ react: await getPackageVersion("react", yarnVersion),
106
+ "react-dom": await getPackageVersion("react-dom", yarnVersion),
107
+ packages: await getUxfPackagesInfo(yarnVersion),
67
108
  },
68
109
  null,
69
110
  " ",