just-task 1.11.0 → 1.13.0
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/CHANGELOG.json +37 -1
- package/CHANGELOG.md +19 -2
- package/lib/cache.js +13 -13
- package/lib/chain.js +2 -2
- package/lib/cli.js +8 -8
- package/lib/condition.js +1 -1
- package/lib/config.js +9 -9
- package/lib/enableTypeScript.js +3 -3
- package/lib/logger.d.ts +16 -1
- package/lib/logger.d.ts.map +1 -1
- package/lib/logger.js +52 -11
- package/lib/package/findDependents.js +10 -10
- package/lib/package/findPackageRoot.js +1 -1
- package/lib/resolve.js +2 -2
- package/lib/task.js +6 -6
- package/lib/undertaker.js +3 -3
- package/package.json +1 -2
- package/src/cache.ts +1 -1
- package/src/cli.ts +1 -1
- package/src/config.ts +2 -2
- package/src/enableTypeScript.ts +1 -1
- package/src/logger.ts +85 -1
- package/src/package/findDependents.ts +1 -1
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,43 @@
|
|
|
2
2
|
"name": "just-task",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "
|
|
5
|
+
"date": "Thu, 11 Dec 2025 17:20:50 GMT",
|
|
6
|
+
"version": "1.13.0",
|
|
7
|
+
"tag": "just-task_v1.13.0",
|
|
8
|
+
"comments": {
|
|
9
|
+
"minor": [
|
|
10
|
+
{
|
|
11
|
+
"author": "elcraig@microsoft.com",
|
|
12
|
+
"package": "just-task",
|
|
13
|
+
"commit": "9f2ae785ea8288e0dd60c4e684a17858c2d67902",
|
|
14
|
+
"comment": "Merge just-task-logger into this package"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"date": "Fri, 28 Mar 2025 08:01:48 GMT",
|
|
21
|
+
"version": "1.12.0",
|
|
22
|
+
"tag": "just-task_v1.12.0",
|
|
23
|
+
"comments": {
|
|
24
|
+
"minor": [
|
|
25
|
+
{
|
|
26
|
+
"author": "elcraig@microsoft.com",
|
|
27
|
+
"package": "just-task",
|
|
28
|
+
"commit": "b08901cb0e1ca7833027ae1e6473ff8dff7b4529",
|
|
29
|
+
"comment": "Build with TypeScript 4.5"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"author": "beachball",
|
|
33
|
+
"package": "just-task",
|
|
34
|
+
"comment": "Bump just-task-logger to v1.3.0",
|
|
35
|
+
"commit": "not available"
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"date": "Tue, 10 Dec 2024 22:22:46 GMT",
|
|
6
42
|
"version": "1.11.0",
|
|
7
43
|
"tag": "just-task_v1.11.0",
|
|
8
44
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,29 @@
|
|
|
1
1
|
# Change Log - just-task
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
<!-- This log was last generated on Thu, 11 Dec 2025 17:20:50 GMT and should not be manually modified. -->
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 1.13.0
|
|
8
|
+
|
|
9
|
+
Thu, 11 Dec 2025 17:20:50 GMT
|
|
10
|
+
|
|
11
|
+
### Minor changes
|
|
12
|
+
|
|
13
|
+
- Merge just-task-logger into this package (elcraig@microsoft.com)
|
|
14
|
+
|
|
15
|
+
## 1.12.0
|
|
16
|
+
|
|
17
|
+
Fri, 28 Mar 2025 08:01:48 GMT
|
|
18
|
+
|
|
19
|
+
### Minor changes
|
|
20
|
+
|
|
21
|
+
- Build with TypeScript 4.5 (elcraig@microsoft.com)
|
|
22
|
+
- Bump just-task-logger to v1.3.0
|
|
23
|
+
|
|
7
24
|
## 1.11.0
|
|
8
25
|
|
|
9
|
-
Tue, 10 Dec 2024 22:22:
|
|
26
|
+
Tue, 10 Dec 2024 22:22:46 GMT
|
|
10
27
|
|
|
11
28
|
### Minor changes
|
|
12
29
|
|
package/lib/cache.js
CHANGED
|
@@ -6,7 +6,7 @@ const option_1 = require("./option");
|
|
|
6
6
|
const resolve_1 = require("./resolve");
|
|
7
7
|
const fs = require("fs-extra");
|
|
8
8
|
const path = require("path");
|
|
9
|
-
const
|
|
9
|
+
const logger_1 = require("./logger");
|
|
10
10
|
const findDependents_1 = require("./package/findDependents");
|
|
11
11
|
const findGitRoot_1 = require("./package/findGitRoot");
|
|
12
12
|
const child_process_1 = require("child_process");
|
|
@@ -41,7 +41,7 @@ function isCached(taskName) {
|
|
|
41
41
|
shouldCache = JSON.stringify(currentHash) === JSON.stringify(cachedHash);
|
|
42
42
|
}
|
|
43
43
|
catch (e) {
|
|
44
|
-
|
|
44
|
+
logger_1.logger.warn('Invalid package-deps.json detected');
|
|
45
45
|
}
|
|
46
46
|
return shouldCache;
|
|
47
47
|
}
|
|
@@ -62,7 +62,7 @@ function saveCache(taskName) {
|
|
|
62
62
|
exports.saveCache = saveCache;
|
|
63
63
|
function getPackageRootPath() {
|
|
64
64
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
65
|
-
const packageJsonFilePath = resolve_1.resolveCwd('package.json');
|
|
65
|
+
const packageJsonFilePath = (0, resolve_1.resolveCwd)('package.json');
|
|
66
66
|
return path.dirname(packageJsonFilePath);
|
|
67
67
|
}
|
|
68
68
|
function getCachePath() {
|
|
@@ -72,8 +72,8 @@ function getCachePath() {
|
|
|
72
72
|
function getLockFileHashes() {
|
|
73
73
|
const results = {};
|
|
74
74
|
const lockFiles = ['shrinkwrap.yml', 'package-lock.json', 'yarn.lock', 'pnpmfile.js'];
|
|
75
|
-
const gitRoot = findGitRoot_1.findGitRoot();
|
|
76
|
-
const lsFileResults = child_process_1.spawnSync('git', ['ls-files', ...lockFiles], { cwd: gitRoot });
|
|
75
|
+
const gitRoot = (0, findGitRoot_1.findGitRoot)();
|
|
76
|
+
const lsFileResults = (0, child_process_1.spawnSync)('git', ['ls-files', ...lockFiles], { cwd: gitRoot });
|
|
77
77
|
if (lsFileResults.status !== 0) {
|
|
78
78
|
return {};
|
|
79
79
|
}
|
|
@@ -81,7 +81,7 @@ function getLockFileHashes() {
|
|
|
81
81
|
.toString()
|
|
82
82
|
.split(/\n/)
|
|
83
83
|
.map(l => l.trim());
|
|
84
|
-
const hashResults = child_process_1.spawnSync('git', ['hash-object', ...foundLockFiles], { cwd: gitRoot });
|
|
84
|
+
const hashResults = (0, child_process_1.spawnSync)('git', ['hash-object', ...foundLockFiles], { cwd: gitRoot });
|
|
85
85
|
if (hashResults.status !== 0) {
|
|
86
86
|
return {};
|
|
87
87
|
}
|
|
@@ -95,11 +95,11 @@ function getLockFileHashes() {
|
|
|
95
95
|
return results;
|
|
96
96
|
}
|
|
97
97
|
function getHash(taskName) {
|
|
98
|
-
|
|
99
|
-
const { ...args } = option_1.argv();
|
|
98
|
+
(0, logger_1.mark)('cache:getHash');
|
|
99
|
+
const { ...args } = (0, option_1.argv)();
|
|
100
100
|
const packageRootPath = getPackageRootPath();
|
|
101
101
|
const packageDeps = {
|
|
102
|
-
...Object.fromEntries(package_deps_hash_1.getPackageDeps(packageRootPath)),
|
|
102
|
+
...Object.fromEntries((0, package_deps_hash_1.getPackageDeps)(packageRootPath)),
|
|
103
103
|
...getLockFileHashes(),
|
|
104
104
|
};
|
|
105
105
|
const hash = {
|
|
@@ -108,12 +108,12 @@ function getHash(taskName) {
|
|
|
108
108
|
hash: packageDeps,
|
|
109
109
|
dependentHashTimestamps: getDependentHashTimestamps(),
|
|
110
110
|
};
|
|
111
|
-
|
|
111
|
+
logger_1.logger.perf('cache:getHash');
|
|
112
112
|
return hash;
|
|
113
113
|
}
|
|
114
114
|
function getDependentHashTimestamps() {
|
|
115
|
-
|
|
116
|
-
const dependentPkgPaths = findDependents_1.findDependents();
|
|
115
|
+
(0, logger_1.mark)('cache:getDependentHashTimestamps');
|
|
116
|
+
const dependentPkgPaths = (0, findDependents_1.findDependents)();
|
|
117
117
|
const timestampsByPackage = {};
|
|
118
118
|
for (const pkgDepInfo of dependentPkgPaths) {
|
|
119
119
|
const pkgPath = pkgDepInfo.path;
|
|
@@ -128,6 +128,6 @@ function getDependentHashTimestamps() {
|
|
|
128
128
|
timestampsByPackage[pkgDepInfo.name] = new Date().getTime();
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
-
|
|
131
|
+
logger_1.logger.perf('cache:getDependentHashTimestamps');
|
|
132
132
|
return timestampsByPackage;
|
|
133
133
|
}
|
package/lib/chain.js
CHANGED
|
@@ -11,13 +11,13 @@ function chain(subjectTaskName) {
|
|
|
11
11
|
const id = `${taskName}_before_${counter++}?`;
|
|
12
12
|
const subject = undertaker_1.undertaker.task(subjectTaskName);
|
|
13
13
|
undertaker_1.undertaker.task(id, undertaker_1.undertaker.task(taskName));
|
|
14
|
-
undertaker_1.undertaker.task(taskName, undertaker_1.series(subject, id));
|
|
14
|
+
undertaker_1.undertaker.task(taskName, (0, undertaker_1.series)(subject, id));
|
|
15
15
|
},
|
|
16
16
|
after: function runAfter(taskName) {
|
|
17
17
|
const id = `${taskName}_after_${counter++}?`;
|
|
18
18
|
const subject = undertaker_1.undertaker.task(subjectTaskName);
|
|
19
19
|
undertaker_1.undertaker.task(id, undertaker_1.undertaker.task(taskName));
|
|
20
|
-
undertaker_1.undertaker.task(taskName, undertaker_1.series(id, subject));
|
|
20
|
+
undertaker_1.undertaker.task(taskName, (0, undertaker_1.series)(id, subject));
|
|
21
21
|
},
|
|
22
22
|
};
|
|
23
23
|
}
|
package/lib/cli.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const undertaker_1 = require("./undertaker");
|
|
4
4
|
const option_1 = require("./option");
|
|
5
|
-
const
|
|
5
|
+
const logger_1 = require("./logger");
|
|
6
6
|
const config_1 = require("./config");
|
|
7
7
|
const task_1 = require("./task");
|
|
8
8
|
const originalEmitWarning = process.emitWarning;
|
|
@@ -30,32 +30,32 @@ function showHelp() {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
// Define a built-in option of "config" so users can specify which path to choose for configurations
|
|
33
|
-
option_1.option('config', {
|
|
33
|
+
(0, option_1.option)('config', {
|
|
34
34
|
describe: 'path to a just configuration file (includes the file name, e.g. /path/to/just.config.ts)',
|
|
35
35
|
});
|
|
36
|
-
option_1.option('defaultConfig', {
|
|
36
|
+
(0, option_1.option)('defaultConfig', {
|
|
37
37
|
describe: 'path to a default just configuration file that will be used when the current project does not have a just configuration file. (includes the file name, e.g. /path/to/just.config.ts)',
|
|
38
38
|
});
|
|
39
|
-
option_1.option('esm', {
|
|
39
|
+
(0, option_1.option)('esm', {
|
|
40
40
|
describe: 'Configure ts-node to support imports of ESM package (changes TS module/moduleResolution settings to Node16)',
|
|
41
41
|
});
|
|
42
42
|
const registry = undertaker_1.undertaker.registry();
|
|
43
|
-
const configModule = config_1.readConfig();
|
|
43
|
+
const configModule = (0, config_1.readConfig)();
|
|
44
44
|
// Support named task function as exports of a config module
|
|
45
45
|
if (configModule && typeof configModule === 'object') {
|
|
46
46
|
for (const taskName of Object.keys(configModule)) {
|
|
47
47
|
if (typeof configModule[taskName] == 'function') {
|
|
48
|
-
task_1.task(taskName, configModule[taskName]);
|
|
48
|
+
(0, task_1.task)(taskName, configModule[taskName]);
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
const command = option_1.parseCommand();
|
|
52
|
+
const command = (0, option_1.parseCommand)();
|
|
53
53
|
if (command) {
|
|
54
54
|
if (registry.get(command)) {
|
|
55
55
|
undertaker_1.undertaker.series(registry.get(command))(() => undefined);
|
|
56
56
|
}
|
|
57
57
|
else {
|
|
58
|
-
|
|
58
|
+
logger_1.logger.error(`Command not defined: ${command}`);
|
|
59
59
|
process.exitCode = 1;
|
|
60
60
|
}
|
|
61
61
|
}
|
package/lib/condition.js
CHANGED
|
@@ -5,7 +5,7 @@ const undertaker_1 = require("./undertaker");
|
|
|
5
5
|
function condition(taskName, conditional) {
|
|
6
6
|
return function (done) {
|
|
7
7
|
if (conditional && conditional()) {
|
|
8
|
-
undertaker_1.parallel(taskName)(done);
|
|
8
|
+
(0, undertaker_1.parallel)(taskName)(done);
|
|
9
9
|
}
|
|
10
10
|
else {
|
|
11
11
|
done();
|
package/lib/config.js
CHANGED
|
@@ -5,7 +5,7 @@ const fs = require("fs");
|
|
|
5
5
|
const path = require("path");
|
|
6
6
|
const option_1 = require("./option");
|
|
7
7
|
const resolve_1 = require("./resolve");
|
|
8
|
-
const
|
|
8
|
+
const logger_1 = require("./logger");
|
|
9
9
|
const enableTypeScript_1 = require("./enableTypeScript");
|
|
10
10
|
function resolveConfigFile(args) {
|
|
11
11
|
for (const entry of [
|
|
@@ -17,7 +17,7 @@ function resolveConfigFile(args) {
|
|
|
17
17
|
'./just.config.cts',
|
|
18
18
|
args.defaultConfig,
|
|
19
19
|
]) {
|
|
20
|
-
const configFile = resolve_1.resolve(entry);
|
|
20
|
+
const configFile = (0, resolve_1.resolve)(entry);
|
|
21
21
|
if (configFile) {
|
|
22
22
|
return configFile;
|
|
23
23
|
}
|
|
@@ -27,31 +27,31 @@ function resolveConfigFile(args) {
|
|
|
27
27
|
exports.resolveConfigFile = resolveConfigFile;
|
|
28
28
|
function readConfig() {
|
|
29
29
|
// uses a separate instance of yargs to first parse the config (without the --help in the way) so we can parse the configFile first regardless
|
|
30
|
-
const args = option_1.argv();
|
|
30
|
+
const args = (0, option_1.argv)();
|
|
31
31
|
const configFile = resolveConfigFile(args);
|
|
32
32
|
if (configFile && fs.existsSync(configFile)) {
|
|
33
33
|
const ext = path.extname(configFile);
|
|
34
34
|
if (ext === '.cts' || ext === '.ts' || ext === '.tsx') {
|
|
35
35
|
// TODO: add option to do typechecking as well
|
|
36
|
-
enableTypeScript_1.enableTypeScript({ transpileOnly: true, esm: args.esm });
|
|
36
|
+
(0, enableTypeScript_1.enableTypeScript)({ transpileOnly: true, esm: args.esm });
|
|
37
37
|
}
|
|
38
38
|
try {
|
|
39
39
|
const configModule = require(configFile);
|
|
40
|
-
|
|
40
|
+
(0, logger_1.mark)('registry:configModule');
|
|
41
41
|
if (typeof configModule === 'function') {
|
|
42
42
|
configModule();
|
|
43
43
|
}
|
|
44
|
-
|
|
44
|
+
logger_1.logger.perf('registry:configModule');
|
|
45
45
|
return configModule;
|
|
46
46
|
}
|
|
47
47
|
catch (e) {
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
logger_1.logger.error(`Invalid configuration file: ${configFile}`);
|
|
49
|
+
logger_1.logger.error(`Error: ${e.stack || e.message || e}`);
|
|
50
50
|
process.exit(1);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
else {
|
|
54
|
-
|
|
54
|
+
logger_1.logger.error(`Cannot find config file "${configFile}".`, `Please create a file called "just.config.js" in the root of the project next to "package.json".`);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
exports.readConfig = readConfig;
|
package/lib/enableTypeScript.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.enableTypeScript = void 0;
|
|
4
4
|
const resolve_1 = require("./resolve");
|
|
5
|
-
const
|
|
5
|
+
const logger_1 = require("./logger");
|
|
6
6
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
7
7
|
function enableTypeScript({ transpileOnly = true, esm = false }) {
|
|
8
|
-
const tsNodeModule = resolve_1.resolve('ts-node');
|
|
8
|
+
const tsNodeModule = (0, resolve_1.resolve)('ts-node');
|
|
9
9
|
if (tsNodeModule) {
|
|
10
10
|
const tsNode = require(tsNodeModule);
|
|
11
11
|
tsNode.register({
|
|
@@ -25,7 +25,7 @@ function enableTypeScript({ transpileOnly = true, esm = false }) {
|
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
else {
|
|
28
|
-
|
|
28
|
+
logger_1.logger.error(`In order to use TypeScript with just.config.ts, you need to install "ts-node" module:
|
|
29
29
|
|
|
30
30
|
npm install -D ts-node
|
|
31
31
|
|
package/lib/logger.d.ts
CHANGED
|
@@ -1,2 +1,17 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare function mark(marker: string): void;
|
|
2
|
+
export interface Logger {
|
|
3
|
+
/** Whether verbose logging is enabled. Default false unless --verbose arg is given. */
|
|
4
|
+
enableVerbose: boolean;
|
|
5
|
+
/** Log to `console.info` with a timestamp, but only if verbose logging is enabled. */
|
|
6
|
+
verbose(...args: any[]): void;
|
|
7
|
+
/** Log to `console.info` with a timestamp. */
|
|
8
|
+
info(...args: any[]): void;
|
|
9
|
+
/** Log to `console.warn` with a timestamp. */
|
|
10
|
+
warn(...args: any[]): void;
|
|
11
|
+
/** Log to `console.error` with a timestamp. */
|
|
12
|
+
error(...args: any[]): void;
|
|
13
|
+
/** Log perf marker data to `consold.info` with timestamp, only if verbose is enabled */
|
|
14
|
+
perf(marker: string, ...args: any[]): void;
|
|
15
|
+
}
|
|
16
|
+
export declare const logger: Logger;
|
|
2
17
|
//# sourceMappingURL=logger.d.ts.map
|
package/lib/logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAcA,wBAAgB,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAEzC;AAYD,MAAM,WAAW,MAAM;IACrB,uFAAuF;IACvF,aAAa,EAAE,OAAO,CAAC;IACvB,sFAAsF;IACtF,OAAO,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAC9B,8CAA8C;IAC9C,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAC3B,8CAA8C;IAC9C,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAC3B,+CAA+C;IAC/C,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAC5B,wFAAwF;IACxF,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;CAC5C;AAMD,eAAO,MAAM,MAAM,EAAE,MAqCpB,CAAC"}
|
package/lib/logger.js
CHANGED
|
@@ -1,13 +1,54 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
-
};
|
|
12
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
|
|
3
|
+
exports.logger = exports.mark = void 0;
|
|
4
|
+
const chalk = require("chalk");
|
|
5
|
+
const parser = require("yargs-parser");
|
|
6
|
+
const argv = parser(process.argv.slice(2));
|
|
7
|
+
function logInternal(method, symbol, ...args) {
|
|
8
|
+
const now = new Date();
|
|
9
|
+
const timestamp = chalk.gray(`[${now.toLocaleTimeString()}]`);
|
|
10
|
+
console[method](timestamp, symbol, ...args);
|
|
11
|
+
}
|
|
12
|
+
const markers = {};
|
|
13
|
+
function mark(marker) {
|
|
14
|
+
markers[marker] = process.hrtime();
|
|
15
|
+
}
|
|
16
|
+
exports.mark = mark;
|
|
17
|
+
function getDeltaAndClearMark(marker) {
|
|
18
|
+
if (markers[marker]) {
|
|
19
|
+
const delta = process.hrtime(markers[marker]);
|
|
20
|
+
delete markers[marker];
|
|
21
|
+
return delta;
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
const emptySquare = '\u25a1';
|
|
26
|
+
const square = '\u25a0';
|
|
27
|
+
const triangle = '\u25b2';
|
|
28
|
+
exports.logger = {
|
|
29
|
+
enableVerbose: !!argv.verbose,
|
|
30
|
+
verbose(...args) {
|
|
31
|
+
if (exports.logger.enableVerbose) {
|
|
32
|
+
logInternal('info', chalk.gray(emptySquare), ...args);
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
info(...args) {
|
|
36
|
+
logInternal('info', chalk.green(square), ...args);
|
|
37
|
+
},
|
|
38
|
+
warn(...args) {
|
|
39
|
+
logInternal('warn', chalk.yellow(triangle), ...args);
|
|
40
|
+
},
|
|
41
|
+
error(...args) {
|
|
42
|
+
logInternal('error', chalk.redBright('x'), ...args);
|
|
43
|
+
},
|
|
44
|
+
perf(marker, ...args) {
|
|
45
|
+
if (exports.logger.enableVerbose) {
|
|
46
|
+
const delta = getDeltaAndClearMark(marker);
|
|
47
|
+
if (delta) {
|
|
48
|
+
const ns = delta[0] * 1e9 + delta[1];
|
|
49
|
+
const deltaMsg = `${ns / 1e9}s`;
|
|
50
|
+
logInternal('info', chalk.cyan(square), `mark(${chalk.cyanBright(marker)}): took ${chalk.cyanBright(deltaMsg)}`, ...args);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
};
|
|
@@ -5,18 +5,18 @@ const fs = require("fs");
|
|
|
5
5
|
const path = require("path");
|
|
6
6
|
const resolve_1 = require("../resolve");
|
|
7
7
|
const findPackageRoot_1 = require("./findPackageRoot");
|
|
8
|
-
const
|
|
8
|
+
const logger_1 = require("../logger");
|
|
9
9
|
const findGitRoot_1 = require("./findGitRoot");
|
|
10
10
|
const paths_1 = require("../paths");
|
|
11
11
|
function findDependents() {
|
|
12
|
-
|
|
13
|
-
const results = collectAllDependentPaths(findPackageRoot_1.findPackageRoot());
|
|
14
|
-
|
|
12
|
+
(0, logger_1.mark)('cache:findDependents');
|
|
13
|
+
const results = collectAllDependentPaths((0, findPackageRoot_1.findPackageRoot)());
|
|
14
|
+
logger_1.logger.perf('cache:findDependents');
|
|
15
15
|
return results;
|
|
16
16
|
}
|
|
17
17
|
exports.findDependents = findDependents;
|
|
18
18
|
function getDepsPaths(pkgPath) {
|
|
19
|
-
const gitRoot = findGitRoot_1.findGitRoot();
|
|
19
|
+
const gitRoot = (0, findGitRoot_1.findGitRoot)();
|
|
20
20
|
const packageJsonFile = path.join(pkgPath, 'package.json');
|
|
21
21
|
try {
|
|
22
22
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonFile).toString());
|
|
@@ -29,21 +29,21 @@ function getDepsPaths(pkgPath) {
|
|
|
29
29
|
return deps
|
|
30
30
|
.map(dep => {
|
|
31
31
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
32
|
-
const depPackageJson = resolve_1.resolveCwd(path.join(dep, 'package.json'));
|
|
32
|
+
const depPackageJson = (0, resolve_1.resolveCwd)(path.join(dep, 'package.json'));
|
|
33
33
|
if (!depPackageJson) {
|
|
34
34
|
return null;
|
|
35
35
|
}
|
|
36
36
|
return { name: dep, path: path.dirname(fs.realpathSync(depPackageJson)) };
|
|
37
37
|
})
|
|
38
|
-
.filter(p => p && p.path.indexOf('node_modules') === -1 && paths_1.isChildOf(p.path, gitRoot));
|
|
38
|
+
.filter(p => p && p.path.indexOf('node_modules') === -1 && (0, paths_1.isChildOf)(p.path, gitRoot));
|
|
39
39
|
}
|
|
40
40
|
catch (e) {
|
|
41
|
-
|
|
41
|
+
logger_1.logger.error(`Invalid package.json detected at ${packageJsonFile} `, e);
|
|
42
42
|
return [];
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
function collectAllDependentPaths(pkgPath, collected = new Set()) {
|
|
46
|
-
|
|
46
|
+
(0, logger_1.mark)(`collectAllDependentPaths:${pkgPath}`);
|
|
47
47
|
const depPaths = getDepsPaths(pkgPath);
|
|
48
48
|
depPaths.forEach(depPath => collected.add(depPath));
|
|
49
49
|
for (const depPath of depPaths) {
|
|
@@ -51,6 +51,6 @@ function collectAllDependentPaths(pkgPath, collected = new Set()) {
|
|
|
51
51
|
collectAllDependentPaths(depPath.path, collected);
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
|
|
54
|
+
logger_1.logger.perf(`collectAllDependentPaths:${pkgPath}`);
|
|
55
55
|
return collected;
|
|
56
56
|
}
|
|
@@ -5,7 +5,7 @@ const path = require("path");
|
|
|
5
5
|
const resolve_1 = require("../resolve");
|
|
6
6
|
function findPackageRoot() {
|
|
7
7
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
8
|
-
const packageJsonFilePath = resolve_1.resolveCwd('package.json');
|
|
8
|
+
const packageJsonFilePath = (0, resolve_1.resolveCwd)('package.json');
|
|
9
9
|
return path.dirname(packageJsonFilePath);
|
|
10
10
|
}
|
|
11
11
|
exports.findPackageRoot = findPackageRoot;
|
package/lib/resolve.js
CHANGED
|
@@ -36,7 +36,7 @@ function _tryResolve(moduleName, options) {
|
|
|
36
36
|
try {
|
|
37
37
|
const { cwd, ...rest } = options;
|
|
38
38
|
const nameToResolve = _isFileNameLike(moduleName) ? `./${moduleName}` : moduleName;
|
|
39
|
-
return resolve_1.sync(nameToResolve, { basedir: cwd, ...rest, preserveSymlinks: true });
|
|
39
|
+
return (0, resolve_1.sync)(nameToResolve, { basedir: cwd, ...rest, preserveSymlinks: true });
|
|
40
40
|
}
|
|
41
41
|
catch (e) {
|
|
42
42
|
return null;
|
|
@@ -51,7 +51,7 @@ function _getResolvePaths(cwd) {
|
|
|
51
51
|
if (!cwd) {
|
|
52
52
|
cwd = process.cwd();
|
|
53
53
|
}
|
|
54
|
-
const configArg = option_1.argv().config;
|
|
54
|
+
const configArg = (0, option_1.argv)().config;
|
|
55
55
|
const configFilePath = configArg ? path.resolve(path.dirname(configArg)) : undefined;
|
|
56
56
|
return [cwd, ...(configFilePath ? [configFilePath] : []), ...customResolvePaths, __dirname];
|
|
57
57
|
}
|
package/lib/task.js
CHANGED
|
@@ -11,9 +11,9 @@ function task(firstParam, secondParam, thirdParam) {
|
|
|
11
11
|
}
|
|
12
12
|
else if (argCount === 2 && isString(firstParam) && isString(secondParam)) {
|
|
13
13
|
// task('default', 'build');
|
|
14
|
-
const wrapped = wrapTask_1.wrapTask(undertaker_1.undertaker.series(secondParam));
|
|
14
|
+
const wrapped = (0, wrapTask_1.wrapTask)(undertaker_1.undertaker.series(secondParam));
|
|
15
15
|
wrapped.cached = () => {
|
|
16
|
-
cache_1.registerCachedTask(firstParam);
|
|
16
|
+
(0, cache_1.registerCachedTask)(firstParam);
|
|
17
17
|
};
|
|
18
18
|
undertaker_1.undertaker.task(firstParam, wrapped);
|
|
19
19
|
return wrapped;
|
|
@@ -21,18 +21,18 @@ function task(firstParam, secondParam, thirdParam) {
|
|
|
21
21
|
else if (argCount === 2 && isString(firstParam) && isTaskFunction(secondParam)) {
|
|
22
22
|
// task('pretter', prettierTask());
|
|
23
23
|
// task('custom', () => { ... });
|
|
24
|
-
const wrapped = wrapTask_1.wrapTask(secondParam);
|
|
24
|
+
const wrapped = (0, wrapTask_1.wrapTask)(secondParam);
|
|
25
25
|
wrapped.cached = () => {
|
|
26
|
-
cache_1.registerCachedTask(firstParam);
|
|
26
|
+
(0, cache_1.registerCachedTask)(firstParam);
|
|
27
27
|
};
|
|
28
28
|
undertaker_1.undertaker.task(firstParam, wrapped);
|
|
29
29
|
return wrapped;
|
|
30
30
|
}
|
|
31
31
|
else if (argCount === 3 && isString(firstParam) && isString(secondParam) && isTaskFunction(thirdParam)) {
|
|
32
32
|
// task('custom', 'describes this thing', () => { ... })
|
|
33
|
-
const wrapped = wrapTask_1.wrapTask(thirdParam);
|
|
33
|
+
const wrapped = (0, wrapTask_1.wrapTask)(thirdParam);
|
|
34
34
|
wrapped.cached = () => {
|
|
35
|
-
cache_1.registerCachedTask(firstParam);
|
|
35
|
+
(0, cache_1.registerCachedTask)(firstParam);
|
|
36
36
|
};
|
|
37
37
|
wrapped.description = secondParam;
|
|
38
38
|
undertaker_1.undertaker.task(firstParam, wrapped);
|
package/lib/undertaker.js
CHANGED
|
@@ -65,7 +65,7 @@ undertaker.on('error', function (args) {
|
|
|
65
65
|
logger_1.logger.error(args.error.stderr);
|
|
66
66
|
}
|
|
67
67
|
logger_1.logger.error(chalk.yellow('------------------------------------'));
|
|
68
|
-
cache_1.clearCache();
|
|
68
|
+
(0, cache_1.clearCache)();
|
|
69
69
|
process.exitCode = 1;
|
|
70
70
|
}
|
|
71
71
|
else if (shouldLog(args)) {
|
|
@@ -94,7 +94,7 @@ function parallel(...tasks) {
|
|
|
94
94
|
return task;
|
|
95
95
|
}
|
|
96
96
|
else {
|
|
97
|
-
return wrapTask_1.wrapTask(task);
|
|
97
|
+
return (0, wrapTask_1.wrapTask)(task);
|
|
98
98
|
}
|
|
99
99
|
});
|
|
100
100
|
return undertaker.parallel(newTasks);
|
|
@@ -106,7 +106,7 @@ function series(...tasks) {
|
|
|
106
106
|
return task;
|
|
107
107
|
}
|
|
108
108
|
else {
|
|
109
|
-
return wrapTask_1.wrapTask(task);
|
|
109
|
+
return (0, wrapTask_1.wrapTask)(task);
|
|
110
110
|
}
|
|
111
111
|
});
|
|
112
112
|
return undertaker.series(newTasks);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "just-task",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
4
4
|
"description": "Build task definition library",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"repository": {
|
|
@@ -34,7 +34,6 @@
|
|
|
34
34
|
"chalk": "^4.0.0",
|
|
35
35
|
"chokidar": "^3.5.2",
|
|
36
36
|
"fs-extra": "^11.0.0",
|
|
37
|
-
"just-task-logger": ">=1.2.1 <2.0.0",
|
|
38
37
|
"resolve": "^1.19.0",
|
|
39
38
|
"undertaker": "^2.0.0",
|
|
40
39
|
"undertaker-registry": "^2.0.0",
|
package/src/cache.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { argv } from './option';
|
|
|
3
3
|
import { resolveCwd } from './resolve';
|
|
4
4
|
import * as fs from 'fs-extra';
|
|
5
5
|
import * as path from 'path';
|
|
6
|
-
import { logger, mark } from '
|
|
6
|
+
import { logger, mark } from './logger';
|
|
7
7
|
import { findDependents } from './package/findDependents';
|
|
8
8
|
import { findGitRoot } from './package/findGitRoot';
|
|
9
9
|
import { spawnSync } from 'child_process';
|
package/src/cli.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { undertaker } from './undertaker';
|
|
2
2
|
import { option, parseCommand } from './option';
|
|
3
|
-
import { logger } from '
|
|
3
|
+
import { logger } from './logger';
|
|
4
4
|
import { TaskFunction } from './interfaces';
|
|
5
5
|
import { readConfig } from './config';
|
|
6
6
|
import { task } from './task';
|
package/src/config.ts
CHANGED
|
@@ -3,7 +3,7 @@ import * as path from 'path';
|
|
|
3
3
|
|
|
4
4
|
import { argv } from './option';
|
|
5
5
|
import { resolve } from './resolve';
|
|
6
|
-
import { mark, logger } from '
|
|
6
|
+
import { mark, logger } from './logger';
|
|
7
7
|
import { enableTypeScript } from './enableTypeScript';
|
|
8
8
|
import yargsParser = require('yargs-parser');
|
|
9
9
|
import { TaskFunction } from './interfaces';
|
|
@@ -53,7 +53,7 @@ export function readConfig(): { [key: string]: TaskFunction } | void {
|
|
|
53
53
|
return configModule;
|
|
54
54
|
} catch (e) {
|
|
55
55
|
logger.error(`Invalid configuration file: ${configFile}`);
|
|
56
|
-
logger.error(`Error: ${e.stack || e.message || e}`);
|
|
56
|
+
logger.error(`Error: ${(e as Error).stack || (e as Error).message || e}`);
|
|
57
57
|
process.exit(1);
|
|
58
58
|
}
|
|
59
59
|
} else {
|
package/src/enableTypeScript.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { resolve } from './resolve';
|
|
2
|
-
import { logger } from '
|
|
2
|
+
import { logger } from './logger';
|
|
3
3
|
|
|
4
4
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
5
5
|
export function enableTypeScript({ transpileOnly = true, esm = false }): void {
|
package/src/logger.ts
CHANGED
|
@@ -1 +1,85 @@
|
|
|
1
|
-
|
|
1
|
+
import chalk = require('chalk');
|
|
2
|
+
import * as parser from 'yargs-parser';
|
|
3
|
+
|
|
4
|
+
const argv = parser(process.argv.slice(2));
|
|
5
|
+
|
|
6
|
+
function logInternal(method: 'info' | 'warn' | 'error', symbol: string, ...args: any[]) {
|
|
7
|
+
const now = new Date();
|
|
8
|
+
const timestamp = chalk.gray(`[${now.toLocaleTimeString()}]`);
|
|
9
|
+
|
|
10
|
+
console[method](timestamp, symbol, ...args);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const markers: { [marker: string]: [number, number] } = {};
|
|
14
|
+
|
|
15
|
+
export function mark(marker: string): void {
|
|
16
|
+
markers[marker] = process.hrtime();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function getDeltaAndClearMark(marker: string): [number, number] | null {
|
|
20
|
+
if (markers[marker]) {
|
|
21
|
+
const delta = process.hrtime(markers[marker]);
|
|
22
|
+
delete markers[marker];
|
|
23
|
+
return delta;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface Logger {
|
|
30
|
+
/** Whether verbose logging is enabled. Default false unless --verbose arg is given. */
|
|
31
|
+
enableVerbose: boolean;
|
|
32
|
+
/** Log to `console.info` with a timestamp, but only if verbose logging is enabled. */
|
|
33
|
+
verbose(...args: any[]): void;
|
|
34
|
+
/** Log to `console.info` with a timestamp. */
|
|
35
|
+
info(...args: any[]): void;
|
|
36
|
+
/** Log to `console.warn` with a timestamp. */
|
|
37
|
+
warn(...args: any[]): void;
|
|
38
|
+
/** Log to `console.error` with a timestamp. */
|
|
39
|
+
error(...args: any[]): void;
|
|
40
|
+
/** Log perf marker data to `consold.info` with timestamp, only if verbose is enabled */
|
|
41
|
+
perf(marker: string, ...args: any[]): void;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const emptySquare = '\u25a1';
|
|
45
|
+
const square = '\u25a0';
|
|
46
|
+
const triangle = '\u25b2';
|
|
47
|
+
|
|
48
|
+
export const logger: Logger = {
|
|
49
|
+
enableVerbose: !!argv.verbose,
|
|
50
|
+
|
|
51
|
+
verbose(...args: any[]) {
|
|
52
|
+
if (logger.enableVerbose) {
|
|
53
|
+
logInternal('info', chalk.gray(emptySquare), ...args);
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
info(...args: any[]) {
|
|
58
|
+
logInternal('info', chalk.green(square), ...args);
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
warn(...args: any[]) {
|
|
62
|
+
logInternal('warn', chalk.yellow(triangle), ...args);
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
error(...args: any[]) {
|
|
66
|
+
logInternal('error', chalk.redBright('x'), ...args);
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
perf(marker: string, ...args: any[]) {
|
|
70
|
+
if (logger.enableVerbose) {
|
|
71
|
+
const delta = getDeltaAndClearMark(marker);
|
|
72
|
+
|
|
73
|
+
if (delta) {
|
|
74
|
+
const ns = delta[0] * 1e9 + delta[1];
|
|
75
|
+
const deltaMsg = `${ns / 1e9}s`;
|
|
76
|
+
logInternal(
|
|
77
|
+
'info',
|
|
78
|
+
chalk.cyan(square),
|
|
79
|
+
`mark(${chalk.cyanBright(marker)}): took ${chalk.cyanBright(deltaMsg)}`,
|
|
80
|
+
...args,
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
};
|
|
@@ -2,7 +2,7 @@ import * as fs from 'fs';
|
|
|
2
2
|
import * as path from 'path';
|
|
3
3
|
import { resolveCwd } from '../resolve';
|
|
4
4
|
import { findPackageRoot } from './findPackageRoot';
|
|
5
|
-
import { logger, mark } from '
|
|
5
|
+
import { logger, mark } from '../logger';
|
|
6
6
|
import { findGitRoot } from './findGitRoot';
|
|
7
7
|
import { isChildOf } from '../paths';
|
|
8
8
|
|