├── .eslintrc ├── .github └── workflows │ └── version-bump-publish.yml ├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── babel.config.json ├── package.json ├── packages ├── uxp-devtools-cli │ ├── README.md │ ├── package.json │ ├── scripts │ │ └── setupInspectApp.js │ └── src │ │ ├── cli │ │ ├── commands │ │ │ ├── apps │ │ │ │ ├── AppsCmds.js │ │ │ │ └── index.js │ │ │ ├── devtools │ │ │ │ ├── DevToolsCmds.js │ │ │ │ └── index.js │ │ │ ├── plugin │ │ │ │ ├── debug.js │ │ │ │ ├── index.js │ │ │ │ ├── init.js │ │ │ │ ├── init │ │ │ │ │ ├── BasicInitQuestions.js │ │ │ │ │ ├── BasicInitWorkflow.js │ │ │ │ │ └── TemplateBasedInitWorkflow.js │ │ │ │ ├── load.js │ │ │ │ ├── log.js │ │ │ │ ├── package.js │ │ │ │ ├── pluginTest.js │ │ │ │ ├── reload.js │ │ │ │ ├── unload.js │ │ │ │ ├── validate.js │ │ │ │ └── watch.js │ │ │ └── service │ │ │ │ ├── ServiceCmds.js │ │ │ │ └── index.js │ │ └── utils │ │ │ ├── CLICDTInspectMgr.js │ │ │ ├── Tool.js │ │ │ ├── common.js │ │ │ └── shell.js │ │ └── uxp.js ├── uxp-devtools-core │ ├── package.json │ ├── src │ │ ├── core │ │ │ ├── client │ │ │ │ ├── PluginMgr.js │ │ │ │ ├── connection │ │ │ │ │ ├── CliClientController.js │ │ │ │ │ ├── Connection.js │ │ │ │ │ └── HostAppClient.js │ │ │ │ └── plugin │ │ │ │ │ ├── PluginInspectMgr.js │ │ │ │ │ ├── PluginSession.js │ │ │ │ │ └── actions │ │ │ │ │ ├── PluginBaseCommand.js │ │ │ │ │ ├── PluginDebugCommand.js │ │ │ │ │ ├── PluginLoadCommand.js │ │ │ │ │ ├── PluginLogCommand.js │ │ │ │ │ ├── PluginPackageCommand.js │ │ │ │ │ ├── PluginReloadCommand.js │ │ │ │ │ ├── PluginTestBaseCommand.js │ │ │ │ │ ├── PluginTestCommand.js │ │ │ │ │ ├── PluginTestSetupCommand.js │ │ │ │ │ ├── PluginUnloadCommand.js │ │ │ │ │ ├── PluginValidateCommand.js │ │ │ │ │ ├── RefreshListCommand.js │ │ │ │ │ └── init │ │ │ │ │ ├── templateCommand.js │ │ │ │ │ ├── templatePrompts.js │ │ │ │ │ └── utils.js │ │ │ ├── common │ │ │ │ ├── AppsMgr.js │ │ │ │ ├── CoreHelpers.js │ │ │ │ ├── DevToolsError.js │ │ │ │ ├── DevToolsMgr.js │ │ │ │ ├── ErrorCodes.js │ │ │ │ ├── KillProcess.js │ │ │ │ ├── Logger.js │ │ │ │ ├── Utils.js │ │ │ │ ├── UxpRCMgr.js │ │ │ │ └── WatchServiceMgr.js │ │ │ ├── helpers │ │ │ │ ├── AppsHelper.js │ │ │ │ ├── CommonUtils.js │ │ │ │ └── ManifestHelper.js │ │ │ ├── service │ │ │ │ ├── FeatureConfigMgr.js │ │ │ │ ├── PluginSessionMgr.js │ │ │ │ ├── Server.js │ │ │ │ ├── ServiceMgr.js │ │ │ │ └── clients │ │ │ │ │ ├── AppClient.js │ │ │ │ │ ├── BrowserCDTClient.js │ │ │ │ │ ├── CDTClient.js │ │ │ │ │ ├── Client.js │ │ │ │ │ └── UxpCliClient.js │ │ │ └── udt │ │ │ │ ├── HostDelegate.js │ │ │ │ ├── UDTApplication.js │ │ │ │ ├── UDTClient.js │ │ │ │ ├── UDTInitializerParams.js │ │ │ │ └── UDTServer.js │ │ └── index.js │ └── startUxpDriver.js ├── uxp-devtools-feature │ ├── package.json │ └── src │ │ ├── configs │ │ └── featureFlag.json │ │ ├── feature │ │ └── FeatureFlag.js │ │ └── index.js ├── uxp-devtools-helper │ ├── package.json │ ├── scripts │ │ ├── devtools_setup.js │ │ └── native-libs │ │ │ ├── DevtoolsHelper-v1.1.0-node-darwin-arm64.tar.gz │ │ │ ├── DevtoolsHelper-v1.1.0-node-darwin.tar.gz │ │ │ └── DevtoolsHelper-v1.1.0-node-win32.tar.gz │ └── src │ │ ├── DevToolNativeLib.js │ │ ├── DevToolsHelper.js │ │ ├── DevToolsUtils.js │ │ └── devtools │ │ ├── command.js │ │ ├── internal_mac.sh │ │ ├── internal_win32.bat │ │ ├── mac.sh │ │ └── win32.bat ├── uxp-inspect-frontend │ ├── .gitignore │ ├── README.md │ ├── main │ │ ├── devtools │ │ │ └── CDTCommonUtils.js │ │ └── index.js │ ├── package.json │ ├── resources │ │ └── icons │ │ │ ├── app │ │ │ ├── icon.icns │ │ │ ├── icon.ico │ │ │ ├── icon_folder.icns │ │ │ ├── icon_folder.ico │ │ │ ├── icon_pkg.icns │ │ │ └── icon_pkg.ico │ │ │ └── installer │ │ │ └── uxpdevelopertools_appicons_generalsizes.zip │ ├── scripts │ │ ├── front_end.tar.gz │ │ └── setup.js │ └── src │ │ └── index.html ├── uxp-templates-pack │ ├── uxp-template-default-starter-ps │ │ ├── index.js │ │ ├── package.json │ │ ├── template.json │ │ └── template │ │ │ ├── index.html │ │ │ ├── index.js │ │ │ ├── manifest.json │ │ │ ├── package.json │ │ │ └── uxp-plugin-tests │ │ │ └── sample-tests │ │ │ ├── page-objects │ │ │ └── homepage.js │ │ │ └── specs │ │ │ └── ChangeColorTest.js │ ├── uxp-template-default-starter-xd │ │ ├── index.js │ │ ├── package.json │ │ └── template │ │ │ ├── README.md │ │ │ ├── images │ │ │ ├── icon@1x.png │ │ │ ├── icon@2x.png │ │ │ ├── icon@3x.png │ │ │ ├── icon@4x.png │ │ │ └── icon@5x.png │ │ │ ├── main.js │ │ │ └── manifest.json │ ├── uxp-template-default-starter │ │ ├── index.js │ │ ├── package.json │ │ └── template │ │ │ ├── index.js │ │ │ ├── manifest.json │ │ │ └── package.json │ ├── uxp-template-ps-react-starter │ │ ├── .gitignore │ │ ├── index.js │ │ ├── package.json │ │ ├── template.json │ │ └── template │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── package.json │ │ │ ├── plugin │ │ │ ├── icons │ │ │ │ ├── icon_D.png │ │ │ │ ├── icon_D@2x.png │ │ │ │ ├── icon_N.png │ │ │ │ └── icon_N@2x.png │ │ │ ├── index.html │ │ │ └── manifest.json │ │ │ ├── src │ │ │ ├── components │ │ │ │ ├── About.css │ │ │ │ ├── About.jsx │ │ │ │ ├── ColorPicker.css │ │ │ │ ├── ColorPicker.jsx │ │ │ │ ├── Hello.jsx │ │ │ │ ├── Icons.css │ │ │ │ ├── Icons.jsx │ │ │ │ └── WC.jsx │ │ │ ├── controllers │ │ │ │ ├── CommandController.jsx │ │ │ │ └── PanelController.jsx │ │ │ ├── index.jsx │ │ │ ├── panels │ │ │ │ ├── Demos.jsx │ │ │ │ └── MoreDemos.jsx │ │ │ └── styles.css │ │ │ ├── uxp-plugin-tests │ │ │ └── sample-tests │ │ │ │ ├── page-objects │ │ │ │ └── homepage.js │ │ │ │ └── specs │ │ │ │ └── PopulateButtonTest.js │ │ │ └── webpack.config.js │ ├── uxp-template-ps-react-typescript │ │ ├── .gitignore │ │ ├── .prettierrc │ │ ├── index.js │ │ ├── package.json │ │ ├── template.json │ │ └── template │ │ │ ├── README.md │ │ │ ├── package.json │ │ │ ├── src │ │ │ ├── App.css │ │ │ ├── App.tsx │ │ │ ├── components │ │ │ │ ├── Elements.tsx │ │ │ │ ├── Listener.tsx │ │ │ │ ├── PsApi.tsx │ │ │ │ └── UxpFileFetch.tsx │ │ │ └── index.tsx │ │ │ ├── tsconfig.json │ │ │ ├── tslint.json │ │ │ ├── uxp │ │ │ ├── icons │ │ │ │ ├── icon_D.png │ │ │ │ ├── icon_N.png │ │ │ │ ├── icon_x2_D.png │ │ │ │ └── icon_x2_N.png │ │ │ ├── index.html │ │ │ └── manifest.json │ │ │ ├── webpack.config.js │ │ │ └── yarn.lock │ ├── uxp-template-ps-starter │ │ ├── index.js │ │ ├── package.json │ │ └── template │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── icons │ │ │ ├── dark@1x.png │ │ │ ├── dark@2x.png │ │ │ ├── light@1x.png │ │ │ └── light@2x.png │ │ │ ├── index.html │ │ │ ├── index.js │ │ │ ├── manifest.json │ │ │ ├── package.json │ │ │ └── watch.sh │ ├── uxp-template-xd-starter │ │ ├── index.js │ │ ├── package.json │ │ └── template │ │ │ ├── README.md │ │ │ ├── images │ │ │ ├── icon@1x.png │ │ │ └── icon@2x.png │ │ │ ├── main.js │ │ │ └── manifest.json │ └── uxp-wdio-automation-template │ │ ├── package.json │ │ ├── sample-tests │ │ └── specs │ │ │ └── starterScript.js │ │ └── wdio.conf.js └── uxp-webdriver │ ├── index.js │ ├── lib │ ├── atoms │ │ ├── active.js │ │ ├── call_function.js │ │ ├── click.js │ │ ├── elementDisplayed.js │ │ ├── elementEnabled.js │ │ ├── elementSelected.js │ │ ├── execute_async_script.js │ │ ├── find_element.js │ │ ├── find_elements.js │ │ ├── find_elements_by_xpath.js │ │ ├── getAtomsAttribute.js │ │ ├── getCssProperty.js │ │ ├── getLocation.js │ │ ├── getName.js │ │ ├── getProperty.js │ │ ├── getSize.js │ │ ├── getText.js │ │ ├── uxp_element_blur.js │ │ ├── uxp_element_check_editable.js │ │ ├── uxp_element_clear.js │ │ ├── uxp_element_focus.js │ │ ├── uxp_element_scroll_into_view.js │ │ ├── uxp_getAttribute.js │ │ ├── uxp_is_element_focus.js │ │ └── xpath_polyfill.js │ ├── utils │ │ ├── PointerInput.js │ │ ├── ScreenShot.js │ │ ├── keyboardInput.js │ │ └── uxp_utils.js │ ├── uxpPrepareExtAutomation.js │ ├── uxp_devtool_bridge.js │ ├── uxp_driver.js │ ├── uxp_extension_window.js │ └── uxp_webdriver_server.js │ ├── package.json │ ├── uxp_driver_export.js │ └── yarn.lock ├── scripts ├── cleanup.js ├── common.js └── installScript.js └── yarn.lock /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["airbnb-base"], 3 | "rules": { 4 | "indent": ["error", 4], 5 | "no-underscore-dangle": "off", 6 | "quotes": "off", 7 | "no-console": "off", 8 | "no-plusplus": "off", 9 | "max-classes-per-file": ["error", 6], 10 | "no-restricted-syntax": ["error", "WithStatement", "LabeledStatement"], 11 | "array-callback-return": "off", 12 | "arrow-body-style": "off" 13 | } 14 | } -------------------------------------------------------------------------------- /.github/workflows/version-bump-publish.yml: -------------------------------------------------------------------------------- 1 | name: version-bump-publish 2 | on: 3 | workflow_dispatch: 4 | inputs: 5 | level: 6 | description: ' | major | minor | patch | premajor | preminor | prepatch | prerelease' 7 | required: true 8 | default: 'patch' 9 | tag: 10 | description: 'The tag to publish to.' 11 | required: false 12 | default: 'latest' 13 | jobs: 14 | checkout: 15 | name: checkout 16 | runs-on: ubuntu-latest 17 | steps: 18 | - uses: actions/checkout@v2 19 | - run: | 20 | git config user.name github-actions 21 | git config user.email github-actions@github.com 22 | - uses: actions/setup-node@v1 23 | with: 24 | node-version: 10 25 | - run: | 26 | npm install 27 | - uses: author/action-publish@stable 28 | with: 29 | scan: "./packages" 30 | env: 31 | REGISTRY_TOKEN: ${{ secrets.ADOBE_BOT_NPM_TOKEN }} 32 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | dist 3 | node_modules 4 | .cache 5 | yarn-error.log 6 | .vscode/ 7 | build/ 8 | out/ 9 | Jenkinsfile 10 | build.js 11 | scripts/adobe_internal/commands/demoAppSetup.js 12 | scripts/adobe_internal/demoAppConfig.js 13 | scripts/adobe_internal/npmrcUtil.js 14 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Thanks for choosing to contribute! 4 | 5 | The following are a set of guidelines to follow when contributing to this project. 6 | 7 | ## Code Of Conduct 8 | 9 | This project adheres to the Adobe [code of conduct](./CODE_OF_CONDUCT.md). By participating, 10 | you are expected to uphold this code. Please report unacceptable behavior to 11 | [Grp-opensourceoffice@adobe.com](mailto:Grp-opensourceoffice@adobe.com). 12 | 13 | ## Have A Question? 14 | 15 | Start by filing an issue. The existing committers on this project work to reach 16 | consensus around project direction and issue solutions within issue threads 17 | (when appropriate). 18 | 19 | ## Contributor License Agreement 20 | 21 | All third-party contributions to this project must be accompanied by a signed contributor 22 | license agreement. This gives Adobe permission to redistribute your contributions 23 | as part of the project. [Sign our CLA](https://opensource.adobe.com/cla.html). You 24 | only need to submit an Adobe CLA one time, so if you have submitted one previously, 25 | you are good to go! 26 | 27 | ## Code Reviews 28 | 29 | All submissions should come in the form of pull requests and need to be reviewed 30 | by project committers. Read [GitHub's pull request documentation](https://help.github.com/articles/about-pull-requests/) 31 | for more information on sending pull requests. 32 | 33 | ## From Contributor To Committer 34 | 35 | We love contributions from our community! If you'd like to go a step beyond contributor 36 | and become a committer with full write access and a say in the project, you must 37 | be invited to the project. The existing committers employ an internal nomination 38 | process that must reach lazy consensus (silence is approval) before invitations 39 | are issued. If you feel you are qualified and want to get more deeply involved, 40 | feel free to reach out to existing committers to have a conversation about that. 41 | 42 | ## Security Issues 43 | 44 | Security issues shouldn't be reported on this issue tracker. Instead, [file an issue to our security experts](https://helpx.adobe.com/security/alertus.html). -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | UXP Devtools is a standard tool for rapid Adobe UXP plugin development. UXP Devtools provides the ability to do all of the following: 4 | 5 | - **Discover** UXP-compatible Adobe apps. 6 | - **Load** your development plugins in a target app (no symlinks or deep file system spelunking required). 7 | - **Reload** your currently running plugin instance with new changes (no app restart required). 8 | - **Launch** a rich DevTools environment for debugging your plugin. 9 | - **View** your plugin logs. 10 | 11 | **Current host app support matrix** 12 | 13 | | Host Apps with UXP | DevTools Support Added | 14 | | ------------------ | ----------------------------------------------------- | 15 | | Photoshop | PS June 2020 Release Builds with UXP 3.8.24 or higher | 16 | | Illustrator | Not available yet | 17 | | XD | XD 36 or higher in Mac and XD 38 or higher in windows | 18 | 19 | `UXP Devtools` are available in form of CLI and Standalone application both. Refer the links for more about details about [CLI](./packages/uxp-devtools-cli/README.md) and [Application](https://www.adobe.io/photoshop/uxp/devtool/installation/) 20 | -------------------------------------------------------------------------------- /babel.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["@babel/preset-env","@babel/preset-react"], 3 | "plugins": [ 4 | ["@babel/plugin-proposal-decorators", { "legacy": true }], 5 | ["@babel/plugin-proposal-class-properties"], 6 | ["@babel/plugin-transform-runtime",{ "regenerator": true}], 7 | ["@babel/plugin-syntax-jsx"] 8 | ] 9 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "uxp-developer-tools", 3 | "version": "1.5.1", 4 | "private": true, 5 | "workspaces": { 6 | "packages": [ 7 | "packages/*", 8 | "packages/uxp-templates-pack/*" 9 | ], 10 | "nohoist": [] 11 | }, 12 | "scripts": { 13 | "lint": "eslint --ext \".js,.js6,.jsx,.ts,.tsx\" ./", 14 | "lint-fix": "eslint --ext \".js,.js6,.jsx,.ts,.tsx\" ./ --fix", 15 | "postinstall": "node scripts/installScript.js", 16 | "cleanup": "node scripts/cleanup.js" 17 | }, 18 | "jest": { 19 | "transform": { 20 | "^.+\\.jsx?$": "babel-jest" 21 | } 22 | }, 23 | "devDependencies": { 24 | "@babel/plugin-proposal-class-properties": "^7.10.4", 25 | "@babel/plugin-proposal-decorators": "^7.10.5", 26 | "@babel/preset-env": "^7.11.5", 27 | "babel-eslint": "^10.1.0", 28 | "babel-jest": "^26.3.0", 29 | "@babel/core": "^7.10.4", 30 | "eslint": "^6.8.0", 31 | "eslint-config-airbnb-base": "^14.0.0", 32 | "eslint-plugin-import": "^2.20.1", 33 | "eslint-plugin-react": "^7.21.4", 34 | "jest": "^26.4.2", 35 | "jest-electron": "^0.1.11", 36 | "jest-html-reporter": "^3.1.3", 37 | "nyc": "^15.1.0" 38 | }, 39 | "dependencies": { 40 | "@babel/plugin-syntax-jsx": "^7.10.4", 41 | "@babel/plugin-transform-modules-commonjs": "^7.10.4", 42 | "@babel/plugin-transform-react-jsx": "^7.12.12", 43 | "@babel/plugin-transform-runtime": "^7.11.5", 44 | "@babel/runtime": "^7.11.2", 45 | "babel-plugin-istanbul": "^6.0.0", 46 | "babel-polyfill": "^6.26.0", 47 | "babel-register": "^6.26.0" 48 | }, 49 | "engines": { 50 | "node": ">=12.19.0" 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /packages/uxp-devtools-cli/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@adobe/uxp-devtools-cli", 3 | "version": "1.6.4", 4 | "description": "Command line interface for rapid UXP plugin development", 5 | "main": "src/uxp.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "uxp": "src/uxp.js", 9 | "postinstall": "node scripts/setupInspectApp.js" 10 | }, 11 | "bin": { 12 | "uxp": "src/uxp.js" 13 | }, 14 | "repository": { 15 | "type": "git", 16 | "url": "git@github.com:adobe-uxp/devtools-cli.git", 17 | "directory": "packages/uxp-devtools-cli" 18 | }, 19 | "keywords": [ 20 | "adobe", 21 | "uxp", 22 | "cli", 23 | "plugin" 24 | ], 25 | "author": "Adobe Inc", 26 | "license": "Apache-2.0", 27 | "dependencies": { 28 | "@adobe/uxp-devtools-core": "1.6.0", 29 | "@adobe/uxp-inspect-frontend": "1.6.1", 30 | "@adobe/uxp-template-default-starter": "1.0.0", 31 | "@adobe/uxp-template-default-starter-ps": "1.0.0", 32 | "@adobe/uxp-template-default-starter-xd": "1.0.0", 33 | "@adobe/uxp-template-ps-react-starter": "1.0.0", 34 | "@adobe/uxp-template-ps-react-typescript": "1.0.0", 35 | "@adobe/uxp-template-ps-starter": "1.0.0", 36 | "@adobe/uxp-template-xd-starter": "1.0.0", 37 | "@adobe/uxp-wdio-automation-template": "1.0.0", 38 | "@adobe/uxp_web_driver": "2.2.1", 39 | "chalk": "^3.0.0", 40 | "cli-table3": "^0.6.0", 41 | "prompts": "^2.3.2", 42 | "semver": "^7.3.2", 43 | "yargs": "^15.3.1" 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /packages/uxp-devtools-cli/scripts/setupInspectApp.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 Adobe. All rights reserved. 3 | This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. You may obtain a copy 5 | of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | Unless required by applicable law or agreed to in writing, software distributed under 7 | the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 8 | OF ANY KIND, either express or implied. See the License for the specific language 9 | governing permissions and limitations under the License. 10 | */ 11 | 12 | const path = require("path"); 13 | const os = require("os"); 14 | const { execSync } = require("child_process"); 15 | 16 | function generateDevtoolsAppPacakge() { 17 | let uxpDevtoolAppDir = require.resolve("@adobe/uxp-inspect-frontend/package.json"); 18 | uxpDevtoolAppDir = path.dirname(uxpDevtoolAppDir); 19 | 20 | if(os.arch() === "arm64") { 21 | execSync("yarn package-arm64", { 22 | cwd: uxpDevtoolAppDir, 23 | stdio: [ "inherit", "inherit", "inherit" ] 24 | }); 25 | }else { 26 | execSync("yarn package", { 27 | cwd: uxpDevtoolAppDir, 28 | stdio: [ "inherit", "inherit", "inherit" ] 29 | }); 30 | } 31 | } 32 | 33 | generateDevtoolsAppPacakge(); 34 | -------------------------------------------------------------------------------- /packages/uxp-devtools-cli/src/cli/commands/apps/AppsCmds.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | */ 13 | 14 | const Table = require("cli-table3"); 15 | const { CoreHelpers } = require("@adobe/uxp-devtools-core"); 16 | 17 | function handleAppsListCommand() { 18 | this.app.logLevel = CoreHelpers.LoggerLevel.WARN; 19 | const prom = this.app.client.executePluginCommand("connectedApps"); 20 | return prom.then((appsList) => { 21 | if (!appsList || !appsList.length) { 22 | console.warn("No Host apps are currently connected to uxp devtools cli service"); 23 | console.warn("Please make sure that you have launched an application that supports UXP Developer Tools and try again."); 24 | return null; 25 | } 26 | 27 | const tableOptions = { 28 | head: [ "ID", "Version", "Name" ], 29 | style: { head: [ "green" ] }, 30 | wordWrap: true, 31 | }; 32 | const table = new Table(tableOptions); 33 | appsList.forEach((app) => { 34 | table.push([ app.id, app.version, app.name ]); 35 | }); 36 | 37 | console.log("List of Host Apps currently connected to UXP devtools cli service"); 38 | console.log(table.toString()); 39 | return appsList; 40 | }); 41 | } 42 | 43 | const appsListCommand = { 44 | command: "list", 45 | description: "List Applications that are currently connected to the uxp devtools cli service.", 46 | handler: handleAppsListCommand, 47 | }; 48 | 49 | module.exports = { 50 | appsListCommand, 51 | }; 52 | -------------------------------------------------------------------------------- /packages/uxp-devtools-cli/src/cli/commands/apps/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | */ 13 | 14 | const { appsListCommand } = require("./AppsCmds"); 15 | 16 | function registerAppSubCommands(yargs) { 17 | return yargs.command(appsListCommand); 18 | } 19 | 20 | const appsCommand = { 21 | command: "apps ", 22 | description: "Query applications that support UXP Developer Tools", 23 | builder: registerAppSubCommands, 24 | }; 25 | 26 | module.exports = appsCommand; 27 | -------------------------------------------------------------------------------- /packages/uxp-devtools-cli/src/cli/commands/devtools/index.js: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 4 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. You may obtain a copy 6 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software distributed under 9 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 10 | * OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | * 13 | */ 14 | 15 | const { enableCommand, disableCommand } = require("./DevToolsCmds"); 16 | 17 | function registerdevToolsubCommands(yargs) { 18 | return yargs.command(enableCommand) 19 | .command(disableCommand); 20 | } 21 | 22 | const devToolsCommand = { 23 | command: "devtools ", 24 | description: "Enable or disable UXP Developer Tool workflow", 25 | builder: registerdevToolsubCommands, 26 | }; 27 | 28 | module.exports = devToolsCommand; 29 | -------------------------------------------------------------------------------- /packages/uxp-devtools-cli/src/cli/commands/plugin/index.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable max-len */ 2 | /* 3 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 4 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. You may obtain a copy 6 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software distributed under 9 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 10 | * OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | * 13 | */ 14 | 15 | const loadCommand = require("./load"); 16 | const debugCommand = require("./debug"); 17 | const reloadCommand = require("./reload"); 18 | const unloadCommand = require("./unload"); 19 | const logCommand = require("./log"); 20 | const initCommand = require("./init"); 21 | const validateCommand = require("./validate"); 22 | const packageCommand = require("./package"); 23 | const watchCommand = require("./watch"); 24 | const testCommand = require("./pluginTest"); 25 | 26 | 27 | function registerPluginSubCommands(yargs) { 28 | return yargs.command(loadCommand).command(debugCommand) 29 | .command(reloadCommand).command(logCommand).command(initCommand) 30 | .command(validateCommand).command(unloadCommand).command(watchCommand) 31 | .command(packageCommand).command(testCommand); 32 | } 33 | 34 | const PluginCommand = { 35 | command: "plugin ", 36 | description: "Load, reload, watch, debug, unload, test, package, validate plugins", 37 | builder: registerPluginSubCommands, 38 | }; 39 | 40 | module.exports = PluginCommand; 41 | -------------------------------------------------------------------------------- /packages/uxp-devtools-cli/src/cli/commands/plugin/init/BasicInitQuestions.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the Licrrense for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | */ 13 | const semver = require("semver"); 14 | const pluginName = { 15 | type: "text", 16 | name: "name", 17 | message: "Plugin Name", 18 | validate: (value) => (!!value), 19 | }; 20 | 21 | const pluginVersion = { 22 | type: "text", 23 | name: "version", 24 | message: "Plugin Version", 25 | }; 26 | 27 | const pluginId = { 28 | type: "text", 29 | name: "id", 30 | message: "Plugin Id ?", 31 | validate: (value) => (!!value), 32 | }; 33 | 34 | const host = { 35 | type: "multiselect", 36 | name: "host", 37 | message: "Host Application?", 38 | choices: [ 39 | { title: "Photoshop", value: "PS" }, 40 | { title: "Adobe XD", value: "XD" }, 41 | ], 42 | min: 1, 43 | }; 44 | 45 | 46 | const psVersion = { 47 | type: (prev, values) => { 48 | const appList = values.host; 49 | if (Array.isArray(appList) && appList.includes("PS")) { 50 | return "text"; 51 | } 52 | return null; 53 | }, 54 | name: "psversion", 55 | message: "PhotoShop Version", 56 | validate: value => (semver.valid(value)) ? true : `Please specify valid minVersion in x.y.z format` 57 | }; 58 | 59 | const xdVersion = { 60 | type: (prev, values) => { 61 | const appList = values.host; 62 | if (Array.isArray(appList) && appList.includes("XD")) { 63 | return "text"; 64 | } 65 | return null; 66 | }, 67 | name: "xdversion", 68 | message: "Adobe XD Version", 69 | validate: (value) => (semver.valid(value)) ? true : `Please specify valid minVersion in x.y.z format` 70 | }; 71 | 72 | 73 | const questions = [ 74 | pluginName, 75 | pluginVersion, 76 | pluginId, 77 | host, 78 | psVersion, 79 | xdVersion, 80 | ]; 81 | 82 | module.exports = questions; 83 | -------------------------------------------------------------------------------- /packages/uxp-devtools-cli/src/cli/commands/plugin/log.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | */ 13 | 14 | 15 | const debugCommand = require("./debug"); 16 | 17 | // we are going to leverage the debug command for Logs commnad - 18 | // Logs command is supposed to launch the CDT Inspect with only Console Tab in it. 19 | // Debug command internally takes this option to handle the console case. 20 | 21 | function handlePluginLogsCommand(args) { 22 | // set the forConsole to true - so that we show only the Console Tab in the CDT Inspect for Logs. 23 | args.forConsole = true; 24 | return debugCommand.handler(args); 25 | } 26 | 27 | const logOptions = { 28 | apps: { 29 | describe: "If you plugin is loaded in multiple apps, you can use this option to limit the Apps this command will run on.", 30 | type: "string", 31 | }, 32 | }; 33 | 34 | const logCommand = { 35 | command: "logs", 36 | description: "Show Plugin Logs Window", 37 | handler: handlePluginLogsCommand, 38 | builder: logOptions, 39 | }; 40 | 41 | module.exports = logCommand; 42 | -------------------------------------------------------------------------------- /packages/uxp-devtools-cli/src/cli/commands/plugin/package.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | */ 13 | const path = require("path"); 14 | 15 | const packageOptions = { 16 | manifest: { 17 | describe: "Relative path to plugin's manifest.json file. Defaults to the manifest.json in the current working directory.", 18 | demandOption: false 19 | }, 20 | apps: { 21 | describe: "Space delimited list of app IDs for which the plugin should be packaged. The supported app IDs can be retrieved using `uxp apps list`. The default action is to package the plugin for all the apps specified in the plugin's manifest.", 22 | demandOption: false 23 | }, 24 | outputPath: { 25 | describe: "Output directory path where plugin will be packaged. Defaults to current working directory.", 26 | demandOption: false 27 | } 28 | }; 29 | 30 | function handlePluginPackageResult(args) { 31 | const manifestRelPath = args.manifest || "manifest.json"; 32 | let outputDir = args.outputPath; 33 | const appsList = args.apps ? args.apps.split(" ") : []; 34 | if(outputDir === undefined || outputDir === "") { 35 | outputDir = path.dirname(manifestRelPath); 36 | } 37 | const params = { 38 | manifest: manifestRelPath, 39 | packageDir: outputDir, 40 | apps: appsList 41 | }; 42 | return this.app.client.executePluginCommand("packagePlugin", params).then(() => { 43 | console.log(`Plugin packaged successfully`); 44 | console.log(`Packaged plugin is available at ${path.resolve(outputDir)}`); 45 | return true; 46 | }).catch((err) => { 47 | console.log(`Plugin package command failed: ${err}`); 48 | return false; 49 | }); 50 | } 51 | 52 | const packageCommand = { 53 | command: "package", 54 | description: "Package the plugin for the target applications", 55 | handler: handlePluginPackageResult, 56 | builder: packageOptions, 57 | }; 58 | 59 | module.exports = packageCommand; 60 | -------------------------------------------------------------------------------- /packages/uxp-devtools-cli/src/cli/commands/plugin/reload.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | */ 13 | 14 | const { loadPluginSessionFromUxpRc } = require("../../utils/Common"); 15 | 16 | const reloadOptions = { 17 | apps: { 18 | describe: "Space delimited list of app IDs into which the plugin should be reloaded. The supported app IDs can be retrieved using `uxp apps list`. The default action is to reload the plugin into all currently running apps specified in the plugin's manifest.", 19 | demandOption: false, 20 | }, 21 | }; 22 | 23 | function handlePluginReloadCommand(args) { 24 | // load the current plugin session from the uxprc file. 25 | const pluginSession = loadPluginSessionFromUxpRc(); 26 | const apps = args.apps ? args.apps.split(" ") : []; 27 | const params = { 28 | apps, 29 | }; 30 | const prom = this.app.client.executePluginCommand("reloadPlugin", pluginSession, params); 31 | return prom.then((res) => { 32 | if (res && !res.breakOnStart) { 33 | console.log("Plugin Reload successfull."); 34 | } 35 | return res; 36 | }); 37 | } 38 | 39 | const reloadCommand = { 40 | command: "reload", 41 | description: "Reloads this plugin in the app. The plugin needs to be already loaded in application", 42 | handler: handlePluginReloadCommand, 43 | builder: reloadOptions, 44 | }; 45 | 46 | module.exports = reloadCommand; 47 | -------------------------------------------------------------------------------- /packages/uxp-devtools-cli/src/cli/commands/plugin/unload.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | */ 13 | 14 | const { loadPluginSessionFromUxpRc } = require("../../utils/Common"); 15 | 16 | const unloadOptions = { 17 | apps: { 18 | describe: "Space delimited list of app IDs from which the plugin should be unloaded. The supported app IDs can be retrieved using uxp apps list. The default action is to unload the plugin from all currently running apps specified in the plugin's manifest.", 19 | demandOption: false, 20 | }, 21 | }; 22 | 23 | function handlePluginUnloadCommand(args) { 24 | // load the current plugin session from the uxprc file. 25 | const pluginSession = loadPluginSessionFromUxpRc(); 26 | const apps = args.apps ? args.apps.split(" ") : []; 27 | const params = { 28 | apps, 29 | }; 30 | const prom = this.app.client.executePluginCommand("unloadPlugin", pluginSession, params); 31 | return prom.then((res) => { 32 | console.log("Plugin Unload Successfull."); 33 | return res; 34 | }); 35 | } 36 | 37 | const unloadCommand = { 38 | command: "unload", 39 | description: "Unloads this plugin in the app. The plugin needs to be already loaded in application", 40 | handler: handlePluginUnloadCommand, 41 | builder: unloadOptions, 42 | }; 43 | 44 | module.exports = unloadCommand; 45 | -------------------------------------------------------------------------------- /packages/uxp-devtools-cli/src/cli/commands/plugin/validate.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | */ 13 | const path = require("path"); 14 | 15 | const validateOptions = { 16 | manifest: { 17 | describe: "Relative path to plugin's manifest.json file. Defaults to the manifest.json file in current working directory.", 18 | demandOption: false, 19 | } 20 | }; 21 | 22 | function handlePluginValidateCommand(args) { 23 | const manifestRelPath = args.manifest ? args.manifest : "manifest.json"; 24 | const manifest = path.resolve(manifestRelPath); 25 | const params = { 26 | manifest, 27 | }; 28 | 29 | const prom = this.app.client.executePluginCommand("validatePluginManifest", params); 30 | return prom.then(() => { 31 | console.log("Manifest is validated successfully."); 32 | return true; 33 | }).catch((err) => { 34 | console.error("Manifest Validation Failed."); 35 | console.error(`${err}`); 36 | return false; 37 | }); 38 | } 39 | 40 | const validateCommand = { 41 | command: "validate", 42 | description: "Validates the plugin manifest.", 43 | handler: handlePluginValidateCommand, 44 | builder: validateOptions, 45 | }; 46 | 47 | module.exports = validateCommand; 48 | -------------------------------------------------------------------------------- /packages/uxp-devtools-cli/src/cli/commands/service/ServiceCmds.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | */ 13 | 14 | const { CoreHelpers } = require("@adobe/uxp-devtools-core"); 15 | 16 | function handleServiceStartCommand(argv) { 17 | // start the service at the given port. 18 | const prom = this.app.server.isDevToolsEnabled(); 19 | const devToolsProm = prom.then((result) => { 20 | if (!result) { 21 | console.log("UXP Developer Tools is not enabled. uxp cli will try to run devtools `enable command` to enable it."); 22 | return this.app.server.enableDevTools(); 23 | } 24 | return result; 25 | }).catch((err) => { 26 | console.error(`Devtools enable command failed with ${err}`); 27 | // silently eat the error so we can. 28 | return false; 29 | }); 30 | return devToolsProm.then((result) => { 31 | if (!result) { 32 | console.log("UXP Developer workflow is not enabled. Please enable it before you start the cli service"); 33 | return false; 34 | } 35 | const { port } = argv; 36 | return CoreHelpers.isPortAvailable(port).then((isAvailable) => { 37 | if (!isAvailable) { 38 | throw new Error(`The port ${port} is occupied. Please try another port or close the application which is using the port and try again.`); 39 | } 40 | return this.app.server.startServer(port); 41 | }); 42 | }); 43 | } 44 | 45 | const startOptions = { 46 | port: { 47 | describe: "The port number for the uxp developer service", 48 | type: "number", 49 | default: 14001, 50 | }, 51 | }; 52 | 53 | const startCommand = { 54 | command: "start", 55 | description: "Starts the UXP Developer service. If UXP Developer Tools support is not currently enabled, this command will also attempt to enable support.", 56 | builder: startOptions, 57 | handler: handleServiceStartCommand, 58 | }; 59 | 60 | // export all service related commands here 61 | module.exports = { 62 | startCommand, 63 | }; 64 | -------------------------------------------------------------------------------- /packages/uxp-devtools-cli/src/cli/commands/service/index.js: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 4 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. You may obtain a copy 6 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software distributed under 9 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 10 | * OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | * 13 | */ 14 | 15 | const { startCommand } = require("./ServiceCmds"); 16 | 17 | function registerServiceSubCommands(yargs) { 18 | return yargs.command(startCommand); 19 | } 20 | 21 | const serviceCommand = { 22 | command: "service ", 23 | description: "Start and stop the UXP Developer service", 24 | builder: registerServiceSubCommands, 25 | }; 26 | 27 | module.exports = serviceCommand; 28 | -------------------------------------------------------------------------------- /packages/uxp-devtools-cli/src/cli/utils/common.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | */ 13 | 14 | 15 | function loadPluginSessionFromUxpRc() { 16 | // eslint-disable-next-line global-require 17 | const { CoreHelpers } = require("@adobe/uxp-devtools-core"); 18 | return CoreHelpers.PluginSession.createFromRcFile(); 19 | } 20 | 21 | function createDeferredPromise() { 22 | const obj = {}; 23 | obj.promise = new Promise((resolve, reject) => { 24 | obj.resolve = resolve; 25 | obj.reject = reject; 26 | }); 27 | return obj; 28 | } 29 | 30 | 31 | module.exports = { 32 | loadPluginSessionFromUxpRc, 33 | createDeferredPromise 34 | }; 35 | -------------------------------------------------------------------------------- /packages/uxp-devtools-cli/src/uxp.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | /* 3 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 4 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. You may obtain a copy 6 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software distributed under 9 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 10 | * OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | * 13 | */ 14 | /* eslint-disable global-require */ 15 | const Tool = require("./cli/utils/Tool"); 16 | const { UDTApplication } = require("@adobe/uxp-devtools-core"); 17 | 18 | const commands = [ 19 | require("./cli/commands/apps/index"), 20 | require("./cli/commands/devtools/index"), 21 | require("./cli/commands/plugin/index"), 22 | require("./cli/commands/service/index"), 23 | // TODO(craj) - disabling init related command - webpack has some issues with this. 24 | // require("./cli/commands/plugin/init"), 25 | ]; 26 | 27 | class UxpDevtoolsCLI { 28 | static run() { 29 | const emptyInitParams = {}; 30 | UDTApplication.createInstance(emptyInitParams); 31 | 32 | const args = process.argv.slice(2); 33 | const tool = new Tool(commands); 34 | tool.run(args); 35 | } 36 | } 37 | 38 | UxpDevtoolsCLI.run(); 39 | -------------------------------------------------------------------------------- /packages/uxp-devtools-core/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@adobe/uxp-devtools-core", 3 | "version": "1.6.0", 4 | "description": "UXP Devtools Core Module", 5 | "main": "src/index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git@github.com:adobe-uxp/devtools-cli.git", 12 | "directory": "packages/uxp-devtools-cli" 13 | }, 14 | "keywords": [ 15 | "adobe", 16 | "uxp", 17 | "devtools", 18 | "plugin", 19 | "core" 20 | ], 21 | "author": "Adobe Inc", 22 | "license": "Apache-2.0", 23 | "dependencies": { 24 | "@adobe/uxp-devtools-helper": "1.6.0", 25 | "chalk": "^3.0.0", 26 | "chokidar": "^3.4.2", 27 | "express": "^4.17.1", 28 | "fancy-log": "^1.3.3", 29 | "fs-extra": "^9.0.0", 30 | "lodash": "^4.17.20", 31 | "isomorphic-ws": "^4.0.1", 32 | "ws": "^7.2.3", 33 | "archiver": "5.3.0", 34 | "ignore-walk": "^3.0.3", 35 | "shell-exec": "^1.0.2" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /packages/uxp-devtools-core/src/core/client/connection/HostAppClient.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | */ 13 | 14 | class HostAppClient { 15 | constructor(data) { 16 | this.id = data.id; 17 | if (!data.app || !data.app.appId || !data.app.appVersion || !data.app.uxpVersion) { 18 | UxpLogger.verbose("HostAppClient: data doesn't contain the required app details in it"); 19 | } 20 | this.appEndPoint = { 21 | id: data.app.appId, 22 | version: data.app.appVersion, 23 | name: data.app.appName, 24 | uxpVersion: data.app.uxpVersion 25 | }; 26 | } 27 | 28 | sendMessageWithReply(connection, message) { 29 | return connection.sendClientMessageWithReply(this, message); 30 | } 31 | } 32 | 33 | module.exports = HostAppClient; 34 | -------------------------------------------------------------------------------- /packages/uxp-devtools-core/src/core/client/plugin/PluginInspectMgr.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable global-require */ 2 | /* eslint-disable max-len */ 3 | /* eslint-disable class-methods-use-this */ 4 | /* 5 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 6 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. You may obtain a copy 8 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software distributed under 11 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 12 | * OF ANY KIND, either express or implied. See the License for the specific language 13 | * governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | const uxpInspectApp = require("@adobe/uxp-inspect-app"); 18 | 19 | class PluginInspectMgr { 20 | static showInspectWindow(details) { 21 | uxpInspectApp("", details.app.id, details.app.version, details.data.wsdebugUrl); 22 | return Promise.resolve(true); 23 | } 24 | } 25 | 26 | module.exports = PluginInspectMgr; 27 | -------------------------------------------------------------------------------- /packages/uxp-devtools-core/src/core/client/plugin/PluginSession.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable class-methods-use-this */ 2 | /* 3 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 4 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. You may obtain a copy 6 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software distributed under 9 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 10 | * OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | * 13 | */ 14 | const _ = require("lodash"); 15 | const UxpRcMgr = require("../../common/UxpRCMgr"); 16 | 17 | class PluginSession { 18 | static createFromRcFile() { 19 | const data = UxpRcMgr.readPluginSession(); 20 | return new PluginSession(data.sessions, data.info); 21 | } 22 | 23 | static createFromLoadResults(loadResults, pluginInfo) { 24 | const sessions = loadResults.map((res) => { 25 | const { app, data } = res; 26 | return { 27 | app, 28 | pluginSessionId: data.pluginSessionId, 29 | }; 30 | }); 31 | return new PluginSession(sessions, pluginInfo); 32 | } 33 | 34 | constructor(sessions, pluginInfo) { 35 | this._sessions = sessions; 36 | this._pluginInfo = pluginInfo || {}; 37 | } 38 | 39 | get sessions() { 40 | return this._sessions; 41 | } 42 | 43 | get pluginInfo() { 44 | return this._pluginInfo; 45 | } 46 | 47 | getSessionForApp(appEndPoint) { 48 | return _.find(this._sessions, (ses) => { 49 | _.isEqual(ses.app, appEndPoint); 50 | }); 51 | } 52 | 53 | commitToRc(uxprcDirPath) { 54 | UxpRcMgr.setUxprcPath(uxprcDirPath); 55 | UxpRcMgr.writePluginSession(this._sessions, this._pluginInfo); 56 | } 57 | } 58 | 59 | module.exports = PluginSession; 60 | -------------------------------------------------------------------------------- /packages/uxp-devtools-core/src/core/client/plugin/actions/PluginDebugCommand.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable max-len */ 2 | /* eslint-disable class-methods-use-this */ 3 | /* 4 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 5 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. You may obtain a copy 7 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under 10 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 11 | * OF ANY KIND, either express or implied. See the License for the specific language 12 | * governing permissions and limitations under the License. 13 | * 14 | */ 15 | 16 | const PluginBaseCommand = require("./PluginBaseCommand"); 17 | 18 | 19 | function createDebugMessage(pluginSessionId) { 20 | const msg = { 21 | command: "Plugin", 22 | action: "debug", 23 | pluginSessionId, 24 | }; 25 | return msg; 26 | } 27 | 28 | class PluginDebugCommand extends PluginBaseCommand { 29 | constructor(pluginMgr, params) { 30 | super(pluginMgr); 31 | this.params = params; 32 | } 33 | 34 | get name() { 35 | return "Debug"; 36 | } 37 | 38 | validateParams() { 39 | this.params = this.params || {}; 40 | this.params.apps = this.params.apps || []; 41 | return Promise.resolve(true); 42 | } 43 | 44 | 45 | executeCommand() { 46 | const resultsCallback = this._handlePluginDebugResult.bind(this); 47 | return this.runCommandOnAllApplicableApps(createDebugMessage, resultsCallback); 48 | } 49 | 50 | _handlePluginDebugResult(commandResults) { 51 | const debugUrls = commandResults.map((result) => { 52 | return { 53 | appInfo: result.app, 54 | cdtDebugWsUrl: result.data.wsdebugUrl, 55 | chromeDevToolsUrl: result.data.chromeDevToolsUrl 56 | }; 57 | }); 58 | return debugUrls; 59 | } 60 | } 61 | 62 | module.exports = PluginDebugCommand; 63 | -------------------------------------------------------------------------------- /packages/uxp-devtools-core/src/core/client/plugin/actions/PluginLogCommand.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable max-len */ 2 | /* eslint-disable class-methods-use-this */ 3 | /* 4 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 5 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. You may obtain a copy 7 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under 10 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 11 | * OF ANY KIND, either express or implied. See the License for the specific language 12 | * governing permissions and limitations under the License. 13 | * 14 | */ 15 | 16 | const PluginBaseCommand = require("./PluginBaseCommand"); 17 | 18 | class PluginLogCommand extends PluginBaseCommand { 19 | constructor(pluginMgr, params) { 20 | super(pluginMgr); 21 | this.params = params; 22 | } 23 | 24 | validateParams() { 25 | this.params = this.params || {}; 26 | this.params.apps = this.params.apps || []; 27 | return Promise.resolve(true); 28 | } 29 | 30 | executeCommand() { 31 | throw new Error("Plugin log command is currently not implemented!"); 32 | } 33 | } 34 | 35 | 36 | module.exports = PluginLogCommand; 37 | -------------------------------------------------------------------------------- /packages/uxp-devtools-core/src/core/client/plugin/actions/PluginReloadCommand.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable max-len */ 2 | /* eslint-disable class-methods-use-this */ 3 | /* 4 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 5 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. You may obtain a copy 7 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under 10 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 11 | * OF ANY KIND, either express or implied. See the License for the specific language 12 | * governing permissions and limitations under the License. 13 | * 14 | */ 15 | 16 | const PluginBaseCommand = require("./PluginBaseCommand"); 17 | 18 | function createReloadMessage(pluginSessionId) { 19 | const msg = { 20 | command: "Plugin", 21 | action: "reload", 22 | pluginSessionId, 23 | }; 24 | return msg; 25 | } 26 | 27 | class PluginReloadCommand extends PluginBaseCommand { 28 | constructor(pluginMgr, params) { 29 | super(pluginMgr); 30 | this.params = params; 31 | } 32 | 33 | get name() { 34 | return "Reload"; 35 | } 36 | 37 | validateParams() { 38 | if (!this.params) { 39 | this.params = { 40 | apps: [], 41 | }; 42 | } 43 | return Promise.resolve(true); 44 | } 45 | 46 | executeCommand() { 47 | const resultsCallback = this._handlePluginReloadResult.bind(this); 48 | return this.runCommandOnAllApplicableApps(createReloadMessage, resultsCallback); 49 | } 50 | 51 | breakOnStartEnabled(result) { 52 | const { data } = result; 53 | return data && data.breakOnStart; 54 | } 55 | 56 | _handlePluginReloadResult() { 57 | return true; 58 | } 59 | } 60 | 61 | 62 | module.exports = PluginReloadCommand; 63 | -------------------------------------------------------------------------------- /packages/uxp-devtools-core/src/core/client/plugin/actions/PluginTestSetupCommand.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe Systems Incorporated. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | */ 13 | 14 | 15 | const path = require("path"); 16 | const chalk = require("chalk"); 17 | const PluginTestBaseCommand = require("./PluginTestBaseCommand"); 18 | 19 | 20 | class PluginTestCommand extends PluginTestBaseCommand { 21 | constructor(pluginMgr, params) { 22 | super(pluginMgr); 23 | this.params = params; 24 | } 25 | 26 | get name() { 27 | return "SetupTest"; 28 | } 29 | 30 | validateParams() { 31 | if (!this.params) { 32 | this.params = { 33 | apps: [], 34 | }; 35 | } 36 | return Promise.resolve(true); 37 | } 38 | 39 | executeCommand() { 40 | const pluginFolder = path.dirname(this.params.manifest); 41 | const packageName = this.params.packageName; 42 | console.log(chalk.green("Setup uxp-plugin-tests files at"), chalk.yellow(process.cwd())); 43 | const prom = this.initWithBundledTest(pluginFolder, packageName); 44 | prom.then(() => { 45 | this.installTestDependency(); 46 | return true; 47 | }).catch(() => { 48 | return false; 49 | }); 50 | } 51 | 52 | } 53 | module.exports = PluginTestCommand; 54 | -------------------------------------------------------------------------------- /packages/uxp-devtools-core/src/core/client/plugin/actions/PluginUnloadCommand.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable max-len */ 2 | /* eslint-disable class-methods-use-this */ 3 | /* 4 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 5 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. You may obtain a copy 7 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under 10 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 11 | * OF ANY KIND, either express or implied. See the License for the specific language 12 | * governing permissions and limitations under the License. 13 | * 14 | */ 15 | 16 | const PluginBaseCommand = require("./PluginBaseCommand"); 17 | 18 | function createUnloadMessage(pluginSessionId) { 19 | const msg = { 20 | command: "Plugin", 21 | action: "unload", 22 | pluginSessionId, 23 | }; 24 | return msg; 25 | } 26 | 27 | class PluginUnloadCommand extends PluginBaseCommand { 28 | constructor(pluginMgr, params) { 29 | super(pluginMgr); 30 | this.params = params; 31 | } 32 | 33 | get name() { 34 | return "Unload"; 35 | } 36 | 37 | validateParams() { 38 | this.params = this.params || {}; 39 | this.params.apps = this.params.apps || []; 40 | return Promise.resolve(true); 41 | } 42 | 43 | executeCommand() { 44 | return this.runCommandOnAllApplicableApps(createUnloadMessage); 45 | } 46 | } 47 | 48 | 49 | module.exports = PluginUnloadCommand; 50 | -------------------------------------------------------------------------------- /packages/uxp-devtools-core/src/core/client/plugin/actions/RefreshListCommand.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable class-methods-use-this */ 2 | /* 3 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 4 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. You may obtain a copy 6 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software distributed under 9 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 10 | * OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | * 13 | */ 14 | 15 | /* eslint-disable max-len */ 16 | const PluginBaseCommand = require("./PluginBaseCommand"); 17 | const DevToolsError = require("../../../common/DevToolsError"); 18 | 19 | function createMessage() { 20 | const msg = { 21 | command: "Plugin", 22 | action: "list" 23 | }; 24 | return msg; 25 | } 26 | 27 | class RefreshListCommand extends PluginBaseCommand { 28 | constructor(pluginMgr) { 29 | super(pluginMgr); 30 | } 31 | 32 | get name() { 33 | return "Refresh List"; 34 | } 35 | 36 | validateParams() { 37 | return Promise.resolve(true); 38 | } 39 | 40 | executeCommand() { 41 | const applicableApps = this.pm._cliClientMgr.getConnectedApps(); 42 | if (!applicableApps.length) { 43 | throw new DevToolsError(DevToolsError.ErrorCodes.NO_APPS_CONNECTED_TO_SERVICE); 44 | } 45 | const loadJsonMsg = createMessage(); 46 | return this._sendMessageToAppsAndReconcileResults(applicableApps, loadJsonMsg, this._handleCommandResult.bind(this)); 47 | } 48 | 49 | _handleCommandResult(pluginResults) { 50 | let pluginSet = []; 51 | for (const pluginResult of pluginResults) { 52 | const { app, data } = pluginResult; 53 | const { plugins } = data; 54 | for (const plugin of plugins) { 55 | const pluginInfo = { 56 | plugin, 57 | app 58 | }; 59 | pluginSet.push(pluginInfo); 60 | } 61 | } 62 | return pluginSet; 63 | } 64 | } 65 | 66 | module.exports = RefreshListCommand; 67 | -------------------------------------------------------------------------------- /packages/uxp-devtools-core/src/core/common/AppsMgr.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | */ 13 | -------------------------------------------------------------------------------- /packages/uxp-devtools-core/src/core/common/CoreHelpers.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable global-require */ 2 | /* 3 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 4 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. You may obtain a copy 6 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software distributed under 9 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 10 | * OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | * 13 | */ 14 | 15 | const { LoggerLevel } = require("../common/Utils"); 16 | const PluginSession = require("../client/plugin/PluginSession"); 17 | const ManifestHelper = require("../helpers/ManifestHelper"); 18 | const WatchServiceMgr = require("../common/WatchServiceMgr"); 19 | 20 | function createDeferredPromise() { 21 | const obj = {}; 22 | obj.promise = new Promise((resolve, reject) => { 23 | obj.resolve = resolve; 24 | obj.reject = reject; 25 | }); 26 | return obj; 27 | } 28 | 29 | function isPortAvailable(port) { 30 | const deferred = createDeferredPromise(); 31 | const net = require("net"); 32 | 33 | const sock = new net.Socket(); 34 | sock.setTimeout(2000); 35 | sock.on("connect", () => { 36 | sock.destroy(); 37 | deferred.resolve(false); 38 | }).on("error", () => { 39 | deferred.resolve(true); 40 | }).on("timeout", () => { 41 | deferred.resolve(true); 42 | }).connect(port, "127.0.0.1"); 43 | 44 | return deferred.promise; 45 | } 46 | 47 | module.exports = { 48 | createDeferredPromise, 49 | isPortAvailable, 50 | PluginSession, 51 | LoggerLevel, 52 | ManifestHelper, 53 | WatchServiceMgr 54 | }; 55 | -------------------------------------------------------------------------------- /packages/uxp-devtools-core/src/core/common/DevToolsError.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 Adobe. All rights reserved. 3 | This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. You may obtain a copy 5 | of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | Unless required by applicable law or agreed to in writing, software distributed under 7 | the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 8 | OF ANY KIND, either express or implied. See the License for the specific language 9 | governing permissions and limitations under the License. 10 | */ 11 | 12 | const { getUserFriendlyMessageFromCode, CoreErrorCodes } = require("./ErrorCodes"); 13 | 14 | function DevToolsError(errorCode, details, message) { 15 | this._message = message; 16 | this._code = errorCode; 17 | this._details = details; 18 | if (Error.captureStackTrace) { 19 | Error.captureStackTrace(this, DevToolsError); 20 | } 21 | else { 22 | try { 23 | throw new Error(); 24 | } 25 | catch (e) { 26 | this._stack = e.stack; 27 | } 28 | } 29 | } 30 | 31 | DevToolsError.prototype = Object.create(Error.prototype); 32 | 33 | Object.defineProperties(DevToolsError.prototype, { 34 | message: { 35 | get() { 36 | const msg = this._message; 37 | if (msg) { 38 | return msg; 39 | } 40 | const preMsg = getUserFriendlyMessageFromCode(this.code); 41 | return preMsg || ""; 42 | } 43 | }, 44 | name: { 45 | get() { 46 | return "DevToolsError"; 47 | } 48 | }, 49 | code: { 50 | get() { 51 | return this._code; 52 | } 53 | }, 54 | stack: { 55 | get() { 56 | return this._stack; 57 | } 58 | }, 59 | details: { 60 | get() { 61 | return this._details; 62 | } 63 | }, 64 | hasDetails: { 65 | get() { 66 | return !!this._details; 67 | } 68 | } 69 | }); 70 | 71 | DevToolsError.ErrorCodes = CoreErrorCodes; 72 | DevToolsError.getUserFriendlyMessageFromCode = getUserFriendlyMessageFromCode; 73 | 74 | module.exports = DevToolsError; 75 | -------------------------------------------------------------------------------- /packages/uxp-devtools-core/src/core/common/DevToolsMgr.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | */ 13 | /* eslint-disable class-methods-use-this */ 14 | const DevToolsHelper = require("@adobe/uxp-devtools-helper"); 15 | 16 | class DevToolsMgr { 17 | constructor(isServer) { 18 | this._devToolsHelper = new DevToolsHelper(isServer); 19 | } 20 | 21 | setServerDetails(port) { 22 | this._devToolsHelper.setServerDetails(port); 23 | } 24 | 25 | getAppsList() { 26 | return Promise.resolve(this._devToolsHelper.getAppsList()); 27 | } 28 | 29 | disableDevTools(options) { 30 | return DevToolsHelper.disableDevTools(options); 31 | } 32 | 33 | enableDevTools(options) { 34 | return DevToolsHelper.enableDevTools(options); 35 | } 36 | 37 | isDevToolsEnabled() { 38 | return DevToolsHelper.isDevToolsEnabled(); 39 | } 40 | 41 | discoverServicePort() { 42 | return this._devToolsHelper.getServicePort(); 43 | } 44 | 45 | terminate() { 46 | this._devToolsHelper.terminate(); 47 | } 48 | } 49 | 50 | module.exports = DevToolsMgr; 51 | -------------------------------------------------------------------------------- /packages/uxp-devtools-core/src/core/common/KillProcess.js: -------------------------------------------------------------------------------- 1 | const sh = require("shell-exec"); 2 | 3 | module.exports = function(port, method = "tcp") { 4 | port = Number.parseInt(port); 5 | 6 | if (!port) { 7 | return Promise.reject(new Error("Invalid argument provided for port")); 8 | } 9 | 10 | if (process.platform === "win32") { 11 | return sh("netstat -nao") 12 | .then(res => { 13 | const { stdout } = res; 14 | if (!stdout) { 15 | return res; 16 | } 17 | 18 | const lines = stdout.split("\n"); 19 | // The second white-space delimited column of netstat output is the local port, 20 | // which is the only port we care about. 21 | // The regex here will match only the local port column of the output 22 | const lineWithLocalPortRegEx = new RegExp(`^ *${method.toUpperCase()} *[^ ]*:${port}`, "gm"); 23 | const linesWithLocalPort = lines.filter(line => line.match(lineWithLocalPortRegEx)); 24 | 25 | const pids = linesWithLocalPort.reduce((acc, line) => { 26 | const match = line.match(/(\d*)\w*(\n|$)/gm); 27 | return match && match[0] && !acc.includes(match[0]) ? acc.concat(match[0]) : acc; 28 | }, []); 29 | 30 | return sh(`TaskKill /F /PID ${pids.join(" /PID ")}`); 31 | }); 32 | } 33 | 34 | return sh( 35 | `lsof -i ${method === "udp" ? "udp" : "tcp"}:${port} | grep ${method === "udp" ? "UDP" : "LISTEN"} | awk '{print $2}' | xargs kill -9` 36 | ); 37 | }; 38 | -------------------------------------------------------------------------------- /packages/uxp-devtools-core/src/core/common/Logger.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-unused-vars */ 2 | /* eslint-disable class-methods-use-this */ 3 | /* 4 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 5 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. You may obtain a copy 7 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under 10 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 11 | * OF ANY KIND, either express or implied. See the License for the specific language 12 | * governing permissions and limitations under the License. 13 | * 14 | */ 15 | 16 | const { LoggerLevel } = require("./Utils"); 17 | 18 | class Logger { 19 | constructor() { 20 | this._level = LoggerLevel.DEFAULT; 21 | this.init(); 22 | } 23 | 24 | init() { 25 | const methods = [ { 26 | name: "error", 27 | level: LoggerLevel.ERROR 28 | },{ 29 | name: "warn", 30 | level: LoggerLevel.WARN 31 | },{ 32 | name: "log", 33 | level: LoggerLevel.INFO 34 | },{ 35 | name: "verbose", 36 | level: LoggerLevel.VERBOSE 37 | } ]; 38 | 39 | for (let i = 0; i < methods.length; ++i) { 40 | const method = methods[i]; 41 | this[method.name] = function(msg) { 42 | if (this._provider) { 43 | this._provider[method.name](msg); 44 | return; 45 | } 46 | if (this._level < method.level) { 47 | return; // log-level severity is more so ignore. 48 | } 49 | const consoleMethodName = method.name == "verbose" ? "log" : method.name; 50 | console[consoleMethodName](msg); 51 | }; 52 | } 53 | } 54 | 55 | get level() { 56 | return this._level; 57 | } 58 | 59 | setProvider(provider) { 60 | this._provider = provider; 61 | } 62 | 63 | set level(level) { 64 | this._level = level; 65 | } 66 | } 67 | 68 | 69 | module.exports = new Logger(); 70 | -------------------------------------------------------------------------------- /packages/uxp-devtools-core/src/core/common/Utils.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | */ 13 | 14 | class LoggerLevel { 15 | 16 | } 17 | 18 | LoggerLevel.ERROR = 1; 19 | LoggerLevel.WARN = 2; // warning and above. 20 | LoggerLevel.INFO = 3; // info and above - 21 | LoggerLevel.VERBOSE = 4; // verbose and above - so, contains verbose, info, warning and errors. 22 | LoggerLevel.DEFAULT = LoggerLevel.VERBOSE; 23 | 24 | module.exports = { 25 | LoggerLevel, 26 | }; 27 | -------------------------------------------------------------------------------- /packages/uxp-devtools-core/src/core/helpers/CommonUtils.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | */ 13 | 14 | function createDeferredPromise() { 15 | const obj = {}; 16 | obj.promise = new Promise((resolve, reject) => { 17 | obj.resolve = resolve; 18 | obj.reject = reject; 19 | }); 20 | return obj; 21 | } 22 | 23 | module.exports = { 24 | createDeferredPromise, 25 | }; 26 | -------------------------------------------------------------------------------- /packages/uxp-devtools-core/src/core/service/ServiceMgr.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | */ 13 | 14 | const Server = require("./Server"); 15 | const { createDeferredPromise } = require("../helpers/CommonUtils"); 16 | 17 | class ServiceMgr { 18 | onServerReady() { 19 | this._serviceDeferredProm.resolve(true); 20 | } 21 | 22 | start(port) { 23 | if (!port) { 24 | Promise.reject(new Error("Invalid port number. Service need a valid port number to start.")); 25 | } 26 | this._serviceDeferredProm = createDeferredPromise(); 27 | try { 28 | this._server = new Server(port); 29 | const onServerReady = this.onServerReady.bind(this); 30 | this._server.on("serverReady", onServerReady); 31 | this._server.run(); 32 | } 33 | catch (err) { 34 | return Promise.reject(err); 35 | } 36 | return this._serviceDeferredProm.promise; 37 | } 38 | 39 | handleAppQuit() { 40 | if (this._server) { 41 | this._server.broadcastEvent("UDTAppQuit"); 42 | } 43 | } 44 | } 45 | 46 | module.exports = ServiceMgr; 47 | -------------------------------------------------------------------------------- /packages/uxp-devtools-core/src/core/udt/HostDelegate.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable class-methods-use-this */ 2 | /* eslint-disable no-unused-vars */ 3 | /* 4 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 5 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. You may obtain a copy 7 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under 10 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 11 | * OF ANY KIND, either express or implied. See the Licrrense for the specific language 12 | * governing permissions and limitations under the License. 13 | * 14 | */ 15 | 16 | // Host which is using this devtools as direct dependency ( instead of say cli ) 17 | // can implement this delegate to listen to some events 18 | 19 | class UxpDevtoolsHostDelegate { 20 | 21 | } 22 | 23 | module.exports = UxpDevtoolsHostDelegate; 24 | -------------------------------------------------------------------------------- /packages/uxp-devtools-core/src/core/udt/UDTApplication.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable class-methods-use-this */ 2 | /* eslint-disable global-require */ 3 | /* 4 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 5 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. You may obtain a copy 7 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under 10 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 11 | * OF ANY KIND, either express or implied. See the License for the specific language 12 | * governing permissions and limitations under the License. 13 | * 14 | */ 15 | 16 | const Logger = require("../common/Logger"); 17 | 18 | const appState = {}; 19 | 20 | function installGlobalLogger(logger) { 21 | if (global.Logger) { 22 | console.error("Global Logger is already initialized. This should not be the case"); 23 | } 24 | global.UxpLogger = logger; 25 | } 26 | 27 | class UxpDevtoolsApplicationImpl { 28 | constructor(initParams) { 29 | appState.servicePort = initParams.servicePort; 30 | let { logger } = initParams; 31 | if (logger) { 32 | Logger.setProvider(logger); 33 | } 34 | installGlobalLogger(Logger); 35 | appState.hostDelegate = initParams.hostDelegate; 36 | } 37 | 38 | set logLevel(level) { 39 | Logger.level = level; 40 | } 41 | 42 | get client() { 43 | if (!appState.client) { 44 | const UxpDevtoolsClient = require("./UDTClient"); 45 | appState.client = new UxpDevtoolsClient(appState.servicePort); 46 | } 47 | return appState.client; 48 | } 49 | 50 | get server() { 51 | if (!appState.server) { 52 | const UxpDevtoolsServer = require("./UDTServer"); 53 | appState.server = new UxpDevtoolsServer(); 54 | } 55 | return appState.server; 56 | } 57 | } 58 | 59 | let sIntializerInstance = null; 60 | 61 | class UxpDevtoolsApplication { 62 | static createInstance(initializerParams) { 63 | if (sIntializerInstance) { 64 | throw new Error("Devtools Initializer instance is already created!"); 65 | } 66 | sIntializerInstance = new UxpDevtoolsApplicationImpl(initializerParams); 67 | } 68 | 69 | static instance() { 70 | return sIntializerInstance; 71 | } 72 | } 73 | 74 | module.exports = UxpDevtoolsApplication; 75 | -------------------------------------------------------------------------------- /packages/uxp-devtools-core/src/core/udt/UDTInitializerParams.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable class-methods-use-this */ 2 | /* 3 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 4 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. You may obtain a copy 6 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software distributed under 9 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 10 | * OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | * 13 | */ 14 | 15 | class UxpDevtoolsInitializerParams { 16 | set servicePort(port) { 17 | this._servicePort = port; 18 | } 19 | 20 | get servicePort() { 21 | return this._servicePort; 22 | } 23 | 24 | set logger(logg) { 25 | this._logger = logg; 26 | } 27 | 28 | get logger() { 29 | return this._logger; 30 | } 31 | 32 | set hostDelegate(delegate) { 33 | this._hostDelegate = delegate; 34 | } 35 | 36 | get hostDelegate() { 37 | return this._hostDelegate; 38 | } 39 | } 40 | 41 | module.exports = UxpDevtoolsInitializerParams; 42 | -------------------------------------------------------------------------------- /packages/uxp-devtools-core/src/core/udt/UDTServer.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | */ 13 | 14 | const ServiceMgr = require("../service/ServiceMgr"); 15 | const DevToolsMgr = require("../common/DevToolsMgr"); 16 | const kill = require("../common/KillProcess"); 17 | 18 | class UxpDevToolsServer { 19 | constructor() { 20 | this._serviceMgr = new ServiceMgr(); 21 | this._devToolsMgr = new DevToolsMgr(true); 22 | } 23 | 24 | enableDevTools(options = null) { 25 | return this._devToolsMgr.enableDevTools(options); 26 | } 27 | 28 | disableDevTools(options = null) { 29 | return this._devToolsMgr.disableDevTools(options).then(() => { 30 | if(options.port) { 31 | return kill(options.port, "tcp"); 32 | } 33 | }); 34 | } 35 | 36 | isServiceRunning() { 37 | const result = { success: false }; 38 | return this._devToolsMgr.discoverServicePort().then((port) => { 39 | result.success = true; 40 | result.port = port; 41 | return result; 42 | }).catch(() => { 43 | return result; 44 | }); 45 | } 46 | 47 | isDevToolsEnabled() { 48 | return this._devToolsMgr.isDevToolsEnabled(); 49 | } 50 | 51 | startServer(port) { 52 | const prom = this._serviceMgr.start(port); 53 | return prom.then(() => { 54 | UxpLogger.log(`UXP Developer Service now running at port ${port}`); 55 | // set the server port details - so that it can be discovered by 56 | // clients via Vulcan Messages. 57 | this.setServerDetails(port); 58 | return true; 59 | }); 60 | } 61 | 62 | handleAppQuit() { 63 | this._serviceMgr.handleAppQuit(); 64 | } 65 | 66 | setServerDetails(port) { 67 | this._devToolsMgr.setServerDetails(port); 68 | } 69 | } 70 | 71 | module.exports = UxpDevToolsServer; 72 | -------------------------------------------------------------------------------- /packages/uxp-devtools-core/src/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | */ 13 | const UDTApplication = require("./core/udt/UDTApplication"); 14 | const CoreHelpers = require("./core/common/CoreHelpers"); 15 | const DevToolsError = require("./core/common/DevToolsError"); 16 | // export the main classes. 17 | // Other classes will be derived from this main class. 18 | module.exports = { 19 | UDTApplication, 20 | CoreHelpers, 21 | DevToolsError 22 | }; 23 | -------------------------------------------------------------------------------- /packages/uxp-devtools-core/startUxpDriver.js: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2021 Adobe Systems Incorporated. All rights reserved. 4 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. You may obtain a copy 6 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software distributed under 9 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 10 | * OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | * 13 | */ 14 | 15 | const { startUXPDriver } = require("@adobe/uxp_web_driver"); 16 | function startTestService() { 17 | try { 18 | const UXPDriverPort = process.argv[2]; 19 | startUXPDriver(UXPDriverPort); 20 | } 21 | catch(err) { 22 | throw new Error(`Error in starting UXP Test Service`); 23 | } 24 | } 25 | 26 | startTestService(); 27 | -------------------------------------------------------------------------------- /packages/uxp-devtools-feature/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@adobe/uxp-devtools-feature", 3 | "version": "1.5.0", 4 | "description": "UXP Devtools Feature Config Module", 5 | "main": "src/index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git@github.com:adobe-uxp/devtools-cli.git", 12 | "directory": "packages/uxp-devtools-feature" 13 | }, 14 | "keywords": [ 15 | "adobe", 16 | "uxp", 17 | "devtools", 18 | "plugin", 19 | "core" 20 | ], 21 | "author": "Adobe Inc", 22 | "license": "Apache-2.0", 23 | "dependencies": { 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /packages/uxp-devtools-feature/src/configs/featureFlag.json: -------------------------------------------------------------------------------- 1 | { 2 | "analytics": true 3 | } -------------------------------------------------------------------------------- /packages/uxp-devtools-feature/src/feature/FeatureFlag.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable global-require */ 2 | /* 3 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 4 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. You may obtain a copy 6 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software distributed under 9 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 10 | * OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | * 13 | */ 14 | let sFeatureConfig = null; 15 | 16 | function getFeatureConfig() { 17 | if(sFeatureConfig != null) { 18 | return sFeatureConfig; 19 | } 20 | 21 | try{ 22 | sFeatureConfig = require("./../configs/featureFlag.json"); 23 | return sFeatureConfig; 24 | } 25 | catch(ex) { 26 | console.log(`Failed to read the feature configuration file.`); 27 | sFeatureConfig = {}; 28 | return sFeatureConfig; 29 | } 30 | } 31 | 32 | function isFeatureEnabled(featureName) { 33 | const featureFlagConfig = getFeatureConfig(); 34 | return !!(featureFlagConfig && featureFlagConfig[featureName]); 35 | } 36 | 37 | module.exports = { 38 | isFeatureEnabled 39 | }; 40 | -------------------------------------------------------------------------------- /packages/uxp-devtools-feature/src/index.js: -------------------------------------------------------------------------------- 1 | const FeatureFlag = require("./feature/FeatureFlag"); 2 | 3 | module.exports = { 4 | FeatureFlag 5 | }; 6 | -------------------------------------------------------------------------------- /packages/uxp-devtools-helper/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@adobe/uxp-devtools-helper", 3 | "version": "1.6.0", 4 | "description": "Adobe Devtools helper package used by uxp cli", 5 | "main": "src/DevToolsHelper.js", 6 | "scripts": { 7 | "install": "node scripts/devtools_setup.js" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git@github.com:adobe-uxp/devtools-cli.git", 12 | "directory": "packages/uxp-devtools-helper" 13 | }, 14 | "keywords": [ 15 | "adobe", 16 | "uxp" 17 | ], 18 | "author": "Adobe Inc", 19 | "license": "Apache-2.0", 20 | "dependencies": { 21 | "fs-extra": "^9.0.0", 22 | "node-gyp-build": "^4.2.3", 23 | "@adobe/uxp-devtools-feature": "^1.0.0", 24 | "tar": "^6.0.1" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /packages/uxp-devtools-helper/scripts/devtools_setup.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-console */ 2 | /* 3 | Copyright 2021 Adobe. All rights reserved. 4 | This file is licensed to you under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. You may obtain a copy 6 | of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software distributed under 8 | the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | OF ANY KIND, either express or implied. See the License for the specific language 10 | governing permissions and limitations under the License. 11 | */ 12 | 13 | const path = require("path"); 14 | const fs = require("fs-extra"); 15 | const process = require("process"); 16 | const tar = require("tar"); 17 | const os = require("os"); 18 | 19 | function extractdevToolsTarLib(tarPath, dest) { 20 | return tar.extract({ 21 | file: tarPath, 22 | cwd: dest, 23 | }); 24 | } 25 | 26 | function setupTargetFolder() { 27 | const destDir = path.resolve(__dirname, "../build/"); 28 | // clean-up the old build artifacts. 29 | if (fs.existsSync(destDir)) { 30 | fs.removeSync(destDir); 31 | } 32 | fs.ensureDirSync(destDir); 33 | return destDir; 34 | } 35 | 36 | function setupDevtoolsNativeAddOn() { 37 | console.log("Setting up Adobe devTools node native add-on library... "); 38 | const arch = os.arch(); 39 | const targetFolder = setupTargetFolder(); 40 | const fileName = arch !== "arm64" ? `DevtoolsHelper-v1.1.0-node-${process.platform}.tar.gz` : `DevtoolsHelper-v1.1.0-node-${process.platform}-arm64.tar.gz`; 41 | const devToolsTarPath = path.resolve(__dirname, `./native-libs/${fileName}`); 42 | const prom = extractdevToolsTarLib(devToolsTarPath, targetFolder); 43 | prom.then(() => { 44 | console.log("Adobe devToolsJS native add-on setup successfull."); 45 | }).catch((err) => { 46 | throw new Error(`Adobe devTools-JS native add-on setup failed with error ${err}`); 47 | }); 48 | } 49 | 50 | setupDevtoolsNativeAddOn(); 51 | -------------------------------------------------------------------------------- /packages/uxp-devtools-helper/scripts/native-libs/DevtoolsHelper-v1.1.0-node-darwin-arm64.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adobe-uxp/devtools-cli/ef7e127b0e234e82b94d94e0c18443f3a738f929/packages/uxp-devtools-helper/scripts/native-libs/DevtoolsHelper-v1.1.0-node-darwin-arm64.tar.gz -------------------------------------------------------------------------------- /packages/uxp-devtools-helper/scripts/native-libs/DevtoolsHelper-v1.1.0-node-darwin.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adobe-uxp/devtools-cli/ef7e127b0e234e82b94d94e0c18443f3a738f929/packages/uxp-devtools-helper/scripts/native-libs/DevtoolsHelper-v1.1.0-node-darwin.tar.gz -------------------------------------------------------------------------------- /packages/uxp-devtools-helper/scripts/native-libs/DevtoolsHelper-v1.1.0-node-win32.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adobe-uxp/devtools-cli/ef7e127b0e234e82b94d94e0c18443f3a738f929/packages/uxp-devtools-helper/scripts/native-libs/DevtoolsHelper-v1.1.0-node-win32.tar.gz -------------------------------------------------------------------------------- /packages/uxp-devtools-helper/src/DevToolNativeLib.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 Adobe. All rights reserved. 3 | This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. You may obtain a copy 5 | of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | Unless required by applicable law or agreed to in writing, software distributed under 7 | the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 8 | OF ANY KIND, either express or implied. See the License for the specific language 9 | governing permissions and limitations under the License. 10 | */ 11 | 12 | const path = require("path"); 13 | 14 | const packageBaseFolder = path.resolve(__dirname, ".."); 15 | const DevToolsNativeLib = require("node-gyp-build")(packageBaseFolder); 16 | 17 | module.exports = DevToolsNativeLib; 18 | -------------------------------------------------------------------------------- /packages/uxp-devtools-helper/src/devtools/command.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 Adobe. All rights reserved. 3 | This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. You may obtain a copy 5 | of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | Unless required by applicable law or agreed to in writing, software distributed under 7 | the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 8 | OF ANY KIND, either express or implied. See the License for the specific language 9 | governing permissions and limitations under the License. 10 | */ 11 | 12 | const path = require("path"); 13 | const fs = require("fs-extra"); 14 | const process = require("process"); 15 | 16 | const args = process.argv.slice(2); 17 | 18 | const isEnable = args[0] === "enable"; 19 | const dirs = args[1].split(";;"); 20 | 21 | const baseDirPath = dirs[0]; 22 | const relativeSettingsPath = dirs[1]; 23 | 24 | function validateParams() { 25 | if (baseDirPath.length > 0 && relativeSettingsPath.length > 0) { 26 | const baseDirExists = fs.existsSync(baseDirPath); 27 | if (baseDirExists) { 28 | return; 29 | } 30 | } 31 | throw new Error(`Devtools Command received invalid params : ${args}`); 32 | } 33 | 34 | function setUxpDeveloperMode() { 35 | validateParams(); 36 | const settingsFilePath = path.resolve(baseDirPath, relativeSettingsPath); 37 | const settingsDir = path.dirname(settingsFilePath); 38 | fs.ensureDirSync(settingsDir); 39 | 40 | // write the settings config to the file. 41 | const configData = { 42 | developer: !!isEnable, 43 | }; 44 | fs.writeFileSync(settingsFilePath, JSON.stringify(configData, null, 4), "utf8"); 45 | } 46 | 47 | setUxpDeveloperMode(); 48 | -------------------------------------------------------------------------------- /packages/uxp-devtools-helper/src/devtools/internal_mac.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Details - first arg is Adobe UXP base Folder, 2nd Arg is the relative folder ( which might need to be created ) 4 | # 3rd arg is the settings files itself where the contents will be written to. 5 | # 4th arg is whether to enable or disable the devtols. 6 | 7 | baseDir="/Library/Application Support/Adobe/UXP" 8 | 9 | # echo "Base dir is $baseDir" 10 | 11 | cd "$baseDir" 12 | 13 | if [ $? -ne 0 ]; then 14 | mkdir -p "$baseDir" 15 | cd "$baseDir" 16 | if [ $? -ne 0 ]; then 17 | echo "Failed to execute the command. Base Directory $baseDir is not present." 18 | exit 1; 19 | fi 20 | fi 21 | 22 | devDir="Developer" 23 | 24 | mkdir -p $devDir 25 | if [ $? -ne 0 ]; then 26 | echo "Failed to create sub-directory $devDir under $baseDir." 27 | exit 1; 28 | fi 29 | 30 | cd $devDir 31 | 32 | cat < settings.json 33 | {"developer" : $1, "hostAppPluginWorkspace" : $1} 34 | EOF 35 | 36 | if [ $? -ne 0 ]; then 37 | echo "Failed to write uxp devtools settings to json file." 38 | exit 1; 39 | fi 40 | -------------------------------------------------------------------------------- /packages/uxp-devtools-helper/src/devtools/internal_win32.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | set commonDir=%CommonProgramFiles% 4 | 5 | set baseDir=%commonDir%\Adobe\UXP 6 | 7 | set uxpDevDir=Developer 8 | 9 | echo baseDir is %baseDir% 10 | 11 | :: Create base dir if it does not exist 12 | IF NOT EXIST "%baseDir%" mkdir "%baseDir%" 13 | 14 | :: Check if the base dir exists 15 | IF NOT EXIST "%baseDir%" exit /B 3 16 | 17 | cd /D %baseDir% 18 | 19 | echo checking for %uxpDevDir% 20 | 21 | IF NOT EXIST %uxpDevDir% mkdir %uxpDevDir% 22 | 23 | :: cd into the Developer folder. 24 | cd %uxpDevDir% 25 | 26 | :: Now create the settings json file 27 | 28 | SET config={"developer": %1, "hostAppPluginWorkspace": %1} 29 | 30 | :: echo config is %config% 31 | 32 | echo %config% > settings.json 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /packages/uxp-devtools-helper/src/devtools/mac.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Details - first arg is Adobe UXP base Folder, 2nd Arg is the relative folder ( which might need to be created ) 4 | # 3rd arg is the settings files itself where the contents will be written to. 5 | # 4th arg is whether to enable or disable the devtols. 6 | 7 | baseDir="/Library/Application Support/Adobe/UXP" 8 | 9 | # echo "Base dir is $baseDir" 10 | 11 | cd "$baseDir" 12 | 13 | if [ $? -ne 0 ]; then 14 | mkdir -p "$baseDir" 15 | cd "$baseDir" 16 | if [ $? -ne 0 ]; then 17 | echo "Failed to execute the command. Base Directory $baseDir is not present." 18 | exit 1; 19 | fi 20 | fi 21 | 22 | devDir="Developer" 23 | 24 | mkdir -p $devDir 25 | if [ $? -ne 0 ]; then 26 | echo "Failed to create sub-directory $devDir under $baseDir." 27 | exit 1; 28 | fi 29 | 30 | cd $devDir 31 | 32 | cat < settings.json 33 | {"developer" : $1} 34 | EOF 35 | 36 | if [ $? -ne 0 ]; then 37 | echo "Failed to write uxp devtools settings to json file." 38 | exit 1; 39 | fi 40 | -------------------------------------------------------------------------------- /packages/uxp-devtools-helper/src/devtools/win32.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | set commonDir=%CommonProgramFiles% 4 | 5 | set baseDir=%commonDir%\Adobe\UXP 6 | 7 | set uxpDevDir=Developer 8 | 9 | echo baseDir is %baseDir% 10 | 11 | :: Create base dir if it does not exist 12 | IF NOT EXIST "%baseDir%" mkdir "%baseDir%" 13 | 14 | :: Check if the base dir exists 15 | IF NOT EXIST "%baseDir%" exit /B 3 16 | 17 | cd /D %baseDir% 18 | 19 | echo checking for %uxpDevDir% 20 | 21 | IF NOT EXIST %uxpDevDir% mkdir %uxpDevDir% 22 | 23 | :: cd into the Developer folder. 24 | cd %uxpDevDir% 25 | 26 | :: Now create the settings json file 27 | 28 | SET config={"developer": %1} 29 | 30 | :: echo config is %config% 31 | 32 | echo %config% > settings.json 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /packages/uxp-inspect-frontend/.gitignore: -------------------------------------------------------------------------------- 1 | front_end -------------------------------------------------------------------------------- /packages/uxp-inspect-frontend/README.md: -------------------------------------------------------------------------------- 1 | ## Overview 2 | 3 | Package for custom devtools-frontend inspect App 4 | 5 | ### `front_end.tar.gz` 6 | -------------------------------------------------------------------------------- /packages/uxp-inspect-frontend/main/devtools/CDTCommonUtils.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 Adobe. All rights reserved. 3 | This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. You may obtain a copy 5 | of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | Unless required by applicable law or agreed to in writing, software distributed under 7 | the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 8 | OF ANY KIND, either express or implied. See the License for the specific language 9 | governing permissions and limitations under the License. 10 | */ 11 | 12 | const path = require("path"); 13 | const url = require("url"); 14 | 15 | function getChromeInspectorBaseUrl() { 16 | const cdtPage = "front_end/devtools_app.html"; 17 | const inspectorPage = path.join(path.resolve(__dirname, ".."), cdtPage); 18 | return inspectorPage; 19 | 20 | } 21 | 22 | const encodeChar = (c) => "%" + c.charCodeAt(0).toString(16); 23 | 24 | function getCompleteInspectorUrlWithTitle(cdtDebugWsUrl, details) { 25 | const inspectorPage = getChromeInspectorBaseUrl(); 26 | const inspectorUrl = url.pathToFileURL(inspectorPage); 27 | // Handling special chars here in the URL due to a bug in devtools-frontend due to which 28 | // icons are missing, see (https://jira.corp.adobe.com/browse/UXP-18095). 29 | // This bug is now fixed in the devtools-frontend, 30 | // see (https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3035144). 31 | // The handling done here is temporary and will be removed once CDT front_end is upgraded. 32 | inspectorUrl.pathname = inspectorUrl.pathname 33 | .replace(/[;,:?@&=+$\^!~'()]/g, encodeChar); 34 | const wsUrlStartIndex = 3; // web socket url is of the form "ws=" 35 | inspectorUrl.searchParams.append( 36 | "ws", 37 | cdtDebugWsUrl.substring(wsUrlStartIndex) 38 | ); 39 | 40 | const uxpWindowTitle = `${details.plugin.name} - ${details.app.name} v${details.app.version} (${details.consoleOnly ? "Logs" : "Debug"})`; 41 | inspectorUrl.searchParams.append("uxp_window_title", uxpWindowTitle); 42 | inspectorUrl.searchParams.append( 43 | "uxp_window_type", 44 | `${details.consoleOnly ? "console" : "debug"}` 45 | ); 46 | inspectorUrl.searchParams.append( 47 | "memory_tab", 48 | false 49 | ); 50 | inspectorUrl.searchParams.append( 51 | "protocol_monitor", 52 | false 53 | ); 54 | return inspectorUrl.toString(); 55 | } 56 | 57 | module.exports = { 58 | getCompleteInspectorUrlWithTitle 59 | }; 60 | 61 | -------------------------------------------------------------------------------- /packages/uxp-inspect-frontend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@adobe/uxp-inspect-frontend", 3 | "productName": "Adobe UXP Developer Tool", 4 | "appMenuName": "Adobe UXP Developer Tool", 5 | "version": "1.6.1", 6 | "main": "main/index.js", 7 | "repository": { 8 | "type": "git", 9 | "url": "git@github.com:adobe-uxp/devtools-cli.git", 10 | "directory": "packages/uxp-inspect-frontend" 11 | }, 12 | "author": "Adobe Inc", 13 | "license": "Apache-2.0", 14 | "scripts": { 15 | "cleanup": "rimraf dist/", 16 | "package": "electron-builder --dir --x64", 17 | "package-arm64": "electron-builder --dir --arm64", 18 | "postinstall": "node scripts/setup.js" 19 | }, 20 | "build": { 21 | "productName": "Adobe UXP Developer Tool", 22 | "removePackageScripts": "false", 23 | "appId": "com.adobe.uxp.inspect.app", 24 | "files": [ 25 | "main/", 26 | "src/" 27 | ], 28 | "mac": { 29 | "target": "dir", 30 | "icon": "resources/icons/app/icon.icns", 31 | "category": "public.app-category.developer-tools", 32 | "identity": null 33 | }, 34 | "win": { 35 | "target": "dir", 36 | "icon": "resources/icons/app/icon.ico", 37 | "signAndEditExecutable": true 38 | }, 39 | "directories": { 40 | "buildResources": "resources" 41 | }, 42 | "publish": null, 43 | "npmRebuild": true 44 | }, 45 | "devDependencies": { 46 | "electron": "23.0.0", 47 | "electron-builder": "23.6.0", 48 | "rimraf": "^3.0.2" 49 | }, 50 | "dependencies": { 51 | "tar": "^6.0.1", 52 | "@babel/plugin-proposal-decorators": "^7.10.5", 53 | "fs-extra": "^9.0.1", 54 | "minimist": "^1.2.5" 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /packages/uxp-inspect-frontend/resources/icons/app/icon.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adobe-uxp/devtools-cli/ef7e127b0e234e82b94d94e0c18443f3a738f929/packages/uxp-inspect-frontend/resources/icons/app/icon.icns -------------------------------------------------------------------------------- /packages/uxp-inspect-frontend/resources/icons/app/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adobe-uxp/devtools-cli/ef7e127b0e234e82b94d94e0c18443f3a738f929/packages/uxp-inspect-frontend/resources/icons/app/icon.ico -------------------------------------------------------------------------------- /packages/uxp-inspect-frontend/resources/icons/app/icon_folder.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adobe-uxp/devtools-cli/ef7e127b0e234e82b94d94e0c18443f3a738f929/packages/uxp-inspect-frontend/resources/icons/app/icon_folder.icns -------------------------------------------------------------------------------- /packages/uxp-inspect-frontend/resources/icons/app/icon_folder.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adobe-uxp/devtools-cli/ef7e127b0e234e82b94d94e0c18443f3a738f929/packages/uxp-inspect-frontend/resources/icons/app/icon_folder.ico -------------------------------------------------------------------------------- /packages/uxp-inspect-frontend/resources/icons/app/icon_pkg.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adobe-uxp/devtools-cli/ef7e127b0e234e82b94d94e0c18443f3a738f929/packages/uxp-inspect-frontend/resources/icons/app/icon_pkg.icns -------------------------------------------------------------------------------- /packages/uxp-inspect-frontend/resources/icons/app/icon_pkg.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adobe-uxp/devtools-cli/ef7e127b0e234e82b94d94e0c18443f3a738f929/packages/uxp-inspect-frontend/resources/icons/app/icon_pkg.ico -------------------------------------------------------------------------------- /packages/uxp-inspect-frontend/resources/icons/installer/uxpdevelopertools_appicons_generalsizes.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adobe-uxp/devtools-cli/ef7e127b0e234e82b94d94e0c18443f3a738f929/packages/uxp-inspect-frontend/resources/icons/installer/uxpdevelopertools_appicons_generalsizes.zip -------------------------------------------------------------------------------- /packages/uxp-inspect-frontend/scripts/front_end.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adobe-uxp/devtools-cli/ef7e127b0e234e82b94d94e0c18443f3a738f929/packages/uxp-inspect-frontend/scripts/front_end.tar.gz -------------------------------------------------------------------------------- /packages/uxp-inspect-frontend/scripts/setup.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | */ 13 | 14 | const path = require("path"); 15 | const fs = require("fs-extra"); 16 | const tar = require("tar"); 17 | 18 | function extractTarLib(tarPath, destDir) { 19 | return tar.extract({ 20 | file: tarPath, 21 | cwd: destDir 22 | }); 23 | } 24 | 25 | function setupFrontEnd() { 26 | try { 27 | console.log("Started setting up the UXP Inspect App."); 28 | const tarFileName = path.join(__dirname, "front_end.tar.gz"); 29 | const destDir = path.join(__dirname, "..", "main"); 30 | const fileName = path.join(destDir, "front_end"); 31 | if (fs.existsSync(fileName)) { 32 | console.log("removing existing files"); 33 | fs.removeSync(fileName, { recursive: true }); 34 | } 35 | console.log("extracting", tarFileName, "to", destDir); 36 | extractTarLib(tarFileName, destDir); 37 | console.log("setting up of inspect frontend done"); 38 | } 39 | catch (err) { 40 | console.log("error while setting up inspect frontend", err); 41 | } 42 | } 43 | 44 | 45 | setupFrontEnd(); 46 | -------------------------------------------------------------------------------- /packages/uxp-inspect-frontend/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |
Adobe UXP Developer Tool
8 | 9 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-default-starter-ps/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | Creating empty index file to resolve the file path. 3 | */ 4 | 5 | const templateModule = { 6 | // packageDir should always have the '__dirname' as its value. 7 | // the UXP Plugin initializatin command will look for directory with name "template" in this directory. 8 | "packageDir": __dirname 9 | } 10 | 11 | module.exports = templateModule; -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-default-starter-ps/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@adobe/uxp-template-default-starter-ps", 3 | "version": "1.0.0", 4 | "description": "Default template for creating Adobe UXP based photoshop plugin.", 5 | "main": "index.js", 6 | "repository": { 7 | "type": "git", 8 | "url": "git@github.com:adobe-uxp/devtools-cli.git", 9 | "directory": "packages/uxp-templates-pack" 10 | }, 11 | "keywords": [ 12 | "adobe", 13 | "uxp", 14 | "starter" 15 | ], 16 | "author": "Adobe Inc", 17 | "license": "Apache-2.0", 18 | "files": [ 19 | "template.json", 20 | "template" 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-default-starter-ps/template.json: -------------------------------------------------------------------------------- 1 | { 2 | "package": { 3 | "dependencies" : { 4 | } 5 | }, 6 | "devtools": { 7 | 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-default-starter-ps/template/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 11 | 12 |

Hello world

13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-default-starter-ps/template/index.js: -------------------------------------------------------------------------------- 1 | function changeColor(){ 2 | if(document.body.style.color == "red"){ 3 | document.body.style.color = "black"; 4 | } 5 | else { 6 | document.body.style.color = "red"; 7 | } 8 | } 9 | 10 | document.getElementById("change_color").addEventListener("click", changeColor); 11 | 12 | 13 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-default-starter-ps/template/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "com.adobe.sample", 3 | "name": "Sample plugin", 4 | "version": "1.0", 5 | "host": [ 6 | { 7 | "app": "PS", 8 | "minVersion": "22.0.0" 9 | } 10 | ], 11 | "main": "index.html", 12 | "manifestVersion": 4, 13 | "entrypoints": [ 14 | { 15 | "type": "panel", 16 | "id": "vanilla", 17 | "label": { 18 | "default": "My Network panel", 19 | "en-US": "My Network panel", 20 | "es-ES": "My Network panel" 21 | }, 22 | "minimumSize": { 23 | "width": 120, 24 | "height": 140 25 | }, 26 | "maximumSize": { 27 | "width": 1200, 28 | "height": 10000 29 | }, 30 | "preferredDockedSize": { 31 | "width": 150, 32 | "height": 200 33 | }, 34 | "preferredFloatingSize": { 35 | "width": 300, 36 | "height": 200 37 | }, 38 | "commands": [ 39 | { 40 | "id": "show_alert", 41 | "label": { 42 | "default": "Show Alert", 43 | "en-US": "Show Alert (US)", 44 | "es-ES": "Show Alert (ES)" 45 | } 46 | } 47 | ], 48 | "icons": [ 49 | { "width": 32, "height": 32, "path": "icons/icon_D.png", "scale": [ 1, 2 ], "theme": [ "dark", "darkest" ], "species": [ "generic" ] }, 50 | { "width": 32, "height": 32, "path": "icons/icon_N.png", "scale": [ 1, 2 ], "theme": [ "lightest", "light" ], "species": [ "generic" ] } 51 | ] 52 | } 53 | ], 54 | "icons": [ 55 | { "width": 32, "height": 32, "path": "icons/icon_D.png", "scale": [ 1, 2 ], "theme": [ "dark", "darkest" ], "species": [ "generic" ] }, 56 | { "width": 32, "height": 32, "path": "icons/icon_N.png", "scale": [ 1, 2 ], "theme": [ "lightest", "light" ], "species": [ "generic" ] } 57 | ] 58 | } 59 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-default-starter-ps/template/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "uxp-template-default-starter", 3 | "version": "1.0.0", 4 | "description": "Default template for creating Adobe UXP based photoshop plugin." 5 | } 6 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-default-starter-ps/template/uxp-plugin-tests/sample-tests/page-objects/homepage.js: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2021 Adobe Systems Incorporated. All rights reserved. 4 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. You may obtain a copy 6 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software distributed under 9 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 10 | * OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | * 13 | */ 14 | 15 | /** 16 | * Home page containing specific selectors and methods for a specific page 17 | */ 18 | class HomePage { 19 | /** 20 | * define selectors using getter methods 21 | */ 22 | get ChangeColorButton () { return $('#change_color') } 23 | get SampleText () { return $('#sampleText')} 24 | /** 25 | * a method to encapsule automation code to interact with the page 26 | * e.g. to click on change color button 27 | */ 28 | async click() { 29 | await (await this.ChangeColorButton).click(); 30 | } 31 | } 32 | 33 | module.exports = new HomePage(); -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-default-starter-ps/template/uxp-plugin-tests/sample-tests/specs/ChangeColorTest.js: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2021 Adobe Systems Incorporated. All rights reserved. 4 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. You may obtain a copy 6 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software distributed under 9 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 10 | * OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | * 13 | */ 14 | 15 | const HomePage = require('../page-objects/homepage.js'); 16 | 17 | describe('Click on Change Color Button', () => { 18 | it('should click on Change Color Button', async () => { 19 | await HomePage.click(); 20 | const color = await browser.execute(() => { 21 | const bodyColor = document.body.style.color; 22 | return bodyColor; 23 | }); 24 | expect(color).toStrictEqual("red"); 25 | }); 26 | }); 27 | 28 | 29 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-default-starter-xd/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | Creating empty index file to resolve the file path. 3 | */ 4 | 5 | const templateModule = { 6 | 7 | "devtools": { 8 | }, 9 | // full path to the folder containing the actual uxp plugin project. 10 | "packageDir": __dirname 11 | } 12 | 13 | module.exports = templateModule; -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-default-starter-xd/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@adobe/uxp-template-default-starter-xd", 3 | "version": "1.0.0", 4 | "description": "Starter template for creating Adobe UXP based XD plugin.", 5 | "main": "index.js", 6 | "repository": { 7 | "type": "git", 8 | "url": "git@github.com:adobe-uxp/devtools-cli.git", 9 | "directory": "packages/uxp-templates-pack" 10 | }, 11 | "keywords": [ 12 | "adobe", 13 | "uxp" 14 | ], 15 | "author": "Adobe Inc", 16 | "license": "Apache-2.0", 17 | "files": [ 18 | "template.json", 19 | "template" 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-default-starter-xd/template/README.md: -------------------------------------------------------------------------------- 1 | # Getting started 2 | 3 | This sample simply creates a rectangle object and inserts it into the artboard. 4 | [Read the step-by-step guide for this sample](https://adobexdplatform.com/plugin-docs/tutorials/quick-start/). 5 | 6 | ## Usage 7 | 8 | 1. Run "Plugins > Create Rectangle" 9 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-default-starter-xd/template/images/icon@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adobe-uxp/devtools-cli/ef7e127b0e234e82b94d94e0c18443f3a738f929/packages/uxp-templates-pack/uxp-template-default-starter-xd/template/images/icon@1x.png -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-default-starter-xd/template/images/icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adobe-uxp/devtools-cli/ef7e127b0e234e82b94d94e0c18443f3a738f929/packages/uxp-templates-pack/uxp-template-default-starter-xd/template/images/icon@2x.png -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-default-starter-xd/template/images/icon@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adobe-uxp/devtools-cli/ef7e127b0e234e82b94d94e0c18443f3a738f929/packages/uxp-templates-pack/uxp-template-default-starter-xd/template/images/icon@3x.png -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-default-starter-xd/template/images/icon@4x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adobe-uxp/devtools-cli/ef7e127b0e234e82b94d94e0c18443f3a738f929/packages/uxp-templates-pack/uxp-template-default-starter-xd/template/images/icon@4x.png -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-default-starter-xd/template/images/icon@5x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adobe-uxp/devtools-cli/ef7e127b0e234e82b94d94e0c18443f3a738f929/packages/uxp-templates-pack/uxp-template-default-starter-xd/template/images/icon@5x.png -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-default-starter-xd/template/main.js: -------------------------------------------------------------------------------- 1 | const {Rectangle, Color} = require("scenegraph"); 2 | 3 | function rectangleHandlerFunction(selection) { 4 | 5 | const newElement = new Rectangle(); 6 | newElement.width = 100; 7 | newElement.height = 50; 8 | newElement.fill = new Color("Purple"); 9 | 10 | selection.insertionParent.addChild(newElement); 11 | newElement.moveInParentCoordinates(100, 100); 12 | 13 | } 14 | 15 | module.exports = { 16 | commands: { 17 | createRectangle: rectangleHandlerFunction 18 | } 19 | }; -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-default-starter-xd/template/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "QUICK_START", 3 | "name": "Hello World sample plugin", 4 | "host": { 5 | "app": "XD", 6 | "minVersion": "13.0" 7 | }, 8 | "version": "1.0.0", 9 | "icons": [ 10 | { 11 | "width": 24, 12 | "height": 24, 13 | "path": "images/icon@1x.png" 14 | }, 15 | { 16 | "width": 48, 17 | "height": 48, 18 | "path": "images/icon@2x.png" 19 | } 20 | ], 21 | "uiEntryPoints": [ 22 | { 23 | "type": "menu", 24 | "label": "Create Rectangle", 25 | "commandId": "createRectangle" 26 | } 27 | ] 28 | } -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-default-starter/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | Creating empty index file to resolve the file path. 3 | */ 4 | 5 | const templateModule = { 6 | // packageDir should always have the '__dirname' as its value. 7 | // the UXP Plugin initializatin command will look for directory with name "template" in this directory. 8 | "packageDir": __dirname 9 | } 10 | 11 | module.exports = templateModule; -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-default-starter/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@adobe/uxp-template-default-starter", 3 | "version": "1.0.0", 4 | "description": "Default starter template for creating Adobe UXP based multiple hosts plugin.", 5 | "main": "index.js", 6 | "repository": { 7 | "type": "git", 8 | "url": "git@github.com:adobe-uxp/devtools-cli.git", 9 | "directory": "packages/uxp-templates-pack" 10 | }, 11 | "keywords": [ 12 | "adobe", 13 | "uxp", 14 | "starter" 15 | ], 16 | "author": "Adobe Inc", 17 | "license": "Apache-2.0", 18 | "files": [ 19 | "template.json", 20 | "template" 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-default-starter/template/index.js: -------------------------------------------------------------------------------- 1 | 2 | let panel; 3 | let statusDialog; 4 | 5 | function create() { 6 | const HTML = 7 | ` 30 |
31 |
32 | 36 |

Plugin Div

37 |
38 |
39 |
40 |
41 | ` 42 | function submitFunction() { 43 | statusDialog = document.createElement("dialog"); 44 | const html = ` 45 |
46 | Submitted successfully! 47 |
48 |
49 | `; 50 | statusDialog.innerHTML = html; 51 | document.appendChild(statusDialog); 52 | return statusDialog.showModal(); 53 | } 54 | 55 | panel = document.createElement("div"); 56 | panel.innerHTML = HTML; 57 | panel.querySelector("form").addEventListener("submit", submitFunction); 58 | return panel; 59 | } 60 | 61 | function show(event) { 62 | event.node.appendChild(create()); 63 | } 64 | 65 | function update() { 66 | let form = document.querySelector("form"); 67 | let warning = document.querySelector("#warning"); 68 | form.className = "show"; 69 | warning.className = "hide"; 70 | } 71 | 72 | 73 | module.exports = { 74 | panels: { 75 | samplePlugin: { 76 | show, 77 | update 78 | } 79 | } 80 | }; 81 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-default-starter/template/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "com.adobe.multihostPlugin", 3 | "name": "Multi Host plugin", 4 | "version": "1.0", 5 | "main": "index.js", 6 | "host": [ 7 | { 8 | "app": "PS", 9 | "minVersion": "21.0.0" 10 | }, 11 | { 12 | "app": "XD", 13 | "minVersion": "35.0.0" 14 | } 15 | ], 16 | "manifestVersion": 4, 17 | "entrypoints": [ 18 | { 19 | "type": "panel", 20 | "id": "samplePlugin", 21 | "panelId": "samplePlugin", 22 | "label": { 23 | "default": "Default Plugin", 24 | "en-US": "Default Plugin", 25 | "es-ES": "Default Plugin" 26 | }, 27 | "minimumSize": { 28 | "width": 120, 29 | "height": 140 30 | }, 31 | "maximumSize": { 32 | "width": 1200, 33 | "height": 10000 34 | }, 35 | "preferredDockedSize": { 36 | "width": 150, 37 | "height": 200 38 | }, 39 | "preferredFloatingSize": { 40 | "width": 300, 41 | "height": 200 42 | }, 43 | "commands": [ 44 | { 45 | "id": "show_alert", 46 | "label": { 47 | "default": "Show Alert", 48 | "en-US": "Show Alert (US)", 49 | "es-ES": "Show Alert (ES)" 50 | } 51 | } 52 | ], 53 | "icons": [ 54 | { "width": 32, "height": 32, "path": "icons/icon_D.png", "scale": [ 1, 2 ], "theme": [ "dark", "darkest" ], "species": [ "generic" ] }, 55 | { "width": 32, "height": 32, "path": "icons/icon_N.png", "scale": [ 1, 2 ], "theme": [ "lightest", "light" ], "species": [ "generic" ] } 56 | ] 57 | } 58 | ], 59 | "icons": [ 60 | { "width": 32, "height": 32, "path": "icons/icon_D.png", "scale": [ 1, 2 ], "theme": [ "dark", "darkest" ], "species": [ "generic" ] }, 61 | { "width": 32, "height": 32, "path": "icons/icon_N.png", "scale": [ 1, 2 ], "theme": [ "lightest", "light" ], "species": [ "generic" ] } 62 | ] 63 | } 64 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-default-starter/template/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@adobe/uxp-template-default-starter", 3 | "version": "1.0.0", 4 | "description": "Default starter template for creating Adobe UXP based multiple hosts plugin.", 5 | "main": "index.js", 6 | "repository": { 7 | "type": "git", 8 | "url": "git@github.com:adobe-uxp/devtools-cli.git", 9 | "directory": "packages/uxp-templates-pack" 10 | }, 11 | "keywords": [ 12 | "adobe", 13 | "uxp", 14 | "starter" 15 | ], 16 | "author": "Adobe Inc", 17 | "license": "Apache-2.0", 18 | "files": [ 19 | "template.json", 20 | "template" 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-starter/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | *.lcov 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (https://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # TypeScript v1 declaration files 45 | typings/ 46 | 47 | # TypeScript cache 48 | *.tsbuildinfo 49 | 50 | # Optional npm cache directory 51 | .npm 52 | 53 | # Optional eslint cache 54 | .eslintcache 55 | 56 | # Microbundle cache 57 | .rpt2_cache/ 58 | .rts2_cache_cjs/ 59 | .rts2_cache_es/ 60 | .rts2_cache_umd/ 61 | 62 | # Optional REPL history 63 | .node_repl_history 64 | 65 | # Output of 'npm pack' 66 | *.tgz 67 | 68 | # Yarn Integrity file 69 | .yarn-integrity 70 | 71 | # dotenv environment variables file 72 | .env 73 | .env.test 74 | 75 | # parcel-bundler cache (https://parceljs.org/) 76 | .cache 77 | 78 | # Next.js build output 79 | .next 80 | 81 | # Nuxt.js build / generate output 82 | .nuxt 83 | dist 84 | 85 | # Gatsby files 86 | .cache/ 87 | # Comment in the public line in if your project uses Gatsby and *not* Next.js 88 | # https://nextjs.org/blog/next-9-1#public-directory-support 89 | # public 90 | 91 | # vuepress build output 92 | .vuepress/dist 93 | 94 | # Serverless directories 95 | .serverless/ 96 | 97 | # FuseBox cache 98 | .fusebox/ 99 | 100 | # DynamoDB Local files 101 | .dynamodb/ 102 | 103 | # TernJS port file 104 | .tern-port 105 | 106 | ## uxp 107 | dist/ 108 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-starter/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | Creating empty index file to resolve the file path. 3 | */ 4 | 5 | const templateModule = { 6 | "devtools": { 7 | // manifestPath should point to manifest json location relative to the 'template' folder. 8 | // if this is not specified - then this defaults to "manifest.json" directly within 'template' folder. 9 | "manifestPath" : "plugin/manifest.json", 10 | // buildDir is advanced option - this is the final build directory of the plugin. 11 | // This is the folder which gets loaded into the Host application and parsed by UXP System. 12 | // The manifest.json file will be read from this directory - this folder can be mapped ( viewed as ) to your plugin's final distribuation folder. 13 | // this option can be used for projects like react, typescript - where the source files are webpacked and final JS file is generated in 14 | // a separate build folder - typically 'dist'. So, developers can use this option to override the Devtools default behaviour and ask it to pick / watch this build directory. 15 | // this should be again relative to the 'template'. 16 | // If not present, this defaults to same directory as 'manifestPath' file. 17 | "buildDir": "dist" 18 | }, 19 | // packageDir should always have the '__dirname' as its value. 20 | // the UXP Plugin initializatin command will look for directory with name "template" in this directory. 21 | "packageDir": __dirname 22 | } 23 | 24 | module.exports = templateModule; -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-starter/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@adobe/uxp-template-ps-react-starter", 3 | "version": "1.0.0", 4 | "description": "React starter template for creating Adobe UXP based photoshop plugin.", 5 | "main": "index.js", 6 | "repository": { 7 | "type": "git", 8 | "url": "git@github.com:adobe-uxp/devtools-cli.git", 9 | "directory": "packages/uxp-templates-pack" 10 | }, 11 | "uxp": { 12 | "manifestPath" : "template/manifest.json", 13 | "buildDir" : "dist" 14 | }, 15 | "keywords": [ 16 | "adobe", 17 | "uxp", 18 | "ps-react-starter" 19 | ], 20 | "author": "Adobe Inc", 21 | "license": "Apache-2.0", 22 | "files": [ 23 | "template.json", 24 | "template" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-starter/template.json: -------------------------------------------------------------------------------- 1 | { 2 | "package": { 3 | "dependencies" : { 4 | } 5 | }, 6 | "devtools": { 7 | 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-starter/template/README.md: -------------------------------------------------------------------------------- 1 | # React Starter Plugin 2 | 3 | This plugin is a good place to get started when building a Photoshop plugin using React. It comes defined with all the dependencies that you'll need to get started. As this is a React project, you'll need to do some initial configuration before this will be usable in Photoshop. 4 | 5 | ## Install dependencies 6 | 7 | First, make sure that `npm` is installed on your system. 8 | 9 | After you ensure that your terminal is in the root of this project, use `npm` to install the various dependencies needed: 10 | 11 | ``` 12 | npm install 13 | ``` 14 | 15 | If you prefer to use `yarn`, after you generate the `package-lock.json` file you can run the following line to import dependencies to a `yarn.lock` file: 16 | 17 | ``` 18 | yarn import 19 | ``` 20 | 21 | ## Build Process 22 | 23 | There are two ways to build the plugin for use in Photoshop: 24 | 25 | * `yarn watch` (or `npm watch`) will build a development version of the plugin, and recompile everytime you make a change to the source files. The result is placed in `dist` folder. 26 | * `yarn build` (or `npm build`) will build a production version of the plugin and place it in `dist` folder. It will not update every time you make a change to the source files. 27 | 28 | > You **must** run either `watch` or `build` prior to trying to use within Photoshop! 29 | 30 | ## Launching in Photoshop 31 | 32 | You can use the UXP Developer Tools to load the plugin into Photoshop. 33 | 34 | If the plugin hasn't already been added to your workspace in the UXP Developer Tools, you can add it by clicking "Add Plugin...". You can either add the `dist` folder or the `plugin` folder - if you add the plugin folder - then you need to set the relative path to build folder ( 'dist' ) in the Plugin's Load Option. 35 | 36 | Once added, you can load it into Photoshop by clicking the ••• button on the corresponding row, and clicking "Load". Switch to Photoshop and you should see the starter panels. 37 | 38 | ## What this plugin does 39 | 40 | This plugin doesn't do much, but does illustrate how to create two panels in Photoshop with `entrypoints.setup`, and how to create flyout menus. It also demonstrates the use of several Spectrum UXP widgets to create a simple color picker in the primary panel. 41 | 42 | ### Common Issues 43 | 44 | If you're getting errors with `npm install`, we can reinstall the project dependencies. Let's first make sure to delete `node_modules/*` from the `template` folder as well as the `package-lock.json` and `yarn.lock` file. Staying in the `template` directory, run `npm install` again and this will regenerate your `package-lock.json` file. -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-starter/template/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.adobe.uxp.starter.react", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "preinstall": "npx npm-force-resolutions", 6 | "watch": "nodemon -w src -e js,jsx,json,css,html -w webpack.config.js -x npm run build", 7 | "build": "webpack --mode development", 8 | "uxp:load": "cd dist && uxp plugin load", 9 | "uxp:reload": "cd dist && uxp plugin reload", 10 | "uxp:watch": "cd dist && nodemon --exec \"uxp plugin reload\" -e js,css,html", 11 | "uxp:debug": "cd dist && uxp plugin debug" 12 | }, 13 | "author": "Adobe Inc", 14 | "license": "Apache-2.0", 15 | "devDependencies": { 16 | "@babel/core": "^7.8.7", 17 | "@babel/plugin-proposal-object-rest-spread": "^7.8.3", 18 | "@babel/plugin-syntax-class-properties": "^7.10.4", 19 | "@babel/plugin-transform-react-jsx": "^7.8.3", 20 | "babel-loader": "^8.0.6", 21 | "clean-webpack-plugin": "^2.0.2", 22 | "copy-webpack-plugin": "^5.0.3", 23 | "css-loader": "^2.1.1", 24 | "file-loader": "^5.1.0", 25 | "nodemon": "^2.0.7", 26 | "style-loader": "^1.1.3", 27 | "webpack": "^4.32.2", 28 | "webpack-cli": "^4.9.1" 29 | }, 30 | "dependencies": { 31 | "cross-env": "^7.0.2", 32 | "react": "^16.8.6", 33 | "react-dom": "^16.8.6" 34 | }, 35 | "resolutions": { 36 | "acorn": "npm:acorn-with-stage3" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-starter/template/plugin/icons/icon_D.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adobe-uxp/devtools-cli/ef7e127b0e234e82b94d94e0c18443f3a738f929/packages/uxp-templates-pack/uxp-template-ps-react-starter/template/plugin/icons/icon_D.png -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-starter/template/plugin/icons/icon_D@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adobe-uxp/devtools-cli/ef7e127b0e234e82b94d94e0c18443f3a738f929/packages/uxp-templates-pack/uxp-template-ps-react-starter/template/plugin/icons/icon_D@2x.png -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-starter/template/plugin/icons/icon_N.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adobe-uxp/devtools-cli/ef7e127b0e234e82b94d94e0c18443f3a738f929/packages/uxp-templates-pack/uxp-template-ps-react-starter/template/plugin/icons/icon_N.png -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-starter/template/plugin/icons/icon_N@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adobe-uxp/devtools-cli/ef7e127b0e234e82b94d94e0c18443f3a738f929/packages/uxp-templates-pack/uxp-template-ps-react-starter/template/plugin/icons/icon_N@2x.png -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-starter/template/plugin/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-starter/template/plugin/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "com.adobe.uxp.starter.react", 3 | "name": "UXP React Starter Plugin", 4 | "version": "1.0.0", 5 | "main": "index.html", 6 | "manifestVersion": 4, 7 | "host": { 8 | "app": "PS", 9 | "minVersion": "22.0.0" 10 | }, 11 | "entrypoints": [ 12 | { 13 | "type": "command", 14 | "id": "showAbout", 15 | "label": { 16 | "default": "About React Demo" 17 | }, 18 | "shortcut": { 19 | "mac": "shift+cmd+A", 20 | "win": "ctrl+alt+A" 21 | } 22 | }, 23 | { 24 | "type": "panel", 25 | "id": "demos", 26 | "label": { 27 | "default": "Demo Panel" 28 | }, 29 | "minimumSize": {"width": 230, "height": 200}, 30 | "maximumSize": {"width": 2000, "height": 2000}, 31 | "preferredDockedSize": {"width": 230, "height": 300}, 32 | "preferredFloatingSize": {"width": 230, "height": 300}, 33 | "icons": [ 34 | { "width": 32, "height": 32, "path": "icons/icon_D.png", "scale": [ 1, 2 ], "theme": [ "dark", "darkest" ], "species": [ "generic" ] }, 35 | { "width": 32, "height": 32, "path": "icons/icon_N.png", "scale": [ 1, 2 ], "theme": [ "lightest", "light" ], "species": [ "generic" ] } 36 | ] 37 | }, 38 | { 39 | "type": "panel", 40 | "id": "moreDemos", 41 | "label": { 42 | "default": "Demo Panel 2" 43 | }, 44 | "minimumSize": {"width": 230, "height": 200}, 45 | "maximumSize": {"width": 2000, "height": 2000}, 46 | "preferredDockedSize": {"width": 230, "height": 300}, 47 | "preferredFloatingSize": {"width": 230, "height": 300}, 48 | "icons": [ 49 | { "width": 32, "height": 32, "path": "icons/icon_D.png", "scale": [ 1, 2 ], "theme": [ "dark", "darkest" ], "species": [ "generic" ] }, 50 | { "width": 32, "height": 32, "path": "icons/icon_N.png", "scale": [ 1, 2 ], "theme": [ "lightest", "light" ], "species": [ "generic" ] } 51 | ] 52 | } 53 | ], 54 | "icons": [ 55 | { "width": 32, "height": 32, "path": "icons/icon_D.png", "scale": [ 1, 2 ], "theme": [ "dark", "darkest" ], "species": [ "generic" ] }, 56 | { "width": 32, "height": 32, "path": "icons/icon_N.png", "scale": [ 1, 2 ], "theme": [ "lightest", "light" ], "species": [ "generic" ] } 57 | ] 58 | } 59 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-starter/template/src/components/About.css: -------------------------------------------------------------------------------- 1 | .aboutDialog sp-heading { 2 | margin-top: 0; 3 | } 4 | .aboutDialog sp-divider { 5 | margin: 8px 0; 6 | } 7 | 8 | .aboutDialog sp-button-group { 9 | margin: 16px 0 0 0; 10 | display: flex; 11 | flex-direction: row; 12 | justify-content: flex-end; 13 | } 14 | 15 | .aboutDialog sp-button-group > * { 16 | margin: 0 8px; 17 | } 18 | 19 | .aboutDialog sp-button-group > *:first-child { 20 | margin-left: 0; 21 | } 22 | 23 | .aboutDialog sp-button-group > *:last-child { 24 | margin-right: 0; 25 | } 26 | 27 | .aboutDialog .well { 28 | border-radius: 8px; 29 | width: 100%; 30 | background-color: #095aba; 31 | padding: 16px; 32 | padding-left: 44px; 33 | position: relative; 34 | color: #e1e1e1; 35 | } 36 | 37 | .aboutDialog .well sp-icon { 38 | position: absolute; 39 | top: 18px; 40 | left: 16px; 41 | } 42 | 43 | .aboutDialog .table { 44 | display: flex; 45 | flex-direction: column; 46 | background-color: #00000025; 47 | padding: 16px; 48 | border-radius: 4px; 49 | } 50 | 51 | .aboutDialog .table div { 52 | flex: 1 1 auto; 53 | display: flex; 54 | flex-direction: row; 55 | height: 20px; 56 | border-radius: 2px; 57 | } 58 | 59 | .aboutDialog .table div:nth-child(odd) { 60 | background-color: #00000025; 61 | } 62 | 63 | .aboutDialog .table div sp-detail { 64 | text-align: right; 65 | flex: 0 0 66%; 66 | padding-top: 2px; 67 | margin-right: 1em; 68 | } 69 | 70 | .aboutDialog .table div sp-body { 71 | flex: 1 1 auto; 72 | } 73 | 74 | .aboutDialog code { 75 | font-family: 'Menlo', 'Courier New', Courier, monospace 76 | } 77 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-starter/template/src/components/About.jsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | import { versions } from "uxp"; 4 | import os from "os"; 5 | 6 | import "./About.css"; 7 | 8 | export const About = (props) => { 9 | return ( 10 |
11 | React Starter Plugin 12 | 13 | 14 | This is a simple plugin that demonstrates the various capabilities of React on UXP. 15 | When adapting to your own projects, you can replace index.jsx and the components 16 | with your own. 17 | 18 | 19 | 20 | We've also included the `WC` component and a couple of controllers. You 21 | do not need to use these in your own projects, but you are welcome to do so. 22 | 23 | VERSIONS 24 |
25 |
PLUGIN: {versions.plugin}
26 |
OPERATING SYTEM: {os.platform()} {os.release()}
27 |
UNIFIED EXTENSIBILITY PLATFORM:{versions.uxp}
28 |
29 | 30 | props.dialog.close("reasonCanceled")}>Cancel 31 | props.dialog.close("ok")}>OK 32 | 33 |
34 | ); 35 | } 36 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-starter/template/src/components/ColorPicker.css: -------------------------------------------------------------------------------- 1 | 2 | .colorPicker .color { 3 | margin: 16px auto; 4 | height: 64px; 5 | width: 64px; 6 | border-radius: 8px; 7 | position: relative; 8 | border: 1px solid #252525; 9 | outline: 1px solid #8C8C8C; 10 | outline-radius: 10px; 11 | } 12 | 13 | .colorPicker .color:after { 14 | content: ' '; 15 | position: absolute; 16 | top: 0; left: 0; right: 0; bottom: 0; 17 | border: 1px solid white; 18 | border-radius: 8px; 19 | } 20 | 21 | @media (prefers-color-scheme: darkest) { 22 | .colorPicker .color { 23 | outline-color: #6E6E6E; 24 | } 25 | } 26 | @media (prefers-color-scheme: light), (prefers-color-scheme: lightest) { 27 | .colorPicker .color { 28 | outline-color: #FFFFFF; 29 | } 30 | } 31 | 32 | 33 | .colorPicker .filledRange { 34 | position: relative; 35 | } 36 | 37 | .colorPicker .sliderWithInput { 38 | display: flex; 39 | flex-direction: row; 40 | align-items: center; 41 | } 42 | 43 | .colorPicker .sliderWithInput > *:first-child { 44 | flex: 1 1 auto; 45 | } 46 | 47 | .colorPicker .sliderWithInput > *:last-child { 48 | margin-left: 8px; 49 | flex: 0 0 auto; 50 | width: 50px; 51 | } 52 | .colorPicker sp-textfield { 53 | height: 24px; 54 | background-color: transparent; 55 | } 56 | 57 | .colorPicker sp-slider { 58 | position: absolute; 59 | top: 0; 60 | left: 0; 61 | right: 0; 62 | } 63 | 64 | .colorPicker sp-slider:focus { 65 | outline: 1px solid #2680eb; 66 | outline-radius: 4px; 67 | } 68 | 69 | @media (prefers-color-scheme: darkest), (prefers-color-scheme: lightest) { 70 | .colorPicker sp-slider:focus { 71 | outline-color: #2185E6 72 | } 73 | } 74 | @media (prefers-color-scheme: dark) { 75 | .colorPicker sp-slider:focus { 76 | outline-color: #3592EB 77 | } 78 | } 79 | @media (prefers-color-scheme: light) { 80 | .colorPicker sp-slider:focus { 81 | outline-color: #0679E0 82 | } 83 | } 84 | 85 | .colorPicker .gradient { 86 | margin-top: 21px; 87 | height: 14px; 88 | margin-bottom: 28px; 89 | border-top-left-radius: 8px; 90 | border-top-right-radius: 8px; 91 | margin-left: 8px; 92 | margin-right: 8px; 93 | } 94 | 95 | .colorPicker .gradient.red { 96 | background: linear-gradient(to right, #000000, #FF0000); 97 | } 98 | .colorPicker .gradient.green { 99 | background: linear-gradient(to right, #000000, #00FF00); 100 | } 101 | .colorPicker .gradient.blue { 102 | background: linear-gradient(to right, #000000, #0000FF); 103 | } 104 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-starter/template/src/components/Hello.jsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | export const Hello = (props) => { 4 | return ( 5 | Hello, {props.message || "world"} 6 | ); 7 | } 8 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-starter/template/src/components/Icons.css: -------------------------------------------------------------------------------- 1 | [slot=icon] svg { 2 | fill: currentColor; 3 | } -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-starter/template/src/components/WC.jsx: -------------------------------------------------------------------------------- 1 | import React, { useEffect, useRef } from "react"; 2 | 3 | export const WC = (props) => { 4 | const elRef = useRef(null); 5 | 6 | const handleEvent = (evt) => { 7 | const propName = `on${evt.type[0].toUpperCase()}${evt.type.substr(1)}`; 8 | if (props[propName]) { 9 | props[propName].call(evt.target, evt); 10 | } 11 | } 12 | 13 | useEffect(() => { 14 | const el = elRef.current; 15 | const eventProps = Object.entries(props).filter(([k,v]) => k.startsWith("on")); 16 | eventProps.forEach(([k,v]) => el.addEventListener(k.substr(2).toLowerCase(), handleEvent)); 17 | 18 | return () => { 19 | const el = elRef.current; 20 | const eventProps = Object.entries(props).filter(([k,v]) => k.startsWith("on")); 21 | eventProps.forEach(([k,v]) => el.removeEventListener(k.substr(2).toLowerCase(), handleEvent)); 22 | } 23 | }, []); 24 | 25 | return
{props.children}
26 | } 27 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-starter/template/src/controllers/CommandController.jsx: -------------------------------------------------------------------------------- 1 | import ReactDOM from "react-dom"; 2 | 3 | const _id = Symbol("_id"); 4 | const _root = Symbol("_root"); 5 | const _Component = Symbol("_Component"); 6 | const _dialogOpts = Symbol("_dialogOpts"); 7 | 8 | export class CommandController { 9 | 10 | constructor(Component, { id, ...dialogOpts } = {}) { 11 | this[_id] = null; 12 | this[_root] = null; 13 | this[_Component] = null; 14 | this[_dialogOpts] = {}; 15 | 16 | this[_Component] = Component; 17 | this[_id] = id; 18 | this[_dialogOpts] = Object.assign({}, { 19 | title: id, 20 | resize: "none", 21 | size: { 22 | width: 480, 23 | height: 320 24 | } 25 | }, dialogOpts); 26 | [ "run" ].forEach(fn => this[fn] = this[fn].bind(this)); 27 | } 28 | 29 | async run() { 30 | if (!this[_root]) { 31 | this[_root] = document.createElement("dialog"); 32 | ReactDOM.render(this[_Component]({dialog: this[_root]}), this[_root]); 33 | } 34 | document.body.appendChild(this[_root]); 35 | 36 | await this[_root].showModal(this[_dialogOpts]); 37 | this[_root].remove(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-starter/template/src/controllers/PanelController.jsx: -------------------------------------------------------------------------------- 1 | import ReactDOM from "react-dom"; 2 | 3 | const _id = Symbol("_id"); 4 | const _root = Symbol("_root"); 5 | const _attachment = Symbol("_attachment"); 6 | const _Component = Symbol("_Component"); 7 | const _menuItems = Symbol("_menuItems"); 8 | 9 | export class PanelController { 10 | 11 | constructor(Component, { id, menuItems } = {}) { 12 | this[_id] = null; 13 | this[_root] = null; 14 | this[_attachment] = null; 15 | this[_Component] = null; 16 | this[_menuItems] = []; 17 | 18 | this[_Component] = Component; 19 | this[_id] = id; 20 | this[_menuItems] = menuItems || []; 21 | this.menuItems = this[_menuItems].map(menuItem => ({ 22 | id: menuItem.id, 23 | label: menuItem.label, 24 | enabled: menuItem.enabled || true, 25 | checked: menuItem.checked || false 26 | })); 27 | 28 | [ "create", "show", "hide", "destroy", "invokeMenu" ].forEach(fn => this[fn] = this[fn].bind(this)); 29 | } 30 | 31 | create() { 32 | this[_root] = document.createElement("div"); 33 | this[_root].style.height = "100vh"; 34 | this[_root].style.overflow = "auto"; 35 | this[_root].style.padding = "8px"; 36 | 37 | ReactDOM.render(this[_Component]({panel: this}), this[_root]); 38 | 39 | return this[_root]; 40 | } 41 | 42 | show(event) { 43 | if (!this[_root]) this.create(); 44 | this[_attachment] = event.node; 45 | this[_attachment].appendChild(this[_root]); 46 | } 47 | 48 | hide() { 49 | if (this[_attachment] && this[_root]) { 50 | this[_attachment].removeChild(this[_root]); 51 | this[_attachment] = null; 52 | } 53 | } 54 | 55 | destroy() { } 56 | 57 | invokeMenu(id) { 58 | const menuItem = this[_menuItems].find(c => c.id === id); 59 | if (menuItem) { 60 | const handler = menuItem.oninvoke; 61 | if (handler) { 62 | handler(); 63 | } 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-starter/template/src/index.jsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | import "./styles.css"; 4 | import { PanelController } from "./controllers/PanelController.jsx"; 5 | import { CommandController } from "./controllers/CommandController.jsx"; 6 | import { About } from "./components/About.jsx"; 7 | import { Demos } from "./panels/Demos.jsx"; 8 | import { MoreDemos } from "./panels/MoreDemos.jsx"; 9 | 10 | import { entrypoints } from "uxp"; 11 | 12 | const aboutController = new CommandController(({ dialog }) => , { id: "showAbout", title: "React Starter Plugin Demo", size: { width: 480, height: 480 } }); 13 | const demosController = new PanelController(() => , {id: "demos", menuItems: [ 14 | { id: "reload1", label: "Reload Plugin", enabled: true, checked: false, oninvoke: () => location.reload() }, 15 | { id: "dialog1", label: "About this Plugin", enabled: true, checked: false, oninvoke: () => aboutController.run() }, 16 | ] }); 17 | const moreDemosController = new PanelController(() => , { id: "moreDemos", menuItems: [ 18 | { id: "reload2", label: "Reload Plugin", enabled: true, checked: false, oninvoke: () => location.reload() } 19 | ] }); 20 | 21 | entrypoints.setup({ 22 | plugin: { 23 | create(plugin) { 24 | /* optional */ console.log("created", plugin); 25 | }, 26 | destroy() { 27 | /* optional */ console.log("destroyed"); 28 | } 29 | }, 30 | commands: { 31 | showAbout: aboutController 32 | }, 33 | panels: { 34 | demos: demosController, 35 | moreDemos: moreDemosController 36 | } 37 | }); 38 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-starter/template/src/panels/Demos.jsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | import { ColorPicker } from "../components/ColorPicker.jsx"; 4 | 5 | export const Demos = () => { 6 | return ( 7 | <> 8 | 9 | 10 | ) 11 | } 12 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-starter/template/src/panels/MoreDemos.jsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | import { Hello } from "../components/Hello.jsx"; 4 | import { PlayIcon } from "../components/Icons.jsx"; 5 | 6 | export const MoreDemos = () => { 7 | return ( 8 | <> 9 | 10 | 11 | 12 | 13 | 14 | ); 15 | } 16 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-starter/template/src/styles.css: -------------------------------------------------------------------------------- 1 | .tabbar { 2 | display: flex; 3 | flex: 0 0 auto; 4 | padding: 12px; 5 | background-color: rgba(0,0,0,.25); 6 | border-bottom-left-radius: 4px; 7 | border-bottom-right-radius: 4px; 8 | flex-wrap: wrap; 9 | } 10 | .tabsection { 11 | flex: 1 1 auto; 12 | display: flex; 13 | flex-direction: row; 14 | flex-wrap: wrap; 15 | } 16 | .tabsection:nth-of-type(2) { 17 | justify-content: flex-end; 18 | } 19 | 20 | .tabsection * { 21 | margin: 0 4px; 22 | } -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-starter/template/uxp-plugin-tests/sample-tests/page-objects/homepage.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe Systems Incorporated. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | */ 13 | 14 | /** 15 | * Home page containing specific selectors and methods for a specific page 16 | */ 17 | class HomePage { 18 | /** 19 | * define selectors using getter methods 20 | */ 21 | get populateLayerButton () { return $('#btnPopulate') } 22 | 23 | /** 24 | * a method to encapsule automation code to interact with the page 25 | * e.g. to click on populate layer button 26 | */ 27 | 28 | async clickOnPopulateLayerButton() { 29 | await (await this.populateLayerButton).click(); 30 | } 31 | } 32 | 33 | module.exports = new HomePage(); -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-starter/template/uxp-plugin-tests/sample-tests/specs/PopulateButtonTest.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Adobe Systems Incorporated. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | */ 13 | 14 | const HomePage = require('../page-objects/homepage.js'); 15 | describe('Click on Populate Layers Button', () => { 16 | it('should click on Populate layers Button', async () => { 17 | await HomePage.clickOnPopulateLayerButton(); 18 | // Add your validation here 19 | const result = await browser.execute(() => { 20 | const app = window.require("photoshop").app; 21 | const length = app.activeDocument.layers ? app.activeDocument.layers.length : 0 ; 22 | return length 23 | }); 24 | const result1 = await browser.execute(() => { 25 | return document.getElementsByTagName("li").length; 26 | }); 27 | expect(result).toStrictEqual(result1); 28 | }); 29 | }); -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-starter/template/webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require("path"); 2 | const CleanWebpackPlugin = require("clean-webpack-plugin"); 3 | const CopyPlugin = require("copy-webpack-plugin"); 4 | 5 | module.exports = { 6 | entry: './src/index.jsx', 7 | output: { 8 | path: path.resolve(__dirname, 'dist'), 9 | filename: 'index.js', 10 | //libraryTarget: "commonjs2" 11 | }, 12 | devtool: 'cheap-eval-source-map', // won't work on XD due to lack of eval 13 | externals: { 14 | uxp: 'commonjs2 uxp', 15 | photoshop: 'commonjs2 photoshop', 16 | os: 'commonjs2 os' 17 | }, 18 | resolve: { 19 | extensions: [".js", ".jsx"] 20 | }, 21 | module: { 22 | rules: [ 23 | { 24 | test: /\.jsx?$/, 25 | exclude: /node_modules/, 26 | loader: "babel-loader", 27 | options: { 28 | plugins: [ 29 | "@babel/transform-react-jsx", 30 | "@babel/proposal-object-rest-spread", 31 | "@babel/plugin-syntax-class-properties", 32 | ] 33 | } 34 | }, 35 | { 36 | test: /\.png$/, 37 | exclude: /node_modules/, 38 | loader: 'file-loader' 39 | }, 40 | { 41 | test: /\.css$/, 42 | use: ["style-loader", "css-loader"] 43 | } 44 | ] 45 | }, 46 | plugins: [ 47 | //new CleanWebpackPlugin(), 48 | new CopyPlugin(['plugin'], { 49 | copyUnmodified: true 50 | }) 51 | ] 52 | }; -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-typescript/.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | node_modules 3 | .DS_Store 4 | yarn-error.log -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-typescript/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "trailingComma": "es5", 3 | "tabWidth": 2, 4 | "semi": false, 5 | "bracketSpacing": true, 6 | "singleQuote": true, 7 | "jsxBracketSameLine": false, 8 | "arrowParens": "always" 9 | } 10 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-typescript/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | Creating empty index file to resolve the file path. 3 | */ 4 | const templateModule = { 5 | // look into packages/uxp-templates-pack/uxp-template-ps-react-starter/index.js for details on these values. 6 | "devtools": { 7 | "manifestPath" : "uxp/manifest.json", 8 | "buildDir" : "dist" 9 | }, 10 | // packageDir should always have the '__dirname' as its value. 11 | // the UXP Plugin initializatin command will look for directory with name "template" in this directory. 12 | "packageDir": __dirname 13 | } 14 | 15 | module.exports = templateModule; -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-typescript/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@adobe/uxp-template-ps-react-typescript", 3 | "version": "1.0.0", 4 | "description": "Starter template for creating Adobe UXP based photoshop plugin.", 5 | "main": "index.js", 6 | "repository": { 7 | "type": "git", 8 | "url": "git@github.com:adobe-uxp/devtools-cli.git", 9 | "directory": "packages/uxp-templates-pack" 10 | }, 11 | "uxp": { 12 | "manifestPath" : "template/manifest.json", 13 | "buildDir" : "dist" 14 | }, 15 | "keywords": [ 16 | "adobe", 17 | "uxp", 18 | "ps-react-typescript" 19 | ], 20 | "author": "Adobe Inc", 21 | "license": "Apache-2.0", 22 | "files": [ 23 | "template.json", 24 | "template" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-typescript/template.json: -------------------------------------------------------------------------------- 1 | { 2 | "package": { 3 | "dependencies" : { 4 | } 5 | }, 6 | "devtools": { 7 | 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-typescript/template/README.md: -------------------------------------------------------------------------------- 1 | # react-typescript-plugin 2 | 3 | Quick starter for writing UXP plugins using React, Typescript and Webpack. 4 | 5 | ## Setup 6 | 7 | First, make sure you update three things: 8 | 9 | 1 In uxp/manifest.json, change `name` and `ID` for your own plugin 10 | 11 | 2 In uxp/manifest.json, change `entryPoints > label` for what you want your plugin to show as under the Photoshop Plugins menu 12 | 13 | 3 In uxp/debug.json, change `port` to a value that you're sure other plugins don't use 14 | 15 | Install the dependencies: 16 | 17 | ``` 18 | yarn install 19 | ``` 20 | 21 | Run webpack to bundle 22 | 23 | ``` 24 | yarn build 25 | # or "yarn watch" to watch for file changes and rebuild automatically 26 | ``` 27 | 28 | Now, you can load your plugin using [UXP DevTools](https://github.com/adobe-uxp/devtools-cli), please follow the instructions there. 29 | 30 | ## (PreRelease) Prerequisites 31 | 32 | While we're still developing UXP, we want to make sure these features are behind flags so they don't affect end users. To enable UXP development and see your panels in Photoshop, you will need to set a checkbox in preferences. 33 | 34 | In Preferences > Technology Previews, please find `ScriptDeveloper` under the Prerelease Features table, and enable it. And then restart Photoshop to start loading your plugin. 35 | 36 | ## Panel Entrypoints 37 | 38 | The ui entrypoint of a UXP plugin as a panel is defined in it's `manifest.json` file. This is subject to change, so please refer to latest copy of the starter repository as above. 39 | 40 | The plugin will be available in Plugins menu with it's name. This will open up a PS panel with your plugin loaded in it. 41 | 42 | ### Panel Flyout Menus 43 | 44 | The plugin's `manifest.json` file allows for the static definition of panel menu items. A flat list of items are supported under `entryPoints` as such: 45 | 46 | ``` 47 | "commands" : [ 48 | {"title": {"default": "Command 1"}, "command": "flyoutMenuCommand1"}, 49 | {"title": {"default": "Command 2"}, "command": "flyoutMenuCommand2"}, 50 | ] 51 | ``` 52 | 53 | Ensure that the invoked command or function is available globally. 54 | 55 | ## Debugging 56 | 57 | Please use devtools to debug your plugin with the stand alone debugger. -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-typescript/template/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.0.2", 3 | "scripts": { 4 | "build": "webpack --config webpack.config.js", 5 | "watch": "webpack --watch --config webpack.config.js", 6 | "test": "tslint --format verbose src/**/*.ts src/**/*.tsx" 7 | }, 8 | "author": "Adobe Inc", 9 | "license": "Apache-2.0", 10 | "devDependencies": { 11 | "@babel/core": "^7.4.5", 12 | "@babel/preset-env": "^7.4.5", 13 | "@babel/preset-react": "^7.0.0", 14 | "@types/photoshop": "https://github.com/adobe-uxp/types-photoshop.git", 15 | "@types/react": "^16.8.24", 16 | "@types/react-dom": "^16.8.5", 17 | "babel-loader": "^8.0.6", 18 | "clean-webpack-plugin": "^2.0.2", 19 | "copy-webpack-plugin": "^5.0.3", 20 | "css-loader": "^2.1.1", 21 | "prettier": "^1.18.2", 22 | "style-loader": "^1.1.3", 23 | "ts-loader": "^6.0.4", 24 | "tslint": "^5.18.0", 25 | "tslint-config-prettier": "^1.18.0", 26 | "tslint-loader": "^3.5.4", 27 | "tslint-plugin-prettier": "^2.0.1", 28 | "tslint-react": "^4.0.0", 29 | "typescript": "^3.5.3", 30 | "webpack": "^4.32.2", 31 | "webpack-cli": "^3.3.2" 32 | }, 33 | "dependencies": { 34 | "react": "^16.8.6", 35 | "react-dom": "^16.8.6" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-typescript/template/src/App.css: -------------------------------------------------------------------------------- 1 | dialog { 2 | width: 100%; 3 | height: 100%; 4 | min-width: 300px; 5 | min-height: 400px; 6 | background-color: #fff; 7 | } 8 | 9 | .panel { 10 | overflow: auto; 11 | max-width: 100vw; 12 | max-height: 100vh; 13 | margin: 4px; 14 | } 15 | 16 | .component { 17 | padding: 4px; 18 | min-width: 300px; 19 | margin: 10px 0px 30px 0px; 20 | } 21 | 22 | .component > .heading { 23 | margin: 10px 0; 24 | } 25 | 26 | .element { 27 | margin: 2px; 28 | } 29 | 30 | .scrollable-console { 31 | overflow: scroll; 32 | height: 100px; 33 | } 34 | 35 | .links { 36 | color: rgb(13, 102, 208) 37 | } 38 | 39 | .flex-row { 40 | display: flex; 41 | flex-direction: row; 42 | } 43 | 44 | .flex-col { 45 | display: flex; 46 | flex-direction: column; 47 | } 48 | 49 | .between { justify-content: space-between; } 50 | .around { justify-content: space-around; } 51 | .start { justify-content: flex-start; } 52 | .end { justify-content: flex-end; } 53 | .center { justify-content: center; } 54 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-typescript/template/src/App.tsx: -------------------------------------------------------------------------------- 1 | // App imports 2 | import React from 'react' 3 | import ReactDOM from 'react-dom' 4 | import './App.css' 5 | 6 | import PsApi from './components/PsApi' 7 | import Listener from './components/Listener' 8 | import Elements from './components/Elements' 9 | import UxpFileFetch from './components/UxpFileFetch' 10 | 11 | export default class App extends React.Component { 12 | constructor(props) { 13 | super(props) 14 | } 15 | 16 | public renderDialog() { 17 | const dialogElement = document.createElement('dialog') 18 | document.appendChild(dialogElement) 19 | ReactDOM.render(, dialogElement) 20 | dialogElement.addEventListener('close', () => { 21 | document.removeChild(dialogElement) 22 | }) 23 | dialogElement.showModal() 24 | } 25 | 26 | public render() { 27 | return ( 28 |
29 |

Photoshop UXP Starter Panel

30 | 31 | 32 | 33 | 34 | 35 |
36 | ) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-typescript/template/src/components/Listener.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | interface AppState { 4 | listening: boolean 5 | count: { 6 | all: number 7 | } 8 | } 9 | 10 | /** 11 | * Usage of the Photoshop event listening APIs. 12 | * This section of the APIs are subject to sweeping changes. 13 | */ 14 | export default class ListenerComponent extends React.Component<{}, AppState> { 15 | constructor(props) { 16 | super(props) 17 | this.state = { 18 | listening: false, 19 | count: { 20 | all: 0, 21 | }, 22 | } 23 | 24 | this.listener = this.listener.bind(this) 25 | } 26 | 27 | public render() { 28 | const eventKeys = Object.keys(this.state.count) 29 | return ( 30 |
31 |

Event listener

32 |
33 |
34 |

Num events ($All): {this.state.count.all}

35 |

Num event types: {eventKeys.length - 1}

36 |
37 |
38 |
39 | 40 | 41 | 42 |
43 |
44 |
45 |
46 | ) 47 | } 48 | 49 | /** 50 | * Listener to be attached to all Photoshop notifications. 51 | */ 52 | public async listener(event: string, message: object) { 53 | this.setState((prevState) => { 54 | return { 55 | count: { 56 | ...prevState.count, 57 | all: prevState.count.all + 1, 58 | [event]: prevState.count[event] + 1 || 1, 59 | }, 60 | } 61 | }) 62 | } 63 | 64 | /** 65 | * Attaches the simple listener to the app. 66 | */ 67 | private async attachListener() { 68 | const app = require('photoshop').app 69 | app.eventNotifier = this.listener 70 | 71 | this.setState({ listening: true }) 72 | } 73 | 74 | /** 75 | * Attaches a null listener to the app. 76 | */ 77 | private async removeListener() { 78 | const app = require('photoshop').app 79 | app.eventNotifier = undefined 80 | 81 | this.setState({ 82 | listening: false, 83 | }) 84 | } 85 | 86 | /** 87 | * Util function. 88 | */ 89 | private async resetCounts() { 90 | this.setState({ 91 | count: { all: 0 }, 92 | }) 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-typescript/template/src/index.tsx: -------------------------------------------------------------------------------- 1 | import App from './App' 2 | import ReactDOM from 'react-dom' 3 | import React from 'react' 4 | 5 | // Render dialog to DOM, this will show the UI in the container, like a panel 6 | ReactDOM.render(, document.getElementById('root')) 7 | 8 | // Define entry points for Photoshop Panel Flyout Menu items 9 | function flyoutMenuCommand1() { 10 | const psCore = require('photoshop').core 11 | psCore.showAlert({ message: 'Command 1 was invoked!' }) 12 | } 13 | 14 | // tslint:disable-next-line: no-string-literal 15 | window['flyoutMenuCommand1'] = flyoutMenuCommand1 16 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-typescript/template/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "./dist/", 4 | "sourceMap": true, 5 | "noImplicitAny": false, 6 | "target": "esnext", 7 | "module": "esnext", 8 | "moduleResolution": "node", 9 | "esModuleInterop": true, 10 | "allowSyntheticDefaultImports": true, 11 | "jsx": "react" 12 | }, 13 | "exclude": [ 14 | "node_modules" 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-typescript/template/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "tslint:latest", 4 | "tslint-react", 5 | "tslint-plugin-prettier", 6 | "tslint-config-prettier" 7 | ], 8 | "rules": { 9 | "prettier": true, 10 | "no-submodule-imports": false, 11 | "ordered-imports": false, 12 | "interface-name": false, 13 | "object-literal-sort-keys": false, 14 | "jsx-no-lambda": false, 15 | "no-implicit-dependencies": [ true, [ "uxp", "photoshop" ] ], 16 | "no-console": false, 17 | "no-var-requires": false 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-typescript/template/uxp/icons/icon_D.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adobe-uxp/devtools-cli/ef7e127b0e234e82b94d94e0c18443f3a738f929/packages/uxp-templates-pack/uxp-template-ps-react-typescript/template/uxp/icons/icon_D.png -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-typescript/template/uxp/icons/icon_N.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adobe-uxp/devtools-cli/ef7e127b0e234e82b94d94e0c18443f3a738f929/packages/uxp-templates-pack/uxp-template-ps-react-typescript/template/uxp/icons/icon_N.png -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-typescript/template/uxp/icons/icon_x2_D.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adobe-uxp/devtools-cli/ef7e127b0e234e82b94d94e0c18443f3a738f929/packages/uxp-templates-pack/uxp-template-ps-react-typescript/template/uxp/icons/icon_x2_D.png -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-typescript/template/uxp/icons/icon_x2_N.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adobe-uxp/devtools-cli/ef7e127b0e234e82b94d94e0c18443f3a738f929/packages/uxp-templates-pack/uxp-template-ps-react-typescript/template/uxp/icons/icon_x2_N.png -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-typescript/template/uxp/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-typescript/template/uxp/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Photoshop UXP Starter Extension", 3 | "id": "com.adobe.photoshop.uxp_starter", 4 | "version": "0.1.0", 5 | "main": "index.html", 6 | "host": [ 7 | { 8 | "app": "PS", 9 | "minVersion": "21.0.0" 10 | } 11 | ], 12 | "manifestVersion": 4, 13 | "entrypoints": [ 14 | { 15 | "type": "panel", 16 | "id": "react-typescript", 17 | "label": { 18 | "default": "Starter" 19 | }, 20 | "minimumSize": { 21 | "width": 230, 22 | "height": 200 23 | }, 24 | "maximumSize": { 25 | "width": 2000, 26 | "height": 2000 27 | }, 28 | "preferredDockedSize": { 29 | "width": 230, 30 | "height": 300 31 | }, 32 | "preferredFloatingSize": { 33 | "width": 230, 34 | "height": 300 35 | }, 36 | "commands": [ 37 | { 38 | "label": "Command 1", 39 | "id": "flyoutMenuCommand1" 40 | } 41 | ], 42 | "icons": [ 43 | { "width": 32, "height": 32, "path": "icons/icon_D.png", "scale": [ 1, 2 ], "theme": [ "dark", "darkest" ], "species": [ "generic" ] }, 44 | { "width": 32, "height": 32, "path": "icons/icon_N.png", "scale": [ 1, 2 ], "theme": [ "lightest", "light" ], "species": [ "generic" ] } 45 | ] 46 | } 47 | ], 48 | "icons": [ 49 | { "width": 32, "height": 32, "path": "icons/icon_D.png", "scale": [ 1, 2 ], "theme": [ "dark", "darkest" ], "species": [ "generic" ] }, 50 | { "width": 32, "height": 32, "path": "icons/icon_N.png", "scale": [ 1, 2 ], "theme": [ "lightest", "light" ], "species": [ "generic" ] } 51 | ], 52 | "runOnStartup": true 53 | } -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-react-typescript/template/webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require("path"); 2 | const CopyPlugin = require('copy-webpack-plugin'); 3 | const CleanWebpackPlugin = require('clean-webpack-plugin'); 4 | 5 | module.exports = { 6 | mode: 'development', // Make this custom 7 | entry: './src/index.tsx', 8 | output: { 9 | filename: 'index.js', 10 | path: path.resolve(__dirname, 'dist'), 11 | }, 12 | resolve: { 13 | // Add '.ts' and '.tsx' as resolvable extensions. 14 | extensions: ['.ts', '.tsx', '.js'], 15 | }, 16 | externals: { 17 | 'photoshop': 'commonjs2 photoshop', 18 | 'uxp': 'commonjs2 uxp' 19 | }, 20 | module: { 21 | rules: [ 22 | { 23 | test: /\.ts(x?)$/, 24 | enforce: 'pre', 25 | exclude: /node_modules/, 26 | use: 'tslint-loader', 27 | }, 28 | { 29 | test: /\.ts(x?)$/, 30 | exclude: /node_modules/, 31 | use: 'ts-loader', 32 | }, 33 | { 34 | test: /\.css$/, 35 | use: ['style-loader', 'css-loader'], 36 | }, 37 | ], 38 | }, 39 | plugins: [ 40 | new CleanWebpackPlugin(), 41 | new CopyPlugin(['uxp'], { 42 | copyUnmodified: true, 43 | }), // Copy everything in UXP to dist 44 | ], 45 | } 46 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-starter/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | Creating empty index file to resolve the file path. 3 | */ 4 | 5 | const templateModule = { 6 | 7 | "devtools": { 8 | }, 9 | // full path to the folder containing the actual uxp plugin project. 10 | "packageDir": __dirname 11 | } 12 | 13 | module.exports = templateModule; -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-starter/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@adobe/uxp-template-ps-starter", 3 | "version": "1.0.0", 4 | "description": "Starter template for creating Adobe UXP based photoshop plugin.", 5 | "main": "index.js", 6 | "repository": { 7 | "type": "git", 8 | "url": "git@github.com:adobe-uxp/devtools-cli.git", 9 | "directory": "packages/uxp-templates-pack" 10 | }, 11 | "keywords": [ 12 | "adobe", 13 | "uxp", 14 | "ps-starter" 15 | ], 16 | "author": "Adobe Inc", 17 | "license": "Apache-2.0", 18 | "files": [ 19 | "template.json", 20 | "template" 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-starter/template/README.md: -------------------------------------------------------------------------------- 1 | # Starter Photoshop Plugin (Vanilla) 2 | 3 | This starter plugin is a good place to get started when developing for Photoshop. It does not rely on any frameworks or build steps -- hence the name "Vanilla". 4 | 5 | ## Loading in Photoshop 6 | 7 | You can load this plugin directly in Photoshop by using the UXP Developer Tools application. Once started, click "Add Plugin...", and navigate to the "manifest.json" file in this folder. Then click the ••• button next to the corresponding entry in the developer tools and click "Load". Switch over to Photoshop, and the plugin's panel will be running. 8 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-starter/template/icons/dark@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adobe-uxp/devtools-cli/ef7e127b0e234e82b94d94e0c18443f3a738f929/packages/uxp-templates-pack/uxp-template-ps-starter/template/icons/dark@1x.png -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-starter/template/icons/dark@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adobe-uxp/devtools-cli/ef7e127b0e234e82b94d94e0c18443f3a738f929/packages/uxp-templates-pack/uxp-template-ps-starter/template/icons/dark@2x.png -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-starter/template/icons/light@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adobe-uxp/devtools-cli/ef7e127b0e234e82b94d94e0c18443f3a738f929/packages/uxp-templates-pack/uxp-template-ps-starter/template/icons/light@1x.png -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-starter/template/icons/light@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adobe-uxp/devtools-cli/ef7e127b0e234e82b94d94e0c18443f3a738f929/packages/uxp-templates-pack/uxp-template-ps-starter/template/icons/light@2x.png -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-starter/template/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 22 | 23 | Layers 24 | 25 | No layers 26 | 27 |
28 | Populate Layers 29 |
30 | 31 | 32 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-starter/template/index.js: -------------------------------------------------------------------------------- 1 | function showLayerNames() { 2 | const app = window.require("photoshop").app; 3 | const allLayers = app.activeDocument.layers; 4 | const allLayerNames = allLayers.map(layer => layer.name); 5 | const sortedNames = allLayerNames.sort((a, b) => a < b ? -1 : a > b ? 1 : 0); 6 | document.getElementById("layers").innerHTML = ` 7 |
    ${ 8 | sortedNames.map(name => `
  • ${name}
  • `).join("") 9 | }
`; 10 | } 11 | 12 | document.getElementById("btnPopulate").addEventListener("click", showLayerNames); -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-starter/template/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "com.adobe.example.vanilla-ps-js", 3 | "name": "Starter Panel", 4 | "version": "1.0.0", 5 | "main": "index.html", 6 | "host": [{ 7 | "app": "PS", 8 | "minVersion": "22.0.0" 9 | }], 10 | "manifestVersion": 4, 11 | "entrypoints": [ 12 | { 13 | "type": "panel", 14 | "id": "vanilla", 15 | "minimumSize": {"width": 230, "height": 200}, 16 | "maximumSize": {"width": 2000, "height": 2000}, 17 | "preferredDockedSize": {"width": 230, "height": 300}, 18 | "preferredFloatingSize": {"width": 230, "height": 300}, 19 | "icons": [ 20 | { "width": 32, "height": 32, "path": "icons/icon_D.png", "scale": [ 1, 2 ], "theme": [ "dark", "darkest" ], "species": [ "generic" ] }, 21 | { "width": 32, "height": 32, "path": "icons/icon_N.png", "scale": [ 1, 2 ], "theme": [ "lightest", "light" ], "species": [ "generic" ] } 22 | ], 23 | "label": {"default": "Starter Panel"} 24 | } 25 | ], 26 | "icons": [ 27 | { 28 | "width": 23, "height": 23, "path": "icons/dark.png", "scale": [ 1, 2 ], 29 | "theme": [ "darkest", "dark", "medium" ] 30 | }, { 31 | "width": 23, "height": 23, "path": "icons/light.png", "scale": [ 1, 2 ], 32 | "theme": [ "lightest", "light" ] 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-starter/template/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "uxp-template-ps-starter", 3 | "version": "1.0.0", 4 | "description": "Starter template for creating Adobe UXP based photoshop plugin.", 5 | "author": "Adobe Inc", 6 | "license": "Apache-2.0" 7 | } 8 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-ps-starter/template/watch.sh: -------------------------------------------------------------------------------- 1 | echo "Loading plugin..." 2 | uxp plugin load 3 | 4 | echo "Watching plugin..." 5 | nodemon --exec "uxp plugin reload" -e js,jsx,html 6 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-xd-starter/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | Creating empty index file to resolve the file path. 3 | */ 4 | 5 | const templateModule = { 6 | 7 | "devtools": { 8 | }, 9 | // full path to the folder containing the actual uxp plugin project. 10 | "packageDir": __dirname 11 | } 12 | 13 | module.exports = templateModule; -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-xd-starter/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@adobe/uxp-template-xd-starter", 3 | "version": "1.0.0", 4 | "description": "Starter template for creating Adobe UXP based XD plugin.", 5 | "main": "index.js", 6 | "repository": { 7 | "type": "git", 8 | "url": "git@github.com:adobe-uxp/devtools-cli.git", 9 | "directory": "packages/uxp-templates-pack" 10 | }, 11 | "keywords": [ 12 | "adobe", 13 | "uxp" 14 | ], 15 | "author": "Adobe Inc", 16 | "license": "Apache-2.0", 17 | "files": [ 18 | "template.json", 19 | "template" 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-xd-starter/template/README.md: -------------------------------------------------------------------------------- 1 | # Getting started 2 | 3 | This sample plugin is a persistent panel. Users can increase the width and height of the selected rectangle by inputing pixel values in the panel. 4 | [Read the step-by-step guide for this sample](https://adobexdplatform.com/plugin-docs/tutorials/quick-start-panel/). 5 | 6 | ## Usage 7 | 8 | 1. Run "Plugins > Enlarge a Rectangle" 9 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-xd-starter/template/images/icon@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adobe-uxp/devtools-cli/ef7e127b0e234e82b94d94e0c18443f3a738f929/packages/uxp-templates-pack/uxp-template-xd-starter/template/images/icon@1x.png -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-xd-starter/template/images/icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adobe-uxp/devtools-cli/ef7e127b0e234e82b94d94e0c18443f3a738f929/packages/uxp-templates-pack/uxp-template-xd-starter/template/images/icon@2x.png -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-template-xd-starter/template/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "QUICK_START_PANEL", 3 | "name": "Hello World sample plugin for panel", 4 | "host": { 5 | "app": "XD", 6 | "minVersion": "21.0" 7 | }, 8 | "version": "1.0.0", 9 | "icons": [ 10 | { 11 | "width": 24, 12 | "height": 24, 13 | "path": "images/icon@1x.png" 14 | }, 15 | { 16 | "width": 48, 17 | "height": 48, 18 | "path": "images/icon@2x.png" 19 | } 20 | ], 21 | "uiEntryPoints": [ 22 | { 23 | "type": "panel", 24 | "label": "Enlarge a Rectangle", 25 | "panelId": "enlargeRectangle" 26 | } 27 | ] 28 | } -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-wdio-automation-template/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@adobe/uxp-wdio-automation-template", 3 | "version": "1.0.0", 4 | "description": "A starter automation project created using WebDriverIO framework", 5 | "main": "index.js", 6 | "scripts": { 7 | "uxp-plugin-tests": "npx wdio wdio.conf.js" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "devDependencies": { 13 | "@wdio/cli": "^7.5.1", 14 | "@wdio/local-runner": "^7.5.1", 15 | "@wdio/mocha-framework": "^7.4.6", 16 | "@wdio/spec-reporter": "^7.4.3", 17 | "webdriverio":"7.6.0" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-wdio-automation-template/sample-tests/specs/starterScript.js: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2021 Adobe Systems Incorporated. All rights reserved. 4 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. You may obtain a copy 6 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software distributed under 9 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 10 | * OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | * 13 | */ 14 | 15 | describe("My UXP Plugin", () => { 16 | 17 | it("Starter Script", async() => { 18 | const result = browser.execute((a, b, c, d) => { 19 | // UXP API to be exposed by Host Apps will be called here 20 | return a + b + c + d; 21 | }, 1, 2, 3, 4); 22 | await browser.pause(2000); 23 | console.log(result); 24 | }); 25 | 26 | }); 27 | 28 | 29 | -------------------------------------------------------------------------------- /packages/uxp-templates-pack/uxp-wdio-automation-template/wdio.conf.js: -------------------------------------------------------------------------------- 1 | const yargs = require("yargs"); 2 | 3 | /* These configuration variables are needed for connecting UXP Developer Tools CLI with UXPDriver and the UXP Plugin. */ 4 | 5 | const testRunParam = yargs.argv; 6 | const driverPort = testRunParam.driverPort; 7 | const servicePort = testRunParam.servicePort; 8 | const uxpAppId = testRunParam.app; 9 | const uxpPluginId = testRunParam.uxpPluginID; 10 | 11 | 12 | exports.config = { 13 | 14 | runner: "local", 15 | specs: [ 16 | "./sample-tests/specs/*.js" 17 | ], 18 | exclude: [ 19 | // 'path/to/excluded/files' 20 | ], 21 | 22 | // uxp-plugin-tests currently support " maxInstances: 1 ". 23 | maxInstances: 1, 24 | capabilities: [ { 25 | browserName: "chrome", 26 | "goog:chromeOptions": { 27 | args: [ `--adobe-uxp-app-id=${uxpAppId}`, 28 | `--adobe-uxp-plugin-id=${uxpPluginId}` ], 29 | debuggerAddress: `http://127.0.0.1:${servicePort}`, 30 | } 31 | } ], 32 | hostname: "localhost", 33 | port: driverPort, 34 | path: "/wd/hub", 35 | logLevel: "info", 36 | bail: 0, 37 | waitforTimeout: 10000, 38 | connectionRetryTimeout: 120000, 39 | connectionRetryCount: 3, 40 | reporters: [ "spec" ], 41 | mochaOpts: { 42 | ui: "bdd", 43 | timeout: 60000 44 | }, 45 | }; 46 | -------------------------------------------------------------------------------- /packages/uxp-webdriver/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | */ 13 | 14 | const { startServer } = require("./lib/uxp_webdriver_server"); 15 | const yargs = require("yargs"); 16 | 17 | const DEFAULT_HOST = "localhost"; 18 | const DEFAULT_PORT = 4797; 19 | 20 | async function main() { 21 | let port = yargs.argv.port || DEFAULT_PORT; 22 | let host = yargs.argv.host || DEFAULT_HOST; 23 | return startServer(port, host); 24 | } 25 | 26 | main(); 27 | -------------------------------------------------------------------------------- /packages/uxp-webdriver/lib/atoms/active.js: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 4 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. You may obtain a copy 6 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software distributed under 9 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 10 | * OF ANY KIND, either express or implied. See the License for the specific language 11 | * governing permissions and limitations under the License. 12 | * 13 | */ 14 | 15 | // these functions are not part of automation atoms per se - but js methods specific to Uxp automation. 16 | var ACTIVE_ELEMENT = function() { 17 | return document.activeElement; 18 | }; 19 | module.exports = ACTIVE_ELEMENT; 20 | -------------------------------------------------------------------------------- /packages/uxp-webdriver/lib/atoms/click.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | */ 13 | 14 | var CLICK = "function (element) { \ 15 | element.click(); \ 16 | }"; 17 | 18 | module.exports = CLICK; 19 | -------------------------------------------------------------------------------- /packages/uxp-webdriver/lib/atoms/find_elements_by_xpath.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | */ 13 | 14 | var ELEMENT_FIND_XPATH = function(xpathExpression, context) { // context is the node within which the element should be looked for 15 | var searchNode = context ? context : document; 16 | var nodeSnapshot = document.evaluate(xpathExpression, searchNode, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); 17 | let results = []; 18 | for (let i = 0; i < nodeSnapshot.snapshotLength; i++) { 19 | results.push(nodeSnapshot.snapshotItem(i)); 20 | } 21 | return results; 22 | }; 23 | 24 | module.exports = ELEMENT_FIND_XPATH; 25 | -------------------------------------------------------------------------------- /packages/uxp-webdriver/lib/atoms/getCssProperty.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | */ 13 | 14 | var EFFECIVE_CSS_STYLE = function(...args) { 15 | var [ elem, style ] = args; 16 | var getComputedStyle = document.defaultView && document.defaultView.getComputedStyle; 17 | if (getComputedStyle) { 18 | var cssDecl = getComputedStyle(elem); 19 | return cssDecl.getPropertyValue(style); 20 | } 21 | throw new Error("Cannot compute style property : " + stlye + " of the element"); 22 | }; 23 | module.exports = EFFECIVE_CSS_STYLE; 24 | -------------------------------------------------------------------------------- /packages/uxp-webdriver/lib/atoms/getName.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | */ 13 | 14 | var ELEM_TAGNAME = "function(elem) { return elem.tagName.toLowerCase(); }"; 15 | module.exports = ELEM_TAGNAME; 16 | -------------------------------------------------------------------------------- /packages/uxp-webdriver/lib/atoms/getProperty.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | */ 13 | 14 | /* 15 | * The UXP function is in accordance with the atoms referenced link 16 | * https://github.com/SeleniumHQ/selenium/blob/master/javascript/atoms/domcore.js#L143 17 | */ 18 | 19 | 20 | var GET_PROPERTY = "function(...args) { var elem = args[0]; var propertyName = args[1]; return elem.propertyName;}"; 21 | module.exports = GET_PROPERTY; 22 | -------------------------------------------------------------------------------- /packages/uxp-webdriver/lib/atoms/getSize.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | */ 13 | 14 | var GET_SIZE = "function(){return function(){function d(a,b){function c(){}c.prototype=b.prototype;a.b=b.prototype;a.prototype=new c};function e(a){this.stack=Error().stack||\"\";if(a)this.message=String(a)}d(e,Error);function f(a){for(var b=1;b setTimeout(resolve, ms)); 17 | } 18 | 19 | function normalizeScreenRectForRobotJS(screenRect) { 20 | var robotJS = require("robotjs"); 21 | var sr = { 22 | x: screenRect.x || screenRect.left, 23 | y: screenRect.y || screenRect.top, 24 | width: screenRect.width, 25 | height: screenRect.height 26 | }; 27 | 28 | sr.x = parseInt(sr.x); sr.y = parseInt(sr.y); 29 | sr.width = parseInt(sr.width); sr.height = parseInt(sr.height); 30 | 31 | if (process.platform.toLowerCase() === "darwin") { 32 | /* 33 | * screen rect 0,0 is bottom left on MacOS - we need to convert this to one compatible with 34 | * robotJS which uses top-left as 0,0. 35 | */ 36 | let screenSize = robotJS.getScreenSize(); 37 | // invert the y. 38 | sr.y = screenSize.height - (sr.y + sr.height); 39 | } 40 | return sr; 41 | } 42 | 43 | module.exports = { 44 | sleep, 45 | normalizeScreenRectForRobotJS 46 | }; 47 | -------------------------------------------------------------------------------- /packages/uxp-webdriver/lib/uxpPrepareExtAutomation.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | */ 13 | 14 | var PREAPRE_EXTENSION_FOR_AUTOMATION = function() { 15 | /* 16 | * inject all the details that are currently missing in Uxp and 17 | * which are required for Uxp automation scripts to work. 18 | */ 19 | document.defaultView = window; 20 | }; 21 | 22 | module.exports = PREAPRE_EXTENSION_FOR_AUTOMATION; 23 | -------------------------------------------------------------------------------- /packages/uxp-webdriver/lib/uxp_webdriver_server.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | */ 13 | 14 | const { server, routeConfiguringFunction } = require("appium-base-driver"); 15 | const UxpDriver = require("./uxp_driver"); 16 | const baseServer = server; 17 | 18 | async function startServer(port, address) { 19 | const driver = new UxpDriver({ port, address }); 20 | const server = await baseServer({ 21 | routeConfiguringFunction: routeConfiguringFunction(driver), 22 | port, 23 | hostname: address, 24 | }); 25 | console.log(`Uxp server listening on http://${address}:${port}`); 26 | return server; 27 | } 28 | module.exports = { startServer }; 29 | -------------------------------------------------------------------------------- /packages/uxp-webdriver/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@adobe/uxp_web_driver", 3 | "version": "2.2.1", 4 | "main": "uxp_driver_export.js", 5 | "scripts": { 6 | "run": "node index.js", 7 | "watch": "nodemon index.js", 8 | "linter": "eslint --ext .js,.jsx lib,index.js", 9 | "linter:fix": "eslint --ext .js,.jsx lib,index.js --fix" 10 | }, 11 | "dependencies": { 12 | "appium-base-driver": "5.8.1", 13 | "jimp": "^0.14.0", 14 | "puppeteer-core": "9.1.1", 15 | "robotjs": "0.6.0", 16 | "yargs": "^12.0.5" 17 | } 18 | } -------------------------------------------------------------------------------- /packages/uxp-webdriver/uxp_driver_export.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | */ 13 | 14 | const { startServer } = require("./lib/uxp_webdriver_server"); 15 | 16 | const DEFAULT_HOST = "localhost"; 17 | const DEFAULT_PORT = 4797; 18 | 19 | async function startUXPDriver(port = DEFAULT_PORT, host = DEFAULT_HOST) { 20 | return startServer(port, host); 21 | } 22 | 23 | module.exports = { startUXPDriver }; 24 | 25 | -------------------------------------------------------------------------------- /scripts/cleanup.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | */ 13 | 14 | const fs = require("fs"); 15 | const { getUxpGlobalLocation } = require("./common"); 16 | 17 | function cleanUpUxpSymLink() { 18 | const { uxpBinPath } = getUxpGlobalLocation(); 19 | if (fs.existsSync(uxpBinPath)) { 20 | console.log(`Deleting the sym-link to uxp main script file ${uxpBinPath}`); 21 | fs.unlinkSync(uxpBinPath); 22 | } 23 | } 24 | 25 | cleanUpUxpSymLink(); 26 | -------------------------------------------------------------------------------- /scripts/common.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Adobe Systems Incorporated. All rights reserved. 3 | * This file is licensed to you under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. You may obtain a copy 5 | * of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | * 7 | * Unless required by applicable law or agreed to in writing, software distributed under 8 | * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS 9 | * OF ANY KIND, either express or implied. See the License for the specific language 10 | * governing permissions and limitations under the License. 11 | * 12 | */ 13 | 14 | const path = require("path"); 15 | const { execSync } = require("child_process"); 16 | 17 | function getYarnGlobalBinFolder() { 18 | const binPath = execSync("yarn global bin"); 19 | return binPath.toString().trim(); 20 | } 21 | 22 | function getUxpGlobalLocation() { 23 | const mainScriptFile = path.resolve(__dirname, "../packages/uxp-devtools-cli/src/uxp.js"); 24 | const yarnBinPath = getYarnGlobalBinFolder(); 25 | if (!yarnBinPath) { 26 | throw new Error("Failed to install the cli scripts in yarn bin folder"); 27 | } 28 | const uxpBinPath = path.resolve(yarnBinPath, "uxp"); 29 | return { 30 | mainScriptFile, 31 | uxpBinPath, 32 | }; 33 | } 34 | 35 | module.exports = { 36 | getUxpGlobalLocation, 37 | getYarnGlobalBinFolder, 38 | }; 39 | --------------------------------------------------------------------------------