Skip to content

Commit

Permalink
fix: use import attributes instead of import assertions (#145)
Browse files Browse the repository at this point in the history
* fix: use import attributes instead of import assertions

This should make the code compatible with both versions 20 and 22 of node

* ci: test for node 20 and node 22

In addition: adopt the use of dyne/pnpm action and bump actions/configure-pages to v5

* chore: bump esbuild to version ^0.21.4

This should handle in the correct way the import attributes

* ci: use lts/* and current as node version
  • Loading branch information
matteo-cristino authored May 29, 2024
1 parent 4a3e333 commit 199c3dc
Show file tree
Hide file tree
Showing 30 changed files with 171 additions and 188 deletions.
45 changes: 9 additions & 36 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,13 @@ jobs:
fail-fast: false
max-parallel: 1
matrix:
node: [ 20 ]
node: [ lts/*, current ]

steps:
- name: 🛎️ Checkout
uses: actions/checkout@v4
- name: 🔨 Install pnpm
uses: pnpm/action-setup@v3
- name: 🛠️ Prepare pnpm workspace
uses: dyne/pnpm@main
with:
version: 8
- name: ⏬ Install dependencies
run: pnpm recursive install
node-version: ${{ matrix.node }}
- uses: supercharge/[email protected]
with:
redis-version: 6
Expand All @@ -62,20 +58,10 @@ jobs:
needs: build_and_test
if: github.ref == 'refs/heads/main'
steps:
- name: 🛎️ Checkout
uses: actions/checkout@v4
- name: 🎯 Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- uses: pnpm/action-setup@v3
name: 🔨 Install pnpm
with:
version: 8
- name: 🛠️ Prepare pnpm workspace
uses: dyne/pnpm@main
- name: 📖 Setup Pages
uses: actions/configure-pages@v4
- name: ⏬ Install dependencies
run: pnpm install
uses: actions/configure-pages@v5
- name: 🏗️ update sentences tabled and build the docs
run: pnpm build && pnpm run docs
- name: ⏫ Upload artifact
Expand All @@ -100,21 +86,8 @@ jobs:
needs: build_and_test
if: github.ref == 'refs/heads/main'
steps:
- name: 🛎️ Checkout
uses: actions/checkout@v4
with:
fetch-depth: "0"
- name: 🎯 Setup Node
uses: actions/setup-node@v4
with:
node-version: 20.x
registry-url: 'https://registry.npmjs.org'
- name: 🔨 Install pnpm
uses: pnpm/action-setup@v3
with:
version: 8
- name: ⏬ Install dependencies
run: pnpm i
- name: 🛠️ Prepare pnpm workspace
uses: dyne/pnpm@main
- name: 🏗️ Build all
run: pnpm build
- name: 🌍 Build @slangroom/browser
Expand Down
2 changes: 1 addition & 1 deletion pkg/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"devDependencies": {
"@playwright/test": "^1.40.1",
"@types/node": "^20.10.4",
"esbuild": "^0.18.20"
"esbuild": "^0.21.4"
},
"scripts": {
"build": "pnpm exec esbuild --bundle src/index.ts --outfile=build/slangroom.js --target=es2016 --external:fs --external:path --external:crypto && cp build/slangroom.js public"
Expand Down
2 changes: 1 addition & 1 deletion pkg/core/src/lexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: AGPL-3.0-or-later
// read the version from the package.json
import packageJson from '@slangroom/core/package.json' assert { type: 'json' };
import packageJson from '@slangroom/core/package.json' with { type: 'json' };

/**
* A whitespace-separated string of characters with position information.
Expand Down
2 changes: 1 addition & 1 deletion pkg/core/src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import { PluginMap, Token, type PluginMapKey } from '@slangroom/core';
// read the version from the package.json
import packageJson from '@slangroom/core/package.json' assert { type: 'json' };
import packageJson from '@slangroom/core/package.json' with { type: 'json' };

export const errorColor = (s: string): string => '\x1b[31m' + s + '\x1b[0m';
export const suggestedColor = (s: string): string => '\x1b[32m' + s + '\x1b[0m';
Expand Down
2 changes: 1 addition & 1 deletion pkg/core/test/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { Plugin, Slangroom } from '@slangroom/core';
import test from 'ava';
// read the version from the package.json
import packageJson from '@slangroom/core/package.json' assert { type: 'json' };
import packageJson from '@slangroom/core/package.json' with { type: 'json' };
// error colors
import { errorColor, suggestedColor, missingColor, extraColor } from '@slangroom/core';

Expand Down
2 changes: 1 addition & 1 deletion pkg/db/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { Plugin } from '@slangroom/core';
import { BindOrReplacements, DataTypes, Model, Sequelize } from "sequelize";
// read the version from the package.json
import packageJson from '@slangroom/db/package.json' assert { type: 'json' };
import packageJson from '@slangroom/db/package.json' with { type: 'json' };

class Result extends Model {
public result!: string;
Expand Down
2 changes: 1 addition & 1 deletion pkg/db/test/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { db } from '@slangroom/db';
import { DataTypes, Model, Sequelize } from 'sequelize';
import fs from "fs";
// read the version from the package.json
import packageJson from '@slangroom/db/package.json' assert { type: 'json' };
import packageJson from '@slangroom/db/package.json' with { type: 'json' };

process.env['FILES_DIR'] = "./test";
const dbPath1 = "sqlite://./test/db1.db";
Expand Down
2 changes: 1 addition & 1 deletion pkg/db/test/raw_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Slangroom } from '@slangroom/core';
import { db } from '@slangroom/db';
import sqlite3 from "sqlite3";
// read the version from the package.json
import packageJson from '@slangroom/db/package.json' assert { type: 'json' };
import packageJson from '@slangroom/db/package.json' with { type: 'json' };

const stripAnsiCodes = (str: string) => str.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '');

Expand Down
2 changes: 1 addition & 1 deletion pkg/ethereum/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { erc20abi } from '@slangroom/ethereum';
import { Web3 } from 'web3';
import { isAddress } from 'web3-validator';
// read the version from the package.json
import packageJson from '@slangroom/ethereum/package.json' assert { type: 'json' };
import packageJson from '@slangroom/ethereum/package.json' with { type: 'json' };

const p = new Plugin();

Expand Down
2 changes: 1 addition & 1 deletion pkg/fs/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as os from 'node:os';
import axios from 'axios';
import extractZip from 'extract-zip';
// read the version from the package.json
import packageJson from '@slangroom/fs/package.json' assert { type: 'json' };
import packageJson from '@slangroom/fs/package.json' with { type: 'json' };

export class FsError extends Error {
constructor(e: string) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/fs/test/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import test from 'ava';
import { Slangroom } from '@slangroom/core';
import { fs } from '@slangroom/fs';
// read the version from the package.json
import packageJson from '@slangroom/fs/package.json' assert { type: 'json' };
import packageJson from '@slangroom/fs/package.json' with { type: 'json' };

const stripAnsiCodes = (str: string) => str.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '');

Expand Down
2 changes: 1 addition & 1 deletion pkg/git/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import http from 'isomorphic-git/http/node/index.js';
import * as fs from 'node:fs/promises';
import * as path from 'node:path';
// read the version from the package.json
import packageJson from '@slangroom/git/package.json' assert { type: 'json' };
import packageJson from '@slangroom/git/package.json' with { type: 'json' };

export class GitError extends Error {
constructor(e: string) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/helpers/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { Plugin } from '@slangroom/core';
import _ from 'lodash';
// read the version from the package.json
import packageJson from '@slangroom/helpers/package.json' assert { type: 'json' };
import packageJson from '@slangroom/helpers/package.json' with { type: 'json' };

const p = new Plugin()

Expand Down
2 changes: 1 addition & 1 deletion pkg/helpers/test/concat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Slangroom } from '@slangroom/core';
import { helpers } from '@slangroom/helpers';
import test from 'ava';
// read the version from the package.json
import packageJson from '@slangroom/helpers/package.json' assert { type: 'json' };
import packageJson from '@slangroom/helpers/package.json' with { type: 'json' };

const stripAnsiCodes = (str: string) => str.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '');

Expand Down
2 changes: 1 addition & 1 deletion pkg/helpers/test/pick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Slangroom } from '@slangroom/core';
import { helpers } from '@slangroom/helpers';
import test from 'ava';
// read the version from the package.json
import packageJson from '@slangroom/helpers/package.json' assert { type: 'json' };
import packageJson from '@slangroom/helpers/package.json' with { type: 'json' };

const stripAnsiCodes = (str: string) => str.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '');

Expand Down
2 changes: 1 addition & 1 deletion pkg/http/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { JsonableArray, JsonableObject } from '@slangroom/shared';
import { Plugin, type PluginExecutor } from '@slangroom/core';
import axios, { type AxiosRequestConfig } from 'axios';
// read the version from the package.json
import packageJson from '@slangroom/http/package.json' assert { type: 'json' };
import packageJson from '@slangroom/http/package.json' with { type: 'json' };

export class HttpError extends Error {
constructor(message: string) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/http/test/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import nock from 'nock';
import { Slangroom } from '@slangroom/core';
import { http } from '@slangroom/http';
// read the version from the package.json
import packageJson from '@slangroom/http/package.json' assert { type: 'json' };
import packageJson from '@slangroom/http/package.json' with { type: 'json' };

const stripAnsiCodes = (str: string) => str.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '');

Expand Down
2 changes: 1 addition & 1 deletion pkg/ignored/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import { zencodeParse } from '@slangroom/shared';
// read the version from the package.json
import packageJson from '@slangroom/ignored/package.json' assert { type: 'json' };
import packageJson from '@slangroom/ignored/package.json' with { type: 'json' };

/**
* Represent zencode invalid statement error
Expand Down
2 changes: 1 addition & 1 deletion pkg/json-schema/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { Plugin } from '@slangroom/core';
import { Ajv, type ValidationError } from 'ajv';
// read the version from the package.json
import packageJson from '@slangroom/json-schema/package.json' assert { type: 'json' };
import packageJson from '@slangroom/json-schema/package.json' with { type: 'json' };

export { ValidationError };

Expand Down
2 changes: 1 addition & 1 deletion pkg/oauth/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { AuthenticateHandler, InMemoryCache, AuthorizeHandler } from '@slangroom
import { JsonableObject } from '@slangroom/shared';
import { JWK } from 'jose';
// read the version from the package.json
import packageJson from '@slangroom/oauth/package.json' assert { type: 'json' };
import packageJson from '@slangroom/oauth/package.json' with { type: 'json' };

export class OauthError extends Error {
constructor(message: string) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/pocketbase/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Plugin } from '@slangroom/core';
import { z } from 'zod';
import { Preferences } from '@capacitor/preferences';
// read the version from the package.json
import packageJson from '@slangroom/pocketbase/package.json' assert { type: 'json' };
import packageJson from '@slangroom/pocketbase/package.json' with { type: 'json' };

export class PocketBaseError extends Error {
constructor(message: string) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/pocketbase/test/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import test from 'ava';
import { Slangroom } from '@slangroom/core';
import { JsonableObject } from '@slangroom/shared';
// read the version from the package.json
import packageJson from '@slangroom/pocketbase/package.json' assert { type: 'json' };
import packageJson from '@slangroom/pocketbase/package.json' with { type: 'json' };

const stripAnsiCodes = (str: string) => str.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '');

Expand Down
2 changes: 1 addition & 1 deletion pkg/qrcode/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { Plugin } from '@slangroom/core';
import QrCode from 'qrcode'
// read the version from the package.json
import packageJson from '@slangroom/qrcode/package.json' assert { type: 'json' };
import packageJson from '@slangroom/qrcode/package.json' with { type: 'json' };

export class QrCodeError extends Error {
constructor(message: string) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/redis/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Plugin, PluginContext } from '@slangroom/core';
import type { JsonableObject } from '@slangroom/shared';
import * as redisClient from "@redis/client";
// read the version from the package.json
import packageJson from '@slangroom/redis/package.json' assert { type: 'json' };
import packageJson from '@slangroom/redis/package.json' with { type: 'json' };

export class RedisError extends Error {
constructor(message: string) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/shell/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { Plugin } from '@slangroom/core';
import { execaCommand } from 'execa';
// read the version from the package.json
import packageJson from '@slangroom/shell/package.json' assert { type: 'json' };
import packageJson from '@slangroom/shell/package.json' with { type: 'json' };

export class ShellError extends Error {
constructor(message: string) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/shell/test/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Slangroom } from '@slangroom/core';
import { shell } from '@slangroom/shell';
import { $ } from 'execa';
// read the version from the package.json
import packageJson from '@slangroom/shell/package.json' assert { type: 'json' };
import packageJson from '@slangroom/shell/package.json' with { type: 'json' };

const stripAnsiCodes = (str: string) => str.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '');

Expand Down
2 changes: 1 addition & 1 deletion pkg/wallet/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {
} from '@meeco/sd-jwt-vc';
import type { JsonableArray, JsonableObject } from '@slangroom/shared';
// read the version from the package.json
import packageJson from '@slangroom/wallet/package.json' assert { type: 'json' };
import packageJson from '@slangroom/wallet/package.json' with { type: 'json' };

export class WalletError extends Error {
constructor(message: string) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/zencode/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Plugin } from '@slangroom/core';
import type { JsonableObject } from '@slangroom/shared';
import { zencodeExec } from '@slangroom/shared';
// read the version from the package.json
import packageJson from '@slangroom/zencode/package.json' assert { type: 'json' };
import packageJson from '@slangroom/zencode/package.json' with { type: 'json' };

export class ZencodeError extends Error {
constructor(message: string) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/zencode/test/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Slangroom } from '@slangroom/core';
import { zencode } from '@slangroom/zencode';
import type { JsonableObject } from '@slangroom/shared';
// read the version from the package.json
import packageJson from '@slangroom/zencode/package.json' assert { type: 'json' };
import packageJson from '@slangroom/zencode/package.json' with { type: 'json' };

const stripAnsiCodes = (str: string) => str.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '');

Expand Down
Loading

0 comments on commit 199c3dc

Please sign in to comment.