Skip to content

Commit 815c0c3

Browse files
authored
Migrate to ESM (#324)
* ESM migrate first pass * ESM migration wip * Fix build * Fix some build and linting issues * Downgrade pqueue * Downgrade to vite 2 * Downgrade to vite 2 * Continue cleaning things up * Use 'with' for JSON imports * Fix tests again * Upgrade eslint and fix linting * Update node version in a few more places * Update archive tests * Fix logger styes * Fix CMS exports * Explicit CMS export * Exlcude tests in TS build * Upgrade eslint and downgrade node * Remove eslintignore * Remove v * Fix build * Fix tests * Fix gh action * Replace usage of __dirname
1 parent 7ce59a5 commit 815c0c3

File tree

139 files changed

+1295
-1046
lines changed

Some content is hidden

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

139 files changed

+1295
-1046
lines changed

.eslintignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

.eslintrc.js

Lines changed: 0 additions & 38 deletions
This file was deleted.

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
node-version: [18.x]
14+
node-version: [20.x]
1515
steps:
1616
- uses: actions/checkout@v2
1717
- name: Use Node.js ${{ matrix.node-version }}

api/__tests__/devSecrets.test.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
jest.mock('../../http');
2-
import { http } from '../../http';
1+
import { http } from '../../http/index.js';
2+
import { vi, type MockedFunction } from 'vitest';
33
import {
44
addAppSecret,
55
updateAppSecret,
66
deleteAppSecret,
77
fetchAppSecrets,
8-
} from '../devSecrets';
8+
} from '../devSecrets.js';
99

10-
const httpPostMock = http.post as jest.MockedFunction<typeof http.post>;
11-
const httpPatchMock = http.patch as jest.MockedFunction<typeof http.patch>;
12-
const httpDeleteMock = http.delete as jest.MockedFunction<typeof http.delete>;
13-
const httpGetMock = http.get as jest.MockedFunction<typeof http.get>;
10+
vi.mock('../../http');
11+
12+
const httpPostMock = http.post as MockedFunction<typeof http.post>;
13+
const httpPatchMock = http.patch as MockedFunction<typeof http.patch>;
14+
const httpDeleteMock = http.delete as MockedFunction<typeof http.delete>;
15+
const httpGetMock = http.get as MockedFunction<typeof http.get>;
1416

1517
describe('api/devSecrets', () => {
1618
const accountId = 123;

api/__tests__/fileMapper.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import fileStreamResponse from './fixtures/fileStreamResponse.json';
2-
import { createFileMapperNodeFromStreamResponse } from '../fileMapper';
1+
import fileStreamResponse from './fixtures/fileStreamResponse.json' with { type: 'json' };
2+
import { createFileMapperNodeFromStreamResponse } from '../fileMapper.js';
33

44
describe('api/fileMapper', () => {
55
describe('createFileMapperNodeFromStreamResponse()', () => {

api/__tests__/projects.test.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
jest.mock('../../http');
2-
jest.mock('fs');
1+
vi.mock('../../http');
2+
vi.mock('fs');
33
import { createReadStream } from 'fs';
4-
import { http } from '../../http';
4+
import { http } from '../../http/index.js';
5+
import { vi, type MockedFunction } from 'vitest';
56
import {
67
cancelStagedBuild,
78
checkCloneStatus,
@@ -30,13 +31,13 @@ import {
3031
queueBuild,
3132
uploadFileToBuild,
3233
uploadProject,
33-
} from '../projects';
34+
} from '../projects.js';
3435

35-
const createReadStreamMock = createReadStream as jest.MockedFunction<
36+
const createReadStreamMock = createReadStream as MockedFunction<
3637
typeof createReadStream
3738
>;
3839

39-
const httpPostMock = http.post as jest.MockedFunction<typeof http.post>;
40+
const httpPostMock = http.post as MockedFunction<typeof http.post>;
4041

4142
describe('api/projects', () => {
4243
const accountId = 999999;

api/appsDev.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { http } from '../http';
1+
import { http } from '../http/index.js';
22
import {
33
PublicApp,
44
PublicAppInstallCounts,
55
PublicAppDeveloperTestAccountInstallData,
66
FetchPublicAppsForPortalResponse,
7-
} from '../types/Apps';
8-
import { HubSpotPromise } from '../types/Http';
7+
} from '../types/Apps.js';
8+
import { HubSpotPromise } from '../types/Http.js';
99

1010
const APPS_DEV_API_PATH = 'apps-dev/external/public/v3';
1111
const APPS_HUBLETS_API_PATH = 'apps-hublets/external/static-token/v3';

api/crm.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import path from 'path';
22
import fs from 'fs-extra';
33
import FormData from 'form-data';
44

5-
import { http } from '../http';
6-
import { getCwd } from '../lib/path';
7-
import { HubSpotPromise } from '../types/Http';
8-
import { ImportRequest, ImportResponse } from '../types/Crm';
5+
import { http } from '../http/index.js';
6+
import { getCwd } from '../lib/path.js';
7+
import { HubSpotPromise } from '../types/Http.js';
8+
import { ImportRequest, ImportResponse } from '../types/Crm.js';
99

1010
const HUBSPOT_CRM_IMPORT_PATH = '/crm/v3/imports';
1111

api/customObjects.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { http } from '../http';
1+
import { http } from '../http/index.js';
22
import {
33
FetchSchemasResponse,
44
Schema,
55
SchemaDefinition,
66
ObjectDefinition,
77
CreateObjectsResponse,
8-
} from '../types/Schemas';
9-
import { HubSpotPromise } from '../types/Http';
8+
} from '../types/Schemas.js';
9+
import { HubSpotPromise } from '../types/Http.js';
1010

1111
const CUSTOM_OBJECTS_API_PATH = 'crm/v3/objects';
1212
const SCHEMA_API_PATH = 'crm-object-schemas/v3/schemas';

api/designManager.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { http } from '../http';
2-
import { HubSpotPromise, QueryParams } from '../types/Http';
1+
import { http } from '../http/index.js';
2+
import { HubSpotPromise, QueryParams } from '../types/Http.js';
33
import {
44
FetchThemesResponse,
55
FetchBuiltinMappingResponse,
6-
} from '../types/DesignManager';
6+
} from '../types/DesignManager.js';
77

88
const DESIGN_MANAGER_API_PATH = 'designmanager/v1';
99

0 commit comments

Comments
 (0)