Exemplo n.º 1
0
def update(package_json):
    os.chdir(os.path.dirname(package_json))
    print(package_json.split('/')[-2])
    updating = []
    out = subprocess.check_output(['git', 'diff', '--name-only']).decode()
    if 'package.json' in out:
        print('WARNING: package.json has local changes')
        return
    with open(package_json, 'r') as f:
        j = json.load(f, object_pairs_hook=OrderedDict)
        for package, version in j['devDependencies'].items():
            if lib.get_npm_version(package) != version:
                i = (package, version, lib.get_npm_version(package))
                print('Updating %s: %s --> %s' % i)
                updating.append(i)
                j['devDependencies'][package] = lib.get_npm_version(package)
    if not updating:
        print('Nothing to update')
        return
    with open(package_json, 'w') as f:
        out = json.dumps(j, indent='  ')
        f.write(out + '\n')
    subprocess.call(['npm', 'install'])
    try:
        subprocess.check_call(['npm', 'test'])
    except subprocess.CalledProcessError:
        print('Error updating %s' % package_json)
        return
    msg = 'build: Updating development dependencies\n\n'
    for tup in updating:
        msg += '* %s: %s → %s\n' % tup
    print(msg)
    lib.commit_and_push(files=['package.json'], msg=msg, branch='master',
                        topic='bump-dev-deps')
Exemplo n.º 2
0
                color = ''
            add = info[job]['version']
            if add == lib.get_packagist_version(job):
                add += '✓'
        else:
            add = 'n/a'
        text += '|%s\n' % (color + add)

    for job in NPM.values():
        color = ''
        if job in info:
            color = info[job].get('color')
            if color:
                color = 'style="background-color: %s" |' % color
            else:
                color = ''
            add = info[job]['version']
            if add == lib.get_npm_version(job):
                add += '✓'
        else:
            add = 'n/a'
        text += '|%s\n' % (color + add)
text += '|}'

#print(text)
site = pywikibot.Site('mediawiki', 'mediawiki')
page = pywikibot.Page(site, 'User:Legoktm/ci')
pywikibot.showDiff(page.text, text)
if lib.ON_LABS:
    page.put(text, 'Updating table')
Exemplo n.º 3
0
            print('No MessagesDirs set.')
            sys.exit(1)
else:
    if not os.path.isdir('i18n'):
        print('i18n directory does not exist')
        sys.exit(0)
with open('Gruntfile.js', 'w') as f:
    f.write(grunt_file)

package_data = OrderedDict([
    ('private', True),
    ('scripts', {'test': 'grunt test'}),
    ('devDependencies', OrderedDict())
])
for i in ['grunt', 'grunt-cli', 'grunt-banana-checker', 'grunt-jsonlint']:
    package_data['devDependencies'][i] = lib.get_npm_version(i)
with open('package.json', 'w') as f:
    f.write(json.dumps(package_data, indent='  ') + '\n')
subprocess.call(['npm', 'install'])
res = subprocess.call(['npm', 'test'])
if res != 0:
    print('Error: npm test failed.')
    sys.exit(0)
else:
    print('Yay, npm test passed!')
# Add node_modules to gitignore...
if os.path.exists('.gitignore'):
    add = True
    with open('.gitignore') as f:
        for line in f.read().splitlines():
            if line.strip().startswith('node_modules'):