// import { execSync } from 'child_process'; import { releaseChangelog, releasePublish, releaseVersion } from 'nx/release'; import * as yargs from 'yargs'; import { mediaBasket } from '../cdn/media-basket'; import { syncVersions } from './sync-versions'; import { readFileSync, writeFileSync } from 'fs'; import { join } from 'path'; (async () => { const options = await yargs .version(false) // don't use the default meaning of version in yargs .option('version', { description: 'Explicit version specifier to use, if overriding conventional commits', type: 'string', }) .option('dryRun', { alias: 'd', description: 'Whether or not to perform a dry-run of the release process, defaults to true', type: 'boolean', default: false, }) .option('verbose', { description: 'Whether or not to enable verbose logging, defaults to false', type: 'boolean', default: true, }) .option('distTag', { alias: 'dt', description: 'npm dist-tag', type: 'string', default: '', }) .parseAsync(); const isBeta = options.distTag === 'beta'; const { workspaceVersion, projectsVersionData } = await releaseVersion({ specifier: isBeta ? 'prerelease' : options.version, dryRun: options.dryRun, verbose: options.verbose, preid: isBeta ? '' + Date.now() : undefined, gitCommitMessage: "chore(Release): публикация версии {version}" }); if (!isBeta) { await releaseChangelog({ versionData: projectsVersionData, version: workspaceVersion, dryRun: options.dryRun, verbose: options.verbose, gitCommitMessage: "chore(Release): публикация версии {version}" }); } const publishStatus = await releasePublish({ dryRun: options.dryRun, verbose: options.verbose, tag: options.distTag ? options.distTag : undefined, }); const result = Object.values(publishStatus).find((i) => i.code !== 1); if (!isBeta) syncVersions(workspaceVersion); if (!isBeta) await mediaBasket.upload(); process.exit(result ? result.code : 1); })();