prisma-flare 1.0.0
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/cli/db-create.cjs +240 -0
- package/dist/cli/db-create.d.cts +1 -0
- package/dist/cli/db-create.d.ts +1 -0
- package/dist/cli/db-create.js +217 -0
- package/dist/cli/db-drop.cjs +263 -0
- package/dist/cli/db-drop.d.cts +1 -0
- package/dist/cli/db-drop.d.ts +1 -0
- package/dist/cli/db-drop.js +240 -0
- package/dist/cli/db-migrate.cjs +318 -0
- package/dist/cli/db-migrate.d.cts +1 -0
- package/dist/cli/db-migrate.d.ts +1 -0
- package/dist/cli/db-migrate.js +295 -0
- package/dist/cli/db-reset.cjs +110 -0
- package/dist/cli/db-reset.d.cts +1 -0
- package/dist/cli/db-reset.d.ts +1 -0
- package/dist/cli/db-reset.js +87 -0
- package/dist/cli/db-seed.cjs +87 -0
- package/dist/cli/db-seed.d.cts +1 -0
- package/dist/cli/db-seed.d.ts +1 -0
- package/dist/cli/db-seed.js +64 -0
- package/dist/cli/index.cjs +352 -0
- package/dist/cli/index.d.cts +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +328 -0
- package/dist/core/flareBuilder.cjs +681 -0
- package/dist/core/flareBuilder.d.cts +402 -0
- package/dist/core/flareBuilder.d.ts +402 -0
- package/dist/core/flareBuilder.js +658 -0
- package/dist/core/hooks.cjs +243 -0
- package/dist/core/hooks.d.cts +13 -0
- package/dist/core/hooks.d.ts +13 -0
- package/dist/core/hooks.js +209 -0
- package/dist/generated.cjs +31 -0
- package/dist/generated.d.cts +4 -0
- package/dist/generated.d.ts +4 -0
- package/dist/generated.js +6 -0
- package/dist/index.cjs +1315 -0
- package/dist/index.d.cts +237 -0
- package/dist/index.d.ts +237 -0
- package/dist/index.js +1261 -0
- package/dist/prisma.types-nGNe1CG8.d.cts +201 -0
- package/dist/prisma.types-nGNe1CG8.d.ts +201 -0
- package/license.md +21 -0
- package/package.json +115 -0
- package/readme.md +957 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
18
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
19
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
20
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
21
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
+
mod
|
|
24
|
+
));
|
|
25
|
+
|
|
26
|
+
// src/cli/db-reset.ts
|
|
27
|
+
var import_child_process = require("child_process");
|
|
28
|
+
var dotenv = __toESM(require("dotenv"), 1);
|
|
29
|
+
var readline = __toESM(require("readline"), 1);
|
|
30
|
+
|
|
31
|
+
// src/cli/config.ts
|
|
32
|
+
var fs = __toESM(require("fs"), 1);
|
|
33
|
+
var path = __toESM(require("path"), 1);
|
|
34
|
+
function findProjectRoot(currentDir) {
|
|
35
|
+
if (fs.existsSync(path.join(currentDir, "package.json"))) {
|
|
36
|
+
return currentDir;
|
|
37
|
+
}
|
|
38
|
+
const parentDir = path.dirname(currentDir);
|
|
39
|
+
if (parentDir === currentDir) {
|
|
40
|
+
throw new Error("Could not find package.json");
|
|
41
|
+
}
|
|
42
|
+
return findProjectRoot(parentDir);
|
|
43
|
+
}
|
|
44
|
+
function loadConfig(rootDir) {
|
|
45
|
+
const projectRoot = rootDir || findProjectRoot(process.cwd());
|
|
46
|
+
const configPath = path.join(projectRoot, "prisma-flare.config.json");
|
|
47
|
+
let config3 = {
|
|
48
|
+
modelsPath: "prisma/models",
|
|
49
|
+
dbPath: "prisma/db",
|
|
50
|
+
callbacksPath: "prisma/callbacks"
|
|
51
|
+
};
|
|
52
|
+
if (fs.existsSync(configPath)) {
|
|
53
|
+
try {
|
|
54
|
+
const configFile = fs.readFileSync(configPath, "utf-8");
|
|
55
|
+
const userConfig = JSON.parse(configFile);
|
|
56
|
+
config3 = { ...config3, ...userConfig };
|
|
57
|
+
} catch {
|
|
58
|
+
console.warn("\u26A0\uFE0F Could not read prisma-flare.config.json, using defaults.");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
...config3
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// src/cli/db-reset.ts
|
|
67
|
+
var config2 = loadConfig();
|
|
68
|
+
dotenv.config({ path: config2.envPath });
|
|
69
|
+
function confirm(question) {
|
|
70
|
+
const rl = readline.createInterface({
|
|
71
|
+
input: process.stdin,
|
|
72
|
+
output: process.stdout
|
|
73
|
+
});
|
|
74
|
+
return new Promise((resolve) => {
|
|
75
|
+
rl.question(question, (answer) => {
|
|
76
|
+
rl.close();
|
|
77
|
+
resolve(answer.toLowerCase() === "y" || answer.toLowerCase() === "yes");
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
async function resetDatabase() {
|
|
82
|
+
const databaseUrl = process.env.DATABASE_URL;
|
|
83
|
+
const skipConfirmation = process.argv.includes("--force") || process.argv.includes("-f");
|
|
84
|
+
if (!databaseUrl) {
|
|
85
|
+
console.error("\u274C DATABASE_URL environment variable is not set");
|
|
86
|
+
process.exit(1);
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
if (!skipConfirmation) {
|
|
90
|
+
const confirmed = await confirm(
|
|
91
|
+
`\u26A0\uFE0F Are you sure you want to reset the database? This will delete all data! (y/N): `
|
|
92
|
+
);
|
|
93
|
+
if (!confirmed) {
|
|
94
|
+
console.log("\u274C Operation cancelled");
|
|
95
|
+
process.exit(0);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
console.log("\u{1F504} Resetting database...");
|
|
99
|
+
(0, import_child_process.execSync)("npx prisma migrate reset --force", {
|
|
100
|
+
stdio: "inherit",
|
|
101
|
+
env: process.env
|
|
102
|
+
});
|
|
103
|
+
console.log("\u2713 Database reset successfully");
|
|
104
|
+
process.exit(0);
|
|
105
|
+
} catch (error) {
|
|
106
|
+
console.error("\u274C Error resetting database:", error);
|
|
107
|
+
process.exit(1);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
resetDatabase();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/cli/db-reset.ts
|
|
4
|
+
import { execSync } from "child_process";
|
|
5
|
+
import * as dotenv from "dotenv";
|
|
6
|
+
import * as readline from "readline";
|
|
7
|
+
|
|
8
|
+
// src/cli/config.ts
|
|
9
|
+
import * as fs from "fs";
|
|
10
|
+
import * as path from "path";
|
|
11
|
+
function findProjectRoot(currentDir) {
|
|
12
|
+
if (fs.existsSync(path.join(currentDir, "package.json"))) {
|
|
13
|
+
return currentDir;
|
|
14
|
+
}
|
|
15
|
+
const parentDir = path.dirname(currentDir);
|
|
16
|
+
if (parentDir === currentDir) {
|
|
17
|
+
throw new Error("Could not find package.json");
|
|
18
|
+
}
|
|
19
|
+
return findProjectRoot(parentDir);
|
|
20
|
+
}
|
|
21
|
+
function loadConfig(rootDir) {
|
|
22
|
+
const projectRoot = rootDir || findProjectRoot(process.cwd());
|
|
23
|
+
const configPath = path.join(projectRoot, "prisma-flare.config.json");
|
|
24
|
+
let config3 = {
|
|
25
|
+
modelsPath: "prisma/models",
|
|
26
|
+
dbPath: "prisma/db",
|
|
27
|
+
callbacksPath: "prisma/callbacks"
|
|
28
|
+
};
|
|
29
|
+
if (fs.existsSync(configPath)) {
|
|
30
|
+
try {
|
|
31
|
+
const configFile = fs.readFileSync(configPath, "utf-8");
|
|
32
|
+
const userConfig = JSON.parse(configFile);
|
|
33
|
+
config3 = { ...config3, ...userConfig };
|
|
34
|
+
} catch {
|
|
35
|
+
console.warn("\u26A0\uFE0F Could not read prisma-flare.config.json, using defaults.");
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
...config3
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// src/cli/db-reset.ts
|
|
44
|
+
var config2 = loadConfig();
|
|
45
|
+
dotenv.config({ path: config2.envPath });
|
|
46
|
+
function confirm(question) {
|
|
47
|
+
const rl = readline.createInterface({
|
|
48
|
+
input: process.stdin,
|
|
49
|
+
output: process.stdout
|
|
50
|
+
});
|
|
51
|
+
return new Promise((resolve) => {
|
|
52
|
+
rl.question(question, (answer) => {
|
|
53
|
+
rl.close();
|
|
54
|
+
resolve(answer.toLowerCase() === "y" || answer.toLowerCase() === "yes");
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
async function resetDatabase() {
|
|
59
|
+
const databaseUrl = process.env.DATABASE_URL;
|
|
60
|
+
const skipConfirmation = process.argv.includes("--force") || process.argv.includes("-f");
|
|
61
|
+
if (!databaseUrl) {
|
|
62
|
+
console.error("\u274C DATABASE_URL environment variable is not set");
|
|
63
|
+
process.exit(1);
|
|
64
|
+
}
|
|
65
|
+
try {
|
|
66
|
+
if (!skipConfirmation) {
|
|
67
|
+
const confirmed = await confirm(
|
|
68
|
+
`\u26A0\uFE0F Are you sure you want to reset the database? This will delete all data! (y/N): `
|
|
69
|
+
);
|
|
70
|
+
if (!confirmed) {
|
|
71
|
+
console.log("\u274C Operation cancelled");
|
|
72
|
+
process.exit(0);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
console.log("\u{1F504} Resetting database...");
|
|
76
|
+
execSync("npx prisma migrate reset --force", {
|
|
77
|
+
stdio: "inherit",
|
|
78
|
+
env: process.env
|
|
79
|
+
});
|
|
80
|
+
console.log("\u2713 Database reset successfully");
|
|
81
|
+
process.exit(0);
|
|
82
|
+
} catch (error) {
|
|
83
|
+
console.error("\u274C Error resetting database:", error);
|
|
84
|
+
process.exit(1);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
resetDatabase();
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
18
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
19
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
20
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
21
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
+
mod
|
|
24
|
+
));
|
|
25
|
+
|
|
26
|
+
// src/cli/db-seed.ts
|
|
27
|
+
var import_child_process = require("child_process");
|
|
28
|
+
var dotenv = __toESM(require("dotenv"), 1);
|
|
29
|
+
|
|
30
|
+
// src/cli/config.ts
|
|
31
|
+
var fs = __toESM(require("fs"), 1);
|
|
32
|
+
var path = __toESM(require("path"), 1);
|
|
33
|
+
function findProjectRoot(currentDir) {
|
|
34
|
+
if (fs.existsSync(path.join(currentDir, "package.json"))) {
|
|
35
|
+
return currentDir;
|
|
36
|
+
}
|
|
37
|
+
const parentDir = path.dirname(currentDir);
|
|
38
|
+
if (parentDir === currentDir) {
|
|
39
|
+
throw new Error("Could not find package.json");
|
|
40
|
+
}
|
|
41
|
+
return findProjectRoot(parentDir);
|
|
42
|
+
}
|
|
43
|
+
function loadConfig(rootDir) {
|
|
44
|
+
const projectRoot = rootDir || findProjectRoot(process.cwd());
|
|
45
|
+
const configPath = path.join(projectRoot, "prisma-flare.config.json");
|
|
46
|
+
let config3 = {
|
|
47
|
+
modelsPath: "prisma/models",
|
|
48
|
+
dbPath: "prisma/db",
|
|
49
|
+
callbacksPath: "prisma/callbacks"
|
|
50
|
+
};
|
|
51
|
+
if (fs.existsSync(configPath)) {
|
|
52
|
+
try {
|
|
53
|
+
const configFile = fs.readFileSync(configPath, "utf-8");
|
|
54
|
+
const userConfig = JSON.parse(configFile);
|
|
55
|
+
config3 = { ...config3, ...userConfig };
|
|
56
|
+
} catch {
|
|
57
|
+
console.warn("\u26A0\uFE0F Could not read prisma-flare.config.json, using defaults.");
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
...config3
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// src/cli/db-seed.ts
|
|
66
|
+
var config2 = loadConfig();
|
|
67
|
+
dotenv.config({ path: config2.envPath });
|
|
68
|
+
function seedDatabase() {
|
|
69
|
+
const databaseUrl = process.env.DATABASE_URL;
|
|
70
|
+
if (!databaseUrl) {
|
|
71
|
+
console.error("\u274C DATABASE_URL environment variable is not set");
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
console.log("\u{1F504} Seeding database...");
|
|
76
|
+
(0, import_child_process.execSync)("npx prisma db seed", {
|
|
77
|
+
stdio: "inherit",
|
|
78
|
+
env: process.env
|
|
79
|
+
});
|
|
80
|
+
console.log("\u2713 Database seeded successfully");
|
|
81
|
+
process.exit(0);
|
|
82
|
+
} catch (error) {
|
|
83
|
+
console.error("\u274C Error seeding database:", error);
|
|
84
|
+
process.exit(1);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
seedDatabase();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/cli/db-seed.ts
|
|
4
|
+
import { execSync } from "child_process";
|
|
5
|
+
import * as dotenv from "dotenv";
|
|
6
|
+
|
|
7
|
+
// src/cli/config.ts
|
|
8
|
+
import * as fs from "fs";
|
|
9
|
+
import * as path from "path";
|
|
10
|
+
function findProjectRoot(currentDir) {
|
|
11
|
+
if (fs.existsSync(path.join(currentDir, "package.json"))) {
|
|
12
|
+
return currentDir;
|
|
13
|
+
}
|
|
14
|
+
const parentDir = path.dirname(currentDir);
|
|
15
|
+
if (parentDir === currentDir) {
|
|
16
|
+
throw new Error("Could not find package.json");
|
|
17
|
+
}
|
|
18
|
+
return findProjectRoot(parentDir);
|
|
19
|
+
}
|
|
20
|
+
function loadConfig(rootDir) {
|
|
21
|
+
const projectRoot = rootDir || findProjectRoot(process.cwd());
|
|
22
|
+
const configPath = path.join(projectRoot, "prisma-flare.config.json");
|
|
23
|
+
let config3 = {
|
|
24
|
+
modelsPath: "prisma/models",
|
|
25
|
+
dbPath: "prisma/db",
|
|
26
|
+
callbacksPath: "prisma/callbacks"
|
|
27
|
+
};
|
|
28
|
+
if (fs.existsSync(configPath)) {
|
|
29
|
+
try {
|
|
30
|
+
const configFile = fs.readFileSync(configPath, "utf-8");
|
|
31
|
+
const userConfig = JSON.parse(configFile);
|
|
32
|
+
config3 = { ...config3, ...userConfig };
|
|
33
|
+
} catch {
|
|
34
|
+
console.warn("\u26A0\uFE0F Could not read prisma-flare.config.json, using defaults.");
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
...config3
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// src/cli/db-seed.ts
|
|
43
|
+
var config2 = loadConfig();
|
|
44
|
+
dotenv.config({ path: config2.envPath });
|
|
45
|
+
function seedDatabase() {
|
|
46
|
+
const databaseUrl = process.env.DATABASE_URL;
|
|
47
|
+
if (!databaseUrl) {
|
|
48
|
+
console.error("\u274C DATABASE_URL environment variable is not set");
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
console.log("\u{1F504} Seeding database...");
|
|
53
|
+
execSync("npx prisma db seed", {
|
|
54
|
+
stdio: "inherit",
|
|
55
|
+
env: process.env
|
|
56
|
+
});
|
|
57
|
+
console.log("\u2713 Database seeded successfully");
|
|
58
|
+
process.exit(0);
|
|
59
|
+
} catch (error) {
|
|
60
|
+
console.error("\u274C Error seeding database:", error);
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
seedDatabase();
|