Skip to content

Commit

Permalink
feat(cli): improve "up" command output and flow a lot
Browse files Browse the repository at this point in the history
  • Loading branch information
joakimbeng committed Nov 17, 2023
1 parent e5eec7c commit 59ec16b
Show file tree
Hide file tree
Showing 14 changed files with 534 additions and 63 deletions.
5 changes: 5 additions & 0 deletions .changeset/great-spies-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@emigrate/cli': minor
---

Make the dry run mode work for the "up" command using the "--dry" CLI option
5 changes: 5 additions & 0 deletions .changeset/loud-comics-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@emigrate/cli': minor
---

Improve the default reporter with good looking output that has colors and animations. In non-interactive environments the animations are not used (this includes CI environments).
5 changes: 5 additions & 0 deletions .changeset/many-items-kneel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@emigrate/cli': minor
---

Improve the "up" command flow and the usage of reporters, handle migration errors and automatic skipping of migrations.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
"space": true,
"prettier": true,
"rules": {
"complexity": 0
"complexity": 0,
"capitalized-comments": 0
},
"overrides": [
{
Expand Down
8 changes: 7 additions & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@
"license": "MIT",
"dependencies": {
"@emigrate/plugin-tools": "workspace:*",
"cosmiconfig": "8.3.6"
"ansis": "2.0.2",
"cosmiconfig": "8.3.6",
"elegant-spinner": "3.0.0",
"figures": "6.0.1",
"is-interactive": "2.0.0",
"log-update": "6.0.0",
"pretty-ms": "8.0.0"
},
"volta": {
"extends": "../../package.json"
Expand Down
2 changes: 0 additions & 2 deletions packages/cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,4 @@ try {
} else {
console.error(error);
}

process.exit(1);
}
2 changes: 1 addition & 1 deletion packages/cli/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from './types.js';

export const emigrate = () => {
console.log('Done!');
// console.log('Done!');
};
6 changes: 3 additions & 3 deletions packages/cli/src/new-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import path from 'node:path';
import { getTimestampPrefix, sanitizeMigrationName, getOrLoadPlugin } from '@emigrate/plugin-tools';
import { BadOptionError, MissingArgumentsError, MissingOptionError, UnexpectedError } from './errors.js';
import { type Config } from './types.js';
import { stripLeadingPeriod } from './strip-leading-period.js';
import { withLeadingPeriod } from './with-leading-period.js';

export default async function newCommand({ directory, template, plugins = [], extension }: Config, name: string) {
if (!directory) {
Expand Down Expand Up @@ -34,7 +34,7 @@ export default async function newCommand({ directory, template, plugins = [], ex
throw new UnexpectedError(`Failed to read template file: ${templatePath}`, { cause: error });
}

filename = `${getTimestampPrefix()}_${sanitizeMigrationName(name)}.${stripLeadingPeriod(
filename = `${getTimestampPrefix()}_${sanitizeMigrationName(name)}.${withLeadingPeriod(
extension ?? fileExtension,
)}`;
}
Expand All @@ -56,7 +56,7 @@ export default async function newCommand({ directory, template, plugins = [], ex

if (extension && !hasGeneratedFile) {
content = '';
filename = `${getTimestampPrefix()}_${sanitizeMigrationName(name)}.${stripLeadingPeriod(extension)}`;
filename = `${getTimestampPrefix()}_${sanitizeMigrationName(name)}.${withLeadingPeriod(extension)}`;
}

if (!filename || content === undefined) {
Expand Down
Loading

0 comments on commit 59ec16b

Please sign in to comment.