Commit 7abddce6 authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Merge branch '323477-add-gradle-kotlin-installations-commands' into 'master'

Add Gradle Kotlin installations commands

See merge request gitlab-org/gitlab!60097
parents 268f52ef c0daae92
......@@ -28,10 +28,15 @@ export default {
'mavenSetupXml',
'gradleGroovyInstalCommand',
'gradleGroovyAddSourceCommand',
'gradleKotlinInstalCommand',
'gradleKotlinAddSourceCommand',
]),
showMaven() {
return this.instructionType === 'maven';
},
showGroovy() {
return this.instructionType === 'groovy';
},
},
i18n: {
xmlText: s__(
......@@ -47,8 +52,9 @@ export default {
trackingActions: { ...TrackingActions },
TrackingLabels,
installOptions: [
{ value: 'maven', label: s__('PackageRegistry|Show Maven commands') },
{ value: 'groovy', label: s__('PackageRegistry|Show Gradle Groovy DSL commands') },
{ value: 'maven', label: s__('PackageRegistry|Maven XML') },
{ value: 'groovy', label: s__('PackageRegistry|Gradle Groovy DSL') },
{ value: 'kotlin', label: s__('PackageRegistry|Gradle Kotlin DSL') },
],
};
</script>
......@@ -107,7 +113,7 @@ export default {
</template>
</gl-sprintf>
</template>
<template v-else>
<template v-else-if="showGroovy">
<code-instruction
class="gl-mb-5"
:label="s__('PackageRegistry|Gradle Groovy DSL install command')"
......@@ -125,5 +131,23 @@ export default {
multiline
/>
</template>
<template v-else>
<code-instruction
class="gl-mb-5"
:label="s__('PackageRegistry|Gradle Kotlin DSL install command')"
:instruction="gradleKotlinInstalCommand"
:copy-text="s__('PackageRegistry|Copy Gradle Kotlin DSL install command')"
:tracking-action="$options.trackingActions.COPY_KOTLIN_INSTALL_COMMAND"
:tracking-label="$options.TrackingLabels.CODE_INSTRUCTION"
/>
<code-instruction
:label="s__('PackageRegistry|Add Gradle Kotlin DSL repository command')"
:instruction="gradleKotlinAddSourceCommand"
:copy-text="s__('PackageRegistry|Copy add Gradle Kotlin DSL repository command')"
:tracking-action="$options.trackingActions.COPY_KOTLIN_ADD_TO_SOURCE_COMMAND"
:tracking-label="$options.TrackingLabels.CODE_INSTRUCTION"
multiline
/>
</template>
</div>
</template>
......@@ -38,6 +38,9 @@ export const TrackingActions = {
COPY_GRADLE_INSTALL_COMMAND: 'copy_gradle_install_command',
COPY_GRADLE_ADD_TO_SOURCE_COMMAND: 'copy_gradle_add_to_source_command',
COPY_KOTLIN_INSTALL_COMMAND: 'copy_kotlin_install_command',
COPY_KOTLIN_ADD_TO_SOURCE_COMMAND: 'copy_kotlin_add_to_source_command',
};
export const NpmManager = {
......
......@@ -126,4 +126,15 @@ export const gradleGroovyAddSourceCommand = ({ mavenPath }) =>
url '${mavenPath}'
}`;
export const gradleKotlinInstalCommand = ({ packageEntity }) => {
const {
app_group: group = '',
app_name: name = '',
app_version: version = '',
} = packageEntity.maven_metadatum;
return `implementation("${group}:${name}:${version}")`;
};
export const gradleKotlinAddSourceCommand = ({ mavenPath }) => `maven("${mavenPath}")`;
export const groupExists = ({ groupListUrl }) => groupListUrl.length > 0;
---
title: Add Gradle Kotlin installations commands
merge_request: 60097
author: Cromefire_ (@cromefire_)
type: changed
......@@ -23200,6 +23200,9 @@ msgstr ""
msgid "PackageRegistry|Add Gradle Groovy DSL repository command"
msgstr ""
msgid "PackageRegistry|Add Gradle Kotlin DSL repository command"
msgstr ""
msgid "PackageRegistry|Add NuGet Source"
msgstr ""
......@@ -23242,6 +23245,9 @@ msgstr ""
msgid "PackageRegistry|Copy Gradle Groovy DSL install command"
msgstr ""
msgid "PackageRegistry|Copy Gradle Kotlin DSL install command"
msgstr ""
msgid "PackageRegistry|Copy Maven XML"
msgstr ""
......@@ -23263,6 +23269,9 @@ msgstr ""
msgid "PackageRegistry|Copy add Gradle Groovy DSL repository command"
msgstr ""
msgid "PackageRegistry|Copy add Gradle Kotlin DSL repository command"
msgstr ""
msgid "PackageRegistry|Copy and paste this inside your %{codeStart}pom.xml%{codeEnd} %{codeStart}dependencies%{codeEnd} block."
msgstr ""
......@@ -23314,9 +23323,18 @@ msgstr ""
msgid "PackageRegistry|GitLab Packages allows organizations to utilize GitLab as a private repository for a variety of common package formats. %{linkStart}More Information%{linkEnd}"
msgstr ""
msgid "PackageRegistry|Gradle Groovy DSL"
msgstr ""
msgid "PackageRegistry|Gradle Groovy DSL install command"
msgstr ""
msgid "PackageRegistry|Gradle Kotlin DSL"
msgstr ""
msgid "PackageRegistry|Gradle Kotlin DSL install command"
msgstr ""
msgid "PackageRegistry|If you haven't already done so, you will need to add the below to your %{codeStart}.pypirc%{codeEnd} file."
msgstr ""
......@@ -23341,6 +23359,9 @@ msgstr ""
msgid "PackageRegistry|Maven Command"
msgstr ""
msgid "PackageRegistry|Maven XML"
msgstr ""
msgid "PackageRegistry|NuGet"
msgstr ""
......@@ -23398,12 +23419,6 @@ msgstr ""
msgid "PackageRegistry|Show Conan commands"
msgstr ""
msgid "PackageRegistry|Show Gradle Groovy DSL commands"
msgstr ""
msgid "PackageRegistry|Show Maven commands"
msgstr ""
msgid "PackageRegistry|Show NPM commands"
msgstr ""
......
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`MavenInstallation gradle renders all the messages 1`] = `
exports[`MavenInstallation groovy renders all the messages 1`] = `
<div>
<installation-title-stub
options="[object Object],[object Object]"
options="[object Object],[object Object],[object Object]"
packagetype="maven"
/>
<code-instruction-stub
class="gl-mb-5"
copytext="Copy Gradle Groovy DSL install command"
instruction="foo/gradle/install"
instruction="foo/gradle/groovy/install"
label="Gradle Groovy DSL install command"
trackingaction="copy_gradle_install_command"
trackinglabel="code_instruction"
......@@ -18,7 +18,7 @@ exports[`MavenInstallation gradle renders all the messages 1`] = `
<code-instruction-stub
copytext="Copy add Gradle Groovy DSL repository command"
instruction="foo/gradle/add/source"
instruction="foo/gradle/groovy/add/source"
label="Add Gradle Groovy DSL repository command"
multiline="true"
trackingaction="copy_gradle_add_to_source_command"
......@@ -27,10 +27,37 @@ exports[`MavenInstallation gradle renders all the messages 1`] = `
</div>
`;
exports[`MavenInstallation kotlin renders all the messages 1`] = `
<div>
<installation-title-stub
options="[object Object],[object Object],[object Object]"
packagetype="maven"
/>
<code-instruction-stub
class="gl-mb-5"
copytext="Copy Gradle Kotlin DSL install command"
instruction="foo/gradle/kotlin/install"
label="Gradle Kotlin DSL install command"
trackingaction="copy_kotlin_install_command"
trackinglabel="code_instruction"
/>
<code-instruction-stub
copytext="Copy add Gradle Kotlin DSL repository command"
instruction="foo/gradle/kotlin/add/source"
label="Add Gradle Kotlin DSL repository command"
multiline="true"
trackingaction="copy_kotlin_add_to_source_command"
trackinglabel="code_instruction"
/>
</div>
`;
exports[`MavenInstallation maven renders all the messages 1`] = `
<div>
<installation-title-stub
options="[object Object],[object Object]"
options="[object Object],[object Object],[object Object]"
packagetype="maven"
/>
......
......@@ -17,8 +17,10 @@ describe('MavenInstallation', () => {
const xmlCodeBlock = 'foo/xml';
const mavenCommandStr = 'foo/command';
const mavenSetupXml = 'foo/setup';
const gradleGroovyInstallCommandText = 'foo/gradle/install';
const gradleGroovyAddSourceCommandText = 'foo/gradle/add/source';
const gradleGroovyInstallCommandText = 'foo/gradle/groovy/install';
const gradleGroovyAddSourceCommandText = 'foo/gradle/groovy/add/source';
const gradleKotlinInstallCommandText = 'foo/gradle/kotlin/install';
const gradleKotlinAddSourceCommandText = 'foo/gradle/kotlin/add/source';
const store = new Vuex.Store({
state: {
......@@ -31,6 +33,8 @@ describe('MavenInstallation', () => {
mavenSetupXml: () => mavenSetupXml,
gradleGroovyInstalCommand: () => gradleGroovyInstallCommandText,
gradleGroovyAddSourceCommand: () => gradleGroovyAddSourceCommandText,
gradleKotlinInstalCommand: () => gradleKotlinInstallCommandText,
gradleKotlinAddSourceCommand: () => gradleKotlinAddSourceCommandText,
},
});
......@@ -59,8 +63,9 @@ describe('MavenInstallation', () => {
expect(findInstallationTitle().props()).toMatchObject({
packageType: 'maven',
options: [
{ value: 'maven', label: 'Show Maven commands' },
{ value: 'groovy', label: 'Show Gradle Groovy DSL commands' },
{ value: 'maven', label: 'Maven XML' },
{ value: 'groovy', label: 'Gradle Groovy DSL' },
{ value: 'kotlin', label: 'Gradle Kotlin DSL' },
],
});
});
......@@ -117,9 +122,9 @@ describe('MavenInstallation', () => {
});
});
describe('gradle', () => {
describe('groovy', () => {
beforeEach(() => {
createComponent({ data: { instructionType: 'gradle' } });
createComponent({ data: { instructionType: 'groovy' } });
});
it('renders all the messages', () => {
......@@ -146,4 +151,34 @@ describe('MavenInstallation', () => {
});
});
});
describe('kotlin', () => {
beforeEach(() => {
createComponent({ data: { instructionType: 'kotlin' } });
});
it('renders all the messages', () => {
expect(wrapper.element).toMatchSnapshot();
});
describe('installation commands', () => {
it('renders the gradle install command', () => {
expect(findCodeInstructions().at(0).props()).toMatchObject({
instruction: gradleKotlinInstallCommandText,
multiline: false,
trackingAction: TrackingActions.COPY_KOTLIN_INSTALL_COMMAND,
});
});
});
describe('setup commands', () => {
it('renders the correct gradle command', () => {
expect(findCodeInstructions().at(1).props()).toMatchObject({
instruction: gradleKotlinAddSourceCommandText,
multiline: true,
trackingAction: TrackingActions.COPY_KOTLIN_ADD_TO_SOURCE_COMMAND,
});
});
});
});
});
......@@ -19,6 +19,8 @@ import {
groupExists,
gradleGroovyInstalCommand,
gradleGroovyAddSourceCommand,
gradleKotlinInstalCommand,
gradleKotlinAddSourceCommand,
} from '~/packages/details/store/getters';
import {
conanPackage,
......@@ -259,6 +261,24 @@ describe('Getters PackageDetails Store', () => {
});
});
describe('gradle kotlin string getters', () => {
it('gets the correct gradleKotlinInstalCommand', () => {
setupState();
expect(gradleKotlinInstalCommand(state)).toMatchInlineSnapshot(
`"implementation(\\"com.test.app:test-app:1.0-SNAPSHOT\\")"`,
);
});
it('gets the correct gradleKotlinAddSourceCommand', () => {
setupState();
expect(gradleKotlinAddSourceCommand(state)).toMatchInlineSnapshot(
`"maven(\\"foo/registry\\")"`,
);
});
});
describe('check if group', () => {
it('is set', () => {
setupState({ groupListUrl: '/groups/composer/-/packages' });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment