Skip to content
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

update azdata-test in notebooks extension #24984

Merged
merged 3 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions extensions/notebook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@
"@types/request": "^2.48.1",
"@types/rimraf": "^2.0.2",
"@types/sinon": "^9.0.4",
"@types/tar": "^4.0.3",
"@types/tar": "^6.1.10",
Copy link
Contributor Author

@kisantia kisantia Nov 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to update this version to get rid of the error when yarn npm-run-all -lp extensions-ci was getting run in the Compile & Hygiene step of the PR validation pipeline (example failure) .

The problem was that the type definition file for @types/minipass couldn't be located, but when I looked at the @types/minipass folder in notebooks node_modules folder, the readme said that minipass already includes it's types definition, so dependencies on @types/minipass are unnecessary and it's expected that there isn't an index.d.ts file. The @types/minipass package has been marked as deprecated, so it really shouldn't be used.

Version 4.0.3 of @types/tar has a dependency on @types/minipass, but the latest version has a dependency on minipass, so updating the version resolved the issue of the @types/minipass index.d.ts file not being found.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And we're using v6 of tar anyways, so this is the correct thing to do for that regardless! 😄

"@types/uuid": "^3.4.5",
"assert": "^1.4.1",
"mocha": "^9.2.2",
Expand All @@ -700,7 +700,7 @@
"sinon": "^9.0.2",
"typemoq": "^2.1.0",
"@microsoft/vscodetestcover": "^1.2.2",
"@microsoft/azdata-test": "^3.0.3"
"@microsoft/azdata-test": "^3.0.4"
},
"resolutions": {
"url-parse": "^1.5.8",
Expand Down
2 changes: 1 addition & 1 deletion extensions/notebook/src/book/bookModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export class BookModel {
if (this._tableOfContentsPath) {
try {
let fileContents = await fsPromises.readFile(this._configPath, 'utf-8');
const config = yaml.safeLoad(fileContents.toString());
const config = yaml.safeLoad(fileContents.toString()) as JupyterBookSection;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@barbaravaldez could you double check if this cast and the one below in bookTocManager.ts are correct or should be changed? The variables in the tests have types specified, but wasn't sure about these

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JupyterBookSection is the only class I'm seeing with a title field for this one, and the tableOfContents variable in bookTocManager already had a JupyterBookSection[] type. Looks good to me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup! It looks good to me

fileContents = await fsPromises.readFile(this._tableOfContentsPath, 'utf-8');
let tableOfContents: any = yaml.safeLoad(fileContents.toString());
const parsedTOC: IJupyterBookToc = { sections: this.parseJupyterSections(this._bookVersion, tableOfContents) };
Expand Down
4 changes: 2 additions & 2 deletions extensions/notebook/src/book/bookTocManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export class BookTocManager implements IBookTocManager {
}

for (const [key, value] of this.tocFiles.entries()) {
const yamlFile = await yaml.safeLoad(value);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this wasn't related to the package version update, but it was a red squiggly when I was in the file, so updated this while I was there

const yamlFile = yaml.safeLoad(value);
await fs.writeFile(key, yaml.safeDump(yamlFile, { lineWidth: Infinity, noRefs: true, skipInvalid: true }));
}
}
Expand Down Expand Up @@ -192,7 +192,7 @@ export class BookTocManager implements IBookTocManager {
*/
async updateTOC(version: BookVersion, tocPath: string, findSection?: JupyterBookSection, addSection?: JupyterBookSection): Promise<void> {
const tocFile = await fs.readFile(tocPath, 'utf8');
this.tableofContents = yaml.safeLoad(tocFile);
this.tableofContents = yaml.safeLoad(tocFile) as JupyterBookSection[];
if (!this.tocFiles.has(tocPath)) {
this.tocFiles.set(tocPath, tocFile);
}
Expand Down
12 changes: 6 additions & 6 deletions extensions/notebook/src/test/book/bookTocManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ describe('BookTocManagerTests', function () {
should(listFiles.length).be.equal(7);
});

it ('should create a table of contents with sections if folder contains subfolders', async () => {
it('should create a table of contents with sections if folder contains subfolders', async () => {
await fs.writeFile(path.join(root2FolderPath, subfolder, subfolder2, notebooks[4]), '');
await fs.writeFile(path.join(root2FolderPath, subfolder, subfolder2, notebooks[5]), '');

Expand Down Expand Up @@ -183,7 +183,7 @@ describe('BookTocManagerTests', function () {
{
title: 'Subfolder2',
file: path.posix.join(path.posix.sep, subfolder, subfolder2, 'notebook4'),
sections : expectedSubSections
sections: expectedSubSections
}];

const index = bookTocManager.tableofContents.findIndex(entry => entry.file === path.posix.join(path.posix.sep, subfolder, 'index'));
Expand Down Expand Up @@ -508,7 +508,7 @@ describe('BookTocManagerTests', function () {
});

it('Remove notebook from book', async () => {
let toc: JupyterBookSection[] = yaml.safeLoad((await fs.promises.readFile(notebook5.tableOfContentsPath)).toString());
let toc: JupyterBookSection[] = yaml.safeLoad((await fs.promises.readFile(notebook5.tableOfContentsPath)).toString()) as JupyterBookSection[];
let notebookInToc = toc.some(section => {
if (section.title === 'Notebook 5' && section.file === path.posix.join(path.posix.sep, 'notebook5')) {
return true;
Expand All @@ -519,7 +519,7 @@ describe('BookTocManagerTests', function () {
bookTocManager = new BookTocManager(sourceBookModel);
await bookTocManager.removeNotebook(notebook5);
const listFiles = await fs.promises.readdir(run.sourceBook.contentFolder);
toc = yaml.safeLoad((await fs.promises.readFile(notebook5.tableOfContentsPath)).toString());
toc = yaml.safeLoad((await fs.promises.readFile(notebook5.tableOfContentsPath)).toString()) as JupyterBookSection[];
notebookInToc = toc.some(section => {
if (section.title === 'Notebook 5' && section.file === path.posix.join(path.posix.sep, 'notebook5')) {
return true;
Expand Down Expand Up @@ -576,10 +576,10 @@ describe('BookTocManagerTests', function () {
bookTocManager = new BookTocManager(sourceBookModel);
const fileBasename = `addSectionTest-${generateGuid()}`;
const sectionTitle = 'Section Test';
const testFilePath = path.join(run.sectionA.contentFolder, 'sectionA', sectionTitle,fileBasename).concat(FileExtension.Markdown);
const testFilePath = path.join(run.sectionA.contentFolder, 'sectionA', sectionTitle, fileBasename).concat(FileExtension.Markdown);
const pathDetails = new TocEntryPathHandler(testFilePath, run.sourceBook.root, sectionTitle);
await bookTocManager.addNewTocEntry(pathDetails, sectionA, true);
let toc: JupyterBookSection[] = yaml.safeLoad((await fs.promises.readFile(run.sourceBook.tocPath)).toString());
let toc: JupyterBookSection[] = yaml.safeLoad((await fs.promises.readFile(run.sourceBook.tocPath)).toString()) as JupyterBookSection[];
const sectionAIndex = toc.findIndex(entry => entry.title === sectionA.title);
let newSectionIndex = -1;
let newSection = undefined;
Expand Down
Loading