Skip to content
This repository was archived by the owner on Sep 11, 2025. It is now read-only.
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
12 changes: 12 additions & 0 deletions cli/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,17 @@ export default tseslint.config({
ignores: ["node_modules/**", "dist/**"],
rules: {
"no-undef": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
args: "all",
argsIgnorePattern: "^_",
caughtErrors: "all",
caughtErrorsIgnorePattern: "^_",
destructuredArrayIgnorePattern: "^_",
varsIgnorePattern: "^_",
ignoreRestSiblings: true,
},
],
},
});
8 changes: 8 additions & 0 deletions cli/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"dependencies": {
"@inquirer/prompts": "^7.0.1",
"@oclif/core": "^4",
"@scarf/scarf": "^1.4.0",
"chalk": "^5.3.0",
"chokidar": "^4.0.1",
"gradient-string": "^3.0.0",
Expand Down
26 changes: 24 additions & 2 deletions cli/src/commands/new/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import path from "node:path";

import * as fs from "../../util/fs.js";
import * as vi from "../../util/versioninfo.js";
import * as http from "../../util/http.js";
import { execFile, exec } from "../../util/cp.js";
import { isOnline } from "../../util/index.js";
import { MinGoVersion, MinNodeVersion, MinTinyGoVersion, SDK, parseSDK } from "../../custom/globals.js";
Expand All @@ -30,6 +31,8 @@ import { isErrorWithName } from "../../util/errors.js";

const MODUS_DEFAULT_TEMPLATE_NAME = "default";

const SCARF_ENDPOINT = "hypermode.gateway";

export default class NewCommand extends BaseCommand {
static description = "Create a new Modus app";

Expand Down Expand Up @@ -148,7 +151,8 @@ export default class NewCommand extends BaseCommand {
}

this.log();
await this.createApp(name, dir, sdk, MODUS_DEFAULT_TEMPLATE_NAME, flags["no-prompt"], flags.prerelease, createGitRepo);

await this.createApp(name, dir, sdk, MODUS_DEFAULT_TEMPLATE_NAME, flags.prerelease, createGitRepo);
} catch (err) {
if (isErrorWithName(err) && err.name === "ExitPromptError") {
this.abort();
Expand All @@ -158,6 +162,22 @@ export default class NewCommand extends BaseCommand {
}
}

private async collectInstallInfo(sdk: string, sdkVersion: string) {
try {
// Skip metrics collection if environment variables are set
if (process.env.SCARF_NO_ANALYTICS !== "true" && process.env.DO_NOT_TRACK !== "true") {
const version = this.config.version;
const platform = os.platform();
const arch = os.arch();
const nodeVersion = process.version;

await http.get(`https://${SCARF_ENDPOINT}.scarf.sh/${version}/${platform}/${arch}/${nodeVersion}/${sdk}/${sdkVersion}`);
}
} catch (_error) {
// Fail silently if an error occurs during the analytics call
}
}

private async validateSdkPrereq(sdk: string) {
const sdkText = `Modus ${sdk} SDK`;
switch (sdk) {
Expand Down Expand Up @@ -225,7 +245,7 @@ export default class NewCommand extends BaseCommand {
}
}

private async createApp(name: string, dir: string, sdk: SDK, template: string, force: boolean, prerelease: boolean, createGitRepo: boolean) {
private async createApp(name: string, dir: string, sdk: SDK, template: string, prerelease: boolean, createGitRepo: boolean) {
const sdkText = `Modus ${sdk} SDK`;

// Verify and/or install the Modus SDK
Expand Down Expand Up @@ -287,6 +307,8 @@ export default class NewCommand extends BaseCommand {

// Create the app
this.log(chalk.dim(`Using ${sdkText} ${sdkVersion}`));

await this.collectInstallInfo(sdk, sdkVersion);
await withSpinner(`Creating a new Modus ${sdk} app.`, async () => {
if (!(await fs.exists(dir))) {
await fs.mkdir(dir, { recursive: true });
Expand Down