Skip to content

Commit d133c8b

Browse files
authored
Merge pull request #4591 from NativeScript/fatme/bundle-workflow
feat: introduce webpack only workflow
2 parents cec7c99 + 297814e commit d133c8b

File tree

142 files changed

+4361
-6067
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+4361
-6067
lines changed

PublicAPI.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -656,11 +656,6 @@ interface IDebugData {
656656
*/
657657
applicationIdentifier: string;
658658

659-
/**
660-
* Path to .app built for iOS Simulator.
661-
*/
662-
pathToAppPackage?: string;
663-
664659
/**
665660
* The name of the application, for example `MyProject`.
666661
*/

lib/bootstrap.ts

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,32 @@ $injector.require("projectTemplatesService", "./services/project-templates-servi
3232
$injector.require("projectNameService", "./services/project-name-service");
3333
$injector.require("tnsModulesService", "./services/tns-modules-service");
3434

35-
$injector.require("platformsData", "./platforms-data");
36-
$injector.require("platformService", "./services/platform-service");
37-
$injector.require("preparePlatformJSService", "./services/prepare-platform-js-service");
38-
$injector.require("preparePlatformNativeService", "./services/prepare-platform-native-service");
35+
$injector.require("platformsDataService", "./services/platforms-data-service");
36+
$injector.require("addPlatformService", "./services/platform/add-platform-service");
37+
$injector.require("buildInfoFileService", "./services/build-info-file-service");
38+
$injector.require("prepareNativePlatformService", "./services/platform/prepare-native-platform-service");
39+
$injector.require("platformValidationService", "./services/platform/platform-validation-service");
40+
41+
$injector.require("buildArtefactsService", "./services/build-artefacts-service");
42+
43+
$injector.require("deviceDebugAppService", "./services/device/device-debug-app-service");
44+
$injector.require("deviceInstallAppService", "./services/device/device-install-app-service");
45+
$injector.require("deviceRefreshAppService", "./services/device/device-refresh-app-service");
46+
47+
$injector.require("runEmitter", "./emitters/run-emitter");
48+
$injector.require("previewAppEmitter", "./emitters/preview-app-emitter");
49+
50+
$injector.require("platformController", "./controllers/platform-controller");
51+
$injector.require("prepareController", "./controllers/prepare-controller");
52+
$injector.require("buildController", "./controllers/build-controller");
53+
$injector.require("deployController", "./controllers/deploy-controller");
54+
$injector.require("runController", "./controllers/run-controller");
55+
$injector.require("previewAppController", "./controllers/preview-app-controller");
56+
57+
$injector.require("prepareDataService", "./services/prepare-data-service");
58+
$injector.require("buildDataService", "./services/build-data-service");
59+
60+
$injector.require("liveSyncServiceResolver", "./resolvers/livesync-service-resolver");
3961

4062
$injector.require("debugDataService", "./services/debug-data-service");
4163
$injector.requirePublicClass("debugService", "./services/debug-service");
@@ -47,8 +69,6 @@ $injector.requirePublic("analyticsSettingsService", "./services/analytics-settin
4769
$injector.require("analyticsService", "./services/analytics/analytics-service");
4870
$injector.require("googleAnalyticsProvider", "./services/analytics/google-analytics-provider");
4971

50-
$injector.require("emulatorSettingsService", "./services/emulator-settings-service");
51-
5272
$injector.require("platformCommandParameter", "./platform-command-param");
5373
$injector.requireCommand("create", "./commands/create-project");
5474
$injector.requireCommand("generate", "./commands/generate");
@@ -66,8 +86,6 @@ $injector.requireCommand("debug|ios", "./commands/debug");
6686
$injector.requireCommand("debug|android", "./commands/debug");
6787

6888
$injector.requireCommand("prepare", "./commands/prepare");
69-
$injector.requireCommand("clean-app|ios", "./commands/clean-app");
70-
$injector.requireCommand("clean-app|android", "./commands/clean-app");
7189
$injector.requireCommand("build|ios", "./commands/build");
7290
$injector.requireCommand("build|android", "./commands/build");
7391
$injector.requireCommand("deploy", "./commands/deploy");
@@ -134,10 +152,10 @@ $injector.require("bundleValidatorHelper", "./helpers/bundle-validator-helper");
134152
$injector.require("androidBundleValidatorHelper", "./helpers/android-bundle-validator-helper");
135153
$injector.require("liveSyncCommandHelper", "./helpers/livesync-command-helper");
136154
$injector.require("deployCommandHelper", "./helpers/deploy-command-helper");
155+
$injector.require("platformCommandHelper", "./helpers/platform-command-helper");
137156
$injector.require("optionsTracker", "./helpers/options-track-helper");
138157

139158
$injector.requirePublicClass("localBuildService", "./services/local-build-service");
140-
$injector.requirePublicClass("liveSyncService", "./services/livesync/livesync-service");
141159
$injector.require("LiveSyncSocket", "./services/livesync/livesync-socket");
142160
$injector.requirePublicClass("androidLivesyncTool", "./services/livesync/android-livesync-tool");
143161
$injector.require("androidLiveSyncService", "./services/livesync/android-livesync-service");
@@ -201,3 +219,5 @@ $injector.require("testInitializationService", "./services/test-initialization-s
201219

202220
$injector.require("networkConnectivityValidator", "./helpers/network-connectivity-validator");
203221
$injector.requirePublic("cleanupService", "./services/cleanup-service");
222+
223+
$injector.require("webpackCompilerService", "./services/webpack/webpack-compiler-service");

lib/commands/add-platform.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@ export class AddPlatformCommand extends ValidatePlatformCommandBase implements I
44
public allowedParameters: ICommandParameter[] = [];
55

66
constructor($options: IOptions,
7-
$platformService: IPlatformService,
7+
private $platformCommandHelper: IPlatformCommandHelper,
8+
$platformValidationService: IPlatformValidationService,
89
$projectData: IProjectData,
9-
$platformsData: IPlatformsData,
10+
$platformsDataService: IPlatformsDataService,
1011
private $errors: IErrors) {
11-
super($options, $platformsData, $platformService, $projectData);
12+
super($options, $platformsDataService, $platformValidationService, $projectData);
1213
this.$projectData.initializeProjectData();
1314
}
1415

1516
public async execute(args: string[]): Promise<void> {
16-
await this.$platformService.addPlatforms(args, this.$projectData, this.$options, this.$options.frameworkPath);
17+
await this.$platformCommandHelper.addPlatforms(args, this.$projectData, this.$options.frameworkPath);
1718
}
1819

1920
public async canExecute(args: string[]): Promise<ICanExecuteCommandOutput> {
@@ -23,9 +24,9 @@ export class AddPlatformCommand extends ValidatePlatformCommandBase implements I
2324

2425
let canExecute = true;
2526
for (const arg of args) {
26-
this.$platformService.validatePlatform(arg, this.$projectData);
27+
this.$platformValidationService.validatePlatform(arg, this.$projectData);
2728

28-
if (!this.$platformService.isPlatformSupportedForOS(arg, this.$projectData)) {
29+
if (!this.$platformValidationService.isPlatformSupportedForOS(arg, this.$projectData)) {
2930
this.$errors.fail(`Applications for platform ${arg} can not be built on this OS`);
3031
}
3132

lib/commands/appstore-list.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ export class ListiOSApps implements ICommand {
99
private $logger: ILogger,
1010
private $projectData: IProjectData,
1111
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
12-
private $platformService: IPlatformService,
12+
private $platformValidationService: IPlatformValidationService,
1313
private $errors: IErrors,
1414
private $prompter: IPrompter) {
1515
this.$projectData.initializeProjectData();
1616
}
1717

1818
public async execute(args: string[]): Promise<void> {
19-
if (!this.$platformService.isPlatformSupportedForOS(this.$devicePlatformsConstants.iOS, this.$projectData)) {
19+
if (!this.$platformValidationService.isPlatformSupportedForOS(this.$devicePlatformsConstants.iOS, this.$projectData)) {
2020
this.$errors.fail(`Applications for platform ${this.$devicePlatformsConstants.iOS} can not be built on this OS`);
2121
}
2222

lib/commands/appstore-upload.ts

Lines changed: 17 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import * as path from "path";
22
import { StringCommandParameter } from "../common/command-params";
3+
import { BuildController } from "../controllers/build-controller";
4+
import { IOSBuildData } from "../data/build-data";
35

46
export class PublishIOS implements ICommand {
57
public allowedParameters: ICommandParameter[] = [new StringCommandParameter(this.$injector), new StringCommandParameter(this.$injector),
@@ -13,20 +15,12 @@ export class PublishIOS implements ICommand {
1315
private $options: IOptions,
1416
private $prompter: IPrompter,
1517
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
16-
private $xcodebuildService: IXcodebuildService) {
18+
private $buildController: BuildController,
19+
private $platformValidationService: IPlatformValidationService
20+
) {
1721
this.$projectData.initializeProjectData();
1822
}
1923

20-
private get $platformsData(): IPlatformsData {
21-
return this.$injector.resolve("platformsData");
22-
}
23-
24-
// This property was introduced due to the fact that the $platformService dependency
25-
// ultimately tries to resolve the current project's dir and fails if not executed from within a project
26-
private get $platformService(): IPlatformService {
27-
return this.$injector.resolve("platformService");
28-
}
29-
3024
public async execute(args: string[]): Promise<void> {
3125
let username = args[0];
3226
let password = args[1];
@@ -51,50 +45,24 @@ export class PublishIOS implements ICommand {
5145
}
5246

5347
this.$options.release = true;
48+
const platform = this.$devicePlatformsConstants.iOS.toLowerCase();
5449

5550
if (!ipaFilePath) {
56-
const platform = this.$devicePlatformsConstants.iOS;
5751
// No .ipa path provided, build .ipa on out own.
58-
const appFilesUpdaterOptions: IAppFilesUpdaterOptions = {
59-
bundle: !!this.$options.bundle,
60-
release: this.$options.release,
61-
useHotModuleReload: false
62-
};
63-
const platformInfo: IPreparePlatformInfo = {
64-
platform,
65-
appFilesUpdaterOptions,
66-
projectData: this.$projectData,
67-
config: this.$options,
68-
env: this.$options.env
69-
};
70-
const buildConfig: IBuildConfig = {
71-
projectDir: this.$options.path,
72-
release: this.$options.release,
73-
device: this.$options.device,
74-
provision: this.$options.provision,
75-
teamId: this.$options.teamId,
76-
buildForDevice: true,
77-
iCloudContainerEnvironment: this.$options.iCloudContainerEnvironment,
78-
mobileProvisionIdentifier,
79-
codeSignIdentity
80-
};
81-
8252
if (mobileProvisionIdentifier || codeSignIdentity) {
83-
this.$logger.info("Building .ipa with the selected mobile provision and/or certificate.");
8453
// This is not very correct as if we build multiple targets we will try to sign all of them using the signing identity here.
85-
await this.$platformService.preparePlatform(platformInfo);
86-
await this.$platformService.buildPlatform(platform, buildConfig, this.$projectData);
87-
ipaFilePath = this.$platformService.lastOutputPath(platform, buildConfig, this.$projectData);
88-
} else {
89-
this.$logger.info("No .ipa, mobile provision or certificate set. Perfect! Now we'll build .xcarchive and let Xcode pick the distribution certificate and provisioning profile for you when exporting .ipa for AppStore submission.");
90-
await this.$platformService.preparePlatform(platformInfo);
91-
92-
const platformData = this.$platformsData.getPlatformData(platform, this.$projectData);
54+
this.$logger.info("Building .ipa with the selected mobile provision and/or certificate.");
9355

94-
const exportPath = await this.$xcodebuildService.buildForAppStore(platformData, this.$projectData, buildConfig);
95-
this.$logger.info("Export at: " + exportPath);
56+
// As we need to build the package for device
57+
this.$options.forDevice = true;
9658

97-
ipaFilePath = exportPath;
59+
const buildData = new IOSBuildData(this.$projectData.projectDir, platform, this.$options);
60+
ipaFilePath = await this.$buildController.prepareAndBuild(buildData);
61+
} else {
62+
this.$logger.info("No .ipa, mobile provision or certificate set. Perfect! Now we'll build .xcarchive and let Xcode pick the distribution certificate and provisioning profile for you when exporting .ipa for AppStore submission.");
63+
const buildData = new IOSBuildData(this.$projectData.projectDir, platform, { ...this.$options, buildForAppStore: true });
64+
ipaFilePath = await this.$buildController.prepareAndBuild(buildData);
65+
this.$logger.info(`Export at: ${ipaFilePath}`);
9866
}
9967
}
10068

@@ -107,7 +75,7 @@ export class PublishIOS implements ICommand {
10775
}
10876

10977
public async canExecute(args: string[]): Promise<boolean> {
110-
if (!this.$platformService.isPlatformSupportedForOS(this.$devicePlatformsConstants.iOS, this.$projectData)) {
78+
if (!this.$platformValidationService.isPlatformSupportedForOS(this.$devicePlatformsConstants.iOS, this.$projectData)) {
11179
this.$errors.fail(`Applications for platform ${this.$devicePlatformsConstants.iOS} can not be built on this OS`);
11280
}
11381

lib/commands/build.ts

Lines changed: 26 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -5,60 +5,31 @@ export abstract class BuildCommandBase extends ValidatePlatformCommandBase {
55
constructor($options: IOptions,
66
protected $errors: IErrors,
77
$projectData: IProjectData,
8-
$platformsData: IPlatformsData,
8+
$platformsDataService: IPlatformsDataService,
99
protected $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
10-
$platformService: IPlatformService,
10+
protected $buildController: IBuildController,
11+
$platformValidationService: IPlatformValidationService,
1112
private $bundleValidatorHelper: IBundleValidatorHelper,
13+
private $buildDataService: IBuildDataService,
1214
protected $logger: ILogger) {
13-
super($options, $platformsData, $platformService, $projectData);
15+
super($options, $platformsDataService, $platformValidationService, $projectData);
1416
this.$projectData.initializeProjectData();
1517
}
1618

19+
public dashedOptions = {
20+
watch: { type: OptionType.Boolean, default: false, hasSensitiveValue: false },
21+
};
22+
1723
public async executeCore(args: string[]): Promise<string> {
1824
const platform = args[0].toLowerCase();
19-
const appFilesUpdaterOptions: IAppFilesUpdaterOptions = {
20-
bundle: !!this.$options.bundle,
21-
release: this.$options.release,
22-
useHotModuleReload: this.$options.hmr
23-
};
24-
const platformInfo: IPreparePlatformInfo = {
25-
platform,
26-
appFilesUpdaterOptions,
27-
projectData: this.$projectData,
28-
config: this.$options,
29-
env: this.$options.env
30-
};
31-
32-
await this.$platformService.preparePlatform(platformInfo);
33-
const buildConfig: IBuildConfig = {
34-
buildForDevice: this.$options.forDevice,
35-
iCloudContainerEnvironment: this.$options.iCloudContainerEnvironment,
36-
projectDir: this.$options.path,
37-
clean: this.$options.clean,
38-
teamId: this.$options.teamId,
39-
device: this.$options.device,
40-
provision: this.$options.provision,
41-
release: this.$options.release,
42-
keyStoreAlias: this.$options.keyStoreAlias,
43-
keyStorePath: this.$options.keyStorePath,
44-
keyStoreAliasPassword: this.$options.keyStoreAliasPassword,
45-
keyStorePassword: this.$options.keyStorePassword,
46-
androidBundle: this.$options.aab
47-
};
48-
49-
const outputPath = await this.$platformService.buildPlatform(platform, buildConfig, this.$projectData);
50-
51-
if (this.$options.copyTo) {
52-
this.$platformService.copyLastOutput(platform, this.$options.copyTo, buildConfig, this.$projectData);
53-
} else {
54-
this.$logger.info(`The build result is located at: ${outputPath}`);
55-
}
25+
const buildData = this.$buildDataService.getBuildData(this.$projectData.projectDir, platform, this.$options);
26+
const outputPath = await this.$buildController.prepareAndBuild(buildData);
5627

5728
return outputPath;
5829
}
5930

6031
protected validatePlatform(platform: string): void {
61-
if (!this.$platformService.isPlatformSupportedForOS(platform, this.$projectData)) {
32+
if (!this.$platformValidationService.isPlatformSupportedForOS(platform, this.$projectData)) {
6233
this.$errors.fail(`Applications for platform ${platform} can not be built on this OS`);
6334
}
6435

@@ -78,7 +49,7 @@ export abstract class BuildCommandBase extends ValidatePlatformCommandBase {
7849
return false;
7950
}
8051

81-
const result = await this.$platformService.validateOptions(this.$options.provision, this.$options.teamId, this.$projectData, platform);
52+
const result = await this.$platformValidationService.validateOptions(this.$options.provision, this.$options.teamId, this.$projectData, platform);
8253
return result;
8354
}
8455
}
@@ -89,16 +60,18 @@ export class BuildIosCommand extends BuildCommandBase implements ICommand {
8960
constructor(protected $options: IOptions,
9061
$errors: IErrors,
9162
$projectData: IProjectData,
92-
$platformsData: IPlatformsData,
63+
$platformsDataService: IPlatformsDataService,
9364
$devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
94-
$platformService: IPlatformService,
65+
$buildController: IBuildController,
66+
$platformValidationService: IPlatformValidationService,
9567
$bundleValidatorHelper: IBundleValidatorHelper,
96-
$logger: ILogger) {
97-
super($options, $errors, $projectData, $platformsData, $devicePlatformsConstants, $platformService, $bundleValidatorHelper, $logger);
68+
$logger: ILogger,
69+
$buildDataService: IBuildDataService) {
70+
super($options, $errors, $projectData, $platformsDataService, $devicePlatformsConstants, $buildController, $platformValidationService, $bundleValidatorHelper, $buildDataService, $logger);
9871
}
9972

10073
public async execute(args: string[]): Promise<void> {
101-
await this.executeCore([this.$platformsData.availablePlatforms.iOS]);
74+
await this.executeCore([this.$devicePlatformsConstants.iOS.toLowerCase()]);
10275
}
10376

10477
public async canExecute(args: string[]): Promise<boolean | ICanExecuteCommandOutput> {
@@ -123,17 +96,19 @@ export class BuildAndroidCommand extends BuildCommandBase implements ICommand {
12396
constructor(protected $options: IOptions,
12497
protected $errors: IErrors,
12598
$projectData: IProjectData,
126-
$platformsData: IPlatformsData,
99+
platformsDataService: IPlatformsDataService,
127100
$devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
128-
$platformService: IPlatformService,
101+
$buildController: IBuildController,
102+
$platformValidationService: IPlatformValidationService,
129103
$bundleValidatorHelper: IBundleValidatorHelper,
130104
protected $androidBundleValidatorHelper: IAndroidBundleValidatorHelper,
105+
$buildDataService: IBuildDataService,
131106
protected $logger: ILogger) {
132-
super($options, $errors, $projectData, $platformsData, $devicePlatformsConstants, $platformService, $bundleValidatorHelper, $logger);
107+
super($options, $errors, $projectData, platformsDataService, $devicePlatformsConstants, $buildController, $platformValidationService, $bundleValidatorHelper, $buildDataService, $logger);
133108
}
134109

135110
public async execute(args: string[]): Promise<void> {
136-
await this.executeCore([this.$platformsData.availablePlatforms.Android]);
111+
await this.executeCore([this.$devicePlatformsConstants.Android.toLowerCase()]);
137112

138113
if (this.$options.aab) {
139114
this.$logger.info(AndroidAppBundleMessages.ANDROID_APP_BUNDLE_DOCS_MESSAGE);

0 commit comments

Comments
 (0)