@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.
@@ -154,7 +154,7 @@ function printReport(report) {
154
154
  }
155
155
  function getRecentCommits(count) {
156
156
  try {
157
- const log = (0, node_child_process_1.execSync)(`git log -${count} --format='%H|%an|%aI|%B---END---' --name-only 2>/dev/null`, { encoding: 'utf-8', maxBuffer: 10 * 1024 * 1024 });
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).replace(/'/g, '');
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
- //# sourceMappingURL=audit.js.map
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 mainBranch = (0, node_child_process_1.execSync)('git rev-parse --verify main 2>/dev/null || git rev-parse --verify master 2>/dev/null', {
128
- encoding: 'utf-8',
129
- }).trim();
130
- const currentBranch = (0, node_child_process_1.execSync)('git rev-parse HEAD', { encoding: 'utf-8' }).trim();
131
- if (mainBranch === currentBranch) {
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 `${mainBranch}..HEAD`;
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 = (0, node_child_process_1.execSync)(`git log ${range} --format='%H|%an|%aI|%s' --name-only`, { encoding: 'utf-8', maxBuffer: 10 * 1024 * 1024 });
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: sha.replace(/'/g, ''),
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
- //# sourceMappingURL=validate.js.map
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('charter v0.1.0');
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackbilt/cli",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Charter CLI — repo-level governance checks",
5
5
  "bin": {
6
6
  "charter": "./dist/bin.js"