Skip to content

Commit

Permalink
Merge 89b4f72 into 1c15ac3
Browse files Browse the repository at this point in the history
  • Loading branch information
sulaysumaria committed Mar 14, 2019
2 parents 1c15ac3 + 89b4f72 commit a6e0481
Show file tree
Hide file tree
Showing 30 changed files with 2,496 additions and 3,938 deletions.
3 changes: 2 additions & 1 deletion deploy/googleDeploy.js
Expand Up @@ -26,7 +26,8 @@ class GoogleDeploy {
monitorDeployment,
uploadArtifacts,
updateDeployment,
cleanupDeploymentBucket);
cleanupDeploymentBucket,
);

this.hooks = {
'before:deploy:deploy': () => BbPromise.bind(this)
Expand Down
9 changes: 6 additions & 3 deletions deploy/lib/cleanupDeploymentBucket.test.js
Expand Up @@ -118,7 +118,8 @@ describe('CleanupDeploymentBucket', () => {
'list',
{
bucket: 'sls-my-service-dev-12345678',
})).toEqual(true);
},
)).toEqual(true);
});
});

Expand Down Expand Up @@ -154,7 +155,8 @@ describe('CleanupDeploymentBucket', () => {
'list',
{
bucket: 'sls-my-service-dev-12345678',
})).toEqual(true);
},
)).toEqual(true);
});
});

Expand All @@ -173,7 +175,8 @@ describe('CleanupDeploymentBucket', () => {
'list',
{
bucket: 'sls-my-service-dev-12345678',
})).toEqual(true);
},
)).toEqual(true);
});
});
});
Expand Down
6 changes: 3 additions & 3 deletions deploy/lib/createDeployment.test.js
Expand Up @@ -35,7 +35,8 @@ describe('CreateDeployment', () => {
configurationTemplateCreateFilePath = path.join(
serverless.config.servicePath,
'.serverless',
'configuration-template-create.yml');
'configuration-template-create.yml',
);
});

afterEach(() => {
Expand All @@ -62,8 +63,7 @@ describe('CreateDeployment', () => {
.createDeployment().then(() => {
expect(checkForExistingDeploymentStub.calledOnce).toEqual(true);
expect(createIfNotExistsStub.calledAfter(checkForExistingDeploymentStub));
}),
);
}));
});

describe('#checkForExistingDeployment()', () => {
Expand Down
6 changes: 3 additions & 3 deletions deploy/lib/updateDeployment.test.js
Expand Up @@ -35,7 +35,8 @@ describe('UpdateDeployment', () => {
configurationTemplateUpdateFilePath = path.join(
serverless.config.servicePath,
'.serverless',
'configuration-template-update.yml');
'configuration-template-update.yml',
);
});

afterEach(() => {
Expand All @@ -62,8 +63,7 @@ describe('UpdateDeployment', () => {
.updateDeployment().then(() => {
expect(getDeploymentStub.calledOnce).toEqual(true);
expect(updateStub.calledAfter(getDeploymentStub));
}),
);
}));
});

describe('#getDeployment()', () => {
Expand Down
9 changes: 6 additions & 3 deletions deploy/lib/uploadArtifacts.test.js
Expand Up @@ -62,7 +62,8 @@ describe('UploadArtifacts', () => {
mimeType: 'application/octet-stream',
body: fs.createReadStream('artifact.zip'),
},
})).toEqual(true);
},
)).toEqual(true);
}));

it('should log info messages', () => googleDeploy
Expand All @@ -82,7 +83,8 @@ describe('UploadArtifacts', () => {
mimeType: 'application/octet-stream',
body: fs.createReadStream('artifact.zip'),
},
})).toEqual(true);
},
)).toEqual(true);
}));

it('should read artifact file as read stream', () => googleDeploy
Expand All @@ -102,7 +104,8 @@ describe('UploadArtifacts', () => {
mimeType: 'application/octet-stream',
body: fs.createReadStream('artifact.zip'),
},
})).toEqual(true);
},
)).toEqual(true);
}));
});
});
3 changes: 2 additions & 1 deletion info/googleInfo.js
Expand Up @@ -16,7 +16,8 @@ class GoogleInfo {
this,
validate,
setDefaults,
displayServiceInfo);
displayServiceInfo,
);

this.hooks = {
'before:info:info': () => BbPromise.bind(this)
Expand Down
9 changes: 5 additions & 4 deletions info/lib/displayServiceInfo.js
Expand Up @@ -15,7 +15,7 @@ module.exports = {
},

getResources() {
const project = this.serverless.service.provider.project;
const { project } = this.serverless.service.provider;

return this.provider.request('deploymentmanager', 'resources', 'list', {
project,
Expand All @@ -39,16 +39,17 @@ module.exports = {
_.forEach(resources.resources, (resource) => {
if (resource.type === 'cloudfunctions.v1beta2.function') {
const serviceFuncName = getFunctionNameInService(
resource.name, this.serverless.service.service, this.options.stage);
resource.name, this.serverless.service.service, this.options.stage,
);
const serviceFunc = this.serverless.service.getFunction(serviceFuncName);
const eventType = Object.keys(serviceFunc.events[0])[0];
const funcEventConfig = serviceFunc.events[0][eventType];

let funcResource = funcEventConfig.resource || null;

if (eventType === 'http') {
const region = this.options.region;
const project = this.serverless.service.provider.project;
const { region } = this.options;
const { project } = this.serverless.service.provider;
const baseUrl = `https://${region}-${project}.cloudfunctions.net`;
const path = serviceFunc.handler; // NOTE this might change
funcResource = `${baseUrl}/${path}`;
Expand Down
3 changes: 2 additions & 1 deletion info/lib/displayServiceInfo.test.js
Expand Up @@ -94,7 +94,8 @@ describe('DisplayServiceInfo', () => {
{
project: 'my-project',
deployment: 'sls-my-service-dev',
})).toEqual(true);
},
)).toEqual(true);
}));
});

Expand Down
3 changes: 2 additions & 1 deletion invoke/googleInvoke.js
Expand Up @@ -16,7 +16,8 @@ class GoogleInvoke {
this,
validate,
setDefaults,
invokeFunction);
invokeFunction,
);

this.hooks = {
'before:invoke:invoke': () => BbPromise.bind(this)
Expand Down
7 changes: 4 additions & 3 deletions invoke/lib/invokeFunction.js
Expand Up @@ -13,8 +13,8 @@ module.exports = {
},

invoke() {
const project = this.serverless.service.provider.project;
const region = this.options.region;
const { project } = this.serverless.service.provider;
const { region } = this.options;
let func = this.options.function;
const data = this.options.data || '';

Expand All @@ -33,7 +33,8 @@ module.exports = {
'locations',
'functions',
'call',
params);
params,
);
},

printResult(result) {
Expand Down
12 changes: 6 additions & 6 deletions invoke/lib/invokeFunction.test.js
Expand Up @@ -82,7 +82,8 @@ describe('InvokeFunction', () => {
resource: {
data: '',
},
})).toEqual(true);
},
)).toEqual(true);
});
});

Expand All @@ -102,7 +103,8 @@ describe('InvokeFunction', () => {
resource: {
data: googleInvoke.options.data,
},
})).toEqual(true);
},
)).toEqual(true);
});
});

Expand Down Expand Up @@ -130,8 +132,7 @@ describe('InvokeFunction', () => {
result: 'Foo bar',
};

const expectedOutput =
`${chalk.grey('wasdqwerty')} Foo bar`;
const expectedOutput = `${chalk.grey('wasdqwerty')} Foo bar`;

return googleInvoke.printResult(result).then(() => {
expect(consoleLogStub.calledWithExactly(expectedOutput)).toEqual(true);
Expand All @@ -141,8 +142,7 @@ describe('InvokeFunction', () => {
it('should print an error message to the console when no result was received', () => {
const result = {};

const expectedOutput =
`${chalk.grey('error')} An error occurred while executing your function...`;
const expectedOutput = `${chalk.grey('error')} An error occurred while executing your function...`;

return googleInvoke.printResult(result).then(() => {
expect(consoleLogStub.calledWithExactly(expectedOutput)).toEqual(true);
Expand Down
3 changes: 2 additions & 1 deletion logs/googleLogs.js
Expand Up @@ -30,7 +30,8 @@ class GoogleLogs {
this,
validate,
setDefaults,
retrieveLogs);
retrieveLogs,
);

this.hooks = {
'before:logs:logs': () => BbPromise.bind(this)
Expand Down
4 changes: 2 additions & 2 deletions logs/lib/retrieveLogs.js
Expand Up @@ -13,8 +13,8 @@ module.exports = {
},

getLogs() {
const project = this.serverless.service.provider.project;
const region = this.options.region;
const { project } = this.serverless.service.provider;
const { region } = this.options;
let func = this.options.function;
const pageSize = this.options.count || 10;

Expand Down
12 changes: 6 additions & 6 deletions logs/lib/retrieveLogs.test.js
Expand Up @@ -82,7 +82,8 @@ describe('RetrieveLogs', () => {
'projects/my-project',
],
pageSize: 10,
})).toEqual(true);
},
)).toEqual(true);
});
});

Expand All @@ -102,7 +103,8 @@ describe('RetrieveLogs', () => {
'projects/my-project',
],
pageSize: googleLogs.options.count,
})).toEqual(true);
},
)).toEqual(true);
});
});

Expand Down Expand Up @@ -134,8 +136,7 @@ describe('RetrieveLogs', () => {

const logEntry1 = `${chalk.grey('1970-01-01 00:00:')} Entry 1`;
const logEntry2 = `${chalk.grey('1970-01-01 00:01:')} Entry 2`;
const expectedOutput =
`Displaying the 2 most recent log(s):\n\n${logEntry1}\n${logEntry2}`;
const expectedOutput = `Displaying the 2 most recent log(s):\n\n${logEntry1}\n${logEntry2}`;

return googleLogs.printLogs(logs).then(() => {
expect(consoleLogStub.calledWithExactly(expectedOutput)).toEqual(true);
Expand All @@ -145,8 +146,7 @@ describe('RetrieveLogs', () => {
it('should print a default message to the console when no logs were received', () => {
const date = `${new Date().toISOString().slice(0, 10)}:`;
const logEntry = `${chalk.grey(date)} There is no log data to show...`;
const expectedOutput =
`Displaying the 1 most recent log(s):\n\n${logEntry}`;
const expectedOutput = `Displaying the 1 most recent log(s):\n\n${logEntry}`;

return googleLogs.printLogs({}).then(() => {
expect(consoleLogStub.calledWithExactly(expectedOutput)).toEqual(true);
Expand Down

0 comments on commit a6e0481

Please sign in to comment.