22 HOME = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
24 pkgName = os.path.basename(os.path.normpath(argv[1]))
26 pubspec = os.path.join(HOME, argv[1],
'pubspec.yaml')
27 if not os.path.exists(pubspec):
28 print(
'Error: did not find pubspec.yaml at ' + pubspec)
31 with open(pubspec)
as pubspecFile:
32 lines = pubspecFile.readlines()
35 foundSdkConstraint =
False
36 inDependencies =
False
38 if line.startswith(
'dependencies:'):
40 elif line.startswith(
'environment:'):
41 foundSdkConstraint =
True
42 elif line[0].isalpha():
43 inDependencies =
False
44 if line.startswith(
'version:'):
45 version = line[
len(
'version:'):].strip()
47 if line.endswith(
': any'):
49 'Error in %s: should not use "any" version constraint: %s' %
54 print(
'Error in %s: did not find package version.' % pubspec)
57 if not foundSdkConstraint:
58 print(
'Error in %s: did not find SDK version constraint.' % pubspec)
61 tmpDir = tempfile.mkdtemp()
66 shutil.copytree(os.path.join(HOME, argv[1]), os.path.join(tmpDir, pkgName))
68 if not os.path.exists(os.path.join(tmpDir, pkgName,
'LICENSE')):
69 with open(os.path.join(tmpDir, pkgName,
'LICENSE'),
'w')
as licenseFile:
71 '''Copyright 2014, the Dart project authors. All rights reserved.
72Redistribution and use in source and binary forms, with or without
73modification, are permitted provided that the following conditions are
76 * Redistributions of source code must retain the above copyright
77 notice, this list of conditions and the following disclaimer.
78 * Redistributions
in binary form must reproduce the above
79 copyright notice, this list of conditions
and the following
80 disclaimer
in the documentation
and/
or other materials provided
81 with the distribution.
82 * Neither the name of Google Inc. nor the names of its
83 contributors may be used to endorse
or promote products derived
84 from this software without specific prior written permission.
86THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
87"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
88LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
89A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
90OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
91SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
92LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
93DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
94THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
95(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
96OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
99 print('publishing version ' + version +
' of ' + argv[1] +
' to pub.\n')
109 subprocess.call([
'pub',
'publish'], cwd=os.path.join(tmpDir, pkgName))
110 shutil.rmtree(tmpDir)
113if __name__ ==
'__main__':
114 sys.exit(
Main(sys.argv))
def print(*args, **kwargs)