@naturalcycles/dev-lib 14.1.2 → 14.2.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/dist/bin/up.js
CHANGED
|
@@ -6,6 +6,8 @@ const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
|
|
|
6
6
|
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
7
7
|
(0, nodejs_lib_1.runScript)(async () => {
|
|
8
8
|
(0, nodejs_lib_1.execVoidCommandSync)('yarn', ['upgrade']);
|
|
9
|
+
(0, nodejs_lib_1.execVoidCommandSync)('yarn-deduplicate');
|
|
10
|
+
(0, nodejs_lib_1.execVoidCommandSync)('yarn');
|
|
9
11
|
if (node_fs_1.default.existsSync(`node_modules/patch-package`)) {
|
|
10
12
|
(0, nodejs_lib_1.execVoidCommandSync)('patch-package');
|
|
11
13
|
}
|
|
@@ -25,12 +25,10 @@ async function lintAllCommand() {
|
|
|
25
25
|
default: false,
|
|
26
26
|
},
|
|
27
27
|
}).argv;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if ((commitOnChanges || failOnChanges) && hadChangesBefore) {
|
|
28
|
+
const needToTrackChanges = commitOnChanges || failOnChanges;
|
|
29
|
+
const gitStatusAtStart = gitStatus();
|
|
30
|
+
if (needToTrackChanges && gitStatusAtStart) {
|
|
32
31
|
console.log('lint-all: git shows changes before run:');
|
|
33
|
-
gitStatusAtStart = gitStatus();
|
|
34
32
|
console.log(gitStatusAtStart);
|
|
35
33
|
}
|
|
36
34
|
// We run eslint BEFORE Prettier, because eslint can delete e.g unused imports.
|
|
@@ -43,27 +41,21 @@ async function lintAllCommand() {
|
|
|
43
41
|
runActionLint();
|
|
44
42
|
await runKTLint();
|
|
45
43
|
console.log(`${(0, nodejs_lib_1.boldGrey)('lint-all')} ${(0, nodejs_lib_1.dimGrey)(`took ` + (0, js_lib_1._since)(started))}`);
|
|
46
|
-
if (
|
|
47
|
-
|
|
48
|
-
const hasChanges =
|
|
49
|
-
if (hasChanges)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
// fail on changes
|
|
62
|
-
if (failOnChanges) {
|
|
63
|
-
console.log(gitStatusAfter);
|
|
64
|
-
console.log('lint-all failOnChanges: exiting with status 1');
|
|
65
|
-
process.exitCode = 1;
|
|
66
|
-
}
|
|
44
|
+
if (needToTrackChanges) {
|
|
45
|
+
const gitStatusAfter = gitStatus();
|
|
46
|
+
const hasChanges = gitStatusAfter !== gitStatusAtStart;
|
|
47
|
+
if (!hasChanges)
|
|
48
|
+
return;
|
|
49
|
+
const msg = 'style(ci): ' + (0, js_lib_1._truncate)((0, nodejs_lib_1.commitMessageToTitleMessage)((0, nodejs_lib_1.getLastGitCommitMsg)()), 60);
|
|
50
|
+
// pull, commit, push changes
|
|
51
|
+
(0, nodejs_lib_1.gitPull)();
|
|
52
|
+
(0, nodejs_lib_1.gitCommitAll)(msg);
|
|
53
|
+
(0, nodejs_lib_1.gitPush)();
|
|
54
|
+
// fail on changes
|
|
55
|
+
if (failOnChanges) {
|
|
56
|
+
console.log(gitStatusAfter);
|
|
57
|
+
console.log('lint-all failOnChanges: exiting with status 1');
|
|
58
|
+
process.exitCode = 1;
|
|
67
59
|
}
|
|
68
60
|
}
|
|
69
61
|
}
|
|
@@ -97,7 +89,7 @@ function canRunBinary(name) {
|
|
|
97
89
|
}
|
|
98
90
|
function gitStatus() {
|
|
99
91
|
try {
|
|
100
|
-
return (0, node_child_process_1.execSync)('git status', {
|
|
92
|
+
return (0, node_child_process_1.execSync)('git status -s', {
|
|
101
93
|
encoding: 'utf8',
|
|
102
94
|
});
|
|
103
95
|
}
|