@leverege/build-tools 2.21.9-nick.4 → 2.21.10

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.
@@ -20,7 +20,7 @@ let CHANNEL;
20
20
 
21
21
  // A single unnamed parameter is assumed to be a deploy target.
22
22
  // If named parameters exist, they may not be stored in argv,
23
- // so don't use the length of argv to decide whether to look for them
23
+ // so don't look for a larger length of argv to decide whether to look for named paramters
24
24
  if (_zx.argv._.length === 1) {
25
25
  TARGET = _zx.argv._[0];
26
26
  } else {
@@ -31,6 +31,9 @@ if (_zx.argv._.length === 1) {
31
31
  CHANNEL.expiration = _zx.argv.channelExpiration ?? '7d';
32
32
  }
33
33
  }
34
+
35
+ // If target has not been defined on the command line,
36
+ // then enter interactive mode
34
37
  const INTERACTIVE_MODE = !TARGET;
35
38
  let exited = false;
36
39
  const SECRETS_DIR = 'secrets';
@@ -50,7 +53,9 @@ const firebasercContent = JSON.parse(await _zx.fs.readFile(_zx.path.join(process
50
53
  }));
51
54
 
52
55
  // If in a git repo, fetch the name of the git branch to use as a default
53
- // name in case a deployment channel is needed
56
+ // name in case a deployment channel is needed. Examining this file directly
57
+ // is less cumbersome then running an actual git command to fetch the
58
+ // branch name
54
59
  let gitBranch;
55
60
  if (git) {
56
61
  const gitContent = (await _zx.fs.readFile(_zx.path.join(process.cwd(), '.git/HEAD'), {
@@ -58,11 +63,12 @@ if (git) {
58
63
  }))?.split('/');
59
64
  gitBranch = gitContent[gitContent?.length - 1]?.trimEnd('\n');
60
65
  }
61
- let maxPadding = 0;
62
- const targets = Object.entries(firebasercContent.targets).reduce((prev, [projectId, config, production]) => {
63
- Object.entries(config.hosting).forEach(([siteId, aliases, production]) => {
66
+ let maxSiteIdLength = 0;
67
+ const targets = Object.entries(firebasercContent.targets).reduce((prev, [projectId, config]) => {
68
+ Object.entries(config.hosting).forEach(([siteId, aliases]) => {
64
69
  aliases.forEach(alias => {
65
- maxPadding = Math.max(siteId.length, maxPadding);
70
+ // Store the longest length of site id for formatting later on
71
+ maxSiteIdLength = Math.max(siteId.length, maxSiteIdLength);
66
72
  prev[alias] = {
67
73
  projectId,
68
74
  siteId,
@@ -83,7 +89,7 @@ if (INTERACTIVE_MODE) {
83
89
  choices: Object.values(targets).map(t => {
84
90
  const productionLabel = t.production ? _ansiColors.default.bold.red('--PRODUCTION--') : '';
85
91
  return {
86
- message: `${_ansiColors.default.bold.cyan('Site: ')}${t.siteId.padEnd(maxPadding)} ${_ansiColors.default.bold.green('Project: ')}${t.projectId} ${productionLabel}`,
92
+ message: `${_ansiColors.default.bold.cyan('Site: ')}${t.siteId.padEnd(maxSiteIdLength)} ${_ansiColors.default.bold.green('Project: ')}${t.projectId} ${productionLabel}`,
87
93
  value: t.alias
88
94
  };
89
95
  })
@@ -156,14 +162,15 @@ if (aliasFileExists) {
156
162
  encoding: 'utf-8'
157
163
  }));
158
164
  }
165
+ console.log(`\n\n\n${_ansiColors.default.bold.green('====== Deployment Summary ======')}`);
166
+ console.log(`${_ansiColors.default.blue('Firebase project:')} ${TARGET.projectId} ${TARGET.production ? _ansiColors.default.yellow('--PRODUCTION--') : ''}`);
167
+ console.log(`${_ansiColors.default.blue('Site ID:')} ${TARGET.siteId}`);
168
+ console.log(`${_ansiColors.default.blue('Channel Name:')} ${CHANNEL?.name ?? _ansiColors.default.italic.gray('(none)')}`);
169
+ console.log(`${_ansiColors.default.blue('Channel Expiration date:')} ${CHANNEL?.name ? CHANNEL.expiration ?? _ansiColors.default.italic.gray('(none)') : _ansiColors.default.italic.gray('(n/a)')}`);
170
+ console.log(`${_ansiColors.default.blue('Shared .env file:')} ${sharedFileExists ? `${SECRETS_DIR}/shared.env` : _ansiColors.default.italic.gray('(none)')}`);
171
+ console.log(`${_ansiColors.default.blue('Additional .env overrides:')} ${aliasFileExists ? `${SECRETS_DIR}/${TARGET.alias}.env` : `${SECRETS_DIR}/${TARGET.siteId}.env`}`);
172
+ console.log(`${_ansiColors.default.bold.green('===============================')}`);
159
173
  if (INTERACTIVE_MODE) {
160
- console.log(`\n\n\n${_ansiColors.default.bold.green('====== Deployment Summary ======')}`);
161
- console.log(`${_ansiColors.default.blue('Firebase project:')} ${TARGET.projectId} ${TARGET.production ? _ansiColors.default.yellow('--PRODUCTION--') : ''}`);
162
- console.log(`${_ansiColors.default.blue('Site ID:')} ${TARGET.siteId}`);
163
- console.log(`${_ansiColors.default.blue('Channel Name:')} ${CHANNEL?.name ?? _ansiColors.default.italic.gray('(none)')}`);
164
- console.log(`${_ansiColors.default.blue('Channel Expiration date:')} ${CHANNEL?.name ? CHANNEL.expiration ?? _ansiColors.default.italic.gray('(none)') : _ansiColors.default.italic.gray('(n/a)')}`);
165
- console.log(`${_ansiColors.default.blue('Shared .env file:')} ${sharedFileExists ? `${SECRETS_DIR}/shared.env` : _ansiColors.default.italic.gray('(none)')}`);
166
- console.log(`${_ansiColors.default.blue('Additional .env overrides:')} ${aliasFileExists ? `${SECRETS_DIR}/${TARGET.alias}.env` : `${SECRETS_DIR}/${TARGET.siteId}.env`}`);
167
174
  const {
168
175
  confirmSelections
169
176
  } = await prompt([{
@@ -187,6 +194,7 @@ EXIT_EVENTS.forEach(event => {
187
194
  });
188
195
  await _zx.fs.writeFile(_zx.path.join(process.cwd(), '.env.temp'), envFileContent);
189
196
  try {
197
+ // deploying to a channel requires slightly different parameter structure
190
198
  const deployType = CHANNEL ? `hosting:channel:deploy ${CHANNEL.name} ${CHANNEL.expiration ? `--expires ${CHANNEL.expiration}` : ''}`.split(' ') : 'deploy';
191
199
  const hostingPrefix = CHANNEL ? '' : 'hosting:';
192
200
  await (0, _zx.$)`npm run clean && DOTENV_CONFIG_PATH=${_zx.path.join(process.cwd(), '.env.temp')} npm run build && firebase use ${TARGET.projectId} && firebase ${deployType} --only ${hostingPrefix}${TARGET.siteId}`;
@@ -1,8 +1,10 @@
1
1
  #!/usr/bin/env node
2
+ "use strict";
2
3
 
4
+ console.log(`TOP=>[${process.cwd()}] PWD=[${process.env.PWD}]`);
3
5
  /* eslint-disable no-console */
4
- "use strict";
5
6
 
7
+ const path = require('node:path');
6
8
  const chalk = require('chalk');
7
9
  const cliArgs = require('command-line-args');
8
10
  // const cliHelp = require( 'command-line-usage' )
@@ -69,11 +71,21 @@ const optionsDefinitions = [/* eslint-disable no-multi-spaces */
69
71
 
70
72
  const args = cliArgs(optionsDefinitions);
71
73
 
74
+ // See if we are in a monorepo, which changes some of the rules.
75
+ const gitTop = exec('git rev-parse --show-toplevel', {
76
+ stdio: [undefined]
77
+ }).toString().trim();
78
+ let monoTop;
79
+ if (fs.existsSync(`${gitTop}/packages`)) {
80
+ monoTop = path.basename(path.resolve()); // process.env.PWD
81
+ console.log(`MONO=[${monoTop}]`);
82
+ }
83
+
72
84
  // The kubernetes context is equal to the git branch name.
73
85
  const gitBranch = exec('git rev-parse --abbrev-ref HEAD', {
74
86
  stdio: [undefined]
75
87
  }).toString().trim();
76
- const context = args.context || gitBranch;
88
+ const context = args.context || monoTop || gitBranch;
77
89
  if (context === 'master') {
78
90
  console.log('***ERROR: master context is forbidden; change to a different branch\n\n');
79
91
  process.exit(1);
@@ -20,7 +20,7 @@ let CHANNEL;
20
20
 
21
21
  // A single unnamed parameter is assumed to be a deploy target.
22
22
  // If named parameters exist, they may not be stored in argv,
23
- // so don't use the length of argv to decide whether to look for them
23
+ // so don't look for a larger length of argv to decide whether to look for named paramters
24
24
  if (_zx.argv._.length === 1) {
25
25
  TARGET = _zx.argv._[0];
26
26
  } else {
@@ -31,6 +31,9 @@ if (_zx.argv._.length === 1) {
31
31
  CHANNEL.expiration = _zx.argv.channelExpiration ?? '7d';
32
32
  }
33
33
  }
34
+
35
+ // If target has not been defined on the command line,
36
+ // then enter interactive mode
34
37
  const INTERACTIVE_MODE = !TARGET;
35
38
  let exited = false;
36
39
  const SECRETS_DIR = 'secrets';
@@ -50,7 +53,9 @@ const firebasercContent = JSON.parse(await _zx.fs.readFile(_zx.path.join(process
50
53
  }));
51
54
 
52
55
  // If in a git repo, fetch the name of the git branch to use as a default
53
- // name in case a deployment channel is needed
56
+ // name in case a deployment channel is needed. Examining this file directly
57
+ // is less cumbersome then running an actual git command to fetch the
58
+ // branch name
54
59
  let gitBranch;
55
60
  if (git) {
56
61
  const gitContent = (await _zx.fs.readFile(_zx.path.join(process.cwd(), '.git/HEAD'), {
@@ -58,11 +63,12 @@ if (git) {
58
63
  }))?.split('/');
59
64
  gitBranch = gitContent[gitContent?.length - 1]?.trimEnd('\n');
60
65
  }
61
- let maxPadding = 0;
62
- const targets = Object.entries(firebasercContent.targets).reduce((prev, [projectId, config, production]) => {
63
- Object.entries(config.hosting).forEach(([siteId, aliases, production]) => {
66
+ let maxSiteIdLength = 0;
67
+ const targets = Object.entries(firebasercContent.targets).reduce((prev, [projectId, config]) => {
68
+ Object.entries(config.hosting).forEach(([siteId, aliases]) => {
64
69
  aliases.forEach(alias => {
65
- maxPadding = Math.max(siteId.length, maxPadding);
70
+ // Store the longest length of site id for formatting later on
71
+ maxSiteIdLength = Math.max(siteId.length, maxSiteIdLength);
66
72
  prev[alias] = {
67
73
  projectId,
68
74
  siteId,
@@ -83,7 +89,7 @@ if (INTERACTIVE_MODE) {
83
89
  choices: Object.values(targets).map(t => {
84
90
  const productionLabel = t.production ? _ansiColors.default.bold.red('--PRODUCTION--') : '';
85
91
  return {
86
- message: `${_ansiColors.default.bold.cyan('Site: ')}${t.siteId.padEnd(maxPadding)} ${_ansiColors.default.bold.green('Project: ')}${t.projectId} ${productionLabel}`,
92
+ message: `${_ansiColors.default.bold.cyan('Site: ')}${t.siteId.padEnd(maxSiteIdLength)} ${_ansiColors.default.bold.green('Project: ')}${t.projectId} ${productionLabel}`,
87
93
  value: t.alias
88
94
  };
89
95
  })
@@ -156,14 +162,15 @@ if (aliasFileExists) {
156
162
  encoding: 'utf-8'
157
163
  }));
158
164
  }
165
+ console.log(`\n\n\n${_ansiColors.default.bold.green('====== Deployment Summary ======')}`);
166
+ console.log(`${_ansiColors.default.blue('Firebase project:')} ${TARGET.projectId} ${TARGET.production ? _ansiColors.default.yellow('--PRODUCTION--') : ''}`);
167
+ console.log(`${_ansiColors.default.blue('Site ID:')} ${TARGET.siteId}`);
168
+ console.log(`${_ansiColors.default.blue('Channel Name:')} ${CHANNEL?.name ?? _ansiColors.default.italic.gray('(none)')}`);
169
+ console.log(`${_ansiColors.default.blue('Channel Expiration date:')} ${CHANNEL?.name ? CHANNEL.expiration ?? _ansiColors.default.italic.gray('(none)') : _ansiColors.default.italic.gray('(n/a)')}`);
170
+ console.log(`${_ansiColors.default.blue('Shared .env file:')} ${sharedFileExists ? `${SECRETS_DIR}/shared.env` : _ansiColors.default.italic.gray('(none)')}`);
171
+ console.log(`${_ansiColors.default.blue('Additional .env overrides:')} ${aliasFileExists ? `${SECRETS_DIR}/${TARGET.alias}.env` : `${SECRETS_DIR}/${TARGET.siteId}.env`}`);
172
+ console.log(`${_ansiColors.default.bold.green('===============================')}`);
159
173
  if (INTERACTIVE_MODE) {
160
- console.log(`\n\n\n${_ansiColors.default.bold.green('====== Deployment Summary ======')}`);
161
- console.log(`${_ansiColors.default.blue('Firebase project:')} ${TARGET.projectId} ${TARGET.production ? _ansiColors.default.yellow('--PRODUCTION--') : ''}`);
162
- console.log(`${_ansiColors.default.blue('Site ID:')} ${TARGET.siteId}`);
163
- console.log(`${_ansiColors.default.blue('Channel Name:')} ${CHANNEL?.name ?? _ansiColors.default.italic.gray('(none)')}`);
164
- console.log(`${_ansiColors.default.blue('Channel Expiration date:')} ${CHANNEL?.name ? CHANNEL.expiration ?? _ansiColors.default.italic.gray('(none)') : _ansiColors.default.italic.gray('(n/a)')}`);
165
- console.log(`${_ansiColors.default.blue('Shared .env file:')} ${sharedFileExists ? `${SECRETS_DIR}/shared.env` : _ansiColors.default.italic.gray('(none)')}`);
166
- console.log(`${_ansiColors.default.blue('Additional .env overrides:')} ${aliasFileExists ? `${SECRETS_DIR}/${TARGET.alias}.env` : `${SECRETS_DIR}/${TARGET.siteId}.env`}`);
167
174
  const {
168
175
  confirmSelections
169
176
  } = await prompt([{
@@ -187,6 +194,7 @@ EXIT_EVENTS.forEach(event => {
187
194
  });
188
195
  await _zx.fs.writeFile(_zx.path.join(process.cwd(), '.env.temp'), envFileContent);
189
196
  try {
197
+ // deploying to a channel requires slightly different parameter structure
190
198
  const deployType = CHANNEL ? `hosting:channel:deploy ${CHANNEL.name} ${CHANNEL.expiration ? `--expires ${CHANNEL.expiration}` : ''}`.split(' ') : 'deploy';
191
199
  const hostingPrefix = CHANNEL ? '' : 'hosting:';
192
200
  await (0, _zx.$)`npm run clean && DOTENV_CONFIG_PATH=${_zx.path.join(process.cwd(), '.env.temp')} npm run build && firebase use ${TARGET.projectId} && firebase ${deployType} --only ${hostingPrefix}${TARGET.siteId}`;
@@ -1,8 +1,10 @@
1
1
  #!/usr/bin/env node
2
+ "use strict";
2
3
 
4
+ console.log(`TOP=>[${process.cwd()}] PWD=[${process.env.PWD}]`);
3
5
  /* eslint-disable no-console */
4
- "use strict";
5
6
 
7
+ const path = require('node:path');
6
8
  const chalk = require('chalk');
7
9
  const cliArgs = require('command-line-args');
8
10
  // const cliHelp = require( 'command-line-usage' )
@@ -69,11 +71,21 @@ const optionsDefinitions = [/* eslint-disable no-multi-spaces */
69
71
 
70
72
  const args = cliArgs(optionsDefinitions);
71
73
 
74
+ // See if we are in a monorepo, which changes some of the rules.
75
+ const gitTop = exec('git rev-parse --show-toplevel', {
76
+ stdio: [undefined]
77
+ }).toString().trim();
78
+ let monoTop;
79
+ if (fs.existsSync(`${gitTop}/packages`)) {
80
+ monoTop = path.basename(path.resolve()); // process.env.PWD
81
+ console.log(`MONO=[${monoTop}]`);
82
+ }
83
+
72
84
  // The kubernetes context is equal to the git branch name.
73
85
  const gitBranch = exec('git rev-parse --abbrev-ref HEAD', {
74
86
  stdio: [undefined]
75
87
  }).toString().trim();
76
- const context = args.context || gitBranch;
88
+ const context = args.context || monoTop || gitBranch;
77
89
  if (context === 'master') {
78
90
  console.log('***ERROR: master context is forbidden; change to a different branch\n\n');
79
91
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leverege/build-tools",
3
- "version": "2.21.9-nick.4",
3
+ "version": "2.21.10",
4
4
  "description": "A collection of build / support tools for Leverege developers",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -68,9 +68,9 @@
68
68
  },
69
69
  "devDependencies": {
70
70
  "@babel/cli": "^7.19.3",
71
- "@babel/core": "^7.19.3",
71
+ "@babel/core": "^7.20.2",
72
72
  "@leverege/babel-preset-leverege-node": "^2.0.0",
73
73
  "@leverege/eslint-config-leverege": "^3.0.1",
74
- "npm": "^8.19.2"
74
+ "npm": "^8.19.3"
75
75
  }
76
76
  }
@@ -17,12 +17,12 @@ let CHANNEL
17
17
 
18
18
  // A single unnamed parameter is assumed to be a deploy target.
19
19
  // If named parameters exist, they may not be stored in argv,
20
- // so don't use the length of argv to decide whether to look for them
20
+ // so don't look for a larger length of argv to decide whether to look for named paramters
21
21
  if ( argv._.length === 1 ) {
22
22
  TARGET = argv._[0]
23
23
  } else {
24
24
  TARGET = argv.target
25
-
25
+
26
26
  if ( argv.channelName ) {
27
27
  CHANNEL = {}
28
28
  CHANNEL.name = argv.channelName
@@ -30,6 +30,8 @@ if ( argv._.length === 1 ) {
30
30
  }
31
31
  }
32
32
 
33
+ // If target has not been defined on the command line,
34
+ // then enter interactive mode
33
35
  const INTERACTIVE_MODE = !TARGET
34
36
 
35
37
  let exited = false
@@ -62,23 +64,27 @@ if ( !firebaserc || !firebaseJson ) {
62
64
  const firebasercContent = JSON.parse( await fs.readFile( path.join( process.cwd(), '.firebaserc' ), { encoding : 'utf-8' } ) )
63
65
 
64
66
  // If in a git repo, fetch the name of the git branch to use as a default
65
- // name in case a deployment channel is needed
67
+ // name in case a deployment channel is needed. Examining this file directly
68
+ // is less cumbersome then running an actual git command to fetch the
69
+ // branch name
66
70
  let gitBranch
67
71
  if ( git ) {
68
72
  const gitContent = ( await fs.readFile( path.join( process.cwd(), '.git/HEAD' ), { encoding : 'utf-8' } ) )?.split( '/' )
69
73
  gitBranch = gitContent[gitContent?.length - 1]?.trimEnd( '\n' )
70
74
  }
71
75
 
72
- let maxPadding = 0
76
+ let maxSiteIdLength = 0
73
77
 
74
78
  const targets = Object
75
79
  .entries( firebasercContent.targets )
76
- .reduce( ( prev, [ projectId, config, production ] ) => {
80
+ .reduce( ( prev, [ projectId, config ] ) => {
77
81
  Object
78
82
  .entries( config.hosting )
79
- .forEach( ( [ siteId, aliases, production ] ) => {
83
+ .forEach( ( [ siteId, aliases ] ) => {
80
84
  aliases.forEach( ( alias ) => {
81
- maxPadding = Math.max( siteId.length, maxPadding )
85
+ // Store the longest length of site id for formatting later on
86
+ maxSiteIdLength = Math.max( siteId.length, maxSiteIdLength )
87
+
82
88
  prev[alias] = {
83
89
  projectId,
84
90
  siteId,
@@ -96,9 +102,9 @@ if ( INTERACTIVE_MODE ) {
96
102
  type : 'select',
97
103
  name : 'targetEnv',
98
104
  message : 'To which environment would you like to deploy?',
99
- choices : Object.values( targets ).map( ( t ) => {
105
+ choices : Object.values( targets ).map( ( t ) => {
100
106
  const productionLabel = t.production ? colors.bold.red( '--PRODUCTION--' ) : ''
101
- return { message : `${colors.bold.cyan( 'Site: ' )}${t.siteId.padEnd( maxPadding )} ${colors.bold.green( 'Project: ' )}${t.projectId} ${productionLabel}`, value : t.alias }
107
+ return { message : `${colors.bold.cyan( 'Site: ' )}${t.siteId.padEnd( maxSiteIdLength )} ${colors.bold.green( 'Project: ' )}${t.projectId} ${productionLabel}`, value : t.alias }
102
108
  } )
103
109
  } ] )
104
110
 
@@ -115,7 +121,7 @@ if ( INTERACTIVE_MODE ) {
115
121
  process.exit()
116
122
  }
117
123
  }
118
-
124
+
119
125
  const { useChannel } = await prompt( [ {
120
126
  type : 'confirm',
121
127
  name : 'useChannel',
@@ -127,7 +133,7 @@ if ( INTERACTIVE_MODE ) {
127
133
  type : 'input',
128
134
  name : 'channelName',
129
135
  message : 'To which channel would you like to deploy?',
130
- initial : gitBranch ?? 'temp-deploy'
136
+ initial : gitBranch ?? 'temp-deploy'
131
137
  }, {
132
138
  type : 'input',
133
139
  name : 'channelExpiration',
@@ -137,7 +143,6 @@ if ( INTERACTIVE_MODE ) {
137
143
 
138
144
  CHANNEL = { name : channelName, expiration : channelExpiration }
139
145
  }
140
-
141
146
  } else {
142
147
  TARGET = targets[TARGET]
143
148
  }
@@ -170,15 +175,16 @@ if ( aliasFileExists ) {
170
175
  exec.push( fs.readFile( path.join( process.cwd(), SECRETS_DIR, `${TARGET.siteId}.env` ), { encoding : 'utf-8' } ) )
171
176
  }
172
177
 
173
- if ( INTERACTIVE_MODE ) {
174
- console.log( `\n\n\n${colors.bold.green( '====== Deployment Summary ======' )}` )
175
- console.log( `${colors.blue( 'Firebase project:' )} ${TARGET.projectId} ${TARGET.production ? colors.yellow( '--PRODUCTION--' ) : ''}` )
176
- console.log( `${colors.blue( 'Site ID:' )} ${TARGET.siteId}` )
177
- console.log( `${colors.blue( 'Channel Name:' )} ${CHANNEL?.name ?? colors.italic.gray( '(none)' )}` )
178
- console.log( `${colors.blue( 'Channel Expiration date:' )} ${CHANNEL?.name ? CHANNEL.expiration ?? colors.italic.gray( '(none)' ) : colors.italic.gray( '(n/a)' )}` )
179
- console.log( `${colors.blue( 'Shared .env file:' )} ${sharedFileExists ? `${SECRETS_DIR}/shared.env` : colors.italic.gray( '(none)' )}` )
180
- console.log( `${colors.blue( 'Additional .env overrides:' )} ${aliasFileExists ? `${SECRETS_DIR}/${TARGET.alias}.env` : `${SECRETS_DIR}/${TARGET.siteId}.env`}` )
178
+ console.log( `\n\n\n${colors.bold.green( '====== Deployment Summary ======' )}` )
179
+ console.log( `${colors.blue( 'Firebase project:' )} ${TARGET.projectId} ${TARGET.production ? colors.yellow( '--PRODUCTION--' ) : ''}` )
180
+ console.log( `${colors.blue( 'Site ID:' )} ${TARGET.siteId}` )
181
+ console.log( `${colors.blue( 'Channel Name:' )} ${CHANNEL?.name ?? colors.italic.gray( '(none)' )}` )
182
+ console.log( `${colors.blue( 'Channel Expiration date:' )} ${CHANNEL?.name ? CHANNEL.expiration ?? colors.italic.gray( '(none)' ) : colors.italic.gray( '(n/a)' )}` )
183
+ console.log( `${colors.blue( 'Shared .env file:' )} ${sharedFileExists ? `${SECRETS_DIR}/shared.env` : colors.italic.gray( '(none)' )}` )
184
+ console.log( `${colors.blue( 'Additional .env overrides:' )} ${aliasFileExists ? `${SECRETS_DIR}/${TARGET.alias}.env` : `${SECRETS_DIR}/${TARGET.siteId}.env`}` )
185
+ console.log( `${colors.bold.green( '===============================' )}` )
181
186
 
187
+ if ( INTERACTIVE_MODE ) {
182
188
  const { confirmSelections } = await prompt( [ {
183
189
  type : 'confirm',
184
190
  name : 'confirmSelections',
@@ -205,8 +211,11 @@ EXIT_EVENTS
205
211
  await fs.writeFile( path.join( process.cwd(), '.env.temp' ), envFileContent )
206
212
 
207
213
  try {
214
+
215
+ // deploying to a channel requires slightly different parameter structure
208
216
  const deployType = CHANNEL ? `hosting:channel:deploy ${CHANNEL.name} ${CHANNEL.expiration ? `--expires ${CHANNEL.expiration}` : ''}`.split( ' ' ) : 'deploy'
209
217
  const hostingPrefix = CHANNEL ? '' : 'hosting:'
218
+
210
219
  await $`npm run clean && DOTENV_CONFIG_PATH=${path.join( process.cwd(), '.env.temp' )} npm run build && firebase use ${TARGET.projectId} && firebase ${deployType} --only ${hostingPrefix}${TARGET.siteId}`
211
220
  } catch ( err ) {
212
221
  console.error( err )
package/src/helmup CHANGED
@@ -1,5 +1,5 @@
1
1
  #
2
- # printf "\n***** RUNNING LOCALLY *****\n" && sleep 2
2
+ printf "\n***** RUNNING LOCALLY *****\n" && sleep 2
3
3
 
4
4
  # Load the standard helper functions
5
5
  . `build-tools --bashfun`
@@ -555,7 +555,7 @@ NEED_MANAGED_SECRET
555
555
  addHelmRepo jetstack https://charts.jetstack.io
556
556
  helm upgrade --install cert-manager jetstack/cert-manager \
557
557
  --namespace cert-manager --set installCRDs=true \
558
- --version v1.9
558
+ --version v1.10
559
559
 
560
560
  cat<<DELAY
561
561
 
@@ -630,7 +630,7 @@ TRAEFIK_CFG
630
630
 
631
631
  addHelmRepo traefik https://helm.traefik.io/traefik
632
632
 
633
- [ -z "$TRAEFIK_HELM_CHART" ] && TRAEFIK_HELM_CHART="12"
633
+ [ -z "$TRAEFIK_HELM_CHART" ] && TRAEFIK_HELM_CHART="16"
634
634
  helm upgrade --install traefik traefik/traefik \
635
635
  --namespace traefik \
636
636
  --version $TRAEFIK_HELM_CHART \
@@ -1029,10 +1029,10 @@ NOTRUNNING
1029
1029
  }
1030
1030
 
1031
1031
  # ---------- helmup MAIN ----------
1032
- GITTOP=`git rev-parse --show-toplevel` && cd $GITTOP
1032
+ GITTOP=`git rev-parse --show-toplevel` # `&& cd $GITTOP
1033
1033
  K8S_UTILS="${GITTOP}/k8s-utils"
1034
1034
 
1035
- overwhelm
1035
+ overwhelm.js #XXX
1036
1036
  [ $? -ne 0 ] && printf "\n\n***Aborting helmup...\n\n" && exit 1
1037
1037
 
1038
1038
  doInstall $@
package/src/klog CHANGED
@@ -3,7 +3,7 @@
3
3
  [ -f overwhelm.yaml ] && [ -f package.json ] && npm run ahoy
4
4
 
5
5
  DTS="`date +\"%Y%m%d-%H%M%S\"`"
6
- PRETTY="pino-pretty -c -t 'HH:MM:ss.l'"
6
+ PRETTY="pino-pretty -c -t 'HH:MM:ss.l' -i 'severity'"
7
7
  IFS="/" read APP <<< "$1"
8
8
 
9
9
  if [ ! -z "$APP" ];
package/src/overwhelm.js CHANGED
@@ -1,7 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ console.log( `TOP=>[${process.cwd()}] PWD=[${process.env.PWD}]` )
3
4
  /* eslint-disable no-console */
4
5
 
6
+ const path = require( 'node:path' )
5
7
  const chalk = require( 'chalk' )
6
8
  const cliArgs = require( 'command-line-args' )
7
9
  // const cliHelp = require( 'command-line-usage' )
@@ -28,12 +30,22 @@ const optionsDefinitions = [
28
30
  ]
29
31
  const args = cliArgs( optionsDefinitions )
30
32
 
33
+ // See if we are in a monorepo, which changes some of the rules.
34
+ const gitTop = exec(
35
+ 'git rev-parse --show-toplevel', { stdio : [ undefined ] }
36
+ ).toString().trim()
37
+ let monoTop
38
+ if( fs.existsSync( `${gitTop}/packages` ) ) {
39
+ monoTop = path.basename( path.resolve() ) // process.env.PWD
40
+ console.log( `MONO=[${monoTop}]` )
41
+ }
42
+
31
43
  // The kubernetes context is equal to the git branch name.
32
44
  const gitBranch = exec(
33
45
  'git rev-parse --abbrev-ref HEAD', { stdio : [ undefined ] }
34
46
  ).toString().trim()
35
47
 
36
- const context = args.context || gitBranch
48
+ const context = args.context || monoTop || gitBranch
37
49
 
38
50
  if ( context === 'master' ) {
39
51
  console.log( '***ERROR: master context is forbidden; change to a different branch\n\n' )
package/.env.temp DELETED
@@ -1,18 +0,0 @@
1
- THEFT_RECOVERY_URL='theft.recovermycar.com'
2
- MAPBOX_APIKEY=pk.eyJ1IjoibGV2ZXJlZ2UiLCJhIjoiY2p1Y3E0cWpkMG15azQzbnFzaDY2dmhiMSJ9.7N25h5jsjO2Aq_YmiLrAJw
3
- APPEARANCE_PROJECT_ID=7b2GTbmsZj3f5VdFpjGM8O
4
- INTERCOM_APP_ID='ec0qbuwi'
5
- LOCATOR_ALIAS_KEY='serialNumber'
6
- RECOVR_BILLING_MODULE='recovrBilling'
7
- IMAGINE_HOST=https://leverege-sandbox-imagine-api.leverege.com
8
- RECOVR_HOST=https://dev-recovr-notify.leverege.com
9
- # RECOVR_HOST=http://localhost:8296
10
- SYSTEM_ID=0UTmPFvRHXYLMlT4Kl2z1K
11
- PROJECT_ID=08HBeHEYGxu5Bg4TCCnAAV
12
- VEHICLE_NETWORK_ID='dev-dealership-vehicles'
13
- CONSUMER_VEHICLE_NETWORK_ID='dev-customer-vehicles'
14
- LOCATOR_NETWORK_ID='dev-recovr-tracker'
15
- BEACON_NETWORK_ID='dev-dealership-beacons'
16
- SALE_LOCATION_PARENT_PATH=sales
17
- CONSUMER_LOCATION_ID=1KceIcZlVWrOBvCzsEXYud
18
- IS_DEV=true
package/.firebaserc DELETED
@@ -1,40 +0,0 @@
1
- {
2
- "projects": {
3
- "default": "leverege-sandbox",
4
- "stg-recovr-auto": "stg-recovr-auto",
5
- "prd-recovr-auto":"prd-recovr-auto"
6
- },
7
- "targets": {
8
- "leverege-sandbox": {
9
- "hosting": {
10
- "recovr": [
11
- "dev"
12
- ],
13
- "dev-obd-recovr": [
14
- "dev-obd"
15
- ]
16
- }
17
- },
18
- "stg-recovr-auto": {
19
- "hosting": {
20
- "stg-recovr": [
21
- "stg"
22
- ],
23
- "stg-obd-recovr": [
24
- "stg-obd"
25
- ]
26
- }
27
- },
28
- "prd-recovr-auto": {
29
- "hosting": {
30
- "recovr-auto": [
31
- "prd"
32
- ],
33
- "prd-obd-recovr":[
34
- "prd-obd"
35
- ]
36
- },
37
- "production": true
38
- }
39
- }
40
- }
package/.firebasercizg DELETED
@@ -1,47 +0,0 @@
1
- {
2
- "projects": {
3
- "default": "leverege-sandbox",
4
- "dev-keys": "leverege-dev-nick",
5
- "prd-indoor-zoning" : "prd-indoor-zoning"
6
- },
7
- "targets": {
8
- "leverege-sandbox": {
9
- "hosting": {
10
- "dev-izg": [
11
- "dev-izg"
12
- ],
13
- "dev-olive-indoor-zoning": [
14
- "dev-olive-indoor-zoning"
15
- ]
16
- }
17
- },
18
- "leverege-dev-nick": {
19
- "hosting": {
20
- "dev-keys": [
21
- "dev-keys"
22
- ]
23
- }
24
- },
25
- "prd-indoor-zoning": {
26
- "hosting": {
27
- "prd-indoor-zoning-ui222": [
28
- "prd-indoor-zoning-ui"
29
- ],
30
- "prd-olive-indoor-zoning-ui222": [
31
- "prd-olive-indoor-zoning-ui"
32
- ],
33
- "prd-keys222": [
34
- "prd-keys"
35
- ]
36
- },
37
- "production": true
38
- },
39
- "stg-indoor-zoning-pen-test": {
40
- "hosting": {
41
- "stg-indoor-zoning-ui": [
42
- "stg-indoor-zoning-ui"
43
- ]
44
- }
45
- }
46
- }
47
- }
@@ -1,18 +0,0 @@
1
- {
2
- // Use IntelliSense to learn about possible attributes.
3
- // Hover to view descriptions of existing attributes.
4
- // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
- "version": "0.2.0",
6
- "configurations": [
7
- {
8
- "type": "node",
9
- "request": "launch",
10
- "name": "firebase deploy",
11
- "skipFiles": [
12
- "<node_internals>/**"
13
- ],
14
- "program": "${workspaceFolder}/src/firebaseDeploy.mjs",
15
- "console": "integratedTerminal"
16
- }
17
- ]
18
- }
package/firebase.json DELETED
@@ -1,180 +0,0 @@
1
- {
2
- "hosting": [
3
- {
4
- "site":"dev-izg",
5
- "public": "dist",
6
- "ignore": [
7
- "firebase.json",
8
- "**/.*",
9
- "**/node_modules/**"
10
- ],
11
- "rewrites": [
12
- {
13
- "source": "**",
14
- "destination": "/index.html"
15
- }
16
- ],
17
- "headers": {
18
- "X-Content-Type-Options": "nosniff",
19
- "X-XSS-Protection": "1; mode=block",
20
- "X-Frame-Options": "deny",
21
- "Content-Security-Policy": "default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: leverege-sandbox-imagine-api.leverege.com *.mapbox.com *.firebaseio.com wss://*.firebaseio.com *.googleapis.com *.intercom.io wss://*.intercom.io maxcdn.bootstrapcdn.com *.intercomcdn.com *.gstatic.com;",
22
- "Referrer-Policy":"no-referrer"
23
- }
24
- },
25
- {
26
- "site":"dev-keys",
27
- "public": "dist",
28
- "ignore": [
29
- "firebase.json",
30
- "**/.*",
31
- "**/node_modules/**"
32
- ],
33
- "rewrites": [
34
- {
35
- "source": "**",
36
- "destination": "/index.html"
37
- }
38
- ],
39
- "headers": {
40
- "X-Content-Type-Options": "nosniff",
41
- "X-XSS-Protection": "1; mode=block",
42
- "X-Frame-Options": "deny",
43
- "Content-Security-Policy": "default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: leverege-sandbox-imagine-api.leverege.com *.mapbox.com *.firebaseio.com wss://*.firebaseio.com *.googleapis.com *.intercom.io wss://*.intercom.io maxcdn.bootstrapcdn.com *.intercomcdn.com *.gstatic.com;",
44
- "Referrer-Policy":"no-referrer"
45
- }
46
- },
47
- {
48
- "site":"dev-keys",
49
- "public": "dist",
50
- "ignore": [
51
- "firebase.json",
52
- "**/.*",
53
- "**/node_modules/**"
54
- ],
55
- "rewrites": [
56
- {
57
- "source": "**",
58
- "destination": "/index.html"
59
- }
60
- ],
61
- "headers": {
62
- "X-Content-Type-Options": "nosniff",
63
- "X-XSS-Protection": "1; mode=block",
64
- "X-Frame-Options": "deny",
65
- "Content-Security-Policy": "default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: leverege-sandbox-imagine-api.leverege.com *.mapbox.com *.firebaseio.com wss://*.firebaseio.com *.googleapis.com *.intercom.io wss://*.intercom.io maxcdn.bootstrapcdn.com *.intercomcdn.com *.gstatic.com;",
66
- "Referrer-Policy":"no-referrer"
67
- }
68
- },
69
- {
70
- "site":"dev-olive-indoor-zoning",
71
- "public": "dist",
72
- "ignore": [
73
- "firebase.json",
74
- "**/.*",
75
- "**/node_modules/**"
76
- ],
77
- "rewrites": [
78
- {
79
- "source": "**",
80
- "destination": "/index.html"
81
- }
82
- ],
83
- "headers": {
84
- "X-Content-Type-Options": "nosniff",
85
- "X-XSS-Protection": "1; mode=block",
86
- "X-Frame-Options": "deny",
87
- "Content-Security-Policy": "default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: leverege-sandbox-imagine-api.leverege.com *.mapbox.com *.firebaseio.com wss://*.firebaseio.com *.googleapis.com *.intercom.io wss://*.intercom.io maxcdn.bootstrapcdn.com *.intercomcdn.com *.gstatic.com;",
88
- "Referrer-Policy":"no-referrer"
89
- }
90
- },
91
- {
92
- "site":"prd-indoor-zoning-ui",
93
- "public": "dist",
94
- "ignore": [
95
- "firebase.json",
96
- "**/.*",
97
- "**/node_modules/**"
98
- ],
99
- "rewrites": [
100
- {
101
- "source": "**",
102
- "destination": "/index.html"
103
- }
104
- ],
105
- "headers": {
106
- "X-Content-Type-Options": "nosniff",
107
- "X-XSS-Protection": "1; mode=block",
108
- "X-Frame-Options": "deny",
109
- "Content-Security-Policy": "default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: leverege-sandbox-imagine-api.leverege.com *.mapbox.com *.firebaseio.com wss://*.firebaseio.com *.googleapis.com *.intercom.io wss://*.intercom.io maxcdn.bootstrapcdn.com *.intercomcdn.com *.gstatic.com;",
110
- "Referrer-Policy":"no-referrer"
111
- }
112
- },
113
- {
114
- "site":"prd-keys",
115
- "public": "dist",
116
- "ignore": [
117
- "firebase.json",
118
- "**/.*",
119
- "**/node_modules/**"
120
- ],
121
- "rewrites": [
122
- {
123
- "source": "**",
124
- "destination": "/index.html"
125
- }
126
- ],
127
- "headers": {
128
- "X-Content-Type-Options": "nosniff",
129
- "X-XSS-Protection": "1; mode=block",
130
- "X-Frame-Options": "deny",
131
- "Content-Security-Policy": "default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: leverege-sandbox-imagine-api.leverege.com *.mapbox.com *.firebaseio.com wss://*.firebaseio.com *.googleapis.com *.intercom.io wss://*.intercom.io maxcdn.bootstrapcdn.com *.intercomcdn.com *.gstatic.com;",
132
- "Referrer-Policy":"no-referrer"
133
- }
134
- },
135
- {
136
- "site":"prd-olive-indoor-zoning-ui",
137
- "public": "dist",
138
- "ignore": [
139
- "firebase.json",
140
- "**/.*",
141
- "**/node_modules/**"
142
- ],
143
- "rewrites": [
144
- {
145
- "source": "**",
146
- "destination": "/index.html"
147
- }
148
- ],
149
- "headers": {
150
- "X-Content-Type-Options": "nosniff",
151
- "X-XSS-Protection": "1; mode=block",
152
- "X-Frame-Options": "deny",
153
- "Content-Security-Policy": "default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: leverege-sandbox-imagine-api.leverege.com *.mapbox.com *.firebaseio.com wss://*.firebaseio.com *.googleapis.com *.intercom.io wss://*.intercom.io maxcdn.bootstrapcdn.com *.intercomcdn.com *.gstatic.com;",
154
- "Referrer-Policy":"no-referrer"
155
- }
156
- },
157
- {
158
- "site":"stg-indoor-zoning-ui",
159
- "public": "dist",
160
- "ignore": [
161
- "firebase.json",
162
- "**/.*",
163
- "**/node_modules/**"
164
- ],
165
- "rewrites": [
166
- {
167
- "source": "**",
168
- "destination": "/index.html"
169
- }
170
- ],
171
- "headers": {
172
- "X-Content-Type-Options": "nosniff",
173
- "X-XSS-Protection": "1; mode=block",
174
- "X-Frame-Options": "deny",
175
- "Content-Security-Policy": "default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: leverege-sandbox-imagine-api.leverege.com *.mapbox.com *.firebaseio.com wss://*.firebaseio.com *.googleapis.com *.intercom.io wss://*.intercom.io maxcdn.bootstrapcdn.com *.intercomcdn.com *.gstatic.com;",
176
- "Referrer-Policy":"no-referrer"
177
- }
178
- }
179
- ]
180
- }
@@ -1,13 +0,0 @@
1
- IMAGINE_HOST=https://leverege-sandbox-imagine-api.leverege.com
2
- RECOVR_HOST=https://dev-recovr-notify.leverege.com
3
- # RECOVR_HOST=http://localhost:8296
4
- SYSTEM_ID=0UTmPFvRHXYLMlT4Kl2z1K
5
- PROJECT_ID=08HBeHEYGxu5Bg4TCCnAAV
6
- VEHICLE_NETWORK_ID='dev-dealership-vehicles'
7
- CONSUMER_VEHICLE_NETWORK_ID='dev-customer-vehicles'
8
- LOCATOR_NETWORK_ID='dev-recovr-tracker'
9
- BEACON_NETWORK_ID='dev-dealership-beacons'
10
- SALE_LOCATION_PARENT_PATH=sales
11
- CONSUMER_LOCATION_ID=1KceIcZlVWrOBvCzsEXYud
12
- userManagementUiName='obd'
13
- IS_DEV=true
package/secrets/dev.env DELETED
@@ -1,12 +0,0 @@
1
- IMAGINE_HOST=https://leverege-sandbox-imagine-api.leverege.com
2
- RECOVR_HOST=https://dev-recovr-notify.leverege.com
3
- # RECOVR_HOST=http://localhost:8296
4
- SYSTEM_ID=0UTmPFvRHXYLMlT4Kl2z1K
5
- PROJECT_ID=08HBeHEYGxu5Bg4TCCnAAV
6
- VEHICLE_NETWORK_ID='dev-dealership-vehicles'
7
- CONSUMER_VEHICLE_NETWORK_ID='dev-customer-vehicles'
8
- LOCATOR_NETWORK_ID='dev-recovr-tracker'
9
- BEACON_NETWORK_ID='dev-dealership-beacons'
10
- SALE_LOCATION_PARENT_PATH=sales
11
- CONSUMER_LOCATION_ID=1KceIcZlVWrOBvCzsEXYud
12
- IS_DEV=true
@@ -1,12 +0,0 @@
1
- IMAGINE_HOST=https://prd-recovr-auto-imagine-api.leverege.com
2
- RECOVR_HOST=https://recovr-auto-notify.leverege.com
3
- SYSTEM_ID=2ExK7rl76meCVCCctjOJEY
4
- PROJECT_ID=1Je8Y7dNlfthv7ixV8oEfZ
5
- VEHICLE_NETWORK_ID='prd-auto-vehicles'
6
- CONSUMER_VEHICLE_NETWORK_ID='prd-customer-vehicles'
7
- BEACON_NETWORK_ID='prd-auto-beacons'
8
- GOOGLE_ANALYTICS_TRACKER_ID='G-LBTT0JT9V6'
9
- SALE_LOCATION_PARENT_PATH=location
10
- CONSUMER_LOCATION_ID=26OsDlsRqBTIOxMjyHg9S5
11
- userManagementUiName='obd'
12
- IS_DEV=true
package/secrets/prd.env DELETED
@@ -1,10 +0,0 @@
1
- IMAGINE_HOST=https://prd-recovr-auto-imagine-api.leverege.com
2
- RECOVR_HOST=https://recovr-auto-notify.leverege.com
3
- SYSTEM_ID=2ExK7rl76meCVCCctjOJEY
4
- PROJECT_ID=1Je8Y7dNlfthv7ixV8oEfZ
5
- VEHICLE_NETWORK_ID='prd-auto-vehicles'
6
- CONSUMER_VEHICLE_NETWORK_ID='prd-customer-vehicles'
7
- BEACON_NETWORK_ID='prd-auto-beacons'
8
- GOOGLE_ANALYTICS_TRACKER_ID='G-LBTT0JT9V6'
9
- SALE_LOCATION_PARENT_PATH=location
10
- CONSUMER_LOCATION_ID=26OsDlsRqBTIOxMjyHg9S5
@@ -1,6 +0,0 @@
1
- THEFT_RECOVERY_URL='theft.recovermycar.com'
2
- MAPBOX_APIKEY=pk.eyJ1IjoibGV2ZXJlZ2UiLCJhIjoiY2p1Y3E0cWpkMG15azQzbnFzaDY2dmhiMSJ9.7N25h5jsjO2Aq_YmiLrAJw
3
- APPEARANCE_PROJECT_ID=7b2GTbmsZj3f5VdFpjGM8O
4
- INTERCOM_APP_ID='ec0qbuwi'
5
- LOCATOR_ALIAS_KEY='serialNumber'
6
- RECOVR_BILLING_MODULE='recovrBilling'
@@ -1,10 +0,0 @@
1
- IMAGINE_HOST=https://stg-recovr-auto-imagine-api.leverege.com
2
- # RECOVR_HOST=http://localhost:8296
3
- SYSTEM_ID=6CxONnaSOnbGFBS5gLnZWl
4
- PROJECT_ID=3vo2u8m9GEXPaQgMnJ45rh
5
- VEHICLE_NETWORK_ID='stg-auto-vehicles'
6
- CONSUMER_VEHICLE_NETWORK_ID='stg-customer-vehicles'
7
- BEACON_NETWORK_ID='stg-auto-beacons'
8
- CONSUMER_LOCATION_ID=1SRDkIuPWDpiAy4dsuy0JT
9
- userManagementUiName='obd'
10
- IS_DEV=false
package/secrets/stg.env DELETED
@@ -1,9 +0,0 @@
1
- IMAGINE_HOST=https://stg-recovr-auto-imagine-api.leverege.com
2
- # RECOVR_HOST=http://localhost:8296
3
- SYSTEM_ID=6CxONnaSOnbGFBS5gLnZWl
4
- PROJECT_ID=3vo2u8m9GEXPaQgMnJ45rh
5
- VEHICLE_NETWORK_ID='stg-auto-vehicles'
6
- CONSUMER_VEHICLE_NETWORK_ID='stg-customer-vehicles'
7
- BEACON_NETWORK_ID='stg-auto-beacons'
8
- CONSUMER_LOCATION_ID=1SRDkIuPWDpiAy4dsuy0JT
9
- IS_DEV=false