@leverege/build-tools 2.48.0 → 2.48.2
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/package.json +1 -1
- package/src/Utils.mjs +29 -3
- package/src/chart-compass.mjs +81 -0
- package/src/chart-to-registry.mjs +31 -14
- package/src/docker-to-registry.mjs +1 -1
- package/src/dockreate.sh +3 -1
package/package.json
CHANGED
package/src/Utils.mjs
CHANGED
|
@@ -125,7 +125,7 @@ export const getGitUpstream = async () => {
|
|
|
125
125
|
|
|
126
126
|
export const gitRepoIsDirty = async () => {
|
|
127
127
|
const cleanliness = await shellCmd( 'git status --porcelain' )
|
|
128
|
-
return cleanliness?.length
|
|
128
|
+
return cleanliness?.length > 0
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
export const parseJsonFile = async ( jsonFile ) => {
|
|
@@ -278,7 +278,7 @@ https://console.cloud.google.com/artifacts/browse/leverege-registry?project=leve
|
|
|
278
278
|
}
|
|
279
279
|
|
|
280
280
|
// DEPRECATED: old reference to ./dist should be ./build
|
|
281
|
-
const { build, clean, dockerize, } = packageJson.scripts
|
|
281
|
+
const { build, clean, dockerize, museum, } = packageJson.scripts
|
|
282
282
|
|
|
283
283
|
if ( build.match( 'dist' ) || clean.match( 'dist' ) ) {
|
|
284
284
|
const deprecationError = `
|
|
@@ -315,6 +315,24 @@ https://console.cloud.google.com/artifacts/browse/leverege-registry?project=leve
|
|
|
315
315
|
|
|
316
316
|
deprecated( { deprecationError, deprecationInfo } )
|
|
317
317
|
}
|
|
318
|
+
|
|
319
|
+
// DEPRECATED: old museum reference to push-my-chart instead of chart-to-registry
|
|
320
|
+
if ( museum.match( 'push-my-chart' ) ) {
|
|
321
|
+
const deprecationError = `
|
|
322
|
+
|
|
323
|
+
Update the npm museum script to use chart-to-registry instead of the deprecated
|
|
324
|
+
push-my-chart script. The new museum target is simply:
|
|
325
|
+
`
|
|
326
|
+
const deprecationInfo = `
|
|
327
|
+
"scripts": {
|
|
328
|
+
...
|
|
329
|
+
${chalk.green.bold( '"museum": "chart-to-registry",' )}
|
|
330
|
+
...
|
|
331
|
+
},
|
|
332
|
+
`
|
|
333
|
+
|
|
334
|
+
deprecated( { deprecationError, deprecationInfo } )
|
|
335
|
+
}
|
|
318
336
|
return { artifactRegistry, ...packageJson }
|
|
319
337
|
}
|
|
320
338
|
|
|
@@ -323,13 +341,21 @@ export const parseHelmChart = async ( helmroot = './helm' ) => {
|
|
|
323
341
|
if ( !existsSync( helmroot ) ) { return undefined }
|
|
324
342
|
const chartFiles = readdirSync( helmroot, { encoding : 'utf8', recursive : true } )
|
|
325
343
|
const chartYaml = YAML.load( readFileSync( `${helmroot}/Chart.yaml`, 'utf8' ) )
|
|
344
|
+
const chartPackage = `${chartYaml.name}-${chartYaml.version}.tgz`
|
|
326
345
|
const valuesYaml = YAML.load( readFileSync( `${helmroot}/values.yaml`, 'utf8' ) )
|
|
346
|
+
const imageRegistry = valuesYaml.image?.registry
|
|
347
|
+
const registryComponents = imageRegistry.split( '/' )
|
|
327
348
|
/* eslint-enable security/detect-non-literal-fs-filename */
|
|
328
349
|
return ( {
|
|
350
|
+
chartPackage,
|
|
351
|
+
imageRegistry,
|
|
352
|
+
registryRegion : registryComponents[0],
|
|
353
|
+
registryProject : registryComponents[1],
|
|
354
|
+
registryRepository : registryComponents[2],
|
|
329
355
|
files : chartFiles,
|
|
330
356
|
yaml : {
|
|
331
357
|
'Chart.yaml' : chartYaml,
|
|
332
|
-
'values.yaml' : valuesYaml
|
|
358
|
+
'values.yaml' : valuesYaml,
|
|
333
359
|
}
|
|
334
360
|
} )
|
|
335
361
|
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/*
|
|
3
|
+
* chart-to-registry will...
|
|
4
|
+
*/
|
|
5
|
+
import { existsSync, rmSync } from 'node:fs'
|
|
6
|
+
|
|
7
|
+
import chalk from 'chalk'
|
|
8
|
+
import commandLineArgs from 'command-line-args'
|
|
9
|
+
import commandLineUsage from 'command-line-usage'
|
|
10
|
+
import { lt as semverLt } from 'semver'
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
debug,
|
|
14
|
+
errorExit,
|
|
15
|
+
log,
|
|
16
|
+
getGitRootDirectory,
|
|
17
|
+
parsePackageJson,
|
|
18
|
+
parseHelmChart,
|
|
19
|
+
shellCmd } from './Utils.mjs'
|
|
20
|
+
|
|
21
|
+
const commandLineOptions = [ // Use commandLineOptions to tie into the Usage statements
|
|
22
|
+
/* eslint-disable max-len */
|
|
23
|
+
{
|
|
24
|
+
name : 'location',
|
|
25
|
+
type : String,
|
|
26
|
+
defaultValue : 'us-docker.pkg.dev',
|
|
27
|
+
description : '{green the location of the artifact registry the chart will be pushed to (default us-docker.pkg.dev)}',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name : 'project',
|
|
31
|
+
type : String,
|
|
32
|
+
defaultValue : process.env.HELM_CHART_REGISTRY || 'leverege-registry',
|
|
33
|
+
description : '{green the name of the google project containing the npmrc and slack config secrets (default leverege-registry)}',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name : 'repository',
|
|
37
|
+
type : String,
|
|
38
|
+
description : '{green the target repository to receive the pushed chart}',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name : 'help',
|
|
42
|
+
type : Boolean,
|
|
43
|
+
description : '{green display this help screen}',
|
|
44
|
+
},
|
|
45
|
+
/* eslint-enable max-len */
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
const sections = [
|
|
49
|
+
{
|
|
50
|
+
header : 'Leverege Helm Chart Location Tool',
|
|
51
|
+
content : `{green A tool for locating helm charts in registries. It was created to allow
|
|
52
|
+
the helmup.sh bash script to easily locate charts, which may be in the
|
|
53
|
+
chart museum, La everge artifact-registry project or a 3rd party
|
|
54
|
+
developer\'s artifact-registry.}`
|
|
55
|
+
},
|
|
56
|
+
{ header : 'Options',
|
|
57
|
+
optionList : commandLineOptions,
|
|
58
|
+
},
|
|
59
|
+
]
|
|
60
|
+
|
|
61
|
+
const args = commandLineArgs( commandLineOptions, { camelCase : true, partial : true } )
|
|
62
|
+
const usage = commandLineUsage( sections )
|
|
63
|
+
|
|
64
|
+
if ( args.help ) {
|
|
65
|
+
log( usage )
|
|
66
|
+
process.exit( 0 )
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/* eslint-disable no-underscore-dangle */
|
|
70
|
+
if ( args._unknown ) {
|
|
71
|
+
log( usage )
|
|
72
|
+
log( `\nUnrecognized argument [${chalk.bold.red( args._unknown )}]\n` )
|
|
73
|
+
process.exit( 1 )
|
|
74
|
+
}
|
|
75
|
+
/* eslint-enable no-underscore-dangle */
|
|
76
|
+
|
|
77
|
+
const minNodejsVersion = '18.0.0'
|
|
78
|
+
if ( semverLt( process.version, minNodejsVersion ) ) {
|
|
79
|
+
errorExit( `\n***ERROR: must be running at least node ${minNodejsVersion}\n` )
|
|
80
|
+
}
|
|
81
|
+
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
/*
|
|
3
3
|
* chart-to-registry will...
|
|
4
4
|
*/
|
|
5
|
+
import { existsSync, rmSync } from 'node:fs'
|
|
5
6
|
|
|
6
7
|
import chalk from 'chalk'
|
|
7
8
|
import commandLineArgs from 'command-line-args'
|
|
@@ -9,7 +10,7 @@ import commandLineUsage from 'command-line-usage'
|
|
|
9
10
|
import { lt as semverLt } from 'semver'
|
|
10
11
|
|
|
11
12
|
import {
|
|
12
|
-
|
|
13
|
+
debug,
|
|
13
14
|
errorExit,
|
|
14
15
|
log,
|
|
15
16
|
getGitRootDirectory,
|
|
@@ -20,16 +21,16 @@ import {
|
|
|
20
21
|
const commandLineOptions = [ // Use commandLineOptions to tie into the Usage statements
|
|
21
22
|
/* eslint-disable max-len */
|
|
22
23
|
{
|
|
23
|
-
name : '
|
|
24
|
+
name : 'location',
|
|
24
25
|
type : String,
|
|
25
|
-
defaultValue :
|
|
26
|
-
description : '{green the
|
|
26
|
+
defaultValue : 'us-docker.pkg.dev',
|
|
27
|
+
description : '{green the location of the artifact registry the chart will be pushed to (default us-docker.pkg.dev)}',
|
|
27
28
|
},
|
|
28
29
|
{
|
|
29
|
-
name : '
|
|
30
|
+
name : 'project',
|
|
30
31
|
type : String,
|
|
31
|
-
defaultValue :
|
|
32
|
-
description : '{green the
|
|
32
|
+
defaultValue : process.env.HELM_CHART_REGISTRY || 'leverege-registry',
|
|
33
|
+
description : '{green the name of the google project containing the npmrc and slack config secrets (default leverege-registry)}',
|
|
33
34
|
},
|
|
34
35
|
{
|
|
35
36
|
name : 'repository',
|
|
@@ -48,7 +49,7 @@ const sections = [
|
|
|
48
49
|
{
|
|
49
50
|
header : 'Leverege Helm Chart to Artifact Registry',
|
|
50
51
|
content : `{green This tool helps ...
|
|
51
|
-
... multi-line
|
|
52
|
+
... multi-line help.}`
|
|
52
53
|
},
|
|
53
54
|
{ header : 'Options',
|
|
54
55
|
optionList : commandLineOptions,
|
|
@@ -76,8 +77,6 @@ if ( semverLt( process.version, minNodejsVersion ) ) {
|
|
|
76
77
|
errorExit( `\n***ERROR: must be running at least node ${minNodejsVersion}\n` )
|
|
77
78
|
}
|
|
78
79
|
|
|
79
|
-
log( { args }, chalk.yellow( '\n\n***WARNING: Under Construction' ) )
|
|
80
|
-
|
|
81
80
|
// gcloud auth print-access-token | helm registry login -u oauth2accesstoken \
|
|
82
81
|
// -p ${password} https://us-docker.pkg.dev
|
|
83
82
|
//
|
|
@@ -86,7 +85,7 @@ try {
|
|
|
86
85
|
const accessToken = await shellCmd( 'gcloud auth print-access-token' )
|
|
87
86
|
const registryLoginCommand = `helm registry login -u oauth2accesstoken -p ${accessToken}`
|
|
88
87
|
|
|
89
|
-
const loginResult = await shellCmd( `${registryLoginCommand} https://${args.
|
|
88
|
+
const loginResult = await shellCmd( `${registryLoginCommand} https://${args.location}` ) // TODO: cmd line param
|
|
90
89
|
debug( { loginResult }, '<==registryLogin' )
|
|
91
90
|
} catch ( error ) {
|
|
92
91
|
errorExit( error )
|
|
@@ -116,7 +115,25 @@ try {
|
|
|
116
115
|
errorExit( error )
|
|
117
116
|
}
|
|
118
117
|
|
|
119
|
-
|
|
118
|
+
debug( { packageJson, helmChart }, '<==Parsed package and chart' )
|
|
119
|
+
|
|
120
|
+
// helm push helm-package.tgz oci://REGISTRY_LOCATION/REGISTRY_PROJECT/REGISTRY_REPOSITORY/charts
|
|
121
|
+
//
|
|
122
|
+
const registryLocation = args.location || helmChart.registryLocation
|
|
123
|
+
const registryProject = args.project || helmChart.registryProject
|
|
124
|
+
const registryRepository = args.repository || helmChart.registryRepository
|
|
125
|
+
const ociPushEndpoint = `oci://${registryLocation}/${registryProject}/${registryRepository}/charts`
|
|
120
126
|
|
|
121
|
-
|
|
122
|
-
|
|
127
|
+
try {
|
|
128
|
+
await shellCmd( 'helm package helm' )
|
|
129
|
+
const { chartPackage } = helmChart
|
|
130
|
+
if ( !existsSync( chartPackage ) ) { // eslint-disable-line security/detect-non-literal-fs-filename
|
|
131
|
+
errorExit( `Error: expected helm package to produce ${chartPackage}` )
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
log( `\nPushing ${chalk.green.bold( chartPackage )} => ${chalk.green.bold( ociPushEndpoint )}` )
|
|
135
|
+
await shellCmd( `helm push ${chartPackage} ${ociPushEndpoint}` )
|
|
136
|
+
rmSync( chartPackage )
|
|
137
|
+
} catch ( err ) {
|
|
138
|
+
errorExit( err )
|
|
139
|
+
}
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
|
|
19
19
|
import docker from './Docker.mjs'
|
|
20
20
|
|
|
21
|
-
const minimumBuildToolsVersion = '2.48.
|
|
21
|
+
const minimumBuildToolsVersion = '2.48.1'
|
|
22
22
|
|
|
23
23
|
// refresh-npm-token does not throw so no need to try, but it emits in debug
|
|
24
24
|
const refreshErr = await shellCmd( 'refresh-npm-token' )
|
package/src/dockreate.sh
CHANGED
|
@@ -10,7 +10,9 @@ fi
|
|
|
10
10
|
. `build-tools --bashfun`
|
|
11
11
|
cat<<DOCKREATE_DEPRECATED
|
|
12
12
|
|
|
13
|
-
`color
|
|
13
|
+
`color r "***DOCKREATE is DEPRECATED - move to docker-to-registry***"`
|
|
14
|
+
|
|
15
|
+
For guidance on transitioning run `color g docker-to-registry guide-me`
|
|
14
16
|
|
|
15
17
|
DOCKREATE_DEPRECATED
|
|
16
18
|
sleep 3
|