@nimbuslab/cli 0.2.2 → 0.2.5

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.
package/dist/index.js CHANGED
@@ -1000,7 +1000,7 @@ async function promptConfig(initialName) {
1000
1000
  let stagingUrl = "";
1001
1001
  let productionUrl = "";
1002
1002
  if (configureInfra) {
1003
- const currentYear = new Date().getFullYear().toString().slice(-2);
1003
+ const currentYear = new Date().getFullYear().toString().slice(-3);
1004
1004
  const defaultStagingUrl = type === "fast" ? `https://fast-${contractNumber}-${currentYear}.nimbuslab.net.br` : `https://${name}.nimbuslab.net.br`;
1005
1005
  const defaultFromEmail = "no-reply@nimbuslab.com.br";
1006
1006
  const defaultContactEmail = type === "fast" ? "fast@nimbuslab.com.br" : "suporte@nimbuslab.com.br";
@@ -1064,7 +1064,7 @@ async function promptConfig(initialName) {
1064
1064
  } else {
1065
1065
  const projectOptions = [
1066
1066
  ...projects.map((proj) => ({ value: proj, label: proj })),
1067
- { value: "__new__", label: "Criar novo projeto", hint: "Abrir railway.app/new" },
1067
+ { value: "__new__", label: "Criar novo projeto", hint: "via railway init" },
1068
1068
  { value: "__skip__", label: "Pular", hint: "Configurar depois" }
1069
1069
  ];
1070
1070
  const selectedProject = await ve({
@@ -1074,8 +1074,18 @@ async function promptConfig(initialName) {
1074
1074
  if (pD(selectedProject))
1075
1075
  return selectedProject;
1076
1076
  if (selectedProject === "__new__") {
1077
- console.log(import_picocolors3.default.yellow(" Crie o projeto em: https://railway.app/new"));
1078
- console.log(import_picocolors3.default.dim(" Configure RAILWAY_TOKEN depois no .env"));
1077
+ const projectNameForRailway = name;
1078
+ console.log(import_picocolors3.default.dim(` Criando projeto "${projectNameForRailway}" no Railway...`));
1079
+ try {
1080
+ const result = await $2`railway init -n ${projectNameForRailway} --json`.text();
1081
+ const newProject = JSON.parse(result);
1082
+ railwayProject = newProject.name || projectNameForRailway;
1083
+ console.log(import_picocolors3.default.green(` Projeto "${railwayProject}" criado com sucesso!`));
1084
+ console.log(import_picocolors3.default.dim(` ID: ${newProject.id || "N/A"}`));
1085
+ } catch (error) {
1086
+ console.log(import_picocolors3.default.yellow(" Erro ao criar projeto via CLI."));
1087
+ console.log(import_picocolors3.default.dim(" Crie manualmente em: https://railway.app/new"));
1088
+ }
1079
1089
  } else if (selectedProject !== "__skip__") {
1080
1090
  railwayProject = selectedProject;
1081
1091
  console.log(import_picocolors3.default.green(` Projeto selecionado: ${railwayProject}`));
@@ -1170,6 +1180,16 @@ async function createProject(config) {
1170
1180
  }
1171
1181
  }
1172
1182
  }
1183
+ if (config.railwayProject) {
1184
+ s.start(`Linkando Railway: ${config.railwayProject}...`);
1185
+ try {
1186
+ await $2`railway link -p ${config.railwayProject}`.cwd(config.name).quiet();
1187
+ s.stop(`Railway linkado: ${config.railwayProject}`);
1188
+ } catch (error) {
1189
+ s.stop("Erro ao linkar Railway");
1190
+ console.log(import_picocolors3.default.dim(" Execute manualmente: railway link"));
1191
+ }
1192
+ }
1173
1193
  if (config.resendApiKey || config.stagingUrl) {
1174
1194
  s.start("Gerando arquivo .env...");
1175
1195
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nimbuslab/cli",
3
- "version": "0.2.2",
3
+ "version": "0.2.5",
4
4
  "description": "CLI para criar projetos nimbuslab",
5
5
  "type": "module",
6
6
  "bin": {
@@ -298,7 +298,7 @@ async function promptConfig(initialName?: string): Promise<ProjectConfig | symbo
298
298
  let productionUrl = ""
299
299
 
300
300
  if (configureInfra) {
301
- const currentYear = new Date().getFullYear().toString().slice(-2) // 25, 26, etc
301
+ const currentYear = new Date().getFullYear().toString().slice(-3) // 025, 026, etc
302
302
 
303
303
  // M26: URLs padrão baseadas no tipo
304
304
  // fast: fast-{contrato}-{ano}.nimbuslab.net.br
@@ -386,7 +386,7 @@ async function promptConfig(initialName?: string): Promise<ProjectConfig | symbo
386
386
  // Fast+ pode escolher projeto existente ou criar novo
387
387
  const projectOptions = [
388
388
  ...projects.map(proj => ({ value: proj, label: proj })),
389
- { value: "__new__", label: "Criar novo projeto", hint: "Abrir railway.app/new" },
389
+ { value: "__new__", label: "Criar novo projeto", hint: "via railway init" },
390
390
  { value: "__skip__", label: "Pular", hint: "Configurar depois" },
391
391
  ]
392
392
 
@@ -398,8 +398,19 @@ async function promptConfig(initialName?: string): Promise<ProjectConfig | symbo
398
398
  if (p.isCancel(selectedProject)) return selectedProject
399
399
 
400
400
  if (selectedProject === "__new__") {
401
- console.log(pc.yellow(" Crie o projeto em: https://railway.app/new"))
402
- console.log(pc.dim(" Configure RAILWAY_TOKEN depois no .env"))
401
+ // Criar projeto via Railway CLI
402
+ const projectNameForRailway = name as string
403
+ console.log(pc.dim(` Criando projeto "${projectNameForRailway}" no Railway...`))
404
+ try {
405
+ const result = await $`railway init -n ${projectNameForRailway} --json`.text()
406
+ const newProject = JSON.parse(result)
407
+ railwayProject = newProject.name || projectNameForRailway
408
+ console.log(pc.green(` Projeto "${railwayProject}" criado com sucesso!`))
409
+ console.log(pc.dim(` ID: ${newProject.id || "N/A"}`))
410
+ } catch (error) {
411
+ console.log(pc.yellow(" Erro ao criar projeto via CLI."))
412
+ console.log(pc.dim(" Crie manualmente em: https://railway.app/new"))
413
+ }
403
414
  } else if (selectedProject !== "__skip__") {
404
415
  railwayProject = selectedProject as string
405
416
  console.log(pc.green(` Projeto selecionado: ${railwayProject}`))
@@ -523,6 +534,18 @@ async function createProject(config: ProjectConfig) {
523
534
  }
524
535
  }
525
536
 
537
+ // Railway link (se projeto foi selecionado/criado)
538
+ if (config.railwayProject) {
539
+ s.start(`Linkando Railway: ${config.railwayProject}...`)
540
+ try {
541
+ await $`railway link -p ${config.railwayProject}`.cwd(config.name).quiet()
542
+ s.stop(`Railway linkado: ${config.railwayProject}`)
543
+ } catch (error) {
544
+ s.stop("Erro ao linkar Railway")
545
+ console.log(pc.dim(" Execute manualmente: railway link"))
546
+ }
547
+ }
548
+
526
549
  // M23: Gerar .env se configs foram fornecidas
527
550
  if (config.resendApiKey || config.stagingUrl) {
528
551
  s.start("Gerando arquivo .env...")