Skip to content

Commit 6dab89d

Browse files
committed
fix: adds host config to migrations call
1 parent 1e56f43 commit 6dab89d

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

cli.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ const program = new Command();
5959
program.version(pkg.version);
6060
program
6161
.command('init')
62+
.option('--host <host>', 'Management API host')
6263
.description('Initialize contentful-migrations')
6364
.action(
6465
actionRunner(async (cmd) => {
@@ -99,8 +100,9 @@ program
99100
.option('-e, --environment-id <environment-id>', 'Change the Contentful environment')
100101
.option('-c, --content-type <content-type...>', 'Specify content-types')
101102
.option('-p, --path <path/to/migrations>', 'Change the path where the migrations are saved')
102-
.option('--config <path/to/config>', 'Config file path (disables auto detect)')
103103
.option('-v, --verbose', 'Verbosity')
104+
.option('--host <host>', 'Management API host')
105+
.option('--config <path/to/config>', 'Config file path (disables auto detect)')
104106
.description('Generate a new Contentful migration from content type')
105107
.action(
106108
actionRunner(async (cmd) => {
@@ -115,8 +117,9 @@ program
115117
.option('-s, --space-id <space-id>', 'Contentful space id')
116118
.option('-e, --environment-id <environment-id>', 'Change the Contentful environment')
117119
.option('-p, --path <path/to/migrations>', 'Change the path where the migrations are saved')
118-
.option('--config <path/to/config>', 'Config file path (disables auto detect)')
119120
.option('-v, --verbose', 'Verbosity')
121+
.option('--host <host>', 'Management API host')
122+
.option('--config <path/to/config>', 'Config file path (disables auto detect)')
120123
.description('Generate a new Contentful migration')
121124
.action(
122125
actionRunner(async (cmd) => {
@@ -131,9 +134,10 @@ program
131134
.option('-s, --space-id <space-id>', 'Contentful space id')
132135
.option('-e, --environment-id <environment-id>', 'Change the Contentful environment')
133136
.option('-p, --path <path/to/migrations>', 'Change the path where the migrations are stored')
134-
.option('--config <path/to/config>', 'Config file path (disables auto detect)')
135137
.option('-v, --verbose', 'Verbosity')
136138
.option('-y, --yes', 'Assume "yes" as answer to all prompts and run non-interactively.')
139+
.option('--host <host>', 'Management API host')
140+
.option('--config <path/to/config>', 'Config file path (disables auto detect)')
137141
.option('--bail', 'Abort execution after first failed migration (default: true)', true)
138142
.option('--no-bail', 'Ignore failed migrations')
139143
.description('Execute all unexecuted migrations available.')
@@ -156,9 +160,10 @@ program
156160
.command('execute <file>')
157161
.option('-s, --space-id <space-id>', 'Contentful space id')
158162
.option('-e, --environment-id <environment-id>', 'Change the Contentful environment')
159-
.option('--config <path/to/config>', 'Config file path (disables auto detect)')
160163
.option('-v, --verbose', 'Verbosity')
161164
.option('-y, --yes', 'Assume "yes" as answer to all prompts and run non-interactively.')
165+
.option('--host <host>', 'Management API host')
166+
.option('--config <path/to/config>', 'Config file path (disables auto detect)')
162167
.description('Execute a single migration.')
163168
.action(
164169
actionRunner(async (file, options) => {
@@ -179,8 +184,9 @@ program
179184
.command('version <file>')
180185
.option('-s, --space-id <space-id>', 'Contentful space id')
181186
.option('-e, --environment-id <environment-id>', 'Change the Contentful environment')
182-
.option('--config <path/to/config>', 'Config file path (disables auto detect)')
183187
.option('-v, --verbose', 'Verbosity')
188+
.option('--host <host>', 'Management API host')
189+
.option('--config <path/to/config>', 'Config file path (disables auto detect)')
184190
.option('--add', 'Mark migration as migrated')
185191
.option('--remove', 'Delete migration entry in Contentful')
186192
.description('Manually mark a migration as migrated or not. (Only available with the Content-model storage)')
@@ -211,8 +217,9 @@ program
211217
program
212218
.command('environment <environment-id>')
213219
.option('-s, --space-id <space-id>', 'Contentful space id')
214-
.option('--config <path/to/config>', 'Config file path (disables auto detect)')
215220
.option('-v, --verbose', 'Verbosity')
221+
.option('--host <host>', 'Management API host')
222+
.option('--config <path/to/config>', 'Config file path (disables auto detect)')
216223
.option('--create', 'Create new contentful environment')
217224
.option('--remove', 'Delete contentful environment')
218225
.option('--reset', 'Reset contentful environment')
@@ -243,9 +250,10 @@ program
243250
.option('-s, --space-id <space-id>', 'Contentful space id')
244251
.option('-e, --environment-id <environment-id>', 'Change the Contentful environment')
245252
.option('-p, --path <path/to/docs>', 'Change the path where the docs are stored')
246-
.option('--config <path/to/config>', 'Config file path (disables auto detect)')
247253
.option('-v, --verbose', 'Verbosity')
248254
.option('-t, --template <path/to/template>', 'Use custom template for docs')
255+
.option('--host <host>', 'Management API host')
256+
.option('--config <path/to/config>', 'Config file path (disables auto detect)')
249257
.option('--extension <file-extension>', 'Use custom file extension (default is `md`)')
250258
.description('Generate offline docs from content-types')
251259
.action(
@@ -262,9 +270,10 @@ program
262270
.requiredOption('--dest-environment-id <environment-id>', 'Set the Contentful destination environment (to)')
263271
.option('-s, --space-id <space-id>', 'Contentful space id')
264272
.option('-c, --content-type <content-type>', 'Specify content-type')
265-
.option('--config <path/to/config>', 'Config file path (disables auto detect)')
266273
.option('-v, --verbose', 'Verbosity')
267274
.option('-y, --yes', 'Assume "yes" as answer to all prompts and run non-interactively.')
275+
.option('--host <host>', 'Management API host')
276+
.option('--config <path/to/config>', 'Config file path (disables auto detect)')
268277
.option('--diff', 'Manually choose skip/overwrite for every conflict')
269278
.option('--force', 'No manual diffing. Overwrites all conflicting entries/assets')
270279
.description('Transfer content from source environment to destination environment')

lib/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const getConfig = async (args) => {
2727
spaceId: process.env.CONTENTFUL_SPACE_ID,
2828
environmentId: process.env.CONTENTFUL_ENVIRONMENT_ID,
2929
accessToken: process.env.CONTENTFUL_MANAGEMENT_TOKEN,
30+
host: process.env.CONTENTFUL_HOST,
3031
};
3132

3233
let contentfulCliOptions = {};

lib/migration.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,10 @@ const executeMigration = async (file, config) => {
153153
yes: true,
154154
};
155155

156+
if (config.host) {
157+
options.host = config.host
158+
}
159+
156160
console.log(`\nRun migration ${pc.green(version)} in environment ${pc.green(environmentId)}`);
157161
const proceed = await confirm(config);
158162
if (!proceed) {

0 commit comments

Comments
 (0)