Skip to content

Commit

Permalink
BREAKING CHANGE: Lerna/monorepo refactor package split (#199)
Browse files Browse the repository at this point in the history
Split into 3 packages:
- @morgan-stanley/desktopjs
- @morgan-stanley/desktopjs-electron
- @morgan-stanley/desktpojs-openfin

- Changed public Node types in Electron package to any
- Changed public OpenFin types in OpenFin package to any
  • Loading branch information
bingenito authored Dec 3, 2018
1 parent 090540b commit dcb250e
Show file tree
Hide file tree
Showing 73 changed files with 19,919 additions and 959 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ dist/
build/
docs/
.DS_Store
package-lock.json
lerna-debug.log
22 changes: 22 additions & 0 deletions .gulp/gulpConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module.exports = {
src: ['src/**/*.ts'],
dest: 'dist',
staging: {
dest: 'build',
},
test: {
src: ['**/build/tests/**/*.js', '**/build/tests/**/*.spec.js'],
coverage: {
src: ['**/build/src/**/*.js', '!**/node_modules/**/*'],
dest: 'build/coverage',
coverageFile: 'build/coverage/coverage-final.json',
lcovFile: 'build/coverage/lcov.info',
threshold: 80
}
},
tslint: '../../tslint.json',
documentation: {
src: ['packages/**/src/**/*.ts', '!**/*.d.ts' , '!**/node_modules/**/*'],
out: 'docs/'
}
};
53 changes: 53 additions & 0 deletions .gulp/tasks/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
'use strict';

var rollup = require('rollup'),
clean = require('gulp-clean'),
tsrollup = require('rollup-plugin-typescript'),
replace = require('gulp-replace'),
rollupReplace = require('rollup-plugin-replace'),
commonjs = require('rollup-plugin-commonjs'),
typescript = require('typescript');

module.exports = function (gulp, pkg, config, name, input, iffe, preventReload) {
return function () {
// Main bundle is umd
return createBundle('umd', pkg.main)
.then(function () {
// Generate iife for use as a V8 extension if necessary since umd isn't supported
createBundle('iife', config.dest + iffe);
}).then(function () {
if (preventReload) {
// Wrap umd with a condition checking if desktopJS is already defined to not overwrite it. This will allow
// preload registration of desktopJS without hosted web script includes redefining.
gulp.src(pkg.main)
.pipe(replace(/(\(function \(global, factory\)[\s\S]*}\)\)\);)([\s\S]*)/, "if (typeof desktopJS === \"undefined\") {$1}$2"))
.pipe(clean())
.pipe(gulp.dest(config.dest));
}
});

function createBundle(format, destination) {
return rollup.rollup({
input: input,
plugins: [
tsrollup({ typescript: typescript }),
commonjs(),
rollupReplace({
PACKAGE_VERSION: pkg.version
})
]
}).then(function (bundle) {
return bundle.write({
file: destination,
format: format,
name: name,
moduleName: pkg.title,
sourcemap: true,
globals: {
"@morgan-stanley/desktopjs": "desktopJS"
}
});
});
}
};
}
10 changes: 10 additions & 0 deletions .gulp/tasks/clean.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict';

var clean = require('gulp-clean');

module.exports = function (gulp, path) {
return function () {
return gulp.src(path, { read: false })
.pipe(clean());
};
}
16 changes: 16 additions & 0 deletions .gulp/tasks/compress.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict';

var uglify = require('gulp-uglify'),
sourcemaps = require('gulp-sourcemaps'),
rename = require('gulp-rename');

module.exports = function (gulp, pkg, config) {
return function () {
return gulp.src(pkg.main)
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(uglify())
.pipe(rename({ extname: '.min.js' }))
.pipe(sourcemaps.write(''))
.pipe(gulp.dest(config.dest));
};
}
26 changes: 26 additions & 0 deletions .gulp/tasks/docs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'use strict';

var typedoc = require('gulp-typedoc');

module.exports = function (gulp, config) {
return function () {
return gulp
.src(config.documentation.src)
.pipe(typedoc({
"name": "desktopJS",
"mode": "modules",
"target": "ES6",
"module": "umd",
"includeDeclarations": true,
"excludeExternals": true,
"excludePrivate": true,
"out": config.documentation.out,
"hideGenerator": true,
"ignoreCompilerErrors": true,
"logger": "none"
}))
.on('end', function () {
require('fs').writeFileSync('docs/.nojekyll', '');
});
}
}
16 changes: 16 additions & 0 deletions .gulp/tasks/dts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict';

var dts = require('dts-bundle');

module.exports = function (gulp, name, main, out) {
return function () {
return dts.bundle({
name: name,
main: main,
out: out,
verbose: false,
outputAsModuleFolder: true
});
};
}

25 changes: 25 additions & 0 deletions .gulp/tasks/stage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use strict';

var sourcemaps = require('gulp-sourcemaps'),
gulpts = require('gulp-typescript'),
merge = require('merge2');

module.exports = function (gulp, config) {
return function () {
var tsProject = gulpts.createProject('./tsconfig-staging.json');

var tsResult = tsProject.src()
.pipe(sourcemaps.init())
.pipe(tsProject(gulpts.reporter.fullReporter(true)))
.on("error", (e) => { /* Continue */ });

return merge([
tsResult.js
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(config.staging.dest)),
tsResult.dts
.pipe(gulp.dest(config.staging.dest))
]);;

};
}
47 changes: 47 additions & 0 deletions .gulp/tasks/tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
'use strict';

var jasmine = require('gulp-jasmine'),
istanbul = require('gulp-istanbul'),
remap = require('remap-istanbul/lib/gulpRemapIstanbul'),
instanbulEnforcer = require('gulp-istanbul-enforcer');

module.exports = function (gulp, config) {
return function () {
return gulp.src(config.test.coverage.src)
.pipe(istanbul({ includeUntested: true }))
.pipe(istanbul.hookRequire())
.on('finish', function () {
gulp.src(config.test.src)
.pipe(jasmine({ verbose: true, errorOnFail: false, includeStackTrace: false }))
.pipe(istanbul.writeReports({
dir: config.test.coverage.dest,
reporters: ['json']
}))
.on('end', remapCoverageFiles)
.on('finish', function () {
gulp.src('.')
.pipe(instanbulEnforcer({
coverageDirectory: config.test.coverage.dest,
rootDirectory: '',
thresholds: {
statements: config.test.coverage.threshold || 80
}
}));
});
});

/** Take js coverage json and remap to typescript. Output html and text */
function remapCoverageFiles() {
return gulp.src(config.test.coverage.coverageFile)
.pipe(remap({
reports: {
'json': config.test.coverage.coverageFile, // overwrite js based json with ts remapped version
'html': config.test.coverage.dest,
'lcovonly': config.test.coverage.lcovFile,
'text': null
}
}));
};
};
}

11 changes: 11 additions & 0 deletions .gulp/tasks/tslint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';

var tslint = require('gulp-tslint');

module.exports = function (gulp, config) {
return function () {
return gulp.src(config.src)
.pipe(tslint({ formatter: "verbose", configuration: config.tslint }))
.pipe(tslint.report({ summarizeFailureOutput: true }));
};
}
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ matrix:
fast_finish: true

script:
- npm run bootstrap
- npm run build
- npm test
- npm run docs

after_success:
Expand Down
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"request": "attach",
"port": 9090,
"address": "localhost",
"webRoot": "${workspaceRoot}/dist",
"webRoot": "${workspaceRoot}/packages/desktopjs-openfin/dist",
"sourceMaps": true
},
{
Expand Down
3 changes: 2 additions & 1 deletion examples/electron/electron.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const desktopJS = require('../../dist/desktop.js');
const desktopJS = require('@morgan-stanley/desktopjs');
const djsElectron = require('@morgan-stanley/desktopjs-electron');
const electron = require('electron');
const app = electron.app;

Expand Down
27 changes: 27 additions & 0 deletions examples/electron/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions examples/electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"version": "0.0.0",
"description": "desktopJS Demo",
"main": "electron.js",
"private": true,
"dependencies": {
"@morgan-stanley/desktopjs": "^3.0.0",
"@morgan-stanley/desktopjs-electron": "^3.0.0",
"electron-notify": "^0.1.0"
}
}
2 changes: 2 additions & 0 deletions examples/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<meta charset="utf-8" />
<title>desktopJS</title>
<script type="text/javascript" src="desktop.js"></script>
<script type="text/javascript" src="desktopjs-openfin.js"></script>
<script type="text/javascript" src="desktopjs-electron.js"></script>

<!-- Bootstrap/JQuery from CDN to make example simple -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
Expand Down
Loading

0 comments on commit dcb250e

Please sign in to comment.