@bejibun/database 0.1.15 → 0.1.17
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.
|
@@ -37,17 +37,12 @@ export default class MakeMigrationCommand {
|
|
|
37
37
|
}
|
|
38
38
|
const file = args;
|
|
39
39
|
const migrationsDirectory = "migrations";
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
cwd: migrationsPath
|
|
43
|
-
})).filter(value => (/\.ts$/.test(value) &&
|
|
44
|
-
!value.endsWith(".d.ts")));
|
|
45
|
-
const template = migrations.find(value => value.includes("migration_template"));
|
|
46
|
-
if (isEmpty(template)) {
|
|
40
|
+
const template = Bun.file(path.resolve(__dirname, `../../stubs/database/${migrationsDirectory}/migration_template.ts`));
|
|
41
|
+
if (!await template.exists()) {
|
|
47
42
|
Logger.setContext("APP").error("Whoops, something went wrong, the migration template not found.");
|
|
48
43
|
return;
|
|
49
44
|
}
|
|
50
|
-
const now = Luxon.
|
|
45
|
+
const now = Luxon.DateTime.now().toFormat("yyyyMMdd");
|
|
51
46
|
const latest = Array.from(new Bun.Glob("**/*").scanSync({
|
|
52
47
|
cwd: App.Path.databasePath(migrationsDirectory)
|
|
53
48
|
})).map((value) => {
|
|
@@ -61,7 +56,7 @@ export default class MakeMigrationCommand {
|
|
|
61
56
|
}).map((value) => value.count).sort().reverse()[0];
|
|
62
57
|
const counter = defineValue(parseInt(latest), 0);
|
|
63
58
|
const destination = `${migrationsDirectory}/${now}_${String(counter + 1).padStart(6, "0")}_${file}.ts`;
|
|
64
|
-
await Bun.write(App.Path.databasePath(destination), await
|
|
59
|
+
await Bun.write(App.Path.databasePath(destination), await template.text());
|
|
65
60
|
Logger.setContext("APP").info(`Migration [database/${destination}] created successfully.`);
|
|
66
61
|
}
|
|
67
62
|
}
|
|
@@ -37,17 +37,12 @@ export default class MakeSeederCommand {
|
|
|
37
37
|
}
|
|
38
38
|
const file = args;
|
|
39
39
|
const seedersDirectory = "seeders";
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
cwd: seedersPath
|
|
43
|
-
})).filter(value => (/\.ts$/.test(value) &&
|
|
44
|
-
!value.endsWith(".d.ts")));
|
|
45
|
-
const template = seeders.find(value => value.includes("seeder_template"));
|
|
46
|
-
if (isEmpty(template)) {
|
|
40
|
+
const template = Bun.file(path.resolve(__dirname, `../../stubs/database/${seedersDirectory}/seeder_template.ts`));
|
|
41
|
+
if (!await template.exists()) {
|
|
47
42
|
Logger.setContext("APP").error("Whoops, something went wrong, the seeder template not found.");
|
|
48
43
|
return;
|
|
49
44
|
}
|
|
50
|
-
const now = Luxon.
|
|
45
|
+
const now = Luxon.DateTime.now().toFormat("yyyyMMdd");
|
|
51
46
|
const latest = Array.from(new Bun.Glob("**/*").scanSync({
|
|
52
47
|
cwd: App.Path.databasePath(seedersDirectory)
|
|
53
48
|
})).map((value) => {
|
|
@@ -61,7 +56,7 @@ export default class MakeSeederCommand {
|
|
|
61
56
|
}).map((value) => value.count).sort().reverse()[0];
|
|
62
57
|
const counter = defineValue(parseInt(latest), 0);
|
|
63
58
|
const destination = `${seedersDirectory}/${now}_${String(counter + 1).padStart(6, "0")}_${file}.ts`;
|
|
64
|
-
await Bun.write(App.Path.databasePath(destination), await
|
|
59
|
+
await Bun.write(App.Path.databasePath(destination), await template.text());
|
|
65
60
|
Logger.setContext("APP").info(`Seeder [database/${destination}] created successfully.`);
|
|
66
61
|
}
|
|
67
62
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bejibun/database",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
4
4
|
"author": "Havea Crenata <havea.crenata@gmail.com>",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"type": "module",
|
|
38
38
|
"types": "index.d.ts",
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@bejibun/app": "^0.1.
|
|
41
|
-
"@bejibun/logger": "^0.1.
|
|
42
|
-
"@bejibun/utils": "^0.1.
|
|
40
|
+
"@bejibun/app": "^0.1.20",
|
|
41
|
+
"@bejibun/logger": "^0.1.20",
|
|
42
|
+
"@bejibun/utils": "^0.1.18",
|
|
43
43
|
"knex": "^3.1.0",
|
|
44
44
|
"ora": "^9.0.0",
|
|
45
45
|
"pg": "^8.16.3"
|