From d962d13a9dea1a4dee05bfb816feab0cabbc9fd8 Mon Sep 17 00:00:00 2001 From: Bhargav Krishna Date: Tue, 21 Mar 2017 21:32:14 -0700 Subject: [PATCH] Insiders build - 3/21/2017 * Streamlined build process and updated project structure. * fixing perf problems introduced by upgrading angular and zone.js * Tweaking Application insights labels * adding page tracking * updating version --- .gitignore | 16 +- .vscode/launch.json | 2 +- LICENSE | 20 + config/env.config.js | 8 +- config/webpack.common.js | 297 +++++---- config/webpack.dev.js | 154 ++--- config/webpack.prod.js | 128 ++-- package.json | 119 ++-- {client => src/client}/app/actions/github.ts | 0 {client => src/client}/app/actions/index.ts | 0 {client => src/client}/app/actions/monaco.ts | 0 {client => src/client}/app/actions/snippet.ts | 0 {client => src/client}/app/actions/ui.ts | 0 .../client}/app/components/about.ts | 0 .../client}/app/components/alert.ts | 0 .../client}/app/components/collapse.ts | 0 .../client}/app/components/command.ts | 0 .../client}/app/components/dialog.ts | 0 .../client}/app/components/index.ts | 0 .../client}/app/components/profile.ts | 3 +- .../client}/app/components/snippet.info.ts | 0 {client => src/client}/app/containers/app.ts | 6 +- .../client}/app/containers/editor.ts | 3 + .../client}/app/containers/gallery.list.ts | 0 .../client}/app/containers/import.ts | 21 +- .../client}/app/containers/index.ts | 0 {client => src/client}/app/effects/github.ts | 2 - {client => src/client}/app/effects/index.ts | 0 {client => src/client}/app/effects/monaco.ts | 4 +- {client => src/client}/app/effects/snippet.ts | 10 +- {client => src/client}/app/effects/ui.ts | 0 .../client}/app/helpers/ai.helper.ts | 99 ++- .../client}/app/helpers/environment.ts | 0 .../client}/app/helpers/exception.helper.ts | 5 +- {client => src/client}/app/helpers/index.ts | 0 .../client}/app/helpers/messenger.ts | 2 + .../client}/app/helpers/settings.ts | 13 + {client => src/client}/app/helpers/strings.ts | 2 +- {client => src/client}/app/helpers/theme.ts | 0 .../client}/app/helpers/utilities.ts | 0 {client => src/client}/app/pipes/index.ts | 0 {client => src/client}/app/pipes/keys.ts | 0 {client => src/client}/app/reducers/github.ts | 3 +- {client => src/client}/app/reducers/index.ts | 9 +- {client => src/client}/app/reducers/monaco.ts | 4 +- .../client}/app/reducers/snippet.ts | 0 {client => src/client}/app/reducers/ui.ts | 13 +- .../client}/app/services/github.service.ts | 4 +- {client => src/client}/app/services/index.ts | 0 .../client}/app/services/monaco.service.ts | 9 +- .../client}/app/services/request.ts | 0 .../assets/firebug/firebug-lite-debug.js | 0 .../client}/assets/firebug/skin/xp/blank.gif | Bin .../assets/firebug/skin/xp/buttonBg.png | Bin .../assets/firebug/skin/xp/buttonBgHover.png | Bin .../assets/firebug/skin/xp/debugger.css | 0 .../client}/assets/firebug/skin/xp/detach.png | Bin .../assets/firebug/skin/xp/detachHover.png | Bin .../assets/firebug/skin/xp/disable.gif | Bin .../assets/firebug/skin/xp/disable.png | Bin .../assets/firebug/skin/xp/disableHover.gif | Bin .../assets/firebug/skin/xp/disableHover.png | Bin .../client}/assets/firebug/skin/xp/down.png | Bin .../assets/firebug/skin/xp/downActive.png | Bin .../assets/firebug/skin/xp/downHover.png | Bin .../assets/firebug/skin/xp/errorIcon-sm.png | Bin .../assets/firebug/skin/xp/errorIcon.gif | Bin .../assets/firebug/skin/xp/errorIcon.png | Bin .../assets/firebug/skin/xp/firebug-1.3a2.css | 0 .../assets/firebug/skin/xp/firebug.IE6.css | 0 .../assets/firebug/skin/xp/firebug.css | 0 .../assets/firebug/skin/xp/firebug.html | 0 .../assets/firebug/skin/xp/firebug.png | Bin .../client}/assets/firebug/skin/xp/group.gif | Bin .../client}/assets/firebug/skin/xp/html.css | 0 .../assets/firebug/skin/xp/infoIcon.gif | Bin .../assets/firebug/skin/xp/infoIcon.png | Bin .../assets/firebug/skin/xp/loading_16.gif | Bin .../client}/assets/firebug/skin/xp/min.png | Bin .../assets/firebug/skin/xp/minHover.png | Bin .../client}/assets/firebug/skin/xp/off.png | Bin .../assets/firebug/skin/xp/offHover.png | Bin .../firebug/skin/xp/pixel_transparent.gif | Bin .../assets/firebug/skin/xp/roundCorner.svg | 0 .../client}/assets/firebug/skin/xp/search.gif | Bin .../client}/assets/firebug/skin/xp/search.png | Bin .../client}/assets/firebug/skin/xp/shadow.gif | Bin .../assets/firebug/skin/xp/shadow2.gif | Bin .../assets/firebug/skin/xp/shadowAlpha.png | Bin .../client}/assets/firebug/skin/xp/sprite.png | Bin .../assets/firebug/skin/xp/tabHoverLeft.png | Bin .../assets/firebug/skin/xp/tabHoverMid.png | Bin .../assets/firebug/skin/xp/tabHoverRight.png | Bin .../assets/firebug/skin/xp/tabLeft.png | Bin .../firebug/skin/xp/tabMenuCheckbox.png | Bin .../assets/firebug/skin/xp/tabMenuPin.png | Bin .../assets/firebug/skin/xp/tabMenuRadio.png | Bin .../assets/firebug/skin/xp/tabMenuTarget.png | Bin .../firebug/skin/xp/tabMenuTargetHover.png | Bin .../client}/assets/firebug/skin/xp/tabMid.png | Bin .../assets/firebug/skin/xp/tabRight.png | Bin .../firebug/skin/xp/textEditorBorders.gif | Bin .../firebug/skin/xp/textEditorBorders.png | Bin .../firebug/skin/xp/textEditorCorners.gif | Bin .../firebug/skin/xp/textEditorCorners.png | Bin .../assets/firebug/skin/xp/titlebarMid.png | Bin .../assets/firebug/skin/xp/toolbarMid.png | Bin .../assets/firebug/skin/xp/tree_close.gif | Bin .../assets/firebug/skin/xp/tree_open.gif | Bin .../assets/firebug/skin/xp/twistyClosed.png | Bin .../assets/firebug/skin/xp/twistyOpen.png | Bin .../client}/assets/firebug/skin/xp/up.png | Bin .../assets/firebug/skin/xp/upActive.png | Bin .../assets/firebug/skin/xp/upHover.png | Bin .../assets/firebug/skin/xp/warningIcon.gif | Bin .../assets/firebug/skin/xp/warningIcon.png | Bin .../client}/assets/images/code-16.png | Bin .../client}/assets/images/code-24.png | Bin .../client}/assets/images/code-32.png | Bin .../client}/assets/images/code-48.png | Bin .../client}/assets/images/code-64.png | Bin .../client}/assets/images/code-80.png | Bin .../client}/assets/images/icon-16.png | Bin .../client}/assets/images/icon-24.png | Bin .../client}/assets/images/icon-32.png | Bin .../client}/assets/images/icon-48.png | Bin .../client}/assets/images/icon-64.png | Bin .../client}/assets/images/icon-80.png | Bin .../client}/assets/images/icon-large.png | Bin .../assets/images/playground-background.png | Bin .../assets/images/playground-error.png | Bin .../client}/assets/images/run-16.png | Bin .../client}/assets/images/run-24.png | Bin .../client}/assets/images/run-32.png | Bin .../client}/assets/images/run-48.png | Bin .../client}/assets/images/run-64.png | Bin .../client}/assets/images/run-80.png | Bin {client => src/client}/assets/libraries.json | 0 .../client}/assets/styles/_components.scss | 0 .../client}/assets/styles/_containers.scss | 0 .../client}/assets/styles/_fabric.scss | 0 .../client}/assets/styles/_mixins.scss | 0 .../client}/assets/styles/_theme.scss | 0 .../client}/assets/styles/_vars.scss | 0 .../client}/assets/styles/common.scss | 16 +- .../assets/styles/components/_about.scss | 0 .../assets/styles/components/_command.scss | 0 .../assets/styles/components/_profile.scss | 0 .../assets/styles/components/_spinner.scss | 0 .../assets/styles/containers/_editor.scss | 0 .../assets/styles/containers/_gallery.scss | 0 .../assets/styles/containers/_import.scss | 6 +- .../client}/assets/styles/editor.scss | 0 .../client}/assets/styles/extras.scss | 0 .../styles/mixins/_background.fill.scss | 0 .../assets/styles/mixins/_ellipsis.scss | 0 .../client}/assets/styles/mixins/_flex.scss | 0 .../assets/styles/mixins/_focus.states.scss | 0 .../assets/styles/mixins/_keyframes.scss | 0 .../client}/assets/styles/mixins/_scroll.scss | 0 .../client}/assets/styles/themes/excel.scss | 0 .../client}/assets/styles/themes/minimal.scss | 0 .../client}/assets/styles/themes/onenote.scss | 0 .../assets/styles/themes/powerpoint.scss | 0 .../client}/assets/styles/themes/project.scss | 0 .../client}/assets/styles/themes/web.scss | 0 .../client}/assets/styles/themes/word.scss | 0 {client => src/client}/components.ts | 0 {client => src/client}/main.ts | 18 +- {client => src/client}/polyfills.ts | 0 {client => src/client}/public/.deployment | 0 .../public/favicon/android-icon-144x144.png | Bin .../public/favicon/android-icon-192x192.png | Bin .../public/favicon/android-icon-36x36.png | Bin .../public/favicon/android-icon-48x48.png | Bin .../public/favicon/android-icon-72x72.png | Bin .../public/favicon/android-icon-96x96.png | Bin .../public/favicon/apple-icon-114x114.png | Bin .../public/favicon/apple-icon-120x120.png | Bin .../public/favicon/apple-icon-144x144.png | Bin .../public/favicon/apple-icon-152x152.png | Bin .../public/favicon/apple-icon-180x180.png | Bin .../public/favicon/apple-icon-57x57.png | Bin .../public/favicon/apple-icon-60x60.png | Bin .../public/favicon/apple-icon-72x72.png | Bin .../public/favicon/apple-icon-76x76.png | Bin .../public/favicon/apple-icon-precomposed.png | Bin .../client}/public/favicon/apple-icon.png | Bin .../client}/public/favicon/browserconfig.xml | 0 .../client}/public/favicon/favicon-16x16.png | Bin .../client}/public/favicon/favicon-32x32.png | Bin .../client}/public/favicon/favicon-96x96.png | Bin .../client}/public/favicon/favicon.ico | Bin .../client}/public/favicon/manifest.json | 0 .../public/favicon/ms-icon-144x144.png | Bin .../public/favicon/ms-icon-150x150.png | Bin .../public/favicon/ms-icon-310x310.png | Bin .../client}/public/favicon/ms-icon-70x70.png | Bin {client => src/client}/public/functions.ts | 0 {client => src/client}/public/gallery.ts | 4 +- {client => src/client}/public/heartbeat.ts | 24 +- {client => src/client}/public/refresh.ts | 0 {client => src/client}/public/runner.ts | 10 +- {client => src/client}/public/web.config | 0 {client => src/client}/vendor.ts | 7 +- {client => src/client}/views/functions.html | 0 {client => src/client}/views/heartbeat.html | 0 {client => src/client}/views/index.html | 3 +- {client => src/client}/views/refresh.html | 0 {client => src/client}/views/run.html | 3 +- {typings => src/interfaces}/github.d.ts | 0 {typings => src/interfaces}/monaco.d.ts | 0 {typings => src/interfaces}/playground.d.ts | 2 +- {server => src/server}/.deployment | 0 src/server/core/ai.helper.ts | 116 ++++ {server => src/server}/core/errors.ts | 0 .../server}/core/snippet.generator.ts | 0 .../server}/core/template.generator.ts | 0 {server => src/server}/core/utilities.ts | 0 .../server}/favicon/android-icon-144x144.png | Bin .../server}/favicon/android-icon-192x192.png | Bin .../server}/favicon/android-icon-36x36.png | Bin .../server}/favicon/android-icon-48x48.png | Bin .../server}/favicon/android-icon-72x72.png | Bin .../server}/favicon/android-icon-96x96.png | Bin .../server}/favicon/apple-icon-114x114.png | Bin .../server}/favicon/apple-icon-120x120.png | Bin .../server}/favicon/apple-icon-144x144.png | Bin .../server}/favicon/apple-icon-152x152.png | Bin .../server}/favicon/apple-icon-180x180.png | Bin .../server}/favicon/apple-icon-57x57.png | Bin .../server}/favicon/apple-icon-60x60.png | Bin .../server}/favicon/apple-icon-72x72.png | Bin .../server}/favicon/apple-icon-76x76.png | Bin .../favicon/apple-icon-precomposed.png | Bin {server => src/server}/favicon/apple-icon.png | Bin .../server}/favicon/browserconfig.xml | 0 .../server}/favicon/favicon-16x16.png | Bin .../server}/favicon/favicon-32x32.png | Bin .../server}/favicon/favicon-96x96.png | Bin {server => src/server}/favicon/favicon.ico | Bin {server => src/server}/favicon/manifest.json | 0 .../server}/favicon/ms-icon-144x144.png | Bin .../server}/favicon/ms-icon-150x150.png | Bin .../server}/favicon/ms-icon-310x310.png | Bin .../server}/favicon/ms-icon-70x70.png | Bin {server => src/server}/iisnode.yml | 0 {server => src/server}/package.json | 0 {server => src/server}/robots.txt | 0 {server => src/server}/server.ts | 103 +-- {server => src/server}/templates/error.html | 0 {server => src/server}/templates/runner | 24 +- {server => src/server}/templates/snippet | 0 {server => src/server}/web.config | 0 tsconfig.aot.json | 20 + tsconfig.json | 29 +- tsconfig.server.json | 7 +- tsconfig.webpack.json | 19 + typings/.gitignore | 4 - yarn.lock | 600 +++++++++--------- 260 files changed, 1084 insertions(+), 887 deletions(-) create mode 100644 LICENSE rename {client => src/client}/app/actions/github.ts (100%) rename {client => src/client}/app/actions/index.ts (100%) rename {client => src/client}/app/actions/monaco.ts (100%) rename {client => src/client}/app/actions/snippet.ts (100%) rename {client => src/client}/app/actions/ui.ts (100%) rename {client => src/client}/app/components/about.ts (100%) rename {client => src/client}/app/components/alert.ts (100%) rename {client => src/client}/app/components/collapse.ts (100%) rename {client => src/client}/app/components/command.ts (100%) rename {client => src/client}/app/components/dialog.ts (100%) rename {client => src/client}/app/components/index.ts (100%) rename {client => src/client}/app/components/profile.ts (91%) rename {client => src/client}/app/components/snippet.info.ts (100%) rename {client => src/client}/app/containers/app.ts (97%) rename {client => src/client}/app/containers/editor.ts (97%) rename {client => src/client}/app/containers/gallery.list.ts (100%) rename {client => src/client}/app/containers/import.ts (94%) rename {client => src/client}/app/containers/index.ts (100%) rename {client => src/client}/app/effects/github.ts (99%) rename {client => src/client}/app/effects/index.ts (100%) rename {client => src/client}/app/effects/monaco.ts (98%) rename {client => src/client}/app/effects/snippet.ts (96%) rename {client => src/client}/app/effects/ui.ts (100%) rename {client => src/client}/app/helpers/ai.helper.ts (57%) rename {client => src/client}/app/helpers/environment.ts (100%) rename {client => src/client}/app/helpers/exception.helper.ts (90%) rename {client => src/client}/app/helpers/index.ts (100%) rename {client => src/client}/app/helpers/messenger.ts (93%) rename {client => src/client}/app/helpers/settings.ts (74%) rename {client => src/client}/app/helpers/strings.ts (99%) rename {client => src/client}/app/helpers/theme.ts (100%) rename {client => src/client}/app/helpers/utilities.ts (100%) rename {client => src/client}/app/pipes/index.ts (100%) rename {client => src/client}/app/pipes/keys.ts (100%) rename {client => src/client}/app/reducers/github.ts (98%) rename {client => src/client}/app/reducers/index.ts (95%) rename {client => src/client}/app/reducers/monaco.ts (97%) rename {client => src/client}/app/reducers/snippet.ts (100%) rename {client => src/client}/app/reducers/ui.ts (88%) rename {client => src/client}/app/services/github.service.ts (98%) rename {client => src/client}/app/services/index.ts (100%) rename {client => src/client}/app/services/monaco.service.ts (95%) rename {client => src/client}/app/services/request.ts (100%) rename {client => src/client}/assets/firebug/firebug-lite-debug.js (100%) rename {client => src/client}/assets/firebug/skin/xp/blank.gif (100%) rename {client => src/client}/assets/firebug/skin/xp/buttonBg.png (100%) rename {client => src/client}/assets/firebug/skin/xp/buttonBgHover.png (100%) rename {client => src/client}/assets/firebug/skin/xp/debugger.css (100%) rename {client => src/client}/assets/firebug/skin/xp/detach.png (100%) rename {client => src/client}/assets/firebug/skin/xp/detachHover.png (100%) rename {client => src/client}/assets/firebug/skin/xp/disable.gif (100%) rename {client => src/client}/assets/firebug/skin/xp/disable.png (100%) rename {client => src/client}/assets/firebug/skin/xp/disableHover.gif (100%) rename {client => src/client}/assets/firebug/skin/xp/disableHover.png (100%) rename {client => src/client}/assets/firebug/skin/xp/down.png (100%) rename {client => src/client}/assets/firebug/skin/xp/downActive.png (100%) rename {client => src/client}/assets/firebug/skin/xp/downHover.png (100%) rename {client => src/client}/assets/firebug/skin/xp/errorIcon-sm.png (100%) rename {client => src/client}/assets/firebug/skin/xp/errorIcon.gif (100%) rename {client => src/client}/assets/firebug/skin/xp/errorIcon.png (100%) rename {client => src/client}/assets/firebug/skin/xp/firebug-1.3a2.css (100%) rename {client => src/client}/assets/firebug/skin/xp/firebug.IE6.css (100%) rename {client => src/client}/assets/firebug/skin/xp/firebug.css (100%) rename {client => src/client}/assets/firebug/skin/xp/firebug.html (100%) rename {client => src/client}/assets/firebug/skin/xp/firebug.png (100%) rename {client => src/client}/assets/firebug/skin/xp/group.gif (100%) rename {client => src/client}/assets/firebug/skin/xp/html.css (100%) rename {client => src/client}/assets/firebug/skin/xp/infoIcon.gif (100%) rename {client => src/client}/assets/firebug/skin/xp/infoIcon.png (100%) rename {client => src/client}/assets/firebug/skin/xp/loading_16.gif (100%) rename {client => src/client}/assets/firebug/skin/xp/min.png (100%) rename {client => src/client}/assets/firebug/skin/xp/minHover.png (100%) rename {client => src/client}/assets/firebug/skin/xp/off.png (100%) rename {client => src/client}/assets/firebug/skin/xp/offHover.png (100%) rename {client => src/client}/assets/firebug/skin/xp/pixel_transparent.gif (100%) rename {client => src/client}/assets/firebug/skin/xp/roundCorner.svg (100%) rename {client => src/client}/assets/firebug/skin/xp/search.gif (100%) rename {client => src/client}/assets/firebug/skin/xp/search.png (100%) rename {client => src/client}/assets/firebug/skin/xp/shadow.gif (100%) rename {client => src/client}/assets/firebug/skin/xp/shadow2.gif (100%) rename {client => src/client}/assets/firebug/skin/xp/shadowAlpha.png (100%) rename {client => src/client}/assets/firebug/skin/xp/sprite.png (100%) rename {client => src/client}/assets/firebug/skin/xp/tabHoverLeft.png (100%) rename {client => src/client}/assets/firebug/skin/xp/tabHoverMid.png (100%) rename {client => src/client}/assets/firebug/skin/xp/tabHoverRight.png (100%) rename {client => src/client}/assets/firebug/skin/xp/tabLeft.png (100%) rename {client => src/client}/assets/firebug/skin/xp/tabMenuCheckbox.png (100%) rename {client => src/client}/assets/firebug/skin/xp/tabMenuPin.png (100%) rename {client => src/client}/assets/firebug/skin/xp/tabMenuRadio.png (100%) rename {client => src/client}/assets/firebug/skin/xp/tabMenuTarget.png (100%) rename {client => src/client}/assets/firebug/skin/xp/tabMenuTargetHover.png (100%) rename {client => src/client}/assets/firebug/skin/xp/tabMid.png (100%) rename {client => src/client}/assets/firebug/skin/xp/tabRight.png (100%) rename {client => src/client}/assets/firebug/skin/xp/textEditorBorders.gif (100%) rename {client => src/client}/assets/firebug/skin/xp/textEditorBorders.png (100%) rename {client => src/client}/assets/firebug/skin/xp/textEditorCorners.gif (100%) rename {client => src/client}/assets/firebug/skin/xp/textEditorCorners.png (100%) rename {client => src/client}/assets/firebug/skin/xp/titlebarMid.png (100%) rename {client => src/client}/assets/firebug/skin/xp/toolbarMid.png (100%) rename {client => src/client}/assets/firebug/skin/xp/tree_close.gif (100%) rename {client => src/client}/assets/firebug/skin/xp/tree_open.gif (100%) rename {client => src/client}/assets/firebug/skin/xp/twistyClosed.png (100%) rename {client => src/client}/assets/firebug/skin/xp/twistyOpen.png (100%) rename {client => src/client}/assets/firebug/skin/xp/up.png (100%) rename {client => src/client}/assets/firebug/skin/xp/upActive.png (100%) rename {client => src/client}/assets/firebug/skin/xp/upHover.png (100%) rename {client => src/client}/assets/firebug/skin/xp/warningIcon.gif (100%) rename {client => src/client}/assets/firebug/skin/xp/warningIcon.png (100%) rename {client => src/client}/assets/images/code-16.png (100%) rename {client => src/client}/assets/images/code-24.png (100%) rename {client => src/client}/assets/images/code-32.png (100%) rename {client => src/client}/assets/images/code-48.png (100%) rename {client => src/client}/assets/images/code-64.png (100%) rename {client => src/client}/assets/images/code-80.png (100%) rename {client => src/client}/assets/images/icon-16.png (100%) rename {client => src/client}/assets/images/icon-24.png (100%) rename {client => src/client}/assets/images/icon-32.png (100%) rename {client => src/client}/assets/images/icon-48.png (100%) rename {client => src/client}/assets/images/icon-64.png (100%) rename {client => src/client}/assets/images/icon-80.png (100%) rename {client => src/client}/assets/images/icon-large.png (100%) rename {client => src/client}/assets/images/playground-background.png (100%) rename {client => src/client}/assets/images/playground-error.png (100%) rename {client => src/client}/assets/images/run-16.png (100%) rename {client => src/client}/assets/images/run-24.png (100%) rename {client => src/client}/assets/images/run-32.png (100%) rename {client => src/client}/assets/images/run-48.png (100%) rename {client => src/client}/assets/images/run-64.png (100%) rename {client => src/client}/assets/images/run-80.png (100%) rename {client => src/client}/assets/libraries.json (100%) rename {client => src/client}/assets/styles/_components.scss (100%) rename {client => src/client}/assets/styles/_containers.scss (100%) rename {client => src/client}/assets/styles/_fabric.scss (100%) rename {client => src/client}/assets/styles/_mixins.scss (100%) rename {client => src/client}/assets/styles/_theme.scss (100%) rename {client => src/client}/assets/styles/_vars.scss (100%) rename {client => src/client}/assets/styles/common.scss (87%) rename {client => src/client}/assets/styles/components/_about.scss (100%) rename {client => src/client}/assets/styles/components/_command.scss (100%) rename {client => src/client}/assets/styles/components/_profile.scss (100%) rename {client => src/client}/assets/styles/components/_spinner.scss (100%) rename {client => src/client}/assets/styles/containers/_editor.scss (100%) rename {client => src/client}/assets/styles/containers/_gallery.scss (100%) rename {client => src/client}/assets/styles/containers/_import.scss (95%) rename {client => src/client}/assets/styles/editor.scss (100%) rename {client => src/client}/assets/styles/extras.scss (100%) rename {client => src/client}/assets/styles/mixins/_background.fill.scss (100%) rename {client => src/client}/assets/styles/mixins/_ellipsis.scss (100%) rename {client => src/client}/assets/styles/mixins/_flex.scss (100%) rename {client => src/client}/assets/styles/mixins/_focus.states.scss (100%) rename {client => src/client}/assets/styles/mixins/_keyframes.scss (100%) rename {client => src/client}/assets/styles/mixins/_scroll.scss (100%) rename {client => src/client}/assets/styles/themes/excel.scss (100%) rename {client => src/client}/assets/styles/themes/minimal.scss (100%) rename {client => src/client}/assets/styles/themes/onenote.scss (100%) rename {client => src/client}/assets/styles/themes/powerpoint.scss (100%) rename {client => src/client}/assets/styles/themes/project.scss (100%) rename {client => src/client}/assets/styles/themes/web.scss (100%) rename {client => src/client}/assets/styles/themes/word.scss (100%) rename {client => src/client}/components.ts (100%) rename {client => src/client}/main.ts (89%) rename {client => src/client}/polyfills.ts (100%) rename {client => src/client}/public/.deployment (100%) rename {client => src/client}/public/favicon/android-icon-144x144.png (100%) rename {client => src/client}/public/favicon/android-icon-192x192.png (100%) rename {client => src/client}/public/favicon/android-icon-36x36.png (100%) rename {client => src/client}/public/favicon/android-icon-48x48.png (100%) rename {client => src/client}/public/favicon/android-icon-72x72.png (100%) rename {client => src/client}/public/favicon/android-icon-96x96.png (100%) rename {client => src/client}/public/favicon/apple-icon-114x114.png (100%) rename {client => src/client}/public/favicon/apple-icon-120x120.png (100%) rename {client => src/client}/public/favicon/apple-icon-144x144.png (100%) rename {client => src/client}/public/favicon/apple-icon-152x152.png (100%) rename {client => src/client}/public/favicon/apple-icon-180x180.png (100%) rename {client => src/client}/public/favicon/apple-icon-57x57.png (100%) rename {client => src/client}/public/favicon/apple-icon-60x60.png (100%) rename {client => src/client}/public/favicon/apple-icon-72x72.png (100%) rename {client => src/client}/public/favicon/apple-icon-76x76.png (100%) rename {client => src/client}/public/favicon/apple-icon-precomposed.png (100%) rename {client => src/client}/public/favicon/apple-icon.png (100%) rename {client => src/client}/public/favicon/browserconfig.xml (100%) rename {client => src/client}/public/favicon/favicon-16x16.png (100%) rename {client => src/client}/public/favicon/favicon-32x32.png (100%) rename {client => src/client}/public/favicon/favicon-96x96.png (100%) rename {client => src/client}/public/favicon/favicon.ico (100%) rename {client => src/client}/public/favicon/manifest.json (100%) rename {client => src/client}/public/favicon/ms-icon-144x144.png (100%) rename {client => src/client}/public/favicon/ms-icon-150x150.png (100%) rename {client => src/client}/public/favicon/ms-icon-310x310.png (100%) rename {client => src/client}/public/favicon/ms-icon-70x70.png (100%) rename {client => src/client}/public/functions.ts (100%) rename {client => src/client}/public/gallery.ts (96%) rename {client => src/client}/public/heartbeat.ts (86%) rename {client => src/client}/public/refresh.ts (100%) rename {client => src/client}/public/runner.ts (96%) rename {client => src/client}/public/web.config (100%) rename {client => src/client}/vendor.ts (95%) rename {client => src/client}/views/functions.html (100%) rename {client => src/client}/views/heartbeat.html (100%) rename {client => src/client}/views/index.html (96%) rename {client => src/client}/views/refresh.html (100%) rename {client => src/client}/views/run.html (97%) rename {typings => src/interfaces}/github.d.ts (100%) rename {typings => src/interfaces}/monaco.d.ts (100%) rename {typings => src/interfaces}/playground.d.ts (99%) rename {server => src/server}/.deployment (100%) create mode 100644 src/server/core/ai.helper.ts rename {server => src/server}/core/errors.ts (100%) rename {server => src/server}/core/snippet.generator.ts (100%) rename {server => src/server}/core/template.generator.ts (100%) rename {server => src/server}/core/utilities.ts (100%) rename {server => src/server}/favicon/android-icon-144x144.png (100%) rename {server => src/server}/favicon/android-icon-192x192.png (100%) rename {server => src/server}/favicon/android-icon-36x36.png (100%) rename {server => src/server}/favicon/android-icon-48x48.png (100%) rename {server => src/server}/favicon/android-icon-72x72.png (100%) rename {server => src/server}/favicon/android-icon-96x96.png (100%) rename {server => src/server}/favicon/apple-icon-114x114.png (100%) rename {server => src/server}/favicon/apple-icon-120x120.png (100%) rename {server => src/server}/favicon/apple-icon-144x144.png (100%) rename {server => src/server}/favicon/apple-icon-152x152.png (100%) rename {server => src/server}/favicon/apple-icon-180x180.png (100%) rename {server => src/server}/favicon/apple-icon-57x57.png (100%) rename {server => src/server}/favicon/apple-icon-60x60.png (100%) rename {server => src/server}/favicon/apple-icon-72x72.png (100%) rename {server => src/server}/favicon/apple-icon-76x76.png (100%) rename {server => src/server}/favicon/apple-icon-precomposed.png (100%) rename {server => src/server}/favicon/apple-icon.png (100%) rename {server => src/server}/favicon/browserconfig.xml (100%) rename {server => src/server}/favicon/favicon-16x16.png (100%) rename {server => src/server}/favicon/favicon-32x32.png (100%) rename {server => src/server}/favicon/favicon-96x96.png (100%) rename {server => src/server}/favicon/favicon.ico (100%) rename {server => src/server}/favicon/manifest.json (100%) rename {server => src/server}/favicon/ms-icon-144x144.png (100%) rename {server => src/server}/favicon/ms-icon-150x150.png (100%) rename {server => src/server}/favicon/ms-icon-310x310.png (100%) rename {server => src/server}/favicon/ms-icon-70x70.png (100%) rename {server => src/server}/iisnode.yml (100%) rename {server => src/server}/package.json (100%) rename {server => src/server}/robots.txt (100%) rename {server => src/server}/server.ts (70%) rename {server => src/server}/templates/error.html (100%) rename {server => src/server}/templates/runner (75%) rename {server => src/server}/templates/snippet (100%) rename {server => src/server}/web.config (100%) create mode 100644 tsconfig.aot.json create mode 100644 tsconfig.webpack.json delete mode 100644 typings/.gitignore diff --git a/.gitignore b/.gitignore index cb79a944..71ba5b13 100644 --- a/.gitignore +++ b/.gitignore @@ -48,17 +48,17 @@ $RECYCLE.BIN/ # Windows shortcuts *.lnk -# Ignore the following folders +# Ignore the following folders or files .vs .idea +.awcache *.log obj bin *.user - -node_modules/** -packages/** -typings/** -dist/** - -npm-debug.log.* +node_modules +packages +typings +dist +npm-debug.log. +compiled diff --git a/.vscode/launch.json b/.vscode/launch.json index 4e5fc88c..7a9c6872 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -26,7 +26,7 @@ "program": "${workspaceRoot}\\dist\\server\\server.js", "outFiles": [ "${workspaceRoot}\\dist\\server\\**\\*.js" - ], + ] } }, { diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..ea1d0c41 --- /dev/null +++ b/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2017 Microsoft and contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN \ No newline at end of file diff --git a/config/env.config.js b/config/env.config.js index 346f1089..c7ee2f25 100644 --- a/config/env.config.js +++ b/config/env.config.js @@ -18,7 +18,7 @@ const config = { clientId: '07e7d67e660300b09c38', instrumentationKey: null, editorUrl: 'https://localhost:3000', - tokenUrl: 'https://localhost:3200/auth/local', + tokenUrl: 'https://localhost:3200/auth', runnerUrl: 'https://localhost:3200', samplesUrl: 'https://raw.githubusercontent.com/WrathOfZombies/samples/prod', feedbackUrl: 'https://forms.office.com/Pages/ResponsePage.aspx?id=v4j5cvGGr0GRqy180BHbR_IQfl6RcdlChED7PZI6qXNURUo2UFBUR1YxMkwxWFBLUTRMUE9HRENOWi4u', @@ -28,7 +28,7 @@ const config = { clientId: '95435036e70d23b8549f', instrumentationKey: '07a066dc-d67f-44af-8f77-59cb6ee246a8', editorUrl: 'https://bornholm-edge.azurewebsites.net', - tokenUrl: 'https://bornholm-runner-edge.azurewebsites.net/auth/edge', + tokenUrl: 'https://bornholm-runner-edge.azurewebsites.net/auth', runnerUrl: 'https://bornholm-runner-edge.azurewebsites.net', samplesUrl: 'https://raw.githubusercontent.com/WrathOfZombies/samples/prod', feedbackUrl: 'https://forms.office.com/Pages/ResponsePage.aspx?id=v4j5cvGGr0GRqy180BHbR_IQfl6RcdlChED7PZI6qXNURUo2UFBUR1YxMkwxWFBLUTRMUE9HRENOWi4u', @@ -38,7 +38,7 @@ const config = { clientId: '31ba59b73d83195e58dc', instrumentationKey: 'b3f1f065-02a9-49d3-b75c-4586659f51ef', editorUrl: 'https://bornholm-insiders.azurewebsites.net', - tokenUrl: 'https://bornholm-runner-insiders.azurewebsites.net/auth/insiders', + tokenUrl: 'https://bornholm-runner-insiders.azurewebsites.net/auth', runnerUrl: 'https://bornholm-runner-insiders.azurewebsites.net', samplesUrl: 'https://raw.githubusercontent.com/WrathOfZombies/samples/prod', feedbackUrl: 'https://forms.office.com/Pages/ResponsePage.aspx?id=v4j5cvGGr0GRqy180BHbR_IQfl6RcdlChED7PZI6qXNURUo2UFBUR1YxMkwxWFBLUTRMUE9HRENOWi4u', @@ -58,7 +58,7 @@ const config = { clientId: '8d19e9bbcea2a1cee274', instrumentationKey: '8e0b6b12-8d5e-4710-841d-7996a913f14b', editorUrl: 'https://bornholm.azurewebsites.net', - tokenUrl: 'https://bornholm-runner.azurewebsites.net/auth/cdn', + tokenUrl: 'https://bornholm-runner.azurewebsites.net/auth', runnerUrl: 'https://bornholm-runner.azurewebsites.net', samplesUrl: 'https://raw.githubusercontent.com/WrathOfZombies/samples/prod', feedbackUrl: 'https://forms.office.com/Pages/ResponsePage.aspx?id=v4j5cvGGr0GRqy180BHbR_IQfl6RcdlChED7PZI6qXNURUo2UFBUR1YxMkwxWFBLUTRMUE9HRENOWi4u', diff --git a/config/webpack.common.js b/config/webpack.common.js index d2b798b1..cf3891db 100644 --- a/config/webpack.common.js +++ b/config/webpack.common.js @@ -1,162 +1,157 @@ -var webpack = require('webpack'); -var path = require('path'); -var CopyWebpackPlugin = require('copy-webpack-plugin'); -var HtmlWebpackPlugin = require('html-webpack-plugin'); -var ExtractTextPlugin = require('extract-text-webpack-plugin'); -var { CheckerPlugin } = require('awesome-typescript-loader'); -var autoprefixer = require('autoprefixer'); -var perfectionist = require('perfectionist'); -var { GH_SECRETS } = process.env; +const webpack = require('webpack'); +const path = require('path'); +const CopyWebpackPlugin = require('copy-webpack-plugin'); +const HtmlWebpackPlugin = require('html-webpack-plugin'); +const ExtractTextPlugin = require('extract-text-webpack-plugin'); +const { CheckerPlugin } = require('awesome-typescript-loader'); +const autoprefixer = require('autoprefixer'); +const perfectionist = require('perfectionist'); +const { build, config } = require('./env.config'); +const { GH_SECRETS } = process.env; -module.exports = { - context: path.resolve('./client'), +module.exports = (prodMode) => + ({ + context: path.resolve('./src/client'), - entry: { - polyfills: './polyfills.ts', - vendor: './vendor.ts', - main: './main.ts', - functions: './public/functions.ts', - gallery: './public/gallery.ts', - heartbeat: './public/heartbeat.ts', - refresh: './public/refresh.ts', - runner: './public/runner.ts' - }, + entry: { + polyfills: './polyfills.ts', + vendor: './vendor.ts', + main: './main.ts', + functions: './public/functions.ts', + gallery: './public/gallery.ts', + heartbeat: './public/heartbeat.ts', + refresh: './public/refresh.ts', + runner: './public/runner.ts' + }, - resolve: { - extensions: ['.js', '.ts', '.scss', '.css', '.html'] - }, + resolve: { + extensions: ['.js', '.ts', '.scss', '.css', '.html'] + }, - module: { - rules: [ - { - enforce: 'pre', - test: /\.js$/, - use: "source-map-loader" - }, - { - test: /\.html$/, - use: 'html-loader' - }, - { - test: /\.ts$/, - use: [ - 'awesome-typescript-loader', - 'angular2-template-loader' - ], - exclude: /node_modules/ - }, - { - test: /\.scss$/, - use: ExtractTextPlugin.extract({ - fallback: "style-loader", - use: ['css-loader', 'postcss-loader', 'sass-loader'] - }), - exclude: /theme/ - }, - { - test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)$/, - use: { - loader: 'file-loader', - query: { - name: 'assets/[name].[ext]' + module: { + rules: [ + { + test: /\.html$/, + use: 'html-loader' + }, + { + test: /\.ts$/, + use: 'awesome-typescript-loader?configFileName=tsconfig.webpack.json', + exclude: /node_modules/ + }, + { + test: /\.scss$/, + use: ExtractTextPlugin.extract({ + fallback: "style-loader", + use: ['css-loader', 'postcss-loader', 'sass-loader'] + }), + exclude: /theme/ + }, + { + test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)$/, + use: { + loader: 'file-loader', + query: { + name: 'assets/[name].[ext]' + } } } - } - ] - }, + ] + }, - plugins: [ - new webpack.LoaderOptionsPlugin({ - options: { - postcss: [ - autoprefixer({ browsers: ['Safari >= 8', 'last 2 versions'] }), - perfectionist - ], - htmlLoader: { - minimize: false - } - } - }), - new CheckerPlugin(), - new webpack.LoaderOptionsPlugin({ - options: { - postcss: [ - autoprefixer({ browsers: ['Safari >= 8', 'last 2 versions'] }), - perfectionist - ] - } - }), - new ExtractTextPlugin('[name].bundle.css'), - new webpack.optimize.CommonsChunkPlugin({ - name: ['vendor', 'polyfills'], - minChunks: Infinity - }), - new CopyWebpackPlugin([ - { - from: './assets', - ignore: ['*.scss'], - to: 'assets' - }, - { - from: './public', - to: '', - ignore: ['*.ts'] - }, - { - from: '../node_modules/monaco-editor/min', - to: './libs/monaco-editor' - }, - { - from: '../node_modules/office-ui-fabric-js/dist/css', - to: './libs/office-ui-fabric-js/css' - }, - { - from: '../node_modules/office-ui-fabric-js/dist/js', - to: './libs/office-ui-fabric-js/js' - }, - { - from: '../config/env.config.js', - to: '../server/core/env.config.js', - transform: (content, path) => { - if (GH_SECRETS == null) { - return content; + plugins: [ + new webpack.NoEmitOnErrorsPlugin(), + new webpack.BannerPlugin({ banner: `${build.name} v.${build.version} (${prodMode ? 'PROD' : 'DEV'}:${build.timestamp}) © ${build.author}` }), + new webpack.DefinePlugin({ + PLAYGROUND: JSON.stringify({ + devMode: !prodMode, + build: build, + config: config + }) + }), + new webpack.LoaderOptionsPlugin({ + options: { + postcss: [ + autoprefixer({ browsers: ['Safari >= 8', 'last 2 versions'] }), + perfectionist + ], + htmlLoader: { + minimize: false } + } + }), + new CheckerPlugin(), + new ExtractTextPlugin('[name].bundle.css'), + new webpack.optimize.CommonsChunkPlugin({ + name: ['vendor', 'polyfills'], + minChunks: Infinity + }), + new CopyWebpackPlugin([ + { + from: './assets', + ignore: ['*.scss'], + to: 'assets' + }, + { + from: './public', + to: '', + ignore: ['*.ts'] + }, + { + from: '../../config/env.config.js', + to: '../server/core/env.config.js', + transform: (content, path) => { + if (GH_SECRETS == null) { + return content; + } - const secrets = GH_SECRETS.split(','); - let mappedSecrets = {}; - ['local', 'edge', 'insiders', 'production', 'cdn'].forEach((value, index) => { - mappedSecrets[value] = secrets[index]; - }); + const secrets = GH_SECRETS.split(','); + let mappedSecrets = {}; + ['local', 'edge', 'insiders', 'production', 'cdn'].forEach((value, index) => { + mappedSecrets[value] = secrets[index]; + }); - const data = `\nexports.secrets = ${JSON.stringify(mappedSecrets)};`; - return content + data; + const data = `\nexports.secrets = ${JSON.stringify(mappedSecrets)};`; + return content + data; + } + }, + { + from: '../../node_modules/monaco-editor/min', + to: './libs/monaco-editor' + }, + { + from: '../../node_modules/office-ui-fabric-js/dist/css', + to: './libs/office-ui-fabric-js/css' + }, + { + from: '../../node_modules/office-ui-fabric-js/dist/js', + to: './libs/office-ui-fabric-js/js' } - }, - ]), - new HtmlWebpackPlugin({ - filename: 'index.html', - template: './views/index.html', - chunks: ['polyfills', 'vendor', 'main'] - }), - new HtmlWebpackPlugin({ - filename: 'functions.html', - template: './views/functions.html', - chunks: ['polyfills', 'vendor', 'functions'], - }), - new HtmlWebpackPlugin({ - filename: 'run.html', - template: './views/run.html', - chunks: ['polyfills', 'vendor', 'gallery'], - }), - new HtmlWebpackPlugin({ - filename: 'heartbeat.html', - template: './views/heartbeat.html', - chunks: ['polyfills', 'vendor', 'heartbeat'], - }), - new HtmlWebpackPlugin({ - filename: 'refresh.html', - template: './views/refresh.html', - chunks: ['polyfills', 'vendor', 'refresh'], - }) - ] -}; + ]), + new HtmlWebpackPlugin({ + filename: 'index.html', + template: './views/index.html', + chunks: ['polyfills', 'vendor', 'main'] + }), + new HtmlWebpackPlugin({ + filename: 'functions.html', + template: './views/functions.html', + chunks: ['polyfills', 'vendor', 'functions'], + }), + new HtmlWebpackPlugin({ + filename: 'run.html', + template: './views/run.html', + chunks: ['polyfills', 'vendor', 'gallery'], + }), + new HtmlWebpackPlugin({ + filename: 'heartbeat.html', + template: './views/heartbeat.html', + chunks: ['polyfills', 'vendor', 'heartbeat'], + }), + new HtmlWebpackPlugin({ + filename: 'refresh.html', + template: './views/refresh.html', + chunks: ['polyfills', 'vendor', 'refresh'], + }) + ] + }); diff --git a/config/webpack.dev.js b/config/webpack.dev.js index 4df81765..0e424f56 100644 --- a/config/webpack.dev.js +++ b/config/webpack.dev.js @@ -1,98 +1,68 @@ -var webpack = require('webpack'); -var webpackMerge = require('webpack-merge'); -var BrowserSyncPlugin = require('browser-sync-webpack-plugin'); -var commonConfig = require('./webpack.common.js'); -var path = require('path'); -var { build, config } = require('./env.config'); +const webpack = require('webpack'); +const webpackMerge = require('webpack-merge'); +const commonConfig = require('./webpack.common.js'); +const path = require('path'); +const BrowserSyncPlugin = require('browser-sync-webpack-plugin'); -module.exports = webpackMerge(commonConfig, { - devtool: 'inline-source-map', +module.exports = () => + webpackMerge(commonConfig(false), { + devtool: 'eval-source-map', - output: { - path: path.resolve('./dist/client'), - filename: '[name].bundle.js', - chunkFilename: '[name].chunk.js', - }, + output: { + path: path.resolve('./dist/client'), + filename: '[name].bundle.js', + chunkFilename: '[name].chunk.js', + }, + + resolve: { + modules: ["node_modules"] + }, + + plugins: [ + new BrowserSyncPlugin( + { + https: true, + host: 'localhost', + port: 3000, + proxy: 'https://localhost:3100/' + }, + { + reload: false + } + ) + ], - plugins: [ - new webpack.BannerPlugin({ banner: `${build.name} v.${build.version} (${build.timestamp}) © ${build.author}` }), - new webpack.DefinePlugin({ - PLAYGROUND: JSON.stringify({ - devMode: true, - build: build, - config: config - }) - }), - new BrowserSyncPlugin( - { - https: true, - host: 'localhost', - port: 3000, - proxy: 'https://localhost:3100/' + devServer: { + publicPath: "/", + contentBase: path.resolve('./dist/client'), + https: true, + overlay: { + warnings: false, + errors: true }, - { - reload: false + port: 3100, + quiet: true, + historyApiFallback: true, + stats: { + assets: false, + cached: false, + children: false, + chunks: true, + chunkModules: true, + chunkOrigins: false, + context: "./dist/client/", + colors: true, + errors: true, + errorDetails: true, + hash: true, + modules: false, + modulesSort: "field", + publicPath: true, + reasons: false, + source: false, + timings: true, + version: true, + warnings: true } - ) - ], - - devServer: { - contentBase: path.resolve('./dist/client'), - compress: true, - https: true, - inline: true, - overlay: { - warnings: false, - errors: true - }, - watchContentBase: true, - compress: true, - port: 3100, - historyApiFallback: true, - quiet: true, - stats: { - // Add asset Information - assets: true, - // Add information about cached (not built) modules - cached: false, - // Add children information - children: false, - // Add chunk information (setting this to `false` allows for a less verbose output) - chunks: true, - // Add built modules information to chunk information - chunkModules: true, - // Add the origins of chunks and chunk merging info - chunkOrigins: false, - // Sort the chunks by a field - context: "./dist/client/", - // `webpack --colors` equivalent - colors: true, - // Add errors - errors: true, - // Add details to errors (like resolving log) - errorDetails: true, - // Add the hash of the compilation - hash: true, - // Add built modules information - modules: false, - // Sort the modules by a field - modulesSort: "field", - // Add public path information - publicPath: true, - // Add information about the reasons why modules are included - reasons: false, - // Add the source code of modules - source: false, - // Add timing information - timings: true, - // Add webpack version information - version: true, - // Add warnings - warnings: false - }, - watchOptions: { - aggregateTimeout: 300, - poll: 1000 } - } -}); + }); diff --git a/config/webpack.prod.js b/config/webpack.prod.js index b75f2496..f6fc38b2 100644 --- a/config/webpack.prod.js +++ b/config/webpack.prod.js @@ -1,83 +1,59 @@ -var webpack = require('webpack'); -var webpackMerge = require('webpack-merge'); -var commonConfig = require('./webpack.common.js'); -var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; -var path = require('path'); -var { build, config } = require('./env.config'); - +const webpack = require('webpack'); +const webpackMerge = require('webpack-merge'); +const commonConfig = require('./webpack.common.js'); +const path = require('path'); const ENV = process.env.NODE_ENV = process.env.ENV = 'production'; const { TRAVIS } = process.env; -module.exports = webpackMerge(commonConfig, { - devtool: 'source-map', +module.exports = (env) => + webpackMerge(commonConfig(env.mode === 'prod'), { + devtool: 'source-map', - output: { - path: './dist/client', - filename: '[name].bundle.js', - chunkFilename: '[id].chunk.js' - }, + output: { + path: './dist/client', + filename: '[name].bundle.js', + chunkFilename: '[id].chunk.js' + }, - performance: { - hints: "warning" - }, + performance: { + hints: "warning" + }, - stats: { - // Add asset Information - assets: true, - // Add information about cached (not built) modules - cached: false, - // Add children information - children: false, - // Add chunk information (setting this to `false` allows for a less verbose output) - chunks: true, - // Add built modules information to chunk information - chunkModules: true, - // Add the origins of chunks and chunk merging info - chunkOrigins: false, - // Sort the chunks by a field - context: "./dist/client/", - // `webpack --colors` equivalent - colors: true, - // Add errors - errors: true, - // Add details to errors (like resolving log) - errorDetails: true, - // Add the hash of the compilation - hash: true, - // Add built modules information - modules: false, - // Sort the modules by a field - modulesSort: "field", - // Add public path information - publicPath: true, - // Add information about the reasons why modules are included - reasons: false, - // Add the source code of modules - source: false, - // Add timing information - timings: true, - // Add webpack version information - version: true, - // Add warnings - warnings: false - }, + stats: { + assets: true, + cached: false, + children: false, + chunks: true, + chunkModules: true, + chunkOrigins: false, + context: "./dist/client/", + colors: true, + errors: true, + errorDetails: true, + hash: true, + modules: false, + modulesSort: "field", + publicPath: true, + reasons: false, + source: false, + timings: true, + version: true, + warnings: false + }, - plugins: [ - new webpack.BannerPlugin({ banner: `${build.name} v.${build.version} (${build.timestamp}) © ${build.author}` }), - new webpack.NoErrorsPlugin(), - new webpack.optimize.UglifyJsPlugin({ - sourceMap: true, - compress: true, - mangle: { - keep_fnames: true - } - }), - new webpack.DefinePlugin({ - PLAYGROUND: JSON.stringify({ - devMode: false, - build: build, - config: config - }) - }) - ] -}); + plugins: [ + new webpack.optimize.UglifyJsPlugin({ + sourceMap: true, + compress: true, + mangle: { + screw_ie8: true, + keep_fnames: true + }, + compress: { + warnings: false, + screw_ie8: true + }, + comments: false + }) + ] + }); diff --git a/package.json b/package.json index e59005e0..4b7a6b12 100644 --- a/package.json +++ b/package.json @@ -19,33 +19,37 @@ "url": "https://github.com/officedev/addin-playground/issues" }, "homepage": "https://github.com/officedev/addin-playground#readme", - "version": "1.0.0", + "version": "1.0.0-preview", "scripts": { - "compile": "tsc -p tsconfig.server.json --watch", - "copy": "cpx \"server/**/!(*.ts)\" \"dist/server\" --watch", - "copy-config": "cpx \"config/env.config.js\" \"dist/server/core\" --watch", - "client": "webpack-dev-server --config config/webpack.dev.js --progress", - "start": "rimraf dist && concurrently --kill-others --raw \"npm run client\" \"npm run compile\" \"npm run copy\" \"npm run copy-config\"", + "clean": "rimraf dist && rimraf .awcache", "lint": "tslint --project tsconfig.json", - "build": "rimraf dist && tsc -p tsconfig.server.json && cpx \"server/**/!(*.ts)\" \"dist/server\" && rimraf dist/client && webpack --config config/webpack.prod.js", + "dev:server": "tsc -p tsconfig.server.json --watch", + "dev:copy": "cpx \"src/server/**/!(*.ts)\" \"dist/server\" --watch", + "dev:config": "cpx \"config/env.config.js\" \"dist/server/core\" --watch", + "prod:server": "tsc -p tsconfig.server.json", + "prod:copy": "cpx \"src/server/**/!(*.ts)\" \"dist/server\"", + "build:dev": "webpack-dev-server --config config/webpack.dev.js --progress", + "build:prod": "webpack --config config/webpack.prod.js --env.mode=prod --progress --colors --bail", + "start": "npm-run-all clean -p build:dev dev:*", + "build": "npm-run-all clean -p build:prod prod:*", "deploy": "node config/deploy.js" }, "license": "MIT", "dependencies": { - "@angular/common": "2.4.9", - "@angular/compiler": "2.4.9", - "@angular/core": "2.4.9", - "@angular/forms": "2.4.9", - "@angular/http": "2.4.9", - "@angular/platform-browser": "2.4.9", - "@angular/platform-browser-dynamic": "2.4.9", - "@angular/router": "3.4.9", + "@angular/common": "2.4.10", + "@angular/compiler": "2.4.10", + "@angular/core": "2.4.10", + "@angular/forms": "2.4.10", + "@angular/http": "2.4.10", + "@angular/platform-browser": "2.4.10", + "@angular/platform-browser-dynamic": "2.4.10", + "@angular/router": "3.4.10", "@microsoft/office-js-helpers": "0.6.0-beta.0", "@ngrx/core": "1.2.0", - "@ngrx/effects": "2.0.0", + "@ngrx/effects": "2.0.1", "@ngrx/store": "2.2.1", "@ngrx/store-devtools": "3.2.3", - "applicationinsights": "0.18.0", + "applicationinsights": "0.19.0", "applicationinsights-js": "1.0.8", "body-parser": "1.17.1", "clipboard": "1.6.1", @@ -54,76 +58,75 @@ "crypto-js": "3.1.9-1", "cuid": "1.3.8", "express": "4.15.2", + "serve-static": "1.12.1", "handlebars": "4.0.6", - "jquery": "3.1.1", + "jquery": "3.2.1", "js-yaml": "3.8.2", "lodash": "4.17.4", - "moment": "^2.18.0", + "moment": "2.18.0", "monaco-editor": "0.8.3", - "office-ui-fabric-core": "6.0.0", + "office-ui-fabric-core": "6.0.1", "office-ui-fabric-js": "1.4.0", "reflect-metadata": "0.1.10", - "request": "2.80.0", + "request": "2.81.0", "reselect": "2.5.4", "rxjs": "5.2.0", "typescript": "2.2.1", "uuid": "3.0.1", - "zone.js": "0.7.7" + "zone.js": "0.8.4" }, "devDependencies": { - "cpx": "1.5.0", - "concurrently": "3.4.0", - "angular2-template-loader": "0.6.2", + "@angular/compiler-cli": "2.4.10", + "@ngrx/store-log-monitor": "3.0.2", + "@ngtools/webpack": "1.2.14", + "@types/applicationinsights": "0.15.33", + "@types/applicationinsights-js": "0.23.5", + "@types/body-parser": "0.0.34", + "@types/chalk": "0.4.31", + "@types/clipboard": "1.5.31", + "@types/cors": "2.8.0", + "@types/express": "4.0.35", + "@types/express-serve-static-core": "4.0.40", + "@types/form-data": "0.0.33", + "@types/handlebars": "4.0.31", + "@types/jquery": "2.0.40", + "@types/js-yaml": "3.5.29", + "@types/lodash": "4.14.54", + "@types/mime": "0.0.29", + "@types/node": "7.0.5", + "@types/office-js": "0.0.38", + "@types/request": "0.0.40", + "@types/serve-static": "1.7.31", + "@types/shelljs": "0.7.0", + "@types/webpack": "2.2.9", + "@types/webpack-dev-server": "1.12.6", "autoprefixer": "6.7.6", "awesome-typescript-loader": "3.1.2", "browser-sync": "2.18.8", "browser-sync-webpack-plugin": "1.1.4", + "chalk": "1.1.3", "copy-webpack-plugin": "4.0.1", + "cpx": "1.5.0", "css-loader": "0.26.2", + "extract-loader": "0.1.0", "extract-text-webpack-plugin": "2.1.0", "file-loader": "0.10.1", "html-loader": "0.4.5", - "extract-loader": "0.1.0", "html-webpack-plugin": "2.28.0", "node-sass": "4.5.0", + "npm-run-all": "4.0.2", "perfectionist": "2.4.0", "postcss-loader": "1.3.3", "precss": "1.4.0", "raw-loader": "0.5.1", - "source-map-loader": "0.1.6", - "resolve-url-loader": "2.0.2", "rimraf": "2.6.1", "sass-loader": "6.0.3", + "shelljs": "0.7.7", "style-loader": "0.13.2", - "webpack-bundle-analyzer": "^2.3.0", - "webpack-dev-server": "2.4.1", - "webpack-merge": "4.0.0", - "webpack": "2.2.1", "tslint": "4.5.1", - "chalk": "1.1.3", - "shelljs": "0.7.7", - "@types/shelljs": "0.7.0", - "@types/webpack": "2.2.9", - "@types/webpack-dev-server": "1.12.6", - "@types/applicationinsights-js": "0.23.5", - "@types/applicationinsights": "0.15.33", - "@types/body-parser": "0.0.34", - "@types/express": "4.0.35", - "@types/express-serve-static-core": "4.0.40", - "@types/handlebars": "4.0.31", - "@types/js-beautify": "0.0.28", - "@types/js-yaml": "3.5.29", - "@types/mime": "0.0.29", - "@types/serve-static": "1.7.31", - "@types/cors": "2.8.0", - "@types/form-data": "0.0.33", - "@types/request": "0.0.40", - "@types/clipboard": "1.5.31", - "@types/jquery": "2.0.40", - "@types/lodash": "4.14.54", - "@types/lz-string": "1.3.31", - "@types/node": "7.0.5", - "@types/office-js": "0.0.38", - "@types/chalk": "0.4.31" + "webpack": "2.2.1", + "webpack-bundle-analyzer": "2.3.1", + "webpack-dev-server": "2.4.1", + "webpack-merge": "4.0.0" } -} +} \ No newline at end of file diff --git a/client/app/actions/github.ts b/src/client/app/actions/github.ts similarity index 100% rename from client/app/actions/github.ts rename to src/client/app/actions/github.ts diff --git a/client/app/actions/index.ts b/src/client/app/actions/index.ts similarity index 100% rename from client/app/actions/index.ts rename to src/client/app/actions/index.ts diff --git a/client/app/actions/monaco.ts b/src/client/app/actions/monaco.ts similarity index 100% rename from client/app/actions/monaco.ts rename to src/client/app/actions/monaco.ts diff --git a/client/app/actions/snippet.ts b/src/client/app/actions/snippet.ts similarity index 100% rename from client/app/actions/snippet.ts rename to src/client/app/actions/snippet.ts diff --git a/client/app/actions/ui.ts b/src/client/app/actions/ui.ts similarity index 100% rename from client/app/actions/ui.ts rename to src/client/app/actions/ui.ts diff --git a/client/app/components/about.ts b/src/client/app/components/about.ts similarity index 100% rename from client/app/components/about.ts rename to src/client/app/components/about.ts diff --git a/client/app/components/alert.ts b/src/client/app/components/alert.ts similarity index 100% rename from client/app/components/alert.ts rename to src/client/app/components/alert.ts diff --git a/client/app/components/collapse.ts b/src/client/app/components/collapse.ts similarity index 100% rename from client/app/components/collapse.ts rename to src/client/app/components/collapse.ts diff --git a/client/app/components/command.ts b/src/client/app/components/command.ts similarity index 100% rename from client/app/components/command.ts rename to src/client/app/components/command.ts diff --git a/client/app/components/dialog.ts b/src/client/app/components/dialog.ts similarity index 100% rename from client/app/components/dialog.ts rename to src/client/app/components/dialog.ts diff --git a/client/app/components/index.ts b/src/client/app/components/index.ts similarity index 100% rename from client/app/components/index.ts rename to src/client/app/components/index.ts diff --git a/client/app/components/profile.ts b/src/client/app/components/profile.ts similarity index 91% rename from client/app/components/profile.ts rename to src/client/app/components/profile.ts index c577368e..eacd1798 100644 --- a/client/app/components/profile.ts +++ b/src/client/app/components/profile.ts @@ -1,5 +1,5 @@ import { Component, Input, Output, EventEmitter } from '@angular/core'; -import {Strings} from '../helpers'; +import { Strings, settings } from '../helpers'; @Component({ selector: 'profile', @@ -11,6 +11,7 @@ import {Strings} from '../helpers';
{{profile?.name}}
{{profile?.login}}
{{profile?.bio}}
+
ID: ${settings.user}
diff --git a/client/app/components/snippet.info.ts b/src/client/app/components/snippet.info.ts similarity index 100% rename from client/app/components/snippet.info.ts rename to src/client/app/components/snippet.info.ts diff --git a/client/app/containers/app.ts b/src/client/app/containers/app.ts similarity index 97% rename from client/app/containers/app.ts rename to src/client/app/containers/app.ts index ab79a804..3614f538 100644 --- a/client/app/containers/app.ts +++ b/src/client/app/containers/app.ts @@ -145,7 +145,7 @@ export class AppComponent { return; } - this.isLoggedIn$ + let sub = this.isLoggedIn$ .subscribe(isLoggedIn => { if (!isLoggedIn) { this._store.dispatch(new GitHub.LoginAction()); @@ -157,6 +157,10 @@ export class AppComponent { else { this._store.dispatch(new GitHub.SharePrivateGistAction(this.snippet)); } + + if (sub && !sub.closed) { + sub.unsubscribe(); + } }); } diff --git a/client/app/containers/editor.ts b/src/client/app/containers/editor.ts similarity index 97% rename from client/app/containers/editor.ts rename to src/client/app/containers/editor.ts index cabace52..e8b91956 100644 --- a/client/app/containers/editor.ts +++ b/src/client/app/containers/editor.ts @@ -2,6 +2,7 @@ import { Component, HostListener, AfterViewInit, ViewChild, ElementRef } from '@ import { Dictionary } from '@microsoft/office-js-helpers'; import * as fromRoot from '../reducers'; import { Store } from '@ngrx/store'; +import { AI } from '../helpers'; import { Monaco, Snippet } from '../actions'; import { MonacoService } from '../services'; import { debounce } from 'lodash'; @@ -101,6 +102,7 @@ export class Editor implements AfterViewInit { if (newTab) { // Update the current state to the new tab this.currentState = this.tabs.get(newTab); + let timer = AI.trackPageView(this.currentState.view, `/edit/${this.currentState.name}`); if (this.currentState.name === 'script') { this.updateIntellisense(); } @@ -108,6 +110,7 @@ export class Editor implements AfterViewInit { this._monacoEditor.restoreViewState(this.currentState.viewState); this._monacoEditor.focus(); this._resize(); + timer.stop(); } }); } diff --git a/client/app/containers/gallery.list.ts b/src/client/app/containers/gallery.list.ts similarity index 100% rename from client/app/containers/gallery.list.ts rename to src/client/app/containers/gallery.list.ts diff --git a/client/app/containers/import.ts b/src/client/app/containers/import.ts similarity index 94% rename from client/app/containers/import.ts rename to src/client/app/containers/import.ts index 90011fe6..a5d22546 100644 --- a/client/app/containers/import.ts +++ b/src/client/app/containers/import.ts @@ -2,6 +2,7 @@ import { Component } from '@angular/core'; import * as fromRoot from '../reducers'; import { Store } from '@ngrx/store'; import { UI, Snippet, GitHub } from '../actions'; +import { AI } from '../helpers'; import { isEmpty } from 'lodash'; @Component({ @@ -10,20 +11,19 @@ import { isEmpty } from 'lodash';
-

Please choose the playground flavor:

+

Choose your host:

+
diff --git a/client/views/refresh.html b/src/client/views/refresh.html similarity index 100% rename from client/views/refresh.html rename to src/client/views/refresh.html diff --git a/client/views/run.html b/src/client/views/run.html similarity index 97% rename from client/views/run.html rename to src/client/views/run.html index 5f99fc3f..31279e2e 100644 --- a/client/views/run.html +++ b/src/client/views/run.html @@ -51,8 +51,9 @@

Project Bornholm

-

Please choose the playground flavor:

+

Choose your host:

+
diff --git a/typings/github.d.ts b/src/interfaces/github.d.ts similarity index 100% rename from typings/github.d.ts rename to src/interfaces/github.d.ts diff --git a/typings/monaco.d.ts b/src/interfaces/monaco.d.ts similarity index 100% rename from typings/monaco.d.ts rename to src/interfaces/monaco.d.ts diff --git a/typings/playground.d.ts b/src/interfaces/playground.d.ts similarity index 99% rename from typings/playground.d.ts rename to src/interfaces/playground.d.ts index fde6329e..2616dab5 100644 --- a/typings/playground.d.ts +++ b/src/interfaces/playground.d.ts @@ -103,7 +103,7 @@ interface IEnvironment { build?: { name: string; version: string; - timestamp: number; + timestamp: string; author: string; }, config?: IEnvironmentConfig diff --git a/server/.deployment b/src/server/.deployment similarity index 100% rename from server/.deployment rename to src/server/.deployment diff --git a/src/server/core/ai.helper.ts b/src/server/core/ai.helper.ts new file mode 100644 index 00000000..28f79768 --- /dev/null +++ b/src/server/core/ai.helper.ts @@ -0,0 +1,116 @@ +import * as AppInsights from 'applicationinsights'; + +export class ApplicationInsights { + private _current: Client; + private _disable = false; + + /** + * Sometimes AppInsights will encounter a failure on first use + * (https://github.com/Microsoft/ApplicationInsights-JS/issues/347) + * To avoid the issue, wrap any use of "this.current" in a try/catch + */ + constructor(instrumentationKey, disable?: boolean) { + try { + this._disable = disable; + this._current = AppInsights.setup(instrumentationKey).start().client; + if (!this._disable) { + AppInsights.enableVerboseLogging(); + } + } + catch (e) { + console.error('Could not initialize AppInsights.'); + } + } + + trackTimedEvent(name: string, properties?: { [index: string]: string }, measurement?: { [index: string]: number }) { + let timer = Date; + const tStart = timer.now(); + return { + stop: () => { + try { + const tEnd = timer.now(); + this.trackEvent(name, properties, { ...measurement, duration: (tEnd - tStart) / 1000 }); + } + catch (e) { + } + }, + get elapsed() { + return timer.now() - tStart; + } + }; + } + + /** + * Log an exception you have caught. + * @param exception An Error from a catch clause, or the string error message. + * @param properties map[string, string] - additional data used to filter events and metrics in the portal. Defaults to empty. + * @param measurements map[string, number] - metrics associated with this event, displayed in Metrics Explorer on the portal. Defaults to empty. + * @param severityLevel AI.SeverityLevel - severity level + */ + trackException(error, location) { + try { + if (this._disable) { + console.log(error); + } + this._current.trackException(error.innerError || error, { + message: error.message, + location: location + }); + } + catch (e) { + console.error(error, location); + } + } + + /** + * Log a user action or other occurrence. + * @param name A string to identify this event in the portal. + * @param properties map[string, string] - additional data used to filter events and metrics in the portal. Defaults to empty. + * @param measurements map[string, number] - metrics associated with this event, displayed in Metrics Explorer on the portal. Defaults to empty. + */ + trackEvent(name: string, properties?: { [index: string]: string }, measurement?: { [index: string]: number }) { + try { + if (this._disable) { + console.info(name, { + ...properties, + }, measurement); + } + this._current.trackEvent(name, { + ...properties, + }, measurement); + } + catch (e) { + + } + } + + /** + * Log a numeric value that is not associated with a specific event. Typically used to send regular reports of performance indicators. + * To send a single measurement, use just the first two parameters. If you take measurements very frequently, you can reduce the + * telemetry bandwidth by aggregating multiple measurements and sending the resulting average at intervals. + * @param name A string that identifies the metric. + * @param average Number representing either a single measurement, or the average of several measurements. + * @param sampleCount The number of measurements represented by the average. Defaults to 1. + * @param min The smallest measurement in the sample. Defaults to the average. + * @param max The largest measurement in the sample. Defaults to the average. + */ + trackMetric( + name: string, average: number, sampleCount?: number, min?: number, max?: number, properties?: { + [name: string]: string; + } + ) { + try { + if (this._disable) { + console.info(name, average, sampleCount, min, max, { + ...properties, + }); + } + this._current.trackMetric(name, average, sampleCount, min, max, null, { + ...properties + }); + } + catch (e) { + + } + } +} diff --git a/server/core/errors.ts b/src/server/core/errors.ts similarity index 100% rename from server/core/errors.ts rename to src/server/core/errors.ts diff --git a/server/core/snippet.generator.ts b/src/server/core/snippet.generator.ts similarity index 100% rename from server/core/snippet.generator.ts rename to src/server/core/snippet.generator.ts diff --git a/server/core/template.generator.ts b/src/server/core/template.generator.ts similarity index 100% rename from server/core/template.generator.ts rename to src/server/core/template.generator.ts diff --git a/server/core/utilities.ts b/src/server/core/utilities.ts similarity index 100% rename from server/core/utilities.ts rename to src/server/core/utilities.ts diff --git a/server/favicon/android-icon-144x144.png b/src/server/favicon/android-icon-144x144.png similarity index 100% rename from server/favicon/android-icon-144x144.png rename to src/server/favicon/android-icon-144x144.png diff --git a/server/favicon/android-icon-192x192.png b/src/server/favicon/android-icon-192x192.png similarity index 100% rename from server/favicon/android-icon-192x192.png rename to src/server/favicon/android-icon-192x192.png diff --git a/server/favicon/android-icon-36x36.png b/src/server/favicon/android-icon-36x36.png similarity index 100% rename from server/favicon/android-icon-36x36.png rename to src/server/favicon/android-icon-36x36.png diff --git a/server/favicon/android-icon-48x48.png b/src/server/favicon/android-icon-48x48.png similarity index 100% rename from server/favicon/android-icon-48x48.png rename to src/server/favicon/android-icon-48x48.png diff --git a/server/favicon/android-icon-72x72.png b/src/server/favicon/android-icon-72x72.png similarity index 100% rename from server/favicon/android-icon-72x72.png rename to src/server/favicon/android-icon-72x72.png diff --git a/server/favicon/android-icon-96x96.png b/src/server/favicon/android-icon-96x96.png similarity index 100% rename from server/favicon/android-icon-96x96.png rename to src/server/favicon/android-icon-96x96.png diff --git a/server/favicon/apple-icon-114x114.png b/src/server/favicon/apple-icon-114x114.png similarity index 100% rename from server/favicon/apple-icon-114x114.png rename to src/server/favicon/apple-icon-114x114.png diff --git a/server/favicon/apple-icon-120x120.png b/src/server/favicon/apple-icon-120x120.png similarity index 100% rename from server/favicon/apple-icon-120x120.png rename to src/server/favicon/apple-icon-120x120.png diff --git a/server/favicon/apple-icon-144x144.png b/src/server/favicon/apple-icon-144x144.png similarity index 100% rename from server/favicon/apple-icon-144x144.png rename to src/server/favicon/apple-icon-144x144.png diff --git a/server/favicon/apple-icon-152x152.png b/src/server/favicon/apple-icon-152x152.png similarity index 100% rename from server/favicon/apple-icon-152x152.png rename to src/server/favicon/apple-icon-152x152.png diff --git a/server/favicon/apple-icon-180x180.png b/src/server/favicon/apple-icon-180x180.png similarity index 100% rename from server/favicon/apple-icon-180x180.png rename to src/server/favicon/apple-icon-180x180.png diff --git a/server/favicon/apple-icon-57x57.png b/src/server/favicon/apple-icon-57x57.png similarity index 100% rename from server/favicon/apple-icon-57x57.png rename to src/server/favicon/apple-icon-57x57.png diff --git a/server/favicon/apple-icon-60x60.png b/src/server/favicon/apple-icon-60x60.png similarity index 100% rename from server/favicon/apple-icon-60x60.png rename to src/server/favicon/apple-icon-60x60.png diff --git a/server/favicon/apple-icon-72x72.png b/src/server/favicon/apple-icon-72x72.png similarity index 100% rename from server/favicon/apple-icon-72x72.png rename to src/server/favicon/apple-icon-72x72.png diff --git a/server/favicon/apple-icon-76x76.png b/src/server/favicon/apple-icon-76x76.png similarity index 100% rename from server/favicon/apple-icon-76x76.png rename to src/server/favicon/apple-icon-76x76.png diff --git a/server/favicon/apple-icon-precomposed.png b/src/server/favicon/apple-icon-precomposed.png similarity index 100% rename from server/favicon/apple-icon-precomposed.png rename to src/server/favicon/apple-icon-precomposed.png diff --git a/server/favicon/apple-icon.png b/src/server/favicon/apple-icon.png similarity index 100% rename from server/favicon/apple-icon.png rename to src/server/favicon/apple-icon.png diff --git a/server/favicon/browserconfig.xml b/src/server/favicon/browserconfig.xml similarity index 100% rename from server/favicon/browserconfig.xml rename to src/server/favicon/browserconfig.xml diff --git a/server/favicon/favicon-16x16.png b/src/server/favicon/favicon-16x16.png similarity index 100% rename from server/favicon/favicon-16x16.png rename to src/server/favicon/favicon-16x16.png diff --git a/server/favicon/favicon-32x32.png b/src/server/favicon/favicon-32x32.png similarity index 100% rename from server/favicon/favicon-32x32.png rename to src/server/favicon/favicon-32x32.png diff --git a/server/favicon/favicon-96x96.png b/src/server/favicon/favicon-96x96.png similarity index 100% rename from server/favicon/favicon-96x96.png rename to src/server/favicon/favicon-96x96.png diff --git a/server/favicon/favicon.ico b/src/server/favicon/favicon.ico similarity index 100% rename from server/favicon/favicon.ico rename to src/server/favicon/favicon.ico diff --git a/server/favicon/manifest.json b/src/server/favicon/manifest.json similarity index 100% rename from server/favicon/manifest.json rename to src/server/favicon/manifest.json diff --git a/server/favicon/ms-icon-144x144.png b/src/server/favicon/ms-icon-144x144.png similarity index 100% rename from server/favicon/ms-icon-144x144.png rename to src/server/favicon/ms-icon-144x144.png diff --git a/server/favicon/ms-icon-150x150.png b/src/server/favicon/ms-icon-150x150.png similarity index 100% rename from server/favicon/ms-icon-150x150.png rename to src/server/favicon/ms-icon-150x150.png diff --git a/server/favicon/ms-icon-310x310.png b/src/server/favicon/ms-icon-310x310.png similarity index 100% rename from server/favicon/ms-icon-310x310.png rename to src/server/favicon/ms-icon-310x310.png diff --git a/server/favicon/ms-icon-70x70.png b/src/server/favicon/ms-icon-70x70.png similarity index 100% rename from server/favicon/ms-icon-70x70.png rename to src/server/favicon/ms-icon-70x70.png diff --git a/server/iisnode.yml b/src/server/iisnode.yml similarity index 100% rename from server/iisnode.yml rename to src/server/iisnode.yml diff --git a/server/package.json b/src/server/package.json similarity index 100% rename from server/package.json rename to src/server/package.json diff --git a/server/robots.txt b/src/server/robots.txt similarity index 100% rename from server/robots.txt rename to src/server/robots.txt diff --git a/server/server.ts b/src/server/server.ts similarity index 70% rename from server/server.ts rename to src/server/server.ts index ea3eccc1..4eeaf339 100644 --- a/server/server.ts +++ b/src/server/server.ts @@ -3,51 +3,45 @@ import * as https from 'https'; import * as path from 'path'; import * as express from 'express'; import * as bodyParser from 'body-parser'; -import * as serverStatic from 'serve-static'; import * as cors from 'cors'; import * as Request from 'request'; import { replaceTabsWithSpaces, generateUrl } from './core/utilities'; import { BadRequestError, UnauthorizedError } from './core/errors'; import { loadTemplate } from './core/template.generator'; import { snippetGenerator } from './core/snippet.generator'; +import { ApplicationInsights } from './core/ai.helper'; + const { config, secrets } = require('./core/env.config.js'); +const env = process.env.PG_ENV || 'local'; +const source = config[env] as IEnvironmentConfig; +const ai = new ApplicationInsights(source.instrumentationKey); + const handler = callback => (...args) => callback(...args).catch(args[2] /* pass the error as the 'next' param */); + const app = express(); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: true })); app.use(cors()); -app.use(serverStatic(path.resolve(__dirname, 'favicon'))); - -// /** -// * HTTP GET: / -// * Redirect to a non-error page (there is nothing to do on the root page of the runner, -// * nor do we know the environment in order to redirect to the editor) -// */ -// app.get('/', handler((req: express.Request, res: express.Response) => { -// res.writeHead(302, { -// 'Location': currentConfig.editorUrl -// }); -// return res.send(); -// })); +app.use('/favicon', express.static('favicon')); /** * HTTP POST: /auth * Returns the access_token */ -app.post('/auth/:env', handler(async (req: express.Request, res: express.Response) => { - let { code, state } = req.body; - let { env } = req.params; +app.post('/auth/:user', handler(async (req: express.Request, res: express.Response) => { + const { code, state } = req.body; + const { user } = req.params; if (code == null) { return new BadRequestError('Received invalid code.', code); } - let source = config[env] as IEnvironmentConfig; if (source == null) { return new BadRequestError(`Bad environment configuration: ${env}`, env); } let { clientId, editorUrl } = source; + let timer = ai.trackTimedEvent('[Runner] GitHub Authentication'); let token = await new Promise((resolve, reject) => { return Request.post({ url: 'https://github.com/login/oauth/access_token', @@ -61,7 +55,17 @@ app.post('/auth/:env', handler(async (req: express.Request, res: express.Respons code, state } - }, (error, httpResponse, body) => error ? reject(new UnauthorizedError('Failed to authenticate user.', error)) : resolve(body)); + }, (error, httpResponse, body) => { + timer.stop(); + if (error) { + ai.trackEvent('[Github] Login failed', { user }); + return reject(new UnauthorizedError('Failed to authenticate user.', error)); + } + else { + ai.trackEvent('[Github] Login succeeded', { user }); + return resolve(body); + } + }); }); return res.contentType('application/json').status(200).send(token); @@ -86,29 +90,18 @@ app.post('/compile/page', handler(async (req: express.Request, res: express.Resp })); /** - * Generic exception handler + * Generic exception handler */ app.use((err, req, res, next) => { if (err) { let { code, stack, message } = err; + ai.trackException(err, 'Server - Global handler'); return res.contentType('application/json').send({ code, message, stack }); } }); -if (process.env.NODE_ENV === 'production') { - app.listen(process.env.port || 1337, () => console.log(`Project Bornholm Runner listening on port ${process.env.PORT}`)); -} -else { - const cert = { - key: fs.readFileSync(path.resolve('node_modules/browser-sync/lib/server/certs/server.key')), - cert: fs.readFileSync(path.resolve('node_modules/browser-sync/lib/server/certs/server.crt')) - }; - https.createServer(cert, app).listen(3200, () => console.log('Playground server running on 3200')); -} - async function compileCommon(request: express.Request, wrapWithRunnerChrome?: boolean): Promise { const data: IRunnerState = JSON.parse(request.body.data); - const { snippet, returnUrl } = data; // Note: need the return URL explicitly, so can know exactly where to return to (editor vs. gallery view), @@ -118,6 +111,8 @@ async function compileCommon(request: express.Request, wrapWithRunnerChrome?: bo throw new BadRequestError('Received invalid snippet data.', snippet); } + const timer = ai.trackTimedEvent('[Runner] Compile Snippet', { id: snippet.id }); + const [compiledSnippet, snippetHtml, runnerHtml] = await Promise.all([ snippetGenerator.compile(snippet), @@ -133,7 +128,22 @@ async function compileCommon(request: express.Request, wrapWithRunnerChrome?: bo officeJS: compiledSnippet.officeJS, snippetId: snippet.id, snippetLastModified: snippet.modified_at, - refreshUrl: generateRefreshUrl(), + refreshUrl: (() => { + /** + * Parameters needed for refresh: + * id, to find the snippet. + * host, to know which host container to find the snippet in. + */ + + const refreshParams = { + host: snippet.host /* to know which host flavor to search for the snippet in */, + id: snippet.id /* to find the snippet */, + runnerUrl: request.protocol + '://' + request.get('host') /* for refreshing the snippet */, + returnUrl: returnUrl + }; + + return generateUrl(`${snippet.origin}/refresh.html`, refreshParams); + })(), returnUrl: returnUrl, origin: snippet.origin, host: snippet.host, @@ -142,22 +152,17 @@ async function compileCommon(request: express.Request, wrapWithRunnerChrome?: bo }); } + timer.stop(); return replaceTabsWithSpaces(html); +} - - // Helpers - - function generateRefreshUrl() { - // Parameters needed for refresh: - // * id, to find the snippet. - // * host, to know which host container to find the snippet in. - const refreshParams = { - host: snippet.host /* to know which host flavor to search for the snippet in */, - id: snippet.id /* to find the snippet */, - runnerUrl: request.protocol + '://' + request.get('host') /* for refreshing the snippet */, - returnUrl: returnUrl - }; - - return generateUrl(`${snippet.origin}/refresh.html`, refreshParams); - } +if (process.env.NODE_ENV === 'production') { + app.listen(process.env.port || 1337, () => console.log(`Project Bornholm Runner listening on port ${process.env.PORT}`)); +} +else { + const cert = { + key: fs.readFileSync(path.resolve('node_modules/browser-sync/lib/server/certs/server.key')), + cert: fs.readFileSync(path.resolve('node_modules/browser-sync/lib/server/certs/server.crt')) + }; + https.createServer(cert, app).listen(3200, () => console.log('Playground server running on 3200')); } diff --git a/server/templates/error.html b/src/server/templates/error.html similarity index 100% rename from server/templates/error.html rename to src/server/templates/error.html diff --git a/server/templates/runner b/src/server/templates/runner similarity index 75% rename from server/templates/runner rename to src/server/templates/runner index 1e5ca074..10c87946 100644 --- a/server/templates/runner +++ b/src/server/templates/runner @@ -2,27 +2,10 @@ - Run snippet - - - - - - - - - - - - - - - - - + @@ -61,10 +44,9 @@ - - +