costaff-workspace 0.1.3 → 0.1.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 CHANGED
@@ -1,182 +1,129 @@
1
1
  # costaff-workspace
2
2
 
3
+ [![npm](https://img.shields.io/npm/v/costaff-workspace?style=for-the-badge)](https://www.npmjs.com/package/costaff-workspace)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=for-the-badge)](https://opensource.org/licenses/MIT)
5
+
3
6
  **English** · [繁體中文](README.zh-TW.md)
4
7
 
5
- Turn a document you built on your own machine into a link you can send someone.
8
+ **The command-line tool for [CoStaff Workspace](https://workspace.costaffs.app).**
9
+ Publish a document you built locally and get back a link you can send. Fetch it
10
+ onto another machine, edit, publish again — the link never changes.
6
11
 
7
12
  Works with projects made using [open-doc](https://github.com/simonliu-ai-product/open-doc)
8
13
  (documents), open-slide (decks) and open-sheet (workbooks).
9
14
 
10
- ---
11
-
12
- ## 1. Install it
13
-
14
- You need [Node.js](https://nodejs.org) 20 or newer. Check with `node -v`.
15
-
16
15
  ```bash
17
16
  npm i -g costaff-workspace
18
17
  ```
19
18
 
20
- Confirm it is there:
21
-
22
- ```bash
23
- costaff-workspace --help
24
- ```
25
-
26
- <details>
27
- <summary>If the command is not found</summary>
28
-
29
- Your shell cannot see where npm puts global commands. `npm prefix -g` prints
30
- that folder; add its `bin` to your `PATH`. With pnpm, run `pnpm setup` once.
31
- </details>
32
-
33
- ## 2. Build your project
34
-
35
- Publishing sends the **built** files, so build first.
36
-
37
- ```bash
38
- cd my-doc
39
- pnpm install
40
- pnpm build
41
- ```
42
-
43
- You should now have a `dist/` folder. If your project builds somewhere else,
44
- remember the name — you will pass it in step 3.
45
-
46
- ## 3. Push
47
-
48
- ```bash
49
- costaff-workspace push
50
- ```
19
+ ## Why
51
20
 
52
- ### The first time, it asks you to sign in
21
+ A built document is a folder of files, and sending someone a folder is not
22
+ sending them a document. Static hosting solves the delivery and loses everything
23
+ around it: who may read the file, what it is called, which version they are
24
+ looking at, and the source it was built from.
53
25
 
54
- ```
55
- Sign in to CoStaff Workspace
56
- open https://workspace.costaffs.app/activate?code=WXYZ-1234
57
- code WXYZ-1234
58
- ```
26
+ `costaff-workspace push` closes that gap in one command. What comes back is an
27
+ address, not a deployment.
59
28
 
60
- Open that address in a browser. **The code is already in the link**, so you only
61
- have to approve it. The command waits, then carries on by itself.
29
+ ## Highlights
62
30
 
63
- This machine stays signed in. You will not see this again.
31
+ ### 📤 One command, no configuration
64
32
 
65
- ### Then it publishes
33
+ Run it in a project folder. The slug comes from the folder name, the kind from
34
+ what `package.json` depends on, the bundle from `dist/`, the title from the
35
+ package description. **Every guess is printed**, and a guess it cannot make stops
36
+ the push rather than inventing something.
66
37
 
67
38
  ```
68
- 4 documents one bundle each
69
- getting-started → https://workspace.costaffs.app/dcuk0lmf875ctrgxfppa
70
- q3-numbers → https://workspace.costaffs.app/8fjq2ldk3nx7yrpv0aet
71
- team-offsite → https://workspace.costaffs.app/pv0aet8fjq2ldk3nx7yr
72
- budget-2027 → https://workspace.costaffs.app/3nx7yrpv0aet8fjq2ldk
39
+ guessed --slug q3-report --kind deck --source-dir .
73
40
  ```
74
41
 
75
- Those links are the files. Send one to someone and they can read it.
42
+ ### 🔗 Links that survive edits
76
43
 
77
- ## 4. Manage what you published
44
+ The address is settled before the build rather than assigned afterwards, and it
45
+ is remembered per file. Publish the same folder a year later and everyone holding
46
+ the old link sees the new version.
78
47
 
79
- Go to **<https://workspace.costaffs.app>** to rename files, put them in folders,
80
- and decide who may read each one.
48
+ ### ↩️ Editable from anywhere
81
49
 
82
- > **A newly pushed file is private.** Only you can open it until you say
83
- > otherwise in the file manager. Sending someone the link is not enough — you
84
- > invite them, or you turn the file into a public link, there.
50
+ A push carries the source. `costaff-workspace pull <token>` hands back a complete
51
+ project on any machine install, edit, publish, same link. Nothing is tied to
52
+ the computer that published it first.
85
53
 
86
- ---
54
+ ### 🔒 Private until you say otherwise
87
55
 
88
- ## Doing it again
56
+ A newly published file opens for its owner and nobody else. Readers are invited,
57
+ or the file is made a public link, in the file manager. Sending someone the
58
+ address is not enough on its own.
89
59
 
90
- **You changed something.** Build and push again. **The link stays the same** —
91
- whoever you sent it to sees the new version.
60
+ ### 📦 One bundle per document
92
61
 
93
- ```bash
94
- pnpm build && costaff-workspace push
95
- ```
62
+ A project holding several documents is built once per document. The alternative —
63
+ a single shared build lets anyone sent one document reach every other
64
+ document's assets. Isolation is the reason; the extra builds are the price.
96
65
 
97
- **You are on a different computer.** Fetch the project back with the token — the
98
- last part of the link:
66
+ ## Get started
99
67
 
100
68
  ```bash
101
- costaff-workspace pull dcuk0lmf875ctrgxfppa my-doc
102
69
  cd my-doc
103
- pnpm install
104
- ```
105
-
106
- What comes back is a complete project. Edit it, build it, push it, and the same
107
- link updates.
108
-
109
- **You want to check before publishing.** This packages everything and reports
110
- what it would send, without uploading and without needing a network:
111
-
112
- ```bash
113
- costaff-workspace push --dry-run
70
+ pnpm build # publishing sends the built files
71
+ costaff-workspace push
114
72
  ```
115
73
 
116
- ---
117
-
118
- ## You usually pass no options at all
119
-
120
- Run in a project folder, `push` works out the rest and **prints every guess**:
74
+ The first push prints a sign-in link with the code already in it. Approve it in a
75
+ browser: the command continues on its own, and the machine stays signed in.
121
76
 
122
77
  ```
123
- guessed --slug my-report --kind deck --source-dir .
78
+ 4 documents one bundle each
79
+ getting-started → https://workspace.costaffs.app/dcuk0lmf875ctrgxfppa
80
+ q3-numbers → https://workspace.costaffs.app/8fjq2ldk3nx7yrpv0aet
124
81
  ```
125
82
 
126
- | It guesses | From |
127
- | --- | --- |
128
- | the file's identity (`--slug`) | the folder's name |
129
- | document, deck or workbook (`--kind`) | what your `package.json` depends on |
130
- | the built files (`--site-dir`) | `dist` |
131
- | the title | your `package.json` description, else the slug |
83
+ Names, folders, and who may read each file are managed at
84
+ [workspace.costaffs.app](https://workspace.costaffs.app).
132
85
 
133
- If a guess is wrong, pass that one option. If it cannot guess at all it stops and
134
- says so, rather than inventing something.
86
+ > The project's source is uploaded alongside the build, which is what makes
87
+ > `pull` possible later. `node_modules` and dotfiles are never collected, so
88
+ > **`.env` does not travel**. `--no-source` publishes the built files alone.
135
89
 
136
- ### Options
90
+ ## Commands
137
91
 
138
- | Option | Use it when |
92
+ | | |
139
93
  | --- | --- |
140
- | `--title "Q3 report"` | you want a different name in the file manager |
141
- | `--slug q3-report` | the folder name is not the identity you want |
142
- | `--kind document\|deck\|workbook` | it guessed the wrong kind |
143
- | `--site-dir build` | your build output is not in `dist` |
144
- | `--dry-run` | you want to check before sending |
145
- | `--no-source` | you want to publish the built files alone |
146
-
147
- `costaff-workspace push --help` lists all of them.
148
-
149
- ---
150
-
151
- ## Worth knowing
152
-
153
- **Your source goes up too, and that is on purpose.** It is what lets `pull` hand
154
- you a working project back later, on any machine. `node_modules` and dotfiles are
155
- never collected — **your `.env` does not travel**. `--no-source` opts out, and
156
- then nothing can be pulled back out of that file afterwards.
94
+ | `costaff-workspace push` | publish this folder |
95
+ | `costaff-workspace pull <token> [dir]` | fetch a published file's source |
96
+ | `costaff-workspace theme push\|list\|pull\|rm` | keep the project's `themes/` folder in the workspace |
97
+ | `costaff-workspace whoami` | what this machine is signed in as |
98
+ | `costaff-workspace login` | sign this machine in |
99
+ | `costaff-workspace logout` | forget this machine's sign-in |
157
100
 
158
- **A project with several documents takes longer than one build.** Each document
159
- is built into a bundle of its own. It has to be: inside one shared build, anyone
160
- you send a single document to can reach all the others.
101
+ `--json` on any of them prints one line of JSON instead of prose — the same
102
+ shape for success and failure, and a command that would need an interactive
103
+ sign-in stops rather than waiting for a browser.
161
104
 
162
- **A file someone shared with you comes back as a copy.** It carries no link, so
163
- pushing it publishes it under your own account. The original is untouched.
105
+ A theme is a house style `themes/<id>.md` and an optional
106
+ `themes/<id>.demo.tsx`. It belongs to the account rather than to one file, so
107
+ the next document can start from the last one's look. The framework comes from
108
+ `package.json`; `--kind document|deck|workbook` overrides it, and `--no-demo`
109
+ sends the specs without building each demo.
110
+ `costaff-workspace theme --help` lists the rest.
164
111
 
165
- ---
112
+ ## Options
166
113
 
167
- ## When something goes wrong
114
+ A normal project needs none of these. Pass one when a guess is wrong.
168
115
 
169
- | It says | What it means, and what to do |
116
+ | | |
170
117
  | --- | --- |
171
- | `No site at dist — build it first.` | There is nothing built to publish. Run your project's build. |
172
- | `dist has no index.html it is not a publishable site.` | The build ran but produced no page. Check your build settings. |
173
- | `cannot make a slug out of the folder name` | The folder's name has no letters or digits usable as an identity — a folder named in Chinese, for example. Pass `--slug my-report`. |
174
- | `Sign in first run with --login.` | Run `costaff-workspace login`. |
175
- | `Sign-in code expired.` / `Sign-in timed out.` | The code only lasts a few minutes. Just push again for a new one. |
176
- | `… is not a CoStaff Workspace endpoint` | The service could not be reached check your connection, then try again. |
177
- | `No file at that token.` | Wrong token, or the file is not yours and was not shared with you. |
118
+ | `--title "Q3 report"` | the name shown in the file manager |
119
+ | `--slug q3-report` | the file's identity, and what a re-push updates |
120
+ | `--kind document\|deck\|workbook` | when the kind is guessed wrong |
121
+ | `--site-dir build` | when the build output is not `dist` |
122
+ | `--dry-run` | package and report; uploads nothing, needs no network |
123
+ | `--no-source` | publish the built files without the source |
178
124
 
125
+ `costaff-workspace push --help` lists every option.
179
126
 
180
- ## Licence
127
+ ## License
181
128
 
182
129
  MIT
package/README.zh-TW.md CHANGED
@@ -1,172 +1,118 @@
1
1
  # costaff-workspace
2
2
 
3
- [English](README.md) · **繁體中文**
4
-
5
- 把你在自己電腦上做好的文件,變成一條可以傳給別人的連結。
6
-
7
- 適用於用 [open-doc](https://github.com/simonliu-ai-product/open-doc)(文件)、
8
- open-slide(簡報)、open-sheet(試算表)做的專案。
3
+ [![npm](https://img.shields.io/npm/v/costaff-workspace?style=for-the-badge)](https://www.npmjs.com/package/costaff-workspace)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=for-the-badge)](https://opensource.org/licenses/MIT)
9
5
 
10
- ---
6
+ [English](README.md) · **繁體中文**
11
7
 
12
- ## 1. 安裝
8
+ **[CoStaff Workspace](https://workspace.costaffs.app) 的命令列工具。**
9
+ 把在本機做好的文件發佈出去,拿回一條可以傳的連結。換一台機器取回、修改、再發佈,
10
+ 連結始終不變。
13
11
 
14
- 需要 [Node.js](https://nodejs.org) 20 以上。用 `node -v` 確認。
12
+ 適用於用 [open-doc](https://github.com/simonliu-ai-product/open-doc)(文件)、
13
+ open-slide(簡報)、open-sheet(試算表)做的專案。
15
14
 
16
15
  ```bash
17
16
  npm i -g costaff-workspace
18
17
  ```
19
18
 
20
- 確認裝好了:
21
-
22
- ```bash
23
- costaff-workspace --help
24
- ```
25
-
26
- <details>
27
- <summary>如果顯示「找不到指令」</summary>
28
-
29
- 你的 shell 看不到 npm 放全域指令的地方。`npm prefix -g` 會印出那個資料夾,把它底下的
30
- `bin` 加進 `PATH`。如果你用 pnpm,跑一次 `pnpm setup` 就好。
31
- </details>
32
-
33
- ## 2. 先建置你的專案
19
+ ## 為什麼
34
20
 
35
- 發佈送出去的是**建置後的檔案**,所以要先建置。
21
+ 建置好的文件是一整包檔案,而把一整包檔案傳給別人,不等於把文件交給他。靜態託管解決了
22
+ 傳遞,卻丟掉了周邊的一切:誰可以讀、它叫什麼名字、對方看到的是哪一版,以及它是從什麼
23
+ 原始碼建出來的。
36
24
 
37
- ```bash
38
- cd my-doc
39
- pnpm install
40
- pnpm build
41
- ```
25
+ `costaff-workspace push` 用一個指令補上這段落差。拿回來的是一個位址,不是一次部署。
42
26
 
43
- 跑完應該會出現一個 `dist/` 資料夾。如果你的專案輸出到別的地方,記住那個名字,
44
- 第 3 步會用到。
27
+ ## 特色
45
28
 
46
- ## 3. 推上去
47
-
48
- ```bash
49
- costaff-workspace push
50
- ```
29
+ ### 📤 一個指令,不用設定
51
30
 
52
- ### 第一次會請你登入
31
+ 在專案資料夾裡執行。slug 取自資料夾名稱、種類取自 `package.json` 的相依套件、
32
+ 產物取自 `dist/`、標題取自套件描述。**每一個推斷都會印出來**,而推斷不出來的時候
33
+ 它會停下,不會憑空編一個。
53
34
 
54
35
  ```
55
- Sign in to CoStaff Workspace
56
- open https://workspace.costaffs.app/activate?code=WXYZ-1234
57
- code WXYZ-1234
36
+ guessed --slug q3-report --kind deck --source-dir .
58
37
  ```
59
38
 
60
- 用瀏覽器打開那個網址。**驗證碼已經在網址裡**,所以你只要按同意。指令會自己等著,
61
- 授權完就繼續。
62
-
63
- 這台機器之後就記住登入了,不會再問。
39
+ ### 🔗 改了內容,連結不變
64
40
 
65
- ### 然後它就發佈了
41
+ 位址在建置之前就決定,不是事後才配發的,而且逐一記在檔案上。一年後重新發佈同一個
42
+ 資料夾,所有拿著舊連結的人看到的就是新版本。
66
43
 
67
- ```
68
- 4 documents — one bundle each
69
- getting-started → https://workspace.costaffs.app/dcuk0lmf875ctrgxfppa
70
- q3-numbers → https://workspace.costaffs.app/8fjq2ldk3nx7yrpv0aet
71
- team-offsite → https://workspace.costaffs.app/pv0aet8fjq2ldk3nx7yr
72
- budget-2027 → https://workspace.costaffs.app/3nx7yrpv0aet8fjq2ldk
73
- ```
44
+ ### ↩️ 換台機器就能接手
74
45
 
75
- 那些連結就是檔案本身。傳一條給別人,他就能讀。
46
+ 推送會帶著原始碼。`costaff-workspace pull <token>` 會在任何機器上還你一個完整的
47
+ 專案——安裝、修改、發佈,同一條連結。沒有任何東西綁在最初發佈的那台電腦上。
76
48
 
77
- ## 4. 管理你發佈的東西
49
+ ### 🔒 預設私人,由你決定開放
78
50
 
79
- 到 **<https://workspace.costaffs.app>** 改名字、分資料夾,以及決定每一份誰可以看。
51
+ 剛發佈的檔案只有擁有者打得開。要讓誰讀,是在檔案管理員裡邀請,或把它改成公開連結。
52
+ **光是把位址傳給別人並不夠。**
80
53
 
81
- > **剛推上去的檔案是私人的。** 在檔案管理員裡設定之前,只有你打得開。
82
- > **光是把連結傳給別人是不夠的**——你要在那裡邀請他,或是把檔案改成公開連結。
54
+ ### 📦 一份文件一個 bundle
83
55
 
84
- ---
56
+ 含多份文件的專案會逐份建置。另一種做法——共用一次建置——會讓你只傳一份文件給別人時,
57
+ 他就能取得其他每一份的資產。隔離是理由,多出來的建置次數是代價。
85
58
 
86
- ## 之後要再做的事
87
-
88
- **你改了內容。** 重新建置再推一次。**連結不會變**——你傳出去的那條會直接看到新版本。
89
-
90
- ```bash
91
- pnpm build && costaff-workspace push
92
- ```
93
-
94
- **你換了一台電腦。** 用 token(連結的最後一段)把專案取回來:
59
+ ## 開始使用
95
60
 
96
61
  ```bash
97
- costaff-workspace pull dcuk0lmf875ctrgxfppa my-doc
98
62
  cd my-doc
99
- pnpm install
100
- ```
101
-
102
- 拿回來的是一個完整的專案。改完、建置、推上去,同一條連結就更新了。
103
-
104
- **你想在發佈前先確認。** 這會把東西打包好並回報要送出什麼,但不上傳,也不需要網路:
105
-
106
- ```bash
107
- costaff-workspace push --dry-run
63
+ pnpm build # 發佈送出去的是建置後的檔案
64
+ costaff-workspace push
108
65
  ```
109
66
 
110
- ---
111
-
112
- ## 你通常一個參數都不用打
113
-
114
- 在專案資料夾裡執行,`push` 會自己推斷,而且**每一個猜測都會印出來**:
67
+ 第一次推送會印出一條登入連結,驗證碼已經在網址裡。在瀏覽器按下同意,指令會自己繼續,
68
+ 之後這台機器就保持登入。
115
69
 
116
70
  ```
117
- guessed --slug my-report --kind deck --source-dir .
71
+ 4 documents one bundle each
72
+ getting-started → https://workspace.costaffs.app/dcuk0lmf875ctrgxfppa
73
+ q3-numbers → https://workspace.costaffs.app/8fjq2ldk3nx7yrpv0aet
118
74
  ```
119
75
 
120
- | 它會猜 | 依據 |
121
- | --- | --- |
122
- | 檔案的身分(`--slug`) | 資料夾的名字 |
123
- | 是文件、簡報還是試算表(`--kind`) | 你 `package.json` 裡的相依套件 |
124
- | 建置產物在哪(`--site-dir`) | `dist` |
125
- | 標題 | `package.json` 的 description,沒有就用 slug |
76
+ 名稱、資料夾,以及每一份誰可以讀,都在
77
+ [workspace.costaffs.app](https://workspace.costaffs.app) 管理。
126
78
 
127
- 猜錯就只補那一個參數。**完全猜不出來的時候它會停下來說明,不會憑空編一個。**
79
+ > 專案的原始碼會和建置產物一起上傳,那正是之後 `pull` 得以成立的原因。
80
+ > `node_modules` 和點開頭的檔案永遠不會被收進去,所以 **`.env` 不會跟著走**。
81
+ > `--no-source` 則只發佈建置後的檔案。
128
82
 
129
- ### 參數
83
+ ## 指令
130
84
 
131
- | 參數 | 什麼時候用 |
85
+ | | |
132
86
  | --- | --- |
133
- | `--title "第三季報告"` | 你想在檔案管理員裡顯示別的名字 |
134
- | `--slug q3-report` | 資料夾名字不是你要的身分 |
135
- | `--kind document\|deck\|workbook` | 它猜錯種類了 |
136
- | `--site-dir build` | 你的建置產物不在 `dist` |
137
- | `--dry-run` | 想先確認再送出 |
138
- | `--no-source` | 只想發佈建置後的檔案 |
139
-
140
- `costaff-workspace push --help` 會列出全部。
87
+ | `costaff-workspace push` | 發佈這個資料夾 |
88
+ | `costaff-workspace pull <token> [dir]` | 取回某份已發佈檔案的原始碼 |
89
+ | `costaff-workspace theme push\|list\|pull\|rm` | 把專案的 `themes/` 資料夾留在工作區 |
90
+ | `costaff-workspace whoami` | 這台機器登入的是誰 |
91
+ | `costaff-workspace login` | 讓這台機器登入 |
92
+ | `costaff-workspace logout` | 忘掉這台機器的登入 |
141
93
 
142
- ---
94
+ 任何一個加上 `--json` 就會印一行 JSON 而不是散文——成功和失敗同一種形狀;需要
95
+ 互動登入的指令會直接停下來,而不是等瀏覽器。
143
96
 
144
- ## 值得知道的幾件事
97
+ 主題就是一套版面風格——`themes/<id>.md` 加上可選的 `themes/<id>.demo.tsx`。它屬於帳號
98
+ 而不屬於某一份檔案,所以下一份文件可以從上一份的樣子開始。框架從 `package.json` 判斷,
99
+ `--kind document|deck|workbook` 可以指定,`--no-demo` 則只送規格、不建置示範。
100
+ 其餘看 `costaff-workspace theme --help`。
145
101
 
146
- **原始碼也會一起上去,那是刻意的。** 那正是之後 `pull` 能在任何機器上還你一個
147
- 可以直接跑的專案的原因。`node_modules` 和點開頭的檔案永遠不會被收進去——
148
- **你的 `.env` 不會跟著走**。`--no-source` 可以不送,但那之後這份檔案就拉不回來了。
102
+ ## 參數
149
103
 
150
- **多份文件的專案會比單次建置久。** 每一份文件都會被建成獨立的 bundle。這是必要的:
151
- 在一份共用的建置產物裡,你只傳一份給別人,他就能拿到其他全部。
104
+ 一般的專案一個都不需要。推斷錯了才補上那一個。
152
105
 
153
- **別人分享給你的檔案,拉回來是一份副本。** 它不帶連結,所以推上去會發佈在你自己的
154
- 帳號底下,原件不受影響。
155
-
156
- ---
157
-
158
- ## 出問題的時候
159
-
160
- | 它說 | 意思,以及怎麼辦 |
106
+ | | |
161
107
  | --- | --- |
162
- | `No site at dist — build it first.` | 沒有建置產物可以發佈。先跑專案的建置指令。 |
163
- | `dist has no index.html — it is not a publishable site.` | 建置有跑,但沒有產出頁面。檢查建置設定。 |
164
- | `cannot make a slug out of the folder name` | 資料夾名字裡沒有可以當身分的英數字——例如中文資料夾名。加上 `--slug my-report`。 |
165
- | `Sign in first — run with --login.` | 執行 `costaff-workspace login`。 |
166
- | `Sign-in code expired.` / `Sign-in timed out.` | 驗證碼只有幾分鐘有效。再推一次就會拿到新的。 |
167
- | `… is not a CoStaff Workspace endpoint` | 連不上服務 —— 檢查一下網路再試一次。 |
168
- | `No file at that token.` | token 不對,或這份檔案不是你的、也沒有分享給你。 |
169
-
108
+ | `--title "第三季報告"` | 檔案管理員裡顯示的名稱 |
109
+ | `--slug q3-report` | 檔案的身分,也決定重推會更新哪一份 |
110
+ | `--kind document\|deck\|workbook` | 種類推斷錯誤時 |
111
+ | `--site-dir build` | 建置產物不在 `dist` |
112
+ | `--dry-run` | 打包並回報;不上傳,也不需要網路 |
113
+ | `--no-source` | 只發佈建置後的檔案,不帶原始碼 |
114
+
115
+ `costaff-workspace push --help` 會列出全部參數。
170
116
 
171
117
  ## 授權
172
118
 
package/dist/cli-pull.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { PublishError, discover } from "./client.js";
2
2
  import { DEFAULT_ENDPOINT } from "./defaults.js";
3
3
  import { pull } from "./pull.js";
4
+ import { done, jsonMode, line } from "./report.js";
4
5
  import { login } from "./push.js";
5
6
  const USAGE = `costaff-workspace pull — fetch a published file's source back out
6
7
 
@@ -44,17 +45,24 @@ export async function runPull(argv) {
44
45
  const token = positional[0];
45
46
  if (token === undefined)
46
47
  throw new PublishError('missing <token>');
47
- const out = (line) => {
48
- process.stdout.write(line);
48
+ const out = (text) => {
49
+ line(text);
49
50
  };
50
- await pull({
51
+ const result = await pull({
51
52
  endpoint,
52
53
  token,
53
54
  dir: positional[1],
54
55
  force: flags.force === true,
55
56
  bearer: str('bearer'),
56
57
  out,
57
- signIn: async () => login({ endpoint, out }, (await discover(endpoint)).name),
58
+ signIn: async () => {
59
+ /* 同 push:`--json` 的讀者按不了瀏覽器裡的核准,卡住比報錯更難查。 */
60
+ if (jsonMode()) {
61
+ throw new PublishError('not signed in — run `costaff-workspace login` once, or set COSTAFF_WORKSPACE_TOKEN');
62
+ }
63
+ return login({ endpoint, out }, (await discover(endpoint)).name);
64
+ },
58
65
  });
66
+ done({ command: 'pull', endpoint, token, ...result });
59
67
  }
60
68
  //# sourceMappingURL=cli-pull.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cli-pull.js","sourceRoot":"","sources":["../src/cli-pull.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAElC,MAAM,KAAK,GAAG;;;;2CAI6B,gBAAgB;;;;;;;;CAQ1D,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,IAAc;IAC1C,IAAI,IAAI,CAAC,MAAM,KAAK,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