@sanity/runtime-cli 6.1.1 → 6.2.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 +16 -16
- package/dist/baseCommands.js +1 -1
- package/dist/commands/functions/env/add.js +5 -7
- package/dist/commands/functions/env/list.js +4 -4
- package/dist/commands/functions/env/remove.js +5 -7
- package/dist/commands/functions/logs.js +15 -15
- package/dist/cores/blueprints/config.js +5 -5
- package/dist/cores/blueprints/deploy.js +13 -13
- package/dist/cores/blueprints/destroy.js +9 -9
- package/dist/cores/blueprints/info.js +1 -1
- package/dist/cores/blueprints/init.js +1 -1
- package/dist/cores/blueprints/logs.js +10 -12
- package/dist/cores/blueprints/stacks.js +1 -1
- package/dist/server/static/components/app.css +18 -6
- package/dist/server/static/components/codemirror-theme.d.ts +6 -0
- package/dist/server/static/components/codemirror-theme.js +49 -0
- package/dist/server/static/components/function-list.js +1 -1
- package/dist/server/static/components/payload-panel.js +4 -2
- package/dist/server/static/components/response-panel.js +4 -2
- package/dist/server/static/favicon-dark.svg +17 -0
- package/dist/server/static/favicon.svg +17 -0
- package/dist/server/static/index.html +13 -1
- package/dist/server/static/vendor/vendor.bundle.d.ts +193 -0
- package/dist/server/static/vendor/vendor.bundle.js +51 -14
- package/dist/utils/display/blueprints-formatting.js +24 -17
- package/dist/utils/display/colors.d.ts +8 -4
- package/dist/utils/display/colors.js +8 -16
- package/dist/utils/display/index.d.ts +1 -0
- package/dist/utils/display/index.js +1 -0
- package/dist/utils/display/logs-formatting.js +3 -3
- package/dist/utils/display/presenters.d.ts +4 -0
- package/dist/utils/display/presenters.js +15 -0
- package/dist/utils/display/resources-formatting.d.ts +4 -0
- package/dist/utils/display/resources-formatting.js +52 -0
- package/dist/utils/types.d.ts +5 -0
- package/oclif.manifest.json +1 -1
- package/package.json +16 -15
- package/dist/server/static/sanity-logo-sm.svg +0 -1
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/6.
|
|
23
|
+
@sanity/runtime-cli/6.2.1 linux-x64 node-v22.15.0
|
|
24
24
|
$ sanity-run --help [COMMAND]
|
|
25
25
|
USAGE
|
|
26
26
|
$ sanity-run COMMAND
|
|
@@ -77,7 +77,7 @@ EXAMPLES
|
|
|
77
77
|
$ sanity-run blueprints add function --name my-function --fn-type document-publish --lang js
|
|
78
78
|
```
|
|
79
79
|
|
|
80
|
-
_See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v6.
|
|
80
|
+
_See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v6.2.1/src/commands/blueprints/add.ts)_
|
|
81
81
|
|
|
82
82
|
## `sanity-run blueprints config`
|
|
83
83
|
|
|
@@ -105,7 +105,7 @@ EXAMPLES
|
|
|
105
105
|
$ sanity-run blueprints config --edit --project-id <projectId>
|
|
106
106
|
```
|
|
107
107
|
|
|
108
|
-
_See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v6.
|
|
108
|
+
_See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v6.2.1/src/commands/blueprints/config.ts)_
|
|
109
109
|
|
|
110
110
|
## `sanity-run blueprints deploy`
|
|
111
111
|
|
|
@@ -127,7 +127,7 @@ EXAMPLES
|
|
|
127
127
|
$ sanity-run blueprints deploy --no-wait
|
|
128
128
|
```
|
|
129
129
|
|
|
130
|
-
_See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v6.
|
|
130
|
+
_See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v6.2.1/src/commands/blueprints/deploy.ts)_
|
|
131
131
|
|
|
132
132
|
## `sanity-run blueprints destroy`
|
|
133
133
|
|
|
@@ -148,7 +148,7 @@ EXAMPLES
|
|
|
148
148
|
$ sanity-run blueprints destroy
|
|
149
149
|
```
|
|
150
150
|
|
|
151
|
-
_See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v6.
|
|
151
|
+
_See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v6.2.1/src/commands/blueprints/destroy.ts)_
|
|
152
152
|
|
|
153
153
|
## `sanity-run blueprints info`
|
|
154
154
|
|
|
@@ -165,7 +165,7 @@ EXAMPLES
|
|
|
165
165
|
$ sanity-run blueprints info
|
|
166
166
|
```
|
|
167
167
|
|
|
168
|
-
_See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v6.
|
|
168
|
+
_See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v6.2.1/src/commands/blueprints/info.ts)_
|
|
169
169
|
|
|
170
170
|
## `sanity-run blueprints init [DIR]`
|
|
171
171
|
|
|
@@ -197,7 +197,7 @@ EXAMPLES
|
|
|
197
197
|
$ sanity-run blueprints init --blueprint-type <json|js|ts> --project-id <projectId>
|
|
198
198
|
```
|
|
199
199
|
|
|
200
|
-
_See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v6.
|
|
200
|
+
_See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v6.2.1/src/commands/blueprints/init.ts)_
|
|
201
201
|
|
|
202
202
|
## `sanity-run blueprints logs`
|
|
203
203
|
|
|
@@ -219,7 +219,7 @@ EXAMPLES
|
|
|
219
219
|
$ sanity-run blueprints logs --watch
|
|
220
220
|
```
|
|
221
221
|
|
|
222
|
-
_See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v6.
|
|
222
|
+
_See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v6.2.1/src/commands/blueprints/logs.ts)_
|
|
223
223
|
|
|
224
224
|
## `sanity-run blueprints plan`
|
|
225
225
|
|
|
@@ -236,7 +236,7 @@ EXAMPLES
|
|
|
236
236
|
$ sanity-run blueprints plan
|
|
237
237
|
```
|
|
238
238
|
|
|
239
|
-
_See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v6.
|
|
239
|
+
_See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v6.2.1/src/commands/blueprints/plan.ts)_
|
|
240
240
|
|
|
241
241
|
## `sanity-run functions dev`
|
|
242
242
|
|
|
@@ -256,7 +256,7 @@ EXAMPLES
|
|
|
256
256
|
$ sanity-run functions dev --port 8974
|
|
257
257
|
```
|
|
258
258
|
|
|
259
|
-
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v6.
|
|
259
|
+
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v6.2.1/src/commands/functions/dev.ts)_
|
|
260
260
|
|
|
261
261
|
## `sanity-run functions env add NAME KEY VALUE`
|
|
262
262
|
|
|
@@ -278,7 +278,7 @@ EXAMPLES
|
|
|
278
278
|
$ sanity-run functions env add MyFunction API_URL https://api.example.com/
|
|
279
279
|
```
|
|
280
280
|
|
|
281
|
-
_See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v6.
|
|
281
|
+
_See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v6.2.1/src/commands/functions/env/add.ts)_
|
|
282
282
|
|
|
283
283
|
## `sanity-run functions env list NAME`
|
|
284
284
|
|
|
@@ -298,7 +298,7 @@ EXAMPLES
|
|
|
298
298
|
$ sanity-run functions env list MyFunction
|
|
299
299
|
```
|
|
300
300
|
|
|
301
|
-
_See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v6.
|
|
301
|
+
_See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v6.2.1/src/commands/functions/env/list.ts)_
|
|
302
302
|
|
|
303
303
|
## `sanity-run functions env remove NAME KEY`
|
|
304
304
|
|
|
@@ -319,7 +319,7 @@ EXAMPLES
|
|
|
319
319
|
$ sanity-run functions env remove MyFunction API_URL
|
|
320
320
|
```
|
|
321
321
|
|
|
322
|
-
_See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v6.
|
|
322
|
+
_See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v6.2.1/src/commands/functions/env/remove.ts)_
|
|
323
323
|
|
|
324
324
|
## `sanity-run functions logs NAME`
|
|
325
325
|
|
|
@@ -352,7 +352,7 @@ EXAMPLES
|
|
|
352
352
|
$ sanity-run functions logs <name> --delete
|
|
353
353
|
```
|
|
354
354
|
|
|
355
|
-
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v6.
|
|
355
|
+
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v6.2.1/src/commands/functions/logs.ts)_
|
|
356
356
|
|
|
357
357
|
## `sanity-run functions test NAME`
|
|
358
358
|
|
|
@@ -385,7 +385,7 @@ EXAMPLES
|
|
|
385
385
|
$ sanity-run functions test <name> --data '{ "id": 1 }' --timeout 60
|
|
386
386
|
```
|
|
387
387
|
|
|
388
|
-
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v6.
|
|
388
|
+
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v6.2.1/src/commands/functions/test.ts)_
|
|
389
389
|
|
|
390
390
|
## `sanity-run help [COMMAND]`
|
|
391
391
|
|
|
@@ -405,5 +405,5 @@ DESCRIPTION
|
|
|
405
405
|
Display help for sanity-run.
|
|
406
406
|
```
|
|
407
407
|
|
|
408
|
-
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.
|
|
408
|
+
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.28/src/commands/help.ts)_
|
|
409
409
|
<!-- commandsstop -->
|
package/dist/baseCommands.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { Command } from '@oclif/core';
|
|
3
3
|
import { readLocalBlueprint } from './actions/blueprints/blueprint.js';
|
|
4
4
|
import { getStack } from './actions/blueprints/stacks.js';
|
|
5
|
-
import { niceId } from './utils/display/colors.js';
|
|
6
5
|
import { presentBlueprintParserErrors } from './utils/display/errors.js';
|
|
6
|
+
import { niceId } from './utils/display/presenters.js';
|
|
7
7
|
import { validTokenOrErrorMessage } from './utils/validated-token.js';
|
|
8
8
|
/**
|
|
9
9
|
* @description Guarantees flags, args, sanityToken, and blueprint.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Args } from '@oclif/core';
|
|
2
|
-
import
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import ora from 'ora';
|
|
3
4
|
import { update } from '../../../actions/functions/env/update.js';
|
|
4
5
|
import { DeployedBlueprintCommand } from '../../../baseCommands.js';
|
|
5
|
-
import { red } from '../../../utils/display/colors.js';
|
|
6
6
|
import { findFunctionByName } from '../../../utils/find-function.js';
|
|
7
7
|
export default class EnvAddCommand extends DeployedBlueprintCommand {
|
|
8
8
|
static args = {
|
|
@@ -16,16 +16,14 @@ export default class EnvAddCommand extends DeployedBlueprintCommand {
|
|
|
16
16
|
];
|
|
17
17
|
async run() {
|
|
18
18
|
const args = this.args;
|
|
19
|
-
const spinner =
|
|
20
|
-
text: `Updating "${args.key}" environment variable in "${args.name}"`,
|
|
21
|
-
}).start();
|
|
19
|
+
const spinner = ora(`Updating "${args.key}" environment variable in "${args.name}"`).start();
|
|
22
20
|
const { externalId } = findFunctionByName(this.deployedStack, args.name);
|
|
23
21
|
const result = await update(externalId, args.key, args.value, this.auth);
|
|
24
22
|
if (result.ok) {
|
|
25
|
-
spinner.
|
|
23
|
+
spinner.succeed(`Update of ${args.key} succeeded`);
|
|
26
24
|
}
|
|
27
25
|
else {
|
|
28
|
-
spinner.
|
|
26
|
+
spinner.fail(`${chalk.red('Failed')} to update ${args.key}`);
|
|
29
27
|
this.log(`Error: ${result.error || 'Unknown error'}`);
|
|
30
28
|
}
|
|
31
29
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Args } from '@oclif/core';
|
|
2
|
-
import
|
|
2
|
+
import ora from 'ora';
|
|
3
3
|
import { list } from '../../../actions/functions/env/list.js';
|
|
4
4
|
import { DeployedBlueprintCommand } from '../../../baseCommands.js';
|
|
5
5
|
import { findFunctionByName } from '../../../utils/find-function.js';
|
|
@@ -11,14 +11,14 @@ export default class EnvListCommand extends DeployedBlueprintCommand {
|
|
|
11
11
|
static examples = ['<%= config.bin %> <%= command.id %> MyFunction'];
|
|
12
12
|
async run() {
|
|
13
13
|
const args = this.args;
|
|
14
|
-
const spinner =
|
|
14
|
+
const spinner = ora(`Listing environment variables for "${args.name}"`).start();
|
|
15
15
|
const { externalId } = findFunctionByName(this.deployedStack, args.name);
|
|
16
16
|
const result = await list(externalId, this.auth);
|
|
17
17
|
if (!result.ok) {
|
|
18
|
-
spinner.stop()
|
|
18
|
+
spinner.stop();
|
|
19
19
|
this.error(`Error: ${result.error || 'Unknown error'}`);
|
|
20
20
|
}
|
|
21
|
-
spinner.
|
|
21
|
+
spinner.succeed(`Environment variables for "${args.name}"`);
|
|
22
22
|
for (const key of result.envvars) {
|
|
23
23
|
this.log(key);
|
|
24
24
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Args } from '@oclif/core';
|
|
2
|
-
import
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import ora from 'ora';
|
|
3
4
|
import { remove } from '../../../actions/functions/env/remove.js';
|
|
4
5
|
import { DeployedBlueprintCommand } from '../../../baseCommands.js';
|
|
5
|
-
import { red } from '../../../utils/display/colors.js';
|
|
6
6
|
import { findFunctionByName } from '../../../utils/find-function.js';
|
|
7
7
|
export default class EnvRemoveCommand extends DeployedBlueprintCommand {
|
|
8
8
|
static args = {
|
|
@@ -13,16 +13,14 @@ export default class EnvRemoveCommand extends DeployedBlueprintCommand {
|
|
|
13
13
|
static examples = ['<%= config.bin %> <%= command.id %> MyFunction API_URL'];
|
|
14
14
|
async run() {
|
|
15
15
|
const args = this.args;
|
|
16
|
-
const spinner =
|
|
17
|
-
text: `Removing "${args.key}" environment variable in "${args.name}"`,
|
|
18
|
-
}).start();
|
|
16
|
+
const spinner = ora(`Removing "${args.key}" environment variable in "${args.name}"`).start();
|
|
19
17
|
const { externalId } = findFunctionByName(this.deployedStack, args.name);
|
|
20
18
|
const result = await remove(externalId, args.key, this.auth);
|
|
21
19
|
if (result.ok) {
|
|
22
|
-
spinner.
|
|
20
|
+
spinner.succeed(`Removal of ${args.key} succeeded`);
|
|
23
21
|
}
|
|
24
22
|
else {
|
|
25
|
-
spinner.
|
|
23
|
+
spinner.fail(`${chalk.red('Failed')} to remove ${args.key}`);
|
|
26
24
|
this.log(`Error: ${result.error || 'Unknown error'}`);
|
|
27
25
|
}
|
|
28
26
|
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import chalk from 'chalk';
|
|
2
3
|
import inquirer from 'inquirer';
|
|
3
|
-
import
|
|
4
|
+
import ora from 'ora';
|
|
4
5
|
import { deleteLogs as deleteLogsAction, logs as getLogsAction, } from '../../actions/functions/logs.js';
|
|
5
6
|
import { DeployedBlueprintCommand } from '../../baseCommands.js';
|
|
6
7
|
import { formatTitle } from '../../utils/display/blueprints-formatting.js';
|
|
7
|
-
import { blue, bold, green, red, yellow } from '../../utils/display/colors.js';
|
|
8
8
|
import { findFunctionByName } from '../../utils/find-function.js';
|
|
9
9
|
function logLevel(level) {
|
|
10
10
|
if (level === 'ERROR') {
|
|
11
|
-
return red(level);
|
|
11
|
+
return chalk.red(level);
|
|
12
12
|
}
|
|
13
13
|
if (level === 'WARN') {
|
|
14
|
-
return yellow(level);
|
|
14
|
+
return chalk.yellow(level);
|
|
15
15
|
}
|
|
16
|
-
return green(level);
|
|
16
|
+
return chalk.green(level);
|
|
17
17
|
}
|
|
18
18
|
export default class LogsCommand extends DeployedBlueprintCommand {
|
|
19
19
|
static args = {
|
|
@@ -76,28 +76,28 @@ export default class LogsCommand extends DeployedBlueprintCommand {
|
|
|
76
76
|
const { certain } = await inquirer.prompt({
|
|
77
77
|
type: 'confirm',
|
|
78
78
|
name: 'certain',
|
|
79
|
-
message: `Are you sure you want to delete ${bold('all')} logs for function ${yellow(name)}?`,
|
|
79
|
+
message: `Are you sure you want to delete ${chalk.bold('all')} logs for function ${chalk.yellow(name)}?`,
|
|
80
80
|
default: false,
|
|
81
81
|
});
|
|
82
82
|
if (!certain)
|
|
83
83
|
return;
|
|
84
84
|
}
|
|
85
|
-
const spinner =
|
|
85
|
+
const spinner = ora(`Deleting logs for function ${chalk.yellow(name)}`).start();
|
|
86
86
|
const { ok, error } = await deleteLogsAction(this.externalId, this.auth);
|
|
87
87
|
if (!ok) {
|
|
88
|
-
spinner.
|
|
88
|
+
spinner.fail(`${chalk.red('Failed')} to retrieve logs`);
|
|
89
89
|
this.log(`Error: ${error || 'Unknown error'}`);
|
|
90
90
|
return;
|
|
91
91
|
}
|
|
92
|
-
spinner.
|
|
92
|
+
spinner.succeed('Logs deleted');
|
|
93
93
|
}
|
|
94
94
|
async runGetLogs(name, options) {
|
|
95
95
|
if (!this.externalId)
|
|
96
96
|
this.error('Unable to retrieve logs. Unable to determine function ID.');
|
|
97
|
-
const spinner =
|
|
97
|
+
const spinner = ora(`Finding logs for function "${name}"`).start();
|
|
98
98
|
const { ok, error, logs, total } = await getLogsAction(this.externalId, { limit: options.limit }, this.auth);
|
|
99
99
|
if (!ok) {
|
|
100
|
-
spinner.
|
|
100
|
+
spinner.fail(`${chalk.red('Failed')} to retrieve logs`);
|
|
101
101
|
this.log(`Error: ${error || 'Unknown error'}`);
|
|
102
102
|
return;
|
|
103
103
|
}
|
|
@@ -106,11 +106,11 @@ export default class LogsCommand extends DeployedBlueprintCommand {
|
|
|
106
106
|
spinner.info(`No logs found for function ${name}`);
|
|
107
107
|
return;
|
|
108
108
|
}
|
|
109
|
-
spinner.
|
|
109
|
+
spinner.succeed(`${formatTitle('Function', name)} Logs`);
|
|
110
110
|
if (!options.json) {
|
|
111
|
-
this.log(`Found ${bold(total)} log entries for function ${yellow(name)}`);
|
|
111
|
+
this.log(`Found ${chalk.bold(total)} log entries for function ${chalk.yellow(name)}`);
|
|
112
112
|
if (logs.length < total) {
|
|
113
|
-
this.log(`Here are the last ${bold(filteredLogs.length.toString())} entries`);
|
|
113
|
+
this.log(`Here are the last ${chalk.bold(filteredLogs.length.toString())} entries`);
|
|
114
114
|
}
|
|
115
115
|
this.log('\n');
|
|
116
116
|
for (const log of filteredLogs) {
|
|
@@ -119,7 +119,7 @@ export default class LogsCommand extends DeployedBlueprintCommand {
|
|
|
119
119
|
const [dateString, timeString] = options.utc
|
|
120
120
|
? date.toISOString().slice(0, 19).split('T')
|
|
121
121
|
: [date.toLocaleDateString(), date.toLocaleTimeString()];
|
|
122
|
-
this.log([bold(dateString), bold
|
|
122
|
+
this.log([chalk.bold(dateString), chalk.bold.blue(timeString), logLevel(level), message].join(' '));
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
else {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import highlight from 'color-json';
|
|
3
3
|
import inquirer from 'inquirer';
|
|
4
|
-
import
|
|
4
|
+
import ora from 'ora';
|
|
5
5
|
import { BLUEPRINT_CONFIG_FILE, BLUEPRINT_DIR, writeConfigFile, } from '../../actions/blueprints/blueprint.js';
|
|
6
6
|
import { getProject, listProjects } from '../../actions/blueprints/projects.js';
|
|
7
7
|
import { createStack, getStack, listStacks } from '../../actions/blueprints/stacks.js';
|
|
8
|
-
import { niceId, warn } from '../../utils/display/
|
|
8
|
+
import { niceId, warn } from '../../utils/display/presenters.js';
|
|
9
9
|
export async function blueprintConfigCore(options) {
|
|
10
10
|
const { bin = 'sanity', log, token, flags } = options;
|
|
11
11
|
const { edit: editConfig = false, 'test-config': testConfig = false, 'project-id': flagProjectId, 'stack-id': flagStackId, } = flags;
|
|
@@ -183,16 +183,16 @@ async function promptForStackId({ token, projectId, knownStackId, }) {
|
|
|
183
183
|
return undefined;
|
|
184
184
|
}
|
|
185
185
|
async function testConfigAndReport({ token, stackId, projectId, }) {
|
|
186
|
-
const spinner =
|
|
186
|
+
const spinner = ora('Testing the configuration...').start();
|
|
187
187
|
const { ok, error } = await getStack({
|
|
188
188
|
stackId,
|
|
189
189
|
auth: { token, projectId },
|
|
190
190
|
});
|
|
191
191
|
if (!ok) {
|
|
192
|
-
spinner.
|
|
192
|
+
spinner.fail('Configuration test failed.');
|
|
193
193
|
}
|
|
194
194
|
else {
|
|
195
|
-
spinner.
|
|
195
|
+
spinner.succeed('Configuration is valid.');
|
|
196
196
|
}
|
|
197
197
|
return { ok, error };
|
|
198
198
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { setTimeout } from 'node:timers/promises';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
|
-
import
|
|
3
|
+
import ora from 'ora';
|
|
4
4
|
import { stashAsset } from '../../actions/blueprints/assets.js';
|
|
5
5
|
import { getStack, updateStack } from '../../actions/blueprints/stacks.js';
|
|
6
|
-
import {
|
|
6
|
+
import { niceId } from '../../utils/display/presenters.js';
|
|
7
7
|
import { isLocalFunctionResource } from '../../utils/types.js';
|
|
8
8
|
export async function blueprintDeployCore(options) {
|
|
9
9
|
const { bin = 'sanity', log, auth, stackId, projectId, deployedStack, blueprint, flags } = options;
|
|
@@ -15,16 +15,16 @@ export async function blueprintDeployCore(options) {
|
|
|
15
15
|
// First stash all function assets
|
|
16
16
|
if (functionResources?.length) {
|
|
17
17
|
for (const resource of functionResources) {
|
|
18
|
-
const fnSpinner =
|
|
18
|
+
const fnSpinner = ora(`Processing ${resource.name}...`).start();
|
|
19
19
|
const result = await stashAsset({ resource, auth });
|
|
20
20
|
if (result.success && result.assetId) {
|
|
21
21
|
const src = resource.src;
|
|
22
22
|
resource.src = result.assetId; // TODO: properly reference asset - for now, the API expects the assetId
|
|
23
|
-
fnSpinner.
|
|
23
|
+
fnSpinner.succeed(`${resource.name} ${niceId(result.assetId)}`);
|
|
24
24
|
log(` Source: ${src}`);
|
|
25
25
|
}
|
|
26
26
|
else {
|
|
27
|
-
fnSpinner.
|
|
27
|
+
fnSpinner.fail(`Failed to process ${resource.name}`);
|
|
28
28
|
log(` Error: ${result.error}`);
|
|
29
29
|
return { success: false, error: result.error || 'Failed to process function resource' };
|
|
30
30
|
}
|
|
@@ -35,30 +35,30 @@ export async function blueprintDeployCore(options) {
|
|
|
35
35
|
name: deployedStack.name,
|
|
36
36
|
document: { resources: validResources },
|
|
37
37
|
};
|
|
38
|
-
const spinner =
|
|
38
|
+
const spinner = ora('Deploying...').start();
|
|
39
39
|
const { ok: deployOk, stack, error: deployError, } = await updateStack({ stackId, stackPayload, auth });
|
|
40
40
|
if (deployOk) {
|
|
41
|
-
spinner.
|
|
41
|
+
spinner.succeed(`Deployment "${chalk.bold(stack.name)}" ${niceId(stack.id)} started!`);
|
|
42
42
|
if (!noWait) {
|
|
43
|
-
const waitSpinner =
|
|
43
|
+
const waitSpinner = ora('Waiting for deployment to complete...').start();
|
|
44
44
|
while (true) {
|
|
45
45
|
// TODO: watch logs and print those while polling
|
|
46
46
|
const { ok, stack: currentStack } = await getStack({ stackId: stack.id, auth });
|
|
47
47
|
if (!ok) {
|
|
48
|
-
waitSpinner.
|
|
48
|
+
waitSpinner.fail('Failed to check deployment status');
|
|
49
49
|
return { success: false, error: 'Failed to check deployment status' };
|
|
50
50
|
}
|
|
51
51
|
const operation = currentStack.recentOperation;
|
|
52
52
|
if (!operation) {
|
|
53
|
-
waitSpinner.
|
|
53
|
+
waitSpinner.fail('No operation found');
|
|
54
54
|
return { success: false, error: 'No operation found' };
|
|
55
55
|
}
|
|
56
56
|
if (operation.status === 'COMPLETED') {
|
|
57
|
-
waitSpinner.
|
|
57
|
+
waitSpinner.succeed('Deployment completed successfully');
|
|
58
58
|
break;
|
|
59
59
|
}
|
|
60
60
|
if (operation.status === 'FAILED') {
|
|
61
|
-
waitSpinner.
|
|
61
|
+
waitSpinner.fail('Deployment failed');
|
|
62
62
|
return { success: false, error: 'Deployment failed' };
|
|
63
63
|
}
|
|
64
64
|
await setTimeout(1000);
|
|
@@ -69,7 +69,7 @@ export async function blueprintDeployCore(options) {
|
|
|
69
69
|
}
|
|
70
70
|
return { success: true };
|
|
71
71
|
}
|
|
72
|
-
spinner.
|
|
72
|
+
spinner.fail(`${chalk.red('Failed')} to update deployment`);
|
|
73
73
|
log(`Error: ${deployError || JSON.stringify(stack, null, 2) || 'Unknown error'}`);
|
|
74
74
|
return { success: false, error: deployError || 'Failed to update deployment' };
|
|
75
75
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { setTimeout } from 'node:timers/promises';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
import inquirer from 'inquirer';
|
|
4
|
-
import
|
|
4
|
+
import ora from 'ora';
|
|
5
5
|
import { destroyStack, getStack } from '../../actions/blueprints/stacks.js';
|
|
6
|
-
import { niceId } from '../../utils/display/
|
|
6
|
+
import { niceId } from '../../utils/display/presenters.js';
|
|
7
7
|
export async function blueprintDestroyCore(options) {
|
|
8
8
|
const { bin = 'sanity', log, token, blueprint, flags } = options;
|
|
9
9
|
const { force = false, 'project-id': flagProjectId, 'stack-id': flagStackId, 'no-wait': noWait = false, } = flags;
|
|
@@ -38,7 +38,7 @@ export async function blueprintDestroyCore(options) {
|
|
|
38
38
|
}
|
|
39
39
|
if (!stack)
|
|
40
40
|
return { success: false, error: 'Deployment not found' };
|
|
41
|
-
const destroySpinner =
|
|
41
|
+
const destroySpinner = ora({
|
|
42
42
|
text: `Destroying ${chalk.bold(stack.name)} ${niceId(stack.id)}...`,
|
|
43
43
|
color: 'red',
|
|
44
44
|
});
|
|
@@ -70,27 +70,27 @@ export async function blueprintDestroyCore(options) {
|
|
|
70
70
|
}
|
|
71
71
|
const { ok, error } = await destroyStack({ stackId: stack.id, auth });
|
|
72
72
|
if (!ok) {
|
|
73
|
-
destroySpinner.
|
|
73
|
+
destroySpinner.fail('Failed to destroy deployment');
|
|
74
74
|
return { success: false, error: error || 'Failed to destroy deployment' };
|
|
75
75
|
}
|
|
76
76
|
if (noWait) {
|
|
77
|
-
destroySpinner.
|
|
77
|
+
destroySpinner.succeed(`Deployment "${stack.name}" ${niceId(stack.id)} destroy started!`);
|
|
78
78
|
log(`Use \`${bin} blueprints info\` to check status`);
|
|
79
79
|
return { success: true };
|
|
80
80
|
}
|
|
81
|
-
destroySpinner.stop()
|
|
82
|
-
const waitSpinner =
|
|
81
|
+
destroySpinner.stop();
|
|
82
|
+
const waitSpinner = ora('Waiting for destruction to complete...').start();
|
|
83
83
|
while (true) {
|
|
84
84
|
const { ok: pollOk, stack: currentStack } = await getStack({ stackId: stack.id, auth });
|
|
85
85
|
const operation = currentStack?.recentOperation;
|
|
86
86
|
if (!pollOk || !operation || operation?.status === 'COMPLETED') {
|
|
87
87
|
// Operation is also marked destroyed when stack is deleted
|
|
88
88
|
// It's possible that the operation is "gone" or available and "COMPLETED"
|
|
89
|
-
waitSpinner.
|
|
89
|
+
waitSpinner.succeed(`Deployment "${stack.name}" ${niceId(stack.id)} destroyed`);
|
|
90
90
|
break;
|
|
91
91
|
}
|
|
92
92
|
if (operation.status === 'FAILED') {
|
|
93
|
-
waitSpinner.
|
|
93
|
+
waitSpinner.fail('Destruction failed');
|
|
94
94
|
log(`Run \`${bin} blueprints logs\` for more details`);
|
|
95
95
|
return { success: false, error: 'Destruction failed' };
|
|
96
96
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getStack } from '../../actions/blueprints/stacks.js';
|
|
2
2
|
import { formatResourceTree, formatStackInfo } from '../../utils/display/blueprints-formatting.js';
|
|
3
|
-
import { niceId } from '../../utils/display/
|
|
3
|
+
import { niceId } from '../../utils/display/presenters.js';
|
|
4
4
|
export async function blueprintInfoCore(options) {
|
|
5
5
|
const { log, auth, stackId, flags, deployedStack } = options;
|
|
6
6
|
try {
|
|
@@ -5,7 +5,7 @@ import inquirer from 'inquirer';
|
|
|
5
5
|
import { BLUEPRINT_CONFIG_FILE, BLUEPRINT_DIR, findBlueprintFile, writeBlueprintToDisk, writeConfigFile, } from '../../actions/blueprints/blueprint.js';
|
|
6
6
|
import { getProject, listProjects } from '../../actions/blueprints/projects.js';
|
|
7
7
|
import { createStack, getStack, listStacks } from '../../actions/blueprints/stacks.js';
|
|
8
|
-
import { niceId } from '../../utils/display/
|
|
8
|
+
import { niceId } from '../../utils/display/presenters.js';
|
|
9
9
|
const LAUNCH_LIMIT_STACK_PER_PROJECT = true;
|
|
10
10
|
export async function blueprintInitCore(options) {
|
|
11
11
|
const { log, token, args, flags } = options;
|
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
-
import
|
|
2
|
+
import ora from 'ora';
|
|
3
3
|
import { findNewestLogTimestamp, getLogs, getRecentLogs, isNewerLog, streamLogs, } from '../../actions/blueprints/logs.js';
|
|
4
4
|
import { formatTitle } from '../../utils/display/blueprints-formatting.js';
|
|
5
|
-
import { bold, niceId } from '../../utils/display/colors.js';
|
|
6
5
|
import { formatLogEntry, formatLogsByDay, organizeLogsByDay, } from '../../utils/display/logs-formatting.js';
|
|
6
|
+
import { niceId } from '../../utils/display/presenters.js';
|
|
7
7
|
export async function blueprintLogsCore(options) {
|
|
8
8
|
const { log, auth, stackId, deployedStack, flags } = options;
|
|
9
9
|
const { watch = false } = flags;
|
|
10
|
-
const spinner =
|
|
11
|
-
text: `Fetching recent logs for deployment ${niceId(stackId)}`,
|
|
12
|
-
}).start();
|
|
10
|
+
const spinner = ora(`Fetching recent logs for deployment ${niceId(stackId)}`).start();
|
|
13
11
|
try {
|
|
14
12
|
if (watch) {
|
|
15
13
|
const { ok, logs, error } = await getLogs(stackId, auth);
|
|
16
14
|
if (!ok) {
|
|
17
|
-
spinner.
|
|
15
|
+
spinner.fail(`${chalk.red('Failed')} to retrieve logs`);
|
|
18
16
|
log(`Error: ${error || 'Unknown error'}`);
|
|
19
17
|
return { success: false, error: error || 'Failed to retrieve logs' };
|
|
20
18
|
}
|
|
21
|
-
spinner.stop()
|
|
19
|
+
spinner.stop();
|
|
22
20
|
log(`${formatTitle('Blueprint', deployedStack.name)} ${niceId(stackId)} logs`);
|
|
23
21
|
if (logs.length > 0) {
|
|
24
22
|
log('\nMost recent logs:');
|
|
@@ -31,7 +29,7 @@ export async function blueprintLogsCore(options) {
|
|
|
31
29
|
log(`No recent logs found for deployment ${niceId(stackId)}`);
|
|
32
30
|
}
|
|
33
31
|
const onOpen = () => {
|
|
34
|
-
log(`Watching for new logs... ${bold('ctrl+c')} to stop`);
|
|
32
|
+
log(`Watching for new logs... ${chalk.bold('ctrl+c')} to stop`);
|
|
35
33
|
};
|
|
36
34
|
let newestTimestamp = findNewestLogTimestamp(logs);
|
|
37
35
|
const renderLog = (logEntry) => {
|
|
@@ -50,7 +48,7 @@ export async function blueprintLogsCore(options) {
|
|
|
50
48
|
// Regular non-streaming logs
|
|
51
49
|
const { ok, logs, error } = await getLogs(stackId, auth);
|
|
52
50
|
if (!ok) {
|
|
53
|
-
spinner.
|
|
51
|
+
spinner.fail(`${chalk.red('Failed')} to retrieve logs`);
|
|
54
52
|
log(`Error: ${error || 'Unknown error'}`);
|
|
55
53
|
return { success: false, error: error || 'Failed to retrieve logs' };
|
|
56
54
|
}
|
|
@@ -58,15 +56,15 @@ export async function blueprintLogsCore(options) {
|
|
|
58
56
|
spinner.info(`No logs found for deployment ${stackId}`);
|
|
59
57
|
return { success: true };
|
|
60
58
|
}
|
|
61
|
-
spinner.
|
|
62
|
-
log(`Found ${bold(logs.length.toString())} log entries for deployment ${niceId(stackId)}\n`);
|
|
59
|
+
spinner.succeed(`${formatTitle('Blueprint', deployedStack.name)} Logs`);
|
|
60
|
+
log(`Found ${chalk.bold(logs.length.toString())} log entries for deployment ${niceId(stackId)}\n`);
|
|
63
61
|
// Organize and format logs by day
|
|
64
62
|
const logsByDay = organizeLogsByDay(logs);
|
|
65
63
|
log(formatLogsByDay(logsByDay));
|
|
66
64
|
return { success: true };
|
|
67
65
|
}
|
|
68
66
|
catch (err) {
|
|
69
|
-
spinner.
|
|
67
|
+
spinner.fail('Failed to retrieve logs');
|
|
70
68
|
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
71
69
|
log(`Error: ${errorMessage}`);
|
|
72
70
|
return { success: false, error: errorMessage };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import { listStacks } from '../../actions/blueprints/stacks.js';
|
|
3
3
|
import { formatStacksListing } from '../../utils/display/blueprints-formatting.js';
|
|
4
|
-
import { niceId } from '../../utils/display/
|
|
4
|
+
import { niceId } from '../../utils/display/presenters.js';
|
|
5
5
|
export async function blueprintStacksCore(options) {
|
|
6
6
|
const { log, token, blueprint, flags } = options;
|
|
7
7
|
const { projectId: blueprintProjectId, stackId: blueprintStackId } = blueprint;
|
|
@@ -989,14 +989,20 @@ footer {
|
|
|
989
989
|
cursor: pointer;
|
|
990
990
|
}
|
|
991
991
|
|
|
992
|
-
.
|
|
993
|
-
|
|
994
|
-
|
|
992
|
+
.dropdown-select {
|
|
993
|
+
background: transparent;
|
|
994
|
+
color: light-dark(var(--gray-950), var(--gray-300));
|
|
995
995
|
}
|
|
996
996
|
|
|
997
997
|
ol[type='content'] li:hover:not(.selected:not(.selected)) {
|
|
998
998
|
color: light-dark(var(--gray-950), var(--gray-200));
|
|
999
|
-
background-color: light-dark(var(--gray-50), var(--gray-900))
|
|
999
|
+
background-color: light-dark(var(--gray-50), var(--gray-900));
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
.selected:hover,
|
|
1003
|
+
.selected {
|
|
1004
|
+
color: light-dark(var(--gray-950), var(--gray-200));
|
|
1005
|
+
background-color: light-dark(var(--gray-100), var(--gray-800)) !important;
|
|
1000
1006
|
}
|
|
1001
1007
|
|
|
1002
1008
|
m-box {
|
|
@@ -1043,9 +1049,11 @@ m-tabs {
|
|
|
1043
1049
|
border: 0 !important;
|
|
1044
1050
|
}
|
|
1045
1051
|
|
|
1046
|
-
#payload
|
|
1052
|
+
#payload {
|
|
1053
|
+
height: 100%;
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1047
1056
|
#response {
|
|
1048
|
-
overflow-y: scroll;
|
|
1049
1057
|
height: 100%;
|
|
1050
1058
|
}
|
|
1051
1059
|
|
|
@@ -1073,6 +1081,10 @@ m-tabs {
|
|
|
1073
1081
|
background-color: transparent;
|
|
1074
1082
|
}
|
|
1075
1083
|
|
|
1084
|
+
.cm-cursor.cm-cursor {
|
|
1085
|
+
border-left-color: light-dark(var(--blue-600), var(--blue-400));
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1076
1088
|
.cm-gutters.cm-gutters {
|
|
1077
1089
|
background-color: transparent;
|
|
1078
1090
|
color: light-dark(var(--gray-800), var(--gray-500));
|