supabase 1.26.6 → 1.26.8

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/README.md CHANGED
@@ -49,25 +49,7 @@ brew upgrade supabase
49
49
 
50
50
  #### Windows
51
51
 
52
- Available via [Scoop](https://scoop.sh) and [Chocolatey](https://chocolatey.org).
53
-
54
- ##### via Chocolatey
55
-
56
- To install:
57
-
58
- ```powershell
59
- choco install supabase
60
- ```
61
-
62
- To upgrade:
63
-
64
- ```powershell
65
- choco upgrade supabase
66
- ```
67
-
68
- ##### via Scoop
69
-
70
- To install:
52
+ Available via [Scoop](https://scoop.sh). To install:
71
53
 
72
54
  ```powershell
73
55
  scoop bucket add supabase https://github.com/supabase/scoop-bucket.git
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "supabase",
3
- "version": "1.26.6",
3
+ "version": "1.26.8",
4
4
  "description": "Supabase CLI",
5
5
  "repository": "supabase/cli",
6
6
  "homepage": "https://supabase.com/docs/reference/cli",
@@ -12,11 +12,10 @@
12
12
  "scripts"
13
13
  ],
14
14
  "scripts": {
15
- "preinstall": "node scripts/preinstall.js"
15
+ "postinstall": "node scripts/postinstall.js"
16
16
  },
17
- "url": "https://github.com/supabase/cli/releases/download/v{{version}}/{{bin_name}}_{{version}}_{{platform}}_{{arch}}.tar.gz",
18
- "bin": "bin/supabase",
19
17
  "dependencies": {
18
+ "bin-links": "^4.0.1",
20
19
  "node-fetch": "^3.2.10",
21
20
  "tar": "6.1.13"
22
21
  },
@@ -0,0 +1,110 @@
1
+ #!/usr/bin/env node
2
+
3
+ // Ref 1: https://github.com/sanathkr/go-npm
4
+ // Ref 2: https://blog.xendit.engineer/how-we-repurposed-npm-to-publish-and-distribute-our-go-binaries-for-internal-cli-23981b80911b
5
+ "use strict";
6
+
7
+ import binLinks from "bin-links";
8
+ import fs from "fs";
9
+ import fetch from "node-fetch";
10
+ import path from "path";
11
+ import tar from "tar";
12
+ import zlib from "zlib";
13
+
14
+ // Mapping from Node's `process.arch` to Golang's `$GOARCH`
15
+ const ARCH_MAPPING = {
16
+ x64: "amd64",
17
+ arm64: "arm64",
18
+ };
19
+
20
+ // Mapping between Node's `process.platform` to Golang's
21
+ const PLATFORM_MAPPING = {
22
+ darwin: "darwin",
23
+ linux: "linux",
24
+ win32: "windows",
25
+ };
26
+
27
+ // TODO: import pkg from "../package.json" assert { type: "json" };
28
+ const readPackageJson = async () => {
29
+ const packageJsonPath = path.join(".", "package.json");
30
+ const contents = await fs.promises.readFile(packageJsonPath);
31
+ return JSON.parse(contents);
32
+ };
33
+
34
+ const parsePackageJson = (packageJson) => {
35
+ const arch = ARCH_MAPPING[process.arch];
36
+ if (!arch) {
37
+ throw Error(
38
+ "Installation is not supported for this architecture: " + process.arch
39
+ );
40
+ }
41
+
42
+ const platform = PLATFORM_MAPPING[process.platform];
43
+ if (!platform) {
44
+ throw Error(
45
+ "Installation is not supported for this platform: " + process.platform
46
+ );
47
+ }
48
+
49
+ // Build the download url from package.json
50
+ const pkgName = packageJson.name;
51
+ const version = packageJson.version;
52
+ const repo = packageJson.repository;
53
+ const url = `https://github.com/${repo}/releases/download/v${version}/${pkgName}_${version}_${platform}_${arch}.tar.gz`;
54
+
55
+ let binPath = path.join("bin", "supabase");
56
+ if (platform == "windows") {
57
+ binPath += ".exe";
58
+ }
59
+
60
+ return { binPath, url };
61
+ };
62
+
63
+ const errGlobal = `Installing Supabase CLI as a global module is not supported.
64
+ Please use one of the supported package managers: https://github.com/supabase/cli#install-the-cli
65
+ `;
66
+
67
+ /**
68
+ * Reads the configuration from application's package.json,
69
+ * downloads the binary from package url and stores at
70
+ * ./bin in the package's root.
71
+ *
72
+ * See: https://docs.npmjs.com/files/package.json#bin
73
+ */
74
+ async function main() {
75
+ const yarnGlobal = JSON.parse(
76
+ process.env.npm_config_argv || "{}"
77
+ ).original?.includes("global");
78
+ if (process.env.npm_config_global || yarnGlobal) {
79
+ throw errGlobal;
80
+ }
81
+
82
+ const pkg = await readPackageJson();
83
+ const { binPath, url } = parsePackageJson(pkg);
84
+ const binDir = path.dirname(binPath);
85
+ await fs.promises.mkdir(binDir, { recursive: true });
86
+
87
+ // First we will Un-GZip, then we will untar.
88
+ const ungz = zlib.createGunzip();
89
+ const binName = path.basename(binPath);
90
+ const untar = tar.x({ cwd: binDir }, [binName]);
91
+
92
+ console.info("Downloading", url);
93
+ const resp = await fetch(url);
94
+ resp.body.pipe(ungz).pipe(untar);
95
+ await new Promise((resolve, reject) => {
96
+ untar.on("error", reject);
97
+ untar.on("end", () => resolve());
98
+ });
99
+
100
+ // Link the binaries in postinstall to support yarn
101
+ await binLinks({
102
+ path: path.resolve("."),
103
+ pkg: { ...pkg, bin: { [pkg.name]: binPath } },
104
+ });
105
+
106
+ // TODO: verify checksums
107
+ console.info("Installed Supabase CLI successfully");
108
+ }
109
+
110
+ await main();
@@ -1,135 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // Ref 1: https://github.com/sanathkr/go-npm
4
- // Ref 2: https://blog.xendit.engineer/how-we-repurposed-npm-to-publish-and-distribute-our-go-binaries-for-internal-cli-23981b80911b
5
- "use strict";
6
-
7
- import fetch from "node-fetch";
8
- import path from "path";
9
- import tar from "tar";
10
- import zlib from "zlib";
11
- import fs from "fs";
12
-
13
- // Mapping from Node's `process.arch` to Golang's `$GOARCH`
14
- const ARCH_MAPPING = {
15
- x64: "amd64",
16
- arm64: "arm64",
17
- };
18
-
19
- // Mapping between Node's `process.platform` to Golang's
20
- const PLATFORM_MAPPING = {
21
- darwin: "darwin",
22
- linux: "linux",
23
- win32: "windows",
24
- };
25
-
26
- function validateConfiguration(packageJson) {
27
- if (!packageJson.name) {
28
- return "'name' property must be specified";
29
- }
30
-
31
- if (!packageJson.version) {
32
- return "'version' property must be specified";
33
- }
34
-
35
- if (!packageJson.bin) {
36
- return "'bin' property must be specified";
37
- }
38
-
39
- if (!packageJson.url) {
40
- return "'url' property must be specified";
41
- }
42
- }
43
-
44
- async function parsePackageJson() {
45
- if (!ARCH_MAPPING[process.arch]) {
46
- throw Error(
47
- "Installation is not supported for this architecture: " + process.arch
48
- );
49
- }
50
-
51
- if (!PLATFORM_MAPPING[process.platform]) {
52
- throw Error(
53
- "Installation is not supported for this platform: " + process.platform
54
- );
55
- }
56
-
57
- const packageJsonPath = path.join(".", "package.json");
58
- const contents = await fs.promises.readFile(packageJsonPath);
59
- const packageJson = JSON.parse(contents);
60
- const error = validateConfiguration(packageJson);
61
- if (error) {
62
- throw Error("Invalid package.json: " + error);
63
- }
64
-
65
- // We have validated the config. It exists in all its glory
66
- const pkgName = packageJson.name.toString();
67
- const bin = packageJson.bin.toString();
68
- const binName = path.basename(bin);
69
- const binPath = path.dirname(bin);
70
- let url = packageJson.url.toString();
71
- let version = packageJson.version.toString();
72
-
73
- // strip the 'v' if necessary v0.0.1 => 0.0.1
74
- if (version[0] === "v") version = version.substr(1);
75
-
76
- // Interpolate variables in URL, if necessary
77
- url = url.replace(/{{arch}}/g, ARCH_MAPPING[process.arch]);
78
- url = url.replace(/{{platform}}/g, PLATFORM_MAPPING[process.platform]);
79
- url = url.replace(/{{version}}/g, version);
80
- url = url.replace(/{{bin_name}}/g, binName);
81
-
82
- return { pkgName, binName, binPath, url, version };
83
- }
84
-
85
- const errGlobal = `Installing Supabase CLI as a global module is not supported.
86
- Please use one of the supported package managers: https://github.com/supabase/cli#install-the-cli
87
- `;
88
-
89
- /**
90
- * Reads the configuration from application's package.json,
91
- * validates properties, copied the binary from the package and stores at
92
- * ./bin in the package's root.
93
- *
94
- * See: https://docs.npmjs.com/files/package.json#bin
95
- */
96
- async function main() {
97
- if (process.env.npm_config_global) {
98
- throw errGlobal;
99
- }
100
-
101
- const opts = await parsePackageJson();
102
- await fs.promises.mkdir(opts.binPath, { recursive: true });
103
-
104
- // First we will Un-GZip, then we will untar.
105
- const ungz = zlib.createGunzip();
106
- // Binary name on Windows has .exe suffix
107
- const ext = process.platform === "win32" ? ".exe" : "";
108
- const untar = tar.x({ cwd: opts.binPath }, [opts.binName + ext]);
109
-
110
- console.info("Downloading", opts.url);
111
- const resp = await fetch(opts.url);
112
- resp.body.pipe(ungz).pipe(untar);
113
- await new Promise((resolve, reject) => {
114
- untar.on("error", reject);
115
- untar.on("end", () => resolve());
116
- });
117
-
118
- // Creates a hardlink for npm to find the binary on Windows
119
- if (ext) {
120
- const bin = path.join(opts.binPath, opts.binName);
121
- await fs.promises.link(bin + ext, bin);
122
- }
123
-
124
- // Copy binary because yarn runs as postinstall
125
- if (process.env.npm_config_user_agent.startsWith("yarn/")) {
126
- const src = path.join("..", opts.pkgName, opts.binPath, opts.binName);
127
- const dst = path.join("..", ".bin", opts.binName);
128
- await fs.promises.symlink(src, dst);
129
- }
130
-
131
- // TODO: verify checksums
132
- console.info("Installed Supabase CLI successfully");
133
- }
134
-
135
- await main();