@kontent-ai/migration-toolkit 2.8.0 → 2.9.0
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/core/models/migration.schema.d.ts +119 -1102
- package/dist/core/models/migration.schema.js +1 -1
- package/dist/core/models/migration.schema.js.map +1 -1
- package/dist/core/utils/global.utils.d.ts +0 -7
- package/dist/core/utils/global.utils.js +0 -53
- package/dist/core/utils/global.utils.js.map +1 -1
- package/dist/export/export-manager.js +1 -1
- package/dist/export/export-manager.js.map +1 -1
- package/dist/import/import.models.d.ts +2 -2
- package/dist/import/importers/language-variant-importer.js.map +1 -1
- package/dist/metadata.js +2 -2
- package/dist/toolkit/export.js +1 -18
- package/dist/toolkit/export.js.map +1 -1
- package/dist/toolkit/file.js +10 -41
- package/dist/toolkit/file.js.map +1 -1
- package/dist/toolkit/import.js +11 -28
- package/dist/toolkit/import.js.map +1 -1
- package/dist/toolkit/migrate.js +15 -33
- package/dist/toolkit/migrate.js.map +1 -1
- package/lib/core/models/migration.schema.ts +1 -1
- package/lib/core/utils/global.utils.ts +0 -65
- package/lib/export/export-manager.ts +1 -1
- package/lib/import/import.models.ts +2 -2
- package/lib/import/importers/language-variant-importer.ts +2 -2
- package/lib/metadata.ts +2 -2
- package/lib/toolkit/export.ts +1 -18
- package/lib/toolkit/file.ts +9 -40
- package/lib/toolkit/import.ts +11 -28
- package/lib/toolkit/migrate.ts +16 -34
- package/package.json +20 -21
package/lib/toolkit/file.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Buffer as BufferProxy } from 'buffer';
|
|
2
2
|
import type { Logger, MigrationData } from '../core/index.js';
|
|
3
|
-
import { defaultZipFilename,
|
|
3
|
+
import { defaultZipFilename, getDefaultLogger } from '../core/index.js';
|
|
4
4
|
import { fileManager } from '../file/index.js';
|
|
5
|
-
import { libMetadata } from '../metadata.js';
|
|
6
5
|
import { zipManager } from '../zip/index.js';
|
|
7
6
|
|
|
8
7
|
export interface StoreConfig {
|
|
@@ -20,49 +19,19 @@ export async function storeAsync(config: StoreConfig): Promise<void> {
|
|
|
20
19
|
const logger = config.logger ?? getDefaultLogger();
|
|
21
20
|
const filename = config.filename ?? defaultZipFilename;
|
|
22
21
|
|
|
23
|
-
await
|
|
24
|
-
event: {
|
|
25
|
-
tool: 'migrationToolkit',
|
|
26
|
-
package: {
|
|
27
|
-
name: libMetadata.name,
|
|
28
|
-
version: libMetadata.version
|
|
29
|
-
},
|
|
30
|
-
action: 'store',
|
|
31
|
-
relatedEnvironmentId: undefined,
|
|
32
|
-
details: {}
|
|
33
|
-
},
|
|
34
|
-
func: async () => {
|
|
35
|
-
const zipData = await zipManager(logger).createZipAsync(config.data);
|
|
22
|
+
const zipData = await zipManager(logger).createZipAsync(config.data);
|
|
36
23
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
},
|
|
43
|
-
logger: config.logger
|
|
44
|
-
});
|
|
24
|
+
if (zipData instanceof BufferProxy) {
|
|
25
|
+
await fileManager(logger).writeFileAsync(filename, zipData);
|
|
26
|
+
} else {
|
|
27
|
+
throw Error(`Cannot store '${filename}' on File system because the provided zip is not a Buffer`);
|
|
28
|
+
}
|
|
45
29
|
}
|
|
46
30
|
|
|
47
31
|
export async function extractAsync(config: ExtractConfig): Promise<MigrationData> {
|
|
48
32
|
const logger = config.logger ?? getDefaultLogger();
|
|
49
33
|
const filename = config.filename ?? defaultZipFilename;
|
|
50
34
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
tool: 'migrationToolkit',
|
|
54
|
-
package: {
|
|
55
|
-
name: libMetadata.name,
|
|
56
|
-
version: libMetadata.version
|
|
57
|
-
},
|
|
58
|
-
action: 'extract',
|
|
59
|
-
relatedEnvironmentId: undefined,
|
|
60
|
-
details: {}
|
|
61
|
-
},
|
|
62
|
-
func: async () => {
|
|
63
|
-
const fileData = await fileManager(logger).loadFileAsync(filename);
|
|
64
|
-
return await zipManager(logger).parseZipAsync(fileData);
|
|
65
|
-
},
|
|
66
|
-
logger: config.logger
|
|
67
|
-
});
|
|
35
|
+
const fileData = await fileManager(logger).loadFileAsync(filename);
|
|
36
|
+
return await zipManager(logger).parseZipAsync(fileData);
|
|
68
37
|
}
|
package/lib/toolkit/import.ts
CHANGED
|
@@ -1,37 +1,20 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import { writeFile } from 'fs/promises';
|
|
3
|
-
import { executeWithTrackingAsync } from '../core/index.js';
|
|
4
3
|
import type { ImportConfig, ImportResult } from '../import/index.js';
|
|
5
4
|
import { importManager as _importManager } from '../import/index.js';
|
|
6
|
-
import { libMetadata } from '../metadata.js';
|
|
7
5
|
|
|
8
6
|
export async function importAsync(config: ImportConfig): Promise<ImportResult> {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
tool: 'migrationToolkit',
|
|
12
|
-
package: {
|
|
13
|
-
name: libMetadata.name,
|
|
14
|
-
version: libMetadata.version
|
|
15
|
-
},
|
|
16
|
-
action: 'import',
|
|
17
|
-
relatedEnvironmentId: undefined,
|
|
18
|
-
details: {}
|
|
19
|
-
},
|
|
20
|
-
func: async () => {
|
|
21
|
-
const importManager = _importManager(config);
|
|
22
|
-
const importResult = await importManager.importAsync();
|
|
7
|
+
const importManager = _importManager(config);
|
|
8
|
+
const importResult = await importManager.importAsync();
|
|
23
9
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
10
|
+
if (config.createReportFile) {
|
|
11
|
+
const reportFile = importManager.getReportFile(importResult);
|
|
12
|
+
await writeFile(reportFile.filename, reportFile.content);
|
|
13
|
+
config.logger?.log({
|
|
14
|
+
type: 'writeFs',
|
|
15
|
+
message: `Report '${chalk.yellow(reportFile.filename)}' was created`
|
|
16
|
+
});
|
|
17
|
+
}
|
|
32
18
|
|
|
33
|
-
|
|
34
|
-
},
|
|
35
|
-
logger: config.logger
|
|
36
|
-
});
|
|
19
|
+
return importResult;
|
|
37
20
|
}
|
package/lib/toolkit/migrate.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { IRetryStrategyOptions } from '@kontent-ai/core-sdk';
|
|
2
2
|
import type { ExternalIdGenerator, Logger, ManagementClientConfig, MigrationData } from '../core/index.js';
|
|
3
|
-
import {
|
|
3
|
+
import { getDefaultLogger } from '../core/index.js';
|
|
4
4
|
import type { SourceExportItem } from '../export/index.js';
|
|
5
5
|
import type { ImportResult } from '../import/index.js';
|
|
6
|
-
import { libMetadata } from '../metadata.js';
|
|
7
6
|
import { exportAsync } from './export.js';
|
|
8
7
|
import { importAsync } from './import.js';
|
|
9
8
|
|
|
@@ -27,38 +26,21 @@ export interface MigrationResult {
|
|
|
27
26
|
export async function migrateAsync(config: MigrationConfig): Promise<MigrationResult> {
|
|
28
27
|
const logger = config.logger ?? getDefaultLogger();
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
version: libMetadata.version
|
|
36
|
-
},
|
|
37
|
-
action: 'migrate',
|
|
38
|
-
relatedEnvironmentId: undefined,
|
|
39
|
-
details: {
|
|
40
|
-
itemsCount: config.sourceEnvironment.items.length
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
func: async () => {
|
|
44
|
-
const migrationData = await exportAsync({
|
|
45
|
-
...config.sourceEnvironment,
|
|
46
|
-
logger: logger,
|
|
47
|
-
exportItems: config.sourceEnvironment.items
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
const importResult = await importAsync({
|
|
51
|
-
...config.targetEnvironment,
|
|
52
|
-
logger: logger,
|
|
53
|
-
data: migrationData,
|
|
54
|
-
externalIdGenerator: config.externalIdGenerator
|
|
55
|
-
});
|
|
29
|
+
const migrationData = await exportAsync({
|
|
30
|
+
...config.sourceEnvironment,
|
|
31
|
+
logger: logger,
|
|
32
|
+
exportItems: config.sourceEnvironment.items
|
|
33
|
+
});
|
|
56
34
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
logger: config.logger
|
|
35
|
+
const importResult = await importAsync({
|
|
36
|
+
...config.targetEnvironment,
|
|
37
|
+
logger: logger,
|
|
38
|
+
data: migrationData,
|
|
39
|
+
externalIdGenerator: config.externalIdGenerator
|
|
63
40
|
});
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
importResult,
|
|
44
|
+
migrationData
|
|
45
|
+
};
|
|
64
46
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kontent-ai/migration-toolkit",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.0",
|
|
4
4
|
"description": "This program can be used to import content related data into Kontent.ai from various sources. The included functionality enables the content & asset export/import from Kontent.ai environments.",
|
|
5
5
|
"preferGlobal": true,
|
|
6
6
|
"private": false,
|
|
@@ -50,39 +50,38 @@
|
|
|
50
50
|
],
|
|
51
51
|
"license": "MIT",
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@kontent-ai
|
|
54
|
-
"@kontent-ai/management-sdk": "7.9.0",
|
|
53
|
+
"@kontent-ai/management-sdk": "8.0.0",
|
|
55
54
|
"browser-or-node": "3.0.0",
|
|
56
55
|
"buffer": "6.0.3",
|
|
57
56
|
"bytes": "3.1.2",
|
|
58
|
-
"chalk": "5.
|
|
57
|
+
"chalk": "5.6.2",
|
|
59
58
|
"deep-equal": "2.2.3",
|
|
60
|
-
"dotenv": "
|
|
59
|
+
"dotenv": "17.2.3",
|
|
61
60
|
"jszip": "3.10.1",
|
|
62
|
-
"mime": "4.0
|
|
63
|
-
"ora": "
|
|
64
|
-
"p-limit": "
|
|
61
|
+
"mime": "4.1.0",
|
|
62
|
+
"ora": "9.0.0",
|
|
63
|
+
"p-limit": "7.2.0",
|
|
65
64
|
"prompts": "2.4.2",
|
|
66
|
-
"ts-pattern": "5.
|
|
67
|
-
"yargs": "
|
|
68
|
-
"zod": "
|
|
65
|
+
"ts-pattern": "5.9.0",
|
|
66
|
+
"yargs": "18.0.0",
|
|
67
|
+
"zod": "4.1.12"
|
|
69
68
|
},
|
|
70
69
|
"devDependencies": {
|
|
71
|
-
"@eslint/js": "9.
|
|
70
|
+
"@eslint/js": "9.39.1",
|
|
72
71
|
"@types/browser-or-node": "1.3.2",
|
|
73
72
|
"@types/bytes": "3.1.5",
|
|
74
73
|
"@types/deep-equal": "1.0.4",
|
|
75
|
-
"@types/node": "
|
|
74
|
+
"@types/node": "24.10.0",
|
|
76
75
|
"@types/prompts": "2.4.9",
|
|
77
|
-
"@types/yargs": "17.0.
|
|
78
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
79
|
-
"@typescript-eslint/parser": "8.
|
|
80
|
-
"eslint": "9.
|
|
76
|
+
"@types/yargs": "17.0.34",
|
|
77
|
+
"@typescript-eslint/eslint-plugin": "8.46.4",
|
|
78
|
+
"@typescript-eslint/parser": "8.46.4",
|
|
79
|
+
"eslint": "9.39.1",
|
|
81
80
|
"standard-version": "9.5.0",
|
|
82
81
|
"tslib": "2.8.1",
|
|
83
|
-
"tsx": "4.
|
|
84
|
-
"typescript": "5.
|
|
85
|
-
"typescript-eslint": "8.
|
|
86
|
-
"vitest": "
|
|
82
|
+
"tsx": "4.20.6",
|
|
83
|
+
"typescript": "5.9.3",
|
|
84
|
+
"typescript-eslint": "8.46.4",
|
|
85
|
+
"vitest": "4.0.8"
|
|
87
86
|
}
|
|
88
87
|
}
|