Skip to content

Commit

Permalink
feat: update depenencies WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry-stepanenko committed Aug 20, 2024
1 parent 37c92c2 commit 4efe0ac
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/qwik/src/cli/migrate-v2/run-migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import type { AppCommand } from '../utils/app-command';
import { bgMagenta } from 'kleur/colors';
import { bye } from '../utils/utils';
import { replacePackage } from './replace-package';
import { updateDependencies } from './update-dependencies';

export async function runV2Migration(app: AppCommand) {
intro(
`✨ ${bgMagenta(' This command will migrate your Qwik application from v1 to v2 \n')}` +
`This includes the following: \n` +
// TODO: package names
// TODO: package names
` - "@builder.io/qwik", "@builder.io/qwik-city" packages will be rescoped to "@qwik.dev/core" and "@qwik.dev/qwik-city" \n` +
` - related dependencies will be updated \n`
);
Expand All @@ -22,11 +23,11 @@ export async function runV2Migration(app: AppCommand) {
}

try {
replacePackage('@builder.io/qwik', '@qwik.dev/qwik');
replacePackage('@builder.io/qwik-city', '@qwik.dev/city');
replacePackage('@builder.io/qwik', '@qwik.dev/qwik');
replacePackage('@builder.io/qwik-city', '@qwik.dev/city');
await updateDependencies();
} catch (error) {
console.log(error);

Check failure on line 30 in packages/qwik/src/cli/migrate-v2/run-migration.ts

View workflow job for this annotation

GitHub Actions / Lint Package

Unexpected console statement
throw error
throw error;
}

}
18 changes: 18 additions & 0 deletions packages/qwik/src/cli/migrate-v2/update-dependencies.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { getPackageManager, readPackageJson } from './../utils/utils';
import { installDeps } from '../utils/install-deps';

export async function updateDependencies() {
// TODO: workspaceRoot
const packageJson = await readPackageJson(process.cwd());
// TODO: should come from elsewhere?
const newVersion = '2.0.0';
(packageJson.devDependencies ??= {})['@qwik.dev/qwik'] = newVersion;
(packageJson.devDependencies ??= {})['@qwik.dev/city'] = newVersion;
delete packageJson.dependencies?.['@builder.io/qwik'];
delete packageJson.dependencies?.['@builder.io/qwik-city'];
const { install } = installDeps(getPackageManager(), process.cwd());
const passed = await install;
if (!passed) {
throw new Error('Failed to install dependencies');
}
}

0 comments on commit 4efe0ac

Please sign in to comment.