Skip to content

Commit

Permalink
Repository basic reorganization, build & import scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitaeverywhere committed May 10, 2016
1 parent 6c6914f commit 57001b5
Show file tree
Hide file tree
Showing 42 changed files with 1,530 additions and 148 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["es2015"]
}
2 changes: 1 addition & 1 deletion export/WebTerminal/Engine.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Export generator="Cache" version="25" zv="Cache for Windows (x86-64) 2015.3 (Build 215U)" ts="2015-12-27 13:48:44">
<Class name="WebTerminal.Engine">
<Description>
Cache WEB Terminal version X.X.X/*build.replace:pkg.version*/ core.
Cache WEB Terminal <!-- @echo package.printableName --> v<!-- @echo package.version --> core.
This class is the server-side core of the terminal application.</Description>
<Super>%CSP.WebSocket,Trace,Autocomplete</Super>
<TimeChanged>63913,49707.26915</TimeChanged>
Expand Down
168 changes: 168 additions & 0 deletions gulpfile.babel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
import gulp from "gulp";
import pkg from "./package.json";
import htmlReplace from "gulp-html-replace";
import cssNano from "gulp-cssnano";
import concat from "gulp-concat";
import uglify from "gulp-uglify";
import replace from "gulp-replace";
import rimraf from "gulp-rimraf";
import rename from "gulp-rename";
import preprocess from "gulp-preprocess";
import fs from "fs";

let INSTALLER_CLASS_NAME = `${ pkg["packageName"] }.Installer`;

let dir = __dirname,
dest = `${dir}/build`,
source = `${dir}/source`,
context = {
context: {
package: pkg,
compileAfter: "" // is filled during "pre-cls" task.
}
},
themes = [],
extra = {
themes: ""
};

function themesReady () { // triggered when build is done
themes = fs.readdirSync(`${ dest }/client/css/terminal-theme`);
extra.themes = themes.map(function (n) {
return ', "' + n.replace(/\..*$/, "") + '": "css/terminal-theme/' + n + '"';
}).join("");
}

var specialReplace = function () {
return replace(/[^\s]*\/\*build\.replace:(.*)\*\//g, function (part, match) {
var s = match.toString();
return s.replace(/pkg\.([a-zA-Z]+)/g, function (p,a) { return pkg[a]; })
.replace(/extra\.([a-zA-Z]+)/g, function (p,a) { return extra[a]; });
});
};

gulp.task("clean", function () {
return gulp.src(dest, { read: false })
.pipe(rimraf());
});

gulp.task("html", ["clean"], function () {
return gulp.src(`${ source }/client/index.html`)
.pipe(htmlReplace({
"css": "css/terminal.css",
"js": "js/terminal.js"
}))
.pipe(gulp.dest(`${ dest }/client`));
});

gulp.task("js", ["clean", "css"], function () {
return gulp.src(`${ source }/client/js/**/*.js`)
.pipe(concat("terminal.js"))
.pipe(specialReplace())
.pipe(uglify({
output: {
ascii_only: true,
width: 25000,
max_line_len: 25000
},
preserveComments: "some"
}))
.pipe(replace(/ /g, "\\x0B"))
.pipe(replace(/\x1b/g, "\\x1B"))
.pipe(gulp.dest(`${ dest }/client/js`));
});

gulp.task("copy-css-basic", ["clean"], function () {
return gulp.src(`${ source }/client/css/*.css`)
.pipe(concat("terminal.css"))
.pipe(cssNano())
.pipe(gulp.dest(`${ dest }/client/css`));
});

gulp.task("copy-css-themes", ["clean"], function () {
return gulp.src(`${ source }/client/css/terminal-theme/*.css`)
.pipe(cssNano())
.pipe(gulp.dest(`${ dest }/client/css/terminal-theme/`));
});

// Need css themes directory copied to collect themes names.
gulp.task("css", ["copy-css-basic", "copy-css-themes"], function (cb) {
themesReady();
cb();
});

gulp.task("pre-cls", ["js", "js", "html", "css", "readme"], () => {
return gulp.src([`${ source }/cache/**/*.cls`])
.pipe(rename((f) => {
f.basename = `${ pkg["packageName"] }.${ f.dirname === "." ? "" : f.dirname + "." }${
f.basename
}`;
f.dirname = ".";
if (f.basename !== INSTALLER_CLASS_NAME)
context.context.compileAfter +=
(context.context.compileAfter ? "," : "") + f.basename;
}))
.pipe(gulp.dest(`${dest}/cache`));
});

gulp.task("cls", ["pre-cls"], () => {
return gulp.src([`${dest}/cache/**/*.cls`])
.pipe(preprocess(context))
.pipe(gulp.dest(`${dest}/cache`));
});

gulp.task("readme", ["clean"], function () {
return gulp.src(`${ dir }/readme.md`)
.pipe(gulp.dest(`${ dest }`));
});

// gulp.task("export", [ "copy-html", "copy-js", "prepare-css", "copy-readme" ], function () {
// var files = [];
// return gulp.src("export/WebTerminal/**/*.xml")
// .pipe(foreach(function (stream, file) {
// files.push(path.relative(path.join(path.dirname(__filename), "export"), file.path)
// .replace(/[\\\/]/g, ".").replace(/\.xml$/, ""));
// return stream
// .pipe(replace(/^<\?xml[^]*?<Class/i, "<Class"))
// .pipe(replace(/<\/Export>\s*$/i, ""));
// }))
// .pipe(concat("CacheWebTerminal-v" + pkg["version"] + ".xml"))
// .pipe(specialReplace())
// .pipe(replace(
// /\{\{replace:css}}/,
// function () {
// return fs.readFileSync("./" + buildTo + "/web/css/terminal.css", "utf-8");
// }
// ))
// .pipe(replace(
// /\{\{replace:js}}/,
// function () {
// return fs.readFileSync("./" + buildTo + "/web/js/terminal.js", "utf-8");
// }
// ))
// .pipe(replace(
// /\{\{replace:html}}/,
// function () { return fs.readFileSync("./" + buildTo + "/web/index.html", "utf-8"); }
// ))
// .pipe(replace(
// /\{\{replace:themes}}([^]*)\{\{replace:end}}/g,
// function (p, content) {
// return themes.map(function (n) {
// return content.replace("{{replace:themeName}}", n.replace(/\..*$/, ""))
// .replace("{{replace:themeData}}", function () {
// return fs.readFileSync(
// "./" + buildTo + "/web/css/terminal-theme/" + n
// );
// });
// }).join("\n\n");
// }
// ))
// .pipe(replace(
// /^/,
// '<?xml version="1.0" encoding="UTF-8"?>\r\n<Export generator="Cache" version="25">\r\n'
// ))
// .pipe(replace(/$/, "</Export>"))
// .pipe(gulp.dest("./" + buildTo));
// });

gulp.task("default", ["cls"]);
147 changes: 0 additions & 147 deletions gulpfile.js

This file was deleted.

21 changes: 21 additions & 0 deletions import.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
:: This batch script makes the Caché application deployment much faster by building, importing and
:: exporting the XML the project. Replace the path below to your Caché installation and
:: build & import application to Caché using only one command.

:: Latest NodeJS & Caché 2016.2+ IS REQUIRED TO PROCEED
@echo off

:: CHANGE THIS PATH TO YOUR CACHÉ INSTALLATION PATH ON WINDOWS (folder that contains bin, CSP, mgr and other folders)
set CACHE_DIR=C:\Program Files\InterSystems\Ensemble
:: NAMESPACE TO IMPORT PACKAGE TO
set NAMESPACE=ENSDEMO
:: Other variables
set BUILD_DIR=build\cache
set XML_EXPORT_DIR=build
set PACKAGE_NAME=WebTerminal

:: Build and import application to Caché
echo Building the project...
npm run build && ^
echo w "IMPORT SUCCESS: "_$system.OBJ.ImportDir("%~dp0%BUILD_DIR%",,"ck") halt | "%CACHE_DIR%\bin\cache.exe" -s "%CACHE_DIR%\mgr" -U %NAMESPACE% && ^
echo w $c(13,10)_"EXPORT SUCCESS: "_$system.OBJ.ExportPackage("%PACKAGE_NAME%", "%~dp0%XML_EXPORT_DIR%\%PACKAGE_NAME%-v"_##class(%PACKAGE_NAME%.Installer).#VERSION_".xml") halt | "%CACHE_DIR%\bin\cache.exe" -s "%CACHE_DIR%\mgr" -U %NAMESPACE%
9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
{
"name": "CWT",
"title": "Cache WEB Terminal",
"packageName": "WebTerminal",
"printableName": "Cache Web Terminal",
"description": "Web-based terminal emulator for Caché administering.",
"author": "ZitRo",
"version": "3.3.1",
"releaseNumber": 25,
"scripts": {
"build": "gulp"
},
"repository": {
"type": "git",
"url": "https://github.com/intersystems-ru/webterminal.git"
},
"devDependencies": {
"babel-core": "^6.8.0",
"babel-preset-es2015": "^6.6.0",
"gulp": "^3.9.0",
"gulp-concat": "^2.6.0",
"gulp-foreach": "^0.1.0",
"gulp-html-replace": "^1.5.5",
"gulp-minify-css": "^1.2.2",
"gulp-preprocess": "^2.0.0",
"gulp-rename": "^1.2.2",
"gulp-replace": "^0.5.4",
"gulp-rimraf": "^0.2.0",
"gulp-uglify": "^1.5.1"
Expand Down
Loading

0 comments on commit 57001b5

Please sign in to comment.