-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(config): enable choice of practices supplementally and exclusively
- Loading branch information
1 parent
58781d4
commit d141ec3
Showing
17 changed files
with
259 additions
and
103 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#!/bin/sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
. "$(dirname -- "$0")/check.nvm.sh" | ||
# . "$(dirname -- "$0")/check.nvm.sh" | ||
. "$(dirname -- "$0")/check.lockfile.sh" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
2 changes: 2 additions & 0 deletions
2
src/logic/__test_assets__/example-project-passes-uses-practices-directly/.gitignore
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,2 @@ | ||
node_modules | ||
package-lock.json |
12 changes: 12 additions & 0 deletions
12
src/logic/__test_assets__/example-project-passes-uses-practices-directly/declapract.use.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,12 @@ | ||
declarations: ../example-best-practices-repo | ||
scope: | ||
usecase: lambda-service | ||
practices: | ||
- cicd-common | ||
- conventional-commits | ||
- husky | ||
variables: | ||
organizationName: 'awesome-org' | ||
serviceName: 'svc-awesome-thing' | ||
infrastructureNamespaceId: 'abcde12345' | ||
slackReleaseWebHook: 'https://...' |
5 changes: 5 additions & 0 deletions
5
src/logic/__test_assets__/example-project-passes-uses-practices-directly/package.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"devDependencies": { | ||
"best-practices-typescript": "0.1.7" | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
src/logic/__test_assets__/example-project-passes-uses-practices-exclusively/.gitignore
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,2 @@ | ||
node_modules | ||
package-lock.json |
11 changes: 11 additions & 0 deletions
11
...ogic/__test_assets__/example-project-passes-uses-practices-exclusively/declapract.use.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,11 @@ | ||
declarations: ../example-best-practices-repo | ||
scope: | ||
practices: | ||
- cicd-common | ||
- conventional-commits | ||
- husky | ||
variables: | ||
organizationName: 'awesome-org' | ||
serviceName: 'svc-awesome-thing' | ||
infrastructureNamespaceId: 'abcde12345' | ||
slackReleaseWebHook: 'https://...' |
5 changes: 5 additions & 0 deletions
5
src/logic/__test_assets__/example-project-passes-uses-practices-exclusively/package.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"devDependencies": { | ||
"best-practices-typescript": "0.1.7" | ||
} | ||
} |
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,51 @@ | ||
import { UnexpectedCodePathError } from '@ehmpathy/error-fns'; | ||
|
||
import { ActionUsePracticesConfig } from '../../domain/objects/ActionUsePracticesConfig'; | ||
|
||
export const getDesiredPractices = ({ | ||
config, | ||
filter, | ||
}: { | ||
config: ActionUsePracticesConfig; | ||
filter?: { | ||
practiceNames?: string[]; | ||
filePaths?: string[]; | ||
}; | ||
}) => { | ||
// grab the selected use case's practices | ||
const usecase = | ||
config.declared.useCases.find( | ||
(thisUseCase) => thisUseCase.name === config.scope.usecase, | ||
) ?? null; | ||
if (!usecase && config.scope.usecase) | ||
throw new UnexpectedCodePathError( | ||
'requested usecase was not declared on config', | ||
{ usecase: config.scope.usecase }, | ||
); | ||
|
||
// declare the practices | ||
const practicesChosen = [ | ||
...(usecase?.practices ?? []), | ||
...(config.scope.practices ?? []).map( | ||
(practiceName) => | ||
config.declared.practices.find( | ||
(practice) => practice.name === practiceName, | ||
) ?? | ||
UnexpectedCodePathError.throw( | ||
'requested practice was not declared on config', | ||
{ practiceName }, | ||
), | ||
), | ||
]; | ||
|
||
// filter the practices | ||
const practicesFiltered = practicesChosen.filter( | ||
(practice) => | ||
filter?.practiceNames | ||
? filter?.practiceNames.includes(practice.name) // if practice.name filter was defined, ensure practice.name is included | ||
: true, // otherwise, all are included | ||
); | ||
|
||
// return those | ||
return practicesFiltered; | ||
}; |
Oops, something went wrong.