copy/link assets into web plugin

This commit is contained in:
tfennelly 2016-06-08 10:47:54 +01:00
parent 220cf4f6d9
commit 8222a71c1d
4 changed files with 49 additions and 0 deletions

1
.gitignore vendored
View File

@ -13,3 +13,4 @@ npm-debug.log
**/.settings/
**/.project
**/.classpath
blueocean-web/src/main/webapp/

View File

@ -34,3 +34,49 @@ builder.bundle('src/main/js/blueocean.js')
.inDir('target/classes/io/jenkins/blueocean')
.less('src/main/less/blueocean.less')
.generateNoImportsBundle();
//
// Copy/link the JDL assests into the webapp dir, making them available at runtime.
//
var isWindows = /^win/.test(process.platform);
var assetsDstPath = './src/main/webapp/assets';
if (isWindows) {
var assestsCopyDone = false;
builder.onPreBundle(function() {
if (!assestsCopyDone) {
assestsCopyDone = true;
var ncp = require('ncp').ncp;
// wipe the destination directory and recreate.
if (fs.existsSync(assetsDstPath)) {
rmdir(assetsDstPath);
}
fs.mkdirSync(assetsDstPath);
// copy assets from stc to dsy.
var assetsSrcPath = './node_modules/@jenkins-cd/design-language/dist/assets';
ncp(assetsSrcPath, assetsDstPath, function (err) {
if (err) {
return logger.logError(err);
}
});
}
});
} else if (!fs.existsSync(assetsDstPath)) {
// Just need a symlink for non-windows platforms.
var assetsSrcPath = '../../../node_modules/@jenkins-cd/design-language/dist/assets';
fs.symlinkSync(assetsSrcPath, assetsDstPath);
}
function rmdir(path) {
if (fs.existsSync(path)) {
fs.readdirSync(path).forEach(function (file) {
var curPath = path + "/" + file;
if (fs.lstatSync(curPath).isDirectory()) {
rmdir(curPath);
} else {
fs.unlinkSync(curPath);
}
});
fs.rmdirSync(path);
}
}

View File

@ -20,6 +20,7 @@
"eslint-plugin-react": "^5.0.1",
"giti": "^1.0.6",
"gulp": "^3.9.1",
"ncp": "^2.0.0",
"zombie": "^4.2.1"
},
"dependencies": {

View File

@ -0,0 +1 @@
Placeholder directory for adding JDL assets to the web plugin.