Exemple #1
0
        public TemplateMeta GetTemplateMeta(Project project, string templateName)
        {
            var templates = GetLocalTemplates();
            var template  = templates.FirstOrDefault(t => t.Name == templateName);

            if (template != null && project.Templates.Keys.Contains(templateName))
            {
                var templatePath = Path.Combine(project.TemplateDirectory, templateName);
                if (!_fileUtil.DirectoryExists(templatePath))
                {
                    throw new System.Exception("Could not find template directory: " + templatePath);
                }
                var templateConfigFile = Path.Combine(templatePath, "nebula-meta.json");
                if (!_fileUtil.FileExists(templateConfigFile))
                {
                    throw new System.Exception("Could not find template meta file: " + templateConfigFile);
                }
                var templateMeta = JsonConvert.DeserializeObject <TemplateMeta>(_fileUtil.FileReadAllText(templateConfigFile));
                if (templateMeta == null)
                {
                    throw new System.Exception("Error reading template meta file: " + templateConfigFile);
                }
                templateMeta.TemplatePath = templatePath;
                templateMeta.TemplateData = template;
                return(templateMeta);
            }

            return(null);
        }
Exemple #2
0
        public Project LoadProject(string location)
        {
            var projectFile = Path.Combine(location, "nebula.json");

            if (!_fileUtil.FileExists(projectFile))
            {
                throw new Exception("Could not find nebula.json in current directory");
            }
            var project = JsonConvert.DeserializeObject <Project>(_fileUtil.FileReadAllText(projectFile));

            project.SourceDirectory   = Path.Combine(location, "src");
            project.TemplateDirectory = Path.Combine(location, "templates");
            project.OutputDirectory   = Path.Combine(location, "out");
            project.ManifestDirectory = Path.Combine(location, "manifest");
            project.ProjectDirectory  = location;
            if (!_fileUtil.DirectoryExists(project.SourceDirectory))
            {
                throw new Exception("Could not find src directory within project structure");
            }
            _currentProject = project;
            return(project);
        }
        public string Provide(Func <string> solutionFolderProvider)
        {
            var solutionFolder = solutionFolderProvider();

            if (solutionFolder != null)
            {
                var provided = Path.Combine(solutionFolder, fccOutputFolderName);
                if (fileUtil.DirectoryExists(provided))
                {
                    return(provided);
                }
            }
            return(null);
        }