UNPKG

@arkts/sdk-downloader

Version:
54 lines (52 loc) 2.71 kB
const require_download = require('./download-DonlEH9M.cjs'); const require_command_line = require('./command-line-B4udgTmZ.cjs'); const node_path = require_download.__toESM(require("node:path")); const pino = require_download.__toESM(require("pino")); const pino_pretty = require_download.__toESM(require("pino-pretty")); const __actions_cache = require_download.__toESM(require("@actions/cache")); const __actions_core = require_download.__toESM(require("@actions/core")); //#region src/github-action.ts async function run() { const version = __actions_core.getInput("version", { required: true }); const archInput = __actions_core.getInput("arch", { required: false }) || "X86"; const osInput = __actions_core.getInput("os", { required: false }) || "Linux"; const cacheDir = __actions_core.getInput("cache_dir", { required: false }) || ".cache/sdk"; const targetDir = __actions_core.getInput("target_dir", { required: false }) || "sdk"; const logType = __actions_core.getInput("log_type", { required: false }) || "explicit"; const logTimeout = Number.parseInt(__actions_core.getInput("log_timeout", { required: false }) || "5000", 10); const isCache = __actions_core.getBooleanInput("cache", { required: false }); const logger = (0, pino.default)((0, pino_pretty.default)({ colorize: true, colorizeObjects: true, singleLine: true })); const arch = archInput.toLowerCase() === "arm" ? require_download.SdkArch.ARM : require_download.SdkArch.X86; const os = osInput.toLowerCase() === "macos" ? require_download.SdkOS.MacOS : osInput.toLowerCase() === "windows" ? require_download.SdkOS.Windows : require_download.SdkOS.Linux; const cacheKey = `ohos-sdk-${version}-${arch}-${os}`; const cacheHit = await __actions_cache.restoreCache([node_path.default.resolve(targetDir)], cacheKey); if (cacheHit) { logger.warn(`Cache hit: ${cacheHit}, skipping download...`); await require_command_line.logSdkDirStructure(logger, targetDir); __actions_core.setOutput("sdkPath", node_path.default.resolve(targetDir)); return; } else logger.warn(`Cache miss, starting to download...`); await require_command_line.runCommandLineDownload({ apiVersion: version, arch: require_download.SdkArch[arch], os: require_download.SdkOS[os], cacheDir, targetDir, logType, logTimeout, logger }); if (isCache) { logger.info(`Download & extract successfully, saving cache to ${cacheKey}...`); const cacheId = await __actions_cache.saveCache([node_path.default.resolve(targetDir)], cacheKey); logger.info(`Cache saved with id: ${cacheId}.`); } __actions_core.setOutput("sdkPath", node_path.default.resolve(targetDir)); } run(); //#endregion //# sourceMappingURL=github-action.cjs.map