@leverege/build-tools 2.16.2 → 2.17.1

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,116 @@
1
+ #!/usr/bin/env node
2
+ // https://github.com/google/zx
3
+
4
+ /* eslint-disable max-len */
5
+ "use strict";
6
+
7
+ var _enquirer = _interopRequireDefault(require("enquirer"));
8
+
9
+ var _zx = require("zx");
10
+
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+
13
+ const {
14
+ prompt
15
+ } = _enquirer.default; // This will preserve coloration from spawned child processes
16
+
17
+ process.env.FORCE_COLORS = 3;
18
+ process.env.FORCE_COLOR = '1';
19
+ let TARGET = _zx.argv._[0];
20
+ let exited = false;
21
+ const SECRETS_DIR = 'secrets';
22
+ const EXIT_EVENTS = ['SIGINT', 'exit', 'uncaughException', 'unhandledRejection'];
23
+ const [firebaserc, firebaseJson] = await Promise.all([_zx.fs.exists(_zx.path.join(process.cwd(), '.firebaserc')), _zx.fs.exists(_zx.path.join(process.cwd(), 'firebase.json'))]);
24
+
25
+ if (!firebaserc) {
26
+ console.log(_zx.chalk.red('No .firebaserc file found. Make sure that you are executing firebaseDeploy from within a firebase project directory.'));
27
+ }
28
+
29
+ if (!firebaseJson) {
30
+ console.log(_zx.chalk.red('No firebase.json file found. Make sure that you are executing firebaseDeploy from within a firebase project directory.'));
31
+ }
32
+
33
+ if (!firebaserc || !firebaseJson) {
34
+ process.exit();
35
+ }
36
+
37
+ const firebasercContent = JSON.parse(await _zx.fs.readFile(_zx.path.join(process.cwd(), '.firebaserc'), {
38
+ encoding: 'utf-8'
39
+ }));
40
+ const targets = Object.entries(firebasercContent.targets).reduce((prev, [projectId, config]) => {
41
+ Object.entries(config.hosting).forEach(([siteId, aliases]) => {
42
+ aliases.forEach(alias => {
43
+ prev[alias] = {
44
+ projectId,
45
+ siteId,
46
+ alias
47
+ };
48
+ });
49
+ });
50
+ return prev;
51
+ }, {});
52
+
53
+ if (!TARGET) {
54
+ const {
55
+ targetEnv
56
+ } = await prompt({
57
+ type: 'autocomplete',
58
+ name: 'targetEnv',
59
+ message: 'To which environment would you like to deploy?',
60
+ choices: Object.keys(targets).map(t => ({
61
+ name: t,
62
+ value: t
63
+ }))
64
+ });
65
+ TARGET = targets[targetEnv];
66
+ } else {
67
+ TARGET = targets[TARGET];
68
+ }
69
+
70
+ if (!TARGET) {
71
+ console.log(_zx.chalk.red('No such target exists in .firebaserc config.'));
72
+ process.exit();
73
+ }
74
+
75
+ const [aliasFileExists, siteIdFileExists, sharedFileExists] = await Promise.all([_zx.fs.exists(_zx.path.join(process.cwd(), SECRETS_DIR, `${TARGET.alias}.env`)), _zx.fs.exists(_zx.path.join(process.cwd(), SECRETS_DIR, `${TARGET.siteId}.env`)), _zx.fs.exists(_zx.path.join(process.cwd(), SECRETS_DIR, 'shared.env'))]);
76
+
77
+ if (!aliasFileExists && !siteIdFileExists) {
78
+ console.log(_zx.chalk.red(`No env file for ${TARGET.alias} exists. Check your secrets directory and try again`));
79
+ process.exit();
80
+ }
81
+
82
+ const exec = [];
83
+
84
+ if (sharedFileExists) {
85
+ exec.push(_zx.fs.readFile(_zx.path.join(process.cwd(), SECRETS_DIR, 'shared.env'), {
86
+ encoding: 'utf-8'
87
+ }));
88
+ }
89
+
90
+ if (aliasFileExists) {
91
+ exec.push(_zx.fs.readFile(_zx.path.join(process.cwd(), SECRETS_DIR, `${TARGET.alias}.env`), {
92
+ encoding: 'utf-8'
93
+ }));
94
+ } else {
95
+ exec.push(_zx.fs.readFile(_zx.path.join(process.cwd(), SECRETS_DIR, `${TARGET.siteId}.env`), {
96
+ encoding: 'utf-8'
97
+ }));
98
+ }
99
+
100
+ const envFileContent = (await Promise.all(exec)).join('\n');
101
+ EXIT_EVENTS.forEach(event => {
102
+ process.on(event, () => {
103
+ if (!exited) {
104
+ exited = true;
105
+
106
+ _zx.fs.removeSync(_zx.path.join(process.cwd(), '.env.temp'));
107
+ }
108
+ });
109
+ });
110
+ await _zx.fs.writeFile(_zx.path.join(process.cwd(), '.env.temp'), envFileContent);
111
+
112
+ try {
113
+ await (0, _zx.$)`npm run clean && DOTENV_CONFIG_PATH=${_zx.path.join(process.cwd(), '.env.temp')} npm run build && firebase use ${TARGET.projectId} && firebase deploy --only hosting:${TARGET.siteId}`;
114
+ } catch (err) {
115
+ console.error(err);
116
+ }
@@ -0,0 +1,126 @@
1
+ #!/usr/bin/env node
2
+ // https://github.com/google/zx
3
+
4
+ /* eslint-disable max-len */
5
+ "use strict";
6
+
7
+ var _enquirer = _interopRequireDefault(require("enquirer"));
8
+
9
+ var _zx = require("zx");
10
+
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+
13
+ const {
14
+ prompt
15
+ } = _enquirer.default; // This will preserve coloration from spawned child processes
16
+
17
+ process.env.FORCE_COLORS = 3;
18
+ process.env.FORCE_COLOR = '1';
19
+ let TARGET = _zx.argv._[0];
20
+ let exited = false;
21
+ const SECRETS_DIR = 'secrets';
22
+ const EXIT_EVENTS = ['SIGINT', 'exit', 'uncaughtException', 'unhandledRejection'];
23
+ const [firebaserc, firebaseJson] = await Promise.all([_zx.fs.exists(_zx.path.join(process.cwd(), '.firebaserc')), _zx.fs.exists(_zx.path.join(process.cwd(), 'firebase.json'))]);
24
+
25
+ if (!firebaserc) {
26
+ console.log(_zx.chalk.red('No .firebaserc file found. Make sure that you are executing firebaseDeploy from within a firebase project directory.'));
27
+ }
28
+
29
+ if (!firebaseJson) {
30
+ console.log(_zx.chalk.red('No firebase.json file found. Make sure that you are executing firebaseDeploy from within a firebase project directory.'));
31
+ }
32
+
33
+ if (!firebaserc || !firebaseJson) {
34
+ process.exit();
35
+ }
36
+
37
+ const firebasercContent = JSON.parse(await _zx.fs.readFile(_zx.path.join(process.cwd(), '.firebaserc'), {
38
+ encoding: 'utf-8'
39
+ }));
40
+ const hasLocalConfig = await _zx.fs.exists(_zx.path.join(process.cwd(), SECRETS_DIR, 'local.env'));
41
+ const defaultTargets = {};
42
+
43
+ if (hasLocalConfig) {
44
+ defaultTargets.local = {
45
+ siteId: 'local',
46
+ alias: 'local'
47
+ };
48
+ }
49
+
50
+ const targets = Object.entries(firebasercContent.targets).reduce((prev, [projectId, config]) => {
51
+ Object.entries(config.hosting).forEach(([siteId, aliases]) => {
52
+ aliases.forEach(alias => {
53
+ prev[alias] = {
54
+ projectId,
55
+ siteId,
56
+ alias
57
+ };
58
+ });
59
+ });
60
+ return prev;
61
+ }, defaultTargets);
62
+
63
+ if (!TARGET) {
64
+ const {
65
+ targetEnv
66
+ } = await prompt({
67
+ type: 'autocomplete',
68
+ name: 'targetEnv',
69
+ message: 'Which environment would you like to serve?',
70
+ choices: Object.keys(targets).map(t => ({
71
+ name: t,
72
+ value: t
73
+ }))
74
+ });
75
+ TARGET = targets[targetEnv];
76
+ } else {
77
+ TARGET = targets[TARGET];
78
+ }
79
+
80
+ if (!TARGET) {
81
+ console.log(_zx.chalk.red('No such target exists in .firebaserc config.'));
82
+ process.exit();
83
+ }
84
+
85
+ const [aliasFileExists, siteIdFileExists, sharedFileExists] = await Promise.all([_zx.fs.exists(_zx.path.join(process.cwd(), SECRETS_DIR, `${TARGET.alias}.env`)), _zx.fs.exists(_zx.path.join(process.cwd(), SECRETS_DIR, `${TARGET.siteId}.env`)), _zx.fs.exists(_zx.path.join(process.cwd(), SECRETS_DIR, 'shared.env'))]);
86
+
87
+ if (!aliasFileExists && !siteIdFileExists) {
88
+ console.log(_zx.chalk.red(`No env file for ${TARGET.alias} exists. Check your secrets directory and try again`));
89
+ process.exit();
90
+ }
91
+
92
+ const exec = [];
93
+
94
+ if (sharedFileExists) {
95
+ exec.push(_zx.fs.readFile(_zx.path.join(process.cwd(), SECRETS_DIR, 'shared.env'), {
96
+ encoding: 'utf-8'
97
+ }));
98
+ }
99
+
100
+ if (aliasFileExists) {
101
+ exec.push(_zx.fs.readFile(_zx.path.join(process.cwd(), SECRETS_DIR, `${TARGET.alias}.env`), {
102
+ encoding: 'utf-8'
103
+ }));
104
+ } else {
105
+ exec.push(_zx.fs.readFile(_zx.path.join(process.cwd(), SECRETS_DIR, `${TARGET.siteId}.env`), {
106
+ encoding: 'utf-8'
107
+ }));
108
+ }
109
+
110
+ const envFileContent = (await Promise.all(exec)).join('\n');
111
+ EXIT_EVENTS.forEach(event => {
112
+ process.on(event, () => {
113
+ if (!exited) {
114
+ exited = true;
115
+
116
+ _zx.fs.removeSync(_zx.path.join(process.cwd(), '.env.temp'));
117
+ }
118
+ });
119
+ });
120
+ await _zx.fs.writeFile(_zx.path.join(process.cwd(), '.env.temp'), envFileContent);
121
+
122
+ try {
123
+ await (0, _zx.$)`DOTENV_CONFIG_PATH=${_zx.path.join(process.cwd(), '.env.temp')} npm run serve --colors`;
124
+ } catch (err) {
125
+ console.error(err);
126
+ }
Binary file
@@ -0,0 +1,116 @@
1
+ #!/usr/bin/env node
2
+ // https://github.com/google/zx
3
+
4
+ /* eslint-disable max-len */
5
+ "use strict";
6
+
7
+ var _enquirer = _interopRequireDefault(require("enquirer"));
8
+
9
+ var _zx = require("zx");
10
+
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+
13
+ const {
14
+ prompt
15
+ } = _enquirer.default; // This will preserve coloration from spawned child processes
16
+
17
+ process.env.FORCE_COLORS = 3;
18
+ process.env.FORCE_COLOR = '1';
19
+ let TARGET = _zx.argv._[0];
20
+ let exited = false;
21
+ const SECRETS_DIR = 'secrets';
22
+ const EXIT_EVENTS = ['SIGINT', 'exit', 'uncaughException', 'unhandledRejection'];
23
+ const [firebaserc, firebaseJson] = await Promise.all([_zx.fs.exists(_zx.path.join(process.cwd(), '.firebaserc')), _zx.fs.exists(_zx.path.join(process.cwd(), 'firebase.json'))]);
24
+
25
+ if (!firebaserc) {
26
+ console.log(_zx.chalk.red('No .firebaserc file found. Make sure that you are executing firebaseDeploy from within a firebase project directory.'));
27
+ }
28
+
29
+ if (!firebaseJson) {
30
+ console.log(_zx.chalk.red('No firebase.json file found. Make sure that you are executing firebaseDeploy from within a firebase project directory.'));
31
+ }
32
+
33
+ if (!firebaserc || !firebaseJson) {
34
+ process.exit();
35
+ }
36
+
37
+ const firebasercContent = JSON.parse(await _zx.fs.readFile(_zx.path.join(process.cwd(), '.firebaserc'), {
38
+ encoding: 'utf-8'
39
+ }));
40
+ const targets = Object.entries(firebasercContent.targets).reduce((prev, [projectId, config]) => {
41
+ Object.entries(config.hosting).forEach(([siteId, aliases]) => {
42
+ aliases.forEach(alias => {
43
+ prev[alias] = {
44
+ projectId,
45
+ siteId,
46
+ alias
47
+ };
48
+ });
49
+ });
50
+ return prev;
51
+ }, {});
52
+
53
+ if (!TARGET) {
54
+ const {
55
+ targetEnv
56
+ } = await prompt({
57
+ type: 'autocomplete',
58
+ name: 'targetEnv',
59
+ message: 'To which environment would you like to deploy?',
60
+ choices: Object.keys(targets).map(t => ({
61
+ name: t,
62
+ value: t
63
+ }))
64
+ });
65
+ TARGET = targets[targetEnv];
66
+ } else {
67
+ TARGET = targets[TARGET];
68
+ }
69
+
70
+ if (!TARGET) {
71
+ console.log(_zx.chalk.red('No such target exists in .firebaserc config.'));
72
+ process.exit();
73
+ }
74
+
75
+ const [aliasFileExists, siteIdFileExists, sharedFileExists] = await Promise.all([_zx.fs.exists(_zx.path.join(process.cwd(), SECRETS_DIR, `${TARGET.alias}.env`)), _zx.fs.exists(_zx.path.join(process.cwd(), SECRETS_DIR, `${TARGET.siteId}.env`)), _zx.fs.exists(_zx.path.join(process.cwd(), SECRETS_DIR, 'shared.env'))]);
76
+
77
+ if (!aliasFileExists && !siteIdFileExists) {
78
+ console.log(_zx.chalk.red(`No env file for ${TARGET.alias} exists. Check your secrets directory and try again`));
79
+ process.exit();
80
+ }
81
+
82
+ const exec = [];
83
+
84
+ if (sharedFileExists) {
85
+ exec.push(_zx.fs.readFile(_zx.path.join(process.cwd(), SECRETS_DIR, 'shared.env'), {
86
+ encoding: 'utf-8'
87
+ }));
88
+ }
89
+
90
+ if (aliasFileExists) {
91
+ exec.push(_zx.fs.readFile(_zx.path.join(process.cwd(), SECRETS_DIR, `${TARGET.alias}.env`), {
92
+ encoding: 'utf-8'
93
+ }));
94
+ } else {
95
+ exec.push(_zx.fs.readFile(_zx.path.join(process.cwd(), SECRETS_DIR, `${TARGET.siteId}.env`), {
96
+ encoding: 'utf-8'
97
+ }));
98
+ }
99
+
100
+ const envFileContent = (await Promise.all(exec)).join('\n');
101
+ EXIT_EVENTS.forEach(event => {
102
+ process.on(event, () => {
103
+ if (!exited) {
104
+ exited = true;
105
+
106
+ _zx.fs.removeSync(_zx.path.join(process.cwd(), '.env.temp'));
107
+ }
108
+ });
109
+ });
110
+ await _zx.fs.writeFile(_zx.path.join(process.cwd(), '.env.temp'), envFileContent);
111
+
112
+ try {
113
+ await (0, _zx.$)`npm run clean && DOTENV_CONFIG_PATH=${_zx.path.join(process.cwd(), '.env.temp')} npm run build && firebase use ${TARGET.projectId} && firebase deploy --only hosting:${TARGET.siteId}`;
114
+ } catch (err) {
115
+ console.error(err);
116
+ }
@@ -0,0 +1,126 @@
1
+ #!/usr/bin/env node
2
+ // https://github.com/google/zx
3
+
4
+ /* eslint-disable max-len */
5
+ "use strict";
6
+
7
+ var _enquirer = _interopRequireDefault(require("enquirer"));
8
+
9
+ var _zx = require("zx");
10
+
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+
13
+ const {
14
+ prompt
15
+ } = _enquirer.default; // This will preserve coloration from spawned child processes
16
+
17
+ process.env.FORCE_COLORS = 3;
18
+ process.env.FORCE_COLOR = '1';
19
+ let TARGET = _zx.argv._[0];
20
+ let exited = false;
21
+ const SECRETS_DIR = 'secrets';
22
+ const EXIT_EVENTS = ['SIGINT', 'exit', 'uncaughtException', 'unhandledRejection'];
23
+ const [firebaserc, firebaseJson] = await Promise.all([_zx.fs.exists(_zx.path.join(process.cwd(), '.firebaserc')), _zx.fs.exists(_zx.path.join(process.cwd(), 'firebase.json'))]);
24
+
25
+ if (!firebaserc) {
26
+ console.log(_zx.chalk.red('No .firebaserc file found. Make sure that you are executing firebaseDeploy from within a firebase project directory.'));
27
+ }
28
+
29
+ if (!firebaseJson) {
30
+ console.log(_zx.chalk.red('No firebase.json file found. Make sure that you are executing firebaseDeploy from within a firebase project directory.'));
31
+ }
32
+
33
+ if (!firebaserc || !firebaseJson) {
34
+ process.exit();
35
+ }
36
+
37
+ const firebasercContent = JSON.parse(await _zx.fs.readFile(_zx.path.join(process.cwd(), '.firebaserc'), {
38
+ encoding: 'utf-8'
39
+ }));
40
+ const hasLocalConfig = await _zx.fs.exists(_zx.path.join(process.cwd(), SECRETS_DIR, 'local.env'));
41
+ const defaultTargets = {};
42
+
43
+ if (hasLocalConfig) {
44
+ defaultTargets.local = {
45
+ siteId: 'local',
46
+ alias: 'local'
47
+ };
48
+ }
49
+
50
+ const targets = Object.entries(firebasercContent.targets).reduce((prev, [projectId, config]) => {
51
+ Object.entries(config.hosting).forEach(([siteId, aliases]) => {
52
+ aliases.forEach(alias => {
53
+ prev[alias] = {
54
+ projectId,
55
+ siteId,
56
+ alias
57
+ };
58
+ });
59
+ });
60
+ return prev;
61
+ }, defaultTargets);
62
+
63
+ if (!TARGET) {
64
+ const {
65
+ targetEnv
66
+ } = await prompt({
67
+ type: 'autocomplete',
68
+ name: 'targetEnv',
69
+ message: 'Which environment would you like to serve?',
70
+ choices: Object.keys(targets).map(t => ({
71
+ name: t,
72
+ value: t
73
+ }))
74
+ });
75
+ TARGET = targets[targetEnv];
76
+ } else {
77
+ TARGET = targets[TARGET];
78
+ }
79
+
80
+ if (!TARGET) {
81
+ console.log(_zx.chalk.red('No such target exists in .firebaserc config.'));
82
+ process.exit();
83
+ }
84
+
85
+ const [aliasFileExists, siteIdFileExists, sharedFileExists] = await Promise.all([_zx.fs.exists(_zx.path.join(process.cwd(), SECRETS_DIR, `${TARGET.alias}.env`)), _zx.fs.exists(_zx.path.join(process.cwd(), SECRETS_DIR, `${TARGET.siteId}.env`)), _zx.fs.exists(_zx.path.join(process.cwd(), SECRETS_DIR, 'shared.env'))]);
86
+
87
+ if (!aliasFileExists && !siteIdFileExists) {
88
+ console.log(_zx.chalk.red(`No env file for ${TARGET.alias} exists. Check your secrets directory and try again`));
89
+ process.exit();
90
+ }
91
+
92
+ const exec = [];
93
+
94
+ if (sharedFileExists) {
95
+ exec.push(_zx.fs.readFile(_zx.path.join(process.cwd(), SECRETS_DIR, 'shared.env'), {
96
+ encoding: 'utf-8'
97
+ }));
98
+ }
99
+
100
+ if (aliasFileExists) {
101
+ exec.push(_zx.fs.readFile(_zx.path.join(process.cwd(), SECRETS_DIR, `${TARGET.alias}.env`), {
102
+ encoding: 'utf-8'
103
+ }));
104
+ } else {
105
+ exec.push(_zx.fs.readFile(_zx.path.join(process.cwd(), SECRETS_DIR, `${TARGET.siteId}.env`), {
106
+ encoding: 'utf-8'
107
+ }));
108
+ }
109
+
110
+ const envFileContent = (await Promise.all(exec)).join('\n');
111
+ EXIT_EVENTS.forEach(event => {
112
+ process.on(event, () => {
113
+ if (!exited) {
114
+ exited = true;
115
+
116
+ _zx.fs.removeSync(_zx.path.join(process.cwd(), '.env.temp'));
117
+ }
118
+ });
119
+ });
120
+ await _zx.fs.writeFile(_zx.path.join(process.cwd(), '.env.temp'), envFileContent);
121
+
122
+ try {
123
+ await (0, _zx.$)`DOTENV_CONFIG_PATH=${_zx.path.join(process.cwd(), '.env.temp')} npm run serve --colors`;
124
+ } catch (err) {
125
+ console.error(err);
126
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leverege/build-tools",
3
- "version": "2.16.2",
3
+ "version": "2.17.1",
4
4
  "description": "A collection of build / support tools for Leverege developers",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -44,7 +44,9 @@
44
44
  "pull-git": "src/pull-git",
45
45
  "push-my-chart": "src/push-my-chart",
46
46
  "repo-init": "lib/server/repo-init/index.js",
47
- "unleash": "src/unleash.js"
47
+ "unleash": "src/unleash.js",
48
+ "firebaseDeploy": "src/firebaseDeploy.mjs",
49
+ "firebaseServe": "src/firebaseServe.mjs"
48
50
  },
49
51
  "author": "Leverege Devs",
50
52
  "license": "SEE LICENSE IN LICENSE.md",
@@ -54,26 +56,30 @@
54
56
  "command-line-args": "^5.2.1",
55
57
  "command-line-usage": "^6.1.3",
56
58
  "deepmerge": "^4.2.2",
59
+ "dotenv": "^16.0.1",
60
+ "enquirer": "^2.3.6",
57
61
  "execa": "^5.1.1",
58
62
  "figlet": "^1.5.2",
59
63
  "glob": "^7.2.3",
60
64
  "inquirer": "^8.2.4",
61
65
  "js-yaml": "^4.1.0",
62
66
  "ncp": "^2.0.0",
67
+ "npm-check-updates": "^13.1.2",
63
68
  "npm-registry-fetch": "^11.0.0",
64
69
  "open": "^8.4.0",
65
70
  "ora": "^5.4.1",
66
71
  "parse-gitignore": "^1.0.1",
67
72
  "readline-sync": "^1.4.10",
68
73
  "semver": "^7.3.7",
69
- "simple-git": "^3.10.0"
74
+ "simple-git": "^3.7.1",
75
+ "zx": "^7.0.2"
70
76
  },
71
77
  "devDependencies": {
72
- "@babel/cli": "^7.18.6",
73
- "@babel/core": "^7.18.6",
74
- "@babel/node": "^7.18.6",
78
+ "@babel/cli": "^7.17.10",
79
+ "@babel/core": "^7.18.5",
80
+ "@babel/node": "^7.18.5",
75
81
  "@leverege/babel-preset-leverege-node": "^2.0.0",
76
82
  "@leverege/eslint-config-leverege": "^3.0.1",
77
- "npm": "^8.13.2"
83
+ "npm": "^8.13.1"
78
84
  }
79
85
  }
package/src/bash-funcs CHANGED
@@ -95,6 +95,8 @@ INSTALLING
95
95
  }
96
96
 
97
97
  function addHelmRepo() {
98
+ [ ! -z "$HELM_REPO_SKIP" ] && return
99
+
98
100
  local chart=$1
99
101
  local url=$2
100
102
 
@@ -107,6 +109,6 @@ REPOADD
107
109
  }
108
110
 
109
111
  function removeHelmRepo(){
110
- [ ! -z "$SKIP_RM_HELM_REPO" ] && return
112
+ [ ! -z "$HELM_REPO_SKIP" ] && return
111
113
  helm repo remove $1 &>/dev/null
112
114
  }
@@ -0,0 +1,118 @@
1
+ #!/usr/bin/env node
2
+ // https://github.com/google/zx
3
+ /* eslint-disable max-len */
4
+ import pkg from 'enquirer'
5
+ import { $, fs, argv, path, chalk } from 'zx'
6
+
7
+ const { prompt } = pkg
8
+
9
+ // This will preserve coloration from spawned child processes
10
+ process.env.FORCE_COLORS = 3
11
+ process.env.FORCE_COLOR = '1'
12
+
13
+ let TARGET = argv._[0]
14
+ let exited = false
15
+
16
+ const SECRETS_DIR = 'secrets'
17
+ const EXIT_EVENTS = [ 'SIGINT', 'exit', 'uncaughException', 'unhandledRejection' ]
18
+
19
+ const [
20
+ firebaserc,
21
+ firebaseJson
22
+ ] = await Promise.all( [
23
+ fs.exists( path.join( process.cwd(), '.firebaserc' ) ),
24
+ fs.exists( path.join( process.cwd(), 'firebase.json' ) )
25
+ ] )
26
+
27
+ if ( !firebaserc ) {
28
+ console.log( chalk.red( 'No .firebaserc file found. Make sure that you are executing firebaseDeploy from within a firebase project directory.' ) )
29
+ }
30
+
31
+ if ( !firebaseJson ) {
32
+ console.log( chalk.red( 'No firebase.json file found. Make sure that you are executing firebaseDeploy from within a firebase project directory.' ) )
33
+ }
34
+
35
+ if ( !firebaserc || !firebaseJson ) {
36
+ process.exit()
37
+ }
38
+
39
+ const firebasercContent = JSON.parse( await fs.readFile( path.join( process.cwd(), '.firebaserc' ), { encoding : 'utf-8' } ) )
40
+
41
+ const targets = Object
42
+ .entries( firebasercContent.targets )
43
+ .reduce( ( prev, [ projectId, config ] ) => {
44
+ Object
45
+ .entries( config.hosting )
46
+ .forEach( ( [ siteId, aliases ] ) => {
47
+ aliases.forEach( ( alias ) => {
48
+ prev[alias] = {
49
+ projectId,
50
+ siteId,
51
+ alias
52
+ }
53
+ } )
54
+ } )
55
+
56
+ return prev
57
+ }, {} )
58
+
59
+ if ( !TARGET ) {
60
+ const { targetEnv } = await prompt( {
61
+ type : 'autocomplete',
62
+ name : 'targetEnv',
63
+ message : 'To which environment would you like to deploy?',
64
+ choices : Object.keys( targets ).map( t => ( { name : t, value : t } ) )
65
+ } )
66
+
67
+ TARGET = targets[targetEnv]
68
+ } else {
69
+ TARGET = targets[TARGET]
70
+ }
71
+
72
+ if ( !TARGET ) {
73
+ console.log( chalk.red( 'No such target exists in .firebaserc config.' ) )
74
+ process.exit()
75
+ }
76
+
77
+ const [ aliasFileExists, siteIdFileExists, sharedFileExists ] = await Promise.all( [
78
+ fs.exists( path.join( process.cwd(), SECRETS_DIR, `${TARGET.alias}.env` ) ),
79
+ fs.exists( path.join( process.cwd(), SECRETS_DIR, `${TARGET.siteId}.env` ) ),
80
+ fs.exists( path.join( process.cwd(), SECRETS_DIR, 'shared.env' ) )
81
+ ] )
82
+
83
+ if ( !aliasFileExists && !siteIdFileExists ) {
84
+ console.log( chalk.red( `No env file for ${TARGET.alias} exists. Check your secrets directory and try again` ) )
85
+ process.exit()
86
+ }
87
+
88
+ const exec = []
89
+
90
+ if ( sharedFileExists ) {
91
+ exec.push( fs.readFile( path.join( process.cwd(), SECRETS_DIR, 'shared.env' ), { encoding : 'utf-8' } ) )
92
+ }
93
+
94
+ if ( aliasFileExists ) {
95
+ exec.push( fs.readFile( path.join( process.cwd(), SECRETS_DIR, `${TARGET.alias}.env` ), { encoding : 'utf-8' } ) )
96
+ } else {
97
+ exec.push( fs.readFile( path.join( process.cwd(), SECRETS_DIR, `${TARGET.siteId}.env` ), { encoding : 'utf-8' } ) )
98
+ }
99
+
100
+ const envFileContent = ( await Promise.all( exec ) ).join( '\n' )
101
+
102
+ EXIT_EVENTS
103
+ .forEach( ( event ) => {
104
+ process.on( event, () => {
105
+ if ( !exited ) {
106
+ exited = true
107
+ fs.removeSync( path.join( process.cwd(), '.env.temp' ) )
108
+ }
109
+ } )
110
+ } )
111
+
112
+ await fs.writeFile( path.join( process.cwd(), '.env.temp' ), envFileContent )
113
+
114
+ try {
115
+ await $`npm run clean && DOTENV_CONFIG_PATH=${path.join( process.cwd(), '.env.temp' )} npm run build && firebase use ${TARGET.projectId} && firebase deploy --only hosting:${TARGET.siteId}`
116
+ } catch ( err ) {
117
+ console.error( err )
118
+ }
@@ -0,0 +1,127 @@
1
+ #!/usr/bin/env node
2
+ // https://github.com/google/zx
3
+ /* eslint-disable max-len */
4
+ import pkg from 'enquirer'
5
+ import { $, fs, argv, path, chalk } from 'zx'
6
+
7
+ const { prompt } = pkg
8
+
9
+ // This will preserve coloration from spawned child processes
10
+ process.env.FORCE_COLORS = 3
11
+ process.env.FORCE_COLOR = '1'
12
+
13
+ let TARGET = argv._[0]
14
+ let exited = false
15
+
16
+ const SECRETS_DIR = 'secrets'
17
+ const EXIT_EVENTS = [ 'SIGINT', 'exit', 'uncaughtException', 'unhandledRejection' ]
18
+
19
+ const [
20
+ firebaserc,
21
+ firebaseJson
22
+ ] = await Promise.all( [
23
+ fs.exists( path.join( process.cwd(), '.firebaserc' ) ),
24
+ fs.exists( path.join( process.cwd(), 'firebase.json' ) )
25
+ ] )
26
+
27
+ if ( !firebaserc ) {
28
+ console.log( chalk.red( 'No .firebaserc file found. Make sure that you are executing firebaseDeploy from within a firebase project directory.' ) )
29
+ }
30
+
31
+ if ( !firebaseJson ) {
32
+ console.log( chalk.red( 'No firebase.json file found. Make sure that you are executing firebaseDeploy from within a firebase project directory.' ) )
33
+ }
34
+
35
+ if ( !firebaserc || !firebaseJson ) {
36
+ process.exit()
37
+ }
38
+
39
+ const firebasercContent = JSON.parse( await fs.readFile( path.join( process.cwd(), '.firebaserc' ), { encoding : 'utf-8' } ) )
40
+ const hasLocalConfig = await fs.exists( path.join( process.cwd(), SECRETS_DIR, 'local.env' ) )
41
+ const defaultTargets = {}
42
+
43
+ if ( hasLocalConfig ) {
44
+ defaultTargets.local = {
45
+ siteId : 'local',
46
+ alias : 'local'
47
+ }
48
+ }
49
+
50
+ const targets = Object
51
+ .entries( firebasercContent.targets )
52
+ .reduce( ( prev, [ projectId, config ] ) => {
53
+ Object
54
+ .entries( config.hosting )
55
+ .forEach( ( [ siteId, aliases ] ) => {
56
+ aliases.forEach( ( alias ) => {
57
+ prev[alias] = {
58
+ projectId,
59
+ siteId,
60
+ alias
61
+ }
62
+ } )
63
+ } )
64
+
65
+ return prev
66
+ }, defaultTargets )
67
+
68
+ if ( !TARGET ) {
69
+ const { targetEnv } = await prompt( {
70
+ type : 'autocomplete',
71
+ name : 'targetEnv',
72
+ message : 'Which environment would you like to serve?',
73
+ choices : Object.keys( targets ).map( t => ( { name : t, value : t } ) )
74
+ } )
75
+
76
+ TARGET = targets[targetEnv]
77
+ } else {
78
+ TARGET = targets[TARGET]
79
+ }
80
+
81
+ if ( !TARGET ) {
82
+ console.log( chalk.red( 'No such target exists in .firebaserc config.' ) )
83
+ process.exit()
84
+ }
85
+
86
+ const [ aliasFileExists, siteIdFileExists, sharedFileExists ] = await Promise.all( [
87
+ fs.exists( path.join( process.cwd(), SECRETS_DIR, `${TARGET.alias}.env` ) ),
88
+ fs.exists( path.join( process.cwd(), SECRETS_DIR, `${TARGET.siteId}.env` ) ),
89
+ fs.exists( path.join( process.cwd(), SECRETS_DIR, 'shared.env' ) )
90
+ ] )
91
+
92
+ if ( !aliasFileExists && !siteIdFileExists ) {
93
+ console.log( chalk.red( `No env file for ${TARGET.alias} exists. Check your secrets directory and try again` ) )
94
+ process.exit()
95
+ }
96
+
97
+ const exec = []
98
+
99
+ if ( sharedFileExists ) {
100
+ exec.push( fs.readFile( path.join( process.cwd(), SECRETS_DIR, 'shared.env' ), { encoding : 'utf-8' } ) )
101
+ }
102
+
103
+ if ( aliasFileExists ) {
104
+ exec.push( fs.readFile( path.join( process.cwd(), SECRETS_DIR, `${TARGET.alias}.env` ), { encoding : 'utf-8' } ) )
105
+ } else {
106
+ exec.push( fs.readFile( path.join( process.cwd(), SECRETS_DIR, `${TARGET.siteId}.env` ), { encoding : 'utf-8' } ) )
107
+ }
108
+
109
+ const envFileContent = ( await Promise.all( exec ) ).join( '\n' )
110
+
111
+ EXIT_EVENTS
112
+ .forEach( ( event ) => {
113
+ process.on( event, () => {
114
+ if ( !exited ) {
115
+ exited = true
116
+ fs.removeSync( path.join( process.cwd(), '.env.temp' ) )
117
+ }
118
+ } )
119
+ } )
120
+
121
+ await fs.writeFile( path.join( process.cwd(), '.env.temp' ), envFileContent )
122
+
123
+ try {
124
+ await $`DOTENV_CONFIG_PATH=${path.join( process.cwd(), '.env.temp' )} npm run serve --colors`
125
+ } catch ( err ) {
126
+ console.error( err )
127
+ }
package/src/helmup CHANGED
@@ -140,13 +140,13 @@ function createNamespaceIfNeeded(){
140
140
  function installPrometheus() {
141
141
  # Add the community helm repositories
142
142
  addHelmRepo prometheus-community https://prometheus-community.github.io/helm-charts
143
- [ -z "$PROMETHEUS_HELM_CHART" ] && PROMETHEUS_HELM_CHART="13"
143
+
144
144
  helm upgrade --install prometheus prometheus-community/prometheus \
145
145
  --namespace monitoring \
146
146
  --values prometheus/values.yaml \
147
- --version $PROMETHEUS_HELM_CHART
147
+ --version 13
148
148
 
149
- removeHelmRepo prometheus-community
149
+ # removeHelmRepo prometheus-community
150
150
  }
151
151
 
152
152
  function installRedis() {
@@ -208,17 +208,6 @@ replica:
208
208
  values:
209
209
  - database
210
210
  REDIS_CHART_MODS
211
- if [[ $? -ne 0 ]];
212
- then
213
- clearlyWarn noclear
214
- cat<<OLDER_REDIS
215
- The redis upgrade failed which may mean that the versions are different
216
- enough that k8s cannot gracefully upgrade from one version to the next.
217
- Try removing the existing deployment and redeploying redis:
218
-
219
- $ `color r "helmdn redis && sleep 5 && helmup redis"`
220
- OLDER_REDIS
221
- fi
222
211
  printf "\n\nTo start a specific version => `color g 'REDIS_HELM_CHART="13.0.1" helmup redis'`\n\n"
223
212
  removeHelmRepo bitnami
224
213
  }
@@ -389,7 +378,7 @@ function getManagedSecret() {
389
378
 
390
379
  # https://github.com/estafette/estafette-gke-preemptible-killer
391
380
  function installPreemptibleKiller() {
392
- showInstalling "Preemptible Node Killing Coordinator"
381
+ showInstalling "Preemptible Node Killing Adjusticator"
393
382
  NAMESPACE="estafette"
394
383
  PROJECT_ID="$(getProjectIdFromK8sContext)"
395
384
  SVC_ACCT="preemptible-killer"
@@ -726,7 +715,7 @@ function installVelero() {
726
715
  ## Helpful debugging link => https://github.com/vmware-tanzu/helm-charts/issues/351
727
716
  addHelmRepo vmware-tanzu https://vmware-tanzu.github.io/helm-charts
728
717
  helm upgrade --install velero vmware-tanzu/velero \
729
- --version 2 \
718
+ --version 2.29 \
730
719
  --namespace velero \
731
720
  --set credentials.useSecret="false" \
732
721
  --set configuration.provider="gcp" \