@leverege/build-tools 2.5.5 → 2.5.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.
package/README.md CHANGED
@@ -15,16 +15,15 @@ npm install -g @leverege/build-tools
15
15
  ### General Tools:
16
16
  * **build-tools**: A command to get the root of this repo, a latest version check, or bash functions to source
17
17
  * **circleate**: bootstrap .circleci config repo
18
- * **decrypt-secrets**: decrypts secrets (env, service accounts)
19
- * **dockreate**: bootstrap docker repo
20
- * **encrypt-secrets**: encrypts secrets (env, service accounts)
18
+ * **decrypt/encrypt-secrets**: decrypts/encrypts secrets (env, service accounts)
19
+ * **dockreate**: used to build and deploy docker images to the GCP image area
21
20
  * **repo-init**: A repository bootstrapping tool
22
21
 
23
22
  ### Helm Helpers:
24
23
  * **overwhelm**: A k8s context helper and yaml replacer *OVH:<REPLACE_ME>*
25
24
  * **helmify**: DESCRIPTION
26
25
  * **helmup**: A context safe helm deployment tool
27
- * **helmdn**: A destroyer of helm deplotments (danger zone)
26
+ * **helmdn**: A destroyer of helm deployments (danger zone)
28
27
 
29
28
  ### Kubernetes Helpers:
30
29
  * **k8x**: A script to help run commands on active pods in a k8s cluster.
@@ -113,7 +113,7 @@ const checkForLatest = async (pkg = '@leverege/build-tools') => {
113
113
  }
114
114
  };
115
115
 
116
- if (args.latest) {
116
+ const checkAndAnnounce = () => {
117
117
  checkForLatest().then(latestVersion => {
118
118
  if (semverLt(thisVersion, latestVersion)) {
119
119
  console.log(chalk.white`
@@ -125,11 +125,15 @@ if (args.latest) {
125
125
  process.exit(0);
126
126
  }
127
127
  }).catch(err => {});
128
+ };
129
+
130
+ if (args.latest) {
131
+ checkAndAnnounce();
128
132
  }
129
133
 
130
134
  if (args.version) {
131
135
  console.log(`build-tools version ${thisVersion}`);
132
- process.exit(0);
136
+ checkAndAnnounce();
133
137
  }
134
138
 
135
139
  if (args.help) {
Binary file
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const execa = require('execa');
5
+
6
+ const SimpleGit = require('simple-git');
7
+
8
+ const git = new SimpleGit();
9
+
10
+ const getCurrentBranchName = async () => {
11
+ const branchInfo = await git.branch();
12
+ return Object.entries(branchInfo.branches).find(([name, info]) => info.current)[0];
13
+ };
14
+
15
+ const isProtected = async () => {
16
+ const protectedBranches = ['master', 'development', ...process.argv.slice(2)];
17
+ const theBranch = await getCurrentBranchName();
18
+ return protectedBranches.includes(theBranch);
19
+ };
20
+
21
+ const npmRunner = async script => {
22
+ try {
23
+ const results = await execa('npm', ['run', script], {
24
+ stdio: 'inherit'
25
+ });
26
+ return results;
27
+ } catch (err) {
28
+ process.exit(1);
29
+ }
30
+ };
31
+
32
+ (async () => {
33
+ if (await isProtected()) {
34
+ const script = ['test', 'lint'];
35
+
36
+ for (let i = 0; i < script.length; i++) {
37
+ await npmRunner(script[i]);
38
+ }
39
+ } else {
40
+ process.exit(0);
41
+ }
42
+ })();
@@ -113,7 +113,7 @@ const checkForLatest = async (pkg = '@leverege/build-tools') => {
113
113
  }
114
114
  };
115
115
 
116
- if (args.latest) {
116
+ const checkAndAnnounce = () => {
117
117
  checkForLatest().then(latestVersion => {
118
118
  if (semverLt(thisVersion, latestVersion)) {
119
119
  console.log(chalk.white`
@@ -125,11 +125,15 @@ if (args.latest) {
125
125
  process.exit(0);
126
126
  }
127
127
  }).catch(err => {});
128
+ };
129
+
130
+ if (args.latest) {
131
+ checkAndAnnounce();
128
132
  }
129
133
 
130
134
  if (args.version) {
131
135
  console.log(`build-tools version ${thisVersion}`);
132
- process.exit(0);
136
+ checkAndAnnounce();
133
137
  }
134
138
 
135
139
  if (args.help) {
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const execa = require('execa');
5
+
6
+ const SimpleGit = require('simple-git');
7
+
8
+ const git = new SimpleGit();
9
+
10
+ const getCurrentBranchName = async () => {
11
+ const branchInfo = await git.branch();
12
+ return Object.entries(branchInfo.branches).find(([name, info]) => info.current)[0];
13
+ };
14
+
15
+ const isProtected = async () => {
16
+ const protectedBranches = ['master', 'development', ...process.argv.slice(2)];
17
+ const theBranch = await getCurrentBranchName();
18
+ return protectedBranches.includes(theBranch);
19
+ };
20
+
21
+ const npmRunner = async script => {
22
+ try {
23
+ const results = await execa('npm', ['run', script], {
24
+ stdio: 'inherit'
25
+ });
26
+ return results;
27
+ } catch (err) {
28
+ process.exit(1);
29
+ }
30
+ };
31
+
32
+ (async () => {
33
+ if (await isProtected()) {
34
+ const script = ['test', 'lint'];
35
+
36
+ for (let i = 0; i < script.length; i++) {
37
+ await npmRunner(script[i]);
38
+ }
39
+ } else {
40
+ process.exit(0);
41
+ }
42
+ })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leverege/build-tools",
3
- "version": "2.5.5",
3
+ "version": "2.5.8",
4
4
  "description": "A collection of build / support tools for Leverege developers",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -33,6 +33,7 @@
33
33
  "helminit-dp": "src/helminit-dp",
34
34
  "helminit-scaler": "src/helminit-scaler",
35
35
  "helmup": "src/helmup",
36
+ "husky-check": "src/husky-check.js",
36
37
  "k8scale": "src/k8scale",
37
38
  "k8x": "src/k8x",
38
39
  "npm-link": "src/npm-link",
@@ -42,7 +43,8 @@
42
43
  "pkglint": "src/pkglint",
43
44
  "prune-git": "src/prune-git",
44
45
  "pull-git": "src/pull-git",
45
- "repo-init": "lib/server/repo-init/index.js"
46
+ "repo-init": "lib/server/repo-init/index.js",
47
+ "unleash": "src/unleash.js"
46
48
  },
47
49
  "author": "Leverege Devs",
48
50
  "license": "SEE LICENSE IN LICENSE.md",
@@ -60,20 +62,21 @@
60
62
  "inquirer": "^7.3.3",
61
63
  "js-yaml": "^3.14.0",
62
64
  "ncp": "^2.0.0",
63
- "npm-check-updates": "^7.1.1",
64
- "npm-registry-fetch": "^8.1.4",
65
- "open": "^7.2.0",
66
- "ora": "^5.0.0",
65
+ "npm-check-updates": "^9.1.0",
66
+ "npm-registry-fetch": "^8.1.5",
67
+ "open": "^7.3.0",
68
+ "ora": "^5.1.0",
67
69
  "parse-gitignore": "^1.0.1",
68
70
  "readline-sync": "^1.4.10",
69
71
  "semver": "^7.3.2",
70
- "simple-git": "^2.20.1"
72
+ "simple-git": "^2.21.0"
71
73
  },
72
74
  "devDependencies": {
73
- "@babel/cli": "^7.10.5",
74
- "@babel/core": "^7.11.4",
75
- "@babel/node": "^7.10.5",
76
- "@leverege/babel-preset-leverege-node": "^1.1.0",
77
- "@leverege/eslint-config-leverege": "^2.0.10"
75
+ "@babel/cli": "^7.12.1",
76
+ "@babel/core": "^7.12.3",
77
+ "@babel/node": "^7.12.1",
78
+ "@leverege/babel-preset-leverege-node": "^1.1.1",
79
+ "@leverege/eslint-config-leverege": "^2.1.0",
80
+ "npm": "^6.14.8"
78
81
  }
79
82
  }
@@ -104,7 +104,7 @@ const checkForLatest = async ( pkg = '@leverege/build-tools' ) => {
104
104
  }
105
105
  }
106
106
 
107
- if ( args.latest ) {
107
+ const checkAndAnnounce = () => {
108
108
  checkForLatest()
109
109
  .then( ( latestVersion ) => {
110
110
  if ( semverLt( thisVersion, latestVersion ) ) {
@@ -122,9 +122,13 @@ if ( args.latest ) {
122
122
  } )
123
123
  }
124
124
 
125
+ if ( args.latest ) {
126
+ checkAndAnnounce()
127
+ }
128
+
125
129
  if ( args.version ) {
126
130
  console.log( `build-tools version ${thisVersion}` )
127
- process.exit( 0 )
131
+ checkAndAnnounce()
128
132
  }
129
133
 
130
134
  if ( args.help ) {
package/src/helmup CHANGED
@@ -333,10 +333,10 @@ function installVelero() {
333
333
  --set schedules.timescale.template.labelSelector.matchLabels.release="timescale-db" \
334
334
  --set schedules.timescale.template.labelSelector.matchLabels.app="postgresql" \
335
335
  --set schedules.timescale.template.snapshotVolumes="true" \
336
- --set schedules.timescale.schedule="0 2 * * *" \
337
- --set schedules.timescale.template.ttl="720h" \
338
- --set schedules.timescale.template.labelSelector.matchLabels.app="mysql" \
339
- --set schedules.timescale.template.snapshotVolumes="true"
336
+ --set schedules.mysql.schedule="0 2 * * *" \
337
+ --set schedules.mysql.template.ttl="720h" \
338
+ --set schedules.mysql.template.labelSelector.matchLabels.app="mysql" \
339
+ --set schedules.mysql.template.snapshotVolumes="true"
340
340
 
341
341
  ## Instruct users to move velero keys
342
342
  printf "\n$YELO_WARN MOVE THE SERVICE ACCOUNT TO YOUR KEYS FOLDER"
@@ -0,0 +1,23 @@
1
+ #!/bin/bash
2
+
3
+ IMPERSONATE='gcloud config set auth/impersonate_service_account'
4
+ impersonate() {
5
+ sa=$1
6
+ echo "Impersonating $sa"
7
+ $IMPERSONATE $sa
8
+ }
9
+
10
+ case $1 in
11
+ gke)
12
+ impersonate k8s@project.iam.gserviceaccount.com
13
+ ;;
14
+ admin)
15
+ impersonate admin@other-project.iam.gserviceaccount.com
16
+ ;;
17
+ clear)
18
+ gcloud config unset auth/impersonate_service_account
19
+ ;;
20
+ *)
21
+ echo "Usage: Updates impersonated service account"
22
+ echo " imp-sa [gke|admin|clear]"
23
+ esac
@@ -0,0 +1,46 @@
1
+ #!/bin/bash
2
+
3
+ SVC_PROJ="leverege-dev-john"
4
+
5
+ SVC_NAME="terraformer"
6
+ SVC_ACCT="${SVC_NAME}@${SVC_PROJ}.iam.gserviceaccount.com"
7
+
8
+ function countdown() {
9
+ local SEC=${1}
10
+ shift
11
+ local MSG=${@}
12
+ while [ $SEC -ne 0 ];
13
+ do
14
+ printf "\r\033[KWaiting %.d seconds $MSG" $((SEC--))
15
+ sleep 1
16
+ done
17
+ }
18
+
19
+ gcloud iam service-accounts create ${SVC_NAME} \
20
+ --project=${SVC_PROJ} --quiet \
21
+ --description="the terraforming account" \
22
+ --display-name="terraformer" &> /dev/null
23
+
24
+ gcloud projects add-iam-policy-binding ${SVC_PROJ} \
25
+ --project=${SVC_PROJ} --quiet \
26
+ --member=serviceAccount:${SVC_ACCT} \
27
+ --role=roles/editor &> /dev/null
28
+
29
+ gcloud projects add-iam-policy-binding ${SVC_PROJ} \
30
+ --project=${SVC_PROJ} --quiet \
31
+ --member=serviceAccount:${SVC_ACCT} \
32
+ --role=roles/iam.securityAdmin &> /dev/null
33
+
34
+ countdown 30 "will delete ${SVC_NAME} service account"
35
+
36
+ gcloud projects remove-iam-policy-binding ${SVC_PROJ} \
37
+ --project=${SVC_PROJ} --quiet \
38
+ --member=serviceAccount:${SVC_ACCT} \
39
+ --role=roles/iam.securityAdmin &> /dev/null
40
+
41
+ gcloud projects remove-iam-policy-binding ${SVC_PROJ} \
42
+ --project=${SVC_PROJ} --quiet \
43
+ --member=serviceAccount:${SVC_ACCT} \
44
+ --role=roles/editor &> /dev/null
45
+
46
+ gcloud iam service-accounts delete ${SVC_ACCT} --quiet &> /dev/null
package/src/unleash.js ADDED
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env node
2
+
3
+ const execa = require( 'execa' )
4
+ const SimpleGit = require( 'simple-git' )
5
+ const git = new SimpleGit()
6
+
7
+ const getCurrentBranchName = async () => {
8
+ const branchInfo = await git.branch()
9
+ return Object
10
+ .entries( branchInfo.branches )
11
+ .find( ( [ name, info ] ) => ( info.current ) )[0]
12
+ }
13
+
14
+ const isProtected = async () => {
15
+ const protectedBranches = [ 'master', 'development', ...process.argv.slice( 2 ) ]
16
+ const theBranch = await getCurrentBranchName()
17
+ return protectedBranches.includes( theBranch )
18
+ }
19
+
20
+ const npmRunner = async ( script ) => {
21
+ try {
22
+ const results = await execa( 'npm', [ 'run', script ], { stdio : 'inherit' } )
23
+ return results
24
+ } catch ( err ) {
25
+ process.exit( 1 )
26
+ }
27
+ }
28
+
29
+ ( async () => {
30
+ if ( await isProtected() ) {
31
+ const script = [ 'test', 'lint' ]
32
+ for( let i = 0; i < script.length; i++ ) {
33
+ await npmRunner( script[ i ] )
34
+ }
35
+ } else {
36
+ process.exit( 0 )
37
+ }
38
+ } )()