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 { ...@@ -28,10 +28,15 @@ export default {
'mavenSetupXml', 'mavenSetupXml',
'gradleGroovyInstalCommand', 'gradleGroovyInstalCommand',
'gradleGroovyAddSourceCommand', 'gradleGroovyAddSourceCommand',
'gradleKotlinInstalCommand',
'gradleKotlinAddSourceCommand',
]), ]),
showMaven() { showMaven() {
return this.instructionType === 'maven'; return this.instructionType === 'maven';
}, },
showGroovy() {
return this.instructionType === 'groovy';
},
}, },
i18n: { i18n: {
xmlText: s__( xmlText: s__(
...@@ -47,8 +52,9 @@ export default { ...@@ -47,8 +52,9 @@ export default {
trackingActions: { ...TrackingActions }, trackingActions: { ...TrackingActions },
TrackingLabels, TrackingLabels,
installOptions: [ installOptions: [
{ value: 'maven', label: s__('PackageRegistry|Show Maven commands') }, { value: 'maven', label: s__('PackageRegistry|Maven XML') },
{ value: 'groovy', label: s__('PackageRegistry|Show Gradle Groovy DSL commands') }, { value: 'groovy', label: s__('PackageRegistry|Gradle Groovy DSL') },
{ value: 'kotlin', label: s__('PackageRegistry|Gradle Kotlin DSL') },
], ],
}; };
</script> </script>
...@@ -107,7 +113,7 @@ export default { ...@@ -107,7 +113,7 @@ export default {
</template> </template>
</gl-sprintf> </gl-sprintf>
</template> </template>
<template v-else> <template v-else-if="showGroovy">
<code-instruction <code-instruction
class="gl-mb-5" class="gl-mb-5"
:label="s__('PackageRegistry|Gradle Groovy DSL install command')" :label="s__('PackageRegistry|Gradle Groovy DSL install command')"
...@@ -125,5 +131,23 @@ export default { ...@@ -125,5 +131,23 @@ export default {
multiline multiline
/> />
</template> </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> </div>
</template> </template>
...@@ -38,6 +38,9 @@ export const TrackingActions = { ...@@ -38,6 +38,9 @@ export const TrackingActions = {
COPY_GRADLE_INSTALL_COMMAND: 'copy_gradle_install_command', COPY_GRADLE_INSTALL_COMMAND: 'copy_gradle_install_command',
COPY_GRADLE_ADD_TO_SOURCE_COMMAND: 'copy_gradle_add_to_source_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 = { export const NpmManager = {
......
...@@ -126,4 +126,15 @@ export const gradleGroovyAddSourceCommand = ({ mavenPath }) => ...@@ -126,4 +126,15 @@ export const gradleGroovyAddSourceCommand = ({ mavenPath }) =>
url '${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; 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 "" ...@@ -23200,6 +23200,9 @@ msgstr ""
msgid "PackageRegistry|Add Gradle Groovy DSL repository command" msgid "PackageRegistry|Add Gradle Groovy DSL repository command"
msgstr "" msgstr ""
msgid "PackageRegistry|Add Gradle Kotlin DSL repository command"
msgstr ""
msgid "PackageRegistry|Add NuGet Source" msgid "PackageRegistry|Add NuGet Source"
msgstr "" msgstr ""
...@@ -23242,6 +23245,9 @@ msgstr "" ...@@ -23242,6 +23245,9 @@ msgstr ""
msgid "PackageRegistry|Copy Gradle Groovy DSL install command" msgid "PackageRegistry|Copy Gradle Groovy DSL install command"
msgstr "" msgstr ""
msgid "PackageRegistry|Copy Gradle Kotlin DSL install command"
msgstr ""
msgid "PackageRegistry|Copy Maven XML" msgid "PackageRegistry|Copy Maven XML"
msgstr "" msgstr ""
...@@ -23263,6 +23269,9 @@ msgstr "" ...@@ -23263,6 +23269,9 @@ msgstr ""
msgid "PackageRegistry|Copy add Gradle Groovy DSL repository command" msgid "PackageRegistry|Copy add Gradle Groovy DSL repository command"
msgstr "" 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." msgid "PackageRegistry|Copy and paste this inside your %{codeStart}pom.xml%{codeEnd} %{codeStart}dependencies%{codeEnd} block."
msgstr "" msgstr ""
...@@ -23314,9 +23323,18 @@ 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}" 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 "" msgstr ""
msgid "PackageRegistry|Gradle Groovy DSL"
msgstr ""
msgid "PackageRegistry|Gradle Groovy DSL install command" msgid "PackageRegistry|Gradle Groovy DSL install command"
msgstr "" 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." msgid "PackageRegistry|If you haven't already done so, you will need to add the below to your %{codeStart}.pypirc%{codeEnd} file."
msgstr "" msgstr ""
...@@ -23341,6 +23359,9 @@ msgstr "" ...@@ -23341,6 +23359,9 @@ msgstr ""
msgid "PackageRegistry|Maven Command" msgid "PackageRegistry|Maven Command"
msgstr "" msgstr ""
msgid "PackageRegistry|Maven XML"
msgstr ""
msgid "PackageRegistry|NuGet" msgid "PackageRegistry|NuGet"
msgstr "" msgstr ""
...@@ -23398,12 +23419,6 @@ msgstr "" ...@@ -23398,12 +23419,6 @@ msgstr ""
msgid "PackageRegistry|Show Conan commands" msgid "PackageRegistry|Show Conan commands"
msgstr "" msgstr ""
msgid "PackageRegistry|Show Gradle Groovy DSL commands"
msgstr ""
msgid "PackageRegistry|Show Maven commands"
msgstr ""
msgid "PackageRegistry|Show NPM commands" msgid "PackageRegistry|Show NPM commands"
msgstr "" msgstr ""
......
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`MavenInstallation gradle renders all the messages 1`] = ` exports[`MavenInstallation groovy renders all the messages 1`] = `
<div> <div>
<installation-title-stub <installation-title-stub
options="[object Object],[object Object]" options="[object Object],[object Object],[object Object]"
packagetype="maven" packagetype="maven"
/> />
<code-instruction-stub <code-instruction-stub
class="gl-mb-5" class="gl-mb-5"
copytext="Copy Gradle Groovy DSL install command" copytext="Copy Gradle Groovy DSL install command"
instruction="foo/gradle/install" instruction="foo/gradle/groovy/install"
label="Gradle Groovy DSL install command" label="Gradle Groovy DSL install command"
trackingaction="copy_gradle_install_command" trackingaction="copy_gradle_install_command"
trackinglabel="code_instruction" trackinglabel="code_instruction"
...@@ -18,7 +18,7 @@ exports[`MavenInstallation gradle renders all the messages 1`] = ` ...@@ -18,7 +18,7 @@ exports[`MavenInstallation gradle renders all the messages 1`] = `
<code-instruction-stub <code-instruction-stub
copytext="Copy add Gradle Groovy DSL repository command" 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" label="Add Gradle Groovy DSL repository command"
multiline="true" multiline="true"
trackingaction="copy_gradle_add_to_source_command" trackingaction="copy_gradle_add_to_source_command"
...@@ -27,10 +27,37 @@ exports[`MavenInstallation gradle renders all the messages 1`] = ` ...@@ -27,10 +27,37 @@ exports[`MavenInstallation gradle renders all the messages 1`] = `
</div> </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`] = ` exports[`MavenInstallation maven renders all the messages 1`] = `
<div> <div>
<installation-title-stub <installation-title-stub
options="[object Object],[object Object]" options="[object Object],[object Object],[object Object]"
packagetype="maven" packagetype="maven"
/> />
......
...@@ -17,8 +17,10 @@ describe('MavenInstallation', () => { ...@@ -17,8 +17,10 @@ describe('MavenInstallation', () => {
const xmlCodeBlock = 'foo/xml'; const xmlCodeBlock = 'foo/xml';
const mavenCommandStr = 'foo/command'; const mavenCommandStr = 'foo/command';
const mavenSetupXml = 'foo/setup'; const mavenSetupXml = 'foo/setup';
const gradleGroovyInstallCommandText = 'foo/gradle/install'; const gradleGroovyInstallCommandText = 'foo/gradle/groovy/install';
const gradleGroovyAddSourceCommandText = 'foo/gradle/add/source'; 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({ const store = new Vuex.Store({
state: { state: {
...@@ -31,6 +33,8 @@ describe('MavenInstallation', () => { ...@@ -31,6 +33,8 @@ describe('MavenInstallation', () => {
mavenSetupXml: () => mavenSetupXml, mavenSetupXml: () => mavenSetupXml,
gradleGroovyInstalCommand: () => gradleGroovyInstallCommandText, gradleGroovyInstalCommand: () => gradleGroovyInstallCommandText,
gradleGroovyAddSourceCommand: () => gradleGroovyAddSourceCommandText, gradleGroovyAddSourceCommand: () => gradleGroovyAddSourceCommandText,
gradleKotlinInstalCommand: () => gradleKotlinInstallCommandText,
gradleKotlinAddSourceCommand: () => gradleKotlinAddSourceCommandText,
}, },
}); });
...@@ -59,8 +63,9 @@ describe('MavenInstallation', () => { ...@@ -59,8 +63,9 @@ describe('MavenInstallation', () => {
expect(findInstallationTitle().props()).toMatchObject({ expect(findInstallationTitle().props()).toMatchObject({
packageType: 'maven', packageType: 'maven',
options: [ options: [
{ value: 'maven', label: 'Show Maven commands' }, { value: 'maven', label: 'Maven XML' },
{ value: 'groovy', label: 'Show Gradle Groovy DSL commands' }, { value: 'groovy', label: 'Gradle Groovy DSL' },
{ value: 'kotlin', label: 'Gradle Kotlin DSL' },
], ],
}); });
}); });
...@@ -117,9 +122,9 @@ describe('MavenInstallation', () => { ...@@ -117,9 +122,9 @@ describe('MavenInstallation', () => {
}); });
}); });
describe('gradle', () => { describe('groovy', () => {
beforeEach(() => { beforeEach(() => {
createComponent({ data: { instructionType: 'gradle' } }); createComponent({ data: { instructionType: 'groovy' } });
}); });
it('renders all the messages', () => { it('renders all the messages', () => {
...@@ -146,4 +151,34 @@ describe('MavenInstallation', () => { ...@@ -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 { ...@@ -19,6 +19,8 @@ import {
groupExists, groupExists,
gradleGroovyInstalCommand, gradleGroovyInstalCommand,
gradleGroovyAddSourceCommand, gradleGroovyAddSourceCommand,
gradleKotlinInstalCommand,
gradleKotlinAddSourceCommand,
} from '~/packages/details/store/getters'; } from '~/packages/details/store/getters';
import { import {
conanPackage, conanPackage,
...@@ -259,6 +261,24 @@ describe('Getters PackageDetails Store', () => { ...@@ -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', () => { describe('check if group', () => {
it('is set', () => { it('is set', () => {
setupState({ groupListUrl: '/groups/composer/-/packages' }); 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