@stackbilt/cli 0.1.4 → 0.1.6
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/commands/audit.js +9 -3
- package/dist/commands/validate.js +19 -9
- package/dist/index.js +4 -2
- package/package.json +1 -1
package/dist/commands/audit.js
CHANGED
|
@@ -154,7 +154,7 @@ function printReport(report) {
|
|
|
154
154
|
}
|
|
155
155
|
function getRecentCommits(count) {
|
|
156
156
|
try {
|
|
157
|
-
const log = (
|
|
157
|
+
const log = runGit(['log', `-${count}`, '--format=%H|%an|%aI|%B---END---', '--name-only']);
|
|
158
158
|
const commits = [];
|
|
159
159
|
const entries = log.split('---END---');
|
|
160
160
|
for (const entry of entries) {
|
|
@@ -165,7 +165,7 @@ function getRecentCommits(count) {
|
|
|
165
165
|
if (!firstLine.includes('|'))
|
|
166
166
|
continue;
|
|
167
167
|
const pipeIdx = firstLine.indexOf('|');
|
|
168
|
-
const sha = firstLine.slice(0, pipeIdx)
|
|
168
|
+
const sha = firstLine.slice(0, pipeIdx);
|
|
169
169
|
const rest = firstLine.slice(pipeIdx + 1);
|
|
170
170
|
const [author, timestamp, ...msgParts] = rest.split('|');
|
|
171
171
|
const files = [];
|
|
@@ -189,4 +189,10 @@ function getRecentCommits(count) {
|
|
|
189
189
|
return [];
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
|
-
|
|
192
|
+
function runGit(args) {
|
|
193
|
+
return (0, node_child_process_1.execFileSync)('git', args, {
|
|
194
|
+
encoding: 'utf-8',
|
|
195
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
//# sourceMappingURL=audit.js.map
|
|
@@ -124,14 +124,18 @@ function getCommitRange(args) {
|
|
|
124
124
|
return args[rangeIdx + 1];
|
|
125
125
|
}
|
|
126
126
|
try {
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
127
|
+
const currentBranch = runGit(['rev-parse', 'HEAD']).trim();
|
|
128
|
+
let baseBranch = '';
|
|
129
|
+
try {
|
|
130
|
+
baseBranch = runGit(['rev-parse', '--verify', 'main']).trim();
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
baseBranch = runGit(['rev-parse', '--verify', 'master']).trim();
|
|
134
|
+
}
|
|
135
|
+
if (!baseBranch || baseBranch === currentBranch) {
|
|
132
136
|
return 'HEAD~5..HEAD';
|
|
133
137
|
}
|
|
134
|
-
return `${
|
|
138
|
+
return `${baseBranch}..HEAD`;
|
|
135
139
|
}
|
|
136
140
|
catch {
|
|
137
141
|
return 'HEAD~5..HEAD';
|
|
@@ -139,7 +143,7 @@ function getCommitRange(args) {
|
|
|
139
143
|
}
|
|
140
144
|
function getGitCommits(range) {
|
|
141
145
|
try {
|
|
142
|
-
const log = (
|
|
146
|
+
const log = runGit(['log', range, '--format=%H|%an|%aI|%s', '--name-only']);
|
|
143
147
|
const commits = [];
|
|
144
148
|
let current = null;
|
|
145
149
|
for (const line of log.split('\n')) {
|
|
@@ -148,7 +152,7 @@ function getGitCommits(range) {
|
|
|
148
152
|
commits.push(current);
|
|
149
153
|
const [sha, author, timestamp, ...msgParts] = line.split('|');
|
|
150
154
|
current = {
|
|
151
|
-
sha
|
|
155
|
+
sha,
|
|
152
156
|
author,
|
|
153
157
|
timestamp,
|
|
154
158
|
message: msgParts.join('|'),
|
|
@@ -167,4 +171,10 @@ function getGitCommits(range) {
|
|
|
167
171
|
return [];
|
|
168
172
|
}
|
|
169
173
|
}
|
|
170
|
-
|
|
174
|
+
function runGit(args) {
|
|
175
|
+
return (0, node_child_process_1.execFileSync)('git', args, {
|
|
176
|
+
encoding: 'utf-8',
|
|
177
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=validate.js.map
|
package/dist/index.js
CHANGED
|
@@ -15,6 +15,8 @@ const validate_1 = require("./commands/validate");
|
|
|
15
15
|
const audit_1 = require("./commands/audit");
|
|
16
16
|
const drift_1 = require("./commands/drift");
|
|
17
17
|
const classify_1 = require("./commands/classify");
|
|
18
|
+
const package_json_1 = require("../package.json");
|
|
19
|
+
const CLI_VERSION = package_json_1.version;
|
|
18
20
|
const HELP = `
|
|
19
21
|
charter - repo-level governance toolkit
|
|
20
22
|
|
|
@@ -55,7 +57,7 @@ async function run(args) {
|
|
|
55
57
|
return exports.EXIT_CODE.SUCCESS;
|
|
56
58
|
}
|
|
57
59
|
if (args.includes('--version') || args.includes('-v')) {
|
|
58
|
-
console.log(
|
|
60
|
+
console.log(`charter v${CLI_VERSION}`);
|
|
59
61
|
return exports.EXIT_CODE.SUCCESS;
|
|
60
62
|
}
|
|
61
63
|
const command = args[0];
|
|
@@ -96,4 +98,4 @@ function getFlag(args, flag) {
|
|
|
96
98
|
}
|
|
97
99
|
return undefined;
|
|
98
100
|
}
|
|
99
|
-
//# sourceMappingURL=index.js.map
|
|
101
|
+
//# sourceMappingURL=index.js.map
|