Skip to content

Commit

Permalink
Release from CI (#100)
Browse files Browse the repository at this point in the history
* fix: ensure dev and preview servers close correctly

* fix: prevent vite warning about dynamic imports

* chore: add changesets and other tooling

* chore: add pre-commit linting

* fix: enable running tests without building
  • Loading branch information
rturnq authored Jan 15, 2025
1 parent 9eb0aaa commit 7d7440b
Show file tree
Hide file tree
Showing 139 changed files with 22,256 additions and 2,328 deletions.
12 changes: 12 additions & 0 deletions .c8r.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"all": true,
"excludeAfterRemap": true,
"parserPlugins": ["objectRestSpread", "typescript"],
"reporter": ["text-summary", "lcov"],
"include": [
"packages/*/src/**/*.js",
"packages/*/src/**/*.ts",
"packages/*/src/**/*.marko"
],
"exclude": ["**/__tests__", "**/*.d.ts"]
}
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"updateInternalDependencies": "patch",
"baseBranch": "main",
"access": "public",
"commit": false,
"linked": [],
"ignore": ["*-example"],
"fixed": []
}
5 changes: 5 additions & 0 deletions .changeset/four-islands-perform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@marko/run": patch
---

Test release workflow
2 changes: 1 addition & 1 deletion .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ By participating in this project you agree to abide by its terms.

- Remember that we’re different. The strength of our community comes from its diversity, people from a wide range of backgrounds. Different people have different perspectives on issues. Being unable to understand why someone holds a viewpoint doesn’t mean that they’re wrong. Don’t forget that it is human to err and blaming each other doesn’t get us anywhere. Instead, focus on helping to resolve issues and learning from mistakes.

Please visit http://ebay.github.io/codeofconduct for the full code of conduct.
Please visit http://ebay.github.io/codeofconduct for the full code of conduct.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@

<!--
Disclaimer: Contributions via GitHub pull requests are gladly accepted from their original author. Along with any pull requests, please state that the contribution is your original work and that you license the work to the project under the project's open source license. Whether or not you state this explicitly, by submitting any copyrighted material via pull request, email, or other means you agree to license the material under the project's open source license and warrant that you have the legal authority to do so.
-->
-->
80 changes: 80 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: CI

on:
pull_request:
types: [opened, synchronize]
push:
branches: [main, v3, v4]

concurrency:
group: "${{ github.workflow }}-${{ github.event_name == 'pull_request_target' && github.head_ref || github.ref }}"
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Use node
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- name: Install dependencies
run: npm ci
- name: Build
run: npm run @ci:build
- name: Lint Code
run: npm run @ci:lint
test:
runs-on: ubuntu-latest
name: "test: node@${{ matrix.node }}"
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
node: [18, 20]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Use node@${{ matrix.node }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: npm
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps chromium
- name: Run tests
run: npm run @ci:test
- name: Report code coverage
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
release:
runs-on: ubuntu-latest
needs: [build, test]
if: ${{ github.repository_owner == 'marko-js' && github.event_name == 'push' }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- name: Install dependencies
run: npm ci
- name: Release
id: changesets
uses: changesets/action@v1
with:
version: npm run @ci:version
publish: npm run @ci:release
commit: "[ci] release"
title: "[ci] release"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ dist
*.ignore
.cache
*.actual.*
.app
.app
coverage
*.lcov
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npm exec -- lint-staged && npm run build
5 changes: 5 additions & 0 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "https://json.schemastore.org/lintstagedrc.schema.json",
"*.{ts,js}": ["eslint --fix", "prettier --write --with-node-modules"],
"*.{json,md,css}": ["prettier --write --with-node-modules"]
}
19 changes: 19 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
__snapshots__
.cache
.nvm
.vscode
.marko-run
.cache
*actual*
*expected*
~*
CHANGELOG.md
coverage
dist
fixtures
input.*
node_modules
package-lock.json
snapshots
netlify/*-functions
netlify/assets
4 changes: 4 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://json.schemastore.org/prettierrc",
"plugins": ["prettier-plugin-packagejson"]
}
58 changes: 58 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import eslint from "@eslint/js";
import sortImportPlugin from "eslint-plugin-simple-import-sort";
import globals from "globals";
import tseslint from "typescript-eslint";

export default tseslint.config(
{
ignores: [
"!packages/runtime-class/src/node_modules",
".cache",
".sizes",
".vscode",
"**/.app",
"**/.cache",
"**/.marko-run",
"**/__snapshots__",
"**/*.marko.js",
"**/*actual*",
"**/*dist/",
"**/*expected*",
"**/snapshots",
"**/test/**/input.js",
"coverage",
"node_modules",
"**/netlify/*-functions",
"**/netlify/assets",
],
},
eslint.configs.recommended,
...tseslint.configs.recommended,
{
languageOptions: {
globals: {
...globals.mocha,
...globals.browser,
...globals.node,
},
},
plugins: {
"simple-import-sort": sortImportPlugin,
},
rules: {
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
"no-control-regex": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-import-type-side-effects": "error",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unused-expressions": "off",
"@typescript-eslint/no-require-imports": "off",
"@typescript-eslint/no-duplicate-enum-values": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-empty-object-type": "off",
"@typescript-eslint/no-namespace": "off",
},
},
);
6 changes: 3 additions & 3 deletions examples/netlify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"dev": "marko-run",
"preview": "marko-run preview"
},
"dependencies": {
"marko": "^5.37.4"
},
"devDependencies": {
"@marko/compiler": "^5.39.4",
"@marko/run": "^0.5.8",
Expand All @@ -18,8 +21,5 @@
"prettier": "^3.3.3",
"typescript": "^5.7.2",
"vite": "^6.0.0"
},
"dependencies": {
"marko": "^5.37.4"
}
}
16 changes: 8 additions & 8 deletions examples/netlify/src/routes/+handler.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
export const POST: MarkoRun.Handler = () => {
return new Response('POST-ed', { status: 200 });
}
return new Response("POST-ed", { status: 200 });
};

export const PUT: MarkoRun.Handler = () => {
return new Response('PUT-ed', { status: 200 });
}
return new Response("PUT-ed", { status: 200 });
};

export const GET: MarkoRun.Handler = () => {
console.log('Home route handler')
}
console.log("Home route handler");
};

export const DELETE: MarkoRun.Handler = () => {
return new Response('DELETE-ed', { status: 200 });
}
return new Response("DELETE-ed", { status: 200 });
};
2 changes: 1 addition & 1 deletion examples/netlify/src/routes/+meta.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"name": "foo"
}
}
2 changes: 1 addition & 1 deletion examples/netlify/src/routes/+middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default MarkoRun.route(async ({ request, url, meta }, next) => {
console.log(
`${requestName} completed ${
success ? "successfully" : "with errors"
} in ${performance.now() - startTime}ms`
} in ${performance.now() - startTime}ms`,
);
}
});
2 changes: 1 addition & 1 deletion examples/netlify/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"compilerOptions": {
"rootDir": "./"
}
}
}
2 changes: 1 addition & 1 deletion examples/netlify/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineConfig } from "vite";
import marko from "@marko/run/vite";
import netlifyAdapter from "@marko/run-adapter-netlify";
import { defineConfig } from "vite";

export default defineConfig({
plugins: [marko({ adapter: netlifyAdapter({ edge: true }) })],
Expand Down
10 changes: 5 additions & 5 deletions examples/node-express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
"dev": "marko-run src/index.ts",
"preview": "marko-run preview src/index.ts"
},
"dependencies": {
"compression": "^1.7.5",
"express": "^4.21.1",
"marko": "^5.37.3"
},
"devDependencies": {
"@marko/compiler": "^5.39.3",
"@marko/run": "^0.5",
Expand All @@ -16,10 +21,5 @@
"tsx": "^4.19.2",
"typescript": "^5.7.2",
"vite": "^6.0.0"
},
"dependencies": {
"compression": "^1.7.5",
"express": "^4.21.1",
"marko": "^5.37.3"
}
}
8 changes: 4 additions & 4 deletions examples/node-express/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import path from 'path';
import url from 'url';
import express from "express";
import compressionMiddleware from "compression";
import { routerMiddleware } from "@marko/run-adapter-node/middleware";
import compressionMiddleware from "compression";
import express from "express";
import path from "path";
import url from "url";

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

Expand Down
6 changes: 3 additions & 3 deletions examples/node-express/src/routes/+handler.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export function POST() {
return new Response('posted', { status: 200 });
return new Response("posted", { status: 200 });
}

export function GET(_, next) {
console.log(`'/' route GET handler`)
console.log(`'/' route GET handler`);
return next();
}
}
2 changes: 1 addition & 1 deletion examples/node-express/src/routes/+meta.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"name": "foo"
}
}
2 changes: 1 addition & 1 deletion examples/node-express/src/routes/+middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default async function ({ request, url, meta }, next) {
console.log(
`${requestName} completed ${
success ? "successfully" : "with errors"
} in ${performance.now() - startTime}ms`
} in ${performance.now() - startTime}ms`,
);
}
}
2 changes: 1 addition & 1 deletion examples/node-express/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
"outDir": "./dist",
"noImplicitOverride": false
}
}
}
2 changes: 1 addition & 1 deletion examples/node-express/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import { defineConfig } from "vite";

export default defineConfig({
// plugins: [marko({ adapter: nodeAdapter() })]
plugins: []
plugins: [],
});
Loading

0 comments on commit 7d7440b

Please sign in to comment.