@sanity/runtime-cli 13.4.0 → 13.4.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
@@ -20,7 +20,7 @@ $ npm install -g @sanity/runtime-cli
20
20
  $ sanity-run COMMAND
21
21
  running command...
22
22
  $ sanity-run (--version)
23
- @sanity/runtime-cli/13.4.0 linux-x64 node-v24.13.0
23
+ @sanity/runtime-cli/13.4.1 linux-x64 node-v24.13.0
24
24
  $ sanity-run --help [COMMAND]
25
25
  USAGE
26
26
  $ sanity-run COMMAND
@@ -98,7 +98,7 @@ EXAMPLES
98
98
  $ sanity-run blueprints add function --name my-function --fn-type document-create --fn-type document-update --lang js
99
99
  ```
100
100
 
101
- _See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v13.4.0/src/commands/blueprints/add.ts)_
101
+ _See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v13.4.1/src/commands/blueprints/add.ts)_
102
102
 
103
103
  ## `sanity-run blueprints config`
104
104
 
@@ -133,7 +133,7 @@ EXAMPLES
133
133
  $ sanity-run blueprints config --edit --project-id <projectId> --stack-id <stackId>
134
134
  ```
135
135
 
136
- _See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v13.4.0/src/commands/blueprints/config.ts)_
136
+ _See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v13.4.1/src/commands/blueprints/config.ts)_
137
137
 
138
138
  ## `sanity-run blueprints deploy`
139
139
 
@@ -163,7 +163,7 @@ EXAMPLES
163
163
  $ sanity-run blueprints deploy --no-wait
164
164
  ```
165
165
 
166
- _See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v13.4.0/src/commands/blueprints/deploy.ts)_
166
+ _See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v13.4.1/src/commands/blueprints/deploy.ts)_
167
167
 
168
168
  ## `sanity-run blueprints destroy`
169
169
 
@@ -195,7 +195,7 @@ EXAMPLES
195
195
  $ sanity-run blueprints destroy --stack-id <stackId> --project-id <projectId> --force --no-wait
196
196
  ```
197
197
 
198
- _See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v13.4.0/src/commands/blueprints/destroy.ts)_
198
+ _See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v13.4.1/src/commands/blueprints/destroy.ts)_
199
199
 
200
200
  ## `sanity-run blueprints doctor`
201
201
 
@@ -221,7 +221,7 @@ DESCRIPTION
221
221
  issues.
222
222
  ```
223
223
 
224
- _See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v13.4.0/src/commands/blueprints/doctor.ts)_
224
+ _See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v13.4.1/src/commands/blueprints/doctor.ts)_
225
225
 
226
226
  ## `sanity-run blueprints info`
227
227
 
@@ -251,7 +251,7 @@ EXAMPLES
251
251
  $ sanity-run blueprints info --id <stackId>
252
252
  ```
253
253
 
254
- _See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v13.4.0/src/commands/blueprints/info.ts)_
254
+ _See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v13.4.1/src/commands/blueprints/info.ts)_
255
255
 
256
256
  ## `sanity-run blueprints init [DIR]`
257
257
 
@@ -301,7 +301,7 @@ EXAMPLES
301
301
  $ sanity-run blueprints init --blueprint-type <json|js|ts> --stack-name <stackName>
302
302
  ```
303
303
 
304
- _See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v13.4.0/src/commands/blueprints/init.ts)_
304
+ _See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v13.4.1/src/commands/blueprints/init.ts)_
305
305
 
306
306
  ## `sanity-run blueprints logs`
307
307
 
@@ -329,7 +329,7 @@ EXAMPLES
329
329
  $ sanity-run blueprints logs --watch
330
330
  ```
331
331
 
332
- _See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v13.4.0/src/commands/blueprints/logs.ts)_
332
+ _See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v13.4.1/src/commands/blueprints/logs.ts)_
333
333
 
334
334
  ## `sanity-run blueprints plan`
335
335
 
@@ -352,7 +352,7 @@ EXAMPLES
352
352
  $ sanity-run blueprints plan
353
353
  ```
354
354
 
355
- _See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v13.4.0/src/commands/blueprints/plan.ts)_
355
+ _See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v13.4.1/src/commands/blueprints/plan.ts)_
356
356
 
357
357
  ## `sanity-run blueprints stacks`
358
358
 
@@ -381,7 +381,7 @@ EXAMPLES
381
381
  $ sanity-run blueprints stacks --organization-id <organizationId>
382
382
  ```
383
383
 
384
- _See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v13.4.0/src/commands/blueprints/stacks.ts)_
384
+ _See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v13.4.1/src/commands/blueprints/stacks.ts)_
385
385
 
386
386
  ## `sanity-run functions add`
387
387
 
@@ -430,7 +430,7 @@ EXAMPLES
430
430
  $ sanity-run functions add --name my-function --type document-create --type document-update --lang js
431
431
  ```
432
432
 
433
- _See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v13.4.0/src/commands/functions/add.ts)_
433
+ _See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v13.4.1/src/commands/functions/add.ts)_
434
434
 
435
435
  ## `sanity-run functions dev`
436
436
 
@@ -464,7 +464,7 @@ EXAMPLES
464
464
  $ sanity-run functions dev --timeout 60
465
465
  ```
466
466
 
467
- _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v13.4.0/src/commands/functions/dev.ts)_
467
+ _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v13.4.1/src/commands/functions/dev.ts)_
468
468
 
469
469
  ## `sanity-run functions env add NAME KEY VALUE`
470
470
 
@@ -491,7 +491,7 @@ EXAMPLES
491
491
  $ sanity-run functions env add MyFunction API_URL https://api.example.com/
492
492
  ```
493
493
 
494
- _See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v13.4.0/src/commands/functions/env/add.ts)_
494
+ _See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v13.4.1/src/commands/functions/env/add.ts)_
495
495
 
496
496
  ## `sanity-run functions env list NAME`
497
497
 
@@ -515,7 +515,7 @@ EXAMPLES
515
515
  $ sanity-run functions env list MyFunction
516
516
  ```
517
517
 
518
- _See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v13.4.0/src/commands/functions/env/list.ts)_
518
+ _See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v13.4.1/src/commands/functions/env/list.ts)_
519
519
 
520
520
  ## `sanity-run functions env remove NAME KEY`
521
521
 
@@ -541,7 +541,7 @@ EXAMPLES
541
541
  $ sanity-run functions env remove MyFunction API_URL
542
542
  ```
543
543
 
544
- _See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v13.4.0/src/commands/functions/env/remove.ts)_
544
+ _See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v13.4.1/src/commands/functions/env/remove.ts)_
545
545
 
546
546
  ## `sanity-run functions logs [NAME]`
547
547
 
@@ -580,7 +580,7 @@ EXAMPLES
580
580
  $ sanity-run functions logs <name> --delete
581
581
  ```
582
582
 
583
- _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v13.4.0/src/commands/functions/logs.ts)_
583
+ _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v13.4.1/src/commands/functions/logs.ts)_
584
584
 
585
585
  ## `sanity-run functions test [NAME]`
586
586
 
@@ -634,7 +634,7 @@ EXAMPLES
634
634
  $ sanity-run functions test <name> --event update --data-before '{ "title": "before" }' --data-after '{ "title": "after" }'
635
635
  ```
636
636
 
637
- _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v13.4.0/src/commands/functions/test.ts)_
637
+ _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v13.4.1/src/commands/functions/test.ts)_
638
638
 
639
639
  ## `sanity-run help [COMMAND]`
640
640
 
@@ -654,5 +654,5 @@ DESCRIPTION
654
654
  Display help for sanity-run.
655
655
  ```
656
656
 
657
- _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.36/src/commands/help.ts)_
657
+ _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.37/src/commands/help.ts)_
658
658
  <!-- commandsstop -->
@@ -6,6 +6,7 @@ import { cwd } from 'node:process';
6
6
  import AdmZip from 'adm-zip';
7
7
  import getFolderSize from 'get-folder-size';
8
8
  import config from '../../config.js';
9
+ import { detectNativeModules } from '../../utils/functions/detect-native-modules.js';
9
10
  import { resolveResourceDependencies } from '../../utils/functions/resolve-dependencies.js';
10
11
  import { shouldAutoResolveDependencies } from '../../utils/functions/should-auto-resolve-deps.js';
11
12
  import { shouldTranspileFunction } from '../../utils/functions/should-transpile.js';
@@ -220,6 +221,12 @@ export async function pathToZip(path) {
220
221
  }
221
222
  export async function pathToB64ZipHash(path) {
222
223
  const zip = await pathToZip(path);
224
+ const hasNativeModules = detectNativeModules(zip);
225
+ if (hasNativeModules?.length > 0) {
226
+ const errorMsg = `Native modules detected in Function:\n${hasNativeModules.join('\n')}\n\n` +
227
+ `Please replace with JavaScript alternatives.`;
228
+ throw new Error(errorMsg);
229
+ }
223
230
  const buffer = zip.toBuffer();
224
231
  const b64 = buffer.toString('base64');
225
232
  const hash = hashBuffer(buffer);
@@ -3,7 +3,7 @@ import { basename, dirname, extname } from 'node:path';
3
3
  import { cwd, env } from 'node:process';
4
4
  import { pathToFileURL } from 'node:url';
5
5
  import blueprintParserValidator from '@sanity/blueprints-parser';
6
- import { findUpSync } from 'find-up';
6
+ import * as find from 'empathic/find';
7
7
  import { createJiti } from 'jiti';
8
8
  import { SANITY_FUNCTION_DOCUMENT, SANITY_FUNCTION_MEDIA_LIBRARY_ASSET, SANITY_FUNCTION_SCHEDULE, } from '../../constants.js';
9
9
  import { isLocalFunctionResource, } from '../../utils/types.js';
@@ -52,11 +52,7 @@ export function findBlueprintFile(blueprintPath) {
52
52
  dirToSearch = blueprintPath;
53
53
  }
54
54
  }
55
- const blueprintFile = findUpSync(SUPPORTED_FILE_NAMES, {
56
- cwd: dirToSearch,
57
- type: 'file',
58
- allowSymlinks: false,
59
- });
55
+ const blueprintFile = find.any(SUPPORTED_FILE_NAMES, { cwd: dirToSearch });
60
56
  if (!blueprintFile)
61
57
  return null;
62
58
  return {
package/dist/config.js CHANGED
@@ -1,17 +1,14 @@
1
1
  import { readFileSync } from 'node:fs';
2
2
  import { env } from 'node:process';
3
3
  import { fileURLToPath } from 'node:url';
4
- import { findUpSync } from 'find-up';
4
+ import * as pkg from 'empathic/package';
5
5
  import getToken from './utils/get-token.js';
6
6
  export const BLUEPRINT_CONFIG_VERSION = 'v2025-05-08';
7
7
  export const BLUEPRINT_CONFIG_DIR = '.sanity';
8
8
  export const BLUEPRINT_CONFIG_FILE = 'blueprint.config.json';
9
9
  export let RUNTIME_CLI_VERSION;
10
10
  try {
11
- const packageJsonPath = findUpSync('package.json', {
12
- cwd: fileURLToPath(new URL('.', import.meta.url)),
13
- type: 'file',
14
- });
11
+ const packageJsonPath = pkg.up({ cwd: fileURLToPath(new URL('.', import.meta.url)) });
15
12
  if (packageJsonPath) {
16
13
  const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
17
14
  if (packageJson.name === '@sanity/runtime-cli') {
@@ -1,5 +1,5 @@
1
1
  <!DOCTYPE html>
2
- <html>
2
+ <html lang="en">
3
3
  <head>
4
4
  <meta charset="UTF-8">
5
5
  <title>Sanity Functions</title>
@@ -14,7 +14,7 @@
14
14
  <header data-slot="header">
15
15
  <div class="flex items-center gap-25 pad-2">
16
16
  <div class="logo-image">
17
- <svg xmlns="http://www.w3.org/2000/svg" width="25" height="25" viewBox="0 0 400 400" fill="none">
17
+ <svg xmlns="http://www.w3.org/2000/svg" width="25" height="25" viewBox="0 0 400 400" fill="none" role="img" aria-label="Sanity Logo">
18
18
  <rect width="400" height="400" fill="light-dark(#0B0B0B, #FFFFFF)"/>
19
19
  <g clip-path="url(#clip0_2001_278)">
20
20
  <path d="M304.798 227.286L296.218 212.355L254.714 237.632L300.812 178.943L307.781 174.853L306.057 172.263L309.223 168.217L294.677 156.11L288.019 164.594L153.627 243.22L203.315 183.468L295.864 132.739L287.072 115.742L236.662 143.362L261.485 113.53L247.265 101L191.399 168.174L135.915 198.603L178.394 142.445L205.012 128.591L196.558 111.405L119.008 151.773L140.155 123.789L125.383 111.958L80.7414 171.041L81.4341 171.594L89.7744 188.576L139.265 162.804L94.1565 222.425L101.55 228.348L105.946 236.846L158.052 208.28L100.673 277.288L114.894 289.817L117.75 286.383L256.17 205.137L210.214 263.667L210.963 264.292L210.892 264.336L220.42 280.911L281.545 243.672L258.008 281.653L273.784 292L311.259 231.535L304.798 227.286Z" fill="light-dark(white, #0B0B0B)"/>
@@ -0,0 +1,6 @@
1
+ import type AdmZip from 'adm-zip';
2
+ /**
3
+ * Scan zip entries of dependencies for native modules.
4
+ * Native modules built on one platform may not work on another (e.g., macOS vs Linux)
5
+ */
6
+ export declare const detectNativeModules: (zip: AdmZip) => string[];
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Patterns to identify native modules based on common file types and build configurations.
3
+ */
4
+ const KNOWN_MODULE_PATTERNS = [/binding\.gyp$/, /\.node$/];
5
+ /**
6
+ * Scan zip entries of dependencies for native modules.
7
+ * Native modules built on one platform may not work on another (e.g., macOS vs Linux)
8
+ */
9
+ export const detectNativeModules = (zip) => {
10
+ try {
11
+ const zippedEntries = zip.getEntries();
12
+ const moduleNames = zippedEntries
13
+ // Filter entries that match known native module patterns
14
+ .filter((entry) => KNOWN_MODULE_PATTERNS.some((pattern) => pattern.test(entry.entryName)))
15
+ // Extract package names from the entry paths
16
+ .map((entry) => entry.entryName.match(/node_modules[\\/](.+?)[\\/]/)?.[1])
17
+ // Filter out undefined results (in case the regex didn't match)
18
+ .filter((name) => name !== undefined);
19
+ // return a unique list of module names
20
+ return [...new Set(moduleNames)];
21
+ }
22
+ catch (error) {
23
+ const message = error instanceof Error ? error.message : String(error);
24
+ throw new Error(`Failed to scan zip for native modules: ${message}`);
25
+ }
26
+ };
@@ -2,11 +2,11 @@ import { mkdir, readFile, rm, stat, writeFile } from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
  import { performance } from 'node:perf_hooks';
4
4
  import { cwd } from 'node:process';
5
+ import * as find from 'empathic/find';
5
6
  import { build as viteBuild } from 'vite';
6
7
  import tsConfigPaths from 'vite-tsconfig-paths';
7
8
  import { findFunctionEntryPoint } from '../functions/find-entry-point.js';
8
9
  import { cleanupSourceMaps } from './cleanup-source-maps.js';
9
- import { findDirUp } from './find-up.js';
10
10
  import { verifyHandler } from './verify-handler.js';
11
11
  export async function transpileFunction(resource) {
12
12
  if (!resource.src)
@@ -25,7 +25,7 @@ export async function transpileFunction(resource) {
25
25
  const outputPathStart = performance.now();
26
26
  const outputDir = await getTranspileOutputPath(entryDir, resource.name);
27
27
  const outputFile = path.join(outputDir, getOutputFilename(entry));
28
- const fnRootDir = (await findDirUp('node_modules', entryDir)) || entryDir;
28
+ const fnRootDir = find.dir('node_modules', { cwd: entryDir }) ?? entryDir;
29
29
  timings['transpile:setupOutput'] = performance.now() - outputPathStart;
30
30
  async function cleanupTmpDir() {
31
31
  // Feel a certain way about leaving things uncleaned, but helps with debugging for now
@@ -2026,5 +2026,5 @@
2026
2026
  ]
2027
2027
  }
2028
2028
  },
2029
- "version": "13.4.0"
2029
+ "version": "13.4.1"
2030
2030
  }
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": "13.4.0",
4
+ "version": "13.4.1",
5
5
  "author": "Sanity Runtime Team",
6
6
  "type": "module",
7
7
  "license": "MIT",
@@ -99,38 +99,38 @@
99
99
  "dependencies": {
100
100
  "@architect/hydrate": "^5.0.1",
101
101
  "@architect/inventory": "^5.0.0",
102
- "@inquirer/prompts": "^8.2.0",
102
+ "@inquirer/prompts": "^8.2.1",
103
103
  "@oclif/core": "^4.8.0",
104
- "@oclif/plugin-help": "^6.2.36",
105
- "@sanity/blueprints": "^0.9.0",
104
+ "@oclif/plugin-help": "^6.2.37",
105
+ "@sanity/blueprints": "^0.12.2",
106
106
  "@sanity/blueprints-parser": "^0.4.0",
107
- "@sanity/client": "^7.14.0",
107
+ "@sanity/client": "^7.15.0",
108
108
  "adm-zip": "^0.5.16",
109
109
  "array-treeify": "^0.1.5",
110
110
  "cardinal": "^2.1.1",
111
+ "empathic": "^2.0.0",
111
112
  "eventsource": "^4.1.0",
112
- "find-up": "^8.0.0",
113
113
  "get-folder-size": "^5.0.0",
114
- "groq-js": "^1.25.0",
114
+ "groq-js": "^1.27.1",
115
115
  "jiti": "^2.6.1",
116
116
  "mime-types": "^3.0.2",
117
- "ora": "^9.1.0",
117
+ "ora": "^9.3.0",
118
118
  "tar-stream": "^3.1.7",
119
119
  "vite": "^7.3.1",
120
- "vite-tsconfig-paths": "^6.0.4",
120
+ "vite-tsconfig-paths": "^6.1.1",
121
121
  "ws": "^8.19.0",
122
122
  "xdg-basedir": "^5.1.0"
123
123
  },
124
124
  "devDependencies": {
125
- "@biomejs/biome": "2.3.11",
125
+ "@biomejs/biome": "2.4.3",
126
126
  "@codemirror/lang-json": "^6.0.2",
127
127
  "@codemirror/state": "^6.5.4",
128
128
  "@enhance/store": "^1.0.2",
129
129
  "@lezer/highlight": "^1.2.3",
130
- "@oclif/test": "^4.1.15",
131
- "@playwright/test": "^1.57.0",
130
+ "@oclif/test": "^4.1.16",
131
+ "@playwright/test": "^1.58.2",
132
132
  "@rollup/plugin-node-resolve": "^16.0.3",
133
- "@sanity/functions": "^1.1.0",
133
+ "@sanity/functions": "^1.2.0",
134
134
  "@types/adm-zip": "^0.5.7",
135
135
  "@types/cardinal": "^2.1.1",
136
136
  "@types/mime-types": "^3.0.1",
@@ -139,14 +139,14 @@
139
139
  "@types/ws": "^8.18.1",
140
140
  "codemirror": "^6.0.2",
141
141
  "mentoss": "^0.13.0",
142
- "oclif": "^4.22.67",
142
+ "oclif": "^4.22.79",
143
143
  "pretty-bytes": "^7.1.0",
144
144
  "pretty-ms": "^9.3.0",
145
- "rollup": "^4.55.3",
145
+ "rollup": "^4.57.1",
146
146
  "shx": "^0.4.0",
147
147
  "ts-node": "^10.9.2",
148
148
  "typescript": "^5.9.3",
149
- "vitest": "4.0.17"
149
+ "vitest": "4.0.18"
150
150
  },
151
151
  "oclif": {
152
152
  "bin": "sanity-run",