Skip to content

refactor: dependency and repo cleanup #5722

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 34 commits into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2178873
refactor: drop colors package and use chalk + remove old playground s…
rigor789 Mar 21, 2023
a7d402f
chore: remove old playground related code and further clean up logging
rigor789 Mar 21, 2023
81331c5
chore: cleanup unused code
rigor789 Mar 21, 2023
302f914
chore: bump pacote to latest
rigor789 Mar 21, 2023
839b90c
chore: remove play whoami tests
rigor789 Mar 21, 2023
96536ed
chore: remove osenv
rigor789 Mar 21, 2023
c2715c6
chore: update open
rigor789 Mar 21, 2023
ae9814e
chore: update deps and drop our definitions
rigor789 Mar 21, 2023
f43f528
chore: bump additional deps
rigor789 Mar 21, 2023
cfc18e4
chore: fix typos
rigor789 Mar 21, 2023
3bbe6ab
chore: clean up more deps and code style
rigor789 Mar 21, 2023
6a73de9
chore: update remaining deps, replace zipstream with archiver
rigor789 Mar 21, 2023
f51bfc1
chore: remove unused dep, add back doctor types, use * for version in…
rigor789 Mar 21, 2023
e7bc5e4
chore: bump nativescript-dev-xcode and add tabtab types
rigor789 Mar 21, 2023
57f816a
chore: bundle `@npmcli/move-file` and `stringify-package`
rigor789 Mar 21, 2023
db47ffc
refactor: drop `tabtab` and implement autocompletion using yargs call…
rigor789 Mar 25, 2023
ebc9cc3
refactor: load npm config lazily and add the `--global` flag
rigor789 Mar 25, 2023
6f81d1d
fix(debug-socket): convert message to string
rigor789 Mar 25, 2023
0f668f2
chore: update lockfiles
rigor789 Mar 25, 2023
e0e73cd
chore: remove unused import
rigor789 Mar 25, 2023
19a44da
chore(release): 8.5.0-dev.1
rigor789 Mar 25, 2023
9022ce4
Merge branch 'main' into chore/dep-cleanup
rigor789 Mar 25, 2023
4fba861
chore: update lockfiles
rigor789 Mar 25, 2023
824bbaf
chore: add colors to the log messages
rigor789 Mar 25, 2023
e261967
feat: print instructions for profiling
rigor789 Mar 25, 2023
52a0427
Merge branch 'main' into chore/dep-cleanup
rigor789 Mar 28, 2023
0a4a3b3
chore(release): 8.5.1-dev.0
rigor789 Mar 28, 2023
e0b0cec
Merge branch 'main' into chore/dep-cleanup
rigor789 Apr 6, 2023
857b4ab
chore: update deps and fix incoming changes from main
rigor789 Apr 6, 2023
58c16d2
Merge branch 'main' into chore/dep-cleanup
rigor789 Apr 18, 2023
13cc5bf
chore(release): nativescript 8.5.4-dev.0
rigor789 Apr 18, 2023
296c533
fix: use semver comparison to check for cli update
rigor789 Apr 18, 2023
0ce9db0
chore(release): nativescript 8.5.4-dev.1
rigor789 Apr 18, 2023
50c6528
Merge branch 'main' into chore/dep-cleanup
rigor789 May 22, 2023
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
5 changes: 0 additions & 5 deletions config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,5 @@
"ANDROID_DEBUG_UI_MAC": "Google Chrome",
"USE_POD_SANDBOX": false,
"DISABLE_HOOKS": false,
"UPLOAD_PLAYGROUND_FILES_ENDPOINT": "https://play.nativescript.org/api/files",
"SHORTEN_URL_ENDPOINT": "https://play.nativescript.org/api/shortenurl?longUrl=%s",
"INSIGHTS_URL_ENDPOINT": "https://play-server.nativescript.org/api/insights?ipAddress=%s",
"WHOAMI_URL_ENDPOINT": "https://play.nativescript.org/api/whoami",
"PREVIEW_APP_ENVIRONMENT": "live",
"GA_TRACKING_ID": "UA-111455-51"
}
41 changes: 1 addition & 40 deletions lib/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ injector.require(
"./services/platform/platform-validation-service"
);

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

injector.require(
"deviceInstallAppService",
Expand All @@ -120,10 +120,6 @@ injector.requirePublicClass(
"debugController",
"./controllers/debug-controller"
);
injector.requirePublicClass(
"previewAppController",
"./controllers/preview-app-controller"
);
injector.requirePublicClass(
"updateController",
"./controllers/update-controller"
Expand Down Expand Up @@ -169,11 +165,6 @@ injector.require(
"googleAnalyticsProvider",
"./services/analytics/google-analytics-provider"
);
injector.requirePublicClass(
"companyInsightsController",
"./controllers/company-insights-controller"
);

injector.require("platformCommandParameter", "./platform-command-param");
injector.requireCommand("create", "./commands/create-project");
injector.requireCommand("clean", "./commands/clean");
Expand Down Expand Up @@ -309,34 +300,6 @@ injector.require(
"./services/livesync/ios-livesync-service"
);
injector.require("usbLiveSyncService", "./services/livesync/livesync-service"); // The name is used in https://github.com/NativeScript/nativescript-dev-typescript
injector.require(
"previewAppFilesService",
"./services/livesync/playground/preview-app-files-service"
);
injector.require(
"previewAppLogProvider",
"./services/livesync/playground/preview-app-log-provider"
);
injector.require(
"previewAppPluginsService",
"./services/livesync/playground/preview-app-plugins-service"
);
injector.require(
"previewSdkService",
"./services/livesync/playground/preview-sdk-service"
);
injector.require(
"previewSchemaService",
"./services/livesync/playground/preview-schema-service"
);
injector.requirePublicClass(
"previewDevicesService",
"./services/livesync/playground/devices/preview-devices-service"
);
injector.requirePublic(
"previewQrCodeService",
"./services/livesync/playground/preview-qr-code-service"
);
injector.requirePublic("sysInfo", "./sys-info");

injector.require(
Expand All @@ -353,7 +316,6 @@ injector.require(
"./device-sockets/ios/socket-request-executor"
);
injector.require("messages", "./common/messages/messages");
injector.require("xmlValidator", "./xml-validator");

injector.requireCommand("post-install-cli", "./commands/post-install");
injector.requireCommand("migrate", "./commands/migrate");
Expand Down Expand Up @@ -396,7 +358,6 @@ injector.require(
"./services/terminal-spinner-service"
);

injector.require("playgroundService", "./services/playground-service");
injector.require(
"platformEnvironmentRequirements",
"./services/platform-environment-requirements"
Expand Down
7 changes: 7 additions & 0 deletions lib/color.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// using chalk as some of our other dependencies are already using it...
// exporting from here so we can easily refactor to a different color library if needed
import * as chalk from "chalk";

export type Color = typeof chalk.Color;

export const color = chalk;
8 changes: 2 additions & 6 deletions lib/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,7 @@ export class BuildIosCommand extends BuildCommandBase implements ICommand {

super.validatePlatform(platform);

let canExecute = await super.canExecuteCommandBase(platform, {
notConfiguredEnvOptions: { hideSyncToPreviewAppOption: true },
});
let canExecute = await super.canExecuteCommandBase(platform);
if (canExecute) {
canExecute = await super.validateArgs(args, platform);
}
Expand Down Expand Up @@ -209,9 +207,7 @@ export class BuildAndroidCommand extends BuildCommandBase implements ICommand {
this.$androidBundleValidatorHelper.validateRuntimeVersion(
this.$projectData
);
let canExecute = await super.canExecuteCommandBase(platform, {
notConfiguredEnvOptions: { hideSyncToPreviewAppOption: true },
});
let canExecute = await super.canExecuteCommandBase(platform);
if (canExecute) {
if (this.$options.release && !hasValidAndroidSigning(this.$options)) {
this.$errors.failWithHelp(ANDROID_RELEASE_BUILD_ERROR_MESSAGE);
Expand Down
44 changes: 25 additions & 19 deletions lib/commands/clean.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { color } from "../color";
import { ICommand, ICommandParameter } from "../common/definitions/commands";
import { injector } from "../common/yok";
import * as constants from "../constants";
Expand Down Expand Up @@ -114,9 +115,8 @@ export class CleanCommand implements ICommand {
];

try {
const overridePathsToClean = this.$projectConfigService.getValue(
"cli.pathsToClean"
);
const overridePathsToClean =
this.$projectConfigService.getValue("cli.pathsToClean");
const additionalPaths = this.$projectConfigService.getValue(
"cli.additionalPathsToClean"
);
Expand Down Expand Up @@ -158,7 +158,7 @@ export class CleanCommand implements ICommand {
if (res.ok) {
spinner.succeed("Project successfully cleaned.");
} else {
spinner.fail(`${"Project unsuccessfully cleaned.".red}`);
spinner.fail(color.red("Project unsuccessfully cleaned."));
}
}

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

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

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

return {
title: `${p}${description.grey}`,
title: `${p}${color.grey(description)}`,
value: p,
};
}),
Expand All @@ -261,9 +263,11 @@ export class CleanCommand implements ICommand {
this.$logger.clearScreen();

spinner.warn(
`This will run "${`ns clean`.yellow}" in all the selected projects and ${
"delete files from your system".red.bold
}!`
`This will run "${color.yellow(
`ns clean`
)}" in all the selected projects and ${color.red.bold(
"delete files from your system"
)}!`
);
spinner.warn(`This action cannot be undone!`);

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

spinner.start(
`Cleaning ${currentPath.cyan}... ${i + 1}/${pathsToClean.length}`
`Cleaning ${color.cyan(currentPath)}... ${i + 1}/${pathsToClean.length}`
);

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

if (ok) {
const cleanedSize = projects.get(currentPath);
const cleanedSizeStr = `- ${bytesToHumanReadable(cleanedSize)}`.grey;
spinner.succeed(`Cleaned ${currentPath.cyan} ${cleanedSizeStr}`);
const cleanedSizeStr = color.grey(
`- ${bytesToHumanReadable(cleanedSize)}`
);
spinner.succeed(`Cleaned ${color.cyan(currentPath)} ${cleanedSizeStr}`);
totalSizeCleaned += cleanedSize;
} else {
spinner.fail(`Failed to clean ${currentPath.cyan} - skipped`);
spinner.fail(`Failed to clean ${color.cyan(currentPath)} - skipped`);
}
}
spinner.clear();
spinner.stop();
spinner.succeed(
`Done! We've just freed up ${
bytesToHumanReadable(totalSizeCleaned).green
}! Woohoo! 🎉`
`Done! We've just freed up ${color.green(
bytesToHumanReadable(totalSizeCleaned)
)}! Woohoo! 🎉`
);

if (this.$options.dryRun) {
Expand Down
11 changes: 6 additions & 5 deletions lib/commands/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { injector } from "../common/yok";
import { IProjectConfigService } from "../definitions/project";
import { SupportedConfigValues } from "../tools/config-manipulation/config-transformer";
import { IErrors } from "../common/declarations";
import { color } from "../color";

export class ConfigListCommand implements ICommand {
public allowedParameters: ICommandParameter[] = [];
Expand All @@ -29,14 +30,14 @@ export class ConfigListCommand implements ICommand {
Object.keys(value)
.map((key) => {
return (
`${indent()}${key}: `.green +
color.green(`${indent()}${key}: `) +
this.getValueString(value[key], depth + 1)
);
})
.join("\n")
);
} else {
return `${value}`.yellow as string;
return color.yellow(value.toString());
}
}
}
Expand Down Expand Up @@ -88,9 +89,9 @@ export class ConfigSetCommand implements ICommand {
}
const convertedValue = this.getConvertedValue(value);
const existingKey = current !== undefined;
const keyDisplay = `${key}`.green;
const currentDisplay = `${current}`.yellow;
const updatedDisplay = `${convertedValue}`.cyan;
const keyDisplay = color.green(key);
const currentDisplay = color.yellow(current);
const updatedDisplay = color.cyan(convertedValue);

this.$logger.info(
`${existingKey ? "Updating" : "Setting"} ${keyDisplay}${
Expand Down
27 changes: 14 additions & 13 deletions lib/commands/create-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { IOptions } from "../declarations";
import { ICommand, ICommandParameter } from "../common/definitions/commands";
import { IErrors } from "../common/declarations";
import { injector } from "../common/yok";
import { color } from "../color";

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

const greyDollarSign = "$".grey;
const greyDollarSign = color.grey("$");
this.$logger.clearScreen();
this.$logger.info(
[
[
`Project`.green,
projectName.cyan,
`was successfully created.`.green,
color.green(`Project`),
color.cyan(projectName),
color.green(`was successfully created.`),
].join(" "),
"",
`Now you can navigate to your project with ${
`cd ${relativePath}`.cyan
} and then:`,
`Now you can navigate to your project with ${color.cyan(
`cd ${relativePath}`
)} and then:`,
"",
`Run the project on multiple devices:`,
"",
` ${greyDollarSign} ${"ns run ios".green}`,
` ${greyDollarSign} ${"ns run android".green}`,
` ${greyDollarSign} ${color.green("ns run ios")}`,
` ${greyDollarSign} ${color.green("ns run android")}`,
"",
"Debug the project with Chrome DevTools:",
"",
` ${greyDollarSign} ${"ns debug ios".green}`,
` ${greyDollarSign} ${"ns debug android".green}`,
` ${greyDollarSign} ${color.green("ns debug ios")}`,
` ${greyDollarSign} ${color.green("ns debug android")}`,
``,
`For more options consult the docs or run ${"ns --help".green}`,
`For more options consult the docs or run ${color.green("ns --help")}`,
"",
].join("\n")
);
// Commented as we may bring this back with a playground revision/rewrite
// todo: add back ns preview
// this.$logger.printMarkdown(
// `After that you can preview it on device by executing \`$ ns preview\``
// );
Expand Down
1 change: 0 additions & 1 deletion lib/commands/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ export class DebugPlatformCommand

const result = await super.canExecuteCommandBase(this.platform, {
validateOptions: true,
notConfiguredEnvOptions: { hideSyncToPreviewAppOption: true },
});
return result;
}
Expand Down
9 changes: 7 additions & 2 deletions lib/commands/plugin/list-plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
} from "../../definitions/plugins";
import { ICommand, ICommandParameter } from "../../common/definitions/commands";
import { injector } from "../../common/yok";
import { color } from "../../color";

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

const viewDependenciesCommand: string = "npm view <pluginName> grep dependencies".cyan.toString();
const viewDevDependenciesCommand: string = "npm view <pluginName> grep devDependencies".cyan.toString();
const viewDependenciesCommand: string = color.cyan(
"npm view <pluginName> grep dependencies"
);
const viewDevDependenciesCommand: string = color.cyan(
"npm view <pluginName> grep devDependencies"
);

this.$logger.warn("NOTE:");
this.$logger.warn(
Expand Down
11 changes: 3 additions & 8 deletions lib/commands/post-install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
IHostInfo,
} from "../common/declarations";
import { injector } from "../common/yok";
import { color } from "../color";

export class PostInstallCliCommand implements ICommand {
constructor(
Expand Down Expand Up @@ -54,17 +55,11 @@ export class PostInstallCliCommand implements ICommand {
public async postCommandAction(args: string[]): Promise<void> {
this.$logger.info("");
this.$logger.info(
"You have successfully installed the NativeScript CLI!".green.bold
color.green.bold("You have successfully installed the NativeScript CLI!")
);
this.$logger.info("");
this.$logger.info("Your next step is to create a new project:");
this.$logger.info("ns create".green.bold);

this.$logger.info("");
this.$logger.printMarkdown(
"New to NativeScript?".bold +
" Try the tutorials in NativeScript Playground: `https://play.nativescript.org`"
);
this.$logger.info(color.green.bold("ns create"));

this.$logger.info("");
this.$logger.printMarkdown(
Expand Down
Loading