@leverege/build-tools 2.21.9-nick.3 → 2.21.9

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/.env.temp CHANGED
@@ -15,4 +15,5 @@ LOCATOR_NETWORK_ID='dev-recovr-tracker'
15
15
  BEACON_NETWORK_ID='dev-dealership-beacons'
16
16
  SALE_LOCATION_PARENT_PATH=sales
17
17
  CONSUMER_LOCATION_ID=1KceIcZlVWrOBvCzsEXYud
18
+ userManagementUiName='obd'
18
19
  IS_DEV=true
@@ -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,8 +194,10 @@ 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
- 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 hosting:${TARGET.siteId}`;
199
+ const hostingPrefix = CHANNEL ? '' : 'hosting:';
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}`;
192
201
  } catch (err) {
193
202
  console.error(err);
194
203
  }
@@ -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,8 +194,10 @@ 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
- 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 hosting:${TARGET.siteId}`;
199
+ const hostingPrefix = CHANNEL ? '' : 'hosting:';
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}`;
192
201
  } catch (err) {
193
202
  console.error(err);
194
203
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leverege/build-tools",
3
- "version": "2.21.9-nick.3",
3
+ "version": "2.21.9",
4
4
  "description": "A collection of build / support tools for Leverege developers",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -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,12 @@ 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
- await $`npm run clean && DOTENV_CONFIG_PATH=${path.join( process.cwd(), '.env.temp' )} npm run build && firebase use ${TARGET.projectId} && firebase ${deployType} --only hosting:${TARGET.siteId}`
217
+ const hostingPrefix = CHANNEL ? '' : 'hosting:'
218
+
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}`
210
220
  } catch ( err ) {
211
221
  console.error( err )
212
222
  }