Skip to content

Commit

Permalink
v2.10.297: Improve CLI UI
Browse files Browse the repository at this point in the history
  • Loading branch information
dimikot committed Sep 29, 2024
1 parent b3c54d0 commit 66377b1
Show file tree
Hide file tree
Showing 23 changed files with 459 additions and 168 deletions.
9 changes: 9 additions & 0 deletions .eslintrc.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ module.exports = (projectRoot, extraRules = {}) => ({
"typescript-enum",
"typescript-sort-keys",
"unused-imports",
"no-only-tests",
],
settings: {
react: {
Expand Down Expand Up @@ -109,6 +110,10 @@ module.exports = (projectRoot, extraRules = {}) => ({
"@typescript-eslint/no-useless-constructor": ["error"],
"@typescript-eslint/prefer-optional-chain": ["error"],
"@typescript-eslint/consistent-type-imports": ["error"],
"@typescript-eslint/require-array-sort-compare": [
"error",
{ ignoreStringArrays: true },
],
eqeqeq: ["error"],
"object-shorthand": ["error", "always"],
"@typescript-eslint/unbound-method": ["error"],
Expand Down Expand Up @@ -380,6 +385,7 @@ module.exports = (projectRoot, extraRules = {}) => ({
},
},
],
"import/no-useless-path-segments": ["error", { noUselessIndex: true }],
"unused-imports/no-unused-imports": "error",
"no-restricted-imports": [
"error",
Expand Down Expand Up @@ -430,6 +436,9 @@ module.exports = (projectRoot, extraRules = {}) => ({
],

quotes: ["error", "double", { avoidEscape: true }],

"no-only-tests/no-only-tests": "error",

...extraRules,
},
});
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dist/__tests__
dist/**/__tests__
dist/tsconfig.tsbuildinfo
dist/*.tsbuildinfo
.npmrc

# Common in both .gitignore and .npmignore
Expand Down
1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

8 changes: 8 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"overrides": [
{
"files": ["*.ts", "*.tsx"],
"options": { "parser": "typescript" }
}
]
}
127 changes: 127 additions & 0 deletions docs/interfaces/MigrateOptions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
[@clickup/pg-mig](../README.md) / [Exports](../modules.md) / MigrateOptions

# Interface: MigrateOptions

Options for the migrate() function.

## Properties

### migDir

**migDir**: `string`

The directory the migration versions are loaded from.

#### Defined in

[src/cli.ts:27](https://github.com/clickup/pg-mig/blob/master/src/cli.ts#L27)

___

### hosts

**hosts**: `string`[]

List of PostgreSQL master hostnames. The migration versions in `migDir`
will be applied to all of them.

#### Defined in

[src/cli.ts:30](https://github.com/clickup/pg-mig/blob/master/src/cli.ts#L30)

___

### port

**port**: `number`

PostgreSQL port on each hosts.

#### Defined in

[src/cli.ts:32](https://github.com/clickup/pg-mig/blob/master/src/cli.ts#L32)

___

### user

**user**: `string`

PostgreSQL user on each host.

#### Defined in

[src/cli.ts:34](https://github.com/clickup/pg-mig/blob/master/src/cli.ts#L34)

___

### pass

**pass**: `string`

PostgreSQL password on each host.

#### Defined in

[src/cli.ts:36](https://github.com/clickup/pg-mig/blob/master/src/cli.ts#L36)

___

### db

**db**: `string`

PostgreSQL database name on each host.

#### Defined in

[src/cli.ts:38](https://github.com/clickup/pg-mig/blob/master/src/cli.ts#L38)

___

### parallelism

`Optional` **parallelism**: `number`

How many schemas to process in parallel (defaults to 10).

#### Defined in

[src/cli.ts:40](https://github.com/clickup/pg-mig/blob/master/src/cli.ts#L40)

___

### dry

`Optional` **dry**: `boolean`

If true, prints what it plans to do, but doesn't change anything.

#### Defined in

[src/cli.ts:42](https://github.com/clickup/pg-mig/blob/master/src/cli.ts#L42)

___

### ci

`Optional` **ci**: `boolean`

If true, then doesn't use log-update and doesn't replace lines; instead,
prints logs to stdout line by line.

#### Defined in

[src/cli.ts:45](https://github.com/clickup/pg-mig/blob/master/src/cli.ts#L45)

___

### action

**action**: \{ `type`: ``"make"`` ; `name`: `string` } \| \{ `type`: ``"list"`` } \| \{ `type`: ``"undo"`` ; `version`: `string` } \| \{ `type`: ``"apply"`` }

What to do.

#### Defined in

[src/cli.ts:47](https://github.com/clickup/pg-mig/blob/master/src/cli.ts#L47)
26 changes: 9 additions & 17 deletions docs/modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

# @clickup/pg-mig

## Interfaces

- [MigrateOptions](interfaces/MigrateOptions.md)

## Functions

### main
Expand Down Expand Up @@ -31,7 +35,7 @@ pg-mig

#### Defined in

[src/cli.ts:39](https://github.com/clickup/pg-mig/blob/master/src/cli.ts#L39)
[src/cli.ts:72](https://github.com/clickup/pg-mig/blob/master/src/cli.ts#L72)

___

Expand All @@ -44,26 +48,14 @@ This function is meant to be called from other tools.

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `options` | `Object` | - |
| `options.migDir` | `string` | The directory the migration versions are loaded from. |
| `options.hosts` | `string`[] | List of PostgreSQL master hostnames. The migration versions in `migDir` will be applied to all of them. |
| `options.port` | `number` | PostgreSQL port on each hosts. |
| `options.user` | `string` | PostgreSQL user on each host. |
| `options.pass` | `string` | PostgreSQL password on each host. |
| `options.db` | `string` | PostgreSQL database name on each host. |
| `options.parallelism?` | `number` | How many schemas to process in parallel (defaults to 10). |
| `options.undo?` | `string` | If passed, switches the action to undo the provided migration version. |
| `options.make?` | `string` | If passed, switches the action to create a new migration version. |
| `options.dry?` | `boolean` | If true, prints what it plans to do, but doesn't change anything. |
| `options.list?` | `boolean` | Lists all versions in `migDir`. |
| `options.ci?` | `boolean` | If true, then doesn't use logUpdate() and doesn't replace lines; instead, prints logs to stdout line by line. |
| Name | Type |
| :------ | :------ |
| `options` | [`MigrateOptions`](interfaces/MigrateOptions.md) |

#### Returns

`Promise`\<`boolean`\>

#### Defined in

[src/cli.ts:79](https://github.com/clickup/pg-mig/blob/master/src/cli.ts#L79)
[src/cli.ts:117](https://github.com/clickup/pg-mig/blob/master/src/cli.ts#L117)
4 changes: 4 additions & 0 deletions internal/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
set -e

tsc --build
2 changes: 1 addition & 1 deletion internal/clean.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
set -e

rm -rf dist yarn.lock package-lock.json pnpm-lock.yaml *.log
rm -rf dist dist.* yarn.lock package-lock.json pnpm-lock.yaml node_modules ./*.log
5 changes: 3 additions & 2 deletions internal/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/bash
set -e

npm run build
npm run lint
npm run clean
npm install
npm run test
npm run lint
npm publish --access=public
4 changes: 4 additions & 0 deletions internal/dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
set -e

tsc --watch --preserveWatchOutput
5 changes: 5 additions & 0 deletions internal/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
set -e

bash internal/build.sh
jest
13 changes: 13 additions & 0 deletions jest.config.base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"use strict";
module.exports = {
roots: ["<rootDir>/src"],
testMatch: ["**/*.test.ts"],
clearMocks: true,
restoreMocks: true,
...(process.env.IN_JEST_PROJECT
? {}
: { forceExit: true, testTimeout: 30000 }),
transform: {
"\\.ts$": "ts-jest",
},
};
13 changes: 1 addition & 12 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,2 @@
"use strict";
module.exports = {
roots: ["<rootDir>/src"],
testMatch: ["**/*.test.ts"],
clearMocks: true,
restoreMocks: true,
...(process.env.IN_JEST_PROJECT
? {}
: { forceExit: true, testTimeout: 30000, forceExit: true }),
transform: {
"\\.ts$": "ts-jest",
},
};
module.exports = { ...require("./jest.config.base") };
22 changes: 18 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
{
"name": "@clickup/pg-mig",
"description": "PostgreSQL schema migration tool with micro-sharding and clustering support",
"version": "2.10.296",
"version": "2.10.297",
"license": "MIT",
"keywords": [
"postgresql",
"postgres",
"database",
"schema",
"migration",
"micro-sharding",
"clustering",
"DDL",
"psql",
"database-versioning",
"schema-versioning"
],
"main": "dist/cli.js",
"types": "dist/cli.d.ts",
"bin": {
"pg-mig": "./dist/cli.js"
},
"scripts": {
"build": "tsc",
"dev": "tsc --watch --preserveWatchOutput",
"build": "bash internal/build.sh",
"dev": "bash internal/dev.sh",
"lint": "bash internal/lint.sh",
"test": "jest",
"test": "bash internal/test.sh",
"docs": "bash internal/docs.sh",
"clean": "bash internal/clean.sh",
"copy-package-to-public-dir": "copy-package-to-public-dir.sh",
Expand Down Expand Up @@ -44,6 +57,7 @@
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-lodash": "^7.4.0",
"eslint-plugin-no-only-tests": "^3.1.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react": "^7.32.2",
Expand Down
Loading

0 comments on commit 66377b1

Please sign in to comment.