-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
53 lines (41 loc) · 1.37 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { Migrate } from "./src/migrator.js";
/* Setup config */
const mungingHundler = async (row, parsed) => myDataMunging(row, parsed);
const pathFile = "./input/" + "data.tsv";
const batchSize = 1;
const offset = 0;
const contentTypeId = "ContentTypeIdFromContentful";
// Only use when migrating from one Contentful Organization to other.
// This is the content Type from where exporting the data
const externalContentTypeId = "ContentTypeIdFromContentful";
/*
The myDataMunging function provides each row of data from TSV file or CMA
and a parsed object to pushed wrangled data. Do inside your magic to transform
data as needed.
*/
const myDataMunging = async (row, parsed) => {
console.log(row);
parsed.push({
title: {
"en-US": row.title,
},
});
};
const intoContentful = new Migrate(
mungingHundler,
batchSize,
offset,
pathFile,
contentTypeId,
externalContentTypeId
);
/*
Comment or uncomment following methods as needed:
*/
await intoContentful.getContentTypeStructure(); // Save content Type API response for easier set up
intoContentful.setDebug(); // For console log inside myDataMunging without creating content type
intoContentful.setPublishJustOneBatchForTesting(); // For testing just one batch to evaluate script creation in Contentful
/*
Mandatory method.
*/
await intoContentful.run("file", "create"); // Execute script