@liascript/devserver 1.0.5--0.10.5 β 1.0.5--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 +1 -1
- package/dist/index.js +207 -3
- package/dist/index.js.map +1 -0
- package/package.json +11 -19
- package/views/main.hbs +1 -1
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,208 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
|
|
3
|
+
var $8zHUo$express = require("express");
|
|
4
|
+
var $8zHUo$open = require("open");
|
|
5
|
+
var $8zHUo$fs = require("fs");
|
|
6
|
+
var $8zHUo$path = require("path");
|
|
7
|
+
var $8zHUo$process = require("process");
|
|
8
|
+
var $8zHUo$dotenv = require("dotenv");
|
|
9
|
+
var $8zHUo$cors = require("cors");
|
|
10
|
+
var $8zHUo$expresshandlebars = require("express-handlebars");
|
|
11
|
+
var $8zHUo$minimist = require("minimist");
|
|
12
|
+
var $8zHUo$ip = require("ip");
|
|
13
|
+
var $8zHUo$reloadshjs = require("reloadsh.js");
|
|
14
|
+
|
|
15
|
+
function $parcel$interopDefault(a) {
|
|
16
|
+
return a && a.__esModule ? a.default : a;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
var $882b6d93070905b3$var$__dirname = "src";
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
$8zHUo$dotenv.config();
|
|
26
|
+
const $882b6d93070905b3$var$app = ($parcel$interopDefault($8zHUo$express))();
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
const $882b6d93070905b3$var$argv = $8zHUo$minimist($8zHUo$process.argv.slice(2));
|
|
31
|
+
|
|
32
|
+
const $882b6d93070905b3$var$liascriptPath = ($parcel$interopDefault($8zHUo$path)).resolve(($parcel$interopDefault($8zHUo$path)).join("/home/andre/Workspace/Projects/Freinet/liascript-devserver", 'node_modules/@liascript/editor/dist'));
|
|
33
|
+
const $882b6d93070905b3$var$reloadPath = ($parcel$interopDefault($8zHUo$path)).resolve(($parcel$interopDefault($8zHUo$path)).join("/home/andre/Workspace/Projects/Freinet/liascript-devserver", 'node_modules/reloadsh.js/reloader.browser.js'));
|
|
34
|
+
function $882b6d93070905b3$var$liascript() {
|
|
35
|
+
console.log(' _ _ ____ _ _');
|
|
36
|
+
console.log('| | (_) __ _/ ___| ___ _ __(_)_ __ | |_');
|
|
37
|
+
console.log("| | | |/ _` \\___ \\ / __| '__| | '_ \\| __|");
|
|
38
|
+
console.log('| |___| | (_| |___) | (__| | | | |_) | |_ ');
|
|
39
|
+
console.log('|_____|_|\\__,_|____/ \\___|_| |_| .__/ \\__|');
|
|
40
|
+
console.log(' |_|');
|
|
41
|
+
console.log();
|
|
42
|
+
}
|
|
43
|
+
if ($882b6d93070905b3$var$argv.v || $882b6d93070905b3$var$argv.version) {
|
|
44
|
+
console.log('DevServer: 1.0.5');
|
|
45
|
+
console.log('LiaScript: 0.10.7');
|
|
46
|
+
$8zHUo$process.exit();
|
|
47
|
+
}
|
|
48
|
+
if ($882b6d93070905b3$var$argv.h || $882b6d93070905b3$var$argv.help) {
|
|
49
|
+
$882b6d93070905b3$var$liascript();
|
|
50
|
+
console.log('-h --help show this help');
|
|
51
|
+
console.log('-v --version show version information');
|
|
52
|
+
console.log('-i --input input README.md file or folder (default: .)');
|
|
53
|
+
console.log('-n --hostname hostname of your server (default: localhost)');
|
|
54
|
+
console.log('-p --port used port number (default: 3000)');
|
|
55
|
+
console.log('-l --live do live reload on file change');
|
|
56
|
+
console.log('-o --open open in default browser');
|
|
57
|
+
console.log('-t --test test online on https://LiaScript.github.io');
|
|
58
|
+
console.log();
|
|
59
|
+
console.log('-r --responsiveVoice add optional responsiveVoice support,');
|
|
60
|
+
console.log(' or pass your own responsiveVoice key.');
|
|
61
|
+
console.log(' Adding this feature might slow down');
|
|
62
|
+
console.log(' the reloading speed.');
|
|
63
|
+
console.log(' For more information visit:');
|
|
64
|
+
console.log(' https://responsivevoice.org');
|
|
65
|
+
$8zHUo$process.exit();
|
|
66
|
+
}
|
|
67
|
+
const $882b6d93070905b3$var$port = $882b6d93070905b3$var$argv.p || $882b6d93070905b3$var$argv.port || 3000;
|
|
68
|
+
const $882b6d93070905b3$var$hostname = $882b6d93070905b3$var$argv.n || $882b6d93070905b3$var$argv.hostname || 'localhost';
|
|
69
|
+
const $882b6d93070905b3$var$openInBrowser = $882b6d93070905b3$var$argv.o || $882b6d93070905b3$var$argv.open;
|
|
70
|
+
const $882b6d93070905b3$var$input = $882b6d93070905b3$var$argv.i || $882b6d93070905b3$var$argv.input || '.';
|
|
71
|
+
const $882b6d93070905b3$var$liveReload = $882b6d93070905b3$var$argv.l || $882b6d93070905b3$var$argv.live || false;
|
|
72
|
+
const $882b6d93070905b3$var$testOnline = $882b6d93070905b3$var$argv.t || $882b6d93070905b3$var$argv.test;
|
|
73
|
+
let $882b6d93070905b3$var$responsiveVoice;
|
|
74
|
+
if ($882b6d93070905b3$var$argv.r || $882b6d93070905b3$var$argv.responsiveVoice) {
|
|
75
|
+
let active = $882b6d93070905b3$var$argv.r || $882b6d93070905b3$var$argv.responsiveVoice;
|
|
76
|
+
if (typeof active === 'string') $882b6d93070905b3$var$responsiveVoice = active;
|
|
77
|
+
else $882b6d93070905b3$var$responsiveVoice = undefined;
|
|
78
|
+
}
|
|
79
|
+
var $882b6d93070905b3$var$project = {
|
|
80
|
+
path: null,
|
|
81
|
+
readme: null
|
|
82
|
+
};
|
|
83
|
+
if ($882b6d93070905b3$var$input) {
|
|
84
|
+
const stats = ($parcel$interopDefault($8zHUo$fs)).lstatSync($882b6d93070905b3$var$input);
|
|
85
|
+
// Is it a directory?
|
|
86
|
+
if (stats.isDirectory()) $882b6d93070905b3$var$project.path = $882b6d93070905b3$var$input;
|
|
87
|
+
else if (stats.isFile()) {
|
|
88
|
+
$882b6d93070905b3$var$project.path = ($parcel$interopDefault($8zHUo$path)).dirname($882b6d93070905b3$var$input);
|
|
89
|
+
$882b6d93070905b3$var$project.readme = ($parcel$interopDefault($8zHUo$path)).basename($882b6d93070905b3$var$input);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
$882b6d93070905b3$var$app.set('view engine', 'hbs');
|
|
93
|
+
$882b6d93070905b3$var$app.engine('hbs', $8zHUo$expresshandlebars({
|
|
94
|
+
layoutsDir: ($parcel$interopDefault($8zHUo$path)).normalize($882b6d93070905b3$var$__dirname + '/../views/layouts'),
|
|
95
|
+
defaultLayout: 'main',
|
|
96
|
+
extname: 'hbs'
|
|
97
|
+
}));
|
|
98
|
+
$882b6d93070905b3$var$app.set('views', ($parcel$interopDefault($8zHUo$path)).normalize($882b6d93070905b3$var$__dirname + '/../views'));
|
|
99
|
+
$882b6d93070905b3$var$app.get('/', function(req, res) {
|
|
100
|
+
res.redirect('/home');
|
|
101
|
+
});
|
|
102
|
+
$882b6d93070905b3$var$app.get('/home*', function(req, res) {
|
|
103
|
+
const currentPath = $882b6d93070905b3$var$project.path + '/' + req.params[0];
|
|
104
|
+
const stats = ($parcel$interopDefault($8zHUo$fs)).lstatSync(currentPath);
|
|
105
|
+
// Is it a directory?
|
|
106
|
+
if (stats.isDirectory()) {
|
|
107
|
+
const files = ($parcel$interopDefault($8zHUo$fs)).readdirSync(currentPath).filter((e)=>{
|
|
108
|
+
return e[0] !== '.';
|
|
109
|
+
});
|
|
110
|
+
let basePath = '/home';
|
|
111
|
+
let pathNames = req.params[0].split('/').filter((e)=>{
|
|
112
|
+
return e !== '';
|
|
113
|
+
});
|
|
114
|
+
let paths = [];
|
|
115
|
+
for(let i = 0; i < pathNames.length; i++){
|
|
116
|
+
basePath += '/' + pathNames[i];
|
|
117
|
+
paths.push({
|
|
118
|
+
name: pathNames[i],
|
|
119
|
+
href: basePath
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
res.render('main', {
|
|
123
|
+
layout: 'index',
|
|
124
|
+
path: paths,
|
|
125
|
+
file: files.map((file)=>{
|
|
126
|
+
return {
|
|
127
|
+
name: file,
|
|
128
|
+
href: `http://${$882b6d93070905b3$var$hostname}:${$882b6d93070905b3$var$port}/home${req.params[0]}/${file}`,
|
|
129
|
+
isDirectory: ($parcel$interopDefault($8zHUo$fs)).lstatSync(currentPath + '/' + file).isDirectory()
|
|
130
|
+
};
|
|
131
|
+
}).sort((a, b)=>{
|
|
132
|
+
if (a.isDirectory && !b.isDirectory) return -1;
|
|
133
|
+
else if (!a.isDirectory && b.isDirectory) return 1;
|
|
134
|
+
else {
|
|
135
|
+
if (a.name.toLocaleLowerCase() < b.name.toLocaleLowerCase()) return -1;
|
|
136
|
+
else return 1;
|
|
137
|
+
}
|
|
138
|
+
return 0;
|
|
139
|
+
})
|
|
140
|
+
});
|
|
141
|
+
} else if (stats.isFile()) {
|
|
142
|
+
if (req.params[0].toLocaleLowerCase().endsWith('.md')) {
|
|
143
|
+
if ($882b6d93070905b3$var$testOnline) res.redirect(`https://LiaScript.github.io/course/?http://${$882b6d93070905b3$var$hostname}:${$882b6d93070905b3$var$port}/${req.params[0]}`);
|
|
144
|
+
else res.redirect(`/liascript/index.html?http://${$882b6d93070905b3$var$hostname}:${$882b6d93070905b3$var$port}/${req.params[0]}`);
|
|
145
|
+
} else res.sendFile(req.params[0], {
|
|
146
|
+
root: $882b6d93070905b3$var$project.path
|
|
147
|
+
});
|
|
148
|
+
} else res.send('ups, something went wrong');
|
|
149
|
+
});
|
|
150
|
+
$882b6d93070905b3$var$app.get('/liascript/', function(req, res) {
|
|
151
|
+
res.redirect('/liascript/index.html');
|
|
152
|
+
});
|
|
153
|
+
$882b6d93070905b3$var$app.get('/liascript/index.html', function(req, res) {
|
|
154
|
+
// ------------------------------------
|
|
155
|
+
if ($882b6d93070905b3$var$liveReload && $882b6d93070905b3$var$responsiveVoice) ($parcel$interopDefault($8zHUo$fs)).readFile($882b6d93070905b3$var$liascriptPath + '/index.html', 'utf8', function(err, data) {
|
|
156
|
+
res.send(data.replace('</head>', `<script type='text/javascript' src='/reloader/reloader.js'></script>
|
|
157
|
+
<script type='text/javascript' src='https://code.responsivevoice.org/responsivevoice.js?key=${$882b6d93070905b3$var$responsiveVoice}'></script>
|
|
158
|
+
</head>`));
|
|
159
|
+
});
|
|
160
|
+
else if ($882b6d93070905b3$var$liveReload) ($parcel$interopDefault($8zHUo$fs)).readFile($882b6d93070905b3$var$liascriptPath + '/index.html', 'utf8', function(err, data) {
|
|
161
|
+
res.send(data.replace('</head>', `<script type='text/javascript' src='/reloader/reloader.js'></script></head>`));
|
|
162
|
+
});
|
|
163
|
+
else if ($882b6d93070905b3$var$responsiveVoice) ($parcel$interopDefault($8zHUo$fs)).readFile($882b6d93070905b3$var$liascriptPath + '/index.html', 'utf8', function(err, data) {
|
|
164
|
+
res.send(data.replace('</head>', `<script type='text/javascript' src='https://code.responsivevoice.org/responsivevoice.js?key=${$882b6d93070905b3$var$responsiveVoice}'></script></head>`));
|
|
165
|
+
});
|
|
166
|
+
else res.sendFile($882b6d93070905b3$var$liascriptPath + '/index.html');
|
|
167
|
+
});
|
|
168
|
+
// load everything from the liascript folder
|
|
169
|
+
$882b6d93070905b3$var$app.get('/liascript/*', function(req, res) {
|
|
170
|
+
res.sendFile(req.params[0], {
|
|
171
|
+
root: $882b6d93070905b3$var$liascriptPath
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
// ignore this one
|
|
175
|
+
$882b6d93070905b3$var$app.get('/sw.js', function(req, res) {});
|
|
176
|
+
$882b6d93070905b3$var$app.get('/favicon.ico', function(req, res) {});
|
|
177
|
+
// pass the reloader, to be used for live updates
|
|
178
|
+
$882b6d93070905b3$var$app.get('/reloader/reloader.js', function(req, res) {
|
|
179
|
+
res.sendFile($882b6d93070905b3$var$reloadPath);
|
|
180
|
+
});
|
|
181
|
+
// everything else comes from the current project folder
|
|
182
|
+
$882b6d93070905b3$var$app.get('/*', $8zHUo$cors(), function(req, res) {
|
|
183
|
+
res.sendFile(req.originalUrl, {
|
|
184
|
+
root: $882b6d93070905b3$var$project.path
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
let $882b6d93070905b3$var$localURL = 'http://' + $882b6d93070905b3$var$hostname + ':' + $882b6d93070905b3$var$port;
|
|
188
|
+
if ($882b6d93070905b3$var$project.path && $882b6d93070905b3$var$project.readme) $882b6d93070905b3$var$localURL += '/liascript/index.html?http://' + $882b6d93070905b3$var$hostname + ':' + $882b6d93070905b3$var$port + '/' + $882b6d93070905b3$var$project.readme;
|
|
189
|
+
if ($882b6d93070905b3$var$testOnline && $882b6d93070905b3$var$project.readme) $882b6d93070905b3$var$localURL = 'https://LiaScript.github.io/course/?http://' + $882b6d93070905b3$var$hostname + ':' + $882b6d93070905b3$var$port + '/' + $882b6d93070905b3$var$project.readme;
|
|
190
|
+
$882b6d93070905b3$var$liascript();
|
|
191
|
+
|
|
192
|
+
const $882b6d93070905b3$var$server = $8zHUo$reloadshjs($882b6d93070905b3$var$app, $882b6d93070905b3$var$liveReload ? [
|
|
193
|
+
($parcel$interopDefault($8zHUo$path)).join($882b6d93070905b3$var$project.path, $882b6d93070905b3$var$project.readme || '')
|
|
194
|
+
] : []);
|
|
195
|
+
if ($882b6d93070905b3$var$liveReload) console.log(`β¨ watching for changes on: "${($parcel$interopDefault($8zHUo$path)).join($882b6d93070905b3$var$project.path, $882b6d93070905b3$var$project.readme || '')}"`);
|
|
196
|
+
$882b6d93070905b3$var$server.on('error', (e)=>{
|
|
197
|
+
console.error('π¨ error =>', e.message);
|
|
198
|
+
$8zHUo$process.exit();
|
|
199
|
+
});
|
|
200
|
+
$882b6d93070905b3$var$server.listen($882b6d93070905b3$var$port);
|
|
201
|
+
if ($882b6d93070905b3$var$openInBrowser) ($parcel$interopDefault($8zHUo$open))($882b6d93070905b3$var$localURL);
|
|
202
|
+
console.log('π‘ starting server');
|
|
203
|
+
console.log(` - local: ${$882b6d93070905b3$var$localURL}`);
|
|
204
|
+
console.log(` - on your network: ${$882b6d93070905b3$var$localURL.replace($882b6d93070905b3$var$localURL, $8zHUo$ip.address())}`);
|
|
205
|
+
console.log('β¨ hit Ctrl-c to close the server');
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;AAAA,oBAAwB,EAAE;AAE1B,MAAM,yBAAG,GAAG,wCAAO,EAAE;;;;AAOrB,MAAM,0BAAI,GAAG,eAAmB,CAAC,mBAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;;AAGvD,MAAM,mCAAa,GAAG,qCAAI,CAAC,OAAO,CAChC,qCAAI,CAAC,IAAI,+DAAkB,qCAAqC,CAAC,CAClE;AAED,MAAM,gCAAU,GAAG,qCAAI,CAAC,OAAO,CAC7B,qCAAI,CAAC,IAAI,+DAAkB,8CAA8C,CAAC,CAC3E;AAED,SAAS,+BAAS,GAAG;IACnB,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC;IACvD,OAAO,CAAC,GAAG,CAAC,4CAA4C,CAAC;IACzD,OAAO,CAAC,GAAG,CAAC,gDAAgD,CAAC;IAC7D,OAAO,CAAC,GAAG,CAAC,6CAA6C,CAAC;IAC1D,OAAO,CAAC,GAAG,CAAC,gDAAgD,CAAC;IAC7D,OAAO,CAAC,GAAG,CAAC,qCAAqC,CAAC;IAClD,OAAO,CAAC,GAAG,EAAE;CACd;AAED,IAAI,0BAAI,CAAC,CAAC,IAAI,0BAAI,CAAC,OAAO,EAAE;IAC1B,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;IAC/B,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;IAChC,mBAAY,EAAE;CACf;AAED,IAAI,0BAAI,CAAC,CAAC,IAAI,0BAAI,CAAC,IAAI,EAAE;IACvB,+BAAS,EAAE;IAEX,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC;IAC9C,OA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AAK;IAC7B,OAAO,CAAC,KAAK,CAAC,eAAY,EAAK,CAAC,CAAC,OAAO,CAAC;IACtC,mBAAS,EAAE;CACf,CAAC;AAEF,4BAAM,CAAC,MAAM,CAAC,0BAAI,CAAC;AAEnB,IAAI,mCAAa,EACf,qCAAM,CAAC,8BAAQ,CAAC;AAGlB,OAAO,CAAC,GAAG,CAAC,sBAAmB,CAAI;AAChC,OAAI,CAAC,GAAG,CAAC,CAAC,sBAAsB,EAAE,8BAAQ,CAAC,CAAC,CAAC;AAChD,OAAO,CAAC,GAAG,CAAC,CAAC,sBAAsB,EAAE,8BAAQ,CAAC,OAAO,CAAC,8BAAQ,EAAE,iBAAU,EAAE,CAAC,CAAC,CAAC,CAAC;AAChF,OAAO,CAAC,GAAG,CAAC,oCAAkC,CAAC","sources":["src/index.ts"],"sourcesContent":["require('dotenv').config()\nimport express from 'express'\nconst app = express()\nimport doOpen from 'open'\nimport fs from 'fs'\nimport path from 'path'\nconst cors = require('cors')\nconst handlebars = require('express-handlebars')\n\nconst argv = require('minimist')(process.argv.slice(2))\nconst ip = require('ip')\n\nconst liascriptPath = path.resolve(\n path.join(process.env.PWD, 'node_modules/@liascript/editor/dist')\n)\n\nconst reloadPath = path.resolve(\n path.join(process.env.PWD, 'node_modules/reloadsh.js/reloader.browser.js')\n)\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.5')\n console.log('LiaScript: 0.10.7')\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\nconst port = argv.p || argv.port || 3000\nconst hostname = argv.n || argv.hostname || 'localhost'\nconst openInBrowser = argv.o || argv.open\nconst input = argv.i || argv.input || '.'\nconst liveReload = argv.l || argv.live || false\nconst testOnline = argv.t || argv.test\n\nlet responsiveVoice: string | undefined\n\nif (argv.r || argv.responsiveVoice) {\n let active = argv.r || argv.responsiveVoice\n\n if (typeof active === 'string') {\n responsiveVoice = active\n } else {\n responsiveVoice = process.env.RESPONSIVE_VOICE_KEY\n }\n}\n\nvar project = {\n path: null,\n readme: null,\n}\n\nif (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\napp.set('view engine', 'hbs')\napp.engine(\n 'hbs',\n handlebars({\n layoutsDir: path.normalize(__dirname + '/../views/layouts'),\n defaultLayout: 'main',\n extname: 'hbs',\n })\n)\napp.set('views', path.normalize(__dirname + '/../views'))\n\napp.get('/', function (req, res) {\n res.redirect('/home')\n})\n\napp.get('/home*', function (req, res) {\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) => {\n return e[0] !== '.'\n })\n\n let basePath = '/home'\n let pathNames = req.params[0].split('/').filter((e) => {\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) => {\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((a, b) => {\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 } 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\napp.get('/liascript/', function (req, res) {\n res.redirect('/liascript/index.html')\n})\n\napp.get('/liascript/index.html', function (req, res) {\n // ------------------------------------\n if (liveReload && responsiveVoice) {\n fs.readFile(liascriptPath + '/index.html', 'utf8', function (err, data) {\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 else if (liveReload) {\n fs.readFile(liascriptPath + '/index.html', 'utf8', function (err, data) {\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 else if (responsiveVoice) {\n fs.readFile(liascriptPath + '/index.html', 'utf8', function (err, data) {\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 else {\n res.sendFile(liascriptPath + '/index.html')\n }\n})\n\n// load everything from the liascript folder\napp.get('/liascript/*', function (req, res) {\n res.sendFile(req.params[0], { root: liascriptPath })\n})\n// ignore this one\napp.get('/sw.js', function (req, res) {})\napp.get('/favicon.ico', function (req, res) {})\n\n// pass the reloader, to be used for live updates\napp.get('/reloader/reloader.js', function (req, res) {\n res.sendFile(reloadPath)\n})\n\n// everything else comes from the current project folder\napp.get('/*', cors(), function (req, res) {\n res.sendFile(req.originalUrl, { root: project.path })\n})\n\nlet localURL = 'http://' + hostname + ':' + port\n\nif (project.path && project.readme) {\n localURL +=\n '/liascript/index.html?http://' +\n hostname +\n ':' +\n port +\n '/' +\n project.readme\n}\n\nif (testOnline && project.readme) {\n localURL =\n 'https://LiaScript.github.io/course/?http://' +\n hostname +\n ':' +\n port +\n '/' +\n project.readme\n}\n\nliascript()\nconst server = require('reloadsh.js')(\n app,\n liveReload ? [path.join(project.path, project.readme || '')] : []\n)\n\nif (liveReload) {\n console.log(\n `β¨ watching for changes on: \"${path.join(\n project.path,\n project.readme || ''\n )}\"`\n )\n}\n\nserver.on('error', (e: any) => {\n console.error('π¨ error =>', e.message)\n process.exit()\n})\n\nserver.listen(port)\n\nif (openInBrowser) {\n doOpen(localURL)\n}\n\nconsole.log('π‘ starting server')\nconsole.log(` - local: ${localURL}`)\nconsole.log(` - on your network: ${localURL.replace(localURL, ip.address())}`)\nconsole.log('β¨ hit Ctrl-c to close the server')\n"],"names":[],"version":3,"file":"index.js.map"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@liascript/devserver",
|
|
3
|
-
"version": "1.0.5--0.10.
|
|
3
|
+
"version": "1.0.5--0.10.8",
|
|
4
4
|
"description": "Run a development server for LiaScript locally",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"build": "npx parcel build
|
|
7
|
+
"build": "npx parcel build src/index.ts && npm run shebang",
|
|
8
|
+
"shebang": "sed -i '1i #!/usr/bin/env node\\n' dist/index.js && chmod +x dist/index.js",
|
|
8
9
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
9
10
|
},
|
|
10
11
|
"repository": {
|
|
@@ -30,28 +31,19 @@
|
|
|
30
31
|
"author": "AndrΓ© Dietrich",
|
|
31
32
|
"license": "MIT",
|
|
32
33
|
"dependencies": {
|
|
33
|
-
"@liascript/editor": "^1.1.0--0.10.
|
|
34
|
+
"@liascript/editor": "^1.1.0--0.10.8",
|
|
34
35
|
"cors": "^2.8.5",
|
|
35
36
|
"dotenv": "^5.0.1",
|
|
36
|
-
"express": "^4.17.
|
|
37
|
-
"express-handlebars": "^5.
|
|
37
|
+
"express": "^4.17.3",
|
|
38
|
+
"express-handlebars": "^5.3.5",
|
|
38
39
|
"ip": "^1.1.5",
|
|
39
|
-
"minimist": "^1.2.
|
|
40
|
-
"open": "^7.4.
|
|
40
|
+
"minimist": "^1.2.6",
|
|
41
|
+
"open": "^7.4.2",
|
|
41
42
|
"reloadsh.js": "^2.2.1"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
44
45
|
"@types/express": "^4.17.11",
|
|
45
|
-
"parcel": "^
|
|
46
|
-
"
|
|
47
|
-
|
|
48
|
-
},
|
|
49
|
-
"shebang": [
|
|
50
|
-
{
|
|
51
|
-
"interpreter": "node",
|
|
52
|
-
"files": [
|
|
53
|
-
"src/index.ts"
|
|
54
|
-
]
|
|
55
|
-
}
|
|
56
|
-
]
|
|
46
|
+
"parcel": "^2.4.1",
|
|
47
|
+
"typescript": "^4.6.3"
|
|
48
|
+
}
|
|
57
49
|
}
|