Skip to content

Commit 8bfd41b

Browse files
committed
chore: fix PR comments
1 parent f2d59a7 commit 8bfd41b

14 files changed

+28
-18
lines changed

lib/commands/build.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export abstract class BuildCommandBase extends ValidatePlatformCommandBase {
1616
}
1717

1818
public async executeCore(args: string[]): Promise<string> {
19-
await this.$workflowService.handleLegacyWorkflow(this.$projectData.projectDir, this.$options, true);
19+
await this.$workflowService.handleLegacyWorkflow({ projectDir: this.$projectData.projectDir, settings: this.$options, skipWarnings: true });
2020
const platform = args[0].toLowerCase();
2121
const appFilesUpdaterOptions: IAppFilesUpdaterOptions = {
2222
bundle: !!this.$options.bundle,

lib/commands/debug.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export class DebugPlatformCommand extends ValidatePlatformCommandBase implements
2424
}
2525

2626
public async execute(args: string[]): Promise<void> {
27-
await this.$workflowService.handleLegacyWorkflow(this.$projectData.projectDir, this.$options, true);
27+
await this.$workflowService.handleLegacyWorkflow({ projectDir: this.$projectData.projectDir, settings: this.$options, skipWarnings: true });
2828
await this.$devicesService.initialize({
2929
platform: this.platform,
3030
deviceId: this.$options.device,

lib/commands/prepare.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export class PrepareCommand extends ValidatePlatformCommandBase implements IComm
1414
}
1515

1616
public async execute(args: string[]): Promise<void> {
17-
await this.$workflowService.handleLegacyWorkflow(this.$projectData.projectDir, this.$options, true);
17+
await this.$workflowService.handleLegacyWorkflow({ projectDir: this.$projectData.projectDir, settings: this.$options, skipWarnings: true });
1818
const appFilesUpdaterOptions: IAppFilesUpdaterOptions = {
1919
bundle: !!this.$options.bundle,
2020
release: this.$options.release,

lib/commands/preview.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class PreviewCommand implements ICommand {
2121
}
2222

2323
public async execute(): Promise<void> {
24-
await this.$workflowService.handleLegacyWorkflow(this.$projectData.projectDir, this.$options, true);
24+
await this.$workflowService.handleLegacyWorkflow({ projectDir: this.$projectData.projectDir, settings: this.$options, skipWarnings: true });
2525
this.$previewAppLogProvider.on(DEVICE_LOG_EVENT_NAME, (deviceId: string, message: string) => {
2626
this.$logger.info(message);
2727
});

lib/commands/run.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class RunCommandBase implements ICommand {
1919

2020
public allowedParameters: ICommandParameter[] = [];
2121
public async execute(args: string[]): Promise<void> {
22-
await this.$workflowService.handleLegacyWorkflow(this.$projectData.projectDir, this.$options, true);
22+
await this.$workflowService.handleLegacyWorkflow({ projectDir: this.$projectData.projectDir, settings: this.$options, skipWarnings: true });
2323
await this.$analyticsService.trackPreviewAppData(this.platform, this.$projectData.projectDir);
2424
return this.$liveSyncCommandHelper.executeCommandLiveSync(this.platform, this.liveSyncCommandHelperAdditionalOptions);
2525
}

lib/commands/test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ abstract class TestCommandBase {
1414
protected abstract $workflowService: IWorkflowService;
1515

1616
async execute(args: string[]): Promise<void> {
17-
await this.$workflowService.handleLegacyWorkflow(this.$projectData.projectDir, this.$options, true);
17+
await this.$workflowService.handleLegacyWorkflow({ projectDir: this.$projectData.projectDir, settings: this.$options, skipWarnings: true });
1818
await this.$testExecutionService.startKarmaServer(this.platform, this.$projectData, this.projectFilesConfig);
1919
}
2020

lib/commands/update.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ export class UpdateCommand extends ValidatePlatformCommandBase implements IComma
3030

3131
public async execute(args: string[]): Promise<void> {
3232
if (this.$options.workflow) {
33-
const forceWebpackWorkflow = true;
34-
await this.$workflowService.handleLegacyWorkflow(this.$projectData.projectDir, this.$options, forceWebpackWorkflow);
33+
await this.$workflowService.handleLegacyWorkflow({ projectDir: this.$projectData.projectDir, settings: this.$options, force: true });
3534
return;
3635
}
3736

lib/common/helpers.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,11 @@ export function createTable(headers: string[], data: string[][]): any {
385385
}
386386

387387
export function getMessageWithBorders(message: string, spanLength = 3): string {
388-
const longestRowLength = message.split(EOL).sort(function (a, b) { return b.length - a.length; })[0].length;
388+
if (!message) {
389+
return "";
390+
}
391+
392+
const longestRowLength = message.split(EOL).sort((a, b) => { return b.length - a.length; })[0].length;
389393
let border = "*".repeat(longestRowLength + 2 * spanLength); // * 2 for both sides
390394
if (border.length % 2 === 0) {
391395
border += "*"; // the * should always be an odd number in order to get * in each edge (we will remove the even *s below)

lib/definitions/platform.d.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,14 @@ interface IBuildPlatformAction {
1515
}
1616

1717
interface IWorkflowService {
18-
handleLegacyWorkflow(projectDir: string, settings: IWebpackWorkflowSettings, skipWarnings?: boolean, force?: boolean): Promise<void>;
18+
handleLegacyWorkflow(options: IHandleLegacyWorkflowOptions): Promise<void>;
19+
}
20+
21+
interface IHandleLegacyWorkflowOptions {
22+
projectDir: string;
23+
settings: IWebpackWorkflowSettings;
24+
skipWarnings?: boolean;
25+
force?: boolean;
1926
}
2027

2128
interface IWebpackWorkflowSettings {

lib/services/livesync/playground/preview-app-livesync-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class PreviewAppLiveSyncService extends EventEmitter implements IPreviewA
3030
@performanceLog()
3131
public async initialize(data: IPreviewAppLiveSyncData): Promise<void> {
3232
await this.$previewSdkService.initialize(data.projectDir, async (device: Device) => {
33-
await this.$workflowService.handleLegacyWorkflow(data.projectDir, data);
33+
await this.$workflowService.handleLegacyWorkflow({ projectDir: data.projectDir, settings: data });
3434
try {
3535
if (!device) {
3636
this.$errors.failWithoutHelp("Sending initial preview files without a specified device is not supported.");

lib/services/platform-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ export class PlatformService extends EventEmitter implements IPlatformService {
222222

223223
@performanceLog()
224224
public async preparePlatform(platformInfo: IPreparePlatformInfo): Promise<boolean> {
225-
await this.$workflowService.handleLegacyWorkflow(platformInfo.projectData.projectDir, platformInfo.appFilesUpdaterOptions);
225+
await this.$workflowService.handleLegacyWorkflow({ projectDir: platformInfo.projectData.projectDir, settings: platformInfo.appFilesUpdaterOptions });
226226
const changesInfo = await this.getChangesInfo(platformInfo);
227227
const shouldPrepare = await this.shouldPrepare({ platformInfo, changesInfo });
228228

lib/services/project-data-service.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,8 @@ export class ProjectDataService implements IProjectDataService {
197197
private getNsConfig(nsConfigPath: string): INsConfig {
198198
let result = this.getNsConfigDefaultObject();
199199
if (this.$fs.exists(nsConfigPath)) {
200-
const nsConfigContent = this.$fs.readText(nsConfigPath);
201200
try {
202-
result = <INsConfig>parseJson(nsConfigContent);
201+
result = <INsConfig>this.$fs.readJson(nsConfigPath);
203202
} catch (e) {
204203
// default
205204
}

lib/services/workflow-service.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import * as semver from "semver";
44
import { EOL } from "os";
55

66
export class WorkflowService implements IWorkflowService {
7-
private legacyWorkflowDeprecationMessage = `With the upcoming NativeScript 6.0 the Webpack workflow will become the only way of build apps.
8-
More info about the reason for this change and how to migrate your project can be found in the link below:
7+
private legacyWorkflowDeprecationMessage = `With the upcoming NativeScript 6.0 the Webpack workflow will become the only way of building apps.
8+
More info about the reasons for this change and how to migrate your project can be found in the link below:
99
<TODO: add link here>`;
1010
private webpackWorkflowConfirmMessage = `Do you want to switch your app to the Webpack workflow?`;
1111

@@ -19,7 +19,8 @@ More info about the reason for this change and how to migrate your project can b
1919
) {
2020
}
2121

22-
public async handleLegacyWorkflow(projectDir: string, settings: IWebpackWorkflowSettings, skipWarnings?: boolean, force?: boolean): Promise<void> {
22+
public async handleLegacyWorkflow(options: IHandleLegacyWorkflowOptions): Promise<void> {
23+
const { projectDir, settings, skipWarnings, force } = options;
2324
if (!settings.bundle || force) {
2425
const projectData = this.$projectDataService.getProjectData(projectDir);
2526
if (typeof (projectData.useLegacyWorkflow) !== "boolean" || force) {

test/stubs.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@ export class PerformanceService implements IPerformanceService {
917917
}
918918

919919
export class WorkflowServiceStub implements IWorkflowService {
920-
handleLegacyWorkflow(projectDir: string, settings: IWebpackWorkflowSettings, skipWarnings?: boolean, force?: boolean): Promise<void> {
920+
handleLegacyWorkflow(options: IHandleLegacyWorkflowOptions): Promise<void> {
921921
return;
922922
}
923923
}

0 commit comments

Comments
 (0)