adminforth 2.22.0-next.16 → 2.22.0-next.18
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.
|
@@ -13,6 +13,9 @@ import Handlebars from 'handlebars';
|
|
|
13
13
|
import { promisify } from 'util';
|
|
14
14
|
import { getVersion } from '../cli.js';
|
|
15
15
|
|
|
16
|
+
import { URL } from 'url'
|
|
17
|
+
import net from 'net'
|
|
18
|
+
|
|
16
19
|
const execAsync = promisify(exec);
|
|
17
20
|
|
|
18
21
|
function detectAdminforthVersion() {
|
|
@@ -159,6 +162,44 @@ function checkForExistingPackageJson(options) {
|
|
|
159
162
|
}
|
|
160
163
|
}
|
|
161
164
|
|
|
165
|
+
function checkIfDatabaseLocal(urlString) {
|
|
166
|
+
if (urlString.startsWith('sqlite')) {
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
try {
|
|
170
|
+
const url = new URL(urlString)
|
|
171
|
+
|
|
172
|
+
const host = url.hostname
|
|
173
|
+
|
|
174
|
+
if (!host) return false
|
|
175
|
+
|
|
176
|
+
// localhost
|
|
177
|
+
if (host === 'localhost') return true
|
|
178
|
+
|
|
179
|
+
// loopback ipv4
|
|
180
|
+
if (host === '127.0.0.1') return true
|
|
181
|
+
|
|
182
|
+
// loopback ipv6
|
|
183
|
+
if (host === '::1') return true
|
|
184
|
+
|
|
185
|
+
// private IP ranges
|
|
186
|
+
if (net.isIP(host)) {
|
|
187
|
+
if (
|
|
188
|
+
host.startsWith('10.') ||
|
|
189
|
+
host.startsWith('192.168.') ||
|
|
190
|
+
host.match(/^172\.(1[6-9]|2\d|3[0-1])\./)
|
|
191
|
+
) {
|
|
192
|
+
return true
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
return false
|
|
198
|
+
} catch {
|
|
199
|
+
return false
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
162
203
|
async function scaffoldProject(ctx, options, cwd) {
|
|
163
204
|
const projectDir = path.join(cwd, options.appName);
|
|
164
205
|
await fse.ensureDir(projectDir);
|
|
@@ -253,7 +294,7 @@ async function writeTemplateFiles(dirname, cwd, options) {
|
|
|
253
294
|
{
|
|
254
295
|
src: '.env.local.hbs',
|
|
255
296
|
dest: '.env.local',
|
|
256
|
-
data: { dbUrl, prismaDbUrl },
|
|
297
|
+
data: { dbUrl: checkIfDatabaseLocal(dbUrl) ? dbUrl : null, prismaDbUrl },
|
|
257
298
|
},
|
|
258
299
|
{
|
|
259
300
|
src: '.env.prod.hbs',
|
|
@@ -269,8 +310,7 @@ async function writeTemplateFiles(dirname, cwd, options) {
|
|
|
269
310
|
// We'll write .env using the same content as .env.sample
|
|
270
311
|
src: '.env.local.hbs',
|
|
271
312
|
dest: '.env',
|
|
272
|
-
data: {},
|
|
273
|
-
empty: true,
|
|
313
|
+
data: {dbUrl, prismaDbUrl},
|
|
274
314
|
},
|
|
275
315
|
{
|
|
276
316
|
src: 'adminuser.ts.hbs',
|
|
@@ -23,4 +23,11 @@ export interface CompletionAdapter {
|
|
|
23
23
|
finishReason?: string;
|
|
24
24
|
error?: string;
|
|
25
25
|
}>;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* This method should return the number of tokens in the input content.
|
|
29
|
+
* @param content - The input text for which to measure the token count
|
|
30
|
+
* @returns The number of tokens in the input content
|
|
31
|
+
*/
|
|
32
|
+
measureTokensCount(content: string): Promise<number> | number;
|
|
26
33
|
}
|
|
@@ -16,5 +16,11 @@ export interface CompletionAdapter {
|
|
|
16
16
|
finishReason?: string;
|
|
17
17
|
error?: string;
|
|
18
18
|
}>;
|
|
19
|
+
/**
|
|
20
|
+
* This method should return the number of tokens in the input content.
|
|
21
|
+
* @param content - The input text for which to measure the token count
|
|
22
|
+
* @returns The number of tokens in the input content
|
|
23
|
+
*/
|
|
24
|
+
measureTokensCount(content: string): Promise<number> | number;
|
|
19
25
|
}
|
|
20
26
|
//# sourceMappingURL=CompletionAdapter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompletionAdapter.d.ts","sourceRoot":"","sources":["../../../types/adapters/CompletionAdapter.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAEhC;;;OAGG;IACH,QAAQ,IAAI,IAAI,CAAC;IAEjB;;;;;;OAMG;IACH,QAAQ,CACN,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,SAAS,EAAE,MAAM,EACjB,YAAY,CAAC,EAAE,GAAG,GACjB,OAAO,CAAC;QACT,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"CompletionAdapter.d.ts","sourceRoot":"","sources":["../../../types/adapters/CompletionAdapter.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAEhC;;;OAGG;IACH,QAAQ,IAAI,IAAI,CAAC;IAEjB;;;;;;OAMG;IACH,QAAQ,CACN,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,SAAS,EAAE,MAAM,EACjB,YAAY,CAAC,EAAE,GAAG,GACjB,OAAO,CAAC;QACT,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC,CAAC;IAEH;;;;OAIG;IACH,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;CAC/D"}
|