Ejemplo n.º 1
0
 public static void Initialize(ITelemetryService service = null)
 {
     if (Current == null)
     {
         Current = new CookiecutterTelemetry(service);
     }
 }
        public void SetupTest()
        {
            _redirector = new MockRedirector();

            var output = TestData.GetTempPath("Cookiecutter", true);
            var outputProjectFolder = Path.Combine(output, "integration");
            var feedUrl             = new Uri(TestFeedPath);
            var installedPath       = TestInstalledTemplateFolderPath;
            var userConfigFilePath  = TestUserConfigFilePath;

            _gitClient               = GitClientProvider.Create(_redirector, null);
            _gitHubClient            = new GitHubClient();
            _cutterClient            = CookiecutterClientProvider.Create(null, _redirector);
            _telemetry               = new CookiecutterTelemetry(new TelemetryTestService());
            _installedTemplateSource = new LocalTemplateSource(installedPath, _gitClient);
            _gitHubTemplateSource    = new GitHubTemplateSource(_gitHubClient);
            _feedTemplateSource      = new FeedTemplateSource(feedUrl);
            _projectSystemClient     = new MockProjectSystemClient();

            _vm = new CookiecutterViewModel(
                _cutterClient,
                _gitHubClient,
                _gitClient,
                _telemetry,
                _redirector,
                _installedTemplateSource,
                _feedTemplateSource,
                _gitHubTemplateSource,
                ExecuteCommand,
                _projectSystemClient
                );

            _vm.UserConfigFilePath = userConfigFilePath;
            ((CookiecutterClient)_cutterClient).DefaultBasePath = outputProjectFolder;
        }
Ejemplo n.º 3
0
        public CookiecutterControl(Redirector outputWindow, ICookiecutterTelemetry telemetry, Uri feedUrl, Action <string> openFolder, Action updateCommandUI)
        {
            _updateCommandUI = updateCommandUI;

            _checkForUpdatesTimer       = new DispatcherTimer();
            _checkForUpdatesTimer.Tick += new EventHandler(CheckForUpdateTimer_Tick);

            string gitExeFilePath = GitClient.RecommendedGitFilePath;
            var    gitClient      = new GitClient(gitExeFilePath, outputWindow);
            var    gitHubClient   = new GitHubClient();

            ViewModel = new CookiecutterViewModel(
                CookiecutterClientProvider.Create(outputWindow),
                gitHubClient,
                gitClient,
                telemetry,
                outputWindow,
                new LocalTemplateSource(CookiecutterViewModel.DefaultInstalledFolderPath, gitClient),
                new FeedTemplateSource(feedUrl),
                new GitHubTemplateSource(gitHubClient),
                openFolder
                );

            ViewModel.UserConfigFilePath = CookiecutterViewModel.GetUserConfigPath();
            ViewModel.OutputFolderPath   = string.Empty; // leaving this empty for now, force user to enter one
            ViewModel.ContextLoaded     += ViewModel_ContextLoaded;
            ViewModel.HomeClicked       += ViewModel_HomeClicked;

            _searchPage = new CookiecutterSearchPage {
                DataContext = ViewModel
            };
            _optionsPage = new CookiecutterOptionsPage {
                DataContext = ViewModel
            };

            var pages = new List <Page>();

            pages.Add(_searchPage);
            pages.Add(_optionsPage);

            _pageSequence = new CollectionViewSource {
                Source = new ObservableCollection <Page>(pages)
            };
            PageCount = _pageSequence.View.OfType <object>().Count();

            PageSequence = _pageSequence.View;
            PageSequence.MoveCurrentToFirst();

            DataContext = this;

            InitializeComponent();

            _searchPage.SelectedTemplateChanged += SearchPage_SelectedTemplateChanged;
        }
Ejemplo n.º 4
0
        public CookiecutterControl(Redirector outputWindow, ICookiecutterTelemetry telemetry, Uri feedUrl, Action<string> openFolder, Action updateCommandUI) {
            _updateCommandUI = updateCommandUI;

            _checkForUpdatesTimer = new DispatcherTimer();
            _checkForUpdatesTimer.Tick += new EventHandler(CheckForUpdateTimer_Tick);

            string gitExeFilePath = GitClient.RecommendedGitFilePath;
            var gitClient = new GitClient(gitExeFilePath, outputWindow);
            var gitHubClient = new GitHubClient();
            ViewModel = new CookiecutterViewModel(
                CookiecutterClientProvider.Create(outputWindow),
                gitHubClient,
                gitClient,
                telemetry,
                outputWindow,
                new LocalTemplateSource(CookiecutterViewModel.DefaultInstalledFolderPath, gitClient),
                new FeedTemplateSource(feedUrl),
                new GitHubTemplateSource(gitHubClient),
                openFolder
            );

            ViewModel.UserConfigFilePath = CookiecutterViewModel.GetUserConfigPath();
            ViewModel.OutputFolderPath = string.Empty; // leaving this empty for now, force user to enter one
            ViewModel.ContextLoaded += ViewModel_ContextLoaded;
            ViewModel.HomeClicked += ViewModel_HomeClicked;

            _searchPage = new CookiecutterSearchPage { DataContext = ViewModel };
            _optionsPage = new CookiecutterOptionsPage { DataContext = ViewModel };

            var pages = new List<Page>();
            pages.Add(_searchPage);
            pages.Add(_optionsPage);

            _pageSequence = new CollectionViewSource {
                Source = new ObservableCollection<Page>(pages)
            };
            PageCount = _pageSequence.View.OfType<object>().Count();

            PageSequence = _pageSequence.View;
            PageSequence.MoveCurrentToFirst();

            DataContext = this;

            InitializeComponent();

            _searchPage.SelectedTemplateChanged += SearchPage_SelectedTemplateChanged;
        }
Ejemplo n.º 5
0
        public CookiecutterViewModel(ICookiecutterClient cutter, IGitHubClient githubClient, IGitClient gitClient, ICookiecutterTelemetry telemetry, Redirector outputWindow, ITemplateSource installedTemplateSource, ITemplateSource feedTemplateSource, ITemplateSource gitHubTemplateSource, Action <string> openFolder)
        {
            _cutterClient      = cutter;
            _githubClient      = githubClient;
            _gitClient         = gitClient;
            _telemetry         = telemetry;
            _outputWindow      = outputWindow;
            _recommendedSource = feedTemplateSource;
            _installedSource   = installedTemplateSource;
            _githubSource      = gitHubTemplateSource;
            _openFolder        = openFolder;

            Installed   = new CategorizedViewModel(Strings.TemplateCategoryInstalled);
            Recommended = new CategorizedViewModel(Strings.TemplateCategoryRecommended);
            GitHub      = new CategorizedViewModel(Strings.TemplateCategoryGitHub);
            Custom      = new CategorizedViewModel(Strings.TemplateCategoryCustom);
        }
Ejemplo n.º 6
0
        public CookiecutterViewModel(ICookiecutterClient cutter, IGitHubClient githubClient, IGitClient gitClient, ICookiecutterTelemetry telemetry, Redirector outputWindow, ILocalTemplateSource installedTemplateSource, ITemplateSource feedTemplateSource, ITemplateSource gitHubTemplateSource, Action <string, string> executeCommand, IProjectSystemClient projectSystemClient)
        {
            _cutterClient        = cutter;
            _githubClient        = githubClient;
            _gitClient           = gitClient;
            _telemetry           = telemetry;
            _outputWindow        = outputWindow;
            _recommendedSource   = feedTemplateSource;
            _installedSource     = installedTemplateSource;
            _githubSource        = gitHubTemplateSource;
            _executeCommand      = executeCommand;
            _projectSystemClient = projectSystemClient;

            Installed   = new CategorizedViewModel(Strings.TemplateCategoryInstalled);
            Recommended = new CategorizedViewModel(Strings.TemplateCategoryRecommended);
            GitHub      = new CategorizedViewModel(Strings.TemplateCategoryGitHub);
            Custom      = new CategorizedViewModel(Strings.TemplateCategoryCustom);
        }
Ejemplo n.º 7
0
        public void SetupTest() {
            _redirector = new MockRedirector();

            var output = TestData.GetTempPath("Cookiecutter", true);
            var outputProjectFolder = Path.Combine(output, "integration");
            var feedUrl = new Uri(TestFeedPath);
            var installedPath = TestInstalledTemplateFolderPath;
            var userConfigFilePath = TestUserConfigFilePath;

            _gitClient = GitClientProvider.Create(_redirector, null);
            _gitHubClient = new GitHubClient();
            _cutterClient = CookiecutterClientProvider.Create(null, _redirector);
            _telemetry = new CookiecutterTelemetry(new TelemetryTestService());
            _installedTemplateSource = new LocalTemplateSource(installedPath, _gitClient);
            _gitHubTemplateSource = new GitHubTemplateSource(_gitHubClient);
            _feedTemplateSource = new FeedTemplateSource(feedUrl);
            _projectSystemClient = new MockProjectSystemClient();

            _vm = new CookiecutterViewModel(
                _cutterClient,
                _gitHubClient,
                _gitClient,
                _telemetry,
                _redirector,
                _installedTemplateSource,
                _feedTemplateSource,
                _gitHubTemplateSource,
                OpenFolder,
                _projectSystemClient
            );

            _vm.UserConfigFilePath = userConfigFilePath;
            ((CookiecutterClient)_cutterClient).DefaultBasePath = outputProjectFolder;
        }
Ejemplo n.º 8
0
 public static void Initialize(ITelemetryService service = null) {
     if (Current == null) {
         Current = new CookiecutterTelemetry(service);
     }
 }
Ejemplo n.º 9
0
        public CookiecutterViewModel(ICookiecutterClient cutter, IGitHubClient githubClient, IGitClient gitClient, ICookiecutterTelemetry telemetry, Redirector outputWindow, ILocalTemplateSource installedTemplateSource, ITemplateSource feedTemplateSource, ITemplateSource gitHubTemplateSource, Action<string> openFolder, IProjectSystemClient projectSystemClient) {
            _cutterClient = cutter;
            _githubClient = githubClient;
            _gitClient = gitClient;
            _telemetry = telemetry;
            _outputWindow = outputWindow;
            _recommendedSource = feedTemplateSource;
            _installedSource = installedTemplateSource;
            _githubSource = gitHubTemplateSource;
            _openFolder = openFolder;
            _projectSystemClient = projectSystemClient;

            Installed = new CategorizedViewModel(Strings.TemplateCategoryInstalled);
            Recommended = new CategorizedViewModel(Strings.TemplateCategoryRecommended);
            GitHub = new CategorizedViewModel(Strings.TemplateCategoryGitHub);
            Custom = new CategorizedViewModel(Strings.TemplateCategoryCustom);
        }