Beispiel #1
0
        public void UpdatePackageVersionWithExistingPackageNameAndPackageVersionSpecified()
        {
            GeneratorSettingsJs settings = new GeneratorSettingsJs();

            settings.PackageName    = "npm";
            settings.PackageVersion = "1.2.3";

            settings.UpdatePackageVersion();

            Assert.AreEqual("npm", settings.PackageName);
            Assert.AreEqual("1.2.3", settings.PackageVersion);
        }
Beispiel #2
0
        /// <summary>
        ///     Generate NodeJS client code
        /// </summary>
        /// <param name="serviceClient"></param>
        /// <returns></returns>
        public override async Task Generate(CodeModel cm)
        {
            GeneratorSettingsJs generatorSettings = Singleton <GeneratorSettingsJs> .Instance;

            var codeModel = cm as CodeModelJs;

            if (codeModel == null)
            {
                throw new InvalidCastException("CodeModel is not a NodeJS code model.");
            }

            generatorSettings.UpdatePackageVersion();
            codeModel.PopulateFromSettings(generatorSettings);

            // Service client
            await GenerateServiceClientJs(() => new ServiceClientTemplate { Model = codeModel }, generatorSettings).ConfigureAwait(false);

            await GenerateServiceClientDts(() => new ServiceClientTemplateTS { Model = codeModel }, generatorSettings).ConfigureAwait(false);

            //Models
            if (codeModel.ModelTypes.Any())
            {
                await GenerateModelIndexJs(() => new ModelIndexTemplate { Model = codeModel }, generatorSettings).ConfigureAwait(false);

                await GenerateModelIndexDts(codeModel, generatorSettings).ConfigureAwait(false);

                foreach (CompositeTypeJs modelType in codeModel.ModelTemplateModels)
                {
                    await GenerateModelJs(modelType, generatorSettings).ConfigureAwait(false);
                }
            }

            //MethodGroups
            if (codeModel.MethodGroupModels.Any())
            {
                await GenerateMethodGroupIndexTemplateJs(codeModel, generatorSettings).ConfigureAwait(false);

                await GenerateMethodGroupIndexTemplateDts(codeModel, generatorSettings).ConfigureAwait(false);

                foreach (MethodGroupJs methodGroupModel in codeModel.MethodGroupModels)
                {
                    await GenerateMethodGroupJs(() => new MethodGroupTemplate { Model = methodGroupModel }, generatorSettings).ConfigureAwait(false);
                }
            }

            await GeneratePackageJson(codeModel, generatorSettings).ConfigureAwait(false);

            await GenerateReadmeMd(codeModel, generatorSettings).ConfigureAwait(false);

            await GenerateLicenseTxt(codeModel, generatorSettings).ConfigureAwait(false);

            await GeneratePostinstallScript(codeModel, generatorSettings).ConfigureAwait(false);
        }
Beispiel #3
0
        public void UpdatePackageVersionWithNonExistingPackageNameAndPackageVersionSpecified()
        {
            GeneratorSettingsJs settings = new GeneratorSettingsJs();

            settings.PackageName    = "idontexistandyoucantinstallme";
            settings.PackageVersion = "2.3.4";

            settings.UpdatePackageVersion();

            Assert.AreEqual("idontexistandyoucantinstallme", settings.PackageName);
            Assert.AreEqual("2.3.4", settings.PackageVersion);
        }
Beispiel #4
0
        public void UpdatePackageVersionWithNonExistingPackageName()
        {
            GeneratorSettingsJs settings = new GeneratorSettingsJs();

            settings.PackageName = "idontexistandyoucantinstallme";
            Assert.IsNull(settings.PackageVersion);

            settings.UpdatePackageVersion();

            Assert.AreEqual("idontexistandyoucantinstallme", settings.PackageName);
            Assert.AreEqual("1.0.0", settings.PackageVersion);
        }
Beispiel #5
0
        public void UpdatePackageVersionWithEmptyPackageName()
        {
            GeneratorSettingsJs settings = new GeneratorSettingsJs();

            settings.PackageName = "";
            Assert.IsNull(settings.PackageVersion);

            settings.UpdatePackageVersion();

            Assert.AreEqual("", settings.PackageName);
            Assert.IsNull(settings.PackageVersion);
        }
Beispiel #6
0
        public void UpdatePackageVersionWithNullPackageName()
        {
            GeneratorSettingsJs settings = new GeneratorSettingsJs();

            Assert.IsNull(settings.PackageName);
            Assert.IsNull(settings.PackageVersion);

            settings.UpdatePackageVersion();

            Assert.IsNull(settings.PackageName);
            Assert.IsNull(settings.PackageVersion);
        }
Beispiel #7
0
        public void UpdatePackageVersionWithExistingPackageName()
        {
            GeneratorSettingsJs settings = new GeneratorSettingsJs();

            settings.PackageName = "npm";
            Assert.IsNull(settings.PackageVersion);

            settings.UpdatePackageVersion();

            Assert.AreEqual("npm", settings.PackageName);
            AssertEx.NotNull(settings.PackageVersion);
            AssertEx.NotEmpty(settings.PackageVersion);
        }