Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make uxp command work again, actually use deps correctly, remove postinstall hooks #10

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## This repo contains edits to make the `uxp` CLI command usable.

```bash
npm i -g @adobe-fixed-uxp/uxp-devtools-cli
```

# Overview

UXP Devtools is a standard tool for rapid Adobe UXP plugin development. UXP Devtools provides the ability to do all of the following:
Expand Down
4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@
"scripts": {
"lint": "eslint --ext \".js,.js6,.jsx,.ts,.tsx\" ./",
"lint-fix": "eslint --ext \".js,.js6,.jsx,.ts,.tsx\" ./ --fix",
"postinstall": "node scripts/installScript.js",
"cleanup": "node scripts/cleanup.js"
},
"cpu": [
"!arm64"
],
"jest": {
"transform": {
"^.+\\.jsx?$": "babel-jest"
Expand Down
25 changes: 14 additions & 11 deletions packages/uxp-devtools-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
{
"name": "@adobe/uxp-devtools-cli",
"version": "1.5.1",
"name": "@adobe-fixed-uxp/uxp-devtools-cli",
"version": "1.5.9",
"description": "Command line interface for rapid UXP plugin development",
"main": "src/uxp.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"uxp": "src/uxp.js",
"postinstall": "node scripts/setupInspectApp.js"

"uxp": "src/uxp.js"
},
"bin": {
"uxp": "src/uxp.js"
Expand All @@ -26,21 +24,26 @@
"author": "Adobe Inc",
"license": "Apache-2.0",
"dependencies": {
"@adobe/uxp-devtools-core": "^1.5.0",
"@adobe/uxp-inspect-frontend": "^1.5.1",
"@adobe/uxp-template-ps-starter": "^1.0.0",
"@adobe-fixed-uxp/uxp-devtools-core": "^1.5.1",
"@adobe-fixed-uxp/uxp-wdio-automation-template": "^1.0.0",
"@adobe/uxp-template-default-starter": "^1.0.0",
"@adobe/uxp-template-default-starter-xd": "^1.0.0",
"@adobe/uxp-template-default-starter-ps": "^1.0.0",
"@adobe/uxp-template-default-starter-xd": "^1.0.0",
"@adobe/uxp-template-ps-react-starter": "^1.0.0",
"@adobe/uxp-template-ps-react-typescript": "^1.0.0",
"@adobe/uxp-template-ps-starter": "^1.0.0",
"@adobe/uxp-template-xd-starter": "^1.0.0",
"@adobe/uxp-wdio-automation-template": "^1.0.0",
"@adobe/uxp_web_driver": "2.2.1",
"app-path": "^3.3.0",
"chalk": "^3.0.0",
"cli-table3": "^0.6.0",
"prompts": "^2.3.2",
"semver": "^7.3.2",
"yargs": "^15.3.1"
},
"devDependencies": {
"@adobe-fixed-uxp/uxp-inspect-frontend": "^1.5.1"
},
"optionalDependencies": {
"@adobe-fixed-uxp/uxp-inspect-frontend": "^1.5.1"
}
}
2 changes: 1 addition & 1 deletion packages/uxp-devtools-cli/scripts/setupInspectApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const path = require("path");
const { execSync } = require("child_process");

function generateDevtoolsAppPacakge() {
let uxpDevtoolAppDir = require.resolve("@adobe/uxp-inspect-frontend/package.json");
let uxpDevtoolAppDir = require.resolve("@adobe-fixed-uxp/uxp-inspect-frontend/package.json");
uxpDevtoolAppDir = path.dirname(uxpDevtoolAppDir);

execSync("yarn package", {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/

const Table = require("cli-table3");
const { CoreHelpers } = require("@adobe/uxp-devtools-core");
const { CoreHelpers } = require("@adobe-fixed-uxp/uxp-devtools-core");

function handleAppsListCommand() {
this.app.logLevel = CoreHelpers.LoggerLevel.WARN;
Expand Down
2 changes: 1 addition & 1 deletion packages/uxp-devtools-cli/src/cli/commands/plugin/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
const chalk = require("chalk");
const BasicInitWorkflow = require("./init/BasicInitWorkflow");
const { initWithBundledPluginTemplate } = require("./init/TemplateBasedInitWorkflow");
const { DevToolsError } = require("@adobe/uxp-devtools-core");
const { DevToolsError } = require("@adobe-fixed-uxp/uxp-devtools-core");

const templateHelp = `Specify a template for the plugin.
A custom ${chalk.cyan("--template")} can be one of:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
const path = require("path");
const fs = require("fs-extra");
const _ = require("lodash");
const { DevToolsError } = require("@adobe/uxp-devtools-core");
const { DevToolsError } = require("@adobe-fixed-uxp/uxp-devtools-core");

// Check for file conflicts.
function getConflictingFilesList(pluginDir, uxpPackageDir) {
Expand Down
2 changes: 1 addition & 1 deletion packages/uxp-devtools-cli/src/cli/commands/plugin/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/

const path = require("path");
const { DevToolsError } = require("@adobe/uxp-devtools-core");
const { DevToolsError } = require("@adobe-fixed-uxp/uxp-devtools-core");

const loadOptions = {
manifest: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function handlePluginTestCommand(args) {
const manifestRelPath = args.manifest ? args.manifest : "manifest.json";
const manifest = path.resolve(manifestRelPath);
const apps = args.appId ? args.appId.split(" ") : [];
const packageName = `@adobe/uxp-wdio-automation-template`;
const packageName = `@adobe-fixed-uxp/uxp-wdio-automation-template`;
const driverPort = args.port;
const params = {
manifest,
Expand Down
2 changes: 1 addition & 1 deletion packages/uxp-devtools-cli/src/cli/commands/plugin/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
const path = require("path");
const { loadPluginSessionFromUxpRc } = require("../../utils/Common");
const { CoreHelpers } = require("@adobe/uxp-devtools-core");
const { CoreHelpers } = require("@adobe-fixed-uxp/uxp-devtools-core");

const watchOptions = {
path: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*
*/

const { CoreHelpers } = require("@adobe/uxp-devtools-core");
const { CoreHelpers } = require("@adobe-fixed-uxp/uxp-devtools-core");

function handleServiceStartCommand(argv) {
// start the service at the given port.
Expand Down
31 changes: 19 additions & 12 deletions packages/uxp-devtools-cli/src/cli/utils/CLICDTInspectMgr.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,31 @@ governing permissions and limitations under the License.
const path = require("path");
const child_process = require("child_process");
const process = require("process");
const appPath = require("app-path");
const { createDeferredPromise } = require("./common");

function getDevtoolsAppExecutablePath() {
let uxpDevtoolAppDir = require.resolve("@adobe/uxp-inspect-frontend/package.json");
uxpDevtoolAppDir = path.dirname(uxpDevtoolAppDir);

const productName = "Adobe UXP Developer Tool";
const baseFolder = path.resolve(uxpDevtoolAppDir, "dist");
try {
let uxpDevtoolAppDir = require.resolve("@adobe-fixed-uxp/uxp-inspect-frontend/package.json");
uxpDevtoolAppDir = path.dirname(uxpDevtoolAppDir);

let executablePath = "";
if (process.platform === "darwin") {
executablePath = `${baseFolder}/mac/${productName}.app/Contents/MacOS/${productName}`;
}
else if (process.platform === "win32") {
executablePath = `${baseFolder}/win-unpacked/${productName}.exe`;
}
const baseFolder = path.resolve(uxpDevtoolAppDir, "dist");

return executablePath;
let executablePath = "";
if (process.platform === "darwin") {
executablePath = `${baseFolder}/mac/${productName}.app/Contents/MacOS/${productName}`;
}
else if (process.platform === "win32") {
executablePath = `${baseFolder}/win-unpacked/${productName}.exe`;
}

return executablePath;
} catch (e) {
const p = appPath.sync(productName);
if (!p) throw new Error(`${productName} not found`);
return `${p}/Contents/MacOS/${productName}`;
}
}

function wrapArg(name, arg) {
Expand Down
2 changes: 1 addition & 1 deletion packages/uxp-devtools-cli/src/cli/utils/Tool.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/* eslint-disable func-names */
/* eslint-disable global-require */

const { UDTApplication } = require("@adobe/uxp-devtools-core");
const { UDTApplication } = require("@adobe-fixed-uxp/uxp-devtools-core");

class Tool {
constructor(modules) {
Expand Down
2 changes: 1 addition & 1 deletion packages/uxp-devtools-cli/src/cli/utils/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

function loadPluginSessionFromUxpRc() {
// eslint-disable-next-line global-require
const { CoreHelpers } = require("@adobe/uxp-devtools-core");
const { CoreHelpers } = require("@adobe-fixed-uxp/uxp-devtools-core");
return CoreHelpers.PluginSession.createFromRcFile();
}

Expand Down
2 changes: 1 addition & 1 deletion packages/uxp-devtools-cli/src/uxp.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
/* eslint-disable global-require */
const Tool = require("./cli/utils/Tool");
const { UDTApplication } = require("@adobe/uxp-devtools-core");
const { UDTApplication } = require("@adobe-fixed-uxp/uxp-devtools-core");

const commands = [
require("./cli/commands/apps/index"),
Expand Down
11 changes: 7 additions & 4 deletions packages/uxp-devtools-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@adobe/uxp-devtools-core",
"version": "1.5.0",
"name": "@adobe-fixed-uxp/uxp-devtools-core",
"version": "1.5.1",
"description": "UXP Devtools Core Module",
"main": "src/index.js",
"scripts": {
Expand All @@ -21,17 +21,20 @@
"author": "Adobe Inc",
"license": "Apache-2.0",
"dependencies": {
"@adobe/uxp-devtools-helper": "^1.5.0",
"@adobe-fixed-uxp/uxp-devtools-helper": "^1.5.1",
"chalk": "^3.0.0",
"chokidar": "^3.4.2",
"express": "^4.17.1",
"fancy-log": "^1.3.3",
"fs-extra": "^9.0.0",
"lodash": "^4.17.20",
"isomorphic-ws": "^4.0.1",
"ws": "^7.2.3",
"ws": "^8.12.0",
"archiver": "5.3.0",
"ignore-walk": "^3.0.3",
"shell-exec": "^1.0.2"
},
"devDependencies": {
"@adobe-fixed-uxp/uxp_web_driver": "^2.2.1"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class CliClientController {
_connectToServiceAtPort(port) {
this._createConnection();
this._port = port;
const url = `ws://localhost:${port}/socket/cli`;
const url = `ws://127.0.0.1:${port}/socket/cli`;
this._callerPromise = createDeferredPromise();
this._connection.connect(this, url);
return this._callerPromise.promise;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class Connection extends EventEmitter {
}

onError(evt) {
console.error(evt)
UxpLogger.error(`Websocket error ${evt}`);
this.emit("error", evt);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class PluginTestBaseCommand extends PluginBaseCommand {
const uxpDriver_logFilePath = path.resolve(logPath , logFileName).toString();
const uxpDriver_logFile = await fsPromises.open(uxpDriver_logFilePath, "w+");

let uxpDevtoolCoreDir = require.resolve("@adobe/uxp-devtools-core/package.json");
let uxpDevtoolCoreDir = require.resolve("@adobe-fixed-uxp/uxp-devtools-core/package.json");
uxpDevtoolCoreDir = path.dirname(uxpDevtoolCoreDir);
process.chdir(uxpDevtoolCoreDir);

Expand Down
2 changes: 1 addition & 1 deletion packages/uxp-devtools-core/src/core/common/DevToolsMgr.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*
*/
/* eslint-disable class-methods-use-this */
const DevToolsHelper = require("@adobe/uxp-devtools-helper");
const DevToolsHelper = require("@adobe-fixed-uxp/uxp-devtools-helper");

class DevToolsMgr {
constructor(isServer) {
Expand Down
7 changes: 6 additions & 1 deletion packages/uxp-devtools-core/src/core/service/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,14 @@ class Server extends EventEmitter {
this._io = new WebSocket.Server({ server: this._httpServer });
this._io.on("connection", this._handleSocketConnection.bind(this));

console.log("LISTENING")

// Make sure to listen for error messages on _io to avoid crashes when some error
// is dispatched and we don't have a listener.
this._io.on("error", (err) => {
if (err.code !== "EADDRINUSE") {
UxpLogger.error("WebSocket error:", err);
UxpLogger.error("WebSocket error:", err.name, err.message, err);
console.error(err);
}
});
}
Expand All @@ -65,6 +68,7 @@ class Server extends EventEmitter {
}

_getClientClassForUrl(url) {
console.log("HI", url)
if (url === "/socket/cli") {
return require("./clients/UxpCliClient");
}
Expand All @@ -78,6 +82,7 @@ class Server extends EventEmitter {
}

_handleSocketConnection(socket, req) {
console.log("SOCKET")
// WS changed the way it sends the initial upgrade request.
// Newer versions pass it dirrectly to the connection event handler.
const url = req ? req.url : socket.upgradeReq.url;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class BrowserCDTClient extends Client {

static create(server, socket, url) {
// url is of form "/socket/browser_cdt/?uxp-app-id=PS" hence added a baseURL
let cliUrl = new URL(url, "http://localhost:14001");
let cliUrl = new URL(url, "http://127.0.0.1:14001");
const searchParams = cliUrl.searchParams;
const uxpAppID = searchParams.get("adobe-uxp-app-id");
let browserCDTClient = new BrowserCDTClient(server, socket, uxpAppID);
Expand Down
2 changes: 1 addition & 1 deletion packages/uxp-devtools-core/startUxpDriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

const { startUXPDriver } = require("@adobe/uxp_web_driver");
const { startUXPDriver } = require("@adobe-fixed-uxp/uxp_web_driver");
function startTestService() {
try {
const UXPDriverPort = process.argv[2];
Expand Down
2 changes: 1 addition & 1 deletion packages/uxp-devtools-feature/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@adobe/uxp-devtools-feature",
"name": "@adobe-fixed-uxp/uxp-devtools-feature",
"version": "1.5.0",
"description": "UXP Devtools Feature Config Module",
"main": "src/index.js",
Expand Down
11 changes: 3 additions & 8 deletions packages/uxp-devtools-helper/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
{
"name": "@adobe/uxp-devtools-helper",
"version": "1.5.0",
"name": "@adobe-fixed-uxp/uxp-devtools-helper",
"version": "1.5.1",
"description": "Adobe Devtools helper package used by uxp cli",
"main": "src/DevToolsHelper.js",
"scripts": {
"install": "node scripts/devtools_setup.js"
},
"repository": {
"type": "git",
"url": "[email protected]:adobe-uxp/devtools-cli.git",
Expand All @@ -20,9 +17,7 @@
"dependencies": {
"fs-extra": "^9.0.0",
"node-gyp-build": "^4.2.3",
"@adobe/uxp-devtools-feature": "^1.0.0"
},
"devDependencies": {
"@adobe-fixed-uxp/uxp-devtools-feature": "^1.0.0",
"tar": "^6.0.1"
}
}
2 changes: 1 addition & 1 deletion packages/uxp-devtools-helper/scripts/devtools_setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function postSetupInstallStep() {

function setupDevtoolsNativeAddOn() {
console.log("Setting up Adobe devTools node native add-on library... ");
const arch = process.env.build_arch;
const arch = process.env.build_arch || process.arch;
const targetFolder = setupTargetFolder();
const fileName = arch !== "arm64" ? `DevtoolsHelper-v1.0.0-node-${process.platform}.tar.gz` : `DevtoolsHelper-v1.0.0-node-${process.platform}-arm64.tar.gz`;
const devToolsTarPath = path.resolve(__dirname, `./native-libs/${fileName}`);
Expand Down
1 change: 1 addition & 0 deletions packages/uxp-devtools-helper/src/DevToolsHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ class DevToolsHelper {
prom.resolve(payload.port);
}
catch (err) {
console.error(err)
prom.reject(new Error(errorMsg));
}
prom.handled = true;
Expand Down
2 changes: 1 addition & 1 deletion packages/uxp-devtools-helper/src/DevToolsUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
const path = require("path");
const fs = require("fs");
const { exec } = require("child_process");
const { FeatureFlag } = require("@adobe/uxp-devtools-feature");
const { FeatureFlag } = require("@adobe-fixed-uxp/uxp-devtools-feature");

const isInternalBuild = FeatureFlag.isFeatureEnabled("internalPluginWorkspace");

Expand Down
Loading