Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into drizzle-test
Browse files Browse the repository at this point in the history
  • Loading branch information
SferaDev committed Nov 22, 2023
2 parents de857bc + d981563 commit 5723a50
Show file tree
Hide file tree
Showing 104 changed files with 7,055 additions and 3,942 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18
18.13.0
97 changes: 97 additions & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,102 @@
# @xata.io/cli

## 0.14.4

### Patch Changes

- [#1245](https://github.com/xataio/client-ts/pull/1245) [`82ff1d81`](https://github.com/xataio/client-ts/commit/82ff1d81d437d21deaf274478075ea02ab558063) Thanks [@SferaDev](https://github.com/SferaDev)! - Fix problem with `tslib` dependency

## 0.14.3

### Patch Changes

- [#1231](https://github.com/xataio/client-ts/pull/1231) [`786fc78c`](https://github.com/xataio/client-ts/commit/786fc78caae4a8057cd92cf7875ba510cc293a13) Thanks [@eemmiillyy](https://github.com/eemmiillyy)! - fix: column renaming errors

- Updated dependencies [[`19c5dd47`](https://github.com/xataio/client-ts/commit/19c5dd47e3a032fcb19d990527b8faaa9326d97d), [`d282d18f`](https://github.com/xataio/client-ts/commit/d282d18f025094e0729ade6009b34fc0d34ebbba)]:
- @xata.io/[email protected]
- @xata.io/[email protected]
- @xata.io/[email protected]

## 0.14.2

### Patch Changes

- Updated dependencies [[`302798e8`](https://github.com/xataio/client-ts/commit/302798e8d210c89f420a5c927e0f836a27dbaed9)]:
- @xata.io/[email protected]
- @xata.io/[email protected]

## 0.14.1

### Patch Changes

- [#1210](https://github.com/xataio/client-ts/pull/1210) [`05fd69d8`](https://github.com/xataio/client-ts/commit/05fd69d8d86791f32617a068924fc770e38ee9a6) Thanks [@andrew-farries](https://github.com/andrew-farries)! - Make `branch create` default to branch from `main`

- Updated dependencies [[`fa2883b0`](https://github.com/xataio/client-ts/commit/fa2883b0639e48d68097401bf515c8cb95df5b4b), [`c04faece`](https://github.com/xataio/client-ts/commit/c04faece8830699d978e03c89f29e383e479e824), [`cb45cc9f`](https://github.com/xataio/client-ts/commit/cb45cc9f6829e1b555762e656cc1b0b2e977aaf9), [`9865f127`](https://github.com/xataio/client-ts/commit/9865f1276ffc75f7beeee69b62c7bce6af8568c8)]:
- @xata.io/[email protected]
- @xata.io/[email protected]
- @xata.io/[email protected]

## 0.14.0

### Minor Changes

- [#1190](https://github.com/xataio/client-ts/pull/1190) [`e77644b5`](https://github.com/xataio/client-ts/commit/e77644b560ad02ce6085bc083b07105ae6dddff4) Thanks [@eemmiillyy](https://github.com/eemmiillyy)! - Add support for importing single and multiple files (remote and local) via pathname in CSV column

### Patch Changes

- Updated dependencies [[`652db16b`](https://github.com/xataio/client-ts/commit/652db16b40e507be06ff662e2ffe7a5161f56100), [`0e1c50de`](https://github.com/xataio/client-ts/commit/0e1c50de5850db2dfbbdfff9d66eda3bf1322836), [`d093d363`](https://github.com/xataio/client-ts/commit/d093d363a51fc23c8513d51600bb3b31bbc45334), [`e77644b5`](https://github.com/xataio/client-ts/commit/e77644b560ad02ce6085bc083b07105ae6dddff4)]:
- @xata.io/[email protected]
- @xata.io/[email protected]
- @xata.io/[email protected]

## 0.13.14

### Patch Changes

- Updated dependencies [[`c155c91e`](https://github.com/xataio/client-ts/commit/c155c91e9d5e8125ff07d5f530b0e66d153b3bb9), [`3330c9cf`](https://github.com/xataio/client-ts/commit/3330c9cf8d8db18b8e355a576e4afd589b6152bf), [`a738816d`](https://github.com/xataio/client-ts/commit/a738816d355f4415b0622bb5a23b4154f9855177)]:
- @xata.io/[email protected]
- @xata.io/[email protected]

## 0.13.13

### Patch Changes

- [#1168](https://github.com/xataio/client-ts/pull/1168) [`5daf6972`](https://github.com/xataio/client-ts/commit/5daf69721602755c8e785484679159d51489003a) Thanks [@eemmiillyy](https://github.com/eemmiillyy)! - Add skip code generation flag to pull command

- [#1173](https://github.com/xataio/client-ts/pull/1173) [`c2885adf`](https://github.com/xataio/client-ts/commit/c2885adf710d0dc603be3fe50ed14a18362b3283) Thanks [@eemmiillyy](https://github.com/eemmiillyy)! - Add ability to interactively select branch on xata init when main branch does not exist

## 0.13.12

### Patch Changes

- [#1169](https://github.com/xataio/client-ts/pull/1169) [`641809d4`](https://github.com/xataio/client-ts/commit/641809d4317dc356c538e7a49deb93d30bc34f82) Thanks [@y-71](https://github.com/y-71)! - Support for the bun package manager

## 0.13.11

### Patch Changes

- Updated dependencies [[`b9b9058f`](https://github.com/xataio/client-ts/commit/b9b9058f0bc81b660da45318c27191a62f041f21)]:
- @xata.io/[email protected]
- @xata.io/[email protected]

## 0.13.10

### Patch Changes

- Updated dependencies [[`7166797c`](https://github.com/xataio/client-ts/commit/7166797c28839198d20a9115d0414cebc2fed39b), [`b85df75f`](https://github.com/xataio/client-ts/commit/b85df75f2f466762a8b3d9824c9292c7e3db03fd)]:
- @xata.io/[email protected]
- @xata.io/[email protected]

## 0.13.9

### Patch Changes

- [#1144](https://github.com/xataio/client-ts/pull/1144) [`4910dce2`](https://github.com/xataio/client-ts/commit/4910dce29d3cc17d13aadf32e4eb476ffb571fad) Thanks [@SferaDev](https://github.com/SferaDev)! - Support for JSON and Revlinks

- Updated dependencies [[`4910dce2`](https://github.com/xataio/client-ts/commit/4910dce29d3cc17d13aadf32e4eb476ffb571fad)]:
- @xata.io/[email protected]
- @xata.io/[email protected]

## 0.13.8

### Patch Changes
Expand Down
4 changes: 4 additions & 0 deletions cli/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ alias xatadev="$XATA_CLIENT_TS/cli/bin/dev.js"
alias xatadevbuild="(cd $XATA_CLIENT_TS && pnpm build) && $XATA_CLIENT_TS/cli/bin/run.js"

then: `xatadev status` or `xatadevbuild status`

To run the CLI against a different profile, you can use:

`./cli/bin/dev.js auth login --profile staging --host staging` where host values can be prod, staging, dev, and controlPlaneUrl, dataPlaneUrl (comma delimited for ephemeral instances or localhost docker)
70 changes: 35 additions & 35 deletions cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@xata.io/cli",
"version": "0.13.8",
"version": "0.14.4",
"description": "Xata.io CLI",
"author": "Xata Inc.",
"bin": {
Expand All @@ -19,31 +19,31 @@
"/oclif.manifest.json"
],
"dependencies": {
"@babel/core": "^7.22.11",
"@babel/preset-react": "^7.22.5",
"@babel/preset-typescript": "^7.22.11",
"@oclif/core": "^2.11.10",
"@oclif/plugin-help": "^5.2.18",
"@oclif/plugin-not-found": "^2.3.38",
"@oclif/plugin-plugins": "^3.3.0",
"@rollup/plugin-auto-install": "^3.0.4",
"@rollup/plugin-commonjs": "^25.0.4",
"@rollup/plugin-node-resolve": "^15.2.1",
"@rollup/plugin-virtual": "^3.0.1",
"@types/ini": "^1.3.31",
"@types/prompts": "^2.4.4",
"@babel/core": "^7.23.3",
"@babel/preset-react": "^7.23.3",
"@babel/preset-typescript": "^7.23.3",
"@oclif/core": "^3.11.0",
"@oclif/plugin-help": "^6.0.7",
"@oclif/plugin-not-found": "^3.0.4",
"@oclif/plugin-plugins": "^4.1.8",
"@rollup/plugin-auto-install": "^3.0.5",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-virtual": "^3.0.2",
"@types/ini": "^1.3.33",
"@types/prompts": "^2.4.8",
"@xata.io/client": "workspace:*",
"@xata.io/codegen": "workspace:*",
"@xata.io/importer": "workspace:*",
"ansi-regex": "^6.0.1",
"babel-plugin-module-extension-resolver": "^1.0.0",
"chalk": "^5.3.0",
"chokidar": "^3.5.3",
"cosmiconfig": "^8.2.0",
"cosmiconfig": "^8.3.6",
"deepmerge": "^4.3.1",
"dotenv": "^16.3.1",
"dotenv-expand": "^10.0.0",
"edge-runtime": "^2.5.0",
"edge-runtime": "^2.5.7",
"enquirer": "^2.4.1",
"env-editor": "^1.1.0",
"ini": "^4.1.1",
Expand All @@ -55,33 +55,33 @@
"open": "^9.1.0",
"prompts": "^2.4.2",
"relaxed-json": "^1.0.3",
"rollup": "^3.28.1",
"rollup-plugin-esbuild": "^5.0.0",
"rollup": "^4.5.0",
"rollup-plugin-esbuild": "^6.1.0",
"rollup-plugin-hypothetical": "^2.1.1",
"rollup-plugin-import-cdn": "^0.2.2",
"rollup-plugin-import-cdn": "^0.2.3",
"rollup-plugin-virtual-fs": "^4.0.1-alpha.0",
"text-table": "^0.2.0",
"tslib": "^2.6.2",
"tmp": "^0.2.1",
"which": "^3.0.1",
"zod": "^3.22.2"
"which": "^4.0.0",
"zod": "^3.22.4"
},
"devDependencies": {
"@babel/types": "^7.22.11",
"@types/babel__core": "^7.20.1",
"@types/lodash.compact": "^3.0.7",
"@types/lodash.get": "^4.4.7",
"@types/lodash.set": "^4.3.7",
"@types/relaxed-json": "^1.0.1",
"@types/text-table": "^0.2.2",
"@types/tmp": "^0.2.3",
"@types/which": "^3.0.0",
"eslint": "^8.48.0",
"eslint-config-oclif": "^4.0.0",
"eslint-config-oclif-typescript": "^1.0.3",
"oclif": "^3.11.3",
"@babel/types": "^7.23.3",
"@types/babel__core": "^7.20.4",
"@types/lodash.compact": "^3.0.9",
"@types/lodash.get": "^4.4.9",
"@types/lodash.set": "^4.3.9",
"@types/relaxed-json": "^1.0.4",
"@types/text-table": "^0.2.5",
"@types/tmp": "^0.2.6",
"@types/which": "^3.0.2",
"eslint": "^8.54.0",
"eslint-config-oclif": "^5.0.0",
"eslint-config-oclif-typescript": "^3.0.18",
"oclif": "^4.0.3",
"shx": "^0.3.4",
"ts-node": "^10.9.1",
"tslib": "^2.6.2",
"typescript": "^5.2.2"
},
"oclif": {
Expand Down
12 changes: 11 additions & 1 deletion cli/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,14 +346,24 @@ export abstract class BaseCommand<T extends typeof Command> extends Command {
workspace: string,
region: string,
database: string,
options: { allowEmpty?: boolean; allowCreate?: boolean; title?: string } = {}
options: {
allowEmpty?: boolean;
allowCreate?: boolean;
title?: string;
// Branch to default if exists
defaultBranch?: string;
} = {}
): Promise<string> {
const xata = await this.getXataClient();
const { branches = [] } = await xata.api.branches.getBranchList({ workspace, region, database });

const EMPTY_CHOICE = '$empty';
const CREATE_CHOICE = '$create';

if (options.defaultBranch && branches.map(({ name }) => name).includes(options.defaultBranch)) {
return options.defaultBranch;
}

if (branches.length > 0) {
const choices = branches.map((db) => ({
title: db.name,
Expand Down
15 changes: 15 additions & 0 deletions cli/src/commands/branch/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,21 @@ describe('branches create', () => {
expect(fetchMock.mock.calls[0][1].method).toEqual('PUT');
});

test('fails if the request times out', async () => {
fetchMock.mockReturnValue({
ok: false,
json: async () => {
throw new Error('Unexpected token < in JSON at position 0');
}
});

const config = await Config.load();
const command = new BranchCreate(['featureA'], config);
command.projectConfig = { databaseURL: 'https://test-1234.eu-west-1.xata.sh/db/test' };

await expect(command.run()).rejects.toThrow('Failed to create branch');
});

test.each([[false], [true]])('performs the creation with JSON enabled = %o', async (json) => {
fetchMock.mockReturnValue({
ok: true,
Expand Down
18 changes: 12 additions & 6 deletions cli/src/commands/branch/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export default class BranchCreate extends BaseCommand<typeof BranchCreate> {
...this.commonFlags,
...this.databaseURLFlag,
from: Flags.string({
description: 'Branch name to branch off from'
description: 'Branch name to branch off from',
default: 'main'
})
};

Expand All @@ -30,12 +31,17 @@ export default class BranchCreate extends BaseCommand<typeof BranchCreate> {

const { from } = flags;

const result = await xata.api.branches.createBranch({ workspace, region, database, branch, from });
try {
const result = await xata.api.branches.createBranch({ workspace, region, database, branch, from });

if (this.jsonEnabled()) return result;
if (this.jsonEnabled()) return result;

const message = `Branch ${branch} successfully created`;

this.success(message);
const message = `Branch ${branch} successfully created`;
this.success(message);
} catch (err) {
err instanceof Error
? this.error(`${err.message.includes('Unexpected token < in JSON') ? 'Failed to create branch' : err.message}`)
: this.error(String(err));
}
}
}
4 changes: 2 additions & 2 deletions cli/src/commands/codegen/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export default class Codegen extends BaseCommand<typeof Codegen> {
this.log(`Generated Xata code to ./${relative(process.cwd(), output)}`);
}

static async runIfConfigured(projectConfig?: ProjectConfig) {
if (projectConfig?.codegen?.output) return Codegen.run([]);
static async runIfConfigured(projectConfig?: ProjectConfig, flags?: any[]) {
if (projectConfig?.codegen?.output) return Codegen.run(flags ?? []);
}
}
Loading

0 comments on commit 5723a50

Please sign in to comment.