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

Commit

Permalink
Merge branch 'rc-4.0.0' into upgrade-karma-jasmine
Browse files Browse the repository at this point in the history
  • Loading branch information
Blackbaud-SteveBrush committed Nov 19, 2019
2 parents 495b718 + 4f0fc5d commit 6f705a2
Show file tree
Hide file tree
Showing 16 changed files with 474 additions and 221 deletions.
8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
os:
- linux
- osx

language: node_js
dist: bionic

Expand All @@ -18,8 +22,8 @@ branches:
- /^[0-9]+\.[0-9]+\.[0-9]+.*/

before_install:
- sudo cp ./ssl/skyux-ca.crt /usr/local/share/ca-certificates/skyux-ca.crt
- sudo update-ca-certificates
- npm i -g @skyux-sdk/cli
- skyux certs install

script: "npm run lint && npm run $TEST_COMMAND"

Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 3.11.0 (2019-10-28)

- Updated the local server to use the self-signed certificate implementation introduced in `@skyux-sdk/[email protected]`. See the [SSL documentation](https://developer.blackbaud.com/skyux/learn/get-started/prereqs/ssl-certificate). [#168](https://github.com/blackbaud/skyux-sdk-builder/pull/168)

# 3.10.0 (2019-09-30)

- Upgraded `help-client` to `2.1.0`. [#161](https://github.com/blackbaud/skyux-sdk-builder/pull/161) Thanks, [@Blackbaud-ColbyWhite](https://github.com/Blackbaud-ColbyWhite)!
Expand Down
2 changes: 2 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ environment:
install:
- choco install googlechrome --ignore-checksums
- ps: Install-Product node $env:nodejs_version
- npm i -g @skyux-sdk/cli
- skyux certs install
- npm install

test_script:
Expand Down
2 changes: 1 addition & 1 deletion cli/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ function e2e(command, argv, skyPagesConfig, webpack) {
return killServers(0);
}

server.start()
server.start(argv)
.then((port) => {
argv.assets = 'https://localhost:' + port;

Expand Down
33 changes: 33 additions & 0 deletions cli/utils/cert-resolver.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*jslint node: true */
'use strict';

const fs = require('fs-extra');
const logger = require('@blackbaud/skyux-logger');

function error(prop, code) {
logger.error(`Unable to resolve certificate property ${prop} (code ${code}).`);
logger.error('Please install the latest SKY UX CLI and run `skyux certs install`.');
}

function read(argv, prop) {
if (!argv[prop]) {
error(prop, 0);
} else if (!fs.pathExistsSync(argv[prop])) {
error(prop, 1);
} else {
return fs.readFileSync(argv[prop]);
}
}

function readCert(argv) {
return read(argv, 'sslCert');
}

function readKey(argv) {
return read(argv, 'sslKey');
}

module.exports = {
readCert,
readKey
};
2 changes: 1 addition & 1 deletion cli/utils/karma-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function run(command, argv, specsPattern) {
});
}

server.start();
server.start(argv);
});
}

Expand Down
2 changes: 1 addition & 1 deletion cli/utils/run-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ function cleanupDist() {
function buildServe(argv, skyPagesConfig, webpack, isAot) {
const base = skyPagesConfigUtil.getAppBase(skyPagesConfig);
return server
.start(base)
.start(argv, base)
.then(port => {
argv.assets = argv.assets || `https://localhost:${port}`;
return buildCompiler(argv, skyPagesConfig, webpack, isAot)
Expand Down
8 changes: 4 additions & 4 deletions cli/utils/server.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*jslint node: true */
'use strict';

const fs = require('fs');
const path = require('path');
const portfinder = require('portfinder');
const express = require('express');
const https = require('https');
const cors = require('cors');
const logger = require('@blackbaud/skyux-logger');
const certResolver = require('./cert-resolver');

const app = express();

Expand All @@ -17,7 +17,7 @@ let server;
* Starts the httpServer
* @name start
*/
function start(root, distPath) {
function start(argv, root, distPath) {
return new Promise((resolve, reject) => {

const dist = path.resolve(process.cwd(), distPath || 'dist');
Expand All @@ -33,8 +33,8 @@ function start(root, distPath) {
}

const options = {
cert: fs.readFileSync(path.resolve(__dirname, '../../ssl/server.crt')),
key: fs.readFileSync(path.resolve(__dirname, '../../ssl/server.key'))
cert: certResolver.readCert(argv),
key: certResolver.readKey(argv)
};

server = https.createServer(options, app);
Expand Down
6 changes: 3 additions & 3 deletions config/webpack/serve.webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/*jslint node: true */
'use strict';

const fs = require('fs');
const path = require('path');
const webpackMerge = require('webpack-merge');
const NamedModulesPlugin = require('webpack/lib/NamedModulesPlugin');
Expand All @@ -10,6 +9,7 @@ const HotModuleReplacementPlugin = require('webpack/lib/HotModuleReplacementPlug

const skyPagesConfigUtil = require('../sky-pages/sky-pages.config');
const browser = require('../../cli/utils/browser');
const certResolver = require('../../cli/utils/cert-resolver');

const tsLoaderUtil = require('./ts-loader-rule');

Expand Down Expand Up @@ -73,8 +73,8 @@ function getWebpackConfig(argv, skyPagesConfig) {
index: skyPagesConfigUtil.getAppBase(skyPagesConfig)
},
https: {
key: fs.readFileSync(path.join(__dirname, '../../ssl/server.key')),
cert: fs.readFileSync(path.join(__dirname, '../../ssl/server.crt'))
cert: certResolver.readCert(argv),
key: certResolver.readKey(argv)
},
publicPath: skyPagesConfigUtil.getAppBase(skyPagesConfig)
},
Expand Down
59 changes: 39 additions & 20 deletions e2e/shared/common.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/*jshint node: true*/
/*global browser, element, by*/
/*global browser*/
'use strict';

const os = require('os');
const fs = require('fs-extra');
const path = require('path');
const rimraf = require('rimraf');
Expand All @@ -18,11 +19,15 @@ const skyuxConfigPath = path.resolve(process.cwd(), tmp, 'skyuxconfig.json');
const appExtrasPath = path.resolve(process.cwd(), tmp, 'src/app/app-extras.module.ts');
const cliPath = `../e2e/shared/cli`;

// This is normally provided by the CLI.
const sslCert = path.resolve(`${os.homedir()}/.skyux/certs/skyux-server.crt`);
const sslKey = path.resolve(`${os.homedir()}/.skyux/certs/skyux-server.key`);

let skyuxConfigOriginal;
let appExtrasOriginal;
let webpackServer;
let _exitCode;
let _port;
let spyExitCode;
let spyPort;

/**
* Stops the server.
Expand All @@ -40,7 +45,7 @@ function afterAll() {
if (appExtrasOriginal) {
resetAppExtras();
}
};
}

/**
* Adds event listeners to serve and resolves a promise.
Expand All @@ -53,7 +58,7 @@ function bindServe() {
webpackServer.stdout.on('data', data => {
const dataAsString = log(data);
if (dataAsString.indexOf('Compiled successfully.') > -1) {
resolve(_port);
resolve(spyPort);
}
if (dataAsString.indexOf('Failed to compile.') > -1) {
reject(dataAsString);
Expand Down Expand Up @@ -91,7 +96,7 @@ function exec(cmd, args, opts) {
* Returns the last exit code.
*/
function getExitCode() {
return _exitCode;
return spyExitCode;
}

/**
Expand All @@ -113,12 +118,12 @@ function prepareBuild(config) {
function serve(exitCode) {

// Save our exitCode for testing
_exitCode = exitCode;
spyExitCode = exitCode;

// Reset skyuxconfig.json
resetConfig();

return server.start('unused-root', tmp)
return server.start({ sslCert, sslKey }, 'unused-root', tmp)
.then(port => browser.get(`https://localhost:${port}/dist/`));
}

Expand All @@ -140,15 +145,15 @@ function prepareServe() {

if (webpackServer) {
return bindServe();
} else {
return new Promise((resolve, reject) => {
portfinder.getPortPromise()
.then(writeConfigServe)
.then(bindServe)
.then(resolve)
.catch(err => reject(err));
});
}

return new Promise((resolve, reject) => {
portfinder.getPortPromise()
.then(writeConfigServe)
.then(bindServe)
.then(resolve)
.catch(err => reject(err));
});
}

/**
Expand Down Expand Up @@ -189,15 +194,27 @@ function writeConfig(json) {
*/
function writeConfigServe(port) {
return new Promise(resolve => {
_port = port;
spyPort = port;
const skyuxConfigWithPort = merge(true, skyuxConfigOriginal, {
app: {
port: port
}
});

writeConfig(skyuxConfigWithPort);
const args = [cliPath, `serve`, `-l`, `none`, `--logFormat`, `none`];

const args = [
cliPath,
`serve`,
`-l`,
`none`,
`--logFormat`,
`none`,
`--sslCert`,
sslCert,
`--sslKey`,
sslKey
];
webpackServer = childProcessSpawn(`node`, args, cwdOpts);
resetConfig();
resolve();
Expand Down Expand Up @@ -227,7 +244,7 @@ function writeAppFile(filePath, content) {
*/
function verifyAppFolder(folderPath) {
const resolvedFolderPath = path.join(path.resolve(tmp), 'src', 'app', folderPath);
return new Promise((resolve, reject) => {
return new Promise((resolve) => {
if (!fs.existsSync(resolvedFolderPath)) {
fs.mkdirSync(resolvedFolderPath);
}
Expand Down Expand Up @@ -273,5 +290,7 @@ module.exports = {
writeAppFile: writeAppFile,
removeAppFolderItem: removeAppFolderItem,
verifyAppFolder: verifyAppFolder,
writeAppExtras: writeAppExtras
writeAppExtras: writeAppExtras,
sslCert,
sslKey
};
13 changes: 12 additions & 1 deletion e2e/skyux-e2e.e2e-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,18 @@
const common = require('./shared/common');

function validateTestRun(done) {
common.exec(`node`, [common.cliPath, `e2e`, `--logFormat`, `none`], common.cwdOpts)
const args = [
common.cliPath,
`e2e`,
`--logFormat`,
`none`,
`--sslCert`,
common.sslCert,
`--sslKey`,
common.sslKey
];

common.exec(`node`, args, common.cwdOpts)
.then(exit => {
expect(exit).toEqual(0);
done();
Expand Down
Loading

0 comments on commit 6f705a2

Please sign in to comment.