watchful-cli 1.7.57 → 1.7.59
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/.swcrc +11 -0
- package/lib/abbreviations.js +32 -0
- package/lib/action/batch.js +56 -0
- package/lib/action/help.js +15 -0
- package/lib/action/incremental.js +54 -0
- package/lib/action/version.js +19 -0
- package/lib/action.js +19 -0
- package/lib/bundleFiles.js +36 -0
- package/lib/commands.js +30 -0
- package/lib/configure.js +25 -0
- package/lib/constants.js +62 -0
- package/lib/defaults.js +79 -0
- package/lib/events.js +38 -0
- package/lib/main.js +59 -0
- package/lib/messages.js +118 -0
- package/lib/operation/bundleFiles.js +28 -0
- package/lib/operation/createBundleFilesFunction.js +29 -0
- package/lib/operation/createTranspileFileFunction.js +24 -0
- package/lib/operation/initialise.js +125 -0
- package/lib/operation/retrieveFilePaths.js +45 -0
- package/lib/operation/transpileFiles/mutilpleProcesses.js +51 -0
- package/lib/operation/transpileFiles/singleProcess.js +33 -0
- package/lib/operation/transpileFiles.js +36 -0
- package/lib/options.js +74 -0
- package/lib/paths.js +30 -0
- package/lib/process/transpileFile.js +26 -0
- package/lib/queue.js +93 -0
- package/lib/task/bundleFiles.js +115 -0
- package/lib/task/deleteDirectory.js +119 -0
- package/lib/task/deleteFile.js +119 -0
- package/lib/task/transpileFile.js +120 -0
- package/lib/task.js +101 -0
- package/lib/transpileFile.js +24 -0
- package/lib/utilities/bundle.js +106 -0
- package/lib/utilities/callback.js +46 -0
- package/lib/utilities/fileSystem.js +88 -0
- package/lib/utilities/metrics.js +73 -0
- package/lib/utilities/option.js +29 -0
- package/lib/utilities/path.js +110 -0
- package/lib/utilities/transpile.js +103 -0
- package/lib/utilities/watch.js +102 -0
- package/lib/watch.js +35 -0
- package/lib/wrapper/transpileFile.js +107 -0
- package/package.json +21 -6
- package/{bin → src}/abbreviations.js +18 -19
- package/src/action/batch.js +46 -0
- package/{bin → src}/action/help.js +1 -3
- package/{bin → src}/action/incremental.js +8 -10
- package/src/action/version.js +13 -0
- package/{bin → src}/action.js +2 -4
- package/{bin → src}/bundleFiles.js +2 -4
- package/src/commands.js +6 -0
- package/{bin → src}/configure.js +3 -5
- package/src/constants.js +14 -0
- package/src/defaults.js +20 -0
- package/src/events.js +8 -0
- package/{bin → src}/main.js +23 -25
- package/src/messages.js +28 -0
- package/{bin → src}/operation/bundleFiles.js +2 -4
- package/{bin → src}/operation/createBundleFilesFunction.js +2 -4
- package/{bin → src}/operation/createTranspileFileFunction.js +2 -4
- package/{bin → src}/operation/initialise.js +18 -20
- package/{bin → src}/operation/retrieveFilePaths.js +5 -7
- package/{bin → src}/operation/transpileFiles/mutilpleProcesses.js +3 -5
- package/{bin → src}/operation/transpileFiles/singleProcess.js +3 -5
- package/{bin → src}/operation/transpileFiles.js +5 -7
- package/src/options.js +17 -0
- package/src/paths.js +6 -0
- package/{bin → src}/process/transpileFile.js +4 -4
- package/{bin → src}/queue.js +2 -4
- package/{bin → src}/task/bundleFiles.js +3 -5
- package/{bin → src}/task/deleteDirectory.js +4 -6
- package/{bin → src}/task/deleteFile.js +4 -6
- package/{bin → src}/task/transpileFile.js +5 -7
- package/{bin → src}/task.js +1 -3
- package/{bin → src}/transpileFile.js +2 -4
- package/{bin → src}/utilities/bundle.js +12 -16
- package/{bin → src}/utilities/callback.js +2 -6
- package/{bin → src}/utilities/fileSystem.js +11 -17
- package/{bin → src}/utilities/metrics.js +6 -15
- package/{bin → src}/utilities/option.js +1 -5
- package/{bin → src}/utilities/path.js +32 -42
- package/{bin → src}/utilities/transpile.js +11 -15
- package/{bin → src}/utilities/watch.js +9 -14
- package/{bin → src}/watch.js +6 -8
- package/{bin → src}/wrapper/transpileFile.js +3 -5
- package/watchful.js +3 -3
- package/bin/action/batch.js +0 -48
- package/bin/action/version.js +0 -15
- package/bin/commands.js +0 -13
- package/bin/constants.js +0 -33
- package/bin/defaults.js +0 -39
- package/bin/events.js +0 -17
- package/bin/messages.js +0 -57
- package/bin/options.js +0 -35
- package/bin/paths.js +0 -13
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import fs from "fs";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
import { characters, pathUtilities, fileSystemUtilities } from "necessary";
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
import { W_PLUS } from "../constants";
|
|
8
|
+
import { pathWithoutBottommostNameFromPath } from "../utilities/path";
|
|
9
|
+
|
|
10
|
+
export const { readFile, writeFile, readDirectory, isEntryDirectory, createDirectory } = fileSystemUtilities;
|
|
9
11
|
|
|
10
12
|
const { concatenatePaths } = pathUtilities,
|
|
11
|
-
{ openSync, writeSync, rmdirSync, unlinkSync } = fs
|
|
12
|
-
{ readDirectory, isEntryDirectory, createDirectory } = fileSystemUtilities;
|
|
13
|
+
{ openSync, writeSync, rmdirSync, unlinkSync } = fs;
|
|
13
14
|
|
|
14
15
|
const { PERIOD_CHARACTER } = characters;
|
|
15
16
|
|
|
16
|
-
function deleteFile(filePath, done) {
|
|
17
|
+
export function deleteFile(filePath, done) {
|
|
17
18
|
unlinkSync(filePath);
|
|
18
19
|
|
|
19
20
|
done && done(); ///
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
function writeFileEx(filePath, buffer) {
|
|
23
|
+
export function writeFileEx(filePath, buffer) {
|
|
23
24
|
const file = openSync(filePath, W_PLUS);
|
|
24
25
|
|
|
25
26
|
writeSync(file, buffer);
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
function deleteDirectory(directoryPath, done) {
|
|
29
|
+
export function deleteDirectory(directoryPath, done) {
|
|
29
30
|
cleanDirectory(directoryPath);
|
|
30
31
|
|
|
31
32
|
rmdirSync(directoryPath);
|
|
@@ -33,7 +34,7 @@ function deleteDirectory(directoryPath, done) {
|
|
|
33
34
|
done && done(); ///
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
function createParentDirectory(filePath) {
|
|
37
|
+
export function createParentDirectory(filePath) {
|
|
37
38
|
const filePathWithoutBottommostName = pathWithoutBottommostNameFromPath(filePath);
|
|
38
39
|
|
|
39
40
|
if ((filePathWithoutBottommostName !== PERIOD_CHARACTER) && (filePathWithoutBottommostName !== null)) {
|
|
@@ -43,13 +44,6 @@ function createParentDirectory(filePath) {
|
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
module.exports = Object.assign({}, fileSystemUtilities, {
|
|
47
|
-
deleteFile,
|
|
48
|
-
writeFileEx,
|
|
49
|
-
deleteDirectory,
|
|
50
|
-
createParentDirectory
|
|
51
|
-
});
|
|
52
|
-
|
|
53
47
|
function cleanDirectory(directoryPath) {
|
|
54
48
|
const entryPaths = readDirectory(directoryPath);
|
|
55
49
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function initialiseMetrics(context) {
|
|
3
|
+
export function initialiseMetrics(context) {
|
|
4
4
|
const metrics = {};
|
|
5
5
|
|
|
6
6
|
Object.assign(context, {
|
|
@@ -8,7 +8,7 @@ function initialiseMetrics(context) {
|
|
|
8
8
|
});
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
function startCountMetric(context) {
|
|
11
|
+
export function startCountMetric(context) {
|
|
12
12
|
const { metrics } = context;
|
|
13
13
|
|
|
14
14
|
const count = 0;
|
|
@@ -18,7 +18,7 @@ function startCountMetric(context) {
|
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
function endCountMetric(context) {
|
|
21
|
+
export function endCountMetric(context) {
|
|
22
22
|
const { metrics } = context,
|
|
23
23
|
{ count } = metrics;
|
|
24
24
|
|
|
@@ -27,7 +27,7 @@ function endCountMetric(context) {
|
|
|
27
27
|
return count;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
function updateCountMetric(context) {
|
|
30
|
+
export function updateCountMetric(context) {
|
|
31
31
|
const { metrics } = context;
|
|
32
32
|
|
|
33
33
|
let { count } = metrics;
|
|
@@ -39,7 +39,7 @@ function updateCountMetric(context) {
|
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
function startSecondsMetric(context) {
|
|
42
|
+
export function startSecondsMetric(context) {
|
|
43
43
|
const { metrics } = context,
|
|
44
44
|
now = Date.now();
|
|
45
45
|
|
|
@@ -48,7 +48,7 @@ function startSecondsMetric(context) {
|
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
function endSecondsMetric(context) {
|
|
51
|
+
export function endSecondsMetric(context) {
|
|
52
52
|
const { metrics } = context;
|
|
53
53
|
|
|
54
54
|
let { now } = metrics;
|
|
@@ -63,12 +63,3 @@ function endSecondsMetric(context) {
|
|
|
63
63
|
|
|
64
64
|
return seconds;
|
|
65
65
|
}
|
|
66
|
-
|
|
67
|
-
module.exports = {
|
|
68
|
-
initialiseMetrics,
|
|
69
|
-
startCountMetric,
|
|
70
|
-
endCountMetric,
|
|
71
|
-
updateCountMetric,
|
|
72
|
-
startSecondsMetric,
|
|
73
|
-
endSecondsMetric
|
|
74
|
-
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { EMPTY_STRING } from "../constants";
|
|
4
4
|
|
|
5
|
-
function pathFromOption(option) {
|
|
5
|
+
export function pathFromOption(option) {
|
|
6
6
|
let path = null;
|
|
7
7
|
|
|
8
8
|
const optionAbsolutePath = /^\/.*/.test(option),
|
|
@@ -23,7 +23,3 @@ function pathFromOption(option) {
|
|
|
23
23
|
|
|
24
24
|
return path;
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
module.exports = {
|
|
28
|
-
pathFromOption
|
|
29
|
-
};
|
|
@@ -1,53 +1,54 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import path from "path";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
import { characters, pathUtilities } from "necessary";
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
import { EMPTY_STRING } from "../constants";
|
|
8
8
|
|
|
9
|
-
const { FORWARD_SLASH_CHARACTER } = characters
|
|
10
|
-
{ combinePaths, pathWithoutBottommostNameFromPath } = pathUtilities;
|
|
9
|
+
const { FORWARD_SLASH_CHARACTER } = characters;
|
|
11
10
|
|
|
12
11
|
const currentWorkingDirectoryPath = process.cwd(),
|
|
13
12
|
currentWorkingDirectoryPathLength = currentWorkingDirectoryPath.length;
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
14
|
+
export const { combinePaths, pathWithoutBottommostNameFromPath } = pathUtilities;
|
|
15
|
+
|
|
16
|
+
export function pathFromOption(option) {
|
|
17
|
+
let path = null;
|
|
18
|
+
|
|
19
|
+
const optionAbsolutePath = /^\/.*/.test(option),
|
|
20
|
+
optionAllowedRelativePath = /^\.\/.*/.test(option),
|
|
21
|
+
optionForbiddenRelativePath = /^\.\.\/.*/.test(option);
|
|
22
|
+
|
|
23
|
+
if (false) {
|
|
24
|
+
///
|
|
25
|
+
} else if (optionAbsolutePath) {
|
|
26
|
+
///
|
|
27
|
+
} else if (optionAllowedRelativePath) {
|
|
28
|
+
path = option.replace(/^\.\//, EMPTY_STRING).replace(/\/$/, EMPTY_STRING);
|
|
29
|
+
} else if (optionForbiddenRelativePath) {
|
|
30
|
+
path = null;
|
|
31
|
+
} else {
|
|
32
|
+
path = option; ///
|
|
33
|
+
}
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
return path;
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
function isPathFullQualifiedPath(path) {
|
|
38
|
+
export function isPathFullQualifiedPath(path) {
|
|
38
39
|
const pathStartsWithCurrentWorkingDirectoryPath = path.startsWith(currentWorkingDirectoryPath),
|
|
39
40
|
pathFullyQualifiedPath = pathStartsWithCurrentWorkingDirectoryPath; ///
|
|
40
41
|
|
|
41
42
|
return pathFullyQualifiedPath;
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
function pathFromFullyQualifiedPath(fullyQualifiedPath) {
|
|
45
|
+
export function pathFromFullyQualifiedPath(fullyQualifiedPath) {
|
|
45
46
|
const path = fullyQualifiedPath.substring(currentWorkingDirectoryPathLength);
|
|
46
47
|
|
|
47
48
|
return path;
|
|
48
49
|
}
|
|
49
50
|
|
|
50
|
-
function pathWithoutDirectoryPathFromPathAndDirectoryPath(path, directoryPath) {
|
|
51
|
+
export function pathWithoutDirectoryPathFromPathAndDirectoryPath(path, directoryPath) {
|
|
51
52
|
const directoryPathLength = directoryPath.length,
|
|
52
53
|
forwardSlashCharacterLength = FORWARD_SLASH_CHARACTER.length,
|
|
53
54
|
pathWithoutDirectoryPath = path.substring(directoryPathLength + forwardSlashCharacterLength);
|
|
@@ -55,26 +56,26 @@ function pathWithoutDirectoryPathFromPathAndDirectoryPath(path, directoryPath) {
|
|
|
55
56
|
return pathWithoutDirectoryPath;
|
|
56
57
|
}
|
|
57
58
|
|
|
58
|
-
function sourceFilePathFromFilePathAndSourceDirectoryPath(filePath, sourceDirectoryPath) {
|
|
59
|
+
export function sourceFilePathFromFilePathAndSourceDirectoryPath(filePath, sourceDirectoryPath) {
|
|
59
60
|
const sourceFilePath = combinePaths(sourceDirectoryPath, filePath);
|
|
60
61
|
|
|
61
62
|
return sourceFilePath;
|
|
62
63
|
}
|
|
63
64
|
|
|
64
|
-
function targetFilePathFromFilePathAndTargetDirectoryPath(filePath, targetDirectoryPath) {
|
|
65
|
+
export function targetFilePathFromFilePathAndTargetDirectoryPath(filePath, targetDirectoryPath) {
|
|
65
66
|
const targetFilePath = combinePaths(targetDirectoryPath, filePath);
|
|
66
67
|
|
|
67
68
|
return targetFilePath;
|
|
68
69
|
}
|
|
69
70
|
|
|
70
|
-
function sourceFileNameFromSourceFilePathAndTargetFilePath(sourceFilePath, targetFilePath) {
|
|
71
|
+
export function sourceFileNameFromSourceFilePathAndTargetFilePath(sourceFilePath, targetFilePath) {
|
|
71
72
|
const relativeSourceFilepath = relativeSourceFilePathFromSourceFilePathAndTargetFilePath(sourceFilePath, targetFilePath),
|
|
72
73
|
sourceFileName = relativeSourceFilepath; ///
|
|
73
74
|
|
|
74
75
|
return sourceFileName;
|
|
75
76
|
}
|
|
76
77
|
|
|
77
|
-
function sourcesFromSourcesSourceDirectoryPathAndTargetDirectoryPath(sources, sourceDirectoryPath, targetDirectoryPath) {
|
|
78
|
+
export function sourcesFromSourcesSourceDirectoryPathAndTargetDirectoryPath(sources, sourceDirectoryPath, targetDirectoryPath) {
|
|
78
79
|
sources = sources.map((source) => { ///
|
|
79
80
|
const sourceStartsWithTargetDirectoryPath = source.startsWith(targetDirectoryPath);
|
|
80
81
|
|
|
@@ -95,17 +96,6 @@ function sourcesFromSourcesSourceDirectoryPathAndTargetDirectoryPath(sources, so
|
|
|
95
96
|
return sources;
|
|
96
97
|
}
|
|
97
98
|
|
|
98
|
-
module.exports = Object.assign({}, pathUtilities, {
|
|
99
|
-
pathFromOption,
|
|
100
|
-
isPathFullQualifiedPath,
|
|
101
|
-
pathFromFullyQualifiedPath,
|
|
102
|
-
pathWithoutDirectoryPathFromPathAndDirectoryPath,
|
|
103
|
-
sourceFilePathFromFilePathAndSourceDirectoryPath,
|
|
104
|
-
targetFilePathFromFilePathAndTargetDirectoryPath,
|
|
105
|
-
sourceFileNameFromSourceFilePathAndTargetFilePath,
|
|
106
|
-
sourcesFromSourcesSourceDirectoryPathAndTargetDirectoryPath
|
|
107
|
-
});
|
|
108
|
-
|
|
109
99
|
function relativeSourceFilePathFromSourceFilePathAndTargetFilePath(sourceFilePath, targetFilePath) {
|
|
110
100
|
const targetFilePathWithoutBottommostName = pathWithoutBottommostNameFromPath(targetFilePath),
|
|
111
101
|
relativeSourceFilePath = path.relative(targetFilePathWithoutBottommostName, sourceFilePath);
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import path from "path";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
import { encodings } from "necessary";
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
import { SWC_CORE_PATH, BABEL_CORE_PATH } from "../paths";
|
|
8
|
+
import { readFile, writeFile, createParentDirectory } from "../utilities/fileSystem";
|
|
9
|
+
import { BABEL, INLINE, SOURCE_MAP_PREAMBLE } from "../constants";
|
|
10
|
+
import { SWC_FAILED_MESSAGE, BABEL_FAILED_MESSAGE, SWC_NOT_INSTALLED_MESSAGE, BABEL_NOT_INSTALLED_MESSAGE } from "../messages";
|
|
11
|
+
import { sourceFilePathFromFilePathAndSourceDirectoryPath,
|
|
12
|
+
targetFilePathFromFilePathAndTargetDirectoryPath,
|
|
13
|
+
sourceFileNameFromSourceFilePathAndTargetFilePath,
|
|
14
|
+
sourcesFromSourcesSourceDirectoryPathAndTargetDirectoryPath } from "../utilities/path";
|
|
15
15
|
|
|
16
16
|
const { BASE64_ENCODING } = encodings;
|
|
17
17
|
|
|
18
|
-
function createTranspileFileFunction(context) {
|
|
18
|
+
export function createTranspileFileFunction(context) {
|
|
19
19
|
const { debug, transpiler } = context,
|
|
20
20
|
transpileFileFunction = (transpiler === BABEL) ?
|
|
21
21
|
createBabelTranspileFileFunction(debug) :
|
|
@@ -24,10 +24,6 @@ function createTranspileFileFunction(context) {
|
|
|
24
24
|
return transpileFileFunction;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
module.exports = {
|
|
28
|
-
createTranspileFileFunction
|
|
29
|
-
};
|
|
30
|
-
|
|
31
27
|
function createBabelTranspileFileFunction(debug) {
|
|
32
28
|
let babelTranspileFileFunction = null;
|
|
33
29
|
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import DeleteFileTask from "../task/deleteFile";
|
|
4
|
+
import BundleFilesTask from "../task/bundleFiles";
|
|
5
|
+
import TranspileFileTask from "../task/transpileFile";
|
|
6
|
+
import DeleteDirectoryTask from "../task/deleteDirectory";
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
import { isPathFullQualifiedPath, pathFromFullyQualifiedPath } from "../utilities/path";
|
|
9
|
+
import { ADD_EVENT, CHANGE_EVENT, UNLINK_EVENT, UNLINK_DIR_EVENT } from "../events";
|
|
10
|
+
import { startCountMetric, startSecondsMetric, endCountMetric, endSecondsMetric } from "../utilities/metrics";
|
|
11
11
|
|
|
12
|
-
function eventHandler(queue, event, path, context) {
|
|
12
|
+
export function eventHandler(queue, event, path, context) {
|
|
13
13
|
const { metrics } = context,
|
|
14
14
|
pathFullyQualifiedPath = isPathFullQualifiedPath(path);
|
|
15
15
|
|
|
@@ -47,7 +47,7 @@ function eventHandler(queue, event, path, context) {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
function queueEmptyHandler(queue, previousTask, context) {
|
|
50
|
+
export function queueEmptyHandler(queue, previousTask, context) {
|
|
51
51
|
if (previousTask instanceof BundleFilesTask) {
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
@@ -75,11 +75,6 @@ function queueEmptyHandler(queue, previousTask, context) {
|
|
|
75
75
|
}, wait);
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
module.exports = {
|
|
79
|
-
eventHandler,
|
|
80
|
-
queueEmptyHandler
|
|
81
|
-
}
|
|
82
|
-
|
|
83
78
|
function addOrChangeEventHandler(queue, path, context) {
|
|
84
79
|
const transpileFileTask = TranspileFileTask.fromPath(path, context);
|
|
85
80
|
|
package/{bin → src}/watch.js
RENAMED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import chokidar from "chokidar";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
import Queue from "./queue";
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
import { ALL_EVENT, READY_EVENT } from "./events";
|
|
8
|
+
import { SOURCE_DIRECTORY_WATCH_PATTERN } from "./constants";
|
|
9
|
+
import { eventHandler, queueEmptyHandler } from "./utilities/watch";
|
|
10
10
|
|
|
11
|
-
function watch(context) {
|
|
11
|
+
export default function watch(context) {
|
|
12
12
|
const { quietly, sourceDirectoryPath } = context,
|
|
13
13
|
watchPattern = `${sourceDirectoryPath}${SOURCE_DIRECTORY_WATCH_PATTERN}`,
|
|
14
14
|
watcher = chokidar.watch(watchPattern),
|
|
@@ -22,5 +22,3 @@ function watch(context) {
|
|
|
22
22
|
watcher.on(ALL_EVENT, (event, path) => eventHandler(queue, event, path, context));
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
module.exports = watch;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import child_process from "child_process";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
import { MESSAGE, PROCESS_TRANSPILE_FILE } from "../constants";
|
|
6
6
|
|
|
7
|
-
class TranspileFileWrapper {
|
|
7
|
+
export default class TranspileFileWrapper {
|
|
8
8
|
constructor(process, callback, parameters) {
|
|
9
9
|
this.process = process;
|
|
10
10
|
this.callback = callback;
|
|
@@ -61,5 +61,3 @@ class TranspileFileWrapper {
|
|
|
61
61
|
return transpileFileWrapper;
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
|
|
65
|
-
module.exports = TranspileFileWrapper;
|
package/watchful.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
const { parseArgv } = require("argumentative"),
|
|
4
4
|
{ arrayUtilities } = require("necessary");
|
|
5
5
|
|
|
6
|
-
const main = require("./
|
|
7
|
-
configure = require("./
|
|
8
|
-
abbreviations = require("./
|
|
6
|
+
const { default: main } = require("./lib/main"),
|
|
7
|
+
{ default: configure } = require("./lib/configure"),
|
|
8
|
+
{ default: abbreviations } = require("./lib/abbreviations");
|
|
9
9
|
|
|
10
10
|
const { first, second } = arrayUtilities;
|
|
11
11
|
|
package/bin/action/batch.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const action = require("../action"),
|
|
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
|
-
|
|
11
|
-
const { BATCH_BUILD_FAILED_MESSAGE } = require("../messages");
|
|
12
|
-
|
|
13
|
-
function batchAction(wait, node, debug, release, bundler, quietly, metrics, processes, entryFile, transpiler, bundleFile, libDirectory, tempDirectory, sourceDirectory) {
|
|
14
|
-
const operations = [
|
|
15
|
-
initialiseOperation,
|
|
16
|
-
createTranspileFileFunctionOperation,
|
|
17
|
-
createBundleFilesFunctionOperation,
|
|
18
|
-
retrieveFilePathsOperation,
|
|
19
|
-
transpileFilesOperation,
|
|
20
|
-
bundleFilesOperation
|
|
21
|
-
],
|
|
22
|
-
context = {
|
|
23
|
-
wait,
|
|
24
|
-
node,
|
|
25
|
-
debug,
|
|
26
|
-
release,
|
|
27
|
-
bundler,
|
|
28
|
-
quietly,
|
|
29
|
-
metrics,
|
|
30
|
-
processes,
|
|
31
|
-
entryFile,
|
|
32
|
-
transpiler,
|
|
33
|
-
bundleFile,
|
|
34
|
-
libDirectory,
|
|
35
|
-
tempDirectory,
|
|
36
|
-
sourceDirectory
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
action(operations, (success) => {
|
|
40
|
-
if (!success) {
|
|
41
|
-
console.log(BATCH_BUILD_FAILED_MESSAGE);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
process.exit(); ///
|
|
45
|
-
}, context);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
module.exports = batchAction;
|
package/bin/action/version.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const { packageUtilities } = require("necessary");
|
|
4
|
-
|
|
5
|
-
const { WATCHFUL_CLI } = require("../constants");
|
|
6
|
-
|
|
7
|
-
const { getVersion } = packageUtilities;
|
|
8
|
-
|
|
9
|
-
function versionAction() {
|
|
10
|
-
const version = getVersion(); ///
|
|
11
|
-
|
|
12
|
-
console.log(`${WATCHFUL_CLI} version ${version}`);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
module.exports = versionAction;
|
package/bin/commands.js
DELETED
package/bin/constants.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const S = "s",
|
|
4
|
-
SWC = "swc",
|
|
5
|
-
NODE = "node",
|
|
6
|
-
BABEL = "babel",
|
|
7
|
-
W_PLUS = "w+",
|
|
8
|
-
INLINE = "inline",
|
|
9
|
-
MESSAGE = "message",
|
|
10
|
-
ESBUILD = "esbuild",
|
|
11
|
-
BROWSERIFY = "browserify",
|
|
12
|
-
EMPTY_STRING = "",
|
|
13
|
-
WATCHFUL_CLI = "Watchful-CLI",
|
|
14
|
-
SOURCE_MAP_PREAMBLE = "//# sourceMappingURL=data:application/json;base64,",
|
|
15
|
-
PROCESS_TRANSPILE_FILE = "../process/transpileFile",
|
|
16
|
-
SOURCE_DIRECTORY_WATCH_PATTERN = "/**/*.js";
|
|
17
|
-
|
|
18
|
-
module.exports = {
|
|
19
|
-
S,
|
|
20
|
-
SWC,
|
|
21
|
-
NODE,
|
|
22
|
-
BABEL,
|
|
23
|
-
W_PLUS,
|
|
24
|
-
INLINE,
|
|
25
|
-
MESSAGE,
|
|
26
|
-
ESBUILD,
|
|
27
|
-
BROWSERIFY,
|
|
28
|
-
EMPTY_STRING,
|
|
29
|
-
WATCHFUL_CLI,
|
|
30
|
-
SOURCE_MAP_PREAMBLE,
|
|
31
|
-
PROCESS_TRANSPILE_FILE,
|
|
32
|
-
SOURCE_DIRECTORY_WATCH_PATTERN
|
|
33
|
-
};
|
package/bin/defaults.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const { BABEL, BROWSERIFY } = require("./constants");
|
|
4
|
-
|
|
5
|
-
const DEFAULT_HELP = false,
|
|
6
|
-
DEFAULT_WAIT = 0,
|
|
7
|
-
DEFAULT_NODE = false,
|
|
8
|
-
DEFAULT_DEBUG = false,
|
|
9
|
-
DEFAULT_RELEASE = false,
|
|
10
|
-
DEFAULT_BUNDLER = BROWSERIFY,
|
|
11
|
-
DEFAULT_VERSION = false,
|
|
12
|
-
DEFAULT_QUIETLY = false,
|
|
13
|
-
DEFAULT_METRICS = false,
|
|
14
|
-
DEFAULT_PROCESSES = 1,
|
|
15
|
-
DEFAULT_TRANSPILER = BABEL,
|
|
16
|
-
DEFAULT_ENTRY_FILE = null,
|
|
17
|
-
DEFAULT_BUNDLE_FILE = null,
|
|
18
|
-
DEFAULT_LIB_DIRECTORY = null,
|
|
19
|
-
DEFAULT_TEMP_DIRECTORY = null,
|
|
20
|
-
DEFAULT_SOURCE_DIRECTORY = null;
|
|
21
|
-
|
|
22
|
-
module.exports = {
|
|
23
|
-
DEFAULT_HELP,
|
|
24
|
-
DEFAULT_WAIT,
|
|
25
|
-
DEFAULT_NODE,
|
|
26
|
-
DEFAULT_DEBUG,
|
|
27
|
-
DEFAULT_RELEASE,
|
|
28
|
-
DEFAULT_BUNDLER,
|
|
29
|
-
DEFAULT_VERSION,
|
|
30
|
-
DEFAULT_QUIETLY,
|
|
31
|
-
DEFAULT_METRICS,
|
|
32
|
-
DEFAULT_PROCESSES,
|
|
33
|
-
DEFAULT_TRANSPILER,
|
|
34
|
-
DEFAULT_ENTRY_FILE,
|
|
35
|
-
DEFAULT_BUNDLE_FILE,
|
|
36
|
-
DEFAULT_LIB_DIRECTORY,
|
|
37
|
-
DEFAULT_TEMP_DIRECTORY,
|
|
38
|
-
DEFAULT_SOURCE_DIRECTORY
|
|
39
|
-
};
|
package/bin/events.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const ADD_EVENT = "add",
|
|
4
|
-
ALL_EVENT = "all",
|
|
5
|
-
READY_EVENT = "ready",
|
|
6
|
-
CHANGE_EVENT = "change",
|
|
7
|
-
UNLINK_EVENT = "unlink",
|
|
8
|
-
UNLINK_DIR_EVENT = "unlinkDir";
|
|
9
|
-
|
|
10
|
-
module.exports = {
|
|
11
|
-
ADD_EVENT,
|
|
12
|
-
ALL_EVENT,
|
|
13
|
-
READY_EVENT,
|
|
14
|
-
CHANGE_EVENT,
|
|
15
|
-
UNLINK_EVENT,
|
|
16
|
-
UNLINK_DIR_EVENT
|
|
17
|
-
};
|
package/bin/messages.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const SWC_FAILED_MESSAGE = "swc failed:",
|
|
4
|
-
BABEL_FAILED_MESSAGE = "Babel failed:",
|
|
5
|
-
ESBUILD_FAILED_MESSAGE = "esbuild failed.",
|
|
6
|
-
BROWSERIFY_FAILED_MESSAGE = "Browserify failed:",
|
|
7
|
-
BATCH_BUILD_FAILED_MESSAGE = "The batch build failed.",
|
|
8
|
-
INCREMENTAL_BUILD_FAILED_MESSAGE = "The incremental build failed.",
|
|
9
|
-
SWC_NOT_INSTALLED_MESSAGE = "The '@swc/core' package is not installed.",
|
|
10
|
-
BABEL_NOT_INSTALLED_MESSAGE = "The '@babel/core' package is not installed.",
|
|
11
|
-
ESBUILD_NOT_INSTALLED_MESSAGE = "esbuild is not installed.",
|
|
12
|
-
BROWSERIFY_NOT_INSTALLED_MESSAGE = "Browserify is not installed.",
|
|
13
|
-
NO_COMMAND_GIVEN_MESSAGE = "No command has been given.",
|
|
14
|
-
COMMAND_NOT_RECOGNISED_MESSAGE = "The command is not recognised.",
|
|
15
|
-
NO_ENTRY_FILE_SPECIFIED_MESSAGE = "If a temp directory is specified then an entry file must also be given.",
|
|
16
|
-
NO_BUNDLE_FILE_SPECIFIED_MESSAGE = "If a temp directory is specified then a bundle file must also be given.",
|
|
17
|
-
DEBUG_AND_RELEAES_BOTH_SET_MESSAGE = "The debug and release flags cannot both be set at the same time.",
|
|
18
|
-
NO_SOURCE_DIRECTORY_SPECIFIED_MESSAGE = "The source directory has not been specified.",
|
|
19
|
-
ENTRY_FILE_BUT_NO_BUNDLE_FILE_SPECIFIED_MESSAGE = "If an entry file is specified then a bundle file must also be given.",
|
|
20
|
-
BUNDLE_FILE_BUT_NO_ENTRY_FILE_SPECIFIED_MESSAGE = "If a bundle file is specified then an entry file must also be given.",
|
|
21
|
-
BOTH_LIB_AND_TEMP_DIRECTORIES_SPECIFIED_MESSAGE = "There is no need to specify both a lib and a temp directory.",
|
|
22
|
-
NEITHER_LIB_NOR_TEMP_DIRECTORY_SPECIFIED_MESSAGE = "Neither a lib directory nor a temp directory has been specified",
|
|
23
|
-
ENTRY_FILE_NOT_INCLUDED_IN_BUNDLED_FILES_MESSAGE = "The entry file is not included in the files to be bundled.",
|
|
24
|
-
ENTRY_FILE_PATH_NOT_RELATIVE_TO_CURRENT_DIRECTORY_MESSAGE = "The entry file path is not relative to the current directory.",
|
|
25
|
-
BUNDLE_FILE_PATH_NOT_RELATIVE_TO_CURRENT_DIRECTORY_MESSAGE = "The bundle file path is not relative to the current directory.",
|
|
26
|
-
LIB_DIRECTORY_PATH_NOT_RELATIVE_TO_CURRENT_DIRECTORY_MESSAGE = "The lib directory path is not relative to the current directory.",
|
|
27
|
-
TEMP_DIRECTORY_PATH_NOT_RELATIVE_TO_CURRENT_DIRECTORY_MESSAGE = "The temp directory path is not relative to the current directory.",
|
|
28
|
-
SOURCE_DIRECTORY_PATH_NOT_RELATIVE_TO_CURRENT_DIRECTORY_MESSAGE = "The source directory path is not relative to the current directory.";
|
|
29
|
-
|
|
30
|
-
module.exports = {
|
|
31
|
-
SWC_FAILED_MESSAGE,
|
|
32
|
-
BABEL_FAILED_MESSAGE,
|
|
33
|
-
ESBUILD_FAILED_MESSAGE,
|
|
34
|
-
BROWSERIFY_FAILED_MESSAGE,
|
|
35
|
-
BATCH_BUILD_FAILED_MESSAGE,
|
|
36
|
-
INCREMENTAL_BUILD_FAILED_MESSAGE,
|
|
37
|
-
SWC_NOT_INSTALLED_MESSAGE,
|
|
38
|
-
BABEL_NOT_INSTALLED_MESSAGE,
|
|
39
|
-
ESBUILD_NOT_INSTALLED_MESSAGE,
|
|
40
|
-
BROWSERIFY_NOT_INSTALLED_MESSAGE,
|
|
41
|
-
NO_COMMAND_GIVEN_MESSAGE,
|
|
42
|
-
COMMAND_NOT_RECOGNISED_MESSAGE,
|
|
43
|
-
NO_ENTRY_FILE_SPECIFIED_MESSAGE,
|
|
44
|
-
NO_BUNDLE_FILE_SPECIFIED_MESSAGE,
|
|
45
|
-
DEBUG_AND_RELEAES_BOTH_SET_MESSAGE,
|
|
46
|
-
NO_SOURCE_DIRECTORY_SPECIFIED_MESSAGE,
|
|
47
|
-
ENTRY_FILE_BUT_NO_BUNDLE_FILE_SPECIFIED_MESSAGE,
|
|
48
|
-
BUNDLE_FILE_BUT_NO_ENTRY_FILE_SPECIFIED_MESSAGE,
|
|
49
|
-
BOTH_LIB_AND_TEMP_DIRECTORIES_SPECIFIED_MESSAGE,
|
|
50
|
-
NEITHER_LIB_NOR_TEMP_DIRECTORY_SPECIFIED_MESSAGE,
|
|
51
|
-
ENTRY_FILE_NOT_INCLUDED_IN_BUNDLED_FILES_MESSAGE,
|
|
52
|
-
ENTRY_FILE_PATH_NOT_RELATIVE_TO_CURRENT_DIRECTORY_MESSAGE,
|
|
53
|
-
BUNDLE_FILE_PATH_NOT_RELATIVE_TO_CURRENT_DIRECTORY_MESSAGE,
|
|
54
|
-
LIB_DIRECTORY_PATH_NOT_RELATIVE_TO_CURRENT_DIRECTORY_MESSAGE,
|
|
55
|
-
TEMP_DIRECTORY_PATH_NOT_RELATIVE_TO_CURRENT_DIRECTORY_MESSAGE,
|
|
56
|
-
SOURCE_DIRECTORY_PATH_NOT_RELATIVE_TO_CURRENT_DIRECTORY_MESSAGE
|
|
57
|
-
};
|