@sanity/runtime-cli 1.1.1 → 1.1.2
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 +5 -5
- package/dist/actions/functions/invoke.js +2 -2
- package/dist/actions/functions/logs.js +2 -2
- package/dist/config.d.ts +1 -1
- package/dist/config.js +9 -3
- package/dist/utils/get-token.d.ts +1 -1
- package/dist/utils/get-token.js +3 -2
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
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.1.
|
|
23
|
+
@sanity/runtime-cli/1.1.2 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.1.
|
|
66
|
+
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v1.1.2/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.1.
|
|
92
|
+
_See code: [src/commands/functions/invoke.ts](https://github.com/sanity-io/runtime-cli/blob/v1.1.2/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.1.
|
|
112
|
+
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v1.1.2/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.1.
|
|
141
|
+
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v1.1.2/src/commands/functions/test.ts)_
|
|
142
142
|
|
|
143
143
|
## `sanity help [COMMAND]`
|
|
144
144
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import config from '../../config.js';
|
|
2
2
|
import buildPayload from '../../utils/build-payload.js';
|
|
3
|
-
const {
|
|
3
|
+
const { functions } = config.server;
|
|
4
4
|
export async function invoke(id, options) {
|
|
5
5
|
const payload = buildPayload(options);
|
|
6
6
|
// eslint-disable-next-line n/no-unsupported-features/node-builtins
|
|
7
|
-
const response = await fetch(`${
|
|
7
|
+
const response = await fetch(`${functions}/vX/functions/${id}/invoke`, {
|
|
8
8
|
body: JSON.stringify({ data: payload }),
|
|
9
9
|
headers: {
|
|
10
10
|
Accept: 'application/json',
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import config from '../../config.js';
|
|
2
|
-
const {
|
|
2
|
+
const { functions } = config.server;
|
|
3
3
|
export async function logs(id, token) {
|
|
4
4
|
// eslint-disable-next-line n/no-unsupported-features/node-builtins
|
|
5
|
-
const response = await fetch(`${
|
|
5
|
+
const response = await fetch(`${functions}/vX/functions/${id}/logs`, {
|
|
6
6
|
headers: {
|
|
7
7
|
Accept: 'application/json',
|
|
8
8
|
'Content-Type': 'application/json',
|
package/dist/config.d.ts
CHANGED
package/dist/config.js
CHANGED
|
@@ -2,10 +2,16 @@ import { env } from 'node:process';
|
|
|
2
2
|
import getToken from './utils/get-token.js';
|
|
3
3
|
const nodeEnv = env.NODE_ENV ?? 'development';
|
|
4
4
|
const isDev = nodeEnv === 'development';
|
|
5
|
-
const
|
|
5
|
+
const isProd = nodeEnv === 'production';
|
|
6
|
+
const functionsUrls = {
|
|
7
|
+
production: 'https://api.sanity.io/',
|
|
8
|
+
staging: 'https://api.sanity.work/',
|
|
9
|
+
default: 'http://localhost:4567',
|
|
10
|
+
};
|
|
11
|
+
const functionsUrl = new URL(functionsUrls[nodeEnv] ?? functionsUrls.default);
|
|
6
12
|
export default {
|
|
7
|
-
token: isDev ? 'token' : getToken(),
|
|
13
|
+
token: isDev ? 'token' : getToken(isProd),
|
|
8
14
|
server: {
|
|
9
|
-
|
|
15
|
+
functions: functionsUrl,
|
|
10
16
|
},
|
|
11
17
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function getToken(): string;
|
|
1
|
+
export default function getToken(isProd: boolean): string;
|
package/dist/utils/get-token.js
CHANGED
|
@@ -2,10 +2,11 @@ import { readFileSync } from 'node:fs';
|
|
|
2
2
|
import { tmpdir, userInfo } from 'node:os';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
4
|
import { xdgConfig } from 'xdg-basedir';
|
|
5
|
-
export default function getToken() {
|
|
5
|
+
export default function getToken(isProd) {
|
|
6
|
+
const environmentDir = isProd ? 'sanity' : 'sanity-staging';
|
|
6
7
|
const user = (userInfo().username || 'user').replace(/\\/g, '');
|
|
7
8
|
const configDir = xdgConfig || join(tmpdir(), user, '.config');
|
|
8
|
-
const configPath = join(configDir,
|
|
9
|
+
const configPath = join(configDir, environmentDir, 'config.json');
|
|
9
10
|
const config = JSON.parse(readFileSync(configPath, 'utf8'));
|
|
10
11
|
return config.authToken;
|
|
11
12
|
}
|
package/oclif.manifest.json
CHANGED