private void FetchUser()
        {
            user        = string.Empty;
            userFetched = true;

            NpmCommands.WhoAmI(Registry, currentUser =>
            {
                user = currentUser;
                Refresh(false);
            });
        }
        private static void CopyDirectoryIfExists(TextAsset packageJsonAsset, string src, string dst)
        {
            var packageDirectory = NpmCommands.GetPackageDirectory(packageJsonAsset);

            var documentationSrcPath = packageDirectory + src;
            var documentationDstPath = packageDirectory + dst;

            if (Directory.Exists(documentationSrcPath))
            {
                FileUtil.ReplaceDirectory(documentationSrcPath, documentationDstPath);
            }
        }
Exemplo n.º 3
0
        public static void Execute(TextAsset packageJsonAsset, Action callback,
                                   NpmPublishCommandOptions options)
        {
            NpmCommands.SetWorkingDirectory(packageJsonAsset);

            if (options.CopyDocumentation)
            {
                CopyDirectoryIfExists(packageJsonAsset, "Documentation", "Documentation~");
            }

            if (options.CopySamples)
            {
                CopyDirectoryIfExists(packageJsonAsset, "Samples", "Samples~");
            }

#if NPM_PACKAGE_LOADER
            var packageJsonPath        = AssetDatabase.GetAssetPath(packageJsonAsset);
            var packageExternalLoaders = AssetDatabase
                                         .FindAssets($"t:{typeof(Loader).FullName}", new[] { Path.GetDirectoryName(packageJsonPath) })
                                         .Select(AssetDatabase.GUIDToAssetPath)
                                         .Select(AssetDatabase.LoadAssetAtPath <Loader>)
                                         .ToList();
#endif
            void Step(int index)
            {
#if NPM_PACKAGE_LOADER
                if (index != packageExternalLoaders.Count)
                {
                    var loader = packageExternalLoaders[index];

                    loader.Export(packageJsonAsset,
                                  () => Step(index + 1),
                                  () => Debug.LogError($"Failed to export {loader.name}"));
                }
                else
#endif
                {
                    NpmCommands.SetWorkingDirectory(packageJsonAsset);
                    NpmCommands.Publish((code, result) => callback(), NpmPublishWindow.Registry);
                }
            }

            Step(0);
        }
        private void OnGUI()
        {
            GUI.enabled = !NpmUtils.IsNpmRunning && !UpmClientUtils.IsUpmRunning;

            if (string.IsNullOrEmpty(Registry))
            {
                DrawNoRegistry();
                return;
            }

            if (string.IsNullOrEmpty(directory))
            {
                directory = NpmCommands.GetPackageDirectory(packageAsset);
            }

            NpmUtils.WorkingDirectory = directory;

            EditorGUI.BeginChangeCheck();
            DrawToolbar();
            if (EditorGUI.EndChangeCheck())
            {
                return;
            }

            if (!userFetched)
            {
                FetchUser();
            }

            if (string.IsNullOrEmpty(user))
            {
                DrawNotLoggedIn();
                return;
            }

            DrawContent();

            GUILayout.FlexibleSpace();

            GUI.enabled = true;
        }