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

Add CLI params for disabling deleting and config/policy/cors updates #28

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ echo "error page" >> client/dist/error.html
**Fourth**, run the plugin, and visit your new website!

```
serverless client deploy [--stage $STAGE] [--region $REGION]
serverless client deploy [--stage $STAGE] [--region $REGION] [--no-delete-contents] [--no-config-change] [--no-policy-change] [--no-cors-change]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the no in all the flags get removed somewhere?

These options make sense to me. Just have to figure out how to refactor some of the documentation to explain these options. And also decide if these make sense as command line args or as config details in serverless.yml.

```

The plugin should output the location of your newly deployed static site to the console.
Expand Down
18 changes: 17 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class Client {
this.serverless = serverless;
this.provider = 'aws';
this.aws = this.serverless.getProvider(this.provider);
this.options = options;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove the tabs and add in spaces everywhere? You can review in GitHub to compare the spacing here.


this.commands = {
client: {
Expand Down Expand Up @@ -102,7 +103,7 @@ class Client {
}

deleteObjectsFromBucket(data) {
if (!this.bucketExists) return BbPromise.resolve();
if (!this.bucketExists || this.options['delete-contents'] === false) return BbPromise.resolve();

this.serverless.cli.log(`Deleting all objects from bucket ${this.bucketName}...`);

Expand Down Expand Up @@ -184,6 +185,11 @@ class Client {
}

function configureBucket() {
if (this.options['config-change'] === false) {
this.serverless.cli.log(`Retaining existing bucket configuration for ${this.bucketName}...`);
return BbPromise.resolve();
}

this.serverless.cli.log(`Configuring website bucket ${this.bucketName}...`);

const indexDoc = this.serverless.service.custom.client.indexDocument || 'index.html'
Expand All @@ -201,6 +207,11 @@ class Client {
}

function configurePolicyForBucket(){
if (this.options['policy-change'] === false) {
this.serverless.cli.log(`Retaining existing bucket policy for ${this.bucketName}...`);
return BbPromise.resolve();
}

this.serverless.cli.log(`Configuring policy for bucket ${this.bucketName}...`);

let policy = {
Expand Down Expand Up @@ -228,6 +239,11 @@ class Client {
}

function configureCorsForBucket(){
if (this.options['cors-change'] === false) {
this.serverless.cli.log(`Retaining existing CORS policy for ${this.bucketName}...`);
return BbPromise.resolve();
}

this.serverless.cli.log(`Configuring CORS policy for bucket ${this.bucketName}...`);

let putPostDeleteRule = {
Expand Down