@shortcut-cli/shortcut-cli 3.3.0 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +102 -73
- package/build/_virtual/rolldown_runtime.js +25 -0
- package/build/bin/short-api.js +78 -0
- package/build/bin/short-create.js +52 -147
- package/build/bin/short-epics.js +32 -111
- package/build/bin/short-find.js +6 -5
- package/build/bin/short-install.js +38 -128
- package/build/bin/short-members.js +29 -81
- package/build/bin/short-projects.js +29 -84
- package/build/bin/short-search.js +49 -134
- package/build/bin/short-story.js +200 -363
- package/build/bin/short-workflows.js +26 -74
- package/build/bin/short-workspace.js +62 -127
- package/build/bin/short.js +9 -30
- package/build/lib/client.js +12 -8
- package/build/lib/configure.js +95 -105
- package/build/lib/spinner.js +16 -13
- package/build/lib/stories.js +302 -496
- package/build/package.js +18 -0
- package/package.json +30 -28
- package/build/tsconfig.tsbuildinfo +0 -1
package/README.md
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
1
|
-
# shortcut-cli
|
|
1
|
+
# shortcut-cli
|
|
2
2
|
|
|
3
|
-
[](https://badge.fury.io/js/@shortcut-cli%2Fshortcut-cli)
|
|
4
|
+
[](https://github.com/shortcut-cli/shortcut-cli/blob/main/LICENSE)
|
|
5
|
+
[]()
|
|
4
6
|
|
|
5
|
-
This is a command line interface for [Shortcut](https://
|
|
7
|
+
This is a community-driven command line interface for [Shortcut](https://shortcut.com), focused on the display and manipulation of stories. With this, you can run custom searches, save them as local workspaces, and recall those workspaces. You can also view full stories, update most attributes on a story, and create brand new stories quickly.
|
|
6
8
|
|
|
7
9
|
## Table of Contents
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
10
|
+
|
|
11
|
+
- [Usage & Commands](#usage)
|
|
12
|
+
- [Install](#install)
|
|
13
|
+
- [Search](#search)
|
|
14
|
+
- [Story](#story)
|
|
15
|
+
- [Story Creation](#story-creation)
|
|
16
|
+
- [Workspace](#workspace)
|
|
17
|
+
- [Members](#members)
|
|
18
|
+
- [Epics](#epics)
|
|
19
|
+
- [Workflows](#workflows)
|
|
20
|
+
- [Projects](#projects)
|
|
21
|
+
- [API](#api)
|
|
22
|
+
- [Development](#development)
|
|
23
|
+
- [Acknowledgments](#acknowledgments)
|
|
20
24
|
|
|
21
25
|
## Usage
|
|
22
26
|
|
|
@@ -24,12 +28,12 @@ This is a command line interface for [Shortcut](https://app.shortcut.com), focus
|
|
|
24
28
|
|
|
25
29
|
Install via npm:
|
|
26
30
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
```sh
|
|
32
|
+
npm install @shortcut-cli/shortcut-cli -g
|
|
33
|
+
short install
|
|
34
|
+
```
|
|
31
35
|
|
|
32
|
-
|
|
36
|
+
```
|
|
33
37
|
Usage: short install [options]
|
|
34
38
|
|
|
35
39
|
Install access token for Shortcut API
|
|
@@ -40,13 +44,15 @@ $ short install
|
|
|
40
44
|
-V, --version output the version number
|
|
41
45
|
-f, --force Force install/reinstall
|
|
42
46
|
-h, --help output usage information
|
|
43
|
-
|
|
47
|
+
```
|
|
44
48
|
|
|
45
49
|
You may also provide a Shortcut API token via environment variable `SHORTCUT_API_TOKEN`.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
SHORTCUT_API_TOKEN=foobar short story 3300
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
```
|
|
50
56
|
Usage: short [options] [command]
|
|
51
57
|
|
|
52
58
|
A command line tool for searching, viewing, and updating shortcut.com stories
|
|
@@ -69,15 +75,16 @@ $ SHORTCUT_API_TOKEN=foobar short story 3300
|
|
|
69
75
|
epics list epics and their states
|
|
70
76
|
projects list or search projects
|
|
71
77
|
workspace list stories matching saved workspace query
|
|
78
|
+
api make a request to the Shortcut API
|
|
72
79
|
help [cmd] display help for [cmd]
|
|
73
|
-
|
|
80
|
+
```
|
|
74
81
|
|
|
75
82
|
### Search
|
|
76
83
|
|
|
77
|
-
|
|
84
|
+
```
|
|
78
85
|
Usage: short find [options] [SEARCH OPERATORS]
|
|
79
86
|
|
|
80
|
-
Search through
|
|
87
|
+
Search through Shortcut stories. Arguments (non-flag/options) will
|
|
81
88
|
be passed to Shortcut story search API as search operators. Passing '%self%' as
|
|
82
89
|
a search operator argument will be replaced by your mention name. Note that passing search
|
|
83
90
|
operators and options (e.g. --owner foobar) will use the options as extra filtering
|
|
@@ -106,12 +113,12 @@ $ SHORTCUT_API_TOKEN=foobar short story 3300
|
|
|
106
113
|
-r, --sort [field] Sort stories by field (accessor[:asc|desc][,next])
|
|
107
114
|
-f, --format [template] Format each story output by template
|
|
108
115
|
-h, --help output usage information
|
|
109
|
-
|
|
116
|
+
```
|
|
110
117
|
|
|
111
118
|
Example output
|
|
112
119
|
|
|
113
|
-
|
|
114
|
-
|
|
120
|
+
```
|
|
121
|
+
short search -o 'josh' -s 'Review'
|
|
115
122
|
#1480 Create Thinga-ma-bob
|
|
116
123
|
Type: feature/3
|
|
117
124
|
Label: #512 client_web
|
|
@@ -123,16 +130,16 @@ $ short search -o 'josh' -s 'Review'
|
|
|
123
130
|
URL: https://app.shortcut.com/story/1480
|
|
124
131
|
|
|
125
132
|
# Custom formatting is an option
|
|
126
|
-
|
|
133
|
+
short search -o 'josh' -s 'Review' -f $'%i\t%s\t%t\n\t%o'
|
|
127
134
|
1480 Code Review (#500000020) Create Thinga-ma-bob
|
|
128
135
|
Josh (josh)
|
|
129
|
-
|
|
136
|
+
```
|
|
130
137
|
|
|
131
138
|
#### Story Output Formatting
|
|
132
139
|
|
|
133
140
|
Templating variables:
|
|
134
141
|
|
|
135
|
-
|
|
142
|
+
```
|
|
136
143
|
%id Print ID of story
|
|
137
144
|
%t Print title/name of story
|
|
138
145
|
%a Print archived status of story
|
|
@@ -151,8 +158,8 @@ Templating variables:
|
|
|
151
158
|
%updated Print story updated timestamp (if different from created)
|
|
152
159
|
%j Print full story as formatted JSON
|
|
153
160
|
%gb Print Git integration branch name
|
|
154
|
-
%gbs
|
|
155
|
-
|
|
161
|
+
%gbs Print Git integration branch short name
|
|
162
|
+
```
|
|
156
163
|
|
|
157
164
|
Note that the `$` string operator in bash is helpful in allowing `\t` (tab) and `\n` (newline) literals in the formatting string. Otherwise, you can actually just type a newline character.
|
|
158
165
|
|
|
@@ -162,7 +169,7 @@ The default sorting for stories found is `state.position:asc,position:asc`, whic
|
|
|
162
169
|
|
|
163
170
|
### Story
|
|
164
171
|
|
|
165
|
-
|
|
172
|
+
```
|
|
166
173
|
Usage: short story [options] <id>
|
|
167
174
|
|
|
168
175
|
Update and/or display story details
|
|
@@ -200,12 +207,12 @@ The default sorting for stories found is `state.position:asc,position:asc`, whic
|
|
|
200
207
|
--task-complete [text] Toggle completion of story task matching text
|
|
201
208
|
-y, --type [name] Set type of story
|
|
202
209
|
-h, --help output usage information
|
|
203
|
-
|
|
210
|
+
```
|
|
204
211
|
|
|
205
212
|
Example output:
|
|
206
213
|
|
|
207
|
-
|
|
208
|
-
|
|
214
|
+
```
|
|
215
|
+
short story 1480 -c 'This is a commend' -o josh
|
|
209
216
|
#1480 Create Thinga-ma-bob
|
|
210
217
|
Desc: Create a thing to display:
|
|
211
218
|
Owners: Josh (josh)
|
|
@@ -214,13 +221,13 @@ Label: #512 client_web
|
|
|
214
221
|
Project: #14 Customer
|
|
215
222
|
State: #500000020 Code Review
|
|
216
223
|
URL: https://app.shortcut.com/story/1480
|
|
217
|
-
Comment: This is a
|
|
224
|
+
Comment: This is a comment
|
|
218
225
|
Josh at: 2017-10-25T16:17:04Z
|
|
219
|
-
|
|
226
|
+
```
|
|
220
227
|
|
|
221
228
|
### Story Creation
|
|
222
229
|
|
|
223
|
-
|
|
230
|
+
```
|
|
224
231
|
Usage: short create [options]
|
|
225
232
|
|
|
226
233
|
create a story with provided details
|
|
@@ -245,11 +252,11 @@ Comment: This is a commend
|
|
|
245
252
|
--git-branch Checkout git branch from story slug <mention-name>/ch<id>/<type>-<title>
|
|
246
253
|
as required by the Git integration: https://bit.ly/2RKO1FF
|
|
247
254
|
--git-branch-short Checkout git branch from story slug <mention-name>/ch<id>/<title>
|
|
248
|
-
|
|
255
|
+
```
|
|
249
256
|
|
|
250
257
|
### Workspace
|
|
251
258
|
|
|
252
|
-
|
|
259
|
+
```
|
|
253
260
|
Usage: short workspace [NAME] [options]
|
|
254
261
|
|
|
255
262
|
List stories matching saved workspace query
|
|
@@ -262,11 +269,11 @@ Comment: This is a commend
|
|
|
262
269
|
-u, --unset [name] Force unset saved workspace
|
|
263
270
|
-q, --quiet Print only resulting story output, no loading dialog
|
|
264
271
|
-h, --help output usage information
|
|
265
|
-
|
|
272
|
+
```
|
|
266
273
|
|
|
267
274
|
### Members
|
|
268
275
|
|
|
269
|
-
|
|
276
|
+
```
|
|
270
277
|
Usage: short members [options]
|
|
271
278
|
|
|
272
279
|
Display members available for stories
|
|
@@ -277,11 +284,11 @@ Comment: This is a commend
|
|
|
277
284
|
-s, --search [query] List members with name containing query
|
|
278
285
|
-d, --disabled List members including disabled
|
|
279
286
|
-h, --help output usage information
|
|
280
|
-
|
|
287
|
+
```
|
|
281
288
|
|
|
282
289
|
### Epics
|
|
283
290
|
|
|
284
|
-
|
|
291
|
+
```
|
|
285
292
|
Usage: short epics [options]
|
|
286
293
|
|
|
287
294
|
Display epics available for stories
|
|
@@ -297,13 +304,13 @@ Comment: This is a commend
|
|
|
297
304
|
-t, --title [query] List epics with name/title containing query
|
|
298
305
|
-s, --started List epics that have been started
|
|
299
306
|
-h, --help output usage information
|
|
300
|
-
|
|
307
|
+
```
|
|
301
308
|
|
|
302
309
|
#### Epic Output Formatting
|
|
303
310
|
|
|
304
311
|
Templating variables:
|
|
305
312
|
|
|
306
|
-
|
|
313
|
+
```
|
|
307
314
|
%id Print ID of epic
|
|
308
315
|
%t Print title/name of epic
|
|
309
316
|
%m Print milestone of epic
|
|
@@ -317,11 +324,11 @@ Templating variables:
|
|
|
317
324
|
%a Print archived status of epic
|
|
318
325
|
%st Print started status of epic
|
|
319
326
|
%co Print completed status of epic
|
|
320
|
-
|
|
327
|
+
```
|
|
321
328
|
|
|
322
329
|
### Workflows
|
|
323
330
|
|
|
324
|
-
|
|
331
|
+
```
|
|
325
332
|
Usage: short workflows [options]
|
|
326
333
|
|
|
327
334
|
Display workflows/states available for stories
|
|
@@ -331,11 +338,11 @@ Templating variables:
|
|
|
331
338
|
|
|
332
339
|
-s, --search [query] List states containing query
|
|
333
340
|
-h, --help output usage information
|
|
334
|
-
|
|
341
|
+
```
|
|
335
342
|
|
|
336
343
|
### Projects
|
|
337
344
|
|
|
338
|
-
|
|
345
|
+
```
|
|
339
346
|
Usage: short projects [options]
|
|
340
347
|
|
|
341
348
|
Display projects available for stories
|
|
@@ -347,33 +354,55 @@ Templating variables:
|
|
|
347
354
|
-d, --detailed List more details for each project
|
|
348
355
|
-t, --title [query] List projects with name/title containing query
|
|
349
356
|
-h, --help output usage information
|
|
350
|
-
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
### API
|
|
360
|
+
|
|
361
|
+
```
|
|
362
|
+
Usage: short api <path> [options]
|
|
363
|
+
|
|
364
|
+
Make a request to the Shortcut API.
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
Options:
|
|
368
|
+
|
|
369
|
+
-X, --method <method> The HTTP method to use. (default: "GET")
|
|
370
|
+
-H, --header <header> Add a header to the request (e.g., "Content-Type: application/json"). Can be specified multiple times.
|
|
371
|
+
-f, --raw-field <key=value> Add a string parameter. Can be specified multiple times.
|
|
372
|
+
-h, --help output usage information
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
Examples:
|
|
376
|
+
$ short api /search/iterations -f page_size=10 -f query=123
|
|
377
|
+
$ short api /stories -X POST -f 'name=My new story' -f project_id=123
|
|
378
|
+
# jq can be used to shorten the response output.
|
|
379
|
+
$ short api /search/iterations -f page_size=10 -f query=123 | jq '.data[] | {id, name}'
|
|
380
|
+
```
|
|
351
381
|
|
|
352
382
|
## Development
|
|
353
383
|
|
|
354
|
-
You can use
|
|
384
|
+
You can use TypeScript watcher which will recompile your code automatically:
|
|
355
385
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
386
|
+
```sh
|
|
387
|
+
npm run build:watch
|
|
388
|
+
```
|
|
359
389
|
|
|
360
|
-
You can run shortcut-cli with
|
|
390
|
+
You can run shortcut-cli with TypeScript map enabled:
|
|
361
391
|
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
392
|
+
```sh
|
|
393
|
+
npm start -- story 1234
|
|
394
|
+
```
|
|
365
395
|
|
|
366
396
|
## Acknowledgments
|
|
367
397
|
|
|
368
|
-
-
|
|
369
|
-
-
|
|
370
|
-
-
|
|
371
|
-
-
|
|
398
|
+
- [Repository for this code](https://github.com/shortcut-cli/shortcut-cli)
|
|
399
|
+
- [NPM registry for this code](https://www.npmjs.com/package/@shortcut-cli/shortcut-cli)
|
|
400
|
+
- [Shortcut API](https://shortcut.com/api/rest/v3)
|
|
401
|
+
- Official [@shortcut/client](https://github.com/useshortcut/shortcut-client-js)
|
|
402
|
+
- [joshbeckman](https://github.com/joshbeckman), [j-martin](https://github.com/j-martin), [joshmfrankel](https://github.com/joshmfrankel), and [ohe](https://github.com/ohe) who created and contributed to this project
|
|
372
403
|
|
|
373
404
|
## Contributors
|
|
374
|
-
- [andjosh](https://github.com/andjosh)
|
|
375
|
-
- [j-martin](https://github.com/j-martin)
|
|
376
|
-
- [joshmfrankel](https://github.com/joshmfrankel)
|
|
377
|
-
- [ohe](https://github.com/ohe)
|
|
378
405
|
|
|
379
|
-
|
|
406
|
+
<a href="https://github.com/shortcut-cli/shortcut-cli/graphs/contributors">
|
|
407
|
+
<img src="https://contrib.rocks/image?repo=shortcut-cli/shortcut-cli" />
|
|
408
|
+
</a>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
|
|
25
|
+
exports.__toESM = __toESM;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
2
|
+
const require_lib_spinner = require('../lib/spinner.js');
|
|
3
|
+
const require_lib_client = require('../lib/client.js');
|
|
4
|
+
const commander = require_rolldown_runtime.__toESM(require("commander"));
|
|
5
|
+
const debug = require_rolldown_runtime.__toESM(require("debug"));
|
|
6
|
+
|
|
7
|
+
//#region src/bin/short-api.ts
|
|
8
|
+
const debug$1 = (0, debug.default)("short-api");
|
|
9
|
+
const log = console.log;
|
|
10
|
+
const logError = console.error;
|
|
11
|
+
const spin = require_lib_spinner.default();
|
|
12
|
+
const parseKeyVal = (input, separator = "=") => {
|
|
13
|
+
const parts = input.split(separator);
|
|
14
|
+
const key = parts.shift();
|
|
15
|
+
const value = parts.join(separator);
|
|
16
|
+
return [key, value];
|
|
17
|
+
};
|
|
18
|
+
const collect = (val, memo) => {
|
|
19
|
+
memo.push(val);
|
|
20
|
+
return memo;
|
|
21
|
+
};
|
|
22
|
+
const program = commander.default.description("Make a request to the Shortcut API.").arguments("<path>").option("-X, --method <method>", "The HTTP method to use.", "GET").option("-H, --header <header>", "Add a header to the request (e.g., \"Content-Type: application/json\"). Can be specified multiple times.", collect, []).option("-f, --raw-field <key=value>", "Add a string parameter. Can be specified multiple times.", collect, []).on("--help", () => {
|
|
23
|
+
log("");
|
|
24
|
+
log("Examples:");
|
|
25
|
+
log(` $ short api /search/iterations -f page_size=10 -f query=123`);
|
|
26
|
+
log(` $ short api /stories -X POST -f 'name=My new story' -f project_id=123`);
|
|
27
|
+
log(" # jq can be used to shorten the response output.");
|
|
28
|
+
log(` $ short api /search/iterations -f page_size=10 -f query=123 | jq '.data[] | {id, name}'`);
|
|
29
|
+
}).parse(process.argv);
|
|
30
|
+
const main = async () => {
|
|
31
|
+
const [path] = program.args;
|
|
32
|
+
if (!path) {
|
|
33
|
+
logError("Error path argument is required");
|
|
34
|
+
program.help();
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
const method = (program.method || "GET").toUpperCase();
|
|
38
|
+
const headers = {};
|
|
39
|
+
const params = {};
|
|
40
|
+
if (program.header) program.header.forEach((h) => {
|
|
41
|
+
const [key, value] = parseKeyVal(h, ":");
|
|
42
|
+
headers[key] = value;
|
|
43
|
+
debug$1(`adding header: ${key}: ${value}`);
|
|
44
|
+
});
|
|
45
|
+
if (program.rawField) program.rawField.forEach((f) => {
|
|
46
|
+
const [key, value] = parseKeyVal(f);
|
|
47
|
+
params[key] = value;
|
|
48
|
+
debug$1(`adding raw field: ${key}: ${value}`);
|
|
49
|
+
});
|
|
50
|
+
const requestOptions = {
|
|
51
|
+
path: "/api/v3" + (path.startsWith("/") ? "" : "/") + path,
|
|
52
|
+
method,
|
|
53
|
+
headers
|
|
54
|
+
};
|
|
55
|
+
const bodyMethods = [
|
|
56
|
+
"POST",
|
|
57
|
+
"PUT",
|
|
58
|
+
"PATCH"
|
|
59
|
+
];
|
|
60
|
+
if (bodyMethods.includes(method)) {
|
|
61
|
+
requestOptions.body = params;
|
|
62
|
+
if (!headers["Content-Type"]) headers["Content-Type"] = "application/json";
|
|
63
|
+
} else requestOptions.query = params;
|
|
64
|
+
try {
|
|
65
|
+
debug$1("request options:", requestOptions);
|
|
66
|
+
spin.start();
|
|
67
|
+
const response = await require_lib_client.default.request(requestOptions);
|
|
68
|
+
spin.stop(true);
|
|
69
|
+
log(JSON.stringify(response.data, null, 2));
|
|
70
|
+
} catch (err) {
|
|
71
|
+
spin.stop(true);
|
|
72
|
+
logError("Error calling API:", err.response ? JSON.stringify(err.response.data, null, 2) : err.message);
|
|
73
|
+
process.exit(1);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
main();
|
|
77
|
+
|
|
78
|
+
//#endregion
|
|
@@ -1,150 +1,55 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
3
|
+
const require_lib_spinner = require('../lib/spinner.js');
|
|
4
|
+
const require_lib_configure = require('../lib/configure.js');
|
|
5
|
+
const require_lib_client = require('../lib/client.js');
|
|
6
|
+
const require_lib_stories = require('../lib/stories.js');
|
|
7
|
+
const commander = require_rolldown_runtime.__toESM(require("commander"));
|
|
8
|
+
const child_process = require_rolldown_runtime.__toESM(require("child_process"));
|
|
9
|
+
|
|
10
|
+
//#region src/bin/short-create.ts
|
|
11
|
+
const config = require_lib_configure.loadConfig();
|
|
12
|
+
const spin = require_lib_spinner.default();
|
|
13
|
+
const log = console.log;
|
|
14
|
+
const program = commander.default.usage("[options]").description("create a story with provided details").option("-d, --description [text]", "Set description of story", "").option("-e, --estimate [number]", "Set estimate of story").option("--epic [id|name]", "Set epic of story").option("--git-branch", "Checkout git branch from story slug <mention-name>/ch<id>/<type>-<title>\n as required by the Git integration: https://bit.ly/2RKO1FF").option("--git-branch-short", "Checkout git branch from story slug <mention-name>/ch<id>/<title>").option("-i, --iteration [id|name]", "Set iteration of story").option("-I, --idonly", "Print only ID of story result").option("-l, --label [id|name]", "Stories with label id/name, by regex", "").option("-o, --owners [id|name]", "Set owners of story, comma-separated", "").option("-O, --open", "Open story in browser").option("-p, --project [id|name]", "Set project of story, required if --state is not set", "").option("-T, --team [id|name]", "Set team of story", "").option("-t, --title [text]", "Set title of story, required", "").option("-s, --state [id|name]", "Set workflow state of story, required if --project is not set", "").option("-y, --type [name]", "Set type of story, default: feature", "feature").parse(process.argv);
|
|
15
|
+
const main = async () => {
|
|
16
|
+
const entities = await require_lib_stories.default.fetchEntities();
|
|
17
|
+
if (!program.idonly) spin.start();
|
|
18
|
+
const update = {
|
|
19
|
+
name: program.title,
|
|
20
|
+
story_type: program.type,
|
|
21
|
+
description: `${program.description}`,
|
|
22
|
+
estimate: program.estimate || void 0
|
|
23
|
+
};
|
|
24
|
+
if (program.project) update.project_id = (require_lib_stories.default.findProject(entities, program.project) || {}).id;
|
|
25
|
+
if (program.team) update.group_id = (require_lib_stories.default.findGroup(entities, program.team) || {}).id;
|
|
26
|
+
if (program.state) update.workflow_state_id = (require_lib_stories.default.findState(entities, program.state) || {}).id;
|
|
27
|
+
if (program.epic) update.epic_id = (require_lib_stories.default.findEpic(entities, program.epic) || {}).id;
|
|
28
|
+
if (program.iteration) update.iteration_id = (require_lib_stories.default.findIteration(entities, program.iteration) || {}).id;
|
|
29
|
+
if (program.estimate) update.estimate = parseInt(program.estimate, 10);
|
|
30
|
+
if (program.owners) update.owner_ids = require_lib_stories.default.findOwnerIds(entities, program.owners);
|
|
31
|
+
if (program.label) update.labels = require_lib_stories.default.findLabelNames(entities, program.label);
|
|
32
|
+
let story;
|
|
33
|
+
if (!update.name) {
|
|
34
|
+
if (!program.idonly) spin.stop(true);
|
|
35
|
+
log("Must provide --title");
|
|
36
|
+
} else if (!update.project_id && !update.workflow_state_id) {
|
|
37
|
+
if (!program.idonly) spin.stop(true);
|
|
38
|
+
log("Must provide --project or --state");
|
|
39
|
+
} else try {
|
|
40
|
+
story = await require_lib_client.default.createStory(update).then((r) => r.data);
|
|
41
|
+
} catch (e) {
|
|
42
|
+
log("Error creating story");
|
|
43
|
+
}
|
|
44
|
+
if (!program.idonly) spin.stop(true);
|
|
45
|
+
if (story) {
|
|
46
|
+
const hydrateStory = require_lib_stories.default.hydrateStory(entities, story);
|
|
47
|
+
require_lib_stories.default.printDetailedStory(hydrateStory);
|
|
48
|
+
if (program.gitBranch) require_lib_stories.default.checkoutStoryBranch(hydrateStory);
|
|
49
|
+
else if (program.gitBranchShort) require_lib_stories.default.checkoutStoryBranch(hydrateStory, `${config.mentionName}/sc-${story.id}/`);
|
|
50
|
+
if (program.open) (0, child_process.exec)("open " + require_lib_stories.default.storyURL(story));
|
|
51
|
+
}
|
|
11
52
|
};
|
|
12
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
13
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
14
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
15
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
16
|
-
function step(op) {
|
|
17
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
18
|
-
while (_) try {
|
|
19
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
20
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
21
|
-
switch (op[0]) {
|
|
22
|
-
case 0: case 1: t = op; break;
|
|
23
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
24
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
25
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
26
|
-
default:
|
|
27
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
28
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
29
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
30
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
31
|
-
if (t[2]) _.ops.pop();
|
|
32
|
-
_.trys.pop(); continue;
|
|
33
|
-
}
|
|
34
|
-
op = body.call(thisArg, _);
|
|
35
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
36
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
var stories_1 = require("../lib/stories");
|
|
41
|
-
var child_process_1 = require("child_process");
|
|
42
|
-
var client_1 = require("../lib/client");
|
|
43
|
-
var spinner_1 = require("../lib/spinner");
|
|
44
|
-
var commander = require("commander");
|
|
45
|
-
var configure_1 = require("../lib/configure");
|
|
46
|
-
var config = (0, configure_1.loadConfig)();
|
|
47
|
-
var spin = (0, spinner_1.default)();
|
|
48
|
-
var log = console.log;
|
|
49
|
-
var program = commander
|
|
50
|
-
.usage('[options]')
|
|
51
|
-
.description('create a story with provided details')
|
|
52
|
-
.option('-d, --description [text]', 'Set description of story', '')
|
|
53
|
-
.option('-e, --estimate [number]', 'Set estimate of story')
|
|
54
|
-
.option('--epic [id|name]', 'Set epic of story')
|
|
55
|
-
.option('--git-branch', 'Checkout git branch from story slug <mention-name>/ch<id>/<type>-<title>\n' +
|
|
56
|
-
'\t\t\t\tas required by the Git integration: https://bit.ly/2RKO1FF')
|
|
57
|
-
.option('--git-branch-short', 'Checkout git branch from story slug <mention-name>/ch<id>/<title>')
|
|
58
|
-
.option('-i, --iteration [id|name]', 'Set iteration of story')
|
|
59
|
-
.option('-I, --idonly', 'Print only ID of story result')
|
|
60
|
-
.option('-l, --label [id|name]', 'Stories with label id/name, by regex', '')
|
|
61
|
-
.option('-o, --owners [id|name]', 'Set owners of story, comma-separated', '')
|
|
62
|
-
.option('-O, --open', 'Open story in browser')
|
|
63
|
-
.option('-p, --project [id|name]', 'Set project of story, required if --state is not set', '')
|
|
64
|
-
.option('-T, --team [id|name]', 'Set team of story', '')
|
|
65
|
-
.option('-t, --title [text]', 'Set title of story, required', '')
|
|
66
|
-
.option('-s, --state [id|name]', 'Set workflow state of story, required if --project is not set', '')
|
|
67
|
-
.option('-y, --type [name]', 'Set type of story, default: feature', 'feature')
|
|
68
|
-
.parse(process.argv);
|
|
69
|
-
var main = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
70
|
-
var entities, update, story, e_1, hydrateStory;
|
|
71
|
-
return __generator(this, function (_a) {
|
|
72
|
-
switch (_a.label) {
|
|
73
|
-
case 0: return [4, stories_1.default.fetchEntities()];
|
|
74
|
-
case 1:
|
|
75
|
-
entities = _a.sent();
|
|
76
|
-
if (!program.idonly)
|
|
77
|
-
spin.start();
|
|
78
|
-
update = {
|
|
79
|
-
name: program.title,
|
|
80
|
-
story_type: program.type,
|
|
81
|
-
description: "" + program.description,
|
|
82
|
-
estimate: program.estimate || undefined,
|
|
83
|
-
};
|
|
84
|
-
if (program.project) {
|
|
85
|
-
update.project_id = (stories_1.default.findProject(entities, program.project) || {}).id;
|
|
86
|
-
}
|
|
87
|
-
if (program.team) {
|
|
88
|
-
update.group_id = (stories_1.default.findGroup(entities, program.team) || {}).id;
|
|
89
|
-
}
|
|
90
|
-
if (program.state) {
|
|
91
|
-
update.workflow_state_id = (stories_1.default.findState(entities, program.state) || {}).id;
|
|
92
|
-
}
|
|
93
|
-
if (program.epic) {
|
|
94
|
-
update.epic_id = (stories_1.default.findEpic(entities, program.epic) || {}).id;
|
|
95
|
-
}
|
|
96
|
-
if (program.iteration) {
|
|
97
|
-
update.iteration_id = (stories_1.default.findIteration(entities, program.iteration) || {}).id;
|
|
98
|
-
}
|
|
99
|
-
if (program.estimate) {
|
|
100
|
-
update.estimate = parseInt(program.estimate, 10);
|
|
101
|
-
}
|
|
102
|
-
if (program.owners) {
|
|
103
|
-
update.owner_ids = stories_1.default.findOwnerIds(entities, program.owners);
|
|
104
|
-
}
|
|
105
|
-
if (program.label) {
|
|
106
|
-
update.labels = stories_1.default.findLabelNames(entities, program.label);
|
|
107
|
-
}
|
|
108
|
-
if (!!update.name) return [3, 2];
|
|
109
|
-
if (!program.idonly)
|
|
110
|
-
spin.stop(true);
|
|
111
|
-
log('Must provide --title');
|
|
112
|
-
return [3, 6];
|
|
113
|
-
case 2:
|
|
114
|
-
if (!(!update.project_id && !update.workflow_state_id)) return [3, 3];
|
|
115
|
-
if (!program.idonly)
|
|
116
|
-
spin.stop(true);
|
|
117
|
-
log('Must provide --project or --state');
|
|
118
|
-
return [3, 6];
|
|
119
|
-
case 3:
|
|
120
|
-
_a.trys.push([3, 5, , 6]);
|
|
121
|
-
return [4, client_1.default.createStory(update).then(function (r) { return r.data; })];
|
|
122
|
-
case 4:
|
|
123
|
-
story = _a.sent();
|
|
124
|
-
return [3, 6];
|
|
125
|
-
case 5:
|
|
126
|
-
e_1 = _a.sent();
|
|
127
|
-
log('Error creating story');
|
|
128
|
-
return [3, 6];
|
|
129
|
-
case 6:
|
|
130
|
-
if (!program.idonly)
|
|
131
|
-
spin.stop(true);
|
|
132
|
-
if (story) {
|
|
133
|
-
hydrateStory = stories_1.default.hydrateStory(entities, story);
|
|
134
|
-
stories_1.default.printDetailedStory(hydrateStory);
|
|
135
|
-
if (program.gitBranch) {
|
|
136
|
-
stories_1.default.checkoutStoryBranch(hydrateStory);
|
|
137
|
-
}
|
|
138
|
-
else if (program.gitBranchShort) {
|
|
139
|
-
stories_1.default.checkoutStoryBranch(hydrateStory, config.mentionName + "/sc-" + story.id + "/");
|
|
140
|
-
}
|
|
141
|
-
if (program.open) {
|
|
142
|
-
(0, child_process_1.exec)('open ' + stories_1.default.storyURL(story));
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
return [2];
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
}); };
|
|
149
53
|
main();
|
|
150
|
-
|
|
54
|
+
|
|
55
|
+
//#endregion
|