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
fbdd411e
Commit
fbdd411e
authored
Dec 26, 2018
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve npm packages code according to review
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
14e80d14
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
17 additions
and
6 deletions
+17
-6
doc/user/project/packages/npm_registry.md
doc/user/project/packages/npm_registry.md
+2
-2
ee/app/finders/packages/npm_packages_finder.rb
ee/app/finders/packages/npm_packages_finder.rb
+1
-1
ee/app/models/packages/package.rb
ee/app/models/packages/package.rb
+1
-2
ee/lib/api/npm_packages.rb
ee/lib/api/npm_packages.rb
+1
-1
ee/spec/lib/gitlab/regex_spec.rb
ee/spec/lib/gitlab/regex_spec.rb
+12
-0
No files found.
doc/user/project/packages/npm_registry.md
View file @
fbdd411e
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
> Introduced in [GitLab Premium](https://about.gitlab.com/pricing/) 11.7.
> Introduced in [GitLab Premium](https://about.gitlab.com/pricing/) 11.7.
With the GitLab NPM Registry, every
With the GitLab NPM Registry, every
project can have its own space to store
its
NPM packages.
project can have its own space to store NPM packages.
![
GitLab NPM Registry
](
img/npm_package_view.png
)
![
GitLab NPM Registry
](
img/npm_package_view.png
)
...
@@ -40,7 +40,7 @@ Note that **only packages that have the same path as the project** are supported
...
@@ -40,7 +40,7 @@ Note that **only packages that have the same path as the project** are supported
## Authenticating to the GitLab NPM Registry
## Authenticating to the GitLab NPM Registry
If a project is private or you want to upload NPM package to GitLab,
If a project is private or you want to upload NPM package to GitLab,
credentials will need to be provided for auth
oriz
ation. Support is available for
credentials will need to be provided for auth
entic
ation. Support is available for
[
oauth tokens
](
#authenticating-with-an-oauth-token
)
only.
[
oauth tokens
](
#authenticating-with-an-oauth-token
)
only.
### Authenticating with an oauth token
### Authenticating with an oauth token
...
...
ee/app/finders/packages/npm_packages_finder.rb
View file @
fbdd411e
...
@@ -15,7 +15,7 @@ class Packages::NpmPackagesFinder
...
@@ -15,7 +15,7 @@ class Packages::NpmPackagesFinder
def
packages
def
packages
project
.
packages
project
.
packages
.
only_
npm
.
npm
.
with_name
(
package_name
)
.
with_name
(
package_name
)
.
last_of_each_version
.
last_of_each_version
.
preload_files
.
preload_files
...
...
ee/app/models/packages/package.rb
View file @
fbdd411e
...
@@ -15,7 +15,6 @@ class Packages::Package < ActiveRecord::Base
...
@@ -15,7 +15,6 @@ class Packages::Package < ActiveRecord::Base
enum
package_type:
{
maven:
1
,
npm:
2
}
enum
package_type:
{
maven:
1
,
npm:
2
}
scope
:with_name
,
->
(
name
)
{
where
(
name:
name
)
}
scope
:with_name
,
->
(
name
)
{
where
(
name:
name
)
}
scope
:only_npm
,
->
{
where
(
package_type:
'npm'
)
}
scope
:preload_files
,
->
{
preload
(
:package_files
)
}
scope
:preload_files
,
->
{
preload
(
:package_files
)
}
def
self
.
for_projects
(
projects
)
def
self
.
for_projects
(
projects
)
...
@@ -29,7 +28,7 @@ class Packages::Package < ActiveRecord::Base
...
@@ -29,7 +28,7 @@ class Packages::Package < ActiveRecord::Base
end
end
def
self
.
by_name_and_file_name
(
name
,
file_name
)
def
self
.
by_name_and_file_name
(
name
,
file_name
)
w
here
(
name:
name
)
w
ith_name
(
name
)
.
joins
(
:package_files
)
.
joins
(
:package_files
)
.
where
(
packages_package_files:
{
file_name:
file_name
}).
last!
.
where
(
packages_package_files:
{
file_name:
file_name
}).
last!
end
end
...
...
ee/lib/api/npm_packages.rb
View file @
fbdd411e
...
@@ -67,7 +67,7 @@ module API
...
@@ -67,7 +67,7 @@ module API
get
':id/packages/npm/*package_name/-/*file_name'
,
format:
false
do
get
':id/packages/npm/*package_name/-/*file_name'
,
format:
false
do
authorize_download_package!
authorize_download_package!
package
=
user_project
.
packages
.
only_
npm
package
=
user_project
.
packages
.
npm
.
by_name_and_file_name
(
params
[
:package_name
],
params
[
:file_name
])
.
by_name_and_file_name
(
params
[
:package_name
],
params
[
:file_name
])
package_file
=
::
Packages
::
PackageFileFinder
package_file
=
::
Packages
::
PackageFileFinder
...
...
ee/spec/lib/gitlab/regex_spec.rb
View file @
fbdd411e
...
@@ -19,4 +19,16 @@ describe Gitlab::Regex do
...
@@ -19,4 +19,16 @@ describe Gitlab::Regex do
it
{
is_expected
.
not_to
match
(
'my feature flag'
)
}
it
{
is_expected
.
not_to
match
(
'my feature flag'
)
}
it
{
is_expected
.
not_to
match
(
'!!()()'
)
}
it
{
is_expected
.
not_to
match
(
'!!()()'
)
}
end
end
describe
'.package_name_regex'
do
subject
{
described_class
.
package_name_regex
}
it
{
is_expected
.
to
match
(
'123'
)
}
it
{
is_expected
.
to
match
(
'foo'
)
}
it
{
is_expected
.
to
match
(
'foo/bar'
)
}
it
{
is_expected
.
to
match
(
'@foo/bar'
)
}
it
{
is_expected
.
not_to
match
(
'$foo/bar'
)
}
it
{
is_expected
.
not_to
match
(
'my package name'
)
}
it
{
is_expected
.
not_to
match
(
'!!()()'
)
}
end
end
end
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