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

Delta Between Two Patch Sets: packagerChrome.py

Issue 29549786: Issue 5535 - Replace our module system with webpack (Closed)
Left Patch Set: Rebased and tidied up Created Oct. 10, 2017, 1:17 p.m.
Right Patch Set: Addressed final nits Created Oct. 10, 2017, 5:02 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « package-lock.json ('k') | packagerEdge.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 # This Source Code Form is subject to the terms of the Mozilla Public 1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this 2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
4 4
5 import errno 5 import errno
6 import glob 6 import glob
7 import io 7 import io
8 import json 8 import json
9 import os 9 import os
10 import re 10 import re
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 'chrome': 'chromeInfo.js.tmpl', 153 'chrome': 'chromeInfo.js.tmpl',
154 'edge': 'edgeInfo.js.tmpl', 154 'edge': 'edgeInfo.js.tmpl',
155 'gecko-webext': 'geckoInfo.js.tmpl' 155 'gecko-webext': 'geckoInfo.js.tmpl'
156 } 156 }
157 157
158 # Historically we didn't use relative paths when requiring modules, so in 158 # Historically we didn't use relative paths when requiring modules, so in
159 # order for webpack to know where to find them we need to pass in a list of 159 # order for webpack to know where to find them we need to pass in a list of
160 # resolve paths. Going forward we should always use relative paths, once we 160 # resolve paths. Going forward we should always use relative paths, once we
161 # do that consistently this can be removed. See issues 5760, 5761 and 5762. 161 # do that consistently this can be removed. See issues 5760, 5761 and 5762.
162 resolve_paths = [os.path.join(base_extension_path, dir, 'lib') 162 resolve_paths = [os.path.join(base_extension_path, dir, 'lib')
163 for dir in ['', 'adblockpluscore', 'adblockplusui']] 163 for dir in ['', 'adblockpluscore', 'adblockplusui']]
Sebastian Noack 2017/10/10 16:35:19 The "adblockplus" dependency has been removed mean
kzar 2017/10/10 17:03:38 This is true but as discussed in IRC we can remove
164 164
165 info_template = getTemplate(info_templates[params['type']]) 165 info_template = getTemplate(info_templates[params['type']])
166 info_module = info_template.render( 166 info_module = info_template.render(
167 basename=params['metadata'].get('general', 'basename'), 167 basename=params['metadata'].get('general', 'basename'),
168 version=params['metadata'].get('general', 'version') 168 version=params['metadata'].get('general', 'version')
169 ).encode('utf-8') 169 ).encode('utf-8')
170 170
171 configuration = { 171 configuration = {
172 'bundles': [], 172 'bundles': [],
173 'extension_path': base_extension_path, 173 'extension_path': base_extension_path,
174 'info_module': info_module, 174 'info_module': info_module,
175 'resolve_paths': resolve_paths, 175 'resolve_paths': resolve_paths,
176 } 176 }
177 177
178 for item in params['metadata'].items('bundles'): 178 for item in params['metadata'].items('bundles'):
179 name, value = item 179 name, value = item
180 base_item_path = os.path.dirname(item.source) 180 base_item_path = os.path.dirname(item.source)
181 181
182 bundle_file = os.path.relpath(os.path.join(base_item_path, name), 182 bundle_file = os.path.relpath(os.path.join(base_item_path, name),
183 base_extension_path) 183 base_extension_path)
184 entry_files = [os.path.join(base_item_path, module_path) 184 entry_files = [os.path.join(base_item_path, module_path)
185 for module_path in value.split()] 185 for module_path in value.split()]
186 configuration['bundles'].append({ 186 configuration['bundles'].append({
187 'bundle_name': bundle_file, 187 'bundle_name': bundle_file,
188 'entry_points': entry_files, 188 'entry_points': entry_files,
189 }) 189 })
190 190
191 command = ['node', 191 cmd = ['node', os.path.join(os.path.dirname(__file__), 'webpack_runner.js')]
192 os.path.join(os.path.dirname(__file__), 'webpack_runner.js')] 192 process = subprocess.Popen(cmd, stdout=subprocess.PIPE,
Sebastian Noack 2017/10/10 16:35:19 Nit: It seem you don't need to wrap this list if y
kzar 2017/10/10 17:03:39 Well I pass the variable to the CalledProcessError
Sebastian Noack 2017/10/10 17:23:33 Acknowledged.
193 process = subprocess.Popen( 193 stdin=subprocess.PIPE)
194 command, stdout=subprocess.PIPE, stdin=subprocess.PIPE
195 )
196 output = process.communicate(input=toJson(configuration))[0] 194 output = process.communicate(input=toJson(configuration))[0]
197 if process.returncode != 0: 195 if process.returncode != 0:
198 raise subprocess.CalledProcessError(process.returncode, cmd=command) 196 raise subprocess.CalledProcessError(process.returncode, cmd=cmd)
199 197
200 bundles = json.loads(output) 198 bundles = json.loads(output)
201 for bundle in bundles: 199 for bundle in bundles:
202 files[bundle] = bundles[bundle].encode('utf-8') 200 files[bundle] = bundles[bundle].encode('utf-8')
203 201
204 202
205 def import_locales(params, files): 203 def import_locales(params, files):
206 for item in params['metadata'].items('import_locales'): 204 for item in params['metadata'].items('import_locales'):
207 filename, keys = item 205 filename, keys = item
208 for sourceFile in glob.glob(os.path.join(os.path.dirname(item.source), 206 for sourceFile in glob.glob(os.path.join(os.path.dirname(item.source),
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 params, 'testIndex.html.tmpl', ('general', 'testScripts') 368 params, 'testIndex.html.tmpl', ('general', 'testScripts')
371 ) 369 )
372 370
373 zipdata = files.zipToString() 371 zipdata = files.zipToString()
374 signature = None 372 signature = None
375 pubkey = None 373 pubkey = None
376 if keyFile != None: 374 if keyFile != None:
377 signature = signBinary(zipdata, keyFile) 375 signature = signBinary(zipdata, keyFile)
378 pubkey = getPublicKey(keyFile) 376 pubkey = getPublicKey(keyFile)
379 writePackage(outFile, pubkey, signature, zipdata) 377 writePackage(outFile, pubkey, signature, zipdata)
LEFTRIGHT

Powered by Google App Engine
This is Rietveld