@nodeloc/apps-cli 0.3.0 → 0.3.1

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 CHANGED
@@ -10,11 +10,11 @@ app 是一个导出若干 handler 的 JS 模块,handler 跑在论坛服务端
10
10
  需要 **Node.js 22 或更高**。
11
11
 
12
12
  ```bash
13
- git clone https://github.com/nodeloc/nodeloc-apps-cli.git
14
- cd nodeloc-apps-cli
15
- npm install -g .
13
+ npm install -g @nodeloc/apps-cli
16
14
  ```
17
15
 
16
+ 更新到最新版再跑一次同一条命令。想从源码装:克隆本仓库后在目录里 `npm install -g .`。
17
+
18
18
  ## 登录
19
19
 
20
20
  ```bash
@@ -58,6 +58,8 @@ nodeloc-apps logs --limit 50
58
58
 
59
59
  `dev` 会把相对 import 内联成单个模块,并提前拦掉服务端一定会拒的写法:缺 `render` 导出(service app 则要求至少有一个 `onTrigger`/`onSchedule`/`onFetch`)、`eval`、`node:` 内建、浏览器全局、`fetch`。
60
60
 
61
+ 额度:打包后的代码最多 2 MiB(`dev` 和 `upload` 在本地就会拦,0.3.1 起;更早的版本按 512 KB 拦)。键值存储按区算,一个用户的私有区和一个安装的共享区各算各的:每个区最多 500 个键,单个值(JSON)最多 64 KiB,整个区的键和值合计最多 1 MiB。超出时这次调用的改动整批作废,错误码是 `E_INVALID_EFFECT`(单个值太大)或 `E_KV_QUOTA`(键太多,或者这个区满了)。每次调用都会把整个区读进沙箱,代码越大启动也越慢,所以够用就好。
62
+
61
63
  沙箱没有网络,这一点不会变。要访问外部服务,handler 返回 `http.fetch` effect,由站点代为请求,结果之后作为一次单独的 `onFetch` 调用送回来——只允许 https,只允许管理人员批准过的精确主机名。代码不审核,但 `domains` 里的每个主机都要管理人员逐个批准,批准之前(试玩里也一样)请求会得到 `E_HTTP_DOMAIN_DENIED`;`upload` 和 `playtest` 会打印每个主机的状态(已批准、等批准、没有获批、已撤回)。被拒、撤回的主机再次申请也不会重新排队,请联系管理人员。
62
64
 
63
65
  ## 项目结构
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodeloc/apps-cli",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Build and publish sandboxed NodeLoc apps",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/bundle.js CHANGED
@@ -46,12 +46,15 @@ function defaultImportIn(clause) {
46
46
 
47
47
  export class BundleError extends Error {}
48
48
 
49
+ /** The site's limit on one version's code, checked here so an upload is not wasted on it. */
50
+ export const MAX_BUNDLE_BYTES = 2 * 1024 * 1024;
51
+
49
52
  /**
50
53
  * Inlines relative imports depth-first. This is deliberately not a general
51
54
  * bundler: apps are small, and a dependency graph an author cannot read in one
52
55
  * sitting is a dependency graph a reviewer cannot check.
53
56
  */
54
- export async function bundle(entryPath, { maxBytes = 512 * 1024, seen = new Set() } = {}) {
57
+ export async function bundle(entryPath, { maxBytes = MAX_BUNDLE_BYTES, seen = new Set() } = {}) {
55
58
  const resolved = path.resolve(entryPath);
56
59
 
57
60
  if (seen.has(resolved)) {