@@ -2,6 +2,8 @@ var gulp = require('gulp')
22var gutil = require ( 'gulp-util' )
33var clean = require ( 'gulp-clean' )
44var cheerio = require ( 'gulp-cheerio' )
5+ var wrapper = require ( 'gulp-wrapper' )
6+ var rename = require ( 'gulp-rename' )
57var htmlReplace = require ( 'gulp-html-replace' )
68var fs = require ( 'fs' )
79var path = require ( 'path' )
@@ -34,56 +36,77 @@ gulp.task('webpack', ['clean'], function (callback) {
3436 } ) ;
3537} )
3638
39+ gulp . task ( 'csp' , [ 'webpack' ] , function ( ) {
40+ return gulp . src ( [
41+ './build/**/*' ,
42+ '!./build/xml' ,
43+ '!./build/**/*.xml'
44+ ] )
45+ . pipe ( wrapper ( {
46+ header : '<?xml version="1.0" encoding="UTF-8"?>\n<Export generator="Cache" version="24">\n<CSP name="${filename}" application="/blocks/" default="1"><![CDATA[' ,
47+ footer : ']]></CSP>\n</Export>'
48+ } ) )
49+ . pipe ( rename ( function ( path ) {
50+ path . extname += '.xml'
51+ } ) )
52+ . pipe ( gulp . dest ( './build/xml/' ) )
53+ } ) ;
54+
3755gulp . task ( 'xml' , [ 'clean' , 'webpack' ] , function ( ) {
3856 return gulp . src ( [
3957 './BlocksExplorer.prj.xml' ,
4058 './Blocks/**/*.xml'
4159 ] )
4260 . pipe ( cheerio ( {
4361 run : function ( $ , file ) {
44- var staticFiles = fs . readdirSync ( './build/' )
45-
46- staticFiles . map ( function ( fileName ) {
47- try {
48- fullName = path . join ( './build/' , fileName )
49- if ( ! fs . statSync ( fullName ) . isDirectory ( ) ) {
50- $ ( 'Class[name="Blocks.Router"]' ) . append ( $ ( '<XData>' )
51- . attr ( 'name' , fileName . replace ( / \. / g, '_' ) )
52- . append ( '<Description>*base64*</Description>' )
53- . append (
54- $ ( '<Data><![CDATA[ <data>' + ( fs . readFileSync ( fullName , {
55- encoding : 'base64'
56- } ) ) . replace ( / [ \n \r ] / g, '' ) + '</data> ]]> </Data>' )
57- )
58- )
59- }
60- } catch ( err ) {
61- console . log ( err )
62- }
63- } )
62+ // var staticFiles = fs.readdirSync('./build/')
63+
64+ // staticFiles.map(function (fileName) {
65+ // try {
66+ // fullName = path.join('./build/', fileName)
67+ // if (!fs.statSync(fullName).isDirectory()) {
68+ // $('Project>Items').append(
69+ // $('<ProjectItem>')
70+ // .attr('type', 'CSP')
71+ // .attr('name', fileName)
72+ // );
73+ // // $('Class[name="Blocks.Router"]').append($('<XData>')
74+ // // .attr('name', fileName.replace(/\./g, '_'))
75+ // // .append('<Description>*base64*</Description>')
76+ // // .append(
77+ // // $('<Data><![CDATA[ <data>' + (fs.readFileSync(fullName, {
78+ // // encoding: 'base64'
79+ // // })).replace(/[\n\r]/g, '') + '</data> ]]> </Data>')
80+ // // )
81+ // // )
82+ // }
83+ // } catch (err) {
84+ // console.log(err)
85+ // }
86+ // })
6487
6588 } ,
6689 parserOptions : {
6790 xmlMode : true ,
6891 prettify : true
6992 }
7093 } ) )
71- . pipe ( gulp . dest ( './build/src /' ) )
94+ . pipe ( gulp . dest ( './build/xml /' ) )
7295} )
7396
74- gulp . task ( 'project' , [ 'clean' , 'xml' , 'webpack ' ] , function ( ) {
97+ gulp . task ( 'project' , [ 'clean' , 'xml' , 'csp ' ] , function ( ) {
7598 return gulp . src ( [
76- './build/src /BlocksExplorer.prj.xml' ,
77- './build/src /**/*.xml' ,
78- '!./build/src /**/*Installer.cls.xml'
99+ './build/xml /BlocksExplorer.prj.xml' ,
100+ './build/xml /**/*.xml' ,
101+ '!./build/xml /**/*Installer.cls.xml'
79102 ] )
80103 . pipe ( cacheBuilder ( 'CacheBlocksExplorerProject.xml' ) )
81104 . pipe ( gulp . dest ( './build/' ) )
82105} )
83106
84107gulp . task ( 'standalone' , [ 'project' ] , function ( ) {
85108 return gulp . src ( [
86- './build/src /StandaloneInstaller.cls.xml'
109+ './build/xml /StandaloneInstaller.cls.xml'
87110 ] )
88111 . pipe ( cheerio ( {
89112 run : function ( $ , file ) {
@@ -145,7 +168,7 @@ gulp.task('serve', function (callback) {
145168 target : 'http://localhost:57774/blocks'
146169 } ,
147170 '/websocket' : {
148- target : 'ws://localhost:57774/blocks/rest ' ,
171+ target : 'ws://localhost:57774/blocks' ,
149172 changeOrigin : true ,
150173 ws : true
151174 }
0 commit comments