elegance-js 1.6.0 → 1.6.3

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/dist/build.d.ts CHANGED
@@ -4,6 +4,7 @@ type CompilationOptions = {
4
4
  environment: "production" | "development";
5
5
  pagesDirectory: string;
6
6
  outputDirectory: string;
7
+ quiet?: boolean;
7
8
  publicDirectory?: {
8
9
  path: string;
9
10
  method: "symlink" | "recursive-copy";
package/dist/build.mjs CHANGED
@@ -23,7 +23,7 @@ var MIME_TYPES = {
23
23
  ".ico": "image/x-icon",
24
24
  ".txt": "text/plain; charset=utf-8"
25
25
  };
26
- function startServer({ root, port = 3e3, host = "localhost", environment = "production" }) {
26
+ function startServer({ root, port = 3e3, host = "localhost", environment = "production", quiet = false }) {
27
27
  if (!root) throw new Error("Root directory must be specified.");
28
28
  const requestHandler = async (req, res) => {
29
29
  try {
@@ -38,7 +38,7 @@ function startServer({ root, port = 3e3, host = "localhost", environment = "prod
38
38
  if (req.method === "OPTIONS") {
39
39
  res.writeHead(204);
40
40
  res.end();
41
- if (environment === "development") {
41
+ if (environment === "development" && quiet === false) {
42
42
  console.log(req.method, "::", req.url, "-", res.statusCode);
43
43
  }
44
44
  return;
@@ -49,7 +49,7 @@ function startServer({ root, port = 3e3, host = "localhost", environment = "prod
49
49
  } else {
50
50
  await handleStaticRequest(root, url.pathname, res);
51
51
  }
52
- if (environment === "development") {
52
+ if (environment === "development" && quiet === false) {
53
53
  console.log(req.method, "::", req.url, "-", res.statusCode);
54
54
  }
55
55
  } catch (err) {
@@ -256,6 +256,7 @@ var green = (text) => {
256
256
  return `\x1B[38;2;65;224;108m${text}`;
257
257
  };
258
258
  var log = (...text) => {
259
+ if (options.quiet === true) return;
259
260
  return console.log(text.map((text2) => `${text2}\x1B[0m`).join(""));
260
261
  };
261
262
  var options = process.env.OPTIONS;
@@ -345,7 +346,7 @@ var compile = async (props) => {
345
346
  const watch = options.hotReload !== void 0;
346
347
  const BUILD_FLAG = path.join(options.outputDirectory, "ELEGANCE_BUILD_FLAG");
347
348
  if (!fs2.existsSync(options.outputDirectory)) {
348
- fs2.mkdirSync(options.outputDirectory);
349
+ fs2.mkdirSync(options.outputDirectory, { recursive: true });
349
350
  fs2.writeFileSync(
350
351
  path.join(BUILD_FLAG),
351
352
  "This file just marks this directory as one containing an Elegance Build.",
@@ -358,14 +359,15 @@ var compile = async (props) => {
358
359
  }
359
360
  const DIST_DIR = path.join(props.outputDirectory, "dist");
360
361
  if (!fs2.existsSync(DIST_DIR)) {
361
- fs2.mkdirSync(DIST_DIR);
362
+ fs2.mkdirSync(DIST_DIR, { recursive: true });
362
363
  }
363
364
  if (props.server != void 0 && props.server.runServer == true) {
364
365
  startServer({
365
366
  root: props.server.root ?? DIST_DIR,
366
367
  environment: props.environment,
367
368
  port: props.server.port ?? 3e3,
368
- host: props.server.host ?? "localhost"
369
+ host: props.server.host ?? "localhost",
370
+ quiet: options.quiet
369
371
  });
370
372
  }
371
373
  if (watch) {
@@ -26,7 +26,7 @@ var MIME_TYPES = {
26
26
  ".ico": "image/x-icon",
27
27
  ".txt": "text/plain; charset=utf-8"
28
28
  };
29
- function startServer({ root, port = 3e3, host = "localhost", environment: environment2 = "production" }) {
29
+ function startServer({ root, port = 3e3, host = "localhost", environment: environment2 = "production", quiet = false }) {
30
30
  if (!root) throw new Error("Root directory must be specified.");
31
31
  const requestHandler = async (req, res) => {
32
32
  try {
@@ -41,7 +41,7 @@ function startServer({ root, port = 3e3, host = "localhost", environment: enviro
41
41
  if (req.method === "OPTIONS") {
42
42
  res.writeHead(204);
43
43
  res.end();
44
- if (environment2 === "development") {
44
+ if (environment2 === "development" && quiet === false) {
45
45
  console.log(req.method, "::", req.url, "-", res.statusCode);
46
46
  }
47
47
  return;
@@ -52,7 +52,7 @@ function startServer({ root, port = 3e3, host = "localhost", environment: enviro
52
52
  } else {
53
53
  await handleStaticRequest(root, url.pathname, res);
54
54
  }
55
- if (environment2 === "development") {
55
+ if (environment2 === "development" && quiet === false) {
56
56
  console.log(req.method, "::", req.url, "-", res.statusCode);
57
57
  }
58
58
  } catch (err) {
@@ -259,6 +259,7 @@ var green = (text) => {
259
259
  return `\x1B[38;2;65;224;108m${text}`;
260
260
  };
261
261
  var log = (...text) => {
262
+ if (options.quiet === true) return;
262
263
  return console.log(text.map((text2) => `${text2}\x1B[0m`).join(""));
263
264
  };
264
265
  var options = process.env.OPTIONS;
@@ -348,7 +349,7 @@ var compile = async (props) => {
348
349
  const watch = options.hotReload !== void 0;
349
350
  const BUILD_FLAG = path.join(options.outputDirectory, "ELEGANCE_BUILD_FLAG");
350
351
  if (!fs2.existsSync(options.outputDirectory)) {
351
- fs2.mkdirSync(options.outputDirectory);
352
+ fs2.mkdirSync(options.outputDirectory, { recursive: true });
352
353
  fs2.writeFileSync(
353
354
  path.join(BUILD_FLAG),
354
355
  "This file just marks this directory as one containing an Elegance Build.",
@@ -361,14 +362,15 @@ var compile = async (props) => {
361
362
  }
362
363
  const DIST_DIR = path.join(props.outputDirectory, "dist");
363
364
  if (!fs2.existsSync(DIST_DIR)) {
364
- fs2.mkdirSync(DIST_DIR);
365
+ fs2.mkdirSync(DIST_DIR, { recursive: true });
365
366
  }
366
367
  if (props.server != void 0 && props.server.runServer == true) {
367
368
  startServer({
368
369
  root: props.server.root ?? DIST_DIR,
369
370
  environment: props.environment,
370
371
  port: props.server.port ?? 3e3,
371
- host: props.server.host ?? "localhost"
372
+ host: props.server.host ?? "localhost",
373
+ quiet: options.quiet
372
374
  });
373
375
  }
374
376
  if (watch) {
@@ -4,6 +4,7 @@ interface ServerOptions {
4
4
  port?: number;
5
5
  host?: string;
6
6
  environment?: 'production' | 'development';
7
+ quiet?: boolean;
7
8
  }
8
- export declare function startServer({ root, port, host, environment }: ServerOptions): import("http").Server<typeof IncomingMessage, typeof ServerResponse>;
9
+ export declare function startServer({ root, port, host, environment, quiet, }: ServerOptions): import("http").Server<typeof IncomingMessage, typeof ServerResponse>;
9
10
  export {};
@@ -16,7 +16,7 @@ var MIME_TYPES = {
16
16
  ".ico": "image/x-icon",
17
17
  ".txt": "text/plain; charset=utf-8"
18
18
  };
19
- function startServer({ root, port = 3e3, host = "localhost", environment = "production" }) {
19
+ function startServer({ root, port = 3e3, host = "localhost", environment = "production", quiet = false }) {
20
20
  if (!root) throw new Error("Root directory must be specified.");
21
21
  const requestHandler = async (req, res) => {
22
22
  try {
@@ -31,7 +31,7 @@ function startServer({ root, port = 3e3, host = "localhost", environment = "prod
31
31
  if (req.method === "OPTIONS") {
32
32
  res.writeHead(204);
33
33
  res.end();
34
- if (environment === "development") {
34
+ if (environment === "development" && quiet === false) {
35
35
  console.log(req.method, "::", req.url, "-", res.statusCode);
36
36
  }
37
37
  return;
@@ -42,7 +42,7 @@ function startServer({ root, port = 3e3, host = "localhost", environment = "prod
42
42
  } else {
43
43
  await handleStaticRequest(root, url.pathname, res);
44
44
  }
45
- if (environment === "development") {
45
+ if (environment === "development" && quiet === false) {
46
46
  console.log(req.method, "::", req.url, "-", res.statusCode);
47
47
  }
48
48
  } catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "elegance-js",
3
- "version": "1.6.0",
3
+ "version": "1.6.3",
4
4
  "description": "Web-Framework",
5
5
  "type": "module",
6
6
  "bin": {
@@ -5,7 +5,7 @@ import path from "path";
5
5
 
6
6
  import { execSync } from "node:child_process";
7
7
 
8
- execSync("npm install tailwindcss");
8
+ execSync("npm install tailwindcss @tailwindcss/cli");
9
9
 
10
10
  const dirs = ["pages", "public"];
11
11
  dirs.forEach((dir) => {
package/scripts/dev.js CHANGED
@@ -20,6 +20,6 @@ compile({
20
20
  port: 3000,
21
21
  },
22
22
  postCompile: () => {
23
- exec("npx @tailwindcss/cli -i ./pages/index.css -o .elegance/dist/index.css --watch")
23
+ exec("npx @tailwindcss/cli -i \"./pages/index.css\" -o \".elegance/dist/index.css\" --cwd \"./pages\" --watch")
24
24
  },
25
25
  })
package/scripts/export.js CHANGED
@@ -15,6 +15,6 @@ compile({
15
15
  runServer: false,
16
16
  },
17
17
  postCompile: () => {
18
- exec("npx @tailwindcss/cli -i ./pages/index.css -o .elegance/dist/index.css --minify=true")
18
+ exec("npx @tailwindcss/cli -i \"./pages/index.css\" -o \".elegance/dist/index.css\" --cwd \"./pages\" --minify=true")
19
19
  },
20
20
  })
package/scripts/prod.js CHANGED
@@ -16,6 +16,6 @@ compile({
16
16
  port: 3000,
17
17
  },
18
18
  postCompile: () => {
19
- exec("npx @tailwindcss/cli -i ./pages/index.css -o .elegance/dist/index.css --minify=true")
19
+ exec("npx @tailwindcss/cli -i \"./pages/index.css\" -o \".elegance/dist/index.css\" --cwd \"./pages\" --minidy=true")
20
20
  },
21
21
  })