Skip to content

Commit

Permalink
fix: the tsconfig spec generated for library contains several issues
Browse files Browse the repository at this point in the history
  • Loading branch information
cpaulve-1A committed Dec 17, 2024
1 parent 5cb8aeb commit e700452
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 18 deletions.
25 changes: 24 additions & 1 deletion packages/@o3r/workspace/schematics/library/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import {
chain,
noop,
Rule,
SchematicContext,
strings,
Tree,
} from '@angular-devkit/schematics';
import {
RunSchematicTask,
Expand All @@ -14,6 +16,7 @@ import {
createSchematicWithMetricsIfInstalled,
type DependencyToAdd,
getPackagesBaseRootFolder,
getTestFramework,
getWorkspaceConfig,
isNxContext,
O3rCliError,
Expand All @@ -35,6 +38,25 @@ import {
NgGenerateModuleSchema,
} from './schema';

const updatePackageJsonForJest = (options: NgGenerateModuleSchema) =>
(tree: Tree, context: SchematicContext) => {
if ((options.testingFramework || getTestFramework(getWorkspaceConfig(tree), context)) !== 'jest') {
return;

Check warning on line 44 in packages/@o3r/workspace/schematics/library/index.ts

View check run for this annotation

Codecov / codecov/patch

packages/@o3r/workspace/schematics/library/index.ts#L44

Added line #L44 was not covered by tests
}

const workspaceConfig = getWorkspaceConfig(tree);
const workspaceProject = (options.projectName && workspaceConfig?.projects?.[options.projectName]) || undefined;
if (!workspaceProject?.root) {
context.logger.error(`Failed to find a package json for ${options.name}`);
return;
}
const packageJsonPath = path.resolve(workspaceProject.root, 'package.json');
const packageJsonContent = tree.readJson(packageJsonPath) as PackageJson;
packageJsonContent.script ||= {};
packageJsonContent.scripts!.test ||= 'jest';
tree.overwrite(packageJsonPath, JSON.stringify(packageJsonContent, null, 2));
return tree;

Check warning on line 58 in packages/@o3r/workspace/schematics/library/index.ts

View check run for this annotation

Codecov / codecov/patch

packages/@o3r/workspace/schematics/library/index.ts#L53-L58

Added lines #L53 - L58 were not covered by tests
};
/**
* Add an Otter compatible module to a monorepo
* @param options Schematic options
Expand Down Expand Up @@ -79,7 +101,8 @@ function generateModuleFn(options: NgGenerateModuleSchema): Rule {
context.addTask(new RunSchematicTask('@o3r/core', 'ng-add-create', { name: extendedOptions.name, projectName: extendedOptions.name, path: targetPath }), ids);
}
}),
options.skipLinter ? noop() : applyEsLintFix()
options.skipLinter ? noop() : applyEsLintFix(),
updatePackageJsonForJest(options)
])(tree, context);
};
}
Expand Down

This file was deleted.

27 changes: 27 additions & 0 deletions tools/github-actions/new-version/packaged-action/LICENSE.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e700452

Please sign in to comment.