@gorilla-engine-sdk/gorilla-engine-scripts 1.3.4

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/LICENSE.md ADDED
@@ -0,0 +1,64 @@
1
+ **IMPORTANT NOTICE: PLEASE READ CAREFULLY BEFORE DOWNLOADING, INSTALLING OR USING THE GORILLA ENGINE SDK:**
2
+
3
+ - BY SIGNING THIS AGREEMENT, OR CLICKING ON THE “ACCEPT” BUTTON BELOW (IF AVAILABLE), OR BY DOWNLOADING, INSTALLING, OR USING THE GORILLA ENGINE SDK, YOU AGREE TO THE TERMS OF THIS AGREEMENT, AND ALL INCORPORATED TERMS INCLUDING GORILLA ENGINE’S PRIVACY POLICY, AS APPLICABLE, WHICH WILL BIND YOU.
4
+
5
+ - IF YOU DO NOT AGREE TO THE TERMS OF THIS AGREEMENT, WE WILL NOT LICENSE THE GORILLA ENGINE SDK TO YOU AND YOU MUST DISCONTINUE THE INSTALLATION OR DOWNLOAD PROCESS OR CEASE USE OF THE UJAM GORILLA ENGINE SDK.
6
+
7
+ **GORILLA ENGINE FREE TIER LICENSE**
8
+
9
+ This Gorilla Engine Free Tier License ("Agreement") is entered between UJAM, Inc., a Delaware corporation (hereinafter "UJAM" or "we") and you (“Licensee” or “you”) and becomes effective once you download, install, or use the GORILLA ENGINE SDK.
10
+
11
+ 1. OBJECT OF AGREEMENT. This Agreement governs UJAM’s GORILLA ENGINE SDK (“SDK”) and all related software and documentation and any update, upgrades or bug fixes (collectively referred to as the "UJAM GORILLA ENGINE SDK SERVICE").
12
+
13
+ 2. GRANT OF LICENSE: Subject to your full compliance with all of the terms and conditions of this Agreement, we grant you a non-exclusive, revocable, nonsublicensable (except as specifically provided herein), non-transferable license to use the UJAM GORILLA ENGINE SDK SERVICE solely to: (i) download, install, and use the UJAM GORILLA ENGINE SDK SERVICE for the sole purpose of building audio plugins such as virtual instruments and effects ("Application") and using such Application for music productions and live performances. **HOWEVER, YOU MUST NOT SHARE OR OTHERWISE EXPLOIT YOUR GORILLA ENGINE BASED APPLICATION WITH ANY THIRD PARTY UNTIL YOU HAVE ACQUIRED ONE OF THE ADD-ON LICENSES AS FURTHER DESCRIBED IN SECTION 8 OF THIS AGREEMENT.** If you have any questions regarding this license and allowed uses of the SDK, please reach out to us via email at support@gorilla-engine.com.
14
+
15
+ 3. LICENSE RESTRICTIONS AND OBLIGATIONS: Except as expressly and unambiguously authorized under this Agreement, you must not
16
+ 1. copy, rent, lease, sell, transfer, assign, sublicense, disassemble, reverse engineer or decompile (except to the limited extent expressly authorized by applicable statutory law), modify, create derivative works from, or alter any part of the UJAM GORILLA ENGINE SDK SERVICE;
17
+ 2. sublicense your Application to end-users until you have acquired a license as further described in Section 8 of this Agreement.
18
+ 3. use any automated means, including, without limitation, agents, robots, scripts or spiders, to access the UJAM GORILLA ENGINE SDK SERVICE or bypass the UJAM GORILLA ENGINE SDK SERVICE or to interfere or attempt to interfere with the proper working of the UJAM GORILLA ENGINE SDK SERVICE;
19
+ 4. use the UJAM GORILLA ENGINE SDK SERVICE as a dynamic-link library (for clarity: the SDK shall solely be used as a statically linked library); (g) use the SDK or any part of the SDK in connection with building or distributing your own or a third-party SDK or framework; or (h) use the Licensed Software to train artificial intelligence, your own or a third-party algorithm, and/or any other kind of machine learning processes.
20
+ 5. use the UJAM GORILLA ENGINE SDK SERVICE for the benefit of a third party, other than end users of your Applications as expressly authorized by this Agreement;
21
+ 6. use the UJAM GORILLA ENGINE SDK SERVICE to implement or enhance a product or service that is competitive with the UJAM GORILLA ENGINE SDK SERVICE;
22
+ 7. modify and/or rename the UJAM binary libraries; or
23
+ 8. otherwise engage in activity that interrupts the proper working of the UJAM GORILLA ENGINE SDK SERVICE or is otherwise fraudulent or illegal.
24
+
25
+ Furthermore, you agree
26
+
27
+ 9. display attribution on all embodiments and uses of the Gorilla Engine SDK by displaying the language “powered by Gorilla Engine” ; and
28
+ 10. to contact UJAM once you intend to Distribute (as defined in Section 8\) your Application to obtain the appropriate license to do so – which you agree is required for such a scenario (as further described in Section 8 below).
29
+
30
+ We reserve the right to discontinue, modify, cease support of, and alter the pricing structure of this Agreement (the Gorilla Engine Free Tier License) of the UJAM GORILLA ENGINE SDK SERVICE.
31
+
32
+ 10. LICENSE TO UJAM: You hereby grant to us the non-exclusive, perpetual, worldwide, royalty-free right and license to any and all content ("Content") provided by you or your end users in connection with your use or your end users' use of the SDK, including but not limited to feedback or other contributions made towards the UJAM GORILLA ENGINE SDK SERVICE (including so-called re-usable components, made available by UJAM via its repositories), in order for us to provide and improve the UJAM GORILLA ENGINE SDK SERVICE. You represent and warrant that all Content provided by you shall not violate any third party rights and shall be free of any and all claims.
33
+
34
+ 11. REPRESENTATIONS AND WARRANTIES: You represent and warrant that you: (i) are fully authorized to enter into this agreement; (ii) shall use the UJAM GORILLA ENGINE SDK SERVICE in compliance with all applicable local, state, national and foreign laws, treaties and regulations, including those related to data privacy, international communications, export laws and the transmission of technical or personal data laws; (iii) shall not (and shall not permit any third party, including a permitted sublicensee to), directly or indirectly, take any action or upload, download, post, submit or otherwise distribute or facilitate distribution of Content or any material on or through the UJAM GORILLA ENGINE SDK SERVICE, that: (a) infringes any patent, trademark, trade secret, copyright, right of publicity/privacy or other right of any third party or induces infringement thereof; (b) breaches any third party contract or obligation; (c) is unlawful, threatening, abusive, harassing, defamatory, deceptive, fraudulent, invasive of another's privacy, tortious, obscene, offensive, or profane.
35
+
36
+ 12. OWNERSHIP AND PROPRIETARY RIGHTS: As between UJAM and Licensee (and any permitted sublicensees), the SDK and all intellectual property rights in and to the UJAM GORILLA ENGINE SDK SERVICE, are and shall at all times remain the sole and exclusive property of UJAM and are protected by applicable intellectual property laws and treaties. You shall not obscure, remove or otherwise alter our copyright or trademark notices or other proprietary rights' notices affixed to or within the SDK or elsewhere.
37
+
38
+ 13. SUPPORT AND UPGRADES: This Agreement does not entitle you to any support for the SDK, unless you enter into a separate agreement with us in writing, either signed by both parties or agreed upon via click-through agreement. Any such support provided by us shall be subject to the terms and disclaimers of this Agreement.
39
+
40
+ 14. ADD-ON LICENSES FOR A PERMITTED DISTRIBUTION OF GORILLA ENGINE BASED APPLICATION:
41
+ 1. **Add-On Licenses (Upgrade to Pro Tier):** You agree to contact UJAM to obtain one of our commercial license (including the so-called “Pro Tier” License, including available optional Add-On upgrades which can be ) (collectively referred to as “Add-On Licenses”), whichever deemed to be appropriate for your intended use of the SDK, to Distribute (as defined below in subsection ii.) your Gorilla Engine based Application to end-users. Such Add-On License shall supersede this Agreement, as agreed to by the parties.
42
+ 2. **Failure to comply with Section 8:** If you fail to comply with Section 8(i) by Distributing the SDK as part of an Application beyond the allowed use under this Agreement, you shall immediately contact UJAM and pay to UJAM a royalty per each Distribution (as defined below) in an amount as solely determined by UJAM. A Distribution refers to either an embedded, pre-bundled, pre-installed platform application or software application that is downloaded, delivered, or served to a user or device by any means of distribution including directly from you or through any platform, including cloud based platforms. In avoidance of doubt, any subscription or rental shall be considered a Distribution.
43
+ 3. **Audit Rights**: Should (i) you fail to obtain an Add-On License and distribute the SDK as part of an Application, or should (ii) UJAM believe that you distribute the Application without having obtained an Add-On License, then UJAM shall have the right, upon reasonable notice, to audit/inspect any premises, computer(s), and networks on or in which the SDK is installed or used to monitor compliance with the terms of this Agreement, including but not limited to confirming the number of Distributions of the Application. If an audit reveals any unauthorized use, in addition to all other remedies available to UJAM, you shall be responsible to UJAM for all reasonable expenses related to the audit.
44
+ 4. **Third Party Libraries:** You acknowledge that certain third-party libraries, including JUCE 6 ([https://juce.com/legal/juce-6-license/](https://juce.com/legal/juce-6-license/)), may be used in connection with the SDK, subject to their respective license agreements as further disclosed by UJAM. It is your sole responsibility to abide to such third-party terms, which may include your obligations, amongst others, to provide certain disclosures accompanying your Gorilla Engine based Software and/or acquiring a JUCE license (if applicable).
45
+
46
+ 15. DATA PROTECTION AND PRIVACY: We may collect and process information about you and your use of the Gorilla Engine SDK, some of which may amount to personal data, subject to Gorilla Engine’s Privacy Policy.
47
+
48
+ 16. TRADE SECRETS AND CONFIDENTIAL INFORMATION: You acknowledges that the SDK contains valuable trade secrets of UJAM and, should you access any such trade secrets in violation of this Agreement, you agree to maintain the confidentiality of the trade secrets of the SDK using at least the same degree of care that you use with your own confidential information.
49
+
50
+ 17. WARRANTY DISCLAIMER: THE UJAM GORILLA ENGINE SDK SERVICE, INCLUDING THE SDK, IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, WE DISCLAIM ALL WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, REGARDING THE UJAM GORILLA ENGINE SDK SERVICE, INCLUDING WITHOUT LIMITATION ANY AND ALL IMPLIED WARRANTIES OF MERCHANTABILITY, ACCURACY, RESULTS OF USE, RELIABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE, AVAILABILITY, PERFORMANCE, BANDWIDTH, AND NON-INFRINGEMENT OF THIRD-PARTY RIGHTS. FURTHER, WE DISCLAIM ANY WARRANTY THAT LICENSEE'S USE OF THE UJAM GORILLA ENGINE SDK SERVICE WILL BE AVAILABLE, UNINTERRUPTED OR ERROR FREE.
51
+
52
+ 18. LIABILITY LIMITATION: REGARDLESS OF WHETHER ANY REMEDY SET FORTH HEREIN FAILS OF ITS ESSENTIAL PURPOSE OR OTHERWISE, AND EXCEPT FOR BODILY INJURY, IN NO EVENT WILL WE OR OUR CONTRACTORS, EMPLOYEES OR AFFILIATES BE LIABLE TO YOU OR TO ANY THIRD PARTY UNDER ANY TORT, CONTRACT, NEGLIGENCE, STRICT LIABILITY OR OTHER LEGAL OR EQUITABLE THEORY FOR ANY LOST PROFITS, LOST OR CORRUPTED DATA, COMPUTER FAILURE OR MALFUNCTION, INFRINGEMENT, INTERRUPTION OF BUSINESS, OR OTHER SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND ARISING OUT OF THE USE OR INABILITY TO USE THE UJAM GORILLA ENGINE SDK SERVICE, EVEN IF WE HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSS OR DAMAGES AND WHETHER OR NOT SUCH LOSS OR DAMAGES ARE FORESEEABLE. IN NO EVENT SHALL OUR TOTAL LIABILITY TO YOU OR ANY THIRD PARTY EXCEED TEN USD DOLLARS. ANY CLAIM ARISING OUT OF OR RELATING TO THIS AGREEMENT MUST BE BROUGHT WITHIN ONE (1) YEAR AFTER THE OCCURRENCE OF THE EVENT GIVING RISE TO SUCH CLAIM.
53
+
54
+ 19. INDEMNITY: You agree that we shall have no liability whatsoever for your or your end users of the UJAM GORILLA ENGINE SDK SERVICE. You shall indemnify, defend and hold us harmless from any and all claims, damages, liabilities, costs, and fees (including reasonable attorneys' fees) arising from your or your end users' use of the UJAM GORILLA ENGINE SDK SERVICE or for any breach of this Agreement, including any breach of the representations and warranties you made herein.
55
+
56
+ 20. TERM AND TERMINATION: This Agreement shall continue until terminated as set forth in this Section. Either party may terminate this Agreement at any time, for any reason, or for no reason including, but not limited to, if you violate any provision of this Agreement. We reserve the right to cancel, amend, or modify the SDK at any time. Any termination of this Agreement shall also terminate the license granted hereunder. Upon termination of this Agreement for any reason, you shall immediately destroy and remove from all computers, hard drives, networks, and other storage media all copies of the SDK, and shall so certify to us that such actions have occurred (including all cached ephemeral copies). Sections 5 (“REPRESENTATIONS AND WARRANTIES”), 6 (“OWNERSHIP AND PROPRIETARY RIGHTS”), 10 (“TRADE SECRETS AND CONFIDENTIAL INFORMATION”), 11 (“WARRANTY DISCLAIMER”), 12 (“LIABILITY LIMITATION”), 13 (“INDEMNITY”), 16 (“GOVERNING LAW”), 18 (“GENERAL PROVISIONS”) shall survive termination of this Agreement.
57
+
58
+ 21. EXPORT CONTROLS: You shall comply with all applicable export laws and restrictions and regulations and you shall not export, or allow the export or re-export of the SDK in violation of any such restrictions, laws, or regulations.
59
+
60
+ 22. GOVERNING LAW: This Agreement shall be governed by New York law, excluding conflict of law provisions. The parties agree to and submit to the exclusive jurisdiction of courts located in New York City, New York. The application of the United Nations Convention of Contracts for the International Sale of Goods is expressly excluded.
61
+
62
+ 23. PREVAILING PARTY. Notwithstanding Section 12 (“LIABILITY LIMITATION”), in the event of any court action relating to enforcement of this Agreement, including injunctive relief, the non-prevailing party shall reimburse the prevailing party for all reasonable attorneys’ fees and costs, including expert witness fees, resulting therefrom.
63
+
64
+ 24. GENERAL PROVISIONS. If any part of this Agreement is found void or unenforceable, it will not affect the validity of the balance of the Agreement, which shall remain valid and enforceable according to its terms. This Agreement may only be modified by written agreement between the Parties. Updates to the UJAM GORILLA ENGINE SDK SERVICE may be licensed to you by UJAM with additional or different terms. UJAM further reserves rights, in its discretion, not to license updates. This is the entire Agreement between UJAM and you relating to the UJAM GORILLA ENGINE SDK SERVICE and it supersedes any prior representations, discussions, undertakings, communications, or advertising relating to the UJAM GORILLA ENGINE SDK SERVICE. This Agreement is not assignable by you.
package/README.md ADDED
@@ -0,0 +1,107 @@
1
+ # @gorilla-engine-sdk/gorilla-engine-scripts
2
+
3
+ Build and deployment scripts for Gorilla Engine plugins. Provides two CLI tools:
4
+
5
+ - **`gorilla-engine-scripts-deploy`** — Bundles your plugin's TypeScript/TSX entry point with esbuild, encrypts/signs the output, deploys JS, YAML, and asset files to the plugin folder, exports instrument blobs, regenerates instrument typings, and watches for changes in development.
6
+ - **`gorilla-engine-scripts-build`** — Runs `gorilla-compiler` on a `.ugep` file to produce an installer, with optional auto-install after a successful build.
7
+
8
+ ## Install
9
+
10
+ ```bash
11
+ npm install @gorilla-engine-sdk/gorilla-engine-scripts
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ ### Deploy (development workflow)
17
+
18
+ > **Prerequisite:** The plugin must be built and installed at least once via `gorilla-engine-scripts-build --install` before the deploy workflow can be used. The deploy script writes into the plugin's installed output folder and, when `--standalone` is used, launches the installed standalone binary.
19
+
20
+ ```bash
21
+ gorilla-engine-scripts-deploy --ugep <ugep-file> --entry-point <js-entry-point-file>
22
+ ```
23
+
24
+ **Options:**
25
+
26
+ | Flag | Short | Description |
27
+ | ------------------------- | ----- | ---------------------------------------------------------------------- |
28
+ | `--ugep <FILE>` | `-u` | Path to the `.ugep` project file |
29
+ | `--entry-point <FILE>` | `-e` | TypeScript/TSX entry point of the plugin UI |
30
+ | `--one-shot` | `-1` | Build once and exit (no file watching) |
31
+ | `--build-ui-only` | | With `--one-shot`, bundle only the UI JS |
32
+ | `--sync-instruments-only` | | With `--one-shot`, sync only instrument blobs and generated typings |
33
+ | `--no-deploy` | `-nd` | Skip deployment to the plugin folder |
34
+ | `--standalone` | `-s` | Start/restart the standalone app after each deploy and stop it on exit |
35
+
36
+ **Example:**
37
+
38
+ ```bash
39
+ gorilla-engine-scripts-deploy --ugep my-plugin.ugep --entry-point src/index.tsx
40
+ ```
41
+
42
+ By default the command watches for changes and redeploys automatically. It also watches the `instrument/` folder and re-exports blobs plus regenerates `src/generated/gorilla-instrument-types.d.ts` when instrument sources change.
43
+
44
+ When run with `--one-shot`, the command performs both the one-shot UI bundle and the one-shot instrument sync before exiting. Use `--build-ui-only` or `--sync-instruments-only` to run just one half of that workflow. If `blob-export` is unavailable, the command prints a warning and continues with the rest of the deploy workflow.
45
+
46
+ **Output locations:**
47
+
48
+ - macOS: `/Library/Application Support/<manufacturer>/<pluginName>/`
49
+ - Windows: `<SystemDrive>/ProgramData/<manufacturer>/<pluginName>/`
50
+
51
+ If the output folder is not writable, the script will interactively offer to fix permissions (`sudo chown` on macOS, `icacls` on Windows).
52
+
53
+ ### Build (produce installer)
54
+
55
+ ```bash
56
+ gorilla-engine-scripts-build --ugep <ugep-file> [--credentials <credentials-file>]
57
+ ```
58
+
59
+ **Options:**
60
+
61
+ | Flag | Short | Description |
62
+ | ---------------------- | ----- | --------------------------------------------------------------------------------------- |
63
+ | `--ugep <FILE>` | `-u` | Path to the `.ugep` project file |
64
+ | `--credentials <FILE>` | `-c` | Optional JSON file with `{ "username": "...", "password": "..." }` for gorilla-compiler |
65
+ | `--install` | `-i` | Install the built plugin after a successful build |
66
+
67
+ **Example:**
68
+
69
+ ```bash
70
+ gorilla-engine-scripts-build --ugep my-plugin.ugep --credentials buildCredentials.json
71
+ ```
72
+
73
+ If `--credentials` is not provided, the build command resolves credentials in this order:
74
+
75
+ 1. `<ugep-directory>/buildCredentials.json`
76
+ 2. `GORILLA_BUILD_USERNAME` + `GORILLA_BUILD_PASSWORD`
77
+ 3. `GORILLA_BUILD_CREDENTIALS_FILE`
78
+ 4. `~/.gorilla-engine/credentials.json`
79
+
80
+ When no credentials are found and the command runs in an interactive terminal, it will prompt once and save credentials to `~/.gorilla-engine/credentials.json`.
81
+
82
+ User-wide credential path by platform:
83
+
84
+ - macOS: `/Users/<you>/.gorilla-engine/credentials.json`
85
+ - Windows: `C:\\Users\\<you>\\.gorilla-engine\\credentials.json`
86
+
87
+ ## Encryption
88
+
89
+ Deployed JS and YAML files are encrypted based on the setting in the `.ugep` file.
90
+
91
+ ## Typical `package.json` Integration
92
+
93
+ ```json
94
+ {
95
+ "scripts": {
96
+ "start": "gorilla-engine-scripts-deploy --ugep MyPlugin.ugep --entry-point src/index.tsx",
97
+ "build:ui": "gorilla-engine-scripts-deploy --ugep MyPlugin.ugep --entry-point src/index.tsx --one-shot --no-deploy --build-ui-only",
98
+ "sync:instruments": "gorilla-engine-scripts-deploy --ugep MyPlugin.ugep --entry-point src/index.tsx --one-shot --no-deploy --sync-instruments-only",
99
+ "prepare:artifacts": "npm run build:ui && npm run sync:instruments",
100
+ "build": "gorilla-engine-scripts-build --ugep MyPlugin.ugep --install"
101
+ }
102
+ }
103
+ ```
104
+
105
+ ## License
106
+
107
+ [GORILLA ENGINE FREE TIER LICENSE](./LICENSE.md)
package/build.js ADDED
@@ -0,0 +1,351 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { execFileSync } from 'node:child_process';
4
+ import {
5
+ chmodSync,
6
+ existsSync,
7
+ mkdirSync,
8
+ readFileSync,
9
+ renameSync,
10
+ unlinkSync,
11
+ writeFileSync,
12
+ } from 'node:fs';
13
+ import os from 'node:os';
14
+ import * as path from 'node:path';
15
+ import { createInterface } from 'node:readline/promises';
16
+ import { Writable } from 'node:stream';
17
+ import { requireInstalledGorillaCompilerPath } from './compiler-detection.js';
18
+ import { resolveInstallerPath } from './lib/installer.js';
19
+
20
+ const compilerOpts = { stdio: 'inherit' };
21
+ const isMac = process.platform === 'darwin';
22
+ const CREDENTIALS_FILENAME = 'buildCredentials.json';
23
+ const USER_CREDENTIALS_ENV_FILE = 'GORILLA_BUILD_CREDENTIALS_FILE';
24
+ const USERNAME_ENV = 'GORILLA_BUILD_USERNAME';
25
+ const PASSWORD_ENV = 'GORILLA_BUILD_PASSWORD';
26
+
27
+ function print_usage(exit) {
28
+ let programName;
29
+ if (/node(?:.exe)?$/.test(process.argv[0])) {
30
+ programName = `node ${path.basename(process.argv[1])}`;
31
+ } else {
32
+ programName = path.basename(process.argv[0]);
33
+ }
34
+
35
+ console.log(`
36
+ Usage:
37
+ ${programName} --ugep|-u <ugep-file> [--credentials|-c <credentials-file>]
38
+
39
+ ${programName} will run gorilla-compiler on the ugep file.
40
+ Example:
41
+ ${programName} --ugep my-plugin.ugep
42
+
43
+ -u, --ugep <FILE> the ugep file to run gorilla-compiler on
44
+ -c, --credentials <FILE> optional path to json file that contains the gorilla-compiler
45
+ credentials: {"username": "...","password": "..."}
46
+ -i, --install install the built installer after a successful build
47
+
48
+ Credential fallback order (first match wins):
49
+ 1) --credentials <FILE>
50
+ 2) <ugep-directory>/${CREDENTIALS_FILENAME}
51
+ 3) ${USERNAME_ENV} + ${PASSWORD_ENV}
52
+ 4) ${USER_CREDENTIALS_ENV_FILE}
53
+ 5) ~/.gorilla-engine/credentials.json
54
+
55
+ If no credentials are found and this runs in an interactive terminal, you will be prompted once
56
+ and credentials will be saved to ~/.gorilla-engine/credentials.json.
57
+ `);
58
+ if (typeof exit != 'undefined') {
59
+ process.exit(exit);
60
+ }
61
+ }
62
+
63
+ async function main() {
64
+ console.log('Starting build...');
65
+ const compilerPath = requireInstalledGorillaCompilerPath();
66
+
67
+ const flags = getFlags();
68
+ const { username, password, credentialsPathToSave } = await resolveCredentials(flags);
69
+ const compilerArgs = ['-d', '-p', flags.ugepFile, '-i', '-e', username, '-s', password];
70
+ if (flags.meta) {
71
+ compilerArgs.push('-m');
72
+ }
73
+ try {
74
+ execFileSync(compilerPath, compilerArgs, compilerOpts);
75
+ } catch {
76
+ throw new Error('gorilla-compiler failed. See output above for details.');
77
+ }
78
+
79
+ if (credentialsPathToSave) {
80
+ writeUserCredentials(credentialsPathToSave, { username, password });
81
+ console.log(`Saved build credentials to ${credentialsPathToSave}`);
82
+ }
83
+
84
+ console.log('Build complete');
85
+
86
+ if (flags.install) {
87
+ installPlugin(flags.ugepFile);
88
+ }
89
+ }
90
+
91
+ function getDefaultUserCredentialsPath() {
92
+ return path.join(os.homedir(), '.gorilla-engine', 'credentials.json');
93
+ }
94
+
95
+ function normalizeCredentials(rawCredentials) {
96
+ if (
97
+ rawCredentials === null ||
98
+ typeof rawCredentials !== 'object' ||
99
+ Array.isArray(rawCredentials)
100
+ ) {
101
+ return null;
102
+ }
103
+
104
+ const username =
105
+ typeof rawCredentials.username === 'string' ? rawCredentials.username.trim() : undefined;
106
+ const password =
107
+ typeof rawCredentials.password === 'string' ? rawCredentials.password.trim() : undefined;
108
+
109
+ if (!username || !password) {
110
+ return null;
111
+ }
112
+
113
+ return { username, password };
114
+ }
115
+
116
+ function readCredentialsFile(credentialsPath, { strict, sourceDescription }) {
117
+ if (!existsSync(credentialsPath)) {
118
+ return null;
119
+ }
120
+
121
+ try {
122
+ const parsed = JSON.parse(readFileSync(credentialsPath, 'utf-8'));
123
+ const credentials = normalizeCredentials(parsed);
124
+ if (!credentials) {
125
+ if (strict) {
126
+ throw new Error(
127
+ `${sourceDescription} is missing a non-empty username/password pair: ${credentialsPath}`,
128
+ );
129
+ }
130
+ return null;
131
+ }
132
+ return credentials;
133
+ } catch (error) {
134
+ if (strict) {
135
+ throw new Error(
136
+ `Failed to read ${sourceDescription} at ${credentialsPath}: ${
137
+ error instanceof Error ? error.message : String(error)
138
+ }`,
139
+ );
140
+ }
141
+ return null;
142
+ }
143
+ }
144
+
145
+ function readCredentialsFromEnvironment() {
146
+ const username = process.env[USERNAME_ENV]?.trim();
147
+ const password = process.env[PASSWORD_ENV]?.trim();
148
+
149
+ if (username && password) {
150
+ return { username, password };
151
+ }
152
+
153
+ return null;
154
+ }
155
+
156
+ class MutableOutputStream extends Writable {
157
+ constructor(target) {
158
+ super();
159
+ this.target = target;
160
+ this.muted = false;
161
+ }
162
+
163
+ _write(chunk, encoding, callback) {
164
+ if (!this.muted) {
165
+ this.target.write(chunk, encoding);
166
+ }
167
+ callback();
168
+ }
169
+ }
170
+
171
+ async function promptForCredentials() {
172
+ const mutableOutput = new MutableOutputStream(process.stdout);
173
+ const rl = createInterface({ input: process.stdin, output: mutableOutput, terminal: true });
174
+
175
+ try {
176
+ let username = '';
177
+ while (!username) {
178
+ username = (await rl.question('Gorilla Compiler username: ')).trim();
179
+ if (!username) {
180
+ console.error('Username is required.');
181
+ }
182
+ }
183
+
184
+ let password = '';
185
+ while (!password) {
186
+ process.stdout.write('Gorilla Compiler password: ');
187
+ mutableOutput.muted = true;
188
+ password = (await rl.question('')).trim();
189
+ mutableOutput.muted = false;
190
+ process.stdout.write('\n');
191
+ if (!password) {
192
+ console.error('Password is required.');
193
+ }
194
+ }
195
+
196
+ return { username, password };
197
+ } finally {
198
+ rl.close();
199
+ }
200
+ }
201
+
202
+ function writeUserCredentials(credentialsPath, credentials) {
203
+ const credentialsDirectory = path.dirname(credentialsPath);
204
+ mkdirSync(credentialsDirectory, { recursive: true });
205
+
206
+ const tmpPath = `${credentialsPath}.tmp-${process.pid}-${Date.now()}`;
207
+ const serialized = `${JSON.stringify(credentials, null, 2)}\n`;
208
+
209
+ try {
210
+ writeFileSync(tmpPath, serialized, { encoding: 'utf-8', mode: 0o600 });
211
+ renameSync(tmpPath, credentialsPath);
212
+ if (process.platform !== 'win32') {
213
+ chmodSync(credentialsPath, 0o600);
214
+ }
215
+ } catch (error) {
216
+ if (existsSync(tmpPath)) {
217
+ unlinkSync(tmpPath);
218
+ }
219
+ throw error;
220
+ }
221
+ }
222
+
223
+ async function resolveCredentials(flags) {
224
+ if (flags.credentialsFile) {
225
+ return readCredentialsFile(flags.credentialsFile, {
226
+ strict: true,
227
+ sourceDescription: 'credentials file from --credentials',
228
+ });
229
+ }
230
+
231
+ const ugepDir = path.dirname(path.resolve(flags.ugepFile));
232
+ const projectCredentialsPath = path.join(ugepDir, CREDENTIALS_FILENAME);
233
+ const projectCredentials = readCredentialsFile(projectCredentialsPath, {
234
+ strict: false,
235
+ sourceDescription: `project ${CREDENTIALS_FILENAME}`,
236
+ });
237
+ if (projectCredentials) {
238
+ return projectCredentials;
239
+ }
240
+
241
+ const environmentCredentials = readCredentialsFromEnvironment();
242
+ if (environmentCredentials) {
243
+ return environmentCredentials;
244
+ }
245
+
246
+ const envCredentialsPath = process.env[USER_CREDENTIALS_ENV_FILE];
247
+ if (envCredentialsPath) {
248
+ const environmentCredentialsFile = readCredentialsFile(envCredentialsPath, {
249
+ strict: false,
250
+ sourceDescription: `${USER_CREDENTIALS_ENV_FILE}`,
251
+ });
252
+ if (environmentCredentialsFile) {
253
+ return environmentCredentialsFile;
254
+ }
255
+ }
256
+
257
+ const defaultUserCredentialsPath = getDefaultUserCredentialsPath();
258
+ const userCredentials = readCredentialsFile(defaultUserCredentialsPath, {
259
+ strict: false,
260
+ sourceDescription: 'user-wide credentials',
261
+ });
262
+ if (userCredentials) {
263
+ return userCredentials;
264
+ }
265
+
266
+ if (!process.stdin.isTTY || !process.stdout.isTTY) {
267
+ throw new Error(
268
+ `Build credentials were not found. Provide --credentials, set ${USERNAME_ENV}/${PASSWORD_ENV}, or create ${defaultUserCredentialsPath}.`,
269
+ );
270
+ }
271
+
272
+ console.log('No build credentials found. Running one-time setup...');
273
+ const promptedCredentials = await promptForCredentials();
274
+
275
+ return { ...promptedCredentials, credentialsPathToSave: defaultUserCredentialsPath };
276
+ }
277
+
278
+ function installPlugin(ugepFile) {
279
+ const ugepContent = JSON.parse(readFileSync(ugepFile, 'utf-8'));
280
+ const { pluginConfig } = ugepContent;
281
+
282
+ if (isMac) {
283
+ const { installerName, installerPath } = resolveInstallerPath(ugepFile, pluginConfig, 'pkg');
284
+ console.log(`Installing ${installerName}...`);
285
+ console.log('Your system password is required to install the plugin.');
286
+ execFileSync('sudo', ['installer', '-pkg', installerPath, '-target', '/'], compilerOpts);
287
+ } else {
288
+ const { installerName, installerPath } = resolveInstallerPath(ugepFile, pluginConfig, 'exe');
289
+ console.log(`Installing ${installerName}...`);
290
+ execFileSync(installerPath, ['/SILENT', '/VERYSILENT'], compilerOpts);
291
+ }
292
+
293
+ console.log('Installation complete');
294
+ }
295
+
296
+ function getFlags() {
297
+ const scriptFlags = process.argv.slice(2);
298
+ let current_arg;
299
+ const flags = {};
300
+ while ((current_arg = scriptFlags.shift())) {
301
+ if (!current_arg.startsWith('-')) {
302
+ console.error(`Unknown option: ${current_arg}`);
303
+ print_usage(1);
304
+
305
+ // Show help
306
+ } else if (current_arg === '-h' || current_arg === '--help') {
307
+ print_usage(0);
308
+
309
+ // Use ugep file to deploy
310
+ } else if (current_arg === '-u' || current_arg === '--ugep') {
311
+ flags.ugepFile = scriptFlags.shift();
312
+ if (!existsSync(flags.ugepFile)) {
313
+ console.error(`ugep file does not exist`);
314
+ process.exit(2);
315
+ }
316
+
317
+ // Use ugep file to deploy
318
+ } else if (current_arg === '-c' || current_arg === '--credentials') {
319
+ flags.credentialsFile = scriptFlags.shift();
320
+ if (!existsSync(flags.credentialsFile)) {
321
+ console.error(`credentials file does not exist`);
322
+ process.exit(3);
323
+ }
324
+
325
+ // Create installer-meta.json
326
+ } else if (current_arg === '-m' || current_arg === '--meta') {
327
+ flags.meta = true;
328
+
329
+ // Install after building
330
+ } else if (current_arg === '-i' || current_arg === '--install') {
331
+ flags.install = true;
332
+
333
+ // Not handled in previous ifs => unknown option
334
+ } else {
335
+ console.error(`Unknown option: ${current_arg}`);
336
+ print_usage(1);
337
+ }
338
+ }
339
+
340
+ if (!flags.ugepFile) {
341
+ console.error(`ERROR: --ugep|-u is mandatory`);
342
+ print_usage(1);
343
+ }
344
+
345
+ return flags;
346
+ }
347
+
348
+ await main().catch((error) => {
349
+ console.error(error);
350
+ process.exit(1);
351
+ });
@@ -0,0 +1,50 @@
1
+ import { existsSync } from 'node:fs';
2
+ import path from 'node:path';
3
+
4
+ const isMac = process.platform === 'darwin';
5
+
6
+ const MAC_COMPILER_PATH = '/Applications/Gorilla Compiler.app/Contents/MacOS/Gorilla Compiler';
7
+
8
+ function getWindowsCompilerPaths() {
9
+ const systemDrive = process.env.SystemDrive ?? 'C:';
10
+ const appData = process.env.APPDATA;
11
+
12
+ const sdkCompilerPath = `${systemDrive}\\Program Files\\Gorilla Engine SDK\\Gorilla Compiler\\Gorilla Compiler.exe`;
13
+ const standaloneCompilerPath = appData
14
+ ? path.resolve(appData, '..\\Local\\Programs\\gorilla-compiler\\Gorilla Compiler.exe')
15
+ : null;
16
+
17
+ return [sdkCompilerPath, standaloneCompilerPath].filter(Boolean);
18
+ }
19
+
20
+ export function getGorillaCompilerCandidatePaths() {
21
+ if (isMac) {
22
+ return [MAC_COMPILER_PATH];
23
+ }
24
+
25
+ return getWindowsCompilerPaths();
26
+ }
27
+
28
+ export function findInstalledGorillaCompilerPath() {
29
+ return (
30
+ getGorillaCompilerCandidatePaths().find((compilerPath) => existsSync(compilerPath)) ?? null
31
+ );
32
+ }
33
+
34
+ export function getGorillaCompilerNotFoundMessage() {
35
+ const candidates = getGorillaCompilerCandidatePaths();
36
+
37
+ return [
38
+ 'Gorilla SDK not found. Please download from https://gorilla-engine.com, install and try again',
39
+ `Checked locations:\n- ${candidates.join('\n- ')}`,
40
+ ].join('\n\n');
41
+ }
42
+
43
+ export function requireInstalledGorillaCompilerPath() {
44
+ const compilerPath = findInstalledGorillaCompilerPath();
45
+ if (compilerPath) {
46
+ return compilerPath;
47
+ }
48
+
49
+ throw new Error(getGorillaCompilerNotFoundMessage());
50
+ }
package/deploy.js ADDED
@@ -0,0 +1,93 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { readFile } from 'node:fs/promises';
4
+ import * as path from 'node:path';
5
+
6
+ import { getFlags } from './lib/cli.js';
7
+ import { createConfig } from './lib/config.js';
8
+ import { ensureWriteable } from './lib/permissions.js';
9
+ import { StandaloneManager } from './lib/standalone.js';
10
+ import { AssetDeployer, deployAll } from './lib/assets.js';
11
+ import { InstrumentExporter } from './lib/instruments.js';
12
+ import { createBuildContext } from './lib/build.js';
13
+ import { createWatchers } from './lib/watchers.js';
14
+ import { ts } from './lib/utils.js';
15
+
16
+ const flags = getFlags();
17
+ const ugepContent = JSON.parse(await readFile(flags.ugepFile));
18
+ const config = createConfig(flags, ugepContent);
19
+ const { pluginName, outputFolder } = config;
20
+
21
+ const standaloneManager = new StandaloneManager(config);
22
+
23
+ if (flags.standalone) {
24
+ if (!ugepContent.pluginConfig.buildStandalone) {
25
+ console.error(
26
+ `ERROR: --standalone was specified, but "buildStandalone" is not enabled in ${path.basename(flags.ugepFile)}.`,
27
+ );
28
+ console.error(`Set pluginConfig.buildStandalone to true in your ugep file to use this option.`);
29
+ process.exit(2);
30
+ }
31
+ if (!standaloneManager.exists()) {
32
+ console.error(`ERROR: --standalone was specified, but the standalone binary was not found at:`);
33
+ console.error(` ${standaloneManager.getAppPath()}`);
34
+ console.error(`Make sure the plugin has been built and installed before using --standalone.`);
35
+ process.exit(2);
36
+ }
37
+ }
38
+
39
+ if (!flags.oneShot) {
40
+ await ensureWriteable(config);
41
+ }
42
+
43
+ const assetDeployer = new AssetDeployer(config, standaloneManager);
44
+ const instrumentExporter = new InstrumentExporter(config, assetDeployer, standaloneManager);
45
+
46
+ const shouldBuildUi = !flags.syncInstrumentsOnly;
47
+ const shouldSyncInstruments = !flags.buildUiOnly;
48
+
49
+ const esCtx = shouldBuildUi
50
+ ? await createBuildContext(config, {
51
+ onBuildStarted: () => {
52
+ if (flags.deploy) console.log(`[${ts()}] Changes detected - deploying`);
53
+ },
54
+ onBuildFinished: async () => {
55
+ if (flags.deploy) {
56
+ await deployAll(config);
57
+ console.log(`[${ts()}] Deploy finished\n`);
58
+ if (flags.standalone) await standaloneManager.restart();
59
+ }
60
+ },
61
+ })
62
+ : null;
63
+
64
+ if (flags.oneShot) {
65
+ if (shouldSyncInstruments) {
66
+ await instrumentExporter.runOnce();
67
+ }
68
+ if (shouldBuildUi) {
69
+ await esCtx.rebuild();
70
+ }
71
+ process.exit();
72
+ }
73
+
74
+ const watchers = createWatchers(config, assetDeployer, instrumentExporter);
75
+
76
+ function shutdown() {
77
+ assetDeployer.clearTimer();
78
+ instrumentExporter.clearTimer();
79
+ watchers.close();
80
+ console.log(`[${ts()}] Stopping ${pluginName} standalone`);
81
+ process.off('SIGINT', shutdown);
82
+ process.off('SIGTERM', shutdown);
83
+ standaloneManager.kill();
84
+ }
85
+
86
+ if (flags.standalone) {
87
+ process.on('SIGINT', shutdown);
88
+ process.on('SIGTERM', shutdown);
89
+ process.on('exit', shutdown);
90
+ }
91
+
92
+ await esCtx.watch();
93
+ console.log(`Watching for changes\n`);