@pasmurno/serve 0.0.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 pasmurno by llcawc (github.com/llcawc)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9
+ of the Software, and to permit persons to whom the Software is furnished to do
10
+ so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,84 @@
1
+ # @pasmurno/serve
2
+
3
+ simple static server for local development based [Vite](https://vite.dev/)
4
+
5
+ ## Getting started
6
+
7
+ Install the @pasmurno/serve as global package:
8
+
9
+ ```sh
10
+ npm install -g @pasmurno/serve
11
+ ```
12
+
13
+ or install local in project:
14
+
15
+ ```sh
16
+ npm install --save-dev @pasmurno/serve
17
+ ```
18
+
19
+ ## Commands
20
+
21
+ Usage for global install:
22
+
23
+ ```sh
24
+ $ serve [options]
25
+ ```
26
+
27
+ Usage for install in project:
28
+
29
+ ```sh
30
+ $ npx serve [options]
31
+ ```
32
+
33
+ Use in package.json scripts:
34
+
35
+ ```json
36
+ "scripts": {
37
+ "serve": "serve [options]"
38
+ }
39
+ ```
40
+
41
+ and start this:
42
+
43
+ ```sh
44
+ $ npm run serve
45
+ ```
46
+
47
+ ## Options:
48
+
49
+ ```
50
+ -v, --version output the current version
51
+ -p, --port <n> server port number (default: 3000)
52
+ -d, --dist [value] folder for serve files (default: dist)
53
+ -h, --help display help for command
54
+ ```
55
+
56
+ ## Example call:
57
+
58
+ ```sh
59
+ $ serve -p 4200 -d build
60
+ ...
61
+ $ npx serve --port 8000 --dist './static'
62
+ ```
63
+
64
+ API / Gulp
65
+ You can programmatically start the local server if you import the server() function from the @pasmurno/serve package:
66
+
67
+ ```js
68
+ import server from "@pasmurno/serve";
69
+
70
+ async function browse() {
71
+ await server({
72
+ port: 8080, // server port number (default: 3000)
73
+ dist: "dist", // folder for serve files (default: dist)
74
+ });
75
+ }
76
+ ```
77
+
78
+ The best way to apply this can be found in the gulp project assignment.
79
+
80
+ ---
81
+
82
+ ## License
83
+
84
+ MIT ©2025 pasmurno by [llcawc](https://github.com/llcawc). Made with ❤ to beautiful architecture
package/bin/serve.js ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import '../server/comm.js'
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@pasmurno/serve",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "bin": {
6
+ "serve": "bin/serve.js"
7
+ },
8
+ "main": "./server/index.js",
9
+ "exports": "./server/index.js",
10
+ "files": [
11
+ "bin",
12
+ "server",
13
+ "package.json",
14
+ "LICENSE",
15
+ "README.md"
16
+ ],
17
+ "author": "llcawc",
18
+ "license": "MIT",
19
+ "homepage": "https://github.com/llcawc/serve",
20
+ "description": "Vite based static server for local development",
21
+ "scripts": {
22
+ "tsc": "tsc",
23
+ "make": "nodemon -e ts -x tsc -w ./source",
24
+ "dev": "vite",
25
+ "serve": "npx serve -p 8080",
26
+ "build": "vite build"
27
+ },
28
+ "devDependencies": {
29
+ "@types/node": "^24.3.0",
30
+ "gulp": "^5.0.1",
31
+ "nodemon": "^3.1.10",
32
+ "prettier": "^3.6.2",
33
+ "prettier-plugin-embed": "^0.5.0",
34
+ "prettier-plugin-organize-imports": "^4.2.0",
35
+ "sass": "^1.90.0",
36
+ "typescript": "^5.9.2"
37
+ },
38
+ "dependencies": {
39
+ "commander": "^14.0.0",
40
+ "vite": "^7.1.3"
41
+ }
42
+ }
@@ -0,0 +1 @@
1
+ export {};
package/server/comm.js ADDED
@@ -0,0 +1,19 @@
1
+ import { Command } from 'commander';
2
+ import serve from './viteview.js';
3
+ const program = new Command();
4
+ const header = '\n• Vite based live server for static files\n @pasmurno/serve v.0.0.1\n';
5
+ const footer = '\nMIT License ©2025 pasmurno by llcawc. Made with ❤ to beautiful architecture.';
6
+ const example = '\nExample call:\n' +
7
+ ' • $ serve // global use, default port: 3000, default folder: "dist"\n' +
8
+ ' • $ serve -p 4200 -d build\n' +
9
+ ' • $ npx serve --port 8000 --dist "./static" // for local use';
10
+ program.name('$ serve').usage('[options]');
11
+ program.version('v.0.0.1', '-v, --version', 'output the current version');
12
+ program.addHelpText('before', header).addHelpText('after', example).addHelpText('afterAll', footer);
13
+ program
14
+ .option('-p, --port <n>', 'server port number (default: 8080)')
15
+ .option('-d, --dist [value]', 'folder for serve files (default: dist)')
16
+ .action((opt) => {
17
+ serve(opt.port, opt.dist);
18
+ });
19
+ program.parse(process.argv);
@@ -0,0 +1,2 @@
1
+ import server from './viteview.js';
2
+ export default server;
@@ -0,0 +1,2 @@
1
+ import server from './viteview.js';
2
+ export default server;
@@ -0,0 +1 @@
1
+ export default function server(port?: number | undefined, dist?: string | undefined): Promise<void>;
@@ -0,0 +1,26 @@
1
+ import { join, resolve } from 'node:path';
2
+ import { preview } from 'vite';
3
+ const __dirname = resolve();
4
+ export default async function server(port = 3000, dist = undefined) {
5
+ if (dist) {
6
+ dist = resolve(__dirname, dist);
7
+ }
8
+ else {
9
+ dist = join(__dirname, 'dist');
10
+ }
11
+ const previewServer = await preview({
12
+ // any valid user config options, plus `mode` and `configFile`
13
+ mode: 'development',
14
+ build: {
15
+ outDir: dist,
16
+ },
17
+ preview: {
18
+ port,
19
+ open: false,
20
+ },
21
+ });
22
+ // Root log
23
+ console.log(' ➜ Root: ', dist);
24
+ previewServer.printUrls();
25
+ previewServer.bindCLIShortcuts({ print: true });
26
+ }