@leverege/build-tools 2.93.0-beta.5 → 2.93.0-beta.6
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
|
@@ -12,6 +12,7 @@ class ArtifactPackager {
|
|
|
12
12
|
hash.update( fs.readFileSync( this.artifact.source_path ) )
|
|
13
13
|
return hash.digest( 'base64url' )
|
|
14
14
|
} catch ( error ) {
|
|
15
|
+
console.error( error )
|
|
15
16
|
throw new Error( `Failed to calculate hash for artifact ${this.artifact.name}: ${error.message}` )
|
|
16
17
|
}
|
|
17
18
|
}
|
|
@@ -41,6 +42,35 @@ class ArtifactPackager {
|
|
|
41
42
|
class GenericArtifactPackager extends ArtifactPackager {
|
|
42
43
|
|
|
43
44
|
async exists() {
|
|
45
|
+
|
|
46
|
+
const isDirectory = fs.statSync( this.artifact.source_path ).isDirectory()
|
|
47
|
+
|
|
48
|
+
// If source path is a directory, check whether the destination path alreadu exists in the registry
|
|
49
|
+
if ( isDirectory ) {
|
|
50
|
+
// const command = `gcloud artifacts files list \
|
|
51
|
+
// --project=${this.artifact.gcp_project_id} \
|
|
52
|
+
// --location=${this.artifact.gcp_location} \
|
|
53
|
+
// --repository=${this.artifact.gcp_artifact_registry_repository_name} \
|
|
54
|
+
// --package=${this.artifact.gcp_artifact_registry_package_name} \
|
|
55
|
+
// --version ${this.artifact.gcp_artifact_registry_package_version} \
|
|
56
|
+
// --format="json"`
|
|
57
|
+
// const { execSync } = await import( 'child_process' )
|
|
58
|
+
// const result = execSync( command, { encoding : 'utf8', stdio : 'pipe' } )
|
|
59
|
+
// const files = JSON.parse( result )
|
|
60
|
+
|
|
61
|
+
// // Calculate checksum for each file in the directory
|
|
62
|
+
// // ...
|
|
63
|
+
|
|
64
|
+
// console.log( files )
|
|
65
|
+
// if ( files && files.length > 0 ) {
|
|
66
|
+
// return true
|
|
67
|
+
// }
|
|
68
|
+
// return false
|
|
69
|
+
|
|
70
|
+
// For the time being, return false, and let gcloud skip existing files in upload-time.
|
|
71
|
+
return false
|
|
72
|
+
}
|
|
73
|
+
|
|
44
74
|
// Check if artifact already exists in the registry
|
|
45
75
|
console.log( 'Checking if artifact already exists in the registry...' )
|
|
46
76
|
|
|
@@ -91,15 +121,27 @@ class GenericArtifactPackager extends ArtifactPackager {
|
|
|
91
121
|
|
|
92
122
|
async publish() {
|
|
93
123
|
console.log( 'Publishing artifact to registry...' )
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
124
|
+
|
|
125
|
+
let command = ''
|
|
126
|
+
|
|
127
|
+
command = `gcloud artifacts generic upload \
|
|
128
|
+
--project=${this.artifact.gcp_project_id} \
|
|
129
|
+
--location=${this.artifact.gcp_location} \
|
|
130
|
+
--repository=${this.artifact.gcp_artifact_registry_repository_name} \
|
|
131
|
+
--package=${this.artifact.gcp_artifact_registry_package_name} \
|
|
132
|
+
--version=${this.artifact.gcp_artifact_registry_package_version}`
|
|
133
|
+
|
|
134
|
+
const isDirectory = fs.statSync( this.artifact.source_path ).isDirectory()
|
|
135
|
+
if ( isDirectory ) {
|
|
136
|
+
command += ` --source-directory=${this.artifact.source_path}`
|
|
137
|
+
command += ' --skip-existing'
|
|
138
|
+
} else {
|
|
139
|
+
command += ` --source=${this.artifact.source_path}`
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if ( this.artifact.destination_path ) {
|
|
143
|
+
command += ` --destination-path=${this.artifact.destination_path}`
|
|
144
|
+
}
|
|
103
145
|
|
|
104
146
|
// console.log( 'Command:', command )
|
|
105
147
|
|
|
@@ -31,7 +31,7 @@ const PartialGenericArtifactEntrySchema = assign( PartialArtifactEntrySchema, ob
|
|
|
31
31
|
|
|
32
32
|
const GenericArtifactEntrySchema = assign( ArtifactEntrySchema, object( {
|
|
33
33
|
source_path : string(),
|
|
34
|
-
destination_path : string()
|
|
34
|
+
destination_path : optional( string() )
|
|
35
35
|
} ) )
|
|
36
36
|
|
|
37
37
|
// Superstruct schema for defaults configuration
|
|
@@ -26,6 +26,8 @@ async function main() {
|
|
|
26
26
|
console.error( `No artifact entries found for ${artifactPackageName} version ${artifactPackageVersion} in ${artifactsYmlPath}` )
|
|
27
27
|
process.exit( 1 )
|
|
28
28
|
}
|
|
29
|
+
|
|
30
|
+
// TODO: Use concurrency to package artifacts and provide summary of results.
|
|
29
31
|
for ( const artifactSchema of filteredArtifactSchemas ) {
|
|
30
32
|
let packager
|
|
31
33
|
switch ( artifactSchema.type ) {
|