@uxf/scripts 11.41.5 → 11.47.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.
package/package.json
CHANGED
package/src/uxf-audit/index.js
CHANGED
|
@@ -1,84 +1,4 @@
|
|
|
1
|
-
const
|
|
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) =>
|
|
13
|
-
output
|
|
14
|
-
.split("\n")
|
|
15
|
-
.filter((s) => s !== "")
|
|
16
|
-
.map(JSON.parse),
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function parsePackageName(name) {
|
|
21
|
-
if (name.charAt(0) === "@") {
|
|
22
|
-
const [nameWithoutAt, version] = name.replace("@", "").split("@");
|
|
23
|
-
|
|
24
|
-
return [`@${nameWithoutAt}`, version.replace(/^npm:/, "")];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const [nameWithoutAt, version] = name.split("@");
|
|
28
|
-
return [nameWithoutAt, version.replace(/^npm:/, "")];
|
|
29
|
-
}
|
|
30
|
-
|
|
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
|
-
|
|
53
|
-
return executeJson('yarn list --pattern "@uxf" --depth=1 --json').then((output) => {
|
|
54
|
-
const result = {};
|
|
55
|
-
|
|
56
|
-
output[0].data.trees
|
|
57
|
-
.map((info) => {
|
|
58
|
-
const [name, version] = parsePackageName(info.name);
|
|
59
|
-
return {
|
|
60
|
-
name,
|
|
61
|
-
version,
|
|
62
|
-
isError: info.children.length > 0,
|
|
63
|
-
};
|
|
64
|
-
})
|
|
65
|
-
.forEach((item) => {
|
|
66
|
-
result[item.name] = item;
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
return result;
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
|
|
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
|
-
|
|
78
|
-
return executeJson(`yarn list ${packageName} --depth=0 --json`).then((output) => {
|
|
79
|
-
return parsePackageName(output[0].data.trees[0].name)[1];
|
|
80
|
-
});
|
|
81
|
-
}
|
|
1
|
+
const execute = require("./utils/json-exec").execute;
|
|
82
2
|
|
|
83
3
|
function getNodeVersion() {
|
|
84
4
|
return execute("node -v").then((output) => {
|
|
@@ -96,15 +16,24 @@ module.exports = async function run() {
|
|
|
96
16
|
const yarn = await getYarnVersion();
|
|
97
17
|
const yarnVersion = Number(yarn.replace(/\..*/, ""));
|
|
98
18
|
|
|
19
|
+
const manager = {
|
|
20
|
+
1: require("./manager/yarn-1").Yarn1,
|
|
21
|
+
4: require("./manager/yarn-4").Yarn4,
|
|
22
|
+
}[yarnVersion];
|
|
23
|
+
|
|
24
|
+
if (manager === undefined) {
|
|
25
|
+
throw new Error(`Unknown manager version ${yarnVersion} (${yarn})`);
|
|
26
|
+
}
|
|
27
|
+
|
|
99
28
|
console.log(
|
|
100
29
|
JSON.stringify(
|
|
101
30
|
{
|
|
102
31
|
node: await getNodeVersion(),
|
|
103
32
|
yarn,
|
|
104
|
-
next: await
|
|
105
|
-
react: await
|
|
106
|
-
"react-dom": await
|
|
107
|
-
packages: await
|
|
33
|
+
next: await manager.packageVersion("next"),
|
|
34
|
+
react: await manager.packageVersion("react"),
|
|
35
|
+
"react-dom": await manager.packageVersion("react-dom"),
|
|
36
|
+
packages: await manager.uxfPackagesInfo(),
|
|
108
37
|
},
|
|
109
38
|
null,
|
|
110
39
|
" ",
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const parsePackageName = require("../utils/parser").parsePackageName;
|
|
2
|
+
const executeJson = require("../utils/json-exec").executeJson;
|
|
3
|
+
|
|
4
|
+
const Yarn1 = {
|
|
5
|
+
uxfPackagesInfo() {
|
|
6
|
+
return executeJson('yarn list --pattern "@uxf" --depth=1 --json').then((output) => {
|
|
7
|
+
const result = {};
|
|
8
|
+
|
|
9
|
+
output[0].data.trees
|
|
10
|
+
.map((info) => {
|
|
11
|
+
const [name, version] = parsePackageName(info.name);
|
|
12
|
+
return {
|
|
13
|
+
name,
|
|
14
|
+
version,
|
|
15
|
+
isError: info.children.length > 0,
|
|
16
|
+
};
|
|
17
|
+
})
|
|
18
|
+
.forEach((item) => {
|
|
19
|
+
result[item.name] = item;
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
return result;
|
|
23
|
+
});
|
|
24
|
+
},
|
|
25
|
+
packageVersion(packageName) {
|
|
26
|
+
return executeJson(`yarn list ${packageName} --depth=0 --json`).then((output) => {
|
|
27
|
+
return parsePackageName(output[0].data.trees[0].name)[1];
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
module.exports = {
|
|
33
|
+
Yarn1
|
|
34
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const parsePackageName = require("../utils/parser").parsePackageName;
|
|
2
|
+
const executeJson = require("../utils/json-exec").executeJson;
|
|
3
|
+
|
|
4
|
+
const Yarn4 = {
|
|
5
|
+
uxfPackagesInfo() {
|
|
6
|
+
return executeJson('yarn info "@uxf/*" -AR --json').then((output) => {
|
|
7
|
+
const result = {};
|
|
8
|
+
|
|
9
|
+
output
|
|
10
|
+
.map((info) => {
|
|
11
|
+
const [name, version] = parsePackageName(info.value);
|
|
12
|
+
return {
|
|
13
|
+
name,
|
|
14
|
+
version,
|
|
15
|
+
isError: false,
|
|
16
|
+
};
|
|
17
|
+
})
|
|
18
|
+
.forEach((item) => {
|
|
19
|
+
const isError = result[item.name] !== undefined;
|
|
20
|
+
result[item.name] = item;
|
|
21
|
+
result[item.name].isError = isError;
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
return result;
|
|
25
|
+
});
|
|
26
|
+
},
|
|
27
|
+
packageVersion(packageName) {
|
|
28
|
+
return executeJson(`yarn info ${packageName} --json`).then((output) => parsePackageName(output[0].value)[1]);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
module.exports = {
|
|
33
|
+
Yarn4,
|
|
34
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
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) =>
|
|
13
|
+
output
|
|
14
|
+
.split("\n")
|
|
15
|
+
.filter((s) => s !== "")
|
|
16
|
+
.map(JSON.parse),
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
module.exports = {
|
|
21
|
+
execute,
|
|
22
|
+
executeJson,
|
|
23
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
function parsePackageName(name) {
|
|
2
|
+
if (name.charAt(0) === "@") {
|
|
3
|
+
const [nameWithoutAt, version] = name.replace("@", "").split("@");
|
|
4
|
+
|
|
5
|
+
return [`@${nameWithoutAt}`, version.replace(/^npm:/, "")];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const [nameWithoutAt, version] = name.split("@");
|
|
9
|
+
return [nameWithoutAt, version.replace(/^npm:/, "")];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
module.exports = {
|
|
13
|
+
parsePackageName,
|
|
14
|
+
};
|