Skip to content

Commit

Permalink
Revert "fix(cli): library starter wrong Qwik version (QwikDev#6757)"
Browse files Browse the repository at this point in the history
This reverts commit 16c36da.
  • Loading branch information
maiieul committed Aug 27, 2024
1 parent a21a8bf commit 4d99422
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 59 deletions.
5 changes: 0 additions & 5 deletions .changeset/silver-readers-appear.md

This file was deleted.

18 changes: 9 additions & 9 deletions scripts/create-qwik-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
copyFile,
emptyDir,
getBanner,
getQwikVersion,
mkdir,
nodeTarget,
readdir,
Expand Down Expand Up @@ -92,9 +91,10 @@ export async function publishCreateQwikCli(
}

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

await updateBaseVersions(config, qwikVersion);
await updateBaseVersions(config, distPkg.version);
}

async function updateBaseVersions(config: BuildConfig, version: string) {
Expand Down Expand Up @@ -190,7 +190,6 @@ async function copyDir(config: BuildConfig, srcDir: string, destDir: string) {
async function updatePackageJson(config: BuildConfig, destDir: string) {
const rootPkg = await readPackageJson(config.rootDir);
const pkgJson = await readPackageJson(destDir);
const qwikVersion = await getQwikVersion(config);

const setVersionFromRoot = (pkgName: string) => {
if (pkgJson.devDependencies && pkgJson.devDependencies[pkgName]) {
Expand All @@ -206,11 +205,12 @@ async function updatePackageJson(config: BuildConfig, destDir: string) {
};

if (pkgJson.devDependencies && pkgJson.devDependencies['@builder.io/qwik']) {
pkgJson.devDependencies['@builder.io/qwik'] = qwikVersion;
}

if (pkgJson.devDependencies && pkgJson.devDependencies['eslint-plugin-qwik']) {
pkgJson.devDependencies['eslint-plugin-qwik'] = qwikVersion;
if (
pkgJson.devDependencies['@builder.io/qwik'] !== 'next' &&
pkgJson.devDependencies['@builder.io/qwik'] !== 'dev'
) {
pkgJson.devDependencies['@builder.io/qwik'] = rootPkg.version;
}
}

setVersionFromRoot('@types/eslint');
Expand Down
23 changes: 8 additions & 15 deletions scripts/util.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
import type { Plugin } from 'esbuild';
import { execa, type Options } from 'execa';
import { join } from 'node:path';
import mri from 'mri';
import {
access as fsAccess,
copyFile as fsCopyFile,
mkdir as fsMkdir,
mkdirSync,
readdir as fsReaddir,
readFile as fsReadFile,
rmSync,
stat as fsStat,
unlink as fsUnlink,
writeFile as fsWriteFile,
mkdirSync,
rmSync,
mkdir as fsMkdir,
} from 'node:fs';
import { join } from 'node:path';
import { fileURLToPath } from 'node:url';
import type { Plugin as RollupPlugin } from 'rollup';
import { minify, type MinifyOptions } from 'terser';
import { promisify } from 'util';
import { readPackageJson } from './package-json';
import { minify, type MinifyOptions } from 'terser';
import type { Plugin as RollupPlugin } from 'rollup';
import { execa, type Options } from 'execa';
import { fileURLToPath } from 'node:url';

const stringOptions = [
'distBindingsDir',
Expand Down Expand Up @@ -359,9 +358,3 @@ export const recursiveChangePrefix = <T>(obj: T, prefix: string, replace: string
}
return obj;
};

export async function getQwikVersion(config: BuildConfig) {
const qwikDir = join(config.packagesDir, 'qwik');
const qwikPkgJson = await readPackageJson(qwikDir);
return qwikPkgJson.version;
}
34 changes: 4 additions & 30 deletions scripts/validate-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ async function validateCreateQwikCli() {
const cliPkgJsonPath = join(cliDir, 'package.json');
const cliPkgJson = JSON.parse(readFileSync(cliPkgJsonPath, 'utf-8'));
assert.strictEqual(cliPkgJson.name, 'create-qwik');
const qwikVersion = cliPkgJson.version;

const startersDir = join(cliDir, 'dist', 'starters');
accessSync(startersDir);
Expand All @@ -45,9 +44,9 @@ async function validateCreateQwikCli() {
const tmpDir = join(__dirname, '..', 'dist-dev');

await Promise.all([
validateStarter(api, tmpDir, 'playground', true, `πŸ‘»`, qwikVersion),
validateStarter(api, tmpDir, 'empty', true, `πŸ«™`, qwikVersion),
validateStarter(api, tmpDir, 'library', false, `πŸ“š`, qwikVersion),
validateStarter(api, tmpDir, 'playground', true, `πŸ‘»`),
validateStarter(api, tmpDir, 'empty', true, `πŸ«™`),
validateStarter(api, tmpDir, 'library', false, `πŸ“š`),
]).catch((e) => {
console.error(e);
panic(String(e));
Expand All @@ -61,8 +60,7 @@ async function validateStarter(
distDir: string,
starterId: string,
app: boolean,
emoji: string,
qwikVersion: string
emoji: string
) {
const appDir = join(distDir, 'e2e-' + starterId);

Expand All @@ -82,8 +80,6 @@ async function validateStarter(
const appPkgJsonPath = join(result.outDir, 'package.json');
const appPkgJson = JSON.parse(readFileSync(appPkgJsonPath, 'utf-8'));

assertRightQwikDepsVersions(appPkgJson, qwikVersion, starterId);

// Ensure that npm will use an existing version
appPkgJson.devDependencies['@builder.io/qwik'] = 'latest';
appPkgJson.devDependencies['@builder.io/qwik-city'] = 'latest';
Expand Down Expand Up @@ -147,28 +143,6 @@ async function validateStarter(
console.log(`${emoji} ${starterId} validated\n`);
}

function assertRightQwikDepsVersions(appPkgJson: any, qwikVersion: string, starterType: string) {
assert.strictEqual(
appPkgJson.devDependencies['@builder.io/qwik'].includes(qwikVersion),
true,
`Qwik version mismatch for "${starterType}" starter`
);
if (appPkgJson.devDependencies.hasOwnProperty('@builder.io/qwik-city')) {
assert.strictEqual(
appPkgJson.devDependencies['@builder.io/qwik-city'].includes(qwikVersion),
true,
`Qwik City version mismatch for "${starterType}" starter`
);
}
if (appPkgJson.devDependencies.hasOwnProperty('eslint-plugin-qwik')) {
assert.strictEqual(
appPkgJson.devDependencies['eslint-plugin-qwik'].includes(qwikVersion),
true,
`ESlint plugin version mismatch for "${starterType}" starter`
);
}
}

function cpSync(src: string, dest: string) {
// cpSync() not available until Node v16.7.0
try {
Expand Down

0 comments on commit 4d99422

Please sign in to comment.