diff --git a/packages/gcp-storage/README.md b/packages/gcp-storage/README.md index 97d15715..98031f67 100644 --- a/packages/gcp-storage/README.md +++ b/packages/gcp-storage/README.md @@ -20,9 +20,9 @@ npm install -D @nx-extend/gcp-storage #### Available options: -| name | type | default | description | -|----------------|---------|---------|--------------------------------------------------| -| bucket | string | | What bucket to upload to | -| directory | string | `/` | What directory of the apps dist folder to upload | -| gzip | boolean | false | Use gzip when uploading | -| gzipExtensions | string | | For what extensions to use gzip | +| name | type | default | description | +|----------------|---------|---------|---------------------------------| +| bucket | string | | What bucket to upload to | +| directory | string | | Directory to upload | +| gzip | boolean | false | Use gzip when uploading | +| gzipExtensions | string | | For what extensions to use gzip | diff --git a/packages/gcp-storage/executors.json b/packages/gcp-storage/executors.json index 15908389..ec6192c0 100644 --- a/packages/gcp-storage/executors.json +++ b/packages/gcp-storage/executors.json @@ -2,7 +2,7 @@ "executors": { "upload": { "implementation": "./src/executors/upload/upload.impl", - "schema": "./src/executors/executors/schema.json", + "schema": "./src/executors/upload/schema.json", "description": "Upload to GCP storage" } }, diff --git a/packages/gcp-storage/src/executors/upload/schema.json b/packages/gcp-storage/src/executors/upload/schema.json index 14c46c9b..94b49bcc 100644 --- a/packages/gcp-storage/src/executors/upload/schema.json +++ b/packages/gcp-storage/src/executors/upload/schema.json @@ -12,8 +12,7 @@ }, "directory": { "type": "string", - "description": "Folder from the outputPath to upload", - "default": "" + "description": "Directory to upload" }, "gzip": { "type": "boolean", @@ -25,5 +24,8 @@ "description": "What extensions to gzip", "default": "js,css,html" } - } + }, + "directory": [ + "name" + ] } diff --git a/packages/gcp-storage/src/executors/upload/upload.impl.ts b/packages/gcp-storage/src/executors/upload/upload.impl.ts index 3bf82b60..f6e92b6a 100644 --- a/packages/gcp-storage/src/executors/upload/upload.impl.ts +++ b/packages/gcp-storage/src/executors/upload/upload.impl.ts @@ -13,30 +13,26 @@ export async function uploadExecutor( options: UploadExecutorSchema, context: ExecutorContext ): Promise<{ success: boolean }> { - const { targets } = context.workspace.projects[context.projectName] const { directory, gzip = false, gzipExtensions, bucket } = options - const directoryToUpload = join( - join(context.root, targets?.build?.options?.outputPath.toString()), - directory - ) + if (!directory) { + throw new Error('"directory" is required!') + } + + const directoryToUpload = join(context.root, directory) const uploadTo = `gs://${bucket}` - logger.info( - `Start upload assets from "${directoryToUpload}" to "${uploadTo}"` - ) + logger.info(`Start upload assets from "${directoryToUpload}" to "${uploadTo}"`) return Promise.resolve( - execCommand( - buildCommand([ - 'gsutil rsync -R', - gzip && `-z "${gzipExtensions}"`, - - resolve(process.cwd(), directoryToUpload), - uploadTo - ]) - ) + execCommand(buildCommand([ + 'gsutil rsync -R', + gzip && `-z "${gzipExtensions}"`, + + resolve(process.cwd(), directoryToUpload), + uploadTo + ])) ) }