private static void GetNPMLoginToken(ScopedRegistry registry, string username, string password)
        {
            NPMResponse response = NPM.GetLoginToken(registry.url, username, password);

            if (string.IsNullOrEmpty(response.ok))
            {
                EditorUtility.DisplayDialog("Cannot get token", response.error, "Ok");
            }
            else
            {
                registry.token = response.token;
            }
        }
 private static void GetBintrayToken(ScopedRegistry registry, string username, string password)
 {
     registry.token = NPM.GetBintrayToken(username, password);
 }
Beispiel #3
0
        internal PublicationManifest(string packageFolder, string registry)
        {
            CreateTarball(packageFolder);

            JObject manifest = LoadManifest(packageFolder);

            name = manifest["name"].ToString();
            string version     = manifest["version"].ToString();
            string description = manifest["description"].ToString();

            string tarballName = name + "-" + version + ".tgz";
            string tarballPath = name + "/-/" + tarballName;


            string tarballUri = NPM.UrlCombine(registry, tarballPath);

            tarballUri = Regex.Replace(tarballUri, @"^https:\/\/", "http://");


            string readmeFile = GetReadmeFilename(packageFolder);
            string readme     = null;

            if (readmeFile != null)
            {
                readme = GetReadme(readmeFile);
            }



            j["_id"]         = name;
            j["name"]        = name;
            j["description"] = description;



            j["dist-tags"]           = new JObject();
            j["dist-tags"]["latest"] = version;


            j["versions"]          = new JObject();
            j["versions"][version] = manifest;

            if (!string.IsNullOrEmpty(readmeFile))
            {
                j["versions"][version]["readme"]         = readme;
                j["versions"][version]["readmeFilename"] = readmeFile;
            }

            j["versions"][version]["_id"] = name + "@" + version;


            // Extra options set by the NPM client. Will not set here as they do not seem neccessary.

            // j["versions"][version]["_npmUser"] = new JObject();
            // j["versions"][version]["_npmUser"]["name"] = "";
            // j["versions"][version]["_npmUser"]["email"] = "";
            // j["versions"][version]["_npmVersion"] = "6.14.4";
            // j["versions"][version]["_nodeVersion"] = "12.16.2";

            j["versions"][version]["dist"] = new JObject();
            j["versions"][version]["dist"]["integrity"] = sha512;
            j["versions"][version]["dist"]["shasum"]    = sha1;
            j["versions"][version]["dist"]["tarball"]   = tarballUri.ToString();

            if (!string.IsNullOrEmpty(readme))
            {
                j["readme"] = readme;
            }

            j["_attachments"] = new JObject();
            j["_attachments"][tarballName] = new JObject();
            j["_attachments"][tarballName]["content_type"] = "application/octet-stream";
            j["_attachments"][tarballName]["length"]       = new JValue(size);
            j["_attachments"][tarballName]["data"]         = base64Data;
        }