@leverege/build-tools 2.96.7 → 2.96.8

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.
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ var _execa = _interopRequireDefault(require("execa"));
5
+ var _simpleGit = _interopRequireDefault(require("simple-git"));
6
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
7
+ const git = new _simpleGit.default();
8
+ const getCurrentBranchName = async () => {
9
+ const branchInfo = await git.branch();
10
+
11
+ // first check to see if there are no branches - new repo?
12
+ if (Object.keys(branchInfo.branches).length === 0) {
13
+ return '';
14
+ }
15
+ return Object.entries(branchInfo.branches).find(([name, info]) => info.current)[0];
16
+ };
17
+ const isProtected = async () => {
18
+ const theBranch = await getCurrentBranchName();
19
+ const protectedBranches = ['main', 'master', 'development'];
20
+ const additionalProtectedBranches = [...process.argv.slice(2)];
21
+
22
+ // Check if the current branch starts with any of the additional
23
+ // protected branch name
24
+ let matchesAdditionalBranch = false;
25
+ for (let i = 0; i < additionalProtectedBranches.length; i++) {
26
+ matchesAdditionalBranch = matchesAdditionalBranch || theBranch.startsWith(additionalProtectedBranches[i]);
27
+ }
28
+ return protectedBranches.includes(theBranch) || matchesAdditionalBranch;
29
+ };
30
+ const npmRunner = async script => {
31
+ try {
32
+ const results = await (0, _execa.default)('npm', ['run', script], {
33
+ stdio: 'inherit'
34
+ });
35
+ return results;
36
+ } catch (err) {
37
+ process.exit(1);
38
+ }
39
+ return undefined;
40
+ };
41
+ (async () => {
42
+ if (await isProtected()) {
43
+ const script = ['test', 'lint'];
44
+ for (let i = 0; i < script.length; i++) {
45
+ await npmRunner(script[i]); // eslint-disable-line no-await-in-loop
46
+ }
47
+ } else {
48
+ process.exit(0);
49
+ }
50
+ })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leverege/build-tools",
3
- "version": "2.96.7",
3
+ "version": "2.96.8",
4
4
  "description": "A collection of build / support tools for Leverege developers",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -117,7 +117,7 @@ if ( requiresHelmChart ) {
117
117
  }
118
118
 
119
119
  const leveregeStanza = isNodeJsProject ? closestPackageJson.leverege : repoDescr.rootPyProjectToml.leverege
120
- const runCommand = isYarnProject ? 'node entrypoint.js' : 'node index.js'
120
+ const runCommand = isYarnProject ? 'node entrypoint.mjs' : 'node index.js'
121
121
 
122
122
  const dockerfileOptions = {
123
123
  isNodeJsProject,
@@ -57,4 +57,4 @@ await $$`rm -rf ${buildDir}/node_modules ${buildDir}/entrypoint.js`
57
57
 
58
58
  const entrypointFile = generateEntrypointFile( main )
59
59
 
60
- await fs.writeFile( `${buildDir}/entrypoint.js`, entrypointFile, 'utf-8' )
60
+ await fs.writeFile( `${buildDir}/entrypoint.mjs`, entrypointFile, 'utf-8' )