Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

feat: Azure Functions Offline plugin #159

Merged
merged 9 commits into from
Jun 19, 2019
Merged

feat: Azure Functions Offline plugin #159

merged 9 commits into from
Jun 19, 2019

Conversation

tbarlow12
Copy link
Contributor

@tbarlow12 tbarlow12 commented Jun 5, 2019

  • Added AzureOfflinePlugin
  • Added OfflineService that contains the logic
  • Various questions and topics for discussion within team, will post those on each line

Update:

  • Added fixes to func plugin to account for new package structure
  • Added FuncService to contain logic and utility functions for plugin

src/services/baseService.ts Outdated Show resolved Hide resolved
src/services/baseService.ts Outdated Show resolved Hide resolved
@tbarlow12 tbarlow12 changed the title feat: Azure Offline plugin stub WIP - feat: Azure Offline plugin stub Jun 5, 2019
Copy link
Contributor

@wbreza wbreza left a comment

Choose a reason for hiding this comment

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

Added some feedback.

src/plugins/offline/azureOfflinePlugin.ts Show resolved Hide resolved
src/plugins/offline/azureOfflinePlugin.ts Outdated Show resolved Hide resolved
src/services/baseService.ts Show resolved Hide resolved
src/services/baseService.ts Outdated Show resolved Hide resolved
@tbarlow12 tbarlow12 changed the title WIP - feat: Azure Offline plugin stub feat: Azure Offline plugin Jun 10, 2019
@tbarlow12 tbarlow12 force-pushed the tabarlow/offline-hook branch from b3eefb7 to 6d3be0f Compare June 10, 2019 13:58
@tbarlow12 tbarlow12 changed the title feat: Azure Offline plugin feat: Azure Functions Offline plugin Jun 10, 2019
@tbarlow12 tbarlow12 force-pushed the tabarlow/offline-hook branch from d2ba8b8 to 8edcb89 Compare June 14, 2019 19:11
}

private getServerlessYml() {
return this.serverless.utils.readFileSync("serverless.yml");
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the framework have a way to get the name of the yaml file? With the new --config option, it's possible that the file won't be named serverless.yml. We don't have to over-index around this, but just something to keep in mind.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. Wasn't accounting for this. I'll investigate further here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a getter that defaults to serverless.yml. Good callout

private getFunctionHandler(name: string) {
return `"use strict";

module.exports.handler = async function (context, req) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I almost want to suggest making this a separate template/file (also easier to tell if it's valid code), but given that it's encapsulated here and relatively short, I'm okay with it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd love to capture this in a template file, and we actually discussed this in a previous PR (previous PR got a little murky with all the refactoring, so I closed and opened a new one). The issue I ran into was deciding what kind of file to store the template in:

1. .ts - transpiles to messy .js in build
2. .js - can't be included with current tsconfig (`allowJs` and `declarations` attribute cannot both be true)
3. .txt - Would need to copy to file post-build to the lib directory - seems heavy handed for this ask

If you have any other thoughts here, I'm open to any and all suggestions :)

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, good call. I was thinking some way of reading from a file, but it gets messy in the context of the rest of the build. Will keep thinking about it -- would be nice to have separate, but we can call it good until something else better presents itself.

@pjlittle
Copy link
Contributor

Looking good - just a couple comments. Great work on the tests. 👍

Copy link
Contributor

@mydiemho mydiemho left a comment

Choose a reason for hiding this comment

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

some comments

// Trivial test for now. In the future, this process
// may spawn the start process itself rather than telling
// the user how to do it.
expect(sls.cli.log).toBeCalledTimes(3);
Copy link
Contributor

Choose a reason for hiding this comment

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

I have assumed that this was the original plan. Are we holding off on it now because we want to get something usable, albeit manual, out?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, holding off on the spawn for now. Hoping npm start is not too much work for the time being

src/plugins/offline/azureOfflinePlugin.ts Show resolved Hide resolved
@tbarlow12 tbarlow12 force-pushed the tabarlow/offline-hook branch from ce49a7f to 1704787 Compare June 19, 2019 20:03
@tbarlow12 tbarlow12 merged commit 91d55c6 into dev Jun 19, 2019
@tbarlow12 tbarlow12 deleted the tabarlow/offline-hook branch June 20, 2019 14:41
tbarlow12 added a commit that referenced this pull request Sep 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants