spooder 6.2.2 → 6.2.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/README.md +26 -0
- package/bun.lock +3 -3
- package/package.json +1 -1
- package/src/api.ts +23 -2
- package/src/cli.ts +2 -1
package/README.md
CHANGED
|
@@ -302,6 +302,32 @@ This can be configured in `spooder` using the `instances` array, with each entry
|
|
|
302
302
|
|
|
303
303
|
Instances will be managed individually in the same manner that a single process would be, including auto-restarting and other functionality.
|
|
304
304
|
|
|
305
|
+
### Instance Environment
|
|
306
|
+
|
|
307
|
+
Each instance can define custom environment variables using the `env` property. These variables are merged with the parent process environment and passed to the spawned instance.
|
|
308
|
+
|
|
309
|
+
```json
|
|
310
|
+
"spooder": {
|
|
311
|
+
"instances": [
|
|
312
|
+
{
|
|
313
|
+
"id": "foo",
|
|
314
|
+
"run": "bun run server.ts",
|
|
315
|
+
"env": { "ENVTEST": "foo" }
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
"id": "bar",
|
|
319
|
+
"run": "bun run server.ts",
|
|
320
|
+
"env": { "ENVTEST": "bar" }
|
|
321
|
+
}
|
|
322
|
+
]
|
|
323
|
+
}
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
Environment variable precedence (highest to lowest):
|
|
327
|
+
1. `SPOODER_ENV` - always set by spooder (`dev` or `prod`)
|
|
328
|
+
2. Instance `env` - overrides parent environment
|
|
329
|
+
3. Parent process environment - inherited from spooder
|
|
330
|
+
|
|
305
331
|
### Instance Stagger
|
|
306
332
|
|
|
307
333
|
By default, instances are all launched instantly. This behavior can be configured with the `instance_stagger_interval` configuration property, which defines an interval between instance launches in milliseconds.
|
package/bun.lock
CHANGED
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
},
|
|
11
11
|
},
|
|
12
12
|
"packages": {
|
|
13
|
-
"@types/bun": ["@types/bun@1.3.
|
|
13
|
+
"@types/bun": ["@types/bun@1.3.6", "", { "dependencies": { "bun-types": "1.3.6" } }, "sha512-uWCv6FO/8LcpREhenN1d1b6fcspAB+cefwD7uti8C8VffIv0Um08TKMn98FynpTiU38+y2dUO55T11NgDt8VAA=="],
|
|
14
14
|
|
|
15
|
-
"@types/node": ["@types/node@25.0.
|
|
15
|
+
"@types/node": ["@types/node@25.0.8", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-powIePYMmC3ibL0UJ2i2s0WIbq6cg6UyVFQxSCpaPxxzAaziRfimGivjdF943sSGV6RADVbk0Nvlm5P/FB44Zg=="],
|
|
16
16
|
|
|
17
|
-
"bun-types": ["bun-types@1.3.
|
|
17
|
+
"bun-types": ["bun-types@1.3.6", "", { "dependencies": { "@types/node": "*" } }, "sha512-OlFwHcnNV99r//9v5IIOgQ9Uk37gZqrNMCcqEaExdkVq3Avwqok1bJFmvGMCkCE0FqzdY8VMOZpfpR3lwI+CsQ=="],
|
|
18
18
|
|
|
19
19
|
"undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="],
|
|
20
20
|
}
|
package/package.json
CHANGED
package/src/api.ts
CHANGED
|
@@ -977,8 +977,29 @@ export async function parse_template(template: string, replacements: Replacement
|
|
|
977
977
|
// Parse t-if tags
|
|
978
978
|
const if_regex = /<t-if\s+test="([^"]+)"\s*>(.*?)<\/t-if>/gs;
|
|
979
979
|
result = await replace_async(result, if_regex, async (match, condition_key, if_content) => {
|
|
980
|
-
|
|
981
|
-
|
|
980
|
+
let condition_value;
|
|
981
|
+
let key_exists = false;
|
|
982
|
+
|
|
983
|
+
if (is_replacer_fn) {
|
|
984
|
+
condition_value = await replacements(condition_key);
|
|
985
|
+
key_exists = true;
|
|
986
|
+
} else {
|
|
987
|
+
condition_value = replacements[condition_key];
|
|
988
|
+
key_exists = condition_key in replacements;
|
|
989
|
+
|
|
990
|
+
// try nested property access if direct lookup fails
|
|
991
|
+
if (condition_value === undefined && condition_key.includes('.')) {
|
|
992
|
+
const dot_index = condition_key.indexOf('.');
|
|
993
|
+
const base_key = condition_key.substring(0, dot_index);
|
|
994
|
+
const prop_path = condition_key.substring(dot_index + 1);
|
|
995
|
+
const base_obj = replacements[base_key];
|
|
996
|
+
|
|
997
|
+
if (base_obj !== undefined && typeof base_obj === 'object' && base_obj !== null) {
|
|
998
|
+
condition_value = get_nested_property(base_obj, prop_path);
|
|
999
|
+
key_exists = base_key in replacements;
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
982
1003
|
|
|
983
1004
|
// preserve block for later pass if key doesn't exist and drop_missing is false
|
|
984
1005
|
if (!key_exists && !drop_missing)
|
package/src/cli.ts
CHANGED
|
@@ -10,6 +10,7 @@ type InstanceConfig = {
|
|
|
10
10
|
id: string;
|
|
11
11
|
run: string;
|
|
12
12
|
run_dev?: string;
|
|
13
|
+
env?: Record<string, string>;
|
|
13
14
|
};
|
|
14
15
|
|
|
15
16
|
type Instance = {
|
|
@@ -168,7 +169,7 @@ async function start_instance(instance: InstanceConfig, config: Config, update =
|
|
|
168
169
|
const run_command = is_dev_mode && instance.run_dev ? instance.run_dev : instance.run;
|
|
169
170
|
const proc = Bun.spawn(parse_command_line(run_command), {
|
|
170
171
|
cwd: process.cwd(),
|
|
171
|
-
env: { ...process.env, SPOODER_ENV: is_dev_mode ? 'dev' : 'prod' },
|
|
172
|
+
env: { ...process.env, ...instance.env, SPOODER_ENV: is_dev_mode ? 'dev' : 'prod' },
|
|
172
173
|
stdout: std_mode,
|
|
173
174
|
stderr: std_mode,
|
|
174
175
|
ipc: handle_ipc.bind({ instance_id: instance.id, config })
|