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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 153 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
154 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 154 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
155 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 155 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
156 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 156 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
157 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 157 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
158 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 158 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
159 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 159 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
160 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 160 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
161 '''); | 161 '''); |
162 | 162 |
163 # TODO(jmesserly): this is a hack to make analyzer-experimental work. | |
164 if pkgName.endswith('-experimental'): | |
165 pkgReplace = (pkgName, pkgName.replace('-', '_')) | |
166 replaceInDart.append(pkgReplace) | |
167 replaceInPubspec.append(pkgReplace) | |
168 | |
169 replaceInDart.append( | 163 replaceInDart.append( |
170 (r'(import|part)(\s+)(\'|")(\.\./)+pkg/([^/]+/)lib/', r'\1\2\3package:\5')) | 164 (r'(import|part)(\s+)(\'|")(\.\./)+pkg/([^/]+/)lib/', r'\1\2\3package:\5')) |
171 | 165 |
172 # Replace '../*/pkg' imports and parts. | 166 # Replace '../*/pkg' imports and parts. |
173 for root, dirs, files in os.walk(os.path.join(tmpDir, pkgName)): | 167 for root, dirs, files in os.walk(os.path.join(tmpDir, pkgName)): |
174 # TODO(dgrove): Remove this when dartbug.com/7487 is fixed. | 168 # TODO(dgrove): Remove this when dartbug.com/7487 is fixed. |
175 if '.svn' in dirs: | 169 if '.svn' in dirs: |
176 shutil.rmtree(os.path.join(root, '.svn')) | 170 shutil.rmtree(os.path.join(root, '.svn')) |
177 for name in files: | 171 for name in files: |
178 if name.endswith('.dart'): | 172 if name.endswith('.dart'): |
179 ReplaceInFiles([os.path.join(root, name)], replaceInDart) | 173 ReplaceInFiles([os.path.join(root, name)], replaceInDart) |
180 elif name == 'pubspec.yaml': | 174 elif name == 'pubspec.yaml': |
181 ReplaceInFiles([os.path.join(root, name)], replaceInPubspec) | 175 ReplaceInFiles([os.path.join(root, name)], replaceInPubspec) |
182 | 176 |
183 print 'publishing version ' + version + ' of ' + argv[1] + ' to pub.\n' | 177 print 'publishing version ' + version + ' of ' + argv[1] + ' to pub.\n' |
184 subprocess.call(['pub', 'publish'], cwd=os.path.join(tmpDir, pkgName)) | 178 subprocess.call(['pub', 'publish'], cwd=os.path.join(tmpDir, pkgName)) |
185 shutil.rmtree(tmpDir) | 179 shutil.rmtree(tmpDir) |
186 | 180 |
187 if __name__ == '__main__': | 181 if __name__ == '__main__': |
188 sys.exit(Main(sys.argv)) | 182 sys.exit(Main(sys.argv)) |
OLD | NEW |