-
-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add plugin for moonrepo (moonrepo.dev) #579
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a5174f3
Fix markdown in github comments
webpro eae7913
Add moonrepo plugin
965f440
PR feedback
7c1cd94
More changes
a3e97c0
Add vite-node to binary resolvers and support absolute paths for posi…
webpro 7e65b6d
Add temp root cwd
webpro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
tasks: | ||
lint.filenames: | ||
command: 'ls-lint -workdir . -config $workspaceRoot/.ls-lint.yml' |
9 changes: 9 additions & 0 deletions
9
packages/knip/fixtures/plugins/moonrepo/.moon/tasks/typescript.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
tasks: | ||
lint: | ||
deps: | ||
- lint.typecheck | ||
- lint.code | ||
lint.typecheck: | ||
command: tsc --noEmit | ||
lint.code: | ||
command: eslint . --ignore-path $workspaceRoot/.gitignore --no-error-on-unmatched-pattern |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
tasks: | ||
lint.readme: | ||
command: 'vite-node $workspaceRoot/tools/linters/lint-readme.ts -- $projectRoot' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"name": "a" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
tasks: | ||
start.prod: | ||
command: 'vitest ./server/server.ts' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "b", | ||
"devDependencies": { | ||
"vitest": "*" | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
packages/knip/fixtures/plugins/moonrepo/libs/b/server/server.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const hi = 'hi'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "@fixtures/moonrepo", | ||
"devDependencies": { | ||
"@moonrepo/cli": "*", | ||
"vite-node": "*", | ||
"eslint": "*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
packages: | ||
- 'apps/**' | ||
- 'libs/**' |
1 change: 1 addition & 0 deletions
1
packages/knip/fixtures/plugins/moonrepo/tools/linters/lint-readme.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const hi = 'hello'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": ["@tsconfig/node20/tsconfig.json"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { getDependenciesFromScripts, hasDependency } from '#p/util/plugin.js'; | ||
import type { EnablerPatterns } from '#p/types/config.js'; | ||
import type { IsPluginEnabled, Plugin, ResolveConfig } from '#p/types/plugins.js'; | ||
import type { MoonConfiguration } from './types.js'; | ||
|
||
// link to moonrepo docs: https://moonrepo.dev/docs | ||
|
||
const title = 'moonrepo'; | ||
|
||
const enablers: EnablerPatterns = ['@moonrepo/cli']; | ||
|
||
const isEnabled: IsPluginEnabled = ({ dependencies }) => hasDependency(dependencies, enablers); | ||
|
||
const config: string[] = ['moon.yml', '.moon/tasks.yml', '.moon/tasks/*.yml']; | ||
|
||
const resolveConfig: ResolveConfig<MoonConfiguration> = async (config, options) => { | ||
const tasks = config.tasks ? Object.values(config.tasks) : []; | ||
const dependencies = tasks | ||
.map(task => task.command) | ||
.filter(command => command) | ||
.map(command => command.replace('$workspaceRoot', options.rootCwd!)) | ||
.map(command => command.replace('$projectRoot', options.cwd)) | ||
.flatMap(command => getDependenciesFromScripts(command, options)); | ||
return [...dependencies]; | ||
}; | ||
|
||
export default { | ||
title, | ||
enablers, | ||
isEnabled, | ||
config, | ||
resolveConfig, | ||
} satisfies Plugin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export interface MoonConfiguration { | ||
tasks?: { | ||
[taskName: string]: { | ||
command: string; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import assert from 'node:assert/strict'; | ||
import test from 'node:test'; | ||
import { main } from '../../src/index.js'; | ||
import { resolve, join } from '../../src/util/path.js'; | ||
import baseArguments from '../helpers/baseArguments.js'; | ||
import baseCounters from '../helpers/baseCounters.js'; | ||
|
||
const cwd = resolve('fixtures/plugins/moonrepo'); | ||
|
||
test('Find dependencies with the moonrepo plugin', async () => { | ||
const { issues, counters } = await main({ | ||
...baseArguments, | ||
cwd, | ||
}); | ||
|
||
assert(issues.binaries['.moon/tasks.yml']['ls-lint']); | ||
assert(issues.binaries['.moon/tasks/typescript.yml']['tsc']); | ||
assert(issues.binaries['.moon/tasks/typescript.yml']['eslint']); | ||
assert(issues.binaries['libs/b/moon.yml']['vitest']); | ||
assert(issues.binaries['apps/a/moon.yml']['vite-node']); | ||
|
||
assert(issues.devDependencies['package.json']['@moonrepo/cli']); | ||
assert(issues.devDependencies['package.json']['vite-node']); | ||
assert(issues.devDependencies['package.json']['eslint']); | ||
assert(issues.devDependencies['libs/b/package.json']['vitest']); | ||
|
||
assert(issues.files.has(join(cwd, 'libs/b/server/server.ts'))); | ||
|
||
assert.deepEqual(counters, { | ||
...baseCounters, | ||
files: 1, | ||
devDependencies: 4, | ||
binaries: 5, | ||
processed: 2, | ||
total: 2, | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any chance you could add assertions about
issues.devDependencies
for those 4?