Skip to content

Commit cfedfb3

Browse files
authored
refactor(core): clean up experience migration logic (#7221)
* refactor(core): clean up experience migration logic clean up experience package migration feature flag logic * refactor(experience): remove experience-legacy officially remove the experience-legay package * chore: add changeset add changeset * chore: update changeset comment update changeset comment
1 parent d418ad0 commit cfedfb3

File tree

406 files changed

+26
-24130
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

406 files changed

+26
-24130
lines changed

.changeset/two-cheetahs-marry.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
"@logto/core": patch
3+
---
4+
5+
clean up legacy experience package
6+
7+
The migration to the new experience package is now complete, offering improved flexibility and maintainability through our Experience API. (see release [1.26.0](https://github.com/logto-io/logto/releases/tag/v1.26.0) for more details)
8+
9+
Key updates:
10+
11+
- Removed feature flags and migration-related logic
12+
- Cleaned up transitional code used during gradual rollout
13+
- Deprecated and removed `@logto/experience-legacy` package
14+
- Fully adopted `@logto/experience` package with Experience API for all user interactions
15+
16+
This marks the completion of our authentication UI modernization, providing a more maintainable and extensible foundation for future enhancements.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"prepack": "pnpm -r prepack",
1111
"dev": "pnpm -r prepack && pnpm start:dev",
1212
"dev:cloud": "IS_CLOUD=1 CONSOLE_PUBLIC_URL=/ pnpm dev",
13-
"start:dev": "pnpm -r --parallel --filter=!@logto/integration-tests --filter=!@logto/experience-legacy --filter \"!./packages/connectors/connector-*\" dev",
13+
"start:dev": "pnpm -r --parallel --filter=!@logto/integration-tests --filter \"!./packages/connectors/connector-*\" dev",
1414
"start": "cd packages/core && NODE_ENV=production node .",
1515
"cli": "logto",
1616
"translate": "logto-translate",

packages/core/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
"@logto/core-kit": "workspace:^2.5.4",
4040
"@logto/demo-app": "workspace:*",
4141
"@logto/experience": "workspace:*",
42-
"@logto/experience-legacy": "workspace:*",
4342
"@logto/js": "^5.0.3",
4443
"@logto/language-kit": "workspace:^1.1.3",
4544
"@logto/phrases": "workspace:^1.18.0",
Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import fs from 'node:fs/promises';
22
import path from 'node:path';
33

4-
import { type Nullable, trySafe } from '@silverhand/essentials';
5-
import type { Context, MiddlewareType } from 'koa';
4+
import type { MiddlewareType } from 'koa';
65
import proxy from 'koa-proxies';
76
import type { IRouterParamContext } from 'koa-router';
87

@@ -12,7 +11,6 @@ import type Queries from '#src/tenants/Queries.js';
1211
import { getConsoleLogFromContext } from '#src/utils/console.js';
1312

1413
import serveCustomUiAssets from './koa-serve-custom-ui-assets.js';
15-
import { getExperiencePackageWithFeatureFlagDetection } from './utils/experience-proxy.js';
1614

1715
type Properties = {
1816
readonly mountedApps: string[];
@@ -22,22 +20,6 @@ type Properties = {
2220
readonly prefix?: string;
2321
};
2422

25-
const getDistributionPath = async <ContextT extends Context>(
26-
packagePath: string,
27-
ctx: ContextT
28-
): Promise<[string, string]> => {
29-
if (packagePath === 'experience') {
30-
// Safely get the experience package name with feature flag detection, default fallback to legacy
31-
const moduleName =
32-
(await trySafe(async () => getExperiencePackageWithFeatureFlagDetection(ctx))) ??
33-
'experience-legacy';
34-
35-
return [path.join('node_modules/@logto', moduleName, 'dist'), moduleName];
36-
}
37-
38-
return [path.join('node_modules/@logto', packagePath, 'dist'), packagePath];
39-
};
40-
4123
export default function koaSpaProxy<StateT, ContextT extends IRouterParamContext, ResponseBodyT>({
4224
mountedApps,
4325
packagePath = 'experience',
@@ -47,9 +29,10 @@ export default function koaSpaProxy<StateT, ContextT extends IRouterParamContext
4729
}: Properties): MiddlewareType<StateT, ContextT, ResponseBodyT> {
4830
type Middleware = MiddlewareType<StateT, ContextT, ResponseBodyT>;
4931

50-
// Avoid defining a devProxy if we are in production
51-
const devProxy: Nullable<Middleware> = EnvSet.values.isProduction
52-
? null
32+
const distributionPath = path.join('node_modules/@logto', packagePath, 'dist');
33+
34+
const spaProxy: Middleware = EnvSet.values.isProduction
35+
? serveStatic(distributionPath)
5336
: proxy('*', {
5437
target: `http://localhost:${port}`,
5538
changeOrigin: true,
@@ -58,7 +41,6 @@ export default function koaSpaProxy<StateT, ContextT extends IRouterParamContext
5841
if (path.basename(ctx.request.path).includes('.')) {
5942
return;
6043
}
61-
6244
getConsoleLogFromContext(ctx).plain(`\tproxy --> ${target}`);
6345
},
6446
rewrite: (requestPath) => {
@@ -68,35 +50,30 @@ export default function koaSpaProxy<StateT, ContextT extends IRouterParamContext
6850

6951
return async (ctx, next) => {
7052
const requestPath = ctx.request.path;
71-
7253
// Skip if the request is for another app
7354
if (!prefix && mountedApps.some((app) => app !== prefix && requestPath.startsWith(`/${app}`))) {
7455
return next();
7556
}
76-
7757
const { customUiAssets } = await queries.signInExperiences.findDefaultSignInExperience();
78-
7958
// If user has uploaded custom UI assets, serve them instead of native experience UI
8059
if (customUiAssets && packagePath === 'experience') {
8160
const serve = serveCustomUiAssets(customUiAssets.id);
8261
return serve(ctx, next);
8362
}
8463

85-
// Use the devProxy under development mode
86-
if (devProxy) {
87-
return devProxy(ctx, next);
64+
if (!EnvSet.values.isProduction) {
65+
return spaProxy(ctx, next);
8866
}
8967

90-
const [distributionPath, moduleName] = await getDistributionPath(packagePath, ctx);
9168
const spaDistributionFiles = await fs.readdir(distributionPath);
9269

9370
if (!spaDistributionFiles.some((file) => requestPath.startsWith('/' + file))) {
9471
ctx.request.path = '/';
9572
}
9673

9774
// Add a header to indicate which static package is being served
98-
ctx.set('Logto-Static-Package', moduleName);
75+
ctx.set('Logto-Static-Package', packagePath);
9976

100-
return serveStatic(distributionPath)(ctx, next);
77+
return spaProxy(ctx, next);
10178
};
10279
}

packages/core/src/middleware/utils/experience-proxy.test.ts

Lines changed: 0 additions & 193 deletions
This file was deleted.

0 commit comments

Comments
 (0)