@leverege/build-tools 2.93.3-beta.3 → 2.93.3-beta.5
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
CHANGED
package/src/artifacts/Utils.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { parseYamlFile, err, warning, debug, shellCmd } from '../Utils.mjs'
|
|
|
8
8
|
|
|
9
9
|
import { ArtifactTypeEnum, ArtifactsSchema, GenericArtifactSchema } from './Structs.mjs'
|
|
10
10
|
|
|
11
|
-
const getArtifactsSchema = async ( artifactsFilePath = './artifacts.
|
|
11
|
+
const getArtifactsSchema = async ( artifactsFilePath = './artifacts.yaml' ) => {
|
|
12
12
|
const artifactsConfig = await parseYamlFile( artifactsFilePath )
|
|
13
13
|
const [ error, result ] = validate( artifactsConfig, ArtifactsSchema )
|
|
14
14
|
if ( error ) {
|
|
@@ -163,7 +163,6 @@ const calculateHash = async ( path ) => {
|
|
|
163
163
|
hash.update( await fs.promises.readFile( path ) )
|
|
164
164
|
return `${hash.digest( 'base64url' )}=`
|
|
165
165
|
} catch ( error ) {
|
|
166
|
-
console.error( error )
|
|
167
166
|
throw new Error( `Failed to calculate hash for artifact ${path}: ${error.message}` )
|
|
168
167
|
}
|
|
169
168
|
}
|
|
@@ -13,26 +13,35 @@ import { GenericArtifactPuller } from './ArtifactPuller.mjs'
|
|
|
13
13
|
program
|
|
14
14
|
.name( 'pull-artifact' )
|
|
15
15
|
.description( 'Pull artifacts from GCP Artifact Registry' )
|
|
16
|
-
.
|
|
17
|
-
.
|
|
18
|
-
.requiredOption( '-l, --location <location>', 'GCP location' )
|
|
19
|
-
.requiredOption( '-r, --repository <repository>', 'GCP artifact registry repository' )
|
|
20
|
-
.requiredOption( '-n --package <name>', 'GCP artifact registry package name' )
|
|
21
|
-
.requiredOption( '-v, --version <version>', 'GCP artifact registry package version' )
|
|
16
|
+
.option( '-f, --file <path>', 'Path to artifacts.yaml file', './artifacts.yaml' )
|
|
17
|
+
.option( '-a, --artifact <artifact-path>', 'GCP artifact path' )
|
|
22
18
|
.parse()
|
|
23
19
|
|
|
24
20
|
const options = program.opts()
|
|
25
21
|
|
|
26
22
|
async function main() {
|
|
27
|
-
const artifactsSchema = await getArtifactsSchema( options.
|
|
23
|
+
const artifactsSchema = await getArtifactsSchema( options.file )
|
|
28
24
|
const flattenedArtifactsSchema = flattenArtifactsSchema( artifactsSchema )
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
25
|
+
|
|
26
|
+
let filteredArtifactsSchema = flattenedArtifactsSchema
|
|
27
|
+
|
|
28
|
+
if ( options.artifact ) {
|
|
29
|
+
const artifactPathElements = options.artifact.split( '/' )
|
|
30
|
+
|
|
31
|
+
if ( artifactPathElements.length !== 5 ) {
|
|
32
|
+
warning( 'Invalid artifact path, it must be in the format <project>/<location>/<repository>/<package>/<version>' )
|
|
33
|
+
return false
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const [ project, location, repository, packageName, version ] = artifactPathElements
|
|
37
|
+
|
|
38
|
+
filteredArtifactsSchema = flattenedArtifactsSchema.filter(
|
|
39
|
+
artifact => artifact.project === project &&
|
|
40
|
+
artifact.location === location &&
|
|
41
|
+
artifact.repository === repository &&
|
|
42
|
+
artifact.package === packageName &&
|
|
43
|
+
artifact.version === version )
|
|
44
|
+
}
|
|
36
45
|
|
|
37
46
|
let counter = 0
|
|
38
47
|
|
|
@@ -65,6 +74,8 @@ async function main() {
|
|
|
65
74
|
counter = pullResults.filter( Boolean ).length
|
|
66
75
|
|
|
67
76
|
log( `Successfully pulled ${counter}/${filteredArtifactsSchema.length} artifacts` )
|
|
77
|
+
|
|
78
|
+
return counter === filteredArtifactsSchema.length
|
|
68
79
|
}
|
|
69
80
|
|
|
70
81
|
main()
|
|
@@ -13,26 +13,34 @@ import { GenericArtifactPusher } from './ArtifactPusher.mjs'
|
|
|
13
13
|
program
|
|
14
14
|
.name( 'push-artifact' )
|
|
15
15
|
.description( 'Push artifacts to GCP Artifact Registry' )
|
|
16
|
-
.
|
|
17
|
-
.
|
|
18
|
-
.requiredOption( '-l, --location <location>', 'GCP location' )
|
|
19
|
-
.requiredOption( '-r, --repository <repository>', 'GCP artifact registry repository' )
|
|
20
|
-
.requiredOption( '-n --package <name>', 'GCP artifact registry package name' )
|
|
21
|
-
.requiredOption( '-v, --version <version>', 'GCP artifact registry package version' )
|
|
16
|
+
.option( '-f, --file <path>', 'Path to artifacts.yaml file', './artifacts.yaml' )
|
|
17
|
+
.option( '-a, --artifact <artifact-path>', 'GCP artifact path' )
|
|
22
18
|
.parse()
|
|
23
19
|
|
|
24
20
|
const options = program.opts()
|
|
25
21
|
|
|
26
22
|
async function main() {
|
|
27
|
-
const artifactsSchema = await getArtifactsSchema( options.
|
|
23
|
+
const artifactsSchema = await getArtifactsSchema( options.file )
|
|
28
24
|
const flattenedArtifactsSchema = flattenArtifactsSchema( artifactsSchema )
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
25
|
+
|
|
26
|
+
let filteredArtifactsSchema = flattenedArtifactsSchema
|
|
27
|
+
|
|
28
|
+
if ( options.artifact ) {
|
|
29
|
+
const artifactPathElements = options.artifact.split( '/' )
|
|
30
|
+
if ( artifactPathElements.length !== 5 ) {
|
|
31
|
+
warning( 'Invalid artifact path, it must be in the format <project>/<location>/<repository>/<package>/<version>' )
|
|
32
|
+
return false
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const [ project, location, repository, packageName, version ] = artifactPathElements
|
|
36
|
+
|
|
37
|
+
filteredArtifactsSchema = flattenedArtifactsSchema.filter(
|
|
38
|
+
artifact => artifact.project === project &&
|
|
39
|
+
artifact.location === location &&
|
|
40
|
+
artifact.repository === repository &&
|
|
41
|
+
artifact.package === packageName &&
|
|
42
|
+
artifact.version === version )
|
|
43
|
+
}
|
|
36
44
|
|
|
37
45
|
let counter = 0
|
|
38
46
|
|
|
@@ -65,6 +73,8 @@ async function main() {
|
|
|
65
73
|
counter = pushResults.filter( Boolean ).length
|
|
66
74
|
|
|
67
75
|
log( `Successfully pushed ${counter}/${filteredArtifactsSchema.length} artifacts` )
|
|
76
|
+
|
|
77
|
+
return counter === filteredArtifactsSchema.length
|
|
68
78
|
}
|
|
69
79
|
|
|
70
80
|
main()
|