Skip to content

Commit 5d807ce

Browse files
committed
fix: allow to enforce corePackageName to use custom
1 parent ba9e812 commit 5d807ce

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

lib/common/project-helper.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ import { IErrors, IFileSystem, IProjectHelper } from "./declarations";
44
import { IOptions } from "../declarations";
55
import { injector } from "./yok";
66
import { SCOPED_TNS_CORE_MODULES, TNS_CORE_MODULES_NAME } from "../constants";
7+
import { IProjectData } from "../definitions/project";
8+
import { IInjector } from "./definitions/yok";
79

810
export class ProjectHelper implements IProjectHelper {
911
constructor(
12+
private $injector: IInjector,
1013
private $logger: ILogger,
1114
private $fs: IFileSystem,
1215
private $staticConfig: Config.IStaticConfig,
@@ -76,8 +79,10 @@ export class ProjectHelper implements IProjectHelper {
7679
private isProjectFileCorrect(projectFilePath: string): boolean {
7780
try {
7881
const fileContent = this.$fs.readText(projectFilePath);
82+
const packageName = this.getProjectData(path.dirname(projectFilePath)).nsConfig.corePackageName || SCOPED_TNS_CORE_MODULES;
83+
7984
return (
80-
fileContent.includes(SCOPED_TNS_CORE_MODULES) ||
85+
fileContent.includes(packageName) ||
8186
fileContent.includes(TNS_CORE_MODULES_NAME)
8287
);
8388
} catch (err) {
@@ -89,6 +94,16 @@ export class ProjectHelper implements IProjectHelper {
8994

9095
return false;
9196
}
97+
private getProjectData(projectFilePath: string): IProjectData {
98+
try {
99+
const projectData: IProjectData = this.$injector.resolve("projectData");
100+
projectData.initializeProjectData(projectFilePath);
101+
return projectData;
102+
} catch (error) {
103+
console.error(error)
104+
return null;
105+
}
106+
}
92107
}
93108

94109
injector.register("projectHelper", ProjectHelper);

lib/definitions/project.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ interface INsConfig {
200200
ignoredNativeDependencies?: string[];
201201
hooks?: INsConfigHooks[];
202202
projectName?: string;
203+
corePackageName?: string;
203204
}
204205

205206
interface IProjectData extends ICreateProjectData {

lib/services/versions-service.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,11 @@ class VersionsService implements IVersionsService {
6767
this.projectData.projectDir,
6868
constants.NODE_MODULES_FOLDER_NAME
6969
);
70+
const packageName = this.projectData.nsConfig.corePackageName || constants.SCOPED_TNS_CORE_MODULES;
71+
7072
const scopedPackagePath = path.join(
7173
nodeModulesPath,
72-
constants.SCOPED_TNS_CORE_MODULES
74+
packageName
7375
);
7476
const tnsCoreModulesPath = path.join(
7577
nodeModulesPath,

0 commit comments

Comments
 (0)