OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
4 # for details. All rights reserved. Use of this source code is governed by a | 4 # for details. All rights reserved. Use of this source code is governed by a |
5 # BSD-style license that can be found in the LICENSE file. | 5 # BSD-style license that can be found in the LICENSE file. |
6 # | 6 # |
7 # Script to push a package to pub. | 7 # Script to push a package to pub. |
8 # | 8 # |
9 # Usage: publish_pkg.py pkg_dir | 9 # Usage: publish_pkg.py pkg_dir |
10 # | 10 # |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 minor = ReadVersion(versionFile, 'MINOR') | 46 minor = ReadVersion(versionFile, 'MINOR') |
47 build = ReadVersion(versionFile, 'BUILD') | 47 build = ReadVersion(versionFile, 'BUILD') |
48 patch = ReadVersion(versionFile, 'PATCH') | 48 patch = ReadVersion(versionFile, 'PATCH') |
49 | 49 |
50 # bleeding_edge has a fixed version number of 0.1.x.y . Don't allow users | 50 # bleeding_edge has a fixed version number of 0.1.x.y . Don't allow users |
51 # to publish packages from bleeding_edge. | 51 # to publish packages from bleeding_edge. |
52 if major == 0 and minor <= 1: | 52 if major == 0 and minor <= 1: |
53 print 'Error: Do not run this script from a bleeding_edge checkout.' | 53 print 'Error: Do not run this script from a bleeding_edge checkout.' |
54 return -1 | 54 return -1 |
55 | 55 |
56 version = '%d.%d.%d+%d' % (major, minor, build, patch) | 56 if patch != 0: |
| 57 version = '%d.%d.%d+%d' % (major, minor, build, patch) |
| 58 else: |
| 59 version = '%d.%d.%d' % (major, minor, build) |
57 | 60 |
58 tmpDir = tempfile.mkdtemp() | 61 tmpDir = tempfile.mkdtemp() |
59 pkgName = argv[1].split('/').pop() | 62 pkgName = argv[1].split('/').pop() |
60 | 63 |
61 pubspec = os.path.join(tmpDir, pkgName, 'pubspec.yaml') | 64 pubspec = os.path.join(tmpDir, pkgName, 'pubspec.yaml') |
62 | 65 |
63 if os.path.exists(os.path.join(HOME, argv[1], 'pubspec.yaml')): | 66 if os.path.exists(os.path.join(HOME, argv[1], 'pubspec.yaml')): |
64 # | 67 # |
65 # If pubspec.yaml exists, add the SDK's version number if | 68 # If pubspec.yaml exists, add the SDK's version number if |
66 # no version number is present. | 69 # no version number is present. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 if name.endswith('.dart'): | 123 if name.endswith('.dart'): |
121 ReplaceInFiles([os.path.join(root, name)], | 124 ReplaceInFiles([os.path.join(root, name)], |
122 [(r'(import|part)(\s+)(\'|")(\.\./)+pkg/', r'\1\2\3package:')]) | 125 [(r'(import|part)(\s+)(\'|")(\.\./)+pkg/', r'\1\2\3package:')]) |
123 | 126 |
124 print 'publishing version ' + version + ' of ' + argv[1] + ' to pub.\n' | 127 print 'publishing version ' + version + ' of ' + argv[1] + ' to pub.\n' |
125 subprocess.call(['pub', 'publish'], cwd=os.path.join(tmpDir, pkgName)) | 128 subprocess.call(['pub', 'publish'], cwd=os.path.join(tmpDir, pkgName)) |
126 shutil.rmtree(tmpDir) | 129 shutil.rmtree(tmpDir) |
127 | 130 |
128 if __name__ == '__main__': | 131 if __name__ == '__main__': |
129 sys.exit(Main(sys.argv)) | 132 sys.exit(Main(sys.argv)) |
OLD | NEW |