Skip to content

Commit a385f25

Browse files
committed
update and fix generators
Signed-off-by: Todd Baert <[email protected]>
1 parent e8115ab commit a385f25

File tree

1 file changed

+11
-22
lines changed
  • tools/workspace-plugin/src/generators/open-feature

1 file changed

+11
-22
lines changed

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

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
names,
88
Tree,
99
updateJson,
10+
moveFilesToNewDirectory,
1011
} from '@nx/devkit';
1112
import { libraryGenerator } from '@nx/js';
1213
import { Linter } from '@nx/eslint';
@@ -21,17 +22,10 @@ interface SchemaOptions {
2122
}
2223

2324
export default async function (tree: Tree, schema: SchemaOptions) {
24-
const {
25-
name,
26-
importPath,
27-
projectLibDir,
28-
libFileName,
29-
fileName,
30-
projectRoot,
31-
libClassName,
32-
nxProjectName,
33-
directory,
34-
} = normalizeOptions(tree, schema);
25+
const { name, importPath, libFileName, projectRoot, libClassName, nxProjectName, directory } = normalizeOptions(
26+
tree,
27+
schema,
28+
);
3529

3630
await libraryGenerator(tree, {
3731
name,
@@ -47,14 +41,12 @@ export default async function (tree: Tree, schema: SchemaOptions) {
4741
linter: Linter.EsLint,
4842
});
4943

50-
/**
51-
* Refactors the auto-generated files
52-
*/
44+
// move the files to the right location in the tree
45+
moveFilesToNewDirectory(tree, directory, projectRoot);
46+
47+
// delete the auto-generated files
5348
['spec.ts', 'ts'].forEach((suffix) => {
54-
tree.rename(
55-
joinPathFragments(projectLibDir, `${directory}-${fileName}.${suffix}`),
56-
joinPathFragments(projectLibDir, `${libFileName}.${suffix}`),
57-
);
49+
tree.delete(joinPathFragments(projectRoot, 'src', 'lib', `${name}.${suffix}`));
5850
});
5951

6052
/**
@@ -98,15 +90,13 @@ function normalizeOptions(tree: Tree, schema: SchemaOptions) {
9890
const { libsDir } = getWorkspaceLayout(tree);
9991
const projectRoot = joinPathFragments(libsDir, directory, fileName);
10092
const importPath = `@openfeature/${fileName}-${schema.type}`;
101-
const projectLibDir = joinPathFragments(projectRoot, 'src', 'lib');
10293

10394
return {
10495
name,
10596
libClassName,
10697
libFileName,
10798
nxProjectName,
10899
importPath,
109-
projectLibDir,
110100
fileName,
111101
projectRoot,
112102
directory,
@@ -123,8 +113,6 @@ function updateProject(tree: Tree, projectRoot: string, umdName: string) {
123113
outputPath: `dist/${projectRoot}`,
124114
entryFile: `${projectRoot}/src/index.ts`,
125115
tsConfig: `${projectRoot}/tsconfig.lib.json`,
126-
buildableProjectDepsInPackageJsonType: 'dependencies',
127-
updateBuildableProjectDepsInPackageJson: true,
128116
compiler: 'tsc',
129117
generateExportsField: true,
130118
umdName,
@@ -203,6 +191,7 @@ function updatePackage(tree: Tree, projectRoot: string, schema: SchemaOptions) {
203191
function updateTsConfig(tree: Tree, projectRoot: string) {
204192
updateJson(tree, joinPathFragments(projectRoot, 'tsconfig.json'), (json) => {
205193
json.compilerOptions.module = 'ES6';
194+
json.extends = `../../${json.extends}`;
206195

207196
return json;
208197
});

0 commit comments

Comments
 (0)