Skip to content

Commit 36aead1

Browse files
committed
Use common uuid generator everywhere
1 parent 6a7bd87 commit 36aead1

File tree

32 files changed

+55
-63
lines changed

32 files changed

+55
-63
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
"typedoc": "^0.22.11",
5757
"typedoc-plugin-external-module-map": "1.3.2",
5858
"typescript": "~4.5.5",
59-
"uuid": "^8.0.0",
6059
"yargs": "^15.3.1"
6160
},
6261
"scripts": {

packages/core/src/browser/tooltip-service.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import * as React from 'react';
1919
import ReactTooltip from 'react-tooltip';
2020
import { ReactRenderer, RendererHost } from './widgets/react-renderer';
2121
import { CorePreferences } from './core-preferences';
22-
import { v4 } from 'uuid';
22+
import { generateUuid } from '../common/uuid';
2323

2424
export const TooltipService = Symbol('TooltipService');
2525

@@ -59,7 +59,7 @@ export class TooltipServiceImpl extends ReactRenderer implements TooltipService
5959
@inject(RendererHost) @optional() host?: RendererHost
6060
) {
6161
super(host);
62-
this.tooltipId = v4();
62+
this.tooltipId = generateUuid();
6363
}
6464

6565
@postConstruct()

packages/core/src/common/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,6 @@ export * from './strings';
4646
export * from './telemetry';
4747
export * from './types';
4848
export { default as URI } from './uri';
49+
export * from './uuid';
4950
export * from './view-column';
5051
export * from './version';

packages/core/src/electron-main/electron-main-application-module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// *****************************************************************************
1616

1717
import { ContainerModule } from 'inversify';
18-
import { v4 } from 'uuid';
18+
import { generateUuid } from '../common/uuid';
1919
import { bindContributionProvider } from '../common/contribution-provider';
2020
import { RpcConnectionHandler } from '../common/messaging/proxy-factory';
2121
import { ElectronSecurityToken } from '../electron-common/electron-token';
@@ -29,7 +29,7 @@ import { ElectronSecurityTokenService } from './electron-security-token-service'
2929
import { ElectronMessagingService } from './messaging/electron-messaging-service';
3030
import { ElectronConnectionHandler } from './messaging/electron-connection-handler';
3131

32-
const electronSecurityToken: ElectronSecurityToken = { value: v4() };
32+
const electronSecurityToken: ElectronSecurityToken = { value: generateUuid() };
3333
// eslint-disable-next-line @typescript-eslint/no-explicit-any
3434
(global as any)[ElectronSecurityToken] = electronSecurityToken;
3535

packages/filesystem/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
"stat-mode": "^1.0.0",
1919
"tar-fs": "^1.16.2",
2020
"trash": "^7.2.0",
21-
"uuid": "^8.0.0",
2221
"vscode-languageserver-textdocument": "^1.0.1"
2322
},
2423
"publishConfig": {

packages/filesystem/src/node/disk-file-system-provider.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { equal, fail } from 'assert';
2525
import { promises as fs } from 'fs';
2626
import { join } from 'path';
2727
import * as temp from 'temp';
28-
import { v4 } from 'uuid';
28+
import { generateUuid } from '@theia/core/lib/common/uuid';
2929
import { FilePermission, FileSystemProviderError, FileSystemProviderErrorCode } from '../common/files';
3030
import { DiskFileSystemProvider } from './disk-file-system-provider';
3131
import { bindFileSystemWatcherServer } from './filesystem-backend-module';
@@ -53,7 +53,7 @@ describe('disk-file-system-provider', () => {
5353
describe('stat', () => {
5454
it("should omit the 'permissions' property of the stat if the file can be both read and write", async () => {
5555
const tempDirPath = tracked.mkdirSync();
56-
const tempFilePath = join(tempDirPath, `${v4()}.txt`);
56+
const tempFilePath = join(tempDirPath, `${generateUuid()}.txt`);
5757
await fs.writeFile(tempFilePath, 'some content', { encoding: 'utf8' });
5858

5959
let content = await fs.readFile(tempFilePath, { encoding: 'utf8' });
@@ -70,7 +70,7 @@ describe('disk-file-system-provider', () => {
7070

7171
it("should set the 'permissions' property to `Readonly` if the file can be read but not write", async () => {
7272
const tempDirPath = tracked.mkdirSync();
73-
const tempFilePath = join(tempDirPath, `${v4()}.txt`);
73+
const tempFilePath = join(tempDirPath, `${generateUuid()}.txt`);
7474
await fs.writeFile(tempFilePath, 'readonly content', {
7575
encoding: 'utf8',
7676
});

packages/filesystem/src/node/disk-file-system-provider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
import { injectable, inject, postConstruct } from '@theia/core/shared/inversify';
2626
import { basename, dirname, normalize, join } from 'path';
27-
import { v4 } from 'uuid';
27+
import { generateUuid } from '@theia/core/lib/common/uuid';
2828
import * as os from 'os';
2929
import * as fs from 'fs';
3030
import {
@@ -525,7 +525,7 @@ export class DiskFileSystemProvider implements Disposable,
525525

526526
protected async rimrafMove(path: string): Promise<void> {
527527
try {
528-
const pathInTemp = join(os.tmpdir(), v4());
528+
const pathInTemp = join(os.tmpdir(), generateUuid());
529529
try {
530530
await promisify(rename)(path, pathInTemp);
531531
} catch (error) {

packages/filesystem/src/node/download/file-download-handler.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import * as os from 'os';
1818
import * as fs from '@theia/core/shared/fs-extra';
1919
import * as path from 'path';
20-
import { v4 } from 'uuid';
20+
import { generateUuid } from '@theia/core/lib/common/uuid';
2121
import { Request, Response } from '@theia/core/shared/express';
2222
import { inject, injectable } from '@theia/core/shared/inversify';
2323
import { OK, BAD_REQUEST, METHOD_NOT_ALLOWED, NOT_FOUND, INTERNAL_SERVER_ERROR, REQUESTED_RANGE_NOT_SATISFIABLE, PARTIAL_CONTENT } from 'http-status-codes';
@@ -135,12 +135,12 @@ export abstract class FileDownloadHandler {
135135
end: (isNaN(end) || end > statSize - 1) ? (statSize - 1) : end
136136
};
137137
}
138-
protected async archive(inputPath: string, outputPath: string = path.join(os.tmpdir(), v4()), entries?: string[]): Promise<string> {
138+
protected async archive(inputPath: string, outputPath: string = path.join(os.tmpdir(), generateUuid()), entries?: string[]): Promise<string> {
139139
await this.directoryArchiver.archive(inputPath, outputPath, entries);
140140
return outputPath;
141141
}
142142

143-
protected async createTempDir(downloadId: string = v4()): Promise<string> {
143+
protected async createTempDir(downloadId: string = generateUuid()): Promise<string> {
144144
const outputPath = path.join(os.tmpdir(), downloadId);
145145
await fs.mkdir(outputPath);
146146
return outputPath;
@@ -221,7 +221,7 @@ export class SingleFileDownloadHandler extends FileDownloadHandler {
221221
return;
222222
}
223223
try {
224-
const downloadId = v4();
224+
const downloadId = generateUuid();
225225
const options: PrepareDownloadOptions = { filePath, downloadId, remove: false };
226226
if (!stat.isDirectory()) {
227227
await this.prepareDownload(request, response, options);
@@ -271,7 +271,7 @@ export class MultiFileDownloadHandler extends FileDownloadHandler {
271271
}
272272
}
273273
try {
274-
const downloadId = v4();
274+
const downloadId = generateUuid();
275275
const outputRootPath = await this.createTempDir(downloadId);
276276
const distinctUris = Array.from(new Set(body.uris.map(uri => new URI(uri))));
277277
const tarPaths = [];

packages/mini-browser/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"@types/mime-types": "^2.1.0",
99
"mime-types": "^2.1.18",
1010
"pdfobject": "^2.0.201604172",
11-
"uuid": "^8.0.0",
1211
"vhost": "^3.0.2"
1312
},
1413
"publishConfig": {

packages/mini-browser/src/browser/environment/mini-browser-environment.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { Endpoint, FrontendApplicationContribution } from '@theia/core/lib/brows
1818
import { EnvVariablesServer } from '@theia/core/lib/common/env-variables';
1919
import { environment } from '@theia/core/shared/@theia/application-package/lib/environment';
2020
import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
21-
import { v4 } from 'uuid';
21+
import { generateUuid } from '@theia/core/lib/common/uuid';
2222
import { MiniBrowserEndpoint } from '../../common/mini-browser-endpoint';
2323

2424
/**
@@ -71,7 +71,7 @@ export class MiniBrowserEnvironment implements FrontendApplicationContribution {
7171
* Throws if `hostPatternPromise` is not yet resolved.
7272
*/
7373
getRandomEndpoint(): Endpoint {
74-
return this.getEndpoint(v4());
74+
return this.getEndpoint(generateUuid());
7575
}
7676

7777
protected async getHostPattern(): Promise<string> {

0 commit comments

Comments
 (0)