Skip to content

Commit f5ebc02

Browse files
authored
Migrate CJS to ESM (#1126)
2 parents e685f41 + 54a2958 commit f5ebc02

Some content is hidden

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

65 files changed

+3636
-6462
lines changed

Earthfile

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

2525
build:
2626
FROM +deps
27-
COPY --dir src tsconfig.json .
27+
COPY --dir src scripts tsconfig.json .
2828
COPY ./proto+protoc/pb_types src/pb_types
2929
RUN npm run build:clean
3030
SAVE ARTIFACT dist AS LOCAL ./dist
@@ -40,7 +40,7 @@ proto:
4040
test:
4141
FROM +deps
4242
COPY --dir src tsconfig.json \
43-
__tests__ jest.config.js bigquery_schema ./
43+
__tests__ vitest.config.ts bigquery_schema ./
4444
COPY ./proto+protoc/pb_types src/pb_types
4545
COPY ./proto+protoc/schema bigquery_schema/
4646
RUN npm run test:ci
@@ -58,10 +58,10 @@ docker:
5858
COPY --chmod=755 +deps/tini /tini
5959

6060
# Make "ci_analyzer" command alias
61-
RUN cd dist && ln -s index.js ci_analyzer && chmod +x ci_analyzer
61+
RUN cd dist && ln -s index.mjs ci_analyzer && chmod +x ci_analyzer
6262
ENV PATH=/ci_analyzer/dist:$PATH
6363

64-
ENTRYPOINT [ "/tini", "--", "node", "--enable-source-maps", "/ci_analyzer/dist/index.js" ]
64+
ENTRYPOINT [ "/tini", "--", "node", "--enable-source-maps", "/ci_analyzer/dist/index.mjs" ]
6565
WORKDIR /app
6666

6767
SAVE IMAGE ghcr.io/kesin11/ci_analyzer:latest
@@ -77,5 +77,5 @@ docker-push:
7777
schema:
7878
FROM +deps
7979
COPY --dir src scripts ./
80-
RUN npx ts-node scripts/create_schema.ts schema.json
80+
RUN npx tsx scripts/create_schema.ts schema.json
8181
SAVE ARTIFACT schema.json AS LOCAL ./

README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,6 @@ This repository provide devcontainer that includes all dependencies for developi
417417
## Install and test
418418
```bash
419419
npm ci
420-
npm run build
421420
npm run test
422421
```
423422

@@ -436,10 +435,17 @@ npm run docker
436435
```
437436

438437
## Execute CIAnalyzer using nodejs
438+
### Debugging
439+
439440
```bash
440-
npm run start
441-
# or
442-
node dist/index.js -c your_custom_config.yaml
441+
npx tsx src/index.ts -c your_custom_config.yaml --debug
442+
443+
```
444+
445+
### Execute production bundled build
446+
```bash
447+
npm run build
448+
npm run start -- -c your_custom_config.yaml
443449
```
444450

445451
# LICENSE

__tests__/analyzer/analyzer.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { describe, it, expect, beforeEach } from "vitest"
12
import { convertToReportTestSuites, ReportTestSuites } from '../../src/analyzer/analyzer'
23
import { TestSuites } from 'junit2json'
34

__tests__/analyzer/bitrise_analyzer.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { describe, it, expect, beforeEach } from "vitest"
12
import fs from 'fs'
23
import path from 'path'
34
import { BitriseAnalyzer } from '../../src/analyzer/bitrise_analyzer'

__tests__/analyzer/circleci_analyzer_v2.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { describe, it, expect, beforeEach } from "vitest"
12
import { CircleciAnalyzerV2 } from '../../src/analyzer/circleci_analyzer_v2'
23

34
describe('CircleciAnalyzerV2', () => {

__tests__/client/circleci_client.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { describe, it, expect, beforeEach } from "vitest"
12
import { Logger } from 'tslog'
23
import { ArgumentOptions } from '../../src/arg_options'
34
import { CircleciClient } from '../../src/client/circleci_client'

__tests__/client/circleci_client_v2.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { describe, it, expect, beforeEach } from "vitest"
12
import { Logger } from 'tslog'
23
import { ArgumentOptions } from '../../src/arg_options'
34
import { CircleciClientV2 } from '../../src/client/circleci_client_v2'

__tests__/client/github_client.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { describe, it, expect, beforeEach } from "vitest"
12
import { ArgumentOptions } from '../../src/arg_options'
23
import { GithubClient } from '../../src/client/github_client'
34

__tests__/client/jenkins_client.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { describe, it, expect, beforeEach } from "vitest"
12
import { Logger } from 'tslog'
23
import { ArgumentOptions } from '../../src/arg_options'
34
import { JenkinsClient } from '../../src/client/jenkins_client'

__tests__/config/bitrise_config.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { describe, it, expect, beforeEach } from "vitest"
12
import { parseConfig } from '../../src/config/bitrise_config'
23

34
describe('parseConfig', () => {

__tests__/config/circleci_config.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { describe, it, expect, beforeEach } from "vitest"
12
import { parseConfig } from '../../src/config/circleci_config'
23

34
describe('parseConfig', () => {

__tests__/config/github_config.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { describe, it, expect, beforeEach } from "vitest"
12
import { parseConfig } from '../../src/config/github_config'
23

34
describe('parseConfig', () => {
@@ -81,4 +82,4 @@ describe('parseConfig', () => {
8182
})
8283
})
8384
})
84-
})
85+
})

__tests__/config/jenkins_config.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { describe, it, expect, beforeEach } from "vitest"
12
import { Logger } from 'tslog'
23
import { parseConfig } from '../../src/config/jenkins_config'
34

__tests__/config/validator.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { describe, it, expect, beforeEach } from "vitest"
12
import { Logger } from 'tslog'
23
import { ValidatedYamlConfig, validateConfig } from '../../src/config/config'
34

__tests__/custom_report_collection.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { describe, it, expect, beforeEach } from "vitest"
12
import { CustomReportCollection, aggregateCustomReportArtifacts } from '../src/custom_report_collection'
23
import { CustomReportArtifact } from '../src/client/client'
34

__tests__/exporter/bigquery_exporter.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import path from "path"
2+
import { vi, describe, it, expect, beforeEach } from "vitest"
23
import { BigqueryExporter } from '../../src/exporter/bigquery_exporter'
34
import { BigqueryExporterConfig } from '../../src/config/config'
45
import { CustomReportCollection } from '../../src/custom_report_collection'
56
import { Logger } from "tslog"
67

78
const bigqueryMock = {
8-
dataset: jest.fn().mockReturnThis(),
9-
table: jest.fn().mockReturnThis(),
10-
load: jest.fn(async () => [{}]) // return success 'results' stub
9+
dataset: vi.fn().mockReturnThis(),
10+
table: vi.fn().mockReturnThis(),
11+
load: vi.fn(async () => [{}]) // return success 'results' stub
1112
}
1213
const configDir = path.join(__dirname, '..', '..')
1314
const fixtureSchemaPath = {

__tests__/exporter/local_exporter.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
import { vi, describe, it, expect, beforeEach } from "vitest"
12
import { LocalExporter } from '../../src/exporter/local_exporter'
23
import path from 'path'
34
import { LocalExporterConfig } from '../../src/config/config'
45
import { Logger } from 'tslog'
56

67
const mockFsPromises = {
7-
mkdir: jest.fn(),
8-
writeFile: jest.fn(),
8+
mkdir: vi.fn(),
9+
writeFile: vi.fn(),
910
}
1011
const logger = new Logger({ type: "hidden" })
1112

__tests__/last_run_store.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { describe, it, expect, beforeEach } from "vitest"
12
import { LastRunStore } from '../src/last_run_store'
23
import { Store, AnyObject } from '../src/store/store'
34

__tests__/runner/circleci_runner_v1.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { vi, describe, it, expect, beforeEach } from "vitest"
12
import { CircleciRunnerV1, CircleciV1LastRunMetadata } from '../../src/runner/circleci_runner_v1'
23
import { Logger } from 'tslog'
34
import { ArgumentOptions } from '../../src/arg_options'

__tests__/runner/circleci_runner_v2.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { vi, describe, it, expect, beforeEach } from "vitest"
12
import { CircleciRunnerV2, CircleciV2LastRunMetadata } from '../../src/runner/circleci_runner_v2'
23
import { Logger } from 'tslog'
34
import { ArgumentOptions } from '../../src/arg_options'

__tests__/store/local_store.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { vi, describe, it, expect, beforeEach, afterEach } from "vitest"
12
import { LocalStore } from '../../src/store/local_store'
23
import os from 'os'
34
import fs from 'fs'

__tests__/store/null_store.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { describe, it, expect, beforeEach } from "vitest"
12
import { Logger } from 'tslog'
23
import { NullStore } from '../../src/store/null_store'
34

jest.config.js

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

0 commit comments

Comments
 (0)