Skip to content

Commit d76c0ae

Browse files
authored
fix: use newest import attributes syntax (#993)
## 🧰 Changes TC39 updated their import _assertions_ to be import _attributes_ and it's a bit of a mess now that we're running tests against Node v22. Here's what importing JSON in ESM used to look like: ```js import { x } from "./mod" assert { type: "json" } ``` now it looks like this: ```js import { x } from "./mod" with { type: "json" }; ``` Support for this new `with` keyword was added in [Node v18.20.0](https://github.com/nodejs/node/blob/main/doc/changelogs/CHANGELOG_V18.md#added-support-for-import-attributes) and [Node v20.10.0](https://github.com/nodejs/node/blob/main/doc/changelogs/CHANGELOG_V20.md#2023-11-22-version-20100-iron-lts-targos) (and is supported on all v21 and v22 channels), but importantly the older `assert` keyword is **_not_** supported in Node v22, so unfortunately our `package.json#engines.node` field is going to look a little ridiculous for the time being. Details: https://github.com/tc39/proposal-import-attributes?tab=readme-ov-file#history ## 🧬 QA & Testing Do tests pass?
1 parent 72d61f9 commit d76c0ae

15 files changed

Lines changed: 17 additions & 17 deletions

__tests__/cmds/openapi/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { describe, beforeAll, beforeEach, afterEach, it, expect, vi } from 'vite
1111
import OpenAPICommand from '../../../src/cmds/openapi/index.js';
1212
import APIError from '../../../src/lib/apiError.js';
1313
import config from '../../../src/lib/config.js';
14-
import petstoreWeird from '../../__fixtures__/petstore-simple-weird-version.json' assert { type: 'json' };
14+
import petstoreWeird from '../../__fixtures__/petstore-simple-weird-version.json' with { type: 'json' };
1515
import getAPIMock, { getAPIMockWithVersionHeader } from '../../helpers/get-api-mock.js';
1616
import { after, before } from '../../helpers/get-gha-setup.js';
1717
import { after as afterGHAEnv, before as beforeGHAEnv } from '../../helpers/setup-gha-env.js';

__tests__/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import prompts from 'prompts';
22
import { describe, beforeEach, afterEach, it, expect, vi } from 'vitest';
33

4-
import pkg from '../package.json' assert { type: 'json' };
4+
import pkg from '../package.json' with { type: 'json' };
55
import cli from '../src/index.js';
66
import conf from '../src/lib/configstore.js';
77

__tests__/lib/analyzeOas.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { OASDocument } from 'oas/types';
22

3-
import petstore from '@readme/oas-examples/3.0/json/petstore.json' assert { type: 'json' };
3+
import petstore from '@readme/oas-examples/3.0/json/petstore.json' with { type: 'json' };
44
import { describe, it, expect } from 'vitest';
55

66
import analyzeOas, { getSupportedFeatures } from '../../src/lib/analyzeOas.js';

__tests__/lib/fetch.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { Headers } from 'node-fetch';
33
import { describe, beforeEach, afterEach, it, expect, vi } from 'vitest';
44

5-
import pkg from '../../package.json' assert { type: 'json' };
5+
import pkg from '../../package.json' with { type: 'json' };
66
import readmeAPIFetch, { cleanHeaders, handleRes } from '../../src/lib/readmeAPIFetch.js';
77
import getAPIMock from '../helpers/get-api-mock.js';
88
import { after, before } from '../helpers/setup-gha-env.js';

__tests__/lib/getPkgVersion.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import nock from 'nock';
22
import semver from 'semver';
33
import { describe, beforeEach, afterEach, it, expect, vi } from 'vitest';
44

5-
import pkg from '../../package.json' assert { type: 'json' };
5+
import pkg from '../../package.json' with { type: 'json' };
66
import { getNodeVersion, getPkgVersion } from '../../src/lib/getPkgVersion.js';
77

88
describe('#getNodeVersion()', () => {

__tests__/single-threaded/lib/createGHA.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import createGHA, { getConfigStoreKey, getGHAFileName, getGitData, git } from '.
1919
import { getMajorPkgVersion } from '../../../src/lib/getPkgVersion.js';
2020
import { after, before } from '../../helpers/get-gha-setup.js';
2121
import getGitRemoteMock from '../../helpers/get-git-mock.js';
22-
import ghaWorkflowSchema from '../../helpers/github-workflow-schema.json' assert { type: 'json' };
22+
import ghaWorkflowSchema from '../../helpers/github-workflow-schema.json' with { type: 'json' };
2323

2424
const testWorkingDir = process.cwd();
2525

bin/set-action-image.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import fs from 'node:fs/promises';
55
// eslint-disable-next-line import/no-extraneous-dependencies
66
import jsYaml from 'js-yaml';
77

8-
import pkg from '../package.json' assert { type: 'json' };
8+
import pkg from '../package.json' with { type: 'json' };
99

1010
/**
1111
* Updates our `action.yml` file so it properly points to

bin/set-major-version-tag.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import util from 'node:util';
55

66
import { parse } from 'semver';
77

8-
import pkg from '../package.json' assert { type: 'json' };
8+
import pkg from '../package.json' with { type: 'json' };
99

1010
const execFile = util.promisify(unpromisifiedExecFile);
1111

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"license": "MIT",
66
"author": "ReadMe <[email protected]> (https://readme.com)",
77
"engines": {
8-
"node": ">=18"
8+
"node": "^18.20.0 || >=20.10.0"
99
},
1010
"bin": {
1111
"rdme": "bin/rdme.js"

src/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as core from '@actions/core';
33
import chalk from 'chalk';
44
import updateNotifier from 'update-notifier';
55

6-
import pkg from '../package.json' assert { type: 'json' };
6+
import pkg from '../package.json' with { type: 'json' };
77

88
import { isGHA } from './lib/isCI.js';
99

0 commit comments

Comments
 (0)