@naturalcycles/nodejs-lib 13.33.0 → 13.33.1

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.
@@ -7,10 +7,10 @@ const git2_1 = require("./git2");
7
7
  function generateBuildInfo(opt = {}) {
8
8
  const now = js_lib_1.localTime.orNow(opt.overrideTimestamp);
9
9
  const ts = now.unix;
10
- const rev = git2_1.git2.gitCurrentCommitSha();
11
- const branchName = git2_1.git2.gitCurrentBranchName();
12
- const repoName = git2_1.git2.gitCurrentRepoName();
13
- const tsCommit = git2_1.git2.gitCurrentCommitTimestamp();
10
+ const rev = git2_1.git2.getCurrentCommitSha();
11
+ const branchName = git2_1.git2.getCurrentBranchName();
12
+ const repoName = git2_1.git2.getCurrentRepoName();
13
+ const tsCommit = git2_1.git2.getCurrentCommitTimestamp();
14
14
  const ver = [now.toStringCompact(), repoName, branchName, rev].join('_');
15
15
  let { APP_ENV: env } = process.env;
16
16
  if (!env) {
@@ -5,21 +5,21 @@ import type { UnixTimestampNumber } from '@naturalcycles/js-lib';
5
5
  declare class Git2 {
6
6
  getLastGitCommitMsg(): string;
7
7
  commitMessageToTitleMessage(msg: string): string;
8
- gitHasUncommittedChanges(): boolean;
8
+ hasUncommittedChanges(): boolean;
9
9
  /**
10
10
  * Returns true if there were changes
11
11
  */
12
- gitCommitAll(msg: string): boolean;
12
+ commitAll(msg: string): boolean;
13
13
  /**
14
14
  * @returns true if there are not pushed commits.
15
15
  */
16
- gitIsAhead(): boolean;
17
- gitPull(): void;
18
- gitPush(): void;
19
- gitCurrentCommitSha(full?: boolean): string;
20
- gitCurrentCommitTimestamp(): UnixTimestampNumber;
21
- gitCurrentBranchName(): string;
22
- gitCurrentRepoName(): string;
16
+ isAhead(): boolean;
17
+ pull(): void;
18
+ push(): void;
19
+ getCurrentCommitSha(full?: boolean): string;
20
+ getCurrentCommitTimestamp(): UnixTimestampNumber;
21
+ getCurrentBranchName(): string;
22
+ getCurrentRepoName(): string;
23
23
  }
24
24
  export declare const git2: Git2;
25
25
  export {};
package/dist/util/git2.js CHANGED
@@ -18,7 +18,7 @@ class Git2 {
18
18
  const [preTitle, title] = firstLine.split(': ');
19
19
  return title || preTitle;
20
20
  }
21
- gitHasUncommittedChanges() {
21
+ hasUncommittedChanges() {
22
22
  // git diff-index --quiet HEAD -- || echo "untracked"
23
23
  try {
24
24
  node_child_process_1.default.execSync('git diff-index --quiet HEAD --', {
@@ -33,7 +33,7 @@ class Git2 {
33
33
  /**
34
34
  * Returns true if there were changes
35
35
  */
36
- gitCommitAll(msg) {
36
+ commitAll(msg) {
37
37
  // git commit -a -m "style(lint-all): $GIT_MSG" || true
38
38
  const cmd = `git commit -a --no-verify -m "${msg}"`;
39
39
  // const cmd = `git`
@@ -52,14 +52,14 @@ class Git2 {
52
52
  /**
53
53
  * @returns true if there are not pushed commits.
54
54
  */
55
- gitIsAhead() {
55
+ isAhead() {
56
56
  // ahead=`git rev-list HEAD --not --remotes | wc -l | awk '{print $1}'`
57
57
  const cmd = `git rev-list HEAD --not --remotes | wc -l | awk '{print $1}'`;
58
58
  const stdout = exec2_1.exec2.exec(cmd);
59
59
  // console.log(`gitIsAhead: ${stdout}`)
60
60
  return Number(stdout) > 0;
61
61
  }
62
- gitPull() {
62
+ pull() {
63
63
  const cmd = 'git pull';
64
64
  try {
65
65
  node_child_process_1.default.execSync(cmd, {
@@ -68,26 +68,26 @@ class Git2 {
68
68
  }
69
69
  catch { }
70
70
  }
71
- gitPush() {
71
+ push() {
72
72
  // git push --set-upstream origin $CIRCLE_BRANCH && echo "pushed, exiting" && exit 0
73
73
  let cmd = 'git push';
74
- const branchName = this.gitCurrentBranchName();
74
+ const branchName = this.getCurrentBranchName();
75
75
  if (branchName) {
76
76
  cmd += ` --set-upstream origin ${branchName}`;
77
77
  }
78
78
  exec2_1.exec2.spawn(cmd, { logStart: true });
79
79
  }
80
- gitCurrentCommitSha(full = false) {
80
+ getCurrentCommitSha(full = false) {
81
81
  const sha = exec2_1.exec2.exec('git rev-parse HEAD');
82
82
  return full ? sha : sha.slice(0, 7);
83
83
  }
84
- gitCurrentCommitTimestamp() {
84
+ getCurrentCommitTimestamp() {
85
85
  return Number(exec2_1.exec2.exec('git log -1 --format=%ct'));
86
86
  }
87
- gitCurrentBranchName() {
87
+ getCurrentBranchName() {
88
88
  return exec2_1.exec2.exec('git rev-parse --abbrev-ref HEAD');
89
89
  }
90
- gitCurrentRepoName() {
90
+ getCurrentRepoName() {
91
91
  const originUrl = exec2_1.exec2.exec('git config --get remote.origin.url');
92
92
  return node_path_1.default.basename(originUrl, '.git');
93
93
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/nodejs-lib",
3
- "version": "13.33.0",
3
+ "version": "13.33.1",
4
4
  "scripts": {
5
5
  "prepare": "husky",
6
6
  "build": "dev-lib build",
@@ -19,10 +19,10 @@ export function generateBuildInfo(opt: GenerateBuildInfoOptions = {}): BuildInfo
19
19
  const now = localTime.orNow(opt.overrideTimestamp)
20
20
  const ts = now.unix
21
21
 
22
- const rev = git2.gitCurrentCommitSha()
23
- const branchName = git2.gitCurrentBranchName()
24
- const repoName = git2.gitCurrentRepoName()
25
- const tsCommit = git2.gitCurrentCommitTimestamp()
22
+ const rev = git2.getCurrentCommitSha()
23
+ const branchName = git2.getCurrentBranchName()
24
+ const repoName = git2.getCurrentRepoName()
25
+ const tsCommit = git2.getCurrentCommitTimestamp()
26
26
 
27
27
  const ver = [now.toStringCompact(), repoName, branchName, rev].join('_')
28
28
 
package/src/util/git2.ts CHANGED
@@ -18,7 +18,7 @@ class Git2 {
18
18
  return title || preTitle!
19
19
  }
20
20
 
21
- gitHasUncommittedChanges(): boolean {
21
+ hasUncommittedChanges(): boolean {
22
22
  // git diff-index --quiet HEAD -- || echo "untracked"
23
23
  try {
24
24
  cp.execSync('git diff-index --quiet HEAD --', {
@@ -33,7 +33,7 @@ class Git2 {
33
33
  /**
34
34
  * Returns true if there were changes
35
35
  */
36
- gitCommitAll(msg: string): boolean {
36
+ commitAll(msg: string): boolean {
37
37
  // git commit -a -m "style(lint-all): $GIT_MSG" || true
38
38
  const cmd = `git commit -a --no-verify -m "${msg}"`
39
39
  // const cmd = `git`
@@ -53,7 +53,7 @@ class Git2 {
53
53
  /**
54
54
  * @returns true if there are not pushed commits.
55
55
  */
56
- gitIsAhead(): boolean {
56
+ isAhead(): boolean {
57
57
  // ahead=`git rev-list HEAD --not --remotes | wc -l | awk '{print $1}'`
58
58
  const cmd = `git rev-list HEAD --not --remotes | wc -l | awk '{print $1}'`
59
59
  const stdout = exec2.exec(cmd)
@@ -61,7 +61,7 @@ class Git2 {
61
61
  return Number(stdout) > 0
62
62
  }
63
63
 
64
- gitPull(): void {
64
+ pull(): void {
65
65
  const cmd = 'git pull'
66
66
  try {
67
67
  cp.execSync(cmd, {
@@ -70,11 +70,11 @@ class Git2 {
70
70
  } catch {}
71
71
  }
72
72
 
73
- gitPush(): void {
73
+ push(): void {
74
74
  // git push --set-upstream origin $CIRCLE_BRANCH && echo "pushed, exiting" && exit 0
75
75
  let cmd = 'git push'
76
76
 
77
- const branchName = this.gitCurrentBranchName()
77
+ const branchName = this.getCurrentBranchName()
78
78
 
79
79
  if (branchName) {
80
80
  cmd += ` --set-upstream origin ${branchName}`
@@ -83,20 +83,20 @@ class Git2 {
83
83
  exec2.spawn(cmd, { logStart: true })
84
84
  }
85
85
 
86
- gitCurrentCommitSha(full = false): string {
86
+ getCurrentCommitSha(full = false): string {
87
87
  const sha = exec2.exec('git rev-parse HEAD')
88
88
  return full ? sha : sha.slice(0, 7)
89
89
  }
90
90
 
91
- gitCurrentCommitTimestamp(): UnixTimestampNumber {
91
+ getCurrentCommitTimestamp(): UnixTimestampNumber {
92
92
  return Number(exec2.exec('git log -1 --format=%ct'))
93
93
  }
94
94
 
95
- gitCurrentBranchName(): string {
95
+ getCurrentBranchName(): string {
96
96
  return exec2.exec('git rev-parse --abbrev-ref HEAD')
97
97
  }
98
98
 
99
- gitCurrentRepoName(): string {
99
+ getCurrentRepoName(): string {
100
100
  const originUrl = exec2.exec('git config --get remote.origin.url')
101
101
  return path.basename(originUrl, '.git')
102
102
  }