Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat: enable appium-inspector as an appium plugin #1878

Merged
merged 60 commits into from
Jan 3, 2025

Conversation

KazuCocoa
Copy link
Member

@KazuCocoa KazuCocoa commented Jan 1, 2025

Complete partially in appium/appium#20834

Final PR instead of #1868, which was ordinally just for a prototype.

After this PR merge, we should run npm publish as README's release section in this PR if needed for now. I'll also create a follow-up PR to make it automated as part of the existing workflow https://github.com/appium/appium-inspector/blob/main/.github/workflows/package.yml to push the npm package as well.

@@ -34,16 +34,19 @@
"build": "npm run build:browser && npm run build:electron",
"build:browser": "vite build",
"build:browser:url": "vite build --base $PUBLIC_URL",
"build:plugin": "vite build --base /inspector --outDir ../../plugins/dist-browser",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should it be a part of the common build script?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to include this in build after completing npm publish work as well, so yes but not yet in this PR.

"build:electron": "electron-vite build",
"preview:browser": "npm run build:browser && vite preview",
"preview:electron": "electron-vite preview",
"pack:electron": "electron-builder build --publish never",
"clean": "npm run clean:electron && npm run clean:browser && npm run clean:npm",
"clean:electron": "rimraf dist/ && rimraf node_modules/.vite/ && rimraf node_modules/.vite-electron-renderer/",
"clean:browser": "rimraf dist-browser/ && rimraf node_modules/.vite/",
"clean:plugin": "rimraf plugins/dist-browser",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

"clean:npm": "rimraf package-lock.json && rimraf node_modules && npm install",
"build:docs": "appium-docs build",
"dev:docs": "appium-docs build --serve",
"plugin:sync:version": "node ./scripts/sync-plugin.mjs",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above


(TODO: add this release steps in .github/workflows/package.yml later as another PR)

1. Run `npm run plugin:sync:version` to sync the version with the root project.json
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say this script should be executed automatically as soon as we bump the version of the main project via npm version

Copy link
Member Author

@KazuCocoa KazuCocoa Jan 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. It will be a follow-up PR to treat npm publish stuff in my current plan.

@KazuCocoa
Copy link
Member Author

KazuCocoa commented Jan 2, 2025

Local version: seems to open, but unfortunately it does not load the English translations, which means that many places use the raw translation keys, making it difficult to navigate.

How could I check it?
e.g. on my local with the Development steps:
Screenshot 2025-01-02 at 12 29 31 AM

@eglitise

(npm install is out of scope for now as I haven't tested it well yet. We may need to push with latest, and potentially need to do more)

@eglitise
Copy link
Collaborator

eglitise commented Jan 2, 2025

How could I check it?

When I activate the plugin and open the inspector page, Appium logs all the HTTP requests, which is where I am observing the 404 response:

[HTTP] --> GET /inspector {}
[HTTP] <-- GET /inspector 200 18 ms - 334
[HTTP] --> GET /inspector/assets/index-CNB9fSg_.css {}
[HTTP] --> GET /inspector/assets/index-B5YrvsL3.js {}
[HTTP] <-- GET /inspector/assets/index-CNB9fSg_.css 200 10 ms - 691539
[HTTP] <-- GET /inspector/assets/index-B5YrvsL3.js 200 2 ms - 6732856
[HTTP] --> GET /locales/en/translation.json {}
[HTTP] No route found for /locales/en/translation.json
[HTTP] <-- GET /locales/en/translation.json 404 5 ms - 211

@KazuCocoa
Copy link
Member Author

I see. Then, maybe somewhere may have hard code to /locales where is not modified with --base option in vite.

const localesPath =
process.env.NODE_ENV === 'development'
? '/locales' // 'public' folder contents are served at '/'
: '../locales'; // from 'dist-browser/assets/'
?

@eglitise
Copy link
Collaborator

eglitise commented Jan 2, 2025

It is confusing that the locales load fine for you, though 🤔 maybe the translations are cached? If I open a new private window/incognito, the cache is cleared and I get the 404 again.

@eglitise
Copy link
Collaborator

eglitise commented Jan 2, 2025

This seems to do the trick and works correctly in both web and plugin builds:

// Adjust locales path depending on Vite base (web vs plugin)
const viteBase = import.meta.env.BASE_URL;
const vitePath = viteBase.endsWith('/') ? viteBase : `${viteBase}/`;

const localesPath =
  process.env.NODE_ENV === 'development'
    ? '/locales' // 'public' folder contents are served at '/'
    : `..${vitePath}locales`; // from 'dist-browser/assets/'

@KazuCocoa
Copy link
Member Author

Yea, my env could be the browser cache reason.

@KazuCocoa KazuCocoa merged commit d97228f into main Jan 3, 2025
7 checks passed
@KazuCocoa KazuCocoa deleted the appium-inspector-plugin branch January 3, 2025 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants