supabase 1.137.1 → 1.137.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "supabase",
3
- "version": "1.137.1",
3
+ "version": "1.137.3",
4
4
  "description": "Supabase CLI",
5
5
  "repository": "supabase/cli",
6
6
  "homepage": "https://supabase.com/docs/reference/cli",
@@ -28,41 +28,21 @@ const PLATFORM_MAPPING = {
28
28
  };
29
29
 
30
30
  const arch = ARCH_MAPPING[process.arch];
31
-
32
31
  const platform = PLATFORM_MAPPING[process.platform];
33
32
 
34
33
  // TODO: import pkg from "../package.json" assert { type: "json" };
35
34
  const readPackageJson = async () => {
36
- const packageJsonPath = path.join(".", "package.json");
37
- const contents = await fs.promises.readFile(packageJsonPath);
35
+ const contents = await fs.promises.readFile("package.json");
38
36
  return JSON.parse(contents);
39
37
  };
40
38
 
41
- const parsePackageJson = (packageJson) => {
42
- if (!arch) {
43
- throw Error(
44
- "Installation is not supported for this architecture: " + process.arch
45
- );
46
- }
47
-
48
- if (!platform) {
49
- throw Error(
50
- "Installation is not supported for this platform: " + process.platform
51
- );
52
- }
53
-
54
- // Build the download url from package.json
39
+ // Build the download url from package.json
40
+ const getDownloadUrl = (packageJson) => {
55
41
  const pkgName = packageJson.name;
56
42
  const version = packageJson.version;
57
43
  const repo = packageJson.repository;
58
44
  const url = `https://github.com/${repo}/releases/download/v${version}/${pkgName}_${platform}_${arch}.tar.gz`;
59
-
60
- let binPath = path.join("bin", "supabase");
61
- if (platform == "windows") {
62
- binPath += ".exe";
63
- }
64
-
65
- return { binPath, url };
45
+ return url;
66
46
  };
67
47
 
68
48
  const fetchAndParseCheckSumFile = async (packageJson, agent) => {
@@ -98,6 +78,7 @@ const errGlobal = `Installing Supabase CLI as a global module is not supported.
98
78
  Please use one of the supported package managers: https://github.com/supabase/cli#install-the-cli
99
79
  `;
100
80
  const errChecksum = "Checksum mismatch. Downloaded data might be corrupted.";
81
+ const errUnsupported = `Installation is not supported for ${process.platform} ${process.arch}`;
101
82
 
102
83
  /**
103
84
  * Reads the configuration from application's package.json,
@@ -113,9 +94,17 @@ async function main() {
113
94
  if (process.env.npm_config_global || yarnGlobal) {
114
95
  throw errGlobal;
115
96
  }
97
+ if (!arch || !platform) {
98
+ throw errUnsupported;
99
+ }
116
100
 
117
101
  const pkg = await readPackageJson();
118
- const { binPath, url } = parsePackageJson(pkg);
102
+ if (platform === "windows") {
103
+ // Update bin path in package.json
104
+ pkg.bin[pkg.name] += ".exe";
105
+ }
106
+
107
+ const binPath = pkg.bin[pkg.name];
119
108
  const binDir = path.dirname(binPath);
120
109
  await fs.promises.mkdir(binDir, { recursive: true });
121
110
 
@@ -124,6 +113,7 @@ async function main() {
124
113
  const binName = path.basename(binPath);
125
114
  const untar = tar.x({ cwd: binDir }, [binName]);
126
115
 
116
+ const url = getDownloadUrl(pkg);
127
117
  console.info("Downloading", url);
128
118
  const proxyUrl =
129
119
  process.env.npm_config_https_proxy ||