Skip to content

fix(generator): update generated path project.json, jest.config.ts, .eslintrc.json #1236

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

Merged
merged 4 commits into from
Mar 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ jobs:
- run: git branch --track main origin/main || true

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

e2e:
runs-on: ubuntu-latest
Expand Down
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
"scripts": {
"generate-hook": "nx generate open-feature hook",
"generate-provider": "nx generate open-feature provider",
"test": "nx run-many --all --target=test --skip-nx-cache",
"e2e": "nx run-many --all --target=e2e --skip-nx-cache --output-style=stream --parallel=false",
"lint": "nx run-many --all --target=lint --skip-nx-cache",
"lint:fix": "nx run-many --all --target=lint --skip-nx-cache --fix",
"package": "npx nx run-many --all --target=package",
"publish": "npx nx run-many --all --target=publish"
"test": "nx run-many --all --target=test --skip-nx-cache --exclude=js-sdk-contrib",
"e2e": "nx run-many --all --target=e2e --skip-nx-cache --output-style=stream --parallel=false --exclude=js-sdk-contrib",
"lint": "nx run-many --all --target=lint --skip-nx-cache --exclude=js-sdk-contrib",
"lint:fix": "nx run-many --all --target=lint --skip-nx-cache --fix --exclude=js-sdk-contrib",
"package": "npx nx run-many --all --target=package --exclude=js-sdk-contrib",
"publish": "npx nx run-many --all --target=publish --exclude=js-sdk-contrib"
},
"private": true,
"dependencies": {
Expand Down Expand Up @@ -92,6 +92,7 @@
"ts-jest": "29.2.5",
"ts-node": "10.9.2",
"typescript": "5.7.3",
"undici": "^5.0.0"
"undici": "^5.0.0",
"verdaccio": "^5.0.4"
}
}
14 changes: 14 additions & 0 deletions project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "js-sdk-contrib",
"$schema": "node_modules/nx/schemas/project-schema.json",
"targets": {
"local-registry": {
"executor": "@nx/js:verdaccio",
"options": {
"port": 4873,
"config": ".verdaccio/config.yml",
"storage": "tmp/local-registry/storage"
}
}
}
}
33 changes: 33 additions & 0 deletions tools/workspace-plugin/src/generators/open-feature/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ export default async function (tree: Tree, schema: SchemaOptions) {

updateProject(tree, projectRoot, name);
updateTsConfig(tree, projectRoot);
updateEslintrc(tree, projectRoot);
updateJestConfig(tree, projectRoot);
updateProjectJson(tree, projectRoot);
updatePackage(tree, projectRoot, schema);
updateReleasePleaseConfig(tree, projectRoot);
updateReleasePleaseManifest(tree, projectRoot);
Expand Down Expand Up @@ -197,6 +200,36 @@ function updateTsConfig(tree: Tree, projectRoot: string) {
});
}

function updateEslintrc(tree: Tree, projectRoot: string) {
// Update .eslintrc.json root location
updateJson(tree, joinPathFragments(projectRoot, '.eslintrc.json'), (json) => {
json.extends = `../../${json.extends}`;
return json;
});
}

function updateJestConfig(tree: Tree, projectRoot: string) {
const configPath = joinPathFragments(projectRoot, 'jest.config.ts');

// Update jest.preset.js path
let contents = tree.read(configPath)!.toString();
const replaceJestPresetPath = contents.replace('../jest.preset.js', '../../../jest.preset.js');
tree.write(configPath, replaceJestPresetPath);

// Update coverage path
contents = tree.read(configPath)!.toString();
const replaceCoveragePath = contents.replace('../coverage/providers', `../../../coverage/${projectRoot}`);
tree.write(configPath, replaceCoveragePath);
}

function updateProjectJson(tree: Tree, projectRoot: string) {
// Update jest.config.ts location
updateJson(tree, joinPathFragments(projectRoot, 'project.json'), (json) => {
json.targets.test.options.jestConfig = '{projectRoot}/jest.config.ts';
return json;
});
}

function updateReleasePleaseConfig(tree: Tree, projectRoot: string) {
updateJson(tree, 'release-please-config.json', (json) => {
json.packages[projectRoot] = {
Expand Down