Skip to content

Commit

Permalink
Prepare beta release 0.9.0 (QwikDev#1304)
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat authored Sep 19, 2022
1 parent ad424c5 commit 7b500dd
Show file tree
Hide file tree
Showing 30 changed files with 378 additions and 74 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ packages/docs/src/routes/examples/apps/**/*
packages/docs/src/routes/playground/app/**/*
packages/docs/src/routes/tutorial/**/*
starters/apps/base
starters/apps/library
vite.config.ts
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "qwik-monorepo",
"version": "0.0.113",
"version": "0.9.0",
"scripts": {
"build": "tsm scripts/index.ts --tsc --build --qwikcity --api --platform-binding-wasm-copy",
"build.full": "tsm scripts/index.ts --tsc --build --api --eslint --qwikcity --qwikreact --cli --platform-binding --wasm",
Expand Down
54 changes: 34 additions & 20 deletions packages/create-qwik/create-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,29 +92,41 @@ export async function createApp(opts: CreateAppOptions) {
};

const starterApps = (await loadIntegrations()).filter((i) => i.type === 'app');
const baseApp = starterApps.find((a) => a.id === 'base');
const starterApp = starterApps.find((s) => s.id === opts.starterId);
if (!baseApp) {
throw new Error(`Unable to find base app`);
}
if (!starterApp) {
throw new Error(`Invalid starter id "${opts.starterId}"`);
}

await createFromStarter(result, baseApp, starterApp);
const isLibrary = opts.starterId === 'library';
if (isLibrary) {
const baseApp = starterApps.find((a) => a.id === 'library');
if (!baseApp) {
throw new Error(`Unable to find base app`);
}
await createFromStarter(result, baseApp);
} else {
const baseApp = starterApps.find((a) => a.id === 'base');
if (!baseApp) {
throw new Error(`Unable to find base app`);
}
const starterApp = starterApps.find((s) => s.id === opts.starterId);
if (!starterApp) {
throw new Error(`Invalid starter id "${opts.starterId}"`);
}

await createFromStarter(result, baseApp, starterApp);
}
return result;
}

async function createFromStarter(
result: CreateAppResult,
baseApp: IntegrationData,
starterApp: IntegrationData
starterApp?: IntegrationData
) {
const appInfo = starterApp ?? baseApp;
const appPkgJson = cleanPackageJson({
name: `my-${starterApp.pkgJson.name}`,
description: starterApp.pkgJson.description,
private: true,
...baseApp.pkgJson,
name: `my-${appInfo.pkgJson.name}`,
description: appInfo.pkgJson.description,
scripts: undefined,
dependencies: undefined,
devDependencies: undefined,
});
await writePackageJson(result.outDir, appPkgJson);

Expand All @@ -128,12 +140,14 @@ async function createFromStarter(
});
await baseUpdate.commit(false);

const starterUpdate = await updateApp({
rootDir: result.outDir,
integration: starterApp.id,
installDeps: false,
});
await starterUpdate.commit(false);
if (starterApp) {
const starterUpdate = await updateApp({
rootDir: result.outDir,
integration: starterApp.id,
installDeps: false,
});
await starterUpdate.commit(false);
}
}

function isValidOption(value: any) {
Expand Down
4 changes: 2 additions & 2 deletions packages/create-qwik/create-interactive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ export async function runCreateInteractiveCli() {
function checkNodeVersion() {
const version = process.version;
const majorVersion = Number(version.replace('v', '').split('.')[0]);
if (majorVersion < 15) {
if (majorVersion < 16) {
console.error(
color.red(`Qwik requires Node.js 15 or higher. You are currently running Node.js ${version}.`)
color.red(`Qwik requires Node.js 16 or higher. You are currently running Node.js ${version}.`)
);
process.exit(1);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/create-qwik/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-qwik",
"version": "0.0.113",
"version": "0.9.0",
"description": "Interactive CLI for create Qwik projects and adding features.",
"bin": "./create-qwik.cjs",
"main": "./index.cjs",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-qwik/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-qwik",
"version": "0.0.113",
"version": "0.9.0",
"description": "An Open-Source sub-framework designed with a focus on server-side-rendering, lazy-loading, and styling/animation.",
"main": "index.js",
"author": "Builder Team",
Expand Down
2 changes: 1 addition & 1 deletion packages/qwik-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@builder.io/qwik-react",
"version": "0.0.100",
"version": "0.0.102",
"description": "QwikReact allows to apply inject React component into existing Qwik application",
"scripts": {
"build": "npm run build.lib",
Expand Down
15 changes: 9 additions & 6 deletions packages/qwik-react/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,16 @@ export async function renderToStream(
const result = await renderToString(rootNode, opts);
opts.stream.write(result.html);
return {
...result,
flushes: -1,
size: -1,
prefetchResources: result.prefetchResources,
snapshotResult: result.snapshotResult,
_symbols: result._symbols,
manifest: result.manifest,
flushes: 1,
size: result.html.length,
timing: {
firstFlush: -1,
render: -1,
snapshot: -1,
firstFlush: result.timing.render,
render: result.timing.render,
snapshot: result.timing.snapshot,
},
};
}
2 changes: 1 addition & 1 deletion packages/qwik/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@builder.io/qwik",
"version": "0.0.113",
"version": "0.9.0",
"description": "An Open-Source sub-framework designed with a focus on server-side-rendering, lazy-loading, and styling/animation.",
"main": "./dist/core.cjs",
"types": "./dist/core.d.ts",
Expand Down
60 changes: 44 additions & 16 deletions packages/qwik/src/cli/build/run-build-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,26 @@ export async function runBuildCommand(app: AppCommand) {
}

const isPreviewBuild = app.args.includes('preview');

const buildLibScript = pkgJsonScripts['build.lib'];
const isLibraryBuild = !!buildLibScript;
const buildClientScript = pkgJsonScripts['build.client'];
const buildPreviewScript = isPreviewBuild ? pkgJsonScripts['build.preview'] : undefined;
const buildServerScript = !isPreviewBuild ? pkgJsonScripts['build.server'] : undefined;
const buildStaticScript = pkgJsonScripts['build.static'];
const runSsgScript = pkgJsonScripts['ssg'];
const typecheckScript = !isPreviewBuild ? pkgJsonScripts.typecheck : undefined;
const buildTypes = !isPreviewBuild ? pkgJsonScripts['build.types'] : undefined;

const scripts = [
typecheckScript,
buildTypes,
buildClientScript,
buildLibScript,
buildPreviewScript,
buildServerScript,
buildStaticScript,
].filter((s) => typeof s === 'string' && s.trim().length > 0)!;

if (!buildClientScript) {
if (!isLibraryBuild && !buildClientScript) {
console.log(pkgJsonScripts);
throw new Error(`"build.client" script not found in package.json`);
}

Expand All @@ -45,8 +48,8 @@ export async function runBuildCommand(app: AppCommand) {

let typecheck: Promise<ExecaReturnValue<string>> | null = null;

if (typecheckScript && typecheckScript.startsWith('tsc')) {
const tscScript = parseScript(typecheckScript);
if (buildTypes && buildTypes.startsWith('tsc')) {
const tscScript = parseScript(buildTypes);
if (!tscScript.flags.includes('--pretty')) {
// ensures colors flow throw when we console log the stdout
tscScript.flags.push('--pretty');
Expand All @@ -63,19 +66,41 @@ export async function runBuildCommand(app: AppCommand) {
});
}

const clientScript = parseScript(buildClientScript);
await execa(clientScript.cmd, clientScript.flags, {
stdio: 'inherit',
cwd: app.rootDir,
}).catch(() => {
process.exit(1);
});
if (buildClientScript) {
const clientScript = parseScript(buildClientScript);
await execa(clientScript.cmd, clientScript.flags, {
stdio: 'inherit',
cwd: app.rootDir,
}).catch(() => {
process.exit(1);
});

console.log(``);
console.log(`${color.cyan('✓')} Built client modules`);
console.log(``);
console.log(`${color.cyan('✓')} Built client modules`);
}

const step2: Promise<ExecaReturnValue<string>>[] = [];

if (buildLibScript) {
const libScript = parseScript(buildLibScript);
const libBuild = execa(libScript.cmd, libScript.flags, {
cwd: app.rootDir,
env: {
FORCE_COLOR: 'true',
},
}).catch((e) => {
console.log(``);
if (e.stderr) {
console.log(e.stderr);
} else {
console.log(e.stdout);
}
console.log(``);
process.exit(1);
});
step2.push(libBuild);
}

if (buildPreviewScript) {
const previewScript = parseScript(buildPreviewScript);
const previewBuild = execa(previewScript.cmd, previewScript.flags, {
Expand Down Expand Up @@ -142,6 +167,9 @@ export async function runBuildCommand(app: AppCommand) {

if (step2.length > 0) {
await Promise.all(step2).then(() => {
if (buildLibScript) {
console.log(`${color.cyan('✓')} Built library modules`);
}
if (buildPreviewScript) {
console.log(`${color.cyan('✓')} Built preview (ssr) modules`);
}
Expand All @@ -155,7 +183,7 @@ export async function runBuildCommand(app: AppCommand) {
console.log(`${color.cyan('✓')} Type checked`);
}

if (!isPreviewBuild && !buildServerScript && !buildStaticScript) {
if (!isPreviewBuild && !buildServerScript && !buildStaticScript && !isLibraryBuild) {
const pmRun = pmRunCmd()
console.log(``);
console.log(`${color.bgMagenta(' Missing an integration ')}`);
Expand Down
7 changes: 7 additions & 0 deletions packages/qwik/src/cli/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ export interface IntegrationPackageJson {
devDependencies?: { [k: string]: string };
engines?: { node: string };
private?: boolean;
files?: string[];
main?: string;
exports?: any;
module?: string;
qwik?: string;
types?: string;
type?: string;
__qwik__?: {
priority: number;
viteConfig?: ViteConfigUpdates;
Expand Down
6 changes: 6 additions & 0 deletions packages/qwik/src/cli/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ export function cleanPackageJson(srcPkg: IntegrationPackageJson) {
scripts: srcPkg.scripts,
dependencies: srcPkg.dependencies,
devDependencies: srcPkg.devDependencies,
main: srcPkg.main,
qwik: srcPkg.qwik,
module: srcPkg.module,
types: srcPkg.types,
exports: srcPkg.exports,
files: srcPkg.files,
engines: { node: '>=15.0.0' },
};

Expand Down
2 changes: 1 addition & 1 deletion packages/qwik/src/core/import/qrl-class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export function assertQrl<T>(qrl: QRL<T>): asserts qrl is QRLInternal<T> {
}

export const emitUsedSymbol = (symbol: string, element: Element | undefined) => {
if (!qTest && !isServer()) {
if (!qTest && !isServer() && typeof document === 'object') {
document.dispatchEvent(
new CustomEvent('qsymbol', {
bubbles: false,
Expand Down
1 change: 1 addition & 0 deletions starters/apps/base/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ bazel-testlogs
dist
dist-dev
lib
lib-types
etc
external
node_modules
Expand Down
1 change: 1 addition & 0 deletions starters/apps/base/gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Build
/dist
/lib
/lib-types
/server

# Development
Expand Down
2 changes: 1 addition & 1 deletion starters/apps/base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
"build": "qwik build",
"build.client": "vite build",
"build.preview": "vite build --ssr src/entry.preview.tsx",
"build.types": "tsc --incremental --noEmit",
"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",
"typecheck": "tsc --incremental --noEmit",
"qwik": "qwik"
},
"devDependencies": {
Expand Down
31 changes: 31 additions & 0 deletions starters/apps/library/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
**/*.log
**/.DS_Store
*.
.vscode/settings.json
.history
.yarn
bazel-*
bazel-bin
bazel-out
bazel-qwik
bazel-testlogs
dist
dist-dev
lib
lib-types
etc
external
node_modules
temp
tsc-out
tsdoc-metadata.json
target
output
rollup.config.js
build
.cache
.vscode
.rollup.cache
dist
tsconfig.tsbuildinfo
vite.config.ts
Loading

0 comments on commit 7b500dd

Please sign in to comment.