Skip to content
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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "polyapi",
"version": "0.24.1",
"version": "0.24.2",
"description": "Poly is a CLI tool to help create and manage your Poly definitions.",
"license": "MIT",
"repository": {
Expand Down Expand Up @@ -28,6 +28,7 @@
"prepublishOnly": "npm run lint && npm run build",
"preversion": "npm run lint",
"postversion": "git push && git push --tags",

"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
},
"devDependencies": {
Expand Down
38 changes: 38 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,47 @@ import { loadConfig } from './config';
import { type RenameT } from './commands/model';
import { DEFAULT_POLY_PATH } from './constants';
import { isValidHttpUrl } from './utils';
import fs from 'fs';
import path from 'path';

if (process.env.NO_COLOR) {
// Support NO_COLOR env variable https://no-color.org/
chalk.level = 0;
}

const showWelcomeIfFirstTime = () => {
try {
const polyDir = DEFAULT_POLY_PATH;
const welcomeFile = path.join(polyDir, '.welcome-shown');

// If welcome has already been shown, return early
if (fs.existsSync(welcomeFile)) {
return;
}

// Get version from package.json
const packagePath = path.join(__dirname, '..', 'package.json');
const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf8'));
const version = packageJson.version;

// Show welcome message
console.log('');
console.log(chalk.green('✓ PolyAPI SDK installed successfully!'));
console.log(chalk.blue(`📦 Version: ${version}`));
console.log('');
console.log(chalk.yellow('Getting started:'));
console.log(' • Run ' + chalk.cyan('poly --help') + ' to see all available commands');
console.log(' • Run ' + chalk.cyan('poly setup') + ' to configure your Poly connection');
console.log('');

// Ensure .poly directory exists and mark welcome as shown
fs.mkdirSync(polyDir, { recursive: true });
fs.writeFileSync(welcomeFile, new Date().toISOString());
} catch (error) {
// Silently fail if there's an issue - don't break the CLI
}
};

const checkPolyConfig = (polyPath: string) => {
loadConfig(polyPath);

Expand All @@ -24,6 +59,9 @@ const checkPolyConfig = (polyPath: string) => {
return true;
};

// Show welcome message on first usage
showWelcomeIfFirstTime();

void yargs
.usage('$0 <cmd> [args]')
.command(
Expand Down