Skip to content

Commit

Permalink
Add Nodejs 18 support (#118)
Browse files Browse the repository at this point in the history
* Initial update to configuration for node 18 compatibility

* Add exceptions for dynamic Metaplex file replacement

* Better commenting

* Documentation & engine version requirements updated

* Final engine update

* Gotta get nvm too!
  • Loading branch information
creativedrewy authored Dec 22, 2022
1 parent 8883d52 commit 3a1c308
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v16.13.2
v18.4.0
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"engines": {
"node": ">=16",
"node": ">=18",
"pnpm": ">=7"
},
"scripts": {
Expand Down
4 changes: 1 addition & 3 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
## Prerequisites

- Node 16.13.2 (This specific version, please)
- Node 18+
- PNPM
- Android SDK build tools

If you have Node 16+, you can [activate PNPM with Corepack](https://pnpm.io/installation#using-corepack):

```shell
corepack enable
corepack prepare pnpm@`npm info pnpm --json | jq -r .version` --activate
Expand Down
3 changes: 3 additions & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"main": "./lib/cjs/index.js",
"module": "./lib/esm/index.js",
"types": "./lib/types/index.d.ts",
"engines": {
"node": ">=18"
},
"exports": {
"import": "./lib/esm/index.js",
"require": "./lib/cjs/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { load } from "js-yaml";
import Ajv from "ajv";

// eslint-disable-next-line require-extensions/require-extensions
import schemaJson from "./schema.json";
import schemaJson from "./schema.json" assert { type: "json" };

// TODO: Add version number return here
export interface CLIConfig {
Expand Down
3 changes: 3 additions & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"main": "./lib/cjs/index.js",
"module": "./lib/esm/index.js",
"types": "./lib/types/index.d.ts",
"engines": {
"node": ">=18"
},
"exports": {
"import": "./lib/esm/index.js",
"require": "./lib/cjs/index.js",
Expand Down
22 changes: 19 additions & 3 deletions packages/core/src/validate/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import type {
} from "../types.js";

// eslint-disable-next-line require-extensions/require-extensions
import publisherSchema from "./schemas/publisherJsonMetadata.json";
import publisherSchema from "./schemas/publisherJsonMetadata.json" assert { type: "json" };
// eslint-disable-next-line require-extensions/require-extensions
import appSchema from "./schemas/appJsonMetadata.json";
import appSchema from "./schemas/appJsonMetadata.json" assert { type: "json" };
// eslint-disable-next-line require-extensions/require-extensions
import releaseSchema from "./schemas/releaseJsonMetadata.json";
import releaseSchema from "./schemas/releaseJsonMetadata.json" assert { type: "json" };

export const validatePublisher = (publisherJson: PublisherMetadata) => {
const jsonToValidate = { ...publisherJson };
Expand Down Expand Up @@ -55,6 +55,22 @@ export const validateRelease = (releaseJson: MetaplexFileReleaseJsonMetadata) =>
jsonToValidate.image = jsonToValidate.image?.fileName;
}

// We need to replace media MetaplexFile instances with strings for validation
jsonToValidate.extensions.solana_dapp_store.media.forEach((media, index) => {
if (typeof media.uri !== "string") {
// @ts-ignore Ignoring hard type override from Metaplex to string
jsonToValidate.extensions.solana_dapp_store.media[index].uri = media.uri.fileName;
}
});

// We need to replace file MetaplexFile instances with strings for validation
jsonToValidate.extensions.solana_dapp_store.files.forEach((file, index) => {
if (typeof file.uri !== "string") {
// @ts-ignore
jsonToValidate.extensions.solana_dapp_store.files[index].uri = file.uri.fileName;
}
});

const ajv = new Ajv({ strictTuples: false });
const validate = ajv.compile(releaseSchema);

Expand Down
2 changes: 1 addition & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"include": [],
"compilerOptions": {
"target": "ES2022",
"module": "ES2022",
"module": "esnext",
"moduleResolution": "Node",
"esModuleInterop": true,
"isolatedModules": true,
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.esm.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"extends": "./tsconfig.base.json",
"compilerOptions": {
"target": "ES2020",
"module": "ES2020",
"module": "esnext",
"sourceMap": true,
"declaration": true,
"declarationMap": true
Expand Down

0 comments on commit 3a1c308

Please sign in to comment.