Skip to content

Commit 7a40ca7

Browse files
authored
refactor: dependency and repo cleanup (#5722)
1 parent 5b88e06 commit 7a40ca7

File tree

164 files changed

+11227
-20530
lines changed

Some content is hidden

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

164 files changed

+11227
-20530
lines changed

config/config.json

-5
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,5 @@
44
"ANDROID_DEBUG_UI_MAC": "Google Chrome",
55
"USE_POD_SANDBOX": false,
66
"DISABLE_HOOKS": false,
7-
"UPLOAD_PLAYGROUND_FILES_ENDPOINT": "https://play.nativescript.org/api/files",
8-
"SHORTEN_URL_ENDPOINT": "https://play.nativescript.org/api/shortenurl?longUrl=%s",
9-
"INSIGHTS_URL_ENDPOINT": "https://play-server.nativescript.org/api/insights?ipAddress=%s",
10-
"WHOAMI_URL_ENDPOINT": "https://play.nativescript.org/api/whoami",
11-
"PREVIEW_APP_ENVIRONMENT": "live",
127
"GA_TRACKING_ID": "UA-111455-51"
138
}

lib/bootstrap.ts

+1-40
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ injector.require(
101101
"./services/platform/platform-validation-service"
102102
);
103103

104-
injector.require("buildArtefactsService", "./services/build-artefacts-service");
104+
injector.require("buildArtifactsService", "./services/build-artifacts-service");
105105

106106
injector.require(
107107
"deviceInstallAppService",
@@ -120,10 +120,6 @@ injector.requirePublicClass(
120120
"debugController",
121121
"./controllers/debug-controller"
122122
);
123-
injector.requirePublicClass(
124-
"previewAppController",
125-
"./controllers/preview-app-controller"
126-
);
127123
injector.requirePublicClass(
128124
"updateController",
129125
"./controllers/update-controller"
@@ -169,11 +165,6 @@ injector.require(
169165
"googleAnalyticsProvider",
170166
"./services/analytics/google-analytics-provider"
171167
);
172-
injector.requirePublicClass(
173-
"companyInsightsController",
174-
"./controllers/company-insights-controller"
175-
);
176-
177168
injector.require("platformCommandParameter", "./platform-command-param");
178169
injector.requireCommand("create", "./commands/create-project");
179170
injector.requireCommand("clean", "./commands/clean");
@@ -309,34 +300,6 @@ injector.require(
309300
"./services/livesync/ios-livesync-service"
310301
);
311302
injector.require("usbLiveSyncService", "./services/livesync/livesync-service"); // The name is used in https://github.com/NativeScript/nativescript-dev-typescript
312-
injector.require(
313-
"previewAppFilesService",
314-
"./services/livesync/playground/preview-app-files-service"
315-
);
316-
injector.require(
317-
"previewAppLogProvider",
318-
"./services/livesync/playground/preview-app-log-provider"
319-
);
320-
injector.require(
321-
"previewAppPluginsService",
322-
"./services/livesync/playground/preview-app-plugins-service"
323-
);
324-
injector.require(
325-
"previewSdkService",
326-
"./services/livesync/playground/preview-sdk-service"
327-
);
328-
injector.require(
329-
"previewSchemaService",
330-
"./services/livesync/playground/preview-schema-service"
331-
);
332-
injector.requirePublicClass(
333-
"previewDevicesService",
334-
"./services/livesync/playground/devices/preview-devices-service"
335-
);
336-
injector.requirePublic(
337-
"previewQrCodeService",
338-
"./services/livesync/playground/preview-qr-code-service"
339-
);
340303
injector.requirePublic("sysInfo", "./sys-info");
341304

342305
injector.require(
@@ -353,7 +316,6 @@ injector.require(
353316
"./device-sockets/ios/socket-request-executor"
354317
);
355318
injector.require("messages", "./common/messages/messages");
356-
injector.require("xmlValidator", "./xml-validator");
357319

358320
injector.requireCommand("post-install-cli", "./commands/post-install");
359321
injector.requireCommand("migrate", "./commands/migrate");
@@ -396,7 +358,6 @@ injector.require(
396358
"./services/terminal-spinner-service"
397359
);
398360

399-
injector.require("playgroundService", "./services/playground-service");
400361
injector.require(
401362
"platformEnvironmentRequirements",
402363
"./services/platform-environment-requirements"

lib/color.ts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// using chalk as some of our other dependencies are already using it...
2+
// exporting from here so we can easily refactor to a different color library if needed
3+
import * as chalk from "chalk";
4+
5+
export type Color = typeof chalk.Color;
6+
7+
export const color = chalk;

lib/commands/build.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,7 @@ export class BuildIosCommand extends BuildCommandBase implements ICommand {
138138

139139
super.validatePlatform(platform);
140140

141-
let canExecute = await super.canExecuteCommandBase(platform, {
142-
notConfiguredEnvOptions: { hideSyncToPreviewAppOption: true },
143-
});
141+
let canExecute = await super.canExecuteCommandBase(platform);
144142
if (canExecute) {
145143
canExecute = await super.validateArgs(args, platform);
146144
}
@@ -209,9 +207,7 @@ export class BuildAndroidCommand extends BuildCommandBase implements ICommand {
209207
this.$androidBundleValidatorHelper.validateRuntimeVersion(
210208
this.$projectData
211209
);
212-
let canExecute = await super.canExecuteCommandBase(platform, {
213-
notConfiguredEnvOptions: { hideSyncToPreviewAppOption: true },
214-
});
210+
let canExecute = await super.canExecuteCommandBase(platform);
215211
if (canExecute) {
216212
if (this.$options.release && !hasValidAndroidSigning(this.$options)) {
217213
this.$errors.failWithHelp(ANDROID_RELEASE_BUILD_ERROR_MESSAGE);

lib/commands/clean.ts

+25-19
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { color } from "../color";
12
import { ICommand, ICommandParameter } from "../common/definitions/commands";
23
import { injector } from "../common/yok";
34
import * as constants from "../constants";
@@ -114,9 +115,8 @@ export class CleanCommand implements ICommand {
114115
];
115116

116117
try {
117-
const overridePathsToClean = this.$projectConfigService.getValue(
118-
"cli.pathsToClean"
119-
);
118+
const overridePathsToClean =
119+
this.$projectConfigService.getValue("cli.pathsToClean");
120120
const additionalPaths = this.$projectConfigService.getValue(
121121
"cli.additionalPathsToClean"
122122
);
@@ -158,7 +158,7 @@ export class CleanCommand implements ICommand {
158158
if (res.ok) {
159159
spinner.succeed("Project successfully cleaned.");
160160
} else {
161-
spinner.fail(`${"Project unsuccessfully cleaned.".red}`);
161+
spinner.fail(color.red("Project unsuccessfully cleaned."));
162162
}
163163
}
164164

@@ -183,7 +183,7 @@ export class CleanCommand implements ICommand {
183183

184184
let computed = 0;
185185
const updateProgress = () => {
186-
const current = `${computed}/${paths.length}`.grey;
186+
const current = color.grey(`${computed}/${paths.length}`);
187187
spinner.start(
188188
`Gathering cleanable sizes. This may take a while... ${current}`
189189
);
@@ -236,9 +236,11 @@ export class CleanCommand implements ICommand {
236236
.reduce((a, b) => a + b, 0);
237237

238238
const pathsToClean = await this.$prompter.promptForChoice(
239-
`Found ${projects.size} cleanable project(s) with a total size of: ${
240-
bytesToHumanReadable(totalSize).green
241-
}. Select projects to clean`,
239+
`Found ${
240+
projects.size
241+
} cleanable project(s) with a total size of: ${color.green(
242+
bytesToHumanReadable(totalSize)
243+
)}. Select projects to clean`,
242244
Array.from(projects.keys()).map((p) => {
243245
const size = projects.get(p);
244246
let description;
@@ -249,7 +251,7 @@ export class CleanCommand implements ICommand {
249251
}
250252

251253
return {
252-
title: `${p}${description.grey}`,
254+
title: `${p}${color.grey(description)}`,
253255
value: p,
254256
};
255257
}),
@@ -261,9 +263,11 @@ export class CleanCommand implements ICommand {
261263
this.$logger.clearScreen();
262264

263265
spinner.warn(
264-
`This will run "${`ns clean`.yellow}" in all the selected projects and ${
265-
"delete files from your system".red.bold
266-
}!`
266+
`This will run "${color.yellow(
267+
`ns clean`
268+
)}" in all the selected projects and ${color.red.bold(
269+
"delete files from your system"
270+
)}!`
267271
);
268272
spinner.warn(`This action cannot be undone!`);
269273

@@ -281,7 +285,7 @@ export class CleanCommand implements ICommand {
281285
const currentPath = pathsToClean[i];
282286

283287
spinner.start(
284-
`Cleaning ${currentPath.cyan}... ${i + 1}/${pathsToClean.length}`
288+
`Cleaning ${color.cyan(currentPath)}... ${i + 1}/${pathsToClean.length}`
285289
);
286290

287291
const ok = await this.$childProcess
@@ -304,19 +308,21 @@ export class CleanCommand implements ICommand {
304308

305309
if (ok) {
306310
const cleanedSize = projects.get(currentPath);
307-
const cleanedSizeStr = `- ${bytesToHumanReadable(cleanedSize)}`.grey;
308-
spinner.succeed(`Cleaned ${currentPath.cyan} ${cleanedSizeStr}`);
311+
const cleanedSizeStr = color.grey(
312+
`- ${bytesToHumanReadable(cleanedSize)}`
313+
);
314+
spinner.succeed(`Cleaned ${color.cyan(currentPath)} ${cleanedSizeStr}`);
309315
totalSizeCleaned += cleanedSize;
310316
} else {
311-
spinner.fail(`Failed to clean ${currentPath.cyan} - skipped`);
317+
spinner.fail(`Failed to clean ${color.cyan(currentPath)} - skipped`);
312318
}
313319
}
314320
spinner.clear();
315321
spinner.stop();
316322
spinner.succeed(
317-
`Done! We've just freed up ${
318-
bytesToHumanReadable(totalSizeCleaned).green
319-
}! Woohoo! 🎉`
323+
`Done! We've just freed up ${color.green(
324+
bytesToHumanReadable(totalSizeCleaned)
325+
)}! Woohoo! 🎉`
320326
);
321327

322328
if (this.$options.dryRun) {

lib/commands/config.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { injector } from "../common/yok";
33
import { IProjectConfigService } from "../definitions/project";
44
import { SupportedConfigValues } from "../tools/config-manipulation/config-transformer";
55
import { IErrors } from "../common/declarations";
6+
import { color } from "../color";
67

78
export class ConfigListCommand implements ICommand {
89
public allowedParameters: ICommandParameter[] = [];
@@ -29,14 +30,14 @@ export class ConfigListCommand implements ICommand {
2930
Object.keys(value)
3031
.map((key) => {
3132
return (
32-
`${indent()}${key}: `.green +
33+
color.green(`${indent()}${key}: `) +
3334
this.getValueString(value[key], depth + 1)
3435
);
3536
})
3637
.join("\n")
3738
);
3839
} else {
39-
return `${value}`.yellow as string;
40+
return color.yellow(value.toString());
4041
}
4142
}
4243
}
@@ -88,9 +89,9 @@ export class ConfigSetCommand implements ICommand {
8889
}
8990
const convertedValue = this.getConvertedValue(value);
9091
const existingKey = current !== undefined;
91-
const keyDisplay = `${key}`.green;
92-
const currentDisplay = `${current}`.yellow;
93-
const updatedDisplay = `${convertedValue}`.cyan;
92+
const keyDisplay = color.green(key);
93+
const currentDisplay = color.yellow(current);
94+
const updatedDisplay = color.cyan(convertedValue);
9495

9596
this.$logger.info(
9697
`${existingKey ? "Updating" : "Setting"} ${keyDisplay}${

lib/commands/create-project.ts

+14-13
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { IOptions } from "../declarations";
66
import { ICommand, ICommandParameter } from "../common/definitions/commands";
77
import { IErrors } from "../common/declarations";
88
import { injector } from "../common/yok";
9+
import { color } from "../color";
910

1011
export class CreateProjectCommand implements ICommand {
1112
public enableHooks = false;
@@ -343,35 +344,35 @@ can skip this prompt next time using the --template option, or the --ng, --react
343344
const { projectDir, projectName } = this.createdProjectData;
344345
const relativePath = path.relative(process.cwd(), projectDir);
345346

346-
const greyDollarSign = "$".grey;
347+
const greyDollarSign = color.grey("$");
347348
this.$logger.clearScreen();
348349
this.$logger.info(
349350
[
350351
[
351-
`Project`.green,
352-
projectName.cyan,
353-
`was successfully created.`.green,
352+
color.green(`Project`),
353+
color.cyan(projectName),
354+
color.green(`was successfully created.`),
354355
].join(" "),
355356
"",
356-
`Now you can navigate to your project with ${
357-
`cd ${relativePath}`.cyan
358-
} and then:`,
357+
`Now you can navigate to your project with ${color.cyan(
358+
`cd ${relativePath}`
359+
)} and then:`,
359360
"",
360361
`Run the project on multiple devices:`,
361362
"",
362-
` ${greyDollarSign} ${"ns run ios".green}`,
363-
` ${greyDollarSign} ${"ns run android".green}`,
363+
` ${greyDollarSign} ${color.green("ns run ios")}`,
364+
` ${greyDollarSign} ${color.green("ns run android")}`,
364365
"",
365366
"Debug the project with Chrome DevTools:",
366367
"",
367-
` ${greyDollarSign} ${"ns debug ios".green}`,
368-
` ${greyDollarSign} ${"ns debug android".green}`,
368+
` ${greyDollarSign} ${color.green("ns debug ios")}`,
369+
` ${greyDollarSign} ${color.green("ns debug android")}`,
369370
``,
370-
`For more options consult the docs or run ${"ns --help".green}`,
371+
`For more options consult the docs or run ${color.green("ns --help")}`,
371372
"",
372373
].join("\n")
373374
);
374-
// Commented as we may bring this back with a playground revision/rewrite
375+
// todo: add back ns preview
375376
// this.$logger.printMarkdown(
376377
// `After that you can preview it on device by executing \`$ ns preview\``
377378
// );

lib/commands/debug.ts

-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ export class DebugPlatformCommand
114114

115115
const result = await super.canExecuteCommandBase(this.platform, {
116116
validateOptions: true,
117-
notConfiguredEnvOptions: { hideSyncToPreviewAppOption: true },
118117
});
119118
return result;
120119
}

lib/commands/plugin/list-plugins.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
} from "../../definitions/plugins";
88
import { ICommand, ICommandParameter } from "../../common/definitions/commands";
99
import { injector } from "../../common/yok";
10+
import { color } from "../../color";
1011

1112
export class ListPluginsCommand implements ICommand {
1213
public allowedParameters: ICommandParameter[] = [];
@@ -52,8 +53,12 @@ export class ListPluginsCommand implements ICommand {
5253
this.$logger.info("There are no dev dependencies.");
5354
}
5455

55-
const viewDependenciesCommand: string = "npm view <pluginName> grep dependencies".cyan.toString();
56-
const viewDevDependenciesCommand: string = "npm view <pluginName> grep devDependencies".cyan.toString();
56+
const viewDependenciesCommand: string = color.cyan(
57+
"npm view <pluginName> grep dependencies"
58+
);
59+
const viewDevDependenciesCommand: string = color.cyan(
60+
"npm view <pluginName> grep devDependencies"
61+
);
5762

5863
this.$logger.warn("NOTE:");
5964
this.$logger.warn(

lib/commands/post-install.ts

+3-8
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
IHostInfo,
99
} from "../common/declarations";
1010
import { injector } from "../common/yok";
11+
import { color } from "../color";
1112

1213
export class PostInstallCliCommand implements ICommand {
1314
constructor(
@@ -54,17 +55,11 @@ export class PostInstallCliCommand implements ICommand {
5455
public async postCommandAction(args: string[]): Promise<void> {
5556
this.$logger.info("");
5657
this.$logger.info(
57-
"You have successfully installed the NativeScript CLI!".green.bold
58+
color.green.bold("You have successfully installed the NativeScript CLI!")
5859
);
5960
this.$logger.info("");
6061
this.$logger.info("Your next step is to create a new project:");
61-
this.$logger.info("ns create".green.bold);
62-
63-
this.$logger.info("");
64-
this.$logger.printMarkdown(
65-
"New to NativeScript?".bold +
66-
" Try the tutorials in NativeScript Playground: `https://play.nativescript.org`"
67-
);
62+
this.$logger.info(color.green.bold("ns create"));
6863

6964
this.$logger.info("");
7065
this.$logger.printMarkdown(

0 commit comments

Comments
 (0)