create-domis 1.0.18 → 1.0.20

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/index.js +121 -57
  2. package/package.json +21 -7
package/dist/index.js CHANGED
@@ -2,72 +2,136 @@
2
2
 
3
3
 
4
4
  // src/index.ts
5
- import prompts from "prompts";
6
- import pc from "picocolors";
5
+ import inquirer from "inquirer";
6
+ import chalk from "chalk";
7
7
  import ora from "ora";
8
+ import { execSync } from "child_process";
8
9
  import fs from "fs";
9
10
  import path from "path";
10
- console.log(pc.bgMagenta(pc.black(" DOMIS CLI ")), pc.magenta("v0.1.0 - Acelere seu Angular + Firebase\n"));
11
- var args = process.argv.slice(2);
12
- if (args.includes("--help") || args.includes("-h")) {
13
- console.log(
14
- `USO: npx create-domis@latest [nome] --template [template] --key [PRO_KEY]
15
- TEMPLATES:
16
- domisdocs-firebase-lite
17
- domisdocs-firebase-pro
18
- EXEMPLOS:
19
- npx create-domis@latest meu-app
20
- npx create-domis@latest meu-app --template domisdocs-firebase-lite`
21
- );
22
- process.exit(0);
23
- }
24
- var hasTemplateArg = args.find((a) => a.includes("template"))?.split("=")[1] || args[args.indexOf("--template") + 1];
25
- var hasKeyArg = args.find((a) => a.includes("key"))?.split("=")[1] || args[args.indexOf("--key") + 1];
11
+ var API_VERIFY = "https://us-central1-domisdocs-602fc.cloudfunctions.net/verifyProKey";
12
+ var REPO_PRIVATE = "https://github.com/Domisnnet/DomisPacks-Technical.git";
13
+ console.log(chalk.green.bold("\n\u{1F525} DomisPacks Technical v1.0.20\n"));
26
14
  async function main() {
27
- let template = hasTemplateArg;
28
- let proKey = hasKeyArg;
29
- let projectName = "meu-app-domis";
30
- if (!template) {
31
- const res = await prompts([
32
- { type: "select", name: "template", message: "Qual pack?", choices: [
33
- { title: "\u{1F525} Domflix LITE", value: "domflix-firebase-lite" },
34
- { title: "\u{1F680} Domflix PRO", value: "domflix-firebase-pro" }
35
- ] },
36
- { type: (prev) => prev.includes("pro") ? "text" : null, name: "key", message: "Digite sua PRO_KEY:" },
37
- { type: "text", name: "projectName", message: "Nome do projeto?", initial: "meu-app-domis" }
38
- ]);
39
- template = res.template;
40
- proKey = res.key;
41
- projectName = res.projectName || "meu-app-domis";
42
- await scaffold(template, projectName, proKey);
43
- return;
44
- }
45
- const cliProjectName = args[args.length - 1]?.startsWith("--") ? "meu-app-domis" : args[args.length - 1] || "meu-app-domis";
46
- await scaffold(template, cliProjectName, proKey);
47
- }
48
- async function scaffold(template, projectName, proKey) {
49
- const spinner = ora(`Baixando ${pc.cyan(template)}...`).start();
15
+ const answers = await inquirer.prompt([
16
+ {
17
+ type: "select",
18
+ name: "pack",
19
+ message: "Qual pack voc\xEA quer acelerar hoje?",
20
+ choices: [
21
+ "\u{1F525} DomisDocs Lite \u2014 Next.js 15 + Tailwind v4 + Firebase Killer",
22
+ "\u{1F680} DomisDocs PRO \u2014 Completo"
23
+ ]
24
+ },
25
+ {
26
+ type: "password",
27
+ name: "proKey",
28
+ message: "Digite sua PRO_KEY (recebida por e-mail):",
29
+ mask: "*",
30
+ validate: (v) => {
31
+ return v.startsWith("DOMIS-") ? true : "Formato: DOMIS-XXXX-XXXX-XXXX";
32
+ },
33
+ filter: (v) => (v || "").trim()
34
+ },
35
+ {
36
+ type: "input",
37
+ name: "projectName",
38
+ message: "Nome do seu projeto:",
39
+ default: "meu-app",
40
+ validate: (v) => {
41
+ return v.trim().length > 0 ? true : "Digite um nome";
42
+ }
43
+ },
44
+ {
45
+ type: "confirm",
46
+ name: "autoSetup",
47
+ message: "\u2705 Quer instalar depend\xEAncias e iniciar agora?",
48
+ default: true
49
+ }
50
+ ]);
51
+ const spinner = ora("Verificando PRO_KEY no Firestore...").start();
52
+ let email = "";
50
53
  try {
51
- if (template.includes("pro") && (!proKey || proKey.length < 5)) {
52
- spinner.fail(pc.red("Precisa de PRO_KEY"));
54
+ const { default: fetch } = await import("node-fetch");
55
+ const res = await fetch(`${API_VERIFY}?key=${encodeURIComponent(answers.proKey)}`);
56
+ const data = await res.json();
57
+ if (!data.valid) {
58
+ spinner.fail(chalk.red(`\u274C PRO_KEY inv\xE1lida`));
59
+ console.log(chalk.yellow(`
60
+ \u{1F517} Verifique sua chave: https://domisdocs-602fc.web.app/verificar.html`));
61
+ console.log(chalk.gray(`Exemplo: DOMIS-XXXX-XXXX-XXXX`));
53
62
  process.exit(1);
54
63
  }
55
- const localTemplatePath = path.resolve(process.cwd(), "templates", template);
56
- const srcPath = localTemplatePath;
57
- if (fs.existsSync(srcPath)) {
58
- fs.cpSync(srcPath, path.resolve(process.cwd(), projectName), { recursive: true });
64
+ email = data.email || "";
65
+ spinner.succeed(chalk.green(`\u2714 PRO_KEY v\xE1lida${email ? ` \u2022 ${email}` : ""}`));
66
+ } catch (e) {
67
+ const msg = e instanceof Error ? e.message : String(e);
68
+ spinner.fail(chalk.red("Erro ao verificar: " + msg));
69
+ process.exit(1);
70
+ }
71
+ const templatePath = answers.pack.includes("Lite") ? "templates/domisdocs-firebase-lite" : "templates/domisdocs-firebase-pro";
72
+ const target = answers.projectName.trim();
73
+ console.log(chalk.cyan(`
74
+ \u{1F4E6} Baixando: ${answers.pack}`));
75
+ console.log(chalk.gray(`\u2192 Origem: ${templatePath}`));
76
+ console.log(chalk.gray(`\u2192 Destino: ./${target}`));
77
+ try {
78
+ if (fs.existsSync(target)) {
79
+ throw new Error(`Pasta "${target}" J\xC1 EXISTE! Escolha outro nome ou delete primeiro.`);
80
+ }
81
+ const tempDir = ".domis-temp";
82
+ if (fs.existsSync(tempDir)) {
83
+ fs.rmSync(tempDir, { recursive: true, force: true });
84
+ }
85
+ execSync(`git clone --depth 1 --branch main ${REPO_PRIVATE} "${tempDir}"`, { stdio: "inherit" });
86
+ const srcPath = path.join(process.cwd(), tempDir, templatePath);
87
+ const pkgPath = path.join(process.cwd(), tempDir, "packages", "package.json");
88
+ if (!fs.existsSync(srcPath)) {
89
+ throw new Error(`Template n\xE3o encontrado: ${templatePath}`);
90
+ }
91
+ if (!fs.existsSync(pkgPath)) {
92
+ throw new Error(`package.json protegido n\xE3o encontrado!`);
93
+ }
94
+ fs.cpSync(srcPath, target, { recursive: true });
95
+ fs.copyFileSync(pkgPath, path.join(target, "package.json"));
96
+ fs.rmSync(tempDir, { recursive: true, force: true });
97
+ console.log(chalk.green.bold(`
98
+ \u2705 ${target} criado com SUCESSO!`));
99
+ console.log(chalk.gray(`
100
+ \u2705 P\xE1gina inicial + Dashboard Premium inclusos!`));
101
+ console.log(chalk.gray(`\u2705 Next.js 15.3.6 (seguro) + Tailwind v4`));
102
+ console.log(chalk.gray(`\u2705 Firebase Killer pronto pra deploy \u2705`));
103
+ if (answers.autoSetup) {
104
+ console.log(chalk.cyan(`
105
+ \u{1F4E6} Instalando depend\xEAncias...`));
106
+ execSync(`cd ${target} && npm install`, { stdio: "inherit" });
107
+ console.log(chalk.cyan(`
108
+ \u{1F680} Iniciando servidor em http://localhost:3000`));
109
+ console.log(chalk.gray(` Pressione Ctrl + C para parar
110
+ `));
111
+ execSync(`cd ${target} && npm run dev`, { stdio: "inherit" });
59
112
  } else {
60
- fs.mkdirSync(projectName, { recursive: true });
61
- fs.writeFileSync(path.join(projectName, "firebase.json"), JSON.stringify({ hosting: { public: "dist/seu-projeto/browser", rewrites: [{ source: "**", destination: "/index.html" }] } }, null, 2));
113
+ console.log(chalk.cyan(`
114
+ \u{1F449} Pr\xF3ximos passos:`));
115
+ console.log(chalk.white(`cd ${target}`));
116
+ console.log(chalk.white(`npm install`));
117
+ console.log(chalk.white(`npm run dev`));
62
118
  }
63
- spinner.succeed(pc.green(`Template ${template} em./${projectName}`));
64
- console.log(`
65
- cd ${projectName}
66
- npm install
67
- firebase deploy`);
119
+ console.log(chalk.gray(`
120
+ Suporte: https://domisdocs-602fc.web.app/`));
68
121
  } catch (e) {
69
- spinner.fail(pc.red("Falha"));
70
- console.error(e.message);
122
+ const msg = e instanceof Error ? e.message : String(e);
123
+ console.log(chalk.red(`
124
+ \u274C Erro: ${msg}`));
125
+ if (msg.includes("J\xC1 EXISTE")) {
126
+ console.log(chalk.yellow(`\u{1F4A1} Dica: Delete a pasta "${target}" ou use outro nome.`));
127
+ } else {
128
+ console.log(chalk.yellow(`
129
+ Verifique: 1) Acesso \xE0 repo privada 2) Estrutura templates/ 3) packages/package.json`));
130
+ }
131
+ process.exit(1);
71
132
  }
72
133
  }
73
- main();
134
+ main().catch((err) => {
135
+ console.error(err);
136
+ process.exit(1);
137
+ });
package/package.json CHANGED
@@ -1,30 +1,44 @@
1
1
  {
2
2
  "name": "create-domis",
3
- "version": "1.0.18",
3
+ "version": "1.0.20",
4
4
  "description": "CLI Oficial do ecossistema Domis - Acelere seus projetos Angular + Firebase",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "create-domis": "./dist/index.js"
8
8
  },
9
- "files": ["dist"],
9
+ "files": [
10
+ "dist"
11
+ ],
10
12
  "scripts": {
11
13
  "build": "tsup",
12
14
  "dev": "tsx src/index.ts",
13
15
  "prepublishOnly": "npm run build"
14
16
  },
15
- "keywords": ["angular", "firebase", "domis", "create", "cli", "vitepress"],
17
+ "keywords": [
18
+ "angular",
19
+ "firebase",
20
+ "domis",
21
+ "create",
22
+ "cli",
23
+ "vitepress"
24
+ ],
16
25
  "author": "Domisnnet",
17
26
  "license": "LICENSE",
18
27
  "dependencies": {
19
- "prompts": "^2.4.2",
28
+ "chalk": "^6.0.0",
29
+ "inquirer": "^14.2.1",
30
+ "node-fetch": "^3.3.2",
31
+ "ora": "^7.0.1",
20
32
  "picocolors": "^1.0.1",
21
- "ora": "^7.0.1"
33
+ "prompts": "^2.4.2"
22
34
  },
23
35
  "devDependencies": {
24
- "@types/node": "^22.13.5",
36
+ "@types/inquirer": "^9.0.10",
37
+ "@types/node": "^22.20.1",
38
+ "@types/node-fetch": "^2.6.13",
25
39
  "@types/prompts": "^2.4.9",
26
40
  "tsup": "^8.5.1",
27
41
  "tsx": "^4.7.0",
28
42
  "typescript": "^5.9.3"
29
43
  }
30
- }
44
+ }