elegance-js 1.6.1 → 1.6.4

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.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) {
@@ -301,10 +301,6 @@ var runBuild = (filepath, DIST_DIR) => {
301
301
  options.postCompile();
302
302
  }
303
303
  }
304
- console.log("Received message from child", data);
305
- });
306
- child.on("exit", (code2, signal) => {
307
- console.error(`Child process exited with code ${code2} or signal ${signal}`);
308
304
  });
309
305
  };
310
306
  var build = (DIST_DIR) => {
@@ -346,7 +342,7 @@ var compile = async (props) => {
346
342
  const watch = options.hotReload !== void 0;
347
343
  const BUILD_FLAG = path.join(options.outputDirectory, "ELEGANCE_BUILD_FLAG");
348
344
  if (!fs2.existsSync(options.outputDirectory)) {
349
- fs2.mkdirSync(options.outputDirectory);
345
+ fs2.mkdirSync(options.outputDirectory, { recursive: true });
350
346
  fs2.writeFileSync(
351
347
  path.join(BUILD_FLAG),
352
348
  "This file just marks this directory as one containing an Elegance Build.",
@@ -359,14 +355,15 @@ var compile = async (props) => {
359
355
  }
360
356
  const DIST_DIR = path.join(props.outputDirectory, "dist");
361
357
  if (!fs2.existsSync(DIST_DIR)) {
362
- fs2.mkdirSync(DIST_DIR);
358
+ fs2.mkdirSync(DIST_DIR, { recursive: true });
363
359
  }
364
360
  if (props.server != void 0 && props.server.runServer == true) {
365
361
  startServer({
366
362
  root: props.server.root ?? DIST_DIR,
367
363
  environment: props.environment,
368
364
  port: props.server.port ?? 3e3,
369
- host: props.server.host ?? "localhost"
365
+ host: props.server.host ?? "localhost",
366
+ quiet: options.quiet
370
367
  });
371
368
  }
372
369
  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) {
@@ -304,10 +304,6 @@ var runBuild = (filepath, DIST_DIR) => {
304
304
  options.postCompile();
305
305
  }
306
306
  }
307
- console.log("Received message from child", data);
308
- });
309
- child.on("exit", (code2, signal) => {
310
- console.error(`Child process exited with code ${code2} or signal ${signal}`);
311
307
  });
312
308
  };
313
309
  var build = (DIST_DIR) => {
@@ -349,7 +345,7 @@ var compile = async (props) => {
349
345
  const watch = options.hotReload !== void 0;
350
346
  const BUILD_FLAG = path.join(options.outputDirectory, "ELEGANCE_BUILD_FLAG");
351
347
  if (!fs2.existsSync(options.outputDirectory)) {
352
- fs2.mkdirSync(options.outputDirectory);
348
+ fs2.mkdirSync(options.outputDirectory, { recursive: true });
353
349
  fs2.writeFileSync(
354
350
  path.join(BUILD_FLAG),
355
351
  "This file just marks this directory as one containing an Elegance Build.",
@@ -362,14 +358,15 @@ var compile = async (props) => {
362
358
  }
363
359
  const DIST_DIR = path.join(props.outputDirectory, "dist");
364
360
  if (!fs2.existsSync(DIST_DIR)) {
365
- fs2.mkdirSync(DIST_DIR);
361
+ fs2.mkdirSync(DIST_DIR, { recursive: true });
366
362
  }
367
363
  if (props.server != void 0 && props.server.runServer == true) {
368
364
  startServer({
369
365
  root: props.server.root ?? DIST_DIR,
370
366
  environment: props.environment,
371
367
  port: props.server.port ?? 3e3,
372
- host: props.server.host ?? "localhost"
368
+ host: props.server.host ?? "localhost",
369
+ quiet: options.quiet
373
370
  });
374
371
  }
375
372
  if (watch) {
@@ -426,7 +423,8 @@ compile({
426
423
  } : void 0,
427
424
  server: {
428
425
  runServer: environment === "development"
429
- }
426
+ },
427
+ quiet: true
430
428
  }).then(() => {
431
429
  if (environment === "production") {
432
430
  execSync(`npx @tailwindcss/cli -i ${PAGES_DIR}/index.css -o ${OUTPUT_DIR}/dist/index.css --minify`);
@@ -287,6 +287,7 @@ var green = (text) => {
287
287
  return `\x1B[38;2;65;224;108m${text}`;
288
288
  };
289
289
  var log = (...text) => {
290
+ if (options.quiet) return;
290
291
  return console.log(text.map((text2) => `${text2}\x1B[0m`).join(""));
291
292
  };
292
293
  var options = JSON.parse(process.env.OPTIONS);
@@ -702,7 +703,7 @@ var build = async () => {
702
703
  continue;
703
704
  }
704
705
  fs.rmdirSync(dir, { recursive: true });
705
- console.log("Deleted old page directory:", dir);
706
+ log("Deleted old page directory:", dir);
706
707
  }
707
708
  }
708
709
  }
@@ -785,7 +786,7 @@ var build = async () => {
785
786
  await buildClient(DIST_DIR);
786
787
  const end = performance.now();
787
788
  if (options.publicDirectory) {
788
- console.log("Recursively copying public directory.. this may take a while.");
789
+ log("Recursively copying public directory.. this may take a while.");
789
790
  const src = path.relative(process.cwd(), options.publicDirectory.path);
790
791
  await fs.promises.cp(src, path.join(DIST_DIR), { recursive: true });
791
792
  }
@@ -795,7 +796,7 @@ var build = async () => {
795
796
  log(`${Math.round(end - pagesBuilt)}ms to Build Client`);
796
797
  log(green(bold(`Compiled ${pageFiles.length} pages in ${Math.ceil(end - start)}ms!`)));
797
798
  for (const pageFile of pageFiles) {
798
- console.log(
799
+ log(
799
800
  "- /" + path.relative(options.pagesDirectory, pageFile.parentPath),
800
801
  "(Page)"
801
802
  );
@@ -806,10 +807,10 @@ var build = async () => {
806
807
  }
807
808
  process.send({ event: "message", data: "compile-finish" });
808
809
  if (shouldClientHardReload) {
809
- console.log("Sending hard reload..");
810
+ log("Sending hard reload..");
810
811
  process.send({ event: "message", data: "hard-reload" });
811
812
  } else {
812
- console.log("Sending soft reload..");
813
+ log("Sending soft reload..");
813
814
  process.send({ event: "message", data: "soft-reload" });
814
815
  }
815
816
  } catch (e) {
@@ -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.1",
3
+ "version": "1.6.4",
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
  })