Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
6b9553b
remove fs-extra from lspController
Hweinstock Sep 25, 2024
3302caf
update createCert
Hweinstock Sep 25, 2024
55cc95e
createPolicy update
Hweinstock Sep 25, 2024
b29d360
remove more occurences of fs-extra
Hweinstock Sep 26, 2024
9732e0b
remove instances of fs-extra
Hweinstock Sep 27, 2024
43327df
comment out fixbytest temporarily
Hweinstock Sep 30, 2024
8410f1a
replace fs-extra in tests, first part
Hweinstock Sep 30, 2024
e9613f8
add next chunk of migration
Hweinstock Sep 30, 2024
9c9a89c
push techdebt test back a month
Hweinstock Sep 30, 2024
dfb4889
migrate next chunk of files
Hweinstock Sep 30, 2024
4213161
finish replacements
Hweinstock Sep 30, 2024
aab051e
move to our fs module
Hweinstock Sep 30, 2024
e9e7760
fix half-baked implementation
Hweinstock Sep 30, 2024
4e9d959
Merge branch 'removeFsExtra' into removeFsExtra2
Hweinstock Sep 30, 2024
c8e3efa
move over realpath usage
Hweinstock Sep 30, 2024
355fcaa
merge in upstream changes
Hweinstock Oct 2, 2024
f3cf8a1
remove fs2 references
Hweinstock Oct 2, 2024
405c126
move buffer.from to match variable name
Hweinstock Oct 2, 2024
bd5597a
add recursive options
Hweinstock Oct 2, 2024
402f916
add flags to make deletions recursive
Hweinstock Oct 2, 2024
3e616f0
add force to silence ci fs errors
Hweinstock Oct 2, 2024
5d6b5f7
add recursive option
Hweinstock Oct 2, 2024
5e2331d
Merge branch 'master' into removeFsExtra2
Hweinstock Oct 3, 2024
645229b
add async safe doesThrow
Hweinstock Oct 3, 2024
3a96dc5
merge in master
Hweinstock Oct 3, 2024
40ac03c
merge in master
Hweinstock Oct 4, 2024
a341f85
change flags to recursive
Hweinstock Oct 4, 2024
0d32a19
Merge branch 'master' into removeFsExtra2
Hweinstock Oct 4, 2024
9996ad1
add recursive flag
Hweinstock Oct 4, 2024
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
15 changes: 7 additions & 8 deletions docs/vscode_behaviors.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ for each extension.
- The Extension Host process has at most 5 seconds to shut down, after which it will exit. [1]
- The vscode API will be unreliable at deactivation time. So certain VSC APIs like the filesystem may not work. [1]
- The VSC Filesystem API has been confirmed to not work
- In `Run & Debug` mode, closing the Debug IDE instance behaves differently depending on how it is closed
- The regular close button in the Debug IDE instance results in a graceful shutdown
- The red square in the root IDE instance to stop the debugging session results on a non-graceful shutdown, meaning `deactivate()` is not run.
- `Reload Window` triggers `deactivate()`
- In `Run & Debug` mode, closing the Debug IDE instance behaves differently depending on how it is closed
- The regular close button in the Debug IDE instance results in a graceful shutdown
- The red square in the root IDE instance to stop the debugging session results on a non-graceful shutdown, meaning `deactivate()` is not run.
- `Reload Window` triggers `deactivate()`

Sources:

Expand All @@ -25,8 +25,7 @@ Sources:
## State (`globalState`, `Memento`)

TODO:
- How it behaves between remote (ssh) and local
- How it is not completely reliable. Reads/writes have no guarantee to work (though we are fine in most cases)
- How it can break as observed with crash monitoring work. At a certain point writes were seemingly succeeding, but did not actually propagate to all IDE instances.


- How it behaves between remote (ssh) and local
- How it is not completely reliable. Reads/writes have no guarantee to work (though we are fine in most cases)
- How it can break as observed with crash monitoring work. At a certain point writes were seemingly succeeding, but did not actually propagate to all IDE instances.
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
*/
import assert from 'assert'
import sinon from 'sinon'
import fs from 'fs-extra'
import os from 'os'
import { DiffModel, AddedChangeNode, ModifiedChangeNode } from 'aws-core-vscode/codewhisperer/node'
import path from 'path'
import { getTestResourceFilePath } from './amazonQGumbyUtil'
import { fs } from 'aws-core-vscode/shared'

describe('DiffModel', function () {
afterEach(() => {
Expand All @@ -20,7 +20,7 @@ describe('DiffModel', function () {

const workspacePath = 'workspace'

sinon.replace(fs, 'existsSync', (path) => {
sinon.replace(fs, 'exists', async (path) => {
const pathStr = path.toString()
if (pathStr.includes(workspacePath)) {
return false
Expand All @@ -42,9 +42,9 @@ describe('DiffModel', function () {

const workspacePath = os.tmpdir()

sinon.replace(fs, 'existsSync', (path) => true)
sinon.replace(fs, 'exists', async (path) => true)

fs.writeFileSync(
await fs.writeFile(
path.join(workspacePath, 'README.md'),
'This guide walks you through using Gradle to build a simple Java project.'
)
Expand All @@ -56,6 +56,6 @@ describe('DiffModel', function () {

assert.strictEqual(change instanceof ModifiedChangeNode, true)

fs.rmSync(path.join(workspacePath, 'README.md'))
await fs.delete(path.join(workspacePath, 'README.md'), { recursive: true })
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
import assert from 'assert'
import * as path from 'path'
import * as vscode from 'vscode'
import * as fs from 'fs-extra'
import { detectCdkProjects } from '../../../awsService/cdk/explorer/detectCdkProjects'
import { makeTemporaryToolkitFolder } from '../../../shared/filesystemUtilities'
import { saveCdkJson } from './treeTestUtils'
import { createTestWorkspaceFolder } from '../../testUtil'
import { FakeExtensionContext } from '../../fakeExtensionContext'
import { mkdirp, writeJSON } from 'fs-extra'
import { waitUntil } from '../../../shared/utilities/timeoutUtils'
import { fs } from '../../../shared'

describe('detectCdkProjects', function () {
const workspacePaths: string[] = []
Expand Down Expand Up @@ -45,7 +44,7 @@ describe('detectCdkProjects', function () {

afterEach(async function () {
for (const path of workspacePaths) {
await fs.remove(path)
await fs.delete(path, { recursive: true })
}

workspacePaths.length = 0
Expand Down Expand Up @@ -88,15 +87,15 @@ describe('detectCdkProjects', function () {

it('detects deep projects', async function () {
const cdkJsonUri = vscode.Uri.joinPath(workspaceFolders[0].uri, 'directory1', 'directory2', 'cdk.json')
await mkdirp(path.dirname(cdkJsonUri.fsPath))
await fs.mkdir(path.dirname(cdkJsonUri.fsPath))
await saveCdkJson(cdkJsonUri.fsPath)
const actual = await detectCdkProjects_wait(workspaceFolders)
assert.strictEqual(actual[0]?.cdkJsonUri.fsPath, cdkJsonUri.fsPath)
})

it('ignores projects in `node_modules`', async function () {
const cdkJsonPath = path.join(workspaceFolders[0].uri.fsPath, 'node_modules', 'lib', 'cdk.json')
await mkdirp(path.dirname(cdkJsonPath))
await fs.mkdir(path.dirname(cdkJsonPath))
await saveCdkJson(cdkJsonPath)
const actual = await detectCdkProjects_wait(workspaceFolders)
assert.strictEqual(actual.length, 0)
Expand All @@ -118,7 +117,8 @@ describe('detectCdkProjects', function () {

it('takes into account `output` from cdk.json to build tree.json path', async function () {
const cdkJsonUri = vscode.Uri.joinPath(workspaceFolders[0].uri, 'cdk.json')
await writeJSON(cdkJsonUri.fsPath, { app: 'npx ts-node bin/demo-nov7.ts', output: 'build/cdk.out' })
const cdkJsonStr = JSON.stringify({ app: 'npx ts-node bin/demo-nov7.ts', output: 'build/cdk.out' })
await fs.writeFile(cdkJsonUri.fsPath, cdkJsonStr)
const actual = await detectCdkProjects_wait(workspaceFolders)

assert.ok(actual)
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/test/awsService/cdk/treeTestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { writeFile } from 'fs-extra'
import { ConstructTree, ConstructTreeEntity } from '../../../awsService/cdk/explorer/tree/types'
import { fs } from '../../../shared'

export async function saveCdkJson(cdkJsonPath: string) {
const cdkJsonContent = '{ "app": "npx ts-node bin/demo-nov7.ts"}'

await writeFile(cdkJsonPath, cdkJsonContent, 'utf8')
await fs.writeFile(cdkJsonPath, cdkJsonContent, 'utf8')
}

export function generateConstructTreeEntity(label: string, treePath: string, children?: boolean): ConstructTreeEntity {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import assert from 'assert'
import * as path from 'path'
import * as vscode from 'vscode'
import * as fs from 'fs-extra'

import { createURIFromArgs } from '../../../../awsService/cloudWatchLogs/cloudWatchLogsUtils'
import { saveCurrentLogDataContent } from '../../../../awsService/cloudWatchLogs/commands/saveCurrentLogDataContent'
Expand All @@ -19,6 +18,7 @@ import {
LogDataRegistry,
} from '../../../../awsService/cloudWatchLogs/registry/logDataRegistry'
import { assertTextEditorContains } from '../../../testUtil'
import { fs } from '../../../../shared'

async function testFilterLogEvents(
logGroupInfo: CloudWatchLogsGroupInfo,
Expand Down Expand Up @@ -46,7 +46,7 @@ describe('saveCurrentLogDataContent', async function () {
})

afterEach(async function () {
await fs.remove(tempDir)
await fs.delete(tempDir, { recursive: true })
})

it('saves log content to a file', async function () {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/test/awsService/ec2/sshKeyPair.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('SshKeyUtility', async function () {
})

after(async function () {
await fs.delete(temporaryDirectory, { recursive: true, force: true })
await fs.delete(temporaryDirectory, { recursive: true })
clock.uninstall()
sinon.restore()
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import assert, { fail } from 'assert'
import * as vscode from 'vscode'
import * as fs from 'fs-extra'
import * as sinon from 'sinon'
import { makeTemporaryToolkitFolder } from '../../../shared/filesystemUtilities'
import { transformByQState, TransformByQStoppedError } from '../../../codewhisperer/models/model'
Expand Down Expand Up @@ -37,6 +36,7 @@ import {
} from '../../../codewhisperer/service/transformByQ/transformProjectValidationHandler'
import { TransformationCandidateProject, ZipManifest } from '../../../codewhisperer/models/model'
import globals from '../../../shared/extensionGlobals'
import { fs } from '../../../shared'

describe('transformByQ', function () {
let tempDir: string
Expand All @@ -48,7 +48,7 @@ describe('transformByQ', function () {

afterEach(async function () {
sinon.restore()
await fs.remove(tempDir)
await fs.delete(tempDir, { recursive: true })
})

it('WHEN converting short duration in milliseconds THEN converts correctly', async function () {
Expand Down Expand Up @@ -254,13 +254,13 @@ describe('transformByQ', function () {
'resolver-status.properties',
]

m2Folders.forEach((folder) => {
for (const folder of m2Folders) {
const folderPath = path.join(tempDir, folder)
fs.mkdirSync(folderPath, { recursive: true })
filesToAdd.forEach((file) => {
fs.writeFileSync(path.join(folderPath, file), 'sample content for the test file')
})
})
await fs.mkdir(folderPath)
for (const file of filesToAdd) {
await fs.writeFile(path.join(folderPath, file), 'sample content for the test file')
}
}

const tempFileName = `testfile-${globals.clock.Date.now()}.zip`
transformByQState.setProjectPath(tempDir)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

import assert from 'assert'
import * as path from 'path'
import * as fs from 'fs-extra'
import { EnvironmentVariables } from '../../shared/environmentVariables'
import { makeTemporaryToolkitFolder } from '../../shared/filesystemUtilities'
import { getCredentialsFilename, getConfigFilename } from '../../auth/credentials/sharedCredentialsFile'
import { fs } from '../../shared'

describe('sharedCredentials', function () {
let tempFolder: string
Expand All @@ -26,7 +26,7 @@ describe('sharedCredentials', function () {
})

after(async function () {
await fs.remove(tempFolder)
await fs.delete(tempFolder, { recursive: true })
})

describe('getCredentialsFilename', function () {
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/test/credentials/sso/cache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

import assert from 'assert'
import * as path from 'path'
import * as fs from 'fs-extra'
import { makeTemporaryToolkitFolder, tryRemoveFolder } from '../../../shared/filesystemUtilities'
import { getRegistrationCache, getTokenCache } from '../../../auth/sso/cache'
import { fs } from '../../../shared'

describe('SSO Cache', function () {
const region = 'dummyRegion'
Expand Down Expand Up @@ -47,7 +47,7 @@ describe('SSO Cache', function () {
await cache.save({ startUrl, region }, validRegistration)

const cachedPath = path.join(testDir, `aws-toolkit-vscode-client-id-${region}.json`)
const contents = await fs.readFile(cachedPath, 'utf-8')
const contents = await fs.readFileAsString(cachedPath)

assert.deepStrictEqual(JSON.parse(contents), {
...validRegistration,
Expand All @@ -70,7 +70,7 @@ describe('SSO Cache', function () {

// SHA-1 hash of the encoded start URL `https://123456.awsapps.com/start`
const cachedPath = path.join(testDir, 'c1ac99f782ad92755c6de8647b510ec247330ad1.json')
const contents = await fs.readFile(cachedPath, 'utf-8')
const contents = await fs.readFileAsString(cachedPath)

assert.deepStrictEqual(JSON.parse(contents), {
region,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ import { CloudControlClient, DefaultCloudControlClient } from '../../shared/clie
import { CloudFormationClient, DefaultCloudFormationClient } from '../../shared/clients/cloudFormationClient'
import { makeTemporaryToolkitFolder, readFileAsString } from '../../shared/filesystemUtilities'
import { FakeExtensionContext } from '../fakeExtensionContext'
import { remove } from 'fs-extra'
import { existsSync } from 'fs'
import { ResourceTypeMetadata } from '../../dynamicResources/model/resources'
import globals from '../../shared/extensionGlobals'
import { Stub, stub } from '../utilities/stubber'
import { CloudControl, CloudFormation } from 'aws-sdk'
import { fs } from '../../shared'

describe('ResourceManager', function () {
let sandbox: sinon.SinonSandbox
Expand Down Expand Up @@ -71,7 +71,7 @@ describe('ResourceManager', function () {
registerMappingSpy.restore()
sandbox.restore()
await resourceManager.dispose()
await remove(tempFolder)
await fs.delete(tempFolder, { recursive: true })
})

it('opens resources in preview mode', async function () {
Expand Down
Loading
Loading