Exemplo n.º 1
0
 public void Init()
 {
     this.manifest = new ScriptManifest();
     this.manifest.Name = "Outliner";
     this.manifest.Author = "Pier Janssen";
     this.manifest.Id = new ScriptId(this.manifest.Name, this.manifest.Author);
     this.manifest.Versions.Add(new ScriptVersion(1, 0, 0, ScriptReleaseStage.Release));
 }
Exemplo n.º 2
0
 /// <summary>
 /// Adds the ScriptManifest to the zip package.
 /// Only includes the supplied ScriptVersion in the package manifest versions list.
 /// </summary>
 /// <param name="manifest">The ScriptManifest instance to add.</param>
 /// <param name="version">The ScriptVersion to filter out from the manifest. All other versions will not be included.</param>
 public virtual void AddManifest(ScriptManifest manifest, ScriptVersion version)
 {
     ScriptManifest manifestCopy = manifest.Copy();
     ScriptVersion versionCopy = version.Copy();
     versionCopy.ScriptPath = ScriptManifestTokens.Replace(versionCopy.ScriptPath, manifest, version);
     manifestCopy.Versions = new List<ScriptVersion>() { versionCopy };
     using (StringWriter stringWriter = new StringWriter())
     {
         JsonFileHandler<ScriptManifest> handler = new JsonFileHandler<ScriptManifest>();
         handler.Write(stringWriter, manifestCopy);
         //TODO: change this to work with multiple manifests?
         _currentZipFile.AddEntry(PackageBuilder.InstallerArchivePath + "script" + ScriptManifest.DefaultExtension, stringWriter.ToString());
     }
 }
Exemplo n.º 3
0
        public void LatestVersionTest()
        {
            ScriptVersionNumber expectedVersion = new ScriptVersionNumber(2, 0, 96, ScriptReleaseStage.Release);
            Assert.AreEqual(expectedVersion, manifest.LatestVersion.VersionNumber, "Latest version");

            expectedVersion = new ScriptVersionNumber(3, 0, 0);
            manifest.Versions.Add(new ScriptVersion(expectedVersion));
            Assert.AreEqual(expectedVersion, manifest.LatestVersion.VersionNumber, "Added latest version");

            expectedVersion.Major = 1;
            Assert.AreNotEqual(expectedVersion, manifest.LatestVersion, "Changed version so that it no longer is the latest version.");

            ScriptManifest m = new ScriptManifest();
            Assert.AreEqual(0, m.Versions.Count, "Version count should be 0.");
            Assert.AreEqual(null, m.LatestVersion, "LatestVersion in empty manifest should be null");
        }
Exemplo n.º 4
0
        public void LatestStableVersionTest()
        {
            ScriptVersionNumber expectedVersion = new ScriptVersionNumber(2, 0, 96, ScriptReleaseStage.Release);
            Assert.AreEqual(expectedVersion, manifest.LatestStableVersion.VersionNumber, "Latest stable version 1");

            manifest.Versions.Add(new ScriptVersion(new ScriptVersionNumber(3, 0, 0, ScriptReleaseStage.Alpha)));
            manifest.Versions.Add(new ScriptVersion(new ScriptVersionNumber(3, 0, 0, ScriptReleaseStage.Beta)));
            Assert.AreEqual(expectedVersion, manifest.LatestStableVersion.VersionNumber, "Latest stable version 2");

            expectedVersion = new ScriptVersionNumber(3, 0, 0, ScriptReleaseStage.Release);
            manifest.Versions.Add(new ScriptVersion(expectedVersion));
            Assert.AreEqual(expectedVersion, manifest.LatestStableVersion.VersionNumber, "Latest stable version 3");

            ScriptManifest m = new ScriptManifest();
            Assert.AreEqual(0, m.Versions.Count, "Version count should be 0.");
            Assert.AreEqual(null, m.LatestStableVersion, "LatestStableVersion in empty manifest should be null");
        }
Exemplo n.º 5
0
        public ManifestForm(DevCenter devCenter, ScriptManifest manifest)
        {
            InitializeComponent();

            if (manifest == null)
                throw new ArgumentNullException("Manifest cannot be null");

            this.manifest = manifest;

            this.versionPropertyGrid.PropertyValueChanged += versionPropertyGrid_PropertyValueChanged;

            this.scriptManifestBindingSource.Add(manifest);

            this.versionsListView.BeginUpdate();
            foreach (ScriptVersion version in manifest.Versions)
                this.addVersionToListView(version);
            this.versionsListView.EndUpdate();
        }
Exemplo n.º 6
0
        private TreeNode addManifestToTree(ScriptManifest manifest, String filePath)
        {
            TreeNode tn = new TreeNode(manifest.Name);
            tn.ImageKey = tn.SelectedImageKey = "manifest";
            tn.Tag = new TreeNodeData(manifest, typeof(ManifestForm));

            TreeNode metadataTn = new TreeNode("Metadata");
            metadataTn.ImageKey = metadataTn.SelectedImageKey = "manifest_metadata";
            metadataTn.Tag = new TreeNodeData(manifest, typeof(ManifestMetadataForm));
            tn.Nodes.Add(metadataTn);

            this.filesTree.Nodes.Add(tn);
            this.Files.Add(manifest, filePath);

            manifest.PropertyChanged += new PropertyChangedEventHandler(propertyChanged);

            return tn;
        }
        public void ReplaceTokensTest()
        {
            ScriptManifest manifest = new ScriptManifest();
            manifest.Author = "Pier Janssen";
            manifest.Name = "Outliner";
            manifest.Id = new ScriptId(manifest.Name, manifest.Author);
            manifest.Versions.Add(new ScriptVersion(2, 9, 4, ScriptReleaseStage.Release));

            String origString = ScriptManifestTokens.Id_Token + " something " + ScriptManifestTokens.Name_Token + " " + ScriptManifestTokens.Id_Token;
            String exptectedString = manifest.Id.ToString() + " something " + manifest.Name + " " + manifest.Id.ToString();
            Assert.AreEqual(exptectedString, ScriptManifestTokens.Replace(origString, manifest, manifest.LatestVersion));

            origString = ScriptManifestTokens.Version_Token + " something " + ScriptManifestTokens.Author_Token;
            exptectedString = manifest.Versions[0].VersionNumber.ToString() + " something " + manifest.Author;
            Assert.AreEqual(exptectedString, ScriptManifestTokens.Replace(origString, manifest, manifest.LatestVersion));

            origString = ScriptManifestTokens.VersionMajor_Token + " " + ScriptManifestTokens.VersionMinor_Token + " " + ScriptManifestTokens.VersionRevision_Token + " " + ScriptManifestTokens.VersionStage_Token;
            exptectedString = manifest.Versions[0].VersionNumber.Major + " " + manifest.Versions[0].VersionNumber.Minor + " " + manifest.Versions[0].VersionNumber.Revision + " " + manifest.Versions[0].VersionNumber.ReleaseStage.ToString().ToLower();
            Assert.AreEqual(exptectedString, ScriptManifestTokens.Replace(origString, manifest, manifest.LatestVersion));
        }
Exemplo n.º 8
0
        /// <summary>
        /// Replaces any tokens in the string with values taken from the manifest.
        /// </summary>
        /// <param name="str">The string to replace tokens in.</param>
        /// <param name="manifest">The manifest to take values from.</param>
        /// <param name="version">The version to use for version-related tokens.</param>
        /// <returns>Returns the new string.</returns>
        internal static String Replace(String str, ScriptManifest manifest, ScriptVersion version)
        {
            if (str == null || manifest == null || version == null)
                return String.Empty;

            StringBuilder newString = new StringBuilder(str);

            newString.Replace(Id_Token, manifest.Id.ToString());
            newString.Replace(Name_Token, manifest.Name);
            newString.Replace(Author_Token, manifest.Author);
            newString.Replace(Version_Token, version.VersionNumber.ToString());
            newString.Replace(Version_Underscores_Token, version.VersionNumber.ToString(true));
            newString.Replace(VersionMajor_Token, version.VersionNumber.Major.ToString());
            newString.Replace(VersionMinor_Token, version.VersionNumber.Minor.ToString());
            newString.Replace(VersionRevision_Token, version.VersionNumber.Revision.ToString());
            newString.Replace(VersionStage_Token, version.VersionNumber.ReleaseStage.ToString().ToLower());
            newString.Replace(Date_Token, DateTime.Today.ToString("yyyy'-'MM'-'dd"));

            return newString.ToString();
        }
Exemplo n.º 9
0
        /// <summary>
        /// Writes a ScriptManifest to a file.
        /// </summary>
        /// <param name="manifest">The ScriptManifest to write.</param>
        /// <param name="filePath">The IPath instance of the file to write to.</param>
        /// <returns>True upon success.</returns>
        /// <remarks>Consider removing from this class.</remarks>
        public Boolean WriteManifest(ScriptManifest manifest, IPath filePath)
        {
            //Copy manifest and replace manifest tokens before writing.
            ScriptManifest manifestCopy = manifest.Copy();
            foreach (ScriptVersion v in manifestCopy.Versions)
            {
                v.ScriptPath = ScriptManifestTokens.Replace(v.ScriptPath, manifestCopy, v);
            }

            //Write manifest.
            filePath.AbsolutePath = ScriptManifestTokens.Replace(filePath.AbsolutePath, manifest, manifest.LatestVersion);
            try
            {
                JsonFileHandler<ScriptManifest> handler = new JsonFileHandler<ScriptManifest>();
                handler.Write(filePath, manifestCopy);
            }
            catch
            {
                return false;
            }

            return true;
        }
Exemplo n.º 10
0
 public Installer(String installerDirectory, ScriptManifest manifest, InstallerConfiguration config)
 {
     this.InstallerDirectory = installerDirectory;
     this.Manifest = manifest;
     this.Configuration = config;
 }
Exemplo n.º 11
0
        public void testInitialize()
        {
            this.outputFile = new BasePath(TestHelperMethods.GetOutputDirectory() + "/outliner" + ScriptManifest.DefaultExtension);

            this.manifest = new ScriptManifest();
            this.manifest.Name = "Outliner";
            this.manifest.Author = "Pier Janssen";
            this.manifest.Id = new ScriptId(this.manifest.Name, this.manifest.Author);
            this.manifest.Versions.Add(new ScriptVersion(2, 0, 96, ScriptReleaseStage.Release));
            this.manifest.Versions.Add(new ScriptVersion(2, 0, 95, ScriptReleaseStage.Release));
            this.manifest.Versions.Add(new ScriptVersion(2, 0, 94, ScriptReleaseStage.Release));
            this.manifest.Metadata.Add("description", "descr");
        }
Exemplo n.º 12
0
 private void writeManifest(IPath path, ScriptManifest manifest)
 {
     JsonFileHandler<ScriptManifest> handler = new JsonFileHandler<ScriptManifest>();
     try
     {
     handler.Write(path, manifest);
     }
     catch (Exception exc)
     {
     MessageBox.Show(exc.Message);
     }
 }
Exemplo n.º 13
0
 public void RegisterScript(ScriptManifest m)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 14
0
 public ManifestMetadataForm(DevCenter devCenter, ScriptManifest manifest)
 {
     InitializeComponent();
 }
Exemplo n.º 15
0
        private void button2_Click(object sender, EventArgs e)
        {
            /*
            ScriptCenter.Installer.NewInstallerWizard.NewInstallerWizard w = new Installer.NewInstallerWizard.NewInstallerWizard();
            w.Show();
             */
            ScriptManifest m = new ScriptManifest();
            m.Id = new ScriptId("nl.threesixty.outliner");
            m.Name = "Outliner";
            m.Versions.Add(new ScriptVersion(2, 0, 96, ScriptReleaseStage.Release));

            InstallerConfiguration config = new InstallerConfiguration();
            InstallerUIConfiguration uiConfig = new InstallerUIConfiguration();
        }
Exemplo n.º 16
0
        /// <summary>
        /// Adds the MZP files (readme, mzp.run, install.ms) to the zip package.
        /// </summary>
        /// <param name="manifest">The ScriptManifest to use to replace tokens in the mzp files.</param>
        /// <param name="version">The ScriptVersion to use to replace tokens in the mzp files.</param>
        public virtual void AddMzpFiles(ScriptManifest manifest, ScriptVersion version)
        {
            //Add mzp.run
            _currentZipFile.AddEntry("mzp.run", ScriptManifestTokens.Replace(PackageResources.mzp, manifest, version), Encoding.ASCII);

            //Add readme.txt
            _currentZipFile.AddEntry("README.txt", ScriptManifestTokens.Replace(PackageResources.README, manifest, version), Encoding.UTF8);

            //Add install.ms
            _currentZipFile.AddEntry(PackageBuilder.InstallerArchivePath + "install.ms", ScriptManifestTokens.Replace(PackageResources.install, manifest, version), Encoding.ASCII);
        }
Exemplo n.º 17
0
        private void newManifestButton_Click(object sender, EventArgs e)
        {
            this.switchNewButtonImageText(sender, newManifestButton_Click);

            ScriptManifest m = new ScriptManifest() { Name = "New Script" };
            m.Versions.Add(new ScriptVersion());
            TreeNode tn = addManifestToTree(m, String.Empty);
            tn.Expand();
            this.filesTree.SelectedNode = tn;
        }