@tachybase/test 1.6.13-alpha.6 → 1.6.13

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/es/index.mjs CHANGED
@@ -326,6 +326,7 @@ function patchPluginRuntime(core, workspaceRoot, packageDirByPluginName) {
326
326
  return;
327
327
  }
328
328
  const originalLoadCollections = core.Plugin.prototype.loadCollections;
329
+ const originalLoadMigrations = core.Plugin.prototype.loadMigrations;
329
330
  core.Plugin.prototype.loadCollections = async function loadWorkspaceCollections() {
330
331
  var _a, _b;
331
332
  const currentOptions = getServerTestEnvironmentOptions(core);
@@ -346,6 +347,29 @@ function patchPluginRuntime(core, workspaceRoot, packageDirByPluginName) {
346
347
  from: this.options.packageName
347
348
  });
348
349
  };
350
+ core.Plugin.prototype.loadMigrations = async function loadWorkspaceMigrations() {
351
+ var _a, _b;
352
+ const currentOptions = getServerTestEnvironmentOptions(core);
353
+ const currentWorkspaceRoot = (currentOptions == null ? void 0 : currentOptions.workspaceRoot) || workspaceRoot;
354
+ const currentPackageDirByPluginName = (currentOptions == null ? void 0 : currentOptions.packageDirByPluginName) || packageDirByPluginName;
355
+ const packageDir = ((_a = this.options) == null ? void 0 : _a.workspaceSource) ? workspacePackageDirByPackageName(currentWorkspaceRoot, (_b = this.options) == null ? void 0 : _b.packageName, currentPackageDirByPluginName) : null;
356
+ if (!packageDir) {
357
+ return originalLoadMigrations.call(this);
358
+ }
359
+ const sourceDirectory = path.resolve(currentWorkspaceRoot, "packages", packageDir, "src/server/migrations");
360
+ const compiledDirectory = path.resolve(currentWorkspaceRoot, "packages", packageDir, "dist/server/migrations");
361
+ const directory = fs.existsSync(compiledDirectory) ? compiledDirectory : sourceDirectory;
362
+ if (!fs.existsSync(directory)) {
363
+ return { beforeLoad: [], afterSync: [], afterLoad: [] };
364
+ }
365
+ return this.app.loadMigrations({
366
+ directory: directory.replace(/\\/g, "/"),
367
+ namespace: this.options.packageName,
368
+ context: {
369
+ plugin: this
370
+ }
371
+ });
372
+ };
349
373
  core.Plugin.prototype.__serverTestEnvironmentPatched = true;
350
374
  }
351
375
  function getPluginManagerOptions(PluginManager2) {
@@ -590,6 +614,11 @@ function setupServerTestEnvironment(options = {}) {
590
614
  TachybaseGlobal.settings = testSettings;
591
615
  ImportedTachybaseGlobal.getInstance().set("PLUGIN_PATHS", pluginPaths);
592
616
  TachybaseGlobal.getInstance().set("PLUGIN_PATHS", pluginPaths);
617
+ const workerPaths = [workspaceRoot, ...pluginPaths];
618
+ ImportedTachybaseGlobal.getInstance().set("WORKER_PATHS", workerPaths);
619
+ ImportedTachybaseGlobal.getInstance().set("WORKER_MODULES", []);
620
+ TachybaseGlobal.getInstance().set("WORKER_PATHS", workerPaths);
621
+ TachybaseGlobal.getInstance().set("WORKER_MODULES", []);
593
622
  process.env.TEGO_RUNTIME_HOME = path.join(os.tmpdir(), "test-sqlite");
594
623
  process.env.APP_ENV_PATH = process.env.APP_ENV_PATH || ".env.test";
595
624
  const coreModules = getCoreModules(workspaceRoot, runtimeRequire2);
@@ -160,6 +160,7 @@ function patchPluginRuntime(core, workspaceRoot, packageDirByPluginName) {
160
160
  return;
161
161
  }
162
162
  const originalLoadCollections = core.Plugin.prototype.loadCollections;
163
+ const originalLoadMigrations = core.Plugin.prototype.loadMigrations;
163
164
  core.Plugin.prototype.loadCollections = /* @__PURE__ */ __name(async function loadWorkspaceCollections() {
164
165
  var _a, _b;
165
166
  const currentOptions = getServerTestEnvironmentOptions(core);
@@ -180,6 +181,29 @@ function patchPluginRuntime(core, workspaceRoot, packageDirByPluginName) {
180
181
  from: this.options.packageName
181
182
  });
182
183
  }, "loadWorkspaceCollections");
184
+ core.Plugin.prototype.loadMigrations = /* @__PURE__ */ __name(async function loadWorkspaceMigrations() {
185
+ var _a, _b;
186
+ const currentOptions = getServerTestEnvironmentOptions(core);
187
+ const currentWorkspaceRoot = (currentOptions == null ? void 0 : currentOptions.workspaceRoot) || workspaceRoot;
188
+ const currentPackageDirByPluginName = (currentOptions == null ? void 0 : currentOptions.packageDirByPluginName) || packageDirByPluginName;
189
+ const packageDir = ((_a = this.options) == null ? void 0 : _a.workspaceSource) ? workspacePackageDirByPackageName(currentWorkspaceRoot, (_b = this.options) == null ? void 0 : _b.packageName, currentPackageDirByPluginName) : null;
190
+ if (!packageDir) {
191
+ return originalLoadMigrations.call(this);
192
+ }
193
+ const sourceDirectory = import_node_path.default.resolve(currentWorkspaceRoot, "packages", packageDir, "src/server/migrations");
194
+ const compiledDirectory = import_node_path.default.resolve(currentWorkspaceRoot, "packages", packageDir, "dist/server/migrations");
195
+ const directory = import_node_fs.default.existsSync(compiledDirectory) ? compiledDirectory : sourceDirectory;
196
+ if (!import_node_fs.default.existsSync(directory)) {
197
+ return { beforeLoad: [], afterSync: [], afterLoad: [] };
198
+ }
199
+ return this.app.loadMigrations({
200
+ directory: directory.replace(/\\/g, "/"),
201
+ namespace: this.options.packageName,
202
+ context: {
203
+ plugin: this
204
+ }
205
+ });
206
+ }, "loadWorkspaceMigrations");
183
207
  core.Plugin.prototype.__serverTestEnvironmentPatched = true;
184
208
  }
185
209
  __name(patchPluginRuntime, "patchPluginRuntime");
@@ -428,6 +452,11 @@ function setupServerTestEnvironment(options = {}) {
428
452
  TachybaseGlobal.settings = testSettings;
429
453
  ImportedTachybaseGlobal.getInstance().set("PLUGIN_PATHS", pluginPaths);
430
454
  TachybaseGlobal.getInstance().set("PLUGIN_PATHS", pluginPaths);
455
+ const workerPaths = [workspaceRoot, ...pluginPaths];
456
+ ImportedTachybaseGlobal.getInstance().set("WORKER_PATHS", workerPaths);
457
+ ImportedTachybaseGlobal.getInstance().set("WORKER_MODULES", []);
458
+ TachybaseGlobal.getInstance().set("WORKER_PATHS", workerPaths);
459
+ TachybaseGlobal.getInstance().set("WORKER_MODULES", []);
431
460
  process.env.TEGO_RUNTIME_HOME = import_node_path.default.join(import_node_os.default.tmpdir(), "test-sqlite");
432
461
  process.env.APP_ENV_PATH = process.env.APP_ENV_PATH || ".env.test";
433
462
  const coreModules = getCoreModules(workspaceRoot, runtimeRequire2);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tachybase/test",
3
- "version": "1.6.13-alpha.6",
3
+ "version": "1.6.13",
4
4
  "homepage": "https://github.com/tegojs/tego#readme",
5
5
  "bugs": {
6
6
  "url": "https://github.com/tegojs/tego/issues"
@@ -113,9 +113,9 @@
113
113
  "vite": "^7.1.10",
114
114
  "vitest": "^3.2.4",
115
115
  "ws": "^8.18.3",
116
- "@tachybase/database": "1.6.13-alpha.6",
117
- "@tachybase/globals": "1.6.13-alpha.6",
118
- "@tachybase/schema": "1.6.13-alpha.6",
119
- "@tego/core": "1.6.13-alpha.6"
116
+ "@tachybase/database": "1.6.13",
117
+ "@tachybase/globals": "1.6.13",
118
+ "@tachybase/schema": "1.6.13",
119
+ "@tego/core": "1.6.13"
120
120
  }
121
121
  }