feat: автодополнение и детект режима запуска
- Добавлены служебные команды __list-templates/__list-vars и генерация completion для bash/
zsh/fish
- Введён детект режимов запуска (npx/local/direct/global) и применён в проверке обновлений
- Обновлены help и документация (README, FEATURES)
This commit is contained in:
@@ -5,23 +5,12 @@ import * as https from 'https';
|
||||
import * as readline from 'readline';
|
||||
import { spawnSync } from 'child_process';
|
||||
import ora = require('ora');
|
||||
import { detectRunMode } from './runtime';
|
||||
|
||||
const PACKAGE_NAME = '@gromlab/create';
|
||||
const UPDATE_TIMEOUT_MS = 2000;
|
||||
const UPDATE_PROMPT_COOLDOWN_MS = 24 * 60 * 60 * 1000;
|
||||
|
||||
function isNpxInvocation(): boolean {
|
||||
const argv1 = process.argv[1] ?? '';
|
||||
const npmCommand = process.env.npm_command ?? '';
|
||||
const npmExecPath = process.env.npm_execpath ?? '';
|
||||
|
||||
if (argv1.includes(`${path.sep}_npx${path.sep}`)) return true;
|
||||
if (npmCommand === 'exec') return true;
|
||||
if (npmExecPath.includes('npx-cli.js')) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function getUpdateStatePath(): string {
|
||||
const xdgHome = process.env.XDG_CONFIG_HOME;
|
||||
if (xdgHome) {
|
||||
@@ -180,7 +169,7 @@ function hasSkipUpdateFlag(args: string[]): boolean {
|
||||
}
|
||||
|
||||
export async function maybeHandleUpdate(args: string[]): Promise<boolean> {
|
||||
if (isNpxInvocation()) return true;
|
||||
if (detectRunMode() === 'npx') return true;
|
||||
if (hasSkipUpdateFlag(args)) return true;
|
||||
if (!isInteractive()) return true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user