-
Notifications
You must be signed in to change notification settings - Fork 328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds command listitem attachment add
#5345
Adds command listitem attachment add
#5345
Conversation
Thank you @MathijsVerbeeck we'll try to review it ASAP! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @MathijsVerbeeck, would you mind updating your PR to utilize ESM? Here's a breakdown of the new changes:
- Make sure that all logging is done asynchronously and awaited
await logger.log(attachmentFiles.AttachmentFiles); cli-microsoft365/src/m365/spo/commands/listitem/listitem-attachment-list.spec.ts
Lines 65 to 81 in 515b009
beforeEach(() => { log = []; logger = { log: async (msg: string) => { log.push(msg); }, logRaw: async (msg: string) => { log.push(msg); }, logToStderr: async (msg: string) => { log.push(msg); } }; loggerLogSpy = sinon.spy(logger, 'log'); loggerLogToStderrSpy = sinon.spy(logger, 'logToStderr'); sinon.stub(cli, 'getSettingWithDefaultValue').callsFake(((settingName, defaultValue) => defaultValue)); });
- Adjust the way commands are exported
export default new SpoListItemAttachmentListCommand(); - Replace all instances of
require
withimport
import command from './listitem-attachment-list.js'; - Modify all file imports within the project to have a
.js
extension
64c6135
to
94d3d7f
Compare
dfbe2f0
to
aeb0240
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work @MathijsVerbeeck, I've left a few suggestions you can take a look at.
I've also noticed a bit of a vague error. When you want to upload a file with a name that already exists you get this error:
Error: The specified name is already in use.
The document or folder name was not changed. To change the name to a different value, close this dialog and edit the properties of the document or folder.
Could we modify this so the message is clearer and doesn't return any steps that aren't relevant to CLI usage?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Splendid work @MathijsVerbeeck! Noticed a small detail in the examples but resolved that one myself during the merging.
Add a new attachment to a list item from a local file by using list URL with a different filename | ||
|
||
```sh | ||
m365 spo listitem attachment add --webUrl https://contoso.sharepoint.com/sites/project-x --listUrl "/sites/project-x/Lists/DemoList" --listItemId 147 --filePath "C:/Reports/File1.jpg" --fileName "File2.jpg" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For fileName
, we don't need to define the extension as this is done in code.
m365 spo listitem attachment add --webUrl https://contoso.sharepoint.com/sites/project-x --listUrl "/sites/project-x/Lists/DemoList" --listItemId 147 --filePath "C:/Reports/File1.jpg" --fileName "File2.jpg" | |
m365 spo listitem attachment add --webUrl https://contoso.sharepoint.com/sites/project-x --listUrl "/sites/project-x/Lists/DemoList" --listItemId 147 --filePath "C:/Reports/File1.jpg" --fileName "File2" |
Closes #5219