@bejibun/database 0.1.15 → 0.1.16

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,13 +37,8 @@ export default class MakeMigrationCommand {
37
37
  }
38
38
  const file = args;
39
39
  const migrationsDirectory = "migrations";
40
- const migrationsPath = path.resolve(__dirname, `../../stubs/database/${migrationsDirectory}`);
41
- const migrations = Array.from(new Bun.Glob("**/*").scanSync({
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
  }
@@ -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 Bun.file(path.resolve(migrationsPath, template)).text());
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,13 +37,8 @@ export default class MakeSeederCommand {
37
37
  }
38
38
  const file = args;
39
39
  const seedersDirectory = "seeders";
40
- const seedersPath = path.resolve(__dirname, `../../stubs/database/${seedersDirectory}`);
41
- const seeders = Array.from(new Bun.Glob("**/*").scanSync({
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
  }
@@ -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 Bun.file(path.resolve(seedersPath, template)).text());
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.15",
3
+ "version": "0.1.16",
4
4
  "author": "Havea Crenata <havea.crenata@gmail.com>",
5
5
  "repository": {
6
6
  "type": "git",