File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -209,15 +209,15 @@ module.exports = class TutorialImporter {
209209 data . githubLink = config . tutorialGithubBaseUrl + articlePath . slice ( this . root . length ) + '/article.md' ;
210210
211211 try {
212- data . headJs = fs . readFileSync ( path . join ( articlePath , 'head.js' ) ) ;
212+ data . headJs = fs . readFileSync ( path . join ( articlePath , 'head.js' ) , { encoding : 'utf8' } ) ;
213213 } catch ( e ) {
214214 }
215215 try {
216- data . headCss = fs . readFileSync ( path . join ( articlePath , 'head.css' ) ) ;
216+ data . headCss = fs . readFileSync ( path . join ( articlePath , 'head.css' ) , { encoding : 'utf8' } ) ;
217217 } catch ( e ) {
218218 }
219219 try {
220- data . headHtml = fs . readFileSync ( path . join ( articlePath , 'head.html' ) ) ;
220+ data . headHtml = fs . readFileSync ( path . join ( articlePath , 'head.html' ) , { encoding : 'utf8' } ) ;
221221 } catch ( e ) {
222222 }
223223
Original file line number Diff line number Diff line change @@ -34,7 +34,9 @@ app.proxy = true;
3434
3535// ========= Helper handlers ===========
3636
37- config . handlers . forEach ( handler => app . requireHandler ( handler ) ) ;
37+ for ( const handlerName in config . handlers ) {
38+ app . requireHandler ( handlerName ) ;
39+ }
3840
3941// must be last
4042app . requireHandler ( '404' ) ;
Original file line number Diff line number Diff line change 33const path = require ( 'path' ) ;
44const fs = require ( 'fs' ) ;
55
6- let handlers = [
6+ let handlerNames = [
77 'static' ,
88 'requestId' ,
99 'requestLog' ,
@@ -43,4 +43,17 @@ let handlers = [
4343 'tutorial'
4444] . filter ( Boolean ) ;
4545
46+ let handlers = { } ;
47+
48+ for ( const name of handlerNames ) {
49+ let handlerPath = require . resolve ( name ) ;
50+ if ( handlerPath . endsWith ( 'index.js' ) ) {
51+ handlerPath = path . dirname ( handlerPath ) ;
52+ }
53+ handlers [ name ] = {
54+ path : handlerPath
55+ }
56+ }
57+
58+
4659module . exports = handlers ;
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ let noProcessModulesRegExp = /node_modules\/(angular|prismjs)/;
2424
2525let devMode = process . env . NODE_ENV == 'development' ;
2626
27+
2728module . exports = function ( config ) {
2829// tutorial.js?hash
2930// tutorial.hash.js
@@ -39,6 +40,19 @@ module.exports = function (config) {
3940 modulesDirectories = modulesDirectories . concat ( process . env . NODE_PATH . split ( / [: ; ] / ) . map ( p => path . resolve ( p ) ) ) ;
4041 }
4142
43+ let assetPaths = [ ] ;
44+ for ( let handlerName in config . handlers ) {
45+ let handlerPath = config . handlers [ handlerName ] . path ;
46+ let from = `${ handlerPath } /client/assets` ;
47+ console . log ( from ) ;
48+
49+ if ( fse . existsSync ( from ) ) {
50+ assetPaths . push ( from ) ;
51+ }
52+ }
53+ console . log ( assetPaths ) ;
54+
55+
4256 let webpackConfig = {
4357 output : {
4458 // fs path
@@ -230,16 +244,14 @@ module.exports = function (config) {
230244 } ) ,
231245
232246 new CopyWebpackPlugin (
233- config . handlers . map ( handler => {
234- let from = `handlers/${ handler } /client/assets` ;
235- if ( ! fse . existsSync ( from ) ) return ;
236-
247+ assetPaths . map ( path => {
237248 return {
238- from,
249+ from : path ,
239250 to : config . publicRoot
240251 }
241- } ) . filter ( Boolean ) ,
242- { debug : 'warning' }
252+ } ) ,
253+ { debug : 'debug' }
254+ // { debug: 'warning'}
243255 ) ,
244256
245257 {
Original file line number Diff line number Diff line change @@ -51,11 +51,12 @@ class CssWatchFS {
5151
5252 let styles = glob . sync ( `${ this . roots [ name ] } /**/*.styl` , { cwd : config . projectRoot } ) ;
5353
54- config . handlers . forEach ( handler => {
55- let handlerStyles = glob . sync ( `handlers/ ${ handler } /client/styles/**/*.styl` , { cwd : config . projectRoot } ) ;
54+ for ( const { path : handlerPath } of Object . values ( config . handlers ) ) {
55+ let handlerStyles = glob . sync ( `${ handlerPath } /client/styles/**/*.styl` , { cwd : config . projectRoot } ) ;
5656 styles . push ( ...handlerStyles ) ;
57- } ) ;
57+ }
5858
59+ console . log ( "LOG STYLES" , styles ) ;
5960 let content = styles . map ( s => `@require '../${ s } '` ) . join ( "\n" ) ;
6061
6162 fs . writeFileSync ( `${ config . tmpRoot } /${ name } .styl` , content ) ;
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ $ files = glob ("**/*.js " );
4+ foreach ($ files as $ file ) {
5+ echo "$ file \n" ;
6+ $ content = file_get_contents ($ file );
7+
8+ $ replaced = str_replace ($ search , $ replace , $ content );
9+
10+ file_put_contents ($ file , $ content );
11+ }
12+
13+ $ search = [
14+ "require('textUtil " ,
15+ "require('i18n " ,
16+ "require('log " ,
17+ "require('localStorage " ,
18+ "require('serverPug " ,
19+ "require('momentWithLocale "
20+ ];
21+
22+ $ replace = [
23+ "require('@jsengine/text-utils " ,
24+ "require('@jsengine/i18n " ,
25+ "require('@jsengine/log " ,
26+ "require('@jsengine/local-storage " ,
27+ "require('@jsengine/server-pug " ,
28+ "require('@jsengine/moment-with-locale "
29+ ];
You can’t perform that action at this time.
0 commit comments