@liascript/devserver 1.0.10--0.10.8 → 1.0.11--0.10.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -78,7 +78,7 @@ updated separately, we use two different version, one for the devServer and one
78
78
  for LiaScript.
79
79
 
80
80
  ```text
81
- DevServer: 1.0.10
81
+ DevServer: 1.0.11
82
82
  LiaScript: 0.10.8
83
83
  ```
84
84
 
package/dist/index.js CHANGED
@@ -183,7 +183,7 @@ function $aa3bf3164f10b283$var$liascript() {
183
183
  console.log();
184
184
  }
185
185
  if ($aa3bf3164f10b283$var$argv.v || $aa3bf3164f10b283$var$argv.version) {
186
- console.log('DevServer: 1.0.10');
186
+ console.log('DevServer: 1.0.11');
187
187
  console.log('LiaScript: 0.10.8');
188
188
  process.exit();
189
189
  }
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;ACAA;;;;AAAA,oBAAwB,EAAE;;;;;AAW1B,MAAM,yBAAG,GAAwB,cAAO,EAAE;AAE1C,IAAI,6BAAO,GAAG,EAAE;AAChB,IAAI,kCAAY;AAChB,IAAI,gCAAU,GAAG,EAAE;AACnB,IAAI,mCAAa,GAAG,EAAE;AAEtB,IAAI,mCAAa,AAAK;AAEtB,yCAAI,CAAC,SAAS,CAAC;AAER,SAAS,yCAAI,CAAC,UAAmB,EAAE,eAAwB,EAAE;IAClE,6BAAO,GAAG,UAAU,IAAI,gBAAS,CAAC,SAAS,EAAE,IAAI,CAAC;IAElD,kCAAY,GAAG,eAAe,IAAI,gBAAS,CAAC,6BAAO,EAAE,cAAc,CAAC;IAEpE,gCAAU,GAAG,mBAAY,CACvB,gBAAS,CAAC,kCAAY,EAAE,iCAAiC,CAAC,CAC3D;IAED,mCAAa,GAAG,mBAAY,CAC1B,gBAAS,CAAC,kCAAY,EAAE,wBAAwB,CAAC,CAClD;CACF;;AAEM,SAAS,yCAAK,CACnB,IAAa,EACb,QA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ACnC,OAAO,CAAC,IAAI,EAAE;CACf;AAED,OAAO,CAAC,GAAG,CAAC,oCAAkC,CAAC","sources":["src/index.ts","src/lib.ts"],"sourcesContent":["const argv = require('minimist')(process.argv.slice(2))\n\nimport * as server from './lib'\n\nfunction liascript() {\n console.log(' _ _ ____ _ _')\n console.log('| | (_) __ _/ ___| ___ _ __(_)_ __ | |_')\n console.log(\"| | | |/ _` \\\\___ \\\\ / __| '__| | '_ \\\\| __|\")\n console.log('| |___| | (_| |___) | (__| | | | |_) | |_ ')\n console.log('|_____|_|\\\\__,_|____/ \\\\___|_| |_| .__/ \\\\__|')\n console.log(' |_|')\n console.log()\n}\n\nif (argv.v || argv.version) {\n console.log('DevServer: 1.0.10')\n console.log('LiaScript: 0.10.8')\n process.exit()\n}\n\nif (argv.h || argv.help) {\n liascript()\n\n console.log('-h --help show this help')\n console.log('-v --version show version information')\n console.log('-i --input input README.md file or folder (default: .)')\n console.log('-n --hostname hostname of your server (default: localhost)')\n console.log('-p --port used port number (default: 3000)')\n console.log('-l --live do live reload on file change')\n console.log('-o --open open in default browser')\n console.log('-t --test test online on https://LiaScript.github.io')\n console.log()\n console.log('-r --responsiveVoice add optional responsiveVoice support,')\n console.log(' or pass your own responsiveVoice key.')\n console.log(' Adding this feature might slow down')\n console.log(' the reloading speed.')\n console.log(' For more information visit:')\n console.log(' https://responsivevoice.org')\n\n process.exit()\n}\n\nliascript()\n\nserver.init(argv.node_modules)\n\ntry {\n server.start(\n argv.p || argv.port,\n argv.n || argv.hostname,\n argv.i || argv.input,\n argv.r || argv.responsiveVoice || process.env.RESPONSIVE_VOICE_KEY,\n argv.l || argv.live,\n argv.o || argv.open,\n argv.t || argv.test\n )\n} catch (e) {\n console.error('Error: ', e.message)\n process.exit()\n}\n\nconsole.log('✨ hit Ctrl-c to close the server')\n","require('dotenv').config()\nimport * as express from 'express'\n\nimport * as fs from 'fs'\nimport * as path from 'path'\n\nconst cors = require('cors')\nconst handlebars = require('express-handlebars')\nconst ip = require('ip')\nconst open = require('open')\n\nconst app: express.Application = express()\n\nvar dirname = ''\nvar node_modules\nvar reloadPath = ''\nvar liascriptPath = ''\n\nvar serverPointer: any\n\ninit(__dirname)\n\nexport function init(serverPath?: string, nodeModulesPath?: string) {\n dirname = serverPath || path.join(__dirname, '..')\n\n node_modules = nodeModulesPath || path.join(dirname, 'node_modules')\n\n reloadPath = path.resolve(\n path.join(node_modules, 'reloadsh.js/reloader.browser.js')\n )\n\n liascriptPath = path.resolve(\n path.join(node_modules, '@liascript/editor/dist')\n )\n}\n\nexport function start(\n port?: number,\n hostname?: string,\n input?: string,\n responsiveVoice?: string,\n liveReload?: boolean,\n openInBrowser?: boolean,\n testOnline?: boolean\n) {\n port = port || 3000\n hostname = hostname || 'localhost'\n openInBrowser = openInBrowser || false\n input = input || '.'\n liveReload = liveReload || false\n testOnline = testOnline || false\n\n var project: {\n path: string\n readme?: string\n } = {\n path: input,\n readme: undefined,\n }\n\n if (input) {\n const stats = fs.lstatSync(input)\n\n // Is it a directory?\n if (stats.isDirectory()) {\n project.path = input\n } else if (stats.isFile()) {\n project.path = path.dirname(input)\n project.readme = path.basename(input)\n }\n }\n\n app.set('view engine', 'hbs')\n app.engine(\n 'hbs',\n handlebars({\n layoutsDir: path.resolve(path.join(dirname, 'views/layouts')),\n defaultLayout: 'main',\n extname: 'hbs',\n })\n )\n app.set('views', path.resolve(path.join(dirname, 'views')))\n\n app.get('/', function (req: express.Request, res: express.Response) {\n res.redirect('/home')\n })\n\n app.get('/home*', function (req: express.Request, res: express.Response) {\n const currentPath = project.path + '/' + req.params[0]\n\n const stats = fs.lstatSync(currentPath)\n\n // Is it a directory?\n if (stats.isDirectory()) {\n const files = fs.readdirSync(currentPath).filter((e: string) => {\n return e[0] !== '.'\n })\n\n let basePath = '/home'\n let pathNames = req.params[0].split('/').filter((e: string) => {\n return e !== ''\n })\n\n let paths: { name: string; href: string }[] = []\n for (let i = 0; i < pathNames.length; i++) {\n basePath += '/' + pathNames[i]\n paths.push({ name: pathNames[i], href: basePath })\n }\n\n res.render('main', {\n layout: 'index',\n path: paths,\n file: files\n .map((file: string) => {\n return {\n name: file,\n href: `http://${hostname}:${port}/home${req.params[0]}/${file}`,\n isDirectory: fs.lstatSync(currentPath + '/' + file).isDirectory(),\n }\n })\n .sort(\n (\n a: {\n name: string\n href: string\n isDirectory: boolean\n },\n b: {\n name: string\n href: string\n isDirectory: boolean\n }\n ) => {\n if (a.isDirectory && !b.isDirectory) {\n return -1\n } else if (!a.isDirectory && b.isDirectory) {\n return 1\n } else {\n if (a.name.toLocaleLowerCase() < b.name.toLocaleLowerCase()) {\n return -1\n } else {\n return 1\n }\n }\n return 0\n }\n ),\n })\n } else if (stats.isFile()) {\n if (req.params[0].toLocaleLowerCase().endsWith('.md')) {\n if (testOnline) {\n res.redirect(\n `https://LiaScript.github.io/course/?http://${hostname}:${port}/${req.params[0]}`\n )\n } else {\n res.redirect(\n `/liascript/index.html?http://${hostname}:${port}/${req.params[0]}`\n )\n }\n } else {\n res.sendFile(req.params[0], { root: project.path })\n }\n } else {\n res.send('ups, something went wrong')\n }\n })\n\n app.get(\n '/liascript/',\n function (req: express.Request, res: express.Response) {\n res.redirect('/liascript/index.html')\n }\n )\n\n app.get(\n '/liascript/index.html',\n function (req: express.Request, res: express.Response) {\n // ------------------------------------\n if (liveReload && responsiveVoice) {\n fs.readFile(\n liascriptPath + '/index.html',\n 'utf8',\n function (err: any, data: string) {\n res.send(\n data.replace(\n '</head>',\n `<script type='text/javascript' src='/reloader/reloader.js'></script>\n <script type='text/javascript' src='https://code.responsivevoice.org/responsivevoice.js?key=${responsiveVoice}'></script>\n </head>`\n )\n )\n }\n )\n }\n // ------------------------------------\n else if (liveReload) {\n fs.readFile(\n liascriptPath + '/index.html',\n 'utf8',\n function (err: any, data: string) {\n res.send(\n data.replace(\n '</head>',\n `<script type='text/javascript' src='/reloader/reloader.js'></script></head>`\n )\n )\n }\n )\n }\n // ------------------------------------\n else if (responsiveVoice) {\n fs.readFile(\n liascriptPath + '/index.html',\n 'utf8',\n function (err: any, data: string) {\n res.send(\n data.replace(\n '</head>',\n `<script type='text/javascript' src='https://code.responsivevoice.org/responsivevoice.js?key=${responsiveVoice}'></script></head>`\n )\n )\n }\n )\n }\n // ------------------------------------\n else {\n res.sendFile(liascriptPath + '/index.html')\n }\n }\n )\n\n // load everything from the liascript folder\n app.get(\n '/liascript/*',\n function (req: express.Request, res: express.Response) {\n res.sendFile(req.params[0], { root: liascriptPath })\n }\n )\n // ignore this one\n app.get('/sw.js', function (req: express.Request, res: express.Response) {})\n app.get(\n '/favicon.ico',\n function (req: express.Request, res: express.Response) {}\n )\n\n // pass the reloader, to be used for live updates\n app.get(\n '/reloader/reloader.js',\n function (req: express.Request, res: express.Response) {\n res.sendFile(reloadPath)\n }\n )\n\n // everything else comes from the current project folder\n app.get('/*', cors(), function (req: express.Request, res: express.Response) {\n res.sendFile(req.originalUrl, { root: project.path })\n })\n\n let localURL = 'http://' + hostname + ':' + port\n\n if (project.path && project.readme) {\n localURL +=\n '/liascript/index.html?http://' +\n hostname +\n ':' +\n port +\n '/' +\n project.readme\n }\n\n if (testOnline && project.readme) {\n localURL =\n 'https://LiaScript.github.io/course/?http://' +\n hostname +\n ':' +\n port +\n '/' +\n project.readme\n }\n\n const server = require('reloadsh.js')(\n app,\n liveReload ? [path.join(project.path, project.readme || '')] : []\n )\n\n if (liveReload) {\n console.log(\n `✨ watching for changes on: \"${path.join(\n project.path || '',\n project.readme || ''\n )}\"`\n )\n }\n\n server.on('error', (e: any) => {\n throw e\n })\n\n server.listen(port)\n\n if (openInBrowser) {\n open(localURL)\n }\n\n console.log('📡 starting server')\n console.log(` - local: ${localURL}`)\n console.log(\n ` - on your network: ${localURL.replace(hostname, ip.address())}`\n )\n\n serverPointer = server\n}\n\nexport function stop() {\n if (serverPointer) {\n serverPointer.close()\n }\n}\n"],"names":[],"version":3,"file":"index.js.map","sourceRoot":"../"}
1
+ {"mappings":";;;;;;;;;;;ACAA;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AAC,oDAAoD,CAAC;IAEjE,OAAO,CAAC,IAAI,EAAE;CACf;AAED,+BAAS,EAAE;AAEX,yCAAW,CAAC,0BAAI,CAAC,YAAY,CAAC;AAE9B,IAAI;IACF,yCAAY,CACV,0BAAI,CAAC,CAAC,IAAI,0BAAI,CAAC,IAAI,EACnB,0BAAI,CAAC,CAAC,IAAI,0BAAI,CAAC,QAAQ,EACvB,0BAAI,CAAC,CAAC,IAAI,0BAAI,CAAC,KAAK,EACpB,0BAAI,CAAC,CAAC,IAAI,0BAAI,CAAC,eAAe,IAAI,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAClE,0BAAI,CAAC,CAAC,IAAI,0BAAI,CAAC,IAAI,EACnB,0BAAI,CAAC,CAAC,IAAI,0BAAI,CAAC,IAAI,EACnB,0BAAI,CAAC,CAAC,IAAI,0BAAI,CAAC,IAAI,CACpB;CACF,CAAC,OAAO,CAAC,EAAE;IACV,OAAO,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC;IACnC,OAAO,CAAC,IAAI,EAAE;CACf;AAED,OAAO,CAAC,GAAG,CAAC,oCAAkC,CAAC","sources":["src/index.ts","src/lib.ts"],"sourcesContent":["const argv = require('minimist')(process.argv.slice(2))\n\nimport * as server from './lib'\n\nfunction liascript() {\n console.log(' _ _ ____ _ _')\n console.log('| | (_) __ _/ ___| ___ _ __(_)_ __ | |_')\n console.log(\"| | | |/ _` \\\\___ \\\\ / __| '__| | '_ \\\\| __|\")\n console.log('| |___| | (_| |___) | (__| | | | |_) | |_ ')\n console.log('|_____|_|\\\\__,_|____/ \\\\___|_| |_| .__/ \\\\__|')\n console.log(' |_|')\n console.log()\n}\n\nif (argv.v || argv.version) {\n console.log('DevServer: 1.0.11')\n console.log('LiaScript: 0.10.8')\n process.exit()\n}\n\nif (argv.h || argv.help) {\n liascript()\n\n console.log('-h --help show this help')\n console.log('-v --version show version information')\n console.log('-i --input input README.md file or folder (default: .)')\n console.log('-n --hostname hostname of your server (default: localhost)')\n console.log('-p --port used port number (default: 3000)')\n console.log('-l --live do live reload on file change')\n console.log('-o --open open in default browser')\n console.log('-t --test test online on https://LiaScript.github.io')\n console.log()\n console.log('-r --responsiveVoice add optional responsiveVoice support,')\n console.log(' or pass your own responsiveVoice key.')\n console.log(' Adding this feature might slow down')\n console.log(' the reloading speed.')\n console.log(' For more information visit:')\n console.log(' https://responsivevoice.org')\n\n process.exit()\n}\n\nliascript()\n\nserver.init(argv.node_modules)\n\ntry {\n server.start(\n argv.p || argv.port,\n argv.n || argv.hostname,\n argv.i || argv.input,\n argv.r || argv.responsiveVoice || process.env.RESPONSIVE_VOICE_KEY,\n argv.l || argv.live,\n argv.o || argv.open,\n argv.t || argv.test\n )\n} catch (e) {\n console.error('Error: ', e.message)\n process.exit()\n}\n\nconsole.log('✨ hit Ctrl-c to close the server')\n","require('dotenv').config()\nimport * as express from 'express'\n\nimport * as fs from 'fs'\nimport * as path from 'path'\n\nconst cors = require('cors')\nconst handlebars = require('express-handlebars')\nconst ip = require('ip')\nconst open = require('open')\n\nconst app: express.Application = express()\n\nvar dirname = ''\nvar node_modules\nvar reloadPath = ''\nvar liascriptPath = ''\n\nvar serverPointer: any\n\ninit(__dirname)\n\nexport function init(serverPath?: string, nodeModulesPath?: string) {\n dirname = serverPath || path.join(__dirname, '..')\n\n node_modules = nodeModulesPath || path.join(dirname, 'node_modules')\n\n reloadPath = path.resolve(\n path.join(node_modules, 'reloadsh.js/reloader.browser.js')\n )\n\n liascriptPath = path.resolve(\n path.join(node_modules, '@liascript/editor/dist')\n )\n}\n\nexport function start(\n port?: number,\n hostname?: string,\n input?: string,\n responsiveVoice?: string,\n liveReload?: boolean,\n openInBrowser?: boolean,\n testOnline?: boolean\n) {\n port = port || 3000\n hostname = hostname || 'localhost'\n openInBrowser = openInBrowser || false\n input = input || '.'\n liveReload = liveReload || false\n testOnline = testOnline || false\n\n var project: {\n path: string\n readme?: string\n } = {\n path: input,\n readme: undefined,\n }\n\n if (input) {\n const stats = fs.lstatSync(input)\n\n // Is it a directory?\n if (stats.isDirectory()) {\n project.path = input\n } else if (stats.isFile()) {\n project.path = path.dirname(input)\n project.readme = path.basename(input)\n }\n }\n\n app.set('view engine', 'hbs')\n app.engine(\n 'hbs',\n handlebars({\n layoutsDir: path.resolve(path.join(dirname, 'views/layouts')),\n defaultLayout: 'main',\n extname: 'hbs',\n })\n )\n app.set('views', path.resolve(path.join(dirname, 'views')))\n\n app.get('/', function (req: express.Request, res: express.Response) {\n res.redirect('/home')\n })\n\n app.get('/home*', function (req: express.Request, res: express.Response) {\n const currentPath = project.path + '/' + req.params[0]\n\n const stats = fs.lstatSync(currentPath)\n\n // Is it a directory?\n if (stats.isDirectory()) {\n const files = fs.readdirSync(currentPath).filter((e: string) => {\n return e[0] !== '.'\n })\n\n let basePath = '/home'\n let pathNames = req.params[0].split('/').filter((e: string) => {\n return e !== ''\n })\n\n let paths: { name: string; href: string }[] = []\n for (let i = 0; i < pathNames.length; i++) {\n basePath += '/' + pathNames[i]\n paths.push({ name: pathNames[i], href: basePath })\n }\n\n res.render('main', {\n layout: 'index',\n path: paths,\n file: files\n .map((file: string) => {\n return {\n name: file,\n href: `http://${hostname}:${port}/home${req.params[0]}/${file}`,\n isDirectory: fs.lstatSync(currentPath + '/' + file).isDirectory(),\n }\n })\n .sort(\n (\n a: {\n name: string\n href: string\n isDirectory: boolean\n },\n b: {\n name: string\n href: string\n isDirectory: boolean\n }\n ) => {\n if (a.isDirectory && !b.isDirectory) {\n return -1\n } else if (!a.isDirectory && b.isDirectory) {\n return 1\n } else {\n if (a.name.toLocaleLowerCase() < b.name.toLocaleLowerCase()) {\n return -1\n } else {\n return 1\n }\n }\n return 0\n }\n ),\n })\n } else if (stats.isFile()) {\n if (req.params[0].toLocaleLowerCase().endsWith('.md')) {\n if (testOnline) {\n res.redirect(\n `https://LiaScript.github.io/course/?http://${hostname}:${port}/${req.params[0]}`\n )\n } else {\n res.redirect(\n `/liascript/index.html?http://${hostname}:${port}/${req.params[0]}`\n )\n }\n } else {\n res.sendFile(req.params[0], { root: project.path })\n }\n } else {\n res.send('ups, something went wrong')\n }\n })\n\n app.get(\n '/liascript/',\n function (req: express.Request, res: express.Response) {\n res.redirect('/liascript/index.html')\n }\n )\n\n app.get(\n '/liascript/index.html',\n function (req: express.Request, res: express.Response) {\n // ------------------------------------\n if (liveReload && responsiveVoice) {\n fs.readFile(\n liascriptPath + '/index.html',\n 'utf8',\n function (err: any, data: string) {\n res.send(\n data.replace(\n '</head>',\n `<script type='text/javascript' src='/reloader/reloader.js'></script>\n <script type='text/javascript' src='https://code.responsivevoice.org/responsivevoice.js?key=${responsiveVoice}'></script>\n </head>`\n )\n )\n }\n )\n }\n // ------------------------------------\n else if (liveReload) {\n fs.readFile(\n liascriptPath + '/index.html',\n 'utf8',\n function (err: any, data: string) {\n res.send(\n data.replace(\n '</head>',\n `<script type='text/javascript' src='/reloader/reloader.js'></script></head>`\n )\n )\n }\n )\n }\n // ------------------------------------\n else if (responsiveVoice) {\n fs.readFile(\n liascriptPath + '/index.html',\n 'utf8',\n function (err: any, data: string) {\n res.send(\n data.replace(\n '</head>',\n `<script type='text/javascript' src='https://code.responsivevoice.org/responsivevoice.js?key=${responsiveVoice}'></script></head>`\n )\n )\n }\n )\n }\n // ------------------------------------\n else {\n res.sendFile(liascriptPath + '/index.html')\n }\n }\n )\n\n // load everything from the liascript folder\n app.get(\n '/liascript/*',\n function (req: express.Request, res: express.Response) {\n res.sendFile(req.params[0], { root: liascriptPath })\n }\n )\n // ignore this one\n app.get('/sw.js', function (req: express.Request, res: express.Response) {})\n app.get(\n '/favicon.ico',\n function (req: express.Request, res: express.Response) {}\n )\n\n // pass the reloader, to be used for live updates\n app.get(\n '/reloader/reloader.js',\n function (req: express.Request, res: express.Response) {\n res.sendFile(reloadPath)\n }\n )\n\n // everything else comes from the current project folder\n app.get('/*', cors(), function (req: express.Request, res: express.Response) {\n res.sendFile(req.originalUrl, { root: project.path })\n })\n\n let localURL = 'http://' + hostname + ':' + port\n\n if (project.path && project.readme) {\n localURL +=\n '/liascript/index.html?http://' +\n hostname +\n ':' +\n port +\n '/' +\n project.readme\n }\n\n if (testOnline && project.readme) {\n localURL =\n 'https://LiaScript.github.io/course/?http://' +\n hostname +\n ':' +\n port +\n '/' +\n project.readme\n }\n\n const server = require('reloadsh.js')(\n app,\n liveReload ? [path.join(project.path, project.readme || '')] : []\n )\n\n if (liveReload) {\n console.log(\n `✨ watching for changes on: \"${path.join(\n project.path || '',\n project.readme || ''\n )}\"`\n )\n }\n\n server.on('error', (e: any) => {\n throw e\n })\n\n server.listen(port)\n\n if (openInBrowser) {\n open(localURL)\n }\n\n console.log('📡 starting server')\n console.log(` - local: ${localURL}`)\n console.log(\n ` - on your network: ${localURL.replace(hostname, ip.address())}`\n )\n\n serverPointer = server\n}\n\nexport function stop() {\n if (serverPointer) {\n serverPointer.close()\n }\n}\n"],"names":[],"version":3,"file":"index.js.map","sourceRoot":"../"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liascript/devserver",
3
- "version": "1.0.10--0.10.8",
3
+ "version": "1.0.11--0.10.8",
4
4
  "description": "Run a development server for LiaScript locally",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/src/index.ts ADDED
@@ -0,0 +1,62 @@
1
+ const argv = require('minimist')(process.argv.slice(2))
2
+
3
+ import * as server from './lib'
4
+
5
+ function liascript() {
6
+ console.log(' _ _ ____ _ _')
7
+ console.log('| | (_) __ _/ ___| ___ _ __(_)_ __ | |_')
8
+ console.log("| | | |/ _` \\___ \\ / __| '__| | '_ \\| __|")
9
+ console.log('| |___| | (_| |___) | (__| | | | |_) | |_ ')
10
+ console.log('|_____|_|\\__,_|____/ \\___|_| |_| .__/ \\__|')
11
+ console.log(' |_|')
12
+ console.log()
13
+ }
14
+
15
+ if (argv.v || argv.version) {
16
+ console.log('DevServer: 1.0.11')
17
+ console.log('LiaScript: 0.10.8')
18
+ process.exit()
19
+ }
20
+
21
+ if (argv.h || argv.help) {
22
+ liascript()
23
+
24
+ console.log('-h --help show this help')
25
+ console.log('-v --version show version information')
26
+ console.log('-i --input input README.md file or folder (default: .)')
27
+ console.log('-n --hostname hostname of your server (default: localhost)')
28
+ console.log('-p --port used port number (default: 3000)')
29
+ console.log('-l --live do live reload on file change')
30
+ console.log('-o --open open in default browser')
31
+ console.log('-t --test test online on https://LiaScript.github.io')
32
+ console.log()
33
+ console.log('-r --responsiveVoice add optional responsiveVoice support,')
34
+ console.log(' or pass your own responsiveVoice key.')
35
+ console.log(' Adding this feature might slow down')
36
+ console.log(' the reloading speed.')
37
+ console.log(' For more information visit:')
38
+ console.log(' https://responsivevoice.org')
39
+
40
+ process.exit()
41
+ }
42
+
43
+ liascript()
44
+
45
+ server.init(argv.node_modules)
46
+
47
+ try {
48
+ server.start(
49
+ argv.p || argv.port,
50
+ argv.n || argv.hostname,
51
+ argv.i || argv.input,
52
+ argv.r || argv.responsiveVoice || process.env.RESPONSIVE_VOICE_KEY,
53
+ argv.l || argv.live,
54
+ argv.o || argv.open,
55
+ argv.t || argv.test
56
+ )
57
+ } catch (e) {
58
+ console.error('Error: ', e.message)
59
+ process.exit()
60
+ }
61
+
62
+ console.log('✨ hit Ctrl-c to close the server')
package/src/lib.ts ADDED
@@ -0,0 +1,318 @@
1
+ require('dotenv').config()
2
+ import * as express from 'express'
3
+
4
+ import * as fs from 'fs'
5
+ import * as path from 'path'
6
+
7
+ const cors = require('cors')
8
+ const handlebars = require('express-handlebars')
9
+ const ip = require('ip')
10
+ const open = require('open')
11
+
12
+ const app: express.Application = express()
13
+
14
+ var dirname = ''
15
+ var node_modules
16
+ var reloadPath = ''
17
+ var liascriptPath = ''
18
+
19
+ var serverPointer: any
20
+
21
+ init(__dirname)
22
+
23
+ export function init(serverPath?: string, nodeModulesPath?: string) {
24
+ dirname = serverPath || path.join(__dirname, '..')
25
+
26
+ node_modules = nodeModulesPath || path.join(dirname, 'node_modules')
27
+
28
+ reloadPath = path.resolve(
29
+ path.join(node_modules, 'reloadsh.js/reloader.browser.js')
30
+ )
31
+
32
+ liascriptPath = path.resolve(
33
+ path.join(node_modules, '@liascript/editor/dist')
34
+ )
35
+ }
36
+
37
+ export function start(
38
+ port?: number,
39
+ hostname?: string,
40
+ input?: string,
41
+ responsiveVoice?: string,
42
+ liveReload?: boolean,
43
+ openInBrowser?: boolean,
44
+ testOnline?: boolean
45
+ ) {
46
+ port = port || 3000
47
+ hostname = hostname || 'localhost'
48
+ openInBrowser = openInBrowser || false
49
+ input = input || '.'
50
+ liveReload = liveReload || false
51
+ testOnline = testOnline || false
52
+
53
+ var project: {
54
+ path: string
55
+ readme?: string
56
+ } = {
57
+ path: input,
58
+ readme: undefined,
59
+ }
60
+
61
+ if (input) {
62
+ const stats = fs.lstatSync(input)
63
+
64
+ // Is it a directory?
65
+ if (stats.isDirectory()) {
66
+ project.path = input
67
+ } else if (stats.isFile()) {
68
+ project.path = path.dirname(input)
69
+ project.readme = path.basename(input)
70
+ }
71
+ }
72
+
73
+ app.set('view engine', 'hbs')
74
+ app.engine(
75
+ 'hbs',
76
+ handlebars({
77
+ layoutsDir: path.resolve(path.join(dirname, 'views/layouts')),
78
+ defaultLayout: 'main',
79
+ extname: 'hbs',
80
+ })
81
+ )
82
+ app.set('views', path.resolve(path.join(dirname, 'views')))
83
+
84
+ app.get('/', function (req: express.Request, res: express.Response) {
85
+ res.redirect('/home')
86
+ })
87
+
88
+ app.get('/home*', function (req: express.Request, res: express.Response) {
89
+ const currentPath = project.path + '/' + req.params[0]
90
+
91
+ const stats = fs.lstatSync(currentPath)
92
+
93
+ // Is it a directory?
94
+ if (stats.isDirectory()) {
95
+ const files = fs.readdirSync(currentPath).filter((e: string) => {
96
+ return e[0] !== '.'
97
+ })
98
+
99
+ let basePath = '/home'
100
+ let pathNames = req.params[0].split('/').filter((e: string) => {
101
+ return e !== ''
102
+ })
103
+
104
+ let paths: { name: string; href: string }[] = []
105
+ for (let i = 0; i < pathNames.length; i++) {
106
+ basePath += '/' + pathNames[i]
107
+ paths.push({ name: pathNames[i], href: basePath })
108
+ }
109
+
110
+ res.render('main', {
111
+ layout: 'index',
112
+ path: paths,
113
+ file: files
114
+ .map((file: string) => {
115
+ return {
116
+ name: file,
117
+ href: `http://${hostname}:${port}/home${req.params[0]}/${file}`,
118
+ isDirectory: fs.lstatSync(currentPath + '/' + file).isDirectory(),
119
+ }
120
+ })
121
+ .sort(
122
+ (
123
+ a: {
124
+ name: string
125
+ href: string
126
+ isDirectory: boolean
127
+ },
128
+ b: {
129
+ name: string
130
+ href: string
131
+ isDirectory: boolean
132
+ }
133
+ ) => {
134
+ if (a.isDirectory && !b.isDirectory) {
135
+ return -1
136
+ } else if (!a.isDirectory && b.isDirectory) {
137
+ return 1
138
+ } else {
139
+ if (a.name.toLocaleLowerCase() < b.name.toLocaleLowerCase()) {
140
+ return -1
141
+ } else {
142
+ return 1
143
+ }
144
+ }
145
+ return 0
146
+ }
147
+ ),
148
+ })
149
+ } else if (stats.isFile()) {
150
+ if (req.params[0].toLocaleLowerCase().endsWith('.md')) {
151
+ if (testOnline) {
152
+ res.redirect(
153
+ `https://LiaScript.github.io/course/?http://${hostname}:${port}/${req.params[0]}`
154
+ )
155
+ } else {
156
+ res.redirect(
157
+ `/liascript/index.html?http://${hostname}:${port}/${req.params[0]}`
158
+ )
159
+ }
160
+ } else {
161
+ res.sendFile(req.params[0], { root: project.path })
162
+ }
163
+ } else {
164
+ res.send('ups, something went wrong')
165
+ }
166
+ })
167
+
168
+ app.get(
169
+ '/liascript/',
170
+ function (req: express.Request, res: express.Response) {
171
+ res.redirect('/liascript/index.html')
172
+ }
173
+ )
174
+
175
+ app.get(
176
+ '/liascript/index.html',
177
+ function (req: express.Request, res: express.Response) {
178
+ // ------------------------------------
179
+ if (liveReload && responsiveVoice) {
180
+ fs.readFile(
181
+ liascriptPath + '/index.html',
182
+ 'utf8',
183
+ function (err: any, data: string) {
184
+ res.send(
185
+ data.replace(
186
+ '</head>',
187
+ `<script type='text/javascript' src='/reloader/reloader.js'></script>
188
+ <script type='text/javascript' src='https://code.responsivevoice.org/responsivevoice.js?key=${responsiveVoice}'></script>
189
+ </head>`
190
+ )
191
+ )
192
+ }
193
+ )
194
+ }
195
+ // ------------------------------------
196
+ else if (liveReload) {
197
+ fs.readFile(
198
+ liascriptPath + '/index.html',
199
+ 'utf8',
200
+ function (err: any, data: string) {
201
+ res.send(
202
+ data.replace(
203
+ '</head>',
204
+ `<script type='text/javascript' src='/reloader/reloader.js'></script></head>`
205
+ )
206
+ )
207
+ }
208
+ )
209
+ }
210
+ // ------------------------------------
211
+ else if (responsiveVoice) {
212
+ fs.readFile(
213
+ liascriptPath + '/index.html',
214
+ 'utf8',
215
+ function (err: any, data: string) {
216
+ res.send(
217
+ data.replace(
218
+ '</head>',
219
+ `<script type='text/javascript' src='https://code.responsivevoice.org/responsivevoice.js?key=${responsiveVoice}'></script></head>`
220
+ )
221
+ )
222
+ }
223
+ )
224
+ }
225
+ // ------------------------------------
226
+ else {
227
+ res.sendFile(liascriptPath + '/index.html')
228
+ }
229
+ }
230
+ )
231
+
232
+ // load everything from the liascript folder
233
+ app.get(
234
+ '/liascript/*',
235
+ function (req: express.Request, res: express.Response) {
236
+ res.sendFile(req.params[0], { root: liascriptPath })
237
+ }
238
+ )
239
+ // ignore this one
240
+ app.get('/sw.js', function (req: express.Request, res: express.Response) {})
241
+ app.get(
242
+ '/favicon.ico',
243
+ function (req: express.Request, res: express.Response) {}
244
+ )
245
+
246
+ // pass the reloader, to be used for live updates
247
+ app.get(
248
+ '/reloader/reloader.js',
249
+ function (req: express.Request, res: express.Response) {
250
+ res.sendFile(reloadPath)
251
+ }
252
+ )
253
+
254
+ // everything else comes from the current project folder
255
+ app.get('/*', cors(), function (req: express.Request, res: express.Response) {
256
+ res.sendFile(req.originalUrl, { root: project.path })
257
+ })
258
+
259
+ let localURL = 'http://' + hostname + ':' + port
260
+
261
+ if (project.path && project.readme) {
262
+ localURL +=
263
+ '/liascript/index.html?http://' +
264
+ hostname +
265
+ ':' +
266
+ port +
267
+ '/' +
268
+ project.readme
269
+ }
270
+
271
+ if (testOnline && project.readme) {
272
+ localURL =
273
+ 'https://LiaScript.github.io/course/?http://' +
274
+ hostname +
275
+ ':' +
276
+ port +
277
+ '/' +
278
+ project.readme
279
+ }
280
+
281
+ const server = require('reloadsh.js')(
282
+ app,
283
+ liveReload ? [path.join(project.path, project.readme || '')] : []
284
+ )
285
+
286
+ if (liveReload) {
287
+ console.log(
288
+ `✨ watching for changes on: "${path.join(
289
+ project.path || '',
290
+ project.readme || ''
291
+ )}"`
292
+ )
293
+ }
294
+
295
+ server.on('error', (e: any) => {
296
+ throw e
297
+ })
298
+
299
+ server.listen(port)
300
+
301
+ if (openInBrowser) {
302
+ open(localURL)
303
+ }
304
+
305
+ console.log('📡 starting server')
306
+ console.log(` - local: ${localURL}`)
307
+ console.log(
308
+ ` - on your network: ${localURL.replace(hostname, ip.address())}`
309
+ )
310
+
311
+ serverPointer = server
312
+ }
313
+
314
+ export function stop() {
315
+ if (serverPointer) {
316
+ serverPointer.close()
317
+ }
318
+ }
package/views/main.hbs CHANGED
@@ -7,7 +7,7 @@
7
7
  | |___| | (_| |___) | (__| | | | |_) | |_
8
8
  |_____|_|\__,_|____/ \___|_| |_| .__/ \__|
9
9
  |_|
10
- [ DevServer: 1.0.10--0.10.8 ]
10
+ [ DevServer: 1.0.11--0.10.8 ]
11
11
  </pre>
12
12
  </code>
13
13
  </h4>