@sanity/runtime-cli 4.3.5-bundle.0 → 4.4.0

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.
Files changed (42) hide show
  1. package/README.md +17 -17
  2. package/dist/actions/blueprints/assets.d.ts +0 -1
  3. package/dist/actions/blueprints/assets.js +4 -21
  4. package/dist/actions/functions/test.d.ts +2 -2
  5. package/dist/actions/functions/test.js +2 -2
  6. package/dist/commands/functions/test.js +6 -3
  7. package/dist/server/app.js +12 -80
  8. package/dist/server/static/api.js +3 -24
  9. package/dist/server/static/components/app.css +117 -0
  10. package/dist/server/static/components/console-panel.d.ts +1 -0
  11. package/dist/server/static/components/console-panel.js +53 -0
  12. package/dist/server/static/components/filters.js +4 -3
  13. package/dist/server/static/components/function-list.js +4 -4
  14. package/dist/server/static/components/response-panel.js +25 -28
  15. package/dist/server/static/index.html +4 -2
  16. package/dist/server/static/vendor/vendor.bundle.d.ts +2 -2
  17. package/dist/utils/build-payload.d.ts +1 -1
  18. package/dist/utils/build-payload.js +3 -3
  19. package/dist/utils/child-process-wrapper.js +6 -8
  20. package/dist/utils/invoke-local.d.ts +2 -2
  21. package/dist/utils/invoke-local.js +7 -48
  22. package/dist/utils/is-json.d.ts +1 -0
  23. package/dist/utils/is-json.js +12 -0
  24. package/dist/utils/types.d.ts +1 -3
  25. package/oclif.manifest.json +1 -1
  26. package/package.json +1 -4
  27. package/dist/utils/bundle/bundle-function.d.ts +0 -8
  28. package/dist/utils/bundle/bundle-function.js +0 -125
  29. package/dist/utils/bundle/cleanup-source-maps.d.ts +0 -10
  30. package/dist/utils/bundle/cleanup-source-maps.js +0 -53
  31. package/dist/utils/bundle/find-up.d.ts +0 -16
  32. package/dist/utils/bundle/find-up.js +0 -39
  33. package/dist/utils/bundle/verify-handler.d.ts +0 -2
  34. package/dist/utils/bundle/verify-handler.js +0 -13
  35. package/dist/utils/functions/find-entry-point.d.ts +0 -11
  36. package/dist/utils/functions/find-entry-point.js +0 -75
  37. package/dist/utils/functions/should-bundle.d.ts +0 -2
  38. package/dist/utils/functions/should-bundle.js +0 -23
  39. package/dist/utils/is-record.d.ts +0 -1
  40. package/dist/utils/is-record.js +0 -3
  41. package/dist/utils/parse-json-object.d.ts +0 -1
  42. package/dist/utils/parse-json-object.js +0 -10
@@ -1,11 +0,0 @@
1
- /**
2
- * Resolves the source path to an executable entry file path.
3
- *
4
- * If the source path is a directory, it looks for `package.json#main`, then `index.ts`, then `index.js`.
5
- *
6
- * @param srcPath - The source path (can be a file or directory).
7
- * @param displayName - Optional display name for the function, used in error messages.
8
- * @returns The absolute path to the entry file.
9
- * @throws If the entry file cannot be determined.
10
- */
11
- export declare function findFunctionEntryPoint(srcPath: string, displayName?: string): Promise<string>;
@@ -1,75 +0,0 @@
1
- import { readFile, stat } from 'node:fs/promises';
2
- import { join, resolve } from 'node:path';
3
- import { cwd } from 'node:process';
4
- /**
5
- * Resolves the source path to an executable entry file path.
6
- *
7
- * If the source path is a directory, it looks for `package.json#main`, then `index.ts`, then `index.js`.
8
- *
9
- * @param srcPath - The source path (can be a file or directory).
10
- * @param displayName - Optional display name for the function, used in error messages.
11
- * @returns The absolute path to the entry file.
12
- * @throws If the entry file cannot be determined.
13
- */
14
- export async function findFunctionEntryPoint(srcPath, displayName) {
15
- const absolutePath = resolve(cwd(), srcPath);
16
- let stats;
17
- try {
18
- stats = await stat(absolutePath);
19
- }
20
- catch (err) {
21
- throw new Error(`Source path not found or inaccessible: ${srcPath}`, { cause: err });
22
- }
23
- if (stats.isFile()) {
24
- // It's already an entry file path
25
- return absolutePath;
26
- }
27
- if (stats.isDirectory()) {
28
- // 1. Check package.json#main
29
- try {
30
- const pkgJsonPath = join(absolutePath, 'package.json');
31
- const pkgJsonContent = await readFile(pkgJsonPath, 'utf8');
32
- const pkgJson = JSON.parse(pkgJsonContent);
33
- if (pkgJson.main) {
34
- const mainPath = resolve(absolutePath, pkgJson.main);
35
- if (await fileExists(mainPath)) {
36
- return mainPath;
37
- }
38
- // If pkgJson.main points to a non-existent file, we continue checking index files
39
- }
40
- }
41
- catch {
42
- // Ignore errors (missing package.json, invalid JSON, etc.)
43
- // Consider warning the user on invalid JSON though?
44
- }
45
- // 2. Check index.ts
46
- const indexTs = join(absolutePath, 'index.ts');
47
- if (await fileExists(indexTs)) {
48
- return indexTs;
49
- }
50
- // 3. Check index.js
51
- const indexJs = join(absolutePath, 'index.js');
52
- if (await fileExists(indexJs)) {
53
- return indexJs;
54
- }
55
- const nameHint = displayName ? ` for function "${displayName}"` : '';
56
- throw new Error(`Could not determine entry file${nameHint} in directory: ${srcPath}. Looked for package.json#main, index.ts, index.js.`);
57
- }
58
- // Should not happen if stat succeeded, but defensively handle
59
- throw new Error(`Source path is neither a file nor a directory: ${srcPath}`);
60
- }
61
- /**
62
- * Checks if a file exists and is a file.
63
- */
64
- async function fileExists(filePath) {
65
- try {
66
- const stats = await stat(filePath);
67
- return stats.isFile();
68
- }
69
- catch (err) {
70
- if (err instanceof Error && 'code' in err && err.code === 'ENOENT') {
71
- return false;
72
- }
73
- throw err; // Re-throw other errors
74
- }
75
- }
@@ -1,2 +0,0 @@
1
- import type { LocalFunctionResource } from '../types.js';
2
- export declare function shouldBundleFunction(resource: LocalFunctionResource): Promise<boolean>;
@@ -1,23 +0,0 @@
1
- import { findFunctionEntryPoint } from './find-entry-point.js';
2
- export async function shouldBundleFunction(resource) {
3
- // 1. Explicit configuration takes precedence
4
- if (typeof resource.bundle === 'boolean') {
5
- return resource.bundle;
6
- }
7
- if (!resource.src) {
8
- // Cannot determine without a source path
9
- return false;
10
- }
11
- try {
12
- // 2. Find the actual entry point
13
- const entryPoint = await findFunctionEntryPoint(resource.src, resource.displayName ?? resource.name);
14
- // 3. Check if the resolved entry point is a TypeScript file
15
- return entryPoint.endsWith('.ts');
16
- }
17
- catch (err) {
18
- // If we cannot find the entry point, we cannot determine if it's TS.
19
- // Log a warning and default to false (don't bundle).
20
- console.warn(`[warn] Could not determine entry point for function "${resource.displayName ?? resource.name}" while checking if bundling is needed: ${err instanceof Error ? err.message : err}`);
21
- return false;
22
- }
23
- }
@@ -1 +0,0 @@
1
- export declare function isRecord(value: unknown): value is Record<string, unknown>;
@@ -1,3 +0,0 @@
1
- export function isRecord(value) {
2
- return typeof value === 'object' && value !== null && !Array.isArray(value);
3
- }
@@ -1 +0,0 @@
1
- export declare function parseJsonObject(jsonString: string): null | Record<string, unknown>;
@@ -1,10 +0,0 @@
1
- import { isRecord } from './is-record.js';
2
- export function parseJsonObject(jsonString) {
3
- try {
4
- const o = JSON.parse(jsonString);
5
- return isRecord(o) ? o : null;
6
- }
7
- catch {
8
- return null;
9
- }
10
- }