Skip to content

Commit e625766

Browse files
committed
chore: refactor network into two packages, network and network-tools. network-tools is expected to be used in simple environments, where network is intended to be used in the node context. additionally, makes these packages bundable and removes the ts-node entrypoint to make ESM possible.
1 parent e3f4064 commit e625766

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+543
-312
lines changed

.circleci/src/pipeline/@pipeline.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ commands:
198198
name: Sync Cloud Validations
199199
command: |
200200
source ./scripts/ensure-node.sh
201+
yarn workspace @packages/network-tools build
202+
yarn workspace @packages/network build
201203
yarn gulp syncCloudValidations
202204
- run:
203205
name: Build packages
@@ -1234,6 +1236,8 @@ commands:
12341236
name: Check if binary exists, exit if it does
12351237
command: |
12361238
source ./scripts/ensure-node.sh
1239+
yarn workspace @packages/network-tools build
1240+
yarn workspace @packages/network build
12371241
yarn gulp e2eTestScaffold
12381242
yarn check-binary-on-cdn --version $(node ./scripts/get-next-version.js) --type binary --file cypress.zip
12391243

guides/esm-migration.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ When migrating some of these projects away from the `ts-node` entry [see `@packa
5353
- [x] packages/launcher ✅ **COMPLETED**
5454
- [x] packages/launchpad ✅ **COMPLETED**
5555
- [x] packages/net-stubbing ✅ **COMPLETED**
56-
- [ ] packages/network **PARTIAL** - entry point is JS
56+
- [x] packages/network ✅ **COMPLETED**
57+
- [x] packages/network-tools ✅ **COMPLETED**
5758
- [x] packages/packherd-require ✅ **COMPLETED**
5859
- [ ] packages/proxy **PARTIAL** - entry point is JS
5960
- [x] packages/reporter ✅ **COMPLETED**
@@ -103,6 +104,7 @@ When migrating some of these projects away from the `ts-node` entry [see `@packa
103104
- [ ] packages/launcher
104105
- [ ] packages/net-stubbing
105106
- [x] packages/network ✅ **COMPLETED**
107+
- [x] packages/network-tools ✅ **COMPLETED**
106108
- [ ] packages/packherd-require
107109
- [ ] packages/proxy
108110
- [x] packages/rewriter ✅ **COMPLETED**

packages/config/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,13 @@
4040
},
4141
"devDependencies": {
4242
"@packages/errors": "0.0.0-development",
43-
"@packages/network": "0.0.0-development",
43+
"@packages/network-tools": "0.0.0-development",
4444
"@packages/root": "0.0.0-development",
4545
"@packages/ts": "0.0.0-development",
4646
"@packages/types": "0.0.0-development",
4747
"babel-plugin-tester": "^10.1.0",
4848
"rimraf": "6.0.1",
49+
"typescript": "~5.4.5",
4950
"vitest": "^3.2.4"
5051
},
5152
"files": [

packages/config/src/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import _ from 'lodash'
22
import { toBoolean } from 'underscore.string'
3-
import * as uri from '@packages/network/lib/uri'
3+
import { origin } from '@packages/network-tools'
44

55
export const hideKeys = (token?: string | number | boolean) => {
66
if (!token) {
@@ -26,7 +26,7 @@ export function setUrls (obj: any) {
2626
const proxyUrl = `http://localhost:${obj.port}`
2727

2828
const rootUrl = obj.baseUrl
29-
? uri.origin(obj.baseUrl)
29+
? origin(obj.baseUrl)
3030
: proxyUrl
3131

3232
return {

packages/driver/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"@packages/config": "0.0.0-development",
2727
"@packages/errors": "0.0.0-development",
2828
"@packages/net-stubbing": "0.0.0-development",
29-
"@packages/network": "0.0.0-development",
29+
"@packages/network-tools": "0.0.0-development",
3030
"@packages/proxy": "0.0.0-development",
3131
"@packages/rewriter": "0.0.0-development",
3232
"@packages/runner": "0.0.0-development",

packages/driver/src/cy/commands/origin/validator.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import $utils from '../../../cypress/utils'
22
import $errUtils from '../../../cypress/error_utils'
33
import { difference, isPlainObject, isString, isFunction } from 'lodash'
44
import type { LocationObject } from '../../../cypress/location'
5-
import * as cors from '@packages/network/lib/cors'
6-
import { DocumentDomainInjection } from '@packages/network/lib/document-domain-injection'
5+
import { policyFromConfig, DocumentDomainInjection } from '@packages/network-tools'
76

87
const validOptionKeys = Object.freeze(['args'])
98

@@ -87,7 +86,7 @@ export class Validator {
8786

8887
const injector = DocumentDomainInjection.InjectionBehavior(Cypress.config())
8988

90-
const policy = cors.policyFromConfig({ injectDocumentDomain: Cypress.config('injectDocumentDomain') })
89+
const policy = policyFromConfig({ injectDocumentDomain: Cypress.config('injectDocumentDomain') })
9190

9291
if (injector.urlsMatch(originLocation.href, specHref)) {
9392
$errUtils.throwErrByPath('origin.invalid_url_argument_same_origin', {

packages/driver/src/cypress.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import { PrimaryOriginCommunicator, SpecBridgeCommunicator } from './cross-origi
4545
import { setupAutEventHandlers } from './cypress/aut_event_handlers'
4646

4747
import type { CachedTestState, ReporterRunState, RunState } from '@packages/types'
48-
import { DocumentDomainInjection } from '@packages/network/lib/document-domain-injection'
48+
import { DocumentDomainInjection } from '@packages/network-tools'
4949
import { setSpecContentSecurityPolicy } from './util/privileged_channel'
5050

5151
import { telemetry } from '@packages/telemetry/src/browser'

packages/driver/src/cypress/location.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import _ from 'lodash'
1010
import UrlParse from 'url-parse'
11-
import * as cors from '@packages/network/lib/cors'
11+
import { getSuperDomain, getSuperDomainOrigin } from '@packages/network-tools'
1212

1313
const reHttp = /^https?:\/\//
1414
const reWww = /^www/
@@ -106,11 +106,11 @@ export class $Location {
106106
}
107107

108108
getSuperDomainOrigin () {
109-
return cors.getSuperDomainOrigin(this.remote.href)
109+
return getSuperDomainOrigin(this.remote.href)
110110
}
111111

112112
getSuperDomain () {
113-
return cors.getSuperDomain(this.remote.href)
113+
return getSuperDomain(this.remote.href)
114114
}
115115

116116
getToString () {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/tsconfig.json

packages/network-tools/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
cjs/
2+
esm/

0 commit comments

Comments
 (0)