refactor(cli): move commands to a separate folder

This commit is contained in:
Joakim Carlstein 2023-11-22 13:25:45 +01:00
parent 4f8fb441f8
commit d4d87036df
3 changed files with 11 additions and 11 deletions

View file

@ -70,7 +70,7 @@ Examples:
const plugins = [...(config.plugins ?? []), ...(values.plugin ?? [])];
try {
const { default: upCommand } = await import('./up-command.js');
const { default: upCommand } = await import('./commands/up.js');
await upCommand({ storage, reporter, directory, plugins, dry });
} catch (error) {
if (error instanceof ShowUsageError) {
@ -160,7 +160,7 @@ Examples:
const name = positionals.join(' ').trim();
try {
const { default: newCommand } = await import('./new-command.js');
const { default: newCommand } = await import('./commands/new.js');
await newCommand({ directory, template, plugins, extension, reporter }, name);
} catch (error) {
if (error instanceof ShowUsageError) {

View file

@ -3,11 +3,11 @@ import fs from 'node:fs/promises';
import path from 'node:path';
import { getTimestampPrefix, sanitizeMigrationName, getOrLoadPlugin, getOrLoadReporter } from '@emigrate/plugin-tools';
import { type MigrationMetadata } from '@emigrate/plugin-tools/types';
import { BadOptionError, MissingArgumentsError, MissingOptionError, UnexpectedError } from './errors.js';
import { type Config } from './types.js';
import { withLeadingPeriod } from './with-leading-period.js';
import { BadOptionError, MissingArgumentsError, MissingOptionError, UnexpectedError } from '../errors.js';
import { type Config } from '../types.js';
import { withLeadingPeriod } from '../with-leading-period.js';
const lazyDefaultReporter = async () => import('./reporters/default.js');
const lazyDefaultReporter = async () => import('../reporters/default.js');
export default async function newCommand(
{ directory, template, reporter: reporterConfig, plugins = [], extension }: Config,

View file

@ -13,10 +13,10 @@ import {
MigrationLoadError,
MigrationRunError,
MissingOptionError,
} from './errors.js';
import { type Config } from './types.js';
import { withLeadingPeriod } from './with-leading-period.js';
import pluginLoaderJs from './plugin-loader-js.js';
} from '../errors.js';
import { type Config } from '../types.js';
import { withLeadingPeriod } from '../with-leading-period.js';
import pluginLoaderJs from '../plugin-loader-js.js';
type ExtraFlags = {
dry?: boolean;
@ -27,7 +27,7 @@ const getDuration = (start: [number, number]) => {
return seconds * 1000 + nanoseconds / 1_000_000;
};
const lazyDefaultReporter = async () => import('./reporters/default.js');
const lazyDefaultReporter = async () => import('../reporters/default.js');
export default async function upCommand({
storage: storageConfig,