Skip to content

Commit 8805f1e

Browse files
committed
fix: scoped runtimes, project detection, frameworkPath
1 parent 25edea4 commit 8805f1e

22 files changed

+318
-258
lines changed

lib/commands/create-project.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,12 @@ export class CreateProjectCommand implements ICommand {
4343
(this.$options.tsc ||
4444
this.$options.ng ||
4545
this.$options.vue ||
46+
this.$options.react ||
4647
this.$options.js) &&
4748
this.$options.template
4849
) {
4950
this.$errors.failWithHelp(
50-
"You cannot use a flavor option like --ng, --vue, --tsc and --js together with --template."
51+
"You cannot use a flavor option like --ng, --vue, --react, --tsc and --js together with --template."
5152
);
5253
}
5354

lib/common/project-helper.ts

+13-14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as path from "path";
22
import * as _ from "lodash";
3-
import { IProjectHelper, IFileSystem } from "./declarations";
3+
import { IErrors, IFileSystem, IProjectHelper } from "./declarations";
44
import { IOptions } from "../declarations";
55
import { injector } from "./yok";
66

@@ -9,7 +9,7 @@ export class ProjectHelper implements IProjectHelper {
99
private $logger: ILogger,
1010
private $fs: IFileSystem,
1111
private $staticConfig: Config.IStaticConfig,
12-
// private $errors: IErrors,
12+
private $errors: IErrors,
1313
private $options: IOptions
1414
) {}
1515

@@ -73,19 +73,18 @@ export class ProjectHelper implements IProjectHelper {
7373
}
7474

7575
private isProjectFileCorrect(projectFilePath: string): boolean {
76-
// this is no longer correct, since we have moved the "nativescript" key out from package.json
77-
78-
// if (this.$staticConfig.CLIENT_NAME_KEY_IN_PROJECT_FILE) {
79-
// try {
80-
// const fileContent = this.$fs.readJson(projectFilePath);
81-
// const clientSpecificData = fileContent[this.$staticConfig.CLIENT_NAME_KEY_IN_PROJECT_FILE] && fileContent[this.$staticConfig.CLIENT_NAME_KEY_IN_PROJECT_FILE].id;
82-
// return !!clientSpecificData;
83-
// } catch (err) {
84-
// this.$errors.fail("The project file is corrupted. Additional technical information: %s", err);
85-
// }
86-
// }
76+
try {
77+
const fileContent = this.$fs.readText(projectFilePath);
78+
return fileContent.includes("nativescript");
79+
} catch (err) {
80+
this.$errors.fail(
81+
"The project file is corrupted. Additional technical information: %s",
82+
err
83+
);
84+
}
8785

88-
return true;
86+
return false;
8987
}
9088
}
89+
9190
injector.register("projectHelper", ProjectHelper);

lib/controllers/migrate-controller.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,13 @@ Running this command will ${MigrateController.COMMON_MIGRATE_MESSAGE}`;
182182
packageName: MigrateController.typescriptPackageName,
183183
isDev: true,
184184
verifiedVersion: "3.9.0",
185-
}
185+
},
186186
];
187187

188188
get verifiedPlatformVersions(): IDictionary<string> {
189189
return {
190-
[this.$devicePlatformsConstants.Android.toLowerCase()]: "7.0.0",
191-
[this.$devicePlatformsConstants.iOS.toLowerCase()]: "7.0.0",
190+
[this.$devicePlatformsConstants.Android.toLowerCase()]: "6.5.3",
191+
[this.$devicePlatformsConstants.iOS.toLowerCase()]: "6.5.2",
192192
};
193193
}
194194

lib/declarations.d.ts

+26-18
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ interface IPackageManager extends INodePackageManager {
125125
}
126126

127127
interface IPerformanceService {
128-
// Will process the data based on the command opitons (--performance flag and user-reporting setting)
128+
// Will process the data based on the command options (--performance flag and user-reporting setting)
129129
processExecutionData(
130130
methodInfo: string,
131131
startTime: number,
@@ -143,6 +143,11 @@ interface IPackageInstallationManager {
143143
packageDir: string,
144144
options?: INpmInstallOptions
145145
): Promise<any>;
146+
uninstall(
147+
packageName: string,
148+
packageDir: string,
149+
options?: IDictionary<string | boolean>
150+
): Promise<any>;
146151
getLatestVersion(packageName: string): Promise<string>;
147152
getNextVersion(packageName: string): Promise<string>;
148153
getLatestCompatibleVersion(
@@ -344,36 +349,36 @@ interface INpmInstallCLIResult {
344349
interface INpm5InstallCliResult {
345350
/**
346351
* Added dependencies. Note that whenever add a particular dependency with npm 5 it is listed inside of array with key "Added".
347-
* @type {INpmDependencyUpdateInfo[]}
352+
* @type {INpm5DependencyInfo[]}
348353
*/
349354
added: INpm5DependencyInfo[];
350355
/**
351356
* Removed dependencies. Note that whenever remove a particular dependency with npm 5 it is listed inside of array with key "removed".
352-
* @type {INpmDependencyUpdateInfo[]}
357+
* @type {INpm5DependencyInfo[]}
353358
*/
354359
removed: INpm5DependencyInfo[];
355360
/**
356361
* Updated dependencies. Note that whenever update a particular dependency with npm 5 it is listed inside of array with key "updated".
357-
* @type {INpmDependencyUpdateInfo[]}
362+
* @type {INpm5DependencyInfo[]}
358363
*/
359364
updated: INpm5DependencyInfo[];
360365
/**
361366
* Moved dependencies. Note that whenever move a particular dependency with npm 5 it is listed inside of array with key "moved".
362-
* @type {INpmDependencyUpdateInfo[]}
367+
* @type {INpm5DependencyInfo[]}
363368
*/
364369
moved: INpm5DependencyInfo[];
365370
/**
366371
* Failed dependencies. Note that whenever use npm 5 and the operation over particular dependency fail it is listed inside of array with key "failed".
367-
* @type {INpmDependencyUpdateInfo[]}
372+
* @type {INpm5DependencyInfo[]}
368373
*/
369374
failed: INpm5DependencyInfo[];
370375
/**
371376
* Warnings. Note that whenever use npm 5 and the operation over particular dependency have warnings they are listed inside of array with key "warnings".
372-
* @type {INpmDependencyUpdateInfo[]}
377+
* @type {INpm5DependencyInfo[]}
373378
*/
374379
warnings: INpm5DependencyInfo[];
375380
/**
376-
*Time elapsed.
381+
* Time elapsed.
377382
* @type {Number}
378383
*/
379384
elapsed: Number;
@@ -515,7 +520,7 @@ interface IApplicationPackage {
515520
}
516521

517522
interface IOpener {
518-
open(target: string, appname: string): void;
523+
open(target: string, appName: string): void;
519524
}
520525

521526
interface IBundleString {
@@ -748,7 +753,7 @@ interface IITMSData {
748753
}
749754

750755
/**
751-
* Used for communicating with Xcode's iTMS Transporter tool.
756+
* Used for communicating with Xcode iTMS Transporter tool.
752757
*/
753758
interface IITMSTransporterService {
754759
validate(): Promise<void>;
@@ -766,7 +771,7 @@ interface IITMSTransporterService {
766771
interface IAndroidToolsInfo {
767772
/**
768773
* Provides information about installed Android SDKs, Build Tools, Support Library
769-
* and ANDROID_HOME environement variable.
774+
* and ANDROID_HOME environment variable.
770775
* @param {IProjectDir} config Object with a single property - projectDir. This is the root directory where NativeScript project is located.
771776
* @return {IAndroidToolsInfoData} Information about installed Android Tools and SDKs.
772777
*/
@@ -879,13 +884,15 @@ interface IAppDebugSocketProxyFactory extends NodeJS.EventEmitter {
879884
removeAllProxies(): void;
880885
}
881886

887+
// tslint:disable-next-line:interface-name
882888
interface IiOSNotification extends NodeJS.EventEmitter {
883889
getAttachRequest(appId: string, deviceId: string): string;
884890
getReadyForAttach(appId: string): string;
885891
getRefreshRequest(appId: string): string;
886892
getAppRefreshStarted(appId: string): string;
887893
}
888894

895+
// tslint:disable-next-line:interface-name
889896
interface IiOSSocketRequestExecutor {
890897
executeAttachRequest(
891898
device: Mobile.IiOSDevice,
@@ -959,9 +966,9 @@ interface IVersionsService {
959966
interface IProjectNameService {
960967
/**
961968
* Ensures the passed project name is valid. If the project name is not valid prompts for actions.
962-
* @param {string} project name to be checked.
963-
* @param {IOptions} current command options.
964-
* @return {Promise<strng>} returns the selected name of the project.
969+
* @param {string} projectName project name to be checked.
970+
* @param {IOptions} validateOptions current command options.
971+
* @return {Promise<string>} returns the selected name of the project.
965972
*/
966973
ensureValidName(
967974
projectName: string,
@@ -997,15 +1004,15 @@ interface IXcprojService {
9971004
*/
9981005
interface IXcprojInfo {
9991006
/**
1000-
* determines whether the system needs xcproj to execute ios builds sucessfully
1007+
* determines whether the system needs xcproj to execute ios builds successfully
10011008
*/
10021009
shouldUseXcproj: boolean;
10031010
/**
10041011
* pod version string, as returned by `pod --version`
10051012
*/
10061013
cocoapodVer: string;
10071014
/**
1008-
* Xcode's version
1015+
* Xcode version
10091016
*/
10101017
xcodeVersion: IVersionData;
10111018
/**
@@ -1032,7 +1039,7 @@ interface IXcconfigService {
10321039

10331040
/**
10341041
* Merges the content of source file into destination file
1035-
* @param sourceFile The content of thes source file
1042+
* @param sourceFile The content of the source file
10361043
* @param destinationFile The content of the destination file
10371044
* @returns {Promise<void>}
10381045
*/
@@ -1046,6 +1053,7 @@ interface IBundleValidatorHelper {
10461053
/**
10471054
* Validates bundling options.
10481055
* In case when minSupportedVersion is provided, gets the current version of @nativescript/webpack from package.json and compares with the provided version.
1056+
* @param {IProjectData} projectData
10491057
* @param {string} minSupportedVersion the minimum supported version of @nativescript/webpack
10501058
* @return {void}
10511059
*/
@@ -1206,7 +1214,7 @@ interface IPlatformCommandHelper {
12061214
cleanPlatforms(
12071215
platforms: string[],
12081216
projectData: IProjectData,
1209-
framworkPath: string
1217+
frameworkPath: string
12101218
): Promise<void>;
12111219
removePlatforms(
12121220
platforms: string[],

lib/definitions/project.d.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ interface INsConfigAndroid extends INsConfigPlaform {
128128
discardUncaughtJsExceptions?: boolean;
129129

130130
enableLineBreakpoints?: boolean;
131+
132+
enableMultithreadedJavascript?: boolean;
131133
}
132134

133135
interface INsConfig {
@@ -375,7 +377,7 @@ interface ITemplateData {
375377
* In case template is v1, will be {pathToProjectDir}/node_modules/{templateName}.
376378
* In case template is v2, will be null.
377379
*/
378-
templatePath: string;
380+
// templatePath: string;
379381
/**
380382
* The whole content of package.json file
381383
*/

lib/helpers/platform-command-helper.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,14 @@ export class PlatformCommandHelper implements IPlatformCommandHelper {
106106
platform.toLowerCase()
107107
);
108108
this.$fs.deleteDirectory(platformDir);
109-
this.$projectDataService.removeNSProperty(
110-
projectData.projectDir,
111-
platformData.frameworkPackageName
109+
await this.$packageInstallationManager.uninstall(
110+
platformData.frameworkPackageName,
111+
projectData.projectDir
112112
);
113+
// this.$projectDataService.removeNSProperty(
114+
// projectData.projectDir,
115+
// platformData.frameworkPackageName
116+
// );
113117

114118
this.$logger.info(`Platform ${platform} successfully removed.`);
115119
} catch (err) {

lib/package-installation-manager.ts

+25-4
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
import * as path from "path";
2-
const semver = require("semver");
32
import * as constants from "./constants";
43
import {
4+
INpmInstallOptions,
5+
INpmInstallResultInfo,
56
IPackageInstallationManager,
67
IPackageManager,
78
IStaticConfig,
8-
INpmInstallOptions,
9-
INpmInstallResultInfo,
109
} from "./declarations";
1110
import { IProjectDataService } from "./definitions/project";
1211
import {
1312
IChildProcess,
14-
ISettingsService,
13+
IDictionary,
1514
IFileSystem,
15+
ISettingsService,
1616
} from "./common/declarations";
1717
import { injector } from "./common/yok";
1818

19+
const semver = require("semver");
20+
1921
export class PackageInstallationManager implements IPackageInstallationManager {
2022
constructor(
2123
private $packageManager: IPackageManager,
@@ -151,6 +153,24 @@ export class PackageInstallationManager implements IPackageInstallationManager {
151153
}
152154
}
153155

156+
public async uninstall(
157+
packageToUninstall: string,
158+
projectDir: string,
159+
opts?: IDictionary<string | boolean>
160+
): Promise<any> {
161+
try {
162+
return await this.$packageManager.uninstall(
163+
packageToUninstall,
164+
opts,
165+
projectDir
166+
);
167+
} catch (error) {
168+
this.$logger.debug(error);
169+
170+
throw error;
171+
}
172+
}
173+
154174
public async getInspectorFromCache(
155175
inspectorNpmPackageName: string,
156176
projectDir: string
@@ -308,4 +328,5 @@ export class PackageInstallationManager implements IPackageInstallationManager {
308328
return data[version];
309329
}
310330
}
331+
311332
injector.register("packageInstallationManager", PackageInstallationManager);

lib/project-data.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ export class ProjectData implements IProjectData {
4040
},
4141
{
4242
type: constants.ProjectTypes.NgFlavorName,
43-
requiredDependencies: ["@angular/core", "nativescript-angular"],
43+
requiredDependencies: [
44+
"@angular/core",
45+
"nativescript-angular",
46+
"@nativescript/angular",
47+
],
4448
},
4549
{
4650
type: constants.ProjectTypes.VueFlavorName,
@@ -147,7 +151,7 @@ export class ProjectData implements IProjectData {
147151
);
148152
}
149153

150-
if (nsConfig) {
154+
if (nsConfig && packageJsonData) {
151155
this.projectDir = projectDir;
152156
this.projectName = this.$projectHelper.sanitizeName(
153157
path.basename(projectDir)
@@ -291,6 +295,7 @@ export class ProjectData implements IProjectData {
291295
ios: config.id,
292296
android: config.id,
293297
};
298+
294299
if (config.ios && config.ios.id) {
295300
identifier.ios = config.ios.id;
296301
}

lib/services/marking-mode-service.ts

+6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const MARKING_MODE_NONE_CONFIRM_MSG = `Do you want to switch your app to the rec
1717
More info about the reasons for this change can be found in the link below:
1818
https://www.nativescript.org/blog/markingmode-none-is-official-boost-android-performance-while-avoiding-memory-issues`;
1919

20+
// TODO: update to work with new configs!
2021
export class MarkingModeService implements IMarkingModeService {
2122
constructor(
2223
private $fs: IFileSystem,
@@ -28,6 +29,11 @@ export class MarkingModeService implements IMarkingModeService {
2829
public async handleMarkingModeFullDeprecation(
2930
options: IMarkingModeFullDeprecationOptions
3031
): Promise<void> {
32+
this.$logger.error(
33+
"handleMarkingModeFullDeprecation has not yet been updated to the new config handling!!!!"
34+
);
35+
return;
36+
3137
const { projectDir, skipWarnings, forceSwitch } = options;
3238
const projectData = this.$projectDataService.getProjectData(projectDir);
3339
const innerPackageJsonPath = path.join(

0 commit comments

Comments
 (0)