Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
114d316
feat: config + compiler option for rspack, vite with fallback to webpack
NathanWalker Mar 20, 2025
2451f15
feat: bundler config
NathanWalker Mar 21, 2025
0af7460
Merge remote-tracking branch 'origin/main' into feat/bundler-config
NathanWalker Mar 24, 2025
247f961
feat: bundler config refactor (#5840)
vallemar Mar 25, 2025
5b80974
test: bundler and bundlerConfigPath (#5841)
vallemar Mar 25, 2025
fd695d1
feat: wip vite setup
NathanWalker Apr 22, 2025
a369f81
feat(hooks): support esm
NathanWalker Jul 8, 2025
312db9e
chore: 9.0.0-alpha.0
NathanWalker Jul 8, 2025
cbfe8c2
Merge remote-tracking branch 'origin/main' into feat/hooks-esm-support
NathanWalker Jul 18, 2025
d094859
Merge remote-tracking branch 'origin' into pre/v9-combined-testing
NathanWalker Jul 18, 2025
8013cee
Merge branch 'feat/hooks-esm-support' into pre/v9-combined-testing
NathanWalker Jul 18, 2025
e502c0b
Merge remote-tracking branch 'origin/main' into feat/bundler-config
NathanWalker Jul 18, 2025
77e2516
Merge branch 'feat/bundler-config' into pre/v9-combined-testing
NathanWalker Jul 18, 2025
0cc056b
feat(vite): ensure cli flags are passed
NathanWalker Jul 21, 2025
4b9e451
feat(hooks): support esm
NathanWalker Jul 21, 2025
6b96879
Merge branch 'feat/hooks-esm-support' into pre/v9-combined-testing
NathanWalker Jul 21, 2025
b6f6bae
chore: 9.0.0-alpha.2
NathanWalker Jul 21, 2025
dba4e1a
chore: updated lock
NathanWalker Jul 27, 2025
bb9af69
Merge remote-tracking branch 'origin/main' into pre/v9-combined-testing
NathanWalker Jul 27, 2025
f3a3b90
chore: 9.0.0-alpha.3
NathanWalker Jul 27, 2025
b3bbc1a
feat(hooks): allow cjs extensions
NathanWalker Aug 3, 2025
89daf8a
chore: 9.0.0-alpha.4
NathanWalker Aug 3, 2025
287ebed
Merge remote-tracking branch 'origin/main' into pre/v9-combined-testing
NathanWalker Aug 7, 2025
8a12366
fix: prevent TypeError: Body is unusable during unit test dep generation
NathanWalker Aug 7, 2025
6de802d
chore: cleanup
NathanWalker Aug 7, 2025
15f17df
feat: vite support phase 1
NathanWalker Aug 9, 2025
d68a93d
chore: 9.0.0-alpha.5
NathanWalker Aug 9, 2025
4220582
lib: replace glob with fs.glob
RafaelGSS Aug 28, 2025
d46ffff
lib: replace chalk/ansi-colors with util.styleText
RafaelGSS Aug 28, 2025
c4d679d
Merge branch 'pre/v9-combined-testing' into use-nodejs-builtins
NathanWalker Sep 4, 2025
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
42 changes: 23 additions & 19 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const childProcess = require("child_process");
const EOL = require("os").EOL;
const path = require("path");
const now = new Date().toISOString();
const latestVersion = require('latest-version').default;
const manifest = require('pacote').manifest;


const ENVIRONMENTS = {
Expand Down Expand Up @@ -260,28 +260,26 @@ function registerTestingDependenciesTasks(grunt) {
return done(false);
}


// Kick off all version resolutions in parallel
const versionPromises = testDependencies.map(dep => {
if (dep.version) {
dependenciesVersions[dep.name] = dep.version;
return Promise.resolve();
}
return latestVersion(dep.name).then(v => {
dependenciesVersions[dep.name] = v;
});
});

Promise.all(versionPromises)
.then(() => {
grunt.file.write(generatedVersionFilePath, JSON.stringify(dependenciesVersions, null, 2));
(async () => {
try {
for (const dep of testDependencies) {
if (dep.version) {
dependenciesVersions[dep.name] = dep.version;
} else {
dependenciesVersions[dep.name] = await latestVersion(dep.name);
}
}
grunt.file.write(
generatedVersionFilePath,
JSON.stringify(dependenciesVersions, null, 2)
);
grunt.log.writeln("Wrote", generatedVersionFilePath);
done();
})
.catch(err => {
} catch (err) {
grunt.log.error(err);
done(false);
});
}
})();
});

grunt.registerTask("verify_unit_testing_dependencies", function () {
Expand All @@ -291,3 +289,9 @@ function registerTestingDependenciesTasks(grunt) {
});
}

async function latestVersion(name) {
// only fetches the package.json for the latest dist-tag
const { version } = await manifest(name.toLowerCase(), { fullMetadata: false });
return version;
}

4 changes: 2 additions & 2 deletions lib/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,8 @@ injector.require(
injector.requirePublic("cleanupService", "./services/cleanup-service");

injector.require(
"webpackCompilerService",
"./services/webpack/webpack-compiler-service",
"bundlerCompilerService",
"./services/bundler/bundler-compiler-service",
);

injector.require(
Expand Down
98 changes: 89 additions & 9 deletions lib/color.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,92 @@
// 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 ansi from "ansi-colors";
import * as chalk from "chalk";
import { styleText, stripVTControlCharacters } from "node:util";

export type Color = typeof chalk.Color;
// Define color types based on util.inspect.colors
export type StyleFormat =
| "reset"
| "bold"
| "dim"
| "italic"
| "underline"
| "blink"
| "inverse"
| "hidden"
| "strikethrough"
| "doubleunderline"
| "black"
| "red"
| "green"
| "yellow"
| "blue"
| "magenta"
| "cyan"
| "white"
| "gray"
| "redBright"
| "greenBright"
| "yellowBright"
| "blueBright"
| "magentaBright"
| "cyanBright"
| "whiteBright"
| "bgBlack"
| "bgRed"
| "bgGreen"
| "bgYellow"
| "bgBlue"
| "bgMagenta"
| "bgCyan"
| "bgWhite"
| "bgGray"
| "bgRedBright"
| "bgGreenBright"
| "bgYellowBright"
| "bgBlueBright"
| "bgMagentaBright"
| "bgCyanBright"
| "bgWhiteBright";

export function stripColors(formatStr: string) {
return ansi.stripColor(formatStr);
}
export type Color = StyleFormat;

export const color = chalk;
// Create a chalk-like API using the Node.js util.styleText function
export const color = {
reset: (text: string) => styleText("reset", text),
bold: (text: string) => styleText("bold", text),
dim: (text: string) => styleText("dim", text),
italic: (text: string) => styleText("italic", text),
underline: (text: string) => styleText("underline", text),
inverse: (text: string) => styleText("inverse", text),
hidden: (text: string) => styleText("hidden", text),
strikethrough: (text: string) => styleText("strikethrough", text),

// Text colors
black: (text: string) => styleText("black", text),
red: (text: string) => styleText("red", text),
blue: (text: string) => styleText("blue", text),
magenta: (text: string) => styleText("magenta", text),
cyan: (text: string) => styleText("cyan", text),
white: (text: string) => styleText("white", text),
gray: (text: string) => styleText("gray", text),
yellow: (text: string) => styleText("yellow", text),
green: (text: string) => styleText("green", text),
grey: (text: string) => styleText("grey", text),

// Background colors
bgBlack: (text: string) => styleText("bgBlack", text),
bgBlackBright: (text: string) => styleText("bgBlackBright", text),
bgRed: (text: string) => styleText("bgRed", text),
bgGreen: (text: string) => styleText("bgGreen", text),
bgYellow: (text: string) => styleText("bgYellow", text),
bgBlue: (text: string) => styleText("bgBlue", text),
bgMagenta: (text: string) => styleText("bgMagenta", text),
bgCyan: (text: string) => styleText("bgCyan", text),
bgWhite: (text: string) => styleText("bgWhite", text),
cyanBright: (text: string) => styleText("cyanBright", text),
whiteBright: (text: string) => styleText("whiteBright", text),
greenBright: (text: string) => styleText("greenBright", text),
yellowBright: (text: string) => styleText("yellowBright", text),
redBright: (text: string) => styleText("redBright", text),

styleText,
};

export const stripColors = (text: string) => stripVTControlCharacters(text);
3 changes: 2 additions & 1 deletion lib/commands/clean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,8 @@ export class CleanCommand implements ICommand {
spinner.warn(
`This will run "${color.yellow(
`ns clean`,
)}" in all the selected projects and ${color.red.bold(
)}" in all the selected projects and ${color.styleText(
["red", "bold"],
"delete files from your system",
)}!`,
);
Expand Down
5 changes: 3 additions & 2 deletions lib/commands/embedding/embed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ export class EmbedCommand extends PrepareCommand implements ICommand {
if (!this.$fs.exists(resolvedHostProjectPath)) {
this.$logger.error(
`The host project path ${color.yellow(
hostProjectPath
)} (resolved to: ${color.yellow.dim(
hostProjectPath,
)} (resolved to: ${color.styleText(
["yellow", "dim"],
resolvedHostProjectPath
)}) does not exist.`
);
Expand Down
7 changes: 5 additions & 2 deletions lib/commands/post-install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,14 @@ export class PostInstallCliCommand implements ICommand {
public async postCommandAction(args: string[]): Promise<void> {
this.$logger.info("");
this.$logger.info(
color.green.bold("You have successfully installed the NativeScript CLI!")
color.styleText(
["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(color.green.bold("ns create"));
this.$logger.info(color.styleText(["green", "bold"], "ns create"));

this.$logger.info("");
this.$logger.printMarkdown(
Expand Down
32 changes: 16 additions & 16 deletions lib/commands/typings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { glob } from "glob";
import { glob } from "node:fs/promises";
import { homedir } from "os";
import * as path from "path";
import { PromptObject } from "prompts";
Expand Down Expand Up @@ -67,27 +67,26 @@ export class TypingsCommand implements ICommand {

const pattern = `${target.replaceAll(":", "/")}/**/*.{jar,aar}`;

const res = await glob(pattern, {
const items = [];
for await (const item of glob(pattern, {
cwd: gradleFiles,
});

if (!res || res.length === 0) {
this.$logger.warn("No files found");
return [];
}

const items = res.map((item) => {
})) {
const [group, artifact, version, sha1, file] = item.split(path.sep);
return {
items.push({
id: sha1 + version,
group,
artifact,
version,
sha1,
file,
path: path.resolve(gradleFiles, item),
};
});
});
}

if (items.length === 0) {
this.$logger.warn("No files found");
return [];
}

this.$logger.clearScreen();

Expand All @@ -108,9 +107,10 @@ export class TypingsCommand implements ICommand {
.map((item) => {
return {
title: `${color.white(item.group)}:${color.greenBright(
item.artifact
)}:${color.yellow(item.version)} - ${color.cyanBright.bold(
item.file
item.artifact,
)}:${color.yellow(item.version)} - ${color.styleText(
["cyanBright", "bold"],
item.file,
)}`,
value: item.id,
};
Expand Down
9 changes: 6 additions & 3 deletions lib/common/header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@ export function printHeader() {

const header = [
color.dim("│ "),
color.cyanBright.bold("{N} NativeScript "),
color.whiteBright.bold("CLI"),
color.styleText(["cyanBright", "bold"], "{N} NativeScript "),
color.styleText(["whiteBright", "bold"], "CLI"),
color.dim(` [v${version}] `),
// color.dim(" │"),
].join("");
const tagLine = [
color.dim("│ "),
color.dim(" → "),
color.whiteBright.bold("Empower JavaScript with native APIs "),
color.styleText(
["whiteBright", "bold"],
"Empower JavaScript with native APIs ",
),
// color.dim(" │"),
].join("");

Expand Down
2 changes: 1 addition & 1 deletion lib/common/logger/layouts/cli-layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function layout(config: any) {
}

if (logEvent.level.isEqualTo(LoggerLevel.ERROR)) {
return color.red.bold(msg);
return color.styleText(["red", "bold"], msg);
}

if (logEvent.level.isEqualTo(LoggerLevel.WARN)) {
Expand Down
4 changes: 2 additions & 2 deletions lib/common/logger/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ export class Logger implements ILogger {
const opts = {
unescape: true,
link: color.red,
strong: color.green.bold,
firstHeading: color.blue.bold,
strong: (str: string) => color.styleText(["green", "bold"], str),
firstHeading: (str: string) => color.styleText(["blue", "bold"], str),
tableOptions: {
chars: { mid: "", "left-mid": "", "mid-mid": "", "right-mid": "" },
style: {
Expand Down
Loading