watchful-cli 1.7.14 → 1.7.18

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,29 +1,29 @@
1
1
  "use strict";
2
2
 
3
3
  const action = require("../action"),
4
- initialiseCallback = require("../callback/initialise"),
5
- bundleFilesCallback = require("../callback/bundleFiles"),
6
- transpileFilesCallback = require("../callback/transpileFiles"),
7
- retrieveFilePathsCallback = require("../callback/retrieveFilePaths"),
8
- createBundleFilesFunctionCallback = require("../callback/createBundleFilesFunction"),
9
- createTranspileFileFunctionCallback = require("../callback/createTranspileFileFunction");
4
+ initialiseOperation = require("../operation/initialise"),
5
+ bundleFilesOperation = require("../operation/bundleFiles"),
6
+ transpileFilesOperation = require("../operation/transpileFiles"),
7
+ retrieveFilePathsOperation = require("../operation/retrieveFilePaths"),
8
+ createBundleFilesFunctionOperation = require("../operation/createBundleFilesFunction"),
9
+ createTranspileFileFunctionOperation = require("../operation/createTranspileFileFunction");
10
10
 
11
11
  const { BATCH_BUILD_FAILED_MESSAGE } = require("../messages");
12
12
 
13
13
  function batch(options) {
14
- const callbacks = [
15
- initialiseCallback,
16
- createTranspileFileFunctionCallback,
17
- createBundleFilesFunctionCallback,
18
- retrieveFilePathsCallback,
19
- transpileFilesCallback,
20
- bundleFilesCallback
14
+ const operations = [
15
+ initialiseOperation,
16
+ createTranspileFileFunctionOperation,
17
+ createBundleFilesFunctionOperation,
18
+ retrieveFilePathsOperation,
19
+ transpileFilesOperation,
20
+ bundleFilesOperation
21
21
  ],
22
22
  context = {
23
23
  options
24
24
  };
25
25
 
26
- action(callbacks, (success) => {
26
+ action(operations, (success) => {
27
27
  if (!success) {
28
28
  console.log(BATCH_BUILD_FAILED_MESSAGE);
29
29
 
@@ -2,25 +2,25 @@
2
2
 
3
3
  const watch = require("../watch"),
4
4
  action = require("../action"),
5
- initialiseCallback = require("../callback/initialise"),
6
- retrieveFilePathsCallback = require("../callback/retrieveFilePaths"),
7
- createBundleFilesFunctionCallback = require("../callback/createBundleFilesFunction"),
8
- createTranspileFileFunctionCallback = require("../callback/createTranspileFileFunction");
5
+ initialiseOperation = require("../operation/initialise"),
6
+ retrieveFilePathsOperation = require("../operation/retrieveFilePaths"),
7
+ createBundleFilesFunctionOperation = require("../operation/createBundleFilesFunction"),
8
+ createTranspileFileFunctionOperation = require("../operation/createTranspileFileFunction");
9
9
 
10
10
  const { INCREMENTAL_BUILD_FAILED_MESSAGE } = require("../messages");
11
11
 
12
12
  function incremental(options) {
13
- const callbacks = [
14
- initialiseCallback,
15
- createTranspileFileFunctionCallback,
16
- createBundleFilesFunctionCallback,
17
- retrieveFilePathsCallback
13
+ const operations = [
14
+ initialiseOperation,
15
+ createTranspileFileFunctionOperation,
16
+ createBundleFilesFunctionOperation,
17
+ retrieveFilePathsOperation
18
18
  ],
19
19
  context = {
20
20
  options
21
21
  };
22
22
 
23
- action(callbacks, (success) => {
23
+ action(operations, (success) => {
24
24
  if (!success) {
25
25
  console.log(INCREMENTAL_BUILD_FAILED_MESSAGE);
26
26
 
package/bin/action.js CHANGED
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
 
3
- const { executeCallbacks } = require("./utilities/callback");
3
+ const { executeOperations } = require("./utilities/callback");
4
4
 
5
- function action(callbacks, callback, context) {
6
- executeCallbacks(callbacks, (completed) => {
5
+ function action(operations, callback, context) {
6
+ executeOperations(operations, (completed) => {
7
7
  const success = completed; ///
8
8
 
9
9
  callback(success);
package/bin/constants.js CHANGED
@@ -6,11 +6,8 @@ const S = "s",
6
6
  BABEL = "babel",
7
7
  W_PLUS = "w+",
8
8
  INLINE = "inline",
9
- BASE_64 = "base64",
10
9
  MESSAGE = "message",
11
10
  ESBUILD = "esbuild",
12
- FULL_STOP = ".",
13
- DELIMITER = "/",
14
11
  BROWSERIFY = "browserify",
15
12
  EMPTY_STRING = "",
16
13
  WATCHFUL_CLI = "watchful-cli",
@@ -26,11 +23,8 @@ module.exports = {
26
23
  BABEL,
27
24
  W_PLUS,
28
25
  INLINE,
29
- BASE_64,
30
26
  MESSAGE,
31
27
  ESBUILD,
32
- FULL_STOP,
33
- DELIMITER,
34
28
  BROWSERIFY,
35
29
  EMPTY_STRING,
36
30
  WATCHFUL_CLI,
@@ -2,7 +2,7 @@
2
2
 
3
3
  const bundleFiles = require("../bundleFiles");
4
4
 
5
- function bundleFilesCallback(proceed, abort, context) {
5
+ function bundleFilesOperation(proceed, abort, context) {
6
6
  const { entryFilePath } = context;
7
7
 
8
8
  if (!entryFilePath) {
@@ -16,4 +16,4 @@ function bundleFilesCallback(proceed, abort, context) {
16
16
  });
17
17
  }
18
18
 
19
- module.exports = bundleFilesCallback;
19
+ module.exports = bundleFilesOperation;
@@ -2,7 +2,7 @@
2
2
 
3
3
  const { createBundleFilesFunction } = require("../utilities/bundle");
4
4
 
5
- function createBundleFilesFunctionCallback(proceed, abort, context) {
5
+ function createBundleFilesFunctionOperation(proceed, abort, context) {
6
6
  const { bundleFilePath } = context;
7
7
 
8
8
  if (bundleFilePath === null) {
@@ -26,4 +26,4 @@ function createBundleFilesFunctionCallback(proceed, abort, context) {
26
26
  proceed();
27
27
  }
28
28
 
29
- module.exports = createBundleFilesFunctionCallback;
29
+ module.exports = createBundleFilesFunctionOperation;
@@ -2,7 +2,7 @@
2
2
 
3
3
  const { createTranspileFileFunction } = require("../utilities/transpile");
4
4
 
5
- function createTranspileFileFunctionCallback(proceed, abort, context) {
5
+ function createTranspileFileFunctionOperation(proceed, abort, context) {
6
6
  const transpileFileFunction = createTranspileFileFunction(context);
7
7
 
8
8
  if (transpileFileFunction === null) {
@@ -18,4 +18,4 @@ function createTranspileFileFunctionCallback(proceed, abort, context) {
18
18
  proceed();
19
19
  }
20
20
 
21
- module.exports = createTranspileFileFunctionCallback;
21
+ module.exports = createTranspileFileFunctionOperation;
@@ -23,7 +23,7 @@ const { pathFromOption } = require("../utilities/path"),
23
23
  TEMP_DIRECTORY_PATH_NOT_RELATIVE_TO_CURRENT_DIRECTORY_MESSAGE,
24
24
  SOURCE_DIRECTORY_PATH_NOT_RELATIVE_TO_CURRENT_DIRECTORY_MESSAGE } = require("../messages");
25
25
 
26
- function initialiseCallback(proceed, abort, context) {
26
+ function initialiseOperation(proceed, abort, context) {
27
27
  const { options } = context,
28
28
  { wait = DEFAULT_WAIT,
29
29
  node = DEFAULT_NODE,
@@ -199,4 +199,4 @@ function initialiseCallback(proceed, abort, context) {
199
199
  proceed();
200
200
  }
201
201
 
202
- module.exports = initialiseCallback;
202
+ module.exports = initialiseOperation;
@@ -6,7 +6,7 @@ const { ADD_EVENT, READY_EVENT } = require("../events"),
6
6
  { ENTRY_FILE_NOT_INCLUDED_IN_BUNDLED_FILES_MESSAGE } = require("../messages"),
7
7
  { pathWithoutDirectoryPathFromPathAndDirectoryPath } = require("../utilities/path");
8
8
 
9
- function retrieveFilePathsCallback(proceed, abort, context) {
9
+ function retrieveFilePathsOperation(proceed, abort, context) {
10
10
  const { sourceDirectoryPath } = context,
11
11
  globPattern = `${sourceDirectoryPath}/**/*.js`,
12
12
  filePaths = [],
@@ -44,4 +44,4 @@ function retrieveFilePathsCallback(proceed, abort, context) {
44
44
  });
45
45
  }
46
46
 
47
- module.exports = retrieveFilePathsCallback;
47
+ module.exports = retrieveFilePathsOperation;
@@ -4,7 +4,7 @@ const TranspileFileWrapper = require("../../wrapper/transpileFile");
4
4
 
5
5
  const { updateCountMetric } = require("../../utilities/metrics");
6
6
 
7
- function multipleProcessesTranspileFilesCallback(done, context) {
7
+ function multipleProcessesTranspileFilesOperation(done, context) {
8
8
  const { filePaths, processesLength } = context,
9
9
  filePathsLength = filePaths.length,
10
10
  transpileFileWrappers = [],
@@ -54,4 +54,4 @@ function multipleProcessesTranspileFilesCallback(done, context) {
54
54
  }
55
55
  }
56
56
 
57
- module.exports = multipleProcessesTranspileFilesCallback;
57
+ module.exports = multipleProcessesTranspileFilesOperation;
@@ -8,15 +8,15 @@ const { updateCountMetric } = require("../../utilities/metrics");
8
8
 
9
9
  const { forEach } = asynchronousUtilities;
10
10
 
11
- function singleProcessTranspileFilesCallback(done, context) {
11
+ function singleProcessTranspileFilesOperation(done, context) {
12
12
  const { filePaths } = context;
13
13
 
14
- forEach(filePaths, transpileFileCallback, done, context);
14
+ forEach(filePaths, transpileFileOperation, done, context);
15
15
  }
16
16
 
17
- module.exports = singleProcessTranspileFilesCallback;
17
+ module.exports = singleProcessTranspileFilesOperation;
18
18
 
19
- function transpileFileCallback(filePath, next, done, context) {
19
+ function transpileFileOperation(filePath, next, done, context) {
20
20
  transpileFile(filePath, context, (success) => {
21
21
  if (success) {
22
22
  updateCountMetric(context);
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
 
3
- const singleProcessTranspileFilesCallback = require("../callback/transpileFiles/singleProcess"),
4
- multipleProcessesTranspileFilesCallback = require("../callback/transpileFiles/mutilpleProcesses");
3
+ const singleProcessTranspileFilesCallback = require(".//transpileFiles/singleProcess"),
4
+ multipleProcessesTranspileFilesCallback = require(".//transpileFiles/mutilpleProcesses");
5
5
 
6
6
  const { S, EMPTY_STRING } = require("../constants"),
7
7
  { startCountMetric, endCountMetric, startSecondsMetric, endSecondsMetric } = require("../utilities/metrics");
8
8
 
9
- function transpileFilesCallback(proceed, abort, context) {
9
+ function transpileFilesOperation(proceed, abort, context) {
10
10
  const { metrics, processesLength } = context;
11
11
 
12
12
  if (metrics) {
@@ -33,4 +33,4 @@ function transpileFilesCallback(proceed, abort, context) {
33
33
  }
34
34
  }
35
35
 
36
- module.exports = transpileFilesCallback;
36
+ module.exports = transpileFilesOperation;
@@ -4,18 +4,18 @@ const { asynchronousUtilities } = require("necessary");
4
4
 
5
5
  const { whilst } = asynchronousUtilities;
6
6
 
7
- function executeCallbacks(callbacks, callback, context) {
7
+ function executeOperations(operations, callback, context) {
8
8
  const completed = true;
9
9
 
10
10
  Object.assign(context, {
11
- callbacks,
11
+ operations,
12
12
  completed
13
13
  });
14
14
 
15
- whilst(executeCallback, () => {
15
+ whilst(executeOperation, () => {
16
16
  const { completed } = context;
17
17
 
18
- delete context.callbacks;
18
+ delete context.operations;
19
19
 
20
20
  delete context.completed;
21
21
 
@@ -24,13 +24,13 @@ function executeCallbacks(callbacks, callback, context) {
24
24
  }
25
25
 
26
26
  module.exports = {
27
- executeCallbacks
27
+ executeOperations
28
28
  };
29
29
 
30
- function executeCallback(next, done, context, index) {
31
- const { callbacks } = context,
32
- callbacksLength = callbacks.length,
33
- lastIndex = callbacksLength - 1;
30
+ function executeOperation(next, done, context, index) {
31
+ const { operations } = context,
32
+ operationsLength = operations.length,
33
+ lastIndex = operationsLength - 1;
34
34
 
35
35
  if (index > lastIndex) {
36
36
  done();
@@ -38,9 +38,9 @@ function executeCallback(next, done, context, index) {
38
38
  return;
39
39
  }
40
40
 
41
- const callback = callbacks[index];
41
+ const operation = operations[index];
42
42
 
43
- callback(proceed, abort, context);
43
+ operation(proceed, abort, context);
44
44
 
45
45
  function proceed() {
46
46
  next();
@@ -2,14 +2,16 @@
2
2
 
3
3
  const fs = require("fs");
4
4
 
5
- const { fileSystemUtilities } = require("necessary");
5
+ const { characters, fileSystemUtilities } = require("necessary");
6
6
 
7
- const { W_PLUS, FULL_STOP } = require("../constants"),
7
+ const { W_PLUS } = require("../constants"),
8
8
  { pathWithoutBottommostNameFromPath } = require("../utilities/path");
9
9
 
10
10
  const { openSync, writeSync, rmdirSync, unlinkSync } = fs,
11
11
  { readDirectory, isEntryDirectory, createDirectory } = fileSystemUtilities;
12
12
 
13
+ const { PERIOD_CHARACTER } = characters;
14
+
13
15
  function deleteFile(filePath, done) {
14
16
  unlinkSync(filePath);
15
17
 
@@ -33,7 +35,7 @@ function deleteDirectory(directoryPath, done) {
33
35
  function createParentDirectory(filePath) {
34
36
  const filePathWithoutBottommostName = pathWithoutBottommostNameFromPath(filePath);
35
37
 
36
- if ((filePathWithoutBottommostName !== FULL_STOP) && (filePathWithoutBottommostName !== null)) {
38
+ if ((filePathWithoutBottommostName !== PERIOD_CHARACTER) && (filePathWithoutBottommostName !== null)) {
37
39
  const parentDirectoryPath = filePathWithoutBottommostName; ///
38
40
 
39
41
  createDirectory(parentDirectoryPath);
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
 
3
- const { pathUtilities } = require("necessary");
3
+ const { characters, pathUtilities } = require("necessary");
4
4
 
5
- const { EMPTY_STRING, DELIMITER } = require("../constants");
5
+ const { EMPTY_STRING } = require("../constants");
6
6
 
7
- const { isPathName, bottommostNameFromPath } = pathUtilities;
7
+ const { FORWARD_SLASH_CHARACTER } = characters,
8
+ { isPathName, bottommostNameFromPath } = pathUtilities;
8
9
 
9
10
  const currentWorkingDirectoryPath = process.cwd(),
10
11
  currentWorkingDirectoryPathLength = currentWorkingDirectoryPath.length;
@@ -61,9 +62,9 @@ function pathFromFullyQualifiedPath(fullyQualifiedPath) {
61
62
  }
62
63
 
63
64
  function pathWithoutDirectoryPathFromPathAndDirectoryPath(path, directoryPath) {
64
- const delimiterLength = DELIMITER.length,
65
- directoryPathLength = directoryPath.length,
66
- pathWithoutDirectoryPath = path.substring(directoryPathLength + delimiterLength);
65
+ const directoryPathLength = directoryPath.length,
66
+ forwardSlashCharacterLength = FORWARD_SLASH_CHARACTER.length,
67
+ pathWithoutDirectoryPath = path.substring(directoryPathLength + forwardSlashCharacterLength);
67
68
 
68
69
  return pathWithoutDirectoryPath;
69
70
  }
@@ -2,15 +2,19 @@
2
2
 
3
3
  const path = require("path");
4
4
 
5
+ const { encodings } = require("necessary");
6
+
5
7
  const { SWC_CORE_PATH, BABEL_CORE_PATH } = require("../paths"),
6
8
  { readFile, writeFile, createParentDirectory } = require("../utilities/fileSystem"),
7
- { BABEL, INLINE, BASE_64, SOURCE_MAP_PREAMBLE } = require("../constants"),
9
+ { BABEL, INLINE, SOURCE_MAP_PREAMBLE } = require("../constants"),
8
10
  { sourceFileNameFromSourceFilePathAndTargetFilePath } = require("../utilities/sourceMap"),
9
11
  { SWC_FAILED_MESSAGE,
10
12
  BABEL_FAILED_MESSAGE,
11
13
  SWC_NOT_INSTALLED_MESSAGE,
12
14
  BABEL_NOT_INSTALLED_MESSAGE } = require("../messages");
13
15
 
16
+ const { BASE64_ENCODING } = encodings;
17
+
14
18
  function createTranspileFileFunction(context) {
15
19
  const { debug, transpiler } = context,
16
20
  transpileFileFunction = (transpiler === BABEL) ?
@@ -122,7 +126,7 @@ function createSWCTranspileFileFunction(debug) {
122
126
  });
123
127
 
124
128
  const mapJSONString = JSON.stringify(mapJSON),
125
- base64EncodedMapJSONString = Buffer.from(mapJSONString).toString(BASE_64);
129
+ base64EncodedMapJSONString = Buffer.from(mapJSONString).toString(BASE64_ENCODING);
126
130
 
127
131
  targetFileContent = `${code}
128
132
  ${SOURCE_MAP_PREAMBLE}${base64EncodedMapJSONString}`; ///
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "watchful-cli",
3
3
  "author": "James Smith",
4
- "version": "1.7.14",
4
+ "version": "1.7.18",
5
5
  "license": "MIT, Anti-996",
6
6
  "homepage": "https://github.com/djalbat/watchful-cli",
7
7
  "description": "Incremental transpilation with bundling.",
@@ -15,7 +15,7 @@
15
15
  "dependencies": {
16
16
  "argumentative": "^2.0.14",
17
17
  "chokidar": "^3.3.1",
18
- "necessary": "^10.0.0"
18
+ "necessary": "^11.0.25"
19
19
  },
20
20
  "devDependencies": {},
21
21
  "scripts": {}