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: geocoder demo on windows #1140 #1177

Merged
merged 2 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions demos/geocoder-browser/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Running this demo

1. Make sure you run `npm run bootstrap` in the root folder to setup the dependencies
1. Make sure you run `npm run build` in the root folder to setup the dependencies
2. Register a new app on https://developers.arcgis.com
3. Add a redirect URL of `http://localhost:8080/post-sign-in.html` to your app.
3. Add a redirect URL of `https://localhost:8080/authenticate.html` to your app.
4. Copy the `config.js.template` file, rename it to `config.js`
5. Copy your apps client id into your new `config.js` file.
6. `npm start`
7. Visit http://localhost:8080 and click "Sign In" to start the OAuth 2.0 process.
7. Visit https://localhost:8080 and click "Sign In" to start the OAuth 2.0 process.
8. Start clicking buttons to send off authenticated geocoding requests.

**Note:** The server starts with a special configuration to serve URLs starting with `@esri/arcgis-rest-*` from their respective packages. In your application you will need to change these URLs to point to their respective locations.
2 changes: 1 addition & 1 deletion demos/geocoder-browser/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ <h1>get to geocodin!</h1>
authBtn.addEventListener('click', function (e) {
arcgisRest.ArcGISIdentityManager.beginOAuth2({
clientId: ClientId,
redirectUri: "http://localhost:8080/authenticate.html",
redirectUri: "https://localhost:8080/authenticate.html",
popup: true,
portal: "https://www.arcgis.com/sharing/rest"
}).then((session) => {
Expand Down
11 changes: 7 additions & 4 deletions scripts/get-package-json.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { readFile } from "fs/promises";
import { globby } from "globby";
import pkgDir from "pkg-dir";
import { join, dirname } from "path";
import { posix } from "path";
import { fileURLToPath } from "url";

const __dirname = dirname(new URL(import.meta.url).pathname);
const __dirname = fileURLToPath(new URL('.', import.meta.url)).replace(/\\/g, '/');

/**
* Returns an object like:
Expand All @@ -15,8 +16,10 @@ const __dirname = dirname(new URL(import.meta.url).pathname);
* For all packages in the packages/* folder.
*/
export default async function getPackages() {
const rootDir = await pkgDir(__dirname);
const packageFiles = await globby(join(rootDir, "packages/*/package.json"));
const rootDir = (await pkgDir(__dirname)).replace(/\\/g, "/");

const packageFiles = await globby(posix.join(rootDir, "packages/*/package.json"));

return Promise.all(
packageFiles.map((pkgPath) => {
return readFile(pkgPath).then((pkg) => {
Expand Down
7 changes: 4 additions & 3 deletions scripts/run-demo-server.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import browserSync from "browser-sync";
import { join, resolve, dirname } from "path";
import { resolve, posix } from "path";
import { fileURLToPath } from "url";
import getPackages from "./get-package-json.js";

(async () => {
const cwd = process.cwd();
const packages = await getPackages();
const __dirname = dirname(new URL(import.meta.url).pathname);
const __dirname = fileURLToPath(new URL('.', import.meta.url)).replace(/\\/g, '/');
const packageFolders = packages.map(({ name }) => {
return {
route: `/${name}`,
dir: resolve(join(__dirname, "../", "node_modules", name))
dir: resolve(posix.join(__dirname, "../", "node_modules", name))
};
});

Expand Down
Loading