Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow a developer to remove the 'prod' stage text from bucket name. #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ npm install --save serverless-client-s3
* **Warning:** The plugin will overwrite any data you have in the bucket name you set above if it already exists.
* **Pro Tip:** To add staging and region functionality to your client, use Serverless Variables in the bucket name: `"bucket.name.for.the.client.${stage}.${region}"`

* **Side Note** When hosting a client with a domain name, the bucket name must have exactly the same name as the domain. For this reason you may also optionally specify a regular expression to be replaced in your bucket name to remove, for instance, "prod." from the start of your bucket name:

```js
"bucketName":"${stage}.my.example.com",
"removeBucketRegex":"^prod\\.""
```

**Third**, Create a `client/dist` folder in the root directory of your Serverless project. This is where your distribution-ready website should live. It is recommended to have a `client/src` where you'll be developing your website, and a build script that outputs to `client/dist`. The plugin simply expects and uploads the entire `client/dist` folder to S3, configure the bucket to host the website, and make it publicly available.

Expand Down
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ module.exports = function(S) {
return BbPromise.reject(new SError('Please specify a bucket name for the client in s-project.json'));
}

_this.bucketName = populatedProject.custom.client.bucketName;
var removalRegex = new RegExp(populatedProject.custom.client.removeBucketRegex,"g");
_this.bucketName = populatedProject.custom.client.bucketName.replace(removalRegex,'');
_this.clientPath = path.join(_this.project.getRootPath(), 'client', 'dist');

return BbPromise.resolve();
Expand Down Expand Up @@ -262,4 +263,4 @@ module.exports = function(S) {

}
return ClientDeploy;
};
};