Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
shields
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
shields.io
shields
Commits
5e36dc0a
Unverified
Commit
5e36dc0a
authored
1 year ago
by
chris48s
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
deprecate [tokei] service (#9581)
parent
848e409e
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
services/tokei/tokei.service.js
+11
-84
11 additions, 84 deletions
services/tokei/tokei.service.js
services/tokei/tokei.tester.js
+2
-21
2 additions, 21 deletions
services/tokei/tokei.tester.js
with
13 additions
and
105 deletions
services/tokei/tokei.service.js
+
11
−
84
View file @
5e36dc0a
import
Joi
from
'
joi
'
import
{
metric
}
from
'
../text-formatters.js
'
import
{
nonNegativeInteger
}
from
'
../validators.js
'
import
{
BaseJsonService
,
pathParams
}
from
'
../index.js
'
import
{
deprecatedService
}
from
'
../index.js
'
const
schema
=
Joi
.
object
({
lines
:
nonNegativeInteger
,
}).
required
()
const
description
=
`
The
\`
provider
\`
is the domain name of git host.
If no TLD is provided,
\`
.com
\`
will be added.
For example, setting
\`
gitlab
\`
or
\`
bitbucket.org
\`
as the
provider also works.
Tokei will automatically count all files with a recognized extension. It will
automatically ignore files and folders in
\`
.ignore
\`
files. If you
want to ignore files or folders specifically for tokei, add them to the
\`
.tokeignore
\`
in the root of your repository. See
[https://github.com/XAMPPRocky/tokei#excluding-folders](https://github.com/XAMPPRocky/tokei#excluding-folders)
for more info.
`
export
default
class
Tokei
extends
BaseJsonService
{
static
category
=
'
size
'
static
route
=
{
base
:
'
tokei/lines
'
,
pattern
:
'
:provider/:user/:repo
'
}
static
openApi
=
{
'
/tokei/lines/{provider}/{user}/{repo}
'
:
{
get
:
{
summary
:
'
Lines of code
'
,
description
,
parameters
:
pathParams
(
{
name
:
'
provider
'
,
example
:
'
github
'
,
},
{
name
:
'
user
'
,
example
:
'
badges
'
,
},
{
name
:
'
repo
'
,
example
:
'
shields
'
,
},
),
},
},
}
static
defaultBadgeData
=
{
label
:
'
total lines
'
,
color
:
'
blue
'
,
}
static
render
({
lines
})
{
return
{
message
:
metric
(
lines
)
}
}
async
fetch
({
provider
,
user
,
repo
})
{
// This request uses the tokei-rs (https://github.com/XAMPPRocky/tokei_rs) API.
//
// By default, the API returns an svg, but when the Accept HTTP header is set to
// `application/json`, it sends json data. The `_requestJson` method
// automatically sets the Accept Header to what we need, so we don't need to
// specify it here.
//
// This behaviour of the API is "documented" here:
// https://github.com/XAMPPRocky/tokei_rs/issues/8#issuecomment-475071147
return
this
.
_requestJson
({
schema
,
url
:
`https://tokei.rs/b1/
${
provider
}
/
${
user
}
/
${
repo
}
`
,
httpErrors
:
{
400
:
'
repo not found
'
,
export
const
Tokei
=
deprecatedService
({
category
:
'
size
'
,
route
:
{
base
:
'
tokei/lines
'
,
pattern
:
'
:various*
'
,
},
label
:
'
tokei
'
,
dateAdded
:
new
Date
(
'
2023-09-17
'
),
})
}
async
handle
({
provider
,
user
,
repo
})
{
const
{
lines
}
=
await
this
.
fetch
({
provider
,
user
,
repo
})
return
this
.
constructor
.
render
({
lines
})
}
}
This diff is collapsed.
Click to expand it.
services/tokei/tokei.tester.js
+
2
−
21
View file @
5e36dc0a
import
{
ServiceTester
}
from
'
../tester.js
'
import
{
isMetric
}
from
'
../test-validators.js
'
export
const
t
=
new
ServiceTester
({
id
:
'
tokei
'
,
title
:
'
Tokei LOC Tests
'
})
t
.
create
(
'
GitHub LOC
'
)
.
get
(
'
/lines/github/badges/shields.json
'
)
.
expectBadge
({
label
:
'
total lines
'
,
message
:
isMetric
})
t
.
create
(
'
GitLab LOC
'
)
.
get
(
'
/lines/gitlab/shields-ops-group/tag-test.json
'
)
.
timeout
(
15000
)
.
expectBadge
({
label
:
'
total lines
'
,
message
:
isMetric
})
t
.
create
(
'
GitHub LOC (with .com)
'
)
.
get
(
'
/lines/github.com/badges/shields.json
'
)
.
expectBadge
({
label
:
'
total lines
'
,
message
:
isMetric
})
t
.
create
(
'
GitLab LOC (with .com)
'
)
.
get
(
'
/lines/gitlab.com/shields-ops-group/tag-test.json
'
)
.
timeout
(
15000
)
.
expectBadge
({
label
:
'
total lines
'
,
message
:
isMetric
})
.
expectBadge
({
label
:
'
tokei
'
,
message
:
'
no longer available
'
})
t
.
create
(
'
BitBucket LOC
'
)
.
get
(
'
/lines/bitbucket.org/MonliH/tokei-shields-test.json
'
)
.
expectBadge
({
label
:
'
total lines
'
,
message
:
isMetric
})
t
.
create
(
'
Invalid Provider
'
)
.
get
(
'
/lines/example/tezos/tezos.json
'
)
.
expectBadge
({
label
:
'
total lines
'
,
message
:
'
repo not found
'
})
.
expectBadge
({
label
:
'
tokei
'
,
message
:
'
no longer available
'
})
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment