@contember/cli 2.0.0-alpha.39 → 2.0.0-alpha.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/development/src/commands/migrations/MigrationAmendCommand.cjs +15 -3
- package/dist/development/src/commands/migrations/MigrationAmendCommand.cjs.map +1 -1
- package/dist/development/src/commands/migrations/MigrationAmendCommand.js +15 -3
- package/dist/development/src/commands/migrations/MigrationAmendCommand.js.map +1 -1
- package/dist/development/src/commands/migrations/MigrationDiffCommand.cjs +1 -1
- package/dist/development/src/commands/migrations/MigrationDiffCommand.cjs.map +1 -1
- package/dist/development/src/commands/migrations/MigrationDiffCommand.js +1 -1
- package/dist/development/src/commands/migrations/MigrationDiffCommand.js.map +1 -1
- package/dist/development/src/consts.cjs +3 -1
- package/dist/development/src/consts.cjs.map +1 -1
- package/dist/development/src/consts.js +4 -2
- package/dist/development/src/consts.js.map +1 -1
- package/dist/development/src/dic.cjs +3 -1
- package/dist/development/src/dic.cjs.map +1 -1
- package/dist/development/src/dic.js +3 -1
- package/dist/development/src/dic.js.map +1 -1
- package/dist/development/src/lib/env.cjs +4 -1
- package/dist/development/src/lib/env.cjs.map +1 -1
- package/dist/development/src/lib/env.js +4 -1
- package/dist/development/src/lib/env.js.map +1 -1
- package/dist/development/src/lib/migrations/MigrationExecutionFacade.cjs +1 -1
- package/dist/development/src/lib/migrations/MigrationExecutionFacade.cjs.map +1 -1
- package/dist/development/src/lib/migrations/MigrationExecutionFacade.js +1 -1
- package/dist/development/src/lib/migrations/MigrationExecutionFacade.js.map +1 -1
- package/dist/production/src/commands/migrations/MigrationAmendCommand.cjs +15 -3
- package/dist/production/src/commands/migrations/MigrationAmendCommand.cjs.map +1 -1
- package/dist/production/src/commands/migrations/MigrationAmendCommand.js +15 -3
- package/dist/production/src/commands/migrations/MigrationAmendCommand.js.map +1 -1
- package/dist/production/src/commands/migrations/MigrationDiffCommand.cjs +1 -1
- package/dist/production/src/commands/migrations/MigrationDiffCommand.cjs.map +1 -1
- package/dist/production/src/commands/migrations/MigrationDiffCommand.js +1 -1
- package/dist/production/src/commands/migrations/MigrationDiffCommand.js.map +1 -1
- package/dist/production/src/consts.cjs +3 -1
- package/dist/production/src/consts.cjs.map +1 -1
- package/dist/production/src/consts.js +4 -2
- package/dist/production/src/consts.js.map +1 -1
- package/dist/production/src/dic.cjs +3 -1
- package/dist/production/src/dic.cjs.map +1 -1
- package/dist/production/src/dic.js +3 -1
- package/dist/production/src/dic.js.map +1 -1
- package/dist/production/src/lib/env.cjs +4 -1
- package/dist/production/src/lib/env.cjs.map +1 -1
- package/dist/production/src/lib/env.js +4 -1
- package/dist/production/src/lib/env.js.map +1 -1
- package/dist/production/src/lib/migrations/MigrationExecutionFacade.cjs +1 -1
- package/dist/production/src/lib/migrations/MigrationExecutionFacade.cjs.map +1 -1
- package/dist/production/src/lib/migrations/MigrationExecutionFacade.js +1 -1
- package/dist/production/src/lib/migrations/MigrationExecutionFacade.js.map +1 -1
- package/dist/types/commands/migrations/MigrationAmendCommand.d.ts +1 -0
- package/dist/types/commands/migrations/MigrationAmendCommand.d.ts.map +1 -1
- package/dist/types/consts.d.ts.map +1 -1
- package/dist/types/dic.d.ts.map +1 -1
- package/dist/types/lib/env.d.ts +3 -0
- package/dist/types/lib/env.d.ts.map +1 -1
- package/dist/types/lib/migrations/MigrationExecutionFacade.d.ts +2 -2
- package/dist/types/lib/migrations/MigrationExecutionFacade.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -13
- package/src/commands/migrations/MigrationAmendCommand.ts +16 -3
- package/src/commands/migrations/MigrationDiffCommand.ts +1 -1
- package/src/consts.ts +4 -2
- package/src/dic.ts +3 -1
- package/src/lib/env.ts +6 -0
- package/src/lib/migrations/MigrationExecutionFacade.ts +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contember/cli",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.40",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"bin": {
|
|
6
6
|
"contember": "./dist/production/run.js"
|
|
@@ -20,18 +20,18 @@
|
|
|
20
20
|
"tailwindcss": "^3.4.14"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@contember/cli-common": "2.0.0-alpha.
|
|
24
|
-
"@contember/config-loader": "2.0.0-alpha.
|
|
25
|
-
"@contember/database": "2.0.0-alpha.
|
|
26
|
-
"@contember/dic": "2.0.0-alpha.
|
|
27
|
-
"@contember/engine-common": "2.0.0-alpha.
|
|
28
|
-
"@contember/engine-content-api": "2.0.0-alpha.
|
|
29
|
-
"@contember/graphql-client": "2.0.0-alpha.
|
|
30
|
-
"@contember/migrations-client": "2.0.0-alpha.
|
|
31
|
-
"@contember/schema": "2.0.0-alpha.
|
|
32
|
-
"@contember/schema-migrations": "2.0.0-alpha.
|
|
33
|
-
"@contember/schema-utils": "2.0.0-alpha.
|
|
34
|
-
"@contember/typesafe": "2.0.0-alpha.
|
|
23
|
+
"@contember/cli-common": "2.0.0-alpha.40",
|
|
24
|
+
"@contember/config-loader": "2.0.0-alpha.40",
|
|
25
|
+
"@contember/database": "2.0.0-alpha.40",
|
|
26
|
+
"@contember/dic": "2.0.0-alpha.40",
|
|
27
|
+
"@contember/engine-common": "2.0.0-alpha.40",
|
|
28
|
+
"@contember/engine-content-api": "2.0.0-alpha.40",
|
|
29
|
+
"@contember/graphql-client": "2.0.0-alpha.40",
|
|
30
|
+
"@contember/migrations-client": "2.0.0-alpha.40",
|
|
31
|
+
"@contember/schema": "2.0.0-alpha.40",
|
|
32
|
+
"@contember/schema-migrations": "2.0.0-alpha.40",
|
|
33
|
+
"@contember/schema-utils": "2.0.0-alpha.40",
|
|
34
|
+
"@contember/typesafe": "2.0.0-alpha.40",
|
|
35
35
|
"@graphql-tools/schema": "^10.0.7",
|
|
36
36
|
"chalk": "^5.3.0",
|
|
37
37
|
"chalk-table": "^1.0.2",
|
|
@@ -106,7 +106,7 @@ export class MigrationAmendCommand extends Command<Args, Options> {
|
|
|
106
106
|
await systemClient.migrate([intermediateResult.migration], force)
|
|
107
107
|
await systemClient.migrationDelete(intermediateResult.migration.version)
|
|
108
108
|
|
|
109
|
-
if (!newMigrationResult) {
|
|
109
|
+
if (!newMigrationResult && await this.shouldRemove()) {
|
|
110
110
|
await this.migrationCreator.removeMigration(amendMigration.name)
|
|
111
111
|
await systemClient.migrationDelete(amendMigration.version)
|
|
112
112
|
console.log('Latest migration was removed')
|
|
@@ -115,8 +115,8 @@ export class MigrationAmendCommand extends Command<Args, Options> {
|
|
|
115
115
|
const newMigration = {
|
|
116
116
|
name: amendMigration.name,
|
|
117
117
|
version: amendMigration.version,
|
|
118
|
-
formatVersion: newMigrationResult
|
|
119
|
-
modifications: newMigrationResult
|
|
118
|
+
formatVersion: newMigrationResult?.migration.formatVersion ?? amendMigration.formatVersion,
|
|
119
|
+
modifications: newMigrationResult?.migration.modifications ?? [],
|
|
120
120
|
}
|
|
121
121
|
await this.migrationCreator.saveMigration(newMigration)
|
|
122
122
|
await systemClient.migrationModify(amendMigration.version, newMigration)
|
|
@@ -147,4 +147,17 @@ export class MigrationAmendCommand extends Command<Args, Options> {
|
|
|
147
147
|
})
|
|
148
148
|
return action === 'yes'
|
|
149
149
|
}
|
|
150
|
+
|
|
151
|
+
private async shouldRemove(): Promise<boolean> {
|
|
152
|
+
const { action } = await prompts({
|
|
153
|
+
type: 'select',
|
|
154
|
+
name: 'action',
|
|
155
|
+
message: 'The amendment results in a no-op migration because the changes introduced by the latest migration were reverted.\nYou can choose to remove the latest migration or to modify it so it is empty.',
|
|
156
|
+
choices: [
|
|
157
|
+
{ value: 'remove', title: 'Remove latest migration' },
|
|
158
|
+
{ value: 'keep', title: 'Keep latest migration and make it empty' },
|
|
159
|
+
],
|
|
160
|
+
})
|
|
161
|
+
return action === 'remove'
|
|
162
|
+
}
|
|
150
163
|
}
|
|
@@ -95,7 +95,7 @@ export class MigrationDiffCommand extends Command<Args, Options> {
|
|
|
95
95
|
if (shouldExecute) {
|
|
96
96
|
await this.migrationExecutorFacade.execute({
|
|
97
97
|
force: false,
|
|
98
|
-
requireConfirmation: !yes,
|
|
98
|
+
requireConfirmation: migrations => migrations.length !== 1 && !yes,
|
|
99
99
|
})
|
|
100
100
|
}
|
|
101
101
|
}
|
package/src/consts.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { findPackageRoot } from '@contember/cli-common'
|
|
2
2
|
import { dirname } from 'node:path'
|
|
3
3
|
import { fileURLToPath } from 'node:url'
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
const currentFilePath = dirname(fileURLToPath(import.meta.url))
|
|
6
|
+
export const packageRoot = process.env.CONTEMBER_CLI_PACKAGE_ROOT || findPackageRoot(currentFilePath)
|
|
5
7
|
export const contemberDockerImages = ['contember/engine', 'contember/engine-ee', 'contember/cli']
|
package/src/dic.ts
CHANGED
|
@@ -150,7 +150,9 @@ export const createContainer = ({ env, version, runtime, workspace }: {
|
|
|
150
150
|
.addService('schemaVersionBuilder', ({ migrationsResolver, schemaMigrator }) =>
|
|
151
151
|
new SchemaVersionBuilder(migrationsResolver, schemaMigrator))
|
|
152
152
|
.addService('schemaDiffer', ({ schemaMigrator }) =>
|
|
153
|
-
new SchemaDiffer(schemaMigrator
|
|
153
|
+
new SchemaDiffer(schemaMigrator, {
|
|
154
|
+
maxPatchSize: env.migrationsOptions?.maxPatchSize,
|
|
155
|
+
}))
|
|
154
156
|
.addService('migrationCreator', ({ migrationFilesManager, schemaDiffer }) =>
|
|
155
157
|
new MigrationCreator(migrationFilesManager, schemaDiffer, {
|
|
156
158
|
json: JSON.stringify({ formatVersion: VERSION_LATEST, modifications: [] }, undefined, '\t') + '\n',
|
package/src/lib/env.ts
CHANGED
|
@@ -6,6 +6,9 @@ export interface CliEnv {
|
|
|
6
6
|
dockerComposeFile?: string
|
|
7
7
|
dsn?: string
|
|
8
8
|
dir?: string
|
|
9
|
+
migrationsOptions?: {
|
|
10
|
+
maxPatchSize?: number
|
|
11
|
+
}
|
|
9
12
|
}
|
|
10
13
|
|
|
11
14
|
export const readCliEnv = (): CliEnv => {
|
|
@@ -17,5 +20,8 @@ export const readCliEnv = (): CliEnv => {
|
|
|
17
20
|
projectName: process.env.CONTEMBER_PROJECT_NAME,
|
|
18
21
|
dockerComposeFile: process.env.COMPOSE_FILE,
|
|
19
22
|
dsn: process.env.CONTEMBER_DSN,
|
|
23
|
+
migrationsOptions: {
|
|
24
|
+
maxPatchSize: process.env.CONTEMBER_MIGRATIONS_MAX_PATCH_SIZE ? parseInt(process.env.CONTEMBER_MIGRATIONS_MAX_PATCH_SIZE) : undefined,
|
|
25
|
+
},
|
|
20
26
|
}
|
|
21
27
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import prompts from 'prompts'
|
|
2
2
|
import { MigrationPrinter } from './MigrationPrinter'
|
|
3
|
-
import { isSchemaMigration, MigrationExecutor, SchemaVersionBuilder } from '@contember/migrations-client'
|
|
3
|
+
import { isSchemaMigration, MigrationExecutor, MigrationToExecuteOkStatus, SchemaVersionBuilder } from '@contember/migrations-client'
|
|
4
4
|
import { MigrationsStatusFacade } from './MigrationsStatusFacade'
|
|
5
5
|
import { MigrationVersionHelper } from '@contember/engine-common'
|
|
6
6
|
import { RemoteProject } from '../project/RemoteProject'
|
|
@@ -26,7 +26,7 @@ export class MigrationExecutionFacade {
|
|
|
26
26
|
until,
|
|
27
27
|
additionalMessage,
|
|
28
28
|
}: {
|
|
29
|
-
requireConfirmation: boolean
|
|
29
|
+
requireConfirmation: boolean | ((migrations: MigrationToExecuteOkStatus[]) => boolean)
|
|
30
30
|
force?: boolean
|
|
31
31
|
until?: string
|
|
32
32
|
additionalMessage?: string
|
|
@@ -46,7 +46,7 @@ export class MigrationExecutionFacade {
|
|
|
46
46
|
migrations.forEach(it => console.log(it.name))
|
|
47
47
|
additionalMessage && console.log(additionalMessage)
|
|
48
48
|
|
|
49
|
-
if (requireConfirmation) {
|
|
49
|
+
if (typeof requireConfirmation === 'function' ? requireConfirmation(migrations) : requireConfirmation) {
|
|
50
50
|
if (!process.stdin.isTTY) {
|
|
51
51
|
throw 'TTY not available. Pass --yes option to confirm execution.'
|
|
52
52
|
}
|