@sanity/runtime-cli 15.0.3 → 15.0.5
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 +20 -20
- package/dist/actions/sanity/examples.d.ts +8 -2
- package/dist/actions/sanity/examples.js +10 -11
- package/dist/cores/blueprints/config.js +2 -1
- package/dist/cores/blueprints/deploy.js +5 -1
- package/dist/cores/blueprints/destroy.js +5 -1
- package/dist/cores/blueprints/doctor.js +3 -4
- package/dist/cores/blueprints/mint-deploy-token.js +3 -2
- package/dist/utils/display/blueprints-formatting.js +4 -4
- package/dist/utils/display/dates.d.ts +5 -1
- package/dist/utils/display/dates.js +26 -2
- package/dist/utils/display/logs-formatting.js +1 -12
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ $ npm install -g @sanity/runtime-cli
|
|
|
20
20
|
$ sanity-run COMMAND
|
|
21
21
|
running command...
|
|
22
22
|
$ sanity-run (--version)
|
|
23
|
-
@sanity/runtime-cli/15.0.
|
|
23
|
+
@sanity/runtime-cli/15.0.5 linux-x64 node-v24.14.1
|
|
24
24
|
$ sanity-run --help [COMMAND]
|
|
25
25
|
USAGE
|
|
26
26
|
$ sanity-run COMMAND
|
|
@@ -103,7 +103,7 @@ EXAMPLES
|
|
|
103
103
|
$ sanity-run blueprints add function --name my-function --fn-type document-create --fn-type document-update --lang js
|
|
104
104
|
```
|
|
105
105
|
|
|
106
|
-
_See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.
|
|
106
|
+
_See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.5/src/commands/blueprints/add.ts)_
|
|
107
107
|
|
|
108
108
|
## `sanity-run blueprints config`
|
|
109
109
|
|
|
@@ -140,7 +140,7 @@ EXAMPLES
|
|
|
140
140
|
$ sanity-run blueprints config --edit --project-id <projectId> --stack <name-or-id>
|
|
141
141
|
```
|
|
142
142
|
|
|
143
|
-
_See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.
|
|
143
|
+
_See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.5/src/commands/blueprints/config.ts)_
|
|
144
144
|
|
|
145
145
|
## `sanity-run blueprints deploy`
|
|
146
146
|
|
|
@@ -191,7 +191,7 @@ EXAMPLES
|
|
|
191
191
|
$ sanity-run blueprints deploy --new-stack-name <new-name>
|
|
192
192
|
```
|
|
193
193
|
|
|
194
|
-
_See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.
|
|
194
|
+
_See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.5/src/commands/blueprints/deploy.ts)_
|
|
195
195
|
|
|
196
196
|
## `sanity-run blueprints destroy`
|
|
197
197
|
|
|
@@ -226,7 +226,7 @@ EXAMPLES
|
|
|
226
226
|
$ sanity-run blueprints destroy --stack <name-or-id> --project-id <projectId> --force --no-wait
|
|
227
227
|
```
|
|
228
228
|
|
|
229
|
-
_See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.
|
|
229
|
+
_See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.5/src/commands/blueprints/destroy.ts)_
|
|
230
230
|
|
|
231
231
|
## `sanity-run blueprints doctor`
|
|
232
232
|
|
|
@@ -257,7 +257,7 @@ EXAMPLES
|
|
|
257
257
|
$ sanity-run blueprints doctor --fix
|
|
258
258
|
```
|
|
259
259
|
|
|
260
|
-
_See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.
|
|
260
|
+
_See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.5/src/commands/blueprints/doctor.ts)_
|
|
261
261
|
|
|
262
262
|
## `sanity-run blueprints info`
|
|
263
263
|
|
|
@@ -294,7 +294,7 @@ EXAMPLES
|
|
|
294
294
|
$ sanity-run blueprints info --organization-id <orgId> --stack <name-or-id>
|
|
295
295
|
```
|
|
296
296
|
|
|
297
|
-
_See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.
|
|
297
|
+
_See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.5/src/commands/blueprints/info.ts)_
|
|
298
298
|
|
|
299
299
|
## `sanity-run blueprints init [DIR]`
|
|
300
300
|
|
|
@@ -345,7 +345,7 @@ EXAMPLES
|
|
|
345
345
|
$ sanity-run blueprints init --blueprint-type <json|js|ts> --stack-name <stackName>
|
|
346
346
|
```
|
|
347
347
|
|
|
348
|
-
_See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.
|
|
348
|
+
_See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.5/src/commands/blueprints/init.ts)_
|
|
349
349
|
|
|
350
350
|
## `sanity-run blueprints logs`
|
|
351
351
|
|
|
@@ -391,7 +391,7 @@ EXAMPLES
|
|
|
391
391
|
$ sanity-run blueprints logs --before 2026-05-01T00:00:00Z
|
|
392
392
|
```
|
|
393
393
|
|
|
394
|
-
_See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.
|
|
394
|
+
_See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.5/src/commands/blueprints/logs.ts)_
|
|
395
395
|
|
|
396
396
|
## `sanity-run blueprints mint-deploy-token`
|
|
397
397
|
|
|
@@ -436,7 +436,7 @@ EXAMPLES
|
|
|
436
436
|
$ sanity-run blueprints mint-deploy-token --organization-id <orgId>
|
|
437
437
|
```
|
|
438
438
|
|
|
439
|
-
_See code: [src/commands/blueprints/mint-deploy-token.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.
|
|
439
|
+
_See code: [src/commands/blueprints/mint-deploy-token.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.5/src/commands/blueprints/mint-deploy-token.ts)_
|
|
440
440
|
|
|
441
441
|
## `sanity-run blueprints plan`
|
|
442
442
|
|
|
@@ -469,7 +469,7 @@ EXAMPLES
|
|
|
469
469
|
$ sanity-run blueprints plan --organization-id <orgId> --stack <name-or-id>
|
|
470
470
|
```
|
|
471
471
|
|
|
472
|
-
_See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.
|
|
472
|
+
_See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.5/src/commands/blueprints/plan.ts)_
|
|
473
473
|
|
|
474
474
|
## `sanity-run blueprints promote`
|
|
475
475
|
|
|
@@ -505,7 +505,7 @@ EXAMPLES
|
|
|
505
505
|
$ sanity-run blueprints promote --new-stack-name <new-name>
|
|
506
506
|
```
|
|
507
507
|
|
|
508
|
-
_See code: [src/commands/blueprints/promote.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.
|
|
508
|
+
_See code: [src/commands/blueprints/promote.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.5/src/commands/blueprints/promote.ts)_
|
|
509
509
|
|
|
510
510
|
## `sanity-run blueprints stacks`
|
|
511
511
|
|
|
@@ -541,7 +541,7 @@ EXAMPLES
|
|
|
541
541
|
$ sanity-run blueprints stacks --organization-id <organizationId> --include-projects
|
|
542
542
|
```
|
|
543
543
|
|
|
544
|
-
_See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.
|
|
544
|
+
_See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.5/src/commands/blueprints/stacks.ts)_
|
|
545
545
|
|
|
546
546
|
## `sanity-run functions add`
|
|
547
547
|
|
|
@@ -593,7 +593,7 @@ EXAMPLES
|
|
|
593
593
|
$ sanity-run functions add --name my-function --type document-create --type document-update --lang js
|
|
594
594
|
```
|
|
595
595
|
|
|
596
|
-
_See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.
|
|
596
|
+
_See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.5/src/commands/functions/add.ts)_
|
|
597
597
|
|
|
598
598
|
## `sanity-run functions dev`
|
|
599
599
|
|
|
@@ -628,7 +628,7 @@ EXAMPLES
|
|
|
628
628
|
$ sanity-run functions dev --timeout 60
|
|
629
629
|
```
|
|
630
630
|
|
|
631
|
-
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.
|
|
631
|
+
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.5/src/commands/functions/dev.ts)_
|
|
632
632
|
|
|
633
633
|
## `sanity-run functions env add NAME KEY VALUE`
|
|
634
634
|
|
|
@@ -658,7 +658,7 @@ EXAMPLES
|
|
|
658
658
|
$ sanity-run functions env add MyFunction API_URL https://api.example.com/
|
|
659
659
|
```
|
|
660
660
|
|
|
661
|
-
_See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.
|
|
661
|
+
_See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.5/src/commands/functions/env/add.ts)_
|
|
662
662
|
|
|
663
663
|
## `sanity-run functions env list NAME`
|
|
664
664
|
|
|
@@ -685,7 +685,7 @@ EXAMPLES
|
|
|
685
685
|
$ sanity-run functions env list MyFunction
|
|
686
686
|
```
|
|
687
687
|
|
|
688
|
-
_See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.
|
|
688
|
+
_See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.5/src/commands/functions/env/list.ts)_
|
|
689
689
|
|
|
690
690
|
## `sanity-run functions env remove NAME KEY`
|
|
691
691
|
|
|
@@ -714,7 +714,7 @@ EXAMPLES
|
|
|
714
714
|
$ sanity-run functions env remove MyFunction API_URL
|
|
715
715
|
```
|
|
716
716
|
|
|
717
|
-
_See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.
|
|
717
|
+
_See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.5/src/commands/functions/env/remove.ts)_
|
|
718
718
|
|
|
719
719
|
## `sanity-run functions logs [NAME]`
|
|
720
720
|
|
|
@@ -754,7 +754,7 @@ EXAMPLES
|
|
|
754
754
|
$ sanity-run functions logs <name> --delete
|
|
755
755
|
```
|
|
756
756
|
|
|
757
|
-
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.
|
|
757
|
+
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.5/src/commands/functions/logs.ts)_
|
|
758
758
|
|
|
759
759
|
## `sanity-run functions test [NAME]`
|
|
760
760
|
|
|
@@ -811,7 +811,7 @@ EXAMPLES
|
|
|
811
811
|
$ sanity-run functions test <name> --event update --data-before '{ "title": "before" }' --data-after '{ "title": "after" }'
|
|
812
812
|
```
|
|
813
813
|
|
|
814
|
-
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.
|
|
814
|
+
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.5/src/commands/functions/test.ts)_
|
|
815
815
|
|
|
816
816
|
## `sanity-run help [COMMAND]`
|
|
817
817
|
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import type { Logger } from '../../utils/logger.js';
|
|
2
2
|
export declare const EXAMPLES_CACHE_DIR: string;
|
|
3
3
|
declare const EXAMPLE_TYPES: {
|
|
4
|
-
blueprint:
|
|
5
|
-
|
|
4
|
+
readonly blueprint: {
|
|
5
|
+
readonly repo: "sanity-io/sanity";
|
|
6
|
+
readonly dir: "examples/blueprints";
|
|
7
|
+
};
|
|
8
|
+
readonly function: {
|
|
9
|
+
readonly repo: "sanity-labs/function-recipes";
|
|
10
|
+
readonly dir: "";
|
|
11
|
+
};
|
|
6
12
|
};
|
|
7
13
|
export declare function verifyExampleExists({ type, name, logger, }: {
|
|
8
14
|
type: keyof typeof EXAMPLE_TYPES;
|
|
@@ -6,17 +6,16 @@ import { createGunzip } from 'node:zlib';
|
|
|
6
6
|
import { extract } from 'tar-stream';
|
|
7
7
|
import { gitHubRequest } from '../../utils/other/github.js';
|
|
8
8
|
export const EXAMPLES_CACHE_DIR = join(tmpdir(), 'sanity-examples');
|
|
9
|
-
const EXAMPLES_REPO = 'sanity-io/sanity';
|
|
10
|
-
const EXAMPLES_DIR = 'examples';
|
|
11
|
-
const BLUEPRINTS_DIR = `${EXAMPLES_DIR}/blueprints`;
|
|
12
|
-
const FUNCTIONS_DIR = `${EXAMPLES_DIR}/functions`;
|
|
13
9
|
const EXAMPLE_TYPES = {
|
|
14
|
-
blueprint:
|
|
15
|
-
function:
|
|
10
|
+
blueprint: { repo: 'sanity-io/sanity', dir: 'examples/blueprints' },
|
|
11
|
+
function: { repo: 'sanity-labs/function-recipes', dir: '' },
|
|
16
12
|
};
|
|
13
|
+
function getExamplePath(type, name) {
|
|
14
|
+
const { dir } = EXAMPLE_TYPES[type];
|
|
15
|
+
return dir ? `${dir}/${name}` : name;
|
|
16
|
+
}
|
|
17
17
|
export async function verifyExampleExists({ type, name, logger, }) {
|
|
18
|
-
const
|
|
19
|
-
const path = `/repos/${EXAMPLES_REPO}/contents/${examplePath}`;
|
|
18
|
+
const path = `/repos/${EXAMPLE_TYPES[type].repo}/contents/${getExamplePath(type, name)}`;
|
|
20
19
|
const response = await gitHubRequest(path, logger);
|
|
21
20
|
return response.ok;
|
|
22
21
|
}
|
|
@@ -56,7 +55,7 @@ async function downloadRepoArchive(logger, ownerRepo, ref = 'main') {
|
|
|
56
55
|
}
|
|
57
56
|
}
|
|
58
57
|
async function extractExampleFromArchive({ archiveStream, exampleType, exampleName, }) {
|
|
59
|
-
const fullPath =
|
|
58
|
+
const fullPath = getExamplePath(exampleType, exampleName);
|
|
60
59
|
const files = {};
|
|
61
60
|
let repoPrefix = null;
|
|
62
61
|
const extractStream = extract();
|
|
@@ -154,8 +153,8 @@ function extractInstructions(exampleFiles) {
|
|
|
154
153
|
* @sideEffect Creates the example directory and writes the example to disk.
|
|
155
154
|
* @returns The example files and directory and the function config if it exists.
|
|
156
155
|
*/
|
|
157
|
-
export async function writeExample({ ownerRepo
|
|
158
|
-
const archiveStream = await downloadRepoArchive(logger, ownerRepo);
|
|
156
|
+
export async function writeExample({ ownerRepo, exampleType, exampleName, dir = './tmp', logger, }) {
|
|
157
|
+
const archiveStream = await downloadRepoArchive(logger, ownerRepo ?? EXAMPLE_TYPES[exampleType].repo);
|
|
159
158
|
if (!archiveStream)
|
|
160
159
|
return false;
|
|
161
160
|
const exampleFiles = await extractExampleFromArchive({
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { patchConfigFile, writeConfigFile, } from '../../actions/blueprints/config.js';
|
|
2
2
|
import { resolveStackIdByNameOrId } from '../../actions/blueprints/stacks.js';
|
|
3
|
+
import { formatDateTime } from '../../utils/display/dates.js';
|
|
3
4
|
import { filePathRelativeToCwd, labeledId, warn } from '../../utils/display/presenters.js';
|
|
4
5
|
import { runScopeAndStackWizard } from '../../utils/display/prompt.js';
|
|
5
6
|
import { styleText } from '../../utils/style-text.js';
|
|
@@ -120,7 +121,7 @@ function printConfig(options) {
|
|
|
120
121
|
log(` Deployment: ${labeledId('stack', stackId)}`);
|
|
121
122
|
log(` Scoped to: ${labeledId(scopeType, scopeId)}`);
|
|
122
123
|
if (updatedAt)
|
|
123
|
-
log(` Updated: ${
|
|
124
|
+
log(` Updated: ${formatDateTime(updatedAt)}`);
|
|
124
125
|
if ('configPath' in config) {
|
|
125
126
|
const { configPath } = config;
|
|
126
127
|
if (configPath)
|
|
@@ -81,6 +81,7 @@ export async function blueprintDeployCore(options) {
|
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
83
|
log(styleText('dim', 'Stack deployment progress:'));
|
|
84
|
+
log('');
|
|
84
85
|
const logHints = createLogHintCollector(bin);
|
|
85
86
|
let logStreamCleanup = null;
|
|
86
87
|
try {
|
|
@@ -120,12 +121,14 @@ export async function blueprintDeployCore(options) {
|
|
|
120
121
|
if (operation.status === 'FAILED') {
|
|
121
122
|
if (logStreamCleanup)
|
|
122
123
|
logStreamCleanup();
|
|
124
|
+
log('');
|
|
123
125
|
return {
|
|
124
126
|
success: false,
|
|
125
127
|
error: 'Stack deployment failed',
|
|
126
128
|
suggestions: [
|
|
127
129
|
...logHints.getSuggestions(),
|
|
128
|
-
|
|
130
|
+
'Review the deployment output above for error details.',
|
|
131
|
+
`Run \`npx ${bin} blueprints logs --verbose\` for more context.`,
|
|
129
132
|
`Run \`npx ${bin} blueprints plan\` to identify issues with your Blueprint.`,
|
|
130
133
|
],
|
|
131
134
|
};
|
|
@@ -133,6 +136,7 @@ export async function blueprintDeployCore(options) {
|
|
|
133
136
|
if (operation.status === 'COMPLETED') {
|
|
134
137
|
if (logStreamCleanup)
|
|
135
138
|
logStreamCleanup();
|
|
139
|
+
log('');
|
|
136
140
|
log(styleText(['bold', 'green'], 'Stack deployment completed!'));
|
|
137
141
|
return {
|
|
138
142
|
success: true,
|
|
@@ -133,6 +133,7 @@ export async function blueprintDestroyCore(options) {
|
|
|
133
133
|
async function waitForDestruction(options) {
|
|
134
134
|
const { stackId, stackName, operationId, auth, log, bin } = options;
|
|
135
135
|
log(styleText('dim', 'Stack destruction progress:'));
|
|
136
|
+
log('');
|
|
136
137
|
const logHints = createLogHintCollector(bin);
|
|
137
138
|
let logStreamCleanup = null;
|
|
138
139
|
try {
|
|
@@ -156,18 +157,21 @@ async function waitForDestruction(options) {
|
|
|
156
157
|
// it's possible that the operation is "gone" or available and "COMPLETED"
|
|
157
158
|
if (logStreamCleanup)
|
|
158
159
|
logStreamCleanup();
|
|
160
|
+
log('');
|
|
159
161
|
log(styleText(['bold', 'magenta'], 'Stack destruction completed!'));
|
|
160
162
|
return { success: true, json: { stackId, stackName } };
|
|
161
163
|
}
|
|
162
164
|
if (operation.status === 'FAILED') {
|
|
163
165
|
if (logStreamCleanup)
|
|
164
166
|
logStreamCleanup();
|
|
167
|
+
log('');
|
|
165
168
|
return {
|
|
166
169
|
success: false,
|
|
167
170
|
error: 'Stack destruction failed',
|
|
168
171
|
suggestions: [
|
|
169
172
|
...logHints.getSuggestions(),
|
|
170
|
-
|
|
173
|
+
'Review the destruction output above for error details.',
|
|
174
|
+
`Run \`npx ${bin} blueprints logs --verbose\` for more context.`,
|
|
171
175
|
`Run \`npx ${bin} blueprints info\` to view current Stack status.`,
|
|
172
176
|
],
|
|
173
177
|
};
|
|
@@ -7,6 +7,7 @@ import { readConfigFile } from '../../actions/blueprints/config.js';
|
|
|
7
7
|
import { resolveIds } from '../../actions/blueprints/resolve.js';
|
|
8
8
|
import { getStack } from '../../actions/blueprints/stacks.js';
|
|
9
9
|
import config, { RUNTIME_CLI_VERSION } from '../../config.js';
|
|
10
|
+
import { formatDateTime } from '../../utils/display/dates.js';
|
|
10
11
|
import { check, filePathRelativeToCwd, niceId, renderSection, severe, unsure, } from '../../utils/display/presenters.js';
|
|
11
12
|
import { styleText } from '../../utils/style-text.js';
|
|
12
13
|
import { createTracedFetch } from '../../utils/traced-fetch.js';
|
|
@@ -132,7 +133,7 @@ export async function blueprintDoctorCore(options) {
|
|
|
132
133
|
configRows.push(['Source', styleText('dim', 'no .sanity/blueprint.config.json')]);
|
|
133
134
|
}
|
|
134
135
|
if (blueprintConfig?.updatedAt) {
|
|
135
|
-
configRows.push(['Updated',
|
|
136
|
+
configRows.push(['Updated', formatDateTime(blueprintConfig.updatedAt)]);
|
|
136
137
|
}
|
|
137
138
|
if (token && env.SANITY_AUTH_TOKEN) {
|
|
138
139
|
configRows.push(['SANITY_AUTH_TOKEN', `*** ${styleText('dim', 'environment')}`]);
|
|
@@ -173,9 +174,7 @@ export async function blueprintDoctorCore(options) {
|
|
|
173
174
|
if (stack.recentOperation) {
|
|
174
175
|
const op = stack.recentOperation;
|
|
175
176
|
const time = op.completedAt || op.createdAt;
|
|
176
|
-
const timestamp = time
|
|
177
|
-
? ` ${styleText('dim', new Date(time).toLocaleString('sv-SE'))}`
|
|
178
|
-
: '';
|
|
177
|
+
const timestamp = time ? ` ${styleText('dim', formatDateTime(time))}` : '';
|
|
179
178
|
stackRows.push(['Operation', `${op.status}${timestamp}`]);
|
|
180
179
|
if (op.userMessage)
|
|
181
180
|
stackRows.push([' Message', `"${op.userMessage}"`]);
|
|
@@ -2,6 +2,7 @@ import { hostname } from 'node:os';
|
|
|
2
2
|
import { confirm, input, select } from '@inquirer/prompts';
|
|
3
3
|
import { createRobotToken } from '../../actions/sanity/access.js';
|
|
4
4
|
import { ClipboardUnavailableError, write as clipboardWrite } from '../../utils/clipboard.js';
|
|
5
|
+
import { formatDate, formatDateTime } from '../../utils/display/dates.js';
|
|
5
6
|
import { styleText } from '../../utils/style-text.js';
|
|
6
7
|
const ROLE_BY_SCOPE = {
|
|
7
8
|
project: 'blueprints-deployer',
|
|
@@ -12,7 +13,7 @@ export function isRoleUnavailableError(error) {
|
|
|
12
13
|
return /^\s*role not found\b/i.test(error);
|
|
13
14
|
}
|
|
14
15
|
export function defaultLabel(scopeType) {
|
|
15
|
-
const date = new Date()
|
|
16
|
+
const date = formatDate(new Date());
|
|
16
17
|
let host = 'unknown-host';
|
|
17
18
|
try {
|
|
18
19
|
host = hostname();
|
|
@@ -63,7 +64,7 @@ export async function blueprintMintDeployTokenCore(options) {
|
|
|
63
64
|
}
|
|
64
65
|
log(styleText('green', `Minted "${robot.label}" (${robot.id})`));
|
|
65
66
|
if (robot.expiresAt) {
|
|
66
|
-
log(styleText('dim', `Expires: ${robot.expiresAt}`));
|
|
67
|
+
log(styleText('dim', `Expires: ${formatDateTime(robot.expiresAt)}`));
|
|
67
68
|
}
|
|
68
69
|
const action = await select({
|
|
69
70
|
message: 'What would you like to do with the token?',
|
|
@@ -2,7 +2,7 @@ import { treeify } from 'array-treeify';
|
|
|
2
2
|
import { SANITY_ACCESS_ROBOT, SANITY_ACCESS_ROLE, SANITY_FUNCTION_DOCUMENT, SANITY_FUNCTION_MEDIA_LIBRARY_ASSET, SANITY_FUNCTION_SCHEDULED, SANITY_FUNCTION_SYNC_TAG_INVALIDATE, SANITY_PROJECT, SANITY_PROJECT_CORS, SANITY_PROJECT_DATASET, SANITY_PROJECT_WEBHOOK, } from '../../constants.js';
|
|
3
3
|
import { styleText } from '../style-text.js';
|
|
4
4
|
import { isCorsOriginResource, isDatasetResource, isRobotResource, isRoleResource, isWebhookResource, } from '../types.js';
|
|
5
|
-
import {
|
|
5
|
+
import { formatDateTime, formatDuration } from './dates.js';
|
|
6
6
|
import { capitalize, niceId, renderSection } from './presenters.js';
|
|
7
7
|
import { arrayifyCors, arrayifyDataset, arrayifyFunction, arrayifyRobot, arrayifyRole, arrayifyWebhook, } from './resources-formatting.js';
|
|
8
8
|
const functionCategory = {
|
|
@@ -183,16 +183,16 @@ export function formatStackInfo(stack, isCurrentStack = false) {
|
|
|
183
183
|
rows.push(['Resources', `${count ?? 0}`]);
|
|
184
184
|
}
|
|
185
185
|
if (stack.createdAt)
|
|
186
|
-
rows.push(['Created',
|
|
186
|
+
rows.push(['Created', formatDateTime(stack.createdAt)]);
|
|
187
187
|
if (stack.updatedAt)
|
|
188
|
-
rows.push(['Updated',
|
|
188
|
+
rows.push(['Updated', formatDateTime(stack.updatedAt)]);
|
|
189
189
|
if (stack.recentOperation) {
|
|
190
190
|
const op = stack.recentOperation;
|
|
191
191
|
const color = op.status === 'COMPLETED' ? 'green' : 'red';
|
|
192
192
|
const parts = [styleText(color, op.status || 'UNKNOWN')];
|
|
193
193
|
const time = op.completedAt || op.createdAt;
|
|
194
194
|
if (time)
|
|
195
|
-
parts.push(styleText('dim',
|
|
195
|
+
parts.push(styleText('dim', formatDateTime(time)));
|
|
196
196
|
if (op.completedAt && op.createdAt) {
|
|
197
197
|
parts.push(styleText('yellow', `(${formatDuration(op.createdAt, op.completedAt)})`));
|
|
198
198
|
}
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
type DateInput = string | number | Date;
|
|
2
|
+
export declare function formatDate(input: DateInput): string;
|
|
3
|
+
export declare function formatTime(input: DateInput): string;
|
|
4
|
+
export declare function formatDateTime(input: DateInput): string;
|
|
2
5
|
export declare function formatDuration(startDate: string, endDate: string): string;
|
|
6
|
+
export {};
|
|
@@ -1,5 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
return new Date(
|
|
1
|
+
function toDate(input) {
|
|
2
|
+
return input instanceof Date ? input : new Date(input);
|
|
3
|
+
}
|
|
4
|
+
export function formatDate(input) {
|
|
5
|
+
const d = toDate(input);
|
|
6
|
+
if (Number.isNaN(d.getTime()))
|
|
7
|
+
return '';
|
|
8
|
+
const y = d.getFullYear();
|
|
9
|
+
const m = String(d.getMonth() + 1).padStart(2, '0');
|
|
10
|
+
const day = String(d.getDate()).padStart(2, '0');
|
|
11
|
+
return `${y}-${m}-${day}`;
|
|
12
|
+
}
|
|
13
|
+
export function formatTime(input) {
|
|
14
|
+
const d = toDate(input);
|
|
15
|
+
if (Number.isNaN(d.getTime()))
|
|
16
|
+
return '';
|
|
17
|
+
const h = String(d.getHours()).padStart(2, '0');
|
|
18
|
+
const m = String(d.getMinutes()).padStart(2, '0');
|
|
19
|
+
const s = String(d.getSeconds()).padStart(2, '0');
|
|
20
|
+
return `${h}:${m}:${s}`;
|
|
21
|
+
}
|
|
22
|
+
export function formatDateTime(input) {
|
|
23
|
+
const d = toDate(input);
|
|
24
|
+
if (Number.isNaN(d.getTime()))
|
|
25
|
+
return '';
|
|
26
|
+
return `${formatDate(d)} ${formatTime(d)}`;
|
|
3
27
|
}
|
|
4
28
|
export function formatDuration(startDate, endDate) {
|
|
5
29
|
const start = new Date(startDate).getTime();
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { styleText } from '../style-text.js';
|
|
2
|
+
import { formatDate, formatTime } from './dates.js';
|
|
2
3
|
import { niceId } from './presenters.js';
|
|
3
4
|
const errorStyle = ['bold', 'red'];
|
|
4
5
|
const newOperationStyle = ['bold', 'blue'];
|
|
@@ -44,18 +45,6 @@ function formatMetadataLines(log) {
|
|
|
44
45
|
function singleLine(message) {
|
|
45
46
|
return message.replace(/\n/g, ' ').replace(/\s{2,}/g, ' ');
|
|
46
47
|
}
|
|
47
|
-
function formatDate(date) {
|
|
48
|
-
const y = date.getFullYear();
|
|
49
|
-
const m = String(date.getMonth() + 1).padStart(2, '0');
|
|
50
|
-
const d = String(date.getDate()).padStart(2, '0');
|
|
51
|
-
return `${y}-${m}-${d}`;
|
|
52
|
-
}
|
|
53
|
-
function formatTime(date) {
|
|
54
|
-
const h = String(date.getHours()).padStart(2, '0');
|
|
55
|
-
const m = String(date.getMinutes()).padStart(2, '0');
|
|
56
|
-
const s = String(date.getSeconds()).padStart(2, '0');
|
|
57
|
-
return `${h}:${m}:${s}`;
|
|
58
|
-
}
|
|
59
48
|
export function formatLogEntry(log, verbose = false, previousLog) {
|
|
60
49
|
const date = new Date(log.timestamp);
|
|
61
50
|
const time = formatTime(date);
|
package/oclif.manifest.json
CHANGED