@sanity/runtime-cli 5.0.4 → 5.2.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 (52) hide show
  1. package/README.md +23 -49
  2. package/dist/actions/blueprints/blueprint.d.ts +9 -5
  3. package/dist/actions/blueprints/index.d.ts +1 -1
  4. package/dist/actions/blueprints/index.js +1 -1
  5. package/dist/actions/functions/index.d.ts +0 -1
  6. package/dist/actions/functions/index.js +0 -1
  7. package/dist/baseCommands.d.ts +10 -0
  8. package/dist/baseCommands.js +23 -11
  9. package/dist/commands/blueprints/add.d.ts +0 -8
  10. package/dist/commands/blueprints/add.js +12 -93
  11. package/dist/commands/blueprints/config.d.ts +2 -24
  12. package/dist/commands/blueprints/config.js +12 -179
  13. package/dist/commands/blueprints/deploy.js +12 -69
  14. package/dist/commands/blueprints/destroy.d.ts +5 -4
  15. package/dist/commands/blueprints/destroy.js +21 -61
  16. package/dist/commands/blueprints/info.js +11 -19
  17. package/dist/commands/blueprints/init.d.ts +0 -16
  18. package/dist/commands/blueprints/init.js +10 -167
  19. package/dist/commands/blueprints/logs.js +14 -67
  20. package/dist/commands/blueprints/plan.js +8 -13
  21. package/dist/commands/blueprints/stacks.js +10 -19
  22. package/dist/cores/blueprints/add.d.ts +13 -0
  23. package/dist/cores/blueprints/add.js +107 -0
  24. package/dist/cores/blueprints/config.d.ts +13 -0
  25. package/dist/cores/blueprints/config.js +222 -0
  26. package/dist/cores/blueprints/deploy.d.ts +14 -0
  27. package/dist/cores/blueprints/deploy.js +81 -0
  28. package/dist/cores/blueprints/destroy.d.ts +13 -0
  29. package/dist/cores/blueprints/destroy.js +106 -0
  30. package/dist/cores/blueprints/index.d.ts +18 -0
  31. package/dist/cores/blueprints/index.js +9 -0
  32. package/dist/cores/blueprints/info.d.ts +11 -0
  33. package/dist/cores/blueprints/info.js +33 -0
  34. package/dist/cores/blueprints/init.d.ts +15 -0
  35. package/dist/cores/blueprints/init.js +190 -0
  36. package/dist/cores/blueprints/logs.d.ts +11 -0
  37. package/dist/cores/blueprints/logs.js +74 -0
  38. package/dist/cores/blueprints/plan.d.ts +6 -0
  39. package/dist/cores/blueprints/plan.js +11 -0
  40. package/dist/cores/blueprints/stacks.d.ts +10 -0
  41. package/dist/cores/blueprints/stacks.js +30 -0
  42. package/dist/cores/index.d.ts +20 -0
  43. package/dist/cores/index.js +1 -0
  44. package/dist/utils/display/blueprints-formatting.js +12 -11
  45. package/dist/utils/display/colors.d.ts +3 -1
  46. package/dist/utils/display/colors.js +8 -2
  47. package/oclif.manifest.json +29 -64
  48. package/package.json +5 -1
  49. package/dist/actions/functions/invoke.d.ts +0 -6
  50. package/dist/actions/functions/invoke.js +0 -18
  51. package/dist/commands/functions/invoke.d.ts +0 -13
  52. package/dist/commands/functions/invoke.js +0 -42
@@ -1,18 +0,0 @@
1
- import config from '../../config.js';
2
- import buildPayload from '../../utils/build-payload.js';
3
- import getHeaders from '../../utils/get-headers.js';
4
- const { apiUrl } = config;
5
- export async function invoke(id, options, auth) {
6
- const payload = buildPayload(options);
7
- const response = await fetch(`${apiUrl}vX/functions/${id}/invoke`, {
8
- body: JSON.stringify({ data: payload }),
9
- headers: getHeaders(auth),
10
- method: 'POST',
11
- });
12
- const json = await response.json();
13
- return {
14
- ok: response.ok,
15
- error: response.ok ? null : json?.error?.message,
16
- json: response.ok ? json : undefined,
17
- };
18
- }
@@ -1,13 +0,0 @@
1
- import { DeployedBlueprintCommand } from '../../baseCommands.js';
2
- export default class InvokeCommand extends DeployedBlueprintCommand<typeof InvokeCommand> {
3
- static args: {
4
- name: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
5
- };
6
- static description: string;
7
- static examples: string[];
8
- static flags: {
9
- data: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
- file: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
- };
12
- run(): Promise<void>;
13
- }
@@ -1,42 +0,0 @@
1
- import { Args, Flags } from '@oclif/core';
2
- import Spinner from 'yocto-spinner';
3
- import { invoke } from '../../actions/functions/invoke.js';
4
- import { DeployedBlueprintCommand } from '../../baseCommands.js';
5
- import { red } from '../../utils/display/colors.js';
6
- import { findFunctionByName } from '../../utils/find-function.js';
7
- export default class InvokeCommand extends DeployedBlueprintCommand {
8
- static args = {
9
- name: Args.string({ description: 'The name of the Sanity Function', required: true }),
10
- };
11
- static description = 'Invoke a remote Sanity Function';
12
- static examples = [
13
- `<%= config.bin %> <%= command.id %> <name> --data '{ "id": 1 }'`,
14
- `<%= config.bin %> <%= command.id %> <name> --file 'payload.json'`,
15
- ];
16
- static flags = {
17
- data: Flags.string({ char: 'd', description: 'Data to send to the function', required: false }),
18
- file: Flags.string({
19
- char: 'f',
20
- description: 'Read data from file and send to the function',
21
- required: false,
22
- }),
23
- };
24
- async run() {
25
- const args = this.args;
26
- const flags = this.flags;
27
- const spinner = Spinner({ text: `Invoking function "${args.name}"` }).start();
28
- const { externalId } = findFunctionByName(this.deployedStack, args.name);
29
- const result = await invoke(externalId, { data: flags.data, file: flags.file }, this.auth);
30
- if (result.ok) {
31
- spinner.success(`Invocation of ${args.name} succeeded`);
32
- if (result.json?.data?.type === 'Buffer') {
33
- return;
34
- }
35
- this.log(JSON.stringify(result.json, null, 2));
36
- }
37
- else {
38
- spinner.error(`${red('Failed')} to invoke function`);
39
- this.log(`Error: ${result.error || 'Unknown error'}`);
40
- }
41
- }
42
- }