@promakeai/cli 0.9.4 → 0.9.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promakeai/cli",
3
- "version": "0.9.4",
3
+ "version": "0.9.6",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "promake": "dist/index.js"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@promakeai/template",
3
3
  "private": true,
4
- "version": "0.3.0",
4
+ "version": "0.3.1",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",
@@ -62,11 +62,10 @@
62
62
  "linkedin": ""
63
63
  },
64
64
  "database": {
65
- "adapter": "sqlite",
66
- "apiEndpoint": "/database"
65
+ "adapter": "rest"
67
66
  },
68
- "file":{
67
+ "file": {
69
68
  "maxFiles": 5,
70
69
  "accept": ".pdf,.doc,.docx,.jpg,.jpeg,.png"
71
70
  }
72
- }
71
+ }
@@ -1,14 +1,9 @@
1
- import { useEffect, useState, type ReactNode } from "react";
2
- import { useTranslation } from "react-i18next";
3
- import {
4
- DbProvider,
5
- SqliteAdapter,
6
- RestAdapter,
7
- parseJSONSchema,
8
- } from "@promakeai/dbreact";
9
- import type { IDataAdapter } from "@promakeai/dbreact";
10
- import constants from "@/constants/constants.json";
11
- import schemaJson from "./schema.json";
1
+ import { useEffect, useState, type ReactNode } from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import { DbProvider, SqliteAdapter, RestAdapter, parseJSONSchema } from '@promakeai/dbreact';
4
+ import type { IDataAdapter } from '@promakeai/dbreact';
5
+ import constants from '@/constants/constants.json';
6
+ import schemaJson from './schema.json';
12
7
 
13
8
  const schema = parseJSONSchema(schemaJson as any);
14
9
 
@@ -16,9 +11,8 @@ interface AppDbProviderProps {
16
11
  children: ReactNode;
17
12
  }
18
13
 
19
- const DEFAULT_LANG = constants?.site?.defaultLanguage || "en";
14
+ const DEFAULT_LANG = constants?.site?.defaultLanguage || 'en';
20
15
  const DB_CONFIG = (constants as any)?.database;
21
- const API_BASE_URL = (constants as any)?.api?.baseUrl;
22
16
 
23
17
  /**
24
18
  * Read auth token from localStorage (where auth-core's Zustand store persists).
@@ -26,7 +20,7 @@ const API_BASE_URL = (constants as any)?.api?.baseUrl;
26
20
  */
27
21
  function getAuthToken(): string | null {
28
22
  try {
29
- const raw = localStorage.getItem("auth-storage");
23
+ const raw = localStorage.getItem('auth-storage');
30
24
  if (!raw) return null;
31
25
  const parsed = JSON.parse(raw);
32
26
  return parsed?.state?.tokens?.accessToken ?? null;
@@ -45,11 +39,11 @@ export function AppDbProvider({ children }: AppDbProviderProps) {
45
39
 
46
40
  async function loadDb() {
47
41
  try {
48
- if (DB_CONFIG?.adapter === "rest") {
42
+ if (DB_CONFIG?.adapter === 'rest') {
49
43
  // REST API mode
50
44
  const restAdapter = new RestAdapter({
51
- baseUrl: API_BASE_URL || "",
52
- databasePrefix: DB_CONFIG?.apiEndpoint || "/database",
45
+ baseUrl: 'https://' + import.meta.env.VITE_TENANT_UUID + '.backend.promake.ai',
46
+ databasePrefix: '/database',
53
47
  schema,
54
48
  defaultLang: DEFAULT_LANG,
55
49
  getToken: getAuthToken,
@@ -60,11 +54,9 @@ export function AppDbProvider({ children }: AppDbProviderProps) {
60
54
  }
61
55
  } else {
62
56
  // SQLite mode (default)
63
- const response = await fetch("/data/database.db");
57
+ const response = await fetch('/data/database.db');
64
58
  if (!response.ok) {
65
- throw new Error(
66
- `Failed to load database: ${response.status} ${response.statusText}`
67
- );
59
+ throw new Error(`Failed to load database: ${response.status} ${response.statusText}`);
68
60
  }
69
61
 
70
62
  const buffer = await response.arrayBuffer();
@@ -73,7 +65,7 @@ export function AppDbProvider({ children }: AppDbProviderProps) {
73
65
  const dbAdapter = new SqliteAdapter({
74
66
  schema,
75
67
  defaultLang: DEFAULT_LANG,
76
- wasmPath: "/sql-wasm.wasm",
68
+ wasmPath: '/sql-wasm.wasm',
77
69
  });
78
70
 
79
71
  await dbAdapter.connect();
@@ -106,11 +98,7 @@ export function AppDbProvider({ children }: AppDbProviderProps) {
106
98
  }
107
99
 
108
100
  return (
109
- <DbProvider
110
- adapter={adapter}
111
- lang={i18n?.language || DEFAULT_LANG}
112
- fallbackLang={DEFAULT_LANG}
113
- >
101
+ <DbProvider adapter={adapter} lang={i18n?.language || DEFAULT_LANG} fallbackLang={DEFAULT_LANG}>
114
102
  {children}
115
103
  </DbProvider>
116
104
  );
@@ -1,6 +1,9 @@
1
1
  {
2
2
  "name": "promake",
3
- "languages": ["en", "tr"],
3
+ "languages": [
4
+ "en",
5
+ "tr"
6
+ ],
4
7
  "defaultLanguage": "en",
5
8
  "tables": {
6
9
  "blog_categories": {
@@ -68,7 +71,9 @@
68
71
  "type": "text"
69
72
  },
70
73
  "images": {
71
- "type": ["string"]
74
+ "type": [
75
+ "string"
76
+ ]
72
77
  },
73
78
  "author": {
74
79
  "type": "string",
@@ -87,10 +92,14 @@
87
92
  "type": "timestamp"
88
93
  },
89
94
  "tags": {
90
- "type": ["string"]
95
+ "type": [
96
+ "string"
97
+ ]
91
98
  },
92
99
  "categories": {
93
- "type": ["number"],
100
+ "type": [
101
+ "number"
102
+ ],
94
103
  "ref": "blog_categories"
95
104
  },
96
105
  "read_time": {
@@ -117,6 +126,154 @@
117
126
  "type": "text",
118
127
  "translatable": true
119
128
  }
129
+ },
130
+ "product_categories": {
131
+ "$permissions": {
132
+ "anon": ["read"],
133
+ "user": ["read"],
134
+ "admin": ["read", "create", "update", "delete"]
135
+ },
136
+ "id": {
137
+ "type": "id"
138
+ },
139
+ "name": {
140
+ "type": "string",
141
+ "nullable": false,
142
+ "translatable": true
143
+ },
144
+ "slug": {
145
+ "type": "string",
146
+ "nullable": false,
147
+ "unique": true
148
+ },
149
+ "description": {
150
+ "type": "text",
151
+ "translatable": true
152
+ },
153
+ "image": {
154
+ "type": "text"
155
+ },
156
+ "parent_id": {
157
+ "type": "int",
158
+ "ref": "product_categories"
159
+ },
160
+ "created_at": {
161
+ "type": "timestamp"
162
+ },
163
+ "updated_at": {
164
+ "type": "timestamp"
165
+ }
166
+ },
167
+ "products": {
168
+ "$permissions": {
169
+ "anon": ["read"],
170
+ "user": ["read"],
171
+ "admin": ["read", "create", "update", "delete"]
172
+ },
173
+ "id": {
174
+ "type": "id"
175
+ },
176
+ "name": {
177
+ "type": "string",
178
+ "nullable": false,
179
+ "translatable": true
180
+ },
181
+ "slug": {
182
+ "type": "string",
183
+ "nullable": false,
184
+ "unique": true
185
+ },
186
+ "description": {
187
+ "type": "text",
188
+ "translatable": true
189
+ },
190
+ "price": {
191
+ "type": "decimal",
192
+ "nullable": false
193
+ },
194
+ "sale_price": {
195
+ "type": "decimal"
196
+ },
197
+ "on_sale": {
198
+ "type": "bool",
199
+ "default": false
200
+ },
201
+ "images": {
202
+ "type": [
203
+ "string"
204
+ ]
205
+ },
206
+ "brand": {
207
+ "type": "string",
208
+ "translatable": true
209
+ },
210
+ "sku": {
211
+ "type": "string"
212
+ },
213
+ "stock": {
214
+ "type": "int",
215
+ "default": 0
216
+ },
217
+ "tags": {
218
+ "type": [
219
+ "string"
220
+ ]
221
+ },
222
+ "categories": {
223
+ "type": [
224
+ "number"
225
+ ],
226
+ "ref": "product_categories"
227
+ },
228
+ "rating": {
229
+ "type": "decimal",
230
+ "default": 0
231
+ },
232
+ "review_count": {
233
+ "type": "int",
234
+ "default": 0
235
+ },
236
+ "featured": {
237
+ "type": "bool",
238
+ "default": false
239
+ },
240
+ "is_new": {
241
+ "type": "bool",
242
+ "default": false
243
+ },
244
+ "published": {
245
+ "type": "bool",
246
+ "default": true
247
+ },
248
+ "specifications": {
249
+ "type": "json"
250
+ },
251
+ "variants": {
252
+ "type": [
253
+ {
254
+ "id": "string",
255
+ "name": "string",
256
+ "value": "string",
257
+ "price?": "number",
258
+ "image?": "string",
259
+ "stockQuantity": "number"
260
+ }
261
+ ]
262
+ },
263
+ "created_at": {
264
+ "type": "timestamp"
265
+ },
266
+ "updated_at": {
267
+ "type": "timestamp"
268
+ },
269
+ "meta_description": {
270
+ "type": "text",
271
+ "translatable": true
272
+ },
273
+ "meta_keywords": {
274
+ "type": "text",
275
+ "translatable": true
276
+ }
120
277
  }
121
278
  }
122
- }
279
+ }
@@ -1,3 +1,5 @@
1
+ import fs from "fs";
2
+ import { createRequire } from "module";
1
3
  import path from "path";
2
4
  import { execSync } from "child_process";
3
5
  import tailwindcss from "@tailwindcss/vite";
@@ -100,6 +102,52 @@ function promakeApiPlugin(secret?: string): Plugin {
100
102
  };
101
103
  }
102
104
 
105
+ // Plugin: Write installed package versions to src/constants/versions.json on dev server start
106
+ function packageVersionsPlugin(): Plugin {
107
+ return {
108
+ name: "package-versions",
109
+ configureServer() {
110
+ const root = process.cwd();
111
+ const pkgJsonPath = path.join(root, "package.json");
112
+
113
+ if (!fs.existsSync(pkgJsonPath)) return;
114
+
115
+ const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"));
116
+
117
+ const require = createRequire(pkgJsonPath);
118
+
119
+ const resolveVersions = (deps: Record<string, string> | undefined): Record<string, string> => {
120
+ if (!deps) return {};
121
+ const resolved: Record<string, string> = {};
122
+ for (const name of Object.keys(deps)) {
123
+ if (!name.startsWith("@promakeai/")) continue;
124
+ try {
125
+ const depPkgPath = require.resolve(`${name}/package.json`);
126
+ const depPkg = JSON.parse(fs.readFileSync(depPkgPath, "utf-8"));
127
+ resolved[name] = depPkg.version;
128
+ } catch {
129
+ resolved[name] = deps[name];
130
+ }
131
+ }
132
+ return resolved;
133
+ };
134
+
135
+ const versions = {
136
+ generatedAt: new Date().toISOString(),
137
+ packages: {
138
+ ...resolveVersions(pkgJson.dependencies),
139
+ ...resolveVersions(pkgJson.devDependencies),
140
+ },
141
+ };
142
+
143
+ const outPath = path.join(root, "src", "constants", "versions.json");
144
+ fs.mkdirSync(path.dirname(outPath), { recursive: true });
145
+ fs.writeFileSync(outPath, JSON.stringify(versions, null, 2) + "\n");
146
+ console.log(`📦 Package versions written to src/constants/versions.json`);
147
+ },
148
+ };
149
+ }
150
+
103
151
  // https://vite.dev/config/
104
152
  export default defineConfig(({ mode }) => {
105
153
  const env = loadEnv(mode, process.cwd(), "PROMAKE_");
@@ -112,6 +160,7 @@ export default defineConfig(({ mode }) => {
112
160
  tailwindcss(),
113
161
  mode === "development" && langWatchPlugin(),
114
162
  mode === "development" && promakeApiPlugin(env.PROMAKE_SECRET),
163
+ mode === "development" && packageVersionsPlugin(),
115
164
  ].filter(Boolean),
116
165
  resolve: {
117
166
  alias: {