Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: maintain package #63

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 92 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,28 @@
name: ci

on:
push:
branches:
- master
pull_request:
branches:
- master
on: push

jobs:
ci:
prepare:
name: Prepare (${{ matrix.os}}, Node ${{ matrix.node }})
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest]
node: [14]
node: [16, 18, 20]

steps:
- name: Set up Node
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

- name: Checkout
uses: actions/checkout@master

- name: Cache node_modules
uses: actions/cache@v2
id: cache
uses: actions/cache@v3
with:
path: node_modules
key: ${{ matrix.os }}-node-v${{ matrix.node }}-deps-${{ hashFiles(format('{0}{1}', github.workspace, '/package-lock.json')) }}
Expand All @@ -36,6 +31,31 @@ jobs:
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci

suite:
needs: prepare
name: Suite (${{ matrix.os}}, Node ${{ matrix.node }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
node: [16, 18, 20]

steps:
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

- name: Checkout
uses: actions/checkout@master

- name: Retrieve node_modules
uses: actions/cache@v3
with:
path: node_modules
key: ${{ matrix.os }}-node-v${{ matrix.node }}-deps-${{ hashFiles(format('{0}{1}', github.workspace, '/package-lock.json')) }}

- name: Lint
run: npm run lint

Expand All @@ -46,11 +66,68 @@ jobs:
run: npm run build

- name: Coverage
if: matrix.os == 'ubuntu-latest' && matrix.node == 14
uses: codecov/codecov-action@v1
if: matrix.os == 'ubuntu-latest' && matrix.node == 16
uses: codecov/codecov-action@v3

types:
needs: prepare
name: Types (${{ matrix.os}}, Node ${{ matrix.node }}, TS ${{ matrix.typescript }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
node: [16]
typescript: ["4.6", "4.7", "4.8", "4.9", "5.0"]

steps:
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

- name: Checkout
uses: actions/checkout@master

- name: Retrieve node_modules
uses: actions/cache@v3
with:
path: node_modules
key: ${{ matrix.os }}-node-v${{ matrix.node }}-deps-${{ hashFiles(format('{0}{1}', github.workspace, '/package-lock.json')) }}

- name: Overwrite TypeScript
run: npm install --no-save typescript@${{ matrix.typescript }} && npx tsc --version

- name: Types
run: npm run types

size:
needs: prepare
if: github.event_name == 'pull_request'
name: Size (${{ matrix.os}}, Node ${{ matrix.node }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
node: [16]

steps:
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

- name: Checkout
uses: actions/checkout@master

- name: Retrieve node_modules
uses: actions/cache@v3
with:
path: node_modules
key: ${{ matrix.os }}-node-v${{ matrix.node }}-deps-${{ hashFiles(format('{0}{1}', github.workspace, '/package-lock.json')) }}

- name: Size
if: github.event_name == 'pull_request' && matrix.os == 'ubuntu-latest' && matrix.node == 14
uses: andresz1/size-limit-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
25 changes: 24 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,31 @@
{
"plugins": ["prettier-plugin-jsdoc"],
"plugins": ["@trivago/prettier-plugin-sort-imports", "prettier-plugin-jsdoc"],
"jsdocCapitalizeDescription": false,
"jsdocSeparateReturnsFromParam": true,
"jsdocSeparateTagGroups": true,
"jsdocSingleLineComment": false,
"tsdoc": true,
"importOrder": [
"^vitest(/|$)",
"^node:",
"<THIRD_PARTY_MODULES>",
"^(?!.*/src(/|$)).*/__testutils__(/|$)",
"^(?!.*/src(/|$)).*/__fixtures__(/|$)",
"^(?!.*/src(/|$)).*/lib(/|$)",
"^(?!.*/src(/|$)).*/types(/|$)",
"^(?!.*/src(/|$)).*/errors(/|$)",
"^(?!.*/src(/|$))../../../../../",
"^(?!.*/src(/|$))../../../../",
"^(?!.*/src(/|$))../../../",
"^(?!.*/src(/|$))../../",
"^(?!.*/src(/|$))../",
"^(?!.*/src(/|$))./(.*/)+",
"^(?!.*/src(/|$))./",
"/src(/|$)"
],
"importOrderSeparation": true,
"importOrderSortSpecifiers": true,
"importOrderGroupNamespaceSpecifiers": true,
"printWidth": 80,
"useTabs": true,
"semi": true,
Expand Down
30 changes: 27 additions & 3 deletions .size-limit.cjs
lihbr marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
const pkg = require("./package.json");

module.exports = [pkg.module, pkg.main]
.filter(Boolean)
.map((path) => ({ path }));
function getObjectValues(input, acc = []) {
if (typeof input === "string") {
return input;
} else {
return [
...acc,
...Object.values(input).flatMap((value) => getObjectValues(value)),
];
}
}

module.exports = [
...new Set([pkg.main, pkg.module, ...getObjectValues(pkg.exports)]),
]
.sort()
.filter((path) => {
return path && path !== "./package.json" && !path.endsWith(".d.ts");
})
.map((path) => {
return {
path,
modifyEsbuildConfig(config) {
config.platform = "node";
return config;
},
};
});
2 changes: 1 addition & 1 deletion benchmark/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"benchmark": "^2.1.4"
},
"dependencies": {
"@prismicio/types": "^0.0.9",
"@prismicio/client": "^7.0.1",
"@prismicio/richtext": "^1.1.0",
"@prismicio/richtext-v2": "file:.."
}
Expand Down
10 changes: 6 additions & 4 deletions benchmark/test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import * as fs from "fs/promises";
import * as v2 from "@prismicio/richtext-v2";
import * as path from "path";
import * as url from "url";
import Benchmark from "benchmark";
import { LinkType } from "@prismicio/types";
import { LinkType } from "@prismicio/client";
import v1 from "@prismicio/richtext";
import * as v2 from "@prismicio/richtext-v2";
import Benchmark from "benchmark";

import * as fs from "fs/promises";

// import * as assert from "assert";

const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
Expand Down
Loading