Leon4gr45 commited on
Commit
1d590c7
·
verified ·
1 Parent(s): 04ba84a

Include updated package-lock.json (part 23)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. node_modules/iterare/lib/utils.test.js.map +1 -0
  2. node_modules/iterare/lib/zip.d.ts +7 -0
  3. node_modules/iterare/lib/zip.d.ts.map +1 -0
  4. node_modules/iterare/lib/zip.js +21 -0
  5. node_modules/iterare/lib/zip.js.map +1 -0
  6. node_modules/iterare/lib/zip.test.d.ts +2 -0
  7. node_modules/iterare/lib/zip.test.d.ts.map +1 -0
  8. node_modules/iterare/lib/zip.test.js.map +1 -0
  9. node_modules/iterare/package.json +97 -0
  10. node_modules/jackspeak/LICENSE.md +55 -0
  11. node_modules/jackspeak/README.md +394 -0
  12. node_modules/jackspeak/package.json +115 -0
  13. node_modules/jake/Makefile +44 -0
  14. node_modules/jake/README.md +17 -0
  15. node_modules/jake/bin/bash_completion.sh +41 -0
  16. node_modules/jake/bin/cli.js +31 -0
  17. node_modules/jake/jakefile.js +112 -0
  18. node_modules/jake/lib/api.js +409 -0
  19. node_modules/jake/lib/jake.js +330 -0
  20. node_modules/jake/lib/loader.js +174 -0
  21. node_modules/jake/lib/namespace.js +115 -0
  22. node_modules/jake/lib/package_task.js +406 -0
  23. node_modules/jake/lib/parseargs.js +134 -0
  24. node_modules/jake/lib/program.js +282 -0
  25. node_modules/jake/lib/publish_task.js +290 -0
  26. node_modules/jake/lib/rule.js +311 -0
  27. node_modules/jake/lib/task/directory_task.js +30 -0
  28. node_modules/jake/lib/task/file_task.js +126 -0
  29. node_modules/jake/lib/task/index.js +9 -0
  30. node_modules/jake/lib/task/task.js +458 -0
  31. node_modules/jake/lib/test_task.js +270 -0
  32. node_modules/jake/lib/utils/file.js +286 -0
  33. node_modules/jake/lib/utils/index.js +297 -0
  34. node_modules/jake/lib/utils/logger.js +24 -0
  35. node_modules/jake/package.json +44 -0
  36. node_modules/jake/test/integration/concurrent.js +45 -0
  37. node_modules/jake/test/integration/file.js +228 -0
  38. node_modules/jake/test/integration/file_task.js +141 -0
  39. node_modules/jake/test/integration/helpers.js +80 -0
  40. node_modules/jake/test/integration/jakefile.js +352 -0
  41. node_modules/jake/test/integration/jakelib/concurrent.jake.js +113 -0
  42. node_modules/jake/test/integration/jakelib/publish.jake.js +49 -0
  43. node_modules/jake/test/integration/jakelib/required_module.jake.js +10 -0
  44. node_modules/jake/test/integration/jakelib/rule.jake.js +222 -0
  45. node_modules/jake/test/integration/list_tasks.js +15 -0
  46. node_modules/jake/test/integration/publish_task.js +27 -0
  47. node_modules/jake/test/integration/rule.js +217 -0
  48. node_modules/jake/test/integration/selfdep.js +42 -0
  49. node_modules/jake/test/integration/task_base.js +167 -0
  50. node_modules/jake/test/unit/jakefile.js +36 -0
node_modules/iterare/lib/utils.test.js.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"utils.test.js","sourceRoot":"","sources":["../src/utils.test.ts"],"names":[],"mappings":";;AAAA,iCAAgC;AAChC,mCAA4D;AAE5D,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE;IACnB,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;QACxB,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;YACtD,MAAM,QAAQ,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAA;YAC7C,MAAM,CAAC,KAAK,CAAC,kBAAU,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAA;QAChD,CAAC,CAAC,CAAA;QACF,EAAE,CAAC,2CAA2C,EAAE,GAAG,EAAE;YACjD,MAAM,QAAQ,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;YAC1B,MAAM,QAAQ,GAAG,kBAAU,CAAC,QAAQ,CAAC,CAAA;YACrC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;YACtC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;YACtC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;YACtC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;QAC5C,CAAC,CAAC,CAAA;QACF,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;YAC5C,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE;gBACf,kBAAU,CAAC,GAAU,CAAC,CAAA;YAC1B,CAAC,CAAC,CAAA;QACN,CAAC,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;IACF,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;QACxB,EAAE,CAAC,oCAAoC,EAAE,GAAG,EAAE;YAC1C,MAAM,QAAQ,GAAG;gBACb,IAAI;oBACA,WAAW;gBACf,CAAC;aACJ,CAAA;YACD,MAAM,CAAC,KAAK,CAAC,kBAAU,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,CAAA;QAC5C,CAAC,CAAC,CAAA;QACF,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;YAC3C,MAAM,QAAQ,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;YAC1B,MAAM,CAAC,KAAK,CAAC,kBAAU,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,CAAA;QAC7C,CAAC,CAAC,CAAA;QACF,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;YACpC,MAAM,CAAC,KAAK,CAAC,kBAAU,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAA;QACzC,CAAC,CAAC,CAAA;QACF,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE;YACxC,MAAM,CAAC,KAAK,CAAC,kBAAU,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAA;QACzC,CAAC,CAAC,CAAA;QACF,EAAE,CAAC,wDAAwD,EAAE,GAAG,EAAE;YAC9D,MAAM,CAAC,KAAK,CAAC,kBAAU,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,CAAC,CAAA;QAClD,CAAC,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;IACF,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;QACxB,EAAE,CAAC,oCAAoC,EAAE,GAAG,EAAE;YAC1C,MAAM,QAAQ,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;YAC1B,MAAM,CAAC,KAAK,CAAC,kBAAU,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,CAAA;QAC5C,CAAC,CAAC,CAAA;QACF,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;YAC3C,MAAM,QAAQ,GAAG;gBACb,IAAI;oBACA,WAAW;gBACf,CAAC;aACJ,CAAA;YACD,MAAM,CAAC,KAAK,CAAC,kBAAU,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,CAAA;QAC7C,CAAC,CAAC,CAAA;QACF,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;YACpC,MAAM,CAAC,KAAK,CAAC,kBAAU,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAA;QACzC,CAAC,CAAC,CAAA;QACF,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE;YACxC,MAAM,CAAC,KAAK,CAAC,kBAAU,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAA;QACzC,CAAC,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"}
node_modules/iterare/lib/zip.d.ts ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ export declare class ZipIterator<A, B> implements Iterator<[A, B]> {
2
+ private a;
3
+ private b;
4
+ constructor(a: Iterator<A>, b: Iterator<B>);
5
+ next(): IteratorResult<[A, B]>;
6
+ }
7
+ //# sourceMappingURL=zip.d.ts.map
node_modules/iterare/lib/zip.d.ts.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"zip.d.ts","sourceRoot":"","sources":["../src/zip.ts"],"names":[],"mappings":"AAAA,qBAAa,WAAW,CAAC,CAAC,EAAE,CAAC,CAAE,YAAW,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC1C,OAAO,CAAC,CAAC;IAAe,OAAO,CAAC,CAAC;gBAAzB,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAU,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC;IAE1D,IAAI,IAAI,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CAWjC"}
node_modules/iterare/lib/zip.js ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class ZipIterator {
4
+ constructor(a, b) {
5
+ this.a = a;
6
+ this.b = b;
7
+ }
8
+ next() {
9
+ const a = this.a.next();
10
+ if (a.done) {
11
+ return { done: true };
12
+ }
13
+ const b = this.b.next();
14
+ if (b.done) {
15
+ return { done: true };
16
+ }
17
+ return { value: [a.value, b.value], done: false };
18
+ }
19
+ }
20
+ exports.ZipIterator = ZipIterator;
21
+ //# sourceMappingURL=zip.js.map
node_modules/iterare/lib/zip.js.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"zip.js","sourceRoot":"","sources":["../src/zip.ts"],"names":[],"mappings":";;AAAA,MAAa,WAAW;IACpB,YAAoB,CAAc,EAAU,CAAc;QAAtC,MAAC,GAAD,CAAC,CAAa;QAAU,MAAC,GAAD,CAAC,CAAa;IAAG,CAAC;IAE9D,IAAI;QACA,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;QACvB,IAAI,CAAC,CAAC,IAAI,EAAE;YACR,OAAO,EAAE,IAAI,EAAE,IAAI,EAA4B,CAAA;SAClD;QACD,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;QACvB,IAAI,CAAC,CAAC,IAAI,EAAE;YACR,OAAO,EAAE,IAAI,EAAE,IAAI,EAA4B,CAAA;SAClD;QACD,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAA;IACrD,CAAC;CACJ;AAdD,kCAcC"}
node_modules/iterare/lib/zip.test.d.ts ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ export {};
2
+ //# sourceMappingURL=zip.test.d.ts.map
node_modules/iterare/lib/zip.test.d.ts.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"zip.test.d.ts","sourceRoot":"","sources":["../src/zip.test.ts"],"names":[],"mappings":""}
node_modules/iterare/lib/zip.test.js.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"zip.test.js","sourceRoot":"","sources":["../src/zip.test.ts"],"names":[],"mappings":";;AAAA,iCAAgC;AAChC,+BAAmC;AAEnC,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IACzB,EAAE,CAAC,sDAAsD,EAAE,GAAG,EAAE;QAC5D,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAA;QACzC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAA;QACjD,MAAM,MAAM,GAAG,IAAI,iBAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;QACpC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAA;QAC/C,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAA;QAC/C,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAA;QAC/C,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAA;QAC/C,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IAC1C,CAAC,CAAC,CAAA;IACF,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;QACtD,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAA;QACnC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAA;QACjD,MAAM,MAAM,GAAG,IAAI,iBAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;QACpC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAA;QAC/C,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAA;QAC/C,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IAC1C,CAAC,CAAC,CAAA;IACF,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;QACtD,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAA;QACzC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAA;QACvC,MAAM,MAAM,GAAG,IAAI,iBAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;QACpC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAA;QAC/C,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAA;QAC/C,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IAC1C,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"}
node_modules/iterare/package.json ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "iterare",
3
+ "version": "1.2.1",
4
+ "description": "Array methods for ES6 Iterators",
5
+ "main": "lib/index.js",
6
+ "typings": "lib/index.d.ts",
7
+ "engines": {
8
+ "node": ">=6"
9
+ },
10
+ "scripts": {
11
+ "tslint": "tslint -c tslint.json -p tsconfig.json 'src/**/*.ts'",
12
+ "prettier": "prettier --write --list-different '**/*.{ts,json,js,md,yml}'",
13
+ "test": "nyc mocha",
14
+ "build": "tsc",
15
+ "watch": "tsc -w",
16
+ "typedoc": "typedoc --out typedoc --tsconfig tsconfig.json --ignoreCompilerErrors --mode file --excludeExternals src",
17
+ "semantic-release": "semantic-release"
18
+ },
19
+ "nyc": {
20
+ "all": true,
21
+ "extension": [
22
+ ".ts"
23
+ ],
24
+ "include": [
25
+ "src/**/*.ts"
26
+ ],
27
+ "exclude": [
28
+ "src/**/*.test.ts"
29
+ ],
30
+ "reporter": [
31
+ "text",
32
+ "json"
33
+ ]
34
+ },
35
+ "mocha": {
36
+ "spec": "src/**/*.test.ts",
37
+ "require": "ts-node/register"
38
+ },
39
+ "husky": {
40
+ "hooks": {
41
+ "commit-msg": "commitlint -e $HUSKY_GIT_PARAMS"
42
+ }
43
+ },
44
+ "commitlint": {
45
+ "extends": [
46
+ "@commitlint/config-conventional"
47
+ ]
48
+ },
49
+ "keywords": [
50
+ "iterator",
51
+ "iteration",
52
+ "functional",
53
+ "es6",
54
+ "collection",
55
+ "array",
56
+ "map",
57
+ "set",
58
+ "filter",
59
+ "reduce",
60
+ "flatten",
61
+ "concat",
62
+ "every",
63
+ "some"
64
+ ],
65
+ "author": "Felix Becker <felix.b@outlook.com>",
66
+ "repository": {
67
+ "type": "git",
68
+ "url": "https://github.com/felixfbecker/iterare"
69
+ },
70
+ "bugs": {
71
+ "url": "https://github.com/felixfbecker/iterare/issues"
72
+ },
73
+ "license": "ISC",
74
+ "devDependencies": {
75
+ "@commitlint/cli": "^8.0.0",
76
+ "@commitlint/config-conventional": "^8.0.0",
77
+ "@reactivex/ix-es2015-cjs": "^2.5.3",
78
+ "@types/benchmark": "^1.0.31",
79
+ "@types/lodash": "^4.14.134",
80
+ "@types/mocha": "^5.2.7",
81
+ "@types/node": "^7.10.6",
82
+ "benchmark": "^2.1.4",
83
+ "husky": "^2.4.0",
84
+ "ix": "^2.5.3",
85
+ "lodash": "^4.17.11",
86
+ "mocha": "^6.1.4",
87
+ "nyc": "^14.1.1",
88
+ "prettier": "^1.18.1",
89
+ "rxjs": "^6.5.2",
90
+ "semantic-release": "^15.13.12",
91
+ "ts-node": "^8.2.0",
92
+ "tslint": "^5.17.0",
93
+ "tslint-config-prettier": "^1.18.0",
94
+ "typedoc": "^0.14.2",
95
+ "typescript": "~3.5.1"
96
+ }
97
+ }
node_modules/jackspeak/LICENSE.md ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Blue Oak Model License
2
+
3
+ Version 1.0.0
4
+
5
+ ## Purpose
6
+
7
+ This license gives everyone as much permission to work with
8
+ this software as possible, while protecting contributors
9
+ from liability.
10
+
11
+ ## Acceptance
12
+
13
+ In order to receive this license, you must agree to its
14
+ rules. The rules of this license are both obligations
15
+ under that agreement and conditions to your license.
16
+ You must not do anything with this software that triggers
17
+ a rule that you cannot or will not follow.
18
+
19
+ ## Copyright
20
+
21
+ Each contributor licenses you to do everything with this
22
+ software that would otherwise infringe that contributor's
23
+ copyright in it.
24
+
25
+ ## Notices
26
+
27
+ You must ensure that everyone who gets a copy of
28
+ any part of this software from you, with or without
29
+ changes, also gets the text of this license or a link to
30
+ <https://blueoakcouncil.org/license/1.0.0>.
31
+
32
+ ## Excuse
33
+
34
+ If anyone notifies you in writing that you have not
35
+ complied with [Notices](#notices), you can keep your
36
+ license by taking all practical steps to comply within 30
37
+ days after the notice. If you do not do so, your license
38
+ ends immediately.
39
+
40
+ ## Patent
41
+
42
+ Each contributor licenses you to do everything with this
43
+ software that would otherwise infringe any patent claims
44
+ they can license or become able to license.
45
+
46
+ ## Reliability
47
+
48
+ No contributor can revoke this license.
49
+
50
+ ## No Liability
51
+
52
+ **_As far as the law allows, this software comes as is,
53
+ without any warranty or condition, and no contributor
54
+ will be liable to anyone for any damages related to this
55
+ software or this license, under any kind of legal claim._**
node_modules/jackspeak/README.md ADDED
@@ -0,0 +1,394 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # jackspeak
2
+
3
+ A very strict and proper argument parser.
4
+
5
+ Validate string, boolean, and number options, from the command
6
+ line and the environment.
7
+
8
+ Call the `jack` method with a config object, and then chain
9
+ methods off of it.
10
+
11
+ At the end, call the `.parse()` method, and you'll get an object
12
+ with `positionals` and `values` members.
13
+
14
+ Any unrecognized configs or invalid values will throw an error.
15
+
16
+ As long as you define configs using object literals, types will
17
+ be properly inferred and TypeScript will know what kinds of
18
+ things you got.
19
+
20
+ If you give it a prefix for environment variables, then defaults
21
+ will be read from the environment, and parsed values written back
22
+ to it, so you can easily pass configs through to child processes.
23
+
24
+ Automatically generates a `usage`/`help` banner by calling the
25
+ `.usage()` method.
26
+
27
+ Unless otherwise noted, all methods return the object itself.
28
+
29
+ ## USAGE
30
+
31
+ ```js
32
+ // the minified version has no external deps, typically better
33
+ // startup time for CLI tools that would use jackspeak.
34
+ import { jack } from 'jackspeak/min'
35
+ // this works too:
36
+ // const { jack } = require('jackspeak/min')
37
+
38
+ const { positionals, values } = jack({ envPrefix: 'FOO' })
39
+ .flag({
40
+ asdf: { description: 'sets the asfd flag', short: 'a', default: true },
41
+ 'no-asdf': { description: 'unsets the asdf flag', short: 'A' },
42
+ foo: { description: 'another boolean', short: 'f' },
43
+ })
44
+ .optList({
45
+ 'ip-addrs': {
46
+ description: 'addresses to ip things',
47
+ delim: ',', // defaults to '\n'
48
+ default: ['127.0.0.1'],
49
+ },
50
+ })
51
+ .parse([
52
+ 'some',
53
+ 'positional',
54
+ '--ip-addrs',
55
+ '192.168.0.1',
56
+ '--ip-addrs',
57
+ '1.1.1.1',
58
+ 'args',
59
+ '--foo', // sets the foo flag
60
+ '-A', // short for --no-asdf, sets asdf flag to false
61
+ ])
62
+
63
+ console.log(process.env.FOO_ASDF) // '0'
64
+ console.log(process.env.FOO_FOO) // '1'
65
+ console.log(values) // {
66
+ // 'ip-addrs': ['192.168.0.1', '1.1.1.1'],
67
+ // foo: true,
68
+ // asdf: false,
69
+ // }
70
+ console.log(process.env.FOO_IP_ADDRS) // '192.168.0.1,1.1.1.1'
71
+ console.log(positionals) // ['some', 'positional', 'args']
72
+ ```
73
+
74
+ ## `jack(options: JackOptions = {}) => Jack`
75
+
76
+ Returns a `Jack` object that can be used to chain and add
77
+ field definitions. The other methods (apart from `validate()`,
78
+ `parse()`, and `usage()` obviously) return the same Jack object,
79
+ updated with the new types, so they can be chained together as
80
+ shown in the code examples.
81
+
82
+ Options:
83
+
84
+ - `allowPositionals` Defaults to true. Set to `false` to not
85
+ allow any positional arguments.
86
+
87
+ - `envPrefix` Set to a string to write configs to and read
88
+ configs from the environment. For example, if set to `MY_APP`
89
+ then the `foo-bar` config will default based on the value of
90
+ `env.MY_APP_FOO_BAR` and will write back to that when parsed.
91
+
92
+ Boolean values are written as `'1'` and `'0'`, and will be
93
+ treated as `true` if they're `'1'` or false otherwise.
94
+
95
+ Number values are written with their `toString()`
96
+ representation.
97
+
98
+ Strings are just strings.
99
+
100
+ Any value with `multiple: true` will be represented in the
101
+ environment split by a delimiter, which defaults to `\n`.
102
+
103
+ - `env` The place to read/write environment variables. Defaults
104
+ to `process.env`.
105
+
106
+ - `usage` A short usage string to print at the top of the help
107
+ banner.
108
+
109
+ - `stopAtPositional` Boolean, default false. Stop parsing opts
110
+ and flags at the first positional argument. This is useful if
111
+ you want to pass certain options to subcommands, like some
112
+ programs do, so you can stop parsing and pass the positionals
113
+ to the subcommand to parse.
114
+
115
+ - `stopAtPositionalTest` Conditional `stopAtPositional`. Provide
116
+ a function that takes a positional argument string and returns
117
+ boolean. If it returns `true`, then parsing will stop. Useful
118
+ when _some_ subcommands should parse the rest of the command
119
+ line options, and others should not.
120
+
121
+ ### `Jack.heading(text: string, level?: 1 | 2 | 3 | 4 | 5 | 6)`
122
+
123
+ Define a short string heading, used in the `usage()` output.
124
+
125
+ Indentation of the heading and subsequent description/config
126
+ usage entries (up until the next heading) is set by the heading
127
+ level.
128
+
129
+ If the first usage item defined is a heading, it is always
130
+ treated as level 1, regardless of the argument provided.
131
+
132
+ Headings level 1 and 2 will have a line of padding underneath
133
+ them. Headings level 3 through 6 will not.
134
+
135
+ ### `Jack.description(text: string, { pre?: boolean } = {})`
136
+
137
+ Define a long string description, used in the `usage()` output.
138
+
139
+ If the `pre` option is set to `true`, then whitespace will not be
140
+ normalized. However, if any line is too long for the width
141
+ allotted, it will still be wrapped.
142
+
143
+ ## Option Definitions
144
+
145
+ Configs are defined by calling the appropriate field definition
146
+ method with an object where the keys are the long option name,
147
+ and the value defines the config.
148
+
149
+ Options:
150
+
151
+ - `type` Only needed for the `addFields` method, as the others
152
+ set it implicitly. Can be `'string'`, `'boolean'`, or
153
+ `'number'`.
154
+ - `multiple` Only needed for the `addFields` method, as the
155
+ others set it implicitly. Set to `true` to define an array
156
+ type. This means that it can be set on the CLI multiple times,
157
+ set as an array in the `values`
158
+ and it is represented in the environment as a delimited string.
159
+ - `short` A one-character shorthand for the option.
160
+ - `description` Some words to describe what this option is and
161
+ why you'd set it.
162
+ - `hint` (Only relevant for non-boolean types) The thing to show
163
+ in the usage output, like `--option=<hint>`
164
+ - `validate` A function that returns false (or throws) if an
165
+ option value is invalid.
166
+ - `validOptions` An array of strings or numbers that define the
167
+ valid values that can be set. This is not allowed on `boolean`
168
+ (flag) options. May be used along with a `validate()` method.
169
+ - `default` A default value for the field. Note that this may be
170
+ overridden by an environment variable, if present.
171
+
172
+ ### `Jack.flag({ [option: string]: definition, ... })`
173
+
174
+ Define one or more boolean fields.
175
+
176
+ Boolean options may be set to `false` by using a
177
+ `--no-${optionName}` argument, which will be implicitly created
178
+ if it's not defined to be something else.
179
+
180
+ If a boolean option named `no-${optionName}` with the same
181
+ `multiple` setting is in the configuration, then that will be
182
+ treated as a negating flag.
183
+
184
+ ### `Jack.flagList({ [option: string]: definition, ... })`
185
+
186
+ Define one or more boolean array fields.
187
+
188
+ ### `Jack.num({ [option: string]: definition, ... })`
189
+
190
+ Define one or more number fields. These will be set in the
191
+ environment as a stringified number, and included in the `values`
192
+ object as a number.
193
+
194
+ ### `Jack.numList({ [option: string]: definition, ... })`
195
+
196
+ Define one or more number list fields. These will be set in the
197
+ environment as a delimited set of stringified numbers, and
198
+ included in the `values` as a number array.
199
+
200
+ ### `Jack.opt({ [option: string]: definition, ... })`
201
+
202
+ Define one or more string option fields.
203
+
204
+ ### `Jack.optList({ [option: string]: definition, ... })`
205
+
206
+ Define one or more string list fields.
207
+
208
+ ### `Jack.addFields({ [option: string]: definition, ... })`
209
+
210
+ Define one or more fields of any type. Note that `type` and
211
+ `multiple` must be set explicitly on each definition when using
212
+ this method.
213
+
214
+ ## Informative Getters
215
+
216
+ Once you've defined several fields with the various methods
217
+ described above, you can get at the definitions and such with
218
+ these methods.
219
+
220
+ This are primarily just informative, but can be useful in some
221
+ advanced scenarios, such as providing "Did you mean?" type
222
+ suggestions when someone misspells an option name.
223
+
224
+ ### `Jack.definitions`
225
+
226
+ The set of config field definitions in no particular order. This
227
+ is a data object suitable to passing to `util.parseArgs`, but
228
+ with the addition of `short` and `description` fields, where
229
+ appropriate.
230
+
231
+ ### `Jack.jackOptions`
232
+
233
+ The options passed into the initial `jack()` function (or `new
234
+ Jack()` constructor).
235
+
236
+ ### `Jack.shorts`
237
+
238
+ The `{ <short>: <long> }` name record for all short options
239
+ defined.
240
+
241
+ ### `Jack.usageFields`
242
+
243
+ The array of fields that are used to generate `Jack.usage()` and
244
+ `Jack.usageMarkdown()` content.
245
+
246
+ ## Actions
247
+
248
+ Use these methods on a Jack object that's already had its config
249
+ fields defined.
250
+
251
+ ### `Jack.parse(args: string[] = process.argv): { positionals: string[], values: OptionsResults }`
252
+
253
+ Parse the arguments list, write to the environment if `envPrefix`
254
+ is set, and returned the parsed values and remaining positional
255
+ arguments.
256
+
257
+ ### `Jack.validate(o: unknown): asserts o is OptionsResults`
258
+
259
+ Throws an error if the object provided is not a valid result set,
260
+ for the configurations defined thusfar.
261
+
262
+ ### `Jack.usage(): string`
263
+
264
+ Returns the compiled `usage` string, with all option descriptions
265
+ and heading/description text, wrapped to the appropriate width
266
+ for the terminal.
267
+
268
+ ### `Jack.setConfigValues(options: OptionsResults, src?: string)`
269
+
270
+ Validate the `options` argument, and set the default value for
271
+ each field that appears in the options.
272
+
273
+ Values provided will be overridden by environment variables or
274
+ command line arguments.
275
+
276
+ ### `Jack.usageMarkdown(): string`
277
+
278
+ Returns the compiled `usage` string, with all option descriptions
279
+ and heading/description text, but as markdown instead of
280
+ formatted for a terminal, for generating HTML documentation for
281
+ your CLI.
282
+
283
+ ## Some Example Code
284
+
285
+ Also see [the examples
286
+ folder](https://github.com/isaacs/jackspeak/tree/master/examples)
287
+
288
+ ```js
289
+ // the minified version has no external deps, typically better
290
+ // startup time for CLI tools that would use jackspeak.
291
+ // but `import { jack } from 'jackspeak'` also works fine.
292
+ import { jack } from 'jackspeak/min'
293
+
294
+ const j = jack({
295
+ // Optional
296
+ // This will be auto-generated from the descriptions if not supplied
297
+ // top level usage line, printed by -h
298
+ // will be auto-generated if not specified
299
+ usage: 'foo [options] <files>',
300
+ })
301
+ .heading('The best Foo that ever Fooed')
302
+ .description(
303
+ `
304
+ Executes all the files and interprets their output as
305
+ TAP formatted test result data.
306
+
307
+ To parse TAP data from stdin, specify "-" as a filename.
308
+ `,
309
+ )
310
+
311
+ // flags don't take a value, they're boolean on or off, and can be
312
+ // turned off by prefixing with `--no-`
313
+ // so this adds support for -b to mean --bail, or -B to mean --no-bail
314
+ .flag({
315
+ flag: {
316
+ // specify a short value if you like. this must be a single char
317
+ short: 'f',
318
+ // description is optional as well.
319
+ description: `Make the flags wave`,
320
+ // default value for flags is 'false', unless you change it
321
+ default: true,
322
+ },
323
+ 'no-flag': {
324
+ // you can can always negate a flag with `--no-flag`
325
+ // specifying a negate option will let you define a short
326
+ // single-char option for negation.
327
+ short: 'F',
328
+ description: `Do not wave the flags`,
329
+ },
330
+ })
331
+
332
+ // Options that take a value are specified with `opt()`
333
+ .opt({
334
+ reporter: {
335
+ short: 'R',
336
+ description: 'the style of report to display',
337
+ },
338
+ })
339
+
340
+ // if you want a number, say so, and jackspeak will enforce it
341
+ .num({
342
+ jobs: {
343
+ short: 'j',
344
+ description: 'how many jobs to run in parallel',
345
+ default: 1,
346
+ },
347
+ })
348
+
349
+ // A list is an option that can be specified multiple times,
350
+ // to expand into an array of all the settings. Normal opts
351
+ // will just give you the last value specified.
352
+ .optList({
353
+ 'node-arg': {},
354
+ })
355
+
356
+ // a flagList is an array of booleans, so `-ddd` is [true, true, true]
357
+ // count the `true` values to treat it as a counter.
358
+ .flagList({
359
+ debug: { short: 'd' },
360
+ })
361
+
362
+ // opts take a value, and is set to the string in the results
363
+ // you can combine multiple short-form flags together, but
364
+ // an opt will end the combine chain, posix-style. So,
365
+ // -bofilename would be like --bail --output-file=filename
366
+ .opt({
367
+ 'output-file': {
368
+ short: 'o',
369
+ // optional: make it -o<file> in the help output insead of -o<value>
370
+ hint: 'file',
371
+ description: `Send the raw output to the specified file.`,
372
+ },
373
+ })
374
+
375
+ // now we can parse argv like this:
376
+ const { values, positionals } = j.parse(process.argv)
377
+
378
+ // or decide to show the usage banner
379
+ console.log(j.usage())
380
+
381
+ // or validate an object config we got from somewhere else
382
+ try {
383
+ j.validate(someConfig)
384
+ } catch (er) {
385
+ console.error('someConfig is not valid!', er)
386
+ }
387
+ ```
388
+
389
+ ## Name
390
+
391
+ The inspiration for this module is [yargs](http://npm.im/yargs), which
392
+ is pirate talk themed. Yargs has all the features, and is infinitely
393
+ flexible. "Jackspeak" is the slang of the royal navy. This module
394
+ does not have all the features. It is declarative and rigid by design.
node_modules/jackspeak/package.json ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "jackspeak",
3
+ "version": "4.2.3",
4
+ "description": "A very strict and proper argument parser.",
5
+ "tshy": {
6
+ "main": true,
7
+ "exports": {
8
+ "./package.json": "./package.json",
9
+ ".": "./src/index.js",
10
+ "./min": {
11
+ "import": {
12
+ "types": "./dist/esm/index.d.ts",
13
+ "default": "./dist/esm/index.min.js"
14
+ },
15
+ "require": {
16
+ "types": "./dist/commonjs/index.d.ts",
17
+ "default": "./dist/commonjs/index.min.js"
18
+ }
19
+ }
20
+ }
21
+ },
22
+ "main": "./dist/commonjs/index.js",
23
+ "types": "./dist/commonjs/index.d.ts",
24
+ "type": "module",
25
+ "exports": {
26
+ "./package.json": "./package.json",
27
+ ".": {
28
+ "import": {
29
+ "types": "./dist/esm/index.d.ts",
30
+ "default": "./dist/esm/index.js"
31
+ },
32
+ "require": {
33
+ "types": "./dist/commonjs/index.d.ts",
34
+ "default": "./dist/commonjs/index.js"
35
+ }
36
+ },
37
+ "./min": {
38
+ "import": {
39
+ "types": "./dist/esm/index.d.ts",
40
+ "default": "./dist/esm/index.min.js"
41
+ },
42
+ "require": {
43
+ "types": "./dist/commonjs/index.d.ts",
44
+ "default": "./dist/commonjs/index.min.js"
45
+ }
46
+ }
47
+ },
48
+ "files": [
49
+ "dist"
50
+ ],
51
+ "scripts": {
52
+ "build-examples": "for i in examples/*.js ; do node $i -h > ${i/.js/.txt}; done",
53
+ "preversion": "npm test",
54
+ "postversion": "npm publish",
55
+ "prepublishOnly": "git push origin --follow-tags",
56
+ "prepare": "tshy && bash build.sh",
57
+ "pretest": "npm run prepare",
58
+ "presnap": "npm run prepare",
59
+ "test": "tap",
60
+ "snap": "tap",
61
+ "format": "prettier --write . --log-level warn",
62
+ "typedoc": "typedoc --tsconfig .tshy/esm.json ./src/*.ts"
63
+ },
64
+ "license": "BlueOak-1.0.0",
65
+ "prettier": {
66
+ "experimentalTernaries": true,
67
+ "semi": false,
68
+ "printWidth": 75,
69
+ "tabWidth": 2,
70
+ "useTabs": false,
71
+ "singleQuote": true,
72
+ "jsxSingleQuote": false,
73
+ "bracketSameLine": true,
74
+ "arrowParens": "avoid",
75
+ "endOfLine": "lf"
76
+ },
77
+ "devDependencies": {
78
+ "@types/node": "^25.2.0",
79
+ "esbuild": "^0.27.3",
80
+ "prettier": "^3.3.3",
81
+ "tap": "^21.5.1",
82
+ "tshy": "^3.1.3",
83
+ "typedoc": "^0.28.16"
84
+ },
85
+ "dependencies": {
86
+ "@isaacs/cliui": "^9.0.0"
87
+ },
88
+ "engines": {
89
+ "node": "20 || >=22"
90
+ },
91
+ "funding": {
92
+ "url": "https://github.com/sponsors/isaacs"
93
+ },
94
+ "repository": {
95
+ "type": "git",
96
+ "url": "git+https://github.com/isaacs/jackspeak.git"
97
+ },
98
+ "keywords": [
99
+ "argument",
100
+ "parser",
101
+ "args",
102
+ "option",
103
+ "flag",
104
+ "cli",
105
+ "command",
106
+ "line",
107
+ "parse",
108
+ "parsing"
109
+ ],
110
+ "author": "Isaac Z. Schlueter <i@izs.me>",
111
+ "tap": {
112
+ "typecheck": true
113
+ },
114
+ "module": "./dist/esm/index.js"
115
+ }
node_modules/jake/Makefile ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #
2
+ # Jake JavaScript build tool
3
+ # Copyright 2112 Matthew Eernisse (mde@fleegix.org)
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ .PHONY: all build install clean uninstall
19
+
20
+ PREFIX=/usr/local
21
+ DESTDIR=
22
+
23
+ all: build
24
+
25
+ build:
26
+ @echo 'Jake built.'
27
+
28
+ install:
29
+ @mkdir -p $(DESTDIR)$(PREFIX)/bin && \
30
+ mkdir -p $(DESTDIR)$(PREFIX)/lib/node_modules/jake && \
31
+ mkdir -p ./node_modules && \
32
+ npm install utilities minimatch && \
33
+ cp -R ./* $(DESTDIR)$(PREFIX)/lib/node_modules/jake/ && \
34
+ ln -snf ../lib/node_modules/jake/bin/cli.js $(DESTDIR)$(PREFIX)/bin/jake && \
35
+ chmod 755 $(DESTDIR)$(PREFIX)/lib/node_modules/jake/bin/cli.js && \
36
+ echo 'Jake installed.'
37
+
38
+ clean:
39
+ @true
40
+
41
+ uninstall:
42
+ @rm -f $(DESTDIR)$(PREFIX)/bin/jake && \
43
+ rm -fr $(DESTDIR)$(PREFIX)/lib/node_modules/jake/ && \
44
+ echo 'Jake uninstalled.'
node_modules/jake/README.md ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### Jake -- the JavaScript build tool for Node.js
2
+
3
+ [![Build Status](https://travis-ci.org/jakejs/jake.svg?branch=master)](https://travis-ci.org/jakejs/jake)
4
+
5
+ Documentation site at [http://jakejs.com](http://jakejs.com/)
6
+
7
+ ### Contributing
8
+ 1. [Install node](http://nodejs.org/#download).
9
+ 2. Clone this repository `$ git clone git@github.com:jakejs/jake.git`.
10
+ 3. Install dependencies `$ npm install`.
11
+ 4. Run tests with `$ npm test`.
12
+ 5. Start Hacking!
13
+
14
+ ### License
15
+
16
+ Licensed under the Apache License, Version 2.0
17
+ (<http://www.apache.org/licenses/LICENSE-2.0>)
node_modules/jake/bin/bash_completion.sh ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # http://stackoverflow.com/a/246128
4
+ SOURCE="${BASH_SOURCE[0]}"
5
+ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
6
+ DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
7
+ SOURCE="$(readlink "$SOURCE")"
8
+ [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
9
+ done
10
+ JAKE_BIN_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
11
+
12
+ # http://stackoverflow.com/a/12495480
13
+ # http://stackoverflow.com/a/28647824
14
+ _auto_jake()
15
+ {
16
+ local cur
17
+ local -a COMPGEN=()
18
+ _get_comp_words_by_ref -n : -c cur
19
+
20
+ # run auto-completions in jake via our auto_complete.js wrapper
21
+ local -a auto_complete_info=( $(export COMP_LINE="${COMP_LINE}" && ${JAKE_BIN_DIR}/auto_complete.js "$cur" "${3}") )
22
+ # check reply flag
23
+ local reply_flag="${auto_complete_info[0]}"
24
+ if [[ "${reply_flag}" == "no-complete" ]]; then
25
+ return 1
26
+ fi
27
+ local auto_completions=("${auto_complete_info[@]:1}")
28
+ COMPGEN=( $(compgen -W "${auto_completions[*]}" -- "$cur") )
29
+ COMPREPLY=( "${COMPGEN[@]}" )
30
+
31
+ __ltrim_colon_completions "$cur"
32
+
33
+ # do we need another space??
34
+ if [[ "${reply_flag}" == "yes-space" ]]; then
35
+ COMPREPLY=( "${COMPGEN[@]}" " " )
36
+ fi
37
+
38
+ return 0
39
+ }
40
+
41
+ complete -o default -F _auto_jake jake
node_modules/jake/bin/cli.js ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+ /*
3
+ * Jake JavaScript build tool
4
+ * Copyright 2112 Matthew Eernisse (mde@fleegix.org)
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ */
19
+
20
+ // Try to load a local jake
21
+ try {
22
+ require(`${ process.cwd() }/node_modules/jake`);
23
+ }
24
+ // If that fails, likely running globally
25
+ catch(e) {
26
+ require('../lib/jake');
27
+ }
28
+
29
+ var args = process.argv.slice(2);
30
+
31
+ jake.run.apply(jake, args);
node_modules/jake/jakefile.js ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ let proc = require('child_process');
2
+
3
+ const PROJECT_DIR = process.cwd();
4
+ process.env.PROJECT_DIR = PROJECT_DIR;
5
+
6
+ namespace('doc', function () {
7
+ task('generate', ['doc:clobber'], function () {
8
+ var cmd = '../node-jsdoc-toolkit/app/run.js -n -r=100 ' +
9
+ '-t=../node-jsdoc-toolkit/templates/codeview -d=./doc/ ./lib';
10
+ jake.logger.log('Generating docs ...');
11
+ jake.exec([cmd], function () {
12
+ jake.logger.log('Done.');
13
+ complete();
14
+ });
15
+ }, {async: true});
16
+
17
+ task('clobber', function () {
18
+ var cmd = 'rm -fr ./doc/*';
19
+ jake.exec([cmd], function () {
20
+ jake.logger.log('Clobbered old docs.');
21
+ complete();
22
+ });
23
+ }, {async: true});
24
+
25
+ });
26
+
27
+ desc('Generate docs for Jake');
28
+ task('doc', ['doc:generate']);
29
+
30
+ npmPublishTask('jake', function () {
31
+ this.packageFiles.include([
32
+ 'Makefile',
33
+ 'jakefile.js',
34
+ 'README.md',
35
+ 'package.json',
36
+ 'usage.txt',
37
+ 'lib/**',
38
+ 'bin/**',
39
+ 'test/**'
40
+ ]);
41
+ this.packageFiles.exclude([
42
+ 'test/tmp'
43
+ ]);
44
+ });
45
+
46
+ jake.Task['publish:package'].directory = PROJECT_DIR;
47
+
48
+ namespace('test', function () {
49
+
50
+ let integrationTest = task('integration', async function () {
51
+ let testArgs = [];
52
+ if (process.env.filter) {
53
+ testArgs.push(process.env.filter);
54
+ }
55
+ else {
56
+ testArgs.push('*.js');
57
+ }
58
+ let spawned = proc.spawn(`${PROJECT_DIR}/node_modules/.bin/mocha`, testArgs, {
59
+ stdio: 'inherit'
60
+ });
61
+ return new Promise((resolve, reject) => {
62
+ spawned.on('exit', () => {
63
+ resolve();
64
+ });
65
+ });
66
+
67
+ });
68
+ integrationTest.directory = `${PROJECT_DIR}/test/integration`;
69
+
70
+ let integrationClobber = task('integrationClobber', function () {
71
+ proc.execSync('rm -rf package.json pkg tmp_publish');
72
+ });
73
+ integrationClobber.directory = `${PROJECT_DIR}/test/integration`;
74
+
75
+ let unitTest = task('unit', async function () {
76
+ let testArgs = [];
77
+ if (process.env.filter) {
78
+ testArgs.push(process.env.filter);
79
+ }
80
+ else {
81
+ testArgs.push('*.js');
82
+ }
83
+ let spawned = proc.spawn(`${PROJECT_DIR}/node_modules/.bin/mocha`, testArgs, {
84
+ stdio: 'inherit'
85
+ });
86
+ });
87
+ unitTest.directory = `${PROJECT_DIR}/test/unit`;
88
+
89
+ });
90
+
91
+ desc('Runs all tests');
92
+ task('test', ['test:unit', 'test:integration', 'test:integrationClobber']);
93
+
94
+ desc('Runs eslint for both lib and test directories');
95
+ task('lint', function (doFix) {
96
+
97
+ let cmd = 'eslint --format codeframe "lib/**/*.js" "test/**/*.js"';
98
+ if (doFix) {
99
+ cmd += ' --fix';
100
+ }
101
+ try {
102
+ proc.execSync(cmd);
103
+ }
104
+ catch (err) {
105
+ console.log(err.message);
106
+ console.log(err.stderr.toString());
107
+ console.log(err.stdout.toString());
108
+ fail('eslint failed');
109
+ }
110
+ });
111
+
112
+
node_modules/jake/lib/api.js ADDED
@@ -0,0 +1,409 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Jake JavaScript build tool
3
+ * Copyright 2112 Matthew Eernisse (mde@fleegix.org)
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ *
17
+ */
18
+ let { uuid } = require('./utils');
19
+
20
+ let api = new (function () {
21
+ /**
22
+ @name task
23
+ @static
24
+ @function
25
+ @description Creates a Jake Task
26
+ `
27
+ @param {String} name The name of the Task
28
+ @param {Array} [prereqs] Prerequisites to be run before this task
29
+ @param {Function} [action] The action to perform for this task
30
+ @param {Object} [opts]
31
+ @param {Boolean} [opts.asyc=false] Perform this task asynchronously.
32
+ If you flag a task with this option, you must call the global
33
+ `complete` method inside the task's action, for execution to proceed
34
+ to the next task.
35
+
36
+ @example
37
+ desc('This is the default task.');
38
+ task('default', function (params) {
39
+ console.log('This is the default task.');
40
+ });
41
+
42
+ desc('This task has prerequisites.');
43
+ task('hasPrereqs', ['foo', 'bar', 'baz'], function (params) {
44
+ console.log('Ran some prereqs first.');
45
+ });
46
+
47
+ desc('This is an asynchronous task.');
48
+ task('asyncTask', function () {
49
+ setTimeout(complete, 1000);
50
+ }, {async: true});
51
+ */
52
+ this.task = function (name, prereqs, action, opts) {
53
+ let args = Array.prototype.slice.call(arguments);
54
+ let createdTask;
55
+ args.unshift('task');
56
+ createdTask = jake.createTask.apply(global, args);
57
+ jake.currentTaskDescription = null;
58
+ return createdTask;
59
+ };
60
+
61
+ /**
62
+ @name rule
63
+ @static
64
+ @function
65
+ @description Creates a Jake Suffix Rule
66
+ `
67
+ @param {String} pattern The suffix name of the objective
68
+ @param {String} source The suffix name of the objective
69
+ @param {Array} [prereqs] Prerequisites to be run before this task
70
+ @param {Function} [action] The action to perform for this task
71
+ @param {Object} [opts]
72
+ @param {Boolean} [opts.asyc=false] Perform this task asynchronously.
73
+ If you flag a task with this option, you must call the global
74
+ `complete` method inside the task's action, for execution to proceed
75
+ to the next task.
76
+ @example
77
+ desc('This is a rule, which does not support namespace or pattern.');
78
+ rule('.o', '.c', {async: true}, function () {
79
+ let cmd = util.format('gcc -o %s %s', this.name, this.source);
80
+ jake.exec([cmd], function () {
81
+ complete();
82
+ }, {printStdout: true});
83
+ });
84
+
85
+ desc('This rule has prerequisites.');
86
+ rule('.o', '.c', ['util.h'], {async: true}, function () {
87
+ let cmd = util.format('gcc -o %s %s', this.name, this.source);
88
+ jake.exec([cmd], function () {
89
+ complete();
90
+ }, {printStdout: true});
91
+ });
92
+
93
+ desc('This is a rule with patterns.');
94
+ rule('%.o', '%.c', {async: true}, function () {
95
+ let cmd = util.format('gcc -o %s %s', this.name, this.source);
96
+ jake.exec([cmd], function () {
97
+ complete();
98
+ }, {printStdout: true});
99
+ });
100
+
101
+ desc('This is another rule with patterns.');
102
+ rule('obj/%.o', 'src/%.c', {async: true}, function () {
103
+ let cmd = util.format('gcc -o %s %s', this.name, this.source);
104
+ jake.exec([cmd], function () {
105
+ complete();
106
+ }, {printStdout: true});
107
+ });
108
+
109
+ desc('This is an example with chain rules.');
110
+ rule('%.pdf', '%.dvi', {async: true}, function () {
111
+ let cmd = util.format('dvipdfm %s',this.source);
112
+ jake.exec([cmd], function () {
113
+ complete();
114
+ }, {printStdout: true});
115
+ });
116
+
117
+ rule('%.dvi', '%.tex', {async: true}, function () {
118
+ let cmd = util.format('latex %s',this.source);
119
+ jake.exec([cmd], function () {
120
+ complete();
121
+ }, {printStdout: true});
122
+ });
123
+
124
+ desc('This rule has a namespace.');
125
+ task('default', ['debug:obj/main.o]);
126
+
127
+ namespace('debug', {async: true}, function() {
128
+ rule('obj/%.o', 'src/%.c', function () {
129
+ // ...
130
+ });
131
+ }
132
+ */
133
+ this.rule = function () {
134
+ let args = Array.prototype.slice.call(arguments);
135
+ let arg;
136
+ let pattern = args.shift();
137
+ let source = args.shift();
138
+ let prereqs = [];
139
+ let action = function () {};
140
+ let opts = {};
141
+ let key = pattern.toString(); // May be a RegExp
142
+
143
+ while ((arg = args.shift())) {
144
+ if (typeof arg == 'function') {
145
+ action = arg;
146
+ }
147
+ else if (Array.isArray(arg)) {
148
+ prereqs = arg;
149
+ }
150
+ else {
151
+ opts = arg;
152
+ }
153
+ }
154
+
155
+ jake.currentNamespace.rules[key] = new jake.Rule({
156
+ pattern: pattern,
157
+ source: source,
158
+ prereqs: prereqs,
159
+ action: action,
160
+ opts: opts,
161
+ desc: jake.currentTaskDescription,
162
+ ns: jake.currentNamespace
163
+ });
164
+ jake.currentTaskDescription = null;
165
+ };
166
+
167
+ /**
168
+ @name directory
169
+ @static
170
+ @function
171
+ @description Creates a Jake DirectoryTask. Can be used as a prerequisite
172
+ for FileTasks, or for simply ensuring a directory exists for use with a
173
+ Task's action.
174
+ `
175
+ @param {String} name The name of the DiretoryTask
176
+
177
+ @example
178
+
179
+ // Creates the package directory for distribution
180
+ directory('pkg');
181
+ */
182
+ this.directory = function (name) {
183
+ let args = Array.prototype.slice.call(arguments);
184
+ let createdTask;
185
+ args.unshift('directory');
186
+ createdTask = jake.createTask.apply(global, args);
187
+ jake.currentTaskDescription = null;
188
+ return createdTask;
189
+ };
190
+
191
+ /**
192
+ @name file
193
+ @static
194
+ @function
195
+ @description Creates a Jake FileTask.
196
+ `
197
+ @param {String} name The name of the FileTask
198
+ @param {Array} [prereqs] Prerequisites to be run before this task
199
+ @param {Function} [action] The action to create this file, if it doesn't
200
+ exist already.
201
+ @param {Object} [opts]
202
+ @param {Array} [opts.asyc=false] Perform this task asynchronously.
203
+ If you flag a task with this option, you must call the global
204
+ `complete` method inside the task's action, for execution to proceed
205
+ to the next task.
206
+
207
+ */
208
+ this.file = function (name, prereqs, action, opts) {
209
+ let args = Array.prototype.slice.call(arguments);
210
+ let createdTask;
211
+ args.unshift('file');
212
+ createdTask = jake.createTask.apply(global, args);
213
+ jake.currentTaskDescription = null;
214
+ return createdTask;
215
+ };
216
+
217
+ /**
218
+ @name desc
219
+ @static
220
+ @function
221
+ @description Creates a description for a Jake Task (or FileTask,
222
+ DirectoryTask). When invoked, the description that iscreated will
223
+ be associated with whatever Task is created next.
224
+ `
225
+ @param {String} description The description for the Task
226
+ */
227
+ this.desc = function (description) {
228
+ jake.currentTaskDescription = description;
229
+ };
230
+
231
+ /**
232
+ @name namespace
233
+ @static
234
+ @function
235
+ @description Creates a namespace which allows logical grouping
236
+ of tasks, and prevents name-collisions with task-names. Namespaces
237
+ can be nested inside of other namespaces.
238
+ `
239
+ @param {String} name The name of the namespace
240
+ @param {Function} scope The enclosing scope for the namespaced tasks
241
+
242
+ @example
243
+ namespace('doc', function () {
244
+ task('generate', ['doc:clobber'], function () {
245
+ // Generate some docs
246
+ });
247
+
248
+ task('clobber', function () {
249
+ // Clobber the doc directory first
250
+ });
251
+ });
252
+ */
253
+ this.namespace = function (name, closure) {
254
+ let curr = jake.currentNamespace;
255
+ let ns = curr.childNamespaces[name] || new jake.Namespace(name, curr);
256
+ let fn = closure || function () {};
257
+ curr.childNamespaces[name] = ns;
258
+ jake.currentNamespace = ns;
259
+ fn();
260
+ jake.currentNamespace = curr;
261
+ jake.currentTaskDescription = null;
262
+ return ns;
263
+ };
264
+
265
+ /**
266
+ @name complete
267
+ @static
268
+ @function
269
+ @description Completes an asynchronous task, allowing Jake's
270
+ execution to proceed to the next task. Calling complete globally or without
271
+ arguments completes the last task on the invocationChain. If you use parallel
272
+ execution of prereqs this will probably complete a wrong task. You should call this
273
+ function with this task as the first argument, before the optional return value.
274
+ Alternatively you can call task.complete()
275
+ `
276
+ @example
277
+ task('generate', ['doc:clobber'], function () {
278
+ exec('./generate_docs.sh', function (err, stdout, stderr) {
279
+ if (err || stderr) {
280
+ fail(err || stderr);
281
+ }
282
+ else {
283
+ console.log(stdout);
284
+ complete();
285
+ }
286
+ });
287
+ }, {async: true});
288
+ */
289
+ this.complete = function (task, val) {
290
+ //this should detect if the first arg is a task, but I guess it should be more thorough
291
+ if(task && task. _currentPrereqIndex >=0 ) {
292
+ task.complete(val);
293
+ }
294
+ else {
295
+ val = task;
296
+ if(jake._invocationChain.length > 0) {
297
+ jake._invocationChain[jake._invocationChain.length-1].complete(val);
298
+ }
299
+ }
300
+ };
301
+
302
+ /**
303
+ @name fail
304
+ @static
305
+ @function
306
+ @description Causes Jake execution to abort with an error.
307
+ Allows passing an optional error code, which will be used to
308
+ set the exit-code of exiting process.
309
+ `
310
+ @param {Error|String} err The error to thow when aborting execution.
311
+ If this argument is an Error object, it will simply be thrown. If
312
+ a String, it will be used as the error-message. (If it is a multi-line
313
+ String, the first line will be used as the Error message, and the
314
+ remaining lines will be used as the error-stack.)
315
+
316
+ @example
317
+ task('createTests, function () {
318
+ if (!fs.existsSync('./tests')) {
319
+ fail('Test directory does not exist.');
320
+ }
321
+ else {
322
+ // Do some testing stuff ...
323
+ }
324
+ });
325
+ */
326
+ this.fail = function (err, code) {
327
+ let msg;
328
+ let errObj;
329
+ if (code) {
330
+ jake.errorCode = code;
331
+ }
332
+ if (err) {
333
+ if (typeof err == 'string') {
334
+ // Use the initial or only line of the error as the error-message
335
+ // If there was a multi-line error, use the rest as the stack
336
+ msg = err.split('\n');
337
+ errObj = new Error(msg.shift());
338
+ if (msg.length) {
339
+ errObj.stack = msg.join('\n');
340
+ }
341
+ throw errObj;
342
+ }
343
+ else if (err instanceof Error) {
344
+ throw err;
345
+ }
346
+ else {
347
+ throw new Error(err.toString());
348
+ }
349
+ }
350
+ else {
351
+ throw new Error();
352
+ }
353
+ };
354
+
355
+ this.packageTask = function (name, version, prereqs, definition) {
356
+ return new jake.PackageTask(name, version, prereqs, definition);
357
+ };
358
+
359
+ this.publishTask = function (name, prereqs, opts, definition) {
360
+ return new jake.PublishTask(name, prereqs, opts, definition);
361
+ };
362
+
363
+ // Backward-compat
364
+ this.npmPublishTask = function (name, prereqs, opts, definition) {
365
+ return new jake.PublishTask(name, prereqs, opts, definition);
366
+ };
367
+
368
+ this.testTask = function () {
369
+ let ctor = function () {};
370
+ let t;
371
+ ctor.prototype = jake.TestTask.prototype;
372
+ t = new ctor();
373
+ jake.TestTask.apply(t, arguments);
374
+ return t;
375
+ };
376
+
377
+ this.setTaskTimeout = function (t) {
378
+ this._taskTimeout = t;
379
+ };
380
+
381
+ this.setSeriesAutoPrefix = function (prefix) {
382
+ this._seriesAutoPrefix = prefix;
383
+ };
384
+
385
+ this.series = function (...args) {
386
+ let prereqs = args.map((arg) => {
387
+ let name = (this._seriesAutoPrefix || '') + arg.name;
388
+ jake.task(name, arg);
389
+ return name;
390
+ });
391
+ let seriesName = uuid();
392
+ let seriesTask = jake.task(seriesName, prereqs);
393
+ seriesTask._internal = true;
394
+ let res = function () {
395
+ return new Promise((resolve) => {
396
+ seriesTask.invoke();
397
+ seriesTask.on('complete', (val) => {
398
+ resolve(val);
399
+ });
400
+ });
401
+ };
402
+ Object.defineProperty(res, 'name', {value: uuid(),
403
+ writable: false});
404
+ return res;
405
+ };
406
+
407
+ })();
408
+
409
+ module.exports = api;
node_modules/jake/lib/jake.js ADDED
@@ -0,0 +1,330 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Jake JavaScript build tool
3
+ * Copyright 2112 Matthew Eernisse (mde@fleegix.org)
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ *
17
+ */
18
+
19
+ if (!global.jake) {
20
+
21
+ let EventEmitter = require('events').EventEmitter;
22
+ // And so it begins
23
+ global.jake = new EventEmitter();
24
+
25
+ let fs = require('fs');
26
+ let pc = require('picocolors');
27
+ let taskNs = require('./task');
28
+ let Task = taskNs.Task;
29
+ let FileTask = taskNs.FileTask;
30
+ let DirectoryTask = taskNs.DirectoryTask;
31
+ let Rule = require('./rule').Rule;
32
+ let Namespace = require('./namespace').Namespace;
33
+ let RootNamespace = require('./namespace').RootNamespace;
34
+ let api = require('./api');
35
+ let utils = require('./utils');
36
+ let Program = require('./program').Program;
37
+ let loader = require('./loader')();
38
+ let pkg = JSON.parse(fs.readFileSync(__dirname + '/../package.json').toString());
39
+
40
+ const MAX_RULE_RECURSION_LEVEL = 16;
41
+
42
+ // Globalize jake and top-level API methods (e.g., `task`, `desc`)
43
+ Object.assign(global, api);
44
+
45
+ // Copy utils onto base jake
46
+ jake.logger = utils.logger;
47
+ jake.exec = utils.exec;
48
+
49
+ // File utils should be aliased directly on base jake as well
50
+ Object.assign(jake, utils.file);
51
+
52
+ // Also add top-level API methods to exported object for those who don't want to
53
+ // use the globals (`file` here will overwrite the 'file' utils namespace)
54
+ Object.assign(jake, api);
55
+
56
+ Object.assign(jake, new (function () {
57
+
58
+ this._invocationChain = [];
59
+ this._taskTimeout = 30000;
60
+
61
+ // Public properties
62
+ // =================
63
+ this.version = pkg.version;
64
+ // Used when Jake exits with a specific error-code
65
+ this.errorCode = null;
66
+ // Loads Jakefiles/jakelibdirs
67
+ this.loader = loader;
68
+ // The root of all ... namespaces
69
+ this.rootNamespace = new RootNamespace();
70
+ // Non-namespaced tasks are placed into the default
71
+ this.defaultNamespace = this.rootNamespace;
72
+ // Start in the default
73
+ this.currentNamespace = this.defaultNamespace;
74
+ // Saves the description created by a 'desc' call that prefaces a
75
+ // 'task' call that defines a task.
76
+ this.currentTaskDescription = null;
77
+ this.program = new Program();
78
+ this.FileList = require('filelist').FileList;
79
+ this.PackageTask = require('./package_task').PackageTask;
80
+ this.PublishTask = require('./publish_task').PublishTask;
81
+ this.TestTask = require('./test_task').TestTask;
82
+ this.Task = Task;
83
+ this.FileTask = FileTask;
84
+ this.DirectoryTask = DirectoryTask;
85
+ this.Namespace = Namespace;
86
+ this.Rule = Rule;
87
+
88
+ this.parseAllTasks = function () {
89
+ let _parseNs = function (ns) {
90
+ let nsTasks = ns.tasks;
91
+ let nsNamespaces = ns.childNamespaces;
92
+ for (let q in nsTasks) {
93
+ let nsTask = nsTasks[q];
94
+ jake.Task[nsTask.fullName] = nsTask;
95
+ }
96
+ for (let p in nsNamespaces) {
97
+ let nsNamespace = nsNamespaces[p];
98
+ _parseNs(nsNamespace);
99
+ }
100
+ };
101
+ _parseNs(jake.defaultNamespace);
102
+ };
103
+
104
+ /**
105
+ * Displays the list of descriptions available for tasks defined in
106
+ * a Jakefile
107
+ */
108
+ this.showAllTaskDescriptions = function (f) {
109
+ let p;
110
+ let maxTaskNameLength = 0;
111
+ let task;
112
+ let padding;
113
+ let name;
114
+ let descr;
115
+ let filter = typeof f == 'string' ? f : null;
116
+ let taskParams;
117
+ let len;
118
+
119
+ for (p in jake.Task) {
120
+ if (!Object.prototype.hasOwnProperty.call(jake.Task, p)) {
121
+ continue;
122
+ }
123
+ if (filter && p.indexOf(filter) == -1) {
124
+ continue;
125
+ }
126
+ task = jake.Task[p];
127
+ taskParams = task.params;
128
+
129
+ // Record the length of the longest task name -- used for
130
+ // pretty alignment of the task descriptions
131
+ if (task.description) {
132
+ len = p.length + taskParams.length;
133
+ maxTaskNameLength = len > maxTaskNameLength ?
134
+ len : maxTaskNameLength;
135
+ }
136
+ }
137
+
138
+ // Print out each entry with descriptions neatly aligned
139
+ for (p in jake.Task) {
140
+ if (!Object.prototype.hasOwnProperty.call(jake.Task, p)) {
141
+ continue;
142
+ }
143
+ if (filter && p.indexOf(filter) == -1) {
144
+ continue;
145
+ }
146
+ task = jake.Task[p];
147
+
148
+ taskParams = "";
149
+ if (task.params != "") {
150
+ taskParams = "[" + task.params + "]";
151
+ }
152
+
153
+ //name = '\033[32m' + p + '\033[39m ';
154
+ name = pc.green(p);
155
+
156
+ descr = task.description;
157
+ if (descr) {
158
+ descr = pc.gray('# ' + descr);
159
+
160
+ // Create padding-string with calculated length
161
+ padding = ' '.repeat(maxTaskNameLength - p.length - taskParams.length + 4);
162
+
163
+ console.log('jake ' + name + taskParams + padding + descr);
164
+ }
165
+ }
166
+ };
167
+
168
+ this.createTask = function () {
169
+ let args = Array.prototype.slice.call(arguments);
170
+ let arg;
171
+ let obj;
172
+ let task;
173
+ let type;
174
+ let name;
175
+ let action;
176
+ let opts = {};
177
+ let prereqs = [];
178
+
179
+ type = args.shift();
180
+
181
+ // name, [deps], [action]
182
+ // Name (string) + deps (array) format
183
+ if (typeof args[0] == 'string') {
184
+ name = args.shift();
185
+ if (Array.isArray(args[0])) {
186
+ prereqs = args.shift();
187
+ }
188
+ }
189
+ // name:deps, [action]
190
+ // Legacy object-literal syntax, e.g.: {'name': ['depA', 'depB']}
191
+ else {
192
+ obj = args.shift();
193
+ for (let p in obj) {
194
+ prereqs = prereqs.concat(obj[p]);
195
+ name = p;
196
+ }
197
+ }
198
+
199
+ // Optional opts/callback or callback/opts
200
+ while ((arg = args.shift())) {
201
+ if (typeof arg == 'function') {
202
+ action = arg;
203
+ }
204
+ else {
205
+ opts = Object.assign(Object.create(null), arg);
206
+ }
207
+ }
208
+
209
+ task = jake.currentNamespace.resolveTask(name);
210
+ if (task && !action) {
211
+ // Task already exists and no action, just update prereqs, and return it.
212
+ task.prereqs = task.prereqs.concat(prereqs);
213
+ return task;
214
+ }
215
+
216
+ switch (type) {
217
+ case 'directory':
218
+ action = function action() {
219
+ jake.mkdirP(name);
220
+ };
221
+ task = new DirectoryTask(name, prereqs, action, opts);
222
+ break;
223
+ case 'file':
224
+ task = new FileTask(name, prereqs, action, opts);
225
+ break;
226
+ default:
227
+ task = new Task(name, prereqs, action, opts);
228
+ }
229
+
230
+ jake.currentNamespace.addTask(task);
231
+
232
+ if (jake.currentTaskDescription) {
233
+ task.description = jake.currentTaskDescription;
234
+ jake.currentTaskDescription = null;
235
+ }
236
+
237
+ // FIXME: Should only need to add a new entry for the current
238
+ // task-definition, not reparse the entire structure
239
+ jake.parseAllTasks();
240
+
241
+ return task;
242
+ };
243
+
244
+ this.attemptRule = function (name, ns, level) {
245
+ let prereqRule;
246
+ let prereq;
247
+ if (level > MAX_RULE_RECURSION_LEVEL) {
248
+ return null;
249
+ }
250
+ // Check Rule
251
+ prereqRule = ns.matchRule(name);
252
+ if (prereqRule) {
253
+ prereq = prereqRule.createTask(name, level);
254
+ }
255
+ return prereq || null;
256
+ };
257
+
258
+ this.createPlaceholderFileTask = function (name, namespace) {
259
+ let parsed = name.split(':');
260
+ let filePath = parsed.pop(); // Strip any namespace
261
+ let task;
262
+
263
+ task = namespace.resolveTask(name);
264
+
265
+ // If there's not already an existing dummy FileTask for it,
266
+ // create one
267
+ if (!task) {
268
+ // Create a dummy FileTask only if file actually exists
269
+ if (fs.existsSync(filePath)) {
270
+ task = new jake.FileTask(filePath);
271
+ task.dummy = true;
272
+ let ns;
273
+ if (parsed.length) {
274
+ ns = namespace.resolveNamespace(parsed.join(':'));
275
+ }
276
+ else {
277
+ ns = namespace;
278
+ }
279
+ if (!namespace) {
280
+ throw new Error('Invalid namespace, cannot add FileTask');
281
+ }
282
+ ns.addTask(task);
283
+ // Put this dummy Task in the global Tasks list so
284
+ // modTime will be eval'd correctly
285
+ jake.Task[`${ns.path}:${filePath}`] = task;
286
+ }
287
+ }
288
+
289
+ return task || null;
290
+ };
291
+
292
+
293
+ this.run = function () {
294
+ let args = Array.prototype.slice.call(arguments);
295
+ let program = this.program;
296
+ let loader = this.loader;
297
+ let preempt;
298
+ let opts;
299
+
300
+ program.parseArgs(args);
301
+ program.init();
302
+
303
+ preempt = program.firstPreemptiveOption();
304
+ if (preempt) {
305
+ preempt();
306
+ }
307
+ else {
308
+ opts = program.opts;
309
+ // jakefile flag set but no jakefile yet
310
+ if (opts.autocomplete && opts.jakefile === true) {
311
+ process.stdout.write('no-complete');
312
+ return;
313
+ }
314
+ // Load Jakefile and jakelibdir files
315
+ let jakefileLoaded = loader.loadFile(opts.jakefile);
316
+ let jakelibdirLoaded = loader.loadDirectory(opts.jakelibdir);
317
+
318
+ if(!jakefileLoaded && !jakelibdirLoaded && !opts.autocomplete) {
319
+ fail('No Jakefile. Specify a valid path with -f/--jakefile, ' +
320
+ 'or place one in the current directory.');
321
+ }
322
+
323
+ program.run();
324
+ }
325
+ };
326
+
327
+ })());
328
+ }
329
+
330
+ module.exports = jake;
node_modules/jake/lib/loader.js ADDED
@@ -0,0 +1,174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Jake JavaScript build tool
3
+ * Copyright 2112 Matthew Eernisse (mde@fleegix.org)
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ *
17
+ */
18
+
19
+ let path = require('path');
20
+ let fs = require('fs');
21
+ let existsSync = fs.existsSync;
22
+ let utils = require('./utils');
23
+
24
+ // Files like jakelib/foobar.jake.js
25
+ const JAKELIB_FILE_PAT = /\.jake$|\.js$/;
26
+ const SUPPORTED_EXTENSIONS = {
27
+ 'js': null,
28
+ 'cjs': null,
29
+ 'coffee': function () {
30
+ try {
31
+ let cs = require('coffeescript');
32
+ if (typeof cs.register == 'function') {
33
+ cs.register();
34
+ }
35
+ }
36
+ catch(e) {
37
+ throw new Error('You have a CoffeeScript Jakefile, but have not installed CoffeeScript');
38
+ }
39
+ },
40
+ 'ls': function () {
41
+ try {
42
+ require('livescript');
43
+ }
44
+ catch (e) {
45
+ throw new Error('You have a LiveScript Jakefile, but have not installed LiveScript');
46
+ }
47
+ },
48
+ 'ts': function () {
49
+ try {
50
+ require('ts-node/register/transpile-only');
51
+ }
52
+ catch (e) {
53
+ throw new Error('You have a TypeScript Jakefile, but have not installed TypeScript and ts-node');
54
+ }
55
+ }
56
+ };
57
+ const IMPLICIT_JAKEFILE_NAMES = [
58
+ 'Jakefile',
59
+ 'Gulpfile'
60
+ ];
61
+
62
+ let Loader = function () {
63
+ // Load a Jakefile, running the code inside -- this may result in
64
+ // tasks getting defined using the original Jake API, e.g.,
65
+ // `task('foo' ['bar', 'baz']);`, or can also auto-create tasks
66
+ // from any functions exported from the file
67
+ function loadFile(filePath) {
68
+ let exported = require(filePath);
69
+ for (let [key, value] of Object.entries(exported)) {
70
+ let t;
71
+ if (typeof value == 'function') {
72
+ t = jake.task(key, value);
73
+ t.description = '(Exported function)';
74
+ }
75
+ }
76
+ }
77
+
78
+ function fileExists(name) {
79
+ let nameWithExt = null;
80
+ // Support no file extension as well
81
+ let exts = Object.keys(SUPPORTED_EXTENSIONS).concat(['']);
82
+ exts.some((ext) => {
83
+ let fname = ext ? `${name}.${ext}` : name;
84
+ if (existsSync(fname)) {
85
+ nameWithExt = fname;
86
+ return true;
87
+ }
88
+ });
89
+ return nameWithExt;
90
+ }
91
+
92
+ // Recursive
93
+ function findImplicitJakefile() {
94
+ let cwd = process.cwd();
95
+ let names = IMPLICIT_JAKEFILE_NAMES;
96
+ let found = null;
97
+ names.some((name) => {
98
+ let n;
99
+ // Prefer all-lowercase
100
+ n = name.toLowerCase();
101
+ if ((found = fileExists(n))) {
102
+ return found;
103
+ }
104
+ // Check mixed-case as well
105
+ n = name;
106
+ if ((found = fileExists(n))) {
107
+ return found;
108
+ }
109
+ });
110
+ if (found) {
111
+ return found;
112
+ }
113
+ else {
114
+ process.chdir("..");
115
+ // If we've walked all the way up the directory tree,
116
+ // bail out with no result
117
+ if (cwd === process.cwd()) {
118
+ return null;
119
+ }
120
+ return findImplicitJakefile();
121
+ }
122
+ }
123
+
124
+ this.loadFile = function (fileSpecified) {
125
+ let jakefile;
126
+ let origCwd = process.cwd();
127
+
128
+ if (fileSpecified) {
129
+ if (existsSync(fileSpecified)) {
130
+ jakefile = fileSpecified;
131
+ }
132
+ }
133
+ else {
134
+ jakefile = findImplicitJakefile();
135
+ }
136
+
137
+ if (jakefile) {
138
+ let ext = jakefile.split('.')[1];
139
+ let loaderFunc = SUPPORTED_EXTENSIONS[ext];
140
+ loaderFunc && loaderFunc();
141
+
142
+ loadFile(utils.file.absolutize(jakefile));
143
+ return true;
144
+ }
145
+ else {
146
+ if (!fileSpecified) {
147
+ // Restore the working directory on failure
148
+ process.chdir(origCwd);
149
+ }
150
+ return false;
151
+ }
152
+ };
153
+
154
+ this.loadDirectory = function (d) {
155
+ let dirname = d || 'jakelib';
156
+ let dirlist;
157
+ dirname = utils.file.absolutize(dirname);
158
+ if (existsSync(dirname)) {
159
+ dirlist = fs.readdirSync(dirname);
160
+ dirlist.forEach(function (filePath) {
161
+ if (JAKELIB_FILE_PAT.test(filePath)) {
162
+ loadFile(path.join(dirname, filePath));
163
+ }
164
+ });
165
+ return true;
166
+ }
167
+ return false;
168
+ };
169
+
170
+ };
171
+
172
+ module.exports = function () {
173
+ return new Loader();
174
+ };
node_modules/jake/lib/namespace.js ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const ROOT_NAMESPACE_NAME = '__rootNamespace__';
2
+
3
+ class Namespace {
4
+ constructor(name, parentNamespace) {
5
+ this.name = name;
6
+ this.parentNamespace = parentNamespace;
7
+ this.childNamespaces = {};
8
+ this.tasks = {};
9
+ this.rules = {};
10
+ this.path = this.getPath();
11
+ }
12
+
13
+ get fullName() {
14
+ return this._getFullName();
15
+ }
16
+
17
+ addTask(task) {
18
+ this.tasks[task.name] = task;
19
+ task.namespace = this;
20
+ }
21
+
22
+ resolveTask(name) {
23
+ if (!name) {
24
+ return;
25
+ }
26
+
27
+ let taskPath = name.split(':');
28
+ let taskName = taskPath.pop();
29
+ let task;
30
+ let ns;
31
+
32
+ // Namespaced, return either relative to current, or from root
33
+ if (taskPath.length) {
34
+ taskPath = taskPath.join(':');
35
+ ns = this.resolveNamespace(taskPath) ||
36
+ Namespace.ROOT_NAMESPACE.resolveNamespace(taskPath);
37
+ task = (ns && ns.resolveTask(taskName));
38
+ }
39
+ // Bare task, return either local, or top-level
40
+ else {
41
+ task = this.tasks[name] || Namespace.ROOT_NAMESPACE.tasks[name];
42
+ }
43
+
44
+ return task || null;
45
+ }
46
+
47
+
48
+ resolveNamespace(relativeName) {
49
+ if (!relativeName) {
50
+ return this;
51
+ }
52
+
53
+ let parts = relativeName.split(':');
54
+ let ns = this;
55
+
56
+ for (let i = 0, ii = parts.length; (ns && i < ii); i++) {
57
+ ns = ns.childNamespaces[parts[i]];
58
+ }
59
+
60
+ return ns || null;
61
+ }
62
+
63
+ matchRule(relativeName) {
64
+ let parts = relativeName.split(':');
65
+ parts.pop();
66
+ let ns = this.resolveNamespace(parts.join(':'));
67
+ let rules = ns ? ns.rules : [];
68
+ let r;
69
+ let match;
70
+
71
+ for (let p in rules) {
72
+ r = rules[p];
73
+ if (r.match(relativeName)) {
74
+ match = r;
75
+ }
76
+ }
77
+
78
+ return (ns && match) ||
79
+ (this.parentNamespace &&
80
+ this.parentNamespace.matchRule(relativeName));
81
+ }
82
+
83
+ getPath() {
84
+ let parts = [];
85
+ let next = this.parentNamespace;
86
+ while (next) {
87
+ parts.push(next.name);
88
+ next = next.parentNamespace;
89
+ }
90
+ parts.pop(); // Remove '__rootNamespace__'
91
+ return parts.reverse().join(':');
92
+ }
93
+
94
+ _getFullName() {
95
+ let path = this.path;
96
+ path = (path && path.split(':')) || [];
97
+ path.push(this.name);
98
+ return path.join(':');
99
+ }
100
+
101
+ isRootNamespace() {
102
+ return !this.parentNamespace;
103
+ }
104
+ }
105
+
106
+ class RootNamespace extends Namespace {
107
+ constructor() {
108
+ super(ROOT_NAMESPACE_NAME, null);
109
+ Namespace.ROOT_NAMESPACE = this;
110
+ }
111
+ }
112
+
113
+ module.exports.Namespace = Namespace;
114
+ module.exports.RootNamespace = RootNamespace;
115
+
node_modules/jake/lib/package_task.js ADDED
@@ -0,0 +1,406 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Jake JavaScript build tool
3
+ * Copyright 2112 Matthew Eernisse (mde@fleegix.org)
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ *
17
+ */
18
+
19
+ let path = require('path');
20
+ let fs = require('fs');
21
+ let exec = require('child_process').exec;
22
+ let FileList = require('filelist').FileList;
23
+
24
+ /**
25
+ @name jake
26
+ @namespace jake
27
+ */
28
+ /**
29
+ @name jake.PackageTask
30
+ @constructor
31
+ @description Instantiating a PackageTask creates a number of Jake
32
+ Tasks that make packaging and distributing your software easy.
33
+
34
+ @param {String} name The name of the project
35
+ @param {String} version The current project version (will be
36
+ appended to the project-name in the package-archive
37
+ @param {Function} definition Defines the contents of the package,
38
+ and format of the package-archive. Will be executed on the instantiated
39
+ PackageTask (i.e., 'this', will be the PackageTask instance),
40
+ to set the various instance-propertiess.
41
+
42
+ @example
43
+ let t = new jake.PackageTask('rous', 'v' + version, function () {
44
+ let files = [
45
+ 'Capfile'
46
+ , 'Jakefile'
47
+ , 'README.md'
48
+ , 'package.json'
49
+ , 'app/*'
50
+ , 'bin/*'
51
+ , 'config/*'
52
+ , 'lib/*'
53
+ , 'node_modules/*'
54
+ ];
55
+ this.packageFiles.include(files);
56
+ this.packageFiles.exclude('node_modules/foobar');
57
+ this.needTarGz = true;
58
+ });
59
+
60
+ */
61
+ let PackageTask = function () {
62
+ let args = Array.prototype.slice.call(arguments);
63
+ let name = args.shift();
64
+ let version = args.shift();
65
+ let definition = args.pop();
66
+ let prereqs = args.pop() || []; // Optional
67
+
68
+ prereqs = [].concat(prereqs); // Accept string or list
69
+
70
+ /**
71
+ @name jake.PackageTask#name
72
+ @public
73
+ @type {String}
74
+ @description The name of the project
75
+ */
76
+ this.name = name;
77
+ /**
78
+ @name jake.PackageTask#version
79
+ @public
80
+ @type {String}
81
+ @description The project version-string
82
+ */
83
+ this.version = version;
84
+ /**
85
+ @name jake.PackageTask#prereqs
86
+ @public
87
+ @type {Array}
88
+ @description Tasks to run before packaging
89
+ */
90
+ this.prereqs = prereqs;
91
+ /**
92
+ @name jake.PackageTask#packageDir
93
+ @public
94
+ @type {String='pkg'}
95
+ @description The directory-name to use for packaging the software
96
+ */
97
+ this.packageDir = 'pkg';
98
+ /**
99
+ @name jake.PackageTask#packageFiles
100
+ @public
101
+ @type {jake.FileList}
102
+ @description The list of files and directories to include in the
103
+ package-archive
104
+ */
105
+ this.packageFiles = new FileList();
106
+ /**
107
+ @name jake.PackageTask#needTar
108
+ @public
109
+ @type {Boolean=false}
110
+ @description If set to true, uses the `tar` utility to create
111
+ a gzip .tgz archive of the package
112
+ */
113
+ this.needTar = false;
114
+ /**
115
+ @name jake.PackageTask#needTarGz
116
+ @public
117
+ @type {Boolean=false}
118
+ @description If set to true, uses the `tar` utility to create
119
+ a gzip .tar.gz archive of the package
120
+ */
121
+ this.needTarGz = false;
122
+ /**
123
+ @name jake.PackageTask#needTarBz2
124
+ @public
125
+ @type {Boolean=false}
126
+ @description If set to true, uses the `tar` utility to create
127
+ a bzip2 .bz2 archive of the package
128
+ */
129
+ this.needTarBz2 = false;
130
+ /**
131
+ @name jake.PackageTask#needJar
132
+ @public
133
+ @type {Boolean=false}
134
+ @description If set to true, uses the `jar` utility to create
135
+ a .jar archive of the package
136
+ */
137
+ this.needJar = false;
138
+ /**
139
+ @name jake.PackageTask#needZip
140
+ @public
141
+ @type {Boolean=false}
142
+ @description If set to true, uses the `zip` utility to create
143
+ a .zip archive of the package
144
+ */
145
+ this.needZip = false;
146
+ /**
147
+ @name jake.PackageTask#manifestFile
148
+ @public
149
+ @type {String=null}
150
+ @description Can be set to point the `jar` utility at a manifest
151
+ file to use in a .jar archive. If unset, one will be automatically
152
+ created by the `jar` utility. This path should be relative to the
153
+ root of the package directory (this.packageDir above, likely 'pkg')
154
+ */
155
+ this.manifestFile = null;
156
+ /**
157
+ @name jake.PackageTask#tarCommand
158
+ @public
159
+ @type {String='tar'}
160
+ @description The shell-command to use for creating tar archives.
161
+ */
162
+ this.tarCommand = 'tar';
163
+ /**
164
+ @name jake.PackageTask#jarCommand
165
+ @public
166
+ @type {String='jar'}
167
+ @description The shell-command to use for creating jar archives.
168
+ */
169
+ this.jarCommand = 'jar';
170
+ /**
171
+ @name jake.PackageTask#zipCommand
172
+ @public
173
+ @type {String='zip'}
174
+ @description The shell-command to use for creating zip archives.
175
+ */
176
+ this.zipCommand = 'zip';
177
+ /**
178
+ @name jake.PackageTask#archiveNoBaseDir
179
+ @public
180
+ @type {Boolean=false}
181
+ @description Simple option for performing the archive on the
182
+ contents of the directory instead of the directory itself
183
+ */
184
+ this.archiveNoBaseDir = false;
185
+ /**
186
+ @name jake.PackageTask#archiveChangeDir
187
+ @public
188
+ @type {String=null}
189
+ @description Equivalent to the '-C' command for the `tar` and `jar`
190
+ commands. ("Change to this directory before adding files.")
191
+ */
192
+ this.archiveChangeDir = null;
193
+ /**
194
+ @name jake.PackageTask#archiveContentDir
195
+ @public
196
+ @type {String=null}
197
+ @description Specifies the files and directories to include in the
198
+ package-archive. If unset, this will default to the main package
199
+ directory -- i.e., name + version.
200
+ */
201
+ this.archiveContentDir = null;
202
+
203
+ if (typeof definition == 'function') {
204
+ definition.call(this);
205
+ }
206
+ this.define();
207
+ };
208
+
209
+ PackageTask.prototype = new (function () {
210
+
211
+ let _compressOpts = {
212
+ Tar: {
213
+ ext: '.tgz',
214
+ flags: 'czf',
215
+ cmd: 'tar'
216
+ },
217
+ TarGz: {
218
+ ext: '.tar.gz',
219
+ flags: 'czf',
220
+ cmd: 'tar'
221
+ },
222
+ TarBz2: {
223
+ ext: '.tar.bz2',
224
+ flags: 'cjf',
225
+ cmd: 'tar'
226
+ },
227
+ Jar: {
228
+ ext: '.jar',
229
+ flags: 'cf',
230
+ cmd: 'jar'
231
+ },
232
+ Zip: {
233
+ ext: '.zip',
234
+ flags: 'qr',
235
+ cmd: 'zip'
236
+ }
237
+ };
238
+
239
+ this.define = function () {
240
+ let self = this;
241
+ let packageDirPath = this.packageDirPath();
242
+ let compressTaskArr = [];
243
+
244
+ desc('Build the package for distribution');
245
+ task('package', self.prereqs.concat(['clobberPackage', 'buildPackage']));
246
+ // Backward-compat alias
247
+ task('repackage', ['package']);
248
+
249
+ task('clobberPackage', function () {
250
+ jake.rmRf(self.packageDir, {silent: true});
251
+ });
252
+
253
+ desc('Remove the package');
254
+ task('clobber', ['clobberPackage']);
255
+
256
+ let doCommand = function (p) {
257
+ let filename = path.resolve(self.packageDir + '/' + self.packageName() +
258
+ _compressOpts[p].ext);
259
+ if (process.platform == 'win32') {
260
+ // Windows full path may have drive letter, which is going to cause
261
+ // namespace problems, so strip it.
262
+ if (filename.length > 2 && filename[1] == ':') {
263
+ filename = filename.substr(2);
264
+ }
265
+ }
266
+ compressTaskArr.push(filename);
267
+
268
+ file(filename, [packageDirPath], function () {
269
+ let cmd;
270
+ let opts = _compressOpts[p];
271
+ // Directory to move to when doing the compression-task
272
+ // Changes in the case of zip for emulating -C option
273
+ let chdir = self.packageDir;
274
+ // Save the current dir so it's possible to pop back up
275
+ // after compressing
276
+ let currDir = process.cwd();
277
+ let archiveChangeDir;
278
+ let archiveContentDir;
279
+
280
+ if (self.archiveNoBaseDir) {
281
+ archiveChangeDir = self.packageName();
282
+ archiveContentDir = '.';
283
+ }
284
+ else {
285
+ archiveChangeDir = self.archiveChangeDir;
286
+ archiveContentDir = self.archiveContentDir;
287
+ }
288
+
289
+ cmd = self[opts.cmd + 'Command'];
290
+ cmd += ' -' + opts.flags;
291
+ if (opts.cmd == 'jar' && self.manifestFile) {
292
+ cmd += 'm';
293
+ }
294
+
295
+ // The name of the archive to create -- use full path
296
+ // so compression can be performed from a different dir
297
+ // if needed
298
+ cmd += ' ' + filename;
299
+
300
+ if (opts.cmd == 'jar' && self.manifestFile) {
301
+ cmd += ' ' + self.manifestFile;
302
+ }
303
+
304
+ // Where to perform the compression -- -C option isn't
305
+ // supported in zip, so actually do process.chdir for this
306
+ if (archiveChangeDir) {
307
+ if (opts.cmd == 'zip') {
308
+ chdir = path.join(chdir, archiveChangeDir);
309
+ }
310
+ else {
311
+ cmd += ' -C ' + archiveChangeDir;
312
+ }
313
+ }
314
+
315
+ // Where to get the archive content
316
+ if (archiveContentDir) {
317
+ cmd += ' ' + archiveContentDir;
318
+ }
319
+ else {
320
+ cmd += ' ' + self.packageName();
321
+ }
322
+
323
+ // Move into the desired dir (usually packageDir) to compress
324
+ // Return back up to the current dir after the exec
325
+ process.chdir(chdir);
326
+
327
+ exec(cmd, function (err, stdout, stderr) {
328
+ if (err) { throw err; }
329
+
330
+ // Return back up to the starting directory (see above,
331
+ // before exec)
332
+ process.chdir(currDir);
333
+
334
+ complete();
335
+ });
336
+ }, {async: true});
337
+ };
338
+
339
+ for (let p in _compressOpts) {
340
+ if (this['need' + p]) {
341
+ doCommand(p);
342
+ }
343
+ }
344
+
345
+ task('buildPackage', compressTaskArr, function () {});
346
+
347
+ directory(this.packageDir);
348
+
349
+ file(packageDirPath, this.packageFiles, function () {
350
+ jake.mkdirP(packageDirPath);
351
+ let fileList = [];
352
+ self.packageFiles.forEach(function (name) {
353
+ let f = path.join(self.packageDirPath(), name);
354
+ let fDir = path.dirname(f);
355
+ jake.mkdirP(fDir, {silent: true});
356
+
357
+ // Add both files and directories
358
+ fileList.push({
359
+ from: name,
360
+ to: f
361
+ });
362
+ });
363
+ let _copyFile = function () {
364
+ let file = fileList.pop();
365
+ let stat;
366
+ if (file) {
367
+ stat = fs.statSync(file.from);
368
+ // Target is a directory, just create it
369
+ if (stat.isDirectory()) {
370
+ jake.mkdirP(file.to, {silent: true});
371
+ _copyFile();
372
+ }
373
+ // Otherwise copy the file
374
+ else {
375
+ jake.cpR(file.from, file.to, {silent: true});
376
+ _copyFile();
377
+ }
378
+ }
379
+ else {
380
+ complete();
381
+ }
382
+ };
383
+ _copyFile();
384
+ }, {async: true});
385
+
386
+
387
+ };
388
+
389
+ this.packageName = function () {
390
+ if (this.version) {
391
+ return this.name + '-' + this.version;
392
+ }
393
+ else {
394
+ return this.name;
395
+ }
396
+ };
397
+
398
+ this.packageDirPath = function () {
399
+ return this.packageDir + '/' + this.packageName();
400
+ };
401
+
402
+ })();
403
+
404
+ jake.PackageTask = PackageTask;
405
+ exports.PackageTask = PackageTask;
406
+
node_modules/jake/lib/parseargs.js ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Jake JavaScript build tool
3
+ * Copyright 2112 Matthew Eernisse (mde@fleegix.org)
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ *
17
+ */
18
+
19
+ let parseargs = {};
20
+ let isOpt = function (arg) { return arg.indexOf('-') === 0; };
21
+ let removeOptPrefix = function (opt) { return opt.replace(/^--/, '').replace(/^-/, ''); };
22
+
23
+ /**
24
+ * @constructor
25
+ * Parses a list of command-line args into a key/value object of
26
+ * options and an array of positional commands.
27
+ * @ param {Array} opts A list of options in the following format:
28
+ * [{full: 'foo', abbr: 'f'}, {full: 'bar', abbr: 'b'}]]
29
+ */
30
+ parseargs.Parser = function (opts) {
31
+ // A key/value object of matching options parsed out of the args
32
+ this.opts = {};
33
+ this.taskNames = null;
34
+ this.envVars = null;
35
+
36
+ // Data structures used for parsing
37
+ this.reg = opts;
38
+ this.shortOpts = {};
39
+ this.longOpts = {};
40
+
41
+ let self = this;
42
+ [].forEach.call(opts, function (item) {
43
+ self.shortOpts[item.abbr] = item;
44
+ self.longOpts[item.full] = item;
45
+ });
46
+ };
47
+
48
+ parseargs.Parser.prototype = new function () {
49
+
50
+ let _trueOrNextVal = function (argParts, args) {
51
+ if (argParts[1]) {
52
+ return argParts[1];
53
+ }
54
+ else {
55
+ return (!args[0] || isOpt(args[0])) ?
56
+ true : args.shift();
57
+ }
58
+ };
59
+
60
+ /**
61
+ * Parses an array of arguments into options and positional commands
62
+ * @param {Array} args The command-line args to parse
63
+ */
64
+ this.parse = function (args) {
65
+ let cmds = [];
66
+ let cmd;
67
+ let envVars = {};
68
+ let opts = {};
69
+ let arg;
70
+ let argItem;
71
+ let argParts;
72
+ let cmdItems;
73
+ let taskNames = [];
74
+ let preempt;
75
+
76
+ while (args.length) {
77
+ arg = args.shift();
78
+
79
+ if (isOpt(arg)) {
80
+ arg = removeOptPrefix(arg);
81
+ argParts = arg.split('=');
82
+ argItem = this.longOpts[argParts[0]] || this.shortOpts[argParts[0]];
83
+ if (argItem) {
84
+ // First-encountered preemptive opt takes precedence -- no further opts
85
+ // or possibility of ambiguity, so just look for a value, or set to
86
+ // true and then bail
87
+ if (argItem.preempts) {
88
+ opts[argItem.full] = _trueOrNextVal(argParts, args);
89
+ preempt = true;
90
+ break;
91
+ }
92
+ // If the opt requires a value, see if we can get a value from the
93
+ // next arg, or infer true from no-arg -- if it's followed by another
94
+ // opt, throw an error
95
+ if (argItem.expectValue || argItem.allowValue) {
96
+ opts[argItem.full] = _trueOrNextVal(argParts, args);
97
+ if (argItem.expectValue && !opts[argItem.full]) {
98
+ throw new Error(argItem.full + ' option expects a value.');
99
+ }
100
+ }
101
+ else {
102
+ opts[argItem.full] = true;
103
+ }
104
+ }
105
+ }
106
+ else {
107
+ cmds.unshift(arg);
108
+ }
109
+ }
110
+
111
+ if (!preempt) {
112
+ // Parse out any env-vars and task-name
113
+ while ((cmd = cmds.pop())) {
114
+ cmdItems = cmd.split('=');
115
+ if (cmdItems.length > 1) {
116
+ envVars[cmdItems[0]] = cmdItems[1];
117
+ }
118
+ else {
119
+ taskNames.push(cmd);
120
+ }
121
+ }
122
+
123
+ }
124
+
125
+ return {
126
+ opts: opts,
127
+ envVars: envVars,
128
+ taskNames: taskNames
129
+ };
130
+ };
131
+
132
+ };
133
+
134
+ module.exports = parseargs;
node_modules/jake/lib/program.js ADDED
@@ -0,0 +1,282 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Jake JavaScript build tool
3
+ * Copyright 2112 Matthew Eernisse (mde@fleegix.org)
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ *
17
+ */
18
+
19
+ let fs = require('fs');
20
+ let parseargs = require('./parseargs');
21
+ let utils = require('./utils');
22
+ let Program;
23
+ let usage = require('fs').readFileSync(`${__dirname}/../usage.txt`).toString();
24
+ let { Task } = require('./task/task');
25
+
26
+ function die(msg) {
27
+ console.log(msg);
28
+ process.stdout.write('', function () {
29
+ process.stderr.write('', function () {
30
+ process.exit();
31
+ });
32
+ });
33
+ }
34
+
35
+ let preempts = {
36
+ version: function () {
37
+ die(jake.version);
38
+ },
39
+ help: function () {
40
+ die(usage);
41
+ }
42
+ };
43
+
44
+ let AVAILABLE_OPTS = [
45
+ { full: 'jakefile',
46
+ abbr: 'f',
47
+ expectValue: true
48
+ },
49
+ { full: 'quiet',
50
+ abbr: 'q',
51
+ expectValue: false
52
+ },
53
+ { full: 'directory',
54
+ abbr: 'C',
55
+ expectValue: true
56
+ },
57
+ { full: 'always-make',
58
+ abbr: 'B',
59
+ expectValue: false
60
+ },
61
+ { full: 'tasks',
62
+ abbr: 'T',
63
+ expectValue: false,
64
+ allowValue: true
65
+ },
66
+ // Alias t
67
+ { full: 'tasks',
68
+ abbr: 't',
69
+ expectValue: false,
70
+ allowValue: true
71
+ },
72
+ // Alias ls
73
+ { full: 'tasks',
74
+ abbr: 'ls',
75
+ expectValue: false,
76
+ allowValue: true
77
+ },
78
+ { full: 'help',
79
+ abbr: 'h',
80
+ },
81
+ { full: 'version',
82
+ abbr: 'V',
83
+ },
84
+ // Alias lowercase v
85
+ { full: 'version',
86
+ abbr: 'v',
87
+ },
88
+ { full: 'jakelibdir',
89
+ abbr: 'J',
90
+ expectValue: true
91
+ },
92
+ { full: 'allow-rejection',
93
+ abbr: 'ar',
94
+ expectValue: false
95
+ }
96
+ ];
97
+
98
+ Program = function () {
99
+ this.availableOpts = AVAILABLE_OPTS;
100
+ this.opts = {};
101
+ this.taskNames = null;
102
+ this.taskArgs = null;
103
+ this.envVars = null;
104
+ this.die = die;
105
+ };
106
+
107
+ Program.prototype = new (function () {
108
+
109
+ this.handleErr = function (err) {
110
+ if (jake.listeners('error').length !== 0) {
111
+ jake.emit('error', err);
112
+ return;
113
+ }
114
+
115
+ if (jake.listeners('error').length) {
116
+ jake.emit('error', err);
117
+ return;
118
+ }
119
+
120
+ utils.logger.error('jake aborted.');
121
+ if (err.stack) {
122
+ utils.logger.error(err.stack);
123
+ }
124
+ else {
125
+ utils.logger.error(err.message);
126
+ }
127
+
128
+ process.stdout.write('', function () {
129
+ process.stderr.write('', function () {
130
+ jake.errorCode = jake.errorCode || 1;
131
+ process.exit(jake.errorCode);
132
+ });
133
+ });
134
+ };
135
+
136
+ this.parseArgs = function (args) {
137
+ let result = (new parseargs.Parser(this.availableOpts)).parse(args);
138
+ this.setOpts(result.opts);
139
+ this.setTaskNames(result.taskNames);
140
+ this.setEnvVars(result.envVars);
141
+ };
142
+
143
+ this.setOpts = function (options) {
144
+ let opts = options || {};
145
+ Object.assign(this.opts, opts);
146
+ };
147
+
148
+ this.internalOpts = function (options) {
149
+ this.availableOpts = this.availableOpts.concat(options);
150
+ };
151
+
152
+ this.autocompletions = function (cur) {
153
+ let p; let i; let task;
154
+ let commonPrefix = '';
155
+ let matches = [];
156
+
157
+ for (p in jake.Task) {
158
+ task = jake.Task[p];
159
+ if (
160
+ 'fullName' in task
161
+ && (
162
+ // if empty string, program converts to true
163
+ cur === true ||
164
+ task.fullName.indexOf(cur) === 0
165
+ )
166
+ ) {
167
+ if (matches.length === 0) {
168
+ commonPrefix = task.fullName;
169
+ }
170
+ else {
171
+ for (i = commonPrefix.length; i > -1; --i) {
172
+ commonPrefix = commonPrefix.substr(0, i);
173
+ if (task.fullName.indexOf(commonPrefix) === 0) {
174
+ break;
175
+ }
176
+ }
177
+ }
178
+ matches.push(task.fullName);
179
+ }
180
+ }
181
+
182
+ if (matches.length > 1 && commonPrefix === cur) {
183
+ matches.unshift('yes-space');
184
+ }
185
+ else {
186
+ matches.unshift('no-space');
187
+ }
188
+
189
+ process.stdout.write(matches.join(' '));
190
+ };
191
+
192
+ this.setTaskNames = function (names) {
193
+ if (names && !Array.isArray(names)) {
194
+ throw new Error('Task names must be an array');
195
+ }
196
+ this.taskNames = (names && names.length) ? names : ['default'];
197
+ };
198
+
199
+ this.setEnvVars = function (vars) {
200
+ this.envVars = vars || null;
201
+ };
202
+
203
+ this.firstPreemptiveOption = function () {
204
+ let opts = this.opts;
205
+ for (let p in opts) {
206
+ if (preempts[p]) {
207
+ return preempts[p];
208
+ }
209
+ }
210
+ return false;
211
+ };
212
+
213
+ this.init = function (configuration) {
214
+ let self = this;
215
+ let config = configuration || {};
216
+ if (config.options) {
217
+ this.setOpts(config.options);
218
+ }
219
+ if (config.taskNames) {
220
+ this.setTaskNames(config.taskNames);
221
+ }
222
+ if (config.envVars) {
223
+ this.setEnvVars(config.envVars);
224
+ }
225
+ process.addListener('uncaughtException', function (err) {
226
+ self.handleErr(err);
227
+ });
228
+ if (!this.opts['allow-rejection']) {
229
+ process.addListener('unhandledRejection', (reason, promise) => {
230
+ utils.logger.error('Unhandled rejection at:', promise, 'reason:', reason);
231
+ self.handleErr(reason);
232
+ });
233
+ }
234
+ if (this.envVars) {
235
+ Object.assign(process.env, this.envVars);
236
+ }
237
+ };
238
+
239
+ this.run = function () {
240
+ let rootTask;
241
+ let taskNames;
242
+ let dirname;
243
+ let opts = this.opts;
244
+
245
+ if (opts.autocomplete) {
246
+ return this.autocompletions(opts['autocomplete-cur'], opts['autocomplete-prev']);
247
+ }
248
+ // Run with `jake -T`, just show descriptions
249
+ if (opts.tasks) {
250
+ return jake.showAllTaskDescriptions(opts.tasks);
251
+ }
252
+
253
+ taskNames = this.taskNames;
254
+ if (!(Array.isArray(taskNames) && taskNames.length)) {
255
+ throw new Error('Please pass jake.runTasks an array of task-names');
256
+ }
257
+
258
+ // Set working dir
259
+ dirname = opts.directory;
260
+ if (dirname) {
261
+ if (fs.existsSync(dirname) &&
262
+ fs.statSync(dirname).isDirectory()) {
263
+ process.chdir(dirname);
264
+ }
265
+ else {
266
+ throw new Error(dirname + ' is not a valid directory path');
267
+ }
268
+ }
269
+
270
+ rootTask = task(Task.ROOT_TASK_NAME, taskNames, function () {});
271
+ rootTask._internal = true;
272
+
273
+ rootTask.once('complete', function () {
274
+ jake.emit('complete');
275
+ });
276
+ jake.emit('start');
277
+ rootTask.invoke();
278
+ };
279
+
280
+ })();
281
+
282
+ module.exports.Program = Program;
node_modules/jake/lib/publish_task.js ADDED
@@ -0,0 +1,290 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Jake JavaScript build tool
3
+ * Copyright 2112 Matthew Eernisse (mde@fleegix.org)
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ *
17
+ */
18
+
19
+ let fs = require('fs');
20
+ let path = require('path');
21
+ let exec = require('child_process').execSync;
22
+ let FileList = require('filelist').FileList;
23
+
24
+ let PublishTask = function () {
25
+ let args = Array.prototype.slice.call(arguments).filter(function (item) {
26
+ return typeof item != 'undefined';
27
+ });
28
+ let arg;
29
+ let opts = {};
30
+ let definition;
31
+ let prereqs = [];
32
+ let createDef = function (arg) {
33
+ return function () {
34
+ this.packageFiles.include(arg);
35
+ };
36
+ };
37
+
38
+ this.name = args.shift();
39
+
40
+ // Old API, just name + list of files
41
+ if (args.length == 1 && (Array.isArray(args[0]) || typeof args[0] == 'string')) {
42
+ definition = createDef(args.pop());
43
+ }
44
+ // Current API, name + [prereqs] + [opts] + definition
45
+ else {
46
+ while ((arg = args.pop())) {
47
+ // Definition func
48
+ if (typeof arg == 'function') {
49
+ definition = arg;
50
+ }
51
+ // Prereqs
52
+ else if (Array.isArray(arg) || typeof arg == 'string') {
53
+ prereqs = arg;
54
+ }
55
+ // Opts
56
+ else {
57
+ opts = arg;
58
+ }
59
+ }
60
+ }
61
+
62
+ this.prereqs = prereqs;
63
+ this.packageFiles = new FileList();
64
+ this.publishCmd = opts.publishCmd || 'npm publish %filename';
65
+ this.publishMessage = opts.publishMessage || 'BOOM! Published.';
66
+ this.gitCmd = opts.gitCmd || 'git';
67
+ this.versionFiles = opts.versionFiles || ['package.json'];
68
+ this.scheduleDelay = 5000;
69
+
70
+ // Override utility funcs for testing
71
+ this._ensureRepoClean = function (stdout) {
72
+ if (stdout.length) {
73
+ fail(new Error('Git repository is not clean.'));
74
+ }
75
+ };
76
+ this._getCurrentBranch = function (stdout) {
77
+ return String(stdout).trim();
78
+ };
79
+
80
+ if (typeof definition == 'function') {
81
+ definition.call(this);
82
+ }
83
+ this.define();
84
+ };
85
+
86
+
87
+ PublishTask.prototype = new (function () {
88
+
89
+ let _currentBranch = null;
90
+
91
+ let getPackage = function () {
92
+ let pkg = JSON.parse(fs.readFileSync(path.join(process.cwd(),
93
+ '/package.json')).toString());
94
+ return pkg;
95
+ };
96
+ let getPackageVersionNumber = function () {
97
+ return getPackage().version;
98
+ };
99
+
100
+ this.define = function () {
101
+ let self = this;
102
+
103
+ namespace('publish', function () {
104
+ task('fetchTags', function () {
105
+ // Make sure local tags are up to date
106
+ exec(self.gitCmd + ' fetch --tags');
107
+ console.log('Fetched remote tags.');
108
+ });
109
+
110
+ task('getCurrentBranch', function () {
111
+ // Figure out what branch to push to
112
+ let stdout = exec(self.gitCmd + ' symbolic-ref --short HEAD').toString();
113
+ if (!stdout) {
114
+ throw new Error('No current Git branch found');
115
+ }
116
+ _currentBranch = self._getCurrentBranch(stdout);
117
+ console.log('On branch ' + _currentBranch);
118
+ });
119
+
120
+ task('ensureClean', function () {
121
+ // Only bump, push, and tag if the Git repo is clean
122
+ let stdout = exec(self.gitCmd + ' status --porcelain --untracked-files=no').toString();
123
+ // Throw if there's output
124
+ self._ensureRepoClean(stdout);
125
+ });
126
+
127
+ task('updateVersionFiles', function () {
128
+ let pkg;
129
+ let version;
130
+ let arr;
131
+ let patch;
132
+
133
+ // Grab the current version-string
134
+ pkg = getPackage();
135
+ version = pkg.version;
136
+ // Increment the patch-number for the version
137
+ arr = version.split('.');
138
+ patch = parseInt(arr.pop(), 10) + 1;
139
+ arr.push(patch);
140
+ version = arr.join('.');
141
+
142
+ // Update package.json or other files with the new version-info
143
+ self.versionFiles.forEach(function (file) {
144
+ let p = path.join(process.cwd(), file);
145
+ let data = JSON.parse(fs.readFileSync(p).toString());
146
+ data.version = version;
147
+ fs.writeFileSync(p, JSON.stringify(data, true, 2) + '\n');
148
+ });
149
+ // Return the version string so that listeners for the 'complete' event
150
+ // for this task can use it (e.g., to update other files before pushing
151
+ // to Git)
152
+ return version;
153
+ });
154
+
155
+ task('pushVersion', ['ensureClean', 'updateVersionFiles'], function () {
156
+ let version = getPackageVersionNumber();
157
+ let message = 'Version ' + version;
158
+ let cmds = [
159
+ self.gitCmd + ' commit -a -m "' + message + '"',
160
+ self.gitCmd + ' push origin ' + _currentBranch,
161
+ self.gitCmd + ' tag -a v' + version + ' -m "' + message + '"',
162
+ self.gitCmd + ' push --tags'
163
+ ];
164
+ cmds.forEach((cmd) => {
165
+ exec(cmd);
166
+ });
167
+ version = getPackageVersionNumber();
168
+ console.log('Bumped version number to v' + version + '.');
169
+ });
170
+
171
+ let defineTask = task('definePackage', function () {
172
+ let version = getPackageVersionNumber();
173
+ new jake.PackageTask(self.name, 'v' + version, self.prereqs, function () {
174
+ // Replace the PackageTask's FileList with the PublishTask's FileList
175
+ this.packageFiles = self.packageFiles;
176
+ this.needTarGz = true; // Default to tar.gz
177
+ // If any of the need<CompressionFormat> or archive opts are set
178
+ // proxy them to the PackageTask
179
+ for (let p in this) {
180
+ if (p.indexOf('need') === 0 || p.indexOf('archive') === 0) {
181
+ if (typeof self[p] != 'undefined') {
182
+ this[p] = self[p];
183
+ }
184
+ }
185
+ }
186
+ });
187
+ });
188
+ defineTask._internal = true;
189
+
190
+ task('package', function () {
191
+ let definePack = jake.Task['publish:definePackage'];
192
+ let pack = jake.Task['package'];
193
+ let version = getPackageVersionNumber();
194
+
195
+ // May have already been run
196
+ if (definePack.taskStatus == jake.Task.runStatuses.DONE) {
197
+ definePack.reenable(true);
198
+ }
199
+ definePack.execute();
200
+ definePack.on('complete', function () {
201
+ pack.invoke();
202
+ console.log('Created package for ' + self.name + ' v' + version);
203
+ });
204
+ });
205
+
206
+ task('publish', function () {
207
+ return new Promise((resolve) => {
208
+ let version = getPackageVersionNumber();
209
+ let filename;
210
+ let cmd;
211
+
212
+ console.log('Publishing ' + self.name + ' v' + version);
213
+
214
+ if (typeof self.createPublishCommand == 'function') {
215
+ cmd = self.createPublishCommand(version);
216
+ }
217
+ else {
218
+ filename = './pkg/' + self.name + '-v' + version + '.tar.gz';
219
+ cmd = self.publishCmd.replace(/%filename/gi, filename);
220
+ }
221
+
222
+ if (typeof cmd == 'function') {
223
+ cmd(function (err) {
224
+ if (err) {
225
+ throw err;
226
+ }
227
+ console.log(self.publishMessage);
228
+ resolve();
229
+ });
230
+ }
231
+ else {
232
+ // Hackity hack -- NPM publish sometimes returns errror like:
233
+ // Error sending version data\nnpm ERR!
234
+ // Error: forbidden 0.2.4 is modified, should match modified time
235
+ setTimeout(function () {
236
+ let stdout = exec(cmd).toString() || '';
237
+ stdout = stdout.trim();
238
+ if (stdout) {
239
+ console.log(stdout);
240
+ }
241
+ console.log(self.publishMessage);
242
+ resolve();
243
+ }, self.scheduleDelay);
244
+ }
245
+ });
246
+ });
247
+
248
+ task('cleanup', function () {
249
+ return new Promise((resolve) => {
250
+ let clobber = jake.Task.clobber;
251
+ clobber.reenable(true);
252
+ clobber.on('complete', function () {
253
+ console.log('Cleaned up package');
254
+ resolve();
255
+ });
256
+ clobber.invoke();
257
+ });
258
+ });
259
+
260
+ });
261
+
262
+ let prefixNs = function (item) {
263
+ return 'publish:' + item;
264
+ };
265
+
266
+ // Create aliases in the default namespace
267
+ desc('Create a new version and release.');
268
+ task('publish', self.prereqs.concat(['version', 'release']
269
+ .map(prefixNs)));
270
+
271
+ desc('Release the existing version.');
272
+ task('publishExisting', self.prereqs.concat(['release']
273
+ .map(prefixNs)));
274
+
275
+ task('version', ['fetchTags', 'getCurrentBranch', 'pushVersion']
276
+ .map(prefixNs));
277
+
278
+ task('release', ['package', 'publish', 'cleanup']
279
+ .map(prefixNs));
280
+
281
+ // Invoke proactively so there will be a callable 'package' task
282
+ // which can be used apart from 'publish'
283
+ jake.Task['publish:definePackage'].invoke();
284
+ };
285
+
286
+ })();
287
+
288
+ jake.PublishTask = PublishTask;
289
+ exports.PublishTask = PublishTask;
290
+
node_modules/jake/lib/rule.js ADDED
@@ -0,0 +1,311 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ let path = require('path');
2
+ let fs = require('fs');
3
+ let Task = require('./task/task').Task;
4
+
5
+ // Split a task to two parts, name space and task name.
6
+ // For example, given 'foo:bin/a%.c', return an object with
7
+ // - 'ns' : foo
8
+ // - 'name' : bin/a%.c
9
+ function splitNs(task) {
10
+ let parts = task.split(':');
11
+ let name = parts.pop();
12
+ let ns = resolveNs(parts);
13
+ return {
14
+ 'name' : name,
15
+ 'ns' : ns
16
+ };
17
+ }
18
+
19
+ // Return the namespace based on an array of names.
20
+ // For example, given ['foo', 'baz' ], return the namespace
21
+ //
22
+ // default -> foo -> baz
23
+ //
24
+ // where default is the global root namespace
25
+ // and -> means child namespace.
26
+ function resolveNs(parts) {
27
+ let ns = jake.defaultNamespace;
28
+ for(let i = 0, l = parts.length; ns && i < l; i++) {
29
+ ns = ns.childNamespaces[parts[i]];
30
+ }
31
+ return ns;
32
+ }
33
+
34
+ // Given a pattern p, say 'foo:bin/a%.c'
35
+ // Return an object with
36
+ // - 'ns' : foo
37
+ // - 'dir' : bin
38
+ // - 'prefix' : a
39
+ // - 'suffix' : .c
40
+ function resolve(p) {
41
+ let task = splitNs(p);
42
+ let name = task.name;
43
+ let ns = task.ns;
44
+ let split = path.basename(name).split('%');
45
+ return {
46
+ ns: ns,
47
+ dir: path.dirname(name),
48
+ prefix: split[0],
49
+ suffix: split[1]
50
+ };
51
+ }
52
+
53
+ // Test whether string a is a suffix of string b
54
+ function stringEndWith(a, b) {
55
+ let l;
56
+ return (l = b.lastIndexOf(a)) == -1 ? false : l + a.length == b.length;
57
+ }
58
+
59
+ // Replace the suffix a of the string s with b.
60
+ // Note that, it is assumed a is a suffix of s.
61
+ function stringReplaceSuffix(s, a, b) {
62
+ return s.slice(0, s.lastIndexOf(a)) + b;
63
+ }
64
+
65
+ class Rule {
66
+ constructor(opts) {
67
+ this.pattern = opts.pattern;
68
+ this.source = opts.source;
69
+ this.prereqs = opts.prereqs;
70
+ this.action = opts.action;
71
+ this.opts = opts.opts;
72
+ this.desc = opts.desc;
73
+ this.ns = opts.ns;
74
+ }
75
+
76
+ // Create a file task based on this rule for the specified
77
+ // task-name
78
+ // ======
79
+ // FIXME: Right now this just throws away any passed-in args
80
+ // for the synthsized task (taskArgs param)
81
+ // ======
82
+ createTask(fullName, level) {
83
+ let self = this;
84
+ let pattern;
85
+ let source;
86
+ let action;
87
+ let opts;
88
+ let prereqs;
89
+ let valid;
90
+ let src;
91
+ let tNs;
92
+ let createdTask;
93
+ let name = Task.getBaseTaskName(fullName);
94
+ let nsPath = Task.getBaseNamespacePath(fullName);
95
+ let ns = this.ns.resolveNamespace(nsPath);
96
+
97
+ pattern = this.pattern;
98
+ source = this.source;
99
+
100
+ if (typeof source == 'string') {
101
+ src = Rule.getSource(name, pattern, source);
102
+ }
103
+ else {
104
+ src = source(name);
105
+ }
106
+
107
+ // TODO: Write a utility function that appends a
108
+ // taskname to a namespace path
109
+ src = nsPath.split(':').filter(function (item) {
110
+ return !!item;
111
+ }).concat(src).join(':');
112
+
113
+ // Generate the prerequisite for the matching task.
114
+ // It is the original prerequisites plus the prerequisite
115
+ // representing source file, i.e.,
116
+ //
117
+ // rule( '%.o', '%.c', ['some.h'] ...
118
+ //
119
+ // If the objective is main.o, then new task should be
120
+ //
121
+ // file( 'main.o', ['main.c', 'some.h' ] ...
122
+ prereqs = this.prereqs.slice(); // Get a copy to work with
123
+ prereqs.unshift(src);
124
+
125
+ // Prereq should be:
126
+ // 1. an existing task
127
+ // 2. an existing file on disk
128
+ // 3. a valid rule (i.e., not at too deep a level)
129
+ valid = prereqs.some(function (p) {
130
+ let ns = self.ns;
131
+ return ns.resolveTask(p) ||
132
+ fs.existsSync(Task.getBaseTaskName(p)) ||
133
+ jake.attemptRule(p, ns, level + 1);
134
+ });
135
+
136
+ // If any of the prereqs aren't valid, the rule isn't valid
137
+ if (!valid) {
138
+ return null;
139
+ }
140
+ // Otherwise, hunky-dory, finish creating the task for the rule
141
+ else {
142
+ // Create the action for the task
143
+ action = function () {
144
+ let task = this;
145
+ self.action.apply(task);
146
+ };
147
+
148
+ opts = this.opts;
149
+
150
+ // Insert the file task into Jake
151
+ //
152
+ // Since createTask function stores the task as a child task
153
+ // of currentNamespace. Here we temporariliy switch the namespace.
154
+ // FIXME: Should allow optional ns passed in instead of this hack
155
+ tNs = jake.currentNamespace;
156
+ jake.currentNamespace = ns;
157
+ createdTask = jake.createTask('file', name, prereqs, action, opts);
158
+ createdTask.source = src.split(':').pop();
159
+ jake.currentNamespace = tNs;
160
+
161
+ return createdTask;
162
+ }
163
+ }
164
+
165
+ match(name) {
166
+ return Rule.match(this.pattern, name);
167
+ }
168
+
169
+ // Test wether the a prerequisite matchs the pattern.
170
+ // The arg 'pattern' does not have namespace as prefix.
171
+ // For example, the following tests are true
172
+ //
173
+ // pattern | name
174
+ // bin/%.o | bin/main.o
175
+ // bin/%.o | foo:bin/main.o
176
+ //
177
+ // The following tests are false (trivally)
178
+ //
179
+ // pattern | name
180
+ // bin/%.o | foobin/main.o
181
+ // bin/%.o | bin/main.oo
182
+ static match(pattern, name) {
183
+ let p;
184
+ let task;
185
+ let obj;
186
+ let filename;
187
+
188
+ if (pattern instanceof RegExp) {
189
+ return pattern.test(name);
190
+ }
191
+ else if (pattern.indexOf('%') == -1) {
192
+ // No Pattern. No Folder. No Namespace.
193
+ // A Simple Suffix Rule. Just test suffix
194
+ return stringEndWith(pattern, name);
195
+ }
196
+ else {
197
+ // Resolve the dir, prefix and suffix of pattern
198
+ p = resolve(pattern);
199
+
200
+ // Resolve the namespace and task-name
201
+ task = splitNs(name);
202
+ name = task.name;
203
+
204
+ // Set the objective as the task-name
205
+ obj = name;
206
+
207
+ // Namespace is already matched.
208
+
209
+ // Check dir
210
+ if (path.dirname(obj) != p.dir) {
211
+ return false;
212
+ }
213
+
214
+ filename = path.basename(obj);
215
+
216
+ // Check file name length
217
+ if ((p.prefix.length + p.suffix.length + 1) > filename.length) {
218
+ // Length does not match.
219
+ return false;
220
+ }
221
+
222
+ // Check prefix
223
+ if (filename.indexOf(p.prefix) !== 0) {
224
+ return false;
225
+ }
226
+
227
+ // Check suffix
228
+ if (!stringEndWith(p.suffix, filename)) {
229
+ return false;
230
+ }
231
+
232
+ // OK. Find a match.
233
+ return true;
234
+ }
235
+ }
236
+
237
+ // Generate the source based on
238
+ // - name name for the synthesized task
239
+ // - pattern pattern for the objective
240
+ // - source pattern for the source
241
+ //
242
+ // Return the source with properties
243
+ // - dep the prerequisite of source
244
+ // (with the namespace)
245
+ //
246
+ // - file the file name of source
247
+ // (without the namespace)
248
+ //
249
+ // For example, given
250
+ //
251
+ // - name foo:bin/main.o
252
+ // - pattern bin/%.o
253
+ // - source src/%.c
254
+ //
255
+ // return 'foo:src/main.c',
256
+ //
257
+ static getSource(name, pattern, source) {
258
+ let dep;
259
+ let pat;
260
+ let match;
261
+ let file;
262
+ let src;
263
+
264
+ // Regex pattern -- use to look up the extension
265
+ if (pattern instanceof RegExp) {
266
+ match = pattern.exec(name);
267
+ if (match) {
268
+ if (typeof source == 'function') {
269
+ src = source(name);
270
+ }
271
+ else {
272
+ src = stringReplaceSuffix(name, match[0], source);
273
+ }
274
+ }
275
+ }
276
+ // Assume string
277
+ else {
278
+ // Simple string suffix replacement
279
+ if (pattern.indexOf('%') == -1) {
280
+ if (typeof source == 'function') {
281
+ src = source(name);
282
+ }
283
+ else {
284
+ src = stringReplaceSuffix(name, pattern, source);
285
+ }
286
+ }
287
+ // Percent-based substitution
288
+ else {
289
+ pat = pattern.replace('%', '(.*?)');
290
+ pat = new RegExp(pat);
291
+ match = pat.exec(name);
292
+ if (match) {
293
+ if (typeof source == 'function') {
294
+ src = source(name);
295
+ }
296
+ else {
297
+ file = match[1];
298
+ file = source.replace('%', file);
299
+ dep = match[0];
300
+ src = name.replace(dep, file);
301
+ }
302
+ }
303
+ }
304
+ }
305
+
306
+ return src;
307
+ }
308
+ }
309
+
310
+
311
+ exports.Rule = Rule;
node_modules/jake/lib/task/directory_task.js ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ let fs = require('fs');
2
+ let FileTask = require('./file_task').FileTask;
3
+
4
+ /**
5
+ @name jake
6
+ @namespace jake
7
+ */
8
+ /**
9
+ @name jake.DirectoryTask
10
+ @constructor
11
+ @augments EventEmitter
12
+ @augments jake.Task
13
+ @augments jake.FileTask
14
+ @description A Jake DirectoryTask
15
+
16
+ @param {String} name The name of the directory to create.
17
+ */
18
+ class DirectoryTask extends FileTask {
19
+ constructor(...args) {
20
+ super(...args);
21
+ if (fs.existsSync(this.name)) {
22
+ this.updateModTime();
23
+ }
24
+ else {
25
+ this.modTime = null;
26
+ }
27
+ }
28
+ }
29
+
30
+ exports.DirectoryTask = DirectoryTask;
node_modules/jake/lib/task/file_task.js ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ let fs = require('fs');
2
+ let Task = require('./task').Task;
3
+
4
+ function isFileOrDirectory(t) {
5
+ return (t instanceof FileTask ||
6
+ t instanceof DirectoryTask);
7
+ }
8
+
9
+ function isFile(t) {
10
+ return (t instanceof FileTask && !(t instanceof DirectoryTask));
11
+ }
12
+
13
+ /**
14
+ @name jake
15
+ @namespace jake
16
+ */
17
+ /**
18
+ @name jake.FileTask
19
+ @class`
20
+ @extentds Task
21
+ @description A Jake FileTask
22
+
23
+ @param {String} name The name of the Task
24
+ @param {Array} [prereqs] Prerequisites to be run before this task
25
+ @param {Function} [action] The action to perform to create this file
26
+ @param {Object} [opts]
27
+ @param {Array} [opts.asyc=false] Perform this task asynchronously.
28
+ If you flag a task with this option, you must call the global
29
+ `complete` method inside the task's action, for execution to proceed
30
+ to the next task.
31
+ */
32
+ class FileTask extends Task {
33
+ constructor(...args) {
34
+ super(...args);
35
+ this.dummy = false;
36
+ if (fs.existsSync(this.name)) {
37
+ this.updateModTime();
38
+ }
39
+ else {
40
+ this.modTime = null;
41
+ }
42
+ }
43
+
44
+ isNeeded() {
45
+ let prereqs = this.prereqs;
46
+ let prereqName;
47
+ let prereqTask;
48
+
49
+ // No repeatsies
50
+ if (this.taskStatus == Task.runStatuses.DONE) {
51
+ return false;
52
+ }
53
+ // The always-make override
54
+ else if (jake.program.opts['always-make']) {
55
+ return true;
56
+ }
57
+ // Default case
58
+ else {
59
+
60
+ // We need either an existing file, or an action to create one.
61
+ // First try grabbing the actual mod-time of the file
62
+ try {
63
+ this.updateModTime();
64
+ }
65
+ // Then fall back to looking for an action
66
+ catch(e) {
67
+ if (typeof this.action == 'function') {
68
+ return true;
69
+ }
70
+ else {
71
+ throw new Error('File-task ' + this.fullName + ' has no ' +
72
+ 'existing file, and no action to create one.');
73
+ }
74
+ }
75
+
76
+ // Compare mod-time of all the prereqs with its mod-time
77
+ // If any prereqs are newer, need to run the action to update
78
+ if (prereqs && prereqs.length) {
79
+ for (let i = 0, ii = prereqs.length; i < ii; i++) {
80
+ prereqName = prereqs[i];
81
+ prereqTask = this.namespace.resolveTask(prereqName) ||
82
+ jake.createPlaceholderFileTask(prereqName, this.namespace);
83
+ // Run the action if:
84
+ // 1. The prereq is a normal task (not file/dir)
85
+ // 2. The prereq is a file-task with a mod-date more recent than
86
+ // the one for this file/dir
87
+ if (prereqTask) {
88
+ if (!isFileOrDirectory(prereqTask) ||
89
+ (isFile(prereqTask) && prereqTask.modTime > this.modTime)) {
90
+ return true;
91
+ }
92
+ }
93
+ }
94
+ this.taskStatus = Task.runStatuses.DONE;
95
+ return false;
96
+ }
97
+ // File/dir has no prereqs, and exists -- no need to run
98
+ else {
99
+ // Effectively done
100
+ this.taskStatus = Task.runStatuses.DONE;
101
+ return false;
102
+ }
103
+ }
104
+ }
105
+
106
+ updateModTime() {
107
+ let stats = fs.statSync(this.name);
108
+ this.modTime = stats.mtime;
109
+ }
110
+
111
+ complete() {
112
+ if (!this.dummy) {
113
+ this.updateModTime();
114
+ }
115
+ // Hackity hack
116
+ Task.prototype.complete.apply(this, arguments);
117
+ }
118
+
119
+ }
120
+
121
+ exports.FileTask = FileTask;
122
+
123
+ // DirectoryTask is a subclass of FileTask, depends on it
124
+ // being defined
125
+ let DirectoryTask = require('./directory_task').DirectoryTask;
126
+
node_modules/jake/lib/task/index.js ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+
2
+ let Task = require('./task').Task;
3
+ let FileTask = require('./file_task').FileTask;
4
+ let DirectoryTask = require('./directory_task').DirectoryTask;
5
+
6
+ exports.Task = Task;
7
+ exports.FileTask = FileTask;
8
+ exports.DirectoryTask = DirectoryTask;
9
+
node_modules/jake/lib/task/task.js ADDED
@@ -0,0 +1,458 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ let EventEmitter = require('events').EventEmitter;
2
+ let async = require('async');
3
+ let pc = require('picocolors');
4
+ // 'rule' module is required at the bottom because circular deps
5
+
6
+ // Used for task value, so better not to use
7
+ // null, since value should be unset/uninitialized
8
+ let UNDEFINED_VALUE;
9
+
10
+ const ROOT_TASK_NAME = '__rootTask__';
11
+ const POLLING_INTERVAL = 100;
12
+
13
+ // Parse any positional args attached to the task-name
14
+ function parsePrereqName(name) {
15
+ let taskArr = name.split('[');
16
+ let taskName = taskArr[0];
17
+ let taskArgs = [];
18
+ if (taskArr[1]) {
19
+ taskArgs = taskArr[1].replace(/\]$/, '');
20
+ taskArgs = taskArgs.split(',');
21
+ }
22
+ return {
23
+ name: taskName,
24
+ args: taskArgs
25
+ };
26
+ }
27
+
28
+ /**
29
+ @name jake.Task
30
+ @class
31
+ @extends EventEmitter
32
+ @description A Jake Task
33
+
34
+ @param {String} name The name of the Task
35
+ @param {Array} [prereqs] Prerequisites to be run before this task
36
+ @param {Function} [action] The action to perform for this task
37
+ @param {Object} [opts]
38
+ @param {Array} [opts.asyc=false] Perform this task asynchronously.
39
+ If you flag a task with this option, you must call the global
40
+ `complete` method inside the task's action, for execution to proceed
41
+ to the next task.
42
+ */
43
+ class Task extends EventEmitter {
44
+
45
+ constructor(name, prereqs, action, options) {
46
+ // EventEmitter ctor takes no args
47
+ super();
48
+
49
+ if (name.indexOf(':') > -1) {
50
+ throw new Error('Task name cannot include a colon. It is used internally as namespace delimiter.');
51
+ }
52
+ let opts = options || {};
53
+
54
+ this._currentPrereqIndex = 0;
55
+ this._internal = false;
56
+ this._skipped = false;
57
+
58
+ this.name = name;
59
+ this.prereqs = prereqs;
60
+ this.action = action;
61
+ this.async = false;
62
+ this.taskStatus = Task.runStatuses.UNSTARTED;
63
+ this.description = null;
64
+ this.args = [];
65
+ this.value = UNDEFINED_VALUE;
66
+ this.concurrency = 1;
67
+ this.startTime = null;
68
+ this.endTime = null;
69
+ this.directory = null;
70
+ this.namespace = null;
71
+
72
+ // Support legacy async-flag -- if not explicitly passed or falsy, will
73
+ // be set to empty-object
74
+ if (typeof opts == 'boolean' && opts === true) {
75
+ this.async = true;
76
+ }
77
+ else {
78
+ if (opts.async) {
79
+ this.async = true;
80
+ }
81
+ if (opts.concurrency) {
82
+ this.concurrency = opts.concurrency;
83
+ }
84
+ }
85
+
86
+ //Do a test on self dependencies for this task
87
+ if(Array.isArray(this.prereqs) && this.prereqs.indexOf(this.name) !== -1) {
88
+ throw new Error("Cannot use prereq " + this.name + " as a dependency of itself");
89
+ }
90
+ }
91
+
92
+ get fullName() {
93
+ return this._getFullName();
94
+ }
95
+
96
+ get params() {
97
+ return this._getParams();
98
+ }
99
+
100
+ _initInvocationChain() {
101
+ // Legacy global invocation chain
102
+ jake._invocationChain.push(this);
103
+
104
+ // New root chain
105
+ if (!this._invocationChain) {
106
+ this._invocationChainRoot = true;
107
+ this._invocationChain = [];
108
+ if (jake.currentRunningTask) {
109
+ jake.currentRunningTask._waitForChains = jake.currentRunningTask._waitForChains || [];
110
+ jake.currentRunningTask._waitForChains.push(this._invocationChain);
111
+ }
112
+ }
113
+ }
114
+
115
+ /**
116
+ @name jake.Task#invoke
117
+ @function
118
+ @description Runs prerequisites, then this task. If the task has already
119
+ been run, will not run the task again.
120
+ */
121
+ invoke() {
122
+ this._initInvocationChain();
123
+
124
+ this.args = Array.prototype.slice.call(arguments);
125
+ this.reenabled = false;
126
+ this.runPrereqs();
127
+ }
128
+
129
+ /**
130
+ @name jake.Task#execute
131
+ @function
132
+ @description Run only this task, without prereqs. If the task has already
133
+ been run, *will* run the task again.
134
+ */
135
+ execute() {
136
+ this._initInvocationChain();
137
+
138
+ this.args = Array.prototype.slice.call(arguments);
139
+ this.reenable();
140
+ this.reenabled = true;
141
+ this.run();
142
+ }
143
+
144
+ runPrereqs() {
145
+ if (this.prereqs && this.prereqs.length) {
146
+
147
+ if (this.concurrency > 1) {
148
+ async.eachLimit(this.prereqs, this.concurrency,
149
+
150
+ (name, cb) => {
151
+ let parsed = parsePrereqName(name);
152
+
153
+ let prereq = this.namespace.resolveTask(parsed.name) ||
154
+ jake.attemptRule(name, this.namespace, 0) ||
155
+ jake.createPlaceholderFileTask(name, this.namespace);
156
+
157
+ if (!prereq) {
158
+ throw new Error('Unknown task "' + name + '"');
159
+ }
160
+
161
+ //Test for circular invocation
162
+ if(prereq === this) {
163
+ setImmediate(function () {
164
+ cb(new Error("Cannot use prereq " + prereq.name + " as a dependency of itself"));
165
+ });
166
+ }
167
+
168
+ if (prereq.taskStatus == Task.runStatuses.DONE) {
169
+ //prereq already done, return
170
+ setImmediate(cb);
171
+ }
172
+ else {
173
+ //wait for complete before calling cb
174
+ prereq.once('_done', () => {
175
+ prereq.removeAllListeners('_done');
176
+ setImmediate(cb);
177
+ });
178
+ // Start the prereq if we are the first to encounter it
179
+ if (prereq.taskStatus === Task.runStatuses.UNSTARTED) {
180
+ prereq.taskStatus = Task.runStatuses.STARTED;
181
+ prereq.invoke.apply(prereq, parsed.args);
182
+ }
183
+ }
184
+ },
185
+
186
+ (err) => {
187
+ //async callback is called after all prereqs have run.
188
+ if (err) {
189
+ throw err;
190
+ }
191
+ else {
192
+ setImmediate(this.run.bind(this));
193
+ }
194
+ }
195
+ );
196
+ }
197
+ else {
198
+ setImmediate(this.nextPrereq.bind(this));
199
+ }
200
+ }
201
+ else {
202
+ setImmediate(this.run.bind(this));
203
+ }
204
+ }
205
+
206
+ nextPrereq() {
207
+ let self = this;
208
+ let index = this._currentPrereqIndex;
209
+ let name = this.prereqs[index];
210
+ let prereq;
211
+ let parsed;
212
+
213
+ if (name) {
214
+
215
+ parsed = parsePrereqName(name);
216
+
217
+ prereq = this.namespace.resolveTask(parsed.name) ||
218
+ jake.attemptRule(name, this.namespace, 0) ||
219
+ jake.createPlaceholderFileTask(name, this.namespace);
220
+
221
+ if (!prereq) {
222
+ throw new Error('Unknown task "' + name + '"');
223
+ }
224
+
225
+ // Do when done
226
+ if (prereq.taskStatus == Task.runStatuses.DONE) {
227
+ self.handlePrereqDone(prereq);
228
+ }
229
+ else {
230
+ prereq.once('_done', () => {
231
+ this.handlePrereqDone(prereq);
232
+ prereq.removeAllListeners('_done');
233
+ });
234
+ if (prereq.taskStatus == Task.runStatuses.UNSTARTED) {
235
+ prereq.taskStatus = Task.runStatuses.STARTED;
236
+ prereq._invocationChain = this._invocationChain;
237
+ prereq.invoke.apply(prereq, parsed.args);
238
+ }
239
+ }
240
+ }
241
+ }
242
+
243
+ /**
244
+ @name jake.Task#reenable
245
+ @function
246
+ @description Reenables a task so that it can be run again.
247
+ */
248
+ reenable(deep) {
249
+ let prereqs;
250
+ let prereq;
251
+ this._skipped = false;
252
+ this.taskStatus = Task.runStatuses.UNSTARTED;
253
+ this.value = UNDEFINED_VALUE;
254
+ if (deep && this.prereqs) {
255
+ prereqs = this.prereqs;
256
+ for (let i = 0, ii = prereqs.length; i < ii; i++) {
257
+ prereq = jake.Task[prereqs[i]];
258
+ if (prereq) {
259
+ prereq.reenable(deep);
260
+ }
261
+ }
262
+ }
263
+ }
264
+
265
+ handlePrereqDone(prereq) {
266
+ this._currentPrereqIndex++;
267
+ if (this._currentPrereqIndex < this.prereqs.length) {
268
+ setImmediate(this.nextPrereq.bind(this));
269
+ }
270
+ else {
271
+ setImmediate(this.run.bind(this));
272
+ }
273
+ }
274
+
275
+ isNeeded() {
276
+ let needed = true;
277
+ if (this.taskStatus == Task.runStatuses.DONE) {
278
+ needed = false;
279
+ }
280
+ return needed;
281
+ }
282
+
283
+ run() {
284
+ let val, previous;
285
+ let hasAction = typeof this.action == 'function';
286
+
287
+ if (!this.isNeeded()) {
288
+ this.emit('skip');
289
+ this.emit('_done');
290
+ }
291
+ else {
292
+ if (this._invocationChain.length) {
293
+ previous = this._invocationChain[this._invocationChain.length - 1];
294
+ // If this task is repeating and its previous is equal to this, don't check its status because it was set to UNSTARTED by the reenable() method
295
+ if (!(this.reenabled && previous == this)) {
296
+ if (previous.taskStatus != Task.runStatuses.DONE) {
297
+ let now = (new Date()).getTime();
298
+ if (now - this.startTime > jake._taskTimeout) {
299
+ return jake.fail(`Timed out waiting for task: ${previous.name} with status of ${previous.taskStatus}`);
300
+ }
301
+ setTimeout(this.run.bind(this), POLLING_INTERVAL);
302
+ return;
303
+ }
304
+ }
305
+ }
306
+ if (!(this.reenabled && previous == this)) {
307
+ this._invocationChain.push(this);
308
+ }
309
+
310
+ if (!(this._internal || jake.program.opts.quiet)) {
311
+ jake.emit('started', {
312
+ name: this.fullName,
313
+ task: this,
314
+ });
315
+ console.log("Starting '" + pc.green(this.fullName) + "'...");
316
+ }
317
+
318
+ this.startTime = (new Date()).getTime();
319
+ this.emit('start');
320
+
321
+ jake.currentRunningTask = this;
322
+
323
+ if (hasAction) {
324
+ try {
325
+ if (this.directory) {
326
+ process.chdir(this.directory);
327
+ }
328
+
329
+ val = this.action.apply(this, this.args);
330
+
331
+ if (typeof val == 'object' && typeof val.then == 'function') {
332
+ this.async = true;
333
+
334
+ val.then(
335
+ (result) => {
336
+ setImmediate(() => {
337
+ this.complete(result);
338
+ });
339
+ },
340
+ (err) => {
341
+ setImmediate(() => {
342
+ this.errorOut(err);
343
+ });
344
+ });
345
+ }
346
+ }
347
+ catch (err) {
348
+ this.errorOut(err);
349
+ return; // Bail out, not complete
350
+ }
351
+ }
352
+
353
+ if (!(hasAction && this.async)) {
354
+ setImmediate(() => {
355
+ this.complete(val);
356
+ });
357
+ }
358
+ }
359
+ }
360
+
361
+ errorOut(err) {
362
+ this.taskStatus = Task.runStatuses.ERROR;
363
+ this._invocationChain.chainStatus = Task.runStatuses.ERROR;
364
+ this.emit('error', err);
365
+ }
366
+
367
+ complete(val) {
368
+
369
+ if (Array.isArray(this._waitForChains)) {
370
+ let stillWaiting = this._waitForChains.some((chain) => {
371
+ return !(chain.chainStatus == Task.runStatuses.DONE ||
372
+ chain.chainStatus == Task.runStatuses.ERROR);
373
+ });
374
+ if (stillWaiting) {
375
+ let now = (new Date()).getTime();
376
+ let elapsed = now - this.startTime;
377
+ if (elapsed > jake._taskTimeout) {
378
+ return jake.fail(`Timed out waiting for task: ${this.name} with status of ${this.taskStatus}. Elapsed: ${elapsed}`);
379
+ }
380
+ setTimeout(() => {
381
+ this.complete(val);
382
+ }, POLLING_INTERVAL);
383
+ return;
384
+ }
385
+ }
386
+
387
+ jake._invocationChain.splice(jake._invocationChain.indexOf(this), 1);
388
+
389
+ if (this._invocationChainRoot) {
390
+ this._invocationChain.chainStatus = Task.runStatuses.DONE;
391
+ }
392
+
393
+ this._currentPrereqIndex = 0;
394
+
395
+ // If 'complete' getting called because task has been
396
+ // run already, value will not be passed -- leave in place
397
+ if (!this._skipped) {
398
+ this.taskStatus = Task.runStatuses.DONE;
399
+ this.value = val;
400
+
401
+ this.emit('complete', this.value);
402
+ this.emit('_done');
403
+
404
+ this.endTime = (new Date()).getTime();
405
+ let taskTime = this.endTime - this.startTime;
406
+
407
+ if (!(this._internal || jake.program.opts.quiet)) {
408
+ jake.emit('finished', {
409
+ name: this.fullName,
410
+ task: this,
411
+ time: taskTime,
412
+ });
413
+ console.log("Finished '" + pc.green(this.fullName) + "' after " + pc.magenta(taskTime + ' ms'));
414
+ }
415
+
416
+ }
417
+ }
418
+
419
+ _getFullName() {
420
+ let ns = this.namespace;
421
+ let path = (ns && ns.path) || '';
422
+ path = (path && path.split(':')) || [];
423
+ if (this.namespace !== jake.defaultNamespace) {
424
+ path.push(this.namespace.name);
425
+ }
426
+ path.push(this.name);
427
+ return path.join(':');
428
+ }
429
+
430
+ _getParams() {
431
+ if (!this.action) return "";
432
+ let params = (new RegExp('(?:'+this.action.name+'\\s*|^)\\s*\\((.*?)\\)').exec(this.action.toString().replace(/\n/g, '')) || [''])[1].replace(/\/\*.*?\*\//g, '').replace(/ /g, '');
433
+ return params;
434
+ }
435
+
436
+ static getBaseNamespacePath(fullName) {
437
+ return fullName.split(':').slice(0, -1).join(':');
438
+ }
439
+
440
+ static getBaseTaskName(fullName) {
441
+ return fullName.split(':').pop();
442
+ }
443
+ }
444
+
445
+ Task.runStatuses = {
446
+ UNSTARTED: 'unstarted',
447
+ DONE: 'done',
448
+ STARTED: 'started',
449
+ ERROR: 'error'
450
+ };
451
+
452
+ Task.ROOT_TASK_NAME = ROOT_TASK_NAME;
453
+
454
+ exports.Task = Task;
455
+
456
+ // Required here because circular deps
457
+ require('../rule');
458
+
node_modules/jake/lib/test_task.js ADDED
@@ -0,0 +1,270 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Jake JavaScript build tool
3
+ * Copyright 2112 Matthew Eernisse (mde@fleegix.org)
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ *
17
+ */
18
+
19
+ let path = require('path');
20
+ let currDir = process.cwd();
21
+
22
+ /**
23
+ @name jake
24
+ @namespace jake
25
+ */
26
+ /**
27
+ @name jake.TestTask
28
+ @constructor
29
+ @description Instantiating a TestTask creates a number of Jake
30
+ Tasks that make running tests for your software easy.
31
+
32
+ @param {String} name The name of the project
33
+ @param {Function} definition Defines the list of files containing the tests,
34
+ and the name of the namespace/task for running them. Will be executed on the
35
+ instantiated TestTask (i.e., 'this', will be the TestTask instance), to set
36
+ the various instance-propertiess.
37
+
38
+ @example
39
+ let t = new jake.TestTask('bij-js', function () {
40
+ this.testName = 'testSpecial';
41
+ this.testFiles.include('test/**');
42
+ });
43
+
44
+ */
45
+ let TestTask = function () {
46
+ let self = this;
47
+ let args = Array.prototype.slice.call(arguments);
48
+ let name = args.shift();
49
+ let definition = args.pop();
50
+ let prereqs = args.pop() || [];
51
+
52
+ /**
53
+ @name jake.TestTask#testNam
54
+ @public
55
+ @type {String}
56
+ @description The name of the namespace to place the tests in, and
57
+ the top-level task for running tests. Defaults to "test"
58
+ */
59
+ this.testName = 'test';
60
+
61
+ /**
62
+ @name jake.TestTask#testFiles
63
+ @public
64
+ @type {jake.FileList}
65
+ @description The list of files containing tests to load
66
+ */
67
+ this.testFiles = new jake.FileList();
68
+
69
+ /**
70
+ @name jake.TestTask#showDescription
71
+ @public
72
+ @type {Boolean}
73
+ @description Show the created task when doing Jake -T
74
+ */
75
+ this.showDescription = true;
76
+
77
+ /*
78
+ @name jake.TestTask#totalTests
79
+ @public
80
+ @type {Number}
81
+ @description The total number of tests to run
82
+ */
83
+ this.totalTests = 0;
84
+
85
+ /*
86
+ @name jake.TestTask#executedTests
87
+ @public
88
+ @type {Number}
89
+ @description The number of tests successfully run
90
+ */
91
+ this.executedTests = 0;
92
+
93
+ if (typeof definition == 'function') {
94
+ definition.call(this);
95
+ }
96
+
97
+ if (this.showDescription) {
98
+ desc('Run the tests for ' + name);
99
+ }
100
+
101
+ task(this.testName, prereqs, {async: true}, function () {
102
+ let t = jake.Task[this.fullName + ':run'];
103
+ t.on('complete', function () {
104
+ complete();
105
+ });
106
+ // Pass args to the namespaced test
107
+ t.invoke.apply(t, arguments);
108
+ });
109
+
110
+ namespace(self.testName, function () {
111
+
112
+ let runTask = task('run', {async: true}, function (pat) {
113
+ let re;
114
+ let testFiles;
115
+
116
+ // Don't nest; make a top-level namespace. Don't want
117
+ // re-calling from inside to nest infinitely
118
+ jake.currentNamespace = jake.defaultNamespace;
119
+
120
+ re = new RegExp(pat);
121
+ // Get test files that match the passed-in pattern
122
+ testFiles = self.testFiles.toArray()
123
+ .filter(function (f) {
124
+ return (re).test(f);
125
+ }) // Don't load the same file multiple times -- should this be in FileList?
126
+ .reduce(function (p, c) {
127
+ if (p.indexOf(c) < 0) {
128
+ p.push(c);
129
+ }
130
+ return p;
131
+ }, []);
132
+
133
+ // Create a namespace for all the testing tasks to live in
134
+ namespace(self.testName + 'Exec', function () {
135
+ // Each test will be a prereq for the dummy top-level task
136
+ let prereqs = [];
137
+ // Continuation to pass to the async tests, wrapping `continune`
138
+ let next = function () {
139
+ complete();
140
+ };
141
+ // Create the task for this test-function
142
+ let createTask = function (name, action) {
143
+ // If the test-function is defined with a continuation
144
+ // param, flag the task as async
145
+ let t;
146
+ let isAsync = !!action.length;
147
+
148
+ // Define the actual namespaced task with the name, the
149
+ // wrapped action, and the correc async-flag
150
+ t = task(name, createAction(name, action), {
151
+ async: isAsync
152
+ });
153
+ t.once('complete', function () {
154
+ self.executedTests++;
155
+ });
156
+ t._internal = true;
157
+ return t;
158
+ };
159
+ // Used as the action for the defined task for each test.
160
+ let createAction = function (n, a) {
161
+ // A wrapped function that passes in the `next` function
162
+ // for any tasks that run asynchronously
163
+ return function () {
164
+ let cb;
165
+ if (a.length) {
166
+ cb = next;
167
+ }
168
+ if (!(n == 'before' || n == 'after' ||
169
+ /_beforeEach$/.test(n) || /_afterEach$/.test(n))) {
170
+ jake.logger.log(n);
171
+ }
172
+ // 'this' will be the task when action is run
173
+ return a.call(this, cb);
174
+ };
175
+ };
176
+ // Dummy top-level task for everything to be prereqs for
177
+ let topLevel;
178
+
179
+ // Pull in each test-file, and iterate over any exported
180
+ // test-functions. Register each test-function as a prereq task
181
+ testFiles.forEach(function (file) {
182
+ let exp = require(path.join(currDir, file));
183
+
184
+ // Create a namespace for each filename, so test-name collisions
185
+ // won't be a problem
186
+ namespace(file, function () {
187
+ let testPrefix = self.testName + 'Exec:' + file + ':';
188
+ let testName;
189
+ // Dummy task for displaying file banner
190
+ testName = '*** Running ' + file + ' ***';
191
+ prereqs.push(testPrefix + testName);
192
+ createTask(testName, function () {});
193
+
194
+ // 'before' setup
195
+ if (typeof exp.before == 'function') {
196
+ prereqs.push(testPrefix + 'before');
197
+ // Create the task
198
+ createTask('before', exp.before);
199
+ }
200
+
201
+ // Walk each exported function, and create a task for each
202
+ for (let p in exp) {
203
+ if (p == 'before' || p == 'after' ||
204
+ p == 'beforeEach' || p == 'afterEach') {
205
+ continue;
206
+ }
207
+
208
+ if (typeof exp.beforeEach == 'function') {
209
+ prereqs.push(testPrefix + p + '_beforeEach');
210
+ // Create the task
211
+ createTask(p + '_beforeEach', exp.beforeEach);
212
+ }
213
+
214
+ // Add the namespace:name of this test to the list of prereqs
215
+ // for the dummy top-level task
216
+ prereqs.push(testPrefix + p);
217
+ // Create the task
218
+ createTask(p, exp[p]);
219
+
220
+ if (typeof exp.afterEach == 'function') {
221
+ prereqs.push(testPrefix + p + '_afterEach');
222
+ // Create the task
223
+ createTask(p + '_afterEach', exp.afterEach);
224
+ }
225
+ }
226
+
227
+ // 'after' teardown
228
+ if (typeof exp.after == 'function') {
229
+ prereqs.push(testPrefix + 'after');
230
+ // Create the task
231
+ let afterTask = createTask('after', exp.after);
232
+ afterTask._internal = true;
233
+ }
234
+
235
+ });
236
+ });
237
+
238
+ self.totalTests = prereqs.length;
239
+ process.on('exit', function () {
240
+ // Throw in the case where the process exits without
241
+ // finishing tests, but no error was thrown
242
+ if (!jake.errorCode && (self.totalTests > self.executedTests)) {
243
+ throw new Error('Process exited without all tests completing.');
244
+ }
245
+ });
246
+
247
+ // Create the dummy top-level task. When calling a task internally
248
+ // with `invoke` that is async (or has async prereqs), have to listen
249
+ // for the 'complete' event to know when it's done
250
+ topLevel = task('__top__', prereqs);
251
+ topLevel._internal = true;
252
+ topLevel.addListener('complete', function () {
253
+ jake.logger.log('All tests ran successfully');
254
+ complete();
255
+ });
256
+
257
+ topLevel.invoke(); // Do the thing!
258
+ });
259
+
260
+ });
261
+ runTask._internal = true;
262
+
263
+ });
264
+
265
+
266
+ };
267
+
268
+ jake.TestTask = TestTask;
269
+ exports.TestTask = TestTask;
270
+
node_modules/jake/lib/utils/file.js ADDED
@@ -0,0 +1,286 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Utilities: A classic collection of JavaScript utilities
3
+ * Copyright 2112 Matthew Eernisse (mde@fleegix.org)
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ *
17
+ */
18
+
19
+ let fs = require('fs');
20
+ let path = require('path');
21
+
22
+ /**
23
+ @name file
24
+ @namespace file
25
+ */
26
+
27
+ let fileUtils = new (function () {
28
+
29
+ // Recursively copy files and directories
30
+ let _copyFile = function (fromPath, toPath, opts) {
31
+ let from = path.normalize(fromPath);
32
+ let to = path.normalize(toPath);
33
+ let options = opts || {};
34
+ let fromStat;
35
+ let toStat;
36
+ let destExists;
37
+ let destDoesNotExistErr;
38
+ let content;
39
+ let filename;
40
+ let dirContents;
41
+ let targetDir;
42
+
43
+ fromStat = fs.statSync(from);
44
+
45
+ try {
46
+ //console.dir(to + ' destExists');
47
+ toStat = fs.statSync(to);
48
+ destExists = true;
49
+ }
50
+ catch(e) {
51
+ //console.dir(to + ' does not exist');
52
+ destDoesNotExistErr = e;
53
+ destExists = false;
54
+ }
55
+ // Destination dir or file exists, copy into (directory)
56
+ // or overwrite (file)
57
+ if (destExists) {
58
+
59
+ // If there's a rename-via-copy file/dir name passed, use it.
60
+ // Otherwise use the actual file/dir name
61
+ filename = options.rename || path.basename(from);
62
+
63
+ // Copying a directory
64
+ if (fromStat.isDirectory()) {
65
+ dirContents = fs.readdirSync(from);
66
+ targetDir = path.join(to, filename);
67
+ // We don't care if the target dir already exists
68
+ try {
69
+ fs.mkdirSync(targetDir, {mode: fromStat.mode & 0o777});
70
+ }
71
+ catch(e) {
72
+ if (e.code !== 'EEXIST') {
73
+ throw e;
74
+ }
75
+ }
76
+ for (let i = 0, ii = dirContents.length; i < ii; i++) {
77
+ _copyFile(path.join(from, dirContents[i]), targetDir, {preserveMode: options.preserveMode});
78
+ }
79
+ }
80
+ // Copying a file
81
+ else {
82
+ content = fs.readFileSync(from);
83
+ let mode = fromStat.mode & 0o777;
84
+ let targetFile = to;
85
+
86
+ if (toStat.isDirectory()) {
87
+ targetFile = path.join(to, filename);
88
+ }
89
+
90
+ let fileExists = fs.existsSync(targetFile);
91
+ fs.writeFileSync(targetFile, content);
92
+
93
+ // If the file didn't already exist, use the original file mode.
94
+ // Otherwise, only update the mode if preserverMode is true.
95
+ if(!fileExists || options.preserveMode) {
96
+ fs.chmodSync(targetFile, mode);
97
+ }
98
+ }
99
+ }
100
+ // Dest doesn't exist, can't create it
101
+ else {
102
+ throw destDoesNotExistErr;
103
+ }
104
+ };
105
+
106
+ // Remove the given directory
107
+ let _rmDir = function (dirPath) {
108
+ let dir = path.normalize(dirPath);
109
+ let paths = [];
110
+ paths = fs.readdirSync(dir);
111
+ paths.forEach(function (p) {
112
+ let curr = path.join(dir, p);
113
+ let stat = fs.lstatSync(curr);
114
+ if (stat.isDirectory()) {
115
+ _rmDir(curr);
116
+ }
117
+ else {
118
+ try {
119
+ fs.unlinkSync(curr);
120
+ } catch(e) {
121
+ if (e.code === 'EPERM') {
122
+ fs.chmodSync(curr, parseInt(666, 8));
123
+ fs.unlinkSync(curr);
124
+ } else {
125
+ throw e;
126
+ }
127
+ }
128
+ }
129
+ });
130
+ fs.rmdirSync(dir);
131
+ };
132
+
133
+ /**
134
+ @name file#cpR
135
+ @public
136
+ @function
137
+ @description Copies a directory/file to a destination
138
+ @param {String} fromPath The source path to copy from
139
+ @param {String} toPath The destination path to copy to
140
+ @param {Object} opts Options to use
141
+ @param {Boolean} [opts.preserveMode] If target file already exists, this
142
+ determines whether the original file's mode is copied over. The default of
143
+ false mimics the behavior of the `cp` command line tool. (Default: false)
144
+ */
145
+ this.cpR = function (fromPath, toPath, options) {
146
+ let from = path.normalize(fromPath);
147
+ let to = path.normalize(toPath);
148
+ let toStat;
149
+ let doesNotExistErr;
150
+ let filename;
151
+ let opts = options || {};
152
+
153
+ if (from == to) {
154
+ throw new Error('Cannot copy ' + from + ' to itself.');
155
+ }
156
+
157
+ // Handle rename-via-copy
158
+ try {
159
+ toStat = fs.statSync(to);
160
+ }
161
+ catch(e) {
162
+ doesNotExistErr = e;
163
+
164
+ // Get abs path so it's possible to check parent dir
165
+ if (!this.isAbsolute(to)) {
166
+ to = path.join(process.cwd(), to);
167
+ }
168
+
169
+ // Save the file/dir name
170
+ filename = path.basename(to);
171
+ // See if a parent dir exists, so there's a place to put the
172
+ /// renamed file/dir (resets the destination for the copy)
173
+ to = path.dirname(to);
174
+ try {
175
+ toStat = fs.statSync(to);
176
+ }
177
+ catch(e) {}
178
+ if (toStat && toStat.isDirectory()) {
179
+ // Set the rename opt to pass to the copy func, will be used
180
+ // as the new file/dir name
181
+ opts.rename = filename;
182
+ //console.log('filename ' + filename);
183
+ }
184
+ else {
185
+ throw doesNotExistErr;
186
+ }
187
+ }
188
+
189
+ _copyFile(from, to, opts);
190
+ };
191
+
192
+ /**
193
+ @name file#mkdirP
194
+ @public
195
+ @function
196
+ @description Create the given directory(ies) using the given mode permissions
197
+ @param {String} dir The directory to create
198
+ @param {Number} mode The mode to give the created directory(ies)(Default: 0755)
199
+ */
200
+ this.mkdirP = function (dir, mode) {
201
+ let dirPath = path.normalize(dir);
202
+ let paths = dirPath.split(/\/|\\/);
203
+ let currPath = '';
204
+ let next;
205
+
206
+ if (paths[0] == '' || /^[A-Za-z]+:/.test(paths[0])) {
207
+ currPath = paths.shift() || '/';
208
+ currPath = path.join(currPath, paths.shift());
209
+ //console.log('basedir');
210
+ }
211
+ while ((next = paths.shift())) {
212
+ if (next == '..') {
213
+ currPath = path.join(currPath, next);
214
+ continue;
215
+ }
216
+ currPath = path.join(currPath, next);
217
+ try {
218
+ //console.log('making ' + currPath);
219
+ fs.mkdirSync(currPath, mode || parseInt(755, 8));
220
+ }
221
+ catch(e) {
222
+ if (e.code != 'EEXIST') {
223
+ throw e;
224
+ }
225
+ }
226
+ }
227
+ };
228
+
229
+ /**
230
+ @name file#rmRf
231
+ @public
232
+ @function
233
+ @description Deletes the given directory/file
234
+ @param {String} p The path to delete, can be a directory or file
235
+ */
236
+ this.rmRf = function (p, options) {
237
+ let stat;
238
+ try {
239
+ stat = fs.lstatSync(p);
240
+ if (stat.isDirectory()) {
241
+ _rmDir(p);
242
+ }
243
+ else {
244
+ fs.unlinkSync(p);
245
+ }
246
+ }
247
+ catch (e) {}
248
+ };
249
+
250
+ /**
251
+ @name file#isAbsolute
252
+ @public
253
+ @function
254
+ @return {Boolean/String} If it's absolute the first character is returned otherwise false
255
+ @description Checks if a given path is absolute or relative
256
+ @param {String} p Path to check
257
+ */
258
+ this.isAbsolute = function (p) {
259
+ let match = /^[A-Za-z]+:\\|^\//.exec(p);
260
+ if (match && match.length) {
261
+ return match[0];
262
+ }
263
+ return false;
264
+ };
265
+
266
+ /**
267
+ @name file#absolutize
268
+ @public
269
+ @function
270
+ @return {String} Returns the absolute path for the given path
271
+ @description Returns the absolute path for the given path
272
+ @param {String} p The path to get the absolute path for
273
+ */
274
+ this.absolutize = function (p) {
275
+ if (this.isAbsolute(p)) {
276
+ return p;
277
+ }
278
+ else {
279
+ return path.join(process.cwd(), p);
280
+ }
281
+ };
282
+
283
+ })();
284
+
285
+ module.exports = fileUtils;
286
+
node_modules/jake/lib/utils/index.js ADDED
@@ -0,0 +1,297 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Jake JavaScript build tool
3
+ * Copyright 2112 Matthew Eernisse (mde@fleegix.org)
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ *
17
+ */
18
+
19
+
20
+ let util = require('util'); // Native Node util module
21
+ let spawn = require('child_process').spawn;
22
+ let EventEmitter = require('events').EventEmitter;
23
+ let logger = require('./logger');
24
+ let file = require('./file');
25
+ let Exec;
26
+
27
+ const _UUID_CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
28
+
29
+ let parseArgs = function (argumentsObj) {
30
+ let args;
31
+ let arg;
32
+ let cmds;
33
+ let callback;
34
+ let opts = {
35
+ interactive: false,
36
+ printStdout: false,
37
+ printStderr: false,
38
+ breakOnError: true
39
+ };
40
+
41
+ args = Array.prototype.slice.call(argumentsObj);
42
+
43
+ cmds = args.shift();
44
+ // Arrayize if passed a single string command
45
+ if (typeof cmds == 'string') {
46
+ cmds = [cmds];
47
+ }
48
+ // Make a copy if it's an actual list
49
+ else {
50
+ cmds = cmds.slice();
51
+ }
52
+
53
+ // Get optional callback or opts
54
+ while((arg = args.shift())) {
55
+ if (typeof arg == 'function') {
56
+ callback = arg;
57
+ }
58
+ else if (typeof arg == 'object') {
59
+ opts = Object.assign(opts, arg);
60
+ }
61
+ }
62
+
63
+ // Backward-compat shim
64
+ if (typeof opts.stdout != 'undefined') {
65
+ opts.printStdout = opts.stdout;
66
+ delete opts.stdout;
67
+ }
68
+ if (typeof opts.stderr != 'undefined') {
69
+ opts.printStderr = opts.stderr;
70
+ delete opts.stderr;
71
+ }
72
+
73
+ return {
74
+ cmds: cmds,
75
+ opts: opts,
76
+ callback: callback
77
+ };
78
+ };
79
+
80
+ /**
81
+ @name jake
82
+ @namespace jake
83
+ */
84
+ let utils = new (function () {
85
+ /**
86
+ @name jake.exec
87
+ @static
88
+ @function
89
+ @description Executes shell-commands asynchronously with an optional
90
+ final callback.
91
+ `
92
+ @param {String[]} cmds The list of shell-commands to execute
93
+ @param {Object} [opts]
94
+ @param {Boolean} [opts.printStdout=false] Print stdout from each command
95
+ @param {Boolean} [opts.printStderr=false] Print stderr from each command
96
+ @param {Boolean} [opts.breakOnError=true] Stop further execution on
97
+ the first error.
98
+ @param {Boolean} [opts.windowsVerbatimArguments=false] Don't translate
99
+ arguments on Windows.
100
+ @param {Function} [callback] Callback to run after executing the
101
+ commands
102
+
103
+ @example
104
+ let cmds = [
105
+ 'echo "showing directories"'
106
+ , 'ls -al | grep ^d'
107
+ , 'echo "moving up a directory"'
108
+ , 'cd ../'
109
+ ]
110
+ , callback = function () {
111
+ console.log('Finished running commands.');
112
+ }
113
+ jake.exec(cmds, {stdout: true}, callback);
114
+ */
115
+ this.exec = function (a, b, c) {
116
+ let parsed = parseArgs(arguments);
117
+ let cmds = parsed.cmds;
118
+ let opts = parsed.opts;
119
+ let callback = parsed.callback;
120
+
121
+ let ex = new Exec(cmds, opts, callback);
122
+
123
+ ex.addListener('error', function (msg, code) {
124
+ if (opts.breakOnError) {
125
+ fail(msg, code);
126
+ }
127
+ });
128
+ ex.run();
129
+
130
+ return ex;
131
+ };
132
+
133
+ this.createExec = function (a, b, c) {
134
+ return new Exec(a, b, c);
135
+ };
136
+
137
+ // From Math.uuid.js, https://github.com/broofa/node-uuid
138
+ // Robert Kieffer (robert@broofa.com), MIT license
139
+ this.uuid = function (length, radix) {
140
+ var chars = _UUID_CHARS
141
+ , uuid = []
142
+ , r
143
+ , i;
144
+
145
+ radix = radix || chars.length;
146
+
147
+ if (length) {
148
+ // Compact form
149
+ i = -1;
150
+ while (++i < length) {
151
+ uuid[i] = chars[0 | Math.random()*radix];
152
+ }
153
+ } else {
154
+ // rfc4122, version 4 form
155
+
156
+ // rfc4122 requires these characters
157
+ uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
158
+ uuid[14] = '4';
159
+
160
+ // Fill in random data. At i==19 set the high bits of clock sequence as
161
+ // per rfc4122, sec. 4.1.5
162
+ i = -1;
163
+ while (++i < 36) {
164
+ if (!uuid[i]) {
165
+ r = 0 | Math.random()*16;
166
+ uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
167
+ }
168
+ }
169
+ }
170
+
171
+ return uuid.join('');
172
+ };
173
+
174
+ })();
175
+
176
+ Exec = function () {
177
+ let parsed = parseArgs(arguments);
178
+ let cmds = parsed.cmds;
179
+ let opts = parsed.opts;
180
+ let callback = parsed.callback;
181
+
182
+ this._cmds = cmds;
183
+ this._callback = callback;
184
+ this._config = opts;
185
+ };
186
+
187
+ util.inherits(Exec, EventEmitter);
188
+
189
+ Object.assign(Exec.prototype, new (function () {
190
+
191
+ let _run = function () {
192
+ let self = this;
193
+ let sh;
194
+ let cmd;
195
+ let args;
196
+ let next = this._cmds.shift();
197
+ let config = this._config;
198
+ let errData = '';
199
+ let shStdio;
200
+ let handleStdoutData = function (data) {
201
+ self.emit('stdout', data);
202
+ };
203
+ let handleStderrData = function (data) {
204
+ let d = data.toString();
205
+ self.emit('stderr', data);
206
+ // Accumulate the error-data so we can use it as the
207
+ // stack if the process exits with an error
208
+ errData += d;
209
+ };
210
+
211
+ // Keep running as long as there are commands in the array
212
+ if (next) {
213
+ let spawnOpts = {};
214
+ this.emit('cmdStart', next);
215
+
216
+ // Ganking part of Node's child_process.exec to get cmdline args parsed
217
+ if (process.platform == 'win32') {
218
+ cmd = 'cmd';
219
+ args = ['/c', next];
220
+ if (config.windowsVerbatimArguments) {
221
+ spawnOpts.windowsVerbatimArguments = true;
222
+ }
223
+ }
224
+ else {
225
+ cmd = '/bin/sh';
226
+ args = ['-c', next];
227
+ }
228
+
229
+ if (config.interactive) {
230
+ spawnOpts.stdio = 'inherit';
231
+ sh = spawn(cmd, args, spawnOpts);
232
+ }
233
+ else {
234
+ shStdio = [
235
+ process.stdin
236
+ ];
237
+ if (config.printStdout) {
238
+ shStdio.push(process.stdout);
239
+ }
240
+ else {
241
+ shStdio.push('pipe');
242
+ }
243
+ if (config.printStderr) {
244
+ shStdio.push(process.stderr);
245
+ }
246
+ else {
247
+ shStdio.push('pipe');
248
+ }
249
+ spawnOpts.stdio = shStdio;
250
+ sh = spawn(cmd, args, spawnOpts);
251
+ if (!config.printStdout) {
252
+ sh.stdout.addListener('data', handleStdoutData);
253
+ }
254
+ if (!config.printStderr) {
255
+ sh.stderr.addListener('data', handleStderrData);
256
+ }
257
+ }
258
+
259
+ // Exit, handle err or run next
260
+ sh.on('exit', function (code) {
261
+ let msg;
262
+ if (code !== 0) {
263
+ msg = errData || 'Process exited with error.';
264
+ msg = msg.trim();
265
+ self.emit('error', msg, code);
266
+ }
267
+ if (code === 0 || !config.breakOnError) {
268
+ self.emit('cmdEnd', next);
269
+ setTimeout(function () { _run.call(self); }, 0);
270
+ }
271
+ });
272
+
273
+ }
274
+ else {
275
+ self.emit('end');
276
+ if (typeof self._callback == 'function') {
277
+ self._callback();
278
+ }
279
+ }
280
+ };
281
+
282
+ this.append = function (cmd) {
283
+ this._cmds.push(cmd);
284
+ };
285
+
286
+ this.run = function () {
287
+ _run.call(this);
288
+ };
289
+
290
+ })());
291
+
292
+ utils.Exec = Exec;
293
+ utils.file = file;
294
+ utils.logger = logger;
295
+
296
+ module.exports = utils;
297
+
node_modules/jake/lib/utils/logger.js ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ let util = require('util');
2
+
3
+ let logger = new (function () {
4
+ let _output = function (type, out) {
5
+ let quiet = typeof jake != 'undefined' && jake.program &&
6
+ jake.program.opts && jake.program.opts.quiet;
7
+ let msg;
8
+ if (!quiet) {
9
+ msg = typeof out == 'string' ? out : util.inspect(out);
10
+ console[type](msg);
11
+ }
12
+ };
13
+
14
+ this.log = function (out) {
15
+ _output('log', out);
16
+ };
17
+
18
+ this.error = function (out) {
19
+ _output('error', out);
20
+ };
21
+
22
+ })();
23
+
24
+ module.exports = logger;
node_modules/jake/package.json ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "jake",
3
+ "description": "JavaScript build tool, similar to Make or Rake",
4
+ "keywords": [
5
+ "build",
6
+ "cli",
7
+ "make",
8
+ "rake"
9
+ ],
10
+ "version": "10.9.4",
11
+ "author": "Matthew Eernisse <mde@fleegix.org> (http://fleegix.org)",
12
+ "license": "Apache-2.0",
13
+ "bin": {
14
+ "jake": "./bin/cli.js"
15
+ },
16
+ "main": "./lib/jake.js",
17
+ "scripts": {
18
+ "lint": "eslint --format codeframe \"lib/**/*.js\" \"test/**/*.js\"",
19
+ "lint:fix": "eslint --fix \"lib/**/*.js\" \"test/**/*.js\"",
20
+ "test": "./bin/cli.js test",
21
+ "test:ci": "npm run lint && npm run test"
22
+ },
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git://github.com/jakejs/jake.git"
26
+ },
27
+ "preferGlobal": true,
28
+ "dependencies": {
29
+ "async": "^3.2.6",
30
+ "filelist": "^1.0.4",
31
+ "picocolors": "^1.1.1"
32
+ },
33
+ "devDependencies": {
34
+ "@eslint/js": "^9.16.0",
35
+ "eslint": "^9.16.0",
36
+ "eslint-formatter-codeframe": "^7.32.1",
37
+ "globals": "^15.13.0",
38
+ "mocha": "^11.0.1",
39
+ "q": "^1.5.1"
40
+ },
41
+ "engines": {
42
+ "node": ">=10"
43
+ }
44
+ }
node_modules/jake/test/integration/concurrent.js ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ let assert = require('assert');
2
+ let exec = require('child_process').execSync;
3
+
4
+ const PROJECT_DIR = process.env.PROJECT_DIR;
5
+ const JAKE_CMD = `${PROJECT_DIR}/bin/cli.js`;
6
+
7
+ suite('concurrent', function () {
8
+
9
+ this.timeout(7000);
10
+
11
+ test(' simple concurrent prerequisites 1', function () {
12
+ let out = exec(`${JAKE_CMD} -q concurrent:simple1`).toString().trim();
13
+ assert.equal('Started A\nStarted B\nFinished B\nFinished A', out);
14
+ });
15
+
16
+ test(' simple concurrent prerequisites 2', function () {
17
+ let out = exec(`${JAKE_CMD} -q concurrent:simple2`).toString().trim();
18
+ assert.equal('Started C\nStarted D\nFinished C\nFinished D', out);
19
+ });
20
+
21
+ test(' sequential concurrent prerequisites', function () {
22
+ let out = exec(`${JAKE_CMD} -q concurrent:seqconcurrent`).toString().trim();
23
+ assert.equal('Started A\nStarted B\nFinished B\nFinished A\nStarted C\nStarted D\nFinished C\nFinished D', out);
24
+ });
25
+
26
+ test(' concurrent concurrent prerequisites', function () {
27
+ let out = exec(`${JAKE_CMD} -q concurrent:concurrentconcurrent`).toString().trim();
28
+ assert.equal('Started A\nStarted B\nStarted C\nStarted D\nFinished B\nFinished C\nFinished A\nFinished D', out);
29
+ });
30
+
31
+ test(' concurrent prerequisites with subdependency', function () {
32
+ let out = exec(`${JAKE_CMD} -q concurrent:subdep`).toString().trim();
33
+ assert.equal('Started A\nFinished A\nStarted Ba\nFinished Ba', out);
34
+ });
35
+
36
+ test(' failing in concurrent prerequisites', function () {
37
+ try {
38
+ exec(`${JAKE_CMD} -q concurrent:Cfail`);
39
+ }
40
+ catch(err) {
41
+ assert(err.message.indexOf('Command failed') > -1);
42
+ }
43
+ });
44
+
45
+ });
node_modules/jake/test/integration/file.js ADDED
@@ -0,0 +1,228 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Jake JavaScript build tool
3
+ * Copyright 2112 Matthew Eernisse (mde@fleegix.org)
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ *
17
+ */
18
+
19
+ const PROJECT_DIR = process.env.PROJECT_DIR;
20
+
21
+ let assert = require('assert');
22
+ let fs = require('fs');
23
+ let path = require('path');
24
+ let file = require(`${PROJECT_DIR}/lib/utils/file`);
25
+ let existsSync = fs.existsSync || path.existsSync;
26
+ let exec = require('child_process').execSync;
27
+
28
+ suite('fileUtils', function () {
29
+
30
+ test('mkdirP', function () {
31
+ let expected = [
32
+ ['foo'],
33
+ ['foo', 'bar'],
34
+ ['foo', 'bar', 'baz'],
35
+ ['foo', 'bar', 'baz', 'qux']
36
+ ];
37
+ file.mkdirP('foo/bar/baz/qux');
38
+ let res = exec('find foo').toString().trim().split('\n');
39
+ for (let i = 0, ii = res.length; i < ii; i++) {
40
+ assert.equal(path.join.apply(path, expected[i]), res[i]);
41
+ }
42
+ file.rmRf('foo');
43
+ });
44
+
45
+ test('rmRf', function () {
46
+ file.mkdirP('foo/bar/baz/qux');
47
+ file.rmRf('foo/bar');
48
+ let res = exec('find foo').toString().trim().split('\n');
49
+ assert.equal(1, res.length);
50
+ assert.equal('foo', res[0]);
51
+ fs.rmdirSync('foo');
52
+ });
53
+
54
+ test('rmRf with symlink subdir', function () {
55
+ file.mkdirP('foo');
56
+ file.mkdirP('bar');
57
+ fs.writeFileSync('foo/hello.txt', 'hello, it\'s me');
58
+ fs.symlinkSync('../foo', 'bar/foo'); file.rmRf('bar');
59
+
60
+ // Make sure the bar directory was successfully deleted
61
+ let barDeleted = false;
62
+ try {
63
+ fs.statSync('bar');
64
+ } catch(err) {
65
+ if(err.code == 'ENOENT') {
66
+ barDeleted = true;
67
+ }
68
+ }
69
+ assert.equal(true, barDeleted);
70
+
71
+ // Make sure that the file inside the linked folder wasn't deleted
72
+ let res = fs.readdirSync('foo');
73
+ assert.equal(1, res.length);
74
+ assert.equal('hello.txt', res[0]);
75
+
76
+ // Cleanup
77
+ fs.unlinkSync('foo/hello.txt');
78
+ fs.rmdirSync('foo');
79
+ });
80
+
81
+ test('rmRf with symlinked dir', function () {
82
+ file.mkdirP('foo');
83
+ fs.writeFileSync('foo/hello.txt', 'hello!');
84
+ fs.symlinkSync('foo', 'bar');
85
+ file.rmRf('bar');
86
+
87
+ // Make sure the bar directory was successfully deleted
88
+ let barDeleted = false;
89
+ try {
90
+ fs.statSync('bar');
91
+ } catch(err) {
92
+ if(err.code == 'ENOENT') {
93
+ barDeleted = true;
94
+ }
95
+ }
96
+ assert.equal(true, barDeleted);
97
+
98
+ // Make sure that the file inside the linked folder wasn't deleted
99
+ let res = fs.readdirSync('foo');
100
+ assert.equal(1, res.length);
101
+ assert.equal('hello.txt', res[0]);
102
+
103
+ // Cleanup
104
+ fs.unlinkSync('foo/hello.txt');
105
+ fs.rmdirSync('foo');
106
+ });
107
+
108
+ test('cpR with same name and different directory', function () {
109
+ file.mkdirP('foo');
110
+ fs.writeFileSync('foo/bar.txt', 'w00t');
111
+ file.cpR('foo', 'bar');
112
+ assert.ok(existsSync('bar/bar.txt'));
113
+ file.rmRf('foo');
114
+ file.rmRf('bar');
115
+ });
116
+
117
+ test('cpR with same to and from will throw', function () {
118
+ assert.throws(function () {
119
+ file.cpR('foo.txt', 'foo.txt');
120
+ });
121
+ });
122
+
123
+ test('cpR rename via copy in directory', function () {
124
+ file.mkdirP('foo');
125
+ fs.writeFileSync('foo/bar.txt', 'w00t');
126
+ file.cpR('foo/bar.txt', 'foo/baz.txt');
127
+ assert.ok(existsSync('foo/baz.txt'));
128
+ file.rmRf('foo');
129
+ });
130
+
131
+ test('cpR rename via copy in base', function () {
132
+ fs.writeFileSync('bar.txt', 'w00t');
133
+ file.cpR('bar.txt', 'baz.txt');
134
+ assert.ok(existsSync('baz.txt'));
135
+ file.rmRf('bar.txt');
136
+ file.rmRf('baz.txt');
137
+ });
138
+
139
+ test('cpR keeps file mode', function () {
140
+ fs.writeFileSync('bar.txt', 'w00t', {mode: 0o750});
141
+ fs.writeFileSync('bar1.txt', 'w00t!', {mode: 0o744});
142
+ file.cpR('bar.txt', 'baz.txt');
143
+ file.cpR('bar1.txt', 'baz1.txt');
144
+
145
+ assert.ok(existsSync('baz.txt'));
146
+ assert.ok(existsSync('baz1.txt'));
147
+ let bazStat = fs.statSync('baz.txt');
148
+ let bazStat1 = fs.statSync('baz1.txt');
149
+ assert.equal(0o750, bazStat.mode & 0o7777);
150
+ assert.equal(0o744, bazStat1.mode & 0o7777);
151
+
152
+ file.rmRf('bar.txt');
153
+ file.rmRf('baz.txt');
154
+ file.rmRf('bar1.txt');
155
+ file.rmRf('baz1.txt');
156
+ });
157
+
158
+ test('cpR keeps file mode when overwriting with preserveMode', function () {
159
+ fs.writeFileSync('bar.txt', 'w00t', {mode: 0o755});
160
+ fs.writeFileSync('baz.txt', 'w00t!', {mode: 0o744});
161
+ file.cpR('bar.txt', 'baz.txt', {silent: true, preserveMode: true});
162
+
163
+ assert.ok(existsSync('baz.txt'));
164
+ let bazStat = fs.statSync('baz.txt');
165
+ assert.equal(0o755, bazStat.mode & 0o777);
166
+
167
+ file.rmRf('bar.txt');
168
+ file.rmRf('baz.txt');
169
+ });
170
+
171
+ test('cpR does not keep file mode when overwriting', function () {
172
+ fs.writeFileSync('bar.txt', 'w00t', {mode: 0o766});
173
+ fs.writeFileSync('baz.txt', 'w00t!', {mode: 0o744});
174
+ file.cpR('bar.txt', 'baz.txt');
175
+
176
+ assert.ok(existsSync('baz.txt'));
177
+ let bazStat = fs.statSync('baz.txt');
178
+ assert.equal(0o744, bazStat.mode & 0o777);
179
+
180
+ file.rmRf('bar.txt');
181
+ file.rmRf('baz.txt');
182
+ });
183
+
184
+ test('cpR copies file mode recursively', function () {
185
+ fs.mkdirSync('foo');
186
+ fs.writeFileSync('foo/bar.txt', 'w00t', {mode: 0o740});
187
+ file.cpR('foo', 'baz');
188
+
189
+ assert.ok(existsSync('baz'));
190
+ let barStat = fs.statSync('baz/bar.txt');
191
+ assert.equal(0o740, barStat.mode & 0o777);
192
+
193
+ file.rmRf('foo');
194
+ file.rmRf('baz');
195
+ });
196
+
197
+ test('cpR keeps file mode recursively', function () {
198
+ fs.mkdirSync('foo');
199
+ fs.writeFileSync('foo/bar.txt', 'w00t', {mode: 0o740});
200
+ fs.mkdirSync('baz');
201
+ fs.mkdirSync('baz/foo');
202
+ fs.writeFileSync('baz/foo/bar.txt', 'w00t!', {mode: 0o755});
203
+ file.cpR('foo', 'baz', {silent: true, preserveMode: true});
204
+
205
+ assert.ok(existsSync('baz'));
206
+ let barStat = fs.statSync('baz/foo/bar.txt');
207
+ assert.equal(0o740, barStat.mode & 0o777);
208
+
209
+ file.rmRf('foo');
210
+ file.rmRf('baz');
211
+ });
212
+
213
+ test('cpR copies directory mode recursively', function () {
214
+ fs.mkdirSync('foo', 0o755);
215
+ fs.mkdirSync('foo/bar', 0o700);
216
+ file.cpR('foo', 'bar');
217
+
218
+ assert.ok(existsSync('foo'));
219
+ let fooBarStat = fs.statSync('bar/bar');
220
+ assert.equal(0o700, fooBarStat.mode & 0o777);
221
+
222
+ file.rmRf('foo');
223
+ file.rmRf('bar');
224
+ });
225
+
226
+ });
227
+
228
+
node_modules/jake/test/integration/file_task.js ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Jake JavaScript build tool
3
+ * Copyright 2112 Matthew Eernisse (mde@fleegix.org)
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ *
17
+ */
18
+
19
+ const PROJECT_DIR = process.env.PROJECT_DIR;
20
+ const JAKE_CMD = `${PROJECT_DIR}/bin/cli.js`;
21
+
22
+ let assert = require('assert');
23
+ let fs = require('fs');
24
+ let exec = require('child_process').execSync;
25
+ let { rmRf } = require(`${PROJECT_DIR}/lib/jake`);
26
+
27
+ let cleanUpAndNext = function (callback) {
28
+ rmRf('./foo', {
29
+ silent: true
30
+ });
31
+ callback && callback();
32
+ };
33
+
34
+ suite('fileTask', function () {
35
+ this.timeout(7000);
36
+
37
+ setup(function () {
38
+ cleanUpAndNext();
39
+ });
40
+
41
+ test('where a file-task prereq does not change with --always-make', function () {
42
+ let out;
43
+ out = exec(`${JAKE_CMD} -q fileTest:foo/from-src1.txt`).toString().trim();
44
+ assert.equal('fileTest:foo/src1.txt task\nfileTest:foo/from-src1.txt task',
45
+ out);
46
+ out = exec(`${JAKE_CMD} -q -B fileTest:foo/from-src1.txt`).toString().trim();
47
+ assert.equal('fileTest:foo/src1.txt task\nfileTest:foo/from-src1.txt task',
48
+ out);
49
+ cleanUpAndNext();
50
+ });
51
+
52
+ test('concating two files', function () {
53
+ let out;
54
+ out = exec(`${JAKE_CMD} -q fileTest:foo/concat.txt`).toString().trim();
55
+ assert.equal('fileTest:foo/src1.txt task\ndefault task\nfileTest:foo/src2.txt task\n' +
56
+ 'fileTest:foo/concat.txt task', out);
57
+ // Check to see the two files got concat'd
58
+ let data = fs.readFileSync(process.cwd() + '/foo/concat.txt');
59
+ assert.equal('src1src2', data.toString());
60
+ cleanUpAndNext();
61
+ });
62
+
63
+ test('where a file-task prereq does not change', function () {
64
+ let out;
65
+ out = exec(`${JAKE_CMD} -q fileTest:foo/from-src1.txt`).toString().trim();
66
+ assert.equal('fileTest:foo/src1.txt task\nfileTest:foo/from-src1.txt task', out);
67
+ out = exec(`${JAKE_CMD} -q fileTest:foo/from-src1.txt`).toString().trim();
68
+ // Second time should be a no-op
69
+ assert.equal('', out);
70
+ cleanUpAndNext();
71
+ });
72
+
73
+ test('where a file-task prereq does change, then does not', function (next) {
74
+ exec('mkdir -p ./foo');
75
+ exec('touch ./foo/from-src1.txt');
76
+ setTimeout(() => {
77
+ fs.writeFileSync('./foo/src1.txt', '-SRC');
78
+ // Task should run the first time
79
+ let out;
80
+ out = exec(`${JAKE_CMD} -q fileTest:foo/from-src1.txt`).toString().trim();
81
+ assert.equal('fileTest:foo/from-src1.txt task', out);
82
+ // Task should not run on subsequent invocation
83
+ out = exec(`${JAKE_CMD} -q fileTest:foo/from-src1.txt`).toString().trim();
84
+ assert.equal('', out);
85
+ cleanUpAndNext(next);
86
+ }, 1000);
87
+ });
88
+
89
+ test('a preexisting file', function () {
90
+ let prereqData = 'howdy';
91
+ exec('mkdir -p ./foo');
92
+ fs.writeFileSync('foo/prereq.txt', prereqData);
93
+ let out;
94
+ out = exec(`${JAKE_CMD} -q fileTest:foo/from-prereq.txt`).toString().trim();
95
+ assert.equal('fileTest:foo/from-prereq.txt task', out);
96
+ let data = fs.readFileSync(process.cwd() + '/foo/from-prereq.txt');
97
+ assert.equal(prereqData, data.toString());
98
+ out = exec(`${JAKE_CMD} -q fileTest:foo/from-prereq.txt`).toString().trim();
99
+ // Second time should be a no-op
100
+ assert.equal('', out);
101
+ cleanUpAndNext();
102
+ });
103
+
104
+ test('a preexisting file with --always-make flag', function () {
105
+ let prereqData = 'howdy';
106
+ exec('mkdir -p ./foo');
107
+ fs.writeFileSync('foo/prereq.txt', prereqData);
108
+ let out;
109
+ out = exec(`${JAKE_CMD} -q fileTest:foo/from-prereq.txt`).toString().trim();
110
+ assert.equal('fileTest:foo/from-prereq.txt task', out);
111
+ let data = fs.readFileSync(process.cwd() + '/foo/from-prereq.txt');
112
+ assert.equal(prereqData, data.toString());
113
+ out = exec(`${JAKE_CMD} -q -B fileTest:foo/from-prereq.txt`).toString().trim();
114
+ assert.equal('fileTest:foo/from-prereq.txt task', out);
115
+ cleanUpAndNext();
116
+ });
117
+
118
+ test('nested directory-task', function () {
119
+ exec(`${JAKE_CMD} -q fileTest:foo/bar/baz/bamf.txt`);
120
+ let data = fs.readFileSync(process.cwd() + '/foo/bar/baz/bamf.txt');
121
+ assert.equal('w00t', data);
122
+ cleanUpAndNext();
123
+ });
124
+
125
+ test('partially existing prereqs', function () {
126
+ /*
127
+ dependency graph:
128
+ /-- foo/output2a.txt --\
129
+ foo -- foo/output1.txt --+ +-- output3.txt
130
+ \-- foo/output2b.txt --/
131
+ */
132
+ // build part of the prereqs
133
+ exec(`${JAKE_CMD} -q fileTest:foo/output2a.txt`);
134
+ // verify the final target gets built
135
+ exec(`${JAKE_CMD} -q fileTest:foo/output3.txt`);
136
+ let data = fs.readFileSync(process.cwd() + '/foo/output3.txt');
137
+ assert.equal('w00t', data);
138
+ cleanUpAndNext();
139
+ });
140
+ });
141
+
node_modules/jake/test/integration/helpers.js ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var exec = require('child_process').exec;
2
+
3
+ var helpers = new (function () {
4
+ var _tests;
5
+ var _names = [];
6
+ var _name;
7
+ var _callback;
8
+ var _runner = function () {
9
+ if ((_name = _names.shift())) {
10
+ console.log('Running ' + _name);
11
+ _tests[_name]();
12
+ }
13
+ else {
14
+ _callback();
15
+ }
16
+ };
17
+
18
+ this.exec = function () {
19
+ var args = Array.prototype.slice.call(arguments);
20
+ var arg;
21
+ var cmd = args.shift();
22
+ var opts = {};
23
+ var callback;
24
+ // Optional opts/callback or callback/opts
25
+ while ((arg = args.shift())) {
26
+ if (typeof arg == 'function') {
27
+ callback = arg;
28
+ }
29
+ else {
30
+ opts = arg;
31
+ }
32
+ }
33
+
34
+ cmd += ' --trace';
35
+ var execOpts = opts.execOpts ? opts.execOpts : {};
36
+ exec(cmd, execOpts, function (err, stdout, stderr) {
37
+ var out = helpers.trim(stdout);
38
+ if (err) {
39
+ if (opts.breakOnError === false) {
40
+ return callback(err);
41
+ }
42
+ else {
43
+ throw err;
44
+ }
45
+ }
46
+ if (stderr) {
47
+ callback(stderr);
48
+ }
49
+ else {
50
+ callback(out);
51
+ }
52
+ });
53
+ };
54
+
55
+ this.trim = function (s) {
56
+ var str = s || '';
57
+ return str.replace(/^\s*|\s*$/g, '');
58
+ };
59
+
60
+ this.parse = function (s) {
61
+ var str = s || '';
62
+ str = helpers.trim(str);
63
+ str = str.replace(/'/g, '"');
64
+ return JSON.parse(str);
65
+ };
66
+
67
+ this.run = function (tests, callback) {
68
+ _tests = tests;
69
+ _names = Object.keys(tests);
70
+ _callback = callback;
71
+ _runner();
72
+ };
73
+
74
+ this.next = function () {
75
+ _runner();
76
+ };
77
+
78
+ })();
79
+
80
+ module.exports = helpers;
node_modules/jake/test/integration/jakefile.js ADDED
@@ -0,0 +1,352 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ let fs = require('fs');
2
+ let Q = require('q');
3
+
4
+ desc('The default t.');
5
+ task('default', function () {
6
+ console.log('default task');
7
+ });
8
+
9
+ desc('No action.');
10
+ task({'noAction': ['default']});
11
+
12
+ desc('No action, no prereqs.');
13
+ task('noActionNoPrereqs');
14
+
15
+ desc('Top-level zerbofrangazoomy task');
16
+ task('zerbofrangazoomy', function () {
17
+ console.log('Whaaaaaaaa? Ran the zerbofrangazoomy task!');
18
+ });
19
+
20
+ desc('Task that throws');
21
+ task('throwy', function () {
22
+ let errorListener = function (err) {
23
+ console.log('Emitted');
24
+ console.log(err.toString());
25
+
26
+ jake.removeListener('error', errorListener);
27
+ };
28
+
29
+ jake.on('error', errorListener);
30
+
31
+ throw new Error('I am bad');
32
+ });
33
+
34
+ desc('Task that rejects a Promise');
35
+ task('promiseRejecter', function () {
36
+ const originalOption = jake.program.opts['allow-rejection'];
37
+
38
+ const errorListener = function (err) {
39
+ console.log(err.toString());
40
+ jake.removeListener('error', errorListener);
41
+ jake.program.opts['allow-rejection'] = originalOption; // Restore original 'allow-rejection' option
42
+ };
43
+ jake.on('error', errorListener);
44
+
45
+ jake.program.opts['allow-rejection'] = false; // Do not allow rejection so the rejection is passed to error handlers
46
+
47
+ Promise.reject('<promise rejected on purpose>');
48
+ });
49
+
50
+ desc('Accepts args and env vars.');
51
+ task('argsEnvVars', function () {
52
+ let res = {
53
+ args: arguments
54
+ , env: {
55
+ foo: process.env.foo
56
+ , baz: process.env.baz
57
+ }
58
+ };
59
+ console.log(JSON.stringify(res));
60
+ });
61
+
62
+ namespace('foo', function () {
63
+ desc('The foo:bar t.');
64
+ task('bar', function () {
65
+ if (arguments.length) {
66
+ console.log('foo:bar[' +
67
+ Array.prototype.join.call(arguments, ',') +
68
+ '] task');
69
+ }
70
+ else {
71
+ console.log('foo:bar task');
72
+ }
73
+ });
74
+
75
+ desc('The foo:baz task, calls foo:bar as a prerequisite.');
76
+ task('baz', ['foo:bar'], function () {
77
+ console.log('foo:baz task');
78
+ });
79
+
80
+ desc('The foo:qux task, calls foo:bar with cmdline args as a prerequisite.');
81
+ task('qux', ['foo:bar[asdf,qwer]'], function () {
82
+ console.log('foo:qux task');
83
+ });
84
+
85
+ desc('The foo:frang task,`invokes` foo:bar with passed args as a prerequisite.');
86
+ task('frang', function () {
87
+ let t = jake.Task['foo:bar'];
88
+ // Do args pass-through
89
+ t.invoke.apply(t, arguments);
90
+ t.on('complete', () => {
91
+ console.log('foo:frang task');
92
+ });
93
+ });
94
+
95
+ desc('The foo:zerb task, `executes` foo:bar with passed args as a prerequisite.');
96
+ task('zerb', function () {
97
+ let t = jake.Task['foo:bar'];
98
+ // Do args pass-through
99
+ t.execute.apply(t, arguments);
100
+ t.on('complete', () => {
101
+ console.log('foo:zerb task');
102
+ });
103
+ });
104
+
105
+ desc('The foo:zoobie task, has no prerequisites.');
106
+ task('zoobie', function () {
107
+ console.log('foo:zoobie task');
108
+ });
109
+
110
+ desc('The foo:voom task, run the foo:zoobie task repeatedly.');
111
+ task('voom', function () {
112
+ let t = jake.Task['foo:bar'];
113
+ t.on('complete', function () {
114
+ console.log('complete');
115
+ });
116
+ t.execute.apply(t);
117
+ t.execute.apply(t);
118
+ });
119
+
120
+ desc('The foo:asdf task, has the same prereq twice.');
121
+ task('asdf', ['foo:bar', 'foo:baz'], function () {
122
+ console.log('foo:asdf task');
123
+ });
124
+
125
+ });
126
+
127
+ namespace('bar', function () {
128
+ desc('The bar:foo task, has no prerequisites, is async, returns Promise which resolves.');
129
+ task('foo', async function () {
130
+ return new Promise((resolve, reject) => {
131
+ console.log('bar:foo task');
132
+ resolve();
133
+ });
134
+ });
135
+
136
+ desc('The bar:promise task has no prerequisites, is async, returns Q-based promise.');
137
+ task('promise', function () {
138
+ return Q()
139
+ .then(function () {
140
+ console.log('bar:promise task');
141
+ return 123654;
142
+ });
143
+ });
144
+
145
+ desc('The bar:dependOnpromise task waits for a promise based async test');
146
+ task('dependOnpromise', ['promise'], function () {
147
+ console.log('bar:dependOnpromise task saw value', jake.Task["bar:promise"].value);
148
+ });
149
+
150
+ desc('The bar:brokenPromise task is a failing Q-promise based async task.');
151
+ task('brokenPromise', function () {
152
+ return Q()
153
+ .then(function () {
154
+ throw new Error("nom nom nom");
155
+ });
156
+ });
157
+
158
+ desc('The bar:bar task, has the async bar:foo task as a prerequisite.');
159
+ task('bar', ['bar:foo'], function () {
160
+ console.log('bar:bar task');
161
+ });
162
+
163
+ });
164
+
165
+ namespace('hoge', function () {
166
+ desc('The hoge:hoge task, has no prerequisites.');
167
+ task('hoge', function () {
168
+ console.log('hoge:hoge task');
169
+ });
170
+
171
+ desc('The hoge:piyo task, has no prerequisites.');
172
+ task('piyo', function () {
173
+ console.log('hoge:piyo task');
174
+ });
175
+
176
+ desc('The hoge:fuga task, has hoge:hoge and hoge:piyo as prerequisites.');
177
+ task('fuga', ['hoge:hoge', 'hoge:piyo'], function () {
178
+ console.log('hoge:fuga task');
179
+ });
180
+
181
+ desc('The hoge:charan task, has hoge:fuga as a prerequisite.');
182
+ task('charan', ['hoge:fuga'], function () {
183
+ console.log('hoge:charan task');
184
+ });
185
+
186
+ desc('The hoge:gero task, has hoge:fuga as a prerequisite.');
187
+ task('gero', ['hoge:fuga'], function () {
188
+ console.log('hoge:gero task');
189
+ });
190
+
191
+ desc('The hoge:kira task, has hoge:charan and hoge:gero as prerequisites.');
192
+ task('kira', ['hoge:charan', 'hoge:gero'], function () {
193
+ console.log('hoge:kira task');
194
+ });
195
+
196
+ });
197
+
198
+ namespace('fileTest', function () {
199
+ directory('foo');
200
+
201
+ desc('File task, concatenating two files together');
202
+ file('foo/concat.txt', ['fileTest:foo', 'fileTest:foo/src1.txt', 'fileTest:foo/src2.txt'], function () {
203
+ console.log('fileTest:foo/concat.txt task');
204
+ let data1 = fs.readFileSync('foo/src1.txt');
205
+ let data2 = fs.readFileSync('foo/src2.txt');
206
+ fs.writeFileSync('foo/concat.txt', data1 + data2);
207
+ });
208
+
209
+ desc('File task, async creation with writeFile');
210
+ file('foo/src1.txt', function () {
211
+ return new Promise(function (resolve, reject) {
212
+ fs.writeFile('foo/src1.txt', 'src1', function (err) {
213
+ if (err) {
214
+ reject(err);
215
+ }
216
+ else {
217
+ console.log('fileTest:foo/src1.txt task');
218
+ resolve();
219
+ }
220
+ });
221
+ });
222
+ });
223
+
224
+ desc('File task, sync creation with writeFileSync');
225
+ file('foo/src2.txt', ['default'], function () {
226
+ fs.writeFileSync('foo/src2.txt', 'src2');
227
+ console.log('fileTest:foo/src2.txt task');
228
+ });
229
+
230
+ desc('File task, do not run unless the prereq file changes');
231
+ file('foo/from-src1.txt', ['fileTest:foo', 'fileTest:foo/src1.txt'], function () {
232
+ let data = fs.readFileSync('foo/src1.txt').toString();
233
+ fs.writeFileSync('foo/from-src1.txt', data);
234
+ console.log('fileTest:foo/from-src1.txt task');
235
+ });
236
+
237
+ desc('File task, run if the prereq file changes');
238
+ task('touch-prereq', function () {
239
+ fs.writeFileSync('foo/prereq.txt', 'UPDATED');
240
+ });
241
+
242
+ desc('File task, has a preexisting file (with no associated task) as a prereq');
243
+ file('foo/from-prereq.txt', ['fileTest:foo', 'foo/prereq.txt'], function () {
244
+ let data = fs.readFileSync('foo/prereq.txt');
245
+ fs.writeFileSync('foo/from-prereq.txt', data);
246
+ console.log('fileTest:foo/from-prereq.txt task');
247
+ });
248
+
249
+ directory('foo/bar/baz');
250
+
251
+ desc('Write a file in a nested subdirectory');
252
+ file('foo/bar/baz/bamf.txt', ['foo/bar/baz'], function () {
253
+ fs.writeFileSync('foo/bar/baz/bamf.txt', 'w00t');
254
+ });
255
+
256
+ file('foo/output1.txt', ['foo'], () => {
257
+ fs.writeFileSync('foo/output1.txt', 'Contents of foo/output1.txt');
258
+ });
259
+
260
+ file('foo/output2a.txt', ['foo/output1.txt'], () => {
261
+ fs.writeFileSync('foo/output2a.txt', 'Contents of foo/output2a.txt');
262
+ });
263
+
264
+ file('foo/output2b.txt', ['foo/output1.txt'], () => {
265
+ fs.writeFileSync('foo/output2b.txt', 'Contents of foo/output2b.txt');
266
+ });
267
+
268
+ file('foo/output3.txt', [ 'foo/output2a.txt', 'foo/output2b.txt'], () => {
269
+ fs.writeFileSync('foo/output3.txt', 'w00t');
270
+ });
271
+ });
272
+
273
+ task('blammo');
274
+ // Define task
275
+ task('voom', ['blammo'], function () {
276
+ console.log(this.prereqs.length);
277
+ });
278
+
279
+ // Modify, add a prereq
280
+ task('voom', ['noActionNoPrereqs']);
281
+
282
+ namespace('vronk', function () {
283
+ task('groo', function () {
284
+ let t = jake.Task['vronk:zong'];
285
+ t.addListener('error', function (e) {
286
+ console.log(e.message);
287
+ });
288
+ t.invoke();
289
+ });
290
+ task('zong', function () {
291
+ throw new Error('OMFGZONG');
292
+ });
293
+ });
294
+
295
+ // define namespace
296
+ namespace('one', function () {
297
+ task('one', function () {
298
+ console.log('one:one');
299
+ });
300
+ });
301
+
302
+ // modify namespace (add task)
303
+ namespace('one', function () {
304
+ task('two', ['one:one'], function () {
305
+ console.log('one:two');
306
+ });
307
+ });
308
+
309
+ task('selfdepconst', [], function () {
310
+ task('selfdep', ['selfdep'], function () {
311
+ console.log("I made a task that depends on itself");
312
+ });
313
+ });
314
+ task('selfdepdyn', function () {
315
+ task('selfdeppar', [], {concurrency: 2}, function () {
316
+ console.log("I will depend on myself and will fail at runtime");
317
+ });
318
+ task('selfdeppar', ['selfdeppar']);
319
+ jake.Task['selfdeppar'].invoke();
320
+ });
321
+
322
+ namespace("large", function () {
323
+ task("leaf", function () {
324
+ console.log("large:leaf");
325
+ });
326
+
327
+ const same = [];
328
+ for (let i = 0; i < 2000; i++) {
329
+ same.push("leaf");
330
+ }
331
+
332
+ desc("Task with a large number of same prereqs");
333
+ task("same", same, { concurrency: 2 }, function () {
334
+ console.log("large:same");
335
+ });
336
+
337
+ const different = [];
338
+ for (let i = 0; i < 2000; i++) {
339
+ const name = "leaf-" + i;
340
+ task(name, function () {
341
+ if (name === "leaf-12" || name === "leaf-123") {
342
+ console.log(name);
343
+ }
344
+ });
345
+ different.push(name);
346
+ }
347
+
348
+ desc("Task with a large number of different prereqs");
349
+ task("different", different, { concurrency: 2 } , function () {
350
+ console.log("large:different");
351
+ });
352
+ });
node_modules/jake/test/integration/jakelib/concurrent.jake.js ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ namespace('concurrent', function () {
3
+ task('A', function () {
4
+ console.log('Started A');
5
+ return new Promise((resolve, reject) => {
6
+ setTimeout(() => {
7
+ console.log('Finished A');
8
+ resolve();
9
+ }, 200);
10
+ });
11
+ });
12
+
13
+ task('B', function () {
14
+ console.log('Started B');
15
+ return new Promise((resolve, reject) => {
16
+ setTimeout(() => {
17
+ console.log('Finished B');
18
+ resolve();
19
+ }, 50);
20
+ });
21
+ });
22
+
23
+ task('C', function () {
24
+ console.log('Started C');
25
+ return new Promise((resolve, reject) => {
26
+ setTimeout(() => {
27
+ console.log('Finished C');
28
+ resolve();
29
+ }, 100);
30
+ });
31
+ });
32
+
33
+ task('D', function () {
34
+ console.log('Started D');
35
+ return new Promise((resolve, reject) => {
36
+ setTimeout(() => {
37
+ console.log('Finished D');
38
+ resolve();
39
+ }, 300);
40
+ });
41
+ });
42
+
43
+ task('Ba', ['A'], function () {
44
+ console.log('Started Ba');
45
+ return new Promise((resolve, reject) => {
46
+ setTimeout(() => {
47
+ console.log('Finished Ba');
48
+ resolve();
49
+ }, 50);
50
+ });
51
+ });
52
+
53
+ task('Afail', function () {
54
+ console.log('Started failing task');
55
+ return new Promise((resolve, reject) => {
56
+ setTimeout(() => {
57
+ console.log('Failing B with error');
58
+ throw new Error('I failed');
59
+ }, 50);
60
+ });
61
+ });
62
+
63
+ task('simple1', ['A','B'], {concurrency: 2}, function () {
64
+ return new Promise((resolve, reject) => {
65
+ setTimeout(() => {
66
+ resolve();
67
+ }, 50);
68
+ });
69
+ });
70
+
71
+ task('simple2', ['C','D'], {concurrency: 2}, function () {
72
+ return new Promise((resolve, reject) => {
73
+ setTimeout(() => {
74
+ resolve();
75
+ }, 50);
76
+ });
77
+ });
78
+
79
+ task('seqconcurrent', ['simple1','simple2'], function () {
80
+ return new Promise((resolve, reject) => {
81
+ setTimeout(() => {
82
+ resolve();
83
+ }, 50);
84
+ });
85
+ });
86
+
87
+ task('concurrentconcurrent', ['simple1','simple2'], {concurrency: 2}, function () {
88
+ return new Promise((resolve, reject) => {
89
+ setTimeout(() => {
90
+ resolve();
91
+ }, 50);
92
+ });
93
+ });
94
+
95
+ task('subdep', ['A','Ba'], {concurrency: 2}, function () {
96
+ return new Promise((resolve, reject) => {
97
+ setTimeout(() => {
98
+ resolve();
99
+ }, 50);
100
+ });
101
+ });
102
+
103
+ task('fail', ['A', 'B', 'Afail'], {concurrency: 3}, function () {
104
+ return new Promise((resolve, reject) => {
105
+ setTimeout(() => {
106
+ resolve();
107
+ }, 50);
108
+ });
109
+ });
110
+
111
+ });
112
+
113
+
node_modules/jake/test/integration/jakelib/publish.jake.js ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Jake JavaScript build tool
3
+ * Copyright 2112 Matthew Eernisse (mde@fleegix.org)
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ *
17
+ */
18
+
19
+ const PROJECT_DIR = process.env.PROJECT_DIR;
20
+
21
+ let fs = require('fs');
22
+ let { publishTask, rmRf, mkdirP } = require(`${PROJECT_DIR}/lib/jake`);
23
+
24
+ fs.writeFileSync('package.json', '{"version": "0.0.1"}');
25
+ mkdirP('tmp_publish');
26
+ fs.writeFileSync('tmp_publish/foo.txt', 'FOO');
27
+
28
+ publishTask('zerb', function () {
29
+ this.packageFiles.include([
30
+ 'package.json'
31
+ , 'tmp_publish/**'
32
+ ]);
33
+ this.publishCmd = 'node -p -e "\'%filename\'"';
34
+ this.gitCmd = 'echo';
35
+ this.scheduleDelay = 0;
36
+
37
+ this._ensureRepoClean = function () {};
38
+ this._getCurrentBranch = function () {
39
+ return 'v0.0';
40
+ };
41
+ });
42
+
43
+ jake.setTaskTimeout(5000);
44
+
45
+ jake.Task['publish'].on('complete', function () {
46
+ rmRf('tmp_publish', {silent: true});
47
+ rmRf('package.json', {silent: true});
48
+ });
49
+
node_modules/jake/test/integration/jakelib/required_module.jake.js ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ let { task, namespace } = require(`${process.env.PROJECT_DIR}/lib/jake`);
2
+
3
+ namespace('usingRequire', function () {
4
+ task('test', () => {
5
+ console.log('howdy test');
6
+ });
7
+ });
8
+
9
+
10
+
node_modules/jake/test/integration/jakelib/rule.jake.js ADDED
@@ -0,0 +1,222 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Jake JavaScript build tool
3
+ * Copyright 2112 Matthew Eernisse (mde@fleegix.org)
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ *
17
+ */
18
+
19
+ const PROJECT_DIR = process.env.PROJECT_DIR;
20
+
21
+ let exec = require('child_process').execSync;
22
+ let fs = require('fs');
23
+ let util = require('util');
24
+ let { rule, rmRf } = require(`${PROJECT_DIR}/lib/jake`);
25
+
26
+ directory('tmpsrc');
27
+ directory('tmpbin');
28
+
29
+ ////////////////////////////////////////////////////////////
30
+ // Simple Suffix Rule
31
+ file('tmp', ['tmp_init', 'tmp_dep1.o', 'tmp_dep2.o'], function (params) {
32
+ console.log('tmp task');
33
+ let data1 = fs.readFileSync('tmp_dep1.o');
34
+ let data2 = fs.readFileSync('tmp_dep2.o');
35
+ fs.writeFileSync('tmp', data1 + data2);
36
+ });
37
+
38
+ rule('.o', '.c', function () {
39
+ let cmd = util.format('cp %s %s', this.source, this.name);
40
+ console.log(cmd + ' task');
41
+ exec(cmd);
42
+ });
43
+
44
+ file('tmp_dep1.c', function () {
45
+ fs.writeFileSync('tmp_dep1.c', 'src_1');
46
+ console.log('tmp_dep1.c task');
47
+ });
48
+
49
+ // note that tmp_dep2.o depends on tmp_dep2.c, which is a
50
+ // static file.
51
+ task('tmp_init', function () {
52
+ fs.writeFileSync('tmp_dep2.c', 'src_2');
53
+ console.log('tmp_dep2.c task');
54
+ });
55
+ ////////////////////////////////////////////////////////////
56
+
57
+ ////////////////////////////////////////////////////////////
58
+ // Pattern Rule
59
+ file('tmp_p', ['tmp_init', 'tmp_dep1.oo', 'tmp_dep2.oo'], function (params) {
60
+ console.log('tmp pattern task');
61
+ let data1 = fs.readFileSync('tmp_dep1.oo');
62
+ let data2 = fs.readFileSync('tmp_dep2.oo');
63
+ fs.writeFileSync('tmp_p', data1 + data2 + ' pattern');
64
+ });
65
+
66
+ rule('%.oo', '%.c', function () {
67
+ let cmd = util.format('cp %s %s', this.source, this.name);
68
+ console.log(cmd + ' task');
69
+ exec(cmd);
70
+ });
71
+ ////////////////////////////////////////////////////////////
72
+
73
+ ////////////////////////////////////////////////////////////
74
+ // Pattern Rule with Folder
75
+ // i.e. rule('tmpbin/%.oo', 'tmpsrc/%.c', ...
76
+ file('tmp_pf', [
77
+ 'tmp_src_init'
78
+ , 'tmpbin'
79
+ , 'tmpbin/tmp_dep1.oo'
80
+ , 'tmpbin/tmp_dep2.oo' ], function (params) {
81
+ console.log('tmp pattern folder task');
82
+ let data1 = fs.readFileSync('tmpbin/tmp_dep1.oo');
83
+ let data2 = fs.readFileSync('tmpbin/tmp_dep2.oo');
84
+ fs.writeFileSync('tmp_pf', data1 + data2 + ' pattern folder');
85
+ });
86
+
87
+ rule('tmpbin/%.oo', 'tmpsrc/%.c', function () {
88
+ let cmd = util.format('cp %s %s', this.source, this.name);
89
+ console.log(cmd + ' task');
90
+ exec(cmd);
91
+ });
92
+
93
+ file('tmpsrc/tmp_dep2.c',['tmpsrc'], function () {
94
+ fs.writeFileSync('tmpsrc/tmp_dep2.c', 'src/src_2');
95
+ console.log('tmpsrc/tmp_dep2.c task');
96
+ });
97
+
98
+ // Create static files in folder tmpsrc.
99
+ task('tmp_src_init', ['tmpsrc'], function () {
100
+ fs.writeFileSync('tmpsrc/tmp_dep1.c', 'src/src_1');
101
+ console.log('tmpsrc/tmp_dep1.c task');
102
+ });
103
+ ////////////////////////////////////////////////////////////
104
+
105
+
106
+ ////////////////////////////////////////////////////////////
107
+ // Namespace Test. This is a Mixed Test.
108
+ // Test for
109
+ // - rules belonging to different namespace.
110
+ // - rules with folder and pattern
111
+ task('tmp_ns', [
112
+ 'tmpbin'
113
+ , 'rule:init'
114
+ , 'tmpbin/tmp_dep2.oo' // *** This relies on a rule defined before.
115
+ , 'rule:tmpbin/dep1.oo'
116
+ , 'rule:tmpbin/file2.oo' ], function () {
117
+ console.log('tmp pattern folder namespace task');
118
+ let data1 = fs.readFileSync('tmpbin/dep1.oo');
119
+ let data2 = fs.readFileSync('tmpbin/tmp_dep2.oo');
120
+ let data3 = fs.readFileSync('tmpbin/file2.oo');
121
+ fs.writeFileSync('tmp_ns', data1 + data2 + data3 + ' pattern folder namespace');
122
+ });
123
+
124
+ namespace('rule', function () {
125
+ task('init', ['tmpsrc'], function () {
126
+ fs.writeFileSync('tmpsrc/file2.c', 'src/src_3');
127
+ console.log('tmpsrc/file2.c init task');
128
+ });
129
+
130
+ file('tmpsrc/dep1.c',['tmpsrc'], function () {
131
+ fs.writeFileSync('tmpsrc/dep1.c', 'src/src_1');
132
+ console.log('tmpsrc/dep1.c task');
133
+ }, {async: true});
134
+
135
+ rule('tmpbin/%.oo', 'tmpsrc/%.c', function () {
136
+ let cmd = util.format('cp %s %s', this.source, this.name);
137
+ console.log(cmd + ' ns task');
138
+ exec(cmd);
139
+ });
140
+ });
141
+ ////////////////////////////////////////////////////////////
142
+
143
+ ////////////////////////////////////////////////////////////
144
+ // Chain rule
145
+ // rule('tmpbin/%.pdf', 'tmpbin/%.dvi', function() { ...
146
+ // rule('tmpbin/%.dvi', 'tmpsrc/%.tex', ['tmpbin'], function() { ...
147
+ task('tmp_cr', [
148
+ 'chainrule:init'
149
+ , 'chainrule:tmpbin/file1.pdf'
150
+ , 'chainrule:tmpbin/file2.pdf' ], function () {
151
+ console.log('tmp chainrule namespace task');
152
+ let data1 = fs.readFileSync('tmpbin/file1.pdf');
153
+ let data2 = fs.readFileSync('tmpbin/file2.pdf');
154
+ fs.writeFileSync('tmp_cr', data1 + data2 + ' chainrule namespace');
155
+ });
156
+
157
+ namespace('chainrule', function () {
158
+ task('init', ['tmpsrc', 'tmpbin'], function () {
159
+ fs.writeFileSync('tmpsrc/file1.tex', 'tex1 ');
160
+ fs.writeFileSync('tmpsrc/file2.tex', 'tex2 ');
161
+ console.log('chainrule init task');
162
+ });
163
+
164
+ rule('tmpbin/%.pdf', 'tmpbin/%.dvi', function () {
165
+ let cmd = util.format('cp %s %s', this.source, this.name);
166
+ console.log(cmd + ' dvi->pdf task');
167
+ exec(cmd);
168
+ });
169
+
170
+ rule('tmpbin/%.dvi', 'tmpsrc/%.tex', ['tmpbin'], function () {
171
+ let cmd = util.format('cp %s %s', this.source, this.name);
172
+ console.log(cmd + ' tex->dvi task');
173
+ exec(cmd);
174
+ });
175
+ });
176
+ ////////////////////////////////////////////////////////////
177
+ namespace('precedence', function () {
178
+ task('test', ['foo.html'], function () {
179
+ console.log('ran test');
180
+ });
181
+
182
+ rule('.html', '.txt', function () {
183
+ console.log('created html');
184
+ let data = fs.readFileSync(this.source);
185
+ fs.writeFileSync(this.name, data.toString());
186
+ });
187
+ });
188
+
189
+ namespace('regexPattern', function () {
190
+ task('test', ['foo.html'], function () {
191
+ console.log('ran test');
192
+ });
193
+
194
+ rule(/\.html$/, '.txt', function () {
195
+ console.log('created html');
196
+ let data = fs.readFileSync(this.source);
197
+ fs.writeFileSync(this.name, data.toString());
198
+ });
199
+ });
200
+
201
+ namespace('sourceFunction', function () {
202
+
203
+ let srcFunc = function (taskName) {
204
+ return taskName.replace(/\.[^.]+$/, '.txt');
205
+ };
206
+
207
+ task('test', ['foo.html'], function () {
208
+ console.log('ran test');
209
+ });
210
+
211
+ rule('.html', srcFunc, function () {
212
+ console.log('created html');
213
+ let data = fs.readFileSync(this.source);
214
+ fs.writeFileSync(this.name, data.toString());
215
+ });
216
+ });
217
+
218
+ ////////////////////////////////////////////////////////////
219
+ task('clean', function () {
220
+ rmRf('./foo');
221
+ rmRf('./tmp');
222
+ });
node_modules/jake/test/integration/list_tasks.js ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const PROJECT_DIR = process.env.PROJECT_DIR;
2
+ const JAKE_CMD = `${PROJECT_DIR}/bin/cli.js`;
3
+
4
+ let assert = require('assert');
5
+ let proc = require('child_process');
6
+
7
+ suite('listTasks', function () {
8
+ test('execute "jake -T" without any errors', function () {
9
+ let message = 'cannot run "jake -T" command';
10
+ let listTasks = function () {
11
+ proc.execFileSync(JAKE_CMD, ['-T']);
12
+ };
13
+ assert.doesNotThrow(listTasks, TypeError, message);
14
+ });
15
+ });
node_modules/jake/test/integration/publish_task.js ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ let assert = require('assert');
2
+ let exec = require('child_process').execSync;
3
+
4
+ const PROJECT_DIR = process.env.PROJECT_DIR;
5
+ const JAKE_CMD = `${PROJECT_DIR}/bin/cli.js`;
6
+
7
+ suite('publishTask', function () {
8
+
9
+ this.timeout(7000);
10
+
11
+ test('default task', function () {
12
+ let out = exec(`${JAKE_CMD} -q publish`).toString().trim();
13
+ let expected = [
14
+ 'Fetched remote tags.'
15
+ , 'On branch v0.0'
16
+ , 'Bumped version number to v0.0.2.'
17
+ , 'Created package for zerb v0.0.2'
18
+ , 'Publishing zerb v0.0.2'
19
+ , './pkg/zerb-v0.0.2.tar.gz'
20
+ , 'BOOM! Published.'
21
+ , 'Cleaned up package'
22
+ ].join('\n');
23
+ assert.equal(expected, out);
24
+ });
25
+
26
+ });
27
+
node_modules/jake/test/integration/rule.js ADDED
@@ -0,0 +1,217 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Jake JavaScript build tool
3
+ * Copyright 2112 Matthew Eernisse (mde@fleegix.org)
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ *
17
+ */
18
+
19
+ const PROJECT_DIR = process.env.PROJECT_DIR;
20
+ const JAKE_CMD = `${PROJECT_DIR}/bin/cli.js`;
21
+
22
+ let assert = require('assert');
23
+ let exec = require('child_process').execSync;
24
+ let fs = require('fs');
25
+ let { Rule } = require(`${PROJECT_DIR}/lib/rule`);
26
+ let { rmRf } = require(`${PROJECT_DIR}/lib/jake`);
27
+
28
+ let cleanUpAndNext = function (callback) {
29
+ // Gotta add globbing to file utils rmRf
30
+ let tmpFiles = [
31
+ 'tmp'
32
+ , 'tmp_ns'
33
+ , 'tmp_cr'
34
+ , 'tmp_p'
35
+ , 'tmp_pf'
36
+ , 'tmpbin'
37
+ , 'tmpsrc'
38
+ , 'tmp_dep1.c'
39
+ , 'tmp_dep1.o'
40
+ , 'tmp_dep1.oo'
41
+ , 'tmp_dep2.c'
42
+ , 'tmp_dep2.o'
43
+ , 'tmp_dep2.oo'
44
+ , 'foo'
45
+ , 'foo.html'
46
+ ];
47
+ tmpFiles.forEach(function (f) {
48
+ rmRf(f, {
49
+ silent: true
50
+ });
51
+ });
52
+ callback && callback();
53
+ };
54
+
55
+ suite('rule', function () {
56
+
57
+ this.timeout(7000);
58
+
59
+ setup(function (next) {
60
+ cleanUpAndNext(next);
61
+ });
62
+
63
+
64
+ // - name foo:bin/main.o
65
+ // - pattern bin/%.o
66
+ // - source src/%.c
67
+ //
68
+ // return {
69
+ // 'dep' : 'foo:src/main.c',
70
+ // 'file': 'src/main.c'
71
+ // };
72
+ test('Rule.getSource', function () {
73
+ let src = Rule.getSource('foo:bin/main.o', 'bin/%.o', 'src/%.c');
74
+ assert.equal('foo:src/main.c', src);
75
+ });
76
+
77
+ test('rule w/o pattern', function () {
78
+ let out = exec( `${JAKE_CMD} -q tmp`).toString().trim();
79
+ let output = [
80
+ "tmp_dep2.c task"
81
+ , "tmp_dep1.c task"
82
+ , "cp tmp_dep1.c tmp_dep1.o task"
83
+ , "cp tmp_dep2.c tmp_dep2.o task"
84
+ , "tmp task"];
85
+ assert.equal( output.join('\n'), out);
86
+ let data = fs.readFileSync(process.cwd() + '/tmp');
87
+ assert.equal('src_1src_2', data.toString());
88
+ cleanUpAndNext();
89
+ });
90
+
91
+ test('rule w pattern w/o folder w/o namespace', function () {
92
+ let out = exec( `${JAKE_CMD} -q tmp_p`).toString().trim();
93
+ let output = [
94
+ "tmp_dep2.c task"
95
+ , "tmp_dep1.c task"
96
+ , "cp tmp_dep1.c tmp_dep1.oo task"
97
+ , "cp tmp_dep2.c tmp_dep2.oo task"
98
+ , "tmp pattern task"];
99
+ let data;
100
+ assert.equal( output.join('\n'), out);
101
+ data = fs.readFileSync(process.cwd() + '/tmp_p');
102
+ assert.equal('src_1src_2 pattern', data.toString());
103
+ cleanUpAndNext();
104
+ });
105
+
106
+ test('rule w pattern w folder w/o namespace', function () {
107
+ let out = exec( `${JAKE_CMD} -q tmp_pf`).toString().trim();
108
+ let output = [
109
+ "tmpsrc/tmp_dep1.c task"
110
+ , "cp tmpsrc/tmp_dep1.c tmpbin/tmp_dep1.oo task"
111
+ , "tmpsrc/tmp_dep2.c task"
112
+ , "cp tmpsrc/tmp_dep2.c tmpbin/tmp_dep2.oo task"
113
+ , "tmp pattern folder task"];
114
+ let data;
115
+ assert.equal( output.join('\n'), out);
116
+ data = fs.readFileSync(process.cwd() + '/tmp_pf');
117
+ assert.equal('src/src_1src/src_2 pattern folder', data.toString());
118
+ cleanUpAndNext();
119
+ });
120
+
121
+ test.skip('rule w pattern w folder w namespace', function () {
122
+ let out = exec( `${JAKE_CMD} -q tmp_ns`).toString().trim();
123
+ let output = [
124
+ "tmpsrc/file2.c init task" // yes
125
+ , "tmpsrc/tmp_dep2.c task" // no
126
+ , "cp tmpsrc/tmp_dep2.c tmpbin/tmp_dep2.oo task" // no
127
+ , "tmpsrc/dep1.c task" // no
128
+ , "cp tmpsrc/dep1.c tmpbin/dep1.oo ns task" // no
129
+ , "cp tmpsrc/file2.c tmpbin/file2.oo ns task" // yes
130
+ , "tmp pattern folder namespace task"]; // yes
131
+ let data;
132
+ assert.equal( output.join('\n'), out);
133
+ data = fs.readFileSync(process.cwd() + '/tmp_ns');
134
+ assert.equal('src/src_1src/src_2src/src_3 pattern folder namespace', data.toString());
135
+ cleanUpAndNext();
136
+ });
137
+
138
+ test.skip('rule w chain w pattern w folder w namespace', function () {
139
+ let out = exec( `${JAKE_CMD} -q tmp_cr`).toString().trim();
140
+ let output = [
141
+ "chainrule init task"
142
+ , "cp tmpsrc/file1.tex tmpbin/file1.dvi tex->dvi task"
143
+ , "cp tmpbin/file1.dvi tmpbin/file1.pdf dvi->pdf task"
144
+ , "cp tmpsrc/file2.tex tmpbin/file2.dvi tex->dvi task"
145
+ , "cp tmpbin/file2.dvi tmpbin/file2.pdf dvi->pdf task"
146
+ , "tmp chainrule namespace task"];
147
+ let data;
148
+ assert.equal( output.join('\n'), out);
149
+ data = fs.readFileSync(process.cwd() + '/tmp_cr');
150
+ assert.equal('tex1 tex2 chainrule namespace', data.toString());
151
+ cleanUpAndNext();
152
+ });
153
+
154
+
155
+ ['precedence', 'regexPattern', 'sourceFunction'].forEach(function (key) {
156
+
157
+ test('rule with source file not created yet (' + key + ')', function () {
158
+ let write = process.stderr.write;
159
+ process.stderr.write = () => {};
160
+ rmRf('foo.txt', {silent: true});
161
+ rmRf('foo.html', {silent: true});
162
+ try {
163
+ exec(`${JAKE_CMD} ` + key + ':test');
164
+ }
165
+ catch(err) {
166
+ // foo.txt prereq doesn't exist yet
167
+ assert.ok(err.message.indexOf('Unknown task "foo.html"') > -1);
168
+ }
169
+ process.stderr.write = write;
170
+ });
171
+
172
+ test('rule with source file now created (' + key + ')', function () {
173
+ fs.writeFileSync('foo.txt', '');
174
+ let out = exec(`${JAKE_CMD} -q ` + key + ':test').toString().trim();
175
+ // Should run prereq and test task
176
+ let output = [
177
+ 'created html'
178
+ , 'ran test'
179
+ ];
180
+ assert.equal(output.join('\n'), out);
181
+ });
182
+
183
+ test('rule with source file modified (' + key + ')', function (next) {
184
+ setTimeout(function () {
185
+ fs.writeFileSync('foo.txt', '');
186
+ let out = exec(`${JAKE_CMD} -q ` + key + ':test').toString().trim();
187
+ // Should again run both prereq and test task
188
+ let output = [
189
+ 'created html'
190
+ , 'ran test'
191
+ ];
192
+ assert.equal(output.join('\n'), out);
193
+ //next();
194
+ cleanUpAndNext(next);
195
+ }, 1000); // Wait to do the touch to ensure mod-time is different
196
+ });
197
+
198
+ test('rule with existing objective file and no source ' +
199
+ ' (should be normal file-task) (' + key + ')', function () {
200
+ // Remove just the source file
201
+ fs.writeFileSync('foo.html', '');
202
+ rmRf('foo.txt', {silent: true});
203
+ let out = exec(`${JAKE_CMD} -q ` + key + ':test').toString().trim();
204
+ // Should treat existing objective file as plain file-task,
205
+ // and just run test-task
206
+ let output = [
207
+ 'ran test'
208
+ ];
209
+ assert.equal(output.join('\n'), out);
210
+ cleanUpAndNext();
211
+ });
212
+
213
+ });
214
+
215
+ });
216
+
217
+
node_modules/jake/test/integration/selfdep.js ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ let assert = require('assert');
2
+ let exec = require('child_process').execSync;
3
+
4
+ const PROJECT_DIR = process.env.PROJECT_DIR;
5
+ const JAKE_CMD = `${PROJECT_DIR}/bin/cli.js`;
6
+
7
+ suite('selfDep', function () {
8
+
9
+ this.timeout(7000);
10
+
11
+ let origStderrWrite;
12
+
13
+ setup(function () {
14
+ origStderrWrite = process.stderr.write;
15
+ process.stderr.write = function () {};
16
+ });
17
+
18
+ teardown(function () {
19
+ process.stderr.write = origStderrWrite;
20
+ });
21
+
22
+ test('self dep const', function () {
23
+ try {
24
+ exec(`${JAKE_CMD} selfdepconst`);
25
+ }
26
+ catch(e) {
27
+ assert(e.message.indexOf('dependency of itself') > -1);
28
+ }
29
+ });
30
+
31
+ test('self dep dyn', function () {
32
+ try {
33
+ exec(`${JAKE_CMD} selfdepdyn`);
34
+ }
35
+ catch(e) {
36
+ assert(e.message.indexOf('dependency of itself') > -1);
37
+ }
38
+ });
39
+
40
+ });
41
+
42
+
node_modules/jake/test/integration/task_base.js ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ let assert = require('assert');
2
+ let h = require('./helpers');
3
+ let exec = require('child_process').execSync;
4
+
5
+ const PROJECT_DIR = process.env.PROJECT_DIR;
6
+ const JAKE_CMD = `${PROJECT_DIR}/bin/cli.js`;
7
+
8
+ suite('taskBase', function () {
9
+
10
+ this.timeout(7000);
11
+
12
+ test('default task', function () {
13
+ let out;
14
+ out = exec(`${JAKE_CMD} -q`).toString().trim();
15
+ assert.equal(out, 'default task');
16
+ out = exec(`${JAKE_CMD} -q default`).toString().trim();
17
+ assert.equal(out, 'default task');
18
+ });
19
+
20
+ test('task with no action', function () {
21
+ let out = exec(`${JAKE_CMD} -q noAction`).toString().trim();
22
+ assert.equal(out, 'default task');
23
+ });
24
+
25
+ test('a task with no action and no prereqs', function () {
26
+ exec(`${JAKE_CMD} noActionNoPrereqs`);
27
+ });
28
+
29
+ test('a task that exists at the top-level, and not in the specified namespace, should error', function () {
30
+ let res = require('child_process').spawnSync(`${JAKE_CMD}`,
31
+ ['asdfasdfasdf:zerbofrangazoomy']);
32
+ let err = res.stderr.toString();
33
+ assert.ok(err.indexOf('Unknown task' > -1));
34
+ });
35
+
36
+ test('passing args to a task', function () {
37
+ let out = exec(`${JAKE_CMD} -q argsEnvVars[foo,bar]`).toString().trim();
38
+ let parsed = h.parse(out);
39
+ let args = parsed.args;
40
+ assert.equal(args[0], 'foo');
41
+ assert.equal(args[1], 'bar');
42
+ });
43
+
44
+ test('a task with environment vars', function () {
45
+ let out = exec(`${JAKE_CMD} -q argsEnvVars foo=bar baz=qux`).toString().trim();
46
+ let parsed = h.parse(out);
47
+ let env = parsed.env;
48
+ assert.equal(env.foo, 'bar');
49
+ assert.equal(env.baz, 'qux');
50
+ });
51
+
52
+ test('passing args and using environment vars', function () {
53
+ let out = exec(`${JAKE_CMD} -q argsEnvVars[foo,bar] foo=bar baz=qux`).toString().trim();
54
+ let parsed = h.parse(out);
55
+ let args = parsed.args;
56
+ let env = parsed.env;
57
+ assert.equal(args[0], 'foo');
58
+ assert.equal(args[1], 'bar');
59
+ assert.equal(env.foo, 'bar');
60
+ assert.equal(env.baz, 'qux');
61
+ });
62
+
63
+ test('a simple prereq', function () {
64
+ let out = exec(`${JAKE_CMD} -q foo:baz`).toString().trim();
65
+ assert.equal(out, 'foo:bar task\nfoo:baz task');
66
+ });
67
+
68
+ test('a duplicate prereq only runs once', function () {
69
+ let out = exec(`${JAKE_CMD} -q foo:asdf`).toString().trim();
70
+ assert.equal(out, 'foo:bar task\nfoo:baz task\nfoo:asdf task');
71
+ });
72
+
73
+ test('a prereq with command-line args', function () {
74
+ let out = exec(`${JAKE_CMD} -q foo:qux`).toString().trim();
75
+ assert.equal(out, 'foo:bar[asdf,qwer] task\nfoo:qux task');
76
+ });
77
+
78
+ test('a prereq with args via invoke', function () {
79
+ let out = exec(`${JAKE_CMD} -q foo:frang[zxcv,uiop]`).toString().trim();
80
+ assert.equal(out, 'foo:bar[zxcv,uiop] task\nfoo:frang task');
81
+ });
82
+
83
+ test('a prereq with args via execute', function () {
84
+ let out = exec(`${JAKE_CMD} -q foo:zerb[zxcv,uiop]`).toString().trim();
85
+ assert.equal(out, 'foo:bar[zxcv,uiop] task\nfoo:zerb task');
86
+ });
87
+
88
+ test('repeating the task via execute', function () {
89
+ let out = exec(`${JAKE_CMD} -q foo:voom`).toString().trim();
90
+ assert.equal(out, 'foo:bar task\nfoo:bar task\ncomplete\ncomplete');
91
+ });
92
+
93
+ test('prereq execution-order', function () {
94
+ let out = exec(`${JAKE_CMD} -q hoge:fuga`).toString().trim();
95
+ assert.equal(out, 'hoge:hoge task\nhoge:piyo task\nhoge:fuga task');
96
+ });
97
+
98
+ test('basic async task', function () {
99
+ let out = exec(`${JAKE_CMD} -q bar:bar`).toString().trim();
100
+ assert.equal(out, 'bar:foo task\nbar:bar task');
101
+ });
102
+
103
+ test('promise async task', function () {
104
+ let out = exec(`${JAKE_CMD} -q bar:dependOnpromise`).toString().trim();
105
+ assert.equal(out, 'bar:promise task\nbar:dependOnpromise task saw value 123654');
106
+ });
107
+
108
+ test('failing promise async task', function () {
109
+ try {
110
+ exec(`${JAKE_CMD} -q bar:brokenPromise`);
111
+ }
112
+ catch(e) {
113
+ assert(e.message.indexOf('Command failed') > -1);
114
+ }
115
+ });
116
+
117
+ test('that current-prereq index gets reset', function () {
118
+ let out = exec(`${JAKE_CMD} -q hoge:kira`).toString().trim();
119
+ assert.equal(out, 'hoge:hoge task\nhoge:piyo task\nhoge:fuga task\n' +
120
+ 'hoge:charan task\nhoge:gero task\nhoge:kira task');
121
+ });
122
+
123
+ test('modifying a task by adding prereq during execution', function () {
124
+ let out = exec(`${JAKE_CMD} -q voom`).toString().trim();
125
+ assert.equal(out, 2);
126
+ });
127
+
128
+ test('listening for task error-event', function () {
129
+ try {
130
+ exec(`${JAKE_CMD} -q vronk:groo`).toString().trim();
131
+ }
132
+ catch(e) {
133
+ assert(e.message.indexOf('OMFGZONG') > -1);
134
+ }
135
+ });
136
+
137
+ test('listening for jake error-event', function () {
138
+ let out = exec(`${JAKE_CMD} -q throwy`).toString().trim();
139
+ assert(out.indexOf('Emitted\nError: I am bad') > -1);
140
+ });
141
+
142
+ test('listening for jake unhandledRejection-event', function () {
143
+ let out = exec(`${JAKE_CMD} -q promiseRejecter`).toString().trim();
144
+ assert.equal(out, '<promise rejected on purpose>');
145
+ });
146
+
147
+ test('large number of same prereqs', function () {
148
+ let out = exec(`${JAKE_CMD} -q large:same`).toString().trim();
149
+ assert.equal(out, 'large:leaf\nlarge:same');
150
+ });
151
+
152
+ test('large number of different prereqs', function () {
153
+ let out = exec(`${JAKE_CMD} -q large:different`).toString().trim();
154
+ assert.equal(out, 'leaf-12\nleaf-123\nlarge:different');
155
+ });
156
+
157
+ test('large number of different prereqs', function () {
158
+ let out = exec(`${JAKE_CMD} -q usingRequire:test`).toString().trim();
159
+ assert.equal(out, 'howdy test');
160
+ });
161
+
162
+ test('modifying a namespace by adding a new task', function () {
163
+ let out = exec(`${JAKE_CMD} -q one:two`).toString().trim();
164
+ assert.equal('one:one\none:two', out);
165
+ });
166
+
167
+ });
node_modules/jake/test/unit/jakefile.js ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ task('foo', function () {
3
+ console.log('ran top-level foo');
4
+ });
5
+
6
+ task('bar', function () {
7
+ console.log('ran top-level bar');
8
+ });
9
+
10
+ task('zerb', function () {
11
+ console.log('ran zerb');
12
+ });
13
+
14
+ namespace('zooby', function () {
15
+ task('zerp', function () {});
16
+
17
+ task('derp', ['zerp'], function () {});
18
+
19
+ namespace('frang', function () {
20
+
21
+ namespace('w00t', function () {
22
+ task('bar', function () {
23
+ console.log('ran zooby:frang:w00t:bar');
24
+ });
25
+ });
26
+
27
+ task('asdf', function () {});
28
+ });
29
+
30
+ });
31
+
32
+ namespace('hurr', function () {
33
+ namespace('durr');
34
+ });
35
+
36
+