mirror of
https://github.com/supabase/setup-cli.git
synced 2025-12-09 00:26:26 +00:00
Compare commits
54 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6333c3ad34 | ||
|
|
8b3b75ec99 | ||
|
|
8063edec5e | ||
|
|
d1164a571c | ||
|
|
f7a48658a9 | ||
|
|
013774d7d3 | ||
|
|
0f5e0d0baa | ||
|
|
ceb5052778 | ||
|
|
c8cd7a03b4 | ||
|
|
57c56478ca | ||
|
|
5d9fef7ab8 | ||
|
|
3da7e3232b | ||
|
|
a3322b63a7 | ||
|
|
218a5451ba | ||
|
|
e990a6e26d | ||
|
|
73c42f5dba | ||
|
|
3a4bba5a28 | ||
|
|
0e780eb864 | ||
|
|
f81d675039 | ||
|
|
6718044ec1 | ||
|
|
7d56f2db9d | ||
|
|
d7efa72006 | ||
|
|
ee5499d01d | ||
|
|
9f63332370 | ||
|
|
a62fb52b38 | ||
|
|
cd1e126b6f | ||
|
|
10ad2f1d23 | ||
|
|
3d32144eb9 | ||
|
|
a1b47ce810 | ||
|
|
f048ce30f1 | ||
|
|
1b71a28a2c | ||
|
|
ea547232eb | ||
|
|
0862b396ee | ||
|
|
13f2fdc1d3 | ||
|
|
bf3ce30bf7 | ||
|
|
26598ee1fd | ||
|
|
108ac2dc5f | ||
|
|
e0fe0493e6 | ||
|
|
9a74081b27 | ||
|
|
d7405cc5a0 | ||
|
|
e88752ef33 | ||
|
|
3c43bae0cc | ||
|
|
92b228ec3c | ||
|
|
308fdb678c | ||
|
|
041b4399ad | ||
|
|
8e954081db | ||
|
|
9b4752b18d | ||
|
|
52e4aa5f9f | ||
|
|
93ffe6ac11 | ||
|
|
7b865bc28c | ||
|
|
3fad79ab52 | ||
|
|
c7aa2dced8 | ||
|
|
6439e03aa2 | ||
|
|
63ceca492b |
3
.github/workflows/check-dist.yml
vendored
3
.github/workflows/check-dist.yml
vendored
@@ -24,9 +24,10 @@ jobs:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Set Node.js 16.x
|
||||
uses: actions/setup-node@v3.5.1
|
||||
uses: actions/setup-node@v3.6.0
|
||||
with:
|
||||
node-version: 16.x
|
||||
cache: npm
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
2
.github/workflows/dependabot.yml
vendored
2
.github/workflows/dependabot.yml
vendored
@@ -18,7 +18,7 @@ jobs:
|
||||
# will not occur.
|
||||
- name: Dependabot metadata
|
||||
id: dependabot-metadata
|
||||
uses: dependabot/fetch-metadata@v1.3.5
|
||||
uses: dependabot/fetch-metadata@v1.4.0
|
||||
with:
|
||||
github-token: '${{ secrets.GITHUB_TOKEN }}'
|
||||
|
||||
|
||||
5
.github/workflows/start.yml
vendored
5
.github/workflows/start.yml
vendored
@@ -4,7 +4,7 @@ on:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- 'v*'
|
||||
- 'v[0-9]+.[0-9]+.[0-9]+'
|
||||
schedule:
|
||||
# * is a special character in YAML so you have to quote this string
|
||||
- cron: '30 1,9 * * *'
|
||||
@@ -13,9 +13,6 @@ defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
jobs:
|
||||
e2e: # make sure the action works on a clean machine without building
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
3
.github/workflows/test.yml
vendored
3
.github/workflows/test.yml
vendored
@@ -9,9 +9,6 @@ defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
jobs:
|
||||
build: # make sure build/ci work properly
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
@@ -24,7 +24,7 @@ A specific version of the `supabase` CLI can be installed:
|
||||
steps:
|
||||
- uses: supabase/setup-cli@v1
|
||||
with:
|
||||
version: 1.28.0
|
||||
version: 1.28.3
|
||||
```
|
||||
|
||||
Run `supabase db start` to execute all migrations on a fresh database:
|
||||
@@ -46,7 +46,7 @@ The actions supports the following inputs:
|
||||
|
||||
| Name | Type | Description | Default | Required |
|
||||
| --------- | ------ | ---------------------------------- | -------- | -------- |
|
||||
| `version` | String | Supabase CLI version (or `latest`) | `1.28.0` | false |
|
||||
| `version` | String | Supabase CLI version (or `latest`) | `1.28.3` | false |
|
||||
|
||||
## Advanced Usage
|
||||
|
||||
@@ -117,7 +117,7 @@ Actions are run from GitHub repos so we will checkin the packed dist folder.
|
||||
Then run [ncc](https://github.com/zeit/ncc) and push the results:
|
||||
|
||||
```bash
|
||||
$ npm run package
|
||||
$ npm run all
|
||||
$ git add dist
|
||||
$ git commit -a -m "Update dependencies"
|
||||
$ git push origin releases/v1
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import {getDownloadUrl} from '../src/utils'
|
||||
import {CLI_CONFIG_REGISTRY} from '../src/main'
|
||||
import * as os from 'os'
|
||||
import * as process from 'process'
|
||||
import * as cp from 'child_process'
|
||||
import * as path from 'path'
|
||||
import * as fs from 'fs'
|
||||
import * as yaml from 'js-yaml'
|
||||
import {expect, test} from '@jest/globals'
|
||||
|
||||
test('gets download url to binary', async () => {
|
||||
@@ -36,11 +39,17 @@ test('gets download url to latest version', async () => {
|
||||
// shows how the runner will run a javascript action with env / stdout protocol
|
||||
test('test runs', () => {
|
||||
process.env['RUNNER_TEMP'] = os.tmpdir()
|
||||
process.env['INPUT_VERSION'] = '1.0.0'
|
||||
const config = path.join(__dirname, '..', 'action.yml')
|
||||
const action: any = yaml.load(fs.readFileSync(config, 'utf8'))
|
||||
process.env['INPUT_VERSION'] = action.inputs.version.default
|
||||
const np = process.execPath
|
||||
const ip = path.join(__dirname, '..', 'lib', 'main.js')
|
||||
const options: cp.ExecFileSyncOptions = {
|
||||
env: process.env
|
||||
}
|
||||
console.log(cp.execFileSync(np, [ip], options).toString())
|
||||
const stdout = cp.execFileSync(np, [ip], options).toString()
|
||||
console.log(stdout)
|
||||
expect
|
||||
.stringContaining(`::set-env name=${CLI_CONFIG_REGISTRY}::`)
|
||||
.asymmetricMatch(stdout)
|
||||
})
|
||||
|
||||
@@ -5,7 +5,10 @@ inputs:
|
||||
version:
|
||||
description: Version of Supabase CLI to install
|
||||
required: false
|
||||
default: 1.28.0
|
||||
default: 1.28.3
|
||||
outputs:
|
||||
version:
|
||||
description: Version of installed Supabase CLI
|
||||
runs:
|
||||
using: node16
|
||||
main: dist/index.js
|
||||
|
||||
37
dist/index.js
generated
vendored
37
dist/index.js
generated
vendored
@@ -38,10 +38,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.CLI_CONFIG_REGISTRY = void 0;
|
||||
const core = __importStar(__nccwpck_require__(2186));
|
||||
const tc = __importStar(__nccwpck_require__(7784));
|
||||
const gte_1 = __importDefault(__nccwpck_require__(5522));
|
||||
const utils_1 = __nccwpck_require__(918);
|
||||
exports.CLI_CONFIG_REGISTRY = 'SUPABASE_INTERNAL_IMAGE_REGISTRY';
|
||||
function run() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
@@ -54,6 +60,13 @@ function run() {
|
||||
const pathToCLI = yield tc.extractTar(pathToTarball);
|
||||
// Expose the tool by adding it to the PATH
|
||||
core.addPath(pathToCLI);
|
||||
// Expose installed tool version
|
||||
const determinedVersion = yield (0, utils_1.determineInstalledVersion)();
|
||||
core.setOutput('version', determinedVersion);
|
||||
// Use GHCR mirror by default
|
||||
if (version.toLowerCase() === 'latest' || (0, gte_1.default)(version, '1.28.0')) {
|
||||
core.exportVariable(exports.CLI_CONFIG_REGISTRY, 'ghcr.io');
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
if (error instanceof Error)
|
||||
@@ -84,9 +97,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.getDownloadUrl = void 0;
|
||||
exports.determineInstalledVersion = exports.getDownloadUrl = void 0;
|
||||
const child_process_1 = __nccwpck_require__(2081);
|
||||
const os_1 = __importDefault(__nccwpck_require__(2037));
|
||||
const lt_1 = __importDefault(__nccwpck_require__(194));
|
||||
const util_1 = __nccwpck_require__(3837);
|
||||
const doExec = (0, util_1.promisify)(child_process_1.exec);
|
||||
// arch in [arm, arm64, x64...] (https://nodejs.org/docs/latest-v16.x/api/os.html#osarch)
|
||||
// return value in [amd64, arm64, arm]
|
||||
const mapArch = (arch) => {
|
||||
@@ -116,6 +132,15 @@ const getDownloadUrl = (version) => __awaiter(void 0, void 0, void 0, function*
|
||||
return `https://github.com/supabase/cli/releases/download/v${version}/${filename}`;
|
||||
});
|
||||
exports.getDownloadUrl = getDownloadUrl;
|
||||
const determineInstalledVersion = () => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const { stdout } = yield doExec('supabase --version');
|
||||
const version = stdout.trim();
|
||||
if (!version) {
|
||||
throw new Error('Could not determine installed Supabase CLI version');
|
||||
}
|
||||
return version;
|
||||
});
|
||||
exports.determineInstalledVersion = determineInstalledVersion;
|
||||
|
||||
|
||||
/***/ }),
|
||||
@@ -6598,6 +6623,16 @@ const compare = (a, b, loose) =>
|
||||
module.exports = compare
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 5522:
|
||||
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
||||
|
||||
const compare = __nccwpck_require__(4309)
|
||||
const gte = (a, b, loose) => compare(a, b, loose) >= 0
|
||||
module.exports = gte
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 194:
|
||||
|
||||
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
1423
package-lock.json
generated
1423
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
18
package.json
18
package.json
@@ -27,18 +27,20 @@
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.10.0",
|
||||
"@actions/tool-cache": "^2.0.1",
|
||||
"semver": "^7.3.8"
|
||||
"semver": "^7.5.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/js-yaml": "^4.0.5",
|
||||
"@types/node": "^16.11.47",
|
||||
"@types/semver": "^7.3.13",
|
||||
"@typescript-eslint/parser": "^5.48.0",
|
||||
"@vercel/ncc": "^0.36.0",
|
||||
"eslint": "^8.31.0",
|
||||
"eslint-plugin-github": "^4.6.0",
|
||||
"eslint-plugin-jest": "^27.2.0",
|
||||
"@types/semver": "^7.5.0",
|
||||
"@typescript-eslint/parser": "^5.59.6",
|
||||
"@vercel/ncc": "^0.36.1",
|
||||
"eslint": "^8.40.0",
|
||||
"eslint-plugin-github": "^4.7.0",
|
||||
"eslint-plugin-jest": "^27.2.1",
|
||||
"jest": "^28.1.3",
|
||||
"prettier": "2.8.1",
|
||||
"js-yaml": "^4.1.0",
|
||||
"prettier": "2.8.8",
|
||||
"ts-jest": "^28.0.8",
|
||||
"typescript": "^4.8.4"
|
||||
}
|
||||
|
||||
14
src/main.ts
14
src/main.ts
@@ -1,6 +1,9 @@
|
||||
import * as core from '@actions/core'
|
||||
import * as tc from '@actions/tool-cache'
|
||||
import {getDownloadUrl} from './utils'
|
||||
import gte from 'semver/functions/gte'
|
||||
import {getDownloadUrl, determineInstalledVersion} from './utils'
|
||||
|
||||
export const CLI_CONFIG_REGISTRY = 'SUPABASE_INTERNAL_IMAGE_REGISTRY'
|
||||
|
||||
async function run(): Promise<void> {
|
||||
try {
|
||||
@@ -16,6 +19,15 @@ async function run(): Promise<void> {
|
||||
|
||||
// Expose the tool by adding it to the PATH
|
||||
core.addPath(pathToCLI)
|
||||
|
||||
// Expose installed tool version
|
||||
const determinedVersion = await determineInstalledVersion()
|
||||
core.setOutput('version', determinedVersion)
|
||||
|
||||
// Use GHCR mirror by default
|
||||
if (version.toLowerCase() === 'latest' || gte(version, '1.28.0')) {
|
||||
core.exportVariable(CLI_CONFIG_REGISTRY, 'ghcr.io')
|
||||
}
|
||||
} catch (error) {
|
||||
if (error instanceof Error) core.setFailed(error.message)
|
||||
}
|
||||
|
||||
15
src/utils.ts
15
src/utils.ts
@@ -1,5 +1,9 @@
|
||||
import {exec} from 'child_process'
|
||||
import os from 'os'
|
||||
import lt from 'semver/functions/lt'
|
||||
import {promisify} from 'util'
|
||||
|
||||
const doExec = promisify(exec)
|
||||
|
||||
// arch in [arm, arm64, x64...] (https://nodejs.org/docs/latest-v16.x/api/os.html#osarch)
|
||||
// return value in [amd64, arm64, arm]
|
||||
@@ -31,3 +35,14 @@ export const getDownloadUrl = async (version: string): Promise<string> => {
|
||||
}
|
||||
return `https://github.com/supabase/cli/releases/download/v${version}/${filename}`
|
||||
}
|
||||
|
||||
export const determineInstalledVersion = async (): Promise<string> => {
|
||||
const {stdout} = await doExec('supabase --version')
|
||||
|
||||
const version = stdout.trim()
|
||||
if (!version) {
|
||||
throw new Error('Could not determine installed Supabase CLI version')
|
||||
}
|
||||
|
||||
return version
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user