contentful-import 10.5.1 → 10.5.2
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/index.js +65 -15
- package/dist/index.mjs +65 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4861,7 +4861,7 @@ var startCase_default = startCase;
|
|
|
4861
4861
|
|
|
4862
4862
|
// lib/index.ts
|
|
4863
4863
|
var import_p_queue = __toESM(require("p-queue"));
|
|
4864
|
-
var
|
|
4864
|
+
var import_logging15 = __toESM(require_logging());
|
|
4865
4865
|
var import_listr4 = __toESM(require_listr());
|
|
4866
4866
|
|
|
4867
4867
|
// lib/tasks/init-client.ts
|
|
@@ -7150,6 +7150,9 @@ async function publishEntities2({ entities: entities2, sourceEntities, client, s
|
|
|
7150
7150
|
});
|
|
7151
7151
|
}
|
|
7152
7152
|
|
|
7153
|
+
// lib/transform/transform-space.ts
|
|
7154
|
+
var import_logging13 = __toESM(require_logging());
|
|
7155
|
+
|
|
7153
7156
|
// lib/transform/transformers.ts
|
|
7154
7157
|
var transformers_exports = {};
|
|
7155
7158
|
__export(transformers_exports, {
|
|
@@ -7158,6 +7161,7 @@ __export(transformers_exports, {
|
|
|
7158
7161
|
entries: () => entries,
|
|
7159
7162
|
locales: () => locales,
|
|
7160
7163
|
releases: () => releases,
|
|
7164
|
+
removeMetadataTags: () => removeMetadataTags,
|
|
7161
7165
|
tags: () => tags,
|
|
7162
7166
|
webhooks: () => webhooks
|
|
7163
7167
|
});
|
|
@@ -7208,10 +7212,14 @@ function locales(locale, destinationLocales) {
|
|
|
7208
7212
|
return transformedLocale;
|
|
7209
7213
|
}
|
|
7210
7214
|
function removeMetadataTags(entity, tagsEnabled = false) {
|
|
7211
|
-
if (!
|
|
7212
|
-
|
|
7215
|
+
if (tagsEnabled || !entity.metadata) {
|
|
7216
|
+
return entity;
|
|
7213
7217
|
}
|
|
7214
|
-
|
|
7218
|
+
const restMetadata = omit_default(entity.metadata, "tags");
|
|
7219
|
+
return {
|
|
7220
|
+
...omit_default(entity, "metadata"),
|
|
7221
|
+
...Object.keys(restMetadata).length > 0 ? { metadata: restMetadata } : {}
|
|
7222
|
+
};
|
|
7215
7223
|
}
|
|
7216
7224
|
function releases(release) {
|
|
7217
7225
|
return release;
|
|
@@ -7453,14 +7461,20 @@ function upgradeExperience(entity) {
|
|
|
7453
7461
|
...entity.slots !== void 0 ? { slots: upgradeNodeMap(entity.slots) } : {}
|
|
7454
7462
|
};
|
|
7455
7463
|
}
|
|
7456
|
-
function
|
|
7464
|
+
function upgradeEntityArray(key, resources, upgrade, tagsEnabled) {
|
|
7465
|
+
const items = resources[key];
|
|
7466
|
+
if (!Array.isArray(items)) return {};
|
|
7467
|
+
const upgraded = items.map((entity) => removeMetadataTags(upgrade(entity), tagsEnabled));
|
|
7468
|
+
return { [key]: upgraded };
|
|
7469
|
+
}
|
|
7470
|
+
function upgradeExoResources(resources, tagsEnabled = false) {
|
|
7457
7471
|
if (!resources) return resources;
|
|
7458
7472
|
return {
|
|
7459
7473
|
...resources,
|
|
7460
|
-
...
|
|
7461
|
-
...
|
|
7462
|
-
...
|
|
7463
|
-
...
|
|
7474
|
+
...upgradeEntityArray("components", resources, upgradeComponent, tagsEnabled),
|
|
7475
|
+
...upgradeEntityArray("experienceTemplates", resources, upgradeExperienceTemplate, tagsEnabled),
|
|
7476
|
+
...upgradeEntityArray("experienceFragments", resources, upgradeExperienceFragment, tagsEnabled),
|
|
7477
|
+
...upgradeEntityArray("experiences", resources, upgradeExperience, tagsEnabled)
|
|
7464
7478
|
};
|
|
7465
7479
|
}
|
|
7466
7480
|
|
|
@@ -7474,10 +7488,46 @@ var entities = [
|
|
|
7474
7488
|
"tags",
|
|
7475
7489
|
"releases"
|
|
7476
7490
|
];
|
|
7491
|
+
var TAG_SCRUBBED_ENTITY_TYPES = [
|
|
7492
|
+
"entries",
|
|
7493
|
+
"assets",
|
|
7494
|
+
"components",
|
|
7495
|
+
"experienceTemplates",
|
|
7496
|
+
"experienceFragments",
|
|
7497
|
+
"experiences",
|
|
7498
|
+
"dataAssemblies",
|
|
7499
|
+
"designTokens"
|
|
7500
|
+
];
|
|
7501
|
+
function countEntitiesWithTags(sourceData) {
|
|
7502
|
+
return TAG_SCRUBBED_ENTITY_TYPES.reduce((count, type) => {
|
|
7503
|
+
const entitiesOfType = sourceData[type] ?? [];
|
|
7504
|
+
return count + entitiesOfType.filter((entity) => entity.metadata?.tags?.length).length;
|
|
7505
|
+
}, 0);
|
|
7506
|
+
}
|
|
7507
|
+
function warnIfTagsWillBeStripped(sourceData, tagsEnabled) {
|
|
7508
|
+
if (tagsEnabled) return;
|
|
7509
|
+
const strippedCount = countEntitiesWithTags(sourceData);
|
|
7510
|
+
if (strippedCount === 0) return;
|
|
7511
|
+
import_logging13.logEmitter.emit("warning", `The destination space/environment does not have access to the Tags feature. metadata.tags was removed from ${strippedCount} ${strippedCount === 1 ? "entity" : "entities"} during import.`);
|
|
7512
|
+
}
|
|
7513
|
+
function stripTagsFromDataAssembliesAndDesignTokens(spaceData, tagsEnabled) {
|
|
7514
|
+
if (tagsEnabled) return;
|
|
7515
|
+
if (Array.isArray(spaceData.dataAssemblies)) {
|
|
7516
|
+
spaceData.dataAssemblies = spaceData.dataAssemblies.map((entity) => ({
|
|
7517
|
+
...entity,
|
|
7518
|
+
metadata: { ...entity.metadata, tags: [] }
|
|
7519
|
+
}));
|
|
7520
|
+
}
|
|
7521
|
+
if (Array.isArray(spaceData.designTokens)) {
|
|
7522
|
+
spaceData.designTokens = spaceData.designTokens.map((entity) => removeMetadataTags(entity, false));
|
|
7523
|
+
}
|
|
7524
|
+
}
|
|
7477
7525
|
function transform_space_default(sourceData, destinationData) {
|
|
7478
|
-
const baseSpaceData = upgradeExoResources(omit_default(sourceData, ...entities));
|
|
7479
|
-
sourceData.locales = sortLocales(sourceData.locales);
|
|
7480
7526
|
const tagsEnabled = !!destinationData.tags;
|
|
7527
|
+
warnIfTagsWillBeStripped(sourceData, tagsEnabled);
|
|
7528
|
+
const baseSpaceData = upgradeExoResources(omit_default(sourceData, ...entities), tagsEnabled);
|
|
7529
|
+
stripTagsFromDataAssembliesAndDesignTokens(baseSpaceData, tagsEnabled);
|
|
7530
|
+
sourceData.locales = sortLocales(sourceData.locales);
|
|
7481
7531
|
return entities.reduce((transformedSpaceData, type) => {
|
|
7482
7532
|
const sortedEntities = type === "tags" || type === "releases" ? sourceData[type] ?? [] : sortEntries(sourceData[type] ?? []);
|
|
7483
7533
|
const transformedEntities = sortedEntities.map((entity) => ({
|
|
@@ -7778,7 +7828,7 @@ async function parseOptions(params) {
|
|
|
7778
7828
|
|
|
7779
7829
|
// lib/utils/display-error-log.ts
|
|
7780
7830
|
var import_date_fns2 = require("date-fns");
|
|
7781
|
-
var
|
|
7831
|
+
var import_logging14 = __toESM(require_logging());
|
|
7782
7832
|
function displayErrorLog(errorLog) {
|
|
7783
7833
|
if (errorLog.length) {
|
|
7784
7834
|
const count = errorLog.reduce((count2, curr) => {
|
|
@@ -7793,7 +7843,7 @@ function displayErrorLog(errorLog) {
|
|
|
7793
7843
|
|
|
7794
7844
|
The following ${count.errors} errors and ${count.warnings} warnings occurred:
|
|
7795
7845
|
`);
|
|
7796
|
-
errorLog.map((logMessage) => `${(0, import_date_fns2.format)((0, import_date_fns2.parseISO)(logMessage.ts), "HH:mm:ss")} - ${(0,
|
|
7846
|
+
errorLog.map((logMessage) => `${(0, import_date_fns2.format)((0, import_date_fns2.parseISO)(logMessage.ts), "HH:mm:ss")} - ${(0, import_logging14.formatLogMessageOneLine)(logMessage)}`).map((logMessage) => console.log(logMessage));
|
|
7797
7847
|
return;
|
|
7798
7848
|
}
|
|
7799
7849
|
console.log("No errors or warnings occurred");
|
|
@@ -7825,7 +7875,7 @@ async function runContentfulImport(params) {
|
|
|
7825
7875
|
intervalCap: options.rateLimit,
|
|
7826
7876
|
carryoverConcurrencyCount: true
|
|
7827
7877
|
});
|
|
7828
|
-
(0,
|
|
7878
|
+
(0, import_logging15.setupLogging)(log);
|
|
7829
7879
|
const infoTable = new import_cli_table3.default(tableOptions);
|
|
7830
7880
|
infoTable.push([{ colSpan: 2, content: "The following entities are going to be imported:" }]);
|
|
7831
7881
|
Object.keys(options.content).forEach((type) => {
|
|
@@ -7952,7 +8002,7 @@ async function runContentfulImport(params) {
|
|
|
7952
8002
|
const displayLog = log.filter((logMessage) => logMessage.level !== "info");
|
|
7953
8003
|
displayErrorLog(displayLog);
|
|
7954
8004
|
if (errorLog.length) {
|
|
7955
|
-
return (0,
|
|
8005
|
+
return (0, import_logging15.writeErrorLogFile)(options.errorLogFile, errorLog).then(() => {
|
|
7956
8006
|
const multiError = new ContentfulMultiError("Errors occurred");
|
|
7957
8007
|
multiError.name = "ContentfulMultiError";
|
|
7958
8008
|
multiError.errors = errorLog;
|
package/dist/index.mjs
CHANGED
|
@@ -4827,7 +4827,7 @@ var startCase = createCompounder_default(function(result, word, index) {
|
|
|
4827
4827
|
var startCase_default = startCase;
|
|
4828
4828
|
|
|
4829
4829
|
// lib/index.ts
|
|
4830
|
-
var
|
|
4830
|
+
var import_logging15 = __toESM(require_logging());
|
|
4831
4831
|
var import_listr4 = __toESM(require_listr());
|
|
4832
4832
|
import PQueue from "p-queue";
|
|
4833
4833
|
|
|
@@ -7117,6 +7117,9 @@ async function publishEntities2({ entities: entities2, sourceEntities, client, s
|
|
|
7117
7117
|
});
|
|
7118
7118
|
}
|
|
7119
7119
|
|
|
7120
|
+
// lib/transform/transform-space.ts
|
|
7121
|
+
var import_logging13 = __toESM(require_logging());
|
|
7122
|
+
|
|
7120
7123
|
// lib/transform/transformers.ts
|
|
7121
7124
|
var transformers_exports = {};
|
|
7122
7125
|
__export(transformers_exports, {
|
|
@@ -7125,6 +7128,7 @@ __export(transformers_exports, {
|
|
|
7125
7128
|
entries: () => entries,
|
|
7126
7129
|
locales: () => locales,
|
|
7127
7130
|
releases: () => releases,
|
|
7131
|
+
removeMetadataTags: () => removeMetadataTags,
|
|
7128
7132
|
tags: () => tags,
|
|
7129
7133
|
webhooks: () => webhooks
|
|
7130
7134
|
});
|
|
@@ -7175,10 +7179,14 @@ function locales(locale, destinationLocales) {
|
|
|
7175
7179
|
return transformedLocale;
|
|
7176
7180
|
}
|
|
7177
7181
|
function removeMetadataTags(entity, tagsEnabled = false) {
|
|
7178
|
-
if (!
|
|
7179
|
-
|
|
7182
|
+
if (tagsEnabled || !entity.metadata) {
|
|
7183
|
+
return entity;
|
|
7180
7184
|
}
|
|
7181
|
-
|
|
7185
|
+
const restMetadata = omit_default(entity.metadata, "tags");
|
|
7186
|
+
return {
|
|
7187
|
+
...omit_default(entity, "metadata"),
|
|
7188
|
+
...Object.keys(restMetadata).length > 0 ? { metadata: restMetadata } : {}
|
|
7189
|
+
};
|
|
7182
7190
|
}
|
|
7183
7191
|
function releases(release) {
|
|
7184
7192
|
return release;
|
|
@@ -7420,14 +7428,20 @@ function upgradeExperience(entity) {
|
|
|
7420
7428
|
...entity.slots !== void 0 ? { slots: upgradeNodeMap(entity.slots) } : {}
|
|
7421
7429
|
};
|
|
7422
7430
|
}
|
|
7423
|
-
function
|
|
7431
|
+
function upgradeEntityArray(key, resources, upgrade, tagsEnabled) {
|
|
7432
|
+
const items = resources[key];
|
|
7433
|
+
if (!Array.isArray(items)) return {};
|
|
7434
|
+
const upgraded = items.map((entity) => removeMetadataTags(upgrade(entity), tagsEnabled));
|
|
7435
|
+
return { [key]: upgraded };
|
|
7436
|
+
}
|
|
7437
|
+
function upgradeExoResources(resources, tagsEnabled = false) {
|
|
7424
7438
|
if (!resources) return resources;
|
|
7425
7439
|
return {
|
|
7426
7440
|
...resources,
|
|
7427
|
-
...
|
|
7428
|
-
...
|
|
7429
|
-
...
|
|
7430
|
-
...
|
|
7441
|
+
...upgradeEntityArray("components", resources, upgradeComponent, tagsEnabled),
|
|
7442
|
+
...upgradeEntityArray("experienceTemplates", resources, upgradeExperienceTemplate, tagsEnabled),
|
|
7443
|
+
...upgradeEntityArray("experienceFragments", resources, upgradeExperienceFragment, tagsEnabled),
|
|
7444
|
+
...upgradeEntityArray("experiences", resources, upgradeExperience, tagsEnabled)
|
|
7431
7445
|
};
|
|
7432
7446
|
}
|
|
7433
7447
|
|
|
@@ -7441,10 +7455,46 @@ var entities = [
|
|
|
7441
7455
|
"tags",
|
|
7442
7456
|
"releases"
|
|
7443
7457
|
];
|
|
7458
|
+
var TAG_SCRUBBED_ENTITY_TYPES = [
|
|
7459
|
+
"entries",
|
|
7460
|
+
"assets",
|
|
7461
|
+
"components",
|
|
7462
|
+
"experienceTemplates",
|
|
7463
|
+
"experienceFragments",
|
|
7464
|
+
"experiences",
|
|
7465
|
+
"dataAssemblies",
|
|
7466
|
+
"designTokens"
|
|
7467
|
+
];
|
|
7468
|
+
function countEntitiesWithTags(sourceData) {
|
|
7469
|
+
return TAG_SCRUBBED_ENTITY_TYPES.reduce((count, type) => {
|
|
7470
|
+
const entitiesOfType = sourceData[type] ?? [];
|
|
7471
|
+
return count + entitiesOfType.filter((entity) => entity.metadata?.tags?.length).length;
|
|
7472
|
+
}, 0);
|
|
7473
|
+
}
|
|
7474
|
+
function warnIfTagsWillBeStripped(sourceData, tagsEnabled) {
|
|
7475
|
+
if (tagsEnabled) return;
|
|
7476
|
+
const strippedCount = countEntitiesWithTags(sourceData);
|
|
7477
|
+
if (strippedCount === 0) return;
|
|
7478
|
+
import_logging13.logEmitter.emit("warning", `The destination space/environment does not have access to the Tags feature. metadata.tags was removed from ${strippedCount} ${strippedCount === 1 ? "entity" : "entities"} during import.`);
|
|
7479
|
+
}
|
|
7480
|
+
function stripTagsFromDataAssembliesAndDesignTokens(spaceData, tagsEnabled) {
|
|
7481
|
+
if (tagsEnabled) return;
|
|
7482
|
+
if (Array.isArray(spaceData.dataAssemblies)) {
|
|
7483
|
+
spaceData.dataAssemblies = spaceData.dataAssemblies.map((entity) => ({
|
|
7484
|
+
...entity,
|
|
7485
|
+
metadata: { ...entity.metadata, tags: [] }
|
|
7486
|
+
}));
|
|
7487
|
+
}
|
|
7488
|
+
if (Array.isArray(spaceData.designTokens)) {
|
|
7489
|
+
spaceData.designTokens = spaceData.designTokens.map((entity) => removeMetadataTags(entity, false));
|
|
7490
|
+
}
|
|
7491
|
+
}
|
|
7444
7492
|
function transform_space_default(sourceData, destinationData) {
|
|
7445
|
-
const baseSpaceData = upgradeExoResources(omit_default(sourceData, ...entities));
|
|
7446
|
-
sourceData.locales = sortLocales(sourceData.locales);
|
|
7447
7493
|
const tagsEnabled = !!destinationData.tags;
|
|
7494
|
+
warnIfTagsWillBeStripped(sourceData, tagsEnabled);
|
|
7495
|
+
const baseSpaceData = upgradeExoResources(omit_default(sourceData, ...entities), tagsEnabled);
|
|
7496
|
+
stripTagsFromDataAssembliesAndDesignTokens(baseSpaceData, tagsEnabled);
|
|
7497
|
+
sourceData.locales = sortLocales(sourceData.locales);
|
|
7448
7498
|
return entities.reduce((transformedSpaceData, type) => {
|
|
7449
7499
|
const sortedEntities = type === "tags" || type === "releases" ? sourceData[type] ?? [] : sortEntries(sourceData[type] ?? []);
|
|
7450
7500
|
const transformedEntities = sortedEntities.map((entity) => ({
|
|
@@ -7741,7 +7791,7 @@ async function parseOptions(params) {
|
|
|
7741
7791
|
}
|
|
7742
7792
|
|
|
7743
7793
|
// lib/utils/display-error-log.ts
|
|
7744
|
-
var
|
|
7794
|
+
var import_logging14 = __toESM(require_logging());
|
|
7745
7795
|
import { format as format2, parseISO } from "date-fns";
|
|
7746
7796
|
function displayErrorLog(errorLog) {
|
|
7747
7797
|
if (errorLog.length) {
|
|
@@ -7757,7 +7807,7 @@ function displayErrorLog(errorLog) {
|
|
|
7757
7807
|
|
|
7758
7808
|
The following ${count.errors} errors and ${count.warnings} warnings occurred:
|
|
7759
7809
|
`);
|
|
7760
|
-
errorLog.map((logMessage) => `${format2(parseISO(logMessage.ts), "HH:mm:ss")} - ${(0,
|
|
7810
|
+
errorLog.map((logMessage) => `${format2(parseISO(logMessage.ts), "HH:mm:ss")} - ${(0, import_logging14.formatLogMessageOneLine)(logMessage)}`).map((logMessage) => console.log(logMessage));
|
|
7761
7811
|
return;
|
|
7762
7812
|
}
|
|
7763
7813
|
console.log("No errors or warnings occurred");
|
|
@@ -7789,7 +7839,7 @@ async function runContentfulImport(params) {
|
|
|
7789
7839
|
intervalCap: options.rateLimit,
|
|
7790
7840
|
carryoverConcurrencyCount: true
|
|
7791
7841
|
});
|
|
7792
|
-
(0,
|
|
7842
|
+
(0, import_logging15.setupLogging)(log);
|
|
7793
7843
|
const infoTable = new Table(tableOptions);
|
|
7794
7844
|
infoTable.push([{ colSpan: 2, content: "The following entities are going to be imported:" }]);
|
|
7795
7845
|
Object.keys(options.content).forEach((type) => {
|
|
@@ -7916,7 +7966,7 @@ async function runContentfulImport(params) {
|
|
|
7916
7966
|
const displayLog = log.filter((logMessage) => logMessage.level !== "info");
|
|
7917
7967
|
displayErrorLog(displayLog);
|
|
7918
7968
|
if (errorLog.length) {
|
|
7919
|
-
return (0,
|
|
7969
|
+
return (0, import_logging15.writeErrorLogFile)(options.errorLogFile, errorLog).then(() => {
|
|
7920
7970
|
const multiError = new ContentfulMultiError("Errors occurred");
|
|
7921
7971
|
multiError.name = "ContentfulMultiError";
|
|
7922
7972
|
multiError.errors = errorLog;
|