create-domis 1.0.28 → 1.0.29

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 (3) hide show
  1. package/README.md +1 -1
  2. package/dist/index.js +59 -40
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
  ![Status](https://img.shields.io/badge/Status-Online-brightgreen?style=flat-square)
10
10
  ![CLI](https://img.shields.io/badge/CLI-Oficial-26FF00?style=flat-square)
11
11
  ![Firebase](https://img.shields.io/badge/Firebase-Ready-FFCA28?style=flat-square&logo=firebase&logoColor=black)
12
- [![License](https://img.shields.io/badge/License-Private_Commercial_v1.2-red?style=flat-square)](https://github.com/Domisnnet/DomisPacks-Technical/blob/main/LICENSE)
12
+ [![License](https://img.shields.io/badge/License-Private_Commercial_v1.3-red?style=flat-square)](https://github.com/Domisnnet/DomisPacks-Technical/blob/main/LICENSE)
13
13
  ![Imagem DomisPacks](./src/assets/domispacks.png)
14
14
 
15
15
  Bem-vindo ao **CLI Oficial Domis**. O  `npm create domis@latest` é um acelerador de projetos que elimina 3 horas de configuração de `firebase.json`,  `firestore.rules` e  `GitHub Actions` com 1 comando. Resolvemos o bug de Hosting que quebra 90% dos deploys Next.js 15 no Firebase.
package/dist/index.js CHANGED
@@ -7,8 +7,21 @@ import ora from "ora";
7
7
  import { execSync } from "child_process";
8
8
  import fs from "fs";
9
9
  import path from "path";
10
+ import os from "os";
10
11
  var API_VERIFY = "https://verifyprokey-rk2ogbbeja-uc.a.run.app";
11
- console.log(chalk.green.bold("\n\u{1F525} DomisPacks Technical v1.0.28\n"));
12
+ console.log(chalk.green.bold("\n\u{1F525} DomisPacks Technical v1.0.29\n"));
13
+ function copyRecursive(src, dest) {
14
+ const stat = fs.lstatSync(src);
15
+ if (stat.isDirectory()) {
16
+ fs.mkdirSync(dest, { recursive: true });
17
+ for (const file of fs.readdirSync(src)) {
18
+ if (file === "node_modules" || file === ".next" || file === ".git") continue;
19
+ copyRecursive(path.join(src, file), path.join(dest, file));
20
+ }
21
+ } else {
22
+ fs.copyFileSync(src, dest);
23
+ }
24
+ }
12
25
  async function main() {
13
26
  const answers = await inquirer.prompt([
14
27
  {
@@ -43,69 +56,75 @@ async function main() {
43
56
  try {
44
57
  if (fs.existsSync(target)) throw new Error(`Pasta "${target}" J\xC1 EXISTE!`);
45
58
  fs.mkdirSync(target, { recursive: true });
46
- const legacyDemoPath = "C:/Users/dell/Documents/GitHub/DomisDoc-Legacy-Thecnical/templates/domisdocs-free";
47
- if (fs.existsSync(legacyDemoPath)) {
48
- const files = fs.readdirSync(legacyDemoPath);
49
- for (const file of files) {
50
- if (file === "node_modules" || file === ".next") continue;
51
- fs.copyFileSync(path.join(legacyDemoPath, file), path.join(target, file));
52
- }
53
- spinner2.text = "Copiado do template local atualizado";
59
+ const legacyDemoPath = path.join(process.cwd(), "..", "DomisDoc-Legacy-Thecnical", "templates", "domisdocs-free");
60
+ const localDemoPath = "C:[STRIPPED 79 bytes]";
61
+ const finalDemoPath = fs.existsSync(localDemoPath) ? localDemoPath : fs.existsSync(legacyDemoPath) ? legacyDemoPath : "";
62
+ if (finalDemoPath) {
63
+ copyRecursive(finalDemoPath, target);
64
+ spinner2.text = "Copiado do template local";
54
65
  } else {
55
- fs.writeFileSync(path.join(target, "firebase.json"), JSON.stringify({
56
- hosting: {
57
- public: "dist",
58
- ignore: ["firebase.json", "**/.*", "**/node_modules/**"],
59
- rewrites: [{ source: "**", destination: "/index.html" }]
60
- }
61
- }, null, 2));
62
- fs.writeFileSync(path.join(target, ".firebaserc"), JSON.stringify({
63
- projects: { default: "free" }
64
- }, null, 2));
65
- fs.writeFileSync(path.join(target, "package.json"), JSON.stringify({
66
- name: target,
67
- version: "1.0.0",
68
- private: true,
69
- scripts: { dev: "vite", build: "vite build" }
70
- }, null, 2));
66
+ fs.writeFileSync(path.join(target, "firebase.json"), JSON.stringify({ hosting: { public: "dist", ignore: ["firebase.json", "**/.*", "**/node_modules/**"], rewrites: [{ source: "**", destination: "/index.html" }] } }, null, 2));
67
+ fs.writeFileSync(path.join(target, ".firebaserc"), JSON.stringify({ projects: { default: "free" } }, null, 2));
68
+ fs.writeFileSync(path.join(target, "package.json"), JSON.stringify({ name: target, version: "1.0.0", private: true, scripts: { dev: "vite", build: "vite build" } }, null, 2));
71
69
  fs.writeFileSync(path.join(target, "README.md"), `DomisDocs Free`);
72
70
  }
73
71
  spinner2.succeed(chalk.green.bold(`
74
72
  \u2705 ${target} DomisDocs Free criada!`));
75
73
  console.log(chalk.cyan(`
76
- DomisDocs: https://domisdocs-6a896.web.app`));
77
- console.log(chalk.gray("Esse pack \xE9 gr\xE1tis e p\xFAblico, sem necessidade de PRO_KEY."));
78
- console.log(chalk.cyan(`
79
74
  \u{1F449} cd ${target}`));
80
- const created = fs.readdirSync(target);
81
- console.log(chalk.gray(`\u{1F449} Arquivos: ${created.join(" + ")}`));
82
75
  } catch (e) {
83
76
  const msg = e instanceof Error ? e.message : String(e);
84
- spinner2.fail(chalk.red(`\u274C Erro DEMO: ${msg}`));
77
+ ora().fail(chalk.red(`\u274C Erro DEMO: ${msg}`));
85
78
  process.exit(1);
86
79
  }
87
80
  return;
88
81
  }
89
- const spinner = ora("Verificando PRO_KEY no cofre Legacy...").start();
82
+ const spinner = ora("Verificando PRO_KEY...").start();
90
83
  try {
91
84
  const url = `${API_VERIFY}?key=${encodeURIComponent(answers.proKey)}&pack=${answers.pack}`;
92
85
  const res = await fetch(url);
93
86
  const data = await res.json();
94
- if (!data.valid || !data.downloadUrl) {
95
- spinner.fail(chalk.red(`\u274C ${data.error || "PRO_KEY inv\xE1lida"}`));
96
- console.log(chalk.yellow(`Verifique em https://domisdocs-6a896.web.app/verificar.html`));
87
+ if (!data.valid) {
88
+ const reasonMsg = data.reason === "upgrade_required" ? "Plano LITE n\xE3o pode baixar PRO. Fa\xE7a upgrade." : data.reason === "not_found" ? "PRO_KEY n\xE3o encontrada" : data.error || "PRO_KEY inv\xE1lida";
89
+ spinner.fail(chalk.red(`\u274C ${reasonMsg}`));
90
+ console.log(chalk.yellow(`Verifique em https://domispacks.web.app/validar.html`));
91
+ process.exit(1);
92
+ }
93
+ if (!data.downloadUrl) {
94
+ spinner.fail(chalk.red(`\u274C API sem downloadUrl - atualize a Function`));
97
95
  process.exit(1);
98
96
  }
99
- spinner.text = `Baixando ${answers.pack.toUpperCase()} do cofre...`;
97
+ spinner.text = `Baixando ${answers.pack.toUpperCase()} do cofre (${data.repo})...`;
100
98
  if (fs.existsSync(target)) throw new Error(`Pasta "${target}" J\xC1 EXISTE!`);
101
- const zipTmp = `C:/Users/dell/AppData/Local/Temp/domis-${Date.now()}.zip`;
102
- execSync(`curl -L -o "${zipTmp}" "${data.downloadUrl}"`, { stdio: "inherit" });
99
+ const localLegacyPath = `C:[STRIPPED 75 bytes]${answers.pack}`;
100
+ if (fs.existsSync(localLegacyPath)) {
101
+ fs.mkdirSync(target, { recursive: true });
102
+ copyRecursive(localLegacyPath, target);
103
+ spinner.succeed(chalk.green.bold(`
104
+ \u2705 ${target} criado com SUCESSO! (local)`));
105
+ console.log(chalk.gray(`Origem: templates/domisdocs-${answers.pack}`));
106
+ console.log(chalk.cyan(`
107
+ \u{1F449} cd ${target}
108
+ npm install
109
+ npm run dev`));
110
+ return;
111
+ }
112
+ const zipTmp = path.join(os.tmpdir(), `domis-${Date.now()}.zip`);
113
+ const githubToken = process.env.GITHUB_TOKEN || "";
114
+ const curlCmd = githubToken ? `curl -L -H "Authorization: token ${githubToken}" -o "${zipTmp}" "${data.downloadUrl}"` : `curl -L -o "${zipTmp}" "${data.downloadUrl}"`;
115
+ execSync(curlCmd, { stdio: "inherit" });
103
116
  fs.mkdirSync(target, { recursive: true });
104
- execSync(`powershell -Command "Expand-Archive -Path '${zipTmp}' -DestinationPath '${target}' -Force"`, { stdio: "inherit" });
117
+ const extractTmp = path.join(os.tmpdir(), `domis-extract-${Date.now()}`);
118
+ fs.mkdirSync(extractTmp, { recursive: true });
119
+ execSync(`powershell -Command "Expand-Archive -Path '${zipTmp}' -DestinationPath '${extractTmp}' -Force"`, { stdio: "inherit" });
120
+ const subfolders = fs.readdirSync(extractTmp).filter((f) => fs.lstatSync(path.join(extractTmp, f)).isDirectory());
121
+ const sourceRoot = subfolders.length === 1 ? path.join(extractTmp, subfolders[0]) : extractTmp;
122
+ copyRecursive(sourceRoot, target);
105
123
  fs.rmSync(zipTmp, { force: true });
124
+ fs.rmSync(extractTmp, { recursive: true, force: true });
106
125
  spinner.succeed(chalk.green.bold(`
107
126
  \u2705 ${target} criado com SUCESSO!`));
108
- console.log(chalk.gray(`Origem: DomisDocs-Legacy-Technical/templates/domisdocs-firebase-${answers.pack}`));
127
+ console.log(chalk.gray(`Origem: ${data.repo}`));
109
128
  console.log(chalk.cyan(`
110
129
  \u{1F449} cd ${target}
111
130
  npm install
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-domis",
3
- "version": "1.0.28",
3
+ "version": "1.0.29",
4
4
  "description": "CLI Oficial DomisPacks - Acelerador Next.js 15 + Tailwind v4 + Firebase Killer + Stripe",
5
5
  "type": "module",
6
6
  "bin": {