Skip to content
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

perf(cli:update): automatically add @_mock path #1675

Merged
merged 1 commit into from
Nov 3, 2023
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
1 change: 1 addition & 0 deletions schematics/application/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ function addPathsToTsConfig(): Rule {
paths['@shared'] = ['src/app/shared/index'];
paths['@core'] = ['src/app/core/index'];
paths['@env/*'] = ['src/environments/*'];
paths['@_mock'] = ['_mock/index'];
writeJSON(tree, 'tsconfig.json', json);
return tree;
};
Expand Down
16 changes: 16 additions & 0 deletions schematics/ng-update/upgrade-rules/base.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Rule, Tree } from '@angular-devkit/schematics';

import { readJSON, writeJSON } from '../../utils';

export function updateMockPath(): Rule {
return (tree: Tree) => {
const json = readJSON(tree, 'tsconfig.json', 'compilerOptions');
if (json == null) return tree;
if (!json.compilerOptions) json.compilerOptions = {};
if (!json.compilerOptions.paths) json.compilerOptions.paths = {};
const paths = json.compilerOptions.paths;
paths[`@_mock`] = [`_mock/index`];
writeJSON(tree, 'tsconfig.json', json);
return tree;
};
}
3 changes: 2 additions & 1 deletion schematics/ng-update/upgrade-rules/v16/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as colors from 'ansi-colors';

import { logStart, readJSON, readPackage, writeJSON, writePackage } from '../../../utils';
import { UpgradeMainVersions } from '../../../utils/versions';
import { updateMockPath } from '../base';

function removeStylelintConfigPrettier(): Rule {
return (tree: Tree, context: SchematicContext) => {
Expand Down Expand Up @@ -47,6 +48,6 @@ export function v16Rule(): Rule {
return async (tree: Tree, context: SchematicContext) => {
logStart(context, `Upgrade @delon/* version number`);
UpgradeMainVersions(tree);
return chain([removeStylelintConfigPrettier(), finished()]);
return chain([removeStylelintConfigPrettier(), updateMockPath(), finished()]);
};
}