Skip to content

Commit

Permalink
fix: correct version numbers for starter apps
Browse files Browse the repository at this point in the history
  • Loading branch information
shairez committed Jul 29, 2024
1 parent e2d41bc commit 11a46bd
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 18 deletions.
5 changes: 5 additions & 0 deletions .changeset/heavy-goats-approve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'create-qwik': patch
---

FIX: get the right version number in starter apps
50 changes: 32 additions & 18 deletions scripts/create-qwik-cli.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { build } from 'esbuild';
import { existsSync } from 'node:fs';
import { rm } from 'node:fs/promises';
import { basename, join } from 'node:path';
import { readPackageJson, writePackageJson } from './package-json';
import {
type BuildConfig,
copyFile,
emptyDir,
getBanner,
mkdir,
nodeTarget,
stat,
getBanner,
readdir,
run,
stat,
} from './util';
import { build } from 'esbuild';
import { existsSync } from 'node:fs';
import { rm } from 'node:fs/promises';
import { basename, join } from 'node:path';
import { readPackageJson, writePackageJson } from './package-json';

const PACKAGE = 'create-qwik';

Expand All @@ -23,6 +23,7 @@ export async function buildCreateQwikCli(config: BuildConfig) {

await bundleCreateQwikCli(config, srcCliDir, distCliDir);
await copyStartersDir(config, distCliDir, ['apps']);
await syncBaseStarterVersionsFromQwik(config);

console.log('🐠 create-qwik cli');
}
Expand Down Expand Up @@ -75,6 +76,30 @@ export async function publishCreateQwikCli(
) {
const srcCliDir = join(config.packagesDir, PACKAGE);

await updateBaseVersions(config, version);

console.log(`⛴ publishing ${PACKAGE} ${version}`, isDryRun ? '(dry-run)' : '');

const npmPublishArgs = ['publish', '--tag', distTag];

await run('npm', npmPublishArgs, isDryRun, isDryRun, { cwd: srcCliDir });

console.log(
`🐳 published version "${version}" of ${PACKAGE} with dist-tag "${distTag}" to npm`,
isDryRun ? '(dry-run)' : ''
);
}

async function syncBaseStarterVersionsFromQwik(config: BuildConfig) {
const qwikDir = join(config.packagesDir, 'qwik');
const distPkg = await readPackageJson(qwikDir);

await updateBaseVersions(config, distPkg.version);
}

async function updateBaseVersions(config: BuildConfig, version: string) {
const srcCliDir = join(config.packagesDir, PACKAGE);

// update the base app's package.json
const distCliBaseAppDir = join(srcCliDir, 'dist', 'starters', 'apps', 'base');
const baseAppPkg = await readPackageJson(distCliBaseAppDir);
Expand Down Expand Up @@ -102,17 +127,6 @@ export async function publishCreateQwikCli(

console.log(distCliBaseAppDir, JSON.stringify(baseAppPkg, null, 2));
await writePackageJson(distCliBaseAppDir, baseAppPkg);

console.log(`⛴ publishing ${PACKAGE} ${version}`, isDryRun ? '(dry-run)' : '');

const npmPublishArgs = ['publish', '--tag', distTag];

await run('npm', npmPublishArgs, isDryRun, isDryRun, { cwd: srcCliDir });

console.log(
`🐳 published version "${version}" of ${PACKAGE} with dist-tag "${distTag}" to npm`,
isDryRun ? '(dry-run)' : ''
);
}

export async function copyStartersDir(
Expand Down

0 comments on commit 11a46bd

Please sign in to comment.