Example #1
0
        private async Task Import(string[] args)
        {
            if (!args.Any())
            {
                await Out.WriteLineAsync("No import target defined");

                return;
            }

            var deliveryName = args[0].Trim();

            string directory;

            if (!settings.TryGetChauffeurDirectory(out directory))
            {
                return;
            }

            var file = fileSystem.Path.Combine(directory, deliveryName + ".xml");

            if (!fileSystem.File.Exists(file))
            {
                await Out.WriteLineFormattedAsync("Unable to located the import script '{0}'", deliveryName);

                return;
            }

            var xml = XDocument.Load(file);

            packagingService.ImportContentTypes(xml.Elements().First());

            await Out.WriteLineFormattedAsync("Content Type has been imported");
        }
        public async override Task <DeliverableResponse> Run(string command, string[] args)
        {
            string path;

            if (settings.TryGetSiteRootDirectory(out path))
            {
                await Out.WriteLineFormattedAsync("Site root directory: {0}", path);
            }
            else
            {
                await Out.WriteLineAsync("Unable to locate the site root directory");
            }

            if (settings.TryGetUmbracoDirectory(out path))
            {
                await Out.WriteLineFormattedAsync("Umbraco directory: {0}", path);
            }
            else
            {
                await Out.WriteLineAsync("Unable to locate the Umbraco directory");
            }

            if (settings.TryGetChauffeurDirectory(out path))
            {
                await Out.WriteLineFormattedAsync("Chauffeur directory: {0}", path);
            }
            else
            {
                await Out.WriteLineAsync("Unable to locate the Chauffeur directory");
            }

            await Out.WriteLineFormattedAsync("Connection string: {0}", settings.ConnectionString);

            return(DeliverableResponse.Continue);
        }
        public override async Task <DeliverableResponse> Run(string command, string[] args)
        {
            var packages = args.Where(a => !a.StartsWith("-f:"));

            if (!packages.Any())
            {
                await Out.WriteLineAsync("No packages were provided, use `help package` to see usage");

                return(DeliverableResponse.Continue);
            }

            string chauffeurFolder;

            var overridePath = args.FirstOrDefault(a => a.StartsWith("-f:"));

            if (overridePath != null)
            {
                chauffeurFolder = overridePath.Replace("-f:", string.Empty);
            }
            else
            {
                if (!settings.TryGetChauffeurDirectory(out chauffeurFolder))
                {
                    return(DeliverableResponse.Continue);
                }
            }

            var tasks = packages.Select(pkg => Unpack(pkg, chauffeurFolder));
            await Task.WhenAll(tasks);

            return(DeliverableResponse.Continue);
        }
Example #4
0
        public override async Task <DeliverableResponse> Run(string command, string[] args)
        {
            if (!args.Any())
            {
                await Out.WriteLineAsync("No packages were provided, use `help dictionary` to see usage");

                return(DeliverableResponse.Continue);
            }

            string chauffeurFolder;

            if (!settings.TryGetChauffeurDirectory(out chauffeurFolder))
            {
                return(DeliverableResponse.Continue);
            }

            bool importLangs = false;

            if (args.Length > 1)
            {
                var operation = args[1];
                switch (operation.ToLower())
                {
                case "y":
                case "yes":
                    importLangs = true;
                    break;
                }
            }

            await Unpack(args[0], chauffeurFolder, importLangs);

            return(DeliverableResponse.Continue);
        }
Example #5
0
        public async override Task <DeliverableResponse> Run(string command, string[] args)
        {
            var dic = new Dictionary <string, string>
            {
                { "Umbraco Version", settings.UmbracoVersion },
                { "Chauffeur Version", settings.ChauffeurVersion }
            };

            if (settings.TryGetSiteRootDirectory(out string path))
            {
                dic.Add("Site Root", path);
            }
            else
            {
                dic.Add("Site Root", "Failed to access");
            }

            if (settings.TryGetUmbracoDirectory(out path))
            {
                dic.Add("Umbraco Directory", path);
            }
            else
            {
                dic.Add("Umbraco Directory", "Failed to access");
            }

            if (settings.TryGetChauffeurDirectory(out path))
            {
                dic.Add("Chauffeur Directory", path);
            }
            else
            {
                dic.Add("Chauffeur Directory", "Failed to access");
            }

            dic.Add("Connection String", settings.ConnectionString.ConnectionString);

            await Out.WriteTableAsync(dic.Keys.Select(key => new
            {
                Setting = key,
                Value   = dic[key]
            }));

            return(DeliverableResponse.Continue);
        }
        public override async Task <DeliverableResponse> Run(string command, string[] args)
        {
            if (!args.Any())
            {
                await Out.WriteLineAsync("No packages were provided, use `help content-export` to see usage");

                return(DeliverableResponse.Continue);
            }

            string chauffeurFolder;

            if (!settings.TryGetChauffeurDirectory(out chauffeurFolder))
            {
                return(DeliverableResponse.Continue);
            }

            var tasks = args.Select(arg => Pack(arg, chauffeurFolder));
            await Task.WhenAll(tasks);

            return(DeliverableResponse.Continue);
        }
Example #7
0
        public override async Task <DeliverableResponse> Run(string command, string[] args)
        {
            var dbNotReady = false;

            try
            {
                if (!dbSchemaHelper.TableExist(TableName))
                {
                    if (!await SetupDatabase())
                    {
                        return(DeliverableResponse.FinishedWithError);
                    }
                }
            }
            catch (DbException)
            {
                Out.WriteLine("There was an error checking for the database Chauffeur Delivery tracking table, most likely your connection string is invalid or your database doesn't exist.");
                Out.WriteLine("Chauffeur will attempt to run the first delivery, expecting it to call `install`.");
                dbNotReady = true;
            }

            string directory;

            if (!settings.TryGetChauffeurDirectory(out directory))
            {
                await Out.WriteLineAsync("Error accessing the Chauffeur directory. Check your file system permissions");

                return(DeliverableResponse.Continue);
            }

            var allDeliveries = fileSystem.Directory
                                .GetFiles(directory, "*.delivery", SearchOption.TopDirectoryOnly)
                                .ToArray();

            if (!allDeliveries.Any())
            {
                await Out.WriteLineAsync("No deliveries found.");

                return(DeliverableResponse.Continue);
            }

            var @params = args.Where(arg => arg.StartsWith("-p:"))
                          .Select(arg => arg.TrimStart(new[] { '-', 'p', ':' }))
                          .Select(arg => arg.Split('='))
                          .ToDictionary(arg => arg[0], arg => arg[1]);

            if (dbNotReady)
            {
                try
                {
                    var delivery = allDeliveries.First();
                    var file     = fileSystem.FileInfo.FromFileName(delivery);

                    var tracking = await Deliver(file, @params);

                    if (!tracking.SignedFor)
                    {
                        return(DeliverableResponse.FinishedWithError);
                    }

                    if (!await SetupDatabase())
                    {
                        return(DeliverableResponse.FinishedWithError);
                    }

                    database.Save(tracking);

                    allDeliveries = allDeliveries.Skip(1).ToArray();
                }
                catch (DbException)
                {
                    Out.WriteLine("Ok, I tried. Chauffeur had a database error, either a missing connection string or the DB couldn't be setup.");
                    return(DeliverableResponse.FinishedWithError);
                }
            }

            await ProcessDeliveries(allDeliveries, @params);

            return(DeliverableResponse.Continue);
        }