@sanity/runtime-cli 17.21.0-next.g420037d → 17.21.0-next.g768eed0
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
|
@@ -90,7 +90,7 @@ EXAMPLES
|
|
|
90
90
|
$ sanity-run blueprints add function --name my-function --fn-type document-create --fn-type document-update --lang js
|
|
91
91
|
```
|
|
92
92
|
|
|
93
|
-
_See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.0-next.
|
|
93
|
+
_See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.0-next.g768eed0/src/commands/blueprints/add.ts)_
|
|
94
94
|
|
|
95
95
|
## `sanity-run blueprints config`
|
|
96
96
|
|
|
@@ -127,7 +127,7 @@ EXAMPLES
|
|
|
127
127
|
$ sanity-run blueprints config --edit --project-id <projectId> --stack <name-or-id>
|
|
128
128
|
```
|
|
129
129
|
|
|
130
|
-
_See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.0-next.
|
|
130
|
+
_See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.0-next.g768eed0/src/commands/blueprints/config.ts)_
|
|
131
131
|
|
|
132
132
|
## `sanity-run blueprints deploy`
|
|
133
133
|
|
|
@@ -183,7 +183,7 @@ EXAMPLES
|
|
|
183
183
|
$ sanity-run blueprints deploy --new-stack-name <new-name>
|
|
184
184
|
```
|
|
185
185
|
|
|
186
|
-
_See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.0-next.
|
|
186
|
+
_See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.0-next.g768eed0/src/commands/blueprints/deploy.ts)_
|
|
187
187
|
|
|
188
188
|
## `sanity-run blueprints destroy`
|
|
189
189
|
|
|
@@ -221,7 +221,7 @@ EXAMPLES
|
|
|
221
221
|
$ sanity-run blueprints destroy --stack <name-or-id> --project-id <projectId> --force --no-wait
|
|
222
222
|
```
|
|
223
223
|
|
|
224
|
-
_See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.0-next.
|
|
224
|
+
_See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.0-next.g768eed0/src/commands/blueprints/destroy.ts)_
|
|
225
225
|
|
|
226
226
|
## `sanity-run blueprints doctor`
|
|
227
227
|
|
|
@@ -253,7 +253,7 @@ EXAMPLES
|
|
|
253
253
|
$ sanity-run blueprints doctor --fix
|
|
254
254
|
```
|
|
255
255
|
|
|
256
|
-
_See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.0-next.
|
|
256
|
+
_See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.0-next.g768eed0/src/commands/blueprints/doctor.ts)_
|
|
257
257
|
|
|
258
258
|
## `sanity-run blueprints info`
|
|
259
259
|
|
|
@@ -291,7 +291,7 @@ EXAMPLES
|
|
|
291
291
|
$ sanity-run blueprints info --organization-id <orgId> --stack <name-or-id>
|
|
292
292
|
```
|
|
293
293
|
|
|
294
|
-
_See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.0-next.
|
|
294
|
+
_See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.0-next.g768eed0/src/commands/blueprints/info.ts)_
|
|
295
295
|
|
|
296
296
|
## `sanity-run blueprints init [DIR]`
|
|
297
297
|
|
|
@@ -355,7 +355,7 @@ EXAMPLES
|
|
|
355
355
|
$ sanity-run blueprints init old-stack --type <json|js|ts> --project-id <projectId> --stack-id <existingStackId>
|
|
356
356
|
```
|
|
357
357
|
|
|
358
|
-
_See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.0-next.
|
|
358
|
+
_See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.0-next.g768eed0/src/commands/blueprints/init.ts)_
|
|
359
359
|
|
|
360
360
|
## `sanity-run blueprints logs`
|
|
361
361
|
|
|
@@ -401,7 +401,7 @@ EXAMPLES
|
|
|
401
401
|
$ sanity-run blueprints logs --before 2026-05-01T00:00:00Z
|
|
402
402
|
```
|
|
403
403
|
|
|
404
|
-
_See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.0-next.
|
|
404
|
+
_See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.0-next.g768eed0/src/commands/blueprints/logs.ts)_
|
|
405
405
|
|
|
406
406
|
## `sanity-run blueprints mint-deploy-token`
|
|
407
407
|
|
|
@@ -446,7 +446,7 @@ EXAMPLES
|
|
|
446
446
|
$ sanity-run blueprints mint-deploy-token --organization-id <orgId>
|
|
447
447
|
```
|
|
448
448
|
|
|
449
|
-
_See code: [src/commands/blueprints/mint-deploy-token.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.0-next.
|
|
449
|
+
_See code: [src/commands/blueprints/mint-deploy-token.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.0-next.g768eed0/src/commands/blueprints/mint-deploy-token.ts)_
|
|
450
450
|
|
|
451
451
|
## `sanity-run blueprints plan`
|
|
452
452
|
|
|
@@ -479,7 +479,7 @@ EXAMPLES
|
|
|
479
479
|
$ sanity-run blueprints plan --organization-id <orgId> --stack <name-or-id>
|
|
480
480
|
```
|
|
481
481
|
|
|
482
|
-
_See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.0-next.
|
|
482
|
+
_See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.0-next.g768eed0/src/commands/blueprints/plan.ts)_
|
|
483
483
|
|
|
484
484
|
## `sanity-run blueprints promote`
|
|
485
485
|
|
|
@@ -515,7 +515,7 @@ EXAMPLES
|
|
|
515
515
|
$ sanity-run blueprints promote --new-stack-name <new-name>
|
|
516
516
|
```
|
|
517
517
|
|
|
518
|
-
_See code: [src/commands/blueprints/promote.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.0-next.
|
|
518
|
+
_See code: [src/commands/blueprints/promote.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.0-next.g768eed0/src/commands/blueprints/promote.ts)_
|
|
519
519
|
|
|
520
520
|
## `sanity-run blueprints stacks`
|
|
521
521
|
|
|
@@ -556,7 +556,7 @@ EXAMPLES
|
|
|
556
556
|
$ sanity-run blueprints stacks --organization-id <organizationId> --include-projects
|
|
557
557
|
```
|
|
558
558
|
|
|
559
|
-
_See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.0-next.
|
|
559
|
+
_See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.0-next.g768eed0/src/commands/blueprints/stacks.ts)_
|
|
560
560
|
|
|
561
561
|
## `sanity-run functions add`
|
|
562
562
|
|
|
@@ -608,7 +608,7 @@ EXAMPLES
|
|
|
608
608
|
$ sanity-run functions add --name my-function --type document-create --type document-update --lang js
|
|
609
609
|
```
|
|
610
610
|
|
|
611
|
-
_See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.0-next.
|
|
611
|
+
_See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.0-next.g768eed0/src/commands/functions/add.ts)_
|
|
612
612
|
|
|
613
613
|
## `sanity-run functions dev`
|
|
614
614
|
|
|
@@ -643,7 +643,7 @@ EXAMPLES
|
|
|
643
643
|
$ sanity-run functions dev --timeout 60
|
|
644
644
|
```
|
|
645
645
|
|
|
646
|
-
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.0-next.
|
|
646
|
+
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.0-next.g768eed0/src/commands/functions/dev.ts)_
|
|
647
647
|
|
|
648
648
|
## `sanity-run functions env add NAME KEY VALUE`
|
|
649
649
|
|
|
@@ -676,7 +676,7 @@ EXAMPLES
|
|
|
676
676
|
$ sanity-run functions env add --stack <name-or-id> MyFunction API_URL https://api.example.com/
|
|
677
677
|
```
|
|
678
678
|
|
|
679
|
-
_See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.0-next.
|
|
679
|
+
_See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.0-next.g768eed0/src/commands/functions/env/add.ts)_
|
|
680
680
|
|
|
681
681
|
## `sanity-run functions env list NAME`
|
|
682
682
|
|
|
@@ -706,7 +706,7 @@ EXAMPLES
|
|
|
706
706
|
$ sanity-run functions env list --stack <name-or-id> MyFunction
|
|
707
707
|
```
|
|
708
708
|
|
|
709
|
-
_See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.0-next.
|
|
709
|
+
_See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.0-next.g768eed0/src/commands/functions/env/list.ts)_
|
|
710
710
|
|
|
711
711
|
## `sanity-run functions env remove NAME KEY`
|
|
712
712
|
|
|
@@ -738,7 +738,7 @@ EXAMPLES
|
|
|
738
738
|
$ sanity-run functions env remove --stack <name-or-id> MyFunction API_URL
|
|
739
739
|
```
|
|
740
740
|
|
|
741
|
-
_See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.0-next.
|
|
741
|
+
_See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.0-next.g768eed0/src/commands/functions/env/remove.ts)_
|
|
742
742
|
|
|
743
743
|
## `sanity-run functions logs [NAME]`
|
|
744
744
|
|
|
@@ -778,7 +778,7 @@ EXAMPLES
|
|
|
778
778
|
$ sanity-run functions logs <name> --delete
|
|
779
779
|
```
|
|
780
780
|
|
|
781
|
-
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.0-next.
|
|
781
|
+
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.0-next.g768eed0/src/commands/functions/logs.ts)_
|
|
782
782
|
|
|
783
783
|
## `sanity-run functions test [NAME]`
|
|
784
784
|
|
|
@@ -836,7 +836,7 @@ EXAMPLES
|
|
|
836
836
|
$ sanity-run functions test <name> --event update --data-before '{ "title": "before" }' --data-after '{ "title": "after" }'
|
|
837
837
|
```
|
|
838
838
|
|
|
839
|
-
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.0-next.
|
|
839
|
+
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.0-next.g768eed0/src/commands/functions/test.ts)_
|
|
840
840
|
|
|
841
841
|
## `sanity-run help [COMMAND]`
|
|
842
842
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import AdmZip from 'adm-zip';
|
|
2
2
|
import type { AgentResource } from '../types.js';
|
|
3
|
-
/**
|
|
3
|
+
/** `sanityID` must be exactly 36 characters because the platform manifest gate requires it. */
|
|
4
4
|
export declare const SANITY_ID_LENGTH = 36;
|
|
5
5
|
/** The manifest written to `package.json` at the bundle root. */
|
|
6
6
|
export interface AgentManifest {
|
|
@@ -9,25 +9,14 @@ export interface AgentManifest {
|
|
|
9
9
|
description?: string;
|
|
10
10
|
region: string;
|
|
11
11
|
}
|
|
12
|
-
/** Derive
|
|
12
|
+
/** Derive the 36-character `sanityID` from the project scope id, as a UUID-shaped hash so it is stable across redeploys. */
|
|
13
13
|
export declare function deriveSanityId(scopeId: string): string;
|
|
14
14
|
/** Build the manifest from the resource and project scope. */
|
|
15
15
|
export declare function buildAgentManifest(resource: AgentResource, scopeId: string): AgentManifest;
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
18
|
-
* the
|
|
19
|
-
*
|
|
20
|
-
*
|
|
17
|
+
* Assemble the full bundle for a `sanity.agent` resource: the `package.json`
|
|
18
|
+
* manifest, the authored source under `agent/`, the `www/index.ts` app entry, a
|
|
19
|
+
* `public/` folder, and a `Dockerfile`. Asset prep is the only bundle producer;
|
|
20
|
+
* the Provider just reads the bytes, so the layout must be complete here.
|
|
21
21
|
*/
|
|
22
|
-
export
|
|
23
|
-
/** Seam so tests can supply a fixture `.output` instead of a real build. */
|
|
24
|
-
export declare const eveBuild: {
|
|
25
|
-
run: EveBuildRunner;
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Assemble the Web Function bundle for a `sanity.agent` resource: a runnable
|
|
29
|
-
* root `index.mjs` bootstrap, eve's built node-server under `.output/`, and the
|
|
30
|
-
* root `package.json` manifest. Asset prep is the sole producer; the Provider
|
|
31
|
-
* only reads the bytes, so the layout is complete here.
|
|
32
|
-
*/
|
|
33
|
-
export declare function buildAgentPackage(agentPath: string, manifest: AgentManifest, build?: EveBuildRunner): Promise<AdmZip>;
|
|
22
|
+
export declare function buildAgentPackage(agentPath: string, manifest: AgentManifest): AdmZip;
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import { spawn } from 'node:child_process';
|
|
2
1
|
import crypto from 'node:crypto';
|
|
3
|
-
import fs from 'node:fs';
|
|
4
|
-
import { createRequire } from 'node:module';
|
|
5
|
-
import path from 'node:path';
|
|
6
2
|
import AdmZip from 'adm-zip';
|
|
7
|
-
/**
|
|
3
|
+
/** `sanityID` must be exactly 36 characters because the platform manifest gate requires it. */
|
|
8
4
|
export const SANITY_ID_LENGTH = 36;
|
|
9
|
-
/** Derive
|
|
5
|
+
/** Derive the 36-character `sanityID` from the project scope id, as a UUID-shaped hash so it is stable across redeploys. */
|
|
10
6
|
export function deriveSanityId(scopeId) {
|
|
11
7
|
const hex = crypto.createHash('sha256').update(scopeId).digest('hex');
|
|
12
8
|
return [
|
|
@@ -29,85 +25,36 @@ export function buildAgentManifest(resource, scopeId) {
|
|
|
29
25
|
}
|
|
30
26
|
return manifest;
|
|
31
27
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
//
|
|
35
|
-
|
|
36
|
-
const WEB_FUNCTION_ENTRY = `import {mkdirSync} from 'node:fs'
|
|
37
|
-
const endpoint = process.env.AWS_LAMBDA_HTTP_ENDPOINT || '0.0.0.0:3000'
|
|
38
|
-
const sep = endpoint.lastIndexOf(':')
|
|
39
|
-
const host = sep > 0 ? endpoint.slice(0, sep).replace(/^\\[|\\]$/g, '') : '0.0.0.0'
|
|
40
|
-
const port = sep > 0 ? endpoint.slice(sep + 1) : '3000'
|
|
41
|
-
process.env.HOST = host
|
|
42
|
-
process.env.NITRO_HOST = host
|
|
43
|
-
process.env.PORT = port
|
|
44
|
-
process.env.NITRO_PORT = port
|
|
45
|
-
const dataRoot = process.env.EVE_DATA_ROOT || '/tmp/eve-data'
|
|
46
|
-
process.env.EVE_DATA_ROOT = dataRoot
|
|
47
|
-
mkdirSync(dataRoot, {recursive: true})
|
|
48
|
-
await import('./.output/server/index.mjs')
|
|
28
|
+
/** The `www/index.{js,ts}` app entry the platform layout gate requires. */
|
|
29
|
+
const WWW_INDEX_TS = `// Generated by the sanity.agent asset prep. The app entry the platform build
|
|
30
|
+
// mounts: it re-exports the authored eve agent under agent/.
|
|
31
|
+
export {default} from '../agent/agent.js'
|
|
49
32
|
`;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return path.join(path.dirname(pkgPath), bin);
|
|
62
|
-
}
|
|
63
|
-
catch {
|
|
64
|
-
throw new Error(`eve is not installed for the agent at ${agentPath}. ` +
|
|
65
|
-
'Run `npm install` in the agent project so `eve build` can run.');
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
function runEveBuild(agentPath) {
|
|
69
|
-
const eveBin = resolveEveBin(agentPath);
|
|
70
|
-
return new Promise((resolve, reject) => {
|
|
71
|
-
const child = spawn(process.execPath, [eveBin, 'build'], { cwd: agentPath });
|
|
72
|
-
let output = '';
|
|
73
|
-
child.stdout?.on('data', (d) => {
|
|
74
|
-
output += d;
|
|
75
|
-
});
|
|
76
|
-
child.stderr?.on('data', (d) => {
|
|
77
|
-
output += d;
|
|
78
|
-
});
|
|
79
|
-
child.on('error', reject);
|
|
80
|
-
child.on('close', (code) => {
|
|
81
|
-
if (code !== 0) {
|
|
82
|
-
reject(new Error(`eve build failed for ${agentPath} (exit code ${code}).\n${output.trim()}`));
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
const outputDir = path.join(agentPath, '.output');
|
|
86
|
-
const serverEntry = path.join(outputDir, 'server', 'index.mjs');
|
|
87
|
-
if (!fs.existsSync(serverEntry)) {
|
|
88
|
-
reject(new Error(`eve build did not produce ${serverEntry}.\n${output.trim()}`));
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
resolve(outputDir);
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
/** Seam so tests can supply a fixture `.output` instead of a real build. */
|
|
96
|
-
export const eveBuild = { run: runEveBuild };
|
|
33
|
+
/** The `Dockerfile` build context the platform layout gate requires. */
|
|
34
|
+
const DOCKERFILE = `# Generated by the sanity.agent asset prep.
|
|
35
|
+
FROM node:22-slim
|
|
36
|
+
WORKDIR /app
|
|
37
|
+
COPY . .
|
|
38
|
+
RUN npm install --omit=dev
|
|
39
|
+
EXPOSE 3000
|
|
40
|
+
CMD ["node", "www/index.js"]
|
|
41
|
+
`;
|
|
42
|
+
/** Keep file so the required `public/` folder exists even with no static assets. */
|
|
43
|
+
const PUBLIC_KEEP = '';
|
|
97
44
|
/**
|
|
98
|
-
* Assemble the
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
45
|
+
* Assemble the full bundle for a `sanity.agent` resource: the `package.json`
|
|
46
|
+
* manifest, the authored source under `agent/`, the `www/index.ts` app entry, a
|
|
47
|
+
* `public/` folder, and a `Dockerfile`. Asset prep is the only bundle producer;
|
|
48
|
+
* the Provider just reads the bytes, so the layout must be complete here.
|
|
102
49
|
*/
|
|
103
|
-
export
|
|
104
|
-
const outputDir = await build(agentPath);
|
|
50
|
+
export function buildAgentPackage(agentPath, manifest) {
|
|
105
51
|
const zip = new AdmZip();
|
|
106
|
-
zip.addFile('index.mjs', Buffer.from(WEB_FUNCTION_ENTRY, 'utf8'));
|
|
107
|
-
zip.addLocalFolder(outputDir, '.output');
|
|
108
52
|
zip.addFile('package.json', Buffer.from(JSON.stringify(manifest, null, 2), 'utf8'));
|
|
109
|
-
|
|
110
|
-
|
|
53
|
+
zip.addLocalFolder(agentPath, 'agent');
|
|
54
|
+
zip.addFile('www/index.ts', Buffer.from(WWW_INDEX_TS, 'utf8'));
|
|
55
|
+
zip.addFile('public/.gitkeep', Buffer.from(PUBLIC_KEEP, 'utf8'));
|
|
56
|
+
zip.addFile('Dockerfile', Buffer.from(DOCKERFILE, 'utf8'));
|
|
57
|
+
// Fixed entry times so the same input gives the same bytes, and the same asset id
|
|
111
58
|
for (const entry of zip.getEntries())
|
|
112
59
|
entry.header.time = new Date(0);
|
|
113
60
|
return zip;
|
|
@@ -1,23 +1,9 @@
|
|
|
1
1
|
import type { AgentResource, AssetPrepResult, AuthParams } from '../types.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* producer
|
|
6
|
-
*
|
|
7
|
-
* complete -- a runnable root `index.mjs` bootstrap, eve's built node-server
|
|
8
|
-
* under `.output/`, and the root `package.json` manifest. The platform deploys
|
|
9
|
-
* it as a zip Web Function (`EntryPoint index.mjs`, `Runtime nodejs24.x`), which
|
|
10
|
-
* loads the root `index.mjs`; a container layout (raw `.ts` + Dockerfile) never
|
|
11
|
-
* boots there.
|
|
12
|
-
*
|
|
13
|
-
* The `sanityID` in the manifest is derived from the project scope (`auth.scopeId`);
|
|
14
|
-
* `name`, `description`, and `region` come from the resource.
|
|
15
|
-
*
|
|
16
|
-
* The returned `assetParameter` is `src`, so once the bytes are stashed the
|
|
17
|
-
* resource `src` is rewritten from the source path to the returned `AS-...` asset
|
|
18
|
-
* id before deploy. A build failure (including a failed `eve build`) returns
|
|
19
|
-
* `{success: false}`, which fails the CLI prep step before the Blueprints API is
|
|
20
|
-
* called.
|
|
3
|
+
* Build the full bundle for a `sanity.agent` resource from its `src` source
|
|
4
|
+
* path, with the manifest inside the zip. Asset prep is the only bundle
|
|
5
|
+
* producer; the Provider just reads the prepared bytes. A failure returns
|
|
6
|
+
* `{success: false}`, failing the prep step before the Blueprints API is called.
|
|
21
7
|
*/
|
|
22
8
|
export declare function prepareAsset({ blueprintFileDir, resource, auth, }: {
|
|
23
9
|
blueprintFileDir: string;
|
|
@@ -1,26 +1,13 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { CONVERT_BYTES_TO_MB, MAX_ASSET_SIZE } from '../../constants.js';
|
|
4
|
+
import { isFolderLargerThan } from '../functions/is-folder-larger-than.js';
|
|
4
5
|
import { buildAgentManifest, buildAgentPackage } from './build-package.js';
|
|
5
6
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* producer
|
|
9
|
-
*
|
|
10
|
-
* complete -- a runnable root `index.mjs` bootstrap, eve's built node-server
|
|
11
|
-
* under `.output/`, and the root `package.json` manifest. The platform deploys
|
|
12
|
-
* it as a zip Web Function (`EntryPoint index.mjs`, `Runtime nodejs24.x`), which
|
|
13
|
-
* loads the root `index.mjs`; a container layout (raw `.ts` + Dockerfile) never
|
|
14
|
-
* boots there.
|
|
15
|
-
*
|
|
16
|
-
* The `sanityID` in the manifest is derived from the project scope (`auth.scopeId`);
|
|
17
|
-
* `name`, `description`, and `region` come from the resource.
|
|
18
|
-
*
|
|
19
|
-
* The returned `assetParameter` is `src`, so once the bytes are stashed the
|
|
20
|
-
* resource `src` is rewritten from the source path to the returned `AS-...` asset
|
|
21
|
-
* id before deploy. A build failure (including a failed `eve build`) returns
|
|
22
|
-
* `{success: false}`, which fails the CLI prep step before the Blueprints API is
|
|
23
|
-
* called.
|
|
7
|
+
* Build the full bundle for a `sanity.agent` resource from its `src` source
|
|
8
|
+
* path, with the manifest inside the zip. Asset prep is the only bundle
|
|
9
|
+
* producer; the Provider just reads the prepared bytes. A failure returns
|
|
10
|
+
* `{success: false}`, failing the prep step before the Blueprints API is called.
|
|
24
11
|
*/
|
|
25
12
|
export async function prepareAsset({ blueprintFileDir, resource, auth, }) {
|
|
26
13
|
if (!resource.src)
|
|
@@ -37,9 +24,12 @@ export async function prepareAsset({ blueprintFileDir, resource, auth, }) {
|
|
|
37
24
|
if (!existsSync(agentPath)) {
|
|
38
25
|
throw new Error(`Agent source path not found: ${agentPath}`);
|
|
39
26
|
}
|
|
27
|
+
if (isFolderLargerThan(agentPath, MAX_ASSET_SIZE)) {
|
|
28
|
+
throw new Error('Resource is larger than max asset size of 200 MB.');
|
|
29
|
+
}
|
|
40
30
|
const manifest = buildAgentManifest(resource, auth.scopeId);
|
|
41
|
-
const zip =
|
|
42
|
-
// Sum uncompressed entry sizes so the limit check reflects
|
|
31
|
+
const zip = buildAgentPackage(agentPath, manifest);
|
|
32
|
+
// Sum uncompressed entry sizes so the limit check reflects on-disk size.
|
|
43
33
|
const zipEntrySize = zip
|
|
44
34
|
.getEntries()
|
|
45
35
|
.map((entry) => entry.header.size)
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED