RimacTechnology / semantic-release-s3

semantic-release plugin to push files and folders to AWS S3 bucket
MIT License
3 stars 2 forks source link

Error with regex #17

Closed RomainOliva closed 1 year ago

RomainOliva commented 1 year ago

Issues

semantic-release-s3 Version You Are Using

v2.2.2

Your Config

Node: 16 (I tried in 18 it's the same problem) Yarn: 1.22.17

Steps to reproduce

Send a config like this :

{
        awsAccessKeyName: 'LIBRARY_S3_ACCESS_KEY_ENV',
        awsSecretAccessKeyName: 'LIBRARY_S3_SECRET_ACCESS_KEY_ENV',
        removeDirectoryRoot: true,
        s3Bucket: {
          branchName: `my-bucket/v1.1.0`,
        },
        directoryPath: 'dist/**/*',
},

Expected behavior

The problem came from this change :

https://github.com/RimacTechnology/semantic-release-s3/commit/e31cc03beccb52330ad313ba9ac1cc4c78d88407#diff-a7a74f2666de0f501942c3e3c0ff9146e86f8fb359f8cf521dcdb205490b0e3eR34

This throw the error below (i try in the chrome console too)

Do you have any idea of the problem ?

Thanks a lot :)

Actual behavior


    at publish (/home/runner/work/gtr-form-renderer/gtr-form-renderer/node_modules/@rimac-technology/semantic-release-s3/lib/publish.js:46:55)
    at async validator (/home/runner/work/gtr-form-renderer/gtr-form-renderer/node_modules/semantic-release/lib/plugins/normalize.js:34:24)
    at async /home/runner/work/gtr-form-renderer/gtr-form-renderer/node_modules/semantic-release/lib/plugins/pipeline.js:37:34
    at async Promise.all (index 0)
    at async next (/home/runner/work/gtr-form-renderer/gtr-form-renderer/node_modules/p-reduce/index.js:16:18) {
  pluginName: '@rimac-technology/semantic-release-s3'
}
The automated release failed with SyntaxError: Invalid regular expression: /\$([_a-z]+\w*)|\${(\w*)}/: Incomplete quantifier
    at publish (/home/runner/work/gtr-form-renderer/gtr-form-renderer/node_modules/@rimac-technology/semantic-release-s3/lib/publish.js:46:55)
    at async validator (/home/runner/work/gtr-form-renderer/gtr-form-renderer/node_modules/semantic-release/lib/plugins/normalize.js:34:24)
    at async /home/runner/work/gtr-form-renderer/gtr-form-renderer/node_modules/semantic-release/lib/plugins/pipeline.js:37:34
    at async Promise.all (index 0)
    at async next (/home/runner/work/gtr-form-renderer/gtr-form-renderer/node_modules/p-reduce/index.js:16:18) {
  pluginName: '@rimac-technology/semantic-release-s3'
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.```

### Requirements

- [X] I have read and followed the instructions above and understand that my issue will be closed if I did not provide the required information.
RomainOliva commented 1 year ago

My bad it's not the JS compilation, it's from a commit change, I edit the issue

mario-jerkovic commented 1 year ago

Thank you for reporting the issue, we will take a look ang get back to you.

RomainOliva commented 1 year ago

I have the fix but I don't have the right to push my PR, there is the fix :

const bucketPrefix = bucketPrefixes.join(path.sep).replace(/\$([_a-z]+\w*)|\$\{(\w*)\}/giu, (match, p1, p2) => {
        return process.env[p1 || p2] ?? match
    })

You have just to escape { and } caracters

vuki656 commented 1 year ago

I have the fix but I don't have the right to push my PR, there is the fix :

const bucketPrefix = bucketPrefixes.join(path.sep).replace(/\$([_a-z]+\w*)|\$\{(\w*)\}/giu, (match, p1, p2) => {
        return process.env[p1 || p2] ?? match
    })

You have just to escape { and } caracters

Not sure I follow, are you not able to open a PR or?

If this is tested, we can update it.

RomainOliva commented 1 year ago

Yes i don't have permission : image

I test the regex online yes :

image

it's the same regex but escaped to avoid the js error

RomainOliva commented 1 year ago

Can you just commit the fix and release with the regex escaped please 😇 ?

mario-jerkovic commented 1 year ago

@RomainOliva Yes, you don't have permission to push in this repository. If you want to contribute than follow this guide on how to open a PR from fork a repository LINK or you can follow this guide LINK

RomainOliva commented 1 year ago

The PR is created : https://github.com/RimacTechnology/semantic-release-s3/pull/18

rimac-technology commented 1 year ago

:tada: This issue has been resolved in version 2.2.3 :tada:

The release is available on:

Your semantic-release bot :package::rocket: