just-task 1.4.0 → 1.5.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 CHANGED
@@ -2,7 +2,52 @@
2
2
  "name": "just-task",
3
3
  "entries": [
4
4
  {
5
- "date": "Fri, 02 Apr 2021 23:21:41 GMT",
5
+ "date": "Thu, 31 Mar 2022 17:04:25 GMT",
6
+ "tag": "just-task_v1.5.0",
7
+ "version": "1.5.0",
8
+ "comments": {
9
+ "minor": [
10
+ {
11
+ "author": "dzearing@microsoft.com",
12
+ "package": "just-task",
13
+ "comment": "Upgrading package-deps-hash to latest major to remove transitive security vulnerability in validator package.",
14
+ "commit": "0c2e911432d9c09a7b3396d40c811260d84749ac"
15
+ }
16
+ ]
17
+ }
18
+ },
19
+ {
20
+ "date": "Fri, 10 Sep 2021 23:58:46 GMT",
21
+ "tag": "just-task_v1.4.2",
22
+ "version": "1.4.2",
23
+ "comments": {
24
+ "patch": [
25
+ {
26
+ "author": "kchau@microsoft.com",
27
+ "package": "just-task",
28
+ "comment": "changes the dep from glob-parent which is old with chokidar directly",
29
+ "commit": "c08ccdcce333d655504263efd18f7fc5e82da534"
30
+ }
31
+ ]
32
+ }
33
+ },
34
+ {
35
+ "date": "Thu, 15 Apr 2021 19:00:12 GMT",
36
+ "tag": "just-task_v1.4.1",
37
+ "version": "1.4.1",
38
+ "comments": {
39
+ "patch": [
40
+ {
41
+ "comment": "adding a check to make sure the tasks are registered only for task functions",
42
+ "author": "kchau@microsoft.com",
43
+ "commit": "52359d26690342474ce9e224f6bc2dfb94766089",
44
+ "package": "just-task"
45
+ }
46
+ ]
47
+ }
48
+ },
49
+ {
50
+ "date": "Fri, 02 Apr 2021 23:21:50 GMT",
6
51
  "tag": "just-task_v1.4.0",
7
52
  "version": "1.4.0",
8
53
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,36 @@
1
1
  # Change Log - just-task
2
2
 
3
- This log was last generated on Fri, 02 Apr 2021 23:21:41 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 31 Mar 2022 17:04:25 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 1.5.0
8
+
9
+ Thu, 31 Mar 2022 17:04:25 GMT
10
+
11
+ ### Minor changes
12
+
13
+ - Upgrading package-deps-hash to latest major to remove transitive security vulnerability in validator package. (dzearing@microsoft.com)
14
+
15
+ ## 1.4.2
16
+
17
+ Fri, 10 Sep 2021 23:58:46 GMT
18
+
19
+ ### Patches
20
+
21
+ - changes the dep from glob-parent which is old with chokidar directly (kchau@microsoft.com)
22
+
23
+ ## 1.4.1
24
+
25
+ Thu, 15 Apr 2021 19:00:12 GMT
26
+
27
+ ### Patches
28
+
29
+ - adding a check to make sure the tasks are registered only for task functions (kchau@microsoft.com)
30
+
7
31
  ## 1.4.0
8
32
 
9
- Fri, 02 Apr 2021 23:21:41 GMT
33
+ Fri, 02 Apr 2021 23:21:50 GMT
10
34
 
11
35
  ### Minor changes
12
36
 
package/README.md CHANGED
@@ -5,9 +5,8 @@
5
5
 
6
6
  `Just` is a library that organizes build tasks for your JS projects. It consists of
7
7
 
8
- - a build task build definition library
8
+ - a build task definition library
9
9
  - sane preset build flows for node and browser projects featuring TypeScript, Webpack and jest
10
- - project scaffold tool that generates no-ejection needed repos that tracks template changes
11
10
 
12
11
  # Documentation
13
12
 
@@ -41,11 +40,9 @@ yarn test
41
40
 
42
41
  | Package | Description |
43
42
  | ------------------ | --------------------------------------------------------------------------------------- |
44
- | create-just | Invoked by `npm init just`, a tool that scaffolds project repos |
45
43
  | just-task | The task definition library that wraps `undertaker` and `yargs` libraries |
46
44
  | just-scripts | A reusable preset of frequently used tasks in node and browser projects |
47
- | just-stack-\* | A set of templates to be used by the scaffold tool `create-just` |
48
- | just-scripts-utils | A set of utilities that are shared between `just-scripts` and `create-just` |
45
+ | just-scripts-utils | A set of utilities for `just-scripts` |
49
46
  | just-task-logger | A shared pretty logger used to display timestamps along with a message |
50
47
  | documentation | The Docusaurus site content and styles which generates the Github page for this library |
51
48
 
package/lib/cache.js CHANGED
@@ -1,15 +1,4 @@
1
1
  "use strict";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
2
  Object.defineProperty(exports, "__esModule", { value: true });
14
3
  exports.saveCache = exports.isCached = exports.clearCache = exports.registerCachedTask = void 0;
15
4
  const package_deps_hash_1 = require("@rushstack/package-deps-hash");
@@ -107,11 +96,12 @@ function getLockFileHashes() {
107
96
  }
108
97
  function getHash(taskName) {
109
98
  just_task_logger_1.mark('cache:getHash');
110
- const args = __rest(option_1.argv(), []);
99
+ const { ...args } = option_1.argv();
111
100
  const packageRootPath = getPackageRootPath();
112
- const packageDeps = package_deps_hash_1.getPackageDeps(packageRootPath);
113
- const lockFileHashes = getLockFileHashes();
114
- packageDeps.files = Object.assign(Object.assign({}, packageDeps.files), lockFileHashes);
101
+ const packageDeps = {
102
+ ...Object.fromEntries(package_deps_hash_1.getPackageDeps(packageRootPath)),
103
+ ...getLockFileHashes()
104
+ };
115
105
  const hash = {
116
106
  args,
117
107
  taskName,
package/lib/cli.js CHANGED
@@ -38,7 +38,9 @@ const configModule = config_1.readConfig();
38
38
  // Support named task function as exports of a config module
39
39
  if (configModule && typeof configModule === 'object') {
40
40
  for (const taskName of Object.keys(configModule)) {
41
- task_1.task(taskName, configModule[taskName]);
41
+ if (typeof configModule[taskName] == 'function') {
42
+ task_1.task(taskName, configModule[taskName]);
43
+ }
42
44
  }
43
45
  }
44
46
  const command = option_1.parseCommand();
package/lib/resolve.js CHANGED
@@ -1,15 +1,4 @@
1
1
  "use strict";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
2
  Object.defineProperty(exports, "__esModule", { value: true });
14
3
  exports.resolveCwd = exports.resolve = exports._getResolvePaths = exports._tryResolve = exports._isFileNameLike = exports.resetResolvePaths = exports.addResolvePath = void 0;
15
4
  const resolve_1 = require("resolve");
@@ -45,9 +34,9 @@ exports._isFileNameLike = _isFileNameLike;
45
34
  */
46
35
  function _tryResolve(moduleName, options) {
47
36
  try {
48
- const { cwd } = options, rest = __rest(options, ["cwd"]);
37
+ const { cwd, ...rest } = options;
49
38
  const nameToResolve = _isFileNameLike(moduleName) ? `./${moduleName}` : moduleName;
50
- return resolve_1.sync(nameToResolve, Object.assign(Object.assign({ basedir: cwd }, rest), { preserveSymlinks: true }));
39
+ return resolve_1.sync(nameToResolve, { basedir: cwd, ...rest, preserveSymlinks: true });
51
40
  }
52
41
  catch (e) {
53
42
  return null;
@@ -78,7 +67,7 @@ function resolve(moduleName, cwdOrOptions) {
78
67
  const allResolvePaths = _getResolvePaths(options.cwd);
79
68
  let resolved = null;
80
69
  for (const tryPath of allResolvePaths) {
81
- resolved = _tryResolve(moduleName, Object.assign(Object.assign({}, options), { cwd: tryPath }));
70
+ resolved = _tryResolve(moduleName, { ...options, cwd: tryPath });
82
71
  if (resolved) {
83
72
  return resolved;
84
73
  }
package/lib/watch.d.ts CHANGED
@@ -1,4 +1,7 @@
1
- import { TaskFunction } from './interfaces';
1
+ /// <reference types="node" />
2
2
  import type { WatchOptions, FSWatcher } from 'chokidar';
3
- export declare function watch(globs: string | string[], optionsOrTaskFunction?: TaskFunction | WatchOptions | undefined, taskFunction?: TaskFunction | undefined): FSWatcher;
3
+ import type { Stats } from 'fs';
4
+ declare type WatchListener = (path: string, stats?: Stats) => void;
5
+ export declare function watch(globs: string | string[], optionsOrListener?: WatchListener | WatchOptions | undefined, listener?: WatchListener | undefined): FSWatcher;
6
+ export {};
4
7
  //# sourceMappingURL=watch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../src/watch.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAExD,wBAAgB,KAAK,CACnB,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,EACxB,qBAAqB,CAAC,EAAE,YAAY,GAAG,YAAY,GAAG,SAAS,EAC/D,YAAY,CAAC,EAAE,YAAY,GAAG,SAAS,GACtC,SAAS,CAYX"}
1
+ {"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../src/watch.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,IAAI,CAAC;AAEhC,aAAK,aAAa,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;AAE3D,wBAAgB,KAAK,CACnB,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,EACxB,iBAAiB,CAAC,EAAE,aAAa,GAAG,YAAY,GAAG,SAAS,EAC5D,QAAQ,CAAC,EAAE,aAAa,GAAG,SAAS,GACnC,SAAS,CAoBX"}
package/lib/watch.js CHANGED
@@ -1,19 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.watch = void 0;
4
- const globWatch = require("glob-watcher");
5
- const wrapTask_1 = require("./wrapTask");
6
- function watch(globs, optionsOrTaskFunction, taskFunction) {
4
+ function watch(globs, optionsOrListener, listener) {
5
+ const chokidar = require('chokidar');
7
6
  let options = {};
8
- if (typeof optionsOrTaskFunction === 'function') {
9
- taskFunction = optionsOrTaskFunction;
7
+ if (typeof optionsOrListener === 'function') {
8
+ listener = optionsOrListener;
10
9
  options = {};
11
10
  }
12
11
  else {
13
- options = optionsOrTaskFunction;
12
+ options = optionsOrListener;
14
13
  }
14
+ options = { ...options, ignoreInitial: true };
15
15
  // Wrapping this function teaches the glob-watcher about how to deal with sync taskFunction
16
- const wrappedFunction = wrapTask_1.wrapTask(taskFunction);
17
- return globWatch(globs, options, wrappedFunction);
16
+ const innerListener = listener; // eslint-disable-line
17
+ const watcher = chokidar.watch(globs, options);
18
+ for (const evt of ['add', 'change', 'unlink']) {
19
+ watcher.on(evt, innerListener);
20
+ }
21
+ return watcher;
18
22
  }
19
23
  exports.watch = watch;
@@ -1 +1 @@
1
- {"version":3,"file":"wrapTask.d.ts","sourceRoot":"","sources":["../src/wrapTask.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAG5C,wBAAgB,QAAQ,CAAC,EAAE,EAAE,GAAG,GAAG,YAAY,CAsB9C"}
1
+ {"version":3,"file":"wrapTask.d.ts","sourceRoot":"","sources":["../src/wrapTask.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAG5C,wBAAgB,QAAQ,CAAC,EAAE,EAAE,GAAG,GAAG,YAAY,CAwB9C"}
package/lib/wrapTask.js CHANGED
@@ -20,7 +20,9 @@ function wrapTask(fn) {
20
20
  else if (results && results.then) {
21
21
  return results;
22
22
  }
23
- done();
23
+ if (typeof done === 'function') {
24
+ done();
25
+ }
24
26
  }
25
27
  };
26
28
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "just-task",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "Build task definition library",
5
5
  "keywords": [],
6
6
  "repository": {
@@ -20,7 +20,7 @@
20
20
  "test": "jest"
21
21
  },
22
22
  "dependencies": {
23
- "@rushstack/package-deps-hash": "^2.4.109",
23
+ "@rushstack/package-deps-hash": "^3.2.5",
24
24
  "bach": "^1.2.0",
25
25
  "chalk": "^4.0.0",
26
26
  "fs-extra": "^8.0.0",
@@ -29,12 +29,11 @@
29
29
  "undertaker": "^1.3.0",
30
30
  "undertaker-registry": "^1.0.1",
31
31
  "yargs-parser": "^20.2.3",
32
- "glob-watcher": "^5.0.5"
32
+ "chokidar": "^3.5.2"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@types/chokidar": "^2.1.3",
36
36
  "@types/fs-extra": "^8.0.0",
37
- "@types/glob-watcher": "^5.0.0",
38
37
  "@types/jest": "^26.0.20",
39
38
  "@types/mock-fs": "^4.13.0",
40
39
  "@types/node": "^10.12.18",
@@ -13,6 +13,7 @@ describe('watch', () => {
13
13
 
14
14
  const cleanup = () => {
15
15
  watcher.close();
16
+
16
17
  fs.unlinkSync(changeFile);
17
18
  fs.rmdirSync(tmpDir);
18
19
  };
@@ -27,6 +28,7 @@ describe('watch', () => {
27
28
  done(error);
28
29
  }
29
30
  };
31
+
30
32
  const watcher = watch([path.join(changeFile)], callback);
31
33
 
32
34
  watcher.on('ready', () => {
package/src/cache.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { getPackageDeps, IPackageDeps } from '@rushstack/package-deps-hash';
1
+ import { getPackageDeps } from '@rushstack/package-deps-hash';
2
2
  import { argv } from './option';
3
3
  import { resolveCwd } from './resolve';
4
4
  import * as fs from 'fs-extra';
@@ -83,7 +83,7 @@ function getCachePath() {
83
83
  interface CacheHash {
84
84
  args: { [arg: string]: string };
85
85
  taskName: string;
86
- hash: IPackageDeps;
86
+ hash: Record<string, string>;
87
87
  dependentHashTimestamps: { [pkgName: string]: number };
88
88
  }
89
89
 
@@ -127,11 +127,10 @@ function getHash(taskName: string): CacheHash | null {
127
127
 
128
128
  const packageRootPath = getPackageRootPath();
129
129
 
130
- const packageDeps = getPackageDeps(packageRootPath);
131
-
132
- const lockFileHashes = getLockFileHashes();
133
-
134
- packageDeps.files = { ...packageDeps.files, ...lockFileHashes };
130
+ const packageDeps = {
131
+ ...Object.fromEntries(getPackageDeps(packageRootPath)),
132
+ ...getLockFileHashes()
133
+ };
135
134
 
136
135
  const hash = {
137
136
  args,
package/src/cli.ts CHANGED
@@ -47,7 +47,9 @@ const configModule = readConfig();
47
47
  // Support named task function as exports of a config module
48
48
  if (configModule && typeof configModule === 'object') {
49
49
  for (const taskName of Object.keys(configModule)) {
50
- task(taskName, configModule[taskName]);
50
+ if (typeof configModule[taskName] == 'function') {
51
+ task(taskName, configModule[taskName]);
52
+ }
51
53
  }
52
54
  }
53
55
 
package/src/watch.ts CHANGED
@@ -1,22 +1,30 @@
1
- import * as globWatch from 'glob-watcher';
2
- import { wrapTask } from './wrapTask';
3
- import { TaskFunction } from './interfaces';
4
1
  import type { WatchOptions, FSWatcher } from 'chokidar';
2
+ import type { Stats } from 'fs';
3
+
4
+ type WatchListener = (path: string, stats?: Stats) => void;
5
5
 
6
6
  export function watch(
7
7
  globs: string | string[],
8
- optionsOrTaskFunction?: TaskFunction | WatchOptions | undefined,
9
- taskFunction?: TaskFunction | undefined,
8
+ optionsOrListener?: WatchListener | WatchOptions | undefined,
9
+ listener?: WatchListener | undefined,
10
10
  ): FSWatcher {
11
+ const chokidar = require('chokidar');
12
+
11
13
  let options: WatchOptions = {};
12
- if (typeof optionsOrTaskFunction === 'function') {
13
- taskFunction = optionsOrTaskFunction;
14
+ if (typeof optionsOrListener === 'function') {
15
+ listener = optionsOrListener;
14
16
  options = {};
15
17
  } else {
16
- options = optionsOrTaskFunction as WatchOptions;
18
+ options = optionsOrListener as WatchOptions;
17
19
  }
18
20
 
21
+ options = { ...options, ignoreInitial: true };
22
+
19
23
  // Wrapping this function teaches the glob-watcher about how to deal with sync taskFunction
20
- const wrappedFunction = wrapTask(taskFunction);
21
- return globWatch(globs, options, wrappedFunction) as FSWatcher;
24
+ const innerListener = listener!; // eslint-disable-line
25
+ const watcher = chokidar.watch(globs, options) as FSWatcher;
26
+ for (const evt of ['add', 'change', 'unlink']) {
27
+ watcher.on(evt, innerListener);
28
+ }
29
+ return watcher;
22
30
  }
package/src/wrapTask.ts CHANGED
@@ -20,7 +20,9 @@ export function wrapTask(fn: any): TaskFunction {
20
20
  return results;
21
21
  }
22
22
 
23
- done();
23
+ if (typeof done === 'function') {
24
+ done();
25
+ }
24
26
  }
25
27
  };
26
28
  }