Skip to content

Commit

Permalink
fix(core): read js lib defaults when generating js lib
Browse files Browse the repository at this point in the history
  • Loading branch information
AgentEnder committed Jul 28, 2024
1 parent 771de5b commit c8bac90
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@ async function generateShellProject(
};

const { tasks: codegenTasks, name: codegenProjectName } =
await generateCodegenProject(host, options);
await generateCodegenProject(
host,
options as NormalizedOptions & { codegenProject: string },
);

tasks.push(...codegenTasks);

Expand Down Expand Up @@ -155,21 +158,30 @@ async function generateShellProject(

async function generateCodegenProject(
host: Tree,
options: AddSwaggerJsonExecutorSchema,
options: AddSwaggerJsonExecutorSchema & {
codegenProject: string;
},
): Promise<{ name: string; tasks: GeneratorCallback[] }> {
const tasks: GeneratorCallback[] = [];
const nameWithDirectory = `generated-${options.codegenProject}`;

const nxJson = readNxJson(host);

const {
libraryGenerator,
}: // eslint-disable-next-line @typescript-eslint/no-var-requires
typeof import('@nx/js') = require('@nx/js');
const libraryGeneratorDefaults = {
...nxJson?.generators?.['@nx/js:library'],
...nxJson?.generators?.['@nx/js']?.library,
};
tasks.push(
await libraryGenerator(host, {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
name: options.codegenProject!,
...libraryGeneratorDefaults,
name: options.codegenProject,
directory: 'generated',
buildable: true,
unitTestRunner: 'none',
}),
);
await updateProjectConfiguration(
Expand Down
2 changes: 1 addition & 1 deletion project.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"options": {
"port": 4872,
"config": ".verdaccio/config.yml",
"storage": "build/local-registry/storage"
"storage": "dist/local-registry/storage"
}
}
},
Expand Down

0 comments on commit c8bac90

Please sign in to comment.