@contentful/app-scripts
TypeScript icon, indicating that this package has built-in type declarations

1.30.0 • Public • Published

@contentful/app-scripts

This project makes it easier to perform some recurrent operations in Contentful's App Framework.

📥 Installation

Locally:

npm i @contentful/app-scripts

Globally:

npm i -g @contentful/app-scripts

⚙️ Usage

💻 CLI

When installed

$ contentful-app-scripts create-app-definition

Otherwise

$ npx @contentful/app-scripts create-app-definition

👩‍💻 Programmatic

const { createAppDefinition } = require('@contentful/app-scripts');
const { myCustomLogic } = require('./my-custom-logic')(async function main() {
  myCustomLogic();

  await createAppDefinition.interactive();
})();

📜 API

Scripts exported from this module will all be in the following shape

interface Script<Result, Options> {
  // query the user or local cache for required information
  interactive: () => Result;
  // run by automation (`--ci` flag), they would need all the information upfront
  nonInteractive: (...options: Options) => Result;
}

⚠️ Please note

Both interactive and nonInteractive version of the same script is meant to return the same result.

Create App Definition

Allows creating a new AppDefinition provided a Content Management Token (more details here).

It only runs in interactive mode.

Example

$ npx --no-install @contentful/app-scripts create-app-definition

Upload a bundle to an App Definition

Allows you to upload a build directory and create a new AppBundle that is bound to an AppDefinition. It runs in interactive or non-interactive mode.

Note: The command will automatically activate the bundle. To skip the activation you can pass the --skip-activation argument in interactive and non-interactive mode and then manually activate it.

Interactive mode:

In the interactive mode, the CLI will ask for all required options.

Example

$ npx --no-install @contentful/app-scripts upload

Non-interactive mode:

When passing the --ci argument the command will fail when the required variables are not set as arguments.

Example

$ npx --no-install @contentful/app-scripts upload --ci \
    --bundle-dir ./built \
    --organization-id some-org-id \
    --definition-id some-app-def-id \
    --token $MY_CONTENTFUL_PAT

Options:

Argument Description Default value
--bundle-dir The directory of your build folder (e.g.: ./build)
--organization-id The ID of your organization
--definition-id The ID of the app to which to add the bundle
--token A personal access token
--skip-activation (optional) Boolean flag to skip the automatic activation of the AppBundle false
--comment (optional) A comment which will be associated with the created AppBundle. Can be used to differentiate bundles.
--host (optional) Contentful CMA-endpoint to use api.contentful.com

Note: You can also pass all arguments in interactive mode to skip being asked for it.

Activate an AppBundle

Allows you to activate an AppBundle for an AppDefinition. When activated the app will serve the newly activated AppBundle.

Interactive mode:

In the interactive mode, the CLI will ask for all required options.

Example

$ npx --no-install @contentful/app-scripts activate

Non-interactive mode:

When passing the --ci argument adding all variables as arguments is required.

Example

$ npx --no-install @contentful/app-scripts activate --ci \
    --bundle-id some-bundle-id \
    --organization-id some-org-id \
    --definition-id some-app-def-id \
    --token $MY_CONTENTFUL_PAT

Options:

Argument Description Default value
--bundle-id The ID of the AppBundle you want to activate
--organization-id The ID of your organization
--definition-id The ID of the app to which to add the bundle
--token A personal access token
--host (optional) Contentful CMA-endpoint to use api.contentful.com

Note: You can also pass all arguments in interactive mode to skip being asked for it.

Open Settings of an AppDefinition

It opens the settings in the contentful web app so that you can use the UI to change the settings of an AppDefinition.

Example

$ npx --no-install @contentful/app-scripts open-settings --definition-id some-definition-id

You can also execute this command without the argument if the environment variable (CONTENTFUL_APP_DEF_ID) has been set.

Example

$ CONTENTFUL_APP_DEF_ID=some-definition-id npx --no-install @contentful/app-scripts open-settings

Clean up bundles

Allows you to clean the list of previous bundles. It fetches the list and deletes all bundles except the 50 newest ones. You can adjust the amount you want to keep by passing --keep <amount> to the argument, if not passed, the default is 50.

Interactive mode:

In the interactive mode, the CLI will ask for all required options.

Example

$ npx --no-install @contentful/app-scripts bundle-cleanup

You can also execute this command without the argument if the environment variable (CONTENTFUL_APP_DEF_ID) and (CONTENTFUL_ORG_ID) has been set.

Non-interactive mode:

When passing the --ci argument adding all variables as arguments is required

Example

$ npx --no-install @contentful/app-scripts bundle-cleanup --ci \
    --organization-id some-org-id \
    --definition-id some-app-def-id \
    --token $MY_CONTENTFUL_PAT
    --keep 30

Options:

Argument Description Default value
--organization-id The ID of your organization
--definition-id The ID of the app to which to add the bundle
--token A personal access token
--keep (optional) The amount of bundles to keep 50
--host (optional) Contentful CMA-endpoint to use api.contentful.com

Note: You can also pass all arguments in interactive mode to skip being asked for it.

Install the AppDefinition into a specific space / environment

It opens a dialog to select the space and environment where the app associated with the given AppDefinition should be installed.

Example

$ npx --no-install @contentful/app-scripts install --definition-id some-definition-id

You can also execute this command without the argument if the environment variable (CONTENTFUL_APP_DEF_ID) has been set.

Example

$ CONTENTFUL_APP_DEF_ID=some-definition-id npx --no-install @contentful/app-scripts install

By default, the script will install the app into the default host URL: app.contentful.com. If you want to install the app into a different host URL, you can set the argument --host to the desired host URL.

Example

$ npx --no-install @contentful/app-scripts install --definition-id some-definition-id --host api.eu.contentful.com

Tracking

We gather depersonalized usage data of our CLI tools in order to improve experience. If you do not want your data to be gathered, you can opt out by providing an env variable DISABLE_ANALYTICS set to any value:

Example

DISABLE_ANALYTICS=true npx create-contentful-app

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.16.0-alpha.30canary
1.30.0185latest

Version History

VersionDownloads (Last 7 Days)Published
1.30.0185
1.29.01,589
1.28.05
1.27.01,316
1.26.024
1.25.0303
1.24.023
1.23.0101
1.22.010
1.21.015
1.20.115
1.20.028
1.19.11,031
1.19.0315
1.18.047
1.17.0246
1.15.0202
1.14.0104
1.13.4209
1.13.216
1.13.1634
1.13.0301
1.12.05
1.11.05
1.10.21,298
1.10.15
1.10.05
1.9.036
1.8.25
1.8.151
1.7.13318
1.7.120
1.7.110
1.7.100
1.7.91
1.7.80
1.7.74
1.7.6177
1.7.526
1.7.40
1.7.30
1.7.29
1.7.10
1.7.00
1.6.018
1.5.60
1.5.51
1.5.42
1.5.31
1.5.21
1.5.10
1.5.00
1.4.20
1.2.714
1.2.61
1.2.50
1.2.40
1.2.30
1.2.20
1.2.13
1.2.013
1.1.380
1.1.371
1.1.360
1.1.350
1.1.342
1.1.332
1.1.320
1.1.3134
1.1.300
1.1.290
1.1.285
1.1.273
1.1.260
1.1.250
1.1.240
1.1.236
1.1.220
1.1.210
1.1.200
1.1.190
1.1.182
1.1.179
1.1.161
1.1.154
1.1.140
1.1.130
1.1.120
1.1.11221
1.1.100
1.1.90
1.1.80
1.1.70
1.1.60
1.1.50
1.1.40
1.1.30
1.1.234
1.1.11
1.1.00
1.0.20
1.0.10
1.0.00
0.16.0-alpha.30
0.15.8307
0.16.0-alpha.20
0.15.70
0.15.60
0.15.50
0.15.40
0.15.33
0.15.20
0.16.0-alpha.10
0.15.10
0.16.0-alpha.00
0.15.00
0.14.13611
0.14.1350
0.14.1340
0.14.1330
0.14.1320
0.14.1310
0.14.1300
0.14.1290
0.14.1280
0.14.1270
0.14.1260
0.14.1250
0.14.1240
0.14.1230
0.14.1220
0.14.1210
0.14.1200
0.14.1190
0.14.1180
0.14.1170
0.14.1160
0.14.1150
0.14.1140
0.14.1130
0.14.1120
0.14.1110
0.14.1100
0.14.1090
0.14.1080
0.14.1070
0.14.1060
0.14.1050
0.14.1040
0.14.1030
0.14.1020
0.14.1010
0.14.1000
0.14.990
0.14.980
0.14.970
0.14.960
0.14.950
0.14.940
0.14.930
0.14.920
0.14.910
0.14.900
0.14.890
0.14.880
0.14.870
0.14.860
0.14.850
0.14.840
0.14.830
0.14.820
0.14.810
0.14.800
0.14.790
0.14.780
0.14.770
0.14.760
0.14.750
0.14.740
0.14.730
0.14.720
0.14.710
0.14.700
0.14.690
0.14.680
0.14.670
0.14.660
0.14.650
0.14.640
0.14.630
0.14.620
0.14.610
0.14.605
0.14.590
0.14.580
0.14.570
0.14.560
0.14.550
0.14.540
0.14.530
0.14.520
0.14.510
0.14.500
0.14.490
0.14.480
0.14.470
0.14.460
0.14.450
0.14.440
0.14.430
0.14.420
0.14.410
0.14.400
0.14.390
0.14.380
0.14.370
0.14.360
0.14.350
0.14.340
0.14.330
0.14.320
0.14.310
0.14.300
0.14.290
0.14.280
0.14.270
0.14.260
0.14.250
0.14.240
0.14.230
0.14.220
0.14.210
0.14.200
0.14.190
0.14.180
0.14.170
0.14.160
0.14.150
0.14.140
0.14.13184
0.14.120
0.14.110
0.14.100
0.14.90
0.14.80
0.14.70
0.14.60
0.14.50
0.14.40
0.14.30
0.14.20
0.14.10
0.14.00
0.13.4331
0.13.420
0.13.410
0.13.400
0.13.390
0.13.380
0.13.370
0.13.360
0.13.350
0.13.340
0.13.330
0.13.320
0.13.310
0.13.301
0.13.290
0.13.281
0.13.270
0.13.260
0.13.250
0.13.240
0.13.233
0.13.220
0.13.210
0.13.2080
0.13.190
0.13.180
0.13.170
0.13.160
0.13.150
0.13.140
0.13.130
0.13.120
0.13.110
0.13.100
0.13.90
0.13.80
0.13.70
0.13.60
0.13.50
0.13.40
0.13.30
0.13.20
0.13.10
0.13.00
0.12.67194
0.12.660
0.12.650
0.12.640
0.12.630
0.12.620
0.12.610
0.12.600
0.12.590
0.12.580
0.12.570
0.12.560
0.12.550
0.12.540
0.12.530
0.12.520
0.12.510
0.12.500
0.12.490
0.12.480
0.12.470
0.12.460
0.12.450
0.12.440
0.12.430
0.12.420
0.12.410
0.12.400
0.12.390
0.12.380
0.12.370
0.12.360
0.12.350
0.12.340
0.12.330
0.12.320
0.12.310
0.12.300
0.12.290
0.12.280
0.12.270
0.12.260
0.12.250
0.12.240
0.12.230
0.12.220
0.12.210
0.12.200
0.12.190
0.12.186
0.12.170
0.12.160
0.12.150
0.12.140
0.12.130
0.12.120
0.12.110
0.12.100
0.12.90
0.12.80
0.12.70
0.12.60
0.12.50
0.12.40
0.12.30
0.12.20
0.12.10
0.12.00
0.11.250
0.11.240
0.11.230
0.11.220
0.11.210
0.11.200
0.11.190
0.11.180
0.11.170
0.11.160
0.11.150
0.11.140
0.11.130
0.11.120
0.11.110
0.11.100
0.11.90
0.11.80
0.11.70
0.11.60
0.11.50
0.11.40
0.11.30
0.11.20
0.11.10
0.11.00
0.10.220
0.10.210
0.10.200
0.10.190
0.10.180
0.10.170
0.10.160
0.10.150
0.10.140
0.10.130
0.10.120
0.10.110
0.10.100
0.10.90
0.10.80
0.10.70
0.10.60
0.10.50
0.10.40
0.10.30
0.10.20
0.10.10
0.10.00
0.9.29299
0.9.280
0.9.270
0.9.260
0.9.250
0.9.240
0.9.230
0.9.221
0.9.210
0.9.200
0.9.190
0.9.17-alpha.160
0.9.180
0.9.170
0.9.17-alpha.150
0.8.9-alpha.161
0.9.160
0.8.9-alpha.150
0.9.150
0.9.140
0.9.130
0.9.120
0.9.100
0.9.90
0.9.80
0.9.70
0.9.60
0.9.50
0.9.40
0.9.30
0.9.20
0.9.10
0.9.00
0.8.497
0.8.480
0.8.470
0.8.460
0.8.450
0.8.440
0.8.430
0.8.420
0.8.410
0.8.400
0.8.390
0.8.380
0.8.371
0.8.360
0.8.351
0.8.340
0.8.330
0.8.320
0.8.310
0.8.300
0.8.290
0.8.280
0.8.270
0.8.260
0.8.250
0.8.240
0.8.230
0.8.9-alpha.130
0.8.220
0.8.210
0.8.200
0.8.190
0.8.180
0.8.171
0.8.160
0.8.150
0.8.9-alpha.120
0.8.140
0.8.9-alpha.110
0.8.130
0.8.120
0.8.110
0.8.100
0.8.90
0.8.80
0.8.70
0.8.60
0.8.50
0.8.40
0.8.30
0.8.20
0.8.00
0.7.41
0.6.1-alpha.91
0.7.00
0.6.10
0.6.00
0.5.10
0.5.00
0.4.60
0.4.30

Package Sidebar

Install

npm i @contentful/app-scripts

Weekly Downloads

10,182

Version

1.30.0

License

MIT

Unpacked Size

101 kB

Total Files

77

Last publish

Collaborators

  • michaelpearce
  • it-internal
  • whydah-gally
  • contentful-ecosystem