Skip to content

Commit 04a8b08

Browse files
authored
[ENG-4579][scripts] convert to ESM (#1192)
* upgrade typescript to 4.7.4 * [scripts] add extensions to imports * [scripts] configure as ESM * [scripts] fix after converting to ESM * [scripts] fix lint * [scripts] require node >= 14.16 * [scripts] add node: protocol * add scripts/build to .gitignore * [scripts] add typecheck script * add workflow for testing scripts * address PR feedback
1 parent 8bce9b1 commit 04a8b08

File tree

16 files changed

+82
-45
lines changed

16 files changed

+82
-45
lines changed

.github/workflows/test-scripts.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Test scripts
2+
3+
defaults:
4+
run:
5+
working-directory: scripts
6+
7+
on:
8+
push:
9+
branches: [main]
10+
paths:
11+
- 'scripts/**'
12+
pull_request:
13+
paths:
14+
- 'scripts/**'
15+
16+
jobs:
17+
test:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v2
21+
- name: Setup node
22+
uses: actions/setup-node@v2
23+
with:
24+
node-version: 18
25+
- run: yarn install --frozen-lockfile --check-files
26+
- run: yarn typecheck

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
packages/*/build
33
packages/eas-cli/dist
44
packages/eas-cli/tmp
5+
scripts/build
56

67
# Code editors
78
.idea

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"oclif": "3.0.1",
3030
"prettier": "2.6.2",
3131
"ts-jest": "28.0.2",
32-
"typescript": "4.6.4"
32+
"typescript": "4.7.4"
3333
},
3434
"volta": {
3535
"node": "18.2.0",

packages/eas-cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
"nock": "13.2.4",
104104
"tempy": "0.7.0",
105105
"ts-deepmerge": "2.0.1",
106-
"typescript": "4.6.4"
106+
"typescript": "4.7.4"
107107
},
108108
"engines": {
109109
"node": ">=14.0.0"

packages/eas-json/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"devDependencies": {
1919
"@types/fs-extra": "9.0.13",
2020
"memfs": "3.4.3",
21-
"typescript": "4.6.4"
21+
"typescript": "4.7.4"
2222
},
2323
"engines": {
2424
"node": ">=14.0.0"
File renamed without changes.

scripts/package.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,34 @@
11
{
22
"name": "scripts",
33
"private": true,
4+
"type": "module",
45
"version": "0.31.0",
56
"scripts": {
6-
"changelog-entry": "ts-node src/changelogEntry.ts",
7-
"release-changelog": "ts-node src/releaseChangelog.ts",
8-
"update-local-plugin": "./src/updateLocalPlugin.sh"
7+
"changelog-entry": "ts-node-esm src/changelogEntry.ts",
8+
"release-changelog": "ts-node-esm src/releaseChangelog.ts",
9+
"update-local-plugin": "./src/updateLocalPlugin.sh",
10+
"typecheck": "tsc"
911
},
1012
"author": "Expo <[email protected]>",
1113
"license": "MIT",
1214
"engines": {
13-
"node": ">=14.0.0"
15+
"node": ">=14.16"
1416
},
1517
"dependencies": {
1618
"dateformat": "4.5.1",
1719
"fs-extra": "10.1.0",
18-
"lodash": "4.17.21",
20+
"lodash-es": "4.17.21",
1921
"marked": "3.0.4",
20-
"nullthrows": "1.1.1",
2122
"semver": "7.3.7",
2223
"tslib": "2.4.0"
2324
},
2425
"devDependencies": {
2526
"@types/dateformat": "3.0.1",
2627
"@types/fs-extra": "9.0.13",
27-
"@types/lodash": "4.14.182",
28+
"@types/lodash-es": "4.17.6",
2829
"@types/node": "17.0.32",
2930
"@types/semver": "7.3.9",
3031
"ts-node": "10.7.0",
31-
"typescript": "4.6.4"
32+
"typescript": "4.7.4"
3233
}
3334
}

scripts/src/changelog/consts.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import path from 'path';
1+
import { URL } from 'node:url';
22

33
export enum EntryCategory {
44
BreakingChange = 'breaking-change',
@@ -7,7 +7,7 @@ export enum EntryCategory {
77
Chore = 'chore',
88
}
99

10-
export const CHANGELOG_PATH = path.join(__dirname, '../../../CHANGELOG.md');
10+
export const CHANGELOG_PATH = new URL('../../../CHANGELOG.md', import.meta.url);
1111

1212
export const CATEGORY_HEADERS: Record<EntryCategory, string> = {
1313
[EntryCategory.BreakingChange]: '🛠 Breaking changes',

scripts/src/changelog/file.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fs from 'fs-extra';
22

3-
import * as markdown from '../markdown';
4-
import { CHANGELOG_PATH } from './consts';
3+
import * as markdown from '../markdown.js';
4+
import { CHANGELOG_PATH } from './consts.js';
55

66
export async function readAndParseChangelogAsync(): Promise<markdown.Tokens> {
77
const contents = await fs.readFile(CHANGELOG_PATH, 'utf8');

scripts/src/changelogEntry.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import nullthrows from 'nullthrows';
2-
3-
import { CATEGORY_HEADERS, EntryCategory } from './changelog/consts';
4-
import { readAndParseChangelogAsync, writeChangelogAsync } from './changelog/file';
5-
import * as markdown from './markdown';
1+
import { CATEGORY_HEADERS, EntryCategory } from './changelog/consts.js';
2+
import { readAndParseChangelogAsync, writeChangelogAsync } from './changelog/file.js';
3+
import * as markdown from './markdown.js';
4+
import { nullthrows } from './nullthrows.js';
65

76
const [rawCategory, ...rest] = process.argv.slice(2);
87
const message = rest.join(' ');

0 commit comments

Comments
 (0)