Skip to content

Commit 2ada0d1

Browse files
committed
Address code review feedback
1 parent 8cb4ced commit 2ada0d1

5 files changed

Lines changed: 63 additions & 17 deletions

File tree

.devproxy/api-specs/sharepoint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ paths:
8282
description: list GUID
8383
schema:
8484
type: string
85-
example: "'b2307a39-e878-458b-bc90-03bc578531d6'"
85+
example: b2307a39-e878-458b-bc90-03bc578531d6
8686
- name: itemId
8787
in: path
8888
required: true

docs/docs/cmd/spo/file/file-unarchive.mdx

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,42 @@ m365 spo file unarchive --webUrl https://contoso.sharepoint.com/sites/Marketing
6565

6666
## Response
6767

68-
The command won't return a response on success.
68+
<Tabs>
69+
<TabItem value="JSON">
70+
71+
```json
72+
{
73+
"value": "reactivating"
74+
}
75+
```
76+
77+
</TabItem>
78+
<TabItem value="Text">
79+
80+
```text
81+
value: reactivating
82+
```
83+
84+
</TabItem>
85+
<TabItem value="CSV">
86+
87+
```csv
88+
value
89+
reactivating
90+
```
91+
92+
</TabItem>
93+
<TabItem value="Markdown">
94+
95+
```md
96+
# spo file unarchive --debug "false" --verbose "false" --webUrl "https://contoso.sharepoint.com/sites/Marketing" --url "/sites/Marketing/shared documents/General/document.docx" --force "true"
97+
98+
Date: 5/8/2026
99+
100+
Property | Value
101+
---------|-------
102+
value | reactivating
103+
```
104+
105+
</TabItem>
106+
</Tabs>

docs/src/config/sidebars.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2756,6 +2756,11 @@ const sidebars: SidebarsConfig = {
27562756
label: 'file rename',
27572757
id: 'cmd/spo/file/file-rename'
27582758
},
2759+
{
2760+
type: 'doc',
2761+
label: 'file unarchive',
2762+
id: 'cmd/spo/file/file-unarchive'
2763+
},
27592764
{
27602765
type: 'doc',
27612766
label: 'file retentionlabel ensure',
@@ -2821,11 +2826,6 @@ const sidebars: SidebarsConfig = {
28212826
label: 'file sharinglink set',
28222827
id: 'cmd/spo/file/file-sharinglink-set'
28232828
},
2824-
{
2825-
type: 'doc',
2826-
label: 'file unarchive',
2827-
id: 'cmd/spo/file/file-unarchive'
2828-
},
28292829
{
28302830
type: 'doc',
28312831
label: 'file version clear',

src/m365/spo/commands/file/file-unarchive.spec.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ describe(commands.FILE_UNARCHIVE, () => {
2323
let confirmationPromptStub: sinon.SinonStub;
2424
let loggerLogSpy: sinon.SinonSpy;
2525

26+
const unarchiveResponse = {
27+
value: 'reactivating'
28+
};
29+
2630
before(() => {
2731
sinon.stub(auth, 'restoreAuth').resolves();
2832
sinon.stub(telemetry, 'trackEvent').resolves();
@@ -134,7 +138,7 @@ describe(commands.FILE_UNARCHIVE, () => {
134138

135139
it('prompts before unarchiving file when confirmation argument not passed', async () => {
136140
sinon.stub(request, 'get').resolves({ ListId: 'b2307a39-e878-458b-bc90-03bc578531d6', ListItemAllFields: { Id: 1 } });
137-
sinon.stub(request, 'post').resolves();
141+
sinon.stub(request, 'post').resolves(unarchiveResponse);
138142

139143
await command.action(logger, {
140144
options: {
@@ -147,7 +151,7 @@ describe(commands.FILE_UNARCHIVE, () => {
147151

148152
it('aborts unarchiving file when prompt not confirmed', async () => {
149153
const getStub = sinon.stub(request, 'get').resolves({ ListId: 'b2307a39-e878-458b-bc90-03bc578531d6', ListItemAllFields: { Id: 1 } });
150-
const postStub = sinon.stub(request, 'post').resolves();
154+
const postStub = sinon.stub(request, 'post').resolves(unarchiveResponse);
151155

152156
await command.action(logger, {
153157
options: {
@@ -176,7 +180,7 @@ describe(commands.FILE_UNARCHIVE, () => {
176180

177181
const postStub = sinon.stub(request, 'post').callsFake(async (opts) => {
178182
if (opts.url === `https://contoso.sharepoint.com/sites/test/_api/Lists(guid'b2307a39-e878-458b-bc90-03bc578531d6')/items(1)/UnArchive`) {
179-
return;
183+
return unarchiveResponse;
180184
}
181185

182186
throw 'Invalid request';
@@ -191,6 +195,7 @@ describe(commands.FILE_UNARCHIVE, () => {
191195
});
192196

193197
assert(postStub.calledOnce);
198+
assert(loggerLogSpy.calledWith(unarchiveResponse));
194199
});
195200

196201
it('unarchives file by id', async () => {
@@ -210,7 +215,7 @@ describe(commands.FILE_UNARCHIVE, () => {
210215

211216
const postStub = sinon.stub(request, 'post').callsFake(async (opts) => {
212217
if (opts.url === `https://contoso.sharepoint.com/sites/test/_api/Lists(guid'b2307a39-e878-458b-bc90-03bc578531d6')/items(1)/UnArchive`) {
213-
return;
218+
return unarchiveResponse;
214219
}
215220

216221
throw 'Invalid request';
@@ -226,6 +231,7 @@ describe(commands.FILE_UNARCHIVE, () => {
226231
});
227232

228233
assert(postStub.calledOnce);
234+
assert(loggerLogSpy.calledWith(unarchiveResponse));
229235
});
230236

231237
it('unarchives file using site-relative url', async () => {
@@ -244,7 +250,7 @@ describe(commands.FILE_UNARCHIVE, () => {
244250

245251
const postStub = sinon.stub(request, 'post').callsFake(async (opts) => {
246252
if (opts.url === `https://contoso.sharepoint.com/sites/test/_api/Lists(guid'b2307a39-e878-458b-bc90-03bc578531d6')/items(1)/UnArchive`) {
247-
return;
253+
return unarchiveResponse;
248254
}
249255

250256
throw 'Invalid request';
@@ -259,11 +265,12 @@ describe(commands.FILE_UNARCHIVE, () => {
259265
});
260266

261267
assert(postStub.calledOnce);
268+
assert(loggerLogSpy.calledWith(unarchiveResponse));
262269
});
263270

264-
it('outputs no result when unarchiving a file', async () => {
271+
it('outputs the API response when unarchiving a file', async () => {
265272
sinon.stub(request, 'get').resolves({ ListId: 'b2307a39-e878-458b-bc90-03bc578531d6', ListItemAllFields: { Id: 1 } });
266-
sinon.stub(request, 'post').resolves();
273+
sinon.stub(request, 'post').resolves(unarchiveResponse);
267274

268275
await command.action(logger, {
269276
options: {
@@ -273,7 +280,7 @@ describe(commands.FILE_UNARCHIVE, () => {
273280
}
274281
});
275282

276-
assert(loggerLogSpy.notCalled);
283+
assert(loggerLogSpy.calledOnceWith(unarchiveResponse));
277284
});
278285

279286
it('handles error correctly', async () => {

src/m365/spo/commands/file/file-unarchive.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class SpoFileUnarchiveCommand extends SpoCommand {
5555
const { webUrl, url, id, force, verbose } = args.options;
5656

5757
if (!force) {
58-
const result = await cli.promptForConfirmation({ message: `This item is archived. Reactivation could take up to 24 hours. Are you sure you would like to unarchive this item?` });
58+
const result = await cli.promptForConfirmation({ message: `Reactivation could take up to 24 hours. Files that are reactivated cannot be archived again for 30 days. Are you sure you would like to unarchive this item?` });
5959
if (!result) {
6060
return;
6161
}
@@ -93,7 +93,8 @@ class SpoFileUnarchiveCommand extends SpoCommand {
9393
responseType: 'json'
9494
};
9595

96-
await request.post(requestOptions);
96+
const res = await request.post(requestOptions);
97+
await logger.log(res);
9798
}
9899
catch (err: any) {
99100
this.handleRejectedODataJsonPromise(err);

0 commit comments

Comments
 (0)