cloudflare-next-intl 0.8.11 → 0.8.12

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.
Files changed (2) hide show
  1. package/bin/db_codegen.mjs +29 -1
  2. package/package.json +1 -1
@@ -40,6 +40,7 @@ import { runInstallExecStep } from './install_exec_step.mjs';
40
40
  import { startEphemeralPostgres } from './ephemeral_pg.mjs';
41
41
  import { orderedSqlFiles } from './ddl_order.mjs';
42
42
 
43
+ const PACKAGE_ROOT = new URL('..', import.meta.url).pathname;
43
44
  const paths = resolveCodegenPaths(process.argv.slice(2), process.env, process.cwd());
44
45
 
45
46
  async function isReachable(url) {
@@ -97,6 +98,12 @@ if (paths.check) {
97
98
 
98
99
  let effectiveDbUrl = paths.dbUrl;
99
100
  let ephemeral = null;
101
+ // drizzle-kit's own default config resolution looks for `drizzle.config.json`
102
+ // in the cwd and errors out if it's missing — a project has no reason to
103
+ // keep one around just for this script when --db-url/CODEGEN_DATABASE_URL
104
+ // (or the ephemeral fallback) already says everything drizzle-kit needs. So
105
+ // when the caller didn't pass --drizzle-config, generate one on the fly.
106
+ let generatedConfigPath = null;
100
107
  try {
101
108
  if (!(await isReachable(paths.dbUrl))) {
102
109
  if (paths.dbUrlExplicit) failUnreachable(paths.dbUrl);
@@ -105,13 +112,34 @@ try {
105
112
  effectiveDbUrl = ephemeral.url;
106
113
  }
107
114
 
115
+ let configPath = paths.drizzleConfig;
116
+ if (!configPath) {
117
+ generatedConfigPath = join(paths.pullDir, '..', '.drizzle-config.json');
118
+ mkdirSync(join(paths.pullDir, '..'), { recursive: true });
119
+ writeFileSync(generatedConfigPath, JSON.stringify({
120
+ out: paths.pullDir,
121
+ dialect: 'postgresql',
122
+ dbCredentials: { url: effectiveDbUrl },
123
+ }, null, 2));
124
+ configPath = generatedConfigPath;
125
+ }
126
+
108
127
  rmSync(paths.pullDir, { recursive: true, force: true });
109
- execFileSync('npx', ['drizzle-kit', 'pull', ...(paths.drizzleConfig ? [`--config=${paths.drizzleConfig}`] : [])], {
128
+ // drizzle-kit itself requires `drizzle-orm` at runtime. This package
129
+ // depends on drizzle-orm, but npm doesn't guarantee that dependency gets
130
+ // hoisted to the consuming project's own node_modules (it commonly stays
131
+ // nested under node_modules/cloudflare-next-intl/node_modules) — so
132
+ // running from *this* package's own directory, where it's guaranteed
133
+ // resolvable, avoids "please install required packages: drizzle-orm"
134
+ // when a consumer doesn't happen to have it hoisted.
135
+ execFileSync('npx', ['drizzle-kit', 'pull', `--config=${configPath}`], {
110
136
  stdio: 'inherit',
137
+ cwd: PACKAGE_ROOT,
111
138
  env: { ...process.env, CODEGEN_DATABASE_URL: effectiveDbUrl },
112
139
  });
113
140
  } finally {
114
141
  if (ephemeral) await ephemeral.stop();
142
+ if (generatedConfigPath) rmSync(generatedConfigPath, { force: true });
115
143
  }
116
144
 
117
145
  const pulled = join(paths.pullDir, "schema.ts");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudflare-next-intl",
3
- "version": "0.8.11",
3
+ "version": "0.8.12",
4
4
  "description": "Optimized Next Intl Package Special for App Router and Cloudflare",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",