Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(essentials): set version atlantis command #439

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@ Tools are designed to be used in projects with Javascript and Typescript and are

To start using it:

First time:

- `yarn set version https://raw.githubusercontent.com/atls/raijin/master/yarn/cli/dist/yarn.mjs` - installs our latest custom yarn bundle in the project scope.

Upgrade already installed bundle:

- `yarn set version atlantis` - updates bundle to latest version and updates `@atls/code-runtime` dependency to latest

## Commonly used scrips `yarn`

Besides standard `yarn` scripts we developed our custom ones for ease of work:
Expand Down
6 changes: 6 additions & 0 deletions README_RU.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@

Для начала использования нашей сборки:

Первая установка:

- `yarn set version https://raw.githubusercontent.com/atls/raijin/master/yarn/cli/dist/yarn.mjs` - эта команда установит вместо стокового ярна наш и положит в папку .yarn/releases, если же наша сборка уже установленна - произойдёт обновление до актуальной версии

Обновление бандла в уже установленном проекте:

- `yarn set version atlantis` - обновление бандла и обновление `@atls/code-runtime` до последней версии

## Основные скрипты `yarn` для нашей работы

Помимо стандартных скриптов `yarn` мы используем наши кастомные для облегчения работы:
Expand Down
1,448 changes: 724 additions & 724 deletions yarn/cli/dist/yarn.mjs

Large diffs are not rendered by default.

43 changes: 15 additions & 28 deletions yarn/plugin-essentials/sources/commands/set-version.command.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,25 @@
import { BaseCommand } from '@yarnpkg/cli'
import { Configuration } from '@yarnpkg/core'
import { SetVersionCommand as BaseSetVersionCommand } from '@yarnpkg/plugin-essentials'
import { Option } from 'clipanion'
import { BaseCommand } from '@yarnpkg/cli'
import { Configuration } from '@yarnpkg/core'
import { Command } from 'clipanion'

export class SetVersionCommand extends BaseCommand {
static paths = [['set', 'version']]
static paths = [['set', 'version', 'atlantis']]

static usage = BaseSetVersionCommand.usage

useYarnPath = Option.Boolean(`--yarn-path`, {
description: `Set the yarnPath setting even if the version can be accessed by Corepack`,
})

onlyIfNeeded = Option.Boolean(`--only-if-needed`, false, {
description: `Only lock the Yarn version if it isn't already locked`,
static usage = Command.Usage({
description: 'lock the Yarn version used by the project',
details: `
This command will get latest Atlantis bundle from [Atlantis Raijin repo](https://github.com/atls/raijin) and bump \`@atls/code-runtime\` dependency
`,
})

version = Option.String()

async execute(): Promise<number> {
const args = ['set', 'version', 'original']

if (this.useYarnPath === true) {
args.push('--yarn-path')
}

if (this.onlyIfNeeded) {
args.push('--only-if-needed')
}

args.push(this.version)

const args = ['set', 'version']
args.push('https://raw.githubusercontent.com/atls/raijin/master/yarn/cli/dist/yarn.mjs')
const exitCode = await this.cli.run(args)

const bumpArgs = ['up', '@atls/code-runtime']
const bumpExitCode = await this.cli.run(bumpArgs)

const configuration = await Configuration.find(this.context.cwd, this.context.plugins)

await configuration.triggerHook(
Expand All @@ -42,6 +29,6 @@ export class SetVersionCommand extends BaseCommand {
this.context
)

return exitCode
return bumpExitCode && exitCode
}
}
6 changes: 4 additions & 2 deletions yarn/plugin-essentials/sources/essentials.plugin.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { Plugin } from '@yarnpkg/core'
import type { Plugin } from '@yarnpkg/core'

export const plugin: Plugin = {}
import { SetVersionCommand } from './commands/index.js'

export const plugin: Plugin = { commands: [SetVersionCommand] }
Loading