Skip to content

Commit

Permalink
Fix CLI & add package alt resource routes to node.js
Browse files Browse the repository at this point in the history
  • Loading branch information
texodus committed May 7, 2023
1 parent 18b24b5 commit 9af75c2
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 17 deletions.
10 changes: 4 additions & 6 deletions packages/perspective-cli/src/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,18 @@
<!DOCTYPE html>
<html>
<head>
<meta
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"
/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" />

<title>Perspective App</title>

<script type="module" src="perspective.js"></script>
<script type="module" src="perspective-viewer.js"></script>
<script type="module" src="perspective-viewer-datagrid.js"></script>
<script type="module" src="perspective-viewer-d3fc.js"></script>
<script type="module" src="perspective-viewer-openlayers.js"></script>
<script type="module" src="perspective-workspace.js"></script>

<link rel="stylesheet" href="pro-dark.css" />
<link rel="stylesheet" crossorigin="anonymous" href="@finos/perspective-viewer/dist/css/pro.css" />
<link rel="stylesheet" crossorigin="anonymous" href="@finos/perspective-workspace/dist/css/pro.css" />

<style>
perspective-workspace {
Expand Down
2 changes: 1 addition & 1 deletion packages/perspective-cli/src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ program
.option("-o, --open", "Open a browser automagically.")
.action(host);

if (require.main === module) {
if (require.main.path.endsWith("perspective-cli")) {
if (!process.argv.slice(2).length) {
program.help();
} else {
Expand Down
2 changes: 1 addition & 1 deletion packages/perspective/src/js/perspective.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const WARNED_KEYS = new Set();
* The main API module for `@finos/perspective`.
*
* For more information, see the
* [Javascript user guide](https://perspective.finos.org/docs/md/js.html).
* [Javascript user guide](https://perspective.finos.org/docs/js.html).
*
* @module perspective
*/
Expand Down
25 changes: 16 additions & 9 deletions packages/perspective/src/js/perspective.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,22 @@ function perspective_assets(assets, host_psp) {
if (host_psp || typeof host_psp === "undefined") {
for (let rootDir of DEFAULT_ASSETS) {
try {
let paths = require.resolve.paths(rootDir + url);
paths = [
...paths,
...assets.map((x) => path.join(x, "node_modules")),
LOCAL_PATH,
];
let filePath = require.resolve(rootDir + url, {
paths,
});
let filePath;
if (url.startsWith("/" + rootDir)) {
filePath = require.resolve(url.slice(1));
} else {
let paths = require.resolve.paths(rootDir + url);
paths = [
...paths,
...assets.map((x) =>
path.join(x, "node_modules")
),
LOCAL_PATH,
];
filePath = require.resolve(rootDir + url, {
paths,
});
}
let content = await read_promise(filePath);
if (typeof content !== "undefined") {
console.log(`200 ${url}`);
Expand Down

0 comments on commit 9af75c2

Please sign in to comment.