• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript semver.major函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中semver.major函数的典型用法代码示例。如果您正苦于以下问题:TypeScript major函数的具体用法?TypeScript major怎么用?TypeScript major使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了major函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: gnomeTerminalVersion

    gnomeTerminalVersion((version: string) => {
      logHelper.logStepStarted('gnome-terminal');
      if (version === undefined || !semver.valid(version)) {
        logHelper.logSubStepFail('gnome-terminal doesn\'t seem to be installed');
        return;
      }

      if (semver.major(version) === 3 && semver.minor(version) >= 8 || semver.major(version) > 3) {
        execAndReportSync('applying profile theme (Gnome 3.8+)', path.join(__dirname, '../../data/gnome-terminal/profile-theme-3.8.sh'));
      } else {
        execAndReportSync('applying profile theme', path.join(__dirname, 'profile-theme.sh'));
      }
    });
开发者ID:Tyriar,项目名称:dotfiles,代码行数:13,代码来源:gnome-terminal.ts


示例2: ngOnInit

  ngOnInit() {
    let version = this.installation.version;
    let currentVersion = this.installation.currentVersion;
    let versionMatch = /^(([0-9]+\.){2}[0-9]+)/.exec(version);

    if (versionMatch) {
      version = versionMatch[1];
    } else {
      this.status = "outdated";
      return null;
    }

    let major = semver.major(version);
    let minor = semver.minor(version);
    let patch = semver.patch(version);

    let currentMajor = semver.major(currentVersion);
    let currentMinor = semver.minor(currentVersion);
    let currentPatch = semver.patch(currentVersion);

    if (
      semver.satisfies(
        `${major}.${minor}.${patch}`,
        `>=${currentMajor}.${currentMinor}.${currentPatch}`
      )
    ) {
      this.status = "up-to-date";
    } else if (
      semver.satisfies(
        `${major}.${minor}.${patch}`,
        `>=${currentMajor}.${currentMinor}.x`
      )
    ) {
      this.status = "same-minor";
    } else {
      this.status = "outdated";
    }
  }
开发者ID:isaacmg410,项目名称:decidim-monitor,代码行数:38,代码来源:app-installation.component.ts


示例3: getLatestCompatibleVersion

	public async getLatestCompatibleVersion(packageName: string, referenceVersion?: string): Promise<string> {
		referenceVersion = referenceVersion || this.$staticConfig.version;
		const isPreReleaseVersion = semver.prerelease(referenceVersion) !== null;
		// if the user has some v.v.v-prerelease-xx.xx pre-release version, include pre-release versions in the search query.
		const compatibleVersionRange = isPreReleaseVersion
			? `~${referenceVersion}`
			: `~${semver.major(referenceVersion)}.${semver.minor(referenceVersion)}.0`;
		const latestVersion = await this.getLatestVersion(packageName);
		if (semver.satisfies(latestVersion, compatibleVersionRange)) {
			return latestVersion;
		}

		const data = await this.$npm.view(packageName, { "versions": true });

		const maxSatisfying = semver.maxSatisfying(data, compatibleVersionRange);
		return maxSatisfying || latestVersion;
	}
开发者ID:NathanaelA,项目名称:nativescript-cli,代码行数:17,代码来源:npm-installation-manager.ts


示例4: useCpythonVersion

async function useCpythonVersion(parameters: Readonly<TaskParameters>, platform: Platform): Promise<void> {
    const desugaredVersionSpec = desugarDevVersion(parameters.versionSpec);
    const semanticVersionSpec = pythonVersionToSemantic(desugaredVersionSpec);
    task.debug(`Semantic version spec of ${parameters.versionSpec} is ${semanticVersionSpec}`);

    const installDir: string | null = tool.findLocalTool('Python', semanticVersionSpec, parameters.architecture);
    if (!installDir) {
        // Fail and list available versions
        const x86Versions = tool.findLocalToolVersions('Python', 'x86')
            .map(s => `${s} (x86)`)
            .join(os.EOL);

        const x64Versions = tool.findLocalToolVersions('Python', 'x64')
            .map(s => `${s} (x64)`)
            .join(os.EOL);

        throw new Error([
            task.loc('VersionNotFound', parameters.versionSpec, parameters.architecture),
            task.loc('ListAvailableVersions', task.getVariable('Agent.ToolsDirectory')),
            x86Versions,
            x64Versions,
            task.loc('ToolNotFoundMicrosoftHosted', 'Python', 'https://aka.ms/hosted-agent-software'),
            task.loc('ToolNotFoundSelfHosted', 'Python', 'https://go.microsoft.com/fwlink/?linkid=871498')
        ].join(os.EOL));
    }

    task.setVariable('pythonLocation', installDir);
    if (parameters.addToPath) {
        toolUtil.prependPathSafe(installDir);
        toolUtil.prependPathSafe(binDir(installDir, platform))

        if (platform === Platform.Windows) {
            // Add --user directory
            // `installDir` from tool cache should look like $AGENT_TOOLSDIRECTORY/Python/<semantic version>/x64/
            // So if `findLocalTool` succeeded above, we must have a conformant `installDir`
            const version = path.basename(path.dirname(installDir));
            const major = semver.major(version);
            const minor = semver.minor(version);

            const userScriptsDir = path.join(process.env['APPDATA'], 'Python', `Python${major}${minor}`, 'Scripts');
            toolUtil.prependPathSafe(userScriptsDir);
        }
        // On Linux and macOS, pip will create the --user directory and add it to PATH as needed.
    }
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:45,代码来源:usepythonversion.ts


示例5: getSemanticVersion

export function getSemanticVersion() {
    const options = minimist(process.argv.slice(2), {});
    let version = options.version;
    if (!version) {
        version = "0.0.0";
        console.log("No version argument provided, fallback to default version: " + version);
    } else {
        console.log("Found version: " + version);
    }

    if (!semver.valid(version)) {
        throw new Error("Package: invalid semver version: " + version);
    }

    let patch = semver.patch(version);

    if (!options.noversiontransform) {
        patch *= 1000;
        const prerelease = semver.prerelease(version);
        if (prerelease) {
            patch += parseInt(prerelease[1], 10);
        } else {
            patch += 999;
        }
    }

    const result = {
        major: semver.major(version),
        minor: semver.minor(version),
        patch,
        getVersionString() {
            return this.major.toString() + "." + this.minor.toString() + "." + this.patch.toString();
        },
    };

    console.log("Extension Version: " + result.getVersionString());

    return result;
}
开发者ID:geeklearningio,项目名称:gl-vsts-tasks-build-scripts,代码行数:39,代码来源:extension-version.ts


示例6: usePythonVersion

export async function usePythonVersion(parameters: Readonly<TaskParameters>, platform: Platform): Promise<void> {
    // Python's prelease versions look like `3.7.0b2`.
    // This is the one part of Python versioning that does not look like semantic versioning, which specifies `3.7.0-b2`.
    // If the version spec contains prerelease versions, we need to convert them to the semantic version equivalent
    const semanticVersionSpec = pythonVersionToSemantic(parameters.versionSpec);
    task.debug(`Semantic version spec of ${parameters.versionSpec} is ${semanticVersionSpec}`);

    const installDir: string | null = tool.findLocalTool('Python', semanticVersionSpec, parameters.architecture);
    if (!installDir) {
        // Fail and list available versions
        const x86Versions = tool.findLocalToolVersions('Python', 'x86')
            .map(s => `${s} (x86)`)
            .join(os.EOL);

        const x64Versions = tool.findLocalToolVersions('Python', 'x64')
            .map(s => `${s} (x64)`)
            .join(os.EOL);

        throw new Error([
            task.loc('VersionNotFound', parameters.versionSpec),
            task.loc('ListAvailableVersions'),
            x86Versions,
            x64Versions
        ].join(os.EOL));
    }

    task.setVariable('pythonLocation', installDir);
    if (parameters.addToPath) {
        toolUtil.prependPathSafe(installDir);

        // Make sure Python's "bin" directories are in PATH.
        // Python has "scripts" or "bin" directories where command-line tools that come with packages are installed.
        // This is where pip is, along with anything that pip installs.
        // There is a seperate directory for `pip install --user`.
        //
        // For reference, these directories are as follows:
        //   macOS / Linux:
        //      <sys.prefix>/bin (by default /usr/local/bin, but not on hosted agents -- see the `else`)
        //      (--user) ~/.local/bin
        //   Windows:
        //      <Python installation dir>\Scripts
        //      (--user) %APPDATA%\Python\PythonXY\Scripts
        // See https://docs.python.org/3/library/sysconfig.html
        if (platform === Platform.Windows) {
            // On Windows, these directories do not get added to PATH, so we will add them ourselves.
            const scriptsDir = path.join(installDir, 'Scripts');
            toolUtil.prependPathSafe(scriptsDir);

            // Add --user directory
            // `installDir` from tool cache should look like $AGENT_TOOLSDIRECTORY/Python/<semantic version>/x64/
            // So if `findLocalTool` succeeded above, we must have a conformant `installDir`
            const version = path.basename(path.dirname(installDir));
            const major = semver.major(version);
            const minor = semver.minor(version);

            const userScriptsDir = path.join(process.env['APPDATA'], 'Python', `Python${major}${minor}`, 'Scripts');
            toolUtil.prependPathSafe(userScriptsDir);
        } else {
            // On Linux and macOS, tools cache should be set up so that each Python version has its own "bin" directory.
            // We do this so that the tool cache can just be dropped on an agent with minimal installation (no copying to /usr/local).
            // This allows us side-by-side the same minor version of Python with different patch versions or architectures (since Python uses /usr/local/lib/python3.6, etc.).
            toolUtil.prependPathSafe(path.join(installDir, 'bin'));

            // On Linux and macOS, pip will create the --user directory and add it to PATH as needed.
        }
    }
}
开发者ID:bleissem,项目名称:vsts-tasks,代码行数:67,代码来源:usepythonversion.ts


示例7:

sem = semver.parse(str);
strn = semver.valid(str);
strn = semver.clean(str);

strn = semver.valid(str, loose);
strn = semver.clean(str, loose);
strn = semver.inc(str, "major", loose);
strn = semver.inc(str, "premajor", loose);
strn = semver.inc(str, "minor", loose);
strn = semver.inc(str, "preminor", loose);
strn = semver.inc(str, "patch", loose);
strn = semver.inc(str, "prepatch", loose);
strn = semver.inc(str, "prerelease", loose);
strn = semver.inc(str, "prerelease", loose, "alpha");
num = semver.major(str, loose);
num = semver.minor(str, loose);
num = semver.patch(str, loose);
strArr = semver.prerelease(str, loose);

// Comparison
bool = semver.gt(v1, v2, loose);
bool = semver.gte(v1, v2, loose);
bool = semver.lt(v1, v2, loose);
bool = semver.lte(v1, v2, loose);
bool = semver.eq(v1, v2, loose);
bool = semver.neq(v1, v2, loose);
bool = semver.cmp(v1, op, v2, loose);
comparatorResult = semver.compare(v1, v2, loose);
comparatorResult = semver.rcompare(v1, v2, loose);
comparatorResult = semver.compareIdentifiers(str, str);
开发者ID:PriceSpider-NeuIntel,项目名称:DefinitelyTyped,代码行数:30,代码来源:semver-tests.ts


示例8: require

/* tslint:disable:no-var-requires */
import * as fs from 'fs';
import * as path from 'path';
import { mergeDeepRight } from 'ramda';
import * as semver from 'semver';

const config = require('../app.json');
const {
  version,
  versionCode,
  dependencies: { expo }
} = require('../package.json');

const isDev = process.argv[2] === 'development';
const expoVersion = expo.replace('^', '');
const sdkVersion = `${semver.major(expoVersion)}.0.0`;

const travisConfig = mergeDeepRight(config, {
  expo: {
    name: `${config.expo.name}${isDev ? ' Nightly' : ''}`,
    slug: `${config.expo.slug}${isDev ? '-development' : ''}`,
    sdkVersion,
    version,
    packagerOpts: {
      nonPersistent: true
    },
    ios: {
      buildNumber: version.split('-')[0]
    },
    android: {
      versionCode
开发者ID:serlo-org,项目名称:serlo-abc,代码行数:31,代码来源:generate-app-config.ts


示例9: wizard

export default async function wizard(pwd: string, name: string) {
  let its = validateName(name);
  if (!its.validForNewPackages) {
    let errors = (its.errors || []).concat(its.warnings || []);
    throw new Error("Sorry, " + errors.join(" and ") + ".");
  }

  // check for a scoped name
  let scoped = name.match(/@([^\/]+)\/(.*)/);
  let [, scope, local] = scoped ? (scoped as [string, string, string]) : [, null, name];

  console.log("This utility will walk you through creating the " + style.project(name) + " Neon project.");
  console.log("It only covers the most common items, and tries to guess sensible defaults.");
  console.log();
  console.log("Press ^C at any time to quit.");

  let root = path.resolve(pwd, local);
  let guess = await guessAuthor();

  let answers = await prompt([
    {
      type: 'input',
      name: 'version',
      message: "version",
      default: "0.1.0",
      validate: function (input) {
        if (semver.valid(input)) {
          return true;
        }
        return "Invalid version: " + input;
      }
    },
    { type: 'input', name: 'description', message: "description"                               },
    { type: 'input', name: 'node',        message: "node entry point", default: "lib/index.js" },
    { type: 'input', name: 'git',         message: "git repository"                            },
    { type: 'input', name: 'author',      message: "author",           default: guess.name     },
    { type: 'input', name: 'email',       message: "email",            default: guess.email    },
    {
      type: 'input',
      name: 'license',
      message: "license",
      default: "MIT",
      validate: function (input) {
        let its = validateLicense(input);
        if (its.validForNewPackages) {
          return true;
        }
        let errors = its.warnings || [];
        return "Sorry, " + errors.join(" and ") + ".";
      }
    }
  ]);

  answers.name = {
    npm: {
      full: name,
      scope: scope,
      local: local
    },
    cargo: {
      external: local,
      internal: local.replace(/-/g, "_")
    }
  };
  answers.description = escapeQuotes(answers.description);
  answers.git = encodeURI(answers.git);
  answers.author = escapeQuotes(answers.author);

  let ctx = {
    project: answers,
    "neon-cli": {
      major: semver.major(NEON_CLI_VERSION),
      minor: semver.minor(NEON_CLI_VERSION),
      patch: semver.patch(NEON_CLI_VERSION)
    }
  };

  let lib = path.resolve(root, path.dirname(answers.node));
  let native_ = path.resolve(root, 'native');
  let src = path.resolve(native_, 'src');

  await mkdirs(lib);
  await mkdirs(src);

  await writeFile(path.resolve(root,    '.gitignore'),   (await GITIGNORE_TEMPLATE)(ctx), { flag: 'wx' });
  await writeFile(path.resolve(root,    'package.json'), (await NPM_TEMPLATE)(ctx),       { flag: 'wx' });
  await writeFile(path.resolve(native_, 'Cargo.toml'),   (await CARGO_TEMPLATE)(ctx),     { flag: 'wx' });
  await writeFile(path.resolve(root,    'README.md'),    (await README_TEMPLATE)(ctx),    { flag: 'wx' });
  await writeFile(path.resolve(root,    answers.node),   (await INDEXJS_TEMPLATE)(ctx),   { flag: 'wx' });
  await writeFile(path.resolve(src,     'lib.rs'),       (await LIBRS_TEMPLATE)(ctx),     { flag: 'wx' });
  await writeFile(path.resolve(native_, 'build.rs'),     (await BUILDRS_TEMPLATE)(ctx),   { flag: 'wx' });

  let relativeRoot = path.relative(pwd, root);
  let relativeNode = path.relative(pwd, path.resolve(root, answers.node));
  let relativeRust = path.relative(pwd, path.resolve(src, 'lib.rs'));

  console.log();
  console.log("Woo-hoo! Your Neon project has been created in: " + style.path(relativeRoot));
  console.log();
  console.log("The main Node entry point is at: " + style.path(relativeNode));
//.........这里部分代码省略.........
开发者ID:kodeballer,项目名称:neon,代码行数:101,代码来源:neon_new.ts


示例10: major

 (match): match is RegExpExecArray =>
   match !== null && major(match[1]) === majorVersion,
开发者ID:forumone,项目名称:generator-web-starter,代码行数:2,代码来源:getLatestDrupalTag.ts



注:本文中的semver.major函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript semver.maxSatisfying函数代码示例发布时间:2022-05-25
下一篇:
TypeScript semver.ltr函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap