@sanity/runtime-cli 17.11.1 → 17.12.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 +19 -19
- package/dist/actions/blueprints/assets.d.ts +21 -20
- package/dist/actions/blueprints/assets.js +17 -87
- package/dist/actions/blueprints/logs-polling.d.ts +3 -5
- package/dist/actions/blueprints/logs-polling.js +4 -9
- package/dist/actions/blueprints/logs.d.ts +1 -2
- package/dist/actions/blueprints/logs.js +1 -3
- package/dist/actions/blueprints/operations-state.d.ts +10 -0
- package/dist/actions/blueprints/operations-state.js +42 -0
- package/dist/actions/blueprints/operations.d.ts +2 -9
- package/dist/actions/blueprints/operations.js +1 -15
- package/dist/actions/blueprints/pre-deploy.d.ts +14 -9
- package/dist/actions/blueprints/pre-deploy.js +83 -26
- package/dist/actions/blueprints/process-assets.d.ts +12 -11
- package/dist/actions/blueprints/process-assets.js +8 -7
- package/dist/actions/blueprints/stacks.d.ts +4 -4
- package/dist/actions/blueprints/stacks.js +2 -4
- package/dist/actions/blueprints/wait-for-operation.d.ts +1 -10
- package/dist/actions/blueprints/wait-for-operation.js +56 -101
- package/dist/baseCommands.js +6 -1
- package/dist/cores/blueprints/deploy.js +28 -6
- package/dist/cores/blueprints/destroy.js +4 -2
- package/dist/cores/blueprints/doctor.js +1 -1
- package/dist/cores/blueprints/init.js +3 -1
- package/dist/cores/blueprints/logs.js +11 -5
- package/dist/cores/functions/build.js +4 -5
- package/dist/cores/functions/test.js +33 -21
- package/dist/cores/index.js +3 -1
- package/dist/server/handlers/invoke.js +1 -1
- package/dist/utils/blueprints/resolve-deployed-resources.d.ts +2 -3
- package/dist/utils/blueprints/resolve-deployed-resources.js +2 -2
- package/dist/utils/blueprints/wait-for.d.ts +60 -0
- package/dist/utils/blueprints/wait-for.js +115 -0
- package/dist/utils/functions/child-process-wrapper.js +1 -1
- package/dist/utils/functions/child-runtime/durable.js +8 -0
- package/dist/utils/functions/invoke/assert-console.d.ts +5 -0
- package/dist/utils/functions/invoke/assert-console.js +60 -0
- package/dist/utils/functions/invoke/local.js +9 -0
- package/dist/utils/functions/is-folder-larger-than.d.ts +5 -0
- package/dist/utils/functions/is-folder-larger-than.js +38 -0
- package/dist/utils/functions/prepare-asset.d.ts +2 -0
- package/dist/utils/functions/prepare-asset.js +43 -6
- package/dist/utils/studios/prepare-asset.js +5 -3
- package/dist/utils/types.d.ts +19 -5
- package/dist/utils/types.js +0 -3
- package/oclif.manifest.json +1 -1
- package/package.json +2 -2
- package/dist/utils/functions/get-folder-size.d.ts +0 -5
- package/dist/utils/functions/get-folder-size.js +0 -24
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createWriteStream } from 'node:fs';
|
|
2
|
-
import { mkdtemp, rm, stat } from 'node:fs/promises';
|
|
2
|
+
import { mkdtemp, readFile, rm, stat } from 'node:fs/promises';
|
|
3
3
|
import { tmpdir } from 'node:os';
|
|
4
4
|
import path, { basename, dirname, join } from 'node:path';
|
|
5
5
|
import { pipeline } from 'node:stream/promises';
|
|
@@ -105,11 +105,13 @@ export async function prepareStudioAsset({ blueprintFileDir, resource, }) {
|
|
|
105
105
|
}
|
|
106
106
|
// tar/gzip/write the built output
|
|
107
107
|
await pipeline(pack(dirname(outDir), { entries: [basename(outDir)] }), createGzip(), createWriteStream(outFile));
|
|
108
|
+
const buffer = await readFile(outFile);
|
|
108
109
|
return {
|
|
109
110
|
success: true,
|
|
110
111
|
cleanup,
|
|
111
|
-
|
|
112
|
-
|
|
112
|
+
outputBuffer: buffer,
|
|
113
|
+
fileExtension: 'tar.gz',
|
|
114
|
+
assetParameter: 'src',
|
|
113
115
|
};
|
|
114
116
|
}
|
|
115
117
|
catch (error) {
|
package/dist/utils/types.d.ts
CHANGED
|
@@ -20,8 +20,6 @@ export type FunctionResource = FunctionGroqResource | BlueprintPubSubFunctionRes
|
|
|
20
20
|
export type EventFunctionResource = Exclude<FunctionResource, BlueprintPubSubFunctionResource>;
|
|
21
21
|
/** The `event` of any function resource that declares one */
|
|
22
22
|
export type FunctionResourceEvent = EventFunctionResource['event'];
|
|
23
|
-
/** Resource types that carry a deployable asset (have src: string) */
|
|
24
|
-
export type AssetResource = FunctionResource | BlueprintStudioResource;
|
|
25
23
|
/** @internal */
|
|
26
24
|
export interface AuthParams {
|
|
27
25
|
token: string;
|
|
@@ -52,7 +50,6 @@ export declare function isRoleResource(r: unknown): r is BlueprintRoleResource;
|
|
|
52
50
|
export declare function isDatasetResource(r: unknown): r is BlueprintDatasetResource;
|
|
53
51
|
export declare function isStudioResource(r: BlueprintResource): r is BlueprintStudioResource;
|
|
54
52
|
export declare function isDurableFunctionResource(r: unknown): r is BlueprintDurableFunctionResource;
|
|
55
|
-
export declare function isAssetResource(r: BlueprintResource): r is AssetResource;
|
|
56
53
|
export declare function isWebhookResource(r: unknown): r is BlueprintDocumentWebhookResource;
|
|
57
54
|
interface StackBase {
|
|
58
55
|
id: string;
|
|
@@ -301,19 +298,36 @@ export declare const INSTALLER_OPTIONS: readonly ['npm', 'pnpm', 'yarn'];
|
|
|
301
298
|
export type InstallerType = 'npm' | 'pnpm' | 'yarn';
|
|
302
299
|
export type AssetPrepResult = {
|
|
303
300
|
success: true;
|
|
304
|
-
|
|
301
|
+
outputBuffer: Buffer;
|
|
302
|
+
fileExtension: string;
|
|
303
|
+
assetParameter: string;
|
|
305
304
|
cleanup: () => Promise<void>;
|
|
306
305
|
} | {
|
|
307
306
|
success: false;
|
|
308
307
|
cleanup: () => Promise<void>;
|
|
309
308
|
error: string;
|
|
310
309
|
};
|
|
310
|
+
export type PrepAssetFn<R extends BlueprintResource> = (options: {
|
|
311
|
+
resource: R;
|
|
312
|
+
blueprintFileDir: string;
|
|
313
|
+
installer?: InstallerType;
|
|
314
|
+
}) => Promise<AssetPrepResult>;
|
|
315
|
+
export type PreDeployConfig = {
|
|
316
|
+
/** The resource type this config applies to or a function that returns true if this config applies to the given type. */
|
|
317
|
+
resourceType: string | ((type: string) => boolean);
|
|
318
|
+
/** Function that takes a resource and returns a buffer to be sent to blueprints. */
|
|
319
|
+
prepareAsset?: PrepAssetFn<BlueprintResource>;
|
|
320
|
+
};
|
|
321
|
+
export type AssetResource<R extends BlueprintResource> = {
|
|
322
|
+
resource: R;
|
|
323
|
+
prepareAsset: PrepAssetFn<R>;
|
|
324
|
+
};
|
|
311
325
|
export type Warning = {
|
|
312
326
|
code: string;
|
|
313
327
|
suggestions: string[];
|
|
314
328
|
};
|
|
315
329
|
/** @internal */
|
|
316
|
-
export type DurableOperationSteps = 'run' | 'wait' | 'waitForCondition';
|
|
330
|
+
export type DurableOperationSteps = 'run' | 'wait' | 'waitForCondition' | 'delegate';
|
|
317
331
|
/** @internal */
|
|
318
332
|
export type DurableStepPhase = 'start' | 'complete' | 'error';
|
|
319
333
|
/**
|
package/dist/utils/types.js
CHANGED
|
@@ -31,9 +31,6 @@ export function isStudioResource(r) {
|
|
|
31
31
|
export function isDurableFunctionResource(r) {
|
|
32
32
|
return validateDurableFunction(r).length === 0;
|
|
33
33
|
}
|
|
34
|
-
export function isAssetResource(r) {
|
|
35
|
-
return isLocalFunctionResource(r) || isStudioResource(r);
|
|
36
|
-
}
|
|
37
34
|
export function isWebhookResource(r) {
|
|
38
35
|
return validateDocumentWebhook(r).length === 0;
|
|
39
36
|
}
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/runtime-cli",
|
|
3
3
|
"description": "Sanity's Runtime CLI for Blueprints and Functions",
|
|
4
|
-
"version": "17.
|
|
4
|
+
"version": "17.12.1",
|
|
5
5
|
"author": "Sanity Runtime Team",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "MIT",
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"@playwright/test": "^1.62.1",
|
|
102
102
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
103
103
|
"@sanity-labs/design-tokens": "^0.0.2-alpha.2",
|
|
104
|
-
"@sanity/functions": "^1.7.
|
|
104
|
+
"@sanity/functions": "^1.7.2",
|
|
105
105
|
"@types/cardinal": "^2.1.1",
|
|
106
106
|
"@types/mime-types": "^3.0.1",
|
|
107
107
|
"@types/node": "^22",
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { readdirSync, statSync } from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
/**
|
|
4
|
-
* Recursively calculates the total size of a folder, including all nested files and subdirectories.
|
|
5
|
-
*/
|
|
6
|
-
export const getFolderSize = (folder) => {
|
|
7
|
-
if (!statSync(folder).isDirectory()) {
|
|
8
|
-
throw new Error('Provided path is not a directory');
|
|
9
|
-
}
|
|
10
|
-
let totalSize = 0;
|
|
11
|
-
const fileEntries = readdirSync(folder);
|
|
12
|
-
for (const file of fileEntries) {
|
|
13
|
-
const filePath = path.join(folder.toString(), file);
|
|
14
|
-
const stats = statSync(filePath);
|
|
15
|
-
if (stats.isFile()) {
|
|
16
|
-
totalSize += stats.size;
|
|
17
|
-
}
|
|
18
|
-
else if (stats.isDirectory()) {
|
|
19
|
-
const recursiveSize = getFolderSize(filePath);
|
|
20
|
-
totalSize += recursiveSize;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return totalSize;
|
|
24
|
-
};
|