@ooneex/cli 1.29.1 → 1.31.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/index.js +86 -45
- package/dist/index.js.map +3 -3
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -9754,10 +9754,12 @@ MakeMigrationCommand = __legacyDecorateClassTS([
|
|
|
9754
9754
|
decorator22.command()
|
|
9755
9755
|
], MakeMigrationCommand);
|
|
9756
9756
|
// src/commands/ModuleLockCommand.ts
|
|
9757
|
-
import { join as join23 } from "path";
|
|
9757
|
+
import { join as join23, relative } from "path";
|
|
9758
9758
|
import { decorator as decorator23 } from "@ooneex/command";
|
|
9759
9759
|
import { TerminalLogger as TerminalLogger22 } from "@ooneex/logger";
|
|
9760
9760
|
import { migrationTestCreate } from "@ooneex/migrations";
|
|
9761
|
+
import { seedTestCreate } from "@ooneex/seeds";
|
|
9762
|
+
import { toPascalCase as toPascalCase12 } from "@ooneex/utils";
|
|
9761
9763
|
class ModuleLockCommand {
|
|
9762
9764
|
getName() {
|
|
9763
9765
|
return "module:lock";
|
|
@@ -9772,39 +9774,61 @@ class ModuleLockCommand {
|
|
|
9772
9774
|
await ensureModule(module);
|
|
9773
9775
|
}
|
|
9774
9776
|
const base = module ? join23("modules", module) : ".";
|
|
9775
|
-
const migrationsDir = join23(process.cwd(), base, "src", "migrations");
|
|
9776
|
-
const glob = new Bun.Glob("Migration*.ts");
|
|
9777
|
-
const migrationFiles = [];
|
|
9778
|
-
for await (const file of glob.scan({ cwd: migrationsDir, onlyFiles: true })) {
|
|
9779
|
-
migrationFiles.push(file);
|
|
9780
|
-
}
|
|
9781
|
-
if (migrationFiles.length === 0) {
|
|
9782
|
-
logger.info("No migration files found", undefined, {
|
|
9783
|
-
showTimestamp: false,
|
|
9784
|
-
showArrow: false
|
|
9785
|
-
});
|
|
9786
|
-
return;
|
|
9787
|
-
}
|
|
9788
9777
|
const moduleName = module ?? await this.resolveModuleName(base);
|
|
9789
9778
|
const ymlPath = join23(process.cwd(), base, `${moduleName}.yml`);
|
|
9790
|
-
const
|
|
9791
|
-
const registered = await this.parseYml(ymlPath);
|
|
9779
|
+
const { migrations: registeredMigrations, seeds: registeredSeeds } = await this.parseYml(ymlPath);
|
|
9792
9780
|
let added = 0;
|
|
9793
9781
|
let skipped = 0;
|
|
9782
|
+
const migrationsDir = join23(process.cwd(), base, "src", "migrations");
|
|
9783
|
+
const migrationFiles = [];
|
|
9784
|
+
try {
|
|
9785
|
+
const glob = new Bun.Glob("Migration*.ts");
|
|
9786
|
+
for await (const file of glob.scan({ cwd: migrationsDir, onlyFiles: true })) {
|
|
9787
|
+
migrationFiles.push(file);
|
|
9788
|
+
}
|
|
9789
|
+
} catch {}
|
|
9794
9790
|
for (const file of migrationFiles.sort()) {
|
|
9795
9791
|
const name = file.replace(/\.ts$/, "");
|
|
9792
|
+
const testsDir = join23(base, "tests", "migrations");
|
|
9796
9793
|
await migrationTestCreate({ name, testsDir, ...module && { module } });
|
|
9797
|
-
if (
|
|
9794
|
+
if (registeredMigrations[name] && !override) {
|
|
9798
9795
|
skipped++;
|
|
9799
9796
|
continue;
|
|
9800
9797
|
}
|
|
9801
9798
|
const content = await Bun.file(join23(migrationsDir, file)).text();
|
|
9802
|
-
|
|
9799
|
+
registeredMigrations[name] = new Bun.CryptoHasher("sha256").update(content).digest("hex");
|
|
9803
9800
|
added++;
|
|
9804
9801
|
}
|
|
9805
|
-
|
|
9802
|
+
const seedsDir = join23(process.cwd(), base, "src", "seeds");
|
|
9803
|
+
const seedFiles = [];
|
|
9804
|
+
try {
|
|
9805
|
+
const glob = new Bun.Glob("*-seed.yml");
|
|
9806
|
+
for await (const file of glob.scan({ cwd: seedsDir, onlyFiles: true })) {
|
|
9807
|
+
seedFiles.push(file);
|
|
9808
|
+
}
|
|
9809
|
+
} catch {}
|
|
9810
|
+
for (const file of seedFiles.sort()) {
|
|
9811
|
+
const name = file.replace(/\.yml$/, "");
|
|
9812
|
+
const testsDir = join23(base, "tests", "seeds");
|
|
9813
|
+
await seedTestCreate({ name: toPascalCase12(name), testsDir, ...module && { module } });
|
|
9814
|
+
if (registeredSeeds[name] && !override) {
|
|
9815
|
+
skipped++;
|
|
9816
|
+
continue;
|
|
9817
|
+
}
|
|
9818
|
+
const content = await Bun.file(join23(seedsDir, file)).text();
|
|
9819
|
+
registeredSeeds[name] = new Bun.CryptoHasher("sha256").update(content).digest("hex");
|
|
9820
|
+
added++;
|
|
9821
|
+
}
|
|
9822
|
+
if (migrationFiles.length === 0 && seedFiles.length === 0) {
|
|
9823
|
+
logger.info("No migration or seed files found", undefined, {
|
|
9824
|
+
showTimestamp: false,
|
|
9825
|
+
showArrow: false
|
|
9826
|
+
});
|
|
9827
|
+
return;
|
|
9828
|
+
}
|
|
9829
|
+
await this.writeYml(ymlPath, registeredMigrations, registeredSeeds);
|
|
9806
9830
|
if (added > 0) {
|
|
9807
|
-
logger.success(`${ymlPath} updated (${added} migration(s) locked)`, undefined, {
|
|
9831
|
+
logger.success(`${relative(process.cwd(), ymlPath)} updated (${added} migration(s) locked)`, undefined, {
|
|
9808
9832
|
showTimestamp: false,
|
|
9809
9833
|
showArrow: false,
|
|
9810
9834
|
useSymbol: true
|
|
@@ -9829,20 +9853,37 @@ class ModuleLockCommand {
|
|
|
9829
9853
|
async parseYml(ymlPath) {
|
|
9830
9854
|
const file = Bun.file(ymlPath);
|
|
9831
9855
|
if (!await file.exists())
|
|
9832
|
-
return {};
|
|
9856
|
+
return { migrations: {}, seeds: {} };
|
|
9833
9857
|
const data = Bun.YAML.parse(await file.text());
|
|
9834
|
-
const
|
|
9858
|
+
const migrations = {};
|
|
9835
9859
|
for (const [name, entry] of Object.entries(data.migrations ?? {})) {
|
|
9836
9860
|
if (entry?.hash)
|
|
9837
|
-
|
|
9861
|
+
migrations[name] = entry.hash;
|
|
9838
9862
|
}
|
|
9839
|
-
|
|
9863
|
+
const seeds = {};
|
|
9864
|
+
for (const [name, entry] of Object.entries(data.seeds ?? {})) {
|
|
9865
|
+
if (entry?.hash)
|
|
9866
|
+
seeds[name] = entry.hash;
|
|
9867
|
+
}
|
|
9868
|
+
return { migrations, seeds };
|
|
9840
9869
|
}
|
|
9841
|
-
async writeYml(ymlPath, migrations) {
|
|
9842
|
-
const lines = [
|
|
9843
|
-
|
|
9844
|
-
lines.push(
|
|
9845
|
-
|
|
9870
|
+
async writeYml(ymlPath, migrations, seeds) {
|
|
9871
|
+
const lines = [];
|
|
9872
|
+
if (Object.keys(migrations).length > 0) {
|
|
9873
|
+
lines.push("migrations:");
|
|
9874
|
+
for (const [name, hash] of Object.entries(migrations).sort(([a], [b]) => a.localeCompare(b))) {
|
|
9875
|
+
lines.push(` ${name}:`);
|
|
9876
|
+
lines.push(` hash: ${hash}`);
|
|
9877
|
+
}
|
|
9878
|
+
}
|
|
9879
|
+
if (Object.keys(seeds).length > 0) {
|
|
9880
|
+
if (lines.length > 0)
|
|
9881
|
+
lines.push("");
|
|
9882
|
+
lines.push("seeds:");
|
|
9883
|
+
for (const [name, hash] of Object.entries(seeds).sort(([a], [b]) => a.localeCompare(b))) {
|
|
9884
|
+
lines.push(` ${name}:`);
|
|
9885
|
+
lines.push(` hash: ${hash}`);
|
|
9886
|
+
}
|
|
9846
9887
|
}
|
|
9847
9888
|
await Bun.write(ymlPath, `${lines.join(`
|
|
9848
9889
|
`)}
|
|
@@ -9856,7 +9897,7 @@ ModuleLockCommand = __legacyDecorateClassTS([
|
|
|
9856
9897
|
import { join as join24 } from "path";
|
|
9857
9898
|
import { decorator as decorator24 } from "@ooneex/command";
|
|
9858
9899
|
import { TerminalLogger as TerminalLogger23 } from "@ooneex/logger";
|
|
9859
|
-
import { toPascalCase as
|
|
9900
|
+
import { toPascalCase as toPascalCase13 } from "@ooneex/utils";
|
|
9860
9901
|
|
|
9861
9902
|
// src/templates/permission.test.txt
|
|
9862
9903
|
var permission_test_default = `import { describe, expect, test } from "bun:test";
|
|
@@ -9988,7 +10029,7 @@ class MakePermissionCommand {
|
|
|
9988
10029
|
if (!name) {
|
|
9989
10030
|
name = await askName({ message: "Enter permission name" });
|
|
9990
10031
|
}
|
|
9991
|
-
name =
|
|
10032
|
+
name = toPascalCase13(name).replace(/Permission$/, "");
|
|
9992
10033
|
const content = permission_default.replace(/{{NAME}}/g, name);
|
|
9993
10034
|
if (module) {
|
|
9994
10035
|
await ensureModule(module);
|
|
@@ -10035,7 +10076,7 @@ MakePermissionCommand = __legacyDecorateClassTS([
|
|
|
10035
10076
|
import { basename as basename5, join as join25 } from "path";
|
|
10036
10077
|
import { decorator as decorator25 } from "@ooneex/command";
|
|
10037
10078
|
import { TerminalLogger as TerminalLogger24 } from "@ooneex/logger";
|
|
10038
|
-
import { toKebabCase as toKebabCase4, toPascalCase as
|
|
10079
|
+
import { toKebabCase as toKebabCase4, toPascalCase as toPascalCase14 } from "@ooneex/utils";
|
|
10039
10080
|
|
|
10040
10081
|
// src/templates/pubsub.test.txt
|
|
10041
10082
|
var pubsub_test_default = `import { describe, expect, test } from "bun:test";
|
|
@@ -10134,7 +10175,7 @@ class MakePubSubCommand {
|
|
|
10134
10175
|
if (!name) {
|
|
10135
10176
|
name = await askName({ message: "Enter name" });
|
|
10136
10177
|
}
|
|
10137
|
-
name =
|
|
10178
|
+
name = toPascalCase14(name).replace(/PubSub$/, "");
|
|
10138
10179
|
if (!channel) {
|
|
10139
10180
|
channel = toKebabCase4(name);
|
|
10140
10181
|
}
|
|
@@ -10152,7 +10193,7 @@ class MakePubSubCommand {
|
|
|
10152
10193
|
const testsDir = join25(process.cwd(), testsLocalDir);
|
|
10153
10194
|
const testFilePath = join25(testsDir, `${name}Event.spec.ts`);
|
|
10154
10195
|
await Bun.write(testFilePath, testContent);
|
|
10155
|
-
const modulePascalName = module ?
|
|
10196
|
+
const modulePascalName = module ? toPascalCase14(module) : toPascalCase14(basename5(process.cwd()));
|
|
10156
10197
|
const modulePath = join25(process.cwd(), base, "src", `${modulePascalName}Module.ts`);
|
|
10157
10198
|
if (await Bun.file(modulePath).exists()) {
|
|
10158
10199
|
await this.addToModule(modulePath, name);
|
|
@@ -10434,7 +10475,7 @@ MakeReleaseCommand = __legacyDecorateClassTS([
|
|
|
10434
10475
|
import { join as join27 } from "path";
|
|
10435
10476
|
import { decorator as decorator27 } from "@ooneex/command";
|
|
10436
10477
|
import { TerminalLogger as TerminalLogger26 } from "@ooneex/logger";
|
|
10437
|
-
import { toPascalCase as
|
|
10478
|
+
import { toPascalCase as toPascalCase15 } from "@ooneex/utils";
|
|
10438
10479
|
|
|
10439
10480
|
// src/templates/repository.test.txt
|
|
10440
10481
|
var repository_test_default = `import { describe, expect, test } from "bun:test";
|
|
@@ -10642,7 +10683,7 @@ class MakeRepositoryCommand {
|
|
|
10642
10683
|
if (!name) {
|
|
10643
10684
|
name = await askName({ message: "Enter repository name" });
|
|
10644
10685
|
}
|
|
10645
|
-
name =
|
|
10686
|
+
name = toPascalCase15(name).replace(/Repository$/, "");
|
|
10646
10687
|
const content = repository_default.replace(/{{NAME}}/g, name);
|
|
10647
10688
|
if (module) {
|
|
10648
10689
|
await ensureModule(module);
|
|
@@ -11386,7 +11427,7 @@ export class UpdateBookService implements IService {
|
|
|
11386
11427
|
import { join as join28 } from "path";
|
|
11387
11428
|
import { decorator as decorator28 } from "@ooneex/command";
|
|
11388
11429
|
import { TerminalLogger as TerminalLogger27 } from "@ooneex/logger";
|
|
11389
|
-
import { toPascalCase as
|
|
11430
|
+
import { toPascalCase as toPascalCase16 } from "@ooneex/utils";
|
|
11390
11431
|
|
|
11391
11432
|
// src/templates/service.test.txt
|
|
11392
11433
|
var service_test_default = `import { describe, expect, test } from "bun:test";
|
|
@@ -11432,7 +11473,7 @@ class MakeServiceCommand {
|
|
|
11432
11473
|
if (!name) {
|
|
11433
11474
|
name = await askName({ message: "Enter service name" });
|
|
11434
11475
|
}
|
|
11435
|
-
name =
|
|
11476
|
+
name = toPascalCase16(name).replace(/Service$/, "");
|
|
11436
11477
|
const content = service_default.replace(/{{NAME}}/g, name);
|
|
11437
11478
|
if (module) {
|
|
11438
11479
|
await ensureModule(module);
|
|
@@ -21539,7 +21580,7 @@ MakeResourceVideoCommand = __legacyDecorateClassTS([
|
|
|
21539
21580
|
import { join as join44 } from "path";
|
|
21540
21581
|
import { decorator as decorator44 } from "@ooneex/command";
|
|
21541
21582
|
import { TerminalLogger as TerminalLogger29 } from "@ooneex/logger";
|
|
21542
|
-
import { toPascalCase as
|
|
21583
|
+
import { toPascalCase as toPascalCase17, toSnakeCase as toSnakeCase3 } from "@ooneex/utils";
|
|
21543
21584
|
|
|
21544
21585
|
// src/templates/storage.test.txt
|
|
21545
21586
|
var storage_test_default = `import { describe, expect, test } from "bun:test";
|
|
@@ -21632,7 +21673,7 @@ class MakeStorageCommand {
|
|
|
21632
21673
|
if (!name) {
|
|
21633
21674
|
name = await askName({ message: "Enter storage name" });
|
|
21634
21675
|
}
|
|
21635
|
-
name =
|
|
21676
|
+
name = toPascalCase17(name).replace(/Storage$/, "");
|
|
21636
21677
|
const nameUpper = toSnakeCase3(name).toUpperCase();
|
|
21637
21678
|
const content = storage_default.replace(/{{NAME}}/g, name).replace(/{{NAME_UPPER}}/g, nameUpper);
|
|
21638
21679
|
if (module) {
|
|
@@ -21680,7 +21721,7 @@ MakeStorageCommand = __legacyDecorateClassTS([
|
|
|
21680
21721
|
import { join as join45 } from "path";
|
|
21681
21722
|
import { decorator as decorator45 } from "@ooneex/command";
|
|
21682
21723
|
import { TerminalLogger as TerminalLogger30 } from "@ooneex/logger";
|
|
21683
|
-
import { toPascalCase as
|
|
21724
|
+
import { toPascalCase as toPascalCase18 } from "@ooneex/utils";
|
|
21684
21725
|
|
|
21685
21726
|
// src/templates/vector-database.test.txt
|
|
21686
21727
|
var vector_database_test_default = `import { describe, expect, test } from "bun:test";
|
|
@@ -21748,7 +21789,7 @@ class MakeVectorDatabaseCommand {
|
|
|
21748
21789
|
if (!name) {
|
|
21749
21790
|
name = await askName({ message: "Enter vector database name" });
|
|
21750
21791
|
}
|
|
21751
|
-
name =
|
|
21792
|
+
name = toPascalCase18(name).replace(/VectorDatabase$/, "").replace(/Database$/, "");
|
|
21752
21793
|
const content = vector_database_default.replace(/{{NAME}}/g, name);
|
|
21753
21794
|
if (module) {
|
|
21754
21795
|
await ensureModule(module);
|
|
@@ -21874,7 +21915,7 @@ import { rmdir } from "fs/promises";
|
|
|
21874
21915
|
import { join as join47 } from "path";
|
|
21875
21916
|
import { decorator as decorator47 } from "@ooneex/command";
|
|
21876
21917
|
import { TerminalLogger as TerminalLogger32 } from "@ooneex/logger";
|
|
21877
|
-
import { toKebabCase as toKebabCase5, toPascalCase as
|
|
21918
|
+
import { toKebabCase as toKebabCase5, toPascalCase as toPascalCase19 } from "@ooneex/utils";
|
|
21878
21919
|
class RemoveModuleCommand {
|
|
21879
21920
|
getName() {
|
|
21880
21921
|
return "remove:module";
|
|
@@ -21940,7 +21981,7 @@ class RemoveModuleCommand {
|
|
|
21940
21981
|
if (!name) {
|
|
21941
21982
|
name = await askName({ message: "Enter module name to remove" });
|
|
21942
21983
|
}
|
|
21943
|
-
const pascalName =
|
|
21984
|
+
const pascalName = toPascalCase19(name).replace(/Module$/, "");
|
|
21944
21985
|
const kebabName = toKebabCase5(pascalName);
|
|
21945
21986
|
if (kebabName === "app" || kebabName === "shared") {
|
|
21946
21987
|
if (!silent) {
|
|
@@ -22077,4 +22118,4 @@ SeedRunCommand = __legacyDecorateClassTS([
|
|
|
22077
22118
|
// src/index.ts
|
|
22078
22119
|
await run();
|
|
22079
22120
|
|
|
22080
|
-
//# debugId=
|
|
22121
|
+
//# debugId=32D128E4E0A91A5164756E2164756E21
|