Skip to content

Commit

Permalink
Fix Chrome re-opening for pnp (tajo#172)
Browse files Browse the repository at this point in the history
* Fix Chrome re-opening for pnp

* Fix tsc

* Add hiring link
  • Loading branch information
tajo authored Jun 23, 2022
1 parent 04714c9 commit 5049ce9
Show file tree
Hide file tree
Showing 6 changed files with 3,577 additions and 298 deletions.
5 changes: 5 additions & 0 deletions .changeset/tame-singers-visit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ladle/react": patch
---

Fix Chrome (tab) re-opening for pnp environments..
1 change: 1 addition & 0 deletions packages/ladle/build-cjs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ pnpm babel lib/cli --out-dir cjs/lib/cli --plugins=@babel/plugin-transform-modul
pnpm babel lib/shared --out-dir cjs/lib/shared --plugins=@babel/plugin-transform-modules-commonjs
pnpm babel api --out-dir cjs/api --plugins=@babel/plugin-transform-modules-commonjs
cp lib/shared/types.ts cjs/lib/shared/types.ts
cp lib/cli/openChrome.applescript cjs/lib/cli/openChrome.applescript
cp lib/shared/default-config.js cjs/lib/app/src/def-config.ts
./build-cjs.js
13 changes: 12 additions & 1 deletion packages/ladle/lib/cli/open-browser.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-var-requires */
// adapted from https://github.com/facebook/create-react-app/blob/main/packages/react-dev-utils/openBrowser.js

import { dirname } from "path";
Expand Down Expand Up @@ -106,14 +107,24 @@ function startBrowserProcess(browser, url, args) {
// Try our best to reuse existing tab
// on OSX Chromium-based browser with AppleScript
execSync('ps cax | grep "' + chromiumBrowser + '"');
let cwd = __dirname;

// in pnp we need to get cwd differently
if (process.versions.pnp) {
// @ts-ignore
const pnpApi = require("pnpapi");
if (typeof pnpApi.resolveVirtual === "function") {
cwd = pnpApi.resolveVirtual(cwd) || cwd;
}
}
execSync(
'osascript openChrome.applescript "' +
encodeURI(url) +
'" "' +
chromiumBrowser +
'"',
{
cwd: __dirname,
cwd,
stdio: "ignore",
},
);
Expand Down
3 changes: 2 additions & 1 deletion packages/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
},
"dependencies": {
"@algolia/client-search": "4.9.1",
"@types/react": "^17.0.0",
"@docusaurus/core": "2.0.0-beta.18",
"@docusaurus/preset-classic": "2.0.0-beta.18",
"@docusaurus/theme-common": "2.0.0-beta.21",
"@mdx-js/react": "^1.6.22",
"@types/react": "^17.0.0",
"clsx": "^1.1.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
Expand Down
48 changes: 48 additions & 0 deletions packages/website/src/theme/Footer/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import React from "react";
import { useThemeConfig } from "@docusaurus/theme-common";
import FooterLinks from "@theme/Footer/Links";
import FooterLogo from "@theme/Footer/Logo";
import FooterCopyright from "@theme/Footer/Copyright";
import FooterLayout from "@theme/Footer/Layout";

function Footer() {
const { footer } = useThemeConfig();

if (!footer) {
return null;
}

const { copyright, links, logo, style } = footer;
return (
<>
<p
style={{
backgroundColor: "rgb(239, 243, 254)",
padding: "16px",
margin: "32px auto",
maxWidth: "630px",
textAlign: "center",
borderRadius: "16px",
}}
>
Do you want to work on Ladle and other web tooling? Our team at Uber is{" "}
<a href="https://www.uber.com/global/en/careers/list/108900/">hiring</a>
!
</p>
<FooterLayout
style={style}
links={links && links.length > 0 && <FooterLinks links={links} />}
logo={logo && <FooterLogo logo={logo} />}
copyright={copyright && <FooterCopyright copyright={copyright} />}
/>
</>
);
}

export default React.memo(Footer);
Loading

0 comments on commit 5049ce9

Please sign in to comment.