Ejemplo n.º 1
0
def check_npm():
    try:
        npm_version = subprocess.check_output(["npm", "--version"]).strip()
        if version_to_key(npm_version)[0] < 3:
            raise ToolError("We require npm3; you are using version {}.".format(npm_version))
    except subprocess.CalledProcessError:
        raise ToolError(u"You must have npm ≥ 3.0.0 available on your path.")
Ejemplo n.º 2
0
 def do_list(cls, args):
     current_sdk = sdk_manager.get_current_sdk()
     local_sdks = sdk_manager.list_local_sdks()
     local_sdk_versions = sdk_manager.list_local_sdk_versions()
     sorted_local_sdks = sorted(local_sdks, key=lambda x: version_to_key(x['version']), reverse=True)
     if len(local_sdks) > 0:
         print("Installed SDKs:")
         for sdk in sorted_local_sdks:
             line = sdk['version']
             if sdk['channel']:
                 line += " ({})".format(sdk['channel'])
             if sdk['version'] == current_sdk:
                 line += " (active)"
             print(line)
         print()
     else:
         print("No SDKs installed yet.")
     if sdk_manager.get_channel() != '':
         channel_text = ' ({} channel)'.format(sdk_manager.get_channel())
     else:
         channel_text = ''
     print("Available SDKs{}:".format(channel_text))
     try:
         for sdk in sdk_manager.list_remote_sdks():
             if sdk['version'] in local_sdk_versions:
                 continue
             line = sdk['version']
             if sdk['channel']:
                 line += " ({})".format(sdk['channel'])
             if sdk['version'] == current_sdk:
                 line += " (active)"
             print(line)
     except requests.RequestException:
         print("Could not fetch list of available SDKs.")
Ejemplo n.º 3
0
def check_npm():
    try:
        npm_version = subprocess.check_output(["npm", "--version"]).strip()
        if version_to_key(npm_version)[0] < 3:
            raise ToolError(
                "We require npm3; you are using version {}.".format(
                    npm_version))
    except subprocess.CalledProcessError:
        raise ToolError(u"You must have npm ≥ 3.0.0 available on your path.")
Ejemplo n.º 4
0
    def __call__(self, args):
        super(NewProjectCommand, self).__call__(args)

        template_paths = [
            os.path.join(self.get_sdk_path(), 'pebble', 'common', 'templates'),
            os.path.join(os.path.dirname(__file__), '..', '..', 'sdk',
                         'templates')
        ]

        sdk = self.sdk or sdk_version()
        sdk2 = (sdk == "2.9")

        if args.rocky:
            if sdk2:
                raise ToolError("--rocky is not compatible with SDK 2.9")
            if args.simple or args.worker:
                raise ToolError(
                    "--rocky is incompatible with --simple and --worker")
            options = ['rocky']
        else:
            options = ['app']
            if args.javascript:
                options.append('javascript')
            if args.simple:
                options.append('simple')
            if args.worker:
                options.append('worker')

        # Hack for old SDKs that need an appinfo, because the declarative system can't
        # handle "this, but only if not that." For "tintin" SDKs and unparseble
        # versions, assume this hack is not needed.
        version_number = version_to_key(sdk)
        if version_number[:5] != (0, 0, 0, 0, 0) and \
           version_number < (3, 13, 0):
            options.append('appinfo')

        with open(
                extant_path(
                    os.path.join(x, "templates.json")
                    for x in template_paths)) as f:
            template_layout = json.load(f)

        _copy_from_template(template_layout, extant_path(template_paths),
                            args.name, options)

        post_event("sdk_create_project",
                   javascript=args.javascript or args.rocky,
                   worker=args.worker,
                   rocky=args.rocky)
        print("Created new project {}".format(args.name))
Ejemplo n.º 5
0
    def __call__(self, args):
        super(NewProjectCommand, self).__call__(args)

        template_paths = [
            os.path.join(self.get_sdk_path(), 'pebble', 'common', 'templates'),
            os.path.join(os.path.dirname(__file__), '..', '..', 'sdk', 'templates')
        ]

        sdk = self.sdk or sdk_version()
        sdk2 = (sdk == "2.9")

        if args.rocky:
            if sdk2:
                raise ToolError("--rocky is not compatible with SDK 2.9")
            if args.simple or args.worker:
                raise ToolError("--rocky is incompatible with --simple and --worker")
            options = ['rocky']
        else:
            options = ['app']
            if args.javascript:
                options.append('javascript')
            if args.simple:
                options.append('simple')
            if args.worker:
                options.append('worker')

        # Hack for old SDKs that need an appinfo, because the declarative system can't
        # handle "this, but only if not that." For "tintin" SDKs and unparseble
        # versions, assume this hack is not needed.
        version_number = version_to_key(sdk)
        if version_number[:5] != (0, 0, 0, 0, 0) and \
           version_number < (3, 13, 0):
            options.append('appinfo')

        with open(extant_path(os.path.join(x, "templates.json") for x in template_paths)) as f:
            template_layout = json.load(f)

        _copy_from_template(template_layout, extant_path(template_paths), args.name, options)

        post_event("sdk_create_project", javascript=args.javascript or args.rocky, worker=args.worker, rocky=args.rocky)
        print("Created new project {}".format(args.name))
Ejemplo n.º 6
0
 def do_list(cls, args):
     current_sdk = sdk_manager.get_current_sdk()
     local_sdks = sdk_manager.list_local_sdks()
     local_sdk_versions = sdk_manager.list_local_sdk_versions()
     sorted_local_sdks = sorted(local_sdks,
                                key=lambda x: version_to_key(x['version']),
                                reverse=True)
     if len(local_sdks) > 0:
         print("Installed SDKs:")
         for sdk in sorted_local_sdks:
             line = sdk['version']
             if sdk['channel']:
                 line += " ({})".format(sdk['channel'])
             if sdk['version'] == current_sdk:
                 line += " (active)"
             print(line)
         print()
     else:
         print("No SDKs installed yet.")
     if sdk_manager.get_channel() != '':
         channel_text = ' ({} channel)'.format(sdk_manager.get_channel())
     else:
         channel_text = ''
     print("Available SDKs{}:".format(channel_text))
     try:
         for sdk in sdk_manager.list_remote_sdks():
             if sdk['version'] in local_sdk_versions:
                 continue
             line = sdk['version']
             if sdk['channel']:
                 line += " ({})".format(sdk['channel'])
             if sdk['version'] == current_sdk:
                 line += " (active)"
             print(line)
     except requests.RequestException:
         print("Could not fetch list of available SDKs.")
Ejemplo n.º 7
0
 def _check_version(self, new_version, release_notes=None):
     if version_to_key(new_version) > version_to_key(self.current_version):
         logger.debug("Found an update: %s", new_version)
         atexit.register(self.callback, new_version, release_notes)
Ejemplo n.º 8
0
 def _check_version(self, new_version, release_notes=None):
     if version_to_key(new_version) > version_to_key(self.current_version):
         logger.debug("Found an update: %s", new_version)
         atexit.register(self.callback, new_version, release_notes)