@sanity/runtime-cli 1.0.2 → 1.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Sanity.io
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -20,7 +20,7 @@ $ npm install -g @sanity/runtime-cli
20
20
  $ sanity COMMAND
21
21
  running command...
22
22
  $ sanity (--version)
23
- @sanity/runtime-cli/1.0.2 linux-x64 node-v22.13.1
23
+ @sanity/runtime-cli/1.1.1 linux-x64 node-v22.14.0
24
24
  $ sanity --help [COMMAND]
25
25
  USAGE
26
26
  $ sanity COMMAND
@@ -63,7 +63,7 @@ EXAMPLES
63
63
  $ sanity functions dev --port 8974
64
64
  ```
65
65
 
66
- _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v1.0.2/src/commands/functions/dev.ts)_
66
+ _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v1.1.1/src/commands/functions/dev.ts)_
67
67
 
68
68
  ## `sanity functions invoke ID`
69
69
 
@@ -89,7 +89,7 @@ EXAMPLES
89
89
  $ sanity functions invoke <ID> --file 'payload.json'
90
90
  ```
91
91
 
92
- _See code: [src/commands/functions/invoke.ts](https://github.com/sanity-io/runtime-cli/blob/v1.0.2/src/commands/functions/invoke.ts)_
92
+ _See code: [src/commands/functions/invoke.ts](https://github.com/sanity-io/runtime-cli/blob/v1.1.1/src/commands/functions/invoke.ts)_
93
93
 
94
94
  ## `sanity functions logs ID`
95
95
 
@@ -109,7 +109,7 @@ EXAMPLES
109
109
  $ sanity functions logs <ID>
110
110
  ```
111
111
 
112
- _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v1.0.2/src/commands/functions/logs.ts)_
112
+ _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v1.1.1/src/commands/functions/logs.ts)_
113
113
 
114
114
  ## `sanity functions test PATH`
115
115
 
@@ -138,7 +138,7 @@ EXAMPLES
138
138
  $ sanity functions test ./test.ts --data '{ "id": 1 }' --timeout 60
139
139
  ```
140
140
 
141
- _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v1.0.2/src/commands/functions/test.ts)_
141
+ _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v1.1.1/src/commands/functions/test.ts)_
142
142
 
143
143
  ## `sanity help [COMMAND]`
144
144
 
@@ -1 +1 @@
1
- export declare function logs(id: string): Promise<object>;
1
+ export declare function logs(id: string, token: string): Promise<object>;
@@ -1,11 +1,12 @@
1
1
  import config from '../../config.js';
2
2
  const { url } = config.server;
3
- export async function logs(id) {
3
+ export async function logs(id, token) {
4
4
  // eslint-disable-next-line n/no-unsupported-features/node-builtins
5
5
  const response = await fetch(`${url}/api/vX/functions/${id}/logs`, {
6
6
  headers: {
7
7
  Accept: 'application/json',
8
8
  'Content-Type': 'application/json',
9
+ Authorization: `Bearer ${token}`,
9
10
  },
10
11
  method: 'GET',
11
12
  });
@@ -1,5 +1,6 @@
1
1
  import { Args, Command } from '@oclif/core';
2
2
  import { logs } from '../../actions/functions/logs.js';
3
+ import config from '../../config.js';
3
4
  export default class Logs extends Command {
4
5
  static args = {
5
6
  id: Args.string({ description: 'The ID of the function to retrieve logs for', required: true }),
@@ -8,7 +9,7 @@ export default class Logs extends Command {
8
9
  static examples = ['<%= config.bin %> <%= command.id %> <ID>'];
9
10
  async run() {
10
11
  const { args } = await this.parse(Logs);
11
- const result = await logs(args.id);
12
+ const result = await logs(args.id, config.token);
12
13
  this.log(JSON.stringify(result, null, 2));
13
14
  }
14
15
  }
package/dist/config.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  declare const _default: {
2
+ token: string;
2
3
  server: {
3
4
  url: string;
4
5
  };
package/dist/config.js CHANGED
@@ -1,8 +1,10 @@
1
1
  import { env } from 'node:process';
2
+ import getToken from './utils/get-token.js';
2
3
  const nodeEnv = env.NODE_ENV ?? 'development';
3
4
  const isDev = nodeEnv === 'development';
4
5
  const baseUrl = isDev ? 'http://localhost:4567' : '';
5
6
  export default {
7
+ token: isDev ? 'token' : getToken(),
6
8
  server: {
7
9
  url: baseUrl,
8
10
  },
@@ -0,0 +1 @@
1
+ export default function getToken(): string;
@@ -0,0 +1,11 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { tmpdir, userInfo } from 'node:os';
3
+ import { join } from 'node:path';
4
+ import { xdgConfig } from 'xdg-basedir';
5
+ export default function getToken() {
6
+ const user = (userInfo().username || 'user').replace(/\\/g, '');
7
+ const configDir = xdgConfig || join(tmpdir(), user, '.config');
8
+ const configPath = join(configDir, 'sanity', 'config.json');
9
+ const config = JSON.parse(readFileSync(configPath, 'utf8'));
10
+ return config.authToken;
11
+ }
@@ -175,5 +175,5 @@
175
175
  ]
176
176
  }
177
177
  },
178
- "version": "1.0.2"
178
+ "version": "1.1.1"
179
179
  }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@sanity/runtime-cli",
3
3
  "description": "A new CLI generated with oclif",
4
- "version": "1.0.2",
4
+ "version": "1.1.1",
5
5
  "author": "Sanity Runtime Team",
6
6
  "type": "module",
7
- "license": "UNLICENSED",
7
+ "license": "MIT",
8
8
  "repository": "sanity-io/runtime-cli",
9
9
  "bugs": "https://github.com/sanity-io/runtime-cli/issues",
10
10
  "homepage": "https://github.com/sanity-io/runtime-cli",
@@ -39,7 +39,8 @@
39
39
  "@oclif/core": "^4",
40
40
  "@oclif/plugin-help": "^6",
41
41
  "@oclif/plugin-plugins": "^5",
42
- "hono": "^4.7.2"
42
+ "hono": "^4.7.2",
43
+ "xdg-basedir": "^5.1.0"
43
44
  },
44
45
  "devDependencies": {
45
46
  "@biomejs/biome": "1.9.4",