@jungvonmatt/contentful-migrations 6.2.5 → 7.0.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/README.md +22 -11
- package/cli.js +314 -171
- package/index.d.ts +9 -9
- package/lib/backend.js +155 -107
- package/lib/content.js +5 -5
- package/lib/contentful.js +90 -43
- package/lib/diff.js +46 -32
- package/lib/helpers/locale.d.ts +3 -3
- package/lib/helpers/validation.d.ts +94 -15
- package/lib/helpers/validation.js +4 -4
- package/lib/migration.js +68 -51
- package/package.json +54 -117
- package/lib/helpers/validation.test.js +0 -381
- package/lib/helpers/validation.utils.test.js +0 -45
package/cli.js
CHANGED
|
@@ -2,19 +2,37 @@
|
|
|
2
2
|
|
|
3
3
|
/* eslint-disable no-console */
|
|
4
4
|
/* eslint-env node */
|
|
5
|
-
const fs = require(
|
|
6
|
-
const path = require(
|
|
7
|
-
const pc = require(
|
|
8
|
-
const { Command } = require(
|
|
5
|
+
const fs = require("fs-extra");
|
|
6
|
+
const path = require("path");
|
|
7
|
+
const pc = require("picocolors");
|
|
8
|
+
const { Command } = require("commander");
|
|
9
9
|
|
|
10
|
-
const {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const {
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
const {
|
|
11
|
+
initializeContentModel,
|
|
12
|
+
migrateToContentStorage,
|
|
13
|
+
migrateToTagStorage,
|
|
14
|
+
} = require("./lib/backend");
|
|
15
|
+
const {
|
|
16
|
+
createMigration,
|
|
17
|
+
runMigrations,
|
|
18
|
+
fetchMigration,
|
|
19
|
+
executeMigration,
|
|
20
|
+
} = require("./lib/migration");
|
|
21
|
+
const { versionDelete, versionAdd } = require("./lib/version");
|
|
22
|
+
const { transferContent } = require("./lib/content");
|
|
23
|
+
const { createOfflineDocs } = require("./lib/doc");
|
|
24
|
+
const {
|
|
25
|
+
createEnvironment,
|
|
26
|
+
removeEnvironment,
|
|
27
|
+
resetEnvironment,
|
|
28
|
+
} = require("./lib/environment");
|
|
29
|
+
const {
|
|
30
|
+
getConfig,
|
|
31
|
+
confirm,
|
|
32
|
+
STORAGE_CONTENT,
|
|
33
|
+
STORAGE_TAG,
|
|
34
|
+
} = require("./lib/config");
|
|
35
|
+
const pkg = require("./package.json");
|
|
18
36
|
|
|
19
37
|
const parseArgs = (cmd) => {
|
|
20
38
|
const { parent = {} } = cmd || {};
|
|
@@ -37,9 +55,9 @@ const parseArgs = (cmd) => {
|
|
|
37
55
|
const errorHandler = (error, log) => {
|
|
38
56
|
if (log) {
|
|
39
57
|
const { errors, message } = error;
|
|
40
|
-
console.error(pc.red(
|
|
58
|
+
console.error(pc.red("\nError:"), message);
|
|
41
59
|
(errors || []).forEach((err) => {
|
|
42
|
-
console.error(pc.red(
|
|
60
|
+
console.error(pc.red("Error:"), err.message);
|
|
43
61
|
});
|
|
44
62
|
}
|
|
45
63
|
process.exit(1);
|
|
@@ -56,28 +74,31 @@ const program = new Command();
|
|
|
56
74
|
|
|
57
75
|
program.version(pkg.version);
|
|
58
76
|
program
|
|
59
|
-
.command(
|
|
60
|
-
.option(
|
|
61
|
-
.option(
|
|
62
|
-
.option(
|
|
63
|
-
|
|
64
|
-
|
|
77
|
+
.command("init")
|
|
78
|
+
.option("-s, --space-id <space-id>", "Contentful space id")
|
|
79
|
+
.option("--host <host>", "Management API host")
|
|
80
|
+
.option(
|
|
81
|
+
"--config <path/to/config>",
|
|
82
|
+
"Config file path (disables auto detect)",
|
|
83
|
+
)
|
|
84
|
+
.option("--cwd <directory>", "Working directory. Defaults to process.cwd()")
|
|
85
|
+
.description("Initialize contentful-migrations")
|
|
65
86
|
.action(
|
|
66
87
|
actionRunner(async (cmd) => {
|
|
67
88
|
const config = await getConfig(
|
|
68
89
|
parseArgs(cmd || {}),
|
|
69
90
|
[],
|
|
70
91
|
[
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
]
|
|
92
|
+
"managementToken",
|
|
93
|
+
"host",
|
|
94
|
+
"organizationId",
|
|
95
|
+
"spaceId",
|
|
96
|
+
"environmentId",
|
|
97
|
+
"storage",
|
|
98
|
+
"fieldId",
|
|
99
|
+
"migrationContentTypeId",
|
|
100
|
+
"directory",
|
|
101
|
+
],
|
|
81
102
|
);
|
|
82
103
|
|
|
83
104
|
if (config.storage === STORAGE_CONTENT) {
|
|
@@ -88,12 +109,22 @@ program
|
|
|
88
109
|
await migrateToTagStorage(config);
|
|
89
110
|
}
|
|
90
111
|
|
|
91
|
-
const storeConfig = await confirm({
|
|
112
|
+
const storeConfig = await confirm({
|
|
113
|
+
message: "Do you want to store the configuration?",
|
|
114
|
+
});
|
|
92
115
|
|
|
93
116
|
if (storeConfig) {
|
|
94
117
|
// only store relevant config values without management token
|
|
95
118
|
// management token should not be stored inside the project
|
|
96
|
-
const {
|
|
119
|
+
const {
|
|
120
|
+
host,
|
|
121
|
+
spaceId,
|
|
122
|
+
environmentId,
|
|
123
|
+
storage,
|
|
124
|
+
fieldId,
|
|
125
|
+
migrationContentTypeId,
|
|
126
|
+
directory,
|
|
127
|
+
} = config;
|
|
97
128
|
|
|
98
129
|
const data = {
|
|
99
130
|
host,
|
|
@@ -101,200 +132,275 @@ program
|
|
|
101
132
|
environmentId,
|
|
102
133
|
directory,
|
|
103
134
|
storage,
|
|
104
|
-
...(storage === STORAGE_CONTENT
|
|
135
|
+
...(storage === STORAGE_CONTENT
|
|
136
|
+
? { migrationContentTypeId }
|
|
137
|
+
: { fieldId }),
|
|
105
138
|
};
|
|
106
139
|
|
|
107
140
|
// try to store in package.json
|
|
108
|
-
const {
|
|
109
|
-
const localPkg = await
|
|
141
|
+
const { packageUp } = await import("package-up");
|
|
142
|
+
const localPkg = await packageUp();
|
|
110
143
|
if (localPkg) {
|
|
111
144
|
const packageJson = await fs.readJson(localPkg);
|
|
112
|
-
data.directory = path.relative(
|
|
145
|
+
data.directory = path.relative(
|
|
146
|
+
path.dirname(localPkg),
|
|
147
|
+
data.directory,
|
|
148
|
+
);
|
|
113
149
|
packageJson.migrations = data;
|
|
114
150
|
await fs.outputJson(localPkg, packageJson, { spaces: 2 });
|
|
115
151
|
} else {
|
|
116
152
|
// store in .migrationsrc if no package.json is available
|
|
117
153
|
const cwd = cmd.cwd ? path.resolve(cmd.cwd) : process.cwd();
|
|
118
154
|
data.directory = path.relative(cwd, data.directory);
|
|
119
|
-
await fs.outputJson(path.join(cwd,
|
|
155
|
+
await fs.outputJson(path.join(cwd, ".migrationsrc.json"), data, {
|
|
156
|
+
spaces: 2,
|
|
157
|
+
});
|
|
120
158
|
}
|
|
121
159
|
}
|
|
122
|
-
})
|
|
160
|
+
}),
|
|
123
161
|
);
|
|
124
162
|
|
|
125
163
|
program
|
|
126
|
-
.command(
|
|
127
|
-
.option(
|
|
128
|
-
.option(
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
.option(
|
|
133
|
-
.option(
|
|
134
|
-
|
|
135
|
-
|
|
164
|
+
.command("fetch")
|
|
165
|
+
.option("-s, --space-id <space-id>", "Contentful space id")
|
|
166
|
+
.option(
|
|
167
|
+
"-e, --environment-id <environment-id>",
|
|
168
|
+
"Change the Contentful environment",
|
|
169
|
+
)
|
|
170
|
+
.option("-c, --content-type <content-type...>", "Specify content-types")
|
|
171
|
+
.option(
|
|
172
|
+
"-p, --path <path/to/migrations>",
|
|
173
|
+
"Change the path where the migrations are saved",
|
|
174
|
+
)
|
|
175
|
+
.option("-v, --verbose", "Verbosity")
|
|
176
|
+
.option("--host <host>", "Management API host")
|
|
177
|
+
.option(
|
|
178
|
+
"--config <path/to/config>",
|
|
179
|
+
"Config file path (disables auto detect)",
|
|
180
|
+
)
|
|
181
|
+
.option("--cwd <directory>", "Working directory. Defaults to process.cwd()")
|
|
182
|
+
.description("Generate a new Contentful migration from content type")
|
|
136
183
|
.action(
|
|
137
184
|
actionRunner(async (cmd) => {
|
|
138
185
|
const config = await getConfig(parseArgs(cmd || {}), [
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
186
|
+
"managementToken",
|
|
187
|
+
"spaceId",
|
|
188
|
+
"environmentId",
|
|
189
|
+
"directory",
|
|
143
190
|
]);
|
|
144
191
|
|
|
145
192
|
await fetchMigration({ ...config, contentType: cmd.contentType });
|
|
146
|
-
})
|
|
193
|
+
}),
|
|
147
194
|
);
|
|
148
195
|
|
|
149
196
|
program
|
|
150
|
-
.command(
|
|
151
|
-
.option(
|
|
152
|
-
.option(
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
.option(
|
|
157
|
-
|
|
158
|
-
|
|
197
|
+
.command("generate")
|
|
198
|
+
.option("-s, --space-id <space-id>", "Contentful space id")
|
|
199
|
+
.option(
|
|
200
|
+
"-e, --environment-id <environment-id>",
|
|
201
|
+
"Change the Contentful environment",
|
|
202
|
+
)
|
|
203
|
+
.option(
|
|
204
|
+
"-p, --path <path/to/migrations>",
|
|
205
|
+
"Change the path where the migrations are saved",
|
|
206
|
+
)
|
|
207
|
+
.option("-v, --verbose", "Verbosity")
|
|
208
|
+
.option("--host <host>", "Management API host")
|
|
209
|
+
.option(
|
|
210
|
+
"--config <path/to/config>",
|
|
211
|
+
"Config file path (disables auto detect)",
|
|
212
|
+
)
|
|
213
|
+
.option("--cwd <directory>", "Working directory. Defaults to process.cwd()")
|
|
214
|
+
.description("Generate a new Contentful migration")
|
|
159
215
|
.action(
|
|
160
216
|
actionRunner(async (cmd) => {
|
|
161
217
|
const config = await getConfig(parseArgs(cmd || {}), [
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
218
|
+
"managementToken",
|
|
219
|
+
"spaceId",
|
|
220
|
+
"environmentId",
|
|
221
|
+
"directory",
|
|
166
222
|
]);
|
|
167
223
|
await createMigration(config);
|
|
168
|
-
})
|
|
224
|
+
}),
|
|
169
225
|
);
|
|
170
226
|
|
|
171
227
|
program
|
|
172
|
-
.command(
|
|
173
|
-
.option(
|
|
174
|
-
.option(
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
.option(
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
.option(
|
|
183
|
-
.
|
|
228
|
+
.command("migrate")
|
|
229
|
+
.option("-s, --space-id <space-id>", "Contentful space id")
|
|
230
|
+
.option(
|
|
231
|
+
"-e, --environment-id <environment-id>",
|
|
232
|
+
"Change the Contentful environment",
|
|
233
|
+
)
|
|
234
|
+
.option(
|
|
235
|
+
"-p, --path <path/to/migrations>",
|
|
236
|
+
"Change the path where the migrations are stored",
|
|
237
|
+
)
|
|
238
|
+
.option("-v, --verbose", "Verbosity")
|
|
239
|
+
.option(
|
|
240
|
+
"-y, --yes",
|
|
241
|
+
'Assume "yes" as answer to all prompts and run non-interactively.',
|
|
242
|
+
)
|
|
243
|
+
.option("--host <host>", "Management API host")
|
|
244
|
+
.option(
|
|
245
|
+
"--config <path/to/config>",
|
|
246
|
+
"Config file path (disables auto detect)",
|
|
247
|
+
)
|
|
248
|
+
.option("--cwd <directory>", "Working directory. Defaults to process.cwd()")
|
|
249
|
+
.option(
|
|
250
|
+
"--bail",
|
|
251
|
+
"Abort execution after first failed migration (default: true)",
|
|
252
|
+
true,
|
|
253
|
+
)
|
|
254
|
+
.option("--no-bail", "Ignore failed migrations")
|
|
255
|
+
.description("Execute all unexecuted migrations available.")
|
|
184
256
|
.action(
|
|
185
257
|
actionRunner(async (cmd) => {
|
|
186
258
|
const config = await getConfig(parseArgs(cmd || {}), [
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
259
|
+
"managementToken",
|
|
260
|
+
"spaceId",
|
|
261
|
+
"environmentId",
|
|
262
|
+
"storage",
|
|
263
|
+
"fieldId",
|
|
264
|
+
"migrationContentTypeId",
|
|
265
|
+
"directory",
|
|
194
266
|
]);
|
|
195
267
|
|
|
196
268
|
const { missingStorageModel } = config;
|
|
197
269
|
if (missingStorageModel) {
|
|
198
|
-
console.error(
|
|
270
|
+
console.error(
|
|
271
|
+
pc.red("\nError:"),
|
|
272
|
+
`Missing migration content type. Run ${pc.cyan("npx migrations init")}`,
|
|
273
|
+
);
|
|
199
274
|
process.exit(1);
|
|
200
275
|
}
|
|
201
276
|
|
|
202
277
|
await runMigrations(config);
|
|
203
|
-
}, false)
|
|
278
|
+
}, false),
|
|
204
279
|
);
|
|
205
280
|
|
|
206
281
|
program
|
|
207
|
-
.command(
|
|
208
|
-
.option(
|
|
209
|
-
.option(
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
.option(
|
|
214
|
-
.option(
|
|
215
|
-
|
|
282
|
+
.command("execute <file>")
|
|
283
|
+
.option("-s, --space-id <space-id>", "Contentful space id")
|
|
284
|
+
.option(
|
|
285
|
+
"-e, --environment-id <environment-id>",
|
|
286
|
+
"Change the Contentful environment",
|
|
287
|
+
)
|
|
288
|
+
.option("-v, --verbose", "Verbosity")
|
|
289
|
+
.option(
|
|
290
|
+
"-y, --yes",
|
|
291
|
+
'Assume "yes" as answer to all prompts and run non-interactively.',
|
|
292
|
+
)
|
|
293
|
+
.option("--host <host>", "Management API host")
|
|
294
|
+
.option(
|
|
295
|
+
"--config <path/to/config>",
|
|
296
|
+
"Config file path (disables auto detect)",
|
|
297
|
+
)
|
|
298
|
+
.option("--cwd <directory>", "Working directory. Defaults to process.cwd()")
|
|
299
|
+
.description("Execute a single migration.")
|
|
216
300
|
.action(
|
|
217
301
|
actionRunner(async (file, options) => {
|
|
218
302
|
const config = await getConfig(parseArgs(options || {}), [
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
303
|
+
"managementToken",
|
|
304
|
+
"spaceId",
|
|
305
|
+
"environmentId",
|
|
306
|
+
"storage",
|
|
307
|
+
"fieldId",
|
|
308
|
+
"migrationContentTypeId",
|
|
309
|
+
"directory",
|
|
226
310
|
]);
|
|
227
311
|
|
|
228
312
|
const { missingStorageModel } = config;
|
|
229
313
|
if (missingStorageModel) {
|
|
230
|
-
console.error(
|
|
314
|
+
console.error(
|
|
315
|
+
pc.red("\nError:"),
|
|
316
|
+
`Missing migration content type. Run ${pc.cyan("npx migrations init")}`,
|
|
317
|
+
);
|
|
231
318
|
process.exit(1);
|
|
232
319
|
}
|
|
233
320
|
await executeMigration(path.resolve(file), config);
|
|
234
|
-
}, false)
|
|
321
|
+
}, false),
|
|
235
322
|
);
|
|
236
323
|
|
|
237
324
|
program
|
|
238
|
-
.command(
|
|
239
|
-
.option(
|
|
240
|
-
.option(
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
.option(
|
|
245
|
-
.option(
|
|
246
|
-
.option(
|
|
247
|
-
|
|
325
|
+
.command("version <file>")
|
|
326
|
+
.option("-s, --space-id <space-id>", "Contentful space id")
|
|
327
|
+
.option(
|
|
328
|
+
"-e, --environment-id <environment-id>",
|
|
329
|
+
"Change the Contentful environment",
|
|
330
|
+
)
|
|
331
|
+
.option("-v, --verbose", "Verbosity")
|
|
332
|
+
.option("--host <host>", "Management API host")
|
|
333
|
+
.option(
|
|
334
|
+
"--config <path/to/config>",
|
|
335
|
+
"Config file path (disables auto detect)",
|
|
336
|
+
)
|
|
337
|
+
.option("--add", "Mark migration as migrated")
|
|
338
|
+
.option("--remove", "Delete migration entry in Contentful")
|
|
339
|
+
.option("--cwd <directory>", "Working directory. Defaults to process.cwd()")
|
|
340
|
+
.description(
|
|
341
|
+
"Manually mark a migration as migrated or not. (Only available with the Content-model storage)",
|
|
342
|
+
)
|
|
248
343
|
.action(
|
|
249
344
|
actionRunner(async (file, options) => {
|
|
250
345
|
const { remove, add } = options;
|
|
251
346
|
const config = await getConfig(parseArgs(options || {}), [
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
347
|
+
"managementToken",
|
|
348
|
+
"spaceId",
|
|
349
|
+
"environmentId",
|
|
350
|
+
"storage",
|
|
351
|
+
"fieldId",
|
|
352
|
+
"migrationContentTypeId",
|
|
353
|
+
"directory",
|
|
259
354
|
]);
|
|
260
355
|
|
|
261
356
|
const { missingStorageModel } = config;
|
|
262
357
|
if (missingStorageModel) {
|
|
263
|
-
console.error(
|
|
358
|
+
console.error(
|
|
359
|
+
pc.red("\nError:"),
|
|
360
|
+
`Missing migration content type. Run ${pc.cyan("npx migrations init")}`,
|
|
361
|
+
);
|
|
264
362
|
process.exit(1);
|
|
265
363
|
}
|
|
266
364
|
|
|
267
365
|
const { storage } = config || {};
|
|
268
366
|
if (storage === STORAGE_TAG) {
|
|
269
|
-
throw new Error(
|
|
367
|
+
throw new Error(
|
|
368
|
+
'The version command is not available for the "tag" storage',
|
|
369
|
+
);
|
|
270
370
|
}
|
|
271
371
|
if (remove) {
|
|
272
372
|
await versionDelete(file, config);
|
|
273
373
|
} else if (add) {
|
|
274
374
|
await versionAdd(file, config);
|
|
275
375
|
}
|
|
276
|
-
}, true)
|
|
376
|
+
}, true),
|
|
277
377
|
);
|
|
278
378
|
|
|
279
379
|
program
|
|
280
|
-
.command(
|
|
281
|
-
.option(
|
|
282
|
-
.option(
|
|
283
|
-
.option(
|
|
284
|
-
.option(
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
.option(
|
|
289
|
-
.option(
|
|
290
|
-
.
|
|
380
|
+
.command("environment <environment-id>")
|
|
381
|
+
.option("-s, --space-id <space-id>", "Contentful space id")
|
|
382
|
+
.option("-v, --verbose", "Verbosity")
|
|
383
|
+
.option("--host <host>", "Management API host")
|
|
384
|
+
.option(
|
|
385
|
+
"--config <path/to/config>",
|
|
386
|
+
"Config file path (disables auto detect)",
|
|
387
|
+
)
|
|
388
|
+
.option("--create", "Create new contentful environment")
|
|
389
|
+
.option("--remove", "Delete contentful environment")
|
|
390
|
+
.option("--reset", "Reset contentful environment")
|
|
391
|
+
.option(
|
|
392
|
+
"--source-environment-id <environment-id>",
|
|
393
|
+
"Set the source environment to clone new environment from",
|
|
394
|
+
)
|
|
395
|
+
.option("--cwd <directory>", "Working directory. Defaults to process.cwd()")
|
|
396
|
+
.description("Add or remove a contentful environment for migrations")
|
|
291
397
|
.action(
|
|
292
398
|
actionRunner(async (environmentId, options) => {
|
|
293
399
|
const { remove, create, reset } = options;
|
|
294
|
-
const config = await getConfig(parseArgs({ ...
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
400
|
+
const config = await getConfig(parseArgs({ ...options, environmentId }), [
|
|
401
|
+
"managementToken",
|
|
402
|
+
"spaceId",
|
|
403
|
+
"environmentId",
|
|
298
404
|
]);
|
|
299
405
|
|
|
300
406
|
if (create) {
|
|
@@ -308,54 +414,91 @@ program
|
|
|
308
414
|
if (reset) {
|
|
309
415
|
return resetEnvironment(environmentId, config);
|
|
310
416
|
}
|
|
311
|
-
}, true)
|
|
417
|
+
}, true),
|
|
312
418
|
);
|
|
313
419
|
|
|
314
420
|
program
|
|
315
|
-
.command(
|
|
316
|
-
.option(
|
|
317
|
-
.option(
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
.option(
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
.
|
|
421
|
+
.command("doc")
|
|
422
|
+
.option("-s, --space-id <space-id>", "Contentful space id")
|
|
423
|
+
.option(
|
|
424
|
+
"-e, --environment-id <environment-id>",
|
|
425
|
+
"Change the Contentful environment",
|
|
426
|
+
)
|
|
427
|
+
.option(
|
|
428
|
+
"-p, --path <path/to/docs>",
|
|
429
|
+
"Change the path where the docs are stored",
|
|
430
|
+
)
|
|
431
|
+
.option("-v, --verbose", "Verbosity")
|
|
432
|
+
.option("-t, --template <path/to/template>", "Use custom template for docs")
|
|
433
|
+
.option("--host <host>", "Management API host")
|
|
434
|
+
.option(
|
|
435
|
+
"--config <path/to/config>",
|
|
436
|
+
"Config file path (disables auto detect)",
|
|
437
|
+
)
|
|
438
|
+
.option(
|
|
439
|
+
"--extension <file-extension>",
|
|
440
|
+
"Use custom file extension (default is `md`)",
|
|
441
|
+
)
|
|
442
|
+
.option("--cwd <directory>", "Working directory. Defaults to process.cwd()")
|
|
443
|
+
.description("Generate offline docs from content-types")
|
|
326
444
|
.action(
|
|
327
445
|
actionRunner(async (cmd) => {
|
|
328
|
-
const config = await getConfig(parseArgs(cmd || {}), [
|
|
446
|
+
const config = await getConfig(parseArgs(cmd || {}), [
|
|
447
|
+
"managementToken",
|
|
448
|
+
"spaceId",
|
|
449
|
+
"environmentId",
|
|
450
|
+
]);
|
|
329
451
|
await createOfflineDocs(config);
|
|
330
|
-
}, true)
|
|
452
|
+
}, true),
|
|
331
453
|
);
|
|
332
454
|
|
|
333
455
|
program
|
|
334
|
-
.command(
|
|
335
|
-
.requiredOption(
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
.
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
.option(
|
|
344
|
-
.option(
|
|
345
|
-
.
|
|
346
|
-
.option(
|
|
456
|
+
.command("content")
|
|
457
|
+
.requiredOption(
|
|
458
|
+
"--source-environment-id <environment-id>",
|
|
459
|
+
"Set the Contentful source environment (from)",
|
|
460
|
+
)
|
|
461
|
+
.requiredOption(
|
|
462
|
+
"--dest-environment-id <environment-id>",
|
|
463
|
+
"Set the Contentful destination environment (to)",
|
|
464
|
+
)
|
|
465
|
+
.option("-s, --space-id <space-id>", "Contentful space id")
|
|
466
|
+
.option("-c, --content-type <content-type>", "Specify content-type")
|
|
467
|
+
.option("-v, --verbose", "Verbosity")
|
|
468
|
+
.option(
|
|
469
|
+
"-y, --yes",
|
|
470
|
+
'Assume "yes" as answer to all prompts and run non-interactively.',
|
|
471
|
+
)
|
|
472
|
+
.option("--host <host>", "Management API host")
|
|
473
|
+
.option(
|
|
474
|
+
"--config <path/to/config>",
|
|
475
|
+
"Config file path (disables auto detect)",
|
|
476
|
+
)
|
|
477
|
+
.option("--diff", "Manually choose skip/overwrite for every conflict")
|
|
478
|
+
.option(
|
|
479
|
+
"--force",
|
|
480
|
+
"No manual diffing. Overwrites all conflicting entries/assets",
|
|
481
|
+
)
|
|
482
|
+
.description(
|
|
483
|
+
"Transfer content from source environment to destination environment",
|
|
484
|
+
)
|
|
485
|
+
.option("--cwd <directory>", "Working directory. Defaults to process.cwd()")
|
|
347
486
|
.action(
|
|
348
487
|
actionRunner(async (cmd) => {
|
|
349
|
-
const config = await getConfig(parseArgs(cmd || {}), [
|
|
488
|
+
const config = await getConfig(parseArgs(cmd || {}), [
|
|
489
|
+
"managementToken",
|
|
490
|
+
"spaceId",
|
|
491
|
+
"storage",
|
|
492
|
+
]);
|
|
350
493
|
|
|
351
494
|
// run migrations on destination environment
|
|
352
495
|
await transferContent({
|
|
353
496
|
...config,
|
|
354
|
-
contentType: cmd.contentType ||
|
|
497
|
+
contentType: cmd.contentType || "",
|
|
355
498
|
forceOverwrite: cmd.force || false,
|
|
356
499
|
diffConflicts: cmd.diff || false,
|
|
357
500
|
});
|
|
358
|
-
})
|
|
501
|
+
}),
|
|
359
502
|
);
|
|
360
503
|
|
|
361
504
|
program.parse(process.argv);
|