Skip to content
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

feat(cli): adding pre-release + analytics disclaimer on first run of cli #3058

Closed
wants to merge 4 commits into from
Closed
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
38 changes: 38 additions & 0 deletions apps/wing/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
// for WebAssembly typings:
/// <reference lib="dom" />

import os from "os";
import fs from "fs";
import path from "path";
import chalk from "chalk";

import { compile, docs, test, checkForUpdates, run } from "./commands";
import { satisfies } from "compare-versions";

Expand All @@ -24,6 +29,39 @@ function actionErrorHandler(fn: (...args: any[]) => Promise<any>) {
async function main() {
checkNodeVersion();

// Check if the flag file exists
const wingDirPath = path.join(os.homedir(), ".wing");
const flagFilePath = path.join(wingDirPath, ".cli_initialized");
const isFirstRun = !fs.existsSync(flagFilePath);

// If it's the first run, display the disclaimer and create the flag file
if (isFirstRun) {
const disclaimer = `
🧪 This is an early pre-release of the Wing Programming Language (aka "alpha").

We are working hard to make this a great tool, but there's still a pretty good
chance you'll encounter missing pieces, rough edges, performance issues and even,
god forbid, bugs 🐞.

Please don't hesitate to ping us at ${chalk.blueBright.bold.underline(
"https://t.winglang.io/slack"
)} or file an issue at
${chalk.blueBright.bold.underline(
"https://github.com/winglang/wing"
)}. We promise to do our best to respond quickly and help out.

To help us identify issues early, we are collecting anonymous analytics.
To turn this off, set ${chalk.yellowBright.bold("WING_CLI_DISABLE_ANALYTICS=1")}.
For more information see ${chalk.blueBright.bold.underline("https://winglang.io/docs/analytics")}

${chalk.redBright("(This message will self-destruct after the first run)")}
`;

console.log(`${chalk.hex("#2AD5C1")(disclaimer)}`);

fs.writeFileSync(flagFilePath, "");
}

const program = new Command();

program.name("wing").version(PACKAGE_VERSION);
Expand Down
Loading