@redcumbrecl/cli 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cli.js +17 -12
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -790,11 +790,13 @@ function rutaDeLaLlave(proyecto, entorno, env = process.env) {
790
790
  function llaveDelEntorno(proyecto, entorno, env = process.env) {
791
791
  return leerArchivoLlave(rutaDeLaLlave(proyecto, entorno, env));
792
792
  }
793
+ function tieneInstalacionDelCli(carpeta) {
794
+ return [rutaEstado(carpeta), ...ENTORNOS_LLAVE.map((e) => rutaLlave(carpeta, e))].some((m) => fs2.existsSync(m));
795
+ }
793
796
  function raizDelProyecto(desde) {
794
797
  let actual = path2.resolve(desde);
795
798
  for (; ; ) {
796
- const marcas = [rutaEstado(actual), ...ENTORNOS_LLAVE.map((e) => rutaLlave(actual, e))];
797
- if (marcas.some((m) => fs2.existsSync(m))) return actual;
799
+ if (tieneInstalacionDelCli(actual)) return actual;
798
800
  const padre = path2.dirname(actual);
799
801
  if (padre === actual) return path2.resolve(desde);
800
802
  actual = padre;
@@ -1856,7 +1858,7 @@ async function init(ctx, opciones) {
1856
1858
  if (vacia && !lenguaje && terminal) {
1857
1859
  lenguaje = await preguntarLenguaje(ctx);
1858
1860
  if (lenguaje) exigirGenerador(lenguaje, ctx.env);
1859
- } else if (!vacia && terminal && opciones.carpeta === void 0) {
1861
+ } else if (!vacia && terminal && opciones.carpeta === void 0 && !tieneInstalacionDelCli(proyecto)) {
1860
1862
  const respuesta = await terminal.preguntar("\xBFD\xF3nde instalo la llave? [.]: ");
1861
1863
  proyecto = path9.resolve(ctx.cwd, respuesta || ".");
1862
1864
  }
@@ -2504,13 +2506,16 @@ function carpetaDeConfiguracion(env = process.env, plataforma = process.platform
2504
2506
  const base = env.XDG_CONFIG_HOME || path12.join(os3.homedir(), ".config");
2505
2507
  return path12.join(base, "redcumbre");
2506
2508
  }
2507
- function exigirFueraDelProyecto(carpeta, proyecto) {
2508
- const relativa = path12.relative(path12.resolve(proyecto), path12.resolve(carpeta));
2509
- if (!relativa.startsWith("..") && !path12.isAbsolute(relativa)) {
2510
- throw new ErrorCli(
2511
- `La carpeta de configuraci\xF3n (${carpeta}) est\xE1 dentro del proyecto: ah\xED no guardo tu sesi\xF3n. Corre el comando con XDG_CONFIG_HOME fuera del proyecto.`
2512
- );
2513
- }
2509
+ function estaDentro(base, ruta) {
2510
+ const relativa = path12.relative(path12.resolve(base), path12.resolve(ruta));
2511
+ return !relativa.startsWith("..") && !path12.isAbsolute(relativa);
2512
+ }
2513
+ function exigirFueraDelProyecto(carpeta, proyecto, personal = os3.homedir()) {
2514
+ if (!estaDentro(proyecto, carpeta)) return;
2515
+ if (estaDentro(proyecto, personal) && !tieneInstalacionDelCli(proyecto)) return;
2516
+ throw new ErrorCli(
2517
+ `La carpeta de configuraci\xF3n (${carpeta}) est\xE1 dentro del proyecto: ah\xED no guardo tu sesi\xF3n. Corre el comando con XDG_CONFIG_HOME fuera del proyecto.`
2518
+ );
2514
2519
  }
2515
2520
  var AlmacenArchivo = class {
2516
2521
  ruta;
@@ -3022,7 +3027,7 @@ async function correr(globales, accion) {
3022
3027
  const agente = esModoAgente(json2);
3023
3028
  const salida = crearSalida(agente);
3024
3029
  const terminal = agente ? null : crearTerminal(process.stdin, process.stdout);
3025
- const ctx = crearContexto({ salida, terminal, sinNavegador: Boolean(globales.sinNavegador), cwd: process.cwd(), env: process.env, version: "0.3.0" });
3030
+ const ctx = crearContexto({ salida, terminal, sinNavegador: Boolean(globales.sinNavegador), cwd: process.cwd(), env: process.env, version: "0.3.1" });
3026
3031
  try {
3027
3032
  if (!agente) {
3028
3033
  await avisarSiHayVersionNueva({ carpeta: ctx.carpetaConfiguracion, version: ctx.version, ahora: ctx.ahora(), humano: process.stderr, registro: process.env.REDCUMBRE_NPM_REGISTRY });
@@ -3035,7 +3040,7 @@ async function correr(globales, accion) {
3035
3040
  }
3036
3041
  }
3037
3042
  var sumar = (valor, anteriores) => [...anteriores, valor];
3038
- var programa = new Command().name("redcumbre").description("El CLI de REDCUMBRE: conecta tu proyecto en el modo de prueba, opera la API y pasa a real cuando est\xE9s listo.").version("0.3.0", "-v, --version", "muestra la versi\xF3n").helpOption("-h, --help", "muestra esta ayuda").helpCommand(false).usage("[opciones] [comando]").enablePositionalOptions().configureHelp({ styleTitle: (titulo) => TITULOS_AYUDA[titulo] ?? titulo, subcommandTerm: (comando2) => `${comando2.name()} ${comando2.usage()}`.trim() }).showHelpAfterError("(corre redcumbre --help para ver los comandos)").configureOutput({ outputError: (texto2, escribir2) => escribir2(`\u2717 ${errorDeUsoEnEspanol(texto2)}
3043
+ var programa = new Command().name("redcumbre").description("El CLI de REDCUMBRE: conecta tu proyecto en el modo de prueba, opera la API y pasa a real cuando est\xE9s listo.").version("0.3.1", "-v, --version", "muestra la versi\xF3n").helpOption("-h, --help", "muestra esta ayuda").helpCommand(false).usage("[opciones] [comando]").enablePositionalOptions().configureHelp({ styleTitle: (titulo) => TITULOS_AYUDA[titulo] ?? titulo, subcommandTerm: (comando2) => `${comando2.name()} ${comando2.usage()}`.trim() }).showHelpAfterError("(corre redcumbre --help para ver los comandos)").configureOutput({ outputError: (texto2, escribir2) => escribir2(`\u2717 ${errorDeUsoEnEspanol(texto2)}
3039
3044
  `) }).exitOverride((error) => {
3040
3045
  if (error.code === "commander.helpDisplayed" || error.code === "commander.version" || error.code === "commander.help") process.exit(0);
3041
3046
  if (process.argv.includes("--json")) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redcumbrecl/cli",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Conecta tu proyecto con rCAPI de REDCUMBRE: inicia sesión con tu cuenta e instala la llave de la API en el proyecto.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",