@cedarjs/cli 6.0.0-canary.2873 → 6.0.0-canary.2875

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.
@@ -9,6 +9,22 @@ import {
9
9
  checkProjectShape,
10
10
  getSqliteToPostgresTasks
11
11
  } from "../database/postgresHandler.js";
12
+ function isPostgresConnectionString(rawValue) {
13
+ let value = rawValue.trim();
14
+ const quoted = value.match(/^(['"])(.*)\1$/);
15
+ if (quoted) {
16
+ value = quoted[2];
17
+ }
18
+ if (!value) {
19
+ return false;
20
+ }
21
+ try {
22
+ const url = new URL(value);
23
+ return (url.protocol === "postgres:" || url.protocol === "postgresql:") && !!url.hostname;
24
+ } catch {
25
+ return false;
26
+ }
27
+ }
12
28
  async function handler({ force }) {
13
29
  const cedarPaths = getPaths();
14
30
  const shape = checkProjectShape(cedarPaths);
@@ -23,9 +39,8 @@ async function handler({ force }) {
23
39
  const envPath = path.join(cedarPaths.base, ".env");
24
40
  let hasExistingDatabaseUrl = false;
25
41
  if (fs.existsSync(envPath)) {
26
- hasExistingDatabaseUrl = /^DATABASE_URL=/m.test(
27
- fs.readFileSync(envPath, "utf-8")
28
- );
42
+ const match = fs.readFileSync(envPath, "utf-8").match(/^DATABASE_URL=(.*)$/m);
43
+ hasExistingDatabaseUrl = !!match?.[1] && isPostgresConnectionString(match[1]);
29
44
  }
30
45
  const skipProvisioning = hasExistingDatabaseUrl && !force;
31
46
  const notes = [];
@@ -152,13 +167,11 @@ You can try running it manually:
152
167
  let envContent = "";
153
168
  if (fs.existsSync(envPath)) {
154
169
  envContent = fs.readFileSync(envPath, "utf-8");
155
- if (force) {
156
- const lines = envContent.split("\n");
157
- const filtered = lines.filter(
158
- (line) => !line.startsWith("DATABASE_URL=") && !line.startsWith("DIRECT_DATABASE_URL=")
159
- );
160
- envContent = filtered.join("\n").trimEnd();
161
- }
170
+ const lines = envContent.split("\n");
171
+ const filtered = lines.filter(
172
+ (line) => !line.startsWith("DATABASE_URL=") && !line.startsWith("DIRECT_DATABASE_URL=")
173
+ );
174
+ envContent = filtered.join("\n").trimEnd();
162
175
  if (envContent && !envContent.endsWith("\n")) {
163
176
  envContent += "\n";
164
177
  }
@@ -15,9 +15,10 @@ import { isTypeScriptProject } from "../../../lib/project.js";
15
15
  import { runTransform } from "../../../lib/runTransform.js";
16
16
  const handler = async ({ force }) => {
17
17
  const projectIsTypescript = isTypeScriptProject();
18
- const redwoodVersion = await import(path.join(getPaths().base, "package.json"), {
19
- with: { type: "json " }
20
- }).default.devDependencies["@cedarjs/core"] ?? "latest";
18
+ const packageJson = await import(path.join(getPaths().base, "package.json"), {
19
+ with: { type: "json" }
20
+ });
21
+ const cedarVersion = packageJson.default.devDependencies["@cedarjs/core"] ?? "latest";
21
22
  const tasks = new Listr(
22
23
  [
23
24
  {
@@ -65,7 +66,7 @@ const handler = async ({ force }) => {
65
66
  }
66
67
  },
67
68
  {
68
- ...addApiPackages([`@cedarjs/storage@${redwoodVersion}`]),
69
+ ...addApiPackages([`@cedarjs/storage@${cedarVersion}`]),
69
70
  title: "Adding dependencies to your api side..."
70
71
  },
71
72
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/cli",
3
- "version": "6.0.0-canary.2873",
3
+ "version": "6.0.0-canary.2875",
4
4
  "description": "The CedarJS Command Line",
5
5
  "repository": {
6
6
  "type": "git",
@@ -36,17 +36,17 @@
36
36
  "@babel/preset-typescript": "7.29.7",
37
37
  "@babel/traverse": "7.29.7",
38
38
  "@babel/types": "7.29.7",
39
- "@cedarjs/api-server": "6.0.0-canary.2873",
40
- "@cedarjs/babel-config": "6.0.0-canary.2873",
41
- "@cedarjs/cli-helpers": "6.0.0-canary.2873",
42
- "@cedarjs/internal": "6.0.0-canary.2873",
43
- "@cedarjs/prerender": "6.0.0-canary.2873",
44
- "@cedarjs/project-config": "6.0.0-canary.2873",
45
- "@cedarjs/structure": "6.0.0-canary.2873",
46
- "@cedarjs/telemetry": "6.0.0-canary.2873",
47
- "@cedarjs/utils": "6.0.0-canary.2873",
48
- "@cedarjs/vite": "6.0.0-canary.2873",
49
- "@cedarjs/web-server": "6.0.0-canary.2873",
39
+ "@cedarjs/api-server": "6.0.0-canary.2875",
40
+ "@cedarjs/babel-config": "6.0.0-canary.2875",
41
+ "@cedarjs/cli-helpers": "6.0.0-canary.2875",
42
+ "@cedarjs/internal": "6.0.0-canary.2875",
43
+ "@cedarjs/prerender": "6.0.0-canary.2875",
44
+ "@cedarjs/project-config": "6.0.0-canary.2875",
45
+ "@cedarjs/structure": "6.0.0-canary.2875",
46
+ "@cedarjs/telemetry": "6.0.0-canary.2875",
47
+ "@cedarjs/utils": "6.0.0-canary.2875",
48
+ "@cedarjs/vite": "6.0.0-canary.2875",
49
+ "@cedarjs/web-server": "6.0.0-canary.2875",
50
50
  "@listr2/prompt-adapter-enquirer": "4.3.0",
51
51
  "@opentelemetry/api": "1.9.1",
52
52
  "@opentelemetry/core": "1.30.1",
@@ -94,7 +94,7 @@
94
94
  "yargs": "17.7.3"
95
95
  },
96
96
  "devDependencies": {
97
- "@cedarjs/framework-tools": "6.0.0-canary.2873",
97
+ "@cedarjs/framework-tools": "6.0.0-canary.2875",
98
98
  "@prisma/dmmf": "7.8.0",
99
99
  "@types/archiver": "^7.0.0",
100
100
  "memfs": "4.64.0",