@deessejs/collections 0.0.37 → 0.0.39
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/config/index.js +22 -0
- package/dist/drizzle/generate.d.ts +1 -0
- package/dist/drizzle/generate.js +17 -0
- package/dist/worker/index.js +2 -0
- package/package.json +1 -1
package/dist/config/index.js
CHANGED
|
@@ -1,9 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.defineConfig = void 0;
|
|
4
7
|
const node_postgres_1 = require("drizzle-orm/node-postgres");
|
|
8
|
+
// Remarque : on importe depuis "fs" tout court, pas "fs/promises"
|
|
9
|
+
const fs_1 = require("fs");
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
// Fonction utilitaire SYNCHRONE
|
|
12
|
+
const writeSchemaFileSync = () => {
|
|
13
|
+
try {
|
|
14
|
+
const targetPath = path_1.default.join(process.cwd(), ".deesse", "schema.ts");
|
|
15
|
+
const targetDir = path_1.default.dirname(targetPath);
|
|
16
|
+
// mkdirSync et writeFileSync bloquent l'exécution jusqu'à la fin de l'écriture
|
|
17
|
+
(0, fs_1.mkdirSync)(targetDir, { recursive: true });
|
|
18
|
+
(0, fs_1.writeFileSync)(targetPath, "hey", "utf-8");
|
|
19
|
+
console.log(`[config] Schema written to: ${targetPath}`);
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
console.error("[config] Failed to write schema file:", error);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
5
25
|
const defineConfig = (config) => {
|
|
6
26
|
const db = (0, node_postgres_1.drizzle)(config.databaseUrl);
|
|
27
|
+
// On peut l'appeler sans await
|
|
28
|
+
writeSchemaFileSync();
|
|
7
29
|
return db;
|
|
8
30
|
};
|
|
9
31
|
exports.defineConfig = defineConfig;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const generateShadowSchema: () => void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.generateShadowSchema = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const SHADOW_DIR = path_1.default.join(process.cwd(), ".deesse", "shadow");
|
|
10
|
+
const SCHEMA_PATH = path_1.default.join(SHADOW_DIR, "schema.ts");
|
|
11
|
+
const generateShadowSchema = () => {
|
|
12
|
+
fs_1.default.mkdirSync(SHADOW_DIR, { recursive: true });
|
|
13
|
+
// Ajoute "hey" à la fin du fichier
|
|
14
|
+
fs_1.default.appendFileSync(SCHEMA_PATH, "hey\n");
|
|
15
|
+
console.log("[Deesse] Added 'hey' to", SCHEMA_PATH);
|
|
16
|
+
};
|
|
17
|
+
exports.generateShadowSchema = generateShadowSchema;
|
package/dist/worker/index.js
CHANGED
|
@@ -5,8 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const chokidar_1 = __importDefault(require("chokidar"));
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const generate_1 = require("../drizzle/generate");
|
|
8
9
|
const collectionsDir = path_1.default.join(process.cwd(), "src", "collections");
|
|
9
10
|
console.log(`[worker] Watching collections folder: ${collectionsDir}`);
|
|
11
|
+
(0, generate_1.generateShadowSchema)();
|
|
10
12
|
const watcher = chokidar_1.default.watch(collectionsDir, {
|
|
11
13
|
persistent: true,
|
|
12
14
|
ignoreInitial: false,
|