@sanity/runtime-cli 6.2.0 → 6.2.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 +16 -16
- package/dist/actions/blueprints/blueprint.js +9 -9
- 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/vendor/vendor.bundle.js +50 -13
- package/dist/utils/child-process-wrapper.d.ts +1 -1
- package/dist/utils/child-process-wrapper.js +2 -2
- 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/invoke-local.js +2 -1
- package/dist/utils/types.d.ts +5 -0
- package/oclif.manifest.json +1 -1
- package/package.json +15 -15
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.2.
|
|
23
|
+
@sanity/runtime-cli/6.2.2 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.2.
|
|
80
|
+
_See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v6.2.2/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.2.
|
|
108
|
+
_See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v6.2.2/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.2.
|
|
130
|
+
_See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v6.2.2/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.2.
|
|
151
|
+
_See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v6.2.2/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.2.
|
|
168
|
+
_See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v6.2.2/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.2.
|
|
200
|
+
_See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v6.2.2/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.2.
|
|
222
|
+
_See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v6.2.2/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.2.
|
|
239
|
+
_See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v6.2.2/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.2.
|
|
259
|
+
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v6.2.2/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.2.
|
|
281
|
+
_See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v6.2.2/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.2.
|
|
301
|
+
_See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v6.2.2/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.2.
|
|
322
|
+
_See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v6.2.2/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.2.
|
|
355
|
+
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v6.2.2/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.2.
|
|
388
|
+
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v6.2.2/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 -->
|
|
@@ -59,31 +59,31 @@ export async function readLocalBlueprint(blueprintPath) {
|
|
|
59
59
|
const blueprintFile = findBlueprintFile(blueprintPath);
|
|
60
60
|
if (!blueprintFile)
|
|
61
61
|
throw Error('Could not find Blueprint file! Use the init command.');
|
|
62
|
-
const { blueprintFilePath:
|
|
62
|
+
const { blueprintFilePath: foundFilePath, fileName, extension } = blueprintFile;
|
|
63
63
|
let rawBlueprint;
|
|
64
64
|
let blueprintModule;
|
|
65
65
|
try {
|
|
66
66
|
switch (extension) {
|
|
67
67
|
case '.json': {
|
|
68
|
-
const blueprintString = readFileSync(
|
|
68
|
+
const blueprintString = readFileSync(foundFilePath, 'utf8').toString();
|
|
69
69
|
rawBlueprint = JSON.parse(blueprintString);
|
|
70
70
|
break;
|
|
71
71
|
}
|
|
72
72
|
case '.js':
|
|
73
73
|
case '.mjs': {
|
|
74
|
-
const module = await import(
|
|
74
|
+
const module = await import(foundFilePath);
|
|
75
75
|
blueprintModule = module.default;
|
|
76
76
|
break;
|
|
77
77
|
}
|
|
78
78
|
case '.cjs': {
|
|
79
79
|
const require = createRequire(import.meta.url);
|
|
80
|
-
blueprintModule = require(
|
|
80
|
+
blueprintModule = require(foundFilePath);
|
|
81
81
|
break;
|
|
82
82
|
}
|
|
83
83
|
case '.ts': {
|
|
84
84
|
try {
|
|
85
85
|
const { tsImport } = await import('tsx/esm/api');
|
|
86
|
-
const module = await tsImport(
|
|
86
|
+
const module = await tsImport(`file://${foundFilePath}`, dirname(foundFilePath));
|
|
87
87
|
blueprintModule = module.default;
|
|
88
88
|
}
|
|
89
89
|
catch (err) {
|
|
@@ -98,7 +98,7 @@ export async function readLocalBlueprint(blueprintPath) {
|
|
|
98
98
|
throw Error(`Unsupported blueprint file extension: ${extension}`);
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
-
catch {
|
|
101
|
+
catch (err) {
|
|
102
102
|
throw Error(`Error parsing Blueprint file: ${fileName}`);
|
|
103
103
|
}
|
|
104
104
|
if (blueprintModule) {
|
|
@@ -107,7 +107,7 @@ export async function readLocalBlueprint(blueprintPath) {
|
|
|
107
107
|
try {
|
|
108
108
|
rawBlueprint = blueprintModule();
|
|
109
109
|
}
|
|
110
|
-
catch
|
|
110
|
+
catch {
|
|
111
111
|
throw Error(`Error executing Blueprint file: ${fileName}`);
|
|
112
112
|
}
|
|
113
113
|
}
|
|
@@ -121,7 +121,7 @@ export async function readLocalBlueprint(blueprintPath) {
|
|
|
121
121
|
const fnErrors = functionResources.map((r) => validateFunctionResource(r));
|
|
122
122
|
errors.push(...fnErrors.flat());
|
|
123
123
|
}
|
|
124
|
-
const configIds = readConfigFile(
|
|
124
|
+
const configIds = readConfigFile(foundFilePath);
|
|
125
125
|
const configPath = configIds?.configPath;
|
|
126
126
|
let projectId;
|
|
127
127
|
if (configIds?.projectId)
|
|
@@ -133,7 +133,7 @@ export async function readLocalBlueprint(blueprintPath) {
|
|
|
133
133
|
if (!stackId && projectId)
|
|
134
134
|
stackId = `ST-${projectId}`;
|
|
135
135
|
return {
|
|
136
|
-
fileInfo: { blueprintFilePath:
|
|
136
|
+
fileInfo: { blueprintFilePath: foundFilePath, fileName, extension },
|
|
137
137
|
rawBlueprint: rawBlueprint,
|
|
138
138
|
errors,
|
|
139
139
|
projectId,
|
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;
|
|
@@ -12311,17 +12311,26 @@ function isSuspiciousChromeCaretResult(node, offset, x) {
|
|
|
12311
12311
|
: textRange(node, 0, Math.max(node.nodeValue.length, 1)).getBoundingClientRect();
|
|
12312
12312
|
return x - rect.left > 5;
|
|
12313
12313
|
}
|
|
12314
|
-
function blockAt(view, pos) {
|
|
12314
|
+
function blockAt(view, pos, side) {
|
|
12315
12315
|
let line = view.lineBlockAt(pos);
|
|
12316
|
-
if (Array.isArray(line.type))
|
|
12316
|
+
if (Array.isArray(line.type)) {
|
|
12317
|
+
let best;
|
|
12317
12318
|
for (let l of line.type) {
|
|
12318
|
-
if (l.
|
|
12319
|
+
if (l.from > pos)
|
|
12320
|
+
break;
|
|
12321
|
+
if (l.to < pos)
|
|
12322
|
+
continue;
|
|
12323
|
+
if (l.from < pos && l.to > pos)
|
|
12319
12324
|
return l;
|
|
12325
|
+
if (!best || (l.type == BlockType.Text && (best.type != l.type || (side < 0 ? l.from < pos : l.to > pos))))
|
|
12326
|
+
best = l;
|
|
12320
12327
|
}
|
|
12328
|
+
return best || line;
|
|
12329
|
+
}
|
|
12321
12330
|
return line;
|
|
12322
12331
|
}
|
|
12323
12332
|
function moveToLineBoundary(view, start, forward, includeWrap) {
|
|
12324
|
-
let line = blockAt(view, start.head);
|
|
12333
|
+
let line = blockAt(view, start.head, start.assoc || -1);
|
|
12325
12334
|
let coords = !includeWrap || line.type != BlockType.Text || !(view.lineWrapping || line.widgetLineBreaks) ? null
|
|
12326
12335
|
: view.coordsAtPos(start.assoc < 0 && start.head > line.from ? start.head - 1 : start.head);
|
|
12327
12336
|
if (coords) {
|
|
@@ -13556,7 +13565,7 @@ function focusChangeTransaction(state, focus) {
|
|
|
13556
13565
|
if (effect)
|
|
13557
13566
|
effects.push(effect);
|
|
13558
13567
|
}
|
|
13559
|
-
return effects ? state.update({ effects, annotations: isFocusChange.of(true) }) : null;
|
|
13568
|
+
return effects.length ? state.update({ effects, annotations: isFocusChange.of(true) }) : null;
|
|
13560
13569
|
}
|
|
13561
13570
|
function updateForFocusChange(view) {
|
|
13562
13571
|
setTimeout(() => {
|
|
@@ -14591,7 +14600,7 @@ class ViewState {
|
|
|
14591
14600
|
}
|
|
14592
14601
|
else {
|
|
14593
14602
|
this.scrollAnchorPos = -1;
|
|
14594
|
-
this.scrollAnchorHeight =
|
|
14603
|
+
this.scrollAnchorHeight = prevHeight;
|
|
14595
14604
|
}
|
|
14596
14605
|
let viewport = heightChanges.length ? this.mapViewport(this.viewport, update.changes) : this.viewport;
|
|
14597
14606
|
if (scrollTarget && (scrollTarget.range.head < viewport.from || scrollTarget.range.head > viewport.to) ||
|
|
@@ -16087,14 +16096,14 @@ class EditorView {
|
|
|
16087
16096
|
[IME](https://en.wikipedia.org/wiki/Input_method), and at least
|
|
16088
16097
|
one change has been made in the current composition.
|
|
16089
16098
|
*/
|
|
16090
|
-
get composing() { return this.inputState.composing > 0; }
|
|
16099
|
+
get composing() { return !!this.inputState && this.inputState.composing > 0; }
|
|
16091
16100
|
/**
|
|
16092
16101
|
Indicates whether the user is currently in composing state. Note
|
|
16093
16102
|
that on some platforms, like Android, this will be the case a
|
|
16094
16103
|
lot, since just putting the cursor on a word starts a
|
|
16095
16104
|
composition there.
|
|
16096
16105
|
*/
|
|
16097
|
-
get compositionStarted() { return this.inputState.composing >= 0; }
|
|
16106
|
+
get compositionStarted() { return !!this.inputState && this.inputState.composing >= 0; }
|
|
16098
16107
|
/**
|
|
16099
16108
|
The document or shadow root that the view lives in.
|
|
16100
16109
|
*/
|
|
@@ -17521,7 +17530,7 @@ function rectanglesForRange(view, className, range) {
|
|
|
17521
17530
|
let leftSide = contentRect.left +
|
|
17522
17531
|
(lineStyle ? parseInt(lineStyle.paddingLeft) + Math.min(0, parseInt(lineStyle.textIndent)) : 0);
|
|
17523
17532
|
let rightSide = contentRect.right - (lineStyle ? parseInt(lineStyle.paddingRight) : 0);
|
|
17524
|
-
let startBlock = blockAt(view, from), endBlock = blockAt(view, to);
|
|
17533
|
+
let startBlock = blockAt(view, from, 1), endBlock = blockAt(view, to, -1);
|
|
17525
17534
|
let visualStart = startBlock.type == BlockType.Text ? startBlock : null;
|
|
17526
17535
|
let visualEnd = endBlock.type == BlockType.Text ? endBlock : null;
|
|
17527
17536
|
if (visualStart && (view.lineWrapping || startBlock.widgetLineBreaks))
|
|
@@ -26625,8 +26634,36 @@ const toLocaleString = (number, locale, options) => {
|
|
|
26625
26634
|
return result;
|
|
26626
26635
|
};
|
|
26627
26636
|
|
|
26637
|
+
const log10 = numberOrBigInt => {
|
|
26638
|
+
if (typeof numberOrBigInt === 'number') {
|
|
26639
|
+
return Math.log10(numberOrBigInt);
|
|
26640
|
+
}
|
|
26641
|
+
|
|
26642
|
+
const string = numberOrBigInt.toString(10);
|
|
26643
|
+
|
|
26644
|
+
return string.length + Math.log10('0.' + string.slice(0, 15));
|
|
26645
|
+
};
|
|
26646
|
+
|
|
26647
|
+
const log = numberOrBigInt => {
|
|
26648
|
+
if (typeof numberOrBigInt === 'number') {
|
|
26649
|
+
return Math.log(numberOrBigInt);
|
|
26650
|
+
}
|
|
26651
|
+
|
|
26652
|
+
return log10(numberOrBigInt) * Math.log(10);
|
|
26653
|
+
};
|
|
26654
|
+
|
|
26655
|
+
const divide = (numberOrBigInt, divisor) => {
|
|
26656
|
+
if (typeof numberOrBigInt === 'number') {
|
|
26657
|
+
return numberOrBigInt / divisor;
|
|
26658
|
+
}
|
|
26659
|
+
|
|
26660
|
+
const integerPart = numberOrBigInt / BigInt(divisor);
|
|
26661
|
+
const remainder = numberOrBigInt % BigInt(divisor);
|
|
26662
|
+
return Number(integerPart) + (Number(remainder) / divisor);
|
|
26663
|
+
};
|
|
26664
|
+
|
|
26628
26665
|
function prettyBytes(number, options) {
|
|
26629
|
-
if (!Number.isFinite(number)) {
|
|
26666
|
+
if (typeof number !== 'bigint' && !Number.isFinite(number)) {
|
|
26630
26667
|
throw new TypeError(`Expected a finite number, got ${typeof number}: ${number}`);
|
|
26631
26668
|
}
|
|
26632
26669
|
|
|
@@ -26643,7 +26680,7 @@ function prettyBytes(number, options) {
|
|
|
26643
26680
|
|
|
26644
26681
|
const separator = options.space ? ' ' : '';
|
|
26645
26682
|
|
|
26646
|
-
if (options.signed && number === 0) {
|
|
26683
|
+
if (options.signed && (typeof number === 'number' ? number === 0 : number === 0n)) {
|
|
26647
26684
|
return ` 0${separator}${UNITS[0]}`;
|
|
26648
26685
|
}
|
|
26649
26686
|
|
|
@@ -26669,8 +26706,8 @@ function prettyBytes(number, options) {
|
|
|
26669
26706
|
return prefix + numberString + separator + UNITS[0];
|
|
26670
26707
|
}
|
|
26671
26708
|
|
|
26672
|
-
const exponent = Math.min(Math.floor(options.binary ?
|
|
26673
|
-
number
|
|
26709
|
+
const exponent = Math.min(Math.floor(options.binary ? log(number) / Math.log(1024) : log10(number) / 3), UNITS.length - 1);
|
|
26710
|
+
number = divide(number, (options.binary ? 1024 : 1000) ** exponent);
|
|
26674
26711
|
|
|
26675
26712
|
if (!localeOptions) {
|
|
26676
26713
|
number = number.toPrecision(3);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export function getFunctionSource(src: any):
|
|
1
|
+
export function getFunctionSource(src: any): string;
|
|
@@ -10,9 +10,9 @@ export function getFunctionSource(src) {
|
|
|
10
10
|
if (!existsSync(indexPath)) {
|
|
11
11
|
throw Error(`Function directory ${pathToCheck} has no index.js`)
|
|
12
12
|
}
|
|
13
|
-
return indexPath
|
|
13
|
+
return `file://${indexPath}`
|
|
14
14
|
}
|
|
15
|
-
return pathToCheck
|
|
15
|
+
return `file://${pathToCheck}`
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
// Start when payload data arrives from parent process
|
|
@@ -1,33 +1,40 @@
|
|
|
1
1
|
import { treeify } from 'array-treeify';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
|
-
import { niceId } from './colors.js';
|
|
4
3
|
import { formatDate, formatDuration } from './dates.js';
|
|
4
|
+
import { niceId } from './presenters.js';
|
|
5
|
+
import { arrayifyLocalFunction, arrayifyStackFunction } from './resources-formatting.js';
|
|
5
6
|
export function formatTitle(title, name) {
|
|
6
7
|
return `${chalk.bold.blue(title)} ${chalk.bold(`"${name}"`)}`;
|
|
7
8
|
}
|
|
8
9
|
export function formatResourceTree(resources) {
|
|
9
|
-
if (!resources || resources.length === 0)
|
|
10
|
+
if (!resources || resources.length === 0)
|
|
10
11
|
return ' Zero resources';
|
|
11
|
-
}
|
|
12
|
-
const output = [];
|
|
13
|
-
output.push(`${chalk.blue('Blueprint Resources')} [${resources.length}]`);
|
|
12
|
+
const output = [`${chalk.blue('Blueprint Resources')} [${resources.length}]`];
|
|
14
13
|
const functionResources = resources.filter((r) => r.type?.startsWith('sanity.function.'));
|
|
15
14
|
const otherResources = resources.filter((r) => !r.type?.startsWith('sanity.function.'));
|
|
16
15
|
const hasOtherResources = otherResources.length > 0;
|
|
17
16
|
if (functionResources.length > 0) {
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
const
|
|
17
|
+
const fnsOutput = [`${chalk.bold('Functions')} [${functionResources.length}]`];
|
|
18
|
+
const fnDetails = [];
|
|
19
|
+
for (const fn of functionResources) {
|
|
21
20
|
const name = chalk.green(fn.displayName || fn.name);
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
const ids = [
|
|
22
|
+
'id' in fn && fn.id ? `${niceId(fn.id)}` : '',
|
|
23
|
+
'externalId' in fn && fn.externalId ? `<${niceId(fn.externalId)}>` : '',
|
|
24
|
+
].join(' ');
|
|
25
|
+
fnDetails.push(`"${name}" ${ids}`);
|
|
26
|
+
if ('parameters' in fn && fn.parameters) {
|
|
27
|
+
fnDetails.push(arrayifyStackFunction(fn));
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
fnDetails.push(arrayifyLocalFunction(fn));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
fnsOutput.push(fnDetails);
|
|
34
|
+
output.push(fnsOutput);
|
|
27
35
|
}
|
|
28
36
|
if (hasOtherResources) {
|
|
29
|
-
const otherOutput = [];
|
|
30
|
-
otherOutput.push(`${chalk.bold('Other Resources')} [${otherResources.length}]`);
|
|
37
|
+
const otherOutput = [`${chalk.bold('Other Resources')} [${otherResources.length}]`];
|
|
31
38
|
const otherResourcesOutput = otherResources.map((other) => {
|
|
32
39
|
return `"${chalk.yellow(other.displayName ?? other.name ?? 'unnamed')}"`;
|
|
33
40
|
});
|
|
@@ -37,9 +44,8 @@ export function formatResourceTree(resources) {
|
|
|
37
44
|
return treeify(output);
|
|
38
45
|
}
|
|
39
46
|
export function formatStackInfo(stack, isCurrentStack = false) {
|
|
40
|
-
const output = [];
|
|
41
47
|
const isStack = 'id' in stack;
|
|
42
|
-
const
|
|
48
|
+
const output = [];
|
|
43
49
|
if (isStack) {
|
|
44
50
|
const stackName = isCurrentStack ? chalk.bold.blue(stack.name) : chalk.bold(stack.name);
|
|
45
51
|
output.push(`"${stackName}" ${niceId(stack.id)}${isCurrentStack ? ' (current)' : ''}`);
|
|
@@ -47,6 +53,7 @@ export function formatStackInfo(stack, isCurrentStack = false) {
|
|
|
47
53
|
else {
|
|
48
54
|
output.push('Local Blueprint');
|
|
49
55
|
}
|
|
56
|
+
const infoOutput = [];
|
|
50
57
|
if (stack.resources) {
|
|
51
58
|
infoOutput.push(`${stack.resources.length} resource${stack.resources.length === 1 ? '' : 's'}`);
|
|
52
59
|
}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
+
export { info, niceId, warn, severe } from './presenters.js';
|
|
2
|
+
/** @deprecated Use `chalk.bold` directly */
|
|
1
3
|
export declare function bold(str: string): string;
|
|
4
|
+
/** @deprecated Use `chalk.underline` directly */
|
|
2
5
|
export declare function underline(str: string): string;
|
|
6
|
+
/** @deprecated Use `chalk.dim` directly */
|
|
3
7
|
export declare function dim(str: string): string;
|
|
8
|
+
/** @deprecated Use `chalk.blue` directly */
|
|
4
9
|
export declare function blue(str: string): string;
|
|
10
|
+
/** @deprecated Use `chalk.green` directly */
|
|
5
11
|
export declare function green(str: string): string;
|
|
12
|
+
/** @deprecated Use `chalk.red` directly */
|
|
6
13
|
export declare function red(str: string): string;
|
|
14
|
+
/** @deprecated Use `chalk.yellow` directly */
|
|
7
15
|
export declare function yellow(str: string): string;
|
|
8
|
-
export declare function info(str: string): string;
|
|
9
|
-
export declare function warn(str: string): string;
|
|
10
|
-
export declare function severe(str: string): string;
|
|
11
|
-
export declare function niceId(id: string | undefined): string;
|
|
@@ -1,38 +1,30 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
export { info, niceId, warn, severe } from './presenters.js';
|
|
3
|
+
/** @deprecated Use `chalk.bold` directly */
|
|
4
4
|
export function bold(str) {
|
|
5
5
|
return chalk.bold(str);
|
|
6
6
|
}
|
|
7
|
+
/** @deprecated Use `chalk.underline` directly */
|
|
7
8
|
export function underline(str) {
|
|
8
9
|
return chalk.underline(str);
|
|
9
10
|
}
|
|
11
|
+
/** @deprecated Use `chalk.dim` directly */
|
|
10
12
|
export function dim(str) {
|
|
11
13
|
return chalk.dim(str);
|
|
12
14
|
}
|
|
15
|
+
/** @deprecated Use `chalk.blue` directly */
|
|
13
16
|
export function blue(str) {
|
|
14
17
|
return chalk.blue(str);
|
|
15
18
|
}
|
|
19
|
+
/** @deprecated Use `chalk.green` directly */
|
|
16
20
|
export function green(str) {
|
|
17
21
|
return chalk.green(str);
|
|
18
22
|
}
|
|
23
|
+
/** @deprecated Use `chalk.red` directly */
|
|
19
24
|
export function red(str) {
|
|
20
25
|
return chalk.red(str);
|
|
21
26
|
}
|
|
27
|
+
/** @deprecated Use `chalk.yellow` directly */
|
|
22
28
|
export function yellow(str) {
|
|
23
29
|
return chalk.yellow(str);
|
|
24
30
|
}
|
|
25
|
-
export function info(str) {
|
|
26
|
-
return `${chalk.blue('❯')} ${str}`;
|
|
27
|
-
}
|
|
28
|
-
export function warn(str) {
|
|
29
|
-
return `${chalk.yellow('❯')} ${str}`;
|
|
30
|
-
}
|
|
31
|
-
export function severe(str) {
|
|
32
|
-
return `${chalk.red('❯')} ${str}`;
|
|
33
|
-
}
|
|
34
|
-
export function niceId(id) {
|
|
35
|
-
if (!id)
|
|
36
|
-
return '';
|
|
37
|
-
return `<${yellow(id)}>`;
|
|
38
|
-
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * as blueprintsFormatting from './blueprints-formatting.js';
|
|
2
2
|
export * as colors from './colors.js';
|
|
3
|
+
export * as presenters from './presenters.js';
|
|
3
4
|
export * as dates from './dates.js';
|
|
4
5
|
export * as logsFormatting from './logs-formatting.js';
|
|
5
6
|
export * as errors from './errors.js';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * as blueprintsFormatting from './blueprints-formatting.js';
|
|
2
2
|
export * as colors from './colors.js';
|
|
3
|
+
export * as presenters from './presenters.js';
|
|
3
4
|
export * as dates from './dates.js';
|
|
4
5
|
export * as logsFormatting from './logs-formatting.js';
|
|
5
6
|
export * as errors from './errors.js';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { treeify } from 'array-treeify';
|
|
2
|
-
import
|
|
2
|
+
import chalk from 'chalk';
|
|
3
3
|
export function formatLogEntry(log, withDate = true, isNewest = false) {
|
|
4
4
|
const date = new Date(log.timestamp);
|
|
5
5
|
const time = date.toLocaleTimeString();
|
|
6
6
|
const day = date.toLocaleDateString();
|
|
7
|
-
return `${isNewest ? `${green('>')} ` : ''}${withDate ? `${day} ` : ''}${dim(time)} ${log.message}`;
|
|
7
|
+
return `${isNewest ? `${chalk.green('>')} ` : ''}${withDate ? `${day} ` : ''}${chalk.dim(time)} ${log.message}`;
|
|
8
8
|
}
|
|
9
9
|
export function formatRecentLogs(logs) {
|
|
10
10
|
if (logs.length === 0)
|
|
@@ -33,7 +33,7 @@ export function formatLogsByDay(logsByDay) {
|
|
|
33
33
|
return new Date(a).getTime() - new Date(b).getTime();
|
|
34
34
|
});
|
|
35
35
|
for (const day of sortedDays) {
|
|
36
|
-
output.push(`${blue('Date:')} ${bold(day)}`);
|
|
36
|
+
output.push(`${chalk.blue('Date:')} ${chalk.bold(day)}`);
|
|
37
37
|
const dayLogs = logsByDay.get(day) || [];
|
|
38
38
|
dayLogs.sort((a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime());
|
|
39
39
|
const dayLogsOutput = dayLogs.map((log) => formatLogEntry(log, false));
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
export function info(str) {
|
|
3
|
+
return `${chalk.blue('❯')} ${str}`;
|
|
4
|
+
}
|
|
5
|
+
export function warn(str) {
|
|
6
|
+
return `${chalk.yellow('❯')} ${str}`;
|
|
7
|
+
}
|
|
8
|
+
export function severe(str) {
|
|
9
|
+
return `${chalk.red('❯')} ${str}`;
|
|
10
|
+
}
|
|
11
|
+
export function niceId(id) {
|
|
12
|
+
if (!id)
|
|
13
|
+
return '';
|
|
14
|
+
return `<${chalk.yellow(id)}>`;
|
|
15
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { TreeInput } from 'array-treeify';
|
|
2
|
+
import type { LocalFunctionResource, StackFunctionResource } from '../../utils/types.js';
|
|
3
|
+
export declare function arrayifyLocalFunction(fn: LocalFunctionResource): TreeInput;
|
|
4
|
+
export declare function arrayifyStackFunction(fn: StackFunctionResource): TreeInput;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
function formatMemory(memory) {
|
|
3
|
+
return `${chalk.dim('memory:')} ${memory}`;
|
|
4
|
+
}
|
|
5
|
+
function formatTimeout(timeout) {
|
|
6
|
+
return `${chalk.dim('timeout:')} ${timeout}`;
|
|
7
|
+
}
|
|
8
|
+
function arrayifyEvent(event) {
|
|
9
|
+
if (!event)
|
|
10
|
+
return undefined;
|
|
11
|
+
const details = [];
|
|
12
|
+
if (event.on) {
|
|
13
|
+
details.push(`${chalk.dim('on:')} ${event.on.map((o) => `"${o}"`).join(', ')}`);
|
|
14
|
+
}
|
|
15
|
+
if (event.filter) {
|
|
16
|
+
details.push(`${chalk.dim('filter:')} ${event.filter}`);
|
|
17
|
+
}
|
|
18
|
+
if (event.projection) {
|
|
19
|
+
details.push(`${chalk.dim('projection:')} ${event.projection}`);
|
|
20
|
+
}
|
|
21
|
+
return details;
|
|
22
|
+
}
|
|
23
|
+
export function arrayifyLocalFunction(fn) {
|
|
24
|
+
const details = [`${chalk.dim('type:')} "${fn.type}"`];
|
|
25
|
+
if (fn.memory)
|
|
26
|
+
details.push(formatMemory(fn.memory));
|
|
27
|
+
if (fn.timeout)
|
|
28
|
+
details.push(formatTimeout(fn.timeout));
|
|
29
|
+
if (fn.event) {
|
|
30
|
+
const eventDetails = arrayifyEvent(fn.event);
|
|
31
|
+
if (eventDetails) {
|
|
32
|
+
details.push(`${chalk.dim('event:')}`);
|
|
33
|
+
details.push(eventDetails);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return details;
|
|
37
|
+
}
|
|
38
|
+
export function arrayifyStackFunction(fn) {
|
|
39
|
+
const details = [`${chalk.dim('type:')} "${fn.type}"`];
|
|
40
|
+
if (fn.parameters.memory)
|
|
41
|
+
details.push(formatMemory(fn.parameters.memory));
|
|
42
|
+
if (fn.parameters.timeout)
|
|
43
|
+
details.push(formatTimeout(fn.parameters.timeout));
|
|
44
|
+
if (fn.parameters.event) {
|
|
45
|
+
const eventDetails = arrayifyEvent(fn.parameters.event);
|
|
46
|
+
if (eventDetails) {
|
|
47
|
+
details.push(`${chalk.dim('event:')}`);
|
|
48
|
+
details.push(eventDetails);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return details;
|
|
52
|
+
}
|
|
@@ -2,12 +2,13 @@ import { spawn } from 'node:child_process';
|
|
|
2
2
|
import { performance } from 'node:perf_hooks';
|
|
3
3
|
import { cwd } from 'node:process';
|
|
4
4
|
import { setTimeout } from 'node:timers';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
5
6
|
import config from '../config.js';
|
|
6
7
|
import { bundleFunction } from './bundle/bundle-function.js';
|
|
7
8
|
import { findFunctionEntryPoint } from './functions/find-entry-point.js';
|
|
8
9
|
import { shouldBundleFunction } from './functions/should-bundle.js';
|
|
9
10
|
function getChildProcessWrapperPath() {
|
|
10
|
-
return new URL('./child-process-wrapper.js', import.meta.url)
|
|
11
|
+
return fileURLToPath(new URL('./child-process-wrapper.js', import.meta.url));
|
|
11
12
|
}
|
|
12
13
|
export function sanitizeLogs(logs) {
|
|
13
14
|
return logs.replace(/([a-zA-Z0-9]{10})[a-zA-Z0-9]{65,}/g, '$1**********');
|
package/dist/utils/types.d.ts
CHANGED
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/runtime-cli",
|
|
3
3
|
"description": "Sanity's Runtime CLI for Blueprints and Functions",
|
|
4
|
-
"version": "6.2.
|
|
4
|
+
"version": "6.2.2",
|
|
5
5
|
"author": "Sanity Runtime Team",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "MIT",
|
|
@@ -64,20 +64,20 @@
|
|
|
64
64
|
"test:watch": "vitest"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@oclif/core": "^4.
|
|
68
|
-
"@oclif/plugin-help": "^6.2.
|
|
67
|
+
"@oclif/core": "^4.3.0",
|
|
68
|
+
"@oclif/plugin-help": "^6.2.28",
|
|
69
69
|
"adm-zip": "^0.5.16",
|
|
70
|
-
"array-treeify": "^0.1.
|
|
70
|
+
"array-treeify": "^0.1.5",
|
|
71
71
|
"chalk": "^5.4.1",
|
|
72
72
|
"color-json": "^3.0.5",
|
|
73
73
|
"eventsource": "^3.0.6",
|
|
74
74
|
"find-up": "^7.0.0",
|
|
75
|
-
"inquirer": "^12.
|
|
75
|
+
"inquirer": "^12.6.0",
|
|
76
76
|
"mime-types": "^3.0.1",
|
|
77
|
-
"
|
|
77
|
+
"ora": "^8.2.0",
|
|
78
|
+
"vite": "^6.3.5",
|
|
78
79
|
"vite-tsconfig-paths": "^5.1.4",
|
|
79
|
-
"xdg-basedir": "^5.1.0"
|
|
80
|
-
"yocto-spinner": "^0.2.1"
|
|
80
|
+
"xdg-basedir": "^5.1.0"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
83
|
"@biomejs/biome": "1.9.4",
|
|
@@ -87,21 +87,21 @@
|
|
|
87
87
|
"@lezer/highlight": "^1.2.1",
|
|
88
88
|
"@oclif/test": "^4.1.12",
|
|
89
89
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
90
|
-
"@sanity/client": "^
|
|
90
|
+
"@sanity/client": "^7.1.0",
|
|
91
91
|
"@types/adm-zip": "^0.5.7",
|
|
92
92
|
"@types/mime-types": "^2.1.4",
|
|
93
93
|
"@types/node": "18",
|
|
94
94
|
"codemirror": "^6.0.1",
|
|
95
|
-
"mentoss": "^0.
|
|
96
|
-
"oclif": "^4.17.
|
|
97
|
-
"pretty-bytes": "^
|
|
95
|
+
"mentoss": "^0.11.0",
|
|
96
|
+
"oclif": "^4.17.46",
|
|
97
|
+
"pretty-bytes": "^7.0.0",
|
|
98
98
|
"pretty-ms": "^9.2.0",
|
|
99
|
-
"rollup": "^4.40.
|
|
99
|
+
"rollup": "^4.40.2",
|
|
100
100
|
"shx": "^0.4.0",
|
|
101
101
|
"ts-node": "^10.9.2",
|
|
102
|
-
"tsx": "^4.19.
|
|
102
|
+
"tsx": "^4.19.4",
|
|
103
103
|
"typescript": "^5.8.3",
|
|
104
|
-
"vitest": "3.1.
|
|
104
|
+
"vitest": "3.1.3"
|
|
105
105
|
},
|
|
106
106
|
"oclif": {
|
|
107
107
|
"bin": "sanity-run",
|