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

fix: replace keys correctly in js(x) #1112

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions dist/samples/programmatic-load-button/app/index.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions dist/samples/programmatic-load-button/docs/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions dist/samples/programmatic-load-button/jsfiddle/demo.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions dist/samples/programmatic-load-button/playground/index.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/samples/programmatic-load/app/index.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion dist/samples/react-map/app/index.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion dist/samples/react-map/docs/index.jsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion dist/samples/react-map/jsfiddle/demo.jsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion dist/samples/react-map/playground/index.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions samples/programmatic-load-button/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@ const center = { lat: 41.90476224706472, lng: 12.49822074385094 };
const zoom = 14;
const url = "https://maps.googleapis.com/maps/api/staticmap";

// @ts-ignore google.maps.plugins
const apiKey = "YOUR_API_KEY";

const loader = new Loader({
apiKey: "YOUR_API_KEY",
apiKey,
version: "weekly",
});

document.addEventListener("DOMContentLoaded", () => {
const wrapper = document.getElementById("wrapper") as HTMLButtonElement;

wrapper.style.backgroundImage = `url(${url}?center=${center.lat},${center.lng}&zoom=${zoom}&scale=2&size=${wrapper.clientWidth}x${wrapper.clientHeight}&key=YOUR_API_KEY)`;
wrapper.style.backgroundImage = `url(${url}?center=${center.lat},${center.lng}&zoom=${zoom}&scale=2&size=${wrapper.clientWidth}x${wrapper.clientHeight}&key=${apiKey})`;

wrapper.addEventListener("click", () => {
wrapper.remove();
Expand Down
4 changes: 3 additions & 1 deletion samples/react-map/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ const render = (status: Status) => {
return <h1>{status}</h1>;
};

const apiKey = "YOUR_API_KEY";

const App: React.VFC = () => {
// [START maps_react_map_component_app_state]
const [clicks, setClicks] = React.useState<google.maps.LatLng[]>([]);
Expand Down Expand Up @@ -96,7 +98,7 @@ const App: React.VFC = () => {
// [START maps_react_map_component_app_return]
return (
<div style={{ display: "flex", height: "100%" }}>
<Wrapper apiKey={"YOUR_API_KEY"} render={render}>
<Wrapper apiKey={apiKey} render={render}>
<Map
center={center}
onClick={onClick}
Expand Down
4 changes: 2 additions & 2 deletions src/transforms/your-api-key.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ module.exports = function (content, outputPath) {
if (/app\/index\.tsx?$/.test(outputPath)) {
content = content.replace(
/"YOUR_API_KEY"/g,
"import.meta.env.VITE_GOOGLE_MAPS_API_KEY!"
"import.meta.env.VITE_GOOGLE_MAPS_API_KEY"
);
}

if (outputPath.endsWith("playground/index.ts")) {
if (/playground\/index\.tsx?$/.test(outputPath)) {
content = content.replace(
/"YOUR_API_KEY"/g,
"process.env.GOOGLE_MAPS_API_KEY!"
Expand Down