示例#1
0
        /// <summary>
        /// Generates the .tgz file in the <see cref="StandardGlobalInfo.ReleasesFolder"/>
        /// by calling npm pack.
        /// </summary>
        /// <param name="globalInfo">The global information object.</param>
        /// <param name="cleanupPackageJson">
        /// By default, "scripts" and "devDependencies" are removed from the package.json file.
        /// </param>
        /// <param name="packageJsonPreProcessor">Optional package.json pre processor.</param>
        public void RunPack(Action <JObject> packageJsonPreProcessor = null)
        {
            using (TemporaryPrePack(ArtifactInstance.Version, packageJsonPreProcessor))
            {
                GlobalInfo.Cake.NpmPack(new NpmPackSettings()
                {
                    LogLevel         = NpmLogLevel.Info,
                    WorkingDirectory = OutputPath.ToString()
                });
            }
            var tgz = OutputPath.AppendPart(TGZName);

            if (!File.Exists(tgz))
            {
                GlobalInfo.Cake.TerminateWithError($"Package file '{tgz}' has not been generated by 'npm pack'.");
            }
            var target = GlobalInfo.ReleasesFolder.AppendPart(TGZName);

            GlobalInfo.Cake.CopyFile(tgz.Path, target.Path);
            GlobalInfo.Cake.DeleteFile(tgz.Path);
        }
        /// <summary>
        /// Generates the .tgz file in the <see cref="StandardGlobalInfo.ReleasesFolder"/>
        /// by calling npm pack.
        /// </summary>
        /// <param name="globalInfo">The global information object.</param>
        /// <param name="cleanupPackageJson">
        /// By default, "scripts" and "devDependencies" are removed from the package.json file.
        /// </param>
        /// <param name="packageJsonPreProcessor">Optional package.json pre processor.</param>
        public void RunPack(Action <JObject> packageJsonPreProcessor = null)
        {
            var tgz = OutputPath.AppendPart(TGZName);

            using (TemporarySetPackageVersion(ArtifactInstance.Version, true))
            {
                using (TemporaryPrePack(ArtifactInstance.Version, packageJsonPreProcessor, false))
                {
                    GlobalInfo.Cake.NpmPack(new NpmPackSettings()
                    {
                        LogLevel         = NpmLogLevel.Info,
                        WorkingDirectory = OutputPath.ToString()
                    });
                }

                if (_ckliLocalFeedMode)
                {
                    //It meant that we just build a "dirty" package: we need to build the one that will actually get published.
                    File.Move(tgz, tgz.Path + ".local");
                    using (TemporaryPrePack(ArtifactInstance.Version, packageJsonPreProcessor, true))
                    {
                        GlobalInfo.Cake.NpmPack(new NpmPackSettings()
                        {
                            LogLevel         = NpmLogLevel.Info,
                            WorkingDirectory = OutputPath.ToString()
                        });
                    }
                }
            }
            if (!File.Exists(tgz))
            {
                GlobalInfo.Cake.TerminateWithError($"Package file '{tgz}' has not been generated by 'npm pack'.");
            }
            var target = GlobalInfo.ReleasesFolder.AppendPart(TGZName);

            GlobalInfo.Cake.CopyFile(tgz.Path, target.Path);
            GlobalInfo.Cake.DeleteFile(tgz.Path);
        }
示例#3
0
 private protected IDisposable TemporaryPrePack(SVersion version, Action <JObject> packageJsonPreProcessor)
 {
     return(TempFileTextModification.TemporaryReplacePackageVersion(NpmSolution, OutputPath.AppendPart("package.json"), version, true, packageJsonPreProcessor));
 }
示例#4
0
 private protected IDisposable TemporaryPrePack(SVersion version, Action <JObject> packageJsonPreProcessor, bool ckliLocalFeedMode)
 {
     return(TempFileTextModification.TemporaryReplaceDependenciesVersion(NpmSolution, OutputPath.AppendPart("package.json"), ckliLocalFeedMode, version, packageJsonPreProcessor));
 }
示例#5
0
 private protected IDisposable TemporarySetPackageVersion(SVersion version, bool targetOutputPath = false)
 {
     return(TempFileTextModification.TemporaryReplacePackageVersion(!targetOutputPath ? PackageJson.JsonFilePath : OutputPath.AppendPart("package.json"), version));
 }