Skip to content

Commit ea9e62a

Browse files
fix(generator): update generated path project.json, jest.config.ts, .eslintrc.json (#1236)
Signed-off-by: Giovanni De Giorgio <[email protected]> Signed-off-by: Todd Baert <[email protected]> Co-authored-by: Todd Baert <[email protected]>
1 parent d81ef89 commit ea9e62a

File tree

4 files changed

+58
-10
lines changed

4 files changed

+58
-10
lines changed

.github/workflows/ci.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ jobs:
3131
- run: git branch --track main origin/main || true
3232

3333
- run: if ! npx nx format:check ; then echo "Format check failed. Please run 'npx nx format:write'."; fi
34-
- run: npx nx affected --target=lint --parallel=3
35-
- run: npx nx affected --target=test --parallel=3 --ci --code-coverage
36-
- run: npx nx affected --target=build --parallel=3
34+
- run: npx nx affected --target=lint --parallel=3 --exclude=js-sdk-contrib
35+
- run: npx nx affected --target=test --parallel=3 --ci --code-coverage --exclude=js-sdk-contrib
36+
- run: npx nx affected --target=build --parallel=3 --exclude=js-sdk-contrib
3737

3838
e2e:
3939
runs-on: ubuntu-latest

package.json

+8-7
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
"scripts": {
66
"generate-hook": "nx generate open-feature hook",
77
"generate-provider": "nx generate open-feature provider",
8-
"test": "nx run-many --all --target=test --skip-nx-cache",
9-
"e2e": "nx run-many --all --target=e2e --skip-nx-cache --output-style=stream --parallel=false",
10-
"lint": "nx run-many --all --target=lint --skip-nx-cache",
11-
"lint:fix": "nx run-many --all --target=lint --skip-nx-cache --fix",
12-
"package": "npx nx run-many --all --target=package",
13-
"publish": "npx nx run-many --all --target=publish"
8+
"test": "nx run-many --all --target=test --skip-nx-cache --exclude=js-sdk-contrib",
9+
"e2e": "nx run-many --all --target=e2e --skip-nx-cache --output-style=stream --parallel=false --exclude=js-sdk-contrib",
10+
"lint": "nx run-many --all --target=lint --skip-nx-cache --exclude=js-sdk-contrib",
11+
"lint:fix": "nx run-many --all --target=lint --skip-nx-cache --fix --exclude=js-sdk-contrib",
12+
"package": "npx nx run-many --all --target=package --exclude=js-sdk-contrib",
13+
"publish": "npx nx run-many --all --target=publish --exclude=js-sdk-contrib"
1414
},
1515
"private": true,
1616
"dependencies": {
@@ -92,6 +92,7 @@
9292
"ts-jest": "29.2.5",
9393
"ts-node": "10.9.2",
9494
"typescript": "5.7.3",
95-
"undici": "^5.0.0"
95+
"undici": "^5.0.0",
96+
"verdaccio": "^5.0.4"
9697
}
9798
}

project.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "js-sdk-contrib",
3+
"$schema": "node_modules/nx/schemas/project-schema.json",
4+
"targets": {
5+
"local-registry": {
6+
"executor": "@nx/js:verdaccio",
7+
"options": {
8+
"port": 4873,
9+
"config": ".verdaccio/config.yml",
10+
"storage": "tmp/local-registry/storage"
11+
}
12+
}
13+
}
14+
}

tools/workspace-plugin/src/generators/open-feature/index.ts

+33
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ export default async function (tree: Tree, schema: SchemaOptions) {
6565

6666
updateProject(tree, projectRoot, name);
6767
updateTsConfig(tree, projectRoot);
68+
updateEslintrc(tree, projectRoot);
69+
updateJestConfig(tree, projectRoot);
70+
updateProjectJson(tree, projectRoot);
6871
updatePackage(tree, projectRoot, schema);
6972
updateReleasePleaseConfig(tree, projectRoot);
7073
updateReleasePleaseManifest(tree, projectRoot);
@@ -197,6 +200,36 @@ function updateTsConfig(tree: Tree, projectRoot: string) {
197200
});
198201
}
199202

203+
function updateEslintrc(tree: Tree, projectRoot: string) {
204+
// Update .eslintrc.json root location
205+
updateJson(tree, joinPathFragments(projectRoot, '.eslintrc.json'), (json) => {
206+
json.extends = `../../${json.extends}`;
207+
return json;
208+
});
209+
}
210+
211+
function updateJestConfig(tree: Tree, projectRoot: string) {
212+
const configPath = joinPathFragments(projectRoot, 'jest.config.ts');
213+
214+
// Update jest.preset.js path
215+
let contents = tree.read(configPath)!.toString();
216+
const replaceJestPresetPath = contents.replace('../jest.preset.js', '../../../jest.preset.js');
217+
tree.write(configPath, replaceJestPresetPath);
218+
219+
// Update coverage path
220+
contents = tree.read(configPath)!.toString();
221+
const replaceCoveragePath = contents.replace('../coverage/providers', `../../../coverage/${projectRoot}`);
222+
tree.write(configPath, replaceCoveragePath);
223+
}
224+
225+
function updateProjectJson(tree: Tree, projectRoot: string) {
226+
// Update jest.config.ts location
227+
updateJson(tree, joinPathFragments(projectRoot, 'project.json'), (json) => {
228+
json.targets.test.options.jestConfig = '{projectRoot}/jest.config.ts';
229+
return json;
230+
});
231+
}
232+
200233
function updateReleasePleaseConfig(tree: Tree, projectRoot: string) {
201234
updateJson(tree, 'release-please-config.json', (json) => {
202235
json.packages[projectRoot] = {

0 commit comments

Comments
 (0)