Create CEP Extensions with no build configuration.


Keywords
react, webpack, adobe, extendscript, cep-extension
License
BSD-3-Clause
Install
npm install create-cep-extension@1.0.0-beta.20

Documentation

Notice: I encourage you to check out parcel-cep-plugin. It's a more maintainable approach to the same problem that has a much smaller codebase than a fork create-react-app ever will. Parcel also has many benefits that should be enticing enough to consider switching.

Create CEP Extension

Create CEP Extensions with no build configuration. Closely matches functionality from Create React App.

  • Getting Started – How to create a new app.
  • User Guide – How to develop apps bootstrapped with Create React App.

Create React App works on macOS, Windows, and Linux.
If something doesn’t work please file an issue.

Quick Overview

npm install -g create-cep-extension

create-cep-extension my-cep-extension
cd my-cep-extension
npm start

Then open http://localhost:3000/ to see your app.
When you’re ready to deploy to production, create a minified bundle with npm run build.

npm start

Get Started Immediately

You don’t need to install or configure tools like Webpack or Babel.
They are preconfigured and hidden so that you can focus on the code.

Just create a project, and you’re good to go.

Getting Started

Installation

Install it once globally:

npm install -g create-cep-extension

You’ll need to have Node >= 4 on your machine.

We strongly recommend to use Node >= 6 and npm >= 3 for faster installation speed and better disk usage. You can use nvm to easily switch Node versions between different projects.

This tool doesn’t assume a Node backend. The Node installation is only required for Create React App itself.

Creating an App

To create a new app, run:

create-cep-extension my-cep-extension
cd my-cep-extension

It will create a directory called my-cep-extension inside the current folder.<cep-extension Inside that directory, it will generate the initial project structure and install the transitive dependencies:

my-cep-extension
  README.md
  node_modules/
  package.json
  .gitignore
  .env
  extendscript/
    index.jsx
  public/
    favicon.ico
    index.html
  src/
    App.css
    App.js
    App.test.js
    index.css
    index.js
    logo.svg

No configuration or complicated folder structures, just the files you need to build your app.
Once the installation is done, you can run some commands inside the project folder:

npm start or yarn start

Runs the app in development mode.
Open http://localhost:3000 to view it in the browser.

The page will reload if you make edits.
You will see the build errors and lint warnings in the console.

Build errors

npm test or yarn test

Runs the test watcher in an interactive mode.
By default, runs tests related to files changes since the last commit.

Read more about testing.

npm run build or yarn build

Builds the app for production to the build folder.
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.
Your app is ready to be deployed!

npm run archive or yarn archive

Creates a ZXP archive of the build folder to the archive folder.

You can then send the ZXP archive to your users to install using a ZXP installer. For instance:

Environment Variables

You can customize the name of the extension and multiple other variables by modifying the .env file.

NAME="My Extension"
BUNDLE_ID="com.mycompany.myextension"

Hosts

By default, the extension will target all known Adobe hosts. To target specific hosts, uncomment the HOSTS variable to .env and modify the list of the hosts you want to target.

For example, to target just Illustrator and After Effects, you would add this to your .env file:

HOSTS="ILST, AEFT"

And to target specific versions:

HOSTS="ILST, IDSN@*, PHXS@6.0, AEFT@[5.0,10.0]"

This will target all versions of Illustrator and In Design, Photoshop 6.0, and After Effects 5.0 - 10.0.

Type

Sets the type of window. Options are ModalDialog, Modeless, Panel is default.

UI_TYPE=ModalDialog

Icon

To add a custom panel icon, add all icon files inside the public folder and set their paths inside your .env file:

ICON_NORMAL="./assets/icon-normal.png"
ICON_ROLLOVER="./assets/icon-rollover.png"
ICON_DARK_NORMAL="./assets/icon-dark.png"
ICON_DARK_ROLLOVER="./assets/icon-dark-rollover.png"

Cerificate Variables

In order to create a valid ZXP, you will need to provide the following variables replaced with the correct information inside your .env.

CERTIFICATE_COUNTRY="US"
CERTIFICATE_PROVINCE="CA"
CERTIFICATE_ORG="MyCompany"
CERTIFICATE_NAME="com.mycompany"
CERTIFICATE_PASSWORD="mypassword"

Communicating with Extendscript

There are few functions that you can import from the cep-interface package to ease Extendscript communication from CEP.

loadExtendscript(extendScriptFileName: string): Promise

Loads and evaluates the specified file in the src/extendscript directory. Returns a promise with the result.

import { loadExtendscript } from 'cep-interface';

loadExtendscript('index.jsx');

evalExtendscript(code: string): Promise

Evaluates the specified code. Returns a Promise.

import { evalExtendscript } from 'cep-interface';

evalExtendscript('$.writeln("Hello Foo");'); // writes "Hello Foo" to the info panel

If you return a JSON string using json2 or similar from Extendscript, you can get the parsed result.

import { evalExtendscript } from 'cep-interface';

evalExtendscript('JSON.stringifiy({foo: "bar"});')
  .then(result => console.log(result)) // prints {foo: "bar"}
  .catch(error => console.warn(error));

Other functions

There are a few other functions available in addition.

openURLInDefaultBrowser(url: string)

import { openURLInDefaultBrowser } from 'cep-interface';

openURLInDefaultBrowser('www.google.com');

Opens the url in the default browser. Will also work when viewing outside the target application in a browser.

Contributing

We'd love to have your helping hand on create-cep-extension! See CONTRIBUTING.md for more information on what we're looking for and how to get started.

Todo

  • Improve target host configuration per #4.
  • Create .jsxbin's automatically and smoothly. Adobe has made this nearly impossible to do on macOS, so not sure if its worth the trouble. Especially since .jsxbin doesn't really deter hackers.
  • Testing.