@hatk/hatk 0.0.1-alpha.19 → 0.0.1-alpha.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.
- package/dist/backfill.d.ts +1 -1
- package/dist/backfill.d.ts.map +1 -1
- package/dist/cli.js +17 -13
- package/dist/config.d.ts +3 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +33 -7
- package/dist/main.js +2 -2
- package/dist/test.js +4 -4
- package/dist/vite-plugin.js +1 -1
- package/package.json +2 -1
package/dist/backfill.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ interface BackfillOpts {
|
|
|
7
7
|
plcUrl: string;
|
|
8
8
|
/** AT Protocol collection NSIDs to index (e.g. `app.bsky.feed.post`). */
|
|
9
9
|
collections: Set<string>;
|
|
10
|
-
/** Backfill behavior settings from `config.
|
|
10
|
+
/** Backfill behavior settings from `hatk.config.ts`. */
|
|
11
11
|
config: BackfillConfig;
|
|
12
12
|
}
|
|
13
13
|
/**
|
package/dist/backfill.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backfill.d.ts","sourceRoot":"","sources":["../src/backfill.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjD,6CAA6C;AAC7C,UAAU,YAAY;IACpB,wFAAwF;IACxF,MAAM,EAAE,MAAM,CAAA;IACd,8FAA8F;IAC9F,MAAM,EAAE,MAAM,CAAA;IACd,yEAAyE;IACzE,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IACxB,
|
|
1
|
+
{"version":3,"file":"backfill.d.ts","sourceRoot":"","sources":["../src/backfill.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjD,6CAA6C;AAC7C,UAAU,YAAY;IACpB,wFAAwF;IACxF,MAAM,EAAE,MAAM,CAAA;IACd,8FAA8F;IAC9F,MAAM,EAAE,MAAM,CAAA;IACd,yEAAyE;IACzE,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IACxB,wDAAwD;IACxD,MAAM,EAAE,cAAc,CAAA;CACvB;AAuGD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAsJ/G;AAgCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAkIrE"}
|
package/dist/cli.js
CHANGED
|
@@ -364,14 +364,18 @@ if (command === 'new') {
|
|
|
364
364
|
for (const sub of subs) {
|
|
365
365
|
mkdirSync(join(dir, sub));
|
|
366
366
|
}
|
|
367
|
-
writeFileSync(join(dir, 'config.
|
|
368
|
-
plc: http://localhost:2582
|
|
369
|
-
port: 3000
|
|
370
|
-
database: data/hatk.db
|
|
371
|
-
admins: []
|
|
367
|
+
writeFileSync(join(dir, 'hatk.config.ts'), `import { defineConfig } from '@hatk/hatk/config'
|
|
372
368
|
|
|
373
|
-
|
|
374
|
-
|
|
369
|
+
export default defineConfig({
|
|
370
|
+
relay: 'ws://localhost:2583',
|
|
371
|
+
plc: 'http://localhost:2582',
|
|
372
|
+
port: 3000,
|
|
373
|
+
database: 'data/hatk.db',
|
|
374
|
+
admins: [],
|
|
375
|
+
backfill: {
|
|
376
|
+
parallelism: 10,
|
|
377
|
+
},
|
|
378
|
+
})
|
|
375
379
|
`);
|
|
376
380
|
writeFileSync(join(dir, 'public', 'index.html'), `<!DOCTYPE html>
|
|
377
381
|
<html><head><title>${name}</title></head>
|
|
@@ -848,7 +852,7 @@ COPY . .
|
|
|
848
852
|
RUN node_modules/.bin/hatk build
|
|
849
853
|
RUN npm prune --omit=dev
|
|
850
854
|
EXPOSE 3000
|
|
851
|
-
CMD ["node", "--max-old-space-size=512", "node_modules/@hatk/hatk/dist/main.js", "config.
|
|
855
|
+
CMD ["node", "--experimental-strip-types", "--max-old-space-size=512", "node_modules/@hatk/hatk/dist/main.js", "hatk.config.ts"]
|
|
852
856
|
`);
|
|
853
857
|
const pkgDeps = { '@hatk/oauth-client': '*', hatk: '*' };
|
|
854
858
|
const pkgDevDeps = {
|
|
@@ -1079,7 +1083,7 @@ a {
|
|
|
1079
1083
|
`);
|
|
1080
1084
|
}
|
|
1081
1085
|
console.log(`Created ${name}/`);
|
|
1082
|
-
console.log(` config.
|
|
1086
|
+
console.log(` hatk.config.ts`);
|
|
1083
1087
|
console.log(` lexicons/ — lexicon JSON files (core + your own)`);
|
|
1084
1088
|
console.log(` feeds/ — feed generators`);
|
|
1085
1089
|
console.log(` xrpc/ — XRPC method handlers`);
|
|
@@ -1490,7 +1494,7 @@ else if (command === 'dev') {
|
|
|
1490
1494
|
else {
|
|
1491
1495
|
// No frontend — just run the hatk server directly
|
|
1492
1496
|
const mainPath = resolve(import.meta.dirname, 'main.js');
|
|
1493
|
-
execSync(`npx tsx ${mainPath} config.
|
|
1497
|
+
execSync(`npx tsx ${mainPath} hatk.config.ts`, {
|
|
1494
1498
|
stdio: 'inherit',
|
|
1495
1499
|
cwd: process.cwd(),
|
|
1496
1500
|
env: { ...process.env, DEV_MODE: '1' },
|
|
@@ -1520,7 +1524,7 @@ else if (command === 'build') {
|
|
|
1520
1524
|
}
|
|
1521
1525
|
}
|
|
1522
1526
|
else if (command === 'reset') {
|
|
1523
|
-
const config = loadConfig(resolve('config.
|
|
1527
|
+
const config = await loadConfig(resolve('hatk.config.ts'));
|
|
1524
1528
|
if (config.database !== ':memory:') {
|
|
1525
1529
|
for (const suffix of ['', '.wal']) {
|
|
1526
1530
|
const file = config.database + suffix;
|
|
@@ -1680,7 +1684,7 @@ else if (command === 'resolve') {
|
|
|
1680
1684
|
execSync('npx hatk generate types', { stdio: 'inherit', cwd: process.cwd() });
|
|
1681
1685
|
}
|
|
1682
1686
|
else if (command === 'schema') {
|
|
1683
|
-
const config = loadConfig(resolve('config.
|
|
1687
|
+
const config = await loadConfig(resolve('hatk.config.ts'));
|
|
1684
1688
|
if (config.database === ':memory:') {
|
|
1685
1689
|
console.error('No database file configured (database is :memory:)');
|
|
1686
1690
|
process.exit(1);
|
|
@@ -1707,7 +1711,7 @@ else if (command === 'schema') {
|
|
|
1707
1711
|
else if (command === 'start') {
|
|
1708
1712
|
try {
|
|
1709
1713
|
const mainPath = resolve(import.meta.dirname, 'main.js');
|
|
1710
|
-
execSync(`npx tsx ${mainPath} config.
|
|
1714
|
+
execSync(`npx tsx ${mainPath} hatk.config.ts`, { stdio: 'inherit', cwd: process.cwd() });
|
|
1711
1715
|
}
|
|
1712
1716
|
catch (e) {
|
|
1713
1717
|
if (e.signal === 'SIGINT' || e.signal === 'SIGTERM')
|
package/dist/config.d.ts
CHANGED
|
@@ -41,7 +41,9 @@ export interface HatkConfig {
|
|
|
41
41
|
oauth: OAuthConfig | null;
|
|
42
42
|
admins: string[];
|
|
43
43
|
}
|
|
44
|
+
/** Identity function that provides type inference for hatk config files. */
|
|
45
|
+
export declare function defineConfig(config: Partial<HatkConfig>): Partial<HatkConfig>;
|
|
44
46
|
/** Derive HTTP URL from relay WebSocket URL (ws://host → http://host) */
|
|
45
47
|
export declare function relayHttpUrl(relay: string): string;
|
|
46
|
-
export declare function loadConfig(configPath: string): HatkConfig
|
|
48
|
+
export declare function loadConfig(configPath: string): Promise<HatkConfig>;
|
|
47
49
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,WAAW;IAC1B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AM,EAAE,MAAM,EAAE,CAAA;CACjB;AAED,4EAA4E;AAC5E,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAE7E;AAED,yEAAyE;AACzE,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,wBAAsB,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAuDxE"}
|
package/dist/config.js
CHANGED
|
@@ -1,14 +1,40 @@
|
|
|
1
|
-
|
|
1
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return path;
|
|
8
|
+
};
|
|
2
9
|
import { resolve, dirname } from 'node:path';
|
|
3
|
-
import
|
|
10
|
+
import { existsSync } from 'node:fs';
|
|
11
|
+
/** Identity function that provides type inference for hatk config files. */
|
|
12
|
+
export function defineConfig(config) {
|
|
13
|
+
return config;
|
|
14
|
+
}
|
|
4
15
|
/** Derive HTTP URL from relay WebSocket URL (ws://host → http://host) */
|
|
5
16
|
export function relayHttpUrl(relay) {
|
|
6
17
|
return relay.replace(/^ws(s?):\/\//, 'http$1://');
|
|
7
18
|
}
|
|
8
|
-
export function loadConfig(configPath) {
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
19
|
+
export async function loadConfig(configPath) {
|
|
20
|
+
const resolved = resolve(configPath);
|
|
21
|
+
if (!existsSync(resolved)) {
|
|
22
|
+
console.error(`Config file not found: ${resolved}`);
|
|
23
|
+
console.error(`hatk now uses hatk.config.ts instead of config.yaml.`);
|
|
24
|
+
console.error(`Create a hatk.config.ts file or run 'hatk new' to scaffold a project.`);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
const configDir = dirname(resolved);
|
|
28
|
+
let mod;
|
|
29
|
+
try {
|
|
30
|
+
mod = await import(__rewriteRelativeImportExtension(resolved));
|
|
31
|
+
}
|
|
32
|
+
catch (err) {
|
|
33
|
+
console.error(`Failed to load config file: ${resolved}`);
|
|
34
|
+
console.error(err.message || err);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
const parsed = mod.default || {};
|
|
12
38
|
const backfillRaw = parsed.backfill || {};
|
|
13
39
|
const env = process.env;
|
|
14
40
|
const database = env.DATABASE || parsed.database;
|
|
@@ -17,7 +43,7 @@ export function loadConfig(configPath) {
|
|
|
17
43
|
plc: env.DID_PLC_URL || parsed.plc || 'https://plc.directory',
|
|
18
44
|
port: parseInt(env.PORT || '') || parsed.port || 3000,
|
|
19
45
|
database: database ? resolve(configDir, database) : ':memory:',
|
|
20
|
-
publicDir: parsed.
|
|
46
|
+
publicDir: parsed.publicDir === null ? null : resolve(configDir, parsed.publicDir || './public'),
|
|
21
47
|
collections: parsed.collections || [],
|
|
22
48
|
backfill: {
|
|
23
49
|
signalCollections: backfillRaw.signalCollections || undefined,
|
package/dist/main.js
CHANGED
|
@@ -23,11 +23,11 @@ function logMemory(phase) {
|
|
|
23
23
|
const mem = process.memoryUsage();
|
|
24
24
|
log(`[mem] ${phase}: heap=${Math.round(mem.heapUsed / 1024 / 1024)}MB rss=${Math.round(mem.rss / 1024 / 1024)}MB external=${Math.round(mem.external / 1024 / 1024)}MB arrayBuffers=${Math.round(mem.arrayBuffers / 1024 / 1024)}MB`);
|
|
25
25
|
}
|
|
26
|
-
const configPath = process.argv[2] || 'config.
|
|
26
|
+
const configPath = process.argv[2] || 'hatk.config.ts';
|
|
27
27
|
const configDir = dirname(resolve(configPath));
|
|
28
28
|
logMemory('startup');
|
|
29
29
|
// 1. Load config
|
|
30
|
-
const config = loadConfig(configPath);
|
|
30
|
+
const config = await loadConfig(configPath);
|
|
31
31
|
configureRelay(config.relay);
|
|
32
32
|
// 2. Load lexicons, validate schemas, and discover collections
|
|
33
33
|
const lexicons = loadLexicons(resolve(configDir, 'lexicons'));
|
package/dist/test.js
CHANGED
|
@@ -14,14 +14,14 @@ import { validateLexicons } from '@bigmoves/lexicon';
|
|
|
14
14
|
import { packCursor, unpackCursor, isTakendownDid, filterTakendownDids } from "./db.js";
|
|
15
15
|
import { seed as createSeedHelpers } from "./seed.js";
|
|
16
16
|
/**
|
|
17
|
-
* Find the project's config.
|
|
18
|
-
* Returns the resolved config path, or falls back to 'config.
|
|
17
|
+
* Find the project's hatk.config.ts by walking up from cwd.
|
|
18
|
+
* Returns the resolved config path, or falls back to 'hatk.config.ts'.
|
|
19
19
|
*/
|
|
20
20
|
function findConfigPath() {
|
|
21
21
|
const explicit = process.env.APPVIEW_CONFIG;
|
|
22
22
|
if (explicit)
|
|
23
23
|
return resolve(explicit);
|
|
24
|
-
return resolve('config.
|
|
24
|
+
return resolve('hatk.config.ts');
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
* Boot an in-memory hatk context for unit tests.
|
|
@@ -34,7 +34,7 @@ function findConfigPath() {
|
|
|
34
34
|
*/
|
|
35
35
|
export async function createTestContext() {
|
|
36
36
|
const configPath = findConfigPath();
|
|
37
|
-
const config = loadConfig(configPath);
|
|
37
|
+
const config = await loadConfig(configPath);
|
|
38
38
|
const configDir = dirname(resolve(configPath));
|
|
39
39
|
configureRelay(config.relay);
|
|
40
40
|
// Load and validate lexicons
|
package/dist/vite-plugin.js
CHANGED
|
@@ -64,7 +64,7 @@ export function hatk(opts) {
|
|
|
64
64
|
const mainPath = resolve(import.meta.dirname, 'main.js');
|
|
65
65
|
const watchDirs = ['xrpc', 'feeds', 'labels', 'jobs', 'setup', 'lexicons'].filter((d) => existsSync(d));
|
|
66
66
|
const watchArgs = watchDirs.flatMap((d) => ['--watch-path', d]);
|
|
67
|
-
serverProcess = spawn('npx', ['tsx', 'watch', ...watchArgs, mainPath, 'config.
|
|
67
|
+
serverProcess = spawn('npx', ['tsx', 'watch', ...watchArgs, mainPath, 'hatk.config.ts'], {
|
|
68
68
|
stdio: 'inherit',
|
|
69
69
|
cwd: process.cwd(),
|
|
70
70
|
env: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hatk/hatk",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.20",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"bin": {
|
|
6
6
|
"hatk": "dist/cli.js"
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"./setup": "./dist/setup.js",
|
|
24
24
|
"./test": "./dist/test.js",
|
|
25
25
|
"./test/browser": "./dist/test-browser.js",
|
|
26
|
+
"./config": "./dist/config.js",
|
|
26
27
|
"./vite-plugin": "./dist/vite-plugin.js"
|
|
27
28
|
},
|
|
28
29
|
"scripts": {
|