protobufjs 6.8.8 → 6.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/CHANGELOG.md +941 -921
  2. package/LICENSE +39 -39
  3. package/README.md +901 -879
  4. package/cli/LICENSE +33 -33
  5. package/cli/README.md +11 -11
  6. package/cli/index.d.ts +3 -3
  7. package/cli/index.js +3 -3
  8. package/cli/lib/tsd-jsdoc/LICENSE +20 -20
  9. package/cli/lib/tsd-jsdoc/README.md +23 -23
  10. package/cli/lib/tsd-jsdoc/plugin.js +21 -21
  11. package/cli/lib/tsd-jsdoc/publish.js +705 -693
  12. package/cli/lib/tsd-jsdoc.json +18 -18
  13. package/cli/package.json +1 -1
  14. package/cli/package.standalone.json +32 -32
  15. package/cli/pbjs.d.ts +9 -9
  16. package/cli/pbjs.js +329 -329
  17. package/cli/pbts.d.ts +9 -9
  18. package/cli/pbts.js +197 -197
  19. package/cli/targets/json-module.js +38 -38
  20. package/cli/targets/json.js +8 -8
  21. package/cli/targets/proto.js +326 -326
  22. package/cli/targets/proto2.js +10 -10
  23. package/cli/targets/proto3.js +10 -10
  24. package/cli/targets/static-module.js +29 -29
  25. package/cli/targets/static.js +702 -702
  26. package/cli/util.js +183 -183
  27. package/cli/wrappers/amd.js +7 -7
  28. package/cli/wrappers/closure.js +7 -7
  29. package/cli/wrappers/commonjs.js +7 -7
  30. package/cli/wrappers/default.js +15 -15
  31. package/cli/wrappers/es6.js +5 -5
  32. package/dist/README.md +31 -31
  33. package/dist/light/README.md +31 -31
  34. package/dist/light/protobuf.js +6058 -6032
  35. package/dist/light/protobuf.js.map +1 -1
  36. package/dist/light/protobuf.min.js +3 -3
  37. package/dist/light/protobuf.min.js.map +1 -1
  38. package/dist/minimal/README.md +31 -31
  39. package/dist/minimal/protobuf.js +1900 -1877
  40. package/dist/minimal/protobuf.js.map +1 -1
  41. package/dist/minimal/protobuf.min.js +3 -3
  42. package/dist/minimal/protobuf.min.js.map +1 -1
  43. package/dist/protobuf.js +7625 -7596
  44. package/dist/protobuf.js.map +1 -1
  45. package/dist/protobuf.min.js +3 -3
  46. package/dist/protobuf.min.js.map +1 -1
  47. package/ext/debug/README.md +4 -4
  48. package/ext/debug/index.js +71 -71
  49. package/ext/descriptor/README.md +72 -72
  50. package/ext/descriptor/index.js +1052 -1052
  51. package/ext/descriptor/test.js +54 -54
  52. package/google/LICENSE +27 -27
  53. package/google/README.md +1 -1
  54. package/google/api/annotations.proto +10 -10
  55. package/google/protobuf/descriptor.proto +286 -286
  56. package/google/protobuf/source_context.proto +7 -7
  57. package/index.d.ts +6 -6
  58. package/index.js +4 -4
  59. package/light.d.ts +2 -2
  60. package/light.js +3 -3
  61. package/minimal.d.ts +2 -2
  62. package/minimal.js +4 -4
  63. package/package-lock.json +4223 -3171
  64. package/package.json +122 -122
  65. package/scripts/changelog.js +150 -150
  66. package/scripts/postinstall.js +35 -35
  67. package/src/common.js +399 -399
  68. package/src/converter.js +293 -293
  69. package/src/decoder.js +106 -106
  70. package/src/encoder.js +100 -100
  71. package/src/enum.js +181 -181
  72. package/src/field.js +371 -371
  73. package/src/index-light.js +104 -104
  74. package/src/index-minimal.js +36 -36
  75. package/src/index.js +12 -12
  76. package/src/mapfield.js +126 -126
  77. package/src/message.js +138 -138
  78. package/src/method.js +151 -151
  79. package/src/namespace.js +433 -433
  80. package/src/object.js +200 -200
  81. package/src/oneof.js +203 -203
  82. package/src/parse.js +761 -758
  83. package/src/reader.js +411 -405
  84. package/src/reader_buffer.js +51 -44
  85. package/src/root.js +353 -351
  86. package/src/roots.js +18 -18
  87. package/src/rpc/service.js +142 -142
  88. package/src/rpc.js +36 -36
  89. package/src/service.js +167 -167
  90. package/src/tokenize.js +397 -397
  91. package/src/type.js +589 -589
  92. package/src/types.js +196 -196
  93. package/src/typescript.jsdoc +15 -15
  94. package/src/util/longbits.js +200 -200
  95. package/src/util/minimal.js +414 -414
  96. package/src/util.js +178 -178
  97. package/src/verifier.js +176 -176
  98. package/src/wrappers.js +83 -83
  99. package/src/writer.js +465 -459
  100. package/src/writer_buffer.js +85 -81
  101. package/tsconfig.json +6 -6
  102. package/cli/node_modules/os-tmpdir/index.js +0 -25
  103. package/cli/node_modules/os-tmpdir/license +0 -21
  104. package/cli/node_modules/os-tmpdir/readme.md +0 -32
  105. package/cli/node_modules/tmp/LICENSE +0 -21
  106. package/cli/node_modules/tmp/README.md +0 -314
  107. package/cli/node_modules/tmp/lib/tmp.js +0 -611
  108. package/cli/package-lock.json +0 -20
package/package.json CHANGED
@@ -1,122 +1,122 @@
1
- {
2
- "name": "protobufjs",
3
- "version": "6.8.8",
4
- "versionScheme": "~",
5
- "description": "Protocol Buffers for JavaScript (& TypeScript).",
6
- "author": "Daniel Wirtz <dcode+protobufjs@dcode.io>",
7
- "license": "BSD-3-Clause",
8
- "repository": {
9
- "type": "git",
10
- "url": "https://github.com/dcodeIO/protobuf.js.git"
11
- },
12
- "bugs": "https://github.com/dcodeIO/protobuf.js/issues",
13
- "homepage": "http://dcode.io/protobuf.js",
14
- "keywords": [
15
- "protobuf",
16
- "protocol-buffers",
17
- "serialization",
18
- "typescript"
19
- ],
20
- "main": "index.js",
21
- "types": "index.d.ts",
22
- "bin": {
23
- "pbjs": "bin/pbjs",
24
- "pbts": "bin/pbts"
25
- },
26
- "scripts": {
27
- "bench": "node bench",
28
- "build": "gulp --gulpfile scripts/gulpfile.js",
29
- "changelog": "node scripts/changelog -w",
30
- "coverage": "istanbul --config=config/istanbul.json cover node_modules/tape/bin/tape tests/*.js tests/node/*.js",
31
- "docs": "jsdoc -c config/jsdoc.json -R README.md --verbose --pedantic",
32
- "lint": "eslint **/*.js -c config/eslint.json && tslint **/*.d.ts -e **/node_modules/** -t stylish -c config/tslint.json",
33
- "pages": "node scripts/pages",
34
- "prepublish": "node scripts/prepublish",
35
- "postinstall": "node scripts/postinstall",
36
- "prof": "node bench/prof",
37
- "test": "tape -r ./lib/tape-adapter tests/*.js tests/node/*.js",
38
- "test-types": "tsc tests/comp_typescript.ts --lib es2015 --strictNullChecks --experimentalDecorators --emitDecoratorMetadata && tsc tests/data/test.js.ts --lib es2015 --noEmit --strictNullChecks && tsc tests/data/rpc.ts --lib es2015 --noEmit --strictNullChecks",
39
- "types": "node bin/pbts --main --global protobuf --out index.d.ts src/ lib/aspromise/index.js lib/base64/index.js lib/codegen/index.js lib/eventemitter/index.js lib/float/index.js lib/fetch/index.js lib/inquire/index.js lib/path/index.js lib/pool/index.js lib/utf8/index.js && npm run test-types",
40
- "make": "npm run test && npm run types && npm run build && npm run lint",
41
- "release": "npm run make && npm run changelog"
42
- },
43
- "dependencies": {
44
- "@protobufjs/aspromise": "^1.1.2",
45
- "@protobufjs/base64": "^1.1.2",
46
- "@protobufjs/codegen": "^2.0.4",
47
- "@protobufjs/eventemitter": "^1.1.0",
48
- "@protobufjs/fetch": "^1.1.0",
49
- "@protobufjs/float": "^1.0.2",
50
- "@protobufjs/inquire": "^1.1.0",
51
- "@protobufjs/path": "^1.1.2",
52
- "@protobufjs/pool": "^1.1.0",
53
- "@protobufjs/utf8": "^1.1.0",
54
- "@types/long": "^4.0.0",
55
- "@types/node": "^10.1.0",
56
- "long": "^4.0.0"
57
- },
58
- "devDependencies": {
59
- "benchmark": "^2.1.4",
60
- "browserify": "^16.2.2",
61
- "browserify-wrap": "^1.0.2",
62
- "bundle-collapser": "^1.3.0",
63
- "chalk": "^2.4.1",
64
- "escodegen": "^1.9.1",
65
- "eslint": "^4.19.1",
66
- "espree": "^3.5.4",
67
- "estraverse": "^4.2.0",
68
- "gh-pages": "^1.1.0",
69
- "git-raw-commits": "^1.3.6",
70
- "git-semver-tags": "^1.3.6",
71
- "glob": "^7.1.2",
72
- "google-protobuf": "^3.5.0",
73
- "gulp": "^4.0.0",
74
- "gulp-header": "^2.0.5",
75
- "gulp-if": "^2.0.1",
76
- "gulp-sourcemaps": "^2.6.4",
77
- "gulp-uglify": "^3.0.0",
78
- "istanbul": "^0.4.5",
79
- "jaguarjs-jsdoc": "github:dcodeIO/jaguarjs-jsdoc",
80
- "jsdoc": "^3.5.5",
81
- "minimist": "^1.2.0",
82
- "reflect-metadata": "^0.1.12",
83
- "semver": "^5.5.0",
84
- "tape": "^4.9.0",
85
- "tmp": "0.0.33",
86
- "tslint": "^5.10.0",
87
- "typescript": "^2.8.3",
88
- "uglify-js": "^3.3.25",
89
- "vinyl-buffer": "^1.0.1",
90
- "vinyl-fs": "^3.0.3",
91
- "vinyl-source-stream": "^2.0.0"
92
- },
93
- "cliDependencies": [
94
- "semver",
95
- "chalk",
96
- "glob",
97
- "jsdoc",
98
- "minimist",
99
- "tmp",
100
- "uglify-js",
101
- "espree",
102
- "escodegen",
103
- "estraverse"
104
- ],
105
- "files": [
106
- "index.js",
107
- "index.d.ts",
108
- "light.d.ts",
109
- "light.js",
110
- "minimal.d.ts",
111
- "minimal.js",
112
- "package-lock.json",
113
- "tsconfig.json",
114
- "scripts/postinstall.js",
115
- "bin/**",
116
- "cli/**",
117
- "dist/**",
118
- "ext/**",
119
- "google/**",
120
- "src/**"
121
- ]
122
- }
1
+ {
2
+ "name": "protobufjs",
3
+ "version": "6.9.0",
4
+ "versionScheme": "~",
5
+ "description": "Protocol Buffers for JavaScript (& TypeScript).",
6
+ "author": "Daniel Wirtz <dcode+protobufjs@dcode.io>",
7
+ "license": "BSD-3-Clause",
8
+ "repository": "protobufjs/protobuf.js",
9
+ "bugs": "https://github.com/dcodeIO/protobuf.js/issues",
10
+ "homepage": "http://dcode.io/protobuf.js",
11
+ "keywords": [
12
+ "protobuf",
13
+ "protocol-buffers",
14
+ "serialization",
15
+ "typescript"
16
+ ],
17
+ "main": "index.js",
18
+ "types": "index.d.ts",
19
+ "bin": {
20
+ "pbjs": "bin/pbjs",
21
+ "pbts": "bin/pbts"
22
+ },
23
+ "scripts": {
24
+ "bench": "node bench",
25
+ "build": "npm run build:bundle && npm run build:types",
26
+ "build:bundle": "gulp --gulpfile scripts/gulpfile.js",
27
+ "build:types": "node bin/pbts --main --global protobuf --out index.d.ts src/ lib/aspromise/index.js lib/base64/index.js lib/codegen/index.js lib/eventemitter/index.js lib/float/index.js lib/fetch/index.js lib/inquire/index.js lib/path/index.js lib/pool/index.js lib/utf8/index.js",
28
+ "changelog": "node scripts/changelog -w",
29
+ "coverage": "nyc tape -r ./lib/tape-adapter tests/*.js tests/node/*.js",
30
+ "docs": "jsdoc -c config/jsdoc.json -R README.md --verbose --pedantic",
31
+ "lint": "npm run lint:sources && npm run lint:types",
32
+ "lint:sources": "eslint \"**/*.js\" -c config/eslint.json",
33
+ "lint:types": "tslint \"**/*.d.ts\" -e \"**/node_modules/**\" -t stylish -c config/tslint.json",
34
+ "pages": "node scripts/pages",
35
+ "prepublish": "node scripts/prepublish",
36
+ "postinstall": "node scripts/postinstall",
37
+ "prof": "node bench/prof",
38
+ "test": "npm run test:sources && npm run test:types",
39
+ "test:sources": "tape -r ./lib/tape-adapter tests/*.js tests/node/*.js",
40
+ "test:types": "tsc tests/comp_typescript.ts --lib es2015 --strictNullChecks --experimentalDecorators --emitDecoratorMetadata && tsc tests/data/test.js.ts --lib es2015 --noEmit --strictNullChecks && tsc tests/data/rpc.ts --lib es2015 --noEmit --strictNullChecks",
41
+ "make": "npm run lint && npm run build && npm test"
42
+ },
43
+ "dependencies": {
44
+ "@protobufjs/aspromise": "^1.1.2",
45
+ "@protobufjs/base64": "^1.1.2",
46
+ "@protobufjs/codegen": "^2.0.4",
47
+ "@protobufjs/eventemitter": "^1.1.0",
48
+ "@protobufjs/fetch": "^1.1.0",
49
+ "@protobufjs/float": "^1.0.2",
50
+ "@protobufjs/inquire": "^1.1.0",
51
+ "@protobufjs/path": "^1.1.2",
52
+ "@protobufjs/pool": "^1.1.0",
53
+ "@protobufjs/utf8": "^1.1.0",
54
+ "@types/long": "^4.0.1",
55
+ "@types/node": "^13.7.0",
56
+ "long": "^4.0.0"
57
+ },
58
+ "devDependencies": {
59
+ "benchmark": "^2.1.4",
60
+ "browserify": "^16.5.0",
61
+ "browserify-wrap": "^1.0.2",
62
+ "bundle-collapser": "^1.3.0",
63
+ "chalk": "^4.0.0",
64
+ "escodegen": "^1.13.0",
65
+ "eslint": "^6.8.0",
66
+ "espree": "^6.1.2",
67
+ "estraverse": "^5.1.0",
68
+ "gh-pages": "^2.2.0",
69
+ "git-raw-commits": "^2.0.3",
70
+ "git-semver-tags": "^3.0.1",
71
+ "glob": "^7.1.6",
72
+ "google-protobuf": "^3.11.3",
73
+ "gulp": "^4.0.2",
74
+ "gulp-header": "^2.0.9",
75
+ "gulp-if": "^3.0.0",
76
+ "gulp-sourcemaps": "^2.6.5",
77
+ "gulp-uglify": "^3.0.2",
78
+ "jaguarjs-jsdoc": "github:dcodeIO/jaguarjs-jsdoc",
79
+ "jsdoc": "^3.6.3",
80
+ "minimist": "^1.2.0",
81
+ "nyc": "^15.0.0",
82
+ "reflect-metadata": "^0.1.13",
83
+ "semver": "^7.1.2",
84
+ "tape": "^4.13.0",
85
+ "tmp": "^0.1.0",
86
+ "tslint": "^5.20.1",
87
+ "typescript": "^3.7.5",
88
+ "uglify-js": "^3.7.7",
89
+ "vinyl-buffer": "^1.0.1",
90
+ "vinyl-fs": "^3.0.3",
91
+ "vinyl-source-stream": "^2.0.0"
92
+ },
93
+ "cliDependencies": [
94
+ "semver",
95
+ "chalk",
96
+ "glob",
97
+ "jsdoc",
98
+ "minimist",
99
+ "tmp",
100
+ "uglify-js",
101
+ "espree",
102
+ "escodegen",
103
+ "estraverse"
104
+ ],
105
+ "files": [
106
+ "index.js",
107
+ "index.d.ts",
108
+ "light.d.ts",
109
+ "light.js",
110
+ "minimal.d.ts",
111
+ "minimal.js",
112
+ "package-lock.json",
113
+ "tsconfig.json",
114
+ "scripts/postinstall.js",
115
+ "bin/**",
116
+ "cli/**",
117
+ "dist/**",
118
+ "ext/**",
119
+ "google/**",
120
+ "src/**"
121
+ ]
122
+ }
@@ -1,150 +1,150 @@
1
- "use strict";
2
-
3
- var path = require("path"),
4
- fs = require("fs");
5
-
6
- var gitSemverTags = require("git-semver-tags"),
7
- gitRawCommits = require("git-raw-commits"),
8
- minimist = require("minimist");
9
-
10
- var basedir = path.join(__dirname, "..");
11
- var pkg = require(basedir + "/package.json");
12
-
13
- var argv = minimist(process.argv, {
14
- alias: {
15
- tag : "t",
16
- write : "w"
17
- },
18
- string: [ "tag" ],
19
- boolean: [ "write" ],
20
- default: {
21
- tag: null,
22
- write: false
23
- }
24
- });
25
-
26
- // categories to be used in the future and regexes for lazy / older subjects
27
- var validCategories = {
28
- "Breaking": null,
29
- "Fixed": /fix|properly|prevent|correctly/i,
30
- "New": /added|initial/i,
31
- "CLI": /pbjs|pbts|CLI/,
32
- "Docs": /README/i,
33
- "Other": null
34
- };
35
- var breakingFallback = /removed|stripped|dropped/i;
36
-
37
- var repo = "https://github.com/dcodeIO/protobuf.js";
38
-
39
- gitSemverTags(function(err, tags) {
40
- if (err)
41
- throw err;
42
-
43
- var categories = {};
44
- Object.keys(validCategories).forEach(function(category) {
45
- categories[category] = [];
46
- });
47
- var output = [];
48
-
49
- var from = tags[0];
50
- var to = "HEAD";
51
- var tag;
52
- if (argv.tag) {
53
- var idx = tags.indexOf(argv.tag);
54
- if (idx < 0)
55
- throw Error("no such tag: " + argv.tag);
56
- from = tags[idx + 1];
57
- tag = to = tags[idx];
58
- } else
59
- tag = pkg.version;
60
-
61
- var commits = gitRawCommits({
62
- from: from,
63
- to: to,
64
- merges: false,
65
- format: "%B%n#%H"
66
- });
67
-
68
- commits.on("error", function(err) {
69
- throw err;
70
- });
71
-
72
- commits.on("data", function(chunk) {
73
- var message = chunk.toString("utf8").trim();
74
- var match = /#([0-9a-f]{40})$/.exec(message);
75
- var hash;
76
- if (match) {
77
- message = message.substring(0, message.length - match[1].length).trim();
78
- hash = match[1];
79
- }
80
- message.split(";").forEach(function(message) {
81
- if (/^(Merge pull request |Post-merge)/.test(message))
82
- return;
83
- var match = /^(\w+):/i.exec(message = message.trim());
84
- var category;
85
- if (match && match[1] in validCategories) {
86
- category = match[1];
87
- message = message.substring(match[1].length + 1).trim();
88
- } else {
89
- var keys = Object.keys(validCategories);
90
- for (var i = 0; i < keys.length; ++i) {
91
- var re = validCategories[keys[i]];
92
- if (re && re.test(message)) {
93
- category = keys[i];
94
- break;
95
- }
96
- }
97
- message = message.replace(/^(\w+):/i, "").trim();
98
- }
99
- if (!category) {
100
- if (breakingFallback.test(message))
101
- category = "Breaking";
102
- else
103
- category = "Other";
104
- }
105
- var nl = message.indexOf("\n");
106
- if (nl > -1)
107
- message = message.substring(0, nl).trim();
108
- if (!hash || message.length < 12)
109
- return;
110
- message = message.replace(/\[ci skip\]/, "").trim();
111
- categories[category].push({
112
- text: message,
113
- hash: hash
114
- });
115
- });
116
- });
117
-
118
- commits.on("end", function() {
119
- output.push("# [" + tag + "](" + repo + "/releases/tag/" + tag + ")\n");
120
- Object.keys(categories).forEach(function(category) {
121
- var messages = categories[category];
122
- if (!messages.length)
123
- return;
124
- output.push("\n## " + category + "\n");
125
- messages.forEach(function(message) {
126
- var text = message.text.replace(/#(\d+)/g, "[#$1](" + repo + "/issues/$1)");
127
- output.push("[:hash:](" + repo + "/commit/" + message.hash + ") " + text + "<br />\n");
128
- });
129
- });
130
- var current;
131
- try {
132
- current = fs.readFileSync(basedir + "/CHANGELOG.md").toString("utf8");
133
- } catch (e) {
134
- current = "";
135
- }
136
- var re = new RegExp("^# \\[" + tag + "\\]");
137
- if (re.test(current)) { // regenerated, replace
138
- var pos = current.indexOf("# [", 1);
139
- if (pos > -1)
140
- current = current.substring(pos).trim();
141
- else
142
- current = "";
143
- }
144
- var contents = output.join("") + "\n" + current;
145
- if (argv.write)
146
- fs.writeFileSync(basedir + "/CHANGELOG.md", contents, "utf8");
147
- else
148
- process.stdout.write(contents);
149
- });
150
- });
1
+ "use strict";
2
+
3
+ var path = require("path"),
4
+ fs = require("fs");
5
+
6
+ var gitSemverTags = require("git-semver-tags"),
7
+ gitRawCommits = require("git-raw-commits"),
8
+ minimist = require("minimist");
9
+
10
+ var basedir = path.join(__dirname, "..");
11
+ var pkg = require(basedir + "/package.json");
12
+
13
+ var argv = minimist(process.argv, {
14
+ alias: {
15
+ tag : "t",
16
+ write : "w"
17
+ },
18
+ string: [ "tag" ],
19
+ boolean: [ "write" ],
20
+ default: {
21
+ tag: null,
22
+ write: false
23
+ }
24
+ });
25
+
26
+ // categories to be used in the future and regexes for lazy / older subjects
27
+ var validCategories = {
28
+ "Breaking": null,
29
+ "Fixed": /fix|properly|prevent|correctly/i,
30
+ "New": /added|initial/i,
31
+ "CLI": /pbjs|pbts|CLI/,
32
+ "Docs": /README/i,
33
+ "Other": null
34
+ };
35
+ var breakingFallback = /removed|stripped|dropped/i;
36
+
37
+ var repo = "https://github.com/protobufjs/protobuf.js";
38
+
39
+ gitSemverTags(function(err, tags) {
40
+ if (err)
41
+ throw err;
42
+
43
+ var categories = {};
44
+ Object.keys(validCategories).forEach(function(category) {
45
+ categories[category] = [];
46
+ });
47
+ var output = [];
48
+
49
+ var from = tags[0];
50
+ var to = "HEAD";
51
+ var tag;
52
+ if (argv.tag) {
53
+ var idx = tags.indexOf(argv.tag);
54
+ if (idx < 0)
55
+ throw Error("no such tag: " + argv.tag);
56
+ from = tags[idx + 1];
57
+ tag = to = tags[idx];
58
+ } else
59
+ tag = pkg.version;
60
+
61
+ var commits = gitRawCommits({
62
+ from: from,
63
+ to: to,
64
+ merges: false,
65
+ format: "%B%n#%H"
66
+ });
67
+
68
+ commits.on("error", function(err) {
69
+ throw err;
70
+ });
71
+
72
+ commits.on("data", function(chunk) {
73
+ var message = chunk.toString("utf8").trim();
74
+ var match = /##([0-9a-f]{40})$/.exec(message);
75
+ var hash;
76
+ if (match) {
77
+ message = message.substring(0, message.length - match[1].length).trim();
78
+ hash = match[1];
79
+ }
80
+ message.split(";").forEach(function(message) {
81
+ if (/^(Merge pull request |Post-merge)/.test(message))
82
+ return;
83
+ var match = /^(\w+):/i.exec(message = message.trim());
84
+ var category;
85
+ if (match && match[1] in validCategories) {
86
+ category = match[1];
87
+ message = message.substring(match[1].length + 1).trim();
88
+ } else {
89
+ var keys = Object.keys(validCategories);
90
+ for (var i = 0; i < keys.length; ++i) {
91
+ var re = validCategories[keys[i]];
92
+ if (re && re.test(message)) {
93
+ category = keys[i];
94
+ break;
95
+ }
96
+ }
97
+ message = message.replace(/^(\w+):/i, "").trim();
98
+ }
99
+ if (!category) {
100
+ if (breakingFallback.test(message))
101
+ category = "Breaking";
102
+ else
103
+ category = "Other";
104
+ }
105
+ var nl = message.indexOf("\n");
106
+ if (nl > -1)
107
+ message = message.substring(0, nl).trim();
108
+ if (!hash || message.length < 12)
109
+ return;
110
+ message = message.replace(/\[ci skip\]/, "").trim();
111
+ categories[category].push({
112
+ text: message,
113
+ hash: hash
114
+ });
115
+ });
116
+ });
117
+
118
+ commits.on("end", function() {
119
+ output.push("## [" + tag + "](" + repo + "/releases/tag/" + tag + ")\n");
120
+ Object.keys(categories).forEach(function(category) {
121
+ var messages = categories[category];
122
+ if (!messages.length)
123
+ return;
124
+ output.push("\n### " + category + "\n");
125
+ messages.forEach(function(message) {
126
+ var text = message.text.replace(/#(\d+)/g, "[#$1](" + repo + "/issues/$1)");
127
+ output.push("[:hash:](" + repo + "/commit/" + message.hash + ") " + text + "<br />\n");
128
+ });
129
+ });
130
+ var current;
131
+ try {
132
+ current = fs.readFileSync(basedir + "/CHANGELOG.md").toString("utf8");
133
+ } catch (e) {
134
+ current = "";
135
+ }
136
+ var re = new RegExp("^## \\[" + tag + "\\]");
137
+ if (re.test(current)) { // regenerated, replace
138
+ var pos = current.indexOf("## [", 1);
139
+ if (pos > -1)
140
+ current = current.substring(pos).trim();
141
+ else
142
+ current = "";
143
+ }
144
+ var contents = output.join("") + "\n" + current;
145
+ if (argv.write)
146
+ fs.writeFileSync(basedir + "/CHANGELOG.md", contents, "utf8");
147
+ else
148
+ process.stdout.write(contents);
149
+ });
150
+ });
@@ -1,35 +1,35 @@
1
- "use strict";
2
-
3
- var path = require("path"),
4
- fs = require("fs"),
5
- pkg = require(path.join(__dirname, "..", "package.json"));
6
-
7
- // ensure that there is a node_modules folder for cli dependencies
8
- try { fs.mkdirSync(path.join(__dirname, "..", "cli", "node_modules")); } catch (e) {/**/}
9
-
10
- // check version scheme used by dependents
11
- if (!pkg.versionScheme)
12
- return;
13
-
14
- var warn = process.stderr.isTTY
15
- ? "\x1b[30m\x1b[43mWARN\x1b[0m \x1b[35m" + path.basename(process.argv[1], ".js") + "\x1b[0m"
16
- : "WARN " + path.basename(process.argv[1], ".js");
17
-
18
- var basePkg;
19
- try {
20
- basePkg = JSON.parse(fs.readFileSync(path.join(__dirname, "..", "..", "package.json")));
21
- } catch (e) {
22
- return;
23
- }
24
-
25
- [
26
- "dependencies",
27
- "devDependencies",
28
- "optionalDependencies",
29
- "peerDependencies"
30
- ]
31
- .forEach(function(check) {
32
- var version = basePkg && basePkg[check] && basePkg[check][pkg.name];
33
- if (typeof version === "string" && version.charAt(0) !== pkg.versionScheme)
34
- process.stderr.write(pkg.name + " " + warn + " " + pkg.name + "@" + version + " is configured as a dependency of " + basePkg.name + ". use " + pkg.name + "@" + pkg.versionScheme + version.substring(1) + " instead for API compatibility.\n");
35
- });
1
+ "use strict";
2
+
3
+ var path = require("path"),
4
+ fs = require("fs"),
5
+ pkg = require(path.join(__dirname, "..", "package.json"));
6
+
7
+ // ensure that there is a node_modules folder for cli dependencies
8
+ try { fs.mkdirSync(path.join(__dirname, "..", "cli", "node_modules")); } catch (e) {/**/}
9
+
10
+ // check version scheme used by dependents
11
+ if (!pkg.versionScheme)
12
+ return;
13
+
14
+ var warn = process.stderr.isTTY
15
+ ? "\x1b[30m\x1b[43mWARN\x1b[0m \x1b[35m" + path.basename(process.argv[1], ".js") + "\x1b[0m"
16
+ : "WARN " + path.basename(process.argv[1], ".js");
17
+
18
+ var basePkg;
19
+ try {
20
+ basePkg = JSON.parse(fs.readFileSync(path.join(__dirname, "..", "..", "package.json")));
21
+ } catch (e) {
22
+ return;
23
+ }
24
+
25
+ [
26
+ "dependencies",
27
+ "devDependencies",
28
+ "optionalDependencies",
29
+ "peerDependencies"
30
+ ]
31
+ .forEach(function(check) {
32
+ var version = basePkg && basePkg[check] && basePkg[check][pkg.name];
33
+ if (typeof version === "string" && version.charAt(0) !== pkg.versionScheme)
34
+ process.stderr.write(pkg.name + " " + warn + " " + pkg.name + "@" + version + " is configured as a dependency of " + basePkg.name + ". use " + pkg.name + "@" + pkg.versionScheme + version.substring(1) + " instead for API compatibility.\n");
35
+ });