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

RC > Merged master #444

Merged
merged 24 commits into from
Aug 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
caedefa
Navigate post message (#414)
Jun 20, 2018
3e225c9
Support tilde imports for SCSS files (#415)
Blackbaud-SteveBrush Jun 20, 2018
61098c2
Added lcov to output types for istanbul (#416)
blackbaud-brandonhare Jun 20, 2018
3e3589c
Allow multiline styleUrls (#418)
Blackbaud-SteveBrush Jun 21, 2018
db92894
Updated CHANGELOG.md and package.json for 1.18.0 (#423)
Jun 21, 2018
2800fbe
Libraries > Use the same compiler as `skyux build` (#417)
Blackbaud-SteveBrush Jul 3, 2018
26e97d4
Expose config (#431)
Jul 17, 2018
bbfa0bf
Skyuxconfig schema (#358)
Jul 17, 2018
c87f1d4
Add better type info and documentation to SkyPactService. (#430)
Blackbaud-KrisMahon Jul 17, 2018
b202540
Option to exclude params from request (#432)
Blackbaud-PaulCrowder Jul 18, 2018
ab04dd5
Updated CHANGELOG.md and package.json for 1.19.0 (#433)
Jul 18, 2018
8411843
Libraries > Separated transpile and bundle actions (#439)
Blackbaud-SteveBrush Jul 23, 2018
928c8fc
Release 1.19.1 (#440)
Blackbaud-SteveBrush Jul 23, 2018
94b248b
Merged master
Blackbaud-SteveBrush Jul 26, 2018
0c704d5
Fixed merge conflict
Blackbaud-SteveBrush Jul 26, 2018
1165fc4
Fixed conflicts
Blackbaud-SteveBrush Jul 26, 2018
6841e83
Fixed duplicate aot plugins
Blackbaud-SteveBrush Jul 26, 2018
ca9ca6e
Fixed library build failures on Windows machines (#445)
Blackbaud-SteveBrush Aug 2, 2018
52433b1
Reverted Pact interaction type for backwards compatibility (#446)
Blackbaud-SteveBrush Aug 2, 2018
1ead8c7
Updated CHANGELOG.md and package.json for 1.19.2 (#447)
Aug 2, 2018
e227653
Merged master
Blackbaud-SteveBrush Aug 9, 2018
fd871f7
Merge branch 'rc-2.0.0' into rc-merge-master-07-26-2018
Blackbaud-SteveBrush Aug 9, 2018
d7e95b6
Changed logic to include the generated locales if no locale exists. (…
Aug 13, 2018
becaf58
Merged master
Blackbaud-SteveBrush Aug 13, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# 1.19.2 (2018-08-02)

- Reverted stricter type information for `SkyPactService`. [#446](https://github.com/blackbaud/skyux-builder/pull/446)
- Bugfix for `skyux build-public-library` command to successfully run on Windows. [#445](https://github.com/blackbaud/skyux-builder/pull/445)

# 1.19.1 (2018-07-23)

- Bugfix to allow component libraries to properly consume external components. [#439](https://github.com/blackbaud/skyux-builder/pull/439)

# 1.19.0 (2018-07-18)

- Updated the `skyux build-public-library` command to use same compiler as `skyux build`. [#417](https://github.com/blackbaud/skyux-builder/pull/417)
Expand Down Expand Up @@ -241,7 +250,7 @@ To opt into this new behavior, simply add the following to your `skyuxconfig.jso

- Bugfix to allow `redirects` property in `skyuxconfig.json`. [#224](https://github.com/blackbaud/skyux-builder/pull/224)
- Bugfix that caused plugins to process files twice during AOT compilation. [#225](https://github.com/blackbaud/skyux-builder/pull/225)
- Implemented a better caching strategy and fallback to non-region-specific languages. [#226](https://github.com/blackbaud/skyux-builder/pull/226)
- Implemented a better caching strategy and fallback to non-region-specific languages. [#226](https://github.com/blackbaud/skyux-builder/pull/226)
- Upgraded `@blackbaud/auth-client` to 1.9.1. [#227](https://github.com/blackbaud/skyux-builder/pull/227)

# 1.0.0-rc.7 (2017-07-13)
Expand All @@ -255,7 +264,7 @@ To opt into this new behavior, simply add the following to your `skyuxconfig.jso
# 1.0.0-rc.6 (2017-07-05)

- Updated the auth client library to pick up logic for showing the search button based on whether search has been implemented by the SPA author. [#214](https://github.com/blackbaud/skyux-builder/pull/214)

# 1.0.0-rc.5 (2017-07-03)

- Added web-animations polyfill to support Angular animations in more browsers. [#204](https://github.com/blackbaud/skyux-builder/pull/204)
Expand Down Expand Up @@ -285,7 +294,7 @@ To opt into this new behavior, simply add the following to your `skyuxconfig.jso

# 1.0.0-rc.0 (2017-06-16)

- Added support for Angular v4.1.3 and SKY UX 2.0.0-rc.0.
- Added support for Angular v4.1.3 and SKY UX 2.0.0-rc.0.

# 1.0.0-beta.33 (2017-06-15)

Expand Down
51 changes: 47 additions & 4 deletions cli/build-public-library.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*jshint node: true*/
'use strict';

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

const stageTypeScriptFiles = require('./utils/stage-library-ts');
const preparePackage = require('./utils/prepare-library-package');
const webpackConfig = require('../config/webpack/build-public-library.webpack.config.js');
const skyPagesConfigUtil = require('../config/sky-pages/sky-pages.config');
const runCompiler = require('./utils/run-compiler');
const tsLinter = require('./utils/ts-linter');
Expand Down Expand Up @@ -83,9 +83,14 @@ function writeTSConfig() {
fs.writeJSONSync(skyPagesConfigUtil.spaPathTemp('tsconfig.json'), config);
}

/**
* Create a "placeholder" module for Angular AoT compiler.
* This is needed to avoid breaking changes; in the future,
* we should require a module name be provided by the consumer.
*/
function writePlaceholderModule() {
const content = `import { NgModule } from '@angular/core';
import './index';
export * from './index';
@NgModule({})
export class SkyLibPlaceholderModule {}
`;
Expand All @@ -95,11 +100,48 @@ export class SkyLibPlaceholderModule {}
});
}

function transpile(skyPagesConfig, webpack) {
/**
* Creates a UMD JavaScript bundle.
* @param {*} skyPagesConfig
* @param {*} webpack
*/
function createBundle(skyPagesConfig, webpack) {
const webpackConfig = require('../config/webpack/build-public-library.webpack.config');
const config = webpackConfig.getWebpackConfig(skyPagesConfig);
return runCompiler(webpack, config);
}

/**
* Transpiles TypeScript files into JavaScript files
* to be included with the NPM package.
*/
function transpile() {
return new Promise((resolve, reject) => {
const result = spawn.sync(
skyPagesConfigUtil.spaPath('node_modules', '.bin', 'ngc'),
[
'--project',
skyPagesConfigUtil.spaPathTemp('tsconfig.json')
],
{ stdio: 'inherit' }
);

// Catch ngc errors.
if (result.err) {
reject(result.err);
return;
}

// Catch non-zero status codes.
if (result.status !== 0) {
reject(new Error(`Angular compiler (ngc) exited with status code ${result.status}.`));
return;
}

resolve();
});
}

module.exports = (skyPagesConfig, webpack) => {
runLinter();
cleanAll();
Expand All @@ -108,7 +150,8 @@ module.exports = (skyPagesConfig, webpack) => {
writePlaceholderModule();
copyRuntime();

return transpile(skyPagesConfig, webpack)
return createBundle(skyPagesConfig, webpack)
.then(() => transpile())
.then(() => {
cleanRuntime();
preparePackage();
Expand Down
32 changes: 18 additions & 14 deletions config/webpack/build-public-library.webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
const ngtools = require('@ngtools/webpack');
const fs = require('fs-extra');
const webpack = require('webpack');
const ngcWebpack = require('ngc-webpack');
const skyPagesConfigUtil = require('../sky-pages/sky-pages.config');

function parseRegExp(name) {
Expand All @@ -26,19 +25,27 @@ function getWebpackConfig(skyPagesConfig) {
skyPagesConfigUtil.spaPath('package.json')
);

let builderDependencies = [];
let dependencies = [];
if (builderPackageJson.dependencies) {
builderDependencies = Object.keys(builderPackageJson.dependencies)
.map(key => parseRegExp(key));
dependencies = Object.keys(builderPackageJson.dependencies);
}

if (builderPackageJson.peerDependencies) {
dependencies = dependencies.concat(Object.keys(builderPackageJson.peerDependencies));
}

let spaDependencies = [];
if (spaPackageJson.dependencies) {
spaDependencies = Object.keys(spaPackageJson.dependencies)
.map(key => parseRegExp(key));
dependencies = dependencies.concat(Object.keys(spaPackageJson.dependencies));
}

if (spaPackageJson.peerDependencies) {
dependencies = dependencies.concat(Object.keys(spaPackageJson.peerDependencies));
}

const externals = builderDependencies.concat(spaDependencies);
// Remove duplicates from array.
// https://stackoverflow.com/questions/1960473/get-all-unique-values-in-a-javascript-array-remove-duplicates
const externals = [...new Set(dependencies)]
.map(key => parseRegExp(key));

return {
entry: skyPagesConfigUtil.spaPathTemp('index.ts'),
Expand Down Expand Up @@ -74,12 +81,9 @@ function getWebpackConfig(skyPagesConfig) {
]
},
plugins: [
// Generate transpiled source files.
new ngcWebpack.NgcWebpackPlugin({
tsConfig: skyPagesConfigUtil.spaPathTemp('tsconfig.json')
}),

// Generates an aot JavaScript bundle.
// Generates an AoT JavaScript bundle.
// TODO: Remove this in favor of Angular's native library bundler,
// once we've upgraded to Angular version 6.
new ngtools.AotPlugin({
tsConfigPath: skyPagesConfigUtil.spaPathTemp('tsconfig.json'),
entryModule: skyPagesConfigUtil.spaPathTemp('main.ts') + '#SkyLibPlaceholderModule',
Expand Down
3 changes: 2 additions & 1 deletion lib/locale-assets-processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function getNonDefaultLocaleFiles(dirname) {
function mergeDefaultLocaleFiles() {
const libFiles = getDefaultLocaleFiles(libPath);
const libInternalFiles = getDefaultLocaleFiles(libInternalPath);
const contents = extendJson(defaultFile, ...libFiles, ...libInternalFiles);
const contents = extendJson(...libFiles, ...libInternalFiles, defaultFile);
fs.writeJsonSync(defaultFile, contents);
}

Expand Down Expand Up @@ -146,6 +146,7 @@ process.on('SIGINT', () => {
});

module.exports = {
getDefaultLocaleFiles,
isLocaleFile,
parseLocaleFileBasename,
prepareLocaleFiles,
Expand Down
11 changes: 10 additions & 1 deletion lib/sky-pages-assets-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,19 @@ function getSource() {
const srcPath = skyPagesConfigUtil.spaPath('src');
const assetsPath = skyPagesConfigUtil.spaPath('src', 'assets');

const filePaths = glob.sync(
let filePaths = glob.sync(
skyPagesConfigUtil.spaPath('src', 'assets', '**', '*.*')
);

// Use auto-generated en-US file even if site has no file.
// This will let sites use consumed library files without having to create their own en_US file.
const hasLocaleFile = filePaths.some(filePath => localeAssetsProcessor.isLocaleFile(filePath));
if (!hasLocaleFile) {
filePaths = filePaths.concat(
localeAssetsProcessor.getDefaultLocaleFiles('.skypageslocales')
);
}

const pathMap = filePaths.map(filePath => {
let key;
let location;
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@blackbaud/skyux-builder",
"version": "1.19.0",
"version": "1.19.2",
"description": "Builds the output of a SKY UX application.",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -83,7 +83,6 @@
"loader-utils": "1.1.0",
"lodash.get": "4.4.2",
"lodash.mergewith": "4.6.0",
"ngc-webpack": "3.0.0",
"node-sass": "4.5.3",
"node-sass-tilde-importer": "1.0.2",
"open": "0.0.5",
Expand Down
6 changes: 1 addition & 5 deletions runtime/pact.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ import {
PactWeb
} from '@pact-foundation/pact-web';

import {
InteractionObject
} from '@pact-foundation/pact-web/dsl/interaction';

declare var Pact: any;

/**
Expand Down Expand Up @@ -42,7 +38,7 @@ export class SkyPactService {
* @param provider The name of the provider service.
* @param interaction The provider interaction.
*/
public addInteraction(provider: string, interaction: InteractionObject): Promise<string> {
public addInteraction(provider: string, interaction: any): Promise<string> {
return this.pactProviders[provider].addInteraction(interaction);
}

Expand Down
39 changes: 38 additions & 1 deletion test/cli-build-public-library.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ describe('cli build-public-library', () => {
let webpackConfig;
let mockWebpack;
let mockFs;
let mockSpawn;

beforeEach(() => {
mockFs = {
Expand All @@ -19,6 +20,14 @@ describe('cli build-public-library', () => {
copySync() {}
};

mockSpawn = {
sync() {
return {
status: 0
};
}
};

mockWebpack = () => {
return {
run: (cb) => {
Expand Down Expand Up @@ -50,6 +59,7 @@ describe('cli build-public-library', () => {
});

mock('fs-extra', mockFs);
mock('cross-spawn', mockSpawn);

spyOn(process, 'exit').and.callFake(() => {});
spyOn(skyPagesConfigUtil, 'spaPath').and.returnValue('');
Expand Down Expand Up @@ -108,7 +118,7 @@ describe('cli build-public-library', () => {
const args = spy.calls.argsFor(0);
expect(args[0]).toEqual('main.ts');
expect(args[1]).toEqual(`import { NgModule } from '@angular/core';
import './index';
export * from './index';
@NgModule({})
export class SkyLibPlaceholderModule {}
`);
Expand Down Expand Up @@ -155,4 +165,31 @@ export class SkyLibPlaceholderModule {}
done();
});
});

it('should handle transpilation errors', (done) => {
const cliCommand = mock.reRequire(requirePath);
const spy = spyOn(logger, 'error').and.callThrough();
spyOn(mockSpawn, 'sync').and.returnValue({
err: 'something bad happened'
});
cliCommand({}, mockWebpack).then(() => {
expect(spy).toHaveBeenCalledWith('something bad happened');
done();
});
});

it('should catch non-zero status codes during transpilation', (done) => {
const cliCommand = mock.reRequire(requirePath);
const spy = spyOn(logger, 'error').and.returnValue();
spyOn(mockSpawn, 'sync').and.returnValue({
err: null,
status: 1
});
cliCommand({}, mockWebpack).then(() => {
expect(spy).toHaveBeenCalledWith(
new Error(`Angular compiler (ngc) exited with status code 1.`)
);
done();
});
});
});
11 changes: 4 additions & 7 deletions test/cli-utils-run-build.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,17 @@
const mock = require('mock-require');
const logger = require('@blackbaud/skyux-logger');
const runtimeUtils = require('../utils/runtime-test-utils');
const localeAssetsProcessor = require('../lib/locale-assets-processor');

describe('cli utils run build', () => {
let mockAssetsProcessor;
let mockLocaleProcessor;

beforeEach(() => {
mockLocaleProcessor = {
isLocaleFile() {
return true;
},
parseLocaleFileBasename() {
return '';
},
prepareLocaleFiles() {}
getDefaultLocaleFiles: localeAssetsProcessor.getDefaultLocaleFiles,
prepareLocaleFiles() {},
isLocaleFile() {},
};

mockAssetsProcessor = {
Expand Down
7 changes: 7 additions & 0 deletions test/config-webpack-build-public-library.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ describe('config webpack build public library', () => {
'@angular/common': '4.3.6',
'@pact-foundation/pact-web': '5.3.0',
'zone.js': '0.8.10'
},
peerDependencies: {
'@angular/core': '4.3.6'

Choose a reason for hiding this comment

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

Is this the behavior we want in RC?

Copy link
Member Author

Choose a reason for hiding this comment

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

@Blackbaud-BobbyEarl I'm unsure exactly what you mean, but we definitely don't want libraries bundling peerDependencies (referring to this line: https://github.com/blackbaud/skyux-builder/pull/444/files#diff-054d421f3f99ee39229267add1ee72daR42).

}
};
}
Expand All @@ -90,6 +93,9 @@ describe('config webpack build public library', () => {
dependencies: {
'@blackbaud/skyux': '2.13.0',
'@blackbaud-internal/skyux-lib-testing': 'latest'
},
peerDependencies: {
'@angular/core': '4.3.6'
}
};
});
Expand All @@ -99,6 +105,7 @@ describe('config webpack build public library', () => {
/^@angular\/common/,
/^@pact\-foundation\/pact\-web/,
/^zone\.js/,
/^@angular\/core/,
/^@blackbaud\/skyux/,
/^@blackbaud\-internal\/skyux\-lib\-testing/
]);
Expand Down
Loading