protoc 1.1.3 → 21.0.0-rc2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -34
- package/assets.json +42 -0
- package/bin/protoc-linux-aarch_64 +0 -0
- package/bin/protoc-linux-x86_64 +0 -0
- package/bin/protoc-osx-aarch_64 +0 -0
- package/bin/protoc-osx-x86_64 +0 -0
- package/bin/protoc-win64.exe +0 -0
- package/include/google/protobuf/any.proto +158 -0
- package/include/google/protobuf/api.proto +208 -0
- package/include/google/protobuf/compiler/plugin.proto +183 -0
- package/include/google/protobuf/descriptor.proto +921 -0
- package/include/google/protobuf/duration.proto +116 -0
- package/include/google/protobuf/empty.proto +51 -0
- package/include/google/protobuf/field_mask.proto +245 -0
- package/include/google/protobuf/source_context.proto +48 -0
- package/include/google/protobuf/struct.proto +95 -0
- package/include/google/protobuf/timestamp.proto +147 -0
- package/include/google/protobuf/type.proto +187 -0
- package/include/google/protobuf/wrappers.proto +123 -0
- package/package.json +32 -18
- package/protoc.cjs +27 -0
- package/bin/protoc +0 -20
- package/index.js +0 -130
- package/protoc.js +0 -5
- package/scripts/postinstall.js +0 -58
- package/scripts/test.js +0 -7
package/index.js
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
const path = require("path");
|
|
2
|
-
const cp = require("child_process");
|
|
3
|
-
const fs = require("fs");
|
|
4
|
-
const protoc = require("./protoc.js");
|
|
5
|
-
const Vinyl = require("vinyl");
|
|
6
|
-
const uuid = require("uuid");
|
|
7
|
-
const mkdirp = require("mkdirp");
|
|
8
|
-
const glob = require("glob");
|
|
9
|
-
|
|
10
|
-
exports.protoc = function(args, options, callback) {
|
|
11
|
-
cp.execFile(protoc, args, options, callback);
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
exports.closure = function(files, options, callback) {
|
|
15
|
-
if (!callback) {
|
|
16
|
-
callback = options;
|
|
17
|
-
options = null;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
options.imports = options.imports || [];
|
|
21
|
-
options.outputPath = options.outputPath || "./";
|
|
22
|
-
|
|
23
|
-
const cwd = process.cwd();
|
|
24
|
-
const absoluteOutputPath = path.resolve(cwd, options.outputPath);
|
|
25
|
-
const relative = path.relative(absoluteOutputPath, cwd);
|
|
26
|
-
|
|
27
|
-
const args = [
|
|
28
|
-
"--js_out=one_output_file_per_input_file,binary:."
|
|
29
|
-
];
|
|
30
|
-
|
|
31
|
-
for (var i = 0; i < options.imports.length; i++) {
|
|
32
|
-
args.push("-I", path.join(relative, options.imports[i]));
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
for (var i = 0; i < files.length; i++) {
|
|
36
|
-
args.push(path.join(relative, files[i]));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
mkdirp(options.outputPath, function(err) {
|
|
40
|
-
if (err) {
|
|
41
|
-
callback(err);
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
exports.protoc(args, {
|
|
46
|
-
"cwd": options.outputPath
|
|
47
|
-
}, callback);
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Converts .proto files to .js files that can be used in Google Closure
|
|
53
|
-
* Compiler.
|
|
54
|
-
* The generated .js files require the files in
|
|
55
|
-
* https://github.com/protocolbuffers/protobuf/tree/v3.20.3/js.
|
|
56
|
-
* @param {?Array<string>} files the proto files.
|
|
57
|
-
* @param {?function(?Error, ?Array<Vinyl>)} callback the callback method.
|
|
58
|
-
*/
|
|
59
|
-
exports.library = function(files, callback) {
|
|
60
|
-
var dirpath = "tmp";
|
|
61
|
-
var filename = uuid.v4();
|
|
62
|
-
var jsFile = path.join(dirpath, filename);
|
|
63
|
-
mkdirp("tmp", function(err) {
|
|
64
|
-
if (err) {
|
|
65
|
-
callback(err);
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
exports.protoc(["--js_out=library=" + jsFile + ",binary:."].concat(files), function(err, stdout, stderr) {
|
|
70
|
-
if (err) {
|
|
71
|
-
callback(err);
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (fs.existsSync(jsFile + ".js")) {
|
|
76
|
-
fs.readFile(jsFile + ".js", function(err, contents) {
|
|
77
|
-
if (err) {
|
|
78
|
-
callback(err);
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
fs.unlink(jsFile + ".js", function(err) {
|
|
83
|
-
if (err) {
|
|
84
|
-
callback(err);
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
fs.rmdir(dirpath, function() {
|
|
89
|
-
callback(null, [new Vinyl({
|
|
90
|
-
"cwd": "/",
|
|
91
|
-
"base": "/",
|
|
92
|
-
"path": filename + ".js",
|
|
93
|
-
"contents": contents
|
|
94
|
-
})]);
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
} else {
|
|
99
|
-
glob("**/*.js", {
|
|
100
|
-
"cwd": jsFile
|
|
101
|
-
}, function(err, matches) {
|
|
102
|
-
if (err) {
|
|
103
|
-
callback(err, null);
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
var files = matches.map(function(match) {
|
|
108
|
-
return new Vinyl({
|
|
109
|
-
"cwd": "/",
|
|
110
|
-
"base": "/",
|
|
111
|
-
"path": match,
|
|
112
|
-
"contents": fs.readFileSync(path.join(jsFile, match))
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
rimraf(jsFile, function(err) {
|
|
117
|
-
if (err) {
|
|
118
|
-
callback(err);
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
fs.rmdir(dirpath, function() {
|
|
123
|
-
callback(null, files);
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
};
|
package/protoc.js
DELETED
package/scripts/postinstall.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
const fs = require("fs");
|
|
2
|
-
const path = require("path");
|
|
3
|
-
const unzip = require("unzipper");
|
|
4
|
-
const mkdirp = require("mkdirp");
|
|
5
|
-
const protoc = require("../protoc.js");
|
|
6
|
-
|
|
7
|
-
const protoVersion = "3.20.3";
|
|
8
|
-
|
|
9
|
-
const releases = {
|
|
10
|
-
"win32_x86_32": `https://github.com/protocolbuffers/protobuf/releases/download/v${protoVersion}/protoc-${protoVersion}-win32.zip`,
|
|
11
|
-
"win32_x86_64": `https://github.com/protocolbuffers/protobuf/releases/download/v${protoVersion}/protoc-${protoVersion}-win32.zip`,
|
|
12
|
-
"linux_x86_32": `https://github.com/protocolbuffers/protobuf/releases/download/v${protoVersion}/protoc-${protoVersion}-linux-x86_32.zip`,
|
|
13
|
-
"linux_x86_64": `https://github.com/protocolbuffers/protobuf/releases/download/v${protoVersion}/protoc-${protoVersion}-linux-x86_64.zip`,
|
|
14
|
-
"darwin_x86_64": `https://github.com/protocolbuffers/protobuf/releases/download/v${protoVersion}/protoc-${protoVersion}-osx-x86_64.zip`
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const platform = process.platform;
|
|
18
|
-
const arch = process.arch === "x64" ? "x86_64" : "x86_32";
|
|
19
|
-
const release = platform + "_" + arch;
|
|
20
|
-
const protocDirectory = path.join(__dirname, "..", "protoc");
|
|
21
|
-
|
|
22
|
-
(async () => {
|
|
23
|
-
if (!releases[release]) {
|
|
24
|
-
throw new Error(`Unsupported platform: ${release}. Was not able to find a proper protoc version.`);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
fs.rmSync(protocDirectory, { recursive: true, force: true });
|
|
28
|
-
|
|
29
|
-
const fetch = await import("node-fetch");
|
|
30
|
-
const response = await fetch.default(releases[release]);
|
|
31
|
-
response
|
|
32
|
-
.body
|
|
33
|
-
.pipe(unzip.Parse())
|
|
34
|
-
.on("entry", entry => {
|
|
35
|
-
const isFile = "File" === entry.type;
|
|
36
|
-
const isDir = "Directory" === entry.type;
|
|
37
|
-
const fullpath = path.join(protocDirectory, entry.path);
|
|
38
|
-
const directory = isDir ? fullpath : path.dirname(fullpath);
|
|
39
|
-
|
|
40
|
-
mkdirp(directory, err => {
|
|
41
|
-
if (err) {
|
|
42
|
-
throw err;
|
|
43
|
-
}
|
|
44
|
-
if (isFile) {
|
|
45
|
-
entry.pipe(fs.createWriteStream(fullpath))
|
|
46
|
-
.on("finish", function() {
|
|
47
|
-
if (protoc === fullpath) {
|
|
48
|
-
fs.chmod(fullpath, 0o755, function(err) {
|
|
49
|
-
if (err) {
|
|
50
|
-
throw err;
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
})();
|