Skip to content

Commit

Permalink
Version 1.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
kerrishotts committed Jul 13, 2020
1 parent 11e9f02 commit ecfff62
Show file tree
Hide file tree
Showing 16 changed files with 117 additions and 62 deletions.
27 changes: 7 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ UXP CLI is a standard tooling for Adobe UXP plugin development. Its a full syste

- Yarn version >= 1.5
- Node version >= 10.16
- Git

Devtools helper uses N-api v4. Node-version and n-api compatible matrix is available [here](https://nodejs.org/api/n-api.html#n_api_n_api_version_matrix)

Expand All @@ -44,12 +45,14 @@ You can run this command on terminal to add yarn global bin path.
You can add yarn global bin path to system variables by following the steps given [here](https://docs.microsoft.com/en-us/previous-versions/office/developer/sharepoint-2010/ee537574(v%3Doffice.14)).


### Installation
### Installation through npm (Work in progress)

Navigate to the root of this project and type:
npm install @adobe/uxp-devtools-cli

yarn install

or

yarn add @adobe/uxp-devtools-cli


### Quick guide for getting started

Expand All @@ -64,22 +67,6 @@ After a successful yarn install, First, start a cli service ( Make sure Applicat

```$ uxp service start```

> **IMPORTANT**
>
> For macOS, there is a bug where `uxp service start` won't work if devtools hasn't been enabled before. If you can a permissions error about a path, use the following steps to work around it manually.
>
> * Navigate to `/Library/Application Support/Adobe/UXP/Developer`
> * Create a new file called `settings.json` (this will require `sudo`). I use `vi`, but any editor will do.
>
> Inside this file, put:
>
> ```
> {
> "developer": true
> }
> ```
In another terminal instance - run plugin commands for to load plugin

```$ uxp plugin load```
Expand Down
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,5 @@
"eslint-config-airbnb-base": "^14.0.0",
"eslint-plugin-import": "^2.20.1",
"jest": "^26.0.1"
},
"dependencies": {
"fancy-log": "^1.3.3"
}
}
2 changes: 1 addition & 1 deletion packages/uxp-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@adobe/uxp",
"version": "1.1.0",
"version": "1.1.1",
"description": "Command line interface for rapid UXP plugin development",
"main": "index.js",
"scripts": {
Expand Down
10 changes: 9 additions & 1 deletion packages/uxp-cli/src/cli/commands/plugin/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,28 @@ const loadOptions = {
describe: "Space delimited list of app IDs into which the plugin should be loaded. The supported app IDs can be retrieved using `uxp apps list`. The default action is to load the plugin into all currently running apps specified in the plugin's manifest.",
demandOption: false,
},
breakOnStart: {
describe: "Blocks the plugin until a debugger attaches. If specified, attach is assumed, and a debugger will immediately be spawned. Defaults to false.",
demandOption: false,
}
};

function handlePluginLoadCommand(args) {
const manifestRelPath = args.manifest ? args.manifest : "manifest.json";
const manifest = path.resolve(manifestRelPath);
const apps = args.apps ? args.apps.split(" ") : [];
const breakOnStart = (args.breakOnStart === "true") ? true : false;
const params = {
manifest,
apps,
breakOnStart,
};

const prom = this.uxp.pluginMgr.loadPlugin(params);
return prom.then((res) => {
this.log('Plugin Loaded Successfully.');
if (!breakOnStart) {
this.log('Plugin Loaded Successfully.');
}
return res;
});
}
Expand Down
4 changes: 3 additions & 1 deletion packages/uxp-cli/src/cli/commands/plugin/reload.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
function handlePluginReloadCommand() {
const prom = this.uxp.pluginMgr.reloadPlugin();
return prom.then((res) => {
console.log("Plugin Reload successfull.");
if (res && !res.breakOnStart) {
console.log("Plugin Reload successfull.");
}
return res;
});
}
Expand Down
4 changes: 2 additions & 2 deletions packages/uxp-cli/src/core/client/PluginMgr.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class PluginMgr {
}

debugPlugin(params) {
const pluginLoadCommand = new PluginDebugCommand(this, params);
return pluginLoadCommand.execute();
const pluginDebugCommand = new PluginDebugCommand(this, params);
return pluginDebugCommand.execute();
}

reloadPlugin() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class CliClientController {
const url = `ws://localhost:${port}/socket/cli`;
this._callerPromise = createDeferredPromise();
this._connection.connect(this, url);
this._isConnected = true;
return this._callerPromise.promise;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function validateManifest(manifestPath) {
return report.manifest;
}

function createLoadMessage(pluginFolder) {
function createLoadMessage(pluginFolder, breakOnStart) {
const msg = {
command: "Plugin",
action: "load",
Expand All @@ -38,6 +38,7 @@ function createLoadMessage(pluginFolder) {
path: pluginFolder,
},
},
breakOnStart,
};
return msg;
}
Expand Down Expand Up @@ -76,7 +77,7 @@ class PluginLoadCommand extends PluginBaseCommand {
throw new Error("Load command didn't find any of the currently running apps applicable for loading this plugin. Make sure your target application is running and try again.");
}
const pluginFolder = path.dirname(this.params.manifest);
const loadJsonMsg = createLoadMessage(pluginFolder);
const loadJsonMsg = createLoadMessage(pluginFolder, this.params.breakOnStart);
console.log(`Sending "Load Plugin" command to apps ${JSON.stringify(applicableAppsForLoading)}`);
const loadReqProm = this.sendMessageToAppsWithReply(applicableAppsForLoading, loadJsonMsg);
return loadReqProm.then((results) => {
Expand All @@ -98,8 +99,7 @@ class PluginLoadCommand extends PluginBaseCommand {
}
throw new Error("Plugin Load command failed. Failed to load in any of the connected apps");
}
this._handlePluginLoadSuccess(successfulLoads);
return true;
return this._handlePluginLoadSuccess(successfulLoads);
});
}

Expand All @@ -108,6 +108,14 @@ class PluginLoadCommand extends PluginBaseCommand {
// to a uxprc file so as to persist the state for later commands ( like plugin debug/log et al)
this.pm._createPluginSession(pluginLoadResults);
this.pm._saveCurrentPluginSession();
if (this.params.breakOnStart) {
console.log('The loading of the plugin is blocked. Waiting for a debugger to be launched.');
return this.pm.debugPlugin(this.params).then((res) => {
console.log("Launched standalone Chrome Developer Tools window.");
return res;
});
}
return true;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,26 @@ class PluginReloadCommand extends PluginBaseCommand {
}

executeCommand() {
return this.runCommandOnAllApplicableApps(createReloadMessage);
const resultsCallback = this._handlePluginReloadResult.bind(this);
return this.runCommandOnAllApplicableApps(createReloadMessage, resultsCallback);
}

breakOnStartEnabled(result) {
const { data } = result;
return data && data.breakOnStart;
}

_handlePluginReloadResult(results) {
if (results.length > 0) {
if (this.breakOnStartEnabled(results[0])) {
console.log('The loading of the plugin is blocked. Waiting for a debugger to be launched.');
return this.pm.debugPlugin(this.params).then((res) => {
console.log("Launched standalone Chrome Developer Tools window.");
return { "breakOnStart" : true, res };
});
}
}
return true;
}
}

Expand Down
4 changes: 3 additions & 1 deletion packages/uxp-cli/src/uxp.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ class UxpDevTools {

setMode(mode) {
const isServer = mode === "service";
this._devToolsMgr = new DevToolsMgr(isServer);
if (!this._devToolsMgr) {
this._devToolsMgr = new DevToolsMgr(isServer);
}
}

get devToolsMgr() {
Expand Down
6 changes: 4 additions & 2 deletions packages/uxp-devtools-helper/src/DevToolsHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,10 @@ class DevToolsHelper {
}

terminate() {
this._devToolsNative.terminate();
this._devToolsNative = null;
if (this._devToolsNative) {
this._devToolsNative.terminate();
this._devToolsNative = null;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/uxp-inspect-app/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@adobe/uxp-inspect-app",
"productName": "Adobe UXP Inspect",
"version": "1.0.7",
"version": "1.0.8",
"description": "Inspect app for debugging uxp plugins.",
"main": "src/main.js",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
"modules" : [
{ "name": "inspector_main", "type": "autostart" },
{ "name": "mobile_throttling"},

{ "name": "browser_debugger" },
{ "name": "elements" }
{ "name": "cookie_table" },
{ "name": "elements" },
{ "name": "har_importer" },
{ "name": "network" }
],
"extends": "shell",
"has_html": true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
{ "name": "diff" },
{ "name": "event_listeners" },
{ "name": "formatter" },
{ "name": "heap_snapshot_model" },
{ "name": "inline_editor" },
{ "name": "javascript_metadata" },
{ "name": "object_ui" },
{ "name": "perf_ui" },
{ "name": "quick_open" },
{ "name": "search" },
{ "name": "snippets" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ function showLayerNames() {

document.getElementById("btnPopulate").addEventListener("click", showLayerNames);

function flyoutMenuShowAlert() {
const psCore = require('photoshop').core
psCore.showAlert({ message: 'Hi!' })
function flyoutMenuShowAlert(commandId) {
const psCore = require('photoshop').core;
psCore.showAlert({ message: 'Hi!'+commandId });
}

window['flyoutMenuShowAlert'] = flyoutMenuShowAlert
// Hook up a listener for uxpcommands (entrypoints)
document.addEventListener("uxpcommand", (ev) => flyoutMenuShowAlert(ev.commandId));
Original file line number Diff line number Diff line change
@@ -1,28 +1,52 @@
{

"id": "com.adobe.ps.starter",
"name": "Adobe Photoshop UXP plugin starter template",
"version": "1.0.0",
"main": "index.html",
"host": [
{
"app": "PS",
"minVersion": "21.0.0"
}],
"uiEntrypoints": [
"manifestVersion": 4,
"entrypoints": [
{
"type": "panel",
"panelId": "vanilla",
"panelInfo": {
"title": {"default": "Vanilla"},
"minimumSize": {"width": 230, "height": 200},
"maximumSize": {"width": 2000, "height": 2000},
"preferredDockedSize": {"width": 230, "height": 300},
"preferredFloatingSize": {"width": 230, "height": 300},
"flyoutMenu" : [
{"title": {"default": "Show Alert"}, "command": "flyoutMenuShowAlert"}
]
}
"id": "vanilla",
"label": {
"default": "My Network panel",
"en-US": "My Network panel",
"es-ES": "My Network panel"
},
"minimumSize": {
"width": 120,
"height": 140
},
"maximumSize": {
"width": 1200,
"height": 10000
},
"preferredDockedSize": {
"width": 150,
"height": 200
},
"preferredFloatingSize": {
"width": 300,
"height": 200
},
"commands": [
{
"id": "show_alert",
"label": {
"default": "Show Alert",
"en-US": "Show Alert (US)",
"es-ES": "Show Alert (ES)"
}
}
]
}
],
"runOnStartup": true
}
"host": [
{
"app": "PS",
"minVersion": "21.0.0",
"maxVersion": "31.1.1"
}
]
}

0 comments on commit ecfff62

Please sign in to comment.