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

Side by Side 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.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH
4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 "use strict";
19
20 const path = require("path");
21 const {exec} = require("child_process");
22 const signAddon = require("sign-addon").default;
23 const {promisify} = require("util");
24 const fs = require("fs");
25 const mv = require("mv");
26
27 const readFileAsync = promisify(fs.readFile);
28 const mvFileAsync = promisify(mv);
29
30 exports.addArguments = function(parser)
31 {
32 parser.addArgument(["-p", "--package"], {required: true});
33 parser.addArgument(["-c", "--credentials"], {required: true});
34 parser.addArgument(["-t", "--target"], {defaultValue: "dist"});
35 };
36
37 exports.run = function(args)
38 {
39 let appIdFromPython = new Promise((resolve, reject) =>
40 {
41 exec(
42 "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
43 "from buildtools.chainedconfigparser import ChainedConfigParser; " +
44 "p = ChainedConfigParser(); " +
45 "p.read('metadata.gecko'); " +
46 "print p.get('general', 'app_id_devbuild')\"",
47 (error, stdout, stderr) =>
48 {
49 if (error)
50 {
51 console.error(stderr);
52 reject(error);
53 }
54 else
55 resolve(stdout.trim());
56 }
57 );
58 });
59
60 Promise.all([
61 appIdFromPython,
62 readFileAsync(path.resolve(args.credentials))
63 ]).then(([appId, fileContent]) =>
64 {
65 let auth = JSON.parse(fileContent);
66 let extension = path.extname(args.package);
67 let version = args.package.replace(extension, "").split("-");
68 version = version[version.length - 1];
69
70 return signAddon({
71 xpiPath: args.package,
72 version,
73 apiKey: auth["AMO_KEY"],
74 apiSecret: auth["AMO_SECRET"],
75 channel: "unlisted",
76 id: appId
77 });
78 }).then(result =>
79 {
80 if (!result.success)
81 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.
82
83 let fullName = result.downloadedFiles[0];
84 let newName = path.join(args.target, path.basename(fullName));
85
86 return mvFileAsync(fullName, newName, {mkdirp: true});
87 }).catch(err =>
88 {
89 console.error(err);
90 process.exit(1);
91 });
92 };
OLDNEW
« automation/publish.js ('K') | « automation/publish.js ('k') | package.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld