From 1e5b68423a2b3d308a8438885f419840234c009a Mon Sep 17 00:00:00 2001 From: Gao Sun Date: Sun, 2 Apr 2023 17:40:07 +0800 Subject: [PATCH] refactor(core): add single-page apps as dependencies --- .changeset/config.json | 5 +---- .pnpmfile.cjs | 6 +++++- packages/console/package.json | 1 + packages/core/package.json | 3 +++ packages/core/src/middleware/koa-spa-proxy.ts | 2 +- packages/demo-app/package.json | 1 + packages/ui/package.json | 1 + pnpm-lock.yaml | 9 +++++++++ 8 files changed, 22 insertions(+), 6 deletions(-) diff --git a/.changeset/config.json b/.changeset/config.json index 85dfb5a6a..0073d6478 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -9,10 +9,7 @@ "@logto/cli", "@logto/create" ]], - "linked": [[ - "@logto/phrases", - "@logto/phrases-ui" - ]], + "linked": [], "//": "END OF CAUTION", "access": "restricted", "baseBranch": "master", diff --git a/.pnpmfile.cjs b/.pnpmfile.cjs index 1dd3e8b58..8add22ecf 100644 --- a/.pnpmfile.cjs +++ b/.pnpmfile.cjs @@ -1,5 +1,6 @@ // See https://pnpm.io/pnpmfile const fs = require('node:fs/promises'); +const path = require('node:path'); // Types are inspected and edited from https://github.com/pnpm/pnpm/blob/ef6c22e129dc3d76998cee33647b70a66d1f36bf/hooks/pnpmfile/src/requireHooks.ts /** @@ -27,7 +28,10 @@ const hooks = { readPackage: async (pkg) => { } // Apply connector's `package.json` to the template - const result = JSON.parse(await fs.readFile('packages/connectors/templates/package.json', 'utf8')); + const result = JSON.parse( + // Use `__dirname` since the `pnpm i` command may be executed in nested workspace directories + await fs.readFile(path.join(__dirname, 'packages/connectors/templates/package.json'), 'utf8') + ); for (const [key, value] of Object.entries(pkg)) { if (key === '$schema') { continue; diff --git a/packages/console/package.json b/packages/console/package.json index 1a454d30c..573290fc4 100644 --- a/packages/console/package.json +++ b/packages/console/package.json @@ -7,6 +7,7 @@ "license": "MPL-2.0", "type": "module", "private": true, + "files": ["dist"], "scripts": { "precommit": "lint-staged", "start": "parcel src/index.html", diff --git a/packages/core/package.json b/packages/core/package.json index 4af5da523..325438a25 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -30,12 +30,15 @@ "@logto/app-insights": "workspace:^", "@logto/cli": "workspace:^", "@logto/connector-kit": "workspace:^", + "@logto/console": "workspace:*", "@logto/core-kit": "workspace:^", + "@logto/demo-app": "workspace:*", "@logto/language-kit": "workspace:^", "@logto/phrases": "workspace:^", "@logto/phrases-ui": "workspace:^", "@logto/schemas": "workspace:^", "@logto/shared": "workspace:^", + "@logto/ui": "workspace:*", "@silverhand/essentials": "^2.5.0", "aws-sdk": "^2.1329.0", "chalk": "^5.0.0", diff --git a/packages/core/src/middleware/koa-spa-proxy.ts b/packages/core/src/middleware/koa-spa-proxy.ts index 5c6c9bdc6..6874dbd7a 100644 --- a/packages/core/src/middleware/koa-spa-proxy.ts +++ b/packages/core/src/middleware/koa-spa-proxy.ts @@ -16,7 +16,7 @@ export default function koaSpaProxy { type Middleware = MiddlewareType; - const distributionPath = path.join('..', packagePath, 'dist'); + const distributionPath = path.join('node_modules/@logto', packagePath, 'dist'); const spaProxy: Middleware = EnvSet.values.isProduction ? serveStatic(distributionPath) diff --git a/packages/demo-app/package.json b/packages/demo-app/package.json index 195c77bca..47b45b7f8 100644 --- a/packages/demo-app/package.json +++ b/packages/demo-app/package.json @@ -5,6 +5,7 @@ "author": "Silverhand Inc. ", "license": "MPL-2.0", "private": true, + "files": ["dist"], "scripts": { "precommit": "lint-staged", "start": "parcel src/index.html", diff --git a/packages/ui/package.json b/packages/ui/package.json index 3739983eb..1ee6815d3 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -4,6 +4,7 @@ "license": "MPL-2.0", "type": "module", "private": true, + "files": ["dist"], "scripts": { "precommit": "lint-staged", "start": "parcel src/index.html", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 10647e45e..00559183b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3008,9 +3008,15 @@ importers: '@logto/connector-kit': specifier: workspace:^ version: link:../toolkit/connector-kit + '@logto/console': + specifier: workspace:* + version: link:../console '@logto/core-kit': specifier: workspace:^ version: link:../toolkit/core-kit + '@logto/demo-app': + specifier: workspace:* + version: link:../demo-app '@logto/language-kit': specifier: workspace:^ version: link:../toolkit/language-kit @@ -3026,6 +3032,9 @@ importers: '@logto/shared': specifier: workspace:^ version: link:../shared + '@logto/ui': + specifier: workspace:* + version: link:../ui '@silverhand/essentials': specifier: ^2.5.0 version: 2.5.0