Skip to content

Commit

Permalink
Renames
Browse files Browse the repository at this point in the history
  • Loading branch information
devinrsmith committed Dec 13, 2023
1 parent bcde5ff commit 3eb9c3d
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 33 deletions.
24 changes: 12 additions & 12 deletions plugin/src/main/java/io/deephaven/plugin/js/JsPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static Builder builder() {
public abstract String version();

/**
* The main JS file path, specified relative to {@link #rootPath()}. The main JS file must exist
* The main JS file path, specified relative to {@link #path()}. The main JS file must exist
* ({@code Files.isRegularFile(root().resolve(main()))}) and must be included in {@link #paths()}. Will be included
* as the "main" field for the manifest entry in "js-plugins/manifest.json".
*
Expand All @@ -53,15 +53,15 @@ public static Builder builder() {
public abstract Path main();

/**
* The root directory path of the resources to serve. The root must exist ({@code Files.isDirectory(root())}).
* The directory path of the resources to serve. The path must exist ({@code Files.isDirectory(path())}).
*
* @return the root
* @return the path
*/
public abstract Path rootPath();
public abstract Path path();

/**
* The paths to serve, specified relative to {@link #rootPath()}. The resources will be served via the URL path
* "js-plugins/{name}/{pathRelativeToRoot}". By default, is {@link Paths#all()}.
* The paths to serve, specified relative to {@link #path()}. The resources will be served via the URL path
* "js-plugins/{name}/{relativePath}". By default, is {@link Paths#all()}.
*
* @return the paths
*/
Expand All @@ -76,15 +76,15 @@ public final <T, V extends Plugin.Visitor<T>> T walk(V visitor) {
}

@Check
final void checkRootPath() {
if (!Files.isDirectory(rootPath())) {
throw new IllegalArgumentException(String.format("rootPath ('%s') must exist and be a directory", rootPath()));
final void checkPath() {
if (!Files.isDirectory(path())) {
throw new IllegalArgumentException(String.format("path ('%s') must exist and be a directory", path()));
}
}

@Check
final void checkMain() {
final Path mainPath = rootPath().resolve(main());
final Path mainPath = path().resolve(main());
if (!Files.isRegularFile(mainPath)) {
throw new IllegalArgumentException(String.format("main ('%s') must exist and be a regular file", mainPath));
}
Expand All @@ -95,7 +95,7 @@ final void checkPaths() {
if (!(paths() instanceof PathsInternal)) {
throw new IllegalArgumentException("Must construct one of the approved Paths");
}
final Path relativeMain = rootPath().relativize(rootPath().resolve(main()));
final Path relativeMain = path().relativize(path().resolve(main()));
if (!((PathsInternal) paths()).matches(relativeMain)) {
throw new IllegalArgumentException(String.format("main ('%s') is not in paths", relativeMain));
}
Expand All @@ -108,7 +108,7 @@ public interface Builder {

Builder main(Path main);

Builder rootPath(Path rootPath);
Builder path(Path path);

Builder paths(Paths paths);

Expand Down
7 changes: 2 additions & 5 deletions py/server/deephaven_internal/plugin/js/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@


def to_j_js_plugin(js_plugin: JsPlugin) -> jpy.JType:
with js_plugin.path() as tmp_path:
path = tmp_path
if not path.exists():
raise NotImplementedError(f"The Deephaven JsPlugin server-side currently only supports normal filesystem resources. {js_plugin}")
main_path = root_path.relativize(root_path.resolve(js_plugin.main))
j_path = _JPath.of(str(js_plugin.path))
main_path = j_path.relativize(j_path.resolve(js_plugin.main))
builder = _JJsPlugin.builder()
builder.name(js_plugin.name)
builder.version(js_plugin.version)
Expand Down
2 changes: 1 addition & 1 deletion py/server/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def _compute_version():
python_requires='>=3.8',
install_requires=[
'jpy>=0.14.0',
'deephaven-plugin==0.5.0',
'deephaven-plugin>=0.6.0',
'numpy',
'pandas>=1.5.0',
'pyarrow',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public synchronized void add(JsPlugin plugin) throws IOException {
// If listing and traversing the contents of development directories (and skipping the copy) becomes
// too expensive, we can add logic here wrt PathsInternal/PathsPrefix to specify a dirMatcher. Or,
// properly route directly from the filesystem via Jetty.
CopyHelper.copyRecursive(plugin.rootPath(), dstPath, pathMatcher);
CopyHelper.copyRecursive(plugin.path(), dstPath, pathMatcher);
plugins.add(plugin);
writeManifest(fs);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,36 +32,36 @@ public void registerInto(Callback callback) {
}

private static JsPlugin example1() throws URISyntaxException {
final Path resourceRoot = Path.of(Sentinel.class.getResource("examples/@deephaven_test/example1").toURI());
final Path main = resourceRoot.relativize(resourceRoot.resolve("dist/index.js"));
final Path resourcePath = Path.of(Sentinel.class.getResource("examples/@deephaven_test/example1").toURI());
final Path main = resourcePath.relativize(resourcePath.resolve("dist/index.js"));
return JsPlugin.builder()
.name("@deephaven_test/example1")
.version("0.1.0")
.main(main)
.rootPath(resourceRoot)
.path(resourcePath)
.build();
}

private static JsPlugin example2() throws URISyntaxException {
final Path resourceRoot = Path.of(Sentinel.class.getResource("examples/@deephaven_test/example2").toURI());
final Path main = resourceRoot.relativize(resourceRoot.resolve("dist/index.js"));
final Path resourcePath = Path.of(Sentinel.class.getResource("examples/@deephaven_test/example2").toURI());
final Path main = resourcePath.relativize(resourcePath.resolve("dist/index.js"));
return JsPlugin.builder()
.name("@deephaven_test/example2")
.version("0.2.0")
.main(main)
.rootPath(resourceRoot)
.path(resourcePath)
.paths(Paths.ofPrefixes(main))
.build();
}

private static JsPlugin example3() throws URISyntaxException {
final Path resourceRoot = Path.of(Sentinel.class.getResource("examples/@deephaven_test/example3").toURI());
final Path main = resourceRoot.relativize(resourceRoot.resolve("index.js"));
final Path resourcePath = Path.of(Sentinel.class.getResource("examples/@deephaven_test/example3").toURI());
final Path main = resourcePath.relativize(resourcePath.resolve("index.js"));
return JsPlugin.builder()
.name("@deephaven_test/example3")
.version("0.3.0")
.main(main)
.rootPath(resourceRoot)
.path(resourcePath)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static JsPlugin of(Path packageRoot) throws IOException {
.name(packageJson.name())
.version(packageJson.version())
.main(main)
.rootPath(packageRoot)
.path(packageRoot)
.paths(paths);
return builder.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* configuration is meant for development-oriented use-cases and is done on a "best-effort" basis.
*
* <p>
* The configuration value of the above property corresponds to the {@link JsPlugin#rootPath()} directory. A
* The configuration value of the above property corresponds to the {@link JsPlugin#path()} directory. A
* {@value PACKAGE_JSON} must exist in this directory (as specified via
* <a href="https://docs.npmjs.com/cli/v6/configuring-npm/package-json">package-json</a>). The {@value NAME} json value
* corresponds to {@link JsPlugin#name()}, the {@value VERSION} json value corresponds to {@link JsPlugin#version()},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ static List<JsPlugin> of(Path manifestRoot) throws IOException {
final JsPluginManifest manifest = JsPluginManifest.read(manifestRoot.resolve(JsPluginManifest.MANIFEST_JSON));
final List<JsPlugin> plugins = new ArrayList<>(manifest.plugins().size());
for (JsPluginManifestEntry entry : manifest.plugins()) {
final Path pluginRoot = manifestRoot.resolve(entry.name());
final Path pluginMain = pluginRoot.relativize(pluginRoot.resolve(entry.main()));
final Path pluginPath = manifestRoot.resolve(entry.name());
final Path pluginMain = pluginPath.relativize(pluginPath.resolve(entry.main()));
final JsPlugin plugin = JsPlugin.builder()
.name(entry.name())
.version(entry.version())
.main(pluginMain)
.rootPath(pluginRoot)
.path(pluginPath)
.build();
// We expect manifests to be "production" use cases - they should already be packed as appropriate.
// Additionally, there is no strict requirement that they have package.json anyways.
Expand Down

0 comments on commit 3eb9c3d

Please sign in to comment.