@leverege/build-tools 2.103.0 → 2.104.0

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,7 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "npm"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "weekly"
7
+ open-pull-requests-limit: 10
@@ -0,0 +1,13 @@
1
+ import eslintConfig from '@leverege/eslint-config-leverege'
2
+
3
+ export default [
4
+ ...eslintConfig,
5
+ {
6
+ rules: {
7
+ '@stylistic/curly-newline': 'off',
8
+ '@stylistic/key-spacing': 'off',
9
+ '@stylistic/object-curly-newline': 'off',
10
+ '@stylistic/nonblock-statement-body-position': 'off'
11
+ }
12
+ }
13
+ ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leverege/build-tools",
3
- "version": "2.103.0",
3
+ "version": "2.104.0",
4
4
  "description": "A collection of build / support tools for Leverege developers",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "scripts": {
11
11
  "clean": "rm -rf lib",
12
- "lint": "find ./src -name \\*.\\*js | xargs npx eslint --report-unused-disable-directives",
12
+ "lint": "eslint",
13
13
  "prepare": "[ $SKIP_PREPARE ] && exit 0 || ./src/hook-and-release.mjs",
14
14
  "test": "mocha -t 60000 --exit 'test/**/!(*e2e*).mjs'",
15
15
  "test-all": "mocha -t 60000 --exit 'test/**/**.mjs'",
@@ -66,7 +66,6 @@
66
66
  "send-to-slack": "src/send-to-slack.mjs",
67
67
  "service-man": "src/service-man/service-man.mjs",
68
68
  "snapshot-cnpg": "src/snapshot-cnpg.mjs",
69
- "unleash": "src/unleash.mjs",
70
69
  "upload-model": "src/upload-model.sh",
71
70
  "yarn-build": "src/yarn-build.mjs"
72
71
  },
@@ -111,8 +110,9 @@
111
110
  "zx": "^8.8.5"
112
111
  },
113
112
  "devDependencies": {
114
- "@leverege/eslint-config-leverege": "^5.1.2",
113
+ "@leverege/eslint-config-leverege": "^9.0.1",
115
114
  "chai": "^6.2.2",
115
+ "eslint": "^9",
116
116
  "mocha": "^11.7.5",
117
117
  "npm": "^11.14.1"
118
118
  }
package/src/Docker.mjs CHANGED
@@ -98,7 +98,7 @@ const generateDockerfile = async ( options ) => {
98
98
  // could probably be tightened up a little.
99
99
  try {
100
100
  fs.readdirSync( './docker' )
101
- } catch ( err ) {
101
+ } catch ( err ) { // eslint-disable-line no-unused-vars
102
102
  warning( 'creating the missing ./docker directory' )
103
103
  fs.mkdirSync( './docker' ) // TODO: blindly assumes the mkdir succeeds
104
104
  }
@@ -120,7 +120,7 @@ const generateDockerfile = async ( options ) => {
120
120
  try {
121
121
  fs.writeFileSync( bashrcFile, bashrcTemplate )
122
122
  fs.appendFileSync( bashrcFile, bashrcPlugin )
123
- } catch ( err ) {
123
+ } catch ( err ) { // eslint-disable-line no-unused-vars
124
124
  errorExit( `***ERROR: failed creation of the ${bashrcFile} file` )
125
125
  }
126
126
 
@@ -136,7 +136,7 @@ const generateDockerfile = async ( options ) => {
136
136
  if ( build.length === 0 ) {
137
137
  errorExit( `***ERROR: the build dir is empty - ${chalk.yellow( 'npm run build' )}` )
138
138
  }
139
- } catch ( err ) {
139
+ } catch ( err ) { // eslint-disable-line no-unused-vars
140
140
  errorExit( `***ERROR: expected the ${buildDir} directory to exist - ${chalk.yellow( 'npm run build' )}` )
141
141
  }
142
142
 
package/src/Utils.mjs CHANGED
@@ -132,7 +132,7 @@ export const shellCmd = async ( cmd, opts = {} ) => {
132
132
  } else {
133
133
  const parsed = parse( cmd ).filter( x => typeof x === 'string' )
134
134
  // the leading ; forces a break from previous line otherwise trailing ) and leading [ collide
135
- ;[ command, ...args ] = parsed // eslint-disable-line semi-style
135
+ ;[ command, ...args ] = parsed // eslint-disable-line @stylistic/semi-style
136
136
  }
137
137
 
138
138
  debug( { command, args }, '<== execa $ invoke' )
@@ -271,7 +271,7 @@ export const getGitBranchAndUpstream = async () => {
271
271
  let upstream = 'no-upstream'
272
272
  try {
273
273
  upstream = await tryCommand( `git rev-parse --abbrev-ref ${branch}@{u}`, 'getGitUpstream' ) ?? 'no-upstream'
274
- } catch ( error ) {}
274
+ } catch ( error ) {} // eslint-disable-line no-unused-vars
275
275
  return { branch, upstream }
276
276
  }
277
277
 
@@ -710,12 +710,12 @@ export const analyzeRepository = async ( giveGuidance ) => {
710
710
  let wsName
711
711
  try {
712
712
  wsName = await shellCmd( 'npm exec -c pwd -ws' )
713
- } catch ( err ) { }
713
+ } catch ( err ) { } // eslint-disable-line no-unused-vars
714
714
 
715
715
  let gitRemote
716
716
  try {
717
717
  gitRemote = await shellCmd( 'git config --get remote.origin.url' )
718
- } catch ( err ) { }
718
+ } catch ( err ) { } // eslint-disable-line no-unused-vars
719
719
 
720
720
  // TODO: Add in Define VERBOSE_DOCKREATE_NPM="yes" for verbose build logging
721
721
  // TODO: Validity check for version and package.json
@@ -139,7 +139,7 @@ const buildAndPushImage = async () => {
139
139
  const dockerfilePath = path.join( buildDir, 'Dockerfile' )
140
140
 
141
141
  try {
142
- fs.writeFileSync( dockerfilePath, renderedDockerfile )
142
+ fs.writeFileSync( dockerfilePath, renderedDockerfile ) // eslint-disable-line security/detect-non-literal-fs-filename
143
143
 
144
144
  log( chalk.yellow( '\nBuilding Docker image...' ) )
145
145
  const cloudBuildSubmit = 'gcloud builds submit --project leverege-registry'
@@ -96,7 +96,7 @@ if ( args.init ) {
96
96
  errorExit( '\n***ERROR: expected to run in the root of a platform-k8s branch - no overwhelm.yaml present' )
97
97
  }
98
98
 
99
- if ( fs.existsSync( args.compass ) ) {
99
+ if ( fs.existsSync( args.compass ) ) { // eslint-disable-line security/detect-non-literal-fs-filename
100
100
  errorExit( `\n***ERROR: ${args.compass} compass file already exists - not overwriting` )
101
101
  }
102
102
 
@@ -107,12 +107,12 @@ if ( args.init ) {
107
107
 
108
108
  // simply wraps the YAML read/sync
109
109
  const buildCompassMap = ( yamlFile ) => {
110
- if ( !fs.existsSync( yamlFile ) ) {
110
+ if ( !fs.existsSync( yamlFile ) ) { // eslint-disable-line security/detect-non-literal-fs-filename
111
111
  debug( `chart-compass file ${yamlFile} does not exist` )
112
112
  process.exit( 1 )
113
113
  }
114
114
 
115
- const chartCompass = YAML.load( fs.readFileSync( yamlFile, 'utf8' ) )
115
+ const chartCompass = YAML.load( fs.readFileSync( yamlFile, 'utf8' ) ) // eslint-disable-line security/detect-non-literal-fs-filename
116
116
  return chartCompass
117
117
  }
118
118
 
@@ -151,7 +151,7 @@ try {
151
151
  } else {
152
152
  errorExit( `\n***ERROR: chart ${chartName} version ${chartVersion} already exists` )
153
153
  }
154
- } catch ( error ) {
154
+ } catch ( error ) { // eslint-disable-line no-unused-vars
155
155
  debug( `Chart ${chartName} version ${chartVersion} does not exist - proceeding` )
156
156
  }
157
157
 
@@ -123,7 +123,7 @@ const runner = async ( projects ) => {
123
123
  log( `Project [${project}]` )
124
124
  try {
125
125
  await prepareContext( project ) // eslint-disable-line no-await-in-loop
126
- } catch ( error ) {
126
+ } catch ( error ) { // eslint-disable-line no-unused-vars
127
127
  log( `Project or context is invalid, skipping [${chalk.redBright( project )}]` )
128
128
  continue
129
129
  }
@@ -59,6 +59,7 @@ export default class DashboardManager {
59
59
  // leaf directory — apply JSON files using basename as the Grafana folder name
60
60
  const folderName = path.basename( dir )
61
61
  for ( const file of jsonFiles ) {
62
+ // eslint-disable-next-line no-await-in-loop
62
63
  const name = await this.#applyDashboard( folderName, path.join( dir, file.name ) )
63
64
  if ( name ) applied.add( name )
64
65
  }
@@ -79,6 +80,7 @@ export default class DashboardManager {
79
80
  .filter( f => f.endsWith( '.json' ) )
80
81
 
81
82
  for ( const file of files ) {
83
+ // eslint-disable-next-line no-await-in-loop
82
84
  const name = await this.#applyDashboard( folder.name, path.join( dir, folder.name, file ) )
83
85
  if ( name ) applied.add( name )
84
86
  }
@@ -159,6 +161,7 @@ export default class DashboardManager {
159
161
  if ( subDirs.length === 0 ) {
160
162
  const folderName = path.basename( dir )
161
163
  for ( const file of jsonFiles ) {
164
+ // eslint-disable-next-line no-await-in-loop
162
165
  const name = await this.#applyDashboard( folderName, path.join( dir, file.name ), local )
163
166
  if ( name ) applied.add( name )
164
167
  }
@@ -168,6 +171,7 @@ export default class DashboardManager {
168
171
  .filter( f => f.endsWith( '.json' ) )
169
172
 
170
173
  for ( const file of files ) {
174
+ // eslint-disable-next-line no-await-in-loop
171
175
  const name = await this.#applyDashboard( folder.name, path.join( dir, folder.name, file ), local )
172
176
  if ( name ) applied.add( name )
173
177
  }
@@ -259,6 +263,7 @@ export default class DashboardManager {
259
263
  continue
260
264
  }
261
265
  try {
266
+ // eslint-disable-next-line no-await-in-loop
262
267
  await api.deleteNamespacedConfigMap( { name, namespace : this.#namespace } )
263
268
  log( chalk.red( ` ✗ pruned ${name}` ) )
264
269
  } catch ( e ) {
@@ -290,6 +295,7 @@ export default class DashboardManager {
290
295
  continue
291
296
  }
292
297
  try {
298
+ // eslint-disable-next-line no-await-in-loop
293
299
  await api.deleteNamespacedConfigMap( { name, namespace : this.#namespace } )
294
300
  log( chalk.red( ` ✗ pruned (local) ${name}` ) )
295
301
  } catch ( e ) {
@@ -79,7 +79,6 @@ const targets = Object
79
79
  // Store the longest length of site id for formatting later on
80
80
  maxSiteIdLength = Math.max( siteId.length, maxSiteIdLength )
81
81
 
82
- // eslint-disable-next-line no-param-reassign
83
82
  prev[alias] = {
84
83
  projectId,
85
84
  siteId,
@@ -65,7 +65,6 @@ const targets = Object
65
65
  .entries( config.hosting )
66
66
  .forEach( ( [ siteId, aliases ] ) => {
67
67
  aliases.forEach( ( alias ) => {
68
- // eslint-disable-next-line no-param-reassign
69
68
  prev[alias] = {
70
69
  projectId,
71
70
  siteId,
package/src/overwhelm.mjs CHANGED
@@ -26,7 +26,7 @@ import {
26
26
  } from './Utils.mjs'
27
27
 
28
28
  const optionsDefinitions = [
29
- /* eslint-disable no-multi-spaces */
29
+ /* DISABLED eslint-disable no-multi-spaces */
30
30
  { name : 'context', alias : 'x', type : String, default : '' },
31
31
  { name : 'deprecated', alias : 'd', type : Boolean, default : false },
32
32
  { name : 'section', alias : 's', type : String, default : 'default' },
@@ -38,7 +38,7 @@ const optionsDefinitions = [
38
38
  { name : 'genvals', alias : 'g', type : Boolean, default : false }, // only generates values.yaml
39
39
  { name : 'matchk8s', alias : 'm', type : Boolean, default : false }, // checks k8s context
40
40
  { name : 'verbose', alias : 'v', type : Boolean, default : false },
41
- /* eslint-enable no-multi-spaces */
41
+ /* DISABLED eslint-enable no-multi-spaces */
42
42
  ]
43
43
  const args = cliArgs( optionsDefinitions )
44
44
 
@@ -307,12 +307,12 @@ ahoy.forEach( ( dir ) => {
307
307
  const valuesAll = YAML.load( valuesOut ) || {}
308
308
  const valuesSvc = {
309
309
  service : {
310
- /* eslint-disable no-template-curly-in-string */
310
+ /* DISABLE eslint-disable no-template-curly-in-string */
311
311
  project_id : '${PROJECT_ID}',
312
312
  project_name : '${PROJECT_NAME}',
313
313
  host : '${HOST}',
314
314
  ingress : '${INGRESS}',
315
- /* eslint-enable no-template-curly-in-string */
315
+ /* DISABLE eslint-enable no-template-curly-in-string */
316
316
  }
317
317
  }
318
318
  const valuesMerged = YAML.dump( deepmerge( valuesSvc, valuesAll ), { quotingType : '"' } )
@@ -342,33 +342,11 @@ if ( over.PROJECT_NAME === 'minikube' ) {
342
342
  const projectId = over.PROJECT_ID
343
343
  const zone = over.GCE_REGION + ( over.GCE_ZONE ? `-${over.GCE_ZONE}` : '' )
344
344
 
345
- if ( !clusterName ) {
346
- /* eslint-disable quotes */
347
- log( chalk.yellow(
348
- `
349
-
350
- The overwhelm.yaml file in this branch is missing a CLUSTER_NAME setting,
351
- which was added to support cluster names that do not match the project
352
- name. Since the mismatch is rare, you can probably get by with simply
353
- adding this line following PROJECT_NAME in the default section of
354
- overwhelm.yaml:
355
-
356
- ${chalk.bold.green( `CLUSTER_NAME : '\${PROJECT_NAME}'` )}
357
-
358
- However, if the CLUSTER_NAME is not the same as the PROJECT_NAME then go
359
- ahead and add the CLUSTER_NAME setting to the ${chalk.bold.green( projectId )} section of the
360
- overwhelm.yaml file.
361
-
362
- ` ) )
363
- /* eslint-enable quotes */
364
- process.exit( 1 )
365
- }
366
-
367
345
  // the kubectl call will throw if there isn't an existing context
368
346
  let currentCtx = '_no_current_context_'
369
347
  try {
370
348
  currentCtx = await shellCmd( 'kubectl config current-context' )
371
- } catch ( err ) {
349
+ } catch ( err ) { // eslint-disable-line no-unused-vars
372
350
  // err && log( `Caught Error =>[${err}]` )
373
351
  }
374
352
 
@@ -386,7 +364,7 @@ if ( args.fetchctx ) {
386
364
  if ( !matchedCtx ) {
387
365
  try {
388
366
  await shellCmd( cmd )
389
- } catch ( err ) {
367
+ } catch ( err ) { // eslint-disable-line no-unused-vars
390
368
  process.exit( 61 ) // ECONNREFUSED
391
369
  }
392
370
  }
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- /* eslint-disable security/detect-non-literal-fs-filename, no-multi-spaces, key-spacing */
2
+ /* eslint-disable security/detect-non-literal-fs-filename */
3
3
  import fs from 'node:fs'
4
4
  import path from 'node:path'
5
5
 
@@ -94,12 +94,14 @@ const cliOptionList = [ // Use cliOptionList to tie into the Usage statements
94
94
  default : false,
95
95
  description : '{green display this help screen}',
96
96
  },
97
- { name : 'version',
97
+ {
98
+ name : 'version',
98
99
  type : Boolean,
99
100
  default : false,
100
101
  description : '{green returns the build-tools repo version}',
101
102
  },
102
- { name : 'verbose',
103
+ {
104
+ name : 'verbose',
103
105
  alias : 'v',
104
106
  type : Boolean,
105
107
  default : false,
@@ -114,7 +116,8 @@ const sections = [
114
116
  {green This utility attempts to ease the pain of managing IAM roles and the creation of service accounts for new clusters and services.}
115
117
  `,
116
118
  },
117
- { header : 'Options',
119
+ {
120
+ header : 'Options',
118
121
  optionList : cliOptionList,
119
122
  },
120
123
  ]
@@ -57,7 +57,7 @@ export default class Config {
57
57
  Remove => ` + chalk.yellow.bold( dumpDir ) )
58
58
  process.exit( 1 )
59
59
  }
60
- } catch ( err ) {
60
+ } catch ( err ) { // eslint-disable-line no-unused-vars
61
61
  // this file does not exist is a good thing
62
62
  }
63
63
 
@@ -24,7 +24,7 @@ export default class RolesManager {
24
24
  /* eslint-disable-next-line no-await-in-loop */
25
25
  await shellCmd( `gcloud iam roles ${iamVerb} ${roleName} --project ${k8sProject}` )
26
26
  iamVerb = 'update' // no err then the role exists - do an update
27
- } catch ( err ) {
27
+ } catch ( err ) { // eslint-disable-line no-unused-vars
28
28
  iamVerb = 'create' // failed call so role does not exist - create it
29
29
  }
30
30
 
@@ -42,7 +42,7 @@ export default class SecretsManager {
42
42
  try {
43
43
  await shellCmd( `gcloud secrets describe ${key} --project ${project}` )
44
44
  exists = true
45
- } catch ( err ) {
45
+ } catch ( err ) { // eslint-disable-line no-unused-vars
46
46
  exists = false
47
47
  }
48
48
 
@@ -72,7 +72,7 @@ export default class SecretsManager {
72
72
  if ( labelStr ) createCmd.push( `--labels=${labelStr}` )
73
73
  if ( annotationStr ) createCmd.push( `--set-annotations=${annotationStr}` )
74
74
  await shellCmd( createCmd, { input : value } )
75
- } catch ( err ) {
75
+ } catch ( err ) { // eslint-disable-line no-unused-vars
76
76
  log( chalk.red( `\nSM secret write failed for ${key}\n` ) )
77
77
  }
78
78
  }
@@ -136,7 +136,7 @@ ${dataLines}
136
136
  log( ` Applying ExternalSecret => ${chalk.green( name )} in ${chalk.yellow( namespace )}` )
137
137
  try {
138
138
  await shellCmd( [ 'kubectl', 'apply', '-f', '-' ], { input : yaml } ) // eslint-disable-line no-await-in-loop
139
- } catch ( err ) {
139
+ } catch ( err ) { // eslint-disable-line no-unused-vars
140
140
  log( chalk.red( `\nExternalSecret apply failed for ${name}\n` ) )
141
141
  }
142
142
  }
@@ -74,7 +74,7 @@ export default class ServiceAccountManager {
74
74
  try {
75
75
  await shellCmd( `${command} ${options}` ) // eslint-disable-line no-await-in-loop
76
76
  return true
77
- } catch ( err ) {
77
+ } catch ( err ) { // eslint-disable-line no-unused-vars
78
78
  log( ' IAM propagating => ', chalk.yellow( role ) )
79
79
  }
80
80
  await delayWithBackoff( retryCount ) // eslint-disable-line no-await-in-loop
@@ -108,7 +108,7 @@ export default class ServiceAccountManager {
108
108
  try {
109
109
  await shellCmd( `${command} ${options}` ) // eslint-disable-line no-await-in-loop
110
110
  return true
111
- } catch ( err ) {
111
+ } catch ( err ) { // eslint-disable-line no-unused-vars
112
112
  await delayWithBackoff( retryCount ) // eslint-disable-line no-await-in-loop
113
113
  }
114
114
  }
@@ -136,7 +136,7 @@ export default class ServiceAccountManager {
136
136
  if ( shellOut.match( `email: ${serviceName}` ) ) {
137
137
  return true
138
138
  }
139
- } catch ( err ) {
139
+ } catch ( err ) { // eslint-disable-line no-unused-vars
140
140
  log( ' SA propagating => ', chalk.yellow( serviceName ) )
141
141
  await delayWithBackoff( retryCount ) // eslint-disable-line no-await-in-loop
142
142
  }
@@ -220,7 +220,7 @@ export default class ServiceAccountManager {
220
220
  log( '\nSkip existing SvcAct =>', chalk.yellow( saName ) )
221
221
  continue
222
222
  }
223
- } catch ( err ) {
223
+ } catch ( err ) { // eslint-disable-line no-unused-vars
224
224
  log( '\nCreating new SvcAcct =>', chalk.green( saName ) )
225
225
  }
226
226
 
package/src/unleash.mjs CHANGED
@@ -39,7 +39,7 @@ const npmRunner = async ( script ) => {
39
39
  const cmd = `npm run ${script}`
40
40
  const results = await shellCmd( cmd, { stdio : 'inherit' } )
41
41
  return results
42
- } catch ( err ) {
42
+ } catch ( err ) { // eslint-disable-line no-unused-vars
43
43
  process.exit( 1 )
44
44
  }
45
45
  return undefined