Skip to content

Commit e915a93

Browse files
committed
feat: passing appPath and appResourcesPath through gradle args
+ remove redundant markingMode migration calls
1 parent 8c5e259 commit e915a93

19 files changed

+93
-97
lines changed

lib/commands/build.ts

+1-6
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,7 @@ export class BuildAndroidCommand extends BuildCommandBase implements ICommand {
165165
protected $androidBundleValidatorHelper: IAndroidBundleValidatorHelper,
166166
$buildDataService: IBuildDataService,
167167
protected $logger: ILogger,
168-
private $migrateController: IMigrateController,
169-
private $markingModeService: IMarkingModeService
168+
private $migrateController: IMigrateController
170169
) {
171170
super(
172171
$options,
@@ -182,10 +181,6 @@ export class BuildAndroidCommand extends BuildCommandBase implements ICommand {
182181
}
183182

184183
public async execute(args: string[]): Promise<void> {
185-
await this.$markingModeService.handleMarkingModeFullDeprecation({
186-
projectDir: this.$projectData.projectDir,
187-
skipWarnings: true,
188-
});
189184
await this.executeCore([
190185
this.$devicePlatformsConstants.Android.toLowerCase(),
191186
]);

lib/commands/debug.ts

-5
Original file line numberDiff line numberDiff line change
@@ -225,17 +225,12 @@ export class DebugAndroidCommand implements ICommand {
225225
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
226226
private $injector: IInjector,
227227
private $projectData: IProjectData,
228-
private $markingModeService: IMarkingModeService,
229228
private $options: IOptions
230229
) {
231230
this.$projectData.initializeProjectData();
232231
}
233232

234233
public async execute(args: string[]): Promise<void> {
235-
await this.$markingModeService.handleMarkingModeFullDeprecation({
236-
projectDir: this.$projectData.projectDir,
237-
skipWarnings: true,
238-
});
239234
return this.debugPlatformCommand.execute(args);
240235
}
241236
public async canExecute(args: string[]): Promise<boolean> {

lib/commands/deploy.ts

-7
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ export class DeployOnDeviceCommand
3636
private $mobileHelper: Mobile.IMobileHelper,
3737
$platformsDataService: IPlatformsDataService,
3838
private $deployCommandHelper: DeployCommandHelper,
39-
private $markingModeService: IMarkingModeService,
4039
private $migrateController: IMigrateController
4140
) {
4241
super(
@@ -50,12 +49,6 @@ export class DeployOnDeviceCommand
5049

5150
public async execute(args: string[]): Promise<void> {
5251
const platform = args[0];
53-
if (this.$mobileHelper.isAndroidPlatform(platform)) {
54-
await this.$markingModeService.handleMarkingModeFullDeprecation({
55-
projectDir: this.$projectData.projectDir,
56-
skipWarnings: true,
57-
});
58-
}
5952

6053
await this.$deployCommandHelper.deploy(platform);
6154
}

lib/commands/prepare.ts

+1-9
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ export class PrepareCommand
3131
private $platformCommandParameter: ICommandParameter,
3232
$platformsDataService: IPlatformsDataService,
3333
private $prepareDataService: PrepareDataService,
34-
private $migrateController: IMigrateController,
35-
private $markingModeService: IMarkingModeService,
36-
private $mobileHelper: Mobile.IMobileHelper
34+
private $migrateController: IMigrateController
3735
) {
3836
super(
3937
$options,
@@ -46,12 +44,6 @@ export class PrepareCommand
4644

4745
public async execute(args: string[]): Promise<void> {
4846
const platform = args[0];
49-
if (this.$mobileHelper.isAndroidPlatform(platform)) {
50-
await this.$markingModeService.handleMarkingModeFullDeprecation({
51-
projectDir: this.$projectData.projectDir,
52-
skipWarnings: true,
53-
});
54-
}
5547

5648
const prepareData = this.$prepareDataService.getPrepareData(
5749
this.$projectData.projectDir,

lib/commands/preview.ts

+1-6
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,13 @@ export class PreviewCommand implements ICommand {
2121
private $options: IOptions,
2222
private $previewAppLogProvider: IPreviewAppLogProvider,
2323
private $previewQrCodeService: IPreviewQrCodeService,
24-
$cleanupService: ICleanupService,
25-
private $markingModeService: IMarkingModeService
24+
$cleanupService: ICleanupService
2625
) {
2726
this.$analyticsService.setShouldDispose(false);
2827
$cleanupService.setShouldDispose(false);
2928
}
3029

3130
public async execute(): Promise<void> {
32-
await this.$markingModeService.handleMarkingModeFullDeprecation({
33-
projectDir: this.$projectData.projectDir,
34-
skipWarnings: true,
35-
});
3631
this.$previewAppLogProvider.on(
3732
DEVICE_LOG_EVENT_NAME,
3833
(deviceId: string, message: string) => {

lib/commands/run.ts

+1-6
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,10 @@ export class RunAndroidCommand implements ICommand {
148148
private $injector: IInjector,
149149
private $options: IOptions,
150150
private $platformValidationService: IPlatformValidationService,
151-
private $projectData: IProjectData,
152-
private $markingModeService: IMarkingModeService
151+
private $projectData: IProjectData
153152
) {}
154153

155154
public async execute(args: string[]): Promise<void> {
156-
await this.$markingModeService.handleMarkingModeFullDeprecation({
157-
projectDir: this.$projectData.projectDir,
158-
skipWarnings: true,
159-
});
160155
return this.runCommand.execute(args);
161156
}
162157

lib/commands/test.ts

+1-6
Original file line numberDiff line numberDiff line change
@@ -155,17 +155,12 @@ class TestAndroidCommand extends TestCommandBase implements ICommand {
155155
protected $cleanupService: ICleanupService,
156156
protected $liveSyncCommandHelper: ILiveSyncCommandHelper,
157157
protected $devicesService: Mobile.IDevicesService,
158-
protected $migrateController: IMigrateController,
159-
protected $markingModeService: IMarkingModeService
158+
protected $migrateController: IMigrateController
160159
) {
161160
super();
162161
}
163162

164163
public async execute(args: string[]): Promise<void> {
165-
await this.$markingModeService.handleMarkingModeFullDeprecation({
166-
projectDir: this.$projectData.projectDir,
167-
skipWarnings: true,
168-
});
169164
await super.execute(args);
170165
}
171166

lib/controllers/prepare-controller.ts

+21-26
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ import {
1212
AnalyticsEventLabelDelimiter,
1313
CONFIG_FILE_NAME_JS,
1414
CONFIG_FILE_NAME_TS,
15-
SCOPED_IOS_RUNTIME_NAME,
16-
SCOPED_ANDROID_RUNTIME_NAME,
17-
TNS_IOS_RUNTIME_NAME,
18-
TNS_ANDROID_RUNTIME_NAME,
15+
SupportedPlatform,
1916
} from "../constants";
2017
import {
2118
IProjectDataService,
@@ -79,6 +76,14 @@ export class PrepareController extends EventEmitter {
7976
await this.$markingModeService.handleMarkingModeFullDeprecation({
8077
projectDir: projectData.projectDir,
8178
});
79+
80+
this.$projectConfigService.writeLegacyNSConfigIfNeeded(
81+
projectData.projectDir,
82+
this.$projectDataService.getRuntimePackage(
83+
projectData.projectDir,
84+
prepareData.platform as SupportedPlatform
85+
)
86+
);
8287
}
8388

8489
await this.trackRuntimeVersion(prepareData.platform, projectData);
@@ -443,32 +448,22 @@ export class PrepareController extends EventEmitter {
443448
platform: string,
444449
projectData: IProjectData
445450
): Promise<void> {
446-
let runtimeVersion: string = null;
447-
try {
448-
if (projectData.devDependencies) {
449-
if (platform.toLowerCase() === "ios") {
450-
runtimeVersion =
451-
projectData.devDependencies[SCOPED_IOS_RUNTIME_NAME] ||
452-
projectData.devDependencies[TNS_IOS_RUNTIME_NAME];
453-
} else {
454-
runtimeVersion =
455-
projectData.devDependencies[SCOPED_ANDROID_RUNTIME_NAME] ||
456-
projectData.devDependencies[TNS_ANDROID_RUNTIME_NAME];
457-
}
458-
}
459-
} catch (err) {
451+
const { version } = this.$projectDataService.getRuntimePackage(
452+
projectData.projectDir,
453+
platform as SupportedPlatform
454+
);
455+
456+
if (!version) {
460457
this.$logger.trace(
461-
`Unable to get runtime version for project directory: ${projectData.projectDir} and platform ${platform}. Error is: `,
462-
err
458+
`Unable to get runtime version for project directory: ${projectData.projectDir} and platform ${platform}.`
463459
);
460+
return;
464461
}
465462

466-
if (runtimeVersion) {
467-
await this.$analyticsService.trackEventActionInGoogleAnalytics({
468-
action: TrackActionNames.UsingRuntimeVersion,
469-
additionalData: `${platform.toLowerCase()}${AnalyticsEventLabelDelimiter}${runtimeVersion}`,
470-
});
471-
}
463+
await this.$analyticsService.trackEventActionInGoogleAnalytics({
464+
action: TrackActionNames.UsingRuntimeVersion,
465+
additionalData: `${platform.toLowerCase()}${AnalyticsEventLabelDelimiter}${version}`,
466+
});
472467
}
473468
}
474469
injector.register("prepareController", PrepareController);

lib/controllers/preview-app-controller.ts

+1-9
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ export class PreviewAppController
4141
private $hmrStatusService: IHmrStatusService,
4242
private $logger: ILogger,
4343
public $hooksService: IHooksService,
44-
private $mobileHelper: Mobile.IMobileHelper,
4544
private $pluginsService: IPluginsService,
4645
private $prepareController: PrepareController,
4746
private $previewAppFilesService: IPreviewAppFilesService,
@@ -50,8 +49,7 @@ export class PreviewAppController
5049
private $previewQrCodeService: IPreviewQrCodeService,
5150
private $previewSdkService: IPreviewSdkService,
5251
private $prepareDataService: PrepareDataService,
53-
private $projectDataService: IProjectDataService,
54-
private $markingModeService: IMarkingModeService
52+
private $projectDataService: IProjectDataService
5553
) {
5654
super();
5755
}
@@ -100,12 +98,6 @@ export class PreviewAppController
10098
await this.$previewSdkService.initialize(
10199
data.projectDir,
102100
async (device: Device) => {
103-
if (this.$mobileHelper.isAndroidPlatform(device.platform)) {
104-
await this.$markingModeService.handleMarkingModeFullDeprecation({
105-
projectDir: projectData.projectDir,
106-
});
107-
}
108-
109101
try {
110102
if (!device) {
111103
this.$errors.fail(

lib/definitions/project.d.ts

+5
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,11 @@ interface IProjectConfigService {
315315
getDefaultTSConfig(appId: string): string;
316316

317317
writeDefaultConfig(projectDir?: string, appId?: string): void;
318+
319+
writeLegacyNSConfigIfNeeded(
320+
projectDir: string,
321+
runtimePackage: IBasePluginData
322+
): void;
318323
}
319324

320325
interface IAssetItem {

lib/services/android/gradle-build-args-service.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ import { IAndroidToolsInfo } from "../../declarations";
55
import { IAndroidBuildData } from "../../definitions/build";
66
import { IHooksService, IAnalyticsService } from "../../common/declarations";
77
import { injector } from "../../common/yok";
8+
import { IProjectData } from "../../definitions/project";
89

910
export class GradleBuildArgsService implements IGradleBuildArgsService {
1011
constructor(
1112
private $androidToolsInfo: IAndroidToolsInfo,
1213
private $hooksService: IHooksService,
1314
private $analyticsService: IAnalyticsService,
1415
private $staticConfig: Config.IStaticConfig,
16+
private $projectData: IProjectData,
1517
private $logger: ILogger
1618
) {}
1719

@@ -50,11 +52,17 @@ export class GradleBuildArgsService implements IGradleBuildArgsService {
5052
const toolsInfo = this.$androidToolsInfo.getToolsInfo({
5153
projectDir: buildData.projectDir,
5254
});
55+
56+
// ensure we initialize project data
57+
this.$projectData.initializeProjectData(buildData.projectDir);
58+
5359
args.push(
5460
`-PcompileSdk=android-${toolsInfo.compileSdkVersion}`,
5561
`-PtargetSdk=${toolsInfo.targetSdkVersion}`,
5662
`-PbuildToolsVersion=${toolsInfo.buildToolsVersion}`,
57-
`-PgenerateTypings=${toolsInfo.generateTypings}`
63+
`-PgenerateTypings=${toolsInfo.generateTypings}`,
64+
`-PappPath=${this.$projectData.getAppDirectoryPath()}`,
65+
`-PappResourcesPath=${this.$projectData.getAppResourcesDirectoryPath()}`
5866
);
5967

6068
if (buildData.release) {

lib/services/project-config-service.ts

+34-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {
2+
CONFIG_FILE_NAME_DISPLAY,
23
CONFIG_FILE_NAME_JS,
34
CONFIG_FILE_NAME_TS,
4-
CONFIG_FILE_NAME_DISPLAY,
55
} from "../constants";
66
import * as path from "path";
77
import * as _ from "lodash";
@@ -10,6 +10,8 @@ import { IFileSystem, IProjectHelper } from "../common/declarations";
1010
import { injector } from "../common/yok";
1111
import { INsConfig, IProjectConfigService } from "../definitions/project";
1212
import { IInjector } from "../common/definitions/yok";
13+
import { IBasePluginData } from "../definitions/plugins";
14+
import semver = require("semver/preload");
1315

1416
export class ProjectConfigService implements IProjectConfigService {
1517
constructor(
@@ -125,6 +127,37 @@ export default {
125127

126128
this.$fs.writeFile(configTSFilePath, this.getDefaultTSConfig(appId));
127129
}
130+
131+
public writeLegacyNSConfigIfNeeded(
132+
projectDir: string,
133+
runtimePackage: IBasePluginData
134+
) {
135+
if (
136+
runtimePackage.version &&
137+
semver.gte(runtimePackage.version, "7.0.0-rc.5")
138+
) {
139+
return;
140+
}
141+
this.$logger.warn();
142+
this.$logger.printMarkdown(`
143+
Using __${runtimePackage.name}${
144+
runtimePackage.version ? "@" + runtimePackage.version : ""
145+
}__ which requires \`nsconfig.json\` to be present.
146+
Writing \`nsconfig.json\` based on the values set in \`${CONFIG_FILE_NAME_DISPLAY}\`.
147+
You may add \`nsconfig.json\` to \`.gitignore\` as the CLI will regenerate it as necessary.`);
148+
const nsConfigPath = path.join(
149+
projectDir || this.projectHelper.projectDir,
150+
"nsconfig.json"
151+
);
152+
153+
this.$fs.writeJson(nsConfigPath, {
154+
_info1: `Auto Generated for backwards compatibility with the currently used runtime.`,
155+
_info2: `Do not edit this file manually, as any changes will be ignored.`,
156+
_info3: `Config changes should be done in ${CONFIG_FILE_NAME_DISPLAY} instead.`,
157+
appPath: this.getValue("appPath"),
158+
appResourcesPath: this.getValue("appResourcesPath"),
159+
});
160+
}
128161
}
129162

130163
injector.register("projectConfigService", ProjectConfigService);

test/package-installation-manager.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,14 @@ import * as yok from "../lib/common/yok";
1515
import ChildProcessLib = require("../lib/common/child-process");
1616
import { SettingsService } from "../lib/common/test/unit-tests/stubs";
1717
import { ProjectDataService } from "../lib/services/project-data-service";
18-
import { MarkingModeServiceStub, ProjectDataStub } from "./stubs";
18+
import { ProjectDataStub } from "./stubs";
1919
import { IInjector } from "../lib/common/definitions/yok";
2020
import * as _ from "lodash";
2121
import { IDictionary } from "../lib/common/declarations";
2222

2323
function createTestInjector(): IInjector {
2424
const testInjector = new yok.Yok();
2525

26-
testInjector.register("markingModeService", MarkingModeServiceStub);
2726
testInjector.register("projectData", ProjectDataStub);
2827
testInjector.register("config", ConfigLib.Configuration);
2928
testInjector.register("logger", LoggerLib.Logger);

test/platform-commands.ts

-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import { Messages } from "../lib/common/messages/messages";
2121
import { SettingsService } from "../lib/common/test/unit-tests/stubs";
2222
import { PlatformValidationService } from "../lib/services/platform/platform-validation-service";
2323
import { PlatformCommandHelper } from "../lib/helpers/platform-command-helper";
24-
import { MarkingModeServiceStub } from "./stubs";
2524
import {
2625
IPlatformData,
2726
IBuildOutputOptions,
@@ -138,7 +137,6 @@ function createTestInjector() {
138137
const testInjector = new yok.Yok();
139138

140139
testInjector.register("injector", testInjector);
141-
testInjector.register("markingModeService", MarkingModeServiceStub);
142140
testInjector.register("hooksService", stubs.HooksServiceStub);
143141
testInjector.register("staticConfig", StaticConfigLib.StaticConfig);
144142
testInjector.register("nodeModulesDependenciesBuilder", {});

0 commit comments

Comments
 (0)