@emigrate/cli
Advanced tools
Comparing version 0.14.0 to 0.14.1
@@ -0,1 +1,2 @@ | ||
import { extname } from 'node:path'; | ||
import { toMigrationMetadata } from './to-migration-metadata.js'; | ||
@@ -6,3 +7,4 @@ import { getMigrations as getMigrationsOriginal } from './get-migrations.js'; | ||
const seen = new Set(); | ||
for await (const entry of history) { | ||
for await (const entry_ of history) { | ||
const entry = extname(entry_.name) === '' ? { ...entry_, name: `${entry_.name}.js` } : entry_; | ||
const index = allMigrations.findIndex((migrationFile) => migrationFile.name === entry.name); | ||
@@ -9,0 +11,0 @@ if (index === -1) { |
@@ -32,2 +32,50 @@ import { describe, it, mock } from 'node:test'; | ||
}); | ||
it('returns 0 and finishes without an error when all migrations have already been run', async () => { | ||
const { reporter, run } = getUpCommand(['my_migration.js'], getStorage(['my_migration.js'])); | ||
const exitCode = await run(); | ||
assert.strictEqual(exitCode, 0); | ||
assert.strictEqual(reporter.onInit.mock.calls.length, 1); | ||
assert.deepStrictEqual(reporter.onInit.mock.calls[0]?.arguments, [ | ||
{ | ||
command: 'up', | ||
cwd: '/emigrate', | ||
dry: false, | ||
color: undefined, | ||
version, | ||
directory: 'migrations', | ||
}, | ||
]); | ||
assert.strictEqual(reporter.onCollectedMigrations.mock.calls.length, 1); | ||
assert.strictEqual(reporter.onLockedMigrations.mock.calls.length, 1); | ||
assert.strictEqual(reporter.onMigrationStart.mock.calls.length, 0); | ||
assert.strictEqual(reporter.onMigrationSuccess.mock.calls.length, 0); | ||
assert.strictEqual(reporter.onMigrationError.mock.calls.length, 0); | ||
assert.strictEqual(reporter.onMigrationSkip.mock.calls.length, 0); | ||
assert.strictEqual(reporter.onFinished.mock.calls.length, 1); | ||
assert.deepStrictEqual(reporter.onFinished.mock.calls[0]?.arguments, [[], undefined]); | ||
}); | ||
it('returns 0 and finishes without an error when all migrations have already been run even when the history responds without file extensions', async () => { | ||
const { reporter, run } = getUpCommand(['my_migration.js'], getStorage(['my_migration'])); | ||
const exitCode = await run(); | ||
assert.strictEqual(exitCode, 0); | ||
assert.strictEqual(reporter.onInit.mock.calls.length, 1); | ||
assert.deepStrictEqual(reporter.onInit.mock.calls[0]?.arguments, [ | ||
{ | ||
command: 'up', | ||
cwd: '/emigrate', | ||
dry: false, | ||
color: undefined, | ||
version, | ||
directory: 'migrations', | ||
}, | ||
]); | ||
assert.strictEqual(reporter.onCollectedMigrations.mock.calls.length, 1); | ||
assert.strictEqual(reporter.onLockedMigrations.mock.calls.length, 1); | ||
assert.strictEqual(reporter.onMigrationStart.mock.calls.length, 0); | ||
assert.strictEqual(reporter.onMigrationSuccess.mock.calls.length, 0); | ||
assert.strictEqual(reporter.onMigrationError.mock.calls.length, 0); | ||
assert.strictEqual(reporter.onMigrationSkip.mock.calls.length, 0); | ||
assert.strictEqual(reporter.onFinished.mock.calls.length, 1); | ||
assert.deepStrictEqual(reporter.onFinished.mock.calls[0]?.arguments, [[], undefined]); | ||
}); | ||
it('returns 1 and finishes with an error when there are migration file extensions without a corresponding loader plugin', async () => { | ||
@@ -34,0 +82,0 @@ const { reporter, run } = getUpCommand(['some_other.js', 'some_file.sql'], getStorage([])); |
@@ -19,3 +19,3 @@ import path from 'node:path'; | ||
const migrationFiles = allFilesInMigrationDirectory | ||
.filter((file) => file.isFile() && !file.name.startsWith('.') && !file.name.startsWith('_')) | ||
.filter((file) => file.isFile() && !file.name.startsWith('.') && !file.name.startsWith('_') && path.extname(file.name) !== '') | ||
.sort((a, b) => a.name.localeCompare(b.name)) | ||
@@ -22,0 +22,0 @@ .map(({ name }) => { |
{ | ||
"name": "@emigrate/cli", | ||
"version": "0.14.0", | ||
"version": "0.14.1", | ||
"publishConfig": { | ||
@@ -5,0 +5,0 @@ "access": "public" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
213304
2118