Skip to content

feat: remove cloud builds references #5313

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions lib/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ $injector.requireCommand("apple-login", "./commands/apple-login");
$injector.require("itmsTransporterService", "./services/itmstransporter-service");

$injector.requireCommand("setup|*", "./commands/setup");
$injector.requireCommand(["setup|cloud", "cloud|setup"], "./commands/setup");

$injector.requirePublic("packageManager", "./package-manager");
$injector.requirePublic("npm", "./node-package-manager");
Expand Down Expand Up @@ -198,12 +197,10 @@ $injector.requireCommand("extension|uninstall", "./commands/extensibility/uninst
$injector.requirePublicClass("extensibilityService", "./services/extensibility-service");

$injector.require("nodeModulesDependenciesBuilder", "./tools/node-modules/node-modules-dependencies-builder");
$injector.require("subscriptionService", "./services/subscription-service");
$injector.require("terminalSpinnerService", "./services/terminal-spinner-service");

$injector.require('playgroundService', './services/playground-service');
$injector.require("platformEnvironmentRequirements", "./services/platform-environment-requirements");
$injector.require("nativeScriptCloudExtensionService", "./services/nativescript-cloud-extension-service");

$injector.requireCommand("resources|generate|icons", "./commands/generate-assets");
$injector.requireCommand("resources|generate|splashes", "./commands/generate-assets");
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class DebugPlatformCommand extends ValidatePlatformCommandBase implements
this.$errors.failWithHelp("--release flag is not applicable to this command.");
}

const result = await super.canExecuteCommandBase(this.platform, { validateOptions: true, notConfiguredEnvOptions: { hideCloudBuildOption: true, hideSyncToPreviewAppOption: true } });
const result = await super.canExecuteCommandBase(this.platform, { validateOptions: true, notConfiguredEnvOptions: { hideSyncToPreviewAppOption: true } });
return result;
}
}
Expand Down
5 changes: 0 additions & 5 deletions lib/commands/post-install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { doesCurrentNpmCommandMatch } from "../common/helpers";

export class PostInstallCliCommand implements ICommand {
constructor(private $fs: IFileSystem,
private $subscriptionService: ISubscriptionService,
private $commandsService: ICommandsService,
private $helpService: IHelpService,
private $settingsService: ISettingsService,
Expand Down Expand Up @@ -36,10 +35,6 @@ export class PostInstallCliCommand implements ICommand {
await this.$analyticsService.checkConsent();
await this.$commandsService.tryExecuteCommand("autocomplete", []);
}

if (canExecutePostInstallTask) {
await this.$subscriptionService.subscribeForNewsletter();
}
}

public async postCommandAction(args: string[]): Promise<void> {
Expand Down
11 changes: 0 additions & 11 deletions lib/commands/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,3 @@ export class SetupCommand implements ICommand {
}
}
$injector.registerCommand("setup|*", SetupCommand);

export class CloudSetupCommand implements ICommand {
public allowedParameters: ICommandParameter[] = [];

constructor(private $nativeScriptCloudExtensionService: INativeScriptCloudExtensionService) { }

public execute(args: string[]): Promise<any> {
return this.$nativeScriptCloudExtensionService.install();
}
}
$injector.registerCommand(["setup|cloud", "cloud|setup"], CloudSetupCommand);
3 changes: 1 addition & 2 deletions lib/commands/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ abstract class TestCommandBase {
projectDir: this.$projectData.projectDir,
options: this.$options,
notConfiguredEnvOptions: {
hideSyncToPreviewAppOption: true,
hideCloudBuildOption: true
hideSyncToPreviewAppOption: true
}
});

Expand Down
2 changes: 1 addition & 1 deletion lib/common/yok.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export class Yok implements IInjector {
} else {
commandName = defaultCommand ? this.getHierarchicalCommandName(name, defaultCommand) : "help";
// If we'll execute the default command, but it's full name had been written by the user
// for example "appbuilder cloud list", we have to remove the "list" option from the arguments that we'll pass to the command.
// for example "tns run ios", we have to remove the "ios" option from the arguments that we'll pass to the command.
if (_.includes(this.hierarchicalCommands[name], CommandsDelimiters.DefaultCommandSymbol + args[0])) {
commandArguments = _.tail(args);
} else {
Expand Down
2 changes: 0 additions & 2 deletions lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,6 @@ export const enum BuildStates {
Incremental = "Incremental"
}

export const NATIVESCRIPT_CLOUD_EXTENSION_NAME = "nativescript-cloud";

/**
* Used in ProjectDataService to concatenate the names of the properties inside nativescript key of package.json.
*/
Expand Down
35 changes: 0 additions & 35 deletions lib/services/nativescript-cloud-extension-service.ts

This file was deleted.

151 changes: 14 additions & 137 deletions lib/services/platform-environment-requirements.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { NATIVESCRIPT_CLOUD_EXTENSION_NAME, TrackActionNames } from "../constants";
import { TrackActionNames } from "../constants";
import { isInteractive, hook } from "../common/helpers";
import { EOL } from "os";

export class PlatformEnvironmentRequirements implements IPlatformEnvironmentRequirements {
constructor(private $commandsService: ICommandsService,
private $doctorService: IDoctorService,
constructor(private $doctorService: IDoctorService,
private $errors: IErrors,
private $logger: ILogger,
private $nativeScriptCloudExtensionService: INativeScriptCloudExtensionService,
private $prompter: IPrompter,
private $staticConfig: IStaticConfig,
private $analyticsService: IAnalyticsService,
Expand All @@ -18,27 +16,16 @@ export class PlatformEnvironmentRequirements implements IPlatformEnvironmentRequ
return this.$injector.resolve("previewAppController");
}

public static CLOUD_SETUP_OPTION_NAME = "Configure for Cloud Builds";
public static LOCAL_SETUP_OPTION_NAME = "Configure for Local Builds";
public static TRY_CLOUD_OPERATION_OPTION_NAME = "Try Cloud Operation";
public static SYNC_TO_PREVIEW_APP_OPTION_NAME = "Sync to Playground";
public static MANUALLY_SETUP_OPTION_NAME = "Skip Step and Configure Manually";
private static BOTH_CLOUD_SETUP_AND_LOCAL_SETUP_OPTION_NAME = "Configure for Both Local and Cloud Builds";
private static CHOOSE_OPTIONS_MESSAGE = "To continue, choose one of the following options: ";
private static NOT_CONFIGURED_ENV_AFTER_SETUP_SCRIPT_MESSAGE = `The setup script was not able to configure your environment for local builds. To execute local builds, you have to set up your environment manually. Please consult our setup instructions here 'https://docs.nativescript.org/start/quick-setup'.`;
private static MISSING_LOCAL_SETUP_MESSAGE = "Your environment is not configured properly and you will not be able to execute local builds.";
private static MISSING_LOCAL_AND_CLOUD_SETUP_MESSAGE = `You are missing the ${NATIVESCRIPT_CLOUD_EXTENSION_NAME} extension and you will not be able to execute cloud builds. ${PlatformEnvironmentRequirements.MISSING_LOCAL_SETUP_MESSAGE} ${PlatformEnvironmentRequirements.CHOOSE_OPTIONS_MESSAGE} `;
private static MISSING_LOCAL_BUT_CLOUD_SETUP_MESSAGE = `You have ${NATIVESCRIPT_CLOUD_EXTENSION_NAME} extension installed, so you can execute cloud builds, but ${_.lowerFirst(PlatformEnvironmentRequirements.MISSING_LOCAL_SETUP_MESSAGE)}`;
private static RUN_TNS_SETUP_MESSAGE = 'Run $ tns setup command to run the setup script to try to automatically configure your environment for local builds.';
private static SYNC_TO_PREVIEW_APP_MESSAGE = `Select "Sync to Playground" to enjoy NativeScript without any local setup. All you need is a couple of companion apps installed on your devices.`;
private static RUN_PREVIEW_COMMAND_MESSAGE = `Run $ tns preview command to enjoy NativeScript without any local setup.`;

private cliCommandToCloudCommandName: IStringDictionary = {
"build": "tns cloud build",
"run": "tns cloud run",
"deploy": "tns cloud deploy"
};

@hook("checkEnvironment")
public async checkEnvironmentRequirements(input: ICheckEnvironmentRequirementsInput): Promise<ICheckEnvironmentRequirementsOutput> {
const { platform, projectDir, runtimeVersion } = input;
Expand Down Expand Up @@ -75,7 +62,6 @@ export class PlatformEnvironmentRequirements implements IPlatformEnvironmentRequ

selectedOption = await this.promptForChoice({ infoMessage, choices });

await this.processCloudBuildsIfNeeded(selectedOption, platform);
this.processManuallySetupIfNeeded(selectedOption, platform);
await this.processSyncToPreviewAppIfNeeded(selectedOption, projectDir, options);

Expand All @@ -89,44 +75,8 @@ export class PlatformEnvironmentRequirements implements IPlatformEnvironmentRequ
};
}

if (this.$nativeScriptCloudExtensionService.isInstalled()) {
const option = await this.promptForChoice({
infoMessage: PlatformEnvironmentRequirements.NOT_CONFIGURED_ENV_AFTER_SETUP_SCRIPT_MESSAGE,
choices: [
PlatformEnvironmentRequirements.TRY_CLOUD_OPERATION_OPTION_NAME,
PlatformEnvironmentRequirements.MANUALLY_SETUP_OPTION_NAME
]
});

this.processTryCloudSetupIfNeeded(option, platform);
this.processManuallySetupIfNeeded(option, platform);
} else {
const option = await this.promptForChoice({
infoMessage: PlatformEnvironmentRequirements.NOT_CONFIGURED_ENV_AFTER_SETUP_SCRIPT_MESSAGE,
choices: [
PlatformEnvironmentRequirements.CLOUD_SETUP_OPTION_NAME,
PlatformEnvironmentRequirements.MANUALLY_SETUP_OPTION_NAME
]
});

await this.processCloudBuildsIfNeeded(option, platform);
this.processManuallySetupIfNeeded(option, platform);
}
this.fail(PlatformEnvironmentRequirements.NOT_CONFIGURED_ENV_AFTER_SETUP_SCRIPT_MESSAGE);
}

if (selectedOption === PlatformEnvironmentRequirements.BOTH_CLOUD_SETUP_AND_LOCAL_SETUP_OPTION_NAME) {
await this.processBothCloudBuildsAndSetupScript();
if (await this.$doctorService.canExecuteLocalBuild({ platform, projectDir, runtimeVersion, forceCheck: input.forceCheck })) {
return {
canExecute: true,
selectedOption
};
}

this.processManuallySetup(platform);
}

this.processTryCloudSetupIfNeeded(selectedOption, platform);
}

return {
Expand All @@ -135,40 +85,6 @@ export class PlatformEnvironmentRequirements implements IPlatformEnvironmentRequ
};
}

private async processCloudBuildsIfNeeded(selectedOption: string, platform?: string): Promise<void> {
if (selectedOption === PlatformEnvironmentRequirements.CLOUD_SETUP_OPTION_NAME) {
await this.processCloudBuilds(platform);
}
}

private async processCloudBuilds(platform: string): Promise<void> {
await this.processCloudBuildsCore();
this.fail(this.getCloudBuildsMessage(platform));
}

private processCloudBuildsCore(): Promise<IExtensionData> {
return this.$nativeScriptCloudExtensionService.install();
}

private getCloudBuildsMessage(platform?: string): string {
const cloudCommandName = this.cliCommandToCloudCommandName[(this.$commandsService.currentCommandData || <any>{}).commandName];
if (!cloudCommandName) {
return `In order to test your application use the $ tns login command to log in with your account and then $ tns cloud build command to build your app in the cloud.`;
}

if (!platform) {
return `Use the $ tns login command to log in with your account and then $ ${cloudCommandName.toLowerCase()} command.`;
}

return `Use the $ tns login command to log in with your account and then $ ${cloudCommandName.toLowerCase()} ${platform.toLowerCase()} command.`;
}

private processTryCloudSetupIfNeeded(selectedOption: string, platform?: string) {
if (selectedOption === PlatformEnvironmentRequirements.TRY_CLOUD_OPERATION_OPTION_NAME) {
this.fail(this.getCloudBuildsMessage(platform));
}
}

private processManuallySetupIfNeeded(selectedOption: string, platform?: string) {
if (selectedOption === PlatformEnvironmentRequirements.MANUALLY_SETUP_OPTION_NAME) {
this.processManuallySetup(platform);
Expand All @@ -195,52 +111,25 @@ export class PlatformEnvironmentRequirements implements IPlatformEnvironmentRequ
this.fail(`To be able to ${platform ? `build for ${platform}` : 'build'}, verify that your environment is configured according to the system requirements described at ${this.$staticConfig.SYS_REQUIREMENTS_LINK}. If you have any questions, check Stack Overflow: 'https://stackoverflow.com/questions/tagged/nativescript' and our public Slack channel: 'https://nativescriptcommunity.slack.com/'`);
}

private async processBothCloudBuildsAndSetupScript(): Promise<void> {
try {
await this.processCloudBuildsCore();
} catch (e) {
this.$logger.trace(`Error while installing ${NATIVESCRIPT_CLOUD_EXTENSION_NAME} extension. ${e.message}.`);
}

await this.$doctorService.runSetupScript();
}

private fail(message: string): void {
this.$errors.fail({ formatStr: message, printOnStdout: true });
}

private getNonInteractiveConsoleMessage(platform: string) {
return this.$nativeScriptCloudExtensionService.isInstalled() ?
this.buildMultilineMessage([
`${PlatformEnvironmentRequirements.MISSING_LOCAL_SETUP_MESSAGE} ${PlatformEnvironmentRequirements.CHOOSE_OPTIONS_MESSAGE}`,
PlatformEnvironmentRequirements.RUN_PREVIEW_COMMAND_MESSAGE,
PlatformEnvironmentRequirements.RUN_TNS_SETUP_MESSAGE,
this.getCloudBuildsMessage(platform),
this.getEnvVerificationMessage()
]) :
this.buildMultilineMessage([
PlatformEnvironmentRequirements.MISSING_LOCAL_AND_CLOUD_SETUP_MESSAGE,
PlatformEnvironmentRequirements.RUN_PREVIEW_COMMAND_MESSAGE,
PlatformEnvironmentRequirements.RUN_TNS_SETUP_MESSAGE,
`Run $ tns cloud setup command to install the ${NATIVESCRIPT_CLOUD_EXTENSION_NAME} extension to configure your environment for cloud builds.`,
this.getEnvVerificationMessage()
]);
return this.buildMultilineMessage([
`${PlatformEnvironmentRequirements.MISSING_LOCAL_SETUP_MESSAGE} ${PlatformEnvironmentRequirements.CHOOSE_OPTIONS_MESSAGE}`,
PlatformEnvironmentRequirements.RUN_PREVIEW_COMMAND_MESSAGE,
PlatformEnvironmentRequirements.RUN_TNS_SETUP_MESSAGE,
this.getEnvVerificationMessage()
]);
}

private getInteractiveConsoleMessage(options: INotConfiguredEnvOptions) {
const isNativeScriptCloudExtensionInstalled = this.$nativeScriptCloudExtensionService.isInstalled();
const message = isNativeScriptCloudExtensionInstalled ?
`${PlatformEnvironmentRequirements.MISSING_LOCAL_BUT_CLOUD_SETUP_MESSAGE} ${PlatformEnvironmentRequirements.CHOOSE_OPTIONS_MESSAGE}` :
PlatformEnvironmentRequirements.MISSING_LOCAL_AND_CLOUD_SETUP_MESSAGE;
const choices = isNativeScriptCloudExtensionInstalled ? [
const message = PlatformEnvironmentRequirements.MISSING_LOCAL_SETUP_MESSAGE;
const choices = [
`Select "Configure for Local Builds" to run the setup script and automatically configure your environment for local builds.`,
`Select "Skip Step and Configure Manually" to disregard this option and install any required components manually.`
] : [
`Select "Configure for Cloud Builds" to install the ${NATIVESCRIPT_CLOUD_EXTENSION_NAME} extension and automatically configure your environment for cloud builds.`,
`Select "Configure for Local Builds" to run the setup script and automatically configure your environment for local builds.`,
`Select "Configure for Both Local and Cloud Builds" to automatically configure your environment for both options.`,
`Select "Configure for Both Local and Cloud Builds" to automatically configure your environment for both options.`
];
];

if (!options.hideSyncToPreviewAppOption) {
choices.unshift(PlatformEnvironmentRequirements.SYNC_TO_PREVIEW_APP_MESSAGE);
Expand Down Expand Up @@ -279,21 +168,9 @@ export class PlatformEnvironmentRequirements implements IPlatformEnvironmentRequ

private getChoices(options: INotConfiguredEnvOptions): string[] {
const choices: string[] = [];
if (this.$nativeScriptCloudExtensionService.isInstalled()) {
choices.push(...[PlatformEnvironmentRequirements.LOCAL_SETUP_OPTION_NAME,
PlatformEnvironmentRequirements.MANUALLY_SETUP_OPTION_NAME]);

if (!options.hideCloudBuildOption) {
choices.unshift(PlatformEnvironmentRequirements.TRY_CLOUD_OPERATION_OPTION_NAME);
}
} else {
choices.push(...[
PlatformEnvironmentRequirements.CLOUD_SETUP_OPTION_NAME,
PlatformEnvironmentRequirements.LOCAL_SETUP_OPTION_NAME,
PlatformEnvironmentRequirements.BOTH_CLOUD_SETUP_AND_LOCAL_SETUP_OPTION_NAME,
PlatformEnvironmentRequirements.MANUALLY_SETUP_OPTION_NAME,
]);
}
choices.push(...[PlatformEnvironmentRequirements.LOCAL_SETUP_OPTION_NAME,
PlatformEnvironmentRequirements.MANUALLY_SETUP_OPTION_NAME]);

if (!options.hideSyncToPreviewAppOption) {
choices.unshift(PlatformEnvironmentRequirements.SYNC_TO_PREVIEW_APP_OPTION_NAME);
Expand Down
Loading