npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@contentful/app-scripts

v1.19.0

Published

A collection of scripts for building Contentful Apps

Downloads

54,870

Readme

@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;
}

:warning: 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.

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