Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
b847b5dc
Commit
b847b5dc
authored
Sep 28, 2021
by
Nicolò Maria Mezzopera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unused getters and utils
- source - tests
parent
6b755868
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
2 additions
and
452 deletions
+2
-452
app/assets/javascripts/packages/details/constants.js
app/assets/javascripts/packages/details/constants.js
+0
-48
app/assets/javascripts/packages/details/store/getters.js
app/assets/javascripts/packages/details/store/getters.js
+0
-137
app/assets/javascripts/packages/details/utils.js
app/assets/javascripts/packages/details/utils.js
+0
-10
spec/frontend/packages/details/store/getters_spec.js
spec/frontend/packages/details/store/getters_spec.js
+2
-257
No files found.
app/assets/javascripts/packages/details/constants.js
View file @
b847b5dc
import
{
s__
}
from
'
~/locale
'
;
export
const
TrackingLabels
=
{
CODE_INSTRUCTION
:
'
code_instruction
'
,
CONAN_INSTALLATION
:
'
conan_installation
'
,
MAVEN_INSTALLATION
:
'
maven_installation
'
,
NPM_INSTALLATION
:
'
npm_installation
'
,
NUGET_INSTALLATION
:
'
nuget_installation
'
,
PYPI_INSTALLATION
:
'
pypi_installation
'
,
COMPOSER_INSTALLATION
:
'
composer_installation
'
,
};
export
const
TrackingActions
=
{
INSTALLATION
:
'
installation
'
,
REGISTRY_SETUP
:
'
registry_setup
'
,
COPY_CONAN_COMMAND
:
'
copy_conan_command
'
,
COPY_CONAN_SETUP_COMMAND
:
'
copy_conan_setup_command
'
,
COPY_MAVEN_XML
:
'
copy_maven_xml
'
,
COPY_MAVEN_COMMAND
:
'
copy_maven_command
'
,
COPY_MAVEN_SETUP
:
'
copy_maven_setup_xml
'
,
COPY_NPM_INSTALL_COMMAND
:
'
copy_npm_install_command
'
,
COPY_NPM_SETUP_COMMAND
:
'
copy_npm_setup_command
'
,
COPY_YARN_INSTALL_COMMAND
:
'
copy_yarn_install_command
'
,
COPY_YARN_SETUP_COMMAND
:
'
copy_yarn_setup_command
'
,
COPY_NUGET_INSTALL_COMMAND
:
'
copy_nuget_install_command
'
,
COPY_NUGET_SETUP_COMMAND
:
'
copy_nuget_setup_command
'
,
COPY_PIP_INSTALL_COMMAND
:
'
copy_pip_install_command
'
,
COPY_PYPI_SETUP_COMMAND
:
'
copy_pypi_setup_command
'
,
COPY_COMPOSER_REGISTRY_INCLUDE_COMMAND
:
'
copy_composer_registry_include_command
'
,
COPY_COMPOSER_PACKAGE_INCLUDE_COMMAND
:
'
copy_composer_package_include_command
'
,
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
=
{
NPM
:
'
npm
'
,
YARN
:
'
yarn
'
,
};
export
const
FETCH_PACKAGE_VERSIONS_ERROR
=
s__
(
'
PackageRegistry|Unable to fetch package version information.
'
,
);
...
...
app/assets/javascripts/packages/details/store/getters.js
View file @
b847b5dc
import
{
PackageType
}
from
'
../../shared/constants
'
;
import
{
getPackageTypeLabel
}
from
'
../../shared/utils
'
;
import
{
NpmManager
}
from
'
../constants
'
;
export
const
packagePipeline
=
({
packageEntity
})
=>
{
return
packageEntity
?.
pipeline
||
null
;
};
export
const
packageTypeDisplay
=
({
packageEntity
})
=>
{
return
getPackageTypeLabel
(
packageEntity
.
package_type
);
};
export
const
packageIcon
=
({
packageEntity
})
=>
{
if
(
packageEntity
.
package_type
===
PackageType
.
NUGET
)
{
return
packageEntity
.
nuget_metadatum
?.
icon_url
||
null
;
}
return
null
;
};
export
const
conanInstallationCommand
=
({
packageEntity
})
=>
{
// eslint-disable-next-line @gitlab/require-i18n-strings
return
`conan install
${
packageEntity
.
name
}
--remote=gitlab`
;
};
export
const
conanSetupCommand
=
({
conanPath
})
=>
// eslint-disable-next-line @gitlab/require-i18n-strings
`conan remote add gitlab
${
conanPath
}
`
;
export
const
mavenInstallationXml
=
({
packageEntity
=
{}
})
=>
{
const
{
app_group
:
appGroup
=
''
,
app_name
:
appName
=
''
,
app_version
:
appVersion
=
''
,
}
=
packageEntity
.
maven_metadatum
;
return
`<dependency>
<groupId>
${
appGroup
}
</groupId>
<artifactId>
${
appName
}
</artifactId>
<version>
${
appVersion
}
</version>
</dependency>`
;
};
export
const
mavenInstallationCommand
=
({
packageEntity
=
{}
})
=>
{
const
{
app_group
:
group
=
''
,
app_name
:
name
=
''
,
app_version
:
version
=
''
,
}
=
packageEntity
.
maven_metadatum
;
return
`mvn dependency:get -Dartifact=
${
group
}
:
${
name
}
:
${
version
}
`
;
};
export
const
mavenSetupXml
=
({
mavenPath
})
=>
`<repositories>
<repository>
<id>gitlab-maven</id>
<url>
${
mavenPath
}
</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>gitlab-maven</id>
<url>
${
mavenPath
}
</url>
</repository>
<snapshotRepository>
<id>gitlab-maven</id>
<url>
${
mavenPath
}
</url>
</snapshotRepository>
</distributionManagement>`
;
export
const
npmInstallationCommand
=
({
packageEntity
})
=>
(
type
=
NpmManager
.
NPM
)
=>
{
// eslint-disable-next-line @gitlab/require-i18n-strings
const
instruction
=
type
===
NpmManager
.
NPM
?
'
npm i
'
:
'
yarn add
'
;
return
`
${
instruction
}
${
packageEntity
.
name
}
`
;
};
export
const
npmSetupCommand
=
({
packageEntity
,
npmPath
})
=>
(
type
=
NpmManager
.
NPM
)
=>
{
const
scope
=
packageEntity
.
name
.
substring
(
0
,
packageEntity
.
name
.
indexOf
(
'
/
'
));
if
(
type
===
NpmManager
.
NPM
)
{
return
`echo
${
scope
}
:registry=
${
npmPath
}
/ >> .npmrc`
;
}
return
`echo \\"
${
scope
}
:registry\\" \\"
${
npmPath
}
/\\" >> .yarnrc`
;
};
export
const
nugetInstallationCommand
=
({
packageEntity
})
=>
`nuget install
${
packageEntity
.
name
}
-Source "GitLab"`
;
export
const
nugetSetupCommand
=
({
nugetPath
})
=>
`nuget source Add -Name "GitLab" -Source "
${
nugetPath
}
" -UserName <your_username> -Password <your_token>`
;
export
const
pypiPipCommand
=
({
pypiPath
,
packageEntity
})
=>
// eslint-disable-next-line @gitlab/require-i18n-strings
`pip install
${
packageEntity
.
name
}
--extra-index-url
${
pypiPath
}
`
;
export
const
pypiSetupCommand
=
({
pypiSetupPath
})
=>
`[gitlab]
repository =
${
pypiSetupPath
}
username = __token__
password = <your personal access token>`
;
export
const
composerRegistryInclude
=
({
composerPath
,
composerConfigRepositoryName
})
=>
// eslint-disable-next-line @gitlab/require-i18n-strings
`composer config repositories.
${
composerConfigRepositoryName
}
'{"type": "composer", "url": "
${
composerPath
}
"}'`
;
export
const
composerPackageInclude
=
({
packageEntity
})
=>
// eslint-disable-next-line @gitlab/require-i18n-strings
`composer req
${[
packageEntity
.
name
]}
:
${
packageEntity
.
version
}
`
;
export
const
gradleGroovyInstalCommand
=
({
packageEntity
})
=>
{
const
{
app_group
:
group
=
''
,
app_name
:
name
=
''
,
app_version
:
version
=
''
,
}
=
packageEntity
.
maven_metadatum
;
// eslint-disable-next-line @gitlab/require-i18n-strings
return
`implementation '
${
group
}
:
${
name
}
:
${
version
}
'`
;
};
export
const
gradleGroovyAddSourceCommand
=
({
mavenPath
})
=>
// eslint-disable-next-line @gitlab/require-i18n-strings
`maven {
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
;
app/assets/javascripts/packages/details/utils.js
deleted
100644 → 0
View file @
6b755868
import
{
TrackingActions
}
from
'
./constants
'
;
export
const
trackInstallationTabChange
=
{
methods
:
{
trackInstallationTabChange
(
tabIndex
)
{
const
action
=
tabIndex
===
0
?
TrackingActions
.
INSTALLATION
:
TrackingActions
.
REGISTRY_SETUP
;
this
.
track
(
action
,
{
label
:
this
.
trackingLabel
});
},
},
};
spec/frontend/packages/details/store/getters_spec.js
View file @
b847b5dc
import
{
NpmManager
}
from
'
~/packages/details/constant
s
'
;
import
{
packagePipeline
}
from
'
~/packages/details/store/getter
s
'
;
import
{
conanInstallationCommand
,
conanSetupCommand
,
packagePipeline
,
packageTypeDisplay
,
packageIcon
,
mavenInstallationXml
,
mavenInstallationCommand
,
mavenSetupXml
,
npmInstallationCommand
,
npmSetupCommand
,
nugetInstallationCommand
,
nugetSetupCommand
,
pypiPipCommand
,
pypiSetupCommand
,
composerRegistryInclude
,
composerPackageInclude
,
groupExists
,
gradleGroovyInstalCommand
,
gradleGroovyAddSourceCommand
,
gradleKotlinInstalCommand
,
gradleKotlinAddSourceCommand
,
}
from
'
~/packages/details/store/getters
'
;
import
{
conanPackage
,
npmPackage
,
nugetPackage
,
mockPipelineInfo
,
mavenPackage
as
packageWithoutBuildInfo
,
pypiPackage
,
rubygemsPackage
,
}
from
'
../../mock_data
'
;
import
{
generateMavenCommand
,
generateXmlCodeBlock
,
generateMavenSetupXml
,
registryUrl
,
pypiSetupCommandStr
,
}
from
'
../mock_data
'
;
describe
(
'
Getters PackageDetails Store
'
,
()
=>
{
let
state
;
const
defaultState
=
{
packageEntity
:
packageWithoutBuildInfo
,
conanPath
:
registryUrl
,
mavenPath
:
registryUrl
,
npmPath
:
registryUrl
,
nugetPath
:
registryUrl
,
pypiPath
:
registryUrl
,
};
const
setupState
=
(
testState
=
{})
=>
{
...
...
@@ -58,28 +19,6 @@ describe('Getters PackageDetails Store', () => {
};
};
const
conanInstallationCommandStr
=
`conan install
${
conanPackage
.
name
}
--remote=gitlab`
;
const
conanSetupCommandStr
=
`conan remote add gitlab
${
registryUrl
}
`
;
const
mavenCommandStr
=
generateMavenCommand
(
packageWithoutBuildInfo
.
maven_metadatum
);
const
mavenInstallationXmlBlock
=
generateXmlCodeBlock
(
packageWithoutBuildInfo
.
maven_metadatum
);
const
mavenSetupXmlBlock
=
generateMavenSetupXml
();
const
npmInstallStr
=
`npm i
${
npmPackage
.
name
}
`
;
const
npmSetupStr
=
`echo @Test:registry=
${
registryUrl
}
/ >> .npmrc`
;
const
yarnInstallStr
=
`yarn add
${
npmPackage
.
name
}
`
;
const
yarnSetupStr
=
`echo \\"@Test:registry\\" \\"
${
registryUrl
}
/\\" >> .yarnrc`
;
const
nugetInstallationCommandStr
=
`nuget install
${
nugetPackage
.
name
}
-Source "GitLab"`
;
const
nugetSetupCommandStr
=
`nuget source Add -Name "GitLab" -Source "
${
registryUrl
}
" -UserName <your_username> -Password <your_token>`
;
const
pypiPipCommandStr
=
`pip install
${
pypiPackage
.
name
}
--extra-index-url
${
registryUrl
}
`
;
const
composerRegistryIncludeStr
=
'
composer config repositories.gitlab.com/123
\'
{"type": "composer", "url": "foo"}
\'
'
;
const
composerPackageIncludeStr
=
`composer req
${[
packageWithoutBuildInfo
.
name
]}
:
${
packageWithoutBuildInfo
.
version
}
`
;
describe
(
'
packagePipeline
'
,
()
=>
{
it
(
'
should return the pipeline info when pipeline exists
'
,
()
=>
{
setupState
({
...
...
@@ -93,203 +32,9 @@ describe('Getters PackageDetails Store', () => {
});
it
(
'
should return null when build_info does not exist
'
,
()
=>
{
setupState
();
setupState
(
{
pipeline
:
undefined
}
);
expect
(
packagePipeline
(
state
)).
toBe
(
null
);
});
});
describe
(
'
packageTypeDisplay
'
,
()
=>
{
describe
.
each
`
packageEntity | expectedResult
${
conanPackage
}
|
${
'
Conan
'
}
${
packageWithoutBuildInfo
}
|
${
'
Maven
'
}
${
npmPackage
}
|
${
'
npm
'
}
${
nugetPackage
}
|
${
'
NuGet
'
}
${
pypiPackage
}
|
${
'
PyPI
'
}
${
rubygemsPackage
}
|
${
'
RubyGems
'
}
`
(
`package type`
,
({
packageEntity
,
expectedResult
})
=>
{
beforeEach
(()
=>
setupState
({
packageEntity
}));
it
(
`
${
packageEntity
.
package_type
}
should show as
${
expectedResult
}
`
,
()
=>
{
expect
(
packageTypeDisplay
(
state
)).
toBe
(
expectedResult
);
});
});
});
describe
(
'
packageIcon
'
,
()
=>
{
describe
(
'
nuget packages
'
,
()
=>
{
it
(
'
should return nuget package icon
'
,
()
=>
{
setupState
({
packageEntity
:
nugetPackage
});
expect
(
packageIcon
(
state
)).
toBe
(
nugetPackage
.
nuget_metadatum
.
icon_url
);
});
it
(
'
should return null when nuget package does not have an icon
'
,
()
=>
{
setupState
({
packageEntity
:
{
...
nugetPackage
,
nuget_metadatum
:
{}
}
});
expect
(
packageIcon
(
state
)).
toBe
(
null
);
});
});
it
(
'
should not find icons for other package types
'
,
()
=>
{
setupState
({
packageEntity
:
npmPackage
});
expect
(
packageIcon
(
state
)).
toBe
(
null
);
});
});
describe
(
'
conan string getters
'
,
()
=>
{
it
(
'
gets the correct conanInstallationCommand
'
,
()
=>
{
setupState
({
packageEntity
:
conanPackage
});
expect
(
conanInstallationCommand
(
state
)).
toBe
(
conanInstallationCommandStr
);
});
it
(
'
gets the correct conanSetupCommand
'
,
()
=>
{
setupState
({
packageEntity
:
conanPackage
});
expect
(
conanSetupCommand
(
state
)).
toBe
(
conanSetupCommandStr
);
});
});
describe
(
'
maven string getters
'
,
()
=>
{
it
(
'
gets the correct mavenInstallationXml
'
,
()
=>
{
setupState
();
expect
(
mavenInstallationXml
(
state
)).
toBe
(
mavenInstallationXmlBlock
);
});
it
(
'
gets the correct mavenInstallationCommand
'
,
()
=>
{
setupState
();
expect
(
mavenInstallationCommand
(
state
)).
toBe
(
mavenCommandStr
);
});
it
(
'
gets the correct mavenSetupXml
'
,
()
=>
{
setupState
();
expect
(
mavenSetupXml
(
state
)).
toBe
(
mavenSetupXmlBlock
);
});
});
describe
(
'
npm string getters
'
,
()
=>
{
it
(
'
gets the correct npmInstallationCommand for npm
'
,
()
=>
{
setupState
({
packageEntity
:
npmPackage
});
expect
(
npmInstallationCommand
(
state
)(
NpmManager
.
NPM
)).
toBe
(
npmInstallStr
);
});
it
(
'
gets the correct npmSetupCommand for npm
'
,
()
=>
{
setupState
({
packageEntity
:
npmPackage
});
expect
(
npmSetupCommand
(
state
)(
NpmManager
.
NPM
)).
toBe
(
npmSetupStr
);
});
it
(
'
gets the correct npmInstallationCommand for Yarn
'
,
()
=>
{
setupState
({
packageEntity
:
npmPackage
});
expect
(
npmInstallationCommand
(
state
)(
NpmManager
.
YARN
)).
toBe
(
yarnInstallStr
);
});
it
(
'
gets the correct npmSetupCommand for Yarn
'
,
()
=>
{
setupState
({
packageEntity
:
npmPackage
});
expect
(
npmSetupCommand
(
state
)(
NpmManager
.
YARN
)).
toBe
(
yarnSetupStr
);
});
});
describe
(
'
nuget string getters
'
,
()
=>
{
it
(
'
gets the correct nugetInstallationCommand
'
,
()
=>
{
setupState
({
packageEntity
:
nugetPackage
});
expect
(
nugetInstallationCommand
(
state
)).
toBe
(
nugetInstallationCommandStr
);
});
it
(
'
gets the correct nugetSetupCommand
'
,
()
=>
{
setupState
({
packageEntity
:
nugetPackage
});
expect
(
nugetSetupCommand
(
state
)).
toBe
(
nugetSetupCommandStr
);
});
});
describe
(
'
pypi string getters
'
,
()
=>
{
it
(
'
gets the correct pypiPipCommand
'
,
()
=>
{
setupState
({
packageEntity
:
pypiPackage
});
expect
(
pypiPipCommand
(
state
)).
toBe
(
pypiPipCommandStr
);
});
it
(
'
gets the correct pypiSetupCommand
'
,
()
=>
{
setupState
({
pypiSetupPath
:
'
foo
'
});
expect
(
pypiSetupCommand
(
state
)).
toBe
(
pypiSetupCommandStr
);
});
});
describe
(
'
composer string getters
'
,
()
=>
{
it
(
'
gets the correct composerRegistryInclude command
'
,
()
=>
{
setupState
({
composerPath
:
'
foo
'
,
composerConfigRepositoryName
:
'
gitlab.com/123
'
});
expect
(
composerRegistryInclude
(
state
)).
toBe
(
composerRegistryIncludeStr
);
});
it
(
'
gets the correct composerPackageInclude command
'
,
()
=>
{
setupState
();
expect
(
composerPackageInclude
(
state
)).
toBe
(
composerPackageIncludeStr
);
});
});
describe
(
'
gradle groovy string getters
'
,
()
=>
{
it
(
'
gets the correct gradleGroovyInstalCommand
'
,
()
=>
{
setupState
();
expect
(
gradleGroovyInstalCommand
(
state
)).
toMatchInlineSnapshot
(
`"implementation 'com.test.app:test-app:1.0-SNAPSHOT'"`
,
);
});
it
(
'
gets the correct gradleGroovyAddSourceCommand
'
,
()
=>
{
setupState
();
expect
(
gradleGroovyAddSourceCommand
(
state
)).
toMatchInlineSnapshot
(
`
"maven {
url 'foo/registry'
}"
`
);
});
});
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
'
});
expect
(
groupExists
(
state
)).
toBe
(
true
);
});
it
(
'
is not set
'
,
()
=>
{
setupState
({
groupListUrl
:
''
});
expect
(
groupExists
(
state
)).
toBe
(
false
);
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment