@leverege/build-tools 2.4.8 → 2.5.0-beta.39

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.
Files changed (41) hide show
  1. package/README.md +0 -1
  2. package/lib/server/build-tools.js +144 -0
  3. package/lib/server/getfbcfg.js +25 -0
  4. package/lib/server/getjson.js +74 -0
  5. package/lib/server/helmify/helm.js +5 -5
  6. package/lib/server/npm-scripts/postinstall.js +19 -0
  7. package/lib/server/overwhelm.js +373 -0
  8. package/lib/server/repo-init/Config.js +45 -0
  9. package/lib/server/repo-init/RepoInit.js +176 -0
  10. package/lib/server/repo-init/config.tgz +0 -0
  11. package/lib/server/repo-init/gitter/Gitter.js +241 -0
  12. package/lib/server/repo-init/gitter/RepoHosting.js +106 -0
  13. package/lib/server/repo-init/gitter/index.js +9 -0
  14. package/lib/server/repo-init/index.js +6 -0
  15. package/lib/server/repo-init/templates/Templates.js +279 -0
  16. package/lib/server/repo-init/templates/ToBuildSpec.js +95 -0
  17. package/lib/server/repo-init/templates/index.js +9 -0
  18. package/lib/server/repo-init/utils/Shell.js +102 -0
  19. package/lib/server/repo-init/utils/VersionCheck.js +82 -0
  20. package/lib/server/repo-init/utils/index.js +67 -0
  21. package/lib/web/build-tools.js +144 -0
  22. package/lib/web/getfbcfg.js +25 -0
  23. package/lib/web/getjson.js +74 -0
  24. package/lib/web/npm-scripts/postinstall.js +19 -0
  25. package/lib/web/overwhelm.js +373 -0
  26. package/package.json +30 -29
  27. package/src/bash-funcs +61 -0
  28. package/src/build-tools.js +137 -0
  29. package/src/{getfbcfg → getfbcfg.js} +7 -6
  30. package/src/getjson.js +74 -0
  31. package/src/helmdn +1 -1
  32. package/src/helminit-dp +2 -0
  33. package/src/npm-scripts/postinstall.js +17 -0
  34. package/src/{overwhelm → overwhelm.js} +83 -83
  35. package/lib/server/packleate/Packleator.js +0 -280
  36. package/lib/server/packleate/index.js +0 -98
  37. package/lib/server/packleate/logo-ansi.js +0 -17
  38. package/lib/web/packleate/Packleator.js +0 -623
  39. package/lib/web/packleate/index.js +0 -163
  40. package/lib/web/packleate/logo-ansi.js +0 -3
  41. package/src/getjson +0 -48
package/package.json CHANGED
@@ -1,26 +1,31 @@
1
1
  {
2
2
  "name": "@leverege/build-tools",
3
- "version": "2.4.8",
3
+ "version": "2.5.0-beta.39",
4
4
  "description": "A collection of build / support tools for Leverege developers",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "build": "npm run compile",
8
- "compile": "rm -fr lib && npm run compile_server && npm run compile_web",
9
- "compile_server": "NODE_ENV=server babel -d lib/server src/",
8
+ "clean": "rm -rf lib",
9
+ "compile": "npm run clean && npm run compile_server && npm run compile_web",
10
+ "compile_server": "NODE_ENV=server babel -d lib/server src/ && npm run repo_init_publisher",
10
11
  "compile_web": "NODE_ENV=web babel -d lib/web src/",
11
12
  "licenseCheck": "license-checker --summary --failOn GPL",
13
+ "npm-check-updates": "npm-check-updates -i",
14
+ "postinstall": "src/npm-scripts/postinstall.js",
12
15
  "prepublintOnly": "npm run lint && npm run build",
13
16
  "prepublishOnly": "npm run compile",
17
+ "repo_init_publisher": "src/repo-init/scripts/augment-npmpublish",
14
18
  "test": "echo \"Error: no test specified\" && exit 1"
15
19
  },
16
20
  "bin": {
21
+ "build-tools": "src/build-tools.js",
17
22
  "circleate": "src/circleate",
18
23
  "decrypt-secrets": "src/decrypt-secrets",
19
24
  "dirty-git": "src/dirty-git",
20
25
  "dockreate": "src/dockreate",
21
26
  "encrypt-secrets": "src/encrypt-secrets",
22
- "getfbcfg": "src/getfbcfg",
23
- "getjson": "src/getjson",
27
+ "getfbcfg": "src/getfbcfg.js",
28
+ "getjson": "src/getjson.js",
24
29
  "git-tar": "src/git-tar",
25
30
  "helmdn": "src/helmdn",
26
31
  "helmify": "lib/server/helmify/index.js",
@@ -32,47 +37,43 @@
32
37
  "k8x": "src/k8x",
33
38
  "npm-link": "src/npm-link",
34
39
  "npm-unlink": "src/npm-unlink",
35
- "overwhelm": "src/overwhelm",
36
- "packleate": "lib/web/packleate/index.js",
40
+ "overwhelm": "src/overwhelm.js",
37
41
  "pkgck": "src/pkgck",
38
42
  "pkglint": "src/pkglint",
39
43
  "prune-git": "src/prune-git",
40
- "pull-git": "src/pull-git"
44
+ "pull-git": "src/pull-git",
45
+ "repo-init": "lib/server/repo-init/index.js"
41
46
  },
42
47
  "author": "Leverege Devs",
43
48
  "license": "SEE LICENSE IN LICENSE.md",
44
49
  "dependencies": {
45
- "async": "^3.2.0",
46
- "chalk": "^3.0.0",
50
+ "chalk": "^4.1.0",
47
51
  "clear": "^0.1.0",
52
+ "clipboardy": "^2.3.0",
48
53
  "command-line-args": "^5.1.1",
49
54
  "command-line-usage": "^6.1.0",
50
- "commander": "^2.20.3",
51
55
  "dotenv": "^8.2.0",
52
- "execa": "^4.0.2",
53
- "figlet": "^1.4.0",
54
- "fs-extra": "^8.1.0",
56
+ "execa": "^4.0.3",
57
+ "figlet": "^1.5.0",
55
58
  "git-branch": "^2.0.1",
56
59
  "glob": "^7.1.6",
57
- "inquirer": "^7.1.0",
60
+ "inquirer": "^7.3.3",
58
61
  "js-yaml": "^3.14.0",
59
- "minimist": "^1.2.5",
60
- "ora": "^3.4.0",
62
+ "ncp": "^2.0.0",
63
+ "npm-check-updates": "^7.0.2",
64
+ "npm-registry-fetch": "^8.1.3",
65
+ "open": "^7.1.0",
66
+ "ora": "^4.0.5",
61
67
  "parse-gitignore": "^1.0.1",
62
68
  "readline-sync": "^1.4.10",
63
- "recursive-copy": "^2.0.10",
64
- "regenerator-runtime": "^0.13.5",
65
- "semver": "^6.3.0",
66
- "tar": "^5.0.5"
69
+ "semver": "^7.3.2",
70
+ "simple-git": "^2.15.0"
67
71
  },
68
72
  "devDependencies": {
69
- "@babel/cli": "^7.8.4",
70
- "@babel/core": "^7.9.6",
71
- "@babel/plugin-proposal-class-properties": "^7.8.3",
72
- "@babel/plugin-proposal-optional-chaining": "^7.9.0",
73
- "@babel/preset-env": "^7.9.6",
74
- "@babel/register": "^7.9.0",
75
- "@leverege/eslint-config-leverege": "^2.0.10",
76
- "core-js": "^3.6.5"
73
+ "@babel/cli": "^7.10.5",
74
+ "@babel/core": "^7.10.5",
75
+ "@babel/node": "^7.10.5",
76
+ "@leverege/babel-preset-leverege-node": "^1.0.4",
77
+ "@leverege/eslint-config-leverege": "^2.0.10"
77
78
  }
78
79
  }
package/src/bash-funcs ADDED
@@ -0,0 +1,61 @@
1
+ #!/bin/bash
2
+ #
3
+ # A collection of bash things that have traditionally been copied around from
4
+ # script to script, which is a pain. These scripts reside in the # build-tools
5
+ # and can now be easily added to a script via bash sourcing:
6
+ # . `build-tools --bashfun`
7
+
8
+ # Simple ANSI color coded string generator.
9
+ function color() {
10
+ local color=
11
+ case "$1" in
12
+ 'g') color="92m" ;; # green
13
+ 'c') color="96m" ;; # lt blue
14
+ 'y') color="93m" ;; # yellow
15
+ 'r') color="91m" ;; # red
16
+ 'toast') color="1;3;7;91;103;5m" ;;
17
+ esac
18
+ printf "\e[$color$2\e[0m"
19
+ }
20
+
21
+ function clearlyWarn() {
22
+ [ -z "$1" ] && clear
23
+ cat<<CLEARWARN
24
+
25
+ `color y '*** WARNING *** WARNING *** WARNING *** WARNING *** WARNING *** WARNING ***'`
26
+
27
+ CLEARWARN
28
+ }
29
+
30
+ function errorExit() {
31
+ cat <<ERREXIT
32
+
33
+ `color r ***ERROR:` $1
34
+
35
+ ERREXIT
36
+ exit 1
37
+ }
38
+
39
+ function yesOrSkipToContinue() {
40
+ printf "\n Enter \"`color g yes`\" ${1}, \"`color y skip`\" to skip this step, or anything else to exit.\n\n"
41
+ read ANS
42
+ [ "$ANS" == 'yes' ] && return 0
43
+ [ "$ANS" == 'skip' ] && return 2
44
+ exit 1
45
+ }
46
+
47
+ function yesToContinue() {
48
+ printf "\n Enter \"`color g yes`\" ${1}, or anything else to exit.\n\n"
49
+ read ANS
50
+ [ "$ANS" != 'yes' ] && exit 1
51
+ }
52
+
53
+ function proceedOnEnter() {
54
+ printf " Hit `color g return` to proceed\n\n" && read ANS
55
+ }
56
+
57
+ function setOrUnset() {
58
+ local setting=`color toast "NEEDS TO BE SET"`
59
+ [ ! -z "$1" ] && setting=`color g $1`
60
+ echo "$setting"
61
+ }
@@ -0,0 +1,137 @@
1
+ #!/usr/bin/env node
2
+
3
+ const chalk = require( 'chalk' )
4
+ const cliArgs = require( 'command-line-args' )
5
+ const cliHelp = require( 'command-line-usage' )
6
+ const fs = require( 'fs' )
7
+ const npmRegistryFetch = require( 'npm-registry-fetch' )
8
+ const path = require( 'path' )
9
+ const semverLt = require( 'semver/functions/lt' )
10
+
11
+ /* eslint-disable no-console */
12
+
13
+ const optionList = [ // Use optionList to tie into the Usage statements
14
+ { name : 'root',
15
+ type : Boolean,
16
+ default : false,
17
+ description : 'returns the root of the build-tools installation',
18
+ },
19
+ { name : 'bashfun',
20
+ type : Boolean,
21
+ default : false,
22
+ descriptions : 'returns path to a script to source for common bash functions',
23
+ },
24
+ {
25
+ name : 'help',
26
+ type : Boolean,
27
+ default : false,
28
+ description : 'display this help screen',
29
+ },
30
+ { name : 'latest',
31
+ type : Boolean,
32
+ default : false,
33
+ description : 'verifies the latest build-tools are installed',
34
+ },
35
+ { name : 'version',
36
+ type : Boolean,
37
+ default : false,
38
+ description : 'returns the build-tools repo version',
39
+ },
40
+ { name : 'verbose',
41
+ alias : 'v',
42
+ type : Boolean,
43
+ default : false,
44
+ description : 'emit additional info at run time',
45
+ },
46
+ ]
47
+
48
+ const sections = [
49
+ {
50
+ header : 'Something to go in the Header',
51
+ content : 'Generate something {italic very} important.',
52
+ },
53
+ { header : 'Options',
54
+ optionList,
55
+ },
56
+ ]
57
+ const args = cliArgs( optionList, { partial : true } )
58
+ const help = cliHelp( sections )
59
+
60
+ const repoRoot = path.dirname( __dirname )
61
+ const thisPackage = require( `${repoRoot}/package.json` )
62
+ const thisVersion = thisPackage.version
63
+
64
+ if ( args.root ) {
65
+ console.log( repoRoot )
66
+ process.exit( 0 )
67
+ }
68
+
69
+ if ( args.bashfun ) {
70
+ console.log( `${repoRoot}/src/bash-funcs` )
71
+ process.exit( 0 )
72
+ }
73
+
74
+ const checkForLatest = async ( pkg = '@leverege/build-tools' ) => {
75
+ const getToken = () => {
76
+ const tokenFile = `${process.env.HOME}/.npmrc`
77
+ if ( !fs.existsSync( tokenFile ) ) {
78
+ console.error( `Cannot find token file ${tokenFile}` )
79
+ process.exit( 1 )
80
+ }
81
+ try {
82
+ const tokenLine = fs.readFileSync( tokenFile ).toString()
83
+ const tokenRegX = new RegExp( '.*registry.npmjs.org\\/:\\w+=+(.*)' )
84
+ const tokenStr = tokenLine.match( tokenRegX )
85
+ if ( !tokenStr ) {
86
+ console.error( `\n***ERROR: malformed npm token in ${tokenFile}\n` )
87
+ process.exit( 1 )
88
+ }
89
+ return tokenLine.match( tokenRegX )[1]
90
+ } catch ( err ) {
91
+ console.error( err )
92
+ }
93
+ }
94
+
95
+ try {
96
+ const list = await npmRegistryFetch.json(
97
+ pkg, { '//registry.npmjs.org/:token': getToken() }
98
+ )
99
+ return list['dist-tags'].latest
100
+ } catch ( err ) {
101
+ console.log( err )
102
+ }
103
+ }
104
+
105
+ if ( args.latest ) {
106
+ checkForLatest()
107
+ .then( ( latestVersion ) => {
108
+ if ( semverLt( thisVersion, latestVersion ) ) {
109
+ console.log(chalk.white`
110
+ Update available ${chalk.grey( thisVersion )} \u2b62 ${chalk.green( latestVersion )}
111
+ Run ${chalk.cyan( 'npm i -g @leverege/build-tools' )} to update
112
+ `
113
+ )
114
+ process.exit( 1 )
115
+ } else {
116
+ process.exit( 0 )
117
+ }
118
+ } )
119
+ .catch( ( err ) => {
120
+ } )
121
+ }
122
+
123
+ if ( args.version ) {
124
+ console.log( `build-tools version ${thisVersion}` )
125
+ process.exit( 0 )
126
+ }
127
+
128
+ if ( args.help ) {
129
+ console.log( help )
130
+ process.exit( 0 )
131
+ }
132
+
133
+ /* eslint-disable no-underscore-dangle */
134
+ if ( args._unknown ) {
135
+ console.log( `Hey Bozo, WTF am I supposed to do with ${args._unknown}?` )
136
+ process.exit( 1 )
137
+ }
@@ -3,21 +3,22 @@
3
3
  /**
4
4
  * This script parses a firebase config into something useful.
5
5
  */
6
- let stdbuf = []
6
+ const stdbuf = []
7
7
 
8
+ /* eslint-disable no-console */
8
9
  process.stdin
9
10
  .on( 'data', ( d ) => { stdbuf.push( d ) } )
10
11
  .on( 'end', () => {
11
12
  const rawCfg = stdbuf.join( '' ).replace( /["\n\r]/g, '' )
12
- const keyVals = rawCfg.match(/\{(.*)\}/)[1].split(',')
13
+ const keyVals = rawCfg.match( /\{(.*)\}/ )[1].split( ',' )
13
14
 
14
15
  const lastLine = keyVals.length - 1
15
- console.log( "{" )
16
- for( let i = 0; i <= lastLine; i++ ) {
16
+ console.log( '{' )
17
+ for ( let i = 0; i <= lastLine; i++ ) {
17
18
  const kv = keyVals[i].trim().split( ' ' )
18
- console.log( ` "${kv[0].replace( /:/, '')}": "${kv[1]}"${(i < lastLine ? ',' : '')}` )
19
+ console.log( ` "${kv[0].replace( /:/, '' )}": "${kv[1]}"${( i < lastLine ? ',' : '' )}` )
19
20
  }
20
- console.log( "}" )
21
+ console.log( '}' )
21
22
 
22
23
  } )
23
24
  .setEncoding( 'utf8' )
package/src/getjson.js ADDED
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * This script will allow the user to grab a value from a JSON file and
5
+ * optionally apply a regular expression to it. Given this test.json file:
6
+ *
7
+ * {
8
+ * "name": "@leverege/packagename",
9
+ * "main": "lib/index.js"
10
+ * }
11
+ *
12
+ * and invoking as:
13
+ * ./getjson --file ./test.json --key name --regex "^@\w{3}"
14
+ *
15
+ * will yield an output of: @lev
16
+ */
17
+
18
+ /**
19
+ * Get a command line switch parser.
20
+ */
21
+ const fs = require( 'fs' )
22
+ const cliArgs = require( 'command-line-args' )
23
+ const cliHelp = require( 'command-line-usage' )
24
+
25
+ /* eslint-disable no-console */
26
+ const optionList = [ // Use optionList to tie into the Usage statements
27
+ { name : 'file',
28
+ type : String,
29
+ alias : 'f',
30
+ description : 'file to parse JSON from',
31
+ },
32
+ {
33
+ name : 'key',
34
+ type : String,
35
+ alias : 'k',
36
+ description : 'JSON key whose value to grab',
37
+ },
38
+ {
39
+ name : 'regex',
40
+ type : String,
41
+ alias : 'r',
42
+ description : 'regular expression to apply to the value',
43
+ },
44
+ ]
45
+
46
+ const sections = [
47
+ {
48
+ header : 'JSON variable fetching script',
49
+ content :
50
+ ` This script is intended to give shell scripts a simple JSON
51
+ parsing capability.`,
52
+ },
53
+ { header : 'Options',
54
+ optionList,
55
+ },
56
+ ]
57
+ const args = cliArgs( optionList, { partial : true } )
58
+ const help = cliHelp( sections )
59
+
60
+ if ( !args.file ) {
61
+ console.error( '\n***ERROR: Missing a --file param\n' )
62
+ console.log( help )
63
+ process.exit( 1 )
64
+ }
65
+
66
+ try {
67
+ const json = JSON.parse( fs.readFileSync( args.file, 'utf8' ) )
68
+ const value = json[args.key]
69
+ const match = new RegExp( args.regex || '.*' ).exec( value )
70
+
71
+ console.log( match ? match[match.length - 1] : '' )
72
+ } catch ( e ) {
73
+ console.log( e )
74
+ }
package/src/helmdn CHANGED
@@ -102,7 +102,7 @@ NOGRESS
102
102
 
103
103
  [ "$SERVICE" == "elastic" ] && doNuking elasticsearch && continue
104
104
 
105
- helm delete --purge $SERVICE
105
+ helm delete $SERVICE
106
106
  done
107
107
  }
108
108
 
package/src/helminit-dp CHANGED
@@ -5,6 +5,7 @@ chartName=${dockerName//-/_}
5
5
 
6
6
  enableFirebase=$2
7
7
  enableBigQuery=$3
8
+ protocol=$4
8
9
 
9
10
  if [ "$enableFirebase" = true ] ; then
10
11
  firebaseVolume="
@@ -125,6 +126,7 @@ spec:
125
126
  {{- if .Values.$chartName.port }}
126
127
  - name: api
127
128
  containerPort: {{ .Values.$chartName.port }}
129
+ protocol: $protocol
128
130
  {{- end }}
129
131
  - name: node-metrics
130
132
  containerPort: 5111
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+
3
+ const execa = require( 'execa' )
4
+ const fs = require( 'fs' )
5
+
6
+ const untarConfigTarball = async ( subdir, tarball ) => {
7
+ if ( fs.existsSync( subdir ) ) {
8
+ process.chdir( subdir )
9
+ await execa( 'tar', [ 'xf', tarball ] )
10
+ }
11
+ }
12
+
13
+ const awaiter = async ( subdir, tarball) => {
14
+ await untarConfigTarball( subdir, tarball )
15
+ }
16
+
17
+ awaiter( 'lib/server/repo-init', 'config.tgz' )