Skip to content

Commit

Permalink
feat(appengine): support publishing appengine module as an npm package (
Browse files Browse the repository at this point in the history
  • Loading branch information
danielpeach committed Apr 3, 2018
1 parent fa43648 commit 28b568e
Show file tree
Hide file tree
Showing 81 changed files with 223 additions and 25 deletions.
2 changes: 1 addition & 1 deletion app/scripts/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { module } from 'angular';
import { CORE_MODULE } from '@spinnaker/core';
import { DOCKER_MODULE } from '@spinnaker/docker';
import { AMAZON_MODULE } from '@spinnaker/amazon';
import { APPENGINE_MODULE } from './modules/appengine/appengine.module';
import { APPENGINE_MODULE } from '@spinnaker/appengine';
import { GOOGLE_MODULE } from '@spinnaker/google';
import { OPENSTACK_MODULE } from '@spinnaker/openstack';
import { CANARY_MODULE } from './modules/canary/canary.module';
Expand Down
11 changes: 11 additions & 0 deletions app/scripts/modules/appengine/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "@spinnaker/appengine",
"version": "0.0.1",
"main": "lib/lib.js",
"typings": "lib/index.d.ts",
"scripts": {
"clean": "../../../../node_modules/rimraf/bin.js lib",
"lib": "npm run clean && ../../../../node_modules/typescript/bin/tsc && node ../../../../node_modules/webpack/bin/webpack.js",
"prepare": "npm run lib"
}
}
1 change: 1 addition & 0 deletions app/scripts/modules/appengine/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { APPENGINE_MODULE } from './appengine.module';
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { APPENGINE_START_SERVER_GROUP_STAGE } from './stages/startServerGroup/ap
import { APPENGINE_STOP_SERVER_GROUP_STAGE } from './stages/stopServerGroup/appengineStopServerGroupStage';

export const APPENGINE_PIPELINE_MODULE = 'spinnaker.appengine.pipeline.module';

module(APPENGINE_PIPELINE_MODULE, [
APPENGINE_DESTROY_ASG_STAGE,
APPENGINE_DISABLE_ASG_STAGE,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { module } from 'angular';

import { ACCOUNT_SERVICE, AccountService } from '@spinnaker/core';
import { ACCOUNT_SERVICE, AccountService, PIPELINE_CONFIG_PROVIDER, PipelineConfigProvider } from '@spinnaker/core';

import { IAppengineStageScope } from 'appengine/domain/index';
import { IAppengineStageScope } from 'appengine/domain';
import { AppengineStageCtrl } from '../appengineStage.controller';

class AppengineDestroyAsgStageCtrl extends AppengineStageCtrl {
Expand All @@ -23,10 +23,11 @@ class AppengineDestroyAsgStageCtrl extends AppengineStageCtrl {

export const APPENGINE_DESTROY_ASG_STAGE = 'spinnaker.appengine.pipeline.stage.destroyAsgStage';

module(APPENGINE_DESTROY_ASG_STAGE, [ACCOUNT_SERVICE])
.config(function(pipelineConfigProvider: any) {
module(APPENGINE_DESTROY_ASG_STAGE, [ACCOUNT_SERVICE, PIPELINE_CONFIG_PROVIDER])
.config((pipelineConfigProvider: PipelineConfigProvider) => {
pipelineConfigProvider.registerStage({
provides: 'destroyServerGroup',
key: 'destroyServerGroup',
cloudProvider: 'appengine',
templateUrl: require('./destroyAsgStage.html'),
executionStepLabelUrl: require('./destroyAsgStepLabel.html'),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { module } from 'angular';

import { ACCOUNT_SERVICE, AccountService } from '@spinnaker/core';
import { ACCOUNT_SERVICE, AccountService, PIPELINE_CONFIG_PROVIDER, PipelineConfigProvider } from '@spinnaker/core';

import { AppengineHealth } from 'appengine/common/appengineHealth';
import { IAppengineStageScope } from 'appengine/domain/index';
import { IAppengineStageScope } from 'appengine/domain';
import { AppengineStageCtrl } from '../appengineStage.controller';

class AppengineDisableAsgStageCtrl extends AppengineStageCtrl {
Expand Down Expand Up @@ -32,10 +32,12 @@ export const APPENGINE_DISABLE_ASG_STAGE = 'spinnaker.appengine.pipeline.stage.d

module(APPENGINE_DISABLE_ASG_STAGE, [
ACCOUNT_SERVICE,
PIPELINE_CONFIG_PROVIDER,
])
.config(function(pipelineConfigProvider: any) {
.config((pipelineConfigProvider: PipelineConfigProvider) => {
pipelineConfigProvider.registerStage({
provides: 'disableServerGroup',
key: 'disableServerGroup',
cloudProvider: 'appengine',
templateUrl: require('./disableAsgStage.html'),
executionStepLabelUrl: require('./disableAsgStepLabel.html'),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { module } from 'angular';

import { ACCOUNT_SERVICE, AccountService } from '@spinnaker/core';
import { ACCOUNT_SERVICE, AccountService, PIPELINE_CONFIG_PROVIDER, PipelineConfigProvider } from '@spinnaker/core';

import { AppengineHealth } from 'appengine/common/appengineHealth';
import { IAppengineStageScope } from 'appengine/domain/index';
import { IAppengineStageScope } from 'appengine/domain';
import { AppengineStageCtrl } from '../appengineStage.controller';

class AppengineEnableAsgStageCtrl extends AppengineStageCtrl {
Expand Down Expand Up @@ -32,10 +32,12 @@ export const APPENGINE_ENABLE_ASG_STAGE = 'spinnaker.appengine.pipeline.stage.en

module(APPENGINE_ENABLE_ASG_STAGE, [
ACCOUNT_SERVICE,
PIPELINE_CONFIG_PROVIDER,
])
.config(function(pipelineConfigProvider: any) {
.config((pipelineConfigProvider: PipelineConfigProvider) => {
pipelineConfigProvider.registerStage({
provides: 'enableServerGroup',
key: 'enableServerGroup',
cloudProvider: 'appengine',
templateUrl: require('./enableAsgStage.html'),
executionStepLabelUrl: require('./enableAsgStepLabel.html'),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { module } from 'angular';

import { ACCOUNT_SERVICE, AccountService } from '@spinnaker/core';
import { ACCOUNT_SERVICE, AccountService, PIPELINE_CONFIG_PROVIDER, PipelineConfigProvider } from '@spinnaker/core';

import { IAppengineStage, IAppengineStageScope } from 'appengine/domain/index';
import { AppengineStageCtrl } from '../appengineStage.controller';
Expand Down Expand Up @@ -43,10 +43,11 @@ class AppengineShrinkClusterStageCtrl extends AppengineStageCtrl {

export const APPENGINE_SHRINK_CLUSTER_STAGE = 'spinnaker.appengine.pipeline.stage.shrinkClusterStage';

module(APPENGINE_SHRINK_CLUSTER_STAGE, [ACCOUNT_SERVICE])
.config(function(pipelineConfigProvider: any) {
module(APPENGINE_SHRINK_CLUSTER_STAGE, [ACCOUNT_SERVICE, PIPELINE_CONFIG_PROVIDER])
.config(function(pipelineConfigProvider: PipelineConfigProvider) {
pipelineConfigProvider.registerStage({
provides: 'shrinkCluster',
key: 'shrinkCluster',
cloudProvider: 'appengine',
templateUrl: require('./shrinkClusterStage.html'),
validators: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { module } from 'angular';

import { ACCOUNT_SERVICE, AccountService } from '@spinnaker/core';
import { ACCOUNT_SERVICE, AccountService, PIPELINE_CONFIG_PROVIDER, PipelineConfigProvider } from '@spinnaker/core';

import { AppengineHealth } from 'appengine/common/appengineHealth';
import { IAppengineStageScope } from 'appengine/domain/index';
import { IAppengineStageScope } from 'appengine/domain';
import { AppengineStageCtrl } from '../appengineStage.controller';

class AppengineStartServerGroupStageCtrl extends AppengineStageCtrl {
Expand All @@ -27,8 +27,8 @@ class AppengineStartServerGroupStageCtrl extends AppengineStageCtrl {

export const APPENGINE_START_SERVER_GROUP_STAGE = 'spinnaker.appengine.pipeline.stage.startServerGroupStage';

module(APPENGINE_START_SERVER_GROUP_STAGE, [ACCOUNT_SERVICE])
.config(function(pipelineConfigProvider: any) {
module(APPENGINE_START_SERVER_GROUP_STAGE, [ACCOUNT_SERVICE, PIPELINE_CONFIG_PROVIDER])
.config((pipelineConfigProvider: PipelineConfigProvider) => {
pipelineConfigProvider.registerStage({
label: 'Start Server Group',
description: 'Starts a server group.',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { module } from 'angular';

import { ACCOUNT_SERVICE, AccountService } from '@spinnaker/core';
import { ACCOUNT_SERVICE, AccountService, PIPELINE_CONFIG_PROVIDER, PipelineConfigProvider } from '@spinnaker/core';

import { AppengineHealth } from 'appengine/common/appengineHealth';
import { IAppengineStageScope } from 'appengine/domain/index';
Expand All @@ -27,8 +27,8 @@ class AppengineStopServerGroupStageCtrl extends AppengineStageCtrl {

export const APPENGINE_STOP_SERVER_GROUP_STAGE = 'spinnaker.appengine.pipeline.stage.stopServerGroupStage';

module(APPENGINE_STOP_SERVER_GROUP_STAGE, [ACCOUNT_SERVICE])
.config(function(pipelineConfigProvider: any) {
module(APPENGINE_STOP_SERVER_GROUP_STAGE, [ACCOUNT_SERVICE, PIPELINE_CONFIG_PROVIDER])
.config((pipelineConfigProvider: PipelineConfigProvider) => {
pipelineConfigProvider.registerStage({
label: 'Stop Server Group',
description: 'Stops a server group.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
IAppengineGitTrigger,
IAppengineJenkinsTrigger,
IAppengineServerGroup
} from 'appengine/domain/index';
} from 'appengine/domain';

import { AppengineProviderSettings } from 'appengine/appengine.settings';
import { AppengineDeployDescription } from '../transformer';
Expand Down Expand Up @@ -62,7 +62,7 @@ export enum AppengineSourceType {
CONTAINER_IMAGE = 'containerImage',
}

interface IViewState {
export interface IViewState {
mode: string;
submitButtonLabel: string;
disableStrategySelection: boolean;
Expand Down
50 changes: 50 additions & 0 deletions app/scripts/modules/appengine/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"buildOnSave": false,
"compileOnSave": true,
"compilerOptions": {
"allowJs": false,
"baseUrl": "./src",
"declaration": true,
"declarationDir": "lib",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"jsx": "react",
"lib": [
"es2016",
"dom"
],
"moduleResolution": "node",
"module": "commonjs",
"noEmitHelpers": false,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": false, // should really get to a place where we can turn this on
"noUnusedLocals": true,
"noUnusedParameters": true,
"outDir": "lib",
"pretty": true,
"removeComments": false,
"rootDir": "./src",
"skipLibCheck": true,
"sourceMap": true,
"inlineSources": true,
"strictNullChecks": false, // should really get to a place where we can turn this on
"target": "es6",
"typeRoots": [
"../../../../node_modules/@types"
],
"paths": {
"@spinnaker/core": ["../../core/lib"],
"appengine/*": ["*"],
"appengine": ["."]
}
},
"include": [
"src/**/*.ts",
"src/**/*.tsx"
],
"exclude": [
"./lib",
"**/*.spec.*"
]
}
126 changes: 126 additions & 0 deletions app/scripts/modules/appengine/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
'use strict';

const path = require('path');
const basePath = path.join(__dirname, '..', '..', '..', '..');
const NODE_MODULE_PATH = path.join(basePath, 'node_modules');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const nodeExternals = require('webpack-node-externals');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const exclusionPattern = /(node_modules|\.\.\/deck)/;
const WEBPACK_THREADS = Math.max(require('physical-cpu-count') - 1, 1);

const WATCH = process.env.WATCH === 'true';
const WEBPACK_MODE = WATCH ? 'development' : 'production';
const IS_PRODUCTION = WEBPACK_MODE === 'production';

module.exports = {
context: basePath,
mode: WEBPACK_MODE,
stats: 'minimal',
watch: WATCH,
entry: {
lib: path.join(__dirname, 'src', 'index.ts'),
},
output: {
path: path.join(__dirname, 'lib'),
filename: '[name].js',
library: '@spinnaker/appengine',
libraryTarget: 'umd',
umdNamedDefine: true,
},
devtool: 'source-map',
optimization: {
minimizer: IS_PRODUCTION ? [
new UglifyJSPlugin({
cache: true,
parallel: true,
sourceMap: true,
uglifyOptions: { mangle: false }
})
] : [], // disable minification in development mode
},
resolve: {
extensions: ['.json', '.js', '.jsx', '.ts', '.tsx', '.css', '.less', '.html'],
modules: [
NODE_MODULE_PATH,
path.resolve('.'),
],
alias: {
'@spinnaker/appengine': path.join(__dirname, 'src'),
'coreImports': path.resolve(basePath, 'app', 'scripts', 'modules', 'core', 'src', 'presentation', 'less', 'imports', 'commonImports.less'),
'appengine': path.join(__dirname, 'src')
}
},
module: {
rules: [
{
test: /\.js$/,
use: [
{ loader: 'cache-loader' },
{ loader: 'thread-loader', options: { workers: WEBPACK_THREADS } },
{ loader: 'babel-loader' },
{ loader: 'envify-loader' },
{ loader: 'eslint-loader' },
],
exclude: exclusionPattern
},
{
test: /\.tsx?$/,
use: [
{ loader: 'cache-loader' },
{ loader: 'thread-loader', options: { workers: WEBPACK_THREADS } },
{ loader: 'babel-loader' },
{ loader: 'ts-loader', options: { happyPackMode: true } },
{ loader: 'tslint-loader' },
],
exclude: exclusionPattern
},
{
test: /\.less$/,
use: [
{ loader: 'style-loader' },
{ loader: 'css-loader' },
{ loader: 'postcss-loader' },
{ loader: 'less-loader' },
],
},
{
test: /\.css$/,
use: [
{ loader: 'style-loader' },
{ loader: 'css-loader' },
{ loader: 'postcss-loader' },
]
},
{
test: /\.html$/,
exclude: exclusionPattern,
use: [
{ loader: 'ngtemplate-loader?relativeTo=' + (path.resolve(__dirname)) + '&prefix=appengine' },
{ loader: 'html-loader' },
]
},
{
test: /\.(woff|woff2|otf|ttf|eot|png|gif|ico|svg)$/,
use: [
{ loader: 'file-loader', options: { name: '[name].[hash:5].[ext]'} },
],
},
{
test: require.resolve('jquery'),
use: [
{ loader: 'expose-loader?$' },
{ loader: 'expose-loader?jQuery' },
],
},
],
},
plugins: [
new ForkTsCheckerWebpackPlugin({ checkSyntacticErrors: true }),
],
externals: [
'@spinnaker/core',
'exports-loader?"n3-line-chart"!n3-charts/build/LineChart.js',
nodeExternals({ modulesDir: '../../../../node_modules' }),
],
};
5 changes: 4 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@
"amazon": ["amazon/src"],
"@spinnaker/google": ["google/src"],
"google/*": ["google/src/*"],
"google": ["google/src"]
"google": ["google/src"],
"@spinnaker/appengine": ["appengine/src"],
"appengine/*": ["appengine/src/*"],
"appengine/": ["appengine/src"]
},
"pretty": true,
"removeComments": true,
Expand Down
2 changes: 2 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ function configure(env, webpackOpts) {
'openstack': path.join(__dirname, 'app', 'scripts', 'modules', 'openstack', 'src'),
'@spinnaker/openstack': path.join(__dirname, 'app', 'scripts', 'modules', 'openstack', 'src'),
'coreImports': path.resolve(__dirname, 'app', 'scripts', 'modules', 'core', 'src', 'presentation', 'less', 'imports', 'commonImports.less'),
'appengine': path.join(__dirname, 'app', 'scripts', 'modules', 'appengine', 'src'),
'@spinnaker/appengine': path.join(__dirname, 'app', 'scripts', 'modules', 'appengine', 'src'),
}
},
module: {
Expand Down

0 comments on commit 28b568e

Please sign in to comment.