@naturalcycles/nodejs-lib 15.107.2 → 15.107.4
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/bin/generate-build-info.js +2 -0
- package/bin/json2env.js +2 -0
- package/bin/kpy.js +2 -0
- package/bin/secrets-decrypt.js +2 -0
- package/bin/secrets-encrypt.js +2 -0
- package/bin/secrets-gen-key.js +2 -0
- package/bin/slack-this.js +2 -0
- package/dist/bin/generate-build-info.d.ts +0 -1
- package/dist/bin/generate-build-info.js +0 -1
- package/dist/bin/json2env.d.ts +0 -1
- package/dist/bin/json2env.js +0 -1
- package/dist/bin/kpy.d.ts +0 -1
- package/dist/bin/kpy.js +0 -1
- package/dist/bin/secrets-decrypt.d.ts +0 -1
- package/dist/bin/secrets-decrypt.js +0 -1
- package/dist/bin/secrets-encrypt.d.ts +0 -1
- package/dist/bin/secrets-encrypt.js +0 -1
- package/dist/bin/secrets-gen-key.d.ts +0 -1
- package/dist/bin/secrets-gen-key.js +0 -1
- package/dist/bin/slack-this.d.ts +0 -1
- package/dist/bin/slack-this.js +0 -1
- package/dist/util/git2.d.ts +9 -1
- package/dist/util/git2.js +53 -1
- package/dist/validation/ajv/jSchema.js +1 -4
- package/package.json +11 -10
- package/src/bin/generate-build-info.ts +0 -2
- package/src/bin/json2env.ts +0 -2
- package/src/bin/kpy.ts +0 -2
- package/src/bin/secrets-decrypt.ts +0 -2
- package/src/bin/secrets-encrypt.ts +0 -2
- package/src/bin/secrets-gen-key.ts +0 -2
- package/src/bin/slack-this.ts +0 -2
- package/src/util/git2.ts +55 -1
- package/src/validation/ajv/jSchema.ts +1 -3
package/bin/json2env.js
ADDED
package/bin/kpy.js
ADDED
package/dist/bin/json2env.d.ts
CHANGED
package/dist/bin/json2env.js
CHANGED
package/dist/bin/kpy.d.ts
CHANGED
package/dist/bin/kpy.js
CHANGED
package/dist/bin/slack-this.d.ts
CHANGED
package/dist/bin/slack-this.js
CHANGED
package/dist/util/git2.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ declare class Git2 {
|
|
|
7
7
|
commitMessageToTitleMessage(msg: string): string;
|
|
8
8
|
hasUncommittedChanges(): boolean;
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* @returns true if there were changes
|
|
11
11
|
*/
|
|
12
12
|
commitAll(msg: string): boolean;
|
|
13
13
|
/**
|
|
@@ -22,6 +22,14 @@ declare class Git2 {
|
|
|
22
22
|
getCurrentBranchName(): string;
|
|
23
23
|
getCurrentRepoName(): string;
|
|
24
24
|
getAllBranchesNames(): string[];
|
|
25
|
+
gitRefExists(ref: string): boolean;
|
|
26
|
+
getTrackedFiles(): string[];
|
|
27
|
+
getUntrackedFiles(): string[];
|
|
28
|
+
getTrackedChangedFiles(diffBase: string, diffFilter?: string): string[];
|
|
29
|
+
/**
|
|
30
|
+
* @returns both tracked changed and untracked files
|
|
31
|
+
*/
|
|
32
|
+
getAllChangedFiles(diffBase: string): string[];
|
|
25
33
|
}
|
|
26
34
|
export declare const git2: Git2;
|
|
27
35
|
export {};
|
package/dist/util/git2.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { execSync } from 'node:child_process';
|
|
2
2
|
import { basename } from 'node:path';
|
|
3
|
+
import { _uniq } from '@naturalcycles/js-lib/array';
|
|
3
4
|
import { exec2 } from '../exec2/exec2.js';
|
|
4
5
|
/**
|
|
5
6
|
* Set of utility functions to work with git.
|
|
@@ -26,7 +27,7 @@ class Git2 {
|
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
29
|
/**
|
|
29
|
-
*
|
|
30
|
+
* @returns true if there were changes
|
|
30
31
|
*/
|
|
31
32
|
commitAll(msg) {
|
|
32
33
|
// git commit -a -m "style(lint-all): $GIT_MSG" || true
|
|
@@ -120,5 +121,56 @@ class Git2 {
|
|
|
120
121
|
.filter(s => !s.includes(' -> '))
|
|
121
122
|
.map(s => s.split('/')[1]);
|
|
122
123
|
}
|
|
124
|
+
gitRefExists(ref) {
|
|
125
|
+
try {
|
|
126
|
+
exec2.exec(`git rev-parse --verify --quiet ${ref}`);
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
getTrackedFiles() {
|
|
134
|
+
try {
|
|
135
|
+
return exec2
|
|
136
|
+
.exec('git ls-files')
|
|
137
|
+
.split('\n')
|
|
138
|
+
.filter(s => s.trim().length);
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
return [];
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
getUntrackedFiles() {
|
|
145
|
+
try {
|
|
146
|
+
return exec2
|
|
147
|
+
.exec('git ls-files --others --exclude-standard')
|
|
148
|
+
.split('\n')
|
|
149
|
+
.filter(s => s.trim().length);
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
return [];
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
getTrackedChangedFiles(diffBase, diffFilter = 'AMR') {
|
|
156
|
+
try {
|
|
157
|
+
return exec2
|
|
158
|
+
.exec(`git diff --name-only --diff-filter=${diffFilter} ${diffBase}`)
|
|
159
|
+
.split('\n')
|
|
160
|
+
.filter(s => s.trim().length);
|
|
161
|
+
}
|
|
162
|
+
catch {
|
|
163
|
+
return [];
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* @returns both tracked changed and untracked files
|
|
168
|
+
*/
|
|
169
|
+
getAllChangedFiles(diffBase) {
|
|
170
|
+
const tracked = this.getTrackedChangedFiles(diffBase);
|
|
171
|
+
const untracked = this.getUntrackedFiles();
|
|
172
|
+
const changes = [...tracked, ...untracked];
|
|
173
|
+
return _uniq(changes);
|
|
174
|
+
}
|
|
123
175
|
}
|
|
124
176
|
export const git2 = new Git2();
|
|
@@ -1378,10 +1378,7 @@ function hasNoObjectSchemas(schema) {
|
|
|
1378
1378
|
else if (schema.type === 'array') {
|
|
1379
1379
|
return !schema.items || hasNoObjectSchemas(schema.items);
|
|
1380
1380
|
}
|
|
1381
|
-
|
|
1382
|
-
return !!schema.type && ['string', 'number', 'integer', 'boolean', 'null'].includes(schema.type);
|
|
1383
|
-
}
|
|
1384
|
-
return false;
|
|
1381
|
+
return !!schema.type && ['string', 'number', 'integer', 'boolean', 'null'].includes(schema.type);
|
|
1385
1382
|
}
|
|
1386
1383
|
/**
|
|
1387
1384
|
* Deep copy that preserves functions in customValidations/customConversions.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/nodejs-lib",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "15.107.
|
|
4
|
+
"version": "15.107.4",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@naturalcycles/js-lib": "^15",
|
|
7
7
|
"@standard-schema/spec": "^1",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"yargs": "^18"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@typescript/native-preview": "
|
|
21
|
-
"@naturalcycles/dev-lib": "
|
|
20
|
+
"@typescript/native-preview": "beta",
|
|
21
|
+
"@naturalcycles/dev-lib": "20.45.1"
|
|
22
22
|
},
|
|
23
23
|
"exports": {
|
|
24
24
|
".": "./dist/index.js",
|
|
@@ -41,15 +41,16 @@
|
|
|
41
41
|
"./zip": "./dist/zip/zip2.js"
|
|
42
42
|
},
|
|
43
43
|
"bin": {
|
|
44
|
-
"kpy": "
|
|
45
|
-
"json2env": "
|
|
46
|
-
"generate-build-info": "
|
|
47
|
-
"slack-this": "
|
|
48
|
-
"secrets-gen-key": "
|
|
49
|
-
"secrets-encrypt": "
|
|
50
|
-
"secrets-decrypt": "
|
|
44
|
+
"kpy": "bin/kpy.js",
|
|
45
|
+
"json2env": "bin/json2env.js",
|
|
46
|
+
"generate-build-info": "bin/generate-build-info.js",
|
|
47
|
+
"slack-this": "bin/slack-this.js",
|
|
48
|
+
"secrets-gen-key": "bin/secrets-gen-key.js",
|
|
49
|
+
"secrets-encrypt": "bin/secrets-encrypt.js",
|
|
50
|
+
"secrets-decrypt": "bin/secrets-decrypt.js"
|
|
51
51
|
},
|
|
52
52
|
"files": [
|
|
53
|
+
"bin",
|
|
53
54
|
"dist",
|
|
54
55
|
"src",
|
|
55
56
|
"!src/test",
|
package/src/bin/json2env.ts
CHANGED
package/src/bin/kpy.ts
CHANGED
package/src/bin/slack-this.ts
CHANGED
package/src/util/git2.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { execSync } from 'node:child_process'
|
|
2
2
|
import { basename } from 'node:path'
|
|
3
|
+
import { _uniq } from '@naturalcycles/js-lib/array'
|
|
3
4
|
import type { UnixTimestamp } from '@naturalcycles/js-lib/types'
|
|
4
5
|
import { exec2 } from '../exec2/exec2.js'
|
|
5
6
|
|
|
@@ -30,7 +31,7 @@ class Git2 {
|
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
/**
|
|
33
|
-
*
|
|
34
|
+
* @returns true if there were changes
|
|
34
35
|
*/
|
|
35
36
|
commitAll(msg: string): boolean {
|
|
36
37
|
// git commit -a -m "style(lint-all): $GIT_MSG" || true
|
|
@@ -134,6 +135,59 @@ class Git2 {
|
|
|
134
135
|
.filter(s => !s.includes(' -> '))
|
|
135
136
|
.map(s => s.split('/')[1]!)
|
|
136
137
|
}
|
|
138
|
+
|
|
139
|
+
gitRefExists(ref: string): boolean {
|
|
140
|
+
try {
|
|
141
|
+
exec2.exec(`git rev-parse --verify --quiet ${ref}`)
|
|
142
|
+
return true
|
|
143
|
+
} catch {
|
|
144
|
+
return false
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
getTrackedFiles(): string[] {
|
|
149
|
+
try {
|
|
150
|
+
return exec2
|
|
151
|
+
.exec('git ls-files')
|
|
152
|
+
.split('\n')
|
|
153
|
+
.filter(s => s.trim().length)
|
|
154
|
+
} catch {
|
|
155
|
+
return []
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
getUntrackedFiles(): string[] {
|
|
160
|
+
try {
|
|
161
|
+
return exec2
|
|
162
|
+
.exec('git ls-files --others --exclude-standard')
|
|
163
|
+
.split('\n')
|
|
164
|
+
.filter(s => s.trim().length)
|
|
165
|
+
} catch {
|
|
166
|
+
return []
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
getTrackedChangedFiles(diffBase: string, diffFilter = 'AMR'): string[] {
|
|
171
|
+
try {
|
|
172
|
+
return exec2
|
|
173
|
+
.exec(`git diff --name-only --diff-filter=${diffFilter} ${diffBase}`)
|
|
174
|
+
.split('\n')
|
|
175
|
+
.filter(s => s.trim().length)
|
|
176
|
+
} catch {
|
|
177
|
+
return []
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* @returns both tracked changed and untracked files
|
|
183
|
+
*/
|
|
184
|
+
getAllChangedFiles(diffBase: string): string[] {
|
|
185
|
+
const tracked = this.getTrackedChangedFiles(diffBase)
|
|
186
|
+
const untracked = this.getUntrackedFiles()
|
|
187
|
+
|
|
188
|
+
const changes = [...tracked, ...untracked]
|
|
189
|
+
return _uniq(changes)
|
|
190
|
+
}
|
|
137
191
|
}
|
|
138
192
|
|
|
139
193
|
export const git2 = new Git2()
|
|
@@ -1933,11 +1933,9 @@ function hasNoObjectSchemas(schema: JsonSchema): boolean {
|
|
|
1933
1933
|
return true
|
|
1934
1934
|
} else if (schema.type === 'array') {
|
|
1935
1935
|
return !schema.items || hasNoObjectSchemas(schema.items)
|
|
1936
|
-
} else {
|
|
1937
|
-
return !!schema.type && ['string', 'number', 'integer', 'boolean', 'null'].includes(schema.type)
|
|
1938
1936
|
}
|
|
1939
1937
|
|
|
1940
|
-
return
|
|
1938
|
+
return !!schema.type && ['string', 'number', 'integer', 'boolean', 'null'].includes(schema.type)
|
|
1941
1939
|
}
|
|
1942
1940
|
|
|
1943
1941
|
type EnumBaseType = 'string' | 'number' | 'other'
|