Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: automation/target/gecko.js

Issue 29901591: Issue 7020 - publish gecko with Node.js (Closed) Base URL: https://gitlab.com/eyeo/adblockplus/adblockpluschrome/tree/6323e74d580026e3bd1e8e631fcddaf0bbaa34df
Patch Set: Created Oct. 15, 2018, 10:18 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: automation/target/gecko.js
diff --git a/automation/target/gecko.js b/automation/target/gecko.js
new file mode 100644
index 0000000000000000000000000000000000000000..3c95f8e77ad5eda13283dee99ceb87985cc17788
--- /dev/null
+++ b/automation/target/gecko.js
@@ -0,0 +1,92 @@
+/*
+ * This file is part of Adblock Plus <https://adblockplus.org/>,
+ * Copyright (C) 2006-present eyeo GmbH
+ *
+ * Adblock Plus is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * Adblock Plus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+"use strict";
+
+const path = require("path");
+const {exec} = require("child_process");
+const signAddon = require("sign-addon").default;
+const {promisify} = require("util");
+const fs = require("fs");
+const mv = require("mv");
+
+const readFileAsync = promisify(fs.readFile);
+const mvFileAsync = promisify(mv);
+
+exports.addArguments = function(parser)
+{
+ parser.addArgument(["-p", "--package"], {required: true});
+ parser.addArgument(["-c", "--credentials"], {required: true});
+ parser.addArgument(["-t", "--target"], {defaultValue: "dist"});
+};
+
+exports.run = function(args)
+{
+ let appIdFromPython = new Promise((resolve, reject) =>
+ {
+ exec(
+ "python -c \"" +
kzar 2018/10/15 12:42:58 Maybe we should parse the file using JavaScript in
tlucas 2018/10/15 14:12:39 Originally, we would have to support inheritance i
kzar 2018/10/15 14:46:10 Alright, fair enough. Personally, I'd vote for jus
+ "from buildtools.chainedconfigparser import ChainedConfigParser; " +
+ "p = ChainedConfigParser(); " +
+ "p.read('metadata.gecko'); " +
+ "print p.get('general', 'app_id_devbuild')\"",
+ (error, stdout, stderr) =>
+ {
+ if (error)
+ {
+ console.error(stderr);
+ reject(error);
+ }
+ else
+ resolve(stdout.trim());
+ }
+ );
+ });
+
+ Promise.all([
+ appIdFromPython,
+ readFileAsync(path.resolve(args.credentials))
+ ]).then(([appId, fileContent]) =>
+ {
+ let auth = JSON.parse(fileContent);
+ let extension = path.extname(args.package);
+ let version = args.package.replace(extension, "").split("-");
+ version = version[version.length - 1];
+
+ return signAddon({
+ xpiPath: args.package,
+ version,
+ apiKey: auth["AMO_KEY"],
+ apiSecret: auth["AMO_SECRET"],
+ channel: "unlisted",
+ id: appId
+ });
+ }).then(result =>
+ {
+ if (!result.success)
+ process.exit(1);
kzar 2018/10/15 12:42:58 Should we instead throw an exception here, so it's
tlucas 2018/10/15 14:12:39 Sebastian also asked if we could log something her
kzar 2018/10/15 14:46:10 I see, that's a little misleading but it's not you
tlucas 2018/10/16 08:42:39 Done.
+
+ let fullName = result.downloadedFiles[0];
+ let newName = path.join(args.target, path.basename(fullName));
+
+ return mvFileAsync(fullName, newName, {mkdirp: true});
+ }).catch(err =>
+ {
+ console.error(err);
+ process.exit(1);
+ });
+};
« automation/publish.js ('K') | « automation/publish.js ('k') | package.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld