def update_angular(path):
        """
        Update modules for {N} project
        :param path: Path to {N} project
        :return: Output of command that update nativescript-angular plugin.
        """

        # Escape path with spaces
        if " " in path:
            path = "\"" + path + "\""

        if USE_YARN == "True":
            Npm.uninstall(package="nativescript-angular", folder=path)
            output = Npm.install(package=ANGULAR_PACKAGE, folder=path)
        else:
            Npm.uninstall(package="nativescript-angular", option="--save", folder=path)
            output = Npm.install(package=ANGULAR_PACKAGE, option="--save", folder=path)
            if Npm.version() > 3:
                assert "ERR" not in output, "Something went wrong when angular are installed."

        # Update NG dependencies
        update_script = os.path.join(TEST_RUN_HOME, path,
                                     "node_modules", ".bin", "update-app-ng-deps")
        update_out = run(update_script)
        assert "Angular dependencies updated" in update_out

        if USE_YARN == "True":
            Npm.yarn_install(folder=path)
        else:
            Npm.install(folder=path)

        return output
Example #2
0
 def setUpClass(cls):
     BaseClass.setUpClass(cls.__name__)
     Process.kill('Safari')
     Process.kill('NativeScript Inspector')
     Emulator.stop()
     Simulator.stop()
     cls.SIMULATOR_ID = Simulator.ensure_available(
         simulator_name=SIMULATOR_NAME)
     Folder.cleanup(cls.INSPECTOR_GLOBAL_PATH)
     Tns.create_app(cls.app_name,
                    attributes={
                        '--template':
                        os.path.join('data', 'apps',
                                     'livesync-hello-world.tgz')
                    },
                    update_modules=True)
     Tns.platform_add_ios(attributes={
         '--path': cls.app_name,
         '--frameworkPath': IOS_PACKAGE
     })
     if USE_YARN == "True":
         Npm.install(package=IOS_INSPECTOR_PACKAGE,
                     option='--dev',
                     folder=cls.app_name)
     else:
         Npm.install(package=IOS_INSPECTOR_PACKAGE,
                     option='--save-dev',
                     folder=cls.app_name)
     Tns.build_ios(attributes={"--path": cls.app_name})
Example #3
0
    def test_300_build_project_with_dash_and_ios_inspector_added(self):
        """
        Verify we can build projects with dashes.
        Verify we can build android when inspector is added (test for CLI issue 2467)
        """
        Tns.create_app(self.app_name_dash)
        Tns.platform_add_android(attributes={
            "--path": self.app_name_dash,
            "--frameworkPath": ANDROID_PACKAGE
        })
        if USE_YARN == "True":
            Npm.install(package="tns-ios-inspector",
                        option='--dev',
                        folder=self.app_name_dash)
        else:
            Npm.install(package="tns-ios-inspector",
                        option='--save-dev',
                        folder=self.app_name_dash)
        Tns.build_android(attributes={"--path": self.app_name_dash})

        # Verify project id
        output = File.read(self.app_name_dash + "/package.json")
        assert app_identifier in output.lower()

        # Verify AndroidManifest.xml
        output = File.read(self.app_name_dash + "/" +
                           TnsAsserts.PLATFORM_ANDROID_SRC_MAIN_PATH +
                           "AndroidManifest.xml")
        assert app_identifier in output.lower()
    def update_webpack(path):
        """
        Update modules for {N} project
        :param path: Path to {N} project
        :return: Output of command that update nativescript-dev-webpack plugin.
        """

        # Escape path with spaces
        if " " in path:
            path = "\"" + path + "\""

        if USE_YARN == "True":
            Npm.uninstall(package="nativescript-dev-webpack", option="--dev", folder=path)
            output = Npm.install(package=WEBPACK_PACKAGE, option="--dev", folder=path)
        else:
            Npm.uninstall(package="nativescript-dev-webpack", option="--save-dev", folder=path)
            output = Npm.install(package=WEBPACK_PACKAGE, option="--save-dev", folder=path)
            if Npm.version() > 3:
                assert "ERR" not in output, "Something went wrong when webpack are installed."

        # Update webpack dependencies
        update_script = os.path.join(TEST_RUN_HOME, path,
                                     "node_modules", ".bin", "update-ns-webpack --deps --configs")
        run(update_script)
        if USE_YARN == "True":
            Folder.cleanup(folder=os.path.join(TEST_RUN_HOME, path, "node_modules"))
            Npm.yarn_install(folder=path)
        else:
            Npm.install(folder=path)
        return output
Example #5
0
    def update_typescript(path):
        """
        Update modules for {N} project
        :param path: Path to {N} project
        :return: Output of command that update nativescript-typescript plugin.
        """

        # Escape path with spaces
        if " " in path:
            path = "\"" + path + "\""

        if USE_YARN == "True":
            Npm.uninstall(package="nativescript-typescript", folder=path)
            output = Npm.install(package=TYPESCRIPT_PACKAGE, folder=path)
        else:
            Npm.uninstall(package="nativescript-typescript",
                          option="--save",
                          folder=path)
            output = Npm.install(package=TYPESCRIPT_PACKAGE,
                                 option="--save",
                                 folder=path)
            if Npm.version() > 3:
                assert "ERR" not in output, "Something went wrong when typescript are installed."

        # Update TS dependencies
        update_script = os.path.join(TEST_RUN_HOME, path, "node_modules",
                                     ".bin", "ns-upgrade-tsconfig")
        run(update_script)
        if USE_YARN == "True":
            Npm.yarn_install(folder=path)
        else:
            Npm.install(folder=path)

        return output
    def update_typescript(path):
        """
        Update modules for {N} project
        :param path: Path to {N} project
        :return: Output of command that update nativescript-typescript plugin.
        """

        # Escape path with spaces
        if " " in path:
            path = "\"" + path + "\""

        if USE_YARN == "True":
            Npm.uninstall(package="nativescript-typescript", folder=path)
            output = Npm.install(package=TYPESCRIPT_PACKAGE, folder=path)
        else:
            Npm.uninstall(package="nativescript-typescript", option="--save", folder=path)
            output = Npm.install(package=TYPESCRIPT_PACKAGE, option="--save", folder=path)
            if Npm.version() > 3:
                assert "ERR" not in output, "Something went wrong when typescript are installed."

        # Update TS dependencies
        update_script = os.path.join(TEST_RUN_HOME, path,
                                     "node_modules", ".bin", "ns-upgrade-tsconfig")
        run(update_script)
        if USE_YARN == "True":
            Npm.yarn_install(folder=path)
        else:
            Npm.install(folder=path)

        return output
Example #7
0
    def test_302_build_project_with_space_debug_with_plugin(self):
        Tns.platform_remove(
            platform=Platform.ANDROID,
            attributes={"--path": "\"" + self.app_name_space + "\""},
            assert_success=False)

        Npm.install(package="nativescript-mapbox",
                    option="--save",
                    folder="\"" + self.app_name_space + "\"")
        output = Tns.build_android(
            attributes={"--path": "\"" + self.app_name_space + "\""})
        assert "Project successfully built" in output
    def install_npm(package='', option='', folder=None, log_level=CommandLogLevel.FULL):
        cmd = UPDATE_WEBPACK_PATH + " --configs --deps"
        Npm.install(package=package, option=option, folder=folder, log_level=log_level)
        if folder is not None:
            Folder.navigate_to(folder=folder, relative_from_current_folder=True)

        print cmd
        output = run(command=cmd)

        if folder is not None:
            Folder.navigate_to(TEST_RUN_HOME, relative_from_current_folder=False)

        return output
 def setUpClass(cls):
     BaseClass.setUpClass(cls.__name__)
     Process.kill('Safari')
     Process.kill('NativeScript Inspector')
     Emulator.stop()
     Simulator.stop()
     cls.SIMULATOR_ID = Simulator.ensure_available(simulator_name=SIMULATOR_NAME)
     Folder.cleanup(cls.INSPECTOR_GLOBAL_PATH)
     Tns.create_app(cls.app_name,
                    attributes={'--template': os.path.join('data', 'apps', 'livesync-hello-world.tgz')},
                    update_modules=True)
     Tns.platform_add_ios(attributes={'--path': cls.app_name, '--frameworkPath': IOS_PACKAGE})
     if USE_YARN == "True":
         Npm.install(package=IOS_INSPECTOR_PACKAGE, option='--dev', folder=cls.app_name)
     else:
         Npm.install(package=IOS_INSPECTOR_PACKAGE, option='--save-dev', folder=cls.app_name)
     Tns.build_ios(attributes={"--path": cls.app_name})
Example #10
0
 def install():
     package = File.find(base_path=SUT_FOLDER, file_name="nativescript")
     output = Npm.install(package=package, folder=TEST_RUN_HOME)
     message = "NativeScript CLI installation failed - \"{e}\" found in output."
     assert "dev-post-install" not in output, message.format(
         e="dev-post-install")
     cli_path = os.path.join(TEST_RUN_HOME, "node_modules", ".bin", "tns")
     assert File.exists(
         cli_path
     ), "NativeScript CLI installation failed - tns does not exist."
    def update_modules(path):
        """
        Update modules for {N} project
        :param path: Path to {N} project
        :return: Output of command that update tns-core-modules plugin.
        """

        # Escape path with spaces
        if " " in path:
            path = "\"" + path + "\""

        if USE_YARN == "True":
            Npm.uninstall(package="tns-core-modules", folder=path)
            output = Npm.install(package=MODULES_PACKAGE, folder=path)
        else:
            Npm.uninstall(package="tns-core-modules", option="--save", folder=path)
            output = Npm.install(package=MODULES_PACKAGE, option="--save", folder=path)
            if Npm.version() > 3:
                assert "ERR" not in output, "Something went wrong when modules are installed."
        return output
    def test_300_build_project_with_dash_and_ios_inspector_added(self):
        """
        Verify we can build projects with dashes.
        Verify we can build android when inspector is added (test for CLI issue 2467)
        """
        Tns.create_app(self.app_name_dash)
        Tns.platform_add_android(attributes={"--path": self.app_name_dash, "--frameworkPath": ANDROID_PACKAGE})
        if USE_YARN == "True":
            Npm.install(package="tns-ios-inspector", option='--dev', folder=self.app_name_dash)
        else:
            Npm.install(package="tns-ios-inspector", option='--save-dev', folder=self.app_name_dash)
        Tns.build_android(attributes={"--path": self.app_name_dash})

        # Verify project id
        output = File.read(self.app_name_dash + "/package.json")
        assert app_identifier in output.lower()

        # Verify AndroidManifest.xml
        output = File.read(self.app_name_dash + "/" + TnsAsserts.PLATFORM_ANDROID_SRC_MAIN_PATH + "AndroidManifest.xml")
        assert app_identifier in output.lower()
Example #13
0
    def install_npm(package='',
                    option='',
                    folder=None,
                    log_level=CommandLogLevel.FULL):
        cmd = UPDATE_WEBPACK_PATH + " --configs --deps"
        Npm.install(package=package,
                    option=option,
                    folder=folder,
                    log_level=log_level)
        if folder is not None:
            Folder.navigate_to(folder=folder,
                               relative_from_current_folder=True)

        print cmd
        output = run(command=cmd)

        if folder is not None:
            Folder.navigate_to(TEST_RUN_HOME,
                               relative_from_current_folder=False)

        return output
Example #14
0
    def update_webpack(path):
        """
        Update modules for {N} project
        :param path: Path to {N} project
        :return: Output of command that update nativescript-dev-webpack plugin.
        """

        # Escape path with spaces
        if " " in path:
            path = "\"" + path + "\""

        if USE_YARN == "True":
            Npm.uninstall(package="nativescript-dev-webpack",
                          option="--dev",
                          folder=path)
            output = Npm.install(package=WEBPACK_PACKAGE,
                                 option="--dev",
                                 folder=path)
        else:
            Npm.uninstall(package="nativescript-dev-webpack",
                          option="--save-dev",
                          folder=path)
            output = Npm.install(package=WEBPACK_PACKAGE,
                                 option="--save-dev",
                                 folder=path)
            if Npm.version() > 3:
                assert "ERR" not in output, "Something went wrong when webpack are installed."

        # Update webpack dependencies
        update_script = os.path.join(TEST_RUN_HOME, path, "node_modules",
                                     ".bin",
                                     "update-ns-webpack --deps --configs")
        run(update_script)
        if USE_YARN == "True":
            Folder.cleanup(
                folder=os.path.join(TEST_RUN_HOME, path, "node_modules"))
            Npm.yarn_install(folder=path)
        else:
            Npm.install(folder=path)
        return output
Example #15
0
    def test_320_build_ios_with_custom_entitlements(self):
        Tns.build_ios(attributes={"--path": self.app_name})

        # Add entitlements in app/App_Resources/iOS/app.entitlements
        source = os.path.join(TEST_RUN_HOME, 'data', 'entitlements',
                              'app.entitlements')
        target = os.path.join(self.app_name, 'app', 'App_Resources', 'iOS',
                              'app.entitlements')
        File.copy(src=source, dest=target)

        # Build again and verify entitlements are merged
        Tns.build_ios(attributes={"--path": self.app_name})
        entitlements_path = self.app_name + '/platforms/ios/' + self.app_name + '/' + self.app_name + '.entitlements'
        assert File.exists(entitlements_path), "Entitlements file is missing!"
        entitlements_content = File.read(entitlements_path)
        assert '<key>aps-environment</key>' in entitlements_content, "Entitlements file content is wrong!"
        assert '<string>development</string>' in entitlements_content, "Entitlements file content is wrong!"

        # Install plugin with entitlements, build again and verify entitlements are merged
        plugin_path = os.path.join(TEST_RUN_HOME, 'data', 'plugins',
                                   'nativescript-test-entitlements-1.0.0.tgz')
        Npm.install(package=plugin_path, option='--save', folder=self.app_name)
        Tns.build_ios(attributes={"--path": self.app_name})
        entitlements_content = File.read(entitlements_path)
        assert '<key>aps-environment</key>' in entitlements_content, "Entitlements file content is wrong!"
        assert '<string>development</string>' in entitlements_content, "Entitlements file content is wrong!"
        assert '<key>inter-app-audio</key>' in entitlements_content, "Entitlements file content is wrong!"
        assert '<true/>' in entitlements_content, "Entitlements file content is wrong!"

        # Build in release, for device (provision without entitlements)
        output = Tns.build_ios(attributes={
            "--path": self.app_name,
            "--forDevice": "",
            "--release": ""
        },
                               assert_success=False)
        assert "Provisioning profile " in output
        assert "doesn't include the aps-environment and inter-app-audio entitlements" in output
Example #16
0
    def update_modules(path):
        """
        Update modules for {N} project
        :param path: Path to {N} project
        :return: Output of command that update tns-core-modules plugin.
        """

        # Escape path with spaces
        if " " in path:
            path = "\"" + path + "\""

        if USE_YARN == "True":
            Npm.uninstall(package="tns-core-modules", folder=path)
            output = Npm.install(package=MODULES_PACKAGE, folder=path)
        else:
            Npm.uninstall(package="tns-core-modules",
                          option="--save",
                          folder=path)
            output = Npm.install(package=MODULES_PACKAGE,
                                 option="--save",
                                 folder=path)
            if Npm.version() > 3:
                assert "ERR" not in output, "Something went wrong when modules are installed."
        return output
Example #17
0
    def update_angular(path):
        """
        Update modules for {N} project
        :param path: Path to {N} project
        :return: Output of command that update nativescript-angular plugin.
        """

        # Escape path with spaces
        if " " in path:
            path = "\"" + path + "\""

        if USE_YARN == "True":
            Npm.uninstall(package="nativescript-angular", folder=path)
            output = Npm.install(package=ANGULAR_PACKAGE, folder=path)
        else:
            Npm.uninstall(package="nativescript-angular",
                          option="--save",
                          folder=path)
            output = Npm.install(package=ANGULAR_PACKAGE,
                                 option="--save",
                                 folder=path)
            if Npm.version() > 3:
                assert "ERR" not in output, "Something went wrong when angular are installed."

        # Update NG dependencies
        update_script = os.path.join(TEST_RUN_HOME, path, "node_modules",
                                     ".bin", "update-app-ng-deps")
        update_out = run(update_script)
        assert "Angular dependencies updated" in update_out

        if USE_YARN == "True":
            Npm.yarn_install(folder=path)
        else:
            Npm.install(folder=path)

        return output
Example #18
0
 def test_401_prepare_project_with_many_dependencies(self):
     """
     Test for https://github.com/NativeScript/nativescript-cli/issues/2561
     """
     Folder.cleanup(self.app_name)
     Tns.create_app_ng(app_name=self.app_name, template_version="4", update_modules=False)
     if USE_YARN == "True":
         Npm.install(package="lodash", folder=self.app_name)
         Npm.install(package="moment", folder=self.app_name)
         Npm.install(package="nativescript-cardview", folder=self.app_name)
         Npm.install(package="nativescript-sqlite", folder=self.app_name)
         Npm.install(package="nativescript-statusbar", folder=self.app_name)
         Npm.install(package="nativescript-websockets", folder=self.app_name)
         Npm.install(package="number-generator", folder=self.app_name)
         Npm.install(package="eslint", folder=self.app_name)
         Npm.install(package="eslint-plugin-compat", folder=self.app_name)
     else:
         Npm.install(package="lodash", option="--save", folder=self.app_name)
         Npm.install(package="moment", option="--save", folder=self.app_name)
         Npm.install(package="nativescript-cardview", option="--save", folder=self.app_name)
         Npm.install(package="nativescript-sqlite", option="--save", folder=self.app_name)
         Npm.install(package="nativescript-statusbar", option="--save", folder=self.app_name)
         Npm.install(package="nativescript-websockets", option="--save", folder=self.app_name)
         Npm.install(package="number-generator", option="--save", folder=self.app_name)
         Npm.install(package="eslint", option="--save", folder=self.app_name)
         Npm.install(package="eslint-plugin-compat", option="--save", folder=self.app_name)
     Tns.platform_add_android(version="4", attributes={"--path": self.app_name})
     Tns.prepare_android(attributes={"--path": self.app_name}, log_trace=True)
    def test_302_build_project_with_space_debug_with_plugin(self):
        Tns.platform_remove(platform=Platform.ANDROID, attributes={"--path": "\"" + self.app_name_space + "\""}, assert_success=False)

        Npm.install(package="nativescript-mapbox", option="--save", folder="\"" + self.app_name_space + "\"")
        output = Tns.build_android(attributes={"--path": "\"" + self.app_name_space + "\""})
        assert "Project successfully built" in output