Skip to content

Commit

Permalink
refactor: replace uuid with nanoid (#1687)
Browse files Browse the repository at this point in the history
  • Loading branch information
web-padawan authored Sep 24, 2021
1 parent adeab90 commit d4f92e2
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 26 deletions.
8 changes: 8 additions & 0 deletions .changeset/khaki-boxes-pretend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@web/test-runner-browserstack': patch
'@web/test-runner-core': patch
'@web/test-runner-saucelabs': patch
'@web/test-runner': patch
---

Replace uuid dependency with nanoid
5 changes: 2 additions & 3 deletions packages/dev-server-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,9 @@
"@types/koa-static": "^4.0.1",
"@types/lru-cache": "^5.1.0",
"@types/parse5": "^6.0.1",
"@types/uuid": "^8.3.0",
"abort-controller": "^3.0.0",
"nanoid": "^3.1.25",
"node-fetch": "3.0.0-beta.9",
"portfinder": "^1.0.28",
"uuid": "^8.3.2"
"portfinder": "^1.0.28"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { expect } from 'chai';
import fetch from 'node-fetch';
import path from 'path';
import fs from 'fs';
import { v4 as uuid } from 'uuid';
import { nanoid } from 'nanoid';

import { createTestServer, timeout } from '../helpers';
import { DevServer } from '../../src/server/DevServer';
Expand Down Expand Up @@ -71,7 +71,7 @@ describe('etag cache middleware', () => {
expect(etag).to.be.a('string');

await timeout(10);
const fileContent = `// the cache is busted${uuid()}`;
const fileContent = `// the cache is busted${nanoid()}`;
fs.writeFileSync(testFileBPath, fileContent, 'utf-8');
server.fileWatcher.emit('change', testFileBPath);

Expand Down
4 changes: 2 additions & 2 deletions packages/test-runner-browserstack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
"@web/test-runner-selenium": "^0.5.0",
"browserstack-local": "^1.4.8",
"ip": "^1.1.5",
"selenium-webdriver": "^4.0.0-alpha.8",
"uuid": "^8.3.2"
"nanoid": "^3.1.25",
"selenium-webdriver": "^4.0.0-alpha.8"
},
"devDependencies": {
"@types/ip": "^1.1.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/test-runner-browserstack/src/browserstackManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
import browserstack from 'browserstack-local';
import { BrowserLauncher } from '@web/test-runner-core';
import { promisify } from 'util';
import { v4 as uuid } from 'uuid';
import { nanoid } from 'nanoid';

const launchers = new Set<BrowserLauncher>();
let connection: browserstack.Local | undefined = undefined;

export const localId = `web-test-runner-${uuid()}`;
export const localId = `web-test-runner-${nanoid()}`;

async function setupLocalConnection(password: string, options: Partial<browserstack.Options> = {}) {
process.on('SIGINT', closeLocalConnection);
Expand Down
5 changes: 2 additions & 3 deletions packages/test-runner-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
"@types/debounce": "^1.2.0",
"@types/istanbul-lib-coverage": "^2.0.3",
"@types/istanbul-reports": "^3.0.0",
"@types/uuid": "^8.3.0",
"@web/browser-logs": "^0.2.1",
"@web/dev-server-core": "^0.3.12",
"chalk": "^4.1.0",
Expand All @@ -73,10 +72,10 @@
"istanbul-lib-report": "^3.0.0",
"istanbul-reports": "^3.0.2",
"log-update": "^4.0.0",
"nanoid": "^3.1.25",
"open": "^8.0.2",
"picomatch": "^2.2.2",
"source-map": "^0.7.3",
"uuid": "^8.3.2"
"source-map": "^0.7.3"
},
"devDependencies": {
"portfinder": "^1.0.28"
Expand Down
4 changes: 2 additions & 2 deletions packages/test-runner-core/src/runner/createDebugSessions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { v4 as uuid } from 'uuid';
import { nanoid } from 'nanoid';
import { DebugTestSession } from '../test-session/DebugTestSession';
import { TestSession } from '../test-session/TestSession';

Expand All @@ -8,7 +8,7 @@ export function createDebugSessions(sessions: TestSession[]): DebugTestSession[]
for (const session of sessions) {
const debugSession: DebugTestSession = {
...session,
id: uuid(),
id: nanoid(),
debug: true,
};

Expand Down
4 changes: 2 additions & 2 deletions packages/test-runner-core/src/runner/createSessionGroups.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { v4 as uuid } from 'uuid';
import { nanoid } from 'nanoid';
import path from 'path';

import { SESSION_STATUS } from '../test-session/TestSessionStatus';
Expand Down Expand Up @@ -94,7 +94,7 @@ export function createTestSessions(
for (const testFile of testFilesForGroup) {
for (const browser of group.browsers) {
const session: TestSession = {
id: uuid(),
id: nanoid(),
group: sessionGroup,
debug: false,
testRun: -1,
Expand Down
2 changes: 1 addition & 1 deletion packages/test-runner-saucelabs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
"dependencies": {
"@web/test-runner-webdriver": "^0.4.2",
"ip": "^1.1.5",
"nanoid": "^3.1.25",
"saucelabs": "^4.6.2",
"uuid": "^8.3.2",
"webdriver": "^7.9.0",
"webdriverio": "^7.9.0"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/test-runner-saucelabs/src/createSauceLabsLauncher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { SauceLabsOptions, SauceConnectOptions } from 'saucelabs';
import WebDriver from 'webdriver';
import { RemoteOptions } from 'webdriverio';
import { Options } from '@wdio/types';
import { v4 as uuid } from 'uuid';
import { nanoid } from 'nanoid';

import { SauceLabsLauncher } from './SauceLabsLauncher';
import { SauceLabsLauncherManager } from './SauceLabsLauncherManager';
Expand Down Expand Up @@ -32,7 +32,7 @@ export function createSauceLabsLauncher(

const finalConnectOptions: SauceConnectOptions = { ...sauceConnectOptions };
if (typeof finalConnectOptions.tunnelIdentifier !== 'string') {
finalConnectOptions.tunnelIdentifier = `web-test-runner-${uuid()}`;
finalConnectOptions.tunnelIdentifier = `web-test-runner-${nanoid()}`;
}
const manager = new SauceLabsLauncherManager(finalSauceLabsOptions, finalConnectOptions);

Expand Down
9 changes: 2 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2240,11 +2240,6 @@
resolved "https://registry.yarnpkg.com/@types/unist/-/unist-2.0.6.tgz#250a7b16c3b91f672a24552ec64678eeb1d3a08d"
integrity sha512-PBjIUxZHOuj0R15/xuwJYjFi+KZdNFrehocChv4g5hu6aFroHue8m0lBP0POdK2nKzbw0cgV1mws8+V/JAcEkQ==

"@types/uuid@^8.3.0":
version "8.3.1"
resolved "https://registry.yarnpkg.com/@types/uuid/-/uuid-8.3.1.tgz#1a32969cf8f0364b3d8c8af9cc3555b7805df14f"
integrity sha512-Y2mHTRAbqfFkpjldbkHGY8JIzRN6XqYRliG8/24FcHm2D2PwW24fl5xMRTVGdrb7iMrwCaIEbLWerGIkXuFWVg==

"@types/valid-url@^1.0.3":
version "1.0.3"
resolved "https://registry.yarnpkg.com/@types/valid-url/-/valid-url-1.0.3.tgz#a124389fb953559c7f889795a98620e91adb3687"
Expand Down Expand Up @@ -8155,7 +8150,7 @@ nanoid@3.1.20:
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.1.20.tgz#badc263c6b1dcf14b71efaa85f6ab4c1d6cfc788"
integrity sha512-a1cQNyczgKbLX9jwbS/+d7W8fX/RfgYR7lVWwWOGIPNgK2m0MWvrGF6/m4kk6U3QcFMnZf3RIhL0v2Jgh/0Uxw==

nanoid@^3.1.23:
nanoid@^3.1.23, nanoid@^3.1.25:
version "3.1.25"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.1.25.tgz#09ca32747c0e543f0e1814b7d3793477f9c8e152"
integrity sha512-rdwtIXaXCLFAQbnfqDRnI6jaRHp9fTcYBjtFKE8eezcZ7LuLjhUaQGNeMXf1HmRoCH32CLz6XwX0TtxEOS/A3Q==
Expand Down Expand Up @@ -11985,7 +11980,7 @@ utils-merge@1.0.1:
resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713"
integrity sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=

uuid@^8.0.0, uuid@^8.3.2:
uuid@^8.0.0:
version "8.3.2"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==
Expand Down

0 comments on commit d4f92e2

Please sign in to comment.