Skip to content

Commit

Permalink
feat: add qwik-city starter (QwikDev#546)
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat authored May 28, 2022
1 parent a4d1575 commit afd3f69
Show file tree
Hide file tree
Showing 89 changed files with 1,202 additions and 343 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "0.0.21-0",
"scripts": {
"build": "yarn node scripts --tsc --build --api --platform-binding-wasm-copy",
"build.full": "yarn node scripts --tsc --build --api --eslint --platform-binding --wasm",
"build.full": "yarn node scripts --tsc --build --api --eslint --qwikcity --platform-binding --wasm",
"build.platform": "yarn node scripts --platform-binding",
"build.platform.copy": "yarn node scripts --platform-binding-wasm-copy",
"build.only_javascript": "yarn node scripts --tsc --build --api",
Expand Down
11 changes: 10 additions & 1 deletion packages/create-qwik/api/generate-starter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,20 @@ function generateUserStarter(
throw new Error(`Unable to find base app.`);
}

if (starterServer) {
const serverPkgJson = readPackageJson(starterServer.dir);
const vite = serverPkgJson.qwik?.vite;
replacements.push([/\/\* VITE_IMPORTS \*\//g, vite?.VITE_IMPORTS ?? '']);
replacements.push([/\/\* VITE_CONFIG \*\//g, vite?.VITE_CONFIG ?? '']);
replacements.push([/\/\* VITE_QWIK \*\//g, vite?.VITE_QWIK ?? '']);
replacements.push([/\/\* VITE_PLUGINS \*\//g, vite?.VITE_PLUGINS ?? '']);
}

cp(baseApp.dir, result.outDir, replacements);
cp(starterApp.dir, result.outDir, replacements);

const pkgJson = readPackageJson(baseApp.dir);
const starterPkgJson = readPackageJson(baseApp.dir);
const starterPkgJson = readPackageJson(starterApp.dir);
mergePackageJSONs(pkgJson, starterPkgJson);

let readmeContent = baseApp.readme!.trim() + '\n\n';
Expand Down
6 changes: 4 additions & 2 deletions packages/create-qwik/api/utils-api.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { copyFileSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from 'fs';
import { extname, join } from 'path';
import { join } from 'path';
import type { PackageJSON } from '../../../scripts/util';

export type Replacements = [RegExp, string][];
Expand All @@ -17,7 +17,9 @@ export function cp(srcDir: string, destDir: string, replacements: Replacements)
} else if (s.isFile()) {
const shouldReplace =
replacements.length > 0 &&
['.json', '.toml', '.md', '.html'].includes(extname(srcChildPath));
['.json', '.toml', '.md', '.html', 'vite.config.ts'].some((ext) =>
srcChildPath.endsWith(ext)
);
if (shouldReplace) {
let srcContent = readFileSync(srcChildPath, 'utf8');
for (const regex of replacements) {
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"devDependencies": {
"@builder.io/partytown": "^0.5.4",
"@builder.io/qwik": "0.0.21-0",
"@builder.io/qwik-city": "0.0.7",
"@builder.io/qwik-city": "0.0.10",
"@cloudflare/kv-asset-handler": "0.2.0",
"@cloudflare/workers-types": "^3.10.0",
"autoprefixer": "10.4.7",
Expand Down
File renamed without changes.
32 changes: 0 additions & 32 deletions packages/docs/pages/docs/file.mdx

This file was deleted.

File renamed without changes.
2 changes: 1 addition & 1 deletion packages/docs/src/components/on-this-page/on-this-page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { usePage } from '@builder.io/qwik-city';
import { component$, Host, $, useHostElement, useScopedStyles$ } from '@builder.io/qwik';
import { component$, Host, useScopedStyles$ } from '@builder.io/qwik';
import { ChatIcon } from '../svgs/chat-icon';
import { EditIcon } from '../svgs/edit-icon';
import { GithubLogo } from '../svgs/github-logo';
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/src/components/repl/worker/update.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable no-console */
import type { InputOptions, OutputAsset, OutputChunk } from 'rollup';
import type { Diagnostic, QwikRollupPluginOptions } from '@builder.io/qwik/optimizer';
import type { ReplInputOptions, ReplModuleInput, ReplModuleOutput, ReplResult } from '../types';
import type { ReplInputOptions, ReplModuleOutput, ReplResult } from '../types';
import { getCtx, QwikReplContext } from './context';
import { loadDependencies } from './dependencies';
import { ssrHtml } from './ssr-html';
Expand Down
16 changes: 4 additions & 12 deletions packages/docs/src/layouts/examples/examples.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import {
component$,
Host,
useHostElement,
useScopedStyles$,
useWatch$,
useStore,
useStyles$,
} from '@builder.io/qwik';
import { Repl } from '../../components/repl/repl';
import styles from './examples.css?inline';
import { Header } from '../../components/header/header';
import { setHeadMeta, setHeadStyles } from '@builder.io/qwik-city';
import { useHeadMeta } from '@builder.io/qwik-city';
import exampleSections, { ExampleApp } from '@examples-data';
import type { ReplAppInput } from '../../components/repl/types';

const Examples = component$((props: ExamplesProp) => {
const hostElm = useHostElement();
useHeadMeta({ title: `Qwik Examples` });
useStyles$(`html,body { margin: 0; height: 100%; overflow: hidden; }`);

const store = useStore<ExamplesStore>(() => {
// /examples/section/app-id
Expand All @@ -37,15 +38,6 @@ const Examples = component$((props: ExamplesProp) => {
store.files = app?.inputs || [];
});

useWatch$(() => {
setHeadMeta(hostElm, { title: `Qwik Examples` });
setHeadStyles(hostElm, [
{
style: `html,body { margin: 0; height: 100%; overflow: hidden; }`,
},
]);
});

useScopedStyles$(styles);

return (
Expand Down
20 changes: 5 additions & 15 deletions packages/docs/src/layouts/playground/playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@ import {
$,
component$,
Host,
useHostElement,
useScopedStyles$,
useWatch$,
useStore,
useClientEffect$,
useStyles$,
} from '@builder.io/qwik';
import { Repl } from '../../components/repl/repl';
import { Header } from '../../components/header/header';
import { getLocation, setHeadMeta, setHeadStyles } from '@builder.io/qwik-city';
import { getLocation, useHeadMeta } from '@builder.io/qwik-city';
import styles from './playground.css?inline';
import playgroundApp from '@playground-data';
import type { ReplAppInput, ReplModuleInput } from '../../components/repl/types';
import { BUILD_MODE_OPTIONS, ENTRY_STRATEGY_OPTIONS } from '../../components/repl/repl-options';

const Playground = component$(() => {
const hostElm = useHostElement();
useStyles$(`html,body { margin: 0; height: 100%; overflow: hidden; }`);
useScopedStyles$(styles);
useHeadMeta({ title: `Qwik Playground` });

const store = useStore<PlaygroundStore>(() => {
const initStore: PlaygroundStore = {
Expand Down Expand Up @@ -90,17 +91,6 @@ const Playground = component$(() => {
}
});

useWatch$(() => {
setHeadMeta(hostElm, { title: `Qwik Playground` });
setHeadStyles(hostElm, [
{
style: `html,body { margin: 0; height: 100%; overflow: hidden; }`,
},
]);
});

useScopedStyles$(styles);

const pointerDown = $(() => {
store.colResizeActive = true;
});
Expand Down
20 changes: 2 additions & 18 deletions packages/docs/src/layouts/tutorial/tutorial.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,16 @@
import {
component$,
Host,
Slot,
useHostElement,
useScopedStyles$,
useStore,
useWatch$,
} from '@builder.io/qwik';
import { component$, Host, Slot, useScopedStyles$, useStore, useStyles$ } from '@builder.io/qwik';
import { useLocation } from '../../utils/useLocation';
import { Repl } from '../../components/repl/repl';
import styles from './tutorial.css?inline';
import { TutorialContentFooter } from './tutorial-content-footer';
import { TutorialContentHeader } from './tutorial-content-header';
import tutorialSections, { TutorialApp } from '@tutorial-data';
import { Header } from '../../components/header/header';
import { setHeadStyles } from '@builder.io/qwik-city';
import type { ReplAppInput } from '../../components/repl/types';

const Tutorial = component$(() => {
useScopedStyles$(styles);

useWatch$(() => {
setHeadStyles(useHostElement(), [
{
style: `html,body { margin: 0; height: 100%; overflow: hidden; }`,
},
]);
});
useStyles$(`html,body { margin: 0; height: 100%; overflow: hidden; }`);

const loc = useLocation();
const getTutorialApp = (): TutorialApp | undefined => {
Expand Down
1 change: 1 addition & 0 deletions packages/qwik-city/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# QwikCity
8 changes: 4 additions & 4 deletions packages/qwik-city/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
{
"name": "@builder.io/qwik-city",
"version": "0.0.7",
"version": "0.0.10",
"description": "Static Site Generator for Qwik",
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"scripts": {
"build": "yarn node -r esbuild-register scripts/build.ts && npm run build.api",
"build.api": "tsc && api-extractor run -c src/runtime/api-extractor.json --local && api-extractor run -c src/vite/api-extractor.json --local",
"test": "uvu -r tsm src/vite/tests"
},
"dependencies": {
Expand All @@ -19,6 +17,7 @@
"@microsoft/api-extractor": "7.24.0",
"@types/github-slugger": "^1.3.0",
"@types/marked": "^4.0.3",
"@types/node": "17.0.34",
"@types/refractor": "^3.0.2",
"estree-util-value-to-estree": "^1.3.0",
"front-matter": "^4.0.2",
Expand Down Expand Up @@ -56,7 +55,8 @@
}
},
"files": [
"dist"
"dist",
"vite"
],
"license": "MIT",
"homepage": "https://qwik.builder.io/",
Expand Down
61 changes: 0 additions & 61 deletions packages/qwik-city/scripts/build.ts

This file was deleted.

40 changes: 40 additions & 0 deletions packages/qwik-city/src/api-extractor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"bundledPackages": [],
"compiler": {
"overrideTsconfig": {
"compilerOptions": {
"isolatedModules": true,
"esModuleInterop": true,
"skipLibCheck": true
},
"include": ["dist-dev/dts-out/packages/qwik-city/src"]
}
},
"docModel": {
"enabled": false
},
"dtsRollup": {
"enabled": false
},
"tsdocMetadata": {
"enabled": false
},
"messages": {
"compilerMessageReporting": {
"default": {
"logLevel": "error"
}
},
"extractorMessageReporting": {
"default": {
"logLevel": "error"
}
},
"tsdocMessageReporting": {
"default": {
"logLevel": "error"
}
}
}
}
Loading

0 comments on commit afd3f69

Please sign in to comment.