highmark-cli 0.0.149 → 0.0.152

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.
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  const htmlOperation = require("../operation/html"),
4
+ watchOperation = require("../operation/watch"),
4
5
  serverOperation = require("../operation/server"),
5
6
  copyFontsOperation = require("../operation/copyFonts"),
6
7
  copyClientOperation = require("../operation/copyClient"),
@@ -19,7 +20,8 @@ function publishAction(port, watch, server, quietly, copyFonts, copyClient, inpu
19
20
  copyClientOperation,
20
21
  copyFontsOperation,
21
22
  htmlOperation,
22
- serverOperation
23
+ serverOperation,
24
+ watchOperation
23
25
  ],
24
26
  context = {
25
27
  port,
@@ -1,13 +1,15 @@
1
1
  "use strict";
2
2
 
3
- const serverOperation = require("../operation/server");
3
+ const watchOperation = require("../operation/watch"),
4
+ serverOperation = require("../operation/server");
4
5
 
5
6
  const { executeOperations } = require("../utilities/operation"),
6
7
  { SUCCESSFUL_SERVER_MESSAGE, FAILED_SERVER_MESSAGE } = require("../messages");
7
8
 
8
9
  function serverAction(port, watch, server, quietly, outputFilePath) {
9
10
  const operations = [
10
- serverOperation
11
+ serverOperation,
12
+ watchOperation
11
13
  ],
12
14
  context = {
13
15
  port,
@@ -1,14 +1,9 @@
1
1
  "use strict";
2
2
 
3
- const { watch: watchFile } = require("lively-cli"),
4
- { pathUtilities, packageUtilities } = require("necessary");
3
+ const { watch: watchFile } = require("lively-cli");
5
4
 
6
- const { copyFile } = require("../utilities/fileSystem"),
7
- { directoryPathFromFilePath } = require("../utilities/path"),
8
- { DEFER_DELAY, CLIENT_FILE_NAME } = require("../constants");
9
-
10
- const { getPackagePath } = packageUtilities,
11
- { concatenatePaths } = pathUtilities;
5
+ const { DEFER_DELAY } = require("../constants"),
6
+ { copyClientFile: copyClientFileEx, getClientSourceFilePath } = require("../utilities/client");
12
7
 
13
8
  function copyClientOperation(proceed, abort, context) {
14
9
  const { copyClient } = context;
@@ -19,31 +14,27 @@ function copyClientOperation(proceed, abort, context) {
19
14
  return;
20
15
  }
21
16
 
22
- const { outputFilePath } = context,
23
- packagePath = getPackagePath(),
24
- outputDirectoryPath = directoryPathFromFilePath(outputFilePath),
25
- sourceFilePath = concatenatePaths(packagePath, CLIENT_FILE_NAME),
26
- targetFilePath = concatenatePaths(outputDirectoryPath, CLIENT_FILE_NAME);
27
-
28
- copyFile(sourceFilePath, targetFilePath);
17
+ copyClientFile();
29
18
 
30
- const { watch } = context;
19
+ let { server } = context;
31
20
 
32
- if (!watch) {
21
+ if (!server) {
33
22
  proceed();
34
23
 
35
24
  return;
36
25
  }
37
26
 
38
- const watchPattern = sourceFilePath, ///
39
- registerHandler = watchFile(watchPattern);
27
+ const { quietly } = context,
28
+ clientSSourceFilePath = getClientSourceFilePath(context),
29
+ watchPattern = clientSSourceFilePath, ///
30
+ registerHandler = watchFile(watchPattern, quietly);
40
31
 
41
32
  registerHandler(copyClientFile);
42
33
 
43
34
  proceed();
44
35
 
45
36
  function copyClientFile() {
46
- copyFile(sourceFilePath, targetFilePath);
37
+ copyClientFileEx(context);
47
38
 
48
39
  defer(() => {
49
40
  registerHandler(copyClientFile);
@@ -2,9 +2,8 @@
2
2
 
3
3
  const express = require("express");
4
4
 
5
- const { createStaticRouter } = require("../router/static"),
6
- { createLiveReloadHandler } = require("../handler/liveReload"),
7
- { ERROR, LIVE_RELOAD_PATH } = require("../constants"),
5
+ const { ERROR } = require("../constants"),
6
+ { directoryPathFromFilePath } = require("../utilities/path"),
8
7
  { UNABLE_TO_START_SERVER_MESSAGE } = require("../messages");
9
8
 
10
9
  function serverOperation(proceed, abort, context) {
@@ -18,16 +17,15 @@ function serverOperation(proceed, abort, context) {
18
17
 
19
18
  server = express(); ///
20
19
 
21
- const { port, watch } = context,
22
- staticRouter = createStaticRouter(context);
23
-
24
- server.use(staticRouter);
20
+ Object.assign(context, {
21
+ server
22
+ });
25
23
 
26
- if (watch) {
27
- const liveReloadHandler = createLiveReloadHandler(context);
24
+ const { port, outputFilePath } = context,
25
+ outputDirectoryPath = directoryPathFromFilePath(outputFilePath),
26
+ staticRouter = express.static(outputDirectoryPath);
28
27
 
29
- server.get(LIVE_RELOAD_PATH, liveReloadHandler);
30
- }
28
+ server.use(staticRouter);
31
29
 
32
30
  const listener = server.listen(port, () => {
33
31
  console.log(`Server listening on port ${port}...`);
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ const { createLiveReloadHandler } = require("lively-cli");
4
+
5
+ const { LIVE_RELOAD_PATH } = require("../constants"),
6
+ { directoryPathFromFilePath } = require("../utilities/path");
7
+
8
+ function watchOperation(proceed, abort, context) {
9
+ const { watch } = context;
10
+
11
+ if (!watch) {
12
+ proceed();
13
+
14
+ return;
15
+ }
16
+
17
+ const { server = null } = context;
18
+
19
+ if (server === null) {
20
+ proceed();
21
+
22
+ return;
23
+ }
24
+
25
+ const { quietly, outputFilePath } = context,
26
+ outputDirectoryPath = directoryPathFromFilePath(outputFilePath),
27
+ watchPattern = outputDirectoryPath, ///
28
+ liveReloadHandler = createLiveReloadHandler(watchPattern, quietly);
29
+
30
+ server.get(LIVE_RELOAD_PATH, liveReloadHandler);
31
+
32
+ proceed();
33
+ }
34
+
35
+ module.exports = watchOperation;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ const { pathUtilities, packageUtilities } = require("necessary");
4
+
5
+ const { copyFile } = require("../utilities/fileSystem"),
6
+ { CLIENT_FILE_NAME } = require("../constants"),
7
+ { directoryPathFromFilePath } = require("../utilities/path");
8
+
9
+ const { getPackagePath } = packageUtilities,
10
+ { concatenatePaths } = pathUtilities;
11
+
12
+ function copyClientFile(context) {
13
+ const clientTargetFilePath = getClientTargetFilePath(context),
14
+ clientSSourceFilePath = getClientSourceFilePath(context);
15
+
16
+ copyFile(clientSSourceFilePath, clientTargetFilePath);
17
+ }
18
+
19
+ function getClientTargetFilePath(context) {
20
+ const { outputFilePath } = context,
21
+ outputDirectoryPath = directoryPathFromFilePath(outputFilePath),
22
+ clientTargetFilePath = concatenatePaths(outputDirectoryPath, CLIENT_FILE_NAME);
23
+
24
+ return clientTargetFilePath;
25
+ }
26
+
27
+ function getClientSourceFilePath(context) {
28
+ const packagePath = getPackagePath(),
29
+ clientSSourceFilePath = concatenatePaths(packagePath, CLIENT_FILE_NAME);
30
+
31
+ return clientSSourceFilePath;
32
+ }
33
+
34
+ module.exports = {
35
+ copyClientFile,
36
+ getClientTargetFilePath,
37
+ getClientSourceFilePath
38
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "highmark-cli",
3
3
  "author": "James Smith",
4
- "version": "0.0.149",
4
+ "version": "0.0.152",
5
5
  "license": "MIT, Anti-996",
6
6
  "homepage": "https://github.com/djalbat/highmark-cli",
7
7
  "description": "Extensible, styleable Markdown.",
@@ -21,8 +21,8 @@
21
21
  "devDependencies": {
22
22
  "@swc/core": "1.2.52",
23
23
  "easy": "^16.0.21",
24
- "easy-layout": "^6.0.146",
25
- "easy-with-style": "^3.0.349",
24
+ "easy-layout": "^6.0.147",
25
+ "easy-with-style": "^3.0.352",
26
26
  "esbuild": "^0.9.2",
27
27
  "fragmented": "^3.1.2",
28
28
  "juxtapose": "^4.0.81",
@@ -1,18 +0,0 @@
1
- "use strict";
2
-
3
- const { createLiveReloadHandler: createLiveReloadHandlerEx } = require("lively-cli");
4
-
5
- const { directoryPathFromFilePath } = require("../utilities/path");
6
-
7
- function createLiveReloadHandler(context) {
8
- const { quietly, outputFilePath } = context,
9
- outputDirectoryPath = directoryPathFromFilePath(outputFilePath),
10
- watchPattern = outputDirectoryPath, ///
11
- liveReloadHandler = createLiveReloadHandlerEx(watchPattern, quietly);
12
-
13
- return liveReloadHandler;
14
- }
15
-
16
- module.exports = {
17
- createLiveReloadHandler
18
- };
@@ -1,17 +0,0 @@
1
- "use strict";
2
-
3
- const express = require("express");
4
-
5
- const { directoryPathFromFilePath } = require("../utilities/path");
6
-
7
- function createStaticRouter(context) {
8
- const { outputFilePath } = context,
9
- outputDirectoryPath = directoryPathFromFilePath(outputFilePath),
10
- staticRouter = express.static(outputDirectoryPath);
11
-
12
- return staticRouter;
13
- }
14
-
15
- module.exports = {
16
- createStaticRouter
17
- };