Skip to content

feat(pkg.pr.new): test templates feat #863

New issue

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

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

Already on GitHub? # to your account

Closed
wants to merge 11 commits into from
Closed
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
4 changes: 2 additions & 2 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ runs:
steps:
- name: Lint
shell: bash
run: npx nx run-many -t lint --exclude website # --base=last-release <- add that back after fix
run: npx nx run-many -t lint --exclude website,sink # --base=last-release <- add that back after fix

- name: Build packages
shell: bash
run: npx nx run-many -t build --parallel=false --exclude website # --base=last-release <- add that back
run: npx nx run-many -t build --parallel=false --exclude website,sink # --base=last-release <- add that back

- name: Test all except headless
shell: bash
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
uses: ./.github/actions/setup
with:
node_version: 20
- run: pnpm build.headless
- run: pnpx pkg-pr-new publish --compact ./dist/packages/kit-headless
- run: pnpm build.headless && pnpm build
- run: pnpx pkg-pr-new publish ./dist/packages/kit-headless --template ./apps/sink
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GITHUB_TOKEN is provided automatically in any repository
42 changes: 42 additions & 0 deletions apps/sink/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
module.exports = {
root: true,
env: {
browser: true,
es2021: true,
node: true,
},
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:qwik/recommended",
],
parser: "@typescript-eslint/parser",
parserOptions: {
tsconfigRootDir: __dirname,
project: ["./tsconfig.json"],
ecmaVersion: 2021,
sourceType: "module",
ecmaFeatures: {
jsx: true,
},
},
plugins: ["@typescript-eslint"],
rules: {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-this-alias": "off",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/ban-ts-comment": "off",
"prefer-spread": "off",
"no-case-declarations": "off",
"no-console": "off",
"@typescript-eslint/no-unused-vars": ["error"],
"@typescript-eslint/consistent-type-imports": "warn",
"@typescript-eslint/no-unnecessary-condition": "warn",
},
};
6 changes: 6 additions & 0 deletions apps/sink/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Files Prettier should not format
**/*.log
**/.DS_Store
*.
dist
node_modules
65 changes: 65 additions & 0 deletions apps/sink/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Qwik City App ⚡️

- [Qwik Docs](https://qwik.builder.io/)
- [Discord](https://qwik.builder.io/chat)
- [Qwik GitHub](https://github.com/BuilderIO/qwik)
- [@QwikDev](https://twitter.com/QwikDev)
- [Vite](https://vitejs.dev/)

---

## Project Structure

This project is using Qwik with [QwikCity](https://qwik.builder.io/qwikcity/overview/). QwikCity is just a extra set of tools on top of Qwik to make it easier to build a full site, including directory-based routing, layouts, and more.

Inside your project, you'll see the following directory structure:

```
├── public/
│ └── ...
└── src/
├── components/
│ └── ...
└── routes/
└── ...
```

- `src/routes`: Provides the directory based routing, which can include a hierarchy of `layout.tsx` layout files, and an `index.tsx` file as the page. Additionally, `index.ts` files are endpoints. Please see the [routing docs](https://qwik.builder.io/qwikcity/routing/overview/) for more info.

- `src/components`: Recommended directory for components.

- `public`: Any static assets, like images, can be placed in the public directory. Please see the [Vite public directory](https://vitejs.dev/guide/assets.html#the-public-directory) for more info.

## Add Integrations and deployment

Use the `pnpm qwik add` command to add additional integrations. Some examples of integrations include: Cloudflare, Netlify or Express server, and the [Static Site Generator (SSG)](https://qwik.builder.io/qwikcity/static-site-generation/static-site-config/).

```shell
pnpm qwik add # or `yarn qwik add`
```

## Development

Development mode uses [Vite's development server](https://vitejs.dev/). During development, the `dev` command will server-side render (SSR) the output.

```shell
npm start # or `yarn start`
```

> Note: during dev mode, Vite may request a significant number of `.js` files. This does not represent a Qwik production build.

## Preview

The preview command will create a production build of the client modules, a production build of `src/entry.preview.tsx`, and run a local server. The preview server is only for convenience to locally preview a production build, and it should not be used as a production server.

```shell
pnpm preview # or `yarn preview`
```

## Production

The production build will generate client and server modules by running both client and server build commands. Additionally, the build command will use Typescript to run a type check on the source code.

```shell
pnpm build # or `yarn build`
```
40 changes: 40 additions & 0 deletions apps/sink/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "sink",
"type": "module",
"scripts": {
"build": "qwik build",
"build.client": "vite build",
"build.preview": "vite build --ssr src/entry.preview.tsx",
"build.types": "tsc --incremental --noEmit",
"deploy": "echo 'Run \"npm run qwik add\" to install a server adapter'",
"dev": "vite --mode ssr",
"dev.debug": "node --inspect-brk ./node_modules/vite/bin/vite.js --mode ssr --force",
"fmt": "prettier --write .",
"fmt.check": "prettier --check .",
"lint": "eslint \"src/**/*.ts*\"",
"preview": "qwik build preview && vite preview --open",
"start": "vite --open --mode ssr",
"qwik": "qwik"
},
"devDependencies": {
"@builder.io/qwik": "^1.5.7",
"@builder.io/qwik-city": "^1.5.7",
"@types/eslint": "^8.56.10",
"@types/node": "^20.12.7",
"@typescript-eslint/eslint-plugin": "^7.7.1",
"@typescript-eslint/parser": "^7.7.1",
"autoprefixer": "^10.4.14",
"eslint": "^8.57.0",
"eslint-plugin-qwik": "^1.5.7",
"postcss": "^8.4.31",
"prettier": "^3.2.5",
"prettier-plugin-tailwindcss": "^0.5.4",
"tailwindcss": "3.3.3",
"typescript": "5.4.5",
"undici": "*",
"vite": "^5.2.10",
"vite-tsconfig-paths": "^4.2.1",
"@qwikest/icons": "^0.0.13",
"@qwik-ui/headless": "0.4.4"
}
}
6 changes: 6 additions & 0 deletions apps/sink/postcss.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
};
75 changes: 75 additions & 0 deletions apps/sink/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"name": "sink",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "application",
"sourceRoot": "apps/sink/src",
"tags": [],
"targets": {
"build": {
"executor": "qwik-nx:build",
"options": {
"runSequence": ["sink:build.client", "sink:build.ssr"],
"outputPath": "dist/apps/sink"
},
"configurations": {
"preview": {}
}
},
"build.client": {
"executor": "@nx/vite:build",
"options": {
"outputPath": "dist/apps/sink",
"configFile": "apps/sink/vite.config.ts"
}
},
"build.ssr": {
"executor": "@nx/vite:build",
"defaultConfiguration": "preview",
"options": {
"outputPath": "dist/apps/sink"
},
"configurations": {
"preview": {
"ssr": "src/entry.preview.tsx",
"mode": "production"
}
}
},
"preview": {
"executor": "@nx/vite:preview-server",
"options": {
"buildTarget": "sink:build",
"port": 4173
}
},
"test": {
"executor": "@nx/vite:test",
"outputs": ["{options.reportsDirectory}"],
"options": {
"passWithNoTests": true,
"reportsDirectory": "../../coverage/apps/sink"
}
},
"serve": {
"executor": "@nx/vite:dev-server",
"options": {
"buildTarget": "sink:build.client",
"mode": "ssr",
"port": 5173
}
},
"serve.debug": {
"executor": "nx:run-commands",
"options": {
"command": "node --inspect-brk ../../node_modules/vite/bin/vite.js --mode ssr --force",
"cwd": "apps/sink"
}
},
"lint": {
"executor": "@nx/eslint:lint",
"options": {
"lintFilePatterns": ["apps/sink/**/*.{ts,tsx,js,jsx}"]
}
}
}
}
1 change: 1 addition & 0 deletions apps/sink/public/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions apps/sink/public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://json.schemastore.org/web-manifest-combined.json",
"name": "qwik-project-name",
"short_name": "Welcome to Qwik",
"start_url": ".",
"display": "standalone",
"background_color": "#fff",
"description": "A Qwik project app."
}
Empty file added apps/sink/public/robots.txt
Empty file.
48 changes: 48 additions & 0 deletions apps/sink/src/components/accordion/accordion.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { component$, useVisibleTask$ } from '@builder.io/qwik';
import { Accordion } from '@qwik-ui/headless';
import { LuChevronDown } from '@qwikest/icons/lucide';

export default component$(() => {
const items = [
{
trigger: 'Why?',
content:
'So that you can play with the components on your own - even with tailwind ✨',
},
{
trigger: 'Does it run on every commit?',
content: "Yes it does. How? I don't know.",
},
{ trigger: 'How much does it cost?', content: "It's free!" },
{
trigger: 'Who made this?',
content:
'Mohammad Bagher and his team. I would follow them on twitter if I were you.',
},
];

useVisibleTask$(() => {
const rootStyles = getComputedStyle(document.documentElement);
const mainColor = rootStyles;

console.log('mainColor', mainColor);
});

return (
<Accordion.Root class="w-full max-w-sm">
{items.map((item) => (
<Accordion.Item class="border-b" key={item.trigger}>
<Accordion.Header class="flex">
<Accordion.Trigger class="flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline [&[data-open]>svg]:rotate-180">
<span>{item.trigger}</span>
<LuChevronDown class="h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200" />
</Accordion.Trigger>
</Accordion.Header>
<Accordion.Content class="overflow-hidden text-sm data-[closed]:animate-accordion-up data-[open]:animate-accordion-down">
<div class="pb-4 pt-0">{item.content}</div>
</Accordion.Content>
</Accordion.Item>
))}
</Accordion.Root>
);
});
48 changes: 48 additions & 0 deletions apps/sink/src/components/router-head/router-head.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { component$ } from "@builder.io/qwik";
import { useDocumentHead, useLocation } from "@builder.io/qwik-city";

/**
* The RouterHead component is placed inside of the document `<head>` element.
*/
export const RouterHead = component$(() => {
const head = useDocumentHead();
const loc = useLocation();

return (
<>
<title>{head.title}</title>

<link rel="canonical" href={loc.url.href} />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />

{head.meta.map((m) => (
<meta key={m.key} {...m} />
))}

{head.links.map((l) => (
<link key={l.key} {...l} />
))}

{head.styles.map((s) => (
<style
key={s.key}
{...s.props}
{...(s.props?.dangerouslySetInnerHTML
? {}
: { dangerouslySetInnerHTML: s.style })}
/>
))}

{head.scripts.map((s) => (
<script
key={s.key}
{...s.props}
{...(s.props?.dangerouslySetInnerHTML
? {}
: { dangerouslySetInnerHTML: s.script })}
/>
))}
</>
);
});
17 changes: 17 additions & 0 deletions apps/sink/src/entry.dev.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* WHAT IS THIS FILE?
*
* Development entry point using only client-side modules:
* - Do not use this mode in production!
* - No SSR
* - No portion of the application is pre-rendered on the server.
* - All of the application is running eagerly in the browser.
* - More code is transferred to the browser than in SSR mode.
* - Optimizer/Serialization/Deserialization code is not exercised!
*/
import { render, type RenderOptions } from "@builder.io/qwik";
import Root from "./root";

export default function (opts: RenderOptions) {
return render(document, <Root />, opts);
}
Loading
Loading