gencow 0.1.149 → 0.1.150

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/bin/gencow.mjs CHANGED
@@ -140,6 +140,7 @@ const {
140
140
  runInServer,
141
141
  });
142
142
  const runDevCloudCommand = createDevCloudCommand({
143
+ buildEnvImpl: buildEnv,
143
144
  requireCreds,
144
145
  loadConfig,
145
146
  existsSyncImpl: existsSync,
@@ -153,6 +154,8 @@ const runDevCloudCommand = createDevCloudCommand({
153
154
  updateEnvLocalUrlImpl: updateEnvLocalUrl,
154
155
  generateApiTsImpl: generateApiTs,
155
156
  drizzleKitCmdImpl: _drizzleKitCmd,
157
+ isMonorepoImpl: isMonorepo,
158
+ runInServerImpl: runInServer,
156
159
  logImpl: log,
157
160
  infoImpl: info,
158
161
  warnImpl: warn,
@@ -1,4 +1,3 @@
1
- import { execSync } from "child_process";
2
1
  import { existsSync, readFileSync, writeFileSync } from "fs";
3
2
  import { basename, resolve } from "path";
4
3
  import {
@@ -6,12 +5,12 @@ import {
6
5
  formatAuthSchemaConflictMessage,
7
6
  isServerCodegenWatchPath,
8
7
  } from "./codegen-command.mjs";
8
+ import { runDevCloudMigrationGenerate } from "./dev-cloud-migrations.mjs";
9
9
  import {
10
10
  fetchAppDiagnosticLogsViaRest,
11
11
  formatAppDiagnosticLogBlock,
12
12
  normalizeDiagnosticLogLines,
13
13
  } from "./app-diagnostics.mjs";
14
- import { createDevCloudDeployBundle } from "./dev-cloud-bundle.mjs";
15
14
 
16
15
  export function resolveDevCloudAppName({
17
16
  cloudArgs,
@@ -171,12 +170,7 @@ export function createDevCloudCommand(deps) {
171
170
  );
172
171
  }
173
172
  try {
174
- const dk = deps.drizzleKitCmdImpl("generate");
175
- execSync(dk.cmd, {
176
- cwd,
177
- env: { ...deps.processEnv, ...dk.env },
178
- stdio: "inherit",
179
- });
173
+ runDevCloudMigrationGenerate(config, deps);
180
174
  deps.logImpl(
181
175
  `${deps.DIM}${ts}${deps.RESET} ${deps.GREEN}[migrate]${deps.RESET} ✔ Migrations generated`,
182
176
  );
@@ -195,8 +189,12 @@ export function createDevCloudCommand(deps) {
195
189
  }
196
190
 
197
191
  const startMs = Date.now();
198
- const createDevCloudDeployBundleImpl =
199
- deps.createDevCloudDeployBundleImpl ?? createDevCloudDeployBundle;
192
+ let createDevCloudDeployBundleImpl = deps.createDevCloudDeployBundleImpl;
193
+ if (!createDevCloudDeployBundleImpl) {
194
+ ({ createDevCloudDeployBundle: createDevCloudDeployBundleImpl } = await import(
195
+ "./dev-cloud-bundle.mjs"
196
+ ));
197
+ }
200
198
  const { bundle, auditMessage } = await createDevCloudDeployBundleImpl({
201
199
  cwd,
202
200
  rootDir: functionsDir,
@@ -0,0 +1,28 @@
1
+ import { execSync } from "child_process";
2
+
3
+ export function runDevCloudMigrationGenerate(config, deps) {
4
+ const cwd = deps.cwdImpl();
5
+ const execSyncImpl = deps.execSyncImpl ?? execSync;
6
+ const genEnv = deps.buildEnvImpl?.(config) ?? deps.processEnv;
7
+
8
+ if (deps.isMonorepoImpl?.()) {
9
+ if (deps.runInServerImpl) {
10
+ deps.runInServerImpl("pnpm db:generate", genEnv);
11
+ } else {
12
+ execSyncImpl("pnpm db:generate", {
13
+ cwd,
14
+ env: genEnv,
15
+ stdio: "inherit",
16
+ });
17
+ }
18
+ return "server";
19
+ }
20
+
21
+ const dk = deps.drizzleKitCmdImpl("generate");
22
+ execSyncImpl(dk.cmd, {
23
+ cwd,
24
+ env: { ...genEnv, ...dk.env },
25
+ stdio: "inherit",
26
+ });
27
+ return "local";
28
+ }
@@ -23,14 +23,24 @@ export function clearCreds() {
23
23
  unlinkSync(CREDS_PATH);
24
24
  }
25
25
 
26
- export function requireCreds() {
27
- const envToken = process.env.GENCOW_TOKEN || process.env.GENCOW_DEPLOY_TOKEN;
26
+ export function resolveCredsFromSources({ env = process.env, loadCredsImpl = loadCreds } = {}) {
27
+ const envToken = env.GENCOW_TOKEN || env.GENCOW_DEPLOY_TOKEN;
28
28
  if (envToken) {
29
- const platformUrl = process.env.GENCOW_PLATFORM_URL || "https://gencow.app";
29
+ const platformUrl = env.GENCOW_PLATFORM_URL || "https://gencow.app";
30
30
  return { apiKey: envToken, platformUrl: validatePlatformUrl(platformUrl) };
31
31
  }
32
32
 
33
- const creds = loadCreds();
33
+ const creds = loadCredsImpl();
34
+ if (!creds?.apiKey) return null;
35
+ const platformUrl = env.GENCOW_PLATFORM_URL || creds.platformUrl;
36
+ if (platformUrl) {
37
+ return { ...creds, platformUrl: validatePlatformUrl(platformUrl) };
38
+ }
39
+ return creds;
40
+ }
41
+
42
+ export function requireCreds() {
43
+ const creds = resolveCredsFromSources();
34
44
  if (!creds?.apiKey) {
35
45
  if (process.env.CI) {
36
46
  error("CI environment detected but no credentials found.");
@@ -41,9 +51,6 @@ export function requireCreds() {
41
51
  }
42
52
  process.exit(1);
43
53
  }
44
- if (creds.platformUrl) {
45
- creds.platformUrl = validatePlatformUrl(creds.platformUrl);
46
- }
47
54
  return creds;
48
55
  }
49
56
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gencow",
3
- "version": "0.1.149",
3
+ "version": "0.1.150",
4
4
  "description": "Gencow — AI Backend Engine",
5
5
  "type": "module",
6
6
  "bin": {
package/server/index.js CHANGED
@@ -88337,10 +88337,10 @@ function validateBetterAuthSchemaExports(authSchemaModule) {
88337
88337
  }
88338
88338
  function resolveProjectConfigFile(functionsPath) {
88339
88339
  const projectDir = resolve3(functionsPath, "..");
88340
- const configTs = resolve3(projectDir, "gencow.config.ts");
88341
- if (existsSync2(configTs)) return configTs;
88342
88340
  const configJs = resolve3(projectDir, "gencow.config.js");
88343
- return existsSync2(configJs) ? configJs : null;
88341
+ if (existsSync2(configJs)) return configJs;
88342
+ const configTs = resolve3(projectDir, "gencow.config.ts");
88343
+ return existsSync2(configTs) ? configTs : null;
88344
88344
  }
88345
88345
  async function runStartupAudits(functionsPath) {
88346
88346
  const entryPoint = resolveFunctionsEntryPoint(functionsPath);