feli 0.5.0
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 +63 -0
- package/dist/index.js +167 -0
- package/package.json +89 -0
package/README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
feli
|
|
2
|
+
====
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
Presentation
|
|
6
|
+
------------
|
|
7
|
+
|
|
8
|
+
*feli* is a javascript library for building a static web-server for installing and running locally your front-end web-app.
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
Requirements
|
|
12
|
+
------------
|
|
13
|
+
|
|
14
|
+
- [node](https://nodejs.org) > 22.0.0
|
|
15
|
+
- [npm](https://docs.npmjs.com/cli) > 11.0.0
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
Installation
|
|
19
|
+
------------
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm i -D feli
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
Getting started
|
|
27
|
+
---------------
|
|
28
|
+
|
|
29
|
+
```javascript
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Mini-server usage
|
|
35
|
+
-----------------
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npx myMiniServer
|
|
39
|
+
npx myMiniServer --help
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
Mini-server usage without installation
|
|
44
|
+
--------------------------------------
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
npx myMiniServer
|
|
48
|
+
npx --package=myMiniServerPkg myMiniServer
|
|
49
|
+
npx --package=myMiniServerPkg myMiniServer --help
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
Development
|
|
54
|
+
-----------
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
git clone https://github.com/charlyoleg2/feli_mono
|
|
58
|
+
cd feli_mono
|
|
59
|
+
npm install
|
|
60
|
+
npm run ci
|
|
61
|
+
npm -w feli run run
|
|
62
|
+
```
|
|
63
|
+
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/index.ts
|
|
4
|
+
import yargs from "yargs";
|
|
5
|
+
import { hideBin } from "yargs/helpers";
|
|
6
|
+
import fs from "fs";
|
|
7
|
+
import express from "express";
|
|
8
|
+
import open from "open";
|
|
9
|
+
import getport from "get-port";
|
|
10
|
+
|
|
11
|
+
// package.json
|
|
12
|
+
var package_default = {
|
|
13
|
+
name: "feli",
|
|
14
|
+
description: "library for making quickly your mini-server for your front-end only web-app",
|
|
15
|
+
version: "0.5.0",
|
|
16
|
+
private: false,
|
|
17
|
+
repository: {
|
|
18
|
+
type: "git",
|
|
19
|
+
url: "git+https://github.com/charlyoleg2/feli_mono.git"
|
|
20
|
+
},
|
|
21
|
+
homepage: "https://charlyoleg2.github.io/feli_mono/",
|
|
22
|
+
author: "charlyoleg",
|
|
23
|
+
license: "ISC",
|
|
24
|
+
keywords: [
|
|
25
|
+
"web-app",
|
|
26
|
+
"web-ui",
|
|
27
|
+
"front-end",
|
|
28
|
+
"local installation"
|
|
29
|
+
],
|
|
30
|
+
type: "module",
|
|
31
|
+
exports: {
|
|
32
|
+
".": {
|
|
33
|
+
types: "./dist/feli.d.ts",
|
|
34
|
+
default: "./dist/feli.js"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
files: [
|
|
38
|
+
"dist/",
|
|
39
|
+
"!dist/**/*.d.ts",
|
|
40
|
+
"!dist/**/*.map",
|
|
41
|
+
"!dist/**/*.test.*",
|
|
42
|
+
"!dist/**/*.spec.*"
|
|
43
|
+
],
|
|
44
|
+
engines: {
|
|
45
|
+
node: ">=22.0.0"
|
|
46
|
+
},
|
|
47
|
+
tsup: {
|
|
48
|
+
entry: [
|
|
49
|
+
"src/index.ts"
|
|
50
|
+
],
|
|
51
|
+
format: "esm",
|
|
52
|
+
splitting: false,
|
|
53
|
+
dts: true,
|
|
54
|
+
sourcemap: true,
|
|
55
|
+
clean: true
|
|
56
|
+
},
|
|
57
|
+
prettier: {
|
|
58
|
+
useTabs: true,
|
|
59
|
+
singleQuote: true,
|
|
60
|
+
trailingComma: "none",
|
|
61
|
+
printWidth: 100,
|
|
62
|
+
plugins: [],
|
|
63
|
+
overrides: []
|
|
64
|
+
},
|
|
65
|
+
scripts: {
|
|
66
|
+
dev: "tsup --watch",
|
|
67
|
+
build: "tsup",
|
|
68
|
+
check: "tsc --noEmit",
|
|
69
|
+
pretty: "prettier --check .",
|
|
70
|
+
format: "prettier --write .",
|
|
71
|
+
lint: "eslint .",
|
|
72
|
+
"test:unit": "vitest",
|
|
73
|
+
"test:unit:once": "vitest --run",
|
|
74
|
+
ci: "run-s check build pretty lint test:unit:once",
|
|
75
|
+
clean: "rimraf node_modules build dist tmp"
|
|
76
|
+
},
|
|
77
|
+
dependencies: {
|
|
78
|
+
express: "^5.1.0",
|
|
79
|
+
"fs-extra": "^11.3.0",
|
|
80
|
+
"get-port": "^7.1.0",
|
|
81
|
+
open: "^10.1.2",
|
|
82
|
+
yargs: "^18.0.0"
|
|
83
|
+
},
|
|
84
|
+
devDependencies: {
|
|
85
|
+
"@eslint/js": "^9.10.0",
|
|
86
|
+
"@types/eslint__js": "^8.42.3",
|
|
87
|
+
"@types/express": "^5.0.3",
|
|
88
|
+
"@types/fs-extra": "^11.0.4",
|
|
89
|
+
"@types/yargs": "^17.0.33",
|
|
90
|
+
eslint: "^9.29.0",
|
|
91
|
+
"eslint-config-prettier": "^10.1.5",
|
|
92
|
+
"npm-run-all2": "^8.0.4",
|
|
93
|
+
prettier: "^3.6.0",
|
|
94
|
+
rimraf: "^6.0.1",
|
|
95
|
+
tsup: "^8.5.0",
|
|
96
|
+
typescript: "^5.8.3",
|
|
97
|
+
"typescript-eslint": "^8.35.0",
|
|
98
|
+
vitest: "^3.2.4"
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// src/index.ts
|
|
103
|
+
function sleep(ms) {
|
|
104
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
105
|
+
}
|
|
106
|
+
async function mini_server(aDirectory, aBrowser, aPort) {
|
|
107
|
+
const chost = "127.0.0.1";
|
|
108
|
+
if (aDirectory !== "") {
|
|
109
|
+
if (!fs.existsSync(aDirectory)) {
|
|
110
|
+
const eMsg = `ERR339: Error, the path ${aDirectory} doesn't exist!`;
|
|
111
|
+
throw eMsg;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
let portnumber = aPort;
|
|
115
|
+
if (portnumber === 0) {
|
|
116
|
+
portnumber = await getport();
|
|
117
|
+
}
|
|
118
|
+
const app = express();
|
|
119
|
+
if (aDirectory !== "") {
|
|
120
|
+
app.use(express.static(aDirectory));
|
|
121
|
+
}
|
|
122
|
+
app.listen(portnumber, chost, () => {
|
|
123
|
+
console.log(
|
|
124
|
+
`${package_default.name} serves on port ${portnumber} for host ${chost} the directory:
|
|
125
|
+
${aDirectory} ...`
|
|
126
|
+
);
|
|
127
|
+
});
|
|
128
|
+
await sleep(1e3);
|
|
129
|
+
const url = `http://localhost:${portnumber}`;
|
|
130
|
+
if (aBrowser) {
|
|
131
|
+
console.log(`Your browser should open automatically at ${url}`);
|
|
132
|
+
await open(url);
|
|
133
|
+
} else {
|
|
134
|
+
console.log(`Please, open the browser at ${url}`);
|
|
135
|
+
}
|
|
136
|
+
console.log("Press ctrl-c to stop this http-server ...");
|
|
137
|
+
}
|
|
138
|
+
async function feli_cli(defaultPublicDir, argv) {
|
|
139
|
+
const args = await yargs(hideBin(argv)).version(package_default.version).usage("Usage: $0 --port <port> --directoy <directory-path>").example([
|
|
140
|
+
[
|
|
141
|
+
"$0 -p 2022 -d MyPublic",
|
|
142
|
+
"run the webserver on port 2022 and serve the content of the folder MyPublic"
|
|
143
|
+
]
|
|
144
|
+
]).option("directory", {
|
|
145
|
+
alias: "d",
|
|
146
|
+
type: "string",
|
|
147
|
+
description: "path to the directory to be served.",
|
|
148
|
+
//default: `${__dirname}/webui`,
|
|
149
|
+
//default: `${scrDir}/public`
|
|
150
|
+
default: defaultPublicDir
|
|
151
|
+
}).option("browser", {
|
|
152
|
+
alias: "b",
|
|
153
|
+
type: "boolean",
|
|
154
|
+
description: "Open the browser at the corresponding URL.",
|
|
155
|
+
default: true
|
|
156
|
+
}).option("port", {
|
|
157
|
+
alias: "p",
|
|
158
|
+
type: "number",
|
|
159
|
+
description: "port-number used by this web-server. If set to 0 an available port-number is automatically selected",
|
|
160
|
+
default: 0
|
|
161
|
+
}).strict().parseAsync();
|
|
162
|
+
await mini_server(args.directory, args.browser, args.port);
|
|
163
|
+
}
|
|
164
|
+
export {
|
|
165
|
+
feli_cli
|
|
166
|
+
};
|
|
167
|
+
//# sourceMappingURL=index.js.map
|
package/package.json
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "feli",
|
|
3
|
+
"description": "library for making quickly your mini-server for your front-end only web-app",
|
|
4
|
+
"version": "0.5.0",
|
|
5
|
+
"private": false,
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/charlyoleg2/feli_mono.git"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://charlyoleg2.github.io/feli_mono/",
|
|
11
|
+
"author": "charlyoleg",
|
|
12
|
+
"license": "ISC",
|
|
13
|
+
"keywords": [
|
|
14
|
+
"web-app",
|
|
15
|
+
"web-ui",
|
|
16
|
+
"front-end",
|
|
17
|
+
"local installation"
|
|
18
|
+
],
|
|
19
|
+
"type": "module",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/feli.d.ts",
|
|
23
|
+
"default": "./dist/feli.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist/",
|
|
28
|
+
"!dist/**/*.d.ts",
|
|
29
|
+
"!dist/**/*.map",
|
|
30
|
+
"!dist/**/*.test.*",
|
|
31
|
+
"!dist/**/*.spec.*"
|
|
32
|
+
],
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=22.0.0"
|
|
35
|
+
},
|
|
36
|
+
"tsup": {
|
|
37
|
+
"entry": [
|
|
38
|
+
"src/index.ts"
|
|
39
|
+
],
|
|
40
|
+
"format": "esm",
|
|
41
|
+
"splitting": false,
|
|
42
|
+
"dts": true,
|
|
43
|
+
"sourcemap": true,
|
|
44
|
+
"clean": true
|
|
45
|
+
},
|
|
46
|
+
"prettier": {
|
|
47
|
+
"useTabs": true,
|
|
48
|
+
"singleQuote": true,
|
|
49
|
+
"trailingComma": "none",
|
|
50
|
+
"printWidth": 100,
|
|
51
|
+
"plugins": [],
|
|
52
|
+
"overrides": []
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"dev": "tsup --watch",
|
|
56
|
+
"build": "tsup",
|
|
57
|
+
"check": "tsc --noEmit",
|
|
58
|
+
"pretty": "prettier --check .",
|
|
59
|
+
"format": "prettier --write .",
|
|
60
|
+
"lint": "eslint .",
|
|
61
|
+
"test:unit": "vitest",
|
|
62
|
+
"test:unit:once": "vitest --run",
|
|
63
|
+
"ci": "run-s check build pretty lint test:unit:once",
|
|
64
|
+
"clean": "rimraf node_modules build dist tmp"
|
|
65
|
+
},
|
|
66
|
+
"dependencies": {
|
|
67
|
+
"express": "^5.1.0",
|
|
68
|
+
"fs-extra": "^11.3.0",
|
|
69
|
+
"get-port": "^7.1.0",
|
|
70
|
+
"open": "^10.1.2",
|
|
71
|
+
"yargs": "^18.0.0"
|
|
72
|
+
},
|
|
73
|
+
"devDependencies": {
|
|
74
|
+
"@eslint/js": "^9.10.0",
|
|
75
|
+
"@types/eslint__js": "^8.42.3",
|
|
76
|
+
"@types/express": "^5.0.3",
|
|
77
|
+
"@types/fs-extra": "^11.0.4",
|
|
78
|
+
"@types/yargs": "^17.0.33",
|
|
79
|
+
"eslint": "^9.29.0",
|
|
80
|
+
"eslint-config-prettier": "^10.1.5",
|
|
81
|
+
"npm-run-all2": "^8.0.4",
|
|
82
|
+
"prettier": "^3.6.0",
|
|
83
|
+
"rimraf": "^6.0.1",
|
|
84
|
+
"tsup": "^8.5.0",
|
|
85
|
+
"typescript": "^5.8.3",
|
|
86
|
+
"typescript-eslint": "^8.35.0",
|
|
87
|
+
"vitest": "^3.2.4"
|
|
88
|
+
}
|
|
89
|
+
}
|