Skip to content

Commit

Permalink
Built in integration of serverless enterprise (#6074)
Browse files Browse the repository at this point in the history
Built in integration of serverless enterprise
  • Loading branch information
dschep committed May 28, 2019
2 parents 5ccb3ee + 5f6cd03 commit 224669d
Show file tree
Hide file tree
Showing 28 changed files with 867 additions and 125 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# 1.44.0 (2019-05-28)

- [Built in integration of Serverless Enterprise](https://github.com/serverless/serverless/pull/6074)
- [Setup Travis Windows support / Remove AppVeyor](https://github.com/serverless/serverless/pull/6132)
- [Update required Node.js version / Add version check](https://github.com/serverless/serverless/pull/6077)
- [Add scopes for cognito type APIGW referenced authorizer ](https://github.com/serverless/serverless/pull/6150)
- [Do not throw error if authorizer has empty claims](https://github.com/serverless/serverless/pull/6121)
- [Tests: Patch mocha bugs and fix broken async flow cases](https://github.com/serverless/serverless/pull/6157)
- [Fix tagging API Gateway stage fails if tag contains special characters like space](https://github.com/serverless/serverless/pull/6139)
- [Solve the problem of principal format in China region](https://github.com/serverless/serverless/pull/6127)
- [Upgrade mocha, switch from istanbul to nyc, improve tests configuration](https://github.com/serverless/serverless/pull/6169)

## Meta
- [Comparison since last release](https://github.com/serverless/serverless/compare/v1.43.0...v1.44.0)


# 1.43.0 (2019-05-20)

- [Update services.md](https://github.com/serverless/serverless/pull/6138)
Expand Down
25 changes: 23 additions & 2 deletions lib/classes/PluginManager.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
'use strict';

const path = require('path');
const config = require('../utils/config');
const Module = require('module');
const BbPromise = require('bluebird');
const _ = require('lodash');
const crypto = require('crypto');
const updateNotifier = require('update-notifier');
const writeFile = require('../utils/fs/writeFile');
const getCacheFilePath = require('../utils/getCacheFilePath');
const serverlessConfigFileUtils = require('../utils/getServerlessConfigFile');
const crypto = require('crypto');
const getCommandSuggestion = require('../utils/getCommandSuggestion');

/**
Expand Down Expand Up @@ -92,6 +94,7 @@ class PluginManager {
loadAllPlugins(servicePlugins) {
this.loadCorePlugins();
this.loadServicePlugins(servicePlugins);
this.loadEnterprisePlugin();
}

loadPlugins(plugins) {
Expand Down Expand Up @@ -148,7 +151,25 @@ class PluginManager {
if (pluginsObject.localPath) {
module.paths.unshift(pluginsObject.localPath);
}
this.loadPlugins(pluginsObject.modules);
this.loadPlugins(pluginsObject.modules
.filter(name => name !== '@serverless/enterprise-plugin'));
}

loadEnterprisePlugin() {
if (config.getGlobalConfig().enterpriseDisabled) {
return;
}
module.paths.unshift(path.join(__dirname, '../../node_modules'));
this.loadPlugins(['@serverless/enterprise-plugin']);
const sfePkgJson = require('@serverless/enterprise-plugin/package.json');

if (this.serverless.enterpriseEnabled) {
const updates = updateNotifier({ pkg: sfePkgJson, interval: 1 });
if (updates.update) {
this.serverless.cli.log('An updated version of Serverless Enterprise is available. ' +
'Please upgrade by running `npm i -g serverless`');
}
}
}

parsePluginsObject(servicePlugs) {
Expand Down
8 changes: 8 additions & 0 deletions lib/classes/PluginManager.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ describe('PluginManager', () => {

class ServicePluginMock2 {}

class EnterprisePluginMock {}

class BrokenPluginMock {
constructor() {
throw new Error('Broken plugin');
Expand Down Expand Up @@ -735,6 +737,7 @@ describe('PluginManager', () => {
beforeEach(function () { // eslint-disable-line prefer-arrow-callback
mockRequire('ServicePluginMock1', ServicePluginMock1);
mockRequire('ServicePluginMock2', ServicePluginMock2);
mockRequire('@serverless/enterprise-plugin', EnterprisePluginMock);
});

it('should load only core plugins when no service plugins are given', () => {
Expand All @@ -752,9 +755,11 @@ describe('PluginManager', () => {

const servicePluginMock1 = new ServicePluginMock1();
const servicePluginMock2 = new ServicePluginMock2();
const enterprisePluginMock = new EnterprisePluginMock();

expect(pluginManager.plugins).to.contain(servicePluginMock1);
expect(pluginManager.plugins).to.contain(servicePluginMock2);
expect(pluginManager.plugins).to.contain(enterprisePluginMock);
// note: this test will be refactored as the Create plugin will be moved
// to another directory
expect(pluginManager.plugins.length).to.be.above(2);
Expand All @@ -773,15 +778,18 @@ describe('PluginManager', () => {
// This is the exact same functionality like loadCorePlugins()
loadCorePluginsMock();
pluginManager.loadServicePlugins(servicePlugins);
pluginManager.loadEnterprisePlugin();

expect(pluginManager.plugins[0]).to.be.instanceof(Create);
expect(pluginManager.plugins[1]).to.be.instanceof(ServicePluginMock1);
expect(pluginManager.plugins[2]).to.be.instanceof(ServicePluginMock2);
expect(pluginManager.plugins[3]).to.be.instanceof(EnterprisePluginMock);
});

afterEach(function () { // eslint-disable-line prefer-arrow-callback
mockRequire.stop('ServicePluginMock1');
mockRequire.stop('ServicePluginMock2');
mockRequire.stop('@serverless/enterprise-plugin');
});
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
service:
name: aws-alexa-typescript
#app: your-app-name
#tenant: your-tenant-name

plugins:
- serverless-webpack
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

service: aws-clojure
# NOTE: update this with your service name
#app: your-app-name
#tenant: your-tenant-name

# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# Happy Coding!

service: aws-clojurescript-gradle
#app: your-app-name
#tenant: your-tenant-name

# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
Expand Down
2 changes: 2 additions & 0 deletions lib/plugins/create/templates/aws-csharp/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# Happy Coding!

service: aws-csharp # NOTE: update this with your service name
#app: your-app-name
#tenant: your-tenant-name

# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
Expand Down
2 changes: 2 additions & 0 deletions lib/plugins/create/templates/aws-fsharp/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# Happy Coding!

service: aws-fsharp # NOTE: update this with your service name
#app: your-app-name
#tenant: your-tenant-name

# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
Expand Down
2 changes: 2 additions & 0 deletions lib/plugins/create/templates/aws-go-dep/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# Happy Coding!

service: aws-go-dep # NOTE: update this with your service name
#app: your-app-name
#tenant: your-tenant-name

# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
Expand Down
2 changes: 2 additions & 0 deletions lib/plugins/create/templates/aws-go-mod/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# Happy Coding!

service: aws-go-mod # NOTE: update this with your service name
#app: your-app-name
#tenant: your-tenant-name

# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
Expand Down
2 changes: 2 additions & 0 deletions lib/plugins/create/templates/aws-go/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# Happy Coding!

service: aws-go # NOTE: update this with your service name
#app: your-app-name
#tenant: your-tenant-name

# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
Expand Down
2 changes: 2 additions & 0 deletions lib/plugins/create/templates/aws-groovy-gradle/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# Happy Coding!

service: aws-groovy-gradle # NOTE: update this with your service name
#app: your-app-name
#tenant: your-tenant-name

# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
Expand Down
2 changes: 2 additions & 0 deletions lib/plugins/create/templates/aws-java-gradle/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# Happy Coding!

service: aws-java-gradle # NOTE: update this with your service name
#app: your-app-name
#tenant: your-tenant-name

# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
Expand Down
2 changes: 2 additions & 0 deletions lib/plugins/create/templates/aws-java-maven/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# Happy Coding!

service: aws-java-maven # NOTE: update this with your service name
#app: your-app-name
#tenant: your-tenant-name

# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# Happy Coding!

service: aws-kotlin-jvm-gradle # NOTE: update this with your service name
#app: your-app-name
#tenant: your-tenant-name

# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# Happy Coding!

service: aws-kotlin-jvm-maven # NOTE: update this with your service name
#app: your-app-name
#tenant: your-tenant-name

# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# Happy Coding!

service: aws-kotlin-nodejs-gradle # NOTE: update this with your service name
#app: your-app-name
#tenant: your-tenant-name

# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
service:
name: aws-nodejs-ecma-script
#app: your-app-name
#tenant: your-tenant-name

# Add the serverless-webpack plugin
plugins:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
service:
name: aws-nodejs-typescript
#app: your-app-name
#tenant: your-tenant-name

# Add the serverless-webpack plugin
plugins:
Expand Down
2 changes: 2 additions & 0 deletions lib/plugins/create/templates/aws-nodejs/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# Happy Coding!

service: aws-nodejs # NOTE: update this with your service name
#app: your-app-name
#tenant: your-tenant-name

# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
Expand Down
2 changes: 2 additions & 0 deletions lib/plugins/create/templates/aws-provided/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# Happy Coding!

service: aws-provided # NOTE: update this with your service name
#app: your-app-name
#tenant: your-tenant-name

# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
Expand Down
2 changes: 2 additions & 0 deletions lib/plugins/create/templates/aws-python/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# Happy Coding!

service: aws-python # NOTE: update this with your service name
#app: your-app-name
#tenant: your-tenant-name

# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
Expand Down
2 changes: 2 additions & 0 deletions lib/plugins/create/templates/aws-python3/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# Happy Coding!

service: aws-python3 # NOTE: update this with your service name
#app: your-app-name
#tenant: your-tenant-name

# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
Expand Down
2 changes: 2 additions & 0 deletions lib/plugins/create/templates/aws-ruby/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# Happy Coding!

service: aws-ruby # NOTE: update this with your service name
#app: your-app-name
#tenant: your-tenant-name

# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
Expand Down
2 changes: 2 additions & 0 deletions lib/plugins/create/templates/aws-scala-sbt/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# Happy Coding!

service: aws-scala-sbt # NOTE: update this with your service name
#app: your-app-name
#tenant: your-tenant-name

# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
Expand Down
1 change: 1 addition & 0 deletions lib/utils/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ function createConfig() {
userId: null, // currentUserId
frameworkId: initialSetup.generateFrameworkId(),
trackingDisabled: initialSetup.configureTrack(), // default false
enterpriseDisabled: false,
meta: {
created_at: Math.round(+new Date() / 1000), // config file creation date
updated_at: null, // config file updated date
Expand Down
Loading

0 comments on commit 224669d

Please sign in to comment.