From 4d99422ce83ad80c7ecc70f320afc5898229b62e Mon Sep 17 00:00:00 2001 From: maiieul Date: Tue, 27 Aug 2024 14:55:31 +0200 Subject: [PATCH] Revert "fix(cli): library starter wrong Qwik version (#6757)" This reverts commit 16c36da7755bc80b0e2011f589355e1577e41317. --- .changeset/silver-readers-appear.md | 5 ----- scripts/create-qwik-cli.ts | 18 +++++++-------- scripts/util.ts | 23 +++++++------------ scripts/validate-cli.ts | 34 ++++------------------------- 4 files changed, 21 insertions(+), 59 deletions(-) delete mode 100644 .changeset/silver-readers-appear.md diff --git a/.changeset/silver-readers-appear.md b/.changeset/silver-readers-appear.md deleted file mode 100644 index c5dbf44f1d7..00000000000 --- a/.changeset/silver-readers-appear.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'create-qwik': patch ---- - -FIX: wrong version when creating a library diff --git a/scripts/create-qwik-cli.ts b/scripts/create-qwik-cli.ts index b002a3c40c0..fc6623cbae6 100644 --- a/scripts/create-qwik-cli.ts +++ b/scripts/create-qwik-cli.ts @@ -8,7 +8,6 @@ import { copyFile, emptyDir, getBanner, - getQwikVersion, mkdir, nodeTarget, readdir, @@ -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) { @@ -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]) { @@ -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'); diff --git a/scripts/util.ts b/scripts/util.ts index a06732c1718..06de37c6dbb 100644 --- a/scripts/util.ts +++ b/scripts/util.ts @@ -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', @@ -359,9 +358,3 @@ export const recursiveChangePrefix = (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; -} diff --git a/scripts/validate-cli.ts b/scripts/validate-cli.ts index 29a7f0851de..117cae55b3c 100644 --- a/scripts/validate-cli.ts +++ b/scripts/validate-cli.ts @@ -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); @@ -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)); @@ -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); @@ -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'; @@ -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 {