FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
docs/src/content-render/scripts/reusables-cli.ts at main · basiclines/docs · GitHub
basiclines
/
docs
Public
forked from
github/docs
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
docs
/
src
/
content-render
/
scripts
/
reusables-cli.ts
Copy path
More file actions
More file actions
Latest commit
History
History
History
75 lines (65 loc) · 2.42 KB
Breadcrumbs
docs
/
src
/
content-render
/
scripts
/
reusables-cli.ts
Copy path
File metadata and controls
75 lines (65 loc) · 2.42 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/**
*
@purpose
Writer tool
*
@description
Find all content files that use a specific reusable
*/
// Usage: npm run reusables -- --help
// Usage: npm run reusables -- find used accounts/create-account.md
// Usage: npm run reusables -- find unused accounts/create-account.md
// Usage: npm run reusables -- find any-unused
// Usage: npm run reusables -- find top-used
import
{
Command
}
from
'commander'
import
{
findTopUsed
,
findUsed
}
from
'./reusables-cli/find/used'
import
{
findPotentialUses
}
from
'./reusables-cli/find/potential-uses'
import
{
findUnused
}
from
'./reusables-cli/find/unused'
const
defaultSimilarityThreshold
=
10000
const
defaultTopUsedCount
=
10
const
absolutePathDescription
=
'Show absolute paths in output instead of relative path to repo'
const
program
=
new
Command
(
)
program
.
name
(
'reusables-helper-cli'
)
.
description
(
'Tools to help with reusable Docs content snippets'
)
const
findCommand
=
program
.
command
(
'find'
)
findCommand
.
command
(
'used'
)
.
description
(
'Find all content files that use a specific reusable.'
)
.
argument
(
'<reusable-path>'
,
'Path to the reusable file relative to content/data/reusables, e.g. "accounts/create-account.md".'
,
)
.
option
(
'-a --absolute'
,
absolutePathDescription
,
false
)
.
action
(
findUsed
)
findCommand
.
command
(
'top-used'
)
.
description
(
'Find the top x most used reusables.'
)
.
argument
(
'[number-of-most-used-to-find]'
,
'Number of most used reusables to find.'
,
defaultTopUsedCount
,
)
.
option
(
'-a --absolute'
,
absolutePathDescription
,
false
)
.
action
(
findTopUsed
)
findCommand
.
command
(
'unused'
)
.
description
(
'Find all reusables that are not used in any content files. WARNING: This command may take a long time to run.'
,
)
.
option
(
'-a --absolute'
,
absolutePathDescription
,
false
)
.
action
(
findUnused
)
findCommand
.
command
(
'potential-uses'
)
.
option
(
'-s, --similar'
,
'Find files where contents loosely matches a reusable instead of an exact match.'
,
)
.
option
(
'-t, --threshold <number>'
,
'Similarity threshold for similar reusables. e.g. 10000. This requires the --similar flag and some experimentation to find a useful value.'
,
parseFloat
,
defaultSimilarityThreshold
,
)
.
option
(
'-a --absolute'
,
absolutePathDescription
,
false
)
.
description
(
'Find all content files that could use any reusables, but do not. WARNING: This command may take a long time to run.'
,
)
.
action
(
findPotentialUses
)
program
.
parse
(
)
Back
|
FazBrowse Home
|
New Git URL