@thatopen/services 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/commands/rhino.d.ts +11 -0
- package/dist/cli/lib/plugin-install.d.ts +24 -0
- package/dist/cli.js +120 -0
- package/package.json +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* `thatopen rhino ...` — installs the That Open Rhino plug-in.
|
|
5
|
+
*
|
|
6
|
+
* Deliberately much smaller than the Revit group. The Rhino plug-in's whole job in the
|
|
7
|
+
* interoperability layer is to PUBLISH what Rhino has; it applies nothing, so there is nothing to
|
|
8
|
+
* drive from here. Everything that turns a Rhino model into a change in somebody else's model lives
|
|
9
|
+
* in the platform, not in a plug-in.
|
|
10
|
+
*/
|
|
11
|
+
export declare const rhinoCommand: Command;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { EngineServicesClient } from '../../core/client';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Downloads a private plug-in package and hands back the folder it unpacked into.
|
|
5
|
+
*
|
|
6
|
+
* npm does the work on purpose. It resolves what "latest" means, it authenticates against the
|
|
7
|
+
* restricted scope, and it verifies the tarball's integrity — three things this would otherwise
|
|
8
|
+
* hand-roll over HTTP and get subtly wrong. The only thing we add is the platform token, which
|
|
9
|
+
* `setupNpmrc` trades for registry credentials exactly as the `--beta` flows do. No npm account is
|
|
10
|
+
* involved and no npm token is ever asked for.
|
|
11
|
+
*/
|
|
12
|
+
export declare function fetchPluginPackage(client: EngineServicesClient, pkg: string, version?: string): Promise<{
|
|
13
|
+
dir: string;
|
|
14
|
+
cleanup: () => void;
|
|
15
|
+
}>;
|
|
16
|
+
/**
|
|
17
|
+
* Refuses to install while the host application is running.
|
|
18
|
+
*
|
|
19
|
+
* This is not caution, it is the difference between a failed install and a broken one. Both Revit
|
|
20
|
+
* and Rhino hold their plug-in assemblies open for the whole session, so a copy over a running host
|
|
21
|
+
* fails on the first locked file — AFTER copying the ones it reached. The result is a folder holding
|
|
22
|
+
* some new DLLs and some old, which loads, misbehaves, and looks like a bug in the product.
|
|
23
|
+
*/
|
|
24
|
+
export declare function assertHostClosed(processName: string, friendly: string): void;
|
package/dist/cli.js
CHANGED
|
@@ -11686,6 +11686,60 @@ const swapCommand = new Command2("swap").description("Toggle between stable publ
|
|
|
11686
11686
|
console.error("Failed to install dependencies. Run `npm install` manually.");
|
|
11687
11687
|
}
|
|
11688
11688
|
});
|
|
11689
|
+
async function fetchPluginPackage(client, pkg2, version = "latest") {
|
|
11690
|
+
const work = require$$3.mkdtempSync(require$$2.join(node_os.tmpdir(), "thatopen-plugin-"));
|
|
11691
|
+
const cleanup = () => {
|
|
11692
|
+
try {
|
|
11693
|
+
require$$3.rmSync(work, { recursive: true, force: true });
|
|
11694
|
+
} catch {
|
|
11695
|
+
}
|
|
11696
|
+
};
|
|
11697
|
+
try {
|
|
11698
|
+
const creds = await setupNpmrc(client, work);
|
|
11699
|
+
if (creds.status === "forbidden") {
|
|
11700
|
+
throw new Error(
|
|
11701
|
+
"Your account does not have access to the private plug-in packages. They need Founding access, the same as the beta engine libraries."
|
|
11702
|
+
);
|
|
11703
|
+
}
|
|
11704
|
+
if (creds.status === "error") {
|
|
11705
|
+
throw new Error(`Could not get registry credentials: ${creds.message}`);
|
|
11706
|
+
}
|
|
11707
|
+
require$$1.execFileSync("npm", ["pack", `${pkg2}@${version}`, "--silent"], {
|
|
11708
|
+
cwd: work,
|
|
11709
|
+
stdio: ["ignore", "ignore", "inherit"],
|
|
11710
|
+
shell: process.platform === "win32"
|
|
11711
|
+
});
|
|
11712
|
+
const tgz = require$$3.readdirSync(work).find((f) => f.endsWith(".tgz"));
|
|
11713
|
+
if (!tgz) throw new Error(`npm pack produced no tarball for ${pkg2}@${version}.`);
|
|
11714
|
+
require$$1.execFileSync("tar", ["-xzf", tgz], { cwd: work, stdio: "inherit" });
|
|
11715
|
+
const dir = require$$2.join(work, "package");
|
|
11716
|
+
if (!require$$3.existsSync(dir)) throw new Error(`${tgz} did not unpack into a package/ folder.`);
|
|
11717
|
+
return { dir, cleanup };
|
|
11718
|
+
} catch (err) {
|
|
11719
|
+
cleanup();
|
|
11720
|
+
throw err;
|
|
11721
|
+
}
|
|
11722
|
+
}
|
|
11723
|
+
function assertHostClosed(processName, friendly) {
|
|
11724
|
+
let running = false;
|
|
11725
|
+
try {
|
|
11726
|
+
const out = require$$1.execFileSync(
|
|
11727
|
+
"powershell",
|
|
11728
|
+
["-NoProfile", "-Command", `if (Get-Process -Name ${processName} -ErrorAction SilentlyContinue) { 'yes' }`],
|
|
11729
|
+
{ encoding: "utf-8" }
|
|
11730
|
+
);
|
|
11731
|
+
running = out.trim() === "yes";
|
|
11732
|
+
} catch {
|
|
11733
|
+
return;
|
|
11734
|
+
}
|
|
11735
|
+
if (running) {
|
|
11736
|
+
throw new Error(
|
|
11737
|
+
`${friendly} is running. Close it and run this again.
|
|
11738
|
+
|
|
11739
|
+
Its plug-in files are locked while it is open, so installing now would replace some of them and not others.`
|
|
11740
|
+
);
|
|
11741
|
+
}
|
|
11742
|
+
}
|
|
11689
11743
|
function discoveryFile() {
|
|
11690
11744
|
const appData = process.env.APPDATA || require$$2.join(node_os.homedir(), "AppData", "Roaming");
|
|
11691
11745
|
return require$$2.join(appData, "ThatOpen", "revit-addin.json");
|
|
@@ -11746,6 +11800,7 @@ async function configureAddin(apiUrl, accessToken) {
|
|
|
11746
11800
|
key: accessToken
|
|
11747
11801
|
});
|
|
11748
11802
|
}
|
|
11803
|
+
const REVIT_ADDIN_PACKAGE = "@thatopen-platform/flow-revit";
|
|
11749
11804
|
const revitCommand = new Command2("revit").description(
|
|
11750
11805
|
"Revit collaboration — drive the That Open Revit add-in from the CLI"
|
|
11751
11806
|
);
|
|
@@ -11829,6 +11884,70 @@ revitCommand.command("untake").description("Release a workset you own so teammat
|
|
|
11829
11884
|
const r = await callAddin("untake", { workset: opts.workset });
|
|
11830
11885
|
console.log(`Released workset "${r.released}".`);
|
|
11831
11886
|
});
|
|
11887
|
+
revitCommand.command("install").alias("update").description("Install or update the That Open Revit add-in (Revit must be closed)").option("--version <version>", "A specific version instead of the latest", "latest").action(async (opts) => {
|
|
11888
|
+
const cfg = requireResolvedConfig();
|
|
11889
|
+
assertHostClosed("Revit", "Revit");
|
|
11890
|
+
const client = new EngineServicesClient(cfg.accessToken, cfg.apiUrl);
|
|
11891
|
+
console.log(`Fetching ${REVIT_ADDIN_PACKAGE}@${opts.version}...`);
|
|
11892
|
+
const { dir, cleanup } = await fetchPluginPackage(
|
|
11893
|
+
client,
|
|
11894
|
+
REVIT_ADDIN_PACKAGE,
|
|
11895
|
+
opts.version
|
|
11896
|
+
);
|
|
11897
|
+
try {
|
|
11898
|
+
const installer = require$$2.join(dir, "install.ps1");
|
|
11899
|
+
if (!require$$3.existsSync(installer)) {
|
|
11900
|
+
throw new Error(`The package has no install.ps1. Got: ${require$$3.readdirSync(dir).join(", ")}`);
|
|
11901
|
+
}
|
|
11902
|
+
require$$1.execFileSync("powershell", ["-ExecutionPolicy", "Bypass", "-File", installer], {
|
|
11903
|
+
stdio: "inherit"
|
|
11904
|
+
});
|
|
11905
|
+
console.log("\nStart Revit. The That Open tab will be there.");
|
|
11906
|
+
} finally {
|
|
11907
|
+
cleanup();
|
|
11908
|
+
}
|
|
11909
|
+
});
|
|
11910
|
+
const RHINO_PLUGIN_PACKAGE = "@thatopen-platform/flow-rhino";
|
|
11911
|
+
const rhinoCommand = new Command2("rhino").description(
|
|
11912
|
+
"Rhino interoperability — install the That Open Rhino plug-in"
|
|
11913
|
+
);
|
|
11914
|
+
rhinoCommand.command("install").alias("update").description("Install or update the That Open Rhino plug-in (Rhino must be closed)").option("--version <version>", "A specific version instead of the latest", "latest").action(async (opts) => {
|
|
11915
|
+
const cfg = requireResolvedConfig();
|
|
11916
|
+
assertHostClosed("Rhino", "Rhino");
|
|
11917
|
+
const yak = findYak();
|
|
11918
|
+
if (!yak) {
|
|
11919
|
+
throw new Error(
|
|
11920
|
+
"Could not find Yak.exe. It ships with Rhino, at C:\\Program Files\\Rhino 8\\System\\Yak.exe. Is Rhino 8 installed?"
|
|
11921
|
+
);
|
|
11922
|
+
}
|
|
11923
|
+
const client = new EngineServicesClient(cfg.accessToken, cfg.apiUrl);
|
|
11924
|
+
console.log(`Fetching ${RHINO_PLUGIN_PACKAGE}@${opts.version}...`);
|
|
11925
|
+
const { dir, cleanup } = await fetchPluginPackage(client, RHINO_PLUGIN_PACKAGE, opts.version);
|
|
11926
|
+
try {
|
|
11927
|
+
const pkgDir = require$$2.join(dir, "pkg");
|
|
11928
|
+
const yakFile = require$$3.existsSync(pkgDir) ? require$$3.readdirSync(pkgDir).find((f) => f.endsWith(".yak")) : void 0;
|
|
11929
|
+
if (!yakFile) {
|
|
11930
|
+
throw new Error(`The package has no .yak under pkg/. Got: ${require$$3.readdirSync(dir).join(", ")}`);
|
|
11931
|
+
}
|
|
11932
|
+
require$$1.execFileSync(yak, ["install", "--source", ".", "rhino-flow"], {
|
|
11933
|
+
cwd: pkgDir,
|
|
11934
|
+
stdio: "inherit"
|
|
11935
|
+
});
|
|
11936
|
+
console.log(`
|
|
11937
|
+
Installed ${yakFile}.`);
|
|
11938
|
+
console.log("Start Rhino. The plug-in loads at startup, so its local server comes up with it.");
|
|
11939
|
+
} finally {
|
|
11940
|
+
cleanup();
|
|
11941
|
+
}
|
|
11942
|
+
});
|
|
11943
|
+
function findYak() {
|
|
11944
|
+
const candidates = [
|
|
11945
|
+
"C:\\Program Files\\Rhino 8\\System\\Yak.exe",
|
|
11946
|
+
"C:\\Program Files\\Rhino 9\\System\\Yak.exe",
|
|
11947
|
+
"C:\\Program Files\\Rhino 8 WIP\\System\\Yak.exe"
|
|
11948
|
+
];
|
|
11949
|
+
return candidates.find((p) => require$$3.existsSync(p));
|
|
11950
|
+
}
|
|
11832
11951
|
const pkg = JSON.parse(
|
|
11833
11952
|
require$$3.readFileSync(require$$2.join(__dirname, "..", "package.json"), "utf-8")
|
|
11834
11953
|
);
|
|
@@ -11857,4 +11976,5 @@ program.addCommand(runCommand);
|
|
|
11857
11976
|
program.addCommand(localServerCommand);
|
|
11858
11977
|
program.addCommand(swapCommand);
|
|
11859
11978
|
program.addCommand(revitCommand);
|
|
11979
|
+
program.addCommand(rhinoCommand);
|
|
11860
11980
|
program.parse(process.argv);
|