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

TypeScript semver.coerce函数代码示例

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

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



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

示例1: preparePlatformCore

	/* Hooks are expected to use "filesToSync" parameter, as to give plugin authors additional information about the sync process.*/
	@performanceLog()
	@helpers.hook('prepare')
	private async preparePlatformCore(platform: string,
		appFilesUpdaterOptions: IAppFilesUpdaterOptions,
		projectData: IProjectData,
		platformSpecificData: IPlatformSpecificData,
		env: Object,
		changesInfo?: IProjectChangesInfo,
		filesToSync?: string[],
		filesToRemove?: string[],
		nativePrepare?: INativePrepare): Promise<void> {

		this.$logger.info("Preparing project...");

		const platformData = this.$platformsData.getPlatformData(platform, projectData);
		const frameworkVersion = this.getCurrentPlatformVersion(platform, projectData);
		if (semver.lt(semver.coerce(frameworkVersion), semver.coerce('5.1.0'))) {
			this.$logger.warn(`Runtime versions lower than 5.1.0 have been deprecated and will not be supported as of v6.0.0 of NativeScript CLI. More info can be found in this issue https://github.com/NativeScript/nativescript-cli/issues/4518.`);
		}

		const projectFilesConfig = helpers.getProjectFilesConfig({ isReleaseBuild: appFilesUpdaterOptions.release });
		await this.$preparePlatformJSService.preparePlatform({
			platform,
			platformData,
			projectFilesConfig,
			appFilesUpdaterOptions,
			projectData,
			platformSpecificData,
			changesInfo,
			filesToSync,
			filesToRemove,
			env
		});

		if (!nativePrepare || !nativePrepare.skipNativePrepare) {
			await this.$preparePlatformNativeService.preparePlatform({
				platform,
				platformData,
				appFilesUpdaterOptions,
				projectData,
				platformSpecificData,
				changesInfo,
				filesToSync,
				filesToRemove,
				projectFilesConfig,
				env
			});
		}

		const directoryPath = path.join(platformData.appDestinationDirectoryPath, constants.APP_FOLDER_NAME);
		const excludedDirs = [constants.APP_RESOURCES_FOLDER_NAME];
		if (!changesInfo || !changesInfo.modulesChanged) {
			excludedDirs.push(constants.TNS_MODULES_FOLDER_NAME);
		}

		this.$projectFilesManager.processPlatformSpecificFiles(directoryPath, platform, projectFilesConfig, excludedDirs);

		this.$logger.info(`Project successfully prepared (${platform})`);
	}
开发者ID:NativeScript,项目名称:nativescript-cli,代码行数:60,代码来源:platform-service.ts


示例2: validateInstall

	public async validateInstall(device: Mobile.IDevice, projectData: IProjectData, release: IRelease, outputPath?: string): Promise<void> {
		const platform = device.deviceInfo.platform;
		const platformData = this.$platformsData.getPlatformData(platform, projectData);
		const localBuildInfo = this.getBuildInfo(device.deviceInfo.platform, platformData, { buildForDevice: !device.isEmulator, release: release.release }, outputPath);
		if (localBuildInfo.deploymentTarget) {
			if (semver.lt(semver.coerce(device.deviceInfo.version), semver.coerce(localBuildInfo.deploymentTarget))) {
				this.$errors.fail(`Unable to install on device with version ${device.deviceInfo.version} as deployment target is ${localBuildInfo.deploymentTarget}`);
			}
		}
	}
开发者ID:NativeScript,项目名称:nativescript-cli,代码行数:10,代码来源:platform-service.ts


示例3: parseCurrentVersion

function parseCurrentVersion(uiMetadata: UIMetadata): semver.SemVer | null {
  const coercedPackageVersion = semver.coerce(uiMetadata.packageVersion || "");
  if (coercedPackageVersion !== null) {
    return coercedPackageVersion;
  }
  const coercedServerBuild = semver.coerce(uiMetadata.serverBuild || "");
  if (coercedServerBuild !== null) {
    return coercedServerBuild;
  }
  return null;
}
开发者ID:dcos,项目名称:dcos-ui,代码行数:11,代码来源:index.ts


示例4: computeElectronVersion

export async function computeElectronVersion(projectDir: string, projectMetadata: MetadataValue): Promise<string> {
  const result = await getElectronVersionFromInstalled(projectDir)
  if (result != null) {
    return result
  }

  const electronPrebuiltDep = findFromElectronPrebuilt(await projectMetadata!!.value)
  if (electronPrebuiltDep == null || electronPrebuiltDep === "latest") {
    try {
      const releaseInfo = JSON.parse((await httpExecutor.request({
        hostname: "github.com",
        path: "/electron/electron/releases/latest",
        headers: {
          accept: "application/json",
        },
      }))!!)
      return (releaseInfo.tag_name.startsWith("v")) ? releaseInfo.tag_name.substring(1) : releaseInfo.tag_name
    }
    catch (e) {
      log.warn(e)
    }

    throw new Error(`Cannot find electron dependency to get electron version in the '${path.join(projectDir, "package.json")}'`)
  }

  const version = semver.coerce(electronPrebuiltDep)
  if (version == null) {
    throw new Error("cannot compute electron version")
  }
  return version.toString()
}
开发者ID:electron-userland,项目名称:electron-builder,代码行数:31,代码来源:electronVersion.ts


示例5: isVersionCompatible

/**
 * Checks whether plugin expected Kibana version is compatible with the used Kibana version.
 * @param expectedKibanaVersion Kibana version expected by the plugin.
 * @param actualKibanaVersion Used Kibana version.
 */
function isVersionCompatible(expectedKibanaVersion: string, actualKibanaVersion: string) {
  if (expectedKibanaVersion === ALWAYS_COMPATIBLE_VERSION) {
    return true;
  }

  const coercedActualKibanaVersion = coerce(actualKibanaVersion);
  if (coercedActualKibanaVersion == null) {
    return false;
  }

  const coercedExpectedKibanaVersion = coerce(expectedKibanaVersion);
  if (coercedExpectedKibanaVersion == null) {
    return false;
  }

  // Compare coerced versions, e.g. `1.2.3` ---> `1.2.3` and `7.0.0-alpha1` ---> `7.0.0`.
  return coercedActualKibanaVersion.compare(coercedExpectedKibanaVersion) === 0;
}
开发者ID:austec-automation,项目名称:kibana,代码行数:23,代码来源:plugin_manifest_parser.ts


示例6: satisfies

export function satisfies(nodeVersion: string, semverRange: string) {
  // Coercing the version is needed to handle nightly builds correctly.
  // In particular,
  //   semver.satisfies('v10.0.0-nightly201804132a6ab9b37b', '>=10')
  // returns `false`.
  //
  // `semver.coerce` can be used to coerce that nightly version to v10.0.0.
  const coercedVersion = semver.coerce(nodeVersion);
  const finalVersion = coercedVersion ? coercedVersion.version : nodeVersion;
  return semver.satisfies(finalVersion, semverRange);
}
开发者ID:GoogleCloudPlatform,项目名称:cloud-debug-nodejs,代码行数:11,代码来源:utils.ts


示例7: versionSatisfies

function versionSatisfies(version: string | semver.SemVer | null, range: string | semver.Range, loose?: boolean): boolean {
  if (version == null) {
    return false
  }

  const coerced = semver.coerce(version)
  if (coerced == null) {
    return false
  }

  return semver.satisfies(coerced, range, loose)
}
开发者ID:electron-userland,项目名称:electron-builder,代码行数:12,代码来源:packageMetadata.ts


示例8: getLogcatStream

	private async getLogcatStream(deviceIdentifier: string, pid?: string) {
		const device = await this.$devicesService.getDevice(deviceIdentifier);
		const minAndroidWithLogcatPidSupport = "7.0.0";
		const isLogcatPidSupported = !!device.deviceInfo.version && semver.gte(semver.coerce(device.deviceInfo.version), minAndroidWithLogcatPidSupport);
		const adb: Mobile.IDeviceAndroidDebugBridge = this.$injector.resolve(DeviceAndroidDebugBridge, { identifier: deviceIdentifier });
		const logcatCommand = ["logcat"];

		if (pid && isLogcatPidSupported) {
			logcatCommand.push(`--pid=${pid}`);
		}
		const logcatStream = await adb.executeCommand(logcatCommand, { returnChildProcess: true });
		return logcatStream;
	}
开发者ID:NativeScript,项目名称:nativescript-cli,代码行数:13,代码来源:logcat-helper.ts


示例9: getWarningForPluginCore

	private getWarningForPluginCore(localPlugin: string, localPluginVersion: string, devicePluginVersion: string, deviceId: string): string {
		this.$logger.trace(`Comparing plugin ${localPlugin} with localPluginVersion ${localPluginVersion} and devicePluginVersion ${devicePluginVersion}`);

		if (!devicePluginVersion) {
			return util.format(PluginComparisonMessages.PLUGIN_NOT_INCLUDED_IN_PREVIEW_APP, localPlugin, deviceId);
		}

		const shouldSkipCheck = !semver.valid(localPluginVersion) && !semver.validRange(localPluginVersion);
		if (shouldSkipCheck) {
			return null;
		}

		const localPluginVersionData = semver.coerce(localPluginVersion);
		const devicePluginVersionData = semver.coerce(devicePluginVersion);

		if (localPluginVersionData.major !== devicePluginVersionData.major) {
			return util.format(PluginComparisonMessages.LOCAL_PLUGIN_WITH_DIFFERENCE_IN_MAJOR_VERSION, localPlugin, localPluginVersion, devicePluginVersion);
		} else if (localPluginVersionData.minor > devicePluginVersionData.minor) {
			return util.format(PluginComparisonMessages.LOCAL_PLUGIN_WITH_GREATHER_MINOR_VERSION, localPlugin, localPluginVersion, devicePluginVersion);
		}

		return null;
	}
开发者ID:NativeScript,项目名称:nativescript-cli,代码行数:23,代码来源:preview-app-plugins-service.ts


示例10:

		_.each(allPodfiles, podfileContent => {
			const platformMatch = platformRowRegExp.exec(podfileContent);
			const podfilePathMatch: any[] = podfilePathRegExp.exec(podfileContent) || [];
			// platform without version -> select it with highest priority
			if (platformMatch && platformMatch[0] && !platformMatch[2]) {
				selectedPlatformData = {
					version: null,
					content: platformMatch[1],
					path: podfilePathMatch[1]
				};
				return false;
			}

			// platform with version
			if (platformMatch && platformMatch[0] && platformMatch[2]) {
				if (!selectedPlatformData || semver.gt(semver.coerce(platformMatch[2]), semver.coerce(selectedPlatformData.version))) {
					selectedPlatformData = {
						version: platformMatch[2],
						content: platformMatch[1],
						path: podfilePathMatch[1]
					};
				}
			}
		});
开发者ID:NativeScript,项目名称:nativescript-cli,代码行数:24,代码来源:cocoapods-platform-manager.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript semver.compare函数代码示例发布时间:2022-05-25
下一篇:
TypeScript semver.cmp函数代码示例发布时间: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