| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 | 2 |
| 3 # Copyright 2014 The Chromium Authors. All rights reserved. | 3 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 '''Publishes ChromeVox to the webstore. | 7 '''Publishes ChromeVox to the webstore. |
| 8 Given an unpacked extension, compresses and sends to the Chrome webstore. | 8 Given an unpacked extension, compresses and sends to the Chrome webstore. |
| 9 | 9 |
| 10 Releasing to the webstore should involve the following manual steps before | 10 Releasing to the webstore should involve the following manual steps before |
| 11 running this script: | 11 running this script: |
| 12 1. clean the output directory. | 12 1. clean the output directory. |
| 13 2. make a release build. | 13 2. make a release build. |
| 14 3. run manual smoke tests. | 14 3. run manual smoke tests. |
| 15 4. run automated ChromeVox tests. | 15 4. run automated ChromeVox tests. |
| 16 ''' | 16 ''' |
| 17 | 17 |
| 18 import chromevox_webstore_util | 18 import chromevox_webstore_util |
| 19 import json | 19 import json |
| 20 import optparse | 20 import optparse |
| 21 import os | 21 import os |
| 22 import sys | 22 import sys |
| 23 import tempfile | 23 import tempfile |
| 24 from zipfile import ZipFile | 24 from zipfile import ZipFile |
| 25 | 25 |
| 26 # A list of files to exclude from the webstore build. | 26 # A list of files (or directories) to exclude from the webstore build. |
| 27 EXCLUDE_FILES = ['manifest_guest.json'] | 27 EXCLUDE_PATHS = [ |
| 28 'cvox2/background/', |
| 29 'deps.js', |
| 30 'manifest_guest.json', |
| 31 'manifest_next.json', |
| 32 'manifest_next_guest.json' |
| 33 ] |
| 28 | 34 |
| 29 | 35 |
| 30 def CreateOptionParser(): | 36 def CreateOptionParser(): |
| 31 parser = optparse.OptionParser(description=__doc__) | 37 parser = optparse.OptionParser(description=__doc__) |
| 32 parser.usage = '%prog <extension_path> <output_path> <client_secret' | 38 parser.usage = '%prog <extension_path> <output_path> <client_secret' |
| 33 return parser | 39 return parser |
| 34 | 40 |
| 35 def MakeManifestEdits(root, old, new_file): | 41 def MakeManifestEdits(root, old, new_file): |
| 36 '''Customize a manifest for the webstore. | 42 '''Customize a manifest for the webstore. |
| 37 | 43 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 print 'Expected exactly three arguments' | 90 print 'Expected exactly three arguments' |
| 85 sys.exit(1) | 91 sys.exit(1) |
| 86 | 92 |
| 87 extension_path = args[0] | 93 extension_path = args[0] |
| 88 output_path = args[1] | 94 output_path = args[1] |
| 89 client_secret = args[2] | 95 client_secret = args[2] |
| 90 | 96 |
| 91 with ZipFile(output_path, 'w') as zip: | 97 with ZipFile(output_path, 'w') as zip: |
| 92 for root, dirs, files in os.walk(extension_path): | 98 for root, dirs, files in os.walk(extension_path): |
| 93 rel_path = os.path.join(os.path.relpath(root, extension_path), '') | 99 rel_path = os.path.join(os.path.relpath(root, extension_path), '') |
| 100 if rel_path in EXCLUDE_PATHS: |
| 101 continue |
| 94 | 102 |
| 95 for extension_file in files: | 103 for extension_file in files: |
| 96 if extension_file in EXCLUDE_FILES: | 104 if extension_file in EXCLUDE_PATHS: |
| 97 continue | 105 continue |
| 98 if extension_file == 'manifest.json': | 106 if extension_file == 'manifest.json': |
| 99 new_file = tempfile.NamedTemporaryFile(mode='w+a', bufsize=0) | 107 new_file = tempfile.NamedTemporaryFile(mode='w+a', bufsize=0) |
| 100 MakeManifestEdits(root, extension_file, new_file) | 108 MakeManifestEdits(root, extension_file, new_file) |
| 101 zip.write( | 109 zip.write( |
| 102 new_file.name, os.path.join(rel_path, extension_file)) | 110 new_file.name, os.path.join(rel_path, extension_file)) |
| 103 continue | 111 continue |
| 104 | 112 |
| 105 zip.write(os.path.join(root, extension_file), | 113 zip.write(os.path.join(root, extension_file), |
| 106 os.path.join(rel_path, extension_file)) | 114 os.path.join(rel_path, extension_file)) |
| 107 print 'Created ChromeVox zip file in %s' % output_path | 115 print 'Created ChromeVox zip file in %s' % output_path |
| 108 print 'Please run manual smoke tests before proceeding.' | 116 print 'Please run manual smoke tests before proceeding.' |
| 109 RunInteractivePrompt(client_secret, output_path) | 117 RunInteractivePrompt(client_secret, output_path) |
| 110 | 118 |
| 111 | 119 |
| 112 if __name__ == '__main__': | 120 if __name__ == '__main__': |
| 113 main() | 121 main() |
| OLD | NEW |