Skip to content

Commit

Permalink
fix: generate workspace support for docs pages
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekarrys committed Jan 1, 2023
1 parent 450e50f commit 72e6d6f
Show file tree
Hide file tree
Showing 28 changed files with 69 additions and 58 deletions.
2 changes: 0 additions & 2 deletions docs/lib/content/commands/npm-adduser.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ description: Add a registry user account

<!-- AUTOGENERATED USAGE DESCRIPTIONS -->

Note: This command is unaware of workspaces.

### Description

Create a new user in the specified registry, and save the credentials to
Expand Down
2 changes: 0 additions & 2 deletions docs/lib/content/commands/npm-cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ description: Manipulates packages cache

<!-- AUTOGENERATED USAGE DESCRIPTIONS -->

Note: This command is unaware of workspaces.

### Description

Used to add, list, or clean the npm cache folder.
Expand Down
2 changes: 0 additions & 2 deletions docs/lib/content/commands/npm-completion.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ description: Tab Completion for npm

<!-- AUTOGENERATED USAGE DESCRIPTIONS -->

Note: This command is unaware of workspaces.

### Description

Enables tab-completion in all npm commands.
Expand Down
2 changes: 0 additions & 2 deletions docs/lib/content/commands/npm-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ description: Manage the npm configuration files

<!-- AUTOGENERATED USAGE DESCRIPTIONS -->

Note: This command is unaware of workspaces.

### Description

npm gets its config settings from the command line, environment
Expand Down
2 changes: 0 additions & 2 deletions docs/lib/content/commands/npm-deprecate.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ description: Deprecate a version of a package

<!-- AUTOGENERATED USAGE DESCRIPTIONS -->

Note: This command is unaware of workspaces.

### Description

This command will update the npm registry entry for a package, providing a
Expand Down
2 changes: 0 additions & 2 deletions docs/lib/content/commands/npm-doctor.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ description: Check your npm environment

<!-- AUTOGENERATED USAGE DESCRIPTIONS -->

Note: This command is unaware of workspaces.

### Description

`npm doctor` runs a set of checks to ensure that your npm installation has
Expand Down
2 changes: 0 additions & 2 deletions docs/lib/content/commands/npm-edit.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ description: Edit an installed package

<!-- AUTOGENERATED USAGE DESCRIPTIONS -->

Note: This command is unaware of workspaces.

### Description

Selects a dependency in the current project and opens the package folder in
Expand Down
2 changes: 0 additions & 2 deletions docs/lib/content/commands/npm-explore.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ description: Browse an installed package

<!-- AUTOGENERATED USAGE DESCRIPTIONS -->

Note: This command is unaware of workspaces.

### Description

Spawn a subshell in the directory of the installed package specified.
Expand Down
2 changes: 0 additions & 2 deletions docs/lib/content/commands/npm-help-search.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ description: Search npm help documentation

<!-- AUTOGENERATED USAGE DESCRIPTIONS -->

Note: This command is unaware of workspaces.

### Description

This command will search the npm markdown documentation files for the terms
Expand Down
2 changes: 0 additions & 2 deletions docs/lib/content/commands/npm-help.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ description: Get help on npm

<!-- AUTOGENERATED USAGE DESCRIPTIONS -->

Note: This command is unaware of workspaces.

### Description

If supplied a topic, then show the appropriate documentation page.
Expand Down
2 changes: 0 additions & 2 deletions docs/lib/content/commands/npm-hook.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ description: Manage registry hooks

<!-- AUTOGENERATED USAGE DESCRIPTIONS -->

Note: This command is unaware of workspaces.

### Description

Allows you to manage [npm
Expand Down
2 changes: 0 additions & 2 deletions docs/lib/content/commands/npm-login.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ description: Login to a registry user account

<!-- AUTOGENERATED USAGE DESCRIPTIONS -->

Note: This command is unaware of workspaces.

### Description

Verify a user in the specified registry, and save the credentials to the
Expand Down
2 changes: 0 additions & 2 deletions docs/lib/content/commands/npm-logout.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ description: Log out of the registry

<!-- AUTOGENERATED USAGE DESCRIPTIONS -->

Note: This command is unaware of workspaces.

### Description

When logged into a registry that supports token-based authentication, tell
Expand Down
2 changes: 0 additions & 2 deletions docs/lib/content/commands/npm-org.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ description: Manage orgs

<!-- AUTOGENERATED USAGE DESCRIPTIONS -->

Note: This command is unaware of workspaces.

### Example

Add a new developer to an org:
Expand Down
2 changes: 0 additions & 2 deletions docs/lib/content/commands/npm-owner.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ description: Manage package owners

<!-- AUTOGENERATED USAGE DESCRIPTIONS -->

Note: This command is unaware of workspaces.

### Description

Manage ownership of published packages.
Expand Down
2 changes: 0 additions & 2 deletions docs/lib/content/commands/npm-ping.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ description: Ping npm registry

<!-- AUTOGENERATED USAGE DESCRIPTIONS -->

Note: This command is unaware of workspaces.

### Description

Ping the configured or given npm registry and verify authentication.
Expand Down
2 changes: 0 additions & 2 deletions docs/lib/content/commands/npm-prefix.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ description: Display prefix

<!-- AUTOGENERATED USAGE DESCRIPTIONS -->

Note: This command is unaware of workspaces.

### Description

Print the local prefix to standard output. This is the closest parent directory
Expand Down
2 changes: 0 additions & 2 deletions docs/lib/content/commands/npm-profile.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ description: Change settings on your registry profile

<!-- AUTOGENERATED USAGE DESCRIPTIONS -->

Note: This command is unaware of workspaces.

### Description

Change your profile information on the registry. Note that this command
Expand Down
2 changes: 0 additions & 2 deletions docs/lib/content/commands/npm-search.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ description: Search for packages

<!-- AUTOGENERATED USAGE DESCRIPTIONS -->

Note: This command is unaware of workspaces.

### Description

Search the registry for packages matching the search terms. `npm search`
Expand Down
2 changes: 0 additions & 2 deletions docs/lib/content/commands/npm-shrinkwrap.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ description: Lock down dependency versions for publication

<!-- AUTOGENERATED USAGE DESCRIPTIONS -->

Note: This command is unaware of workspaces.

### Description

This command repurposes `package-lock.json` into a publishable
Expand Down
2 changes: 0 additions & 2 deletions docs/lib/content/commands/npm-star.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ description: Mark your favorite packages

<!-- AUTOGENERATED USAGE DESCRIPTIONS -->

Note: This command is unaware of workspaces.

### Description

"Starring" a package means that you have some interest in it. It's
Expand Down
2 changes: 0 additions & 2 deletions docs/lib/content/commands/npm-stars.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ description: View packages marked as favorites

<!-- AUTOGENERATED USAGE DESCRIPTIONS -->

Note: This command is unaware of workspaces.

### Description

If you have starred a lot of neat things and want to find them again
Expand Down
2 changes: 0 additions & 2 deletions docs/lib/content/commands/npm-team.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ description: Manage organization teams and team memberships

<!-- AUTOGENERATED USAGE DESCRIPTIONS -->

Note: This command is unaware of workspaces.

### Description

Used to manage teams in organizations, and change team memberships. Does not
Expand Down
2 changes: 0 additions & 2 deletions docs/lib/content/commands/npm-token.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ description: Manage your authentication tokens

<!-- AUTOGENERATED USAGE DESCRIPTIONS -->

Note: This command is unaware of workspaces.

### Description

This lets you list, create and revoke authentication tokens.
Expand Down
2 changes: 0 additions & 2 deletions docs/lib/content/commands/npm-unstar.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ description: Remove an item from your favorite packages

<!-- AUTOGENERATED USAGE DESCRIPTIONS -->

Note: This command is unaware of workspaces.

### Description

"Unstarring" a package is the opposite of [`npm star`](/commands/npm-star),
Expand Down
2 changes: 0 additions & 2 deletions docs/lib/content/commands/npm-whoami.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ description: Display npm username

<!-- AUTOGENERATED USAGE DESCRIPTIONS -->

Note: This command is unaware of workspaces.

### Description

Display the npm username of the currently logged-in user.
Expand Down
15 changes: 9 additions & 6 deletions docs/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ const getCommandByDoc = (docFile, docExt) => {
// `npx` is not technically a command in and of itself,
// so it just needs the usage of npm exex
const srcName = name === 'npx' ? 'exec' : name
const { params, usage = [''] } = require(`../../lib/commands/${srcName}`)
const { params, usage = [''], workspaces } = require(`../../lib/commands/${srcName}`)
const usagePrefix = name === 'npx' ? 'npx' : `npm ${name}`

return {
name,
workspaces,
params: name === 'npx' ? null : params,
usage: usage.map(u => `${usagePrefix} ${u}`.trim()).join('\n'),
}
Expand All @@ -54,7 +55,7 @@ const replaceVersion = (src) => src.replace(/@VERSION@/g, version)

const replaceUsage = (src, { path }) => {
const replacer = assertPlaceholder(src, path, TAGS.USAGE)
const { usage, name } = getCommandByDoc(path, DOC_EXT)
const { usage, name, workspaces } = getCommandByDoc(path, DOC_EXT)

const synopsis = ['```bash', usage]

Expand All @@ -66,15 +67,17 @@ const replaceUsage = (src, { path }) => {
}, [])

if (cmdAliases.length === 1) {
synopsis.push('')
synopsis.push(`alias: ${cmdAliases[0]}`)
synopsis.push('', `alias: ${cmdAliases[0]}`)
} else if (cmdAliases.length > 1) {
synopsis.push('')
synopsis.push(`aliases: ${cmdAliases.join(', ')}`)
synopsis.push('', `aliases: ${cmdAliases.join(', ')}`)
}

synopsis.push('```')

if (!workspaces) {
synopsis.push('', 'Note: This command is unaware of workspaces.')
}

return src.replace(replacer, synopsis.join('\n'))
}

Expand Down
Loading

0 comments on commit 72e6d6f

Please sign in to comment.