Skip to content

Commit ecfff62

Browse files
committed
Version 1.1.1
1 parent 11e9f02 commit ecfff62

File tree

16 files changed

+117
-62
lines changed

16 files changed

+117
-62
lines changed

README.md

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ UXP CLI is a standard tooling for Adobe UXP plugin development. Its a full syste
2222

2323
- Yarn version >= 1.5
2424
- Node version >= 10.16
25+
- Git
2526

2627
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)
2728

@@ -44,12 +45,14 @@ You can run this command on terminal to add yarn global bin path.
4445
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)).
4546

4647

47-
### Installation
48+
### Installation through npm (Work in progress)
4849

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

51-
yarn install
52-
52+
or
53+
54+
yarn add @adobe/uxp-devtools-cli
55+
5356

5457
### Quick guide for getting started
5558

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

6568
```$ uxp service start```
6669

67-
> **IMPORTANT**
68-
>
69-
> 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.
70-
>
71-
> * Navigate to `/Library/Application Support/Adobe/UXP/Developer`
72-
> * Create a new file called `settings.json` (this will require `sudo`). I use `vi`, but any editor will do.
73-
>
74-
> Inside this file, put:
75-
>
76-
> ```
77-
> {
78-
> "developer": true
79-
> }
80-
> ```
81-
82-
8370
In another terminal instance - run plugin commands for to load plugin
8471

8572
```$ uxp plugin load```

package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,5 @@
2929
"eslint-config-airbnb-base": "^14.0.0",
3030
"eslint-plugin-import": "^2.20.1",
3131
"jest": "^26.0.1"
32-
},
33-
"dependencies": {
34-
"fancy-log": "^1.3.3"
3532
}
3633
}

packages/uxp-cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@adobe/uxp",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"description": "Command line interface for rapid UXP plugin development",
55
"main": "index.js",
66
"scripts": {

packages/uxp-cli/src/cli/commands/plugin/load.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,28 @@ const loadOptions = {
2222
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.",
2323
demandOption: false,
2424
},
25+
breakOnStart: {
26+
describe: "Blocks the plugin until a debugger attaches. If specified, attach is assumed, and a debugger will immediately be spawned. Defaults to false.",
27+
demandOption: false,
28+
}
2529
};
2630

2731
function handlePluginLoadCommand(args) {
2832
const manifestRelPath = args.manifest ? args.manifest : "manifest.json";
2933
const manifest = path.resolve(manifestRelPath);
3034
const apps = args.apps ? args.apps.split(" ") : [];
35+
const breakOnStart = (args.breakOnStart === "true") ? true : false;
3136
const params = {
3237
manifest,
3338
apps,
39+
breakOnStart,
3440
};
3541

3642
const prom = this.uxp.pluginMgr.loadPlugin(params);
3743
return prom.then((res) => {
38-
this.log('Plugin Loaded Successfully.');
44+
if (!breakOnStart) {
45+
this.log('Plugin Loaded Successfully.');
46+
}
3947
return res;
4048
});
4149
}

packages/uxp-cli/src/cli/commands/plugin/reload.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
function handlePluginReloadCommand() {
2828
const prom = this.uxp.pluginMgr.reloadPlugin();
2929
return prom.then((res) => {
30-
console.log("Plugin Reload successfull.");
30+
if (res && !res.breakOnStart) {
31+
console.log("Plugin Reload successfull.");
32+
}
3133
return res;
3234
});
3335
}

packages/uxp-cli/src/core/client/PluginMgr.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ class PluginMgr {
3838
}
3939

4040
debugPlugin(params) {
41-
const pluginLoadCommand = new PluginDebugCommand(this, params);
42-
return pluginLoadCommand.execute();
41+
const pluginDebugCommand = new PluginDebugCommand(this, params);
42+
return pluginDebugCommand.execute();
4343
}
4444

4545
reloadPlugin() {

packages/uxp-cli/src/core/client/connection/CliClientController.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ class CliClientController {
9393
const url = `ws://localhost:${port}/socket/cli`;
9494
this._callerPromise = createDeferredPromise();
9595
this._connection.connect(this, url);
96+
this._isConnected = true;
9697
return this._callerPromise.promise;
9798
}
9899

packages/uxp-cli/src/core/client/plugin/actions/PluginLoadCommand.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function validateManifest(manifestPath) {
2828
return report.manifest;
2929
}
3030

31-
function createLoadMessage(pluginFolder) {
31+
function createLoadMessage(pluginFolder, breakOnStart) {
3232
const msg = {
3333
command: "Plugin",
3434
action: "load",
@@ -38,6 +38,7 @@ function createLoadMessage(pluginFolder) {
3838
path: pluginFolder,
3939
},
4040
},
41+
breakOnStart,
4142
};
4243
return msg;
4344
}
@@ -76,7 +77,7 @@ class PluginLoadCommand extends PluginBaseCommand {
7677
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.");
7778
}
7879
const pluginFolder = path.dirname(this.params.manifest);
79-
const loadJsonMsg = createLoadMessage(pluginFolder);
80+
const loadJsonMsg = createLoadMessage(pluginFolder, this.params.breakOnStart);
8081
console.log(`Sending "Load Plugin" command to apps ${JSON.stringify(applicableAppsForLoading)}`);
8182
const loadReqProm = this.sendMessageToAppsWithReply(applicableAppsForLoading, loadJsonMsg);
8283
return loadReqProm.then((results) => {
@@ -98,8 +99,7 @@ class PluginLoadCommand extends PluginBaseCommand {
9899
}
99100
throw new Error("Plugin Load command failed. Failed to load in any of the connected apps");
100101
}
101-
this._handlePluginLoadSuccess(successfulLoads);
102-
return true;
102+
return this._handlePluginLoadSuccess(successfulLoads);
103103
});
104104
}
105105

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

packages/uxp-cli/src/core/client/plugin/actions/PluginReloadCommand.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,26 @@ class PluginReloadCommand extends PluginBaseCommand {
4242
}
4343

4444
executeCommand() {
45-
return this.runCommandOnAllApplicableApps(createReloadMessage);
45+
const resultsCallback = this._handlePluginReloadResult.bind(this);
46+
return this.runCommandOnAllApplicableApps(createReloadMessage, resultsCallback);
47+
}
48+
49+
breakOnStartEnabled(result) {
50+
const { data } = result;
51+
return data && data.breakOnStart;
52+
}
53+
54+
_handlePluginReloadResult(results) {
55+
if (results.length > 0) {
56+
if (this.breakOnStartEnabled(results[0])) {
57+
console.log('The loading of the plugin is blocked. Waiting for a debugger to be launched.');
58+
return this.pm.debugPlugin(this.params).then((res) => {
59+
console.log("Launched standalone Chrome Developer Tools window.");
60+
return { "breakOnStart" : true, res };
61+
});
62+
}
63+
}
64+
return true;
4665
}
4766
}
4867

packages/uxp-cli/src/uxp.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ class UxpDevTools {
3838

3939
setMode(mode) {
4040
const isServer = mode === "service";
41-
this._devToolsMgr = new DevToolsMgr(isServer);
41+
if (!this._devToolsMgr) {
42+
this._devToolsMgr = new DevToolsMgr(isServer);
43+
}
4244
}
4345

4446
get devToolsMgr() {

0 commit comments

Comments
 (0)