From 383790df8c04018b4df5ce8b7699ac00fa758ee2 Mon Sep 17 00:00:00 2001 From: Luv Kapur Date: Thu, 14 Mar 2024 09:35:58 -0400 Subject: [PATCH 01/32] wip - apollo graphql upgrade --- workspace.jsonc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/workspace.jsonc b/workspace.jsonc index 34a43e858baa..2da52edd6662 100644 --- a/workspace.jsonc +++ b/workspace.jsonc @@ -21,7 +21,7 @@ "@bitdev/react.generators.react-templates": "^1.1.21", "@bitdev/symphony.generators.symphony-templates": "~0.0.11", "@graphql-modules/core": "0.7.17", - "@graphql-tools/schema": "^10.0.0", + "@graphql-tools/schema": "^10.0.3", "@jest/test-result": "26.6.2", "@mdx-js/mdx": "1.6.21", "@mdx-js/react": "1.6.22", @@ -402,6 +402,7 @@ "graphql-subscriptions": "1.2.0", "graphql-tag": "2.12.1", "graphql-type-json": "0.3.2", + "graphql-ws": "^5.15.0", "history": "5.3.0", "html-escaper": "3.0.0", "html-webpack-plugin": "5.3.2", @@ -475,7 +476,6 @@ "ssri": "10.0.1", "string_decoder": "^1.3.0", "strip-ansi": "6.0.0", - "subscriptions-transport-ws": "0.9.18", "symlink-dir": "^5.1.1", "table": "6.7.3", "terser-webpack-plugin": "5.2.0", @@ -498,16 +498,16 @@ "webpack-manifest-plugin": "5.0.0", "webpack-merge": "5.8.0", "workbox-webpack-plugin": "6.2.4", - "ws": "7.4.2", + "ws": "^8.16.0", "yesno": "0.4.0" }, "peerDependencies": { - "@apollo/client": "^3.6.0", + "@apollo/client": "^3.9.0", "@teambit/base-react.navigation.link": "2.0.27", "@teambit/legacy": "1.0.669", "@testing-library/react": "^12.1.5", "core-js": "^3.10.0", - "graphql": "15.8.0", + "graphql": "16.8.1", "mz": "2.7.0", "react": "17.0.2", "react-dom": "17.0.2", @@ -628,7 +628,7 @@ "dependencies": { "@teambit/base-react.navigation.link": "2.0.27", "@teambit/ui-foundation.ui.navigation.react-router-adapter": "6.1.1", - "@apollo/client": "3.6.9", + "@apollo/client": "3.9.7", "@teambit/legacy": "1.0.669", // These are the peer dependencies of Yarn "@yarnpkg/cli": "3.6.1", @@ -637,7 +637,7 @@ // ensure types/react in correct version in the root of bvm version "@types/react": "^17.0.67", "@types/react-dom": "^17.0.21", - "graphql": "15.8.0", + "graphql": "16.8.1", "browserslist": "4.16.3", "reflect-metadata": "0.1.13", "monaco-editor": "0.33.0", From 4e0246c6f0d7a64c52e943560b2ba5e643b2c224 Mon Sep 17 00:00:00 2001 From: Luv Kapur Date: Tue, 2 Apr 2024 15:44:18 -0400 Subject: [PATCH 02/32] wip - apollo graphql upgrade --- .bitmap | 7 ++ scopes/harmony/bit/load-bit.ts | 2 + .../graphql/graphql.execution-context.ts | 0 .../harmony/graphql/graphql.main.runtime.ts | 102 ++++++++++-------- scopes/harmony/graphql/schema.ts | 2 +- workspace.jsonc | 11 +- 6 files changed, 71 insertions(+), 53 deletions(-) create mode 100644 scopes/harmony/graphql/graphql.execution-context.ts diff --git a/.bitmap b/.bitmap index a1f0a2ee5988..e1231a7f10eb 100644 --- a/.bitmap +++ b/.bitmap @@ -499,6 +499,13 @@ "mainFile": "index.ts", "rootDir": "scopes/envs/envs" }, + "envs/core-aspect-env": { + "name": "envs/core-aspect-env", + "scope": "teambit.harmony", + "version": "0.0.27", + "mainFile": "index.ts", + "rootDir": "components/envs/core-aspect-env" + }, "eslint": { "name": "eslint", "scope": "teambit.defender", diff --git a/scopes/harmony/bit/load-bit.ts b/scopes/harmony/bit/load-bit.ts index abe6de796bc9..6d9412f6936e 100644 --- a/scopes/harmony/bit/load-bit.ts +++ b/scopes/harmony/bit/load-bit.ts @@ -12,6 +12,8 @@ import { nativeCompileCache } from '@teambit/toolbox.performance.v8-cache'; nativeCompileCache?.install(); import './hook-require'; +// need it for graphql modules to work. https://the-guild.dev/graphql/modules/docs/di/introduction +import 'reflect-metadata'; import { getAspectDir, diff --git a/scopes/harmony/graphql/graphql.execution-context.ts b/scopes/harmony/graphql/graphql.execution-context.ts new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/scopes/harmony/graphql/graphql.main.runtime.ts b/scopes/harmony/graphql/graphql.main.runtime.ts index 9477cbd2f274..b37c7f0985d4 100644 --- a/scopes/harmony/graphql/graphql.main.runtime.ts +++ b/scopes/harmony/graphql/graphql.main.runtime.ts @@ -1,17 +1,16 @@ import { mergeSchemas } from '@graphql-tools/schema'; -import NoIntrospection from 'graphql-disable-introspection'; -import { GraphQLModule } from '@graphql-modules/core'; +import { SubscriptionServer } from 'subscriptions-transport-ws'; +import { Module, createModule, createApplication, Application } from 'graphql-modules'; import { MainRuntime } from '@teambit/cli'; import { Harmony, Slot, SlotRegistry } from '@teambit/harmony'; import { Logger, LoggerAspect, LoggerMain } from '@teambit/logger'; import express, { Express } from 'express'; -import { graphqlHTTP } from 'express-graphql'; +import { createHandler as createGraphqlHandler } from 'graphql-http/lib/use/express'; import { Port } from '@teambit/toolbox.network.get-port'; -import { execute, subscribe } from 'graphql'; +import { execute, subscribe, GraphQLError } from 'graphql'; import { PubSubEngine, PubSub } from 'graphql-subscriptions'; import { createServer, Server } from 'http'; import httpProxy from 'http-proxy'; -import { SubscriptionServer } from 'subscriptions-transport-ws'; import cors from 'cors'; import { GraphQLServer } from './graphql-server'; import { createRemoteSchemas } from './create-remote-schemas'; @@ -82,7 +81,7 @@ export class GraphqlMain { return new PubSub(); } - private modules = new Map(); + private modules = new Map(); /** * returns the schema for a specific aspect by its id. @@ -130,25 +129,61 @@ export class GraphqlMain { app.use( '/graphql', - // eslint-disable-next-line @typescript-eslint/no-misused-promises - graphqlHTTP((request, res, params) => ({ - customFormatErrorFn: (err) => { - this.logger.error('graphql got an error during running the following query:', params); + createGraphqlHandler({ + schema, + validationRules: disableIntrospection + ? [ + function NoIntrospection(context) { + return { + Field(node) { + if (node.name.value === '__schema' || node.name.value === '__type') { + context.reportError( + new GraphQLError( + 'GraphQL introspection is not allowed, but the query contained __schema or __type', + [node] + ) + ); + } + }, + }; + }, + ] + : undefined, + formatError: (err) => { this.logger.error('graphql error ', err); return Object.assign(err, { // @ts-ignore ERR_CODE: err?.originalError?.errors?.[0].ERR_CODE || err.originalError?.constructor?.name, // @ts-ignore HTTP_CODE: err?.originalError?.errors?.[0].HTTP_CODE || err.originalError?.code, + s, }); }, - schema, - rootValue: request, - graphiql, - validationRules: disableIntrospection ? [NoIntrospection] : undefined, - })) + }) ); + // todo - add graphiql middleware for playground + + // app.use( + // '/graphql', + // // eslint-disable-next-line @typescript-eslint/no-misused-promises + // graphqlHTTP((request, res, params) => ({ + // customFormatErrorFn: (err) => { + // this.logger.error('graphql got an error during running the following query:', params); + // this.logger.error('graphql error ', err); + // return Object.assign(err, { + // // @ts-ignore + // ERR_CODE: err?.originalError?.errors?.[0].ERR_CODE || err.originalError?.constructor?.name, + // // @ts-ignore + // HTTP_CODE: err?.originalError?.errors?.[0].HTTP_CODE || err.originalError?.code, s + // }); + // }, + // schema, + // rootValue: request, + // graphiql, + // validationRules: disableIntrospection ? [NoIntrospection] : undefined, + // })) + const server = createServer(app); const subscriptionsPort = options.subscriptionsPortRange || this.config.subscriptionsPortRange; const subscriptionServerPort = await this.getPort(subscriptionsPort); @@ -227,7 +262,7 @@ export class GraphqlMain { }); // eslint-disable-next-line @typescript-eslint/no-unused-vars - const subServer = new SubscriptionServer( + const subServer = SubscriptionServer.create( { execute, subscribe, @@ -253,30 +288,19 @@ export class GraphqlMain { }); } - private createRootModule(schemaSlot?: SchemaSlot) { + private createRootModule(schemaSlot?: SchemaSlot): Application { const modules = this.buildModules(schemaSlot); - return new GraphQLModule({ - imports: modules, - }); + return createApplication({ modules }); } private buildModules(schemaSlot?: SchemaSlot) { const schemaSlots = schemaSlot ? schemaSlot.toArray() : this.moduleSlot.toArray(); return schemaSlots.map(([extensionId, schema]) => { - const moduleDeps = this.getModuleDependencies(extensionId); - - const module = new GraphQLModule({ + const module = createModule({ + id: extensionId, typeDefs: schema.typeDefs, resolvers: schema.resolvers, - schemaDirectives: schema.schemaDirectives, - imports: moduleDeps, - context: (session) => { - return { - ...session, - verb: session?.headers?.['x-verb'] || Verb.READ, - }; - }, }); this.modules.set(extensionId, module); @@ -285,22 +309,6 @@ export class GraphqlMain { }); } - private getModuleDependencies(extensionId: string): GraphQLModule[] { - const extension = this.context.extensions.get(extensionId); - if (!extension) throw new Error(`aspect ${extensionId} was not found`); - const deps = this.context.getDependencies(extension); - const ids = deps.map((dep) => dep.id); - - // @ts-ignore check :TODO why types are breaking here. - return Array.from(this.modules.entries()) - .map(([depId, module]) => { - const dep = ids.includes(depId); - if (!dep) return undefined; - return module; - }) - .filter((module) => !!module); - } - static slots = [Slot.withType(), Slot.withType(), Slot.withType()]; static defaultConfig = { diff --git a/scopes/harmony/graphql/schema.ts b/scopes/harmony/graphql/schema.ts index cc24b672ef31..3c9c11df6a99 100644 --- a/scopes/harmony/graphql/schema.ts +++ b/scopes/harmony/graphql/schema.ts @@ -5,7 +5,7 @@ import type { SchemaDirectives } from '@graphql-modules/core'; * graphql schema for an extension. */ export type Schema = { - typeDefs?: string | DocumentNode; + typeDefs: DocumentNode; resolvers?: { [key: string]: any }; schemaDirectives?: SchemaDirectives; }; diff --git a/workspace.jsonc b/workspace.jsonc index 2da52edd6662..86064207ca9f 100644 --- a/workspace.jsonc +++ b/workspace.jsonc @@ -14,13 +14,12 @@ "policy": { "dependencies": { "@babel/core": "7.19.6", - "@babel/preset-react": "7.22.15", - "@babel/preset-typescript": "7.22.15", + "@babel/preset-react": "^7.23.3", + "@babel/preset-typescript": "^7.23.3", "@babel/types": "7.22.3", "@bitdev/node.generators.node-templates": "^1.0.15", "@bitdev/react.generators.react-templates": "^1.1.21", "@bitdev/symphony.generators.symphony-templates": "~0.0.11", - "@graphql-modules/core": "0.7.17", "@graphql-tools/schema": "^10.0.3", "@jest/test-result": "26.6.2", "@mdx-js/mdx": "1.6.21", @@ -358,7 +357,6 @@ "apollo-link-context": "1.0.20", "apollo-link-http": "1.5.17", "apollo-link-ws": "1.0.20", - "apollo-server": "2.19.2", "apollo-utilities": "1.3.4", "archiver": "5.3.1", "archy": "1.0.0", @@ -390,7 +388,6 @@ "eventemitter2": "6.4.4", "expose-loader": "3.1.0", "express": "4.17.1", - "express-graphql": "0.12.0", "express-history-api-fallback": "2.2.1", "filenamify": "4.2.0", "find-root": "1.1.0", @@ -399,8 +396,11 @@ "get-tsconfig": "4.2.0", "graceful-fs": "4.2.10", "graphql-disable-introspection": "^1.2.0", + "graphql-http": "^1.22.0", + "graphql-modules": "^2.3.0", "graphql-subscriptions": "1.2.0", "graphql-tag": "2.12.1", + "graphql-tools": "^9.0.1", "graphql-type-json": "0.3.2", "graphql-ws": "^5.15.0", "history": "5.3.0", @@ -476,6 +476,7 @@ "ssri": "10.0.1", "string_decoder": "^1.3.0", "strip-ansi": "6.0.0", + "subscriptions-transport-ws": "^0.11.0", "symlink-dir": "^5.1.1", "table": "6.7.3", "terser-webpack-plugin": "5.2.0", From fe7e45b1dfe4bd75cc338b53b68e8035d36d72fe Mon Sep 17 00:00:00 2001 From: Luv Kapur Date: Thu, 4 Apr 2024 17:31:50 -0400 Subject: [PATCH 03/32] wip - apollo server v4 update --- .../graphql/graphql.execution-context.ts | 0 .../harmony/graphql/graphql.main.runtime.ts | 290 +++++++++++------- scopes/harmony/graphql/schema.ts | 2 - workspace.jsonc | 13 +- 4 files changed, 191 insertions(+), 114 deletions(-) delete mode 100644 scopes/harmony/graphql/graphql.execution-context.ts diff --git a/scopes/harmony/graphql/graphql.execution-context.ts b/scopes/harmony/graphql/graphql.execution-context.ts deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/scopes/harmony/graphql/graphql.main.runtime.ts b/scopes/harmony/graphql/graphql.main.runtime.ts index b37c7f0985d4..07719736a9b8 100644 --- a/scopes/harmony/graphql/graphql.main.runtime.ts +++ b/scopes/harmony/graphql/graphql.main.runtime.ts @@ -1,13 +1,15 @@ import { mergeSchemas } from '@graphql-tools/schema'; -import { SubscriptionServer } from 'subscriptions-transport-ws'; +import { WebSocketServer } from 'ws'; +import { ApolloServer } from '@apollo/server'; +import { expressMiddleware } from '@apollo/server/express4'; +import { ApolloServerPluginDrainHttpServer } from '@apollo/server/plugin/drainHttpServer'; +import { useServer } from 'graphql-ws/lib/use/ws'; import { Module, createModule, createApplication, Application } from 'graphql-modules'; import { MainRuntime } from '@teambit/cli'; import { Harmony, Slot, SlotRegistry } from '@teambit/harmony'; import { Logger, LoggerAspect, LoggerMain } from '@teambit/logger'; import express, { Express } from 'express'; -import { createHandler as createGraphqlHandler } from 'graphql-http/lib/use/express'; import { Port } from '@teambit/toolbox.network.get-port'; -import { execute, subscribe, GraphQLError } from 'graphql'; import { PubSubEngine, PubSub } from 'graphql-subscriptions'; import { createServer, Server } from 'http'; import httpProxy from 'http-proxy'; @@ -104,17 +106,111 @@ export class GraphqlMain { }); } + // async createServer(options: GraphQLServerOptions) { + // const { graphiql = true, disableIntrospection } = options; + // const localSchema = this.createRootModule(options.schemaSlot); + // const remoteSchemas = await createRemoteSchemas(options.remoteSchemas || this.graphQLServerSlot.values()); + // const schemas = [localSchema.schema].concat(remoteSchemas).filter((x) => x); + // const schema = mergeSchemas({ + // schemas, + // }); + + // // TODO: @guy please consider to refactor to express extension. + // const app = options.app || express(); + // if (!this.config.disableCors) { + // app.use( + // // @ts-ignore todo: it's not clear what's the issue. + // cors({ + // origin(origin, callback) { + // callback(null, true); + // }, + // credentials: true, + // }) + // ); + // } + + // app.use( + // '/graphql', + // createGraphqlHandler({ + // schema, + // validationRules: disableIntrospection + // ? [ + // function NoIntrospection(context) { + // return { + // Field(node) { + // if (node.name.value === '__schema' || node.name.value === '__type') { + // context.reportError( + // new GraphQLError( + // 'GraphQL introspection is not allowed, but the query contained __schema or __type', + // [node] + // ) + // ); + // } + // }, + // }; + // }, + // ] + // : undefined, + // formatError: (err) => { + // this.logger.error('graphql error ', err); + // return Object.assign(err, { + // // @ts-ignore + // ERR_CODE: err?.originalError?.errors?.[0].ERR_CODE || err.originalError?.constructor?.name, + // // @ts-ignore + // HTTP_CODE: err?.originalError?.errors?.[0].HTTP_CODE || err.originalError?.code, + // }); + // }, + // }) + // ); + + // // todo - add graphiql middleware for playground + + // // app.use( + // // '/graphql', + // // // eslint-disable-next-line @typescript-eslint/no-misused-promises + // // graphqlHTTP((request, res, params) => ({ + // // customFormatErrorFn: (err) => { + // // this.logger.error('graphql got an error during running the following query:', params); + // // this.logger.error('graphql error ', err); + // // return Object.assign(err, { + // // // @ts-ignore + // // ERR_CODE: err?.originalError?.errors?.[0].ERR_CODE || err.originalError?.constructor?.name, + // // // @ts-ignore + // // HTTP_CODE: err?.originalError?.errors?.[0].HTTP_CODE || err.originalError?.code, s + // // }); + // // }, + // // schema, + // // rootValue: request, + // // graphiql, + // // validationRules: disableIntrospection ? [NoIntrospection] : undefined, + // // })) + + // const server = createServer(app); + // const subscriptionsPort = options.subscriptionsPortRange || this.config.subscriptionsPortRange; + // const subscriptionServerPort = await this.getPort(subscriptionsPort); + // const { port } = await this.createSubscription(options, subscriptionServerPort); + // this.proxySubscription(server, port); + + // return server; + // } + async createServer(options: GraphQLServerOptions) { - const { graphiql = true, disableIntrospection } = options; + const app = options.app || express(); + const httpServer = createServer(app); + const localSchema = this.createRootModule(options.schemaSlot); const remoteSchemas = await createRemoteSchemas(options.remoteSchemas || this.graphQLServerSlot.values()); const schemas = [localSchema.schema].concat(remoteSchemas).filter((x) => x); - const schema = mergeSchemas({ + const mergedSchema = mergeSchemas({ schemas, }); + const apolloServer = new ApolloServer({ + schema: mergedSchema, + plugins: [ApolloServerPluginDrainHttpServer({ httpServer })], + }); + + await apolloServer.start(); - // TODO: @guy please consider to refactor to express extension. - const app = options.app || express(); if (!this.config.disableCors) { app.use( // @ts-ignore todo: it's not clear what's the issue. @@ -127,70 +223,40 @@ export class GraphqlMain { ); } - app.use( - '/graphql', - createGraphqlHandler({ + app.use('/graphql', expressMiddleware(apolloServer, {})); + + await this.createSubscription(mergedSchema, httpServer); + + return httpServer; + } + + async createSubscription(schema, httpServer) { + const websocketServer = new WebSocketServer({ + noServer: true, // Use the HTTP server for handling WebSocket connections + path: this.config.subscriptionsPath, + }); + + httpServer.on('upgrade', (request, socket, head) => { + // Only handle upgrades for the specific path, otherwise ignore + if (request.url.startsWith(this.config.subscriptionsPath)) { + websocketServer.handleUpgrade(request, socket, head, (websocket) => { + websocketServer.emit('connection', websocket, request); + }); + } + }); + + useServer( + { schema, - validationRules: disableIntrospection - ? [ - function NoIntrospection(context) { - return { - Field(node) { - if (node.name.value === '__schema' || node.name.value === '__type') { - context.reportError( - new GraphQLError( - 'GraphQL introspection is not allowed, but the query contained __schema or __type', - [node] - ) - ); - } - }, - }; - }, - ] - : undefined, - formatError: (err) => { - this.logger.error('graphql error ', err); - return Object.assign(err, { - // @ts-ignore - ERR_CODE: err?.originalError?.errors?.[0].ERR_CODE || err.originalError?.constructor?.name, - // @ts-ignore - HTTP_CODE: err?.originalError?.errors?.[0].HTTP_CODE || err.originalError?.code, - s, - }); + onConnect: (ctx) => { + console.log('Connected!', ctx); }, - }) + onDisconnect(ctx, code, reason) { + console.log('Disconnected!', code, reason); + }, + }, + websocketServer ); - - // todo - add graphiql middleware for playground - - // app.use( - // '/graphql', - // // eslint-disable-next-line @typescript-eslint/no-misused-promises - // graphqlHTTP((request, res, params) => ({ - // customFormatErrorFn: (err) => { - // this.logger.error('graphql got an error during running the following query:', params); - // this.logger.error('graphql error ', err); - // return Object.assign(err, { - // // @ts-ignore - // ERR_CODE: err?.originalError?.errors?.[0].ERR_CODE || err.originalError?.constructor?.name, - // // @ts-ignore - // HTTP_CODE: err?.originalError?.errors?.[0].HTTP_CODE || err.originalError?.code, s - // }); - // }, - // schema, - // rootValue: request, - // graphiql, - // validationRules: disableIntrospection ? [NoIntrospection] : undefined, - // })) - - const server = createServer(app); - const subscriptionsPort = options.subscriptionsPortRange || this.config.subscriptionsPortRange; - const subscriptionServerPort = await this.getPort(subscriptionsPort); - const { port } = await this.createSubscription(options, subscriptionServerPort); - this.proxySubscription(server, port); - - return server; } /** @@ -242,48 +308,58 @@ export class GraphqlMain { /** create Subscription server with different port */ - private async createSubscription(options: GraphQLServerOptions, port: number) { - // Create WebSocket listener server - const websocketServer = createServer((request, response) => { - response.writeHead(404); - response.end(); - }); - - // Bind it to port and start listening - websocketServer.listen(port, () => - this.logger.debug(`Websocket Server is now running on http://localhost:${port}`) - ); - - const localSchema = this.createRootModule(options.schemaSlot); - const remoteSchemas = await createRemoteSchemas(options.remoteSchemas || this.graphQLServerSlot.values()); - const schemas = [localSchema.schema].concat(remoteSchemas).filter((x) => x); - const schema = mergeSchemas({ - schemas, - }); - - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const subServer = SubscriptionServer.create( - { - execute, - subscribe, - schema, - onConnect: options.onWsConnect, - }, - { - server: websocketServer, - path: this.config.subscriptionsPath, - } - ); - return { subServer, port }; - } + // private async createSubscription(options: GraphQLServerOptions, port: number) { + // // Create WebSocket listener server + // const websocketServer = createServer((request, response) => { + // response.writeHead(404); + // response.end(); + // }); + + // // Bind it to port and start listening + // websocketServer.listen(port, () => + // this.logger.debug(`Websocket Server is now running on http://localhost:${port}`) + // ); + + // const localSchema = this.createRootModule(options.schemaSlot); + // const remoteSchemas = await createRemoteSchemas(options.remoteSchemas || this.graphQLServerSlot.values()); + // const schemas = [localSchema.schema].concat(remoteSchemas).filter((x) => x); + // const schema = mergeSchemas({ + // schemas, + // }); + + // // eslint-disable-next-line @typescript-eslint/no-unused-vars + // const subServer = SubscriptionServer.create( + // { + // execute, + // subscribe, + // schema, + // onConnect: options.onWsConnect, + // }, + // { + // server: websocketServer, + // path: this.config.subscriptionsPath, + // } + // ); + // return { subServer, port }; + // } /** proxy ws Subscription server to avoid conflict with different websocket connections */ private proxySubscription(server: Server, port: number) { - const proxServer = httpProxy.createProxyServer(); - const subscriptionsPath = this.config.subscriptionsPath; - server.on('upgrade', function (req, socket, head) { - if (req.url === subscriptionsPath) { - proxServer.ws(req, socket, head, { target: { host: 'localhost', port } }); + // const proxServer = httpProxy.createProxyServer(); + // const subscriptionsPath = this.config.subscriptionsPath; + // server.on('upgrade', function (req, socket, head) { + // if (req.url === subscriptionsPath) { + // proxServer.ws(req, socket, head, { target: { host: 'localhost', port } }); + // } + // }); + const proxy = httpProxy.createProxyServer({ ws: true, changeOrigin: true }); + + server.on('upgrade', (req, socket, head) => { + // Check if the upgrade request is for the GraphQL subscriptions endpoint + if (req.url?.startsWith(this.config.subscriptionsPath)) { + proxy.ws(req, socket, head, { + target: `ws://localhost:${port}${this.config.subscriptionsPath}`, + }); } }); } diff --git a/scopes/harmony/graphql/schema.ts b/scopes/harmony/graphql/schema.ts index 3c9c11df6a99..fff1602565f7 100644 --- a/scopes/harmony/graphql/schema.ts +++ b/scopes/harmony/graphql/schema.ts @@ -1,5 +1,4 @@ import type { DocumentNode } from 'graphql'; -import type { SchemaDirectives } from '@graphql-modules/core'; /** * graphql schema for an extension. @@ -7,5 +6,4 @@ import type { SchemaDirectives } from '@graphql-modules/core'; export type Schema = { typeDefs: DocumentNode; resolvers?: { [key: string]: any }; - schemaDirectives?: SchemaDirectives; }; diff --git a/workspace.jsonc b/workspace.jsonc index 86064207ca9f..8f2cc82b95b9 100644 --- a/workspace.jsonc +++ b/workspace.jsonc @@ -13,6 +13,7 @@ "packageManager": "teambit.dependencies/pnpm", "policy": { "dependencies": { + "@apollo/server": "^4.10.2", "@babel/core": "7.19.6", "@babel/preset-react": "^7.23.3", "@babel/preset-typescript": "^7.23.3", @@ -354,10 +355,12 @@ "@yarnpkg/plugin-npm": "2.7.4", "@yarnpkg/plugin-pack": "3.2.0", "ansi-to-html": "0.6.14", - "apollo-link-context": "1.0.20", - "apollo-link-http": "1.5.17", - "apollo-link-ws": "1.0.20", - "apollo-utilities": "1.3.4", + "apollo-link": "^1.2.14", + "apollo-link-context": "^1.0.20", + "apollo-link-http": "^1.5.17", + "apollo-link-ws": "^1.0.20", + "apollo-server": "^3.13.0", + "apollo-utilities": "^1.3.4", "archiver": "5.3.1", "archy": "1.0.0", "assert": "^2.1.0", @@ -399,7 +402,7 @@ "graphql-http": "^1.22.0", "graphql-modules": "^2.3.0", "graphql-subscriptions": "1.2.0", - "graphql-tag": "2.12.1", + "graphql-tag": "^2.12.6", "graphql-tools": "^9.0.1", "graphql-type-json": "0.3.2", "graphql-ws": "^5.15.0", From 66d9bade294ba1482470af663bca58a996bc7813 Mon Sep 17 00:00:00 2001 From: Luv Kapur Date: Fri, 5 Apr 2024 14:18:35 -0400 Subject: [PATCH 04/32] apollo graphql upgrade --- .bitmap | 285 +++++++++--------- .../component-issues/removed-dependencies.ts | 5 +- components/renderers/react/react.renderer.tsx | 5 +- .../schema-nodes-index/schema-nodes-index.tsx | 5 +- .../lane-compare-drawer.tsx | 16 +- .../ui/compare/lane-compare/lane-compare.tsx | 46 ++- .../env-filter/envs-filter.tsx | 5 +- .../component-size/component-size.module.scss | 12 + .../ui/component-size/component-size.tsx | 37 +++ components/ui/component-size/index.ts | 1 + .../inputs/lane-selector_1/lane-menu-item.tsx | 2 + .../menus/use-lanes-menu/use-lanes-menu.tsx | 5 +- components/ui/version-block/version-block.tsx | 5 +- .../api-reference.table-of-contents.tsx | 5 +- .../grouped-schema-nodes-overview-summary.tsx | 5 +- .../renderers/type-ref/type-ref.renderer.tsx | 5 +- .../api-reference-page/api-reference-page.tsx | 5 +- scopes/cloud/cloud/cloud.main.runtime.ts | 54 ++-- scopes/cloud/cloud/login.cmd.ts | 18 +- scopes/cloud/ui/login/login.tsx | 5 +- scopes/compilation/compiler/compiler.cmd.ts | 39 +-- .../events/component-compilation-on-done.ts | 26 -- scopes/compilation/compiler/events/index.ts | 1 - .../compilation/compiler/output-formatter.ts | 8 +- .../compiler/workspace-compiler.ts | 59 ++-- scopes/component/checkout/checkout-cmd.ts | 6 +- .../checkout/checkout.main.runtime.ts | 3 +- .../component-writer.main.runtime.ts | 30 +- scopes/component/component-writer/index.ts | 1 + scopes/component/component/component.ts | 10 + .../component/component/show/id.fragment.ts | 4 +- .../component/ui/top-bar-nav/top-bar-nav.tsx | 5 +- .../component/forking/forking.main.runtime.ts | 10 +- scopes/component/graph/component-id-graph.ts | 46 +-- scopes/component/graph/graph-cmd.ts | 2 +- .../dependencies-compare.tsx | 7 +- .../dependencies-graph/dependencies-graph.tsx | 7 +- scopes/component/mover/move-cmd.ts | 5 +- .../new-component-helper.main.runtime.ts | 38 ++- .../refactoring/refactoring.main.runtime.ts | 35 +-- scopes/component/renaming/rename.cmd.ts | 2 +- .../renaming/renaming.main.runtime.ts | 14 +- scopes/component/renaming/scope-rename.cmd.ts | 7 +- .../snapping/snapping.main.runtime.ts | 3 +- .../compositions/compositions.tsx | 5 +- .../eslint-config-mutator/config-mutator.ts | 18 +- .../defender/eslint-config-mutator/index.ts | 1 + scopes/defender/eslint/eslint.linter.ts | 4 +- scopes/defender/eslint/eslint.main.runtime.ts | 18 +- scopes/defender/eslint/index.ts | 7 +- scopes/defender/linter/lint.task.ts | 16 +- .../prettier-config-mutator/config-mutator.ts | 9 + .../defender/prettier-config-mutator/index.ts | 1 + scopes/defender/prettier/index.ts | 7 +- .../prettier/prettier.main.runtime.ts | 17 +- scopes/defender/tester/tester.ts | 10 + .../dependencies/dependency-list.ts | 4 +- .../dependency-resolver-workspace-config.ts | 6 + .../dependency-resolver.main.runtime.ts | 12 +- .../dependency-resolver/package-manager.ts | 6 + scopes/dependencies/pnpm/lynx.ts | 53 ++-- .../dependencies/pnpm/pnpm.package-manager.ts | 20 +- .../generator/component-generator.ts | 17 +- scopes/generator/generator/create.cmd.ts | 3 + .../exceptions/workspace-path-exists.ts | 7 + .../generator/generator.main.runtime.ts | 15 +- .../generator/workspace-generator.ts | 13 +- scopes/harmony/api-server/api-for-ide.ts | 1 - scopes/harmony/aspect/aspect.env.ts | 26 +- scopes/harmony/aspect/aspect.main.runtime.ts | 13 +- scopes/harmony/bit/load-bit.ts | 4 + scopes/harmony/bit/manifests.ts | 2 + scopes/harmony/cli/cli-parser.ts | 9 +- scopes/harmony/cli/cli.cmd.ts | 2 +- scopes/harmony/cli/cli.main.runtime.ts | 35 ++- scopes/harmony/cli/command-runner.ts | 22 +- scopes/harmony/cli/yargs-adapter.ts | 5 +- .../create-remote-schemas.ts | 111 ++++--- scopes/harmony/graphql/graphql-server.ts | 1 - .../harmony/graphql/graphql.main.runtime.ts | 59 +++- scopes/lanes/lanes/lane.cmd.ts | 27 +- scopes/lanes/lanes/lanes.main.runtime.ts | 11 +- scopes/lanes/lanes/lanes.spec.ts | 4 +- scopes/lanes/lanes/switch-lanes.ts | 8 +- scopes/lanes/lanes/switch.cmd.ts | 10 +- .../merge-lanes/merge-lanes.main.runtime.ts | 7 +- scopes/mdx/mdx/mdx.main.runtime.ts | 26 +- scopes/pkg/pkg/publisher.ts | 13 +- .../bit-react-eslint.js | 7 +- scopes/react/react/react.env.ts | 86 +++--- scopes/react/react/react.main.runtime.ts | 12 +- scopes/scope/export/export-cmd.ts | 4 +- scopes/scope/importer/dependents-getter.ts | 6 +- scopes/scope/importer/fetch-cmd.ts | 2 +- scopes/scope/importer/import-components.ts | 14 +- scopes/scope/importer/import.cmd.ts | 18 +- scopes/scope/importer/index.ts | 1 + scopes/scope/sign/sign.main.runtime.ts | 2 +- .../update-dependencies.cmd.ts | 1 + .../update-dependencies.main.runtime.ts | 22 +- .../transformers/array-literal-expression.ts | 3 +- .../typescript/transformers/literal-value.ts | 3 +- .../transformers/object-literal-expression.ts | 3 +- scopes/ui-foundation/ui/bundle-ui.task.ts | 2 +- scopes/ui-foundation/ui/start.cmd.tsx | 4 +- .../workspace/install/install.main.runtime.ts | 1 + .../node-modules-linker.ts | 6 +- scopes/workspace/watcher/output-formatter.ts | 64 ++-- scopes/workspace/watcher/watch.cmd.ts | 14 +- .../workspace/watcher/watcher.main.runtime.ts | 3 +- scopes/workspace/watcher/watcher.ts | 40 +-- scopes/workspace/workspace/bit-map.ts | 4 + .../workspace/build-graph-ids-from-fs.ts | 12 +- .../workspace/workspace-aspects-loader.ts | 19 +- .../workspace-component-loader.ts | 72 +++-- .../workspace/workspace.main.runtime.ts | 7 +- scopes/workspace/workspace/workspace.ts | 37 ++- workspace.jsonc | 42 +-- 118 files changed, 1263 insertions(+), 807 deletions(-) create mode 100644 components/ui/component-size/component-size.module.scss create mode 100644 components/ui/component-size/component-size.tsx create mode 100644 components/ui/component-size/index.ts delete mode 100644 scopes/compilation/compiler/events/component-compilation-on-done.ts create mode 100644 scopes/generator/generator/exceptions/workspace-path-exists.ts diff --git a/.bitmap b/.bitmap index e1231a7f10eb..589403c975be 100644 --- a/.bitmap +++ b/.bitmap @@ -12,21 +12,21 @@ "api-reference": { "name": "api-reference", "scope": "teambit.api-reference", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/api-reference/api-reference" }, "api-server": { "name": "api-server", "scope": "teambit.harmony", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/harmony/api-server" }, "application": { "name": "application", "scope": "teambit.harmony", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/harmony/application" }, @@ -40,7 +40,7 @@ "aspect": { "name": "aspect", "scope": "teambit.harmony", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/harmony/aspect" }, @@ -194,14 +194,14 @@ "aspect-loader": { "name": "aspect-loader", "scope": "teambit.harmony", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/harmony/aspect-loader" }, "babel": { "name": "babel", "scope": "teambit.compilation", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/compilation/babel" }, @@ -215,14 +215,14 @@ "bit": { "name": "bit", "scope": "teambit.harmony", - "version": "1.6.86", + "version": "1.6.114", "mainFile": "index.ts", "rootDir": "scopes/harmony/bit" }, "builder": { "name": "builder", "scope": "teambit.pipelines", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/pipelines/builder" }, @@ -236,28 +236,28 @@ "bundler": { "name": "bundler", "scope": "teambit.compilation", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/compilation/bundler" }, "cache": { "name": "cache", "scope": "teambit.harmony", - "version": "0.0.950", + "version": "0.0.952", "mainFile": "index.ts", "rootDir": "scopes/harmony/cache" }, "changelog": { "name": "changelog", "scope": "teambit.component", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/component/changelog" }, "checkout": { "name": "checkout", "scope": "teambit.component", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/component/checkout" }, @@ -271,7 +271,7 @@ "cli": { "name": "cli", "scope": "teambit.harmony", - "version": "0.0.857", + "version": "0.0.859", "mainFile": "index.ts", "rootDir": "scopes/harmony/cli" }, @@ -292,49 +292,49 @@ "cloud": { "name": "cloud", "scope": "teambit.cloud", - "version": "0.0.469", + "version": "0.0.497", "mainFile": "index.ts", "rootDir": "scopes/cloud/cloud" }, "code": { "name": "code", "scope": "teambit.component", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/component/code" }, "command-bar": { "name": "command-bar", "scope": "teambit.explorer", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/explorer/command-bar" }, "community": { "name": "community", "scope": "teambit.community", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/community/community" }, "compiler": { "name": "compiler", "scope": "teambit.compilation", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/compilation/compiler" }, "component": { "name": "component", "scope": "teambit.component", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/component/component" }, "component-compare": { "name": "component-compare", "scope": "teambit.component", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/component/component-compare" }, @@ -348,14 +348,14 @@ "component-issues": { "name": "component-issues", "scope": "teambit.component", - "version": "0.0.141", + "version": "0.0.142", "mainFile": "index.ts", "rootDir": "components/component-issues" }, "component-log": { "name": "component-log", "scope": "teambit.component", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/component/component-log" }, @@ -369,21 +369,21 @@ "component-sizer": { "name": "component-sizer", "scope": "teambit.component", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/component/component-sizer" }, "component-tree": { "name": "component-tree", "scope": "teambit.component", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/component/component-tree" }, "component-writer": { "name": "component-writer", "scope": "teambit.component", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/component/component-writer" }, @@ -397,77 +397,77 @@ "compositions": { "name": "compositions", "scope": "teambit.compositions", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/compositions/compositions" }, "config": { "name": "config", "scope": "teambit.harmony", - "version": "0.0.944", + "version": "0.0.972", "mainFile": "index.ts", "rootDir": "scopes/harmony/config" }, "config-merger": { "name": "config-merger", "scope": "teambit.workspace", - "version": "0.0.60", + "version": "0.0.88", "mainFile": "index.ts", "rootDir": "scopes/workspace/config-merger" }, "content/cli-reference": { "name": "content/cli-reference", "scope": "teambit.harmony", - "version": "2.0.200", + "version": "2.0.228", "mainFile": "index.ts", "rootDir": "scopes/harmony/cli-reference" }, "dependencies": { "name": "dependencies", "scope": "teambit.dependencies", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/dependencies/dependencies" }, "dependency-resolver": { "name": "dependency-resolver", "scope": "teambit.dependencies", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/dependencies/dependency-resolver" }, "deprecation": { "name": "deprecation", "scope": "teambit.component", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/component/deprecation" }, "dev-files": { "name": "dev-files", "scope": "teambit.component", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/component/dev-files" }, "diagnostic": { "name": "diagnostic", "scope": "teambit.harmony", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/harmony/diagnostic" }, "docs": { "name": "docs", "scope": "teambit.docs", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/docs/docs" }, "eject": { "name": "eject", "scope": "teambit.workspace", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/workspace/eject" }, @@ -488,42 +488,35 @@ "env": { "name": "env", "scope": "teambit.envs", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/envs/env" }, "envs": { "name": "envs", "scope": "teambit.envs", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/envs/envs" }, - "envs/core-aspect-env": { - "name": "envs/core-aspect-env", - "scope": "teambit.harmony", - "version": "0.0.27", - "mainFile": "index.ts", - "rootDir": "components/envs/core-aspect-env" - }, "eslint": { "name": "eslint", "scope": "teambit.defender", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/defender/eslint" }, "eslint-config-bit-react": { "name": "eslint-config-bit-react", "scope": "teambit.react", - "version": "1.0.132", + "version": "1.0.146", "mainFile": "index.js", "rootDir": "scopes/react/eslint-config-bit-react" }, "eslint/config-mutator": { "name": "eslint/config-mutator", "scope": "teambit.defender", - "version": "0.0.99", + "version": "0.0.101", "mainFile": "index.ts", "rootDir": "scopes/defender/eslint-config-mutator" }, @@ -537,28 +530,28 @@ "export": { "name": "export", "scope": "teambit.scope", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/scope/export" }, "express": { "name": "express", "scope": "teambit.harmony", - "version": "0.0.956", + "version": "0.0.958", "mainFile": "index.ts", "rootDir": "scopes/harmony/express" }, "forking": { "name": "forking", "scope": "teambit.component", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/component/forking" }, "formatter": { "name": "formatter", "scope": "teambit.defender", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/defender/formatter" }, @@ -586,42 +579,42 @@ "generator": { "name": "generator", "scope": "teambit.generator", - "version": "1.0.194", + "version": "1.0.222", "mainFile": "index.ts", "rootDir": "scopes/generator/generator" }, "git": { "name": "git", "scope": "teambit.git", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/git/git" }, "global-config": { "name": "global-config", "scope": "teambit.harmony", - "version": "0.0.860", + "version": "0.0.862", "mainFile": "index.ts", "rootDir": "scopes/harmony/global-config" }, "graph": { "name": "graph", "scope": "teambit.component", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/component/graph" }, "graphql": { "name": "graphql", "scope": "teambit.harmony", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/harmony/graphql" }, "harmony-ui-app": { "name": "harmony-ui-app", "scope": "teambit.ui-foundation", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/ui-foundation/harmony-ui-app/harmony-ui-app" }, @@ -698,112 +691,112 @@ "html": { "name": "html", "scope": "teambit.html", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/html/html" }, "importer": { "name": "importer", "scope": "teambit.scope", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/scope/importer" }, "insights": { "name": "insights", "scope": "teambit.explorer", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/explorer/insights" }, "install": { "name": "install", "scope": "teambit.workspace", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/workspace/install" }, "ipc-events": { "name": "ipc-events", "scope": "teambit.harmony", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/harmony/ipc-events" }, "isolator": { "name": "isolator", "scope": "teambit.component", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/component/isolator" }, "issues": { "name": "issues", "scope": "teambit.component", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/component/issues" }, "jest": { "name": "jest", "scope": "teambit.defender", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/defender/jest" }, "lanes": { "name": "lanes", "scope": "teambit.lanes", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/lanes/lanes" }, "linter": { "name": "linter", "scope": "teambit.defender", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/defender/linter" }, "lister": { "name": "lister", "scope": "teambit.component", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/component/lister" }, "logger": { "name": "logger", "scope": "teambit.harmony", - "version": "0.0.950", + "version": "0.0.952", "mainFile": "index.ts", "rootDir": "scopes/harmony/logger" }, "mdx": { "name": "mdx", "scope": "teambit.mdx", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/mdx/mdx" }, "merge-lanes": { "name": "merge-lanes", "scope": "teambit.lanes", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/lanes/merge-lanes" }, "merging": { "name": "merging", "scope": "teambit.component", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/component/merging" }, "mocha": { "name": "mocha", "scope": "teambit.defender", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/defender/mocha" }, @@ -957,7 +950,7 @@ "modules/node-modules-linker": { "name": "modules/node-modules-linker", "scope": "teambit.workspace", - "version": "0.0.165", + "version": "0.0.166", "mainFile": "index.ts", "rootDir": "scopes/workspace/modules/node-modules-linker" }, @@ -999,21 +992,21 @@ "mover": { "name": "mover", "scope": "teambit.component", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/component/mover" }, "multi-compiler": { "name": "multi-compiler", "scope": "teambit.compilation", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/compilation/multi-compiler" }, "multi-tester": { "name": "multi-tester", "scope": "teambit.defender", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/defender/multi-tester" }, @@ -1027,42 +1020,42 @@ "new-component-helper": { "name": "new-component-helper", "scope": "teambit.component", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/component/new-component-helper" }, "node": { "name": "node", "scope": "teambit.harmony", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/harmony/node" }, "notifications": { "name": "notifications", "scope": "teambit.ui-foundation", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/ui-foundation/notifications/aspect" }, "overview/api-reference-table-of-contents": { "name": "overview/api-reference-table-of-contents", "scope": "teambit.api-reference", - "version": "0.0.9", + "version": "0.0.10", "mainFile": "index.ts", "rootDir": "scopes/api-reference/overview/api-reference-table-of-contents" }, "overview/renderers/grouped-schema-nodes-overview-summary": { "name": "overview/renderers/grouped-schema-nodes-overview-summary", "scope": "teambit.api-reference", - "version": "0.0.9", + "version": "0.0.10", "mainFile": "index.ts", "rootDir": "scopes/api-reference/renderers/grouped-schema-nodes-overview-summary" }, "panels": { "name": "panels", "scope": "teambit.ui-foundation", - "version": "0.0.859", + "version": "0.0.861", "mainFile": "index.ts", "rootDir": "scopes/ui-foundation/panels" }, @@ -1104,7 +1097,7 @@ "pkg": { "name": "pkg", "scope": "teambit.pkg", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/pkg/pkg" }, @@ -1118,98 +1111,98 @@ "pnpm": { "name": "pnpm", "scope": "teambit.dependencies", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/dependencies/pnpm" }, "prettier": { "name": "prettier", "scope": "teambit.defender", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/defender/prettier" }, "prettier/config-mutator": { "name": "prettier/config-mutator", "scope": "teambit.defender", - "version": "0.0.99", + "version": "0.0.100", "mainFile": "index.ts", "rootDir": "scopes/defender/prettier-config-mutator" }, "preview": { "name": "preview", "scope": "teambit.preview", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/preview/preview" }, "pubsub": { "name": "pubsub", "scope": "teambit.harmony", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/harmony/pubsub" }, "react": { "name": "react", "scope": "teambit.react", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/react/react" }, "react-native": { "name": "react-native", "scope": "teambit.react", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/react/react-native" }, "react-router": { "name": "react-router", "scope": "teambit.ui-foundation", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/ui-foundation/react-router/react-router" }, "readme": { "name": "readme", "scope": "teambit.mdx", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/mdx/readme" }, "refactoring": { "name": "refactoring", "scope": "teambit.component", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/component/refactoring" }, "remove": { "name": "remove", "scope": "teambit.component", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/component/remove" }, "renaming": { "name": "renaming", "scope": "teambit.component", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/component/renaming" }, "renderers/api-node-details": { "name": "renderers/api-node-details", "scope": "teambit.api-reference", - "version": "0.0.39", + "version": "0.0.40", "mainFile": "index.ts", "rootDir": "components/renderers/api-node-details" }, "renderers/class": { "name": "renderers/class", "scope": "teambit.api-reference", - "version": "0.0.40", + "version": "0.0.41", "mainFile": "index.ts", "rootDir": "components/renderers/class" }, @@ -1223,14 +1216,14 @@ "renderers/enum": { "name": "renderers/enum", "scope": "teambit.api-reference", - "version": "0.0.40", + "version": "0.0.41", "mainFile": "index.ts", "rootDir": "components/renderers/enum" }, "renderers/function": { "name": "renderers/function", "scope": "teambit.api-reference", - "version": "0.0.43", + "version": "0.0.44", "mainFile": "index.ts", "rootDir": "scopes/api-reference/renderers/function" }, @@ -1251,7 +1244,7 @@ "renderers/interface": { "name": "renderers/interface", "scope": "teambit.api-reference", - "version": "0.0.40", + "version": "0.0.41", "mainFile": "index.ts", "rootDir": "components/renderers/interface" }, @@ -1265,7 +1258,7 @@ "renderers/react": { "name": "renderers/react", "scope": "teambit.api-reference", - "version": "0.0.26", + "version": "0.0.27", "mainFile": "index.ts", "rootDir": "components/renderers/react" }, @@ -1279,21 +1272,21 @@ "renderers/schema-nodes-index": { "name": "renderers/schema-nodes-index", "scope": "teambit.api-reference", - "version": "0.0.34", + "version": "0.0.35", "mainFile": "index.ts", "rootDir": "components/renderers/schema-nodes-index" }, "renderers/this": { "name": "renderers/this", "scope": "teambit.api-reference", - "version": "0.0.28", + "version": "0.0.29", "mainFile": "index.ts", "rootDir": "scopes/api-reference/renderers/this" }, "renderers/type": { "name": "renderers/type", "scope": "teambit.api-reference", - "version": "0.0.39", + "version": "0.0.40", "mainFile": "index.ts", "rootDir": "components/renderers/type" }, @@ -1314,14 +1307,14 @@ "renderers/type-literal": { "name": "renderers/type-literal", "scope": "teambit.api-reference", - "version": "0.0.35", + "version": "0.0.36", "mainFile": "index.ts", "rootDir": "components/renderers/type-literal" }, "renderers/type-ref": { "name": "renderers/type-ref", "scope": "teambit.api-reference", - "version": "0.0.56", + "version": "0.0.57", "mainFile": "index.ts", "rootDir": "scopes/api-reference/renderers/type-ref" }, @@ -1335,35 +1328,35 @@ "renderers/unresolved": { "name": "renderers/unresolved", "scope": "teambit.api-reference", - "version": "0.0.39", + "version": "0.0.40", "mainFile": "index.ts", "rootDir": "components/renderers/unresolved" }, "renderers/variable": { "name": "renderers/variable", "scope": "teambit.api-reference", - "version": "0.0.39", + "version": "0.0.40", "mainFile": "index.ts", "rootDir": "components/renderers/variable" }, "schema": { "name": "schema", "scope": "teambit.semantics", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/semantics/schema" }, "scope": { "name": "scope", "scope": "teambit.scope", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/scope/scope" }, "sections/api-reference-page": { "name": "sections/api-reference-page", "scope": "teambit.api-reference", - "version": "0.0.65", + "version": "0.0.66", "mainFile": "index.ts", "rootDir": "scopes/api-reference/sections/api-reference-page" }, @@ -1377,35 +1370,35 @@ "sidebar": { "name": "sidebar", "scope": "teambit.ui-foundation", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/ui-foundation/sidebar" }, "sign": { "name": "sign", "scope": "teambit.scope", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/scope/sign" }, "snapping": { "name": "snapping", "scope": "teambit.component", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/component/snapping" }, "stash": { "name": "stash", "scope": "teambit.component", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/component/stash" }, "status": { "name": "status", "scope": "teambit.component", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/component/status" }, @@ -1440,28 +1433,28 @@ "tagged-exports": { "name": "tagged-exports", "scope": "teambit.api-reference", - "version": "0.0.9", + "version": "0.0.10", "mainFile": "index.ts", "rootDir": "scopes/api-reference/tagged-exports" }, "tester": { "name": "tester", "scope": "teambit.defender", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/defender/tester" }, "testing/load-aspect": { "name": "testing/load-aspect", "scope": "teambit.harmony", - "version": "0.0.188", + "version": "0.0.189", "mainFile": "index.ts", "rootDir": "scopes/harmony/testing/load-aspect" }, "testing/mock-components": { "name": "testing/mock-components", "scope": "teambit.component", - "version": "0.0.193", + "version": "0.0.194", "mainFile": "index.ts", "rootDir": "scopes/component/testing/mock-components" }, @@ -1482,7 +1475,7 @@ "tracker": { "name": "tracker", "scope": "teambit.component", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/component/tracker" }, @@ -1503,14 +1496,14 @@ "typescript": { "name": "typescript", "scope": "teambit.typescript", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/typescript/typescript" }, "ui": { "name": "ui", "scope": "teambit.ui-foundation", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/ui-foundation/ui" }, @@ -1531,7 +1524,7 @@ "ui/code-compare": { "name": "ui/code-compare", "scope": "teambit.code", - "version": "0.0.293", + "version": "0.0.298", "mainFile": "index.ts", "rootDir": "components/ui/code-compare" }, @@ -1552,14 +1545,14 @@ "ui/compare/lane-compare": { "name": "ui/compare/lane-compare", "scope": "teambit.lanes", - "version": "0.0.179", + "version": "0.0.193", "mainFile": "index.ts", "rootDir": "components/ui/compare/lane-compare" }, "ui/compare/lane-compare-drawer": { "name": "ui/compare/lane-compare-drawer", "scope": "teambit.lanes", - "version": "0.0.156", + "version": "0.0.158", "mainFile": "index.ts", "rootDir": "components/ui/compare/lane-compare-drawer" }, @@ -1580,7 +1573,7 @@ "ui/compare/lane-compare-page": { "name": "ui/compare/lane-compare-page", "scope": "teambit.lanes", - "version": "0.0.159", + "version": "0.0.162", "mainFile": "index.ts", "rootDir": "components/ui/compare/lane-compare-page" }, @@ -1594,7 +1587,7 @@ "ui/component-compare/changelog": { "name": "ui/component-compare/changelog", "scope": "teambit.component", - "version": "0.0.179", + "version": "0.0.180", "mainFile": "index.ts", "rootDir": "components/ui/component-compare/changelog" }, @@ -1657,7 +1650,7 @@ "ui/component-filters/env-filter": { "name": "ui/component-filters/env-filter", "scope": "teambit.component", - "version": "0.0.227", + "version": "0.0.228", "mainFile": "index.ts", "rootDir": "components/ui/component-filters/env-filter" }, @@ -1769,7 +1762,7 @@ "ui/inputs/lane-selector": { "name": "ui/inputs/lane-selector", "scope": "teambit.lanes", - "version": "0.0.221", + "version": "0.0.222", "mainFile": "index.ts", "rootDir": "components/ui/inputs/lane-selector_1" }, @@ -1790,14 +1783,14 @@ "ui/login": { "name": "ui/login", "scope": "teambit.cloud", - "version": "0.0.3", + "version": "0.0.4", "mainFile": "index.ts", "rootDir": "scopes/cloud/ui/login" }, "ui/menus/use-lanes-menu": { "name": "ui/menus/use-lanes-menu", "scope": "teambit.lanes", - "version": "0.0.215", + "version": "0.0.216", "mainFile": "index.ts", "rootDir": "components/ui/menus/use-lanes-menu" }, @@ -1811,7 +1804,7 @@ "ui/navigation/lane-switcher": { "name": "ui/navigation/lane-switcher", "scope": "teambit.lanes", - "version": "0.0.222", + "version": "0.0.223", "mainFile": "index.ts", "rootDir": "components/ui/navigation/lane-switcher" }, @@ -1853,14 +1846,14 @@ "ui/user-bar": { "name": "ui/user-bar", "scope": "teambit.cloud", - "version": "0.0.6", + "version": "0.0.7", "mainFile": "index.ts", "rootDir": "scopes/cloud/ui/user-bar" }, "ui/version-block": { "name": "ui/version-block", "scope": "teambit.component", - "version": "0.0.886", + "version": "0.0.887", "mainFile": "index.ts", "rootDir": "components/ui/version-block" }, @@ -1881,7 +1874,7 @@ "update-dependencies": { "name": "update-dependencies", "scope": "teambit.scope", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/scope/update-dependencies" }, @@ -1902,7 +1895,7 @@ "user-agent": { "name": "user-agent", "scope": "teambit.ui-foundation", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/ui-foundation/user-agent" }, @@ -1951,49 +1944,49 @@ "variants": { "name": "variants", "scope": "teambit.workspace", - "version": "0.0.1037", + "version": "0.0.1065", "mainFile": "index.ts", "rootDir": "scopes/workspace/variants" }, "watcher": { "name": "watcher", "scope": "teambit.workspace", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/workspace/watcher" }, "webpack": { "name": "webpack", "scope": "teambit.webpack", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/webpack/webpack" }, "worker": { "name": "worker", "scope": "teambit.harmony", - "version": "0.0.1161", + "version": "0.0.1163", "mainFile": "index.ts", "rootDir": "scopes/harmony/worker" }, "workspace": { "name": "workspace", "scope": "teambit.workspace", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/workspace/workspace" }, "workspace-config-files": { "name": "workspace-config-files", "scope": "teambit.workspace", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/workspace/workspace-config-files" }, "yarn": { "name": "yarn", "scope": "teambit.dependencies", - "version": "1.0.193", + "version": "1.0.221", "mainFile": "index.ts", "rootDir": "scopes/dependencies/yarn" }, diff --git a/components/component-issues/removed-dependencies.ts b/components/component-issues/removed-dependencies.ts index 29a8f92f91c4..a37f1b9d7086 100644 --- a/components/component-issues/removed-dependencies.ts +++ b/components/component-issues/removed-dependencies.ts @@ -1,8 +1,9 @@ import { ComponentIssue, ISSUE_FORMAT_SPACE } from './component-issue'; export class RemovedDependencies extends ComponentIssue { - description = 'removed dependencies'; - solution = 'run "bit install " or remove any unneeded references to that component from your code'; + description = 'dependencies used in the code were deleted'; + solution = + 'if the dependencies are no longer needed, remove them from the code. otherwise, to get it installed from main run "bit install ". to undo the delete, run "bit recover"'; data: string[]; // deps ids isTagBlocker = true; dataToString() { diff --git a/components/renderers/react/react.renderer.tsx b/components/renderers/react/react.renderer.tsx index d02329d8c888..286e62ec9def 100644 --- a/components/renderers/react/react.renderer.tsx +++ b/components/renderers/react/react.renderer.tsx @@ -5,7 +5,9 @@ import { APINodeDetails } from '@teambit/api-reference.renderers.api-node-detail import { parameterRenderer as defaultParamRenderer } from '@teambit/api-reference.renderers.parameter'; import classnames from 'classnames'; import { TagName } from '@teambit/semantics.entities.semantic-schema'; -import { Link } from '@teambit/base-react.navigation.link'; +import { Link as BaseLink } from '@teambit/base-react.navigation.link'; +// @todo - this will be fixed as part of the @teambit/base-react.navigation.link upgrade to latest +const Link = BaseLink as any; import styles from './react.renderer.module.scss'; @@ -161,6 +163,7 @@ function ReactOverviewComponent(props: APINodeRenderProps) { const description = api.doc?.comment ?? api?.doc?.tags?.filter((tag) => tag.comment).reduce((acc, tag) => acc.concat(`${tag.comment}\n` ?? ''), ''); + return (
diff --git a/components/renderers/schema-nodes-index/schema-nodes-index.tsx b/components/renderers/schema-nodes-index/schema-nodes-index.tsx index 9fbd2b2bbba8..e7a6fee1f293 100644 --- a/components/renderers/schema-nodes-index/schema-nodes-index.tsx +++ b/components/renderers/schema-nodes-index/schema-nodes-index.tsx @@ -4,10 +4,13 @@ import classnames from 'classnames'; import { classes } from '@teambit/design.ui.surfaces.menu.item'; import flatten from 'lodash.flatten'; import { trackedElementClassName } from '@teambit/api-reference.renderers.schema-node-member-summary'; -import { useLocation, Link } from '@teambit/base-react.navigation.link'; +import { useLocation, Link as BaseLink } from '@teambit/base-react.navigation.link'; import styles from './schema-nodes-index.module.scss'; +// @todo - this will be fixed as part of the @teambit/base-react.navigation.link upgrade to latest +const Link = BaseLink as any; + export type SchemaNodesIndexProps = { title?: string; /** diff --git a/components/ui/compare/lane-compare-drawer/lane-compare-drawer.tsx b/components/ui/compare/lane-compare-drawer/lane-compare-drawer.tsx index 9ca67f66adfe..8ede3b07710c 100644 --- a/components/ui/compare/lane-compare-drawer/lane-compare-drawer.tsx +++ b/components/ui/compare/lane-compare-drawer/lane-compare-drawer.tsx @@ -1,3 +1,4 @@ +/* eslint-disable react/jsx-curly-brace-presence */ import React, { HTMLAttributes } from 'react'; import { ComponentCompareProps } from '@teambit/component.ui.component-compare.models.component-compare-props'; import { DrawerProps, DrawerUI } from '@teambit/ui-foundation.ui.tree.drawer'; @@ -26,12 +27,15 @@ export function LaneCompareDrawer({ drawerProps, compareProps, isFullScreen }: L return (
-
); diff --git a/components/ui/compare/lane-compare/lane-compare.tsx b/components/ui/compare/lane-compare/lane-compare.tsx index 383766748a44..d16928e92c27 100644 --- a/components/ui/compare/lane-compare/lane-compare.tsx +++ b/components/ui/compare/lane-compare/lane-compare.tsx @@ -108,6 +108,27 @@ function GroupedComponentCompareDrawer({ customUseComponent, ComponentCompareLoader, drawerKey, +}: { + baseId?: ComponentID; + compareId?: ComponentID; + open: boolean; + changes?: ChangeType[] | null; + fullScreenDrawerKey?: string; + tabs?: MaybeLazyLoaded; + host: string; + hooks: (base?: ComponentID, compare?: ComponentID) => ComponentCompareHooks; + DrawerWidgets?: { + Left?: React.ComponentType; + Right?: React.ComponentType; + }; + base: LaneModel; + compare: LaneModel; + handleDrawerToggle: (id?: string) => void; + onFullScreenClicked: (key?: string) => (e: React.MouseEvent) => void; + Drawer: React.ComponentType; + customUseComponent?: UseComponentType; + ComponentCompareLoader?: React.ComponentType; + drawerKey: string; }) { const { laneCompareState } = useLaneCompareContext() as LaneCompareContextModel; const compKey = computeStateKey(baseId, compareId); @@ -192,7 +213,7 @@ function GroupedComponentCompareDrawer({ role="button" tabIndex={0} > - +
, ], className: classnames( @@ -236,6 +257,21 @@ function GroupedComponentCompare({ hooks, loading, onFullScreenChanged, +}: { + base: LaneModel; + compare: LaneModel; + Drawer: React.ComponentType; + ComponentCompareLoader?: React.ComponentType; + DrawerWidgets?: { + Left?: React.ComponentType; + Right?: React.ComponentType; + }; + host: string; + customUseComponent?: UseComponentType; + tabs?: MaybeLazyLoaded; + hooks: (base?: ComponentID, compare?: ComponentID) => ComponentCompareHooks; + loading: boolean | undefined; + onFullScreenChanged?: (key?: string, location?: Location) => void; }) { const { openDrawerList = [], @@ -325,7 +361,7 @@ function GroupedComponentCompare({ onFullScreenClicked={onFullScreenClicked} handleDrawerToggle={handleDrawerToggle} fullScreenDrawerKey={fullScreenDrawerKey} - drawerKey={compareIdStrWithoutVersion} + drawerKey={compareIdStrWithoutVersion ?? ''} open={!!compareIdStrWithoutVersion && openDrawerList.includes(compareIdStrWithoutVersion)} changes={ !compareIdStrWithoutVersion || loading === undefined @@ -384,9 +420,9 @@ function LaneCompareImpl({ const key = computeStateKey(_base, _compare); const extractedTabs = extractLazyLoadedData(tabs); - const onClicked = (prop: ComponentCompareStateKey) => (id, e) => { - e.preventDefault(); - e.stopPropagation(); + const onClicked = (prop: ComponentCompareStateKey) => (id?: string, e?: React.MouseEvent) => { + e?.preventDefault(); + e?.stopPropagation(); setLaneCompareState((value) => { let existingState = value.get(key); const propState = existingState?.[prop]; diff --git a/components/ui/component-filters/env-filter/envs-filter.tsx b/components/ui/component-filters/env-filter/envs-filter.tsx index c5456c455ed6..adc70a493f54 100644 --- a/components/ui/component-filters/env-filter/envs-filter.tsx +++ b/components/ui/component-filters/env-filter/envs-filter.tsx @@ -5,7 +5,7 @@ import { ComponentUrl } from '@teambit/component.modules.component-url'; import classNames from 'classnames'; import { Ellipsis } from '@teambit/design.ui.styles.ellipsis'; import { Tooltip } from '@teambit/design.ui.tooltip'; -import { Link } from '@teambit/base-react.navigation.link'; +import { Link as BaseLink } from '@teambit/base-react.navigation.link'; import { ComponentFilterCriteria, ComponentFilterRenderProps, @@ -16,6 +16,9 @@ import { import styles from './envs-filter.module.scss'; +// @todo - this will be fixed as part of the @teambit/base-react.navigation.link upgrade to latest +const Link = BaseLink as any; + type EnvFilterEnvState = { active: boolean; icon?: string; diff --git a/components/ui/component-size/component-size.module.scss b/components/ui/component-size/component-size.module.scss new file mode 100644 index 000000000000..2be4eb53bb22 --- /dev/null +++ b/components/ui/component-size/component-size.module.scss @@ -0,0 +1,12 @@ +.componentSizeTooltip { + padding: 0; + max-width: fit-content !important; +} + +.componentSizeTooltipContent { + font-size: var(--bit-p-xs, '14px'); +} + +.label { + padding: 4px 8px; +} diff --git a/components/ui/component-size/component-size.tsx b/components/ui/component-size/component-size.tsx new file mode 100644 index 000000000000..4bbbecd8e77f --- /dev/null +++ b/components/ui/component-size/component-size.tsx @@ -0,0 +1,37 @@ +import React from 'react'; +import fileSize from 'pretty-bytes'; +import { ComponentModel } from '@teambit/component'; +import { PillLabel } from '@teambit/design.ui.pill-label'; +import { Tooltip } from '@teambit/design.ui.tooltip'; +import styles from './component-size.module.scss'; + +export type ComponentSizeProps = { legacyComponentModel?: ComponentModel } & React.HTMLAttributes; + +export function ComponentSize({ legacyComponentModel, ...rest }: ComponentSizeProps) { + // const builderData = componentDescriptor.get('teambit.pipelines/builder'); + // const builder = builderData && BuilderData.fromJson(builderData); + // const size: ComponentPreviewSize = builder?.getDataByAspect('teambit.preview/preview')?.size; + const compressedSize = legacyComponentModel?.size?.compressedTotal; + + if (!compressedSize) return null; + + return ( + + Component bundle with dependencies, minified and gzipped +
+ } + > +
+ + + {fileSize(compressedSize)} + +
+ + ); +} diff --git a/components/ui/component-size/index.ts b/components/ui/component-size/index.ts new file mode 100644 index 000000000000..2707c88aea6e --- /dev/null +++ b/components/ui/component-size/index.ts @@ -0,0 +1 @@ +export { ComponentSize, ComponentSizeProps } from './component-size'; diff --git a/components/ui/inputs/lane-selector_1/lane-menu-item.tsx b/components/ui/inputs/lane-selector_1/lane-menu-item.tsx index 993a794df400..87c82e96b715 100644 --- a/components/ui/inputs/lane-selector_1/lane-menu-item.tsx +++ b/components/ui/inputs/lane-selector_1/lane-menu-item.tsx @@ -18,6 +18,8 @@ export type LaneMenuItemProps = { timestamp?: Date; } & HTMLAttributes; +// TODO: @luv please fix the eslint error +// eslint-disable-next-line react/display-name export const LaneMenuItem = forwardRef( ( { diff --git a/components/ui/menus/use-lanes-menu/use-lanes-menu.tsx b/components/ui/menus/use-lanes-menu/use-lanes-menu.tsx index a0c094242a73..031dabb9582e 100644 --- a/components/ui/menus/use-lanes-menu/use-lanes-menu.tsx +++ b/components/ui/menus/use-lanes-menu/use-lanes-menu.tsx @@ -5,10 +5,13 @@ import { Ellipsis } from '@teambit/design.ui.styles.ellipsis'; import { linkStyles } from '@teambit/ui-foundation.ui.use-box.bottom-link'; import { LanesHost } from '@teambit/lanes.ui.models.lanes-model'; import { UseBoxDropdown } from '@teambit/ui-foundation.ui.use-box.dropdown'; -import { Link } from '@teambit/base-react.navigation.link'; +import { Link as BaseLink } from '@teambit/base-react.navigation.link'; import { LaneId } from '@teambit/lane-id'; import styles from './use-lanes-menu.module.scss'; +// @todo - this will be fixed as part of the @teambit/base-react.navigation.link upgrade to latest +const Link = BaseLink as any; + export type LaneImportContentProps = { currentLaneId: LaneId; switchedOutToCurrentLane: boolean; diff --git a/components/ui/version-block/version-block.tsx b/components/ui/version-block/version-block.tsx index 6e4a45f0274d..38a182780962 100644 --- a/components/ui/version-block/version-block.tsx +++ b/components/ui/version-block/version-block.tsx @@ -1,6 +1,6 @@ import { H3 } from '@teambit/documenter.ui.heading'; import { Contributors } from '@teambit/design.ui.contributors'; -import { Link, useLocation } from '@teambit/base-react.navigation.link'; +import { Link as BaseLink, useLocation } from '@teambit/base-react.navigation.link'; import { Labels } from '@teambit/component.ui.version-label'; import classNames from 'classnames'; import React, { HTMLAttributes, useMemo } from 'react'; @@ -11,6 +11,9 @@ import { LanesModel } from '@teambit/lanes.ui.models.lanes-model'; import styles from './version-block.module.scss'; +// @todo - this will be fixed as part of the @teambit/base-react.navigation.link upgrade to latest +const Link = BaseLink as any; + export type VersionBlockProps = { componentId: string; isLatest: boolean; diff --git a/scopes/api-reference/overview/api-reference-table-of-contents/api-reference.table-of-contents.tsx b/scopes/api-reference/overview/api-reference-table-of-contents/api-reference.table-of-contents.tsx index c6180b183dbe..cfae5124adb1 100644 --- a/scopes/api-reference/overview/api-reference-table-of-contents/api-reference.table-of-contents.tsx +++ b/scopes/api-reference/overview/api-reference-table-of-contents/api-reference.table-of-contents.tsx @@ -3,10 +3,13 @@ import classNames from 'classnames'; import { SchemaNode } from '@teambit/semantics.entities.semantic-schema'; import { APINode, APIReferenceModel } from '@teambit/api-reference.models.api-reference-model'; import { sortAPINodes } from '@teambit/api-reference.utils.sort-api-nodes'; -import { Link } from '@teambit/base-react.navigation.link'; +import { Link as BaseLink } from '@teambit/base-react.navigation.link'; import styles from './api-reference.table-of-contents.module.scss'; +// @todo - this will be fixed as part of the @teambit/base-react.navigation.link upgrade to latest +const Link = BaseLink as any; + export type APIReferenceTableOfContentsProps = { apiModel: APIReferenceModel; } & HTMLAttributes; diff --git a/scopes/api-reference/renderers/grouped-schema-nodes-overview-summary/grouped-schema-nodes-overview-summary.tsx b/scopes/api-reference/renderers/grouped-schema-nodes-overview-summary/grouped-schema-nodes-overview-summary.tsx index 06e61036a33f..192e9c694e9c 100644 --- a/scopes/api-reference/renderers/grouped-schema-nodes-overview-summary/grouped-schema-nodes-overview-summary.tsx +++ b/scopes/api-reference/renderers/grouped-schema-nodes-overview-summary/grouped-schema-nodes-overview-summary.tsx @@ -11,12 +11,15 @@ import { VariableNodeSummary, EnumMemberSummary } from '@teambit/api-reference.r import { parameterRenderer as defaultParamRenderer } from '@teambit/api-reference.renderers.parameter'; import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter'; import defaultTheme from '@teambit/api-reference.utils.custom-prism-syntax-highlighter-theme'; -import { Link } from '@teambit/base-react.navigation.link'; +import { Link as BaseLink } from '@teambit/base-react.navigation.link'; import pluralize from 'pluralize'; import classnames from 'classnames'; import styles from './grouped-schema-nodes-overview-summary.module.scss'; +// @todo - this will be fixed as part of the @teambit/base-react.navigation.link upgrade to latest +const Link = BaseLink as any; + export type SchemaNodesSummaryProps = { name: string; // signature?: string; diff --git a/scopes/api-reference/renderers/type-ref/type-ref.renderer.tsx b/scopes/api-reference/renderers/type-ref/type-ref.renderer.tsx index 07c614f6c65f..66187d10e64a 100644 --- a/scopes/api-reference/renderers/type-ref/type-ref.renderer.tsx +++ b/scopes/api-reference/renderers/type-ref/type-ref.renderer.tsx @@ -7,10 +7,13 @@ import classnames from 'classnames'; import { useUpdatedUrlFromQuery } from '@teambit/api-reference.hooks.use-api-ref-url'; import { ComponentID } from '@teambit/component-id'; import { ComponentUrl } from '@teambit/component.modules.component-url'; -import { Link } from '@teambit/base-react.navigation.link'; +import { Link as BaseLink } from '@teambit/base-react.navigation.link'; import styles from './type-ref.renderer.module.scss'; +// @todo - this will be fixed as part of the @teambit/base-react.navigation.link upgrade to latest +const Link = BaseLink as any; + export const typeRefRenderer: APINodeRenderer = { predicate: (node) => node.__schema === TypeRefSchema.name, Component: TypeRefComponent, diff --git a/scopes/api-reference/sections/api-reference-page/api-reference-page.tsx b/scopes/api-reference/sections/api-reference-page/api-reference-page.tsx index 363e224b43b9..ce0be653f4a5 100644 --- a/scopes/api-reference/sections/api-reference-page/api-reference-page.tsx +++ b/scopes/api-reference/sections/api-reference-page/api-reference-page.tsx @@ -4,7 +4,7 @@ import classNames from 'classnames'; import { ComponentContext } from '@teambit/component'; import { H1 } from '@teambit/documenter.ui.heading'; import { useIsMobile } from '@teambit/ui-foundation.ui.hooks.use-is-mobile'; -import { Link } from '@teambit/base-react.navigation.link'; +import { Link as BaseLink } from '@teambit/base-react.navigation.link'; import { useQuery } from '@teambit/ui-foundation.ui.react-router.use-query'; import { Collapser } from '@teambit/ui-foundation.ui.buttons.collapser'; import { HoverSplitter } from '@teambit/base-ui.surfaces.split-pane.hover-splitter'; @@ -21,6 +21,9 @@ import { ComponentUrl } from '@teambit/component.modules.component-url'; import styles from './api-reference-page.module.scss'; +// @todo - this will be fixed as part of the @teambit/base-react.navigation.link upgrade to latest +const Link = BaseLink as any; + export type APIRefPageProps = { host: string; rendererSlot: APINodeRendererSlot; diff --git a/scopes/cloud/cloud/cloud.main.runtime.ts b/scopes/cloud/cloud/cloud.main.runtime.ts index d036fee90951..7cd7fb2bc870 100644 --- a/scopes/cloud/cloud/cloud.main.runtime.ts +++ b/scopes/cloud/cloud/cloud.main.runtime.ts @@ -119,10 +119,18 @@ export class CloudMain { configUpdates?: string; }> { const authToken = this.getAuthToken(); - const username = this.getUsername(); - if (!authToken || !username) { + if (!authToken) { throw new Error('user is not logged in'); } + const currentUser = await this.getCurrentUser(); + let username = currentUser?.username; + if (!username) { + this.logger.warn('failed to fetch username from cloud for the current user. falling back to the global config.'); + username = this.getUsername(); + } + if (!username) { + throw new Error('username is not found in the global config or the cloud. please login first.'); + } return this.updateNpmConfig({ authToken, username, dryRun, force }); } @@ -200,9 +208,11 @@ export class CloudMain { setupAuthListener({ port: portFromParams, clientId = v4(), + skipConfigUpdate, }: { port?: number; clientId?: string; + skipConfigUpdate?: boolean; } = {}): Promise { return new Promise((resolve, reject) => { const port = portFromParams || this.getLoginPort(); @@ -282,21 +292,27 @@ export class CloudMain { const onLoggedInFns = this.onSuccessLoginSlot.values(); - this.updateNpmConfig({ authToken: token as string, username: username as string }) - .then((configUpdates) => { - onLoggedInFns.forEach((fn) => fn({ username, token: token as string, npmrcUpdateResult: configUpdates })); - }) - .catch((error) => { - onLoggedInFns.forEach((fn) => - fn({ - username, - token: token as string, - npmrcUpdateResult: { - error: new Error(`failed to update npmrc. error ${error?.toString}`), - }, - }) - ); - }); + if (!skipConfigUpdate) { + this.updateNpmConfig({ authToken: token as string, username: username as string }) + .then((configUpdates) => { + onLoggedInFns.forEach((fn) => + fn({ username, token: token as string, npmrcUpdateResult: configUpdates }) + ); + }) + .catch((error) => { + onLoggedInFns.forEach((fn) => + fn({ + username, + token: token as string, + npmrcUpdateResult: { + error: new Error(`failed to update npmrc. error ${error?.toString}`), + }, + }) + ); + }); + } else { + onLoggedInFns.forEach((fn) => fn({ username, token: token as string })); + } if (this.REDIRECT_URL) return res.redirect(this.REDIRECT_URL); if (typeof redirectUri === 'string' && redirectUri) return res.redirect(redirectUri); @@ -424,7 +440,8 @@ export class CloudMain { suppressBrowserLaunch?: boolean, machineName?: string, cloudDomain?: string, - redirectUrl?: string + redirectUrl?: string, + skipConfigUpdate?: boolean ): Promise<{ isAlreadyLoggedIn?: boolean; username?: string; @@ -473,6 +490,7 @@ export class CloudMain { try { this.setupAuthListener({ port: Number(port), + skipConfigUpdate, }) .then(promptLogin) .catch((e) => reject(e)); diff --git a/scopes/cloud/cloud/login.cmd.ts b/scopes/cloud/cloud/login.cmd.ts index cebc5a72fe53..6ce09d807616 100644 --- a/scopes/cloud/cloud/login.cmd.ts +++ b/scopes/cloud/cloud/login.cmd.ts @@ -9,6 +9,7 @@ export class LoginCmd implements Command { group = 'general'; alias = ''; options = [ + ['', 'skip-config-update', 'skip writing to the .npmrc file'], ['d', 'cloud-domain ', 'login cloud domain (default bit.cloud)'], ['p', 'port ', 'port number to open for localhost server (default 8085)'], ['', 'no-browser', 'do not open a browser for authentication'], @@ -37,20 +38,29 @@ export class LoginCmd implements Command { suppressBrowserLaunch, noBrowser, machineName, + skipConfigUpdate, }: { cloudDomain?: string; port: string; suppressBrowserLaunch?: boolean; noBrowser?: boolean; machineName?: string; + skipConfigUpdate?: boolean; } ): Promise { noBrowser = noBrowser || suppressBrowserLaunch; - const result = await this.cloud.login(port || this.port, noBrowser, machineName, cloudDomain, undefined); + const result = await this.cloud.login( + port || this.port, + noBrowser, + machineName, + cloudDomain, + undefined, + skipConfigUpdate + ); let message = chalk.green(`Logged in as ${result?.username}`); - if (result?.isAlreadyLoggedIn) { + if (result?.isAlreadyLoggedIn || skipConfigUpdate) { return message; } @@ -72,18 +82,20 @@ export class LoginCmd implements Command { suppressBrowserLaunch, noBrowser, machineName, + skipConfigUpdate, }: { cloudDomain?: string; port: string; suppressBrowserLaunch?: boolean; noBrowser?: boolean; machineName?: string; + skipConfigUpdate?: boolean; } ): Promise<{ username?: string; token?: string; successfullyUpdatedNpmrc?: boolean }> { if (suppressBrowserLaunch) { noBrowser = true; } - const result = await this.cloud.login(port, noBrowser, machineName, cloudDomain); + const result = await this.cloud.login(port, noBrowser, machineName, cloudDomain, undefined, skipConfigUpdate); return { username: result?.username, token: result?.token, diff --git a/scopes/cloud/ui/login/login.tsx b/scopes/cloud/ui/login/login.tsx index acb4a976d121..8b5832848937 100644 --- a/scopes/cloud/ui/login/login.tsx +++ b/scopes/cloud/ui/login/login.tsx @@ -1,7 +1,10 @@ import React from 'react'; -import { Link } from '@teambit/design.ui.navigation.link'; +import { Link as BaseLink } from '@teambit/design.ui.navigation.link'; import styles from './login.module.scss'; +// @todo - this will be fixed as part of the @teambit/base-react.navigation.link for @teambit/design.ui.navigation.link +const Link = BaseLink as any; + export type LoginProps = { loginText?: string; loginUrl?: string; diff --git a/scopes/compilation/compiler/compiler.cmd.ts b/scopes/compilation/compiler/compiler.cmd.ts index 4a18fd14908e..ab3e1876d330 100644 --- a/scopes/compilation/compiler/compiler.cmd.ts +++ b/scopes/compilation/compiler/compiler.cmd.ts @@ -1,25 +1,13 @@ import { Command, CommandOptions } from '@teambit/cli'; import { Logger } from '@teambit/logger'; -import type { PubsubMain, BitBaseEvent } from '@teambit/pubsub'; +import type { PubsubMain } from '@teambit/pubsub'; import chalk from 'chalk'; import prettyTime from 'pretty-time'; -import { Component } from '@teambit/component'; import { formatCompileResults } from './output-formatter'; -import { CompileError, WorkspaceCompiler, CompileOptions } from './workspace-compiler'; +import { WorkspaceCompiler, CompileOptions, BuildResult } from './workspace-compiler'; import { CompilationInitiator } from './types'; -// IDs & events -import { CompilerAspect } from './compiler.aspect'; -import { ComponentCompilationOnDoneEvent } from './events'; - -export type ComponentsStatus = { - buildResults: string[]; - component: Component; - errors: CompileError[]; -}; - export class CompileCmd implements Command { - componentsStatus: ComponentsStatus[] = []; name = 'compile [component-names...]'; description = 'compile components in the workspace'; helpUrl = 'reference/compiling/compiler-overview'; @@ -43,10 +31,9 @@ export class CompileCmd implements Command { async report([components = []]: [string[]], compilerOptions: CompileOptions) { const startTimestamp = process.hrtime(); this.logger.setStatusLine('Compiling your components, hold tight.'); - this.pubsub.sub(CompilerAspect.id, this.onComponentCompilationDone.bind(this)); let outputString = ''; - await this.compile.compileComponents(components, { + const results = await this.compile.compileComponents(components, { ...compilerOptions, initiator: CompilationInitiator.CmdReport, }); @@ -54,16 +41,16 @@ export class CompileCmd implements Command { outputString += '\n'; outputString += ` ${chalk.underline('STATUS')}\t${chalk.underline('COMPONENT ID')}\n`; - outputString += formatCompileResults(this.componentsStatus, !!compilerOptions.verbose); + outputString += formatCompileResults(results, !!compilerOptions.verbose); outputString += '\n'; - outputString += this.getStatusLine(this.componentsStatus, compileTimeLength); + outputString += this.getStatusLine(results, compileTimeLength); this.logger.clearStatusLine(); return { data: outputString, - code: this.getExitCode(this.componentsStatus), + code: this.getExitCode(results), }; } @@ -81,11 +68,11 @@ export class CompileCmd implements Command { }; } - private failedComponents(componentsStatus: ComponentsStatus[]): ComponentsStatus[] { + private failedComponents(componentsStatus: BuildResult[]): BuildResult[] { return componentsStatus.filter((component) => component.errors.length); } - private getSummaryIcon(componentsStatus: ComponentsStatus[]) { + private getSummaryIcon(componentsStatus: BuildResult[]) { switch (this.failedComponents(componentsStatus).length) { case 0: return Logger.successSymbol(); @@ -96,11 +83,11 @@ export class CompileCmd implements Command { } } - private getExitCode(componentsStatus: ComponentsStatus[]) { + private getExitCode(componentsStatus: BuildResult[]) { return this.failedComponents(componentsStatus).length ? 1 : 0; } - private getStatusLine(componentsStatus: ComponentsStatus[], compileTimeLength) { + private getStatusLine(componentsStatus: BuildResult[], compileTimeLength) { const numberOfComponents = componentsStatus.length; const numberOfFailingComponents = this.failedComponents(componentsStatus).length; const numberOfSuccessfulComponents = componentsStatus.filter((component) => !component.errors.length).length; @@ -112,10 +99,4 @@ export class CompileCmd implements Command { return `${summaryLine}\nFinished. (${prettyTime(compileTimeLength)})`; } - - private onComponentCompilationDone(event: BitBaseEvent) { - if (event.type === ComponentCompilationOnDoneEvent.TYPE) { - this.componentsStatus.push(event.data); - } - } } diff --git a/scopes/compilation/compiler/events/component-compilation-on-done.ts b/scopes/compilation/compiler/events/component-compilation-on-done.ts deleted file mode 100644 index a98536ee14b6..000000000000 --- a/scopes/compilation/compiler/events/component-compilation-on-done.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* eslint-disable max-classes-per-file */ -import { BitBaseEvent } from '@teambit/pubsub'; -import { Component } from '@teambit/component'; -import { CompileError } from '../workspace-compiler'; - -class ComponentCompilationOnDoneEventData { - constructor(readonly errors: Array, readonly component: Component, readonly buildResults: string[]) {} -} - -export class ComponentCompilationOnDoneEvent extends BitBaseEvent { - static readonly TYPE = 'component-compilation-on-done'; - - constructor( - readonly errors: Array, - readonly component: Component, - readonly buildResults: string[], - readonly timestamp = Date.now() - ) { - super( - ComponentCompilationOnDoneEvent.TYPE, - '0.0.1', - timestamp, - new ComponentCompilationOnDoneEventData(errors, component, buildResults) - ); - } -} diff --git a/scopes/compilation/compiler/events/index.ts b/scopes/compilation/compiler/events/index.ts index a0f6dfb3b7f6..bb657b9617b3 100644 --- a/scopes/compilation/compiler/events/index.ts +++ b/scopes/compilation/compiler/events/index.ts @@ -1,2 +1 @@ export * from './compiler-error'; -export * from './component-compilation-on-done'; diff --git a/scopes/compilation/compiler/output-formatter.ts b/scopes/compilation/compiler/output-formatter.ts index 6cae22b00201..40b7733fa074 100644 --- a/scopes/compilation/compiler/output-formatter.ts +++ b/scopes/compilation/compiler/output-formatter.ts @@ -1,11 +1,11 @@ import chalk from 'chalk'; import { Logger } from '@teambit/logger'; -import { ComponentsStatus } from './compiler.cmd'; +import { BuildResult } from './workspace-compiler'; -export const formatCompileResults = (compileResults: ComponentsStatus[], verbose: boolean) => +export const formatCompileResults = (compileResults: BuildResult[], verbose: boolean) => compileResults - .map((componentResult: ComponentsStatus) => ({ - componentId: componentResult.component.id.fullName, + .map((componentResult: BuildResult) => ({ + componentId: componentResult.component, files: componentResult.buildResults, status: componentResult.errors.length ? 'FAILURE' : 'SUCCESS', icon: componentResult.errors.length ? chalk.red('✗') : Logger.successSymbol(), diff --git a/scopes/compilation/compiler/workspace-compiler.ts b/scopes/compilation/compiler/workspace-compiler.ts index 972f67a8d46a..2709337f4470 100644 --- a/scopes/compilation/compiler/workspace-compiler.ts +++ b/scopes/compilation/compiler/workspace-compiler.ts @@ -6,6 +6,7 @@ import type { PubsubMain } from '@teambit/pubsub'; import { SerializableResults, Workspace, OutsideWorkspaceError } from '@teambit/workspace'; import { WatcherMain, WatchOptions } from '@teambit/watcher'; import path from 'path'; +import chalk from 'chalk'; import { ComponentID } from '@teambit/component-id'; import { Logger } from '@teambit/logger'; import loader from '@teambit/legacy/dist/cli/loader'; @@ -27,10 +28,14 @@ import type { PreStartOpts } from '@teambit/ui'; import { PathOsBasedAbsolute, PathOsBasedRelative } from '@teambit/legacy/dist/utils/path'; import { MultiCompiler } from '@teambit/multi-compiler'; import { CompilerAspect } from './compiler.aspect'; -import { CompilerErrorEvent, ComponentCompilationOnDoneEvent } from './events'; +import { CompilerErrorEvent } from './events'; import { Compiler, CompilationInitiator } from './types'; -export type BuildResult = { component: string; buildResults: string[] | null | undefined }; +export type BuildResult = { + component: string; + buildResults: string[]; + errors: CompileError[]; +}; export type CompileOptions = { changed?: boolean; // compile only new and modified components @@ -65,10 +70,11 @@ export class ComponentCompiler { async compile(noThrow = true, options: CompileOptions): Promise { let dataToPersist; const deleteDistDir = options.deleteDistDir ?? this.compilerInstance.deleteDistDir; + const distDirs = await this.distDirs(); // delete dist folder before transpilation (because some compilers (like ngPackagr) can generate files there during the compilation process) if (deleteDistDir) { dataToPersist = new DataToPersist(); - for (const distDir of await this.distDirs()) { + for (const distDir of distDirs) { dataToPersist.removePath(new RemovePath(distDir)); } dataToPersist.addBasePath(this.workspace.path); @@ -83,12 +89,14 @@ export class ComponentCompiler { if (canTranspileFile) { await Promise.all( - this.component.filesystem.files.map((file: AbstractVinyl) => this.compileOneFile(file, options.initiator)) + this.component.filesystem.files.map((file: AbstractVinyl) => + this.compileOneFile(file, options.initiator, distDirs) + ) ); } if (canTranspileComponent) { - await this.compileAllFiles(this.component, options.initiator); + await this.compileAllFiles(this.component, options.initiator, distDirs); } if (!canTranspileFile && !canTranspileComponent) { @@ -110,11 +118,8 @@ export class ComponentCompiler { } const buildResults = this.dists.map((distFile) => distFile.path); if (this.component.state._consumer.compiler) loader.succeed(); - this.pubsub.pub( - CompilerAspect.id, - new ComponentCompilationOnDoneEvent(this.compileErrors, this.component, buildResults) - ); - return { component: this.component.id.toString(), buildResults }; + + return { component: this.component.id.toString(), buildResults, errors: this.compileErrors }; } private throwOnCompileErrors(noThrow = true) { @@ -156,7 +161,11 @@ ${this.compileErrors.map(formatError).join('\n')}`); return this.workspace.componentDir(this.component.id); } - private async compileOneFile(file: AbstractVinyl, initiator: CompilationInitiator): Promise { + private async compileOneFile( + file: AbstractVinyl, + initiator: CompilationInitiator, + distDirs: PathOsBasedRelative[] + ): Promise { const options = { componentDir: this.componentDir, filePath: file.relative, initiator }; const isFileSupported = this.compilerInstance.isFileSupported(file.path); let compileResults; @@ -168,7 +177,7 @@ ${this.compileErrors.map(formatError).join('\n')}`); return; } } - for (const base of await this.distDirs()) { + for (const base of distDirs) { if (isFileSupported && compileResults) { this.dists.push( ...compileResults.map( @@ -187,9 +196,13 @@ ${this.compileErrors.map(formatError).join('\n')}`); } } - private async compileAllFiles(component: Component, initiator: CompilationInitiator): Promise { + private async compileAllFiles( + component: Component, + initiator: CompilationInitiator, + distDirs: PathOsBasedRelative[] + ): Promise { const filesToCompile: AbstractVinyl[] = []; - for (const base of await this.distDirs()) { + for (const base of distDirs) { component.filesystem.files.forEach((file: AbstractVinyl) => { const isFileSupported = this.compilerInstance.isFileSupported(file.path); if (isFileSupported) { @@ -290,11 +303,10 @@ export class WorkspaceCompiler { { initiator: watchOpts.initiator || CompilationInitiator.ComponentChanged, deleteDistDir }, true ); - // await linkToNodeModulesByComponents([component], this.workspace); return { results: buildResults, toString() { - return `${buildResults[0]?.buildResults?.join('\n\t')}`; + return formatCompileResults(buildResults, watchOpts.verbose); }, }; } @@ -323,7 +335,6 @@ export class WorkspaceCompiler { const getManyOpts = options.initiator === CompilationInitiator.AspectLoadFail ? { loadSeedersAsAspects: false } : undefined; const components = await this.workspace.getMany(componentIds, getManyOpts); - const grouped = this.groupByIsEnv(components); const envsResults = grouped.envs ? await this.runCompileComponents(grouped.envs, options, noThrow) : []; const otherResults = grouped.other ? await this.runCompileComponents(grouped.other, options, noThrow) : []; @@ -393,3 +404,17 @@ export class WorkspaceCompiler { return this.workspace.listIds(); } } + +function formatCompileResults(buildResults: BuildResult[], verbose?: boolean) { + if (!buildResults.length) return ''; + // this gets called when a file is changed, so the buildResults array always has only one item + const buildResult = buildResults[0]; + const title = ` ${chalk.underline('STATUS\tCOMPONENT ID')}`; + const verboseComponentFilesArrayToString = () => { + return buildResult.buildResults.map((filePath) => ` \t - ${filePath}`).join('\n'); + }; + + return `${title} + ${Logger.successSymbol()}SUCCESS\t${buildResult.component}\n + ${verbose ? `${verboseComponentFilesArrayToString()}\n` : ''}`; +} diff --git a/scopes/component/checkout/checkout-cmd.ts b/scopes/component/checkout/checkout-cmd.ts index 576e850b419f..0a5cddbbbd6f 100644 --- a/scopes/component/checkout/checkout-cmd.ts +++ b/scopes/component/checkout/checkout-cmd.ts @@ -183,14 +183,10 @@ export function checkoutOutput( return `${chalk.underline(title)}\n${body}`; }; const getWsConfigUpdateLogs = () => { - // @TODO: uncomment the line below once UPDATE_DEPS_ON_IMPORT is enabled by default - // if (!importFlags.verbose) return ''; const logs = workspaceConfigUpdateResult?.logs; if (!logs || !logs.length) return ''; const logsStr = logs.join('\n'); - return `${chalk.underline( - 'verbose logs of workspace config update' - )}\n(this is temporarily. once this feature is enabled, use --verbose to see these logs)\n${logsStr}`; + return `${chalk.underline('verbose logs of workspace config update')}\n${logsStr}`; }; const getConflictSummary = () => { if (!components || !components.length || !leftUnresolvedConflicts) return ''; diff --git a/scopes/component/checkout/checkout.main.runtime.ts b/scopes/component/checkout/checkout.main.runtime.ts index 304794948d7d..afbc45a4da3a 100644 --- a/scopes/component/checkout/checkout.main.runtime.ts +++ b/scopes/component/checkout/checkout.main.runtime.ts @@ -5,7 +5,6 @@ import { BitError } from '@teambit/bit-error'; import { compact } from 'lodash'; import { BEFORE_CHECKOUT } from '@teambit/legacy/dist/cli/loader/loader-messages'; import { RemoveAspect, RemoveMain } from '@teambit/remove'; -import { UPDATE_DEPS_ON_IMPORT, isFeatureEnabled } from '@teambit/legacy/dist/api/consumer/lib/feature-toggle'; import { ApplyVersionResults, FailedComponents } from '@teambit/merging'; import { ImporterAspect, ImporterMain } from '@teambit/importer'; import { HEAD, LATEST } from '@teambit/legacy/dist/constants'; @@ -166,7 +165,7 @@ export class CheckoutMain { verbose: checkoutProps.verbose, resetConfig: checkoutProps.reset, skipUpdatingBitMap: checkoutProps.skipUpdatingBitmap || checkoutProps.revert, - shouldUpdateWorkspaceConfig: isFeatureEnabled(UPDATE_DEPS_ON_IMPORT), + shouldUpdateWorkspaceConfig: true, reasonForBitmapChange: 'checkout', }; componentWriterResults = await this.componentWriter.writeMany(manyComponentsWriterOpts); diff --git a/scopes/component/component-writer/component-writer.main.runtime.ts b/scopes/component/component-writer/component-writer.main.runtime.ts index b396b058931c..f74273a15d27 100644 --- a/scopes/component/component-writer/component-writer.main.runtime.ts +++ b/scopes/component/component-writer/component-writer.main.runtime.ts @@ -158,23 +158,13 @@ export class ComponentWriterMain { if (ownerName && !compDir.startsWith(ownerName) && !allDirs.includes(`${ownerName}/${compDir}`)) { compWriter.writeToPath = `${ownerName}/${compDir}`; } else { - compWriter.writeToPath = this.incrementPathRecursively(compWriter.writeToPath, allDirs); + compWriter.writeToPath = incrementPathRecursively(compWriter.writeToPath, allDirs); } allDirs.push(compWriter.writeToPath); }); }); } - private incrementPathRecursively(p: string, allPaths: string[]) { - const incrementPath = (str: string, number: number) => `${str}_${number}`; - let num = 1; - let newPath = incrementPath(p, num); - while (allPaths.includes(newPath)) { - newPath = incrementPath(p, (num += 1)); - } - return newPath; - } - /** * e.g. [bar, bar/foo] => [bar_1, bar/foo] * otherwise, the bar/foo component will be saved inside "bar" component. @@ -187,7 +177,7 @@ export class ComponentWriterMain { const parentsOfOthersComps = componentWriterInstances.filter(({ writeToPath }) => allDirs.find((d) => d.startsWith(`${writeToPath}/`)) ); - const existingRootDirs = Object.keys(this.consumer.bitMap.getAllTrackDirs()); + const existingRootDirs = this.workspace.bitMap.getAllRootDirs(); const parentsOfOthersCompsDirs = parentsOfOthersComps.map((c) => c.writeToPath); const allPaths: PathLinuxRelative[] = [...existingRootDirs, ...parentsOfOthersCompsDirs]; @@ -195,7 +185,7 @@ export class ComponentWriterMain { // change the paths of all these parents root-dir to not collide with the children root-dir parentsOfOthersComps.forEach((componentWriter) => { if (existingRootDirs.includes(componentWriter.writeToPath)) return; // component already exists. - const newPath = this.incrementPathRecursively(componentWriter.writeToPath, allPaths); + const newPath = incrementPathRecursively(componentWriter.writeToPath, allPaths); componentWriter.writeToPath = newPath; }); @@ -206,7 +196,7 @@ export class ComponentWriterMain { const existingParent = existingRootDirs.find((d) => d.startsWith(`${componentWriter.writeToPath}/`)); if (!existingParent) return; if (existingRootDirs.includes(componentWriter.writeToPath)) return; // component already exists. - const newPath = this.incrementPathRecursively(componentWriter.writeToPath, allPaths); + const newPath = incrementPathRecursively(componentWriter.writeToPath, allPaths); componentWriter.writeToPath = newPath; }); @@ -216,7 +206,7 @@ export class ComponentWriterMain { const existingChildren = existingRootDirs.find((d) => componentWriter.writeToPath.startsWith(`${d}/`)); if (!existingChildren) return; // we increment the existing one, because it is used to replace the base-path of the current component - const newPath = this.incrementPathRecursively(existingChildren, allPaths); + const newPath = incrementPathRecursively(existingChildren, allPaths); componentWriter.writeToPath = componentWriter.writeToPath.replace(existingChildren, newPath); }); } @@ -314,3 +304,13 @@ to move all component files to a different directory, run bit remove and then bi ComponentWriterAspect.addRuntime(ComponentWriterMain); export default ComponentWriterMain; + +export function incrementPathRecursively(p: string, allPaths: string[]) { + const incrementPath = (str: string, number: number) => `${str}_${number}`; + let num = 1; + let newPath = incrementPath(p, num); + while (allPaths.includes(newPath)) { + newPath = incrementPath(p, (num += 1)); + } + return newPath; +} diff --git a/scopes/component/component-writer/index.ts b/scopes/component/component-writer/index.ts index 035cb648f0ec..2990bf73635b 100644 --- a/scopes/component/component-writer/index.ts +++ b/scopes/component/component-writer/index.ts @@ -5,5 +5,6 @@ export type { ComponentWriterResults, ManyComponentsWriterParams, } from './component-writer.main.runtime'; +export { incrementPathRecursively } from './component-writer.main.runtime'; export default ComponentWriterAspect; export { ComponentWriterAspect }; diff --git a/scopes/component/component/component.ts b/scopes/component/component/component.ts index b60d0d5d9659..52966da6e53a 100644 --- a/scopes/component/component/component.ts +++ b/scopes/component/component/component.ts @@ -311,6 +311,16 @@ export class Component implements IComponent { return this.id.version; } + /** + * in case a component is new, it returns undefined. + * otherwise, it returns the Snap object (hash/parents/log) of the current component (according to the version in the id) + */ + async getCurrentSnap(): Promise { + const snap = this.getSnapHash(); + if (!snap) return undefined; + return this.loadSnap(snap); + } + /** * checkout the component to a different version in its working tree. */ diff --git a/scopes/component/component/show/id.fragment.ts b/scopes/component/component/show/id.fragment.ts index 3c432c899e62..3cba5060c937 100644 --- a/scopes/component/component/show/id.fragment.ts +++ b/scopes/component/component/show/id.fragment.ts @@ -3,9 +3,11 @@ import { Component } from '../component'; export class IDFragment implements ShowFragment { async renderRow(component: Component) { + const isModified = await component.isModified(); + const modifiedStr = isModified ? ' [modified]' : ''; return { title: 'id', - content: component.id.toString(), + content: `${component.id.toString()}${modifiedStr}`, }; } diff --git a/scopes/component/component/ui/top-bar-nav/top-bar-nav.tsx b/scopes/component/component/ui/top-bar-nav/top-bar-nav.tsx index 64b831aacc11..3c9121610ff5 100644 --- a/scopes/component/component/ui/top-bar-nav/top-bar-nav.tsx +++ b/scopes/component/component/ui/top-bar-nav/top-bar-nav.tsx @@ -1,11 +1,14 @@ import React from 'react'; import classnames from 'classnames'; import { useLocation } from 'react-router-dom'; -import { Link } from '@teambit/base-react.navigation.link'; +import { Link as BaseLink } from '@teambit/base-react.navigation.link'; import { NavPluginProps } from '../menu/nav-plugin'; import styles from './top-bar-nav.module.scss'; +// @todo - this will be fixed as part of the @teambit/base-react.navigation.link upgrade to latest +const Link = BaseLink as any; + export function TopBarNav({ href, className, diff --git a/scopes/component/forking/forking.main.runtime.ts b/scopes/component/forking/forking.main.runtime.ts index 11d8ccbdfef6..2afd3a762f37 100644 --- a/scopes/component/forking/forking.main.runtime.ts +++ b/scopes/component/forking/forking.main.runtime.ts @@ -218,7 +218,15 @@ export class ForkingMain { await pMapSeries(components, async (component) => { const config = await this.getConfig(component); const targetCompId = ComponentID.fromObject({ name: component.id.fullName }, newScope); - await this.newComponentHelper.writeAndAddNewComp(component, targetCompId, { scope: newScope }, config); + await this.newComponentHelper.writeAndAddNewComp( + component, + targetCompId, + { + scope: newScope, + incrementPathIfConflicted: true, + }, + config + ); multipleForkInfo.push({ targetCompId, sourceId: component.id.toStringWithoutVersion(), component }); }); await this.refactorMultipleAndInstall(multipleForkInfo, { diff --git a/scopes/component/graph/component-id-graph.ts b/scopes/component/graph/component-id-graph.ts index f29150034e2a..fe830f9b4ca0 100644 --- a/scopes/component/graph/component-id-graph.ts +++ b/scopes/component/graph/component-id-graph.ts @@ -94,32 +94,33 @@ export class ComponentIdGraph extends Graph { through?: ComponentID[] ): string[][] { const removeVerFromIdStr = (idStr: string) => idStr.split('@')[0]; - const targetsStr = targets.map((t) => t.toStringWithoutVersion()); - const traverseDFS = ( - node: string, - visitedInPath: string[], - visitedInGraph: string[] = [], - allPaths: string[][] - ) => { - if (visitedInPath.includes(node)) return; - visitedInPath.push(node); - if (targetsStr.includes(removeVerFromIdStr(node))) { - allPaths.push(visitedInPath); - return; + const findAllPathsBFS = (start: string[], end: string[]): string[][] => { + const paths: string[][] = []; + const visited = new Set(); + const queue: { node: string; path: string[] }[] = []; + start.forEach((s) => queue.push({ node: s, path: [s] })); + while (queue.length) { + const { node, path } = queue.shift()!; + if (end.includes(removeVerFromIdStr(node))) { + paths.push([...path]); + } else { + visited.add(node); + const successors = this.outEdges(node).map((e) => e.targetId); + for (const successor of successors) { + if (!visited.has(successor)) { + queue.push({ node: successor, path: [...path, successor] }); + } + } + } } - if (visitedInGraph.includes(node)) return; - visitedInGraph.push(node); - const successors = Array.from(this.successorMap(node).values()); - successors.forEach((s) => { - traverseDFS(s.id, [...visitedInPath], visitedInGraph, allPaths); - }); + return paths; }; - let allPaths: string[][] = []; - sources.forEach((source) => { - traverseDFS(source.toString(), [], [], allPaths); - }); + const targetsStr = targets.map((t) => t.toStringWithoutVersion()); + const sourcesStr = sources.map((s) => s.toString()); + + let allPaths = findAllPathsBFS(sourcesStr, targetsStr); if (through?.length) { allPaths = allPaths.filter((pathWithVer) => { @@ -128,7 +129,6 @@ export class ComponentIdGraph extends Graph { }); } - const sourcesStr = sources.map((s) => s.toString()); const filtered = allPaths.filter((path) => { if (path.length < 3) { // if length is 1, the source and target are the same. diff --git a/scopes/component/graph/graph-cmd.ts b/scopes/component/graph/graph-cmd.ts index fc10aaf6ce11..946fc90b4c8d 100644 --- a/scopes/component/graph/graph-cmd.ts +++ b/scopes/component/graph/graph-cmd.ts @@ -4,7 +4,7 @@ import * as path from 'path'; import GraphLib from 'graphlib'; import { Command, CommandOptions } from '@teambit/cli'; import { ComponentID } from '@teambit/component-id'; -import { generateRandomStr } from '@teambit/legacy/dist/utils'; +import { generateRandomStr } from '@teambit/toolbox.string.random'; import VisualDependencyGraph from '@teambit/legacy/dist/scope/graph/vizgraph'; import { Consumer, loadConsumerIfExist } from '@teambit/legacy/dist/consumer'; import DependencyGraph from '@teambit/legacy/dist/scope/graph/scope-graph'; diff --git a/scopes/component/graph/ui/dependencies-compare/dependencies-compare.tsx b/scopes/component/graph/ui/dependencies-compare/dependencies-compare.tsx index 980133fe3c65..315aeeb98ff8 100644 --- a/scopes/component/graph/ui/dependencies-compare/dependencies-compare.tsx +++ b/scopes/component/graph/ui/dependencies-compare/dependencies-compare.tsx @@ -23,11 +23,12 @@ import { diffGraph } from './diff-graph'; function ComponentNodeContainer(props: NodeProps) { const { sourcePosition = Position.Top, targetPosition = Position.Bottom, data, id } = props; - + // @todo - this will be fixed as part of the react-flow-renderer v10 upgrade + const ReactFlowHandle = Handle as any; return (
- - + +
); diff --git a/scopes/component/graph/ui/dependencies-graph/dependencies-graph.tsx b/scopes/component/graph/ui/dependencies-graph/dependencies-graph.tsx index 96d06b6bc0c8..357d887b2429 100644 --- a/scopes/component/graph/ui/dependencies-graph/dependencies-graph.tsx +++ b/scopes/component/graph/ui/dependencies-graph/dependencies-graph.tsx @@ -25,11 +25,12 @@ import styles from './dependencies-graph.module.scss'; function ComponentNodeContainer(props: NodeProps) { const { sourcePosition = Position.Top, targetPosition = Position.Bottom, data, id } = props; - + // @todo - this will be fixed as part of the react-flow-renderer v10 upgrade + const ReactFlowHandle = Handle as any; return (
- - + +
); diff --git a/scopes/component/mover/move-cmd.ts b/scopes/component/mover/move-cmd.ts index 7950bd150fd2..8121679ba824 100644 --- a/scopes/component/mover/move-cmd.ts +++ b/scopes/component/mover/move-cmd.ts @@ -5,8 +5,8 @@ import { MoverMain } from './mover.main.runtime'; export class MoveCmd implements Command { name = 'move '; - description = - "move a component to a different filesystem path (note: this does NOT affect the component's name or scope, just its location in the workspace)"; + description = 'move a component to a different filesystem path'; + extendedDescription = `(note: this does NOT affect the component's name or scope, just its location in the workspace)`; helpUrl = 'reference/workspace/moving-components'; arguments = [ { @@ -19,7 +19,6 @@ export class MoveCmd implements Command { }, ]; group = 'development'; - extendedDescription = `move files or directories of component(s)\n`; alias = 'mv'; loader = true; options = []; diff --git a/scopes/component/new-component-helper/new-component-helper.main.runtime.ts b/scopes/component/new-component-helper/new-component-helper.main.runtime.ts index b7f2a9e8b998..e0bbff1396e5 100644 --- a/scopes/component/new-component-helper/new-component-helper.main.runtime.ts +++ b/scopes/component/new-component-helper/new-component-helper.main.runtime.ts @@ -14,6 +14,7 @@ import { PkgAspect } from '@teambit/pkg'; import { RenamingAspect } from '@teambit/renaming'; import { EnvsAspect } from '@teambit/envs'; import { NewComponentHelperAspect } from './new-component-helper.aspect'; +import { incrementPathRecursively } from '@teambit/component-writer'; const aspectsConfigToIgnore: string[] = [PkgAspect.id, RenamingAspect.id]; @@ -39,7 +40,14 @@ export class NewComponentHelperMain { * if not provided, generate the path based on the component-id. * the component will be written to that path. */ - getNewComponentPath(componentId: ComponentID, pathFromUser?: string, componentsToCreate?: number): PathLinuxRelative { + getNewComponentPath( + componentId: ComponentID, + { + pathFromUser, + componentsToCreate, + incrementPathIfConflicted, + }: { pathFromUser?: string; componentsToCreate?: number; incrementPathIfConflicted?: boolean } = {} + ): PathLinuxRelative { if (pathFromUser) { const fullPath = path.join(this.workspace.path, pathFromUser); const componentPath = componentId.fullName; @@ -53,15 +61,37 @@ export class NewComponentHelperMain { return pathFromUser; } - return this.workspace.consumer.composeRelativeComponentPath(componentId.changeScope(componentId.scope)); + const generatedPath = this.workspace.consumer.composeRelativeComponentPath( + componentId.changeScope(componentId.scope) + ); + if (!incrementPathIfConflicted) { + return generatedPath; + } + + const existingPaths = this.workspace.bitMap.getAllRootDirs(); + // e.g. existing "bar/foo" and currently writing "bar" + const existingParent = existingPaths.find((d) => d.startsWith(`${generatedPath}/`)); + const existingExact = existingPaths.find((d) => d === generatedPath); + // e.g. existing "bar" and currently writing "bar/foo" + const existingChild = existingPaths.find((p) => generatedPath.startsWith(p)); + if (existingParent || existingExact || existingChild) { + // if existingChild, you can't increment the generatedPath, it'll still be a sub-directory of the existingChild + const pathToIncrement = existingChild || generatedPath; + return incrementPathRecursively(pathToIncrement, existingPaths); + } + return generatedPath; } + async writeAndAddNewComp( comp: Component, targetId: ComponentID, - options?: { path?: string; scope?: string; env?: string }, + options?: { path?: string; scope?: string; env?: string; incrementPathIfConflicted?: boolean }, config?: { [aspectName: string]: any } ) { - const targetPath = this.getNewComponentPath(targetId, options?.path); + const targetPath = this.getNewComponentPath(targetId, { + pathFromUser: options?.path, + incrementPathIfConflicted: options?.incrementPathIfConflicted, + }); await this.throwForExistingPath(targetPath); await this.workspace.write(comp, targetPath); if (options?.env && config) { diff --git a/scopes/component/refactoring/refactoring.main.runtime.ts b/scopes/component/refactoring/refactoring.main.runtime.ts index a88fb2bfc1a5..64be016ec202 100644 --- a/scopes/component/refactoring/refactoring.main.runtime.ts +++ b/scopes/component/refactoring/refactoring.main.runtime.ts @@ -21,20 +21,13 @@ import { expressionStatementTransformer, typeReferenceTransformer, } from '@teambit/typescript'; -import { PrettierAspect, PrettierMain } from '@teambit/prettier'; -import { Formatter } from '@teambit/formatter'; import { RefactoringAspect } from './refactoring.aspect'; import { DependencyNameRefactorCmd, RefactorCmd } from './refactor.cmd'; export type MultipleStringsReplacement = Array<{ oldStr: string; newStr: string }>; export class RefactoringMain { - constructor( - private componentMain: ComponentMain, - private pkg: PkgMain, - private envs: EnvsMain, - private prettierMain: PrettierMain - ) {} + constructor(private componentMain: ComponentMain, private pkg: PkgMain, private envs: EnvsMain) {} /** * refactor the dependency name of a component. @@ -259,20 +252,6 @@ export class RefactoringMain { return changed.some((c) => c); } - private getDefaultFormatter(): Formatter { - return this.prettierMain.createFormatter( - { check: false }, - { - config: { - parser: 'typescript', - trailingComma: 'es5', - tabWidth: 2, - singleQuote: true, - }, - } - ); - } - private async replaceMultipleStringsInOneComp( comp: Component, stringsToReplace: MultipleStringsReplacement, @@ -332,16 +311,10 @@ export class RefactoringMain { } static slots = []; - static dependencies = [ComponentAspect, PkgAspect, CLIAspect, EnvsAspect, PrettierAspect]; + static dependencies = [ComponentAspect, PkgAspect, CLIAspect, EnvsAspect]; static runtime = MainRuntime; - static async provider([componentMain, pkg, cli, envMain, prettierMain]: [ - ComponentMain, - PkgMain, - CLIMain, - EnvsMain, - PrettierMain - ]) { - const refactoringMain = new RefactoringMain(componentMain, pkg, envMain, prettierMain); + static async provider([componentMain, pkg, cli, envMain]: [ComponentMain, PkgMain, CLIMain, EnvsMain]) { + const refactoringMain = new RefactoringMain(componentMain, pkg, envMain); const subCommands = [new DependencyNameRefactorCmd(refactoringMain, componentMain)]; const refactorCmd = new RefactorCmd(); refactorCmd.commands = subCommands; diff --git a/scopes/component/renaming/rename.cmd.ts b/scopes/component/renaming/rename.cmd.ts index a90f639b6852..96f80f6baae6 100644 --- a/scopes/component/renaming/rename.cmd.ts +++ b/scopes/component/renaming/rename.cmd.ts @@ -30,7 +30,7 @@ export class RenameCmd implements Command { skipWorkspace = true; alias = ''; options = [ - ['s', 'scope ', 'define the scope for the newly created component'], + ['s', 'scope ', 'define the scope for the new component'], ['r', 'refactor', 'update the import/require statements in all dependent components (in the same workspace)'], ['', 'preserve', 'avoid renaming files and variables/classes according to the new component name'], ['', 'ast', 'EXPERIMENTAL. use ast to transform files instead of regex'], diff --git a/scopes/component/renaming/renaming.main.runtime.ts b/scopes/component/renaming/renaming.main.runtime.ts index 7fd132651417..af95e54e6475 100644 --- a/scopes/component/renaming/renaming.main.runtime.ts +++ b/scopes/component/renaming/renaming.main.runtime.ts @@ -152,11 +152,12 @@ make sure this argument is the name only, without the scope-name. to change the } if (!targetComp) throw new Error(`renameMultiple, targetComp is missing`); await this.refactoring.refactorVariableAndClasses(targetComp, sourceId, targetId, options); + const compPath = this.newComponentHelper.getNewComponentPath(targetId); this.refactoring.refactorFilenames(targetComp, sourceId, targetId); await this.componentWriter.writeMany({ components: [targetComp.state._consumer], skipDependencyInstallation: true, - writeToPath: this.newComponentHelper.getNewComponentPath(targetId), + writeToPath: path.join(this.workspace.path, compPath), reasonForBitmapChange: 'rename', }); }); @@ -184,15 +185,14 @@ make sure this argument is the name only, without the scope-name. to change the } /** - * change the default-scope for new components. optionally (if refactor is true), change the source code to match the - * new scope-name. - * keep in mind that this is working for new components only, for tagged/exported it's impossible. See the errors - * thrown in such cases in this method. + * change the default-scope for new components. + * for tagged/exported components, delete (or deprecate - depends on the flag) the original ones and create new ones. + * optionally (if refactor is true), change the source code to match the new scope-name. */ async renameScope( oldScope: string, newScope: string, - options: { refactor?: boolean; deprecate?: boolean } = {} + options: { refactor?: boolean; deprecate?: boolean; preserve?: boolean } = {} ): Promise { const allComponentsIds = this.workspace.listIds(); const componentsUsingOldScope = allComponentsIds.filter((compId) => compId.scope === oldScope); @@ -206,7 +206,7 @@ make sure this argument is the name only, without the scope-name. to change the const targetId = ComponentID.fromObject({ name: compId.fullName }, newScope); return { sourceId: compId, targetId }; }); - return this.renameMultiple(multipleIds, { ...options, preserve: true }); + return this.renameMultiple(multipleIds, options); } /** diff --git a/scopes/component/renaming/scope-rename.cmd.ts b/scopes/component/renaming/scope-rename.cmd.ts index a4ee2ed56774..6b1f47fa533f 100644 --- a/scopes/component/renaming/scope-rename.cmd.ts +++ b/scopes/component/renaming/scope-rename.cmd.ts @@ -5,7 +5,7 @@ import { RenameResult, RenamingMain } from './renaming.main.runtime'; export class ScopeRenameCmd implements Command { name = 'rename '; description = - "rename the scope name for all components with the specified 'current scope name', if exported, create new components and deprecate the original ones"; + "rename the scope name for all components with the specified 'current scope name'. if exported, create new components and delete the original ones"; extendedDescription = `Note: if \`\` is also the defaultScope for the workspace, this command will set \`\` as the defaultScope instead, and that will then be set for all components by default. You may see updates in your .bitmap file as a result of this change`; @@ -14,6 +14,7 @@ as a result of this change`; { name: 'new-scope-name', description: 'a new scope name to replace the current scope name' }, ]; options = [ + ['', 'preserve', 'avoid renaming files and variables/classes according to the new scope name'], [ 'r', 'refactor', @@ -27,9 +28,9 @@ as a result of this change`; async report( [oldName, newName]: [string, string], - { refactor, deprecate }: { refactor?: boolean; deprecate?: boolean } + { refactor, deprecate, preserve }: { refactor?: boolean; deprecate?: boolean; preserve?: boolean } ) { - const result = await this.renaming.renameScope(oldName, newName, { refactor, deprecate }); + const result = await this.renaming.renameScope(oldName, newName, { refactor, deprecate, preserve }); const title = chalk.green(`successfully replaced "${oldName}" scope with "${newName}"`); const renameOutput = renameScopeOutput(result); return `${title}\n${renameOutput}`; diff --git a/scopes/component/snapping/snapping.main.runtime.ts b/scopes/component/snapping/snapping.main.runtime.ts index 8240885bb300..5239320b8783 100644 --- a/scopes/component/snapping/snapping.main.runtime.ts +++ b/scopes/component/snapping/snapping.main.runtime.ts @@ -641,7 +641,8 @@ if you're willing to lose the history from the head to the specified version, us const allTagPending = await workspace.listPotentialTagIds(); if (allTagPending.length) { throw new BitError(`unable to find matching for "${pattern}" pattern among modified/new components. -there are matching among unmodified components thought. consider using --unmodified flag if needed`); +there are matching among unmodified components though. consider using --unmodified flag if needed. +in case you're unsure about the pattern syntax, use "bit pattern [--help]"`); } } if (!componentIds.length) { diff --git a/scopes/compositions/compositions/compositions.tsx b/scopes/compositions/compositions/compositions.tsx index 86b56dcb490f..cdd4e3f22cef 100644 --- a/scopes/compositions/compositions/compositions.tsx +++ b/scopes/compositions/compositions/compositions.tsx @@ -19,7 +19,7 @@ import { MDXLayout } from '@teambit/mdx.ui.mdx-layout'; import { Separator } from '@teambit/design.ui.separator'; import { H1 } from '@teambit/documenter.ui.heading'; import { AlertCard } from '@teambit/design.ui.alert-card'; -import { Link, useNavigate, useLocation } from '@teambit/base-react.navigation.link'; +import { Link as BaseLink, useNavigate, useLocation } from '@teambit/base-react.navigation.link'; import { OptionButton } from '@teambit/design.ui.input.option-button'; import { StatusMessageCard } from '@teambit/design.ui.surfaces.status-message-card'; import { EmptyStateSlot } from './compositions.ui.runtime'; @@ -30,6 +30,9 @@ import { CompositionsPanel } from './ui/compositions-panel/compositions-panel'; import type { CompositionsMenuSlot } from './compositions.ui.runtime'; import { ComponentCompositionProps } from './ui/composition-preview'; +// @todo - this will be fixed as part of the @teambit/base-react.navigation.link upgrade to latest +const Link = BaseLink as any; + export type MenuBarWidget = { location: 'start' | 'end'; content: ReactNode; diff --git a/scopes/defender/eslint-config-mutator/config-mutator.ts b/scopes/defender/eslint-config-mutator/config-mutator.ts index 112dc2f95f83..679979573f77 100644 --- a/scopes/defender/eslint-config-mutator/config-mutator.ts +++ b/scopes/defender/eslint-config-mutator/config-mutator.ts @@ -1,6 +1,16 @@ import { cloneDeep, set, get, has } from 'lodash'; import { Linter } from 'eslint'; -import { ESLintOptions } from '@teambit/eslint'; +// import { ESLintOptions } from '@teambit/eslint'; +import { ESLintOptions } from '@teambit/defender.eslint-linter'; + +export type EslintConfigTransformContext = { + fix: boolean; +}; + +export type EslintConfigTransformer = ( + config: EslintConfigMutator, + context: EslintConfigTransformContext +) => EslintConfigMutator; export class EslintConfigMutator { constructor(public raw: ESLintOptions) {} @@ -24,13 +34,13 @@ export class EslintConfigMutator { return this; } - setTsConfig(tsconfig: Record): EslintConfigMutator { - this.raw.tsConfig = tsconfig; + setTsConfig(tsconfig: string): EslintConfigMutator { + this.raw.tsconfig = tsconfig; return this; } setPluginPath(newPath: string): EslintConfigMutator { - this.raw.pluginPath = newPath; + this.raw.pluginsPath = newPath; return this; } diff --git a/scopes/defender/eslint-config-mutator/index.ts b/scopes/defender/eslint-config-mutator/index.ts index 9c1357cbdeb0..4e40b13d2fa6 100644 --- a/scopes/defender/eslint-config-mutator/index.ts +++ b/scopes/defender/eslint-config-mutator/index.ts @@ -1 +1,2 @@ export { EslintConfigMutator } from './config-mutator'; +export type { EslintConfigTransformContext, EslintConfigTransformer } from './config-mutator'; diff --git a/scopes/defender/eslint/eslint.linter.ts b/scopes/defender/eslint/eslint.linter.ts index 00e1379dd1a1..7b1c4b2e7916 100644 --- a/scopes/defender/eslint/eslint.linter.ts +++ b/scopes/defender/eslint/eslint.linter.ts @@ -13,7 +13,7 @@ export class ESLintLinter implements Linter { constructor( private logger: Logger, - private options: ESLintOptions, + private options: ESLintOptions = { config: {} }, /** * reference to the eslint module. @@ -42,7 +42,7 @@ export class ESLintLinter implements Linter { this.options.config.overrideConfig.parserOptions.project = tsConfigPath; } } - const resultsP = mapSeries(context.components, async (component) => { + const resultsP = mapSeries(context.componentsDirMap.components, async (component) => { longProcessLogger.logProgress( `component: ${component.id.toString()}, # of files: ${component.filesystem.files.length}` ); diff --git a/scopes/defender/eslint/eslint.main.runtime.ts b/scopes/defender/eslint/eslint.main.runtime.ts index 9b2da06924c4..0ff4c11ba1be 100644 --- a/scopes/defender/eslint/eslint.main.runtime.ts +++ b/scopes/defender/eslint/eslint.main.runtime.ts @@ -3,7 +3,11 @@ import { MainRuntime } from '@teambit/cli'; import { ESLint as ESLintLib } from 'eslint'; import { Linter, LinterContext, LinterMain } from '@teambit/linter'; import { Logger, LoggerAspect, LoggerMain } from '@teambit/logger'; -import { EslintConfigMutator } from '@teambit/defender.eslint.config-mutator'; +import { + EslintConfigMutator, + EslintConfigTransformContext, + EslintConfigTransformer, +} from '@teambit/defender.eslint.config-mutator'; import { WorkspaceConfigFilesMain } from '@teambit/workspace-config-files'; import { ESLintAspect } from './eslint.aspect'; import { ESLintLinter } from './eslint.linter'; @@ -40,15 +44,6 @@ export type ESLintOptions = { tsConfig?: Record; }; -export type EslintConfigTransformContext = { - fix: boolean; -}; - -export type EslintConfigTransformer = ( - config: EslintConfigMutator, - context: EslintConfigTransformContext -) => EslintConfigMutator; - export class ESLintMain { constructor(private logger: Logger) {} @@ -68,6 +63,7 @@ export class ESLintMain { const transformerContext: EslintConfigTransformContext = { fix: !!context.fix }; const afterMutation = runTransformersWithContext(configMutator.clone(), transformers, transformerContext); + // @ts-ignore return new ESLintLinter(this.logger, afterMutation.raw, ESLintModule); } @@ -92,6 +88,8 @@ function getOptions(options: ESLintOptions, context: LinterContext): ESLintOptio overrideConfig: options.config, extensions: context.extensionFormats, useEslintrc: false, + // TODO: this should be probably be replaced with resolve-plugins-relative-to + // https://eslint.org/docs/latest/use/command-line-interface#--resolve-plugins-relative-to cwd: options.pluginPath, fix: !!context.fix, fixTypes: context.fixTypes, diff --git a/scopes/defender/eslint/index.ts b/scopes/defender/eslint/index.ts index b2de995fef6b..94f5f56c7a4e 100644 --- a/scopes/defender/eslint/index.ts +++ b/scopes/defender/eslint/index.ts @@ -1,10 +1,5 @@ import { ESLintAspect } from './eslint.aspect'; export { ESLintAspect }; -export type { - ESLintMain, - ESLintOptions, - EslintConfigTransformContext, - EslintConfigTransformer, -} from './eslint.main.runtime'; +export type { ESLintMain, ESLintOptions } from './eslint.main.runtime'; export default ESLintAspect; diff --git a/scopes/defender/linter/lint.task.ts b/scopes/defender/linter/lint.task.ts index 4e874c95c5b5..36162206ca94 100644 --- a/scopes/defender/linter/lint.task.ts +++ b/scopes/defender/linter/lint.task.ts @@ -1,6 +1,6 @@ import path from 'path'; import { BuildTask, BuiltTaskResult, BuildContext, ComponentResult } from '@teambit/builder'; -import { Component, ComponentMap } from '@teambit/component'; +import { ComponentMap } from '@teambit/component'; import { CapsuleList } from '@teambit/isolator'; import { Linter } from './linter'; import { LinterContext } from './linter-context'; @@ -11,11 +11,7 @@ export class LintTask implements BuildTask { async execute(context: BuildContext): Promise { const linter: Linter = context.env.getLinter(); const rootDir = context.capsuleNetwork.capsulesRootDir; - const componentsDirMap = this.getComponentsDirectory( - rootDir, - context.components, - context.capsuleNetwork.graphCapsules - ); + const componentsDirMap = this.getComponentsDirectory(rootDir, context.capsuleNetwork.originalSeedersCapsules); // @ts-ignore TODO: fix this const linterContext: LinterContext = { @@ -40,12 +36,8 @@ export class LintTask implements BuildTask { }; } - private getComponentsDirectory( - capsuleRootDir: string, - components: Component[], - capsuleList: CapsuleList - ): ComponentMap { - return ComponentMap.as(components, (component) => { + private getComponentsDirectory(capsuleRootDir: string, capsuleList: CapsuleList): ComponentMap { + return ComponentMap.as(capsuleList.getAllComponents(), (component) => { const fullPath = capsuleList.getCapsule(component.id)?.path || ''; const relativePath = path.relative(capsuleRootDir, fullPath); return relativePath; diff --git a/scopes/defender/prettier-config-mutator/config-mutator.ts b/scopes/defender/prettier-config-mutator/config-mutator.ts index 3154d2b96c3a..c1bef83a2102 100644 --- a/scopes/defender/prettier-config-mutator/config-mutator.ts +++ b/scopes/defender/prettier-config-mutator/config-mutator.ts @@ -1,6 +1,15 @@ import { cloneDeep } from 'lodash'; import { Options as PrettierOptions, Plugin } from 'prettier'; +export type PrettierConfigTransformContext = { + check: boolean; +}; + +export type PrettierConfigTransformer = ( + config: PrettierConfigMutator, + context: PrettierConfigTransformContext +) => PrettierConfigMutator; + export class PrettierConfigMutator { constructor(public raw: PrettierOptions) {} diff --git a/scopes/defender/prettier-config-mutator/index.ts b/scopes/defender/prettier-config-mutator/index.ts index 1b8fa5a5299c..ce8e4757bdbc 100644 --- a/scopes/defender/prettier-config-mutator/index.ts +++ b/scopes/defender/prettier-config-mutator/index.ts @@ -1 +1,2 @@ +export type { PrettierConfigTransformContext, PrettierConfigTransformer } from './config-mutator'; export { PrettierConfigMutator } from './config-mutator'; diff --git a/scopes/defender/prettier/index.ts b/scopes/defender/prettier/index.ts index b15dd800a07c..2f2c09cb949a 100644 --- a/scopes/defender/prettier/index.ts +++ b/scopes/defender/prettier/index.ts @@ -1,10 +1,5 @@ import { PrettierAspect } from './prettier.aspect'; export { PrettierAspect }; -export type { - PrettierMain, - PrettierOptions, - PrettierConfigTransformer, - PrettierConfigTransformContext, -} from './prettier.main.runtime'; +export type { PrettierMain, PrettierOptions } from './prettier.main.runtime'; export default PrettierAspect; diff --git a/scopes/defender/prettier/prettier.main.runtime.ts b/scopes/defender/prettier/prettier.main.runtime.ts index ee702858ac51..78ba93265176 100644 --- a/scopes/defender/prettier/prettier.main.runtime.ts +++ b/scopes/defender/prettier/prettier.main.runtime.ts @@ -2,7 +2,11 @@ import { MainRuntime } from '@teambit/cli'; import { Options as PrettierModuleOptions } from 'prettier'; import { Formatter, FormatterMain, FormatterOptions } from '@teambit/formatter'; import { Logger, LoggerAspect, LoggerMain } from '@teambit/logger'; -import { PrettierConfigMutator } from '@teambit/defender.prettier.config-mutator'; +import { + PrettierConfigMutator, + PrettierConfigTransformContext, + PrettierConfigTransformer, +} from '@teambit/defender.prettier.config-mutator'; import { WorkspaceConfigFilesMain } from '@teambit/workspace-config-files'; import { PrettierAspect } from './prettier.aspect'; import { PrettierFormatter } from './prettier.formatter'; @@ -14,15 +18,8 @@ export type PrettierOptions = { config: PrettierModuleOptions; }; -export type PrettierConfigTransformContext = { - check: boolean; -}; - -export type PrettierConfigTransformer = ( - config: PrettierConfigMutator, - context: PrettierConfigTransformContext -) => PrettierConfigMutator; - +// TODO: this aspect is not used anymore, it is still here for now for backward compatibility. +// it will be removed as part of next major bit version export class PrettierMain { constructor(private logger: Logger) {} /** diff --git a/scopes/defender/tester/tester.ts b/scopes/defender/tester/tester.ts index 62ee6f5c2f5a..93fe0d7f0d7f 100644 --- a/scopes/defender/tester/tester.ts +++ b/scopes/defender/tester/tester.ts @@ -77,6 +77,11 @@ export interface TesterContext extends ExecutionContext { */ specFiles: SpecFiles; + /** + * list of source spec files to test. + */ + sourceSpecFiles?: SpecFiles; + /** * rootPath of the component workspace or the capsule root dir (during build). */ @@ -107,6 +112,11 @@ export interface TesterContext extends ExecutionContext { */ patterns: ComponentPatternsMap; + /** + * array of source files patterns to test. + */ + sourcePatterns?: ComponentPatternsMap; + /** * * additional test host dependencies diff --git a/scopes/dependencies/dependency-resolver/dependencies/dependency-list.ts b/scopes/dependencies/dependency-resolver/dependencies/dependency-list.ts index 5b9337d71d93..d01c83afdda7 100644 --- a/scopes/dependencies/dependency-resolver/dependencies/dependency-list.ts +++ b/scopes/dependencies/dependency-resolver/dependencies/dependency-list.ts @@ -1,5 +1,5 @@ import { uniqBy, property } from 'lodash'; -import { SNAP_VERSION_PREFIX } from '@teambit/component-package-version'; +import { SNAP_VERSION_PREFIX, snapToSemver } from '@teambit/component-package-version'; import { Dependency, DependencyLifecycleType, SerializedDependency, SemverVersion, PackageName } from './dependency'; import { KEY_NAME_BY_LIFECYCLE_TYPE } from './constants'; import { ComponentDependency } from './component-dependency'; @@ -148,7 +148,7 @@ export class DependencyList { : KEY_NAME_BY_LIFECYCLE_TYPE[dep.lifecycle]; const entry = dep.toManifest(); if (entry) { - manifest[keyName][entry.packageName] = entry.version; + manifest[keyName][entry.packageName] = snapToSemver(entry.version); if (dep.optional && dep.lifecycle === 'peer') { manifest.peerDependenciesMeta[entry.packageName] = { optional: true }; } diff --git a/scopes/dependencies/dependency-resolver/dependency-resolver-workspace-config.ts b/scopes/dependencies/dependency-resolver/dependency-resolver-workspace-config.ts index 13c414135bdf..755d5aec8276 100644 --- a/scopes/dependencies/dependency-resolver/dependency-resolver-workspace-config.ts +++ b/scopes/dependencies/dependency-resolver/dependency-resolver-workspace-config.ts @@ -198,6 +198,12 @@ export interface DependencyResolverWorkspaceConfig { */ hoistPatterns?: string[]; + /** + * When true, dependencies from the workspace are hoisted to node_modules/.pnpm/node_modules + * even if they are found in the root node_modules + */ + hoistInjectedDependencies?: boolean; + /** * Tells pnpm to automatically install peer dependencies. It is true by default. */ diff --git a/scopes/dependencies/dependency-resolver/dependency-resolver.main.runtime.ts b/scopes/dependencies/dependency-resolver/dependency-resolver.main.runtime.ts index 1b0526ecdba0..a0d308583412 100644 --- a/scopes/dependencies/dependency-resolver/dependency-resolver.main.runtime.ts +++ b/scopes/dependencies/dependency-resolver/dependency-resolver.main.runtime.ts @@ -278,8 +278,9 @@ export class DependencyResolverMain { overridePrefix?: string; wantedRange?: string; }): string { - // A prerelease version is always added as an exact version - if (semver.parse(version)?.prerelease.length) { + // A prerelease version is always added as an exact version. + // A package installed by its exact version is also added as an exact version. + if (semver.parse(version)?.prerelease.length || wantedRange === version) { return version; } if (wantedRange && ['~', '^'].includes(wantedRange[0])) { @@ -316,8 +317,13 @@ export class DependencyResolverMain { const legacyComponent: LegacyComponent = component.state._consumer; const listFactory = this.getDependencyListFactory(); const dependencyList = await listFactory.fromLegacyComponent(legacyComponent); + dependencyList.forEach((dep) => { - const found = componentPolicy.find(dep.id); + let found = componentPolicy.find(dep.id); + if (!found) { + const packageName = dep?.getPackageName?.(); + found = packageName ? componentPolicy.find(packageName) : undefined; + } // if no policy found, the dependency was auto-resolved from the source code dep.source = found?.source || 'auto'; dep.hidden = found?.hidden; diff --git a/scopes/dependencies/dependency-resolver/package-manager.ts b/scopes/dependencies/dependency-resolver/package-manager.ts index 7e8d30c379e6..5de39d07d242 100644 --- a/scopes/dependencies/dependency-resolver/package-manager.ts +++ b/scopes/dependencies/dependency-resolver/package-manager.ts @@ -110,6 +110,12 @@ export type PackageManagerInstallOptions = { */ hoistPatterns?: string[]; + /** + * When true, dependencies from the workspace are hoisted to node_modules/.pnpm/node_modules + * even if they are found in the root node_modules + */ + hoistInjectedDependencies?: boolean; + /** * Tells pnpm to automatically install peer dependencies. It is true by default. */ diff --git a/scopes/dependencies/pnpm/lynx.ts b/scopes/dependencies/pnpm/lynx.ts index 83a0bcf90f98..c62501432c05 100644 --- a/scopes/dependencies/pnpm/lynx.ts +++ b/scopes/dependencies/pnpm/lynx.ts @@ -6,6 +6,7 @@ import { StoreController, WantedDependency } from '@pnpm/package-store'; import { rebuild } from '@pnpm/plugin-commands-rebuild'; import { createOrConnectStoreController, CreateStoreControllerOptions } from '@pnpm/store-connection-manager'; import { sortPackages } from '@pnpm/sort-packages'; +import { type PeerDependencyRules } from '@pnpm/types'; import { ResolvedPackageVersion, Registries, @@ -166,6 +167,7 @@ export interface ReportOptions { hideAddedPkgsProgress?: boolean; hideProgressPrefix?: boolean; hideLifecycleOutput?: boolean; + peerDependencyRules?: PeerDependencyRules; } export async function install( @@ -185,6 +187,7 @@ export async function install( includeOptionalDeps?: boolean; reportOptions?: ReportOptions; hidePackageManagerOutput?: boolean; + hoistInjectedDependencies?: boolean; dryRun?: boolean; dedupeInjectedDeps?: boolean; } & Pick< @@ -205,16 +208,17 @@ export async function install( // eslint-disable-next-line @typescript-eslint/no-unused-vars logger?: Logger ): Promise<{ dependenciesChanged: boolean; rebuild: RebuildFn; storeDir: string }> { - let externalDependencies: Set | undefined; + const externalDependencies = new Set(); const readPackage: ReadPackageHook[] = []; if (options?.rootComponents && !options?.rootComponentsForCapsules) { - externalDependencies = new Set( - Object.values(manifestsByPaths) - .map(({ name }) => name) - .filter(Boolean) as string[] - ); + for (const [dir, { name }] of Object.entries(manifestsByPaths)) { + if (dir !== rootDir && name) { + externalDependencies.add(name); + } + } readPackage.push(readPackageHook as ReadPackageHook); } + readPackage.push(removeLegacyFromDeps as ReadPackageHook); if (!manifestsByPaths[rootDir].dependenciesMeta) { manifestsByPaths = { ...manifestsByPaths, @@ -243,6 +247,12 @@ export async function install( packageImportMethod: options?.packageImportMethod, pnpmHomeDir: options?.pnpmHomeDir, }); + const hoistPattern = options.hoistPattern ?? ['*']; + if (hoistPattern.length > 0 && externalDependencies.size > 0 && !options.hoistInjectedDependencies) { + for (const pkgName of externalDependencies) { + hoistPattern.push(`!${pkgName}`); + } + } const opts: InstallOptions = { allProjects, autoInstallPeers: options.autoInstallPeers, @@ -275,19 +285,9 @@ export async function install( }, ...options, excludeLinksFromLockfile: options.excludeLinksFromLockfile ?? true, - // As of now, pnpm (v8.15.4) uses overrides to mute peer dependency warnings with "allowAny" and "ignoreMissing". - // This is fine as long as the peer dependencies are not automatically installed. - // However, if we override the peer dependencies fields and then automatically install the peers - // we'll get unexpected peer dependencies installed, so we cannot use both settings at the same time. - peerDependencyRules: options.autoInstallPeers - ? {} - : { - allowAny: ['*'], - ignoreMissing: ['*'], - ...options?.peerDependencyRules, - }, depth: options.updateAll ? Infinity : 0, disableRelinkLocalDirDeps: true, + hoistPattern, }; let dependenciesChanged = false; @@ -352,6 +352,11 @@ function initReporter(opts?: ReportOptions) { hideAddedPkgsProgress: opts?.hideAddedPkgsProgress, hideProgressPrefix: opts?.hideProgressPrefix, hideLifecycleOutput: opts?.hideLifecycleOutput, + peerDependencyRules: { + allowAny: ['*'], + ignoreMissing: ['*'], + ...opts?.peerDependencyRules, + }, }, streamParser, // Linked in core aspects are excluded from the output to reduce noise. @@ -382,6 +387,20 @@ function readPackageHookForCapsules(pkg: PackageManifest, workspaceDir?: string) return readDependencyPackageHook(pkg); } +/** + * @teambit/legacy should never be installed as a dependency. + * It is linked from bvm. + */ +function removeLegacyFromDeps(pkg: PackageManifest): PackageManifest { + if (pkg.dependencies?.['@teambit/legacy'] && !pkg.dependencies['@teambit/legacy'].startsWith('link:')) { + delete pkg.dependencies['@teambit/legacy']; + } + if (pkg.peerDependencies?.['@teambit/legacy']) { + delete pkg.peerDependencies['@teambit/legacy']; + } + return pkg; +} + /** * This hook is used when installation happens in a Bit workspace. * We need a different hook for this case because unlike in a capsule, in a workspace, diff --git a/scopes/dependencies/pnpm/pnpm.package-manager.ts b/scopes/dependencies/pnpm/pnpm.package-manager.ts index 14e7ba582467..63bafd01e005 100644 --- a/scopes/dependencies/pnpm/pnpm.package-manager.ts +++ b/scopes/dependencies/pnpm/pnpm.package-manager.ts @@ -16,7 +16,7 @@ import { Logger } from '@teambit/logger'; import fs from 'fs'; import { memoize, omit } from 'lodash'; import { PeerDependencyIssuesByProjects } from '@pnpm/core'; -import { readModulesManifest } from '@pnpm/modules-yaml'; +import { readModulesManifest, Modules } from '@pnpm/modules-yaml'; import { buildDependenciesHierarchy, DependenciesHierarchy, @@ -33,6 +33,7 @@ import type { RebuildFn } from './lynx'; export class PnpmPackageManager implements PackageManager { readonly name = 'pnpm'; + readonly modulesManifestCache: Map = new Map(); private _readConfig = async (dir?: string) => { const { config, warnings } = await readConfig(dir); @@ -81,6 +82,7 @@ export class PnpmPackageManager implements PackageManager { } }); } + this.modulesManifestCache.delete(rootDir); const { dependenciesChanged, rebuild, storeDir } = await install( rootDir, manifests, @@ -90,7 +92,7 @@ export class PnpmPackageManager implements PackageManager { proxyConfig, networkConfig, { - autoInstallPeers: installOptions.autoInstallPeers ?? true, + autoInstallPeers: installOptions.autoInstallPeers ?? false, engineStrict: installOptions.engineStrict ?? config.engineStrict, excludeLinksFromLockfile: installOptions.excludeLinksFromLockfile, lockfileOnly: installOptions.lockfileOnly, @@ -107,11 +109,11 @@ export class PnpmPackageManager implements PackageManager { ? ['*'] : ['@eslint/plugin-*', '*eslint-plugin*', '@prettier/plugin-*', '*prettier-plugin-*'], hoistWorkspacePackages: installOptions.hoistWorkspacePackages, + hoistInjectedDependencies: installOptions.hoistInjectedDependencies, packageImportMethod: installOptions.packageImportMethod ?? config.packageImportMethod, preferOffline: installOptions.preferOffline, rootComponents: installOptions.rootComponents, rootComponentsForCapsules: installOptions.rootComponentsForCapsules, - peerDependencyRules: installOptions.peerDependencyRules, sideEffectsCacheRead: installOptions.sideEffectsCache ?? true, sideEffectsCacheWrite: installOptions.sideEffectsCache ?? true, pnpmHomeDir: config.pnpmHomeDir, @@ -122,6 +124,7 @@ export class PnpmPackageManager implements PackageManager { throttleProgress: installOptions.throttleProgress, hideProgressPrefix: installOptions.hideProgressPrefix, hideLifecycleOutput: installOptions.hideLifecycleOutput, + peerDependencyRules: installOptions.peerDependencyRules, }, }, this.logger @@ -241,8 +244,15 @@ export class PnpmPackageManager implements PackageManager { return modulesState.injectedDeps[`node_modules/${packageName}`] ?? modulesState.injectedDeps[componentDir] ?? []; } - _readModulesManifest(lockfileDir: string) { - return readModulesManifest(join(lockfileDir, 'node_modules')); + async _readModulesManifest(lockfileDir: string): Promise { + if (this.modulesManifestCache.has(lockfileDir)) { + return this.modulesManifestCache.get(lockfileDir); + } + const modulesManifest = await readModulesManifest(join(lockfileDir, 'node_modules')); + if (modulesManifest) { + this.modulesManifestCache.set(lockfileDir, modulesManifest); + } + return modulesManifest ?? undefined; } getWorkspaceDepsOfBitRoots(manifests: ProjectManifest[]): Record { diff --git a/scopes/generator/generator/component-generator.ts b/scopes/generator/generator/component-generator.ts index b299d5a8694b..db0b46f2dcbc 100644 --- a/scopes/generator/generator/component-generator.ts +++ b/scopes/generator/generator/component-generator.ts @@ -52,17 +52,18 @@ export class ComponentGenerator { private envId?: ComponentID ) {} - async generate(): Promise { + async generate(force = false): Promise { const dirsToDeleteIfFailed: string[] = []; const generateResults = await pMapSeries(this.componentIds, async (componentId) => { try { - const componentPath = this.newComponentHelper.getNewComponentPath( - componentId, - this.options.path, - this.componentIds.length - ); - if (fs.existsSync(path.join(this.workspace.path, componentPath))) { - throw new BitError(`unable to create a component at "${componentPath}", this path already exist`); + const componentPath = this.newComponentHelper.getNewComponentPath(componentId, { + pathFromUser: this.options.path, + componentsToCreate: this.componentIds.length, + }); + if (!force && fs.existsSync(path.join(this.workspace.path, componentPath))) { + throw new BitError( + `unable to create a component at "${componentPath}", this path already exists, please use "--path" to create the component in a different path` + ); } dirsToDeleteIfFailed.push(componentPath); return await this.generateOneComponent(componentId, componentPath); diff --git a/scopes/generator/generator/create.cmd.ts b/scopes/generator/generator/create.cmd.ts index 622f7deb3f02..76817eedee9b 100644 --- a/scopes/generator/generator/create.cmd.ts +++ b/scopes/generator/generator/create.cmd.ts @@ -10,6 +10,7 @@ import type { BaseComponentTemplateOptions } from './component-template'; export type CreateOptions = BaseComponentTemplateOptions & { env?: string; aspect?: string; + force?: boolean; }; export class CreateCmd implements Command { @@ -58,6 +59,7 @@ export class CreateCmd implements Command { ['t', 'template ', 'env-id of the template. alias for --aspect.'], ['p', 'path ', 'relative path in the workspace. by default the path is `//`'], ['e', 'env ', "set the component's environment. (overrides the env from variants and the template)"], + ['f', 'force', 'replace existing files at the target location'], ] as CommandOptions; constructor(private generator: GeneratorMain) {} @@ -66,6 +68,7 @@ export class CreateCmd implements Command { [templateName, componentNames]: [string, string[]], options: Partial & { template?: string | ComponentID; + force?: boolean; } ) { options.aspectId = options.aspectId ?? options.template; diff --git a/scopes/generator/generator/exceptions/workspace-path-exists.ts b/scopes/generator/generator/exceptions/workspace-path-exists.ts new file mode 100644 index 000000000000..77ad35b3674e --- /dev/null +++ b/scopes/generator/generator/exceptions/workspace-path-exists.ts @@ -0,0 +1,7 @@ +import { BitError } from '@teambit/bit-error'; + +export class WorkspacePathExists extends BitError { + constructor(readonly path: string) { + super(`unable to create a workspace at "${path}", this path already exists`); + } +} diff --git a/scopes/generator/generator/generator.main.runtime.ts b/scopes/generator/generator/generator.main.runtime.ts index 124da4ee7189..127daaf5747e 100644 --- a/scopes/generator/generator/generator.main.runtime.ts +++ b/scopes/generator/generator/generator.main.runtime.ts @@ -1,13 +1,13 @@ +import fs from 'fs-extra'; +import { resolve } from 'path'; import { GraphqlAspect, GraphqlMain } from '@teambit/graphql'; import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli'; import { WorkspaceAspect, OutsideWorkspaceError, Workspace } from '@teambit/workspace'; import { EnvDefinition, EnvsAspect, EnvsMain } from '@teambit/envs'; import ComponentConfig from '@teambit/legacy/dist/consumer/config'; import { WorkspaceConfigFilesAspect, WorkspaceConfigFilesMain } from '@teambit/workspace-config-files'; - import { ComponentAspect, ComponentID } from '@teambit/component'; import type { ComponentMain, Component } from '@teambit/component'; - import { isCoreAspect, loadBit, restoreGlobals } from '@teambit/bit'; import { Slot, SlotRegistry } from '@teambit/harmony'; import { GitAspect, GitMain } from '@teambit/git'; @@ -35,6 +35,7 @@ import { import { BasicWorkspaceStarter } from './templates/basic'; import { StarterPlugin } from './starter.plugin'; import { GeneratorService } from './generator.service'; +import { WorkspacePathExists } from './exceptions/workspace-path-exists'; export type ComponentTemplateSlot = SlotRegistry; export type WorkspaceTemplateSlot = SlotRegistry; @@ -328,7 +329,7 @@ export class GeneratorMain { templateWithId.id, envId ); - return componentGenerator.generate(); + return componentGenerator.generate(options.force); } private async getEnvIdFromTemplateWithId(templateWithId: ComponentTemplateWithId): Promise { @@ -357,14 +358,18 @@ export class GeneratorMain { if (this.workspace) { throw new BitError('Error: unable to generate a new workspace inside of an existing workspace'); } + const workspacePath = options.currentDir ? process.cwd() : resolve(workspaceName); + if (!options.currentDir && fs.existsSync(workspacePath)) { + throw new WorkspacePathExists(workspacePath); + } const { aspect: aspectId, loadFrom } = options; const { workspaceTemplate, aspect } = loadFrom ? await this.findTemplateInOtherWorkspace(loadFrom, templateName, aspectId) : await this.getWorkspaceTemplate(templateName, aspectId); if (!workspaceTemplate) throw new BitError(`template "${templateName}" was not found`); - const workspaceGenerator = new WorkspaceGenerator(workspaceName, options, workspaceTemplate, aspect); - const workspacePath = await workspaceGenerator.generate(); + const workspaceGenerator = new WorkspaceGenerator(workspaceName, workspacePath, options, workspaceTemplate, aspect); + await workspaceGenerator.generate(); return { workspacePath, appName: workspaceTemplate.appName }; } diff --git a/scopes/generator/generator/workspace-generator.ts b/scopes/generator/generator/workspace-generator.ts index b3bca6d431b5..8c9f1c5ebf95 100644 --- a/scopes/generator/generator/workspace-generator.ts +++ b/scopes/generator/generator/workspace-generator.ts @@ -13,7 +13,7 @@ import { ImporterAspect, ImporterMain } from '@teambit/importer'; import { CompilerAspect, CompilerMain } from '@teambit/compiler'; import getGitExecutablePath from '@teambit/legacy/dist/utils/git/git-executable'; import GitNotFound from '@teambit/legacy/dist/utils/git/exceptions/git-not-found'; -import { resolve, join } from 'path'; +import { join } from 'path'; import { ComponentID } from '@teambit/component-id'; import { GitAspect, GitMain } from '@teambit/git'; import { InstallAspect, InstallMain } from '@teambit/install'; @@ -27,7 +27,6 @@ import { GeneratorMain } from './generator.main.runtime'; export type GenerateResult = { id: ComponentID; dir: string; files: string[]; envId: string }; export class WorkspaceGenerator { - private workspacePath: string; private harmony: Harmony; private workspace: Workspace; private install: InstallMain; @@ -38,21 +37,15 @@ export class WorkspaceGenerator { private wsConfigFiles: WorkspaceConfigFilesMain; private generator: GeneratorMain; - // private componentGenerator?: ComponentGenerator; - constructor( private workspaceName: string, + private workspacePath: string, private options: NewOptions & { currentDir?: boolean }, private template: WorkspaceTemplate, private aspectComponent?: Component - ) { - this.workspacePath = options.currentDir ? process.cwd() : resolve(this.workspaceName); - } + ) {} async generate(): Promise { - if (!this.options.currentDir && fs.existsSync(this.workspacePath)) { - throw new Error(`unable to create a workspace at "${this.workspaceName}", this path already exist`); - } await fs.ensureDir(this.workspacePath); try { process.chdir(this.workspacePath); diff --git a/scopes/harmony/api-server/api-for-ide.ts b/scopes/harmony/api-server/api-for-ide.ts index dd2cf0372c93..2184a647cb61 100644 --- a/scopes/harmony/api-server/api-for-ide.ts +++ b/scopes/harmony/api-server/api-for-ide.ts @@ -142,7 +142,6 @@ export class APIForIDE { ): Promise { const results = await this.lanes.switchLanes(laneName, { skipDependencyInstallation, - getAll: true, }); return (results.components || []).map((c) => c.id.toString()); } diff --git a/scopes/harmony/aspect/aspect.env.ts b/scopes/harmony/aspect/aspect.env.ts index 638d9247e5a2..c657598929c8 100644 --- a/scopes/harmony/aspect/aspect.env.ts +++ b/scopes/harmony/aspect/aspect.env.ts @@ -1,5 +1,5 @@ import { Compiler } from '@teambit/compiler'; -import type { DependenciesEnv, PackageEnv, GetNpmIgnoreContext, PreviewEnv } from '@teambit/envs'; +import type { DependenciesEnv, PackageEnv, PreviewEnv } from '@teambit/envs'; import { merge } from 'lodash'; import { PackageJsonProps } from '@teambit/pkg'; import { TsConfigSourceFile } from 'typescript'; @@ -10,7 +10,6 @@ import { Bundler, BundlerContext } from '@teambit/bundler'; import { WebpackConfigTransformer } from '@teambit/webpack'; import { Tester } from '@teambit/tester'; import { COMPONENT_PREVIEW_STRATEGY_NAME, PreviewStrategyName } from '@teambit/preview'; -import { BUNDLE_UI_DIR } from '@teambit/ui'; import { ConfigWriterEntry } from '@teambit/workspace-config-files'; import { PrettierConfigWriter } from '@teambit/defender.prettier-formatter'; import { TypescriptConfigWriter } from '@teambit/typescript.typescript-compiler'; @@ -78,27 +77,8 @@ export class AspectEnv implements DependenciesEnv, PackageEnv, PreviewEnv { }; } - getNpmIgnore(context?: GetNpmIgnoreContext) { - // ignores only .ts files in the root directory, so d.ts files inside dists are unaffected. - // without this change, the package has "index.ts" file in the root, causing typescript to parse it instead of the - // d.ts files. (changing the "types" prop in the package.json file doesn't help). - - // Ignores all the contents inside the artifacts directory. - // Asterisk (*) is needed in order to ignore all other contents of the artifacts directory, - // especially when specific folders are excluded from the ignore e.g. in combination with `!artifacts/ui-bundle`. - const patterns = ['/*.ts', `${CAPSULE_ARTIFACTS_DIR}/*`]; - - // In order to load the env preview template from core aspects we need it to be in the package of the core envs - // This is because we don't have the core envs in the local scope so we load it from the package itself in the bvm installation - // as this will be excluded from the package tar by default (as it's under the CAPSULE_ARTIFACTS_DIR) - // we want to make sure to add it for the core envs - if (context && this.aspectLoader.isCoreEnv(context.component.id.toStringWithoutVersion())) { - patterns.push(`!${CAPSULE_ARTIFACTS_DIR}/env-template`); - } - if (context && this.aspectLoader.isCoreAspect(context.component.id.toStringWithoutVersion())) { - patterns.push(`!${CAPSULE_ARTIFACTS_DIR}/${BUNDLE_UI_DIR}`); - } - return patterns; + getNpmIgnore() { + return [`${CAPSULE_ARTIFACTS_DIR}/`]; } getPreviewConfig() { diff --git a/scopes/harmony/aspect/aspect.main.runtime.ts b/scopes/harmony/aspect/aspect.main.runtime.ts index b2d0ec344c0e..5e91cc1ca3ae 100644 --- a/scopes/harmony/aspect/aspect.main.runtime.ts +++ b/scopes/harmony/aspect/aspect.main.runtime.ts @@ -1,5 +1,6 @@ import { Harmony } from '@teambit/harmony'; import { AspectLoaderAspect, AspectLoaderMain } from '@teambit/aspect-loader'; +import { BabelCompiler } from '@teambit/compilation.babel-compiler'; import { LoggerAspect, LoggerMain } from '@teambit/logger'; import { BuilderAspect, BuilderMain } from '@teambit/builder'; import { compact, merge } from 'lodash'; @@ -9,7 +10,6 @@ import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli'; import { EnvContext, Environment, EnvsAspect, EnvsMain, EnvTransformer } from '@teambit/envs'; import { ReactAspect, ReactMain } from '@teambit/react'; import { GeneratorAspect, GeneratorMain } from '@teambit/generator'; -import { BabelAspect, BabelMain } from '@teambit/babel'; import { ComponentID } from '@teambit/component-id'; import { AspectList } from '@teambit/component'; import { WorkerAspect, WorkerMain } from '@teambit/worker'; @@ -211,7 +211,6 @@ export class AspectMain { BuilderAspect, AspectLoaderAspect, CompilerAspect, - BabelAspect, GeneratorAspect, WorkspaceAspect, CLIAspect, @@ -220,13 +219,12 @@ export class AspectMain { ]; static async provider( - [react, envs, builder, aspectLoader, compiler, babel, generator, workspace, cli, loggerMain, workerMain]: [ + [react, envs, builder, aspectLoader, compiler, generator, workspace, cli, loggerMain, workerMain]: [ ReactMain, EnvsMain, BuilderMain, AspectLoaderMain, CompilerMain, - BabelMain, GeneratorMain, Workspace, CLIMain, @@ -239,11 +237,14 @@ export class AspectMain { ) { const logger = loggerMain.createLogger(AspectAspect.id); - const babelCompiler = babel.createCompiler({ + const options = { babelTransformOptions: babelConfig, distDir: 'dist', distGlobPatterns: [`dist/**`, `!dist/**/*.d.ts`, `!dist/tsconfig.tsbuildinfo`], - }); + }; + + const babelCompiler = BabelCompiler.create(options, { logger }); + const compilerOverride = envs.override({ getCompiler: () => { return babelCompiler; diff --git a/scopes/harmony/bit/load-bit.ts b/scopes/harmony/bit/load-bit.ts index 6d9412f6936e..e182c7df7377 100644 --- a/scopes/harmony/bit/load-bit.ts +++ b/scopes/harmony/bit/load-bit.ts @@ -93,6 +93,10 @@ async function getWsConfig(consumerPath: string, configOpts: ConfigOptions) { if (fileContent.includes('<<<<<<<') || fileContent.includes('>>>>>>>')) { throw new Error(`please fix the conflicts in workspace.jsonc to continue`); } + if (err.constructor.name === 'ReadConfigError' && err.err?.message) { + const location = err.err.line && err.err.column ? ` (${err.err.line}:${err.err.column})` : ''; + throw new Error(`failed parsing the workspace.jsonc file at ${wsPath}. error: ${err.err.toString()}${location}`); + } throw err; } } diff --git a/scopes/harmony/bit/manifests.ts b/scopes/harmony/bit/manifests.ts index 7316082f7a4b..bcd82793f8e7 100644 --- a/scopes/harmony/bit/manifests.ts +++ b/scopes/harmony/bit/manifests.ts @@ -101,6 +101,7 @@ import { StashAspect } from '@teambit/stash'; import { GitAspect } from '@teambit/git'; import { IpcEventsAspect } from '@teambit/ipc-events'; import { ConfigMergerAspect } from '@teambit/config-merger'; +import { VersionHistoryAspect } from '@teambit/version-history'; import { BitAspect } from './bit.aspect'; export const manifestsMap = { @@ -206,6 +207,7 @@ export const manifestsMap = { [GitAspect.id]: GitAspect, [IpcEventsAspect.id]: IpcEventsAspect, [ConfigMergerAspect.id]: ConfigMergerAspect, + [VersionHistoryAspect.id]: VersionHistoryAspect, }; export function isCoreAspect(id: string) { diff --git a/scopes/harmony/cli/cli-parser.ts b/scopes/harmony/cli/cli-parser.ts index ee2b79acda2a..4716a3065a55 100644 --- a/scopes/harmony/cli/cli-parser.ts +++ b/scopes/harmony/cli/cli-parser.ts @@ -11,10 +11,15 @@ import { getCommandId } from './get-command-id'; import { formatHelp } from './help'; import { GLOBAL_GROUP, STANDARD_GROUP, YargsAdapter } from './yargs-adapter'; import { CommandNotFound } from './exceptions/command-not-found'; +import { OnCommandStartSlot } from './cli.main.runtime'; export class CLIParser { public parser = yargs; - constructor(private commands: Command[], private groups: GroupsType) {} + constructor( + private commands: Command[], + private groups: GroupsType, + private onCommandStartSlot: OnCommandStartSlot + ) {} async parse(args = process.argv.slice(2)) { this.throwForNonExistsCommand(args[0]); @@ -138,7 +143,7 @@ export class CLIParser { } private getYargsCommand(command: Command): YargsAdapter { - const yarnCommand = new YargsAdapter(command); + const yarnCommand = new YargsAdapter(command, this.onCommandStartSlot); yarnCommand.builder = yarnCommand.builder.bind(yarnCommand); yarnCommand.handler = yarnCommand.handler.bind(yarnCommand); diff --git a/scopes/harmony/cli/cli.cmd.ts b/scopes/harmony/cli/cli.cmd.ts index ceea2e445a8e..5f12033f6e67 100644 --- a/scopes/harmony/cli/cli.cmd.ts +++ b/scopes/harmony/cli/cli.cmd.ts @@ -64,7 +64,7 @@ export class CliCmd implements Command { completer: (line, cb) => completer(line, cb, this.cliMain), }); - const cliParser = new CLIParser(this.cliMain.commands, this.cliMain.groups); + const cliParser = new CLIParser(this.cliMain.commands, this.cliMain.groups, this.cliMain.onCommandStartSlot); rl.prompt(); diff --git a/scopes/harmony/cli/cli.main.runtime.ts b/scopes/harmony/cli/cli.main.runtime.ts index a916efdacb3a..8f7d9e8274d9 100644 --- a/scopes/harmony/cli/cli.main.runtime.ts +++ b/scopes/harmony/cli/cli.main.runtime.ts @@ -1,7 +1,7 @@ import { Slot, SlotRegistry } from '@teambit/harmony'; import { buildRegistry } from '@teambit/legacy/dist/cli'; import legacyLogger from '@teambit/legacy/dist/logger/logger'; -import { Command } from '@teambit/legacy/dist/cli/command'; +import { CLIArgs, Flags, Command } from '@teambit/legacy/dist/cli/command'; import pMapSeries from 'p-map-series'; import { groups, GroupsType } from '@teambit/legacy/dist/cli/command-groups'; import { loadConsumerIfExist } from '@teambit/legacy/dist/consumer'; @@ -18,9 +18,11 @@ import { VersionCmd } from './version.cmd'; export type CommandList = Array; export type OnStart = (hasWorkspace: boolean, currentCommand: string) => Promise; +export type OnCommandStart = (commandName: string, args: CLIArgs, flags: Flags) => Promise; export type OnBeforeExitFn = () => Promise; export type OnStartSlot = SlotRegistry; +export type OnCommandStartSlot = SlotRegistry; export type CommandsSlot = SlotRegistry; export type OnBeforeExitSlot = SlotRegistry; @@ -29,6 +31,7 @@ export class CLIMain { constructor( private commandsSlot: CommandsSlot, private onStartSlot: OnStartSlot, + readonly onCommandStartSlot: OnCommandStartSlot, private onBeforeExitSlot: OnBeforeExitSlot, private logger: Logger ) {} @@ -86,11 +89,23 @@ export class CLIMain { } } + /** + * onStart is when bootstrapping the CLI. (it happens before onCommandStart) + */ registerOnStart(onStartFn: OnStart) { this.onStartSlot.register(onStartFn); return this; } + /** + * onCommandStart is when a command is about to start and we have the command object and the parsed args and flags + * already. (it happens after onStart) + */ + registerOnCommandStart(onCommandStartFn: OnCommandStart) { + this.onCommandStartSlot.register(onCommandStartFn); + return this; + } + /** * This will register a function to be called before the process exits. * This will run only for "regular" exits @@ -117,7 +132,7 @@ export class CLIMain { */ async run(hasWorkspace: boolean) { await this.invokeOnStart(hasWorkspace); - const CliParser = new CLIParser(this.commands, this.groups); + const CliParser = new CLIParser(this.commands, this.groups, this.onCommandStartSlot); await CliParser.parse(); } @@ -146,15 +161,25 @@ export class CLIMain { static dependencies = [LoggerAspect]; static runtime = MainRuntime; - static slots = [Slot.withType(), Slot.withType(), Slot.withType()]; + static slots = [ + Slot.withType(), + Slot.withType(), + Slot.withType(), + Slot.withType(), + ]; static async provider( [loggerMain]: [LoggerMain], config, - [commandsSlot, onStartSlot, onBeforeExitSlot]: [CommandsSlot, OnStartSlot, OnBeforeExitSlot] + [commandsSlot, onStartSlot, onCommandStartSlot, onBeforeExitSlot]: [ + CommandsSlot, + OnStartSlot, + OnCommandStartSlot, + OnBeforeExitSlot + ] ) { const logger = loggerMain.createLogger(CLIAspect.id); - const cliMain = new CLIMain(commandsSlot, onStartSlot, onBeforeExitSlot, logger); + const cliMain = new CLIMain(commandsSlot, onStartSlot, onCommandStartSlot, onBeforeExitSlot, logger); const legacyRegistry = buildRegistry(); await ensureWorkspaceAndScope(); const legacyCommands = legacyRegistry.commands; diff --git a/scopes/harmony/cli/command-runner.ts b/scopes/harmony/cli/command-runner.ts index 56410919bd66..0e12990e0ca5 100644 --- a/scopes/harmony/cli/command-runner.ts +++ b/scopes/harmony/cli/command-runner.ts @@ -1,4 +1,4 @@ -import logger, { LoggerLevel } from '@teambit/legacy/dist/logger/logger'; +import logger from '@teambit/legacy/dist/logger/logger'; import { CLIArgs, Command, Flags } from '@teambit/legacy/dist/cli/command'; import { parseCommandName } from '@teambit/legacy/dist/cli/command-registry'; import loader from '@teambit/legacy/dist/cli/loader'; @@ -6,10 +6,17 @@ import { handleErrorAndExit } from '@teambit/legacy/dist/cli/handle-errors'; import { TOKEN_FLAG_NAME } from '@teambit/legacy/dist/constants'; import globalFlags from '@teambit/legacy/dist/cli/global-flags'; import { Analytics } from '@teambit/legacy/dist/analytics/analytics'; +import { OnCommandStartSlot } from './cli.main.runtime'; +import pMapSeries from 'p-map-series'; export class CommandRunner { private commandName: string; - constructor(private command: Command, private args: CLIArgs, private flags: Flags) { + constructor( + private command: Command, + private args: CLIArgs, + private flags: Flags, + private onCommandStartSlot: OnCommandStartSlot + ) { this.commandName = parseCommandName(this.command.name); } @@ -19,6 +26,7 @@ export class CommandRunner { async runCommand() { try { this.bootstrapCommand(); + await this.invokeOnCommandStart(); this.determineConsoleWritingDuringCommand(); if (this.flags.json) { return await this.runJsonHandler(); @@ -48,6 +56,11 @@ export class CommandRunner { } } + private async invokeOnCommandStart() { + const funcs = this.onCommandStartSlot.values(); + await pMapSeries(funcs, (onCommandStart) => onCommandStart(this.commandName, this.args, this.flags)); + } + /** * this works for both, Harmony commands and Legacy commands (the legacy-command-adapter * implements json() method) @@ -88,11 +101,6 @@ export class CommandRunner { loader.off(); logger.shouldWriteToConsole = false; } - if (this.flags.log) { - // probably not necessary anymore. it is handled in src/logger - determineWritingLogToScreen() - const logValue = typeof this.flags.log === 'string' ? this.flags.log : undefined; - logger.switchToConsoleLogger(logValue as LoggerLevel); - } } private async writeAndExit(data: string, exitCode: number) { diff --git a/scopes/harmony/cli/yargs-adapter.ts b/scopes/harmony/cli/yargs-adapter.ts index 2ba9c17a98d1..0fde44132565 100644 --- a/scopes/harmony/cli/yargs-adapter.ts +++ b/scopes/harmony/cli/yargs-adapter.ts @@ -3,6 +3,7 @@ import { Arguments, CommandModule, Argv, Options } from 'yargs'; import { TOKEN_FLAG } from '@teambit/legacy/dist/constants'; import { camelCase } from 'lodash'; import { CommandRunner } from './command-runner'; +import { OnCommandStartSlot } from './cli.main.runtime'; export const GLOBAL_GROUP = 'Global'; export const STANDARD_GROUP = 'Options'; @@ -11,7 +12,7 @@ export class YargsAdapter implements CommandModule { command: string; describe?: string; aliases?: string; - constructor(private commanderCommand: Command) { + constructor(private commanderCommand: Command, private onCommandStartSlot: OnCommandStartSlot) { this.command = commanderCommand.name; this.describe = commanderCommand.description; this.aliases = commanderCommand.alias; @@ -43,7 +44,7 @@ export class YargsAdapter implements CommandModule { }, {}); this.commanderCommand._packageManagerArgs = (argv['--'] || []) as string[]; - const commandRunner = new CommandRunner(this.commanderCommand, argsValues, flags); + const commandRunner = new CommandRunner(this.commanderCommand, argsValues, flags, this.onCommandStartSlot); return commandRunner.runCommand(); } diff --git a/scopes/harmony/graphql/create-remote-schemas/create-remote-schemas.ts b/scopes/harmony/graphql/create-remote-schemas/create-remote-schemas.ts index 1284a6b4a554..eaa8c86e68f5 100644 --- a/scopes/harmony/graphql/create-remote-schemas/create-remote-schemas.ts +++ b/scopes/harmony/graphql/create-remote-schemas/create-remote-schemas.ts @@ -1,15 +1,30 @@ -import fetch from 'node-fetch'; -import { setContext } from 'apollo-link-context'; -import { HttpLink } from 'apollo-link-http'; -import { makeRemoteExecutableSchema, introspectSchema } from 'apollo-server'; -import { WebSocketLink } from 'apollo-link-ws'; -import { split, ApolloLink } from 'apollo-link'; -import { getMainDefinition } from 'apollo-utilities'; -import { SubscriptionClient } from 'subscriptions-transport-ws'; +import { ApolloClient, InMemoryCache, HttpLink, split, NormalizedCacheObject, ApolloLink } from '@apollo/client'; +import { WebSocketLink } from '@apollo/client/link/ws'; +import { setContext } from '@apollo/client/link/context'; +import { getMainDefinition } from '@apollo/client/utilities'; +import { fetch as crossFetch } from 'cross-fetch'; +import { getIntrospectionQuery, buildClientSchema, GraphQLSchema } from 'graphql'; +import { wrapSchema } from '@graphql-tools/wrap'; import ws from 'ws'; import { GraphQLServer } from '../graphql-server'; -async function getRemoteSchema({ uri, subscriptionsUri }) { +async function createApolloClient( + uri: string, + subscriptionsUri?: string +): Promise<{ + client: ApolloClient; + remoteSchema: GraphQLSchema; +}> { + const httpLink = new HttpLink({ uri, fetch: crossFetch }); + const introspectionResponse = await crossFetch(uri, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ query: getIntrospectionQuery() }), + }); + + const { data } = await introspectionResponse.json(); + const remoteSchema = buildClientSchema(data); + const wrappingLink = new ApolloLink((operation, forward) => { return forward(operation).map((response) => { const context = operation.getContext(); @@ -19,45 +34,67 @@ async function getRemoteSchema({ uri, subscriptionsUri }) { return response; }); }); - // @ts-ignore - const http = new HttpLink({ uri, fetch }); - const httpLink = setContext((request, previousContext) => { + const contextLink = setContext((_, prevContext) => { return { - headers: previousContext?.graphqlContext?.headers, + headers: prevContext.graphqlContext?.req?.headers, }; - }) - .concat(wrappingLink) - .concat(http); + }); + + const link = contextLink.concat(httpLink).concat(wrappingLink); - if (!subscriptionsUri) { - return makeRemoteExecutableSchema({ - schema: await introspectSchema(httpLink), - link: httpLink, + if (subscriptionsUri) { + const wsLink = new WebSocketLink({ + uri: subscriptionsUri, + options: { reconnect: true }, + webSocketImpl: ws, }); + + const splitLink = split( + ({ query }) => { + const definition = getMainDefinition(query); + return definition.kind === 'OperationDefinition' && definition.operation === 'subscription'; + }, + wsLink, + link + ); + + return { + client: new ApolloClient({ + link: splitLink, + cache: new InMemoryCache(), + }), + remoteSchema, + }; } - // Create WebSocket link with custom client - const client = new SubscriptionClient(subscriptionsUri, { reconnect: true }, ws); - const wsLink = new WebSocketLink(client); + return { + client: new ApolloClient({ + link, + cache: new InMemoryCache(), + }), + remoteSchema, + }; +} - // Using the ability to split links, we can send data to each link - // depending on what kind of operation is being sent - const link = split( - (operation) => { - const definition = getMainDefinition(operation.query); - return definition.kind === 'OperationDefinition' && definition.operation === 'subscription'; - }, - wsLink, - httpLink - ); +async function getRemoteSchema({ + uri, + subscriptionsUri, +}: { + uri: string; + subscriptionsUri?: string; +}): Promise { + const { client, remoteSchema } = await createApolloClient(uri, subscriptionsUri); - return makeRemoteExecutableSchema({ - schema: await introspectSchema(httpLink), - link, + return wrapSchema({ + schema: remoteSchema, + executor: async ({ document, variables }) => { + const fetchResult = await client.query({ query: document, variables, fetchPolicy: 'network-only' }); + return fetchResult; + }, }); } -export async function createRemoteSchemas(servers: GraphQLServer[]) { +export async function createRemoteSchemas(servers: GraphQLServer[]): Promise { const schemasP = servers.map(async (server) => { return getRemoteSchema({ uri: server.uri, diff --git a/scopes/harmony/graphql/graphql-server.ts b/scopes/harmony/graphql/graphql-server.ts index 67d081273b19..9990f72ef995 100644 --- a/scopes/harmony/graphql/graphql-server.ts +++ b/scopes/harmony/graphql/graphql-server.ts @@ -1,5 +1,4 @@ export interface GraphQLServer { uri: string; - subscriptionsUri?: string; } diff --git a/scopes/harmony/graphql/graphql.main.runtime.ts b/scopes/harmony/graphql/graphql.main.runtime.ts index 07719736a9b8..5ac60251b17e 100644 --- a/scopes/harmony/graphql/graphql.main.runtime.ts +++ b/scopes/harmony/graphql/graphql.main.runtime.ts @@ -3,6 +3,7 @@ import { WebSocketServer } from 'ws'; import { ApolloServer } from '@apollo/server'; import { expressMiddleware } from '@apollo/server/express4'; import { ApolloServerPluginDrainHttpServer } from '@apollo/server/plugin/drainHttpServer'; +import { ApolloServerPluginLandingPageDisabled } from '@apollo/server/plugin/disabled'; import { useServer } from 'graphql-ws/lib/use/ws'; import { Module, createModule, createApplication, Application } from 'graphql-modules'; import { MainRuntime } from '@teambit/cli'; @@ -13,6 +14,7 @@ import { Port } from '@teambit/toolbox.network.get-port'; import { PubSubEngine, PubSub } from 'graphql-subscriptions'; import { createServer, Server } from 'http'; import httpProxy from 'http-proxy'; +import compact from 'lodash.compact'; import cors from 'cors'; import { GraphQLServer } from './graphql-server'; import { createRemoteSchemas } from './create-remote-schemas'; @@ -195,18 +197,60 @@ export class GraphqlMain { // } async createServer(options: GraphQLServerOptions) { + const { graphiql = true, disableIntrospection } = options; const app = options.app || express(); const httpServer = createServer(app); const localSchema = this.createRootModule(options.schemaSlot); - const remoteSchemas = await createRemoteSchemas(options.remoteSchemas || this.graphQLServerSlot.values()); - const schemas = [localSchema.schema].concat(remoteSchemas).filter((x) => x); + // const remoteSchemas = await createRemoteSchemas(options.remoteSchemas || this.graphQLServerSlot.values()); + // const schemas = [localSchema.schema].concat(remoteSchemas).filter((x) => x); + const schemas = [localSchema.schema].concat([]).filter((x) => x); const mergedSchema = mergeSchemas({ schemas, }); + // const gateway = new ApolloGateway({ + // supergraphSdl: new IntrospectAndCompose({ + // /** + // * include all the running services in the super-graph. + // */ + // subgraphs: context.services.map((service) => { + // return { + // name: service.appName || '', + // url: service.url || `http://localhost:${service.port}/graphql`, + // }; + // }), + // }), + // }); + const apolloServer = new ApolloServer({ - schema: mergedSchema, - plugins: [ApolloServerPluginDrainHttpServer({ httpServer })], + gateway: { + async load() { + return { executor: localSchema.createApolloExecutor() }; + }, + onSchemaLoadOrUpdate(callback) { + const apiSchema = { apiSchema: localSchema.schema } as any; + callback(apiSchema); + return () => {}; + }, + // eslint-disable-next-line @typescript-eslint/no-empty-function + async stop() {}, + }, + // schema: localSchema.schema, + // schema: localSchema.schema, + plugins: compact([ + ApolloServerPluginDrainHttpServer({ httpServer }), + !graphiql ? ApolloServerPluginLandingPageDisabled() : null, + ]), + introspection: !disableIntrospection, + formatError: (err) => { + this.logger.error('graphql error ', err); + return Object.assign(err, { + // @ts-ignore + ERR_CODE: err?.originalError?.errors?.[0].ERR_CODE || err.originalError?.constructor?.name, + // @ts-ignore + HTTP_CODE: err?.originalError?.errors?.[0].HTTP_CODE || err.originalError?.code, + }); + }, }); await apolloServer.start(); @@ -223,7 +267,12 @@ export class GraphqlMain { ); } - app.use('/graphql', expressMiddleware(apolloServer, {})); + app.use( + '/graphql', + expressMiddleware(apolloServer, { + context: async ({ req }) => req, + }) + ); await this.createSubscription(mergedSchema, httpServer); diff --git a/scopes/lanes/lanes/lane.cmd.ts b/scopes/lanes/lanes/lane.cmd.ts index aa0e482da182..6cea5aa824df 100644 --- a/scopes/lanes/lanes/lane.cmd.ts +++ b/scopes/lanes/lanes/lane.cmd.ts @@ -12,6 +12,7 @@ import { approveOperation } from '@teambit/legacy/dist/prompts'; import { COMPONENT_PATTERN_HELP, DEFAULT_CLOUD_DOMAIN } from '@teambit/legacy/dist/constants'; import { CreateLaneOptions, LanesMain } from './lanes.main.runtime'; import { SwitchCmd } from './switch.cmd'; +import { FetchCmd } from '@teambit/importer'; type LaneOptions = { details?: boolean; @@ -489,7 +490,31 @@ export class LaneImportCmd implements Command { [lane]: [string], { skipDependencyInstallation = false, pattern }: { skipDependencyInstallation: boolean; pattern?: string } ): Promise { - return this.switchCmd.report([lane], { getAll: true, skipDependencyInstallation, pattern }); + return this.switchCmd.report([lane], { skipDependencyInstallation, pattern }); + } +} + +export class LaneFetchCmd implements Command { + name = 'fetch [lane-id]'; + description = `fetch component objects from lanes. if no lane-id is provided, it fetches from the current lane`; + extendedDescription = `note, it does not save the remote lanes objects locally, only the refs`; + alias = ''; + options = [['a', 'all', 'fetch all remote lanes']] as CommandOptions; + loader = true; + + constructor(private fetchCmd: FetchCmd, private lanes: LanesMain) {} + + async report([laneId]: [string], { all }: { all?: boolean }): Promise { + if (all) return this.fetchCmd.report([[]], { lanes: true }); + const getLaneIdStr = () => { + if (laneId) return laneId; + const currentLane = this.lanes.getCurrentLaneId(); + if (!currentLane || currentLane.isDefault()) + throw new BitError('you are not checked out to any lane. please specify a lane-id to fetch or use --all flag'); + return currentLane.toString(); + }; + const lane = getLaneIdStr(); + return this.fetchCmd.report([[lane]], { lanes: true }); } } diff --git a/scopes/lanes/lanes/lanes.main.runtime.ts b/scopes/lanes/lanes/lanes.main.runtime.ts index b5022894ffe1..b5164d740e87 100644 --- a/scopes/lanes/lanes/lanes.main.runtime.ts +++ b/scopes/lanes/lanes/lanes.main.runtime.ts @@ -15,7 +15,7 @@ import { DiffOptions } from '@teambit/legacy/dist/consumer/component-ops/compone import { MergeStrategy, MergeOptions } from '@teambit/legacy/dist/consumer/versions-ops/merge-version'; import { TrackLane } from '@teambit/legacy/dist/scope/scope-json'; import { HistoryItem } from '@teambit/legacy/dist/scope/models/lane-history'; -import { ImporterAspect, ImporterMain } from '@teambit/importer'; +import { FetchCmd, ImporterAspect, ImporterMain } from '@teambit/importer'; import { ComponentIdList, ComponentID } from '@teambit/component-id'; import { InvalidScopeName, isValidScopeName } from '@teambit/legacy-bit-id'; import { ComponentAspect, Component, ComponentMain } from '@teambit/component'; @@ -56,6 +56,7 @@ import { LaneCheckoutCmd, LaneCheckoutOpts, LaneRevertCmd, + LaneFetchCmd, } from './lane.cmd'; import { lanesSchema } from './lanes.graphql'; import { SwitchCmd } from './switch.cmd'; @@ -87,7 +88,7 @@ export type CreateLaneOptions = { export type SwitchLaneOptions = { alias?: string; merge?: MergeStrategy; - getAll?: boolean; + workspaceOnly?: boolean; pattern?: string; skipDependencyInstallation?: boolean; verbose?: boolean; @@ -548,7 +549,7 @@ please create a new lane instead, which will include all components of this lane */ async switchLanes( laneName: string, - { alias, merge, pattern, getAll = false, skipDependencyInstallation = false }: SwitchLaneOptions + { alias, merge, pattern, workspaceOnly, skipDependencyInstallation = false }: SwitchLaneOptions ) { if (!this.workspace) { throw new BitError(`unable to switch lanes outside of Bit workspace`); @@ -567,7 +568,7 @@ please create a new lane instead, which will include all components of this lane const switchProps = { laneName, - existingOnWorkspaceOnly: !getAll, + existingOnWorkspaceOnly: workspaceOnly, pattern, alias, }; @@ -1183,6 +1184,7 @@ please create a new lane instead, which will include all components of this lane checkout ); const switchCmd = new SwitchCmd(lanesMain); + const fetchCmd = new FetchCmd(importer); const laneCmd = new LaneCmd(lanesMain, workspace, scope); laneCmd.commands = [ new LaneListCmd(lanesMain, workspace, scope), @@ -1198,6 +1200,7 @@ please create a new lane instead, which will include all components of this lane new LaneRemoveReadmeCmd(lanesMain), new LaneImportCmd(switchCmd), new LaneRemoveCompCmd(workspace, lanesMain), + new LaneFetchCmd(fetchCmd, lanesMain), ]; if (isFeatureEnabled(SUPPORT_LANE_HISTORY)) { laneCmd.commands.push(new LaneHistoryCmd(lanesMain)); diff --git a/scopes/lanes/lanes/lanes.spec.ts b/scopes/lanes/lanes/lanes.spec.ts index f13440eb314a..abe6fc8499b6 100644 --- a/scopes/lanes/lanes/lanes.spec.ts +++ b/scopes/lanes/lanes/lanes.spec.ts @@ -273,7 +273,7 @@ describe('LanesAspect', function () { newWorkspace = mockWorkspace({ bareScopeName: workspaceData.remoteScopeName }); lanes = await loadAspect(LanesAspect, newWorkspace.workspacePath); - await lanes.switchLanes(laneId.toString(), { skipDependencyInstallation: true, getAll: true }); + await lanes.switchLanes(laneId.toString(), { skipDependencyInstallation: true }); await lanes.importLaneObject(laneId, true, true); }); after(async () => { @@ -296,7 +296,7 @@ describe('LanesAspect', function () { it('should be able to revert to a previous history id', async () => { const revertWorkspace = mockWorkspace({ bareScopeName: workspaceData.remoteScopeName }); lanes = await loadAspect(LanesAspect, revertWorkspace.workspacePath); - await lanes.switchLanes(laneId.toString(), { skipDependencyInstallation: true, getAll: true }); + await lanes.switchLanes(laneId.toString(), { skipDependencyInstallation: true }); await lanes.importLaneObject(laneId, true, true); const laneHistory = await lanes.getLaneHistory(laneId); const history = laneHistory.getHistory(); diff --git a/scopes/lanes/lanes/switch-lanes.ts b/scopes/lanes/lanes/switch-lanes.ts index 93be84c59aba..6719a54602f2 100644 --- a/scopes/lanes/lanes/switch-lanes.ts +++ b/scopes/lanes/lanes/switch-lanes.ts @@ -15,7 +15,7 @@ export type SwitchProps = { ids?: ComponentID[]; laneBitIds?: ComponentID[]; // only needed for the deprecated onLanesOnly prop. once this prop is removed, this prop can be removed as well. pattern?: string; - existingOnWorkspaceOnly: boolean; + existingOnWorkspaceOnly?: boolean; remoteLane?: Lane; localTrackedLane?: string; alias?: string; @@ -30,7 +30,7 @@ export class LaneSwitcher { private logger: Logger, private switchProps: SwitchProps, private checkoutProps: CheckoutProps, - private Lanes: LanesMain + private lanes: LanesMain ) { this.consumer = this.workspace.consumer; } @@ -56,7 +56,7 @@ export class LaneSwitcher { lane: this.laneToSwitchTo, }; - const results = await this.Lanes.checkout.checkout(checkoutProps); + const results = await this.lanes.checkout.checkout(checkoutProps); await this.saveLanesData(); await this.consumer.onDestroy('lane-switch'); @@ -99,7 +99,7 @@ export class LaneSwitcher { this.laneIdToSwitchTo = remoteLaneId; this.logger.debug(`populatePropsAccordingToRemoteLane, remoteLaneId: ${remoteLaneId.toString()}`); this.throwForSwitchingToCurrentLane(); - const remoteLane = await this.Lanes.fetchLaneWithItsComponents(remoteLaneId); + const remoteLane = await this.lanes.fetchLaneWithItsComponents(remoteLaneId); this.switchProps.laneName = remoteLaneId.name; this.switchProps.localTrackedLane = this.consumer.scope.lanes.getAliasByLaneId(remoteLaneId) || undefined; this.switchProps.remoteLane = remoteLane; diff --git a/scopes/lanes/lanes/switch.cmd.ts b/scopes/lanes/lanes/switch.cmd.ts index 6a1fe7eaaaf7..fc72d29cb5ec 100644 --- a/scopes/lanes/lanes/switch.cmd.ts +++ b/scopes/lanes/lanes/switch.cmd.ts @@ -29,7 +29,8 @@ export class SwitchCmd implements Command { 'merge [strategy]', 'merge local changes with the checked out version. strategy should be "theirs", "ours" or "manual"', ], - ['a', 'get-all', 'checkout all components in a lane, including those not currently in the workspace'], + ['a', 'get-all', 'DEPRECATED. this is currently the default behavior'], + ['a', 'workspace-only', 'checkout only the components in the workspace to the selected lane'], ['x', 'skip-dependency-installation', 'do not install dependencies of the imported components'], [ 'p', @@ -49,6 +50,7 @@ ${COMPONENT_PATTERN_HELP}`, alias, merge, getAll = false, + workspaceOnly = false, skipDependencyInstallation = false, pattern, json = false, @@ -56,6 +58,7 @@ ${COMPONENT_PATTERN_HELP}`, alias?: string; merge?: MergeStrategy; getAll?: boolean; + workspaceOnly?: boolean; skipDependencyInstallation?: boolean; override?: boolean; pattern?: string; @@ -65,10 +68,13 @@ ${COMPONENT_PATTERN_HELP}`, const { components, failedComponents, installationError, compilationError } = await this.lanes.switchLanes(lane, { alias, merge, - getAll, + workspaceOnly, pattern, skipDependencyInstallation, }); + if (getAll) { + this.lanes.logger.warn('the --get-all flag is deprecated and currently the default behavior'); + } if (json) { return JSON.stringify({ components, failedComponents }, null, 4); } diff --git a/scopes/lanes/merge-lanes/merge-lanes.main.runtime.ts b/scopes/lanes/merge-lanes/merge-lanes.main.runtime.ts index 5be12e1c018e..3fbd48fbea83 100644 --- a/scopes/lanes/merge-lanes/merge-lanes.main.runtime.ts +++ b/scopes/lanes/merge-lanes/merge-lanes.main.runtime.ts @@ -390,6 +390,9 @@ export class MergeLanesMain { allVersions: false, // no need to export anything else other than the head. the normal calculation of what to export won't apply here // as it is done from the scope. + // @todo: if we merge main to a lane, then no need to export all main history, it'll be fetched later by fetchMissingHistory. + // once a change is done in the exporter about this, uncomment the next line. + // exportHeadsOnly: shouldSquash || fromLaneId.isDefault(), exportHeadsOnly: shouldSquash, // all artifacts must be pushed. otherwise, they'll be missing from the component-scopes. // unless this is a merge from main to a lane, in which case it's not necessary to export the artifacts as @@ -407,7 +410,9 @@ export class MergeLanesMain { options.excludeNonLaneComps = true; options.skipDependencyInstallation = true; this.scope.legacyScope.setCurrentLaneId(toLaneId); - this.scope.legacyScope.scopeImporter.shouldOnlyFetchFromCurrentLane = true; + // this causes issues when merging main to a lane as it fetches from the lane instead of from main. + // see the e2e-test: "main to lane and multiple scopes when a main-version is missing from lane-scope" + // this.scope.legacyScope.scopeImporter.shouldOnlyFetchFromCurrentLane = true; const result = await this.mergeLane(fromLaneId, toLaneId, options as MergeLaneOptions); const { mergeSnapResults, leftUnresolvedConflicts, failedComponents, components, mergeSnapError } = diff --git a/scopes/mdx/mdx/mdx.main.runtime.ts b/scopes/mdx/mdx/mdx.main.runtime.ts index dc6dec948166..7e50a016050a 100644 --- a/scopes/mdx/mdx/mdx.main.runtime.ts +++ b/scopes/mdx/mdx/mdx.main.runtime.ts @@ -1,14 +1,14 @@ import { Harmony } from '@teambit/harmony'; +import { BabelCompiler } from '@teambit/compilation.babel-compiler'; import { TypescriptConfigMutator } from '@teambit/typescript.modules.ts-config-mutator'; import { TsConfigTransformer } from '@teambit/typescript'; -import { BabelAspect, BabelMain } from '@teambit/babel'; import { MainRuntime } from '@teambit/cli'; import { CompilerAspect, CompilerMain } from '@teambit/compiler'; import { DependencyResolverAspect, DependencyResolverMain } from '@teambit/dependency-resolver'; import { DocsAspect, DocsMain } from '@teambit/docs'; import { ComponentID } from '@teambit/component-id'; -import { LoggerMain } from '@teambit/logger'; -import { WorkerMain } from '@teambit/worker'; +import { LoggerAspect, LoggerMain } from '@teambit/logger'; +import { WorkerAspect, WorkerMain } from '@teambit/worker'; import { EnvContext, EnvsAspect, EnvsMain } from '@teambit/envs'; import { MultiCompilerAspect, MultiCompilerMain } from '@teambit/multi-compiler'; import { ReactAspect, ReactEnv, ReactMain } from '@teambit/react'; @@ -56,9 +56,10 @@ export class MDXMain { ReactAspect, EnvsAspect, MultiCompilerAspect, - BabelAspect, CompilerAspect, GeneratorAspect, + LoggerAspect, + WorkerAspect, ]; static defaultConfig = { @@ -66,13 +67,12 @@ export class MDXMain { }; static async provider( - [docs, depResolver, react, envs, multiCompiler, babel, compiler, generator, loggerAspect, workerMain]: [ + [docs, depResolver, react, envs, multiCompiler, compiler, generator, loggerAspect, workerMain]: [ DocsMain, DependencyResolverMain, ReactMain, EnvsMain, MultiCompilerMain, - BabelMain, CompilerMain, GeneratorMain, LoggerMain, @@ -89,11 +89,21 @@ export class MDXMain { return tsconfig; }; const tsCompiler = react.env.getCompiler([tsTransformer]); + const logger = loggerAspect.createLogger(MDXAspect.id); + + const babelCompiler = BabelCompiler.create( + { + babelTransformOptions: babelConfig, + // set the shouldCopyNonSupportedFiles to false since we don't want babel to copy the .mdx file to the dist + // folder (it will conflict with the .mdx.js file created by the mdx compiler) + shouldCopyNonSupportedFiles: false, + }, + { logger } + ); const mdxCompiler = multiCompiler.createCompiler( [ - // set the shouldCopyNonSupportedFiles to false since we don't want babel to copy the .mdx file to the dist folder (it will conflict with the .mdx.js file created by the mdx compiler) - babel.createCompiler({ babelTransformOptions: babelConfig, shouldCopyNonSupportedFiles: false }), + babelCompiler, mdx.createCompiler({ ignoredPatterns: docs.getPatterns(), babelTransformOptions: babelConfig }), tsCompiler, ], diff --git a/scopes/pkg/pkg/publisher.ts b/scopes/pkg/pkg/publisher.ts index 6f44bd17d64e..e86eb340b7f2 100644 --- a/scopes/pkg/pkg/publisher.ts +++ b/scopes/pkg/pkg/publisher.ts @@ -71,7 +71,6 @@ export class Publisher { const componentIdStr = capsule.id.toString(); const errors: string[] = []; - let metadata: TaskMetadata = {}; try { this.logger.off(); // @todo: once capsule.exec works properly, replace this @@ -79,13 +78,17 @@ export class Publisher { await execa(this.packageManager, publishParams, { cwd, stdio: 'inherit' }); this.logger.on(); this.logger.debug(`${componentIdStr}, successfully ran ${this.packageManager} ${publishParamsStr} at ${cwd}`); - const pkg = await fsx.readJSON(`${capsule.path}/package.json`); - metadata = this.options.dryRun ? {} : { publishedPackage: `${pkg.name}@${pkg.version}` }; - } catch (err: any) { - const errorMsg = `failed running ${this.packageManager} ${publishParamsStr} at ${cwd}`; + } catch (err: unknown) { + const errorDetails = typeof err === 'object' && err && 'message' in err ? err.message : err; + const errorMsg = `failed running ${this.packageManager} ${publishParamsStr} at ${cwd}: ${errorDetails}`; this.logger.error(`${componentIdStr}, ${errorMsg}`); errors.push(errorMsg); } + let metadata: TaskMetadata = {}; + if (errors.length === 0 && !this.options.dryRun) { + const pkg = await fsx.readJSON(`${capsule.path}/package.json`); + metadata = { publishedPackage: `${pkg.name}@${pkg.version}` }; + } const component = capsule.component; return { component, metadata, errors, startTime, endTime: Date.now() }; } diff --git a/scopes/react/eslint-config-bit-react/bit-react-eslint.js b/scopes/react/eslint-config-bit-react/bit-react-eslint.js index 128a63e382dd..d3472be8ca9f 100644 --- a/scopes/react/eslint-config-bit-react/bit-react-eslint.js +++ b/scopes/react/eslint-config-bit-react/bit-react-eslint.js @@ -1,8 +1,8 @@ const configs = require('eslint-plugin-mdx/lib/configs'); module.exports = { - extends: ['plugin:jest/recommended'], - plugins: ['jest'], + extends: ['plugin:jest/recommended', 'plugin:import/recommended'], + plugins: ['jest', 'import'], settings: { 'mdx/code-blocks': true, jest: { @@ -17,6 +17,7 @@ module.exports = { browser: true, mocha: true, node: true, + es6: true, }, overrides: [ { @@ -39,6 +40,8 @@ module.exports = { }, rules: { + 'no-useless-constructor': 'off', + '@typescript-eslint/no-useless-constructor': 'off', '@typescript-eslint/camelcase': 'off', 'import/no-extraneous-dependencies': 'off', 'import/prefer-default-export': 'off', diff --git a/scopes/react/react/react.env.ts b/scopes/react/react/react.env.ts index d8c3c9ee019d..028352255dc0 100644 --- a/scopes/react/react/react.env.ts +++ b/scopes/react/react/react.env.ts @@ -1,14 +1,21 @@ import ts, { TsConfigSourceFile } from 'typescript'; import { tmpdir } from 'os'; import { Component } from '@teambit/component'; +import { ESLint as ESLintLib } from 'eslint'; import { ComponentUrl } from '@teambit/component.modules.component-url'; import { BuildTask, CAPSULE_ARTIFACTS_DIR } from '@teambit/builder'; import { merge, cloneDeep } from 'lodash'; import { Bundler, BundlerContext, DevServer, DevServerContext } from '@teambit/bundler'; import { COMPONENT_PREVIEW_STRATEGY_NAME, PreviewStrategyName } from '@teambit/preview'; -import { PrettierConfigWriter } from '@teambit/defender.prettier-formatter'; +import { PrettierConfigWriter, PrettierFormatter } from '@teambit/defender.prettier-formatter'; +import { + PrettierConfigMutator, + PrettierConfigTransformContext, + PrettierConfigTransformer, +} from '@teambit/defender.prettier.config-mutator'; import { TypescriptConfigWriter } from '@teambit/typescript.typescript-compiler'; -import { EslintConfigWriter } from '@teambit/defender.eslint-linter'; +import { EslintConfigWriter, ESLintLinter } from '@teambit/defender.eslint-linter'; +import type { ESLintOptions } from '@teambit/defender.eslint-linter'; import { CompilerMain } from '@teambit/compiler'; import { BuilderEnv, @@ -29,8 +36,11 @@ import { TsConfigTransformer, TypescriptMain } from '@teambit/typescript'; import type { TypeScriptCompilerOptions } from '@teambit/typescript'; import { WebpackConfigTransformer, WebpackMain } from '@teambit/webpack'; import { Workspace } from '@teambit/workspace'; -import { ESLintMain, EslintConfigTransformer } from '@teambit/eslint'; -import { PrettierConfigTransformer, PrettierMain } from '@teambit/prettier'; +import { + EslintConfigMutator, + EslintConfigTransformContext, + EslintConfigTransformer, +} from '@teambit/defender.eslint.config-mutator'; import { DependencyResolverMain } from '@teambit/dependency-resolver'; import { Linter, LinterContext } from '@teambit/linter'; import { Formatter, FormatterContext } from '@teambit/formatter'; @@ -120,10 +130,6 @@ export class ReactEnv private config: ReactMainConfig, - private eslint: ESLintMain, - - private prettier: PrettierMain, - private dependencyResolver: DependencyResolverMain, private logger: Logger, @@ -244,42 +250,45 @@ export class ReactEnv return this.createTsCjsCompiler('dev', transformers, tsModule); } + private getEslintOptions(options: ESLintLib.Options, pluginPath: string, context: LinterContext): ESLintOptions { + const mergedConfig: ESLintLib.Options = { + // @ts-ignore - this is a bug in the @types/eslint types + overrideConfig: options, + extensions: context.extensionFormats, + useEslintrc: false, + // TODO: this should be probably be replaced with resolve-plugins-relative-to + // https://eslint.org/docs/latest/use/command-line-interface#--resolve-plugins-relative-to + cwd: pluginPath, + fix: !!context.fix, + fixTypes: context.fixTypes, + }; + return Object.assign({}, options, { config: mergedConfig, extensions: context.extensionFormats }); + } + /** * returns and configures the component linter. */ getLinter(context: LinterContext, transformers: EslintConfigTransformer[] = []): Linter { - const tsConfig = this.createTsCompilerOptions('dev').tsconfig; - - const defaultTransformer: EslintConfigTransformer = (configMutator) => { - configMutator.addExtensionTypes(['.md', '.mdx']); - configMutator.setTsConfig(tsConfig); - return configMutator; - }; + const tsconfigPath = require.resolve('./typescript/tsconfig.json'); - const allTransformers = [defaultTransformer, ...transformers]; - - return this.eslint.createLinter( - context, - { - config: eslintConfig, - // resolve all plugins from the react environment. - pluginPath: __dirname, - }, - allTransformers - ); + // resolve all plugins from the react environment. + const mergedOptions = this.getEslintOptions(eslintConfig, __dirname, context); + const configMutator = new EslintConfigMutator(mergedOptions); + const transformerContext: EslintConfigTransformContext = { fix: !!context.fix }; + configMutator.addExtensionTypes(['.md', '.mdx']); + configMutator.setTsConfig(tsconfigPath); + const afterMutation = runTransformersWithContext(configMutator.clone(), transformers, transformerContext); + return ESLintLinter.create(afterMutation.raw, { logger: this.logger }); } /** * returns and configures the component formatter. */ getFormatter(context: FormatterContext, transformers: PrettierConfigTransformer[] = []): Formatter { - return this.prettier.createFormatter( - { check: context?.check }, - { - config: prettierConfig, - }, - transformers - ); + const configMutator = new PrettierConfigMutator(prettierConfig); + const transformerContext: PrettierConfigTransformContext = { check: !!context?.check }; + const afterMutation = runTransformersWithContext(configMutator.clone(), transformers, transformerContext); + return PrettierFormatter.create({ config: afterMutation.raw }, { logger: this.logger }); } private getFileMap(components: Component[], local = false) { @@ -462,9 +471,6 @@ export class ReactEnv } getNpmIgnore() { - // ignores only .ts files in the root directory, so d.ts files inside dists are unaffected. - // without this change, the package has "index.ts" file in the root, causing typescript to parse it instead of the - // d.ts files. (changing the "types" prop in the package.json file doesn't help). return [`${CAPSULE_ARTIFACTS_DIR}/`]; } @@ -590,3 +596,11 @@ export class ReactEnv }; } } + +export function runTransformersWithContext(config: P, transformers: T[] = [], context: C): P { + if (!Array.isArray(transformers)) return config; + const newConfig = transformers.reduce((acc, transformer) => { + return transformer(acc, context); + }, config); + return newConfig; +} diff --git a/scopes/react/react/react.main.runtime.ts b/scopes/react/react/react.main.runtime.ts index c092da36b844..99c492a6f659 100644 --- a/scopes/react/react/react.main.runtime.ts +++ b/scopes/react/react/react.main.runtime.ts @@ -28,8 +28,7 @@ import { ApplicationAspect, ApplicationMain } from '@teambit/application'; import { FormatterContext } from '@teambit/formatter'; import { LinterContext } from '@teambit/linter'; import { Logger, LoggerAspect, LoggerMain } from '@teambit/logger'; -import { ESLintMain, ESLintAspect, EslintConfigTransformer } from '@teambit/eslint'; -import { PrettierMain, PrettierAspect, PrettierConfigTransformer } from '@teambit/prettier'; +import { EslintConfigTransformer } from '@teambit/defender.eslint.config-mutator'; import { WorkerAspect, WorkerMain } from '@teambit/worker'; import { ReactAspect } from './react.aspect'; @@ -40,6 +39,7 @@ import { getTemplates } from './react.templates'; import { ReactAppOptions } from './apps/web/react-app-options'; import { ReactSchema } from './react.schema'; import { ReactAPITransformer } from './react.api.transformer'; +import { PrettierConfigTransformer } from '@teambit/defender.prettier.config-mutator'; type ReactDeps = [ EnvsMain, @@ -51,8 +51,6 @@ type ReactDeps = [ GraphqlMain, PkgMain, TesterMain, - ESLintMain, - PrettierMain, ApplicationMain, GeneratorMain, DependencyResolverMain, @@ -410,8 +408,6 @@ export class ReactMain { GraphqlAspect, PkgAspect, TesterAspect, - ESLintAspect, - PrettierAspect, ApplicationAspect, GeneratorAspect, DependencyResolverAspect, @@ -431,8 +427,6 @@ export class ReactMain { graphql, pkg, tester, - eslint, - prettier, application, generator, dependencyResolver, @@ -454,8 +448,6 @@ export class ReactMain { pkg, tester, config, - eslint, - prettier, dependencyResolver, logger, CompilerAspect.id diff --git a/scopes/scope/export/export-cmd.ts b/scopes/scope/export/export-cmd.ts index b6b0bdff1053..9c7a21dc5f39 100644 --- a/scopes/scope/export/export-cmd.ts +++ b/scopes/scope/export/export-cmd.ts @@ -94,9 +94,9 @@ export class ExportCmd implements Command { } const exportOutput = () => { if (isEmpty(componentsIds)) return ''; - const lanesOutput = exportedLanes.length ? ` from lane ${chalk.bold(exportedLanes[0].name)}` : ''; + const lanesOutput = exportedLanes.length ? ` the lane ${chalk.bold(exportedLanes[0].id())} and` : ''; return chalk.green( - `exported the following ${componentsIds.length} component(s)${lanesOutput}:\n${chalk.bold( + `exported${lanesOutput} the following ${componentsIds.length} component(s):\n${chalk.bold( componentsIds.join('\n') )}` ); diff --git a/scopes/scope/importer/dependents-getter.ts b/scopes/scope/importer/dependents-getter.ts index f507ad135c7e..aac467ff400e 100644 --- a/scopes/scope/importer/dependents-getter.ts +++ b/scopes/scope/importer/dependents-getter.ts @@ -23,7 +23,7 @@ export class DependentsGetter { async getDependents(targetCompIds: ComponentID[]): Promise { this.logger.setStatusLine('finding dependents'); - const { silent } = this.options; + const { silent, dependentsAll } = this.options; const graph = await this.graph.getGraphIds(); const sourceIds = this.workspace.listIds(); const getIdsForThrough = () => { @@ -34,7 +34,7 @@ export class DependentsGetter { .map((id) => ComponentID.fromString(id)); }; const allPaths = graph.findAllPathsFromSourcesToTargets(sourceIds, targetCompIds, getIdsForThrough()); - const selectedPaths = silent ? allPaths : await this.promptDependents(allPaths); + const selectedPaths = silent || dependentsAll ? allPaths : await this.promptDependents(allPaths); const uniqAsStrings = uniq(selectedPaths.flat()); const ids: ComponentID[] = []; @@ -72,7 +72,7 @@ export class DependentsGetter { this.logger.clearStatusLine(); const totalToShow = SHOW_ALL_PATHS_LIMIT; - if (allPaths.length >= totalToShow) { + if (allPaths.length > totalToShow) { return this.promptLevelByLevel(allPaths); } const firstItems = allPaths.slice(0, totalToShow); diff --git a/scopes/scope/importer/fetch-cmd.ts b/scopes/scope/importer/fetch-cmd.ts index 3b0186d05205..b493b649a148 100644 --- a/scopes/scope/importer/fetch-cmd.ts +++ b/scopes/scope/importer/fetch-cmd.ts @@ -2,7 +2,7 @@ import chalk from 'chalk'; import { Command, CommandOptions } from '@teambit/cli'; import { ComponentID } from '@teambit/component-id'; import { FileStatus } from '@teambit/legacy/dist/consumer/versions-ops/merge-version/merge-version'; -import { ImporterMain } from './importer.main.runtime'; +import type { ImporterMain } from './importer.main.runtime'; import { ImportDetails, ImportStatus } from './import-components'; export class FetchCmd implements Command { diff --git a/scopes/scope/importer/import-components.ts b/scopes/scope/importer/import-components.ts index 8abd8a144f61..37e23322bba0 100644 --- a/scopes/scope/importer/import-components.ts +++ b/scopes/scope/importer/import-components.ts @@ -25,7 +25,6 @@ import VersionDependencies, { multipleVersionDependenciesToConsumer, } from '@teambit/legacy/dist/scope/version-dependencies'; import { GraphMain } from '@teambit/graph'; -import { UPDATE_DEPS_ON_IMPORT, isFeatureEnabled } from '@teambit/legacy/dist/api/consumer/lib/feature-toggle'; import { Workspace } from '@teambit/workspace'; import { ComponentWriterMain, ComponentWriterResults, ManyComponentsWriterParams } from '@teambit/component-writer'; import { LATEST_VERSION } from '@teambit/component-version'; @@ -51,6 +50,7 @@ export type ImportOptions = { importDependenciesDirectly?: boolean; // default: false, normally it imports them as packages, not as imported importDependents?: boolean; dependentsVia?: string; + dependentsAll?: boolean; silent?: boolean; // don't show prompt for --dependents flag fromOriginalScope?: boolean; // default: false, otherwise, it fetches flattened dependencies from their dependents saveInLane?: boolean; // save the imported component on the current lane (won't be available on main) @@ -442,7 +442,8 @@ bit import ${idsFromRemote.map((id) => id.toStringWithoutVersion()).join(' ')}`) const bitIds: ComponentID[] = this.options.lanes ? await this.getBitIdsForLanes() : await this.getBitIdsForNonLanes(); - const shouldImportDependents = this.options.importDependents || this.options.dependentsVia; + const shouldImportDependents = + this.options.importDependents || this.options.dependentsVia || this.options.dependentsAll; if (this.options.importDependenciesDirectly || shouldImportDependents) { if (this.options.importDependenciesDirectly) { const dependenciesIds = await this.getFlattenedDepsUnique(bitIds); @@ -617,9 +618,10 @@ to write the components from .bitmap file according to the their remote, please ids.forEach((id: ComponentID) => { const existingId = this.consumer.getParsedIdIfExist(id.toStringWithoutVersion()); if (existingId && !existingId.hasScope()) { - throw new BitError(`unable to import ${id.toString()}. the component name conflicted with your local component with the same name. - it's fine to have components with the same name as long as their scope names are different. - Make sure to export your component first to get a scope and then try importing again`); + throw new BitError(`unable to import ${id.toString()}. the component name conflicted with your local (new/staged) component with the same name. +it's fine to have components with the same name as long as their scope names are different. +if the component was created by mistake, remove it and import the remote one. +otherwise, if tagged/snapped, "bit reset" it, then bit rename it.`); } }); } @@ -773,7 +775,7 @@ to write the components from .bitmap file according to the their remote, please verbose: this.options.verbose, throwForExistingDir: !this.options.override, skipWritingToFs: this.options.trackOnly, - shouldUpdateWorkspaceConfig: isFeatureEnabled(UPDATE_DEPS_ON_IMPORT), + shouldUpdateWorkspaceConfig: true, reasonForBitmapChange: 'import', }; return this.componentWriter.writeMany(manyComponentsWriterOpts); diff --git a/scopes/scope/importer/import.cmd.ts b/scopes/scope/importer/import.cmd.ts index f4ec2105a65b..cd0b57f96888 100644 --- a/scopes/scope/importer/import.cmd.ts +++ b/scopes/scope/importer/import.cmd.ts @@ -31,6 +31,7 @@ type ImportFlags = { dependents?: boolean; dependentsDryRun?: boolean; dependentsVia?: string; + dependentsAll?: boolean; silent?: boolean; allHistory?: boolean; fetchDeps?: boolean; @@ -85,6 +86,11 @@ export class ImportCmd implements Command { 'dependents-via ', 'same as --dependents except the traversal must go through the specified component. to specify multiple components, wrap with quotes and separate by a comma', ], + [ + '', + 'dependents-all', + 'same as --dependents except not prompting for selecting paths but rather selecting all paths and showing final confirmation before importing', + ], [ '', 'dependents-dry-run', @@ -155,14 +161,10 @@ export class ImportCmd implements Command { return formatPlainComponentItemWithVersions(bitId, details); }); const getWsConfigUpdateLogs = () => { - // @TODO: uncomment the line below once UPDATE_DEPS_ON_IMPORT is enabled by default - // if (!importFlags.verbose) return ''; const logs = workspaceConfigUpdateResult?.logs; if (!logs || !logs.length) return ''; const logsStr = logs.join('\n'); - return `${chalk.underline( - 'verbose logs of workspace config update' - )}\n(this is temporarily. once this feature is enabled, use --verbose to see these logs)\n${logsStr}`; + return `${chalk.underline('verbose logs of workspace config update')}\n${logsStr}`; }; const upToDateSuffix = lane ? ' on the lane' : ''; const upToDateStr = upToDateCount === 0 ? '' : `, ${upToDateCount} components are up to date${upToDateSuffix}`; @@ -214,6 +216,7 @@ export class ImportCmd implements Command { dependentsDryRun = false, silent, dependentsVia, + dependentsAll, allHistory = false, fetchDeps = false, trackOnly = false, @@ -268,6 +271,7 @@ export class ImportCmd implements Command { importDependenciesDirectly: dependencies, importDependents: dependents, dependentsVia, + dependentsAll, silent, allHistory, fetchDeps, @@ -295,7 +299,9 @@ function formatPlainComponentItemWithVersions(bitId: ComponentID, importDetails: if (importDetails.latestVersion) { return `${importDetails.versions.length} new version(s) available, latest ${importDetails.latestVersion}`; } - return `new versions: ${importDetails.versions.join(', ')}`; + return importDetails.versions.length > 5 + ? `${importDetails.versions.length} new versions` + : `new versions: ${importDetails.versions.join(', ')}`; }; const versions = getVersionsOutput(); const usedVersion = status === 'added' ? `, currently used version ${bitId.version}` : ''; diff --git a/scopes/scope/importer/index.ts b/scopes/scope/importer/index.ts index 043effc82a0e..277b2eb0d52f 100644 --- a/scopes/scope/importer/index.ts +++ b/scopes/scope/importer/index.ts @@ -1,5 +1,6 @@ import { ImporterAspect } from './importer.aspect'; +export { FetchCmd } from './fetch-cmd'; export type { ImportOptions } from './import-components'; export type { ImporterMain } from './importer.main.runtime'; export default ImporterAspect; diff --git a/scopes/scope/sign/sign.main.runtime.ts b/scopes/scope/sign/sign.main.runtime.ts index e5424b8990c1..08eeab4c603a 100644 --- a/scopes/scope/sign/sign.main.runtime.ts +++ b/scopes/scope/sign/sign.main.runtime.ts @@ -86,7 +86,7 @@ ${componentsToSkip.map((c) => c.toString()).join('\n')}\n`); // using `loadMany` instead of `getMany` to make sure component aspects are loaded. this.logger.setStatusLine(`loading ${componentsToSign.length} components and their aspects...`); - const components = await this.scope.loadMany(componentsToSign, lane, { loadApps: false, loadEnvs: false }); + const components = await this.scope.loadMany(componentsToSign, lane, { loadApps: false, loadEnvs: true }); this.logger.clearStatusLine(); // it's enough to check the first component whether it's a snap or tag, because it can't be a mix of both const shouldRunSnapPipeline = isSnap(components[0].id.version); diff --git a/scopes/scope/update-dependencies/update-dependencies.cmd.ts b/scopes/scope/update-dependencies/update-dependencies.cmd.ts index 1eee4973b014..b377f6b69218 100644 --- a/scopes/scope/update-dependencies/update-dependencies.cmd.ts +++ b/scopes/scope/update-dependencies/update-dependencies.cmd.ts @@ -19,6 +19,7 @@ the input data is a stringified JSON of an array of the following object. componentId: string; // ids always have scope, so it's safe to parse them from string dependencies: string[]; // e.g. [teambit/compiler@1.0.0, teambit/tester@1.0.0] versionToTag?: string; // specific version (e.g. '1.0.0') or semver (e.g. 'minor', 'patch') + versionToSnap?: string; // specific hash to snap } an example of the final data: '[{"componentId":"ci.remote2/comp-b","dependencies":["ci.remote/comp1@0.0.2"]}]' `; diff --git a/scopes/scope/update-dependencies/update-dependencies.main.runtime.ts b/scopes/scope/update-dependencies/update-dependencies.main.runtime.ts index a39879cb7af2..7d5d1d375e26 100644 --- a/scopes/scope/update-dependencies/update-dependencies.main.runtime.ts +++ b/scopes/scope/update-dependencies/update-dependencies.main.runtime.ts @@ -18,6 +18,8 @@ import { LanesAspect, Lane, LanesMain } from '@teambit/lanes'; import { ExtensionDataEntry } from '@teambit/legacy/dist/consumer/config'; import { UpdateDependenciesCmd } from './update-dependencies.cmd'; import { UpdateDependenciesAspect } from './update-dependencies.aspect'; +import { Ref } from '@teambit/legacy/dist/scope/objects'; +import { isSnap } from '@teambit/component-version'; export type UpdateDepsOptions = { tag?: boolean; @@ -35,12 +37,14 @@ export type DepUpdateItemRaw = { componentId: string; // ids always have scope, so it's safe to parse them from string dependencies: string[]; // e.g. [@teambit/compiler@~1.0.0, @teambit/tester@^1.0.0] versionToTag?: string; // specific version or semver. e.g. '1.0.0', 'minor', + versionToSnap?: string; }; export type DepUpdateItem = { component: Component; dependencies: ComponentID[]; versionToTag?: string; + versionToSnap?: string; }; export type UpdateDepsResult = { @@ -229,7 +233,7 @@ to bypass this error, use --skip-new-scope-validation flag (not recommended. it const dependencies = await Promise.all( depUpdateItemRaw.dependencies.map((dep) => this.getDependencyWithExactVersion(dep)) ); - return { component, dependencies, versionToTag: depUpdateItemRaw.versionToTag }; + return { ...depUpdateItemRaw, component, dependencies }; }); } @@ -253,7 +257,21 @@ to bypass this error, use --skip-new-scope-validation flag (not recommended. it legacyComp.setNewVersion(modelComponent.getVersionToAdd(releaseType, exactVersion)); } else { // snap is the default - legacyComp.setNewVersion(); + if (depUpdateItem.versionToSnap) { + if (!isSnap(depUpdateItem.versionToSnap)) { + throw new Error( + `update-dependencies command received an invalid version ${depUpdateItem.versionToSnap} to snap. make sure it's a string, Hex and 40 characters long.` + ); + } + const exist = await this.scope.legacyScope.objects.has(Ref.from(depUpdateItem.versionToSnap)); + if (exist) + throw new Error( + `unable to snap ${depUpdateItem.component.id.toStringWithoutVersion()} with the specified hash ${ + depUpdateItem.versionToSnap + }, it's already exists in the scope` + ); + } + legacyComp.setNewVersion(depUpdateItem.versionToSnap); } }); } diff --git a/scopes/typescript/typescript/transformers/array-literal-expression.ts b/scopes/typescript/typescript/transformers/array-literal-expression.ts index 8ff815b2c318..4233fca29cf0 100644 --- a/scopes/typescript/typescript/transformers/array-literal-expression.ts +++ b/scopes/typescript/typescript/transformers/array-literal-expression.ts @@ -5,7 +5,8 @@ import { } from '@teambit/semantics.entities.semantic-schema'; import pMapSeries from 'p-map-series'; import ts, { ArrayLiteralExpression, Node } from 'typescript'; -import { SchemaExtractorContext, SchemaTransformer } from '..'; +import type { SchemaExtractorContext } from '../schema-extractor-context'; +import { SchemaTransformer } from '../schema-transformer'; import { Identifier } from '../identifier'; export class ArrayLiteralExpressionTransformer implements SchemaTransformer { diff --git a/scopes/typescript/typescript/transformers/literal-value.ts b/scopes/typescript/typescript/transformers/literal-value.ts index cde3fdc35fc8..1748ac9393eb 100644 --- a/scopes/typescript/typescript/transformers/literal-value.ts +++ b/scopes/typescript/typescript/transformers/literal-value.ts @@ -1,6 +1,7 @@ import { LiteralValueSchema, SchemaNode } from '@teambit/semantics.entities.semantic-schema'; import ts, { Node, StringLiteral } from 'typescript'; -import { SchemaExtractorContext, SchemaTransformer } from '..'; +import type { SchemaExtractorContext } from '../schema-extractor-context'; +import { SchemaTransformer } from '../schema-transformer'; import { Identifier } from '../identifier'; export type LiteralValueNode = diff --git a/scopes/typescript/typescript/transformers/object-literal-expression.ts b/scopes/typescript/typescript/transformers/object-literal-expression.ts index e4c0a72fd33a..177cc4bd1662 100644 --- a/scopes/typescript/typescript/transformers/object-literal-expression.ts +++ b/scopes/typescript/typescript/transformers/object-literal-expression.ts @@ -1,7 +1,8 @@ import ts, { Node, ObjectLiteralExpression } from 'typescript'; import pMapSeries from 'p-map-series'; import { ObjectLiteralExpressionSchema, UnImplementedSchema } from '@teambit/semantics.entities.semantic-schema'; -import { SchemaExtractorContext, SchemaTransformer } from '..'; +import type { SchemaExtractorContext } from '../schema-extractor-context'; +import { SchemaTransformer } from '../schema-transformer'; export class ObjectLiteralExpressionTransformer implements SchemaTransformer { predicate(node: Node) { diff --git a/scopes/ui-foundation/ui/bundle-ui.task.ts b/scopes/ui-foundation/ui/bundle-ui.task.ts index 9e23d55455de..7ee4b9ec2f86 100644 --- a/scopes/ui-foundation/ui/bundle-ui.task.ts +++ b/scopes/ui-foundation/ui/bundle-ui.task.ts @@ -1,6 +1,6 @@ import { join } from 'path'; import { existsSync, mkdirSync, writeFileSync } from 'fs'; -import { BuildContext, BuildTask, BuiltTaskResult, TaskLocation } from '@teambit/builder'; +import type { BuildContext, BuildTask, BuiltTaskResult, TaskLocation } from '@teambit/builder'; import { Capsule } from '@teambit/isolator'; import { Logger } from '@teambit/logger'; import { UIAspect } from './ui.aspect'; diff --git a/scopes/ui-foundation/ui/start.cmd.tsx b/scopes/ui-foundation/ui/start.cmd.tsx index 743c5304c06c..d80799f8b4d8 100644 --- a/scopes/ui-foundation/ui/start.cmd.tsx +++ b/scopes/ui-foundation/ui/start.cmd.tsx @@ -94,10 +94,10 @@ export class StartCmd implements Command { uiServer .then(async (server) => { - if (!server.buildOptions?.launchBrowserOnStart) return undefined; const url = this.ui.publicUrl || server.fullUrl; - spinnies.succeed('ui-server', { text: `UI server is ready at ${chalk.cyan(url)}` }); + if (!server.buildOptions?.launchBrowserOnStart) return undefined; + await server.whenReady; const name = server.getName(); const message = chalk.green(`You can now view '${chalk.cyan(name)}' components in the browser. diff --git a/scopes/workspace/install/install.main.runtime.ts b/scopes/workspace/install/install.main.runtime.ts index bbd258609478..db65e0ab9b94 100644 --- a/scopes/workspace/install/install.main.runtime.ts +++ b/scopes/workspace/install/install.main.runtime.ts @@ -320,6 +320,7 @@ export class InstallMain { neverBuiltDependencies: this.dependencyResolver.config.neverBuiltDependencies, overrides: this.dependencyResolver.config.overrides, hoistPatterns: this.dependencyResolver.config.hoistPatterns, + hoistInjectedDependencies: this.dependencyResolver.config.hoistInjectedDependencies, packageImportMethod: this.dependencyResolver.config.packageImportMethod, rootComponents: hasRootComponents, updateAll: options?.updateAll, diff --git a/scopes/workspace/modules/node-modules-linker/node-modules-linker.ts b/scopes/workspace/modules/node-modules-linker/node-modules-linker.ts index c1aca9f2e229..e0b113f6cc1e 100644 --- a/scopes/workspace/modules/node-modules-linker/node-modules-linker.ts +++ b/scopes/workspace/modules/node-modules-linker/node-modules-linker.ts @@ -52,7 +52,11 @@ export default class NodeModuleLinker { const workspacePath = this.workspace.path; links.addBasePath(workspacePath); await links.persistAllToFS(); - await this.consumer?.componentFsCache.deleteAllDependenciesDataCache(); + await Promise.all( + this.components.map((component) => + this.consumer?.componentFsCache.deleteDependenciesDataCache(component.id.toString()) + ) + ); // if this cache is not cleared, then when asking workspace.get again to the same component, it returns it with // component-issues like "MissingLinksFromNodeModulesToSrc" incorrectly. this.workspace.clearAllComponentsCache(); diff --git a/scopes/workspace/watcher/output-formatter.ts b/scopes/workspace/watcher/output-formatter.ts index 07c993ac0738..be7a2bfb6b29 100644 --- a/scopes/workspace/watcher/output-formatter.ts +++ b/scopes/workspace/watcher/output-formatter.ts @@ -1,51 +1,25 @@ import { Logger } from '@teambit/logger'; +import { CompilerAspect } from '@teambit/compiler'; import { OnComponentEventResult } from '@teambit/workspace'; import chalk from 'chalk'; +import { RootDirs } from './watcher'; +import { compact } from 'lodash'; -const verboseComponentFilesArrayToString = (componentFiles = []) => { - return componentFiles.reduce((outputString, filePath) => `${outputString} \t - ${filePath}\n`, ``); -}; - -const resultsForExtensionArrayToString = (resultsForExtension, verbose) => { - return resultsForExtension.reduce( - (outputString, resultForExtension) => - `${outputString}${Logger.successSymbol()}SUCCESS\t${resultForExtension.component}\n - ${verbose ? resultForExtension.componentFilesAsString : ''}\n`, - '' - ); -}; - -export const formatWatchPathsSortByComponent = (trackDirs) => { - return Object.keys(trackDirs).reduce( - (outputString, watchPath) => - `${outputString} - ${Logger.successSymbol()} SUCCESS\t${trackDirs[watchPath]}\n - \t - ${watchPath}\n\n`, - ` ${chalk.underline('STATUS\t\tCOMPONENT ID')}\n` - ); -}; +export function formatWatchPathsSortByComponent(trackDirs: RootDirs) { + const title = ` ${chalk.underline('STATUS\tCOMPONENT ID')}\n`; + return Object.keys(trackDirs).reduce((outputString, watchPath) => { + const componentId = trackDirs[watchPath]; + const formattedWatchPath = `\t\t - ${watchPath}\n`; + return `${outputString}${Logger.successSymbol()} SUCCESS\t${componentId}\n${formattedWatchPath}`; + }, title); +} -/** - * todo: this was implemented incorrectly. - * the original idea of `SerializableResults` was to have each one of the aspects registered to the slot, the - * ability to have their own formatting to their results, and then `toString()` method to print them. - * Here, the printing is specifically to the Compiler aspect. It should move to where it belongs. - */ -export function formatCompileResults(compileResults: OnComponentEventResult[], verbose: boolean) { - if (!compileResults.length || !Array.isArray(compileResults)) return ''; - return compileResults - .filter((compileResult) => compileResult.results?.results && Array.isArray(compileResult.results?.results)) - .map((compileResult) => ({ - extensionId: compileResult.extensionId, - resultsForExtension: compileResult.results?.results?.map((resultForExtension) => ({ - component: resultForExtension.component, - componentFilesAsString: verboseComponentFilesArrayToString(resultForExtension.buildResults), - })), - })) - .reduce( - (outputString, compileResult) => - `${outputString} - ${resultsForExtensionArrayToString(compileResult.resultsForExtension, verbose)}`, - ` ${chalk.underline('STATUS\tCOMPONENT ID')}` - ); +export function formatCompileResults(compileResults: OnComponentEventResult[]) { + if (!compileResults.length) return ''; + return compact( + compileResults + // currently, we are interested only in the compiler results + .filter((compileResult) => compileResult.extensionId === CompilerAspect.id) + .map((compileResult) => compileResult.results.toString()) + ).join('\n'); } diff --git a/scopes/workspace/watcher/watch.cmd.ts b/scopes/workspace/watcher/watch.cmd.ts index af59c425b1b5..683505bee2a1 100644 --- a/scopes/workspace/watcher/watch.cmd.ts +++ b/scopes/workspace/watcher/watch.cmd.ts @@ -3,12 +3,12 @@ import moment from 'moment'; import { Command, CommandOptions } from '@teambit/cli'; import type { Logger } from '@teambit/logger'; import type { BitBaseEvent, PubsubMain } from '@teambit/pubsub'; -import { OnComponentEventResult } from '@teambit/workspace'; +import { OnComponentEventResult, Workspace } from '@teambit/workspace'; // import IDs and events import { CompilerAspect, CompilerErrorEvent } from '@teambit/compiler'; -import { EventMessages, WatchOptions } from './watcher'; +import { EventMessages, RootDirs, WatchOptions } from './watcher'; import { formatCompileResults, formatWatchPathsSortByComponent } from './output-formatter'; import { CheckTypes } from './check-types'; import { WatcherMain } from './watcher.main.runtime'; @@ -102,14 +102,14 @@ function getMessages(logger: Logger): EventMessages { return { onAll: (event: string, path: string) => logger.console(`Event: "${event}". Path: ${path}`), onStart: () => {}, - onReady: (workspace, watchPathsSortByComponent, verbose?: boolean) => { + onReady: (workspace: Workspace, watchPathsSortByComponent: RootDirs, verbose?: boolean) => { clearOutdatedData(); if (verbose) { logger.console(formatWatchPathsSortByComponent(watchPathsSortByComponent)); } logger.console( chalk.yellow( - `Watching for component changes in workspace ${workspace.config.name} (${moment().format('HH:mm:ss')})...\n` + `Watching for component changes in workspace ${workspace.name} (${moment().format('HH:mm:ss')})...\n` ) ); }, @@ -146,9 +146,9 @@ function printOnFileEvent( logger.console(`${failureMsg}\n\n`); return; } - logger.console(`The file(s) ${files} have been ${eventMsgPlaceholder}.\n\n`); - logger.console(formatCompileResults(buildResults, verbose)); - logger.console(`Finished. (${duration}ms)`); + logger.console(`The file(s) ${files} have been ${eventMsgPlaceholder}.\n`); + logger.console(formatCompileResults(buildResults)); + logger.console(`Finished (${duration}ms).`); logger.console(chalk.yellow(`Watching for component changes (${moment().format('HH:mm:ss')})...`)); } diff --git a/scopes/workspace/watcher/watcher.main.runtime.ts b/scopes/workspace/watcher/watcher.main.runtime.ts index 180959a4b7e9..d7908d9e8b9d 100644 --- a/scopes/workspace/watcher/watcher.main.runtime.ts +++ b/scopes/workspace/watcher/watcher.main.runtime.ts @@ -6,7 +6,7 @@ import { ComponentID } from '@teambit/component-id'; import { IpcEventsAspect, IpcEventsMain } from '@teambit/ipc-events'; import { Logger, LoggerAspect, LoggerMain } from '@teambit/logger'; import { PubsubAspect, PubsubMain } from '@teambit/pubsub'; -import { WorkspaceAspect, Workspace } from '@teambit/workspace'; +import { WorkspaceAspect, Workspace, OutsideWorkspaceError } from '@teambit/workspace'; import pMapSeries from 'p-map-series'; import { WatchCommand } from './watch.cmd'; import { Watcher, WatchOptions } from './watcher'; @@ -27,6 +27,7 @@ export class WatcherMain { ) {} async watch(opts: WatchOptions) { + if (!this.workspace) throw new OutsideWorkspaceError(); const watcher = new Watcher(this.workspace, this.pubsub, this, opts); await watcher.watch(); } diff --git a/scopes/workspace/watcher/watcher.ts b/scopes/workspace/watcher/watcher.ts index 22ec548e577a..f0a33c05a3f0 100644 --- a/scopes/workspace/watcher/watcher.ts +++ b/scopes/workspace/watcher/watcher.ts @@ -58,6 +58,8 @@ export type WatchOptions = { compile?: boolean; // whether compile modified/added components during watch process }; +export type RootDirs = { [dir: PathLinux]: ComponentID }; + const DEBOUNCE_WAIT_MS = 100; type PathLinux = string; // ts fails when importing it from @teambit/legacy/dist/utils/path. @@ -67,7 +69,7 @@ export class Watcher { private watchQueue = new WatchQueue(); private bitMapChangesInProgress = false; private ipcEventsDir: string; - private trackDirs: { [dir: PathLinux]: ComponentID } = {}; + private rootDirs: RootDirs = {}; private verbose = false; private multipleWatchers: WatcherProcessData[] = []; constructor( @@ -86,8 +88,8 @@ export class Watcher { async watch() { const { msgs, ...watchOpts } = this.options; - await this.setTrackDirs(); - const componentIds = Object.values(this.trackDirs); + await this.setRootDirs(); + const componentIds = Object.values(this.rootDirs); await this.watcherMain.triggerOnPreWatch(componentIds, watchOpts); await this.createWatcher(); const watcher = this.fsWatcher; @@ -101,7 +103,7 @@ export class Watcher { if (msgs?.onAll) watcher.on('all', msgs?.onAll); } watcher.on('ready', () => { - msgs?.onReady(this.workspace, this.trackDirs, this.verbose); + msgs?.onReady(this.workspace, this.rootDirs, this.verbose); // console.log(this.fsWatcher.getWatched()); loader.stop(); }); @@ -287,21 +289,21 @@ export class Watcher { * if .bitmap changed, it's possible that a new component has been added. trigger onComponentAdd. */ private async handleBitmapChanges(): Promise { - const previewsTrackDirs = { ...this.trackDirs }; + const previewsRootDirs = { ...this.rootDirs }; await this.workspace._reloadConsumer(); - await this.setTrackDirs(); + await this.setRootDirs(); await this.workspace.triggerOnBitmapChange(); - const newDirs: string[] = difference(Object.keys(this.trackDirs), Object.keys(previewsTrackDirs)); - const removedDirs: string[] = difference(Object.keys(previewsTrackDirs), Object.keys(this.trackDirs)); + const newDirs: string[] = difference(Object.keys(this.rootDirs), Object.keys(previewsRootDirs)); + const removedDirs: string[] = difference(Object.keys(previewsRootDirs), Object.keys(this.rootDirs)); const results: OnComponentEventResult[] = []; if (newDirs.length) { const addResults = await mapSeries(newDirs, async (dir) => - this.executeWatchOperationsOnComponent(this.trackDirs[dir], [], [], false) + this.executeWatchOperationsOnComponent(this.rootDirs[dir], [], [], false) ); results.push(...addResults.flat()); } if (removedDirs.length) { - await mapSeries(removedDirs, (dir) => this.executeWatchOperationsOnRemove(previewsTrackDirs[dir])); + await mapSeries(removedDirs, (dir) => this.executeWatchOperationsOnRemove(previewsRootDirs[dir])); } return results; @@ -364,24 +366,24 @@ export class Watcher { private getComponentIdByPath(filePath: string): ComponentID | null { const relativeFile = this.getRelativePathLinux(filePath); - const trackDir = this.findTrackDirByFilePathRecursively(relativeFile); - if (!trackDir) { + const rootDir = this.findRootDirByFilePathRecursively(relativeFile); + if (!rootDir) { // the file is not part of any component. If it was a new component, or a new file of // existing component, then, handleBitmapChanges() should deal with it. return null; } - return this.trackDirs[trackDir]; + return this.rootDirs[rootDir]; } private getRelativePathLinux(filePath: string) { return pathNormalizeToLinux(this.consumer.getPathRelativeToConsumer(filePath)); } - private findTrackDirByFilePathRecursively(filePath: string): string | null { - if (this.trackDirs[filePath]) return filePath; + private findRootDirByFilePathRecursively(filePath: string): string | null { + if (this.rootDirs[filePath]) return filePath; const parentDir = dirname(filePath); if (parentDir === filePath) return null; - return this.findTrackDirByFilePathRecursively(parentDir); + return this.findRootDirByFilePathRecursively(parentDir); } private async createWatcher() { @@ -415,13 +417,13 @@ export class Watcher { } } - private async setTrackDirs() { - this.trackDirs = {}; + private async setRootDirs() { + this.rootDirs = {}; const componentsFromBitMap = this.consumer.bitMap.getAllComponents(); componentsFromBitMap.map((componentMap) => { const componentId = componentMap.id; const rootDir = componentMap.getRootDir(); - this.trackDirs[rootDir] = componentId; + this.rootDirs[rootDir] = componentId; }); } } diff --git a/scopes/workspace/workspace/bit-map.ts b/scopes/workspace/workspace/bit-map.ts index d5bd7b821d1e..221fe371d96f 100644 --- a/scopes/workspace/workspace/bit-map.ts +++ b/scopes/workspace/workspace/bit-map.ts @@ -29,6 +29,10 @@ export class BitMap { return this.legacyBitMap.mapPath; } + getAllRootDirs(): string[] { + return Object.keys(this.legacyBitMap.getAllTrackDirs()); + } + /** * adds component config to the .bitmap file. * later, upon `bit tag`, the data is saved in the scope. diff --git a/scopes/workspace/workspace/build-graph-ids-from-fs.ts b/scopes/workspace/workspace/build-graph-ids-from-fs.ts index ecbef928c336..a52f746157b3 100644 --- a/scopes/workspace/workspace/build-graph-ids-from-fs.ts +++ b/scopes/workspace/workspace/build-graph-ids-from-fs.ts @@ -111,7 +111,7 @@ export class GraphIdsFromFsBuilder { return []; } - const deps = await this.dependencyResolver.getComponentDependencies(component); + const deps = this.dependencyResolver.getComponentDependencies(component); const allDepsIds = deps.map((d) => d.componentId); const allDependenciesComps = await this.loadManyComponents(allDepsIds, idStr); @@ -135,18 +135,24 @@ export class GraphIdsFromFsBuilder { graphFromScope: CompIdGraph, component: Component ): Promise { - const deps = await this.dependencyResolver.getComponentDependencies(component); + const deps = this.dependencyResolver.getComponentDependencies(component); const workspaceIds = this.workspace.listIds(); + const workspaceIdsStr = workspaceIds.map((id) => id.toString()); const [depsInScopeGraph, depsNotInScopeGraph] = partition( deps, (dep) => - graphFromScope.hasNode(dep.componentId.toString()) && !workspaceIds.find((id) => id.isEqual(dep.componentId)) + graphFromScope.hasNode(dep.componentId.toString()) && !workspaceIdsStr.includes(dep.componentId.toString()) ); const depsInScopeGraphIds = depsInScopeGraph.map((dep) => dep.componentId.toString()); const depsInScopeGraphIdsNotCompleted = depsInScopeGraphIds.filter((id) => !this.completed.includes(id)); if (depsInScopeGraphIdsNotCompleted.length) { const subGraphs = graphFromScope.successorsSubgraph(depsInScopeGraphIdsNotCompleted); + // delete any edge that its source is from the workspace. if this component is modified, this edge could be + // incorrect. we don't need these edges anyway because we add them directly. + subGraphs.edges.forEach((edge) => { + if (workspaceIdsStr.includes(edge.sourceId)) subGraphs.deleteEdge(edge.sourceId, edge.targetId); + }); this.graph.merge([subGraphs]); this.completed.push(...depsInScopeGraphIdsNotCompleted); } diff --git a/scopes/workspace/workspace/workspace-aspects-loader.ts b/scopes/workspace/workspace/workspace-aspects-loader.ts index 8eb0cb157809..411009c02463 100644 --- a/scopes/workspace/workspace/workspace-aspects-loader.ts +++ b/scopes/workspace/workspace/workspace-aspects-loader.ts @@ -85,6 +85,7 @@ export class WorkspaceAspectsLoader { neededFor?: string, opts: WorkspaceLoadAspectsOptions = {} ): Promise { + this.logger.profile('workspace.loadAspects'); const calculatedThrowOnError: boolean = throwOnError ?? false; const defaultOpts: Required = { useScopeAspectsCapsule: false, @@ -107,7 +108,10 @@ needed-for: ${neededFor || ''}. using opts: ${JSON.stringify(mergedOpts this.workspace.localAspects = localAspects; await this.aspectLoader.loadAspectFromPath(this.workspace.localAspects); const notLoadedIds = nonLocalAspects.filter((id) => !this.aspectLoader.isAspectLoaded(id)); - if (!notLoadedIds.length) return []; + if (!notLoadedIds.length) { + this.logger.profile('workspace.loadAspects'); + return []; + } const coreAspectsStringIds = this.aspectLoader.getCoreAspectIds(); const idsWithoutCore: string[] = difference(notLoadedIds, coreAspectsStringIds); @@ -171,6 +175,7 @@ needed-for: ${neededFor || ''}. using opts: ${JSON.stringify(mergedOpts await this.aspectLoader.loadExtensionsByManifests(pluginsManifests, undefined, { throwOnError }); this.logger.debug(`${loggerPrefix} finish loading aspects`); const manifestIds = manifests.map((manifest) => manifest.id); + this.logger.profile('workspace.loadAspects'); return compact(manifestIds.concat(scopeAspectIds)); } @@ -275,8 +280,7 @@ your workspace.jsonc has this component-id set. you might want to remove/change : difference(this.harmony.extensionsIds, coreAspectsIds); const rootAspectsIds: string[] = difference(configuredAspects, coreAspectsIds); const componentIdsToResolve = await this.workspace.resolveMultipleComponentIds(userAspectsIds); - const components = await this.importAndGetAspects(componentIdsToResolve); - + const components = await this.importAndGetAspects(componentIdsToResolve, opts?.throwOnError); // Run the on load slot await this.runOnAspectsResolveFunctions(components); @@ -753,7 +757,7 @@ your workspace.jsonc has this component-id set. you might want to remove/change /** * same as `this.importAndGetMany()` with a specific error handling of ComponentNotFound */ - private async importAndGetAspects(componentIds: ComponentID[]): Promise { + private async importAndGetAspects(componentIds: ComponentID[], throwOnError = true): Promise { try { // We don't want to load the seeders as aspects as it will cause an infinite loop // once you try to load the seeder it will try to load the workspace component @@ -761,7 +765,12 @@ your workspace.jsonc has this component-id set. you might want to remove/change const loadOpts: ComponentLoadOptions = { idsToNotLoadAsAspects: componentIds.map((id) => id.toString()), }; - return await this.workspace.importAndGetMany(componentIds, 'to load aspects from the workspace', loadOpts); + return await this.workspace.importAndGetMany( + componentIds, + 'to load aspects from the workspace', + loadOpts, + throwOnError + ); } catch (err: any) { this.throwWsJsoncAspectNotFoundError(err); diff --git a/scopes/workspace/workspace/workspace-component/workspace-component-loader.ts b/scopes/workspace/workspace/workspace-component/workspace-component-loader.ts index 221723129ade..fab8bf1baa9a 100644 --- a/scopes/workspace/workspace/workspace-component/workspace-component-loader.ts +++ b/scopes/workspace/workspace/workspace-component/workspace-component-loader.ts @@ -109,6 +109,8 @@ export class WorkspaceComponentLoader { } async getMany(ids: Array, loadOpts?: ComponentLoadOptions, throwOnFailure = true): Promise { + const callId = Math.floor(Math.random() * 1000); // generate a random callId to be able to identify the call from the logs + this.logger.profile(`getMany-${callId}`); const idsWithoutEmpty = compact(ids); this.logger.setStatusLine(`loading ${ids.length} component(s)`); const loadOptsWithDefaults: ComponentLoadOptions = Object.assign( @@ -135,42 +137,48 @@ export class WorkspaceComponentLoader { const { components: loadedComponents, invalidComponents } = await this.getAndLoadSlotOrdered( loadOrCached.idsToLoad || [], loadOptsWithDefaults, - throwOnFailure + callId ); + invalidComponents.forEach(({ err }) => { + if (throwOnFailure) throw err; + }); + const components = [...loadedComponents, ...loadOrCached.fromCache]; // this.logger.clearStatusLine(); components.forEach((comp) => { this.saveInCache(comp, { loadExtensions: true, executeLoadSlot: true }); }); + this.logger.profile(`getMany-${callId}`); return { components, invalidComponents }; } private async getAndLoadSlotOrdered( ids: ComponentID[], loadOpts: ComponentLoadOptions, - throwOnFailure = true + callId = 0 ): Promise { if (!ids?.length) return { components: [], invalidComponents: [] }; const workspaceScopeIdsMap: WorkspaceScopeIdsMap = await this.groupAndUpdateIds(ids); - + this.logger.profile('buildLoadGroups'); const groupsToHandle = await this.buildLoadGroups(workspaceScopeIdsMap); + this.logger.profile('buildLoadGroups'); // prefix your command with "BIT_LOG=*" to see the detailed groups if (process.env.BIT_LOG) { printGroupsToHandle(groupsToHandle, this.logger); } const groupsRes = compact( - await mapSeries(groupsToHandle, async (group) => { + await mapSeries(groupsToHandle, async (group, index) => { const { scopeIds, workspaceIds, aspects, core, seeders } = group; - if (!workspaceIds.length && !scopeIds.length) return undefined; - const res = await this.getAndLoadSlot( - workspaceIds, - scopeIds, - { ...loadOpts, core, seeders, aspects }, - throwOnFailure - ); + const groupDesc = `getMany-${callId} group ${index + 1}/${groupsToHandle.length} - ${loadGroupToStr(group)}`; + this.logger.profile(groupDesc); + if (!workspaceIds.length && !scopeIds.length) { + throw new Error('getAndLoadSlotOrdered - group has no ids to load'); + } + const res = await this.getAndLoadSlot(workspaceIds, scopeIds, { ...loadOpts, core, seeders, aspects }); + this.logger.profile(groupDesc); // We don't want to return components that were not asked originally (we do want to load them) if (!group.seeders) return undefined; return res; @@ -225,8 +233,8 @@ export class WorkspaceComponentLoader { await this.groupAndUpdateIds(extsNotFromTheList, workspaceScopeIdsMap); - const layerdExtFromTheList = this.regroupExtIdsFromTheList(groupedByIsExtOfAnother.true); - const layerdExtGroups = layerdExtFromTheList.map((ids) => { + const layeredExtFromTheList = this.regroupExtIdsFromTheList(groupedByIsExtOfAnother.true); + const layeredExtGroups = layeredExtFromTheList.map((ids) => { return { ids, core: false, @@ -239,10 +247,11 @@ export class WorkspaceComponentLoader { // Always load first core envs { ids: groupedByIsCoreEnvs.true || [], core: true, aspects: true, seeders: true }, { ids: extsNotFromTheList || [], core: false, aspects: true, seeders: false }, - ...layerdExtGroups, + ...layeredExtGroups, { ids: groupedByIsExtOfAnother.false || [], core: false, aspects: false, seeders: true }, ]; const groupsByWsScope = groupsToHandle.map((group) => { + if (!group.ids?.length) return undefined; const groupedByWsScope = groupBy(group.ids, (id) => { return workspaceScopeIdsMap.workspaceIds.has(id.toString()); }); @@ -254,7 +263,7 @@ export class WorkspaceComponentLoader { seeders: group.seeders, }; }); - return groupsByWsScope; + return compact(groupsByWsScope); } private regroupExtIdsFromTheList(ids: ComponentID[]): Array { @@ -270,14 +279,12 @@ export class WorkspaceComponentLoader { private async getAndLoadSlot( workspaceIds: ComponentID[], scopeIds: ComponentID[], - loadOpts: GetAndLoadSlotOpts, - throwOnFailure = true + loadOpts: GetAndLoadSlotOpts ): Promise { const { workspaceComponents, scopeComponents, invalidComponents } = await this.getComponentsWithoutLoadExtensions( workspaceIds, scopeIds, - loadOpts, - throwOnFailure + loadOpts ); const components = workspaceComponents.concat(scopeComponents); @@ -289,12 +296,16 @@ export class WorkspaceComponentLoader { // Ensure we won't load the same extension many times // We don't want to ignore version here, as we do want to load different extensions with same id but different versions here const mergedExtensions = ExtensionDataList.mergeConfigs(allExtensions, false); + this.logger.profile('loadComponentsExtensions'); await this.workspace.loadComponentsExtensions(mergedExtensions); + this.logger.profile('loadComponentsExtensions'); let wsComponentsWithAspects = workspaceComponents; // if (loadOpts.seeders) { + this.logger.profile('executeLoadSlot'); wsComponentsWithAspects = await pMapPool(workspaceComponents, (component) => this.executeLoadSlot(component), { concurrency: concurrentComponentsLimit(), }); + this.logger.profile('executeLoadSlot'); await this.warnAboutMisconfiguredEnvs(wsComponentsWithAspects); // } @@ -303,6 +314,7 @@ export class WorkspaceComponentLoader { // It's important to load the workspace components as aspects here // otherwise the envs from the workspace won't be loaded at time // so we will get wrong dependencies from component who uses envs from the workspace + this.logger.profile('loadCompsAsAspects'); if (loadOpts.loadSeedersAsAspects || (loadOpts.core && loadOpts.aspects)) { await this.loadCompsAsAspects(workspaceComponents.concat(scopeComponents), { loadApps: true, @@ -313,6 +325,7 @@ export class WorkspaceComponentLoader { idsToNotLoadAsAspects: loadOpts.idsToNotLoadAsAspects, }); } + this.logger.profile('loadCompsAsAspects'); return { components: withAspects, invalidComponents }; } @@ -428,8 +441,7 @@ export class WorkspaceComponentLoader { private async getComponentsWithoutLoadExtensions( workspaceIds: ComponentID[], scopeIds: ComponentID[], - loadOpts: GetAndLoadSlotOpts, - throwOnFailure = true + loadOpts: GetAndLoadSlotOpts ) { const invalidComponents: InvalidComponent[] = []; const errors: { id: ComponentID; err: Error }[] = []; @@ -448,7 +460,7 @@ export class WorkspaceComponentLoader { workspaceIds.forEach((id) => { idsIndex[id.toString()] = id; }); - + this.logger.profile('consumer.loadComponents'); const { components: legacyComponents, invalidComponents: legacyInvalidComponents, @@ -458,12 +470,13 @@ export class WorkspaceComponentLoader { false, loadOptsWithDefaults ); + this.logger.profile('consumer.loadComponents'); const allLegacyComponents = legacyComponents.concat(removedComponents); legacyInvalidComponents.forEach((invalidComponent) => { const entry = { id: idsIndex[invalidComponent.id.toString()], err: invalidComponent.error }; if (ConsumerComponent.isComponentInvalidByErrorType(invalidComponent.error)) { - if (throwOnFailure) throw invalidComponent.error; invalidComponents.push(entry); + return; } if ( this.isComponentNotExistsError(invalidComponent.error) || @@ -475,7 +488,7 @@ export class WorkspaceComponentLoader { const getWithCatch = (id, legacyComponent) => { return this.get(id, legacyComponent, undefined, undefined, loadOptsWithDefaults).catch((err) => { - if (ConsumerComponent.isComponentInvalidByErrorType(err) && !throwOnFailure) { + if (ConsumerComponent.isComponentInvalidByErrorType(err)) { invalidComponents.push({ id, err, @@ -858,3 +871,14 @@ function printGroupsToHandle(groupsToHandle: Array, logger: Logger): ); }); } + +function loadGroupToStr(loadGroup: LoadGroup): string { + const { scopeIds, workspaceIds, aspects, core, seeders } = loadGroup; + + const attr: string[] = []; + if (aspects) attr.push('aspects'); + if (core) attr.push('core'); + if (seeders) attr.push('seeders'); + + return `workspaceIds: ${workspaceIds.length}, scopeIds: ${scopeIds.length}, (${attr.join('+')})`; +} diff --git a/scopes/workspace/workspace/workspace.main.runtime.ts b/scopes/workspace/workspace/workspace.main.runtime.ts index 0014d9ae86f7..86ffc9cec51d 100644 --- a/scopes/workspace/workspace/workspace.main.runtime.ts +++ b/scopes/workspace/workspace/workspace.main.runtime.ts @@ -261,9 +261,12 @@ export class WorkspaceMain { cli.register(...commands); component.registerHost(workspace); + // mini-status should be super fast. login/logout don't need loading aspects + const commandsToSkipLoadingAspects = ['mini-status', 'ms', 'login', 'logout']; + cli.registerOnStart(async (_hasWorkspace: boolean, currentCommand: string) => { - if (currentCommand === 'mini-status' || currentCommand === 'ms') { - return; // mini-status should be super fast. + if (commandsToSkipLoadingAspects.includes(currentCommand)) { + return; } if (currentCommand === 'install') { workspace.inInstallContext = true; diff --git a/scopes/workspace/workspace/workspace.ts b/scopes/workspace/workspace/workspace.ts index 3f92dea883b1..21ab0b5d9a23 100644 --- a/scopes/workspace/workspace/workspace.ts +++ b/scopes/workspace/workspace/workspace.ts @@ -46,7 +46,11 @@ import { import fs from 'fs-extra'; import { CompIdGraph, DepEdgeType } from '@teambit/graph'; import { slice, isEmpty, merge, compact, uniqBy } from 'lodash'; -import { MergeConfigFilename, CFG_DEFAULT_RESOLVE_ENVS_FROM_ROOTS } from '@teambit/legacy/dist/constants'; +import { + MergeConfigFilename, + CFG_DEFAULT_RESOLVE_ENVS_FROM_ROOTS, + CFG_USER_TOKEN_KEY, +} from '@teambit/legacy/dist/constants'; import path from 'path'; import ConsumerComponent from '@teambit/legacy/dist/consumer/component'; import { WatchOptions } from '@teambit/watcher'; @@ -60,6 +64,7 @@ import { LaneNotFound } from '@teambit/legacy/dist/api/scope/lib/exceptions/lane import { ScopeNotFoundOrDenied } from '@teambit/legacy/dist/remotes/exceptions/scope-not-found-or-denied'; import { isHash } from '@teambit/component-version'; import { GlobalConfigMain } from '@teambit/global-config'; +import { getAuthHeader } from '@teambit/legacy/dist/scope/network/http/http'; import { ComponentConfigFile } from './component-config-file'; import { OnComponentAdd, @@ -157,7 +162,6 @@ export class Workspace implements ComponentFactory { * This is important to know to ignore missing modules across different places */ inInstallContext = false; - private _cachedListIds?: ComponentIdList; private componentLoadedSelfAsAspects: InMemoryCache; // cache loaded components private aspectsMerger: AspectsMerger; private componentDefaultScopeFromComponentDirAndNameWithoutConfigFileMemoized; @@ -397,13 +401,7 @@ export class Workspace implements ComponentFactory { * get ids of all workspace components. */ listIds(): ComponentIdList { - if (this._cachedListIds && this.bitMap.hasChanged()) { - delete this._cachedListIds; - } - if (!this._cachedListIds) { - this._cachedListIds = this.consumer.bitmapIdsFromCurrentLane; - } - return this._cachedListIds; + return this.consumer.bitmapIdsFromCurrentLane; } listIdsIncludeRemoved(): ComponentIdList { @@ -737,7 +735,6 @@ it's possible that the version ${component.id.version} belong to ${idStr.split(' this.aspectLoader.resetFailedLoadAspects(); if (!options.skipClearFailedToLoadEnvs) this.envs.resetFailedToLoadEnvs(); this.logger.debug('clearing the workspace and scope caches'); - delete this._cachedListIds; this.componentLoader.clearCache(); this.componentStatusLoader.clearCache(); await this.scope.clearCache(); @@ -1033,8 +1030,8 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`); return foundEnv?.components || []; } - async getMany(ids: Array, loadOpts?: ComponentLoadOptions): Promise { - const { components } = await this.componentLoader.getMany(ids, loadOpts); + async getMany(ids: Array, loadOpts?: ComponentLoadOptions, throwOnFailure = true): Promise { + const { components } = await this.componentLoader.getMany(ids, loadOpts, throwOnFailure); return components; } @@ -1080,7 +1077,8 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`); async importAndGetMany( ids: Array, reason?: string, - loadOpts?: ComponentLoadOptions + loadOpts?: ComponentLoadOptions, + throwOnError = true ): Promise { if (!ids.length) return []; const lane = await this.importCurrentLaneIfMissing(); @@ -1092,7 +1090,7 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`); lane, reason, }); - return this.getMany(ids, loadOpts); + return this.getMany(ids, loadOpts, throwOnError); } async importCurrentLaneIfMissing(): Promise { @@ -1691,7 +1689,9 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`); } const url = `https://node-registry.bit.cloud/${packageName}`; - const res = await fetch(url); + const token = await this.globalConfig.get(CFG_USER_TOKEN_KEY); + const headers = token ? getAuthHeader(token) : {}; + const res = await fetch(url, { headers }); if (!res.ok) { throw new BitError(`${errMsgPrefix}got ${res.statusText} from the url: ${url}`); } @@ -1882,6 +1882,9 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`); */ async setEnvToComponents(envId: ComponentID, componentIds: ComponentID[]) { const envStrWithPossiblyVersion = await this.resolveEnvIdWithPotentialVersionForConfig(envId); + const envComp = await this.get(ComponentID.fromString(envStrWithPossiblyVersion)); + const isEnv = this.envs.isEnv(envComp); + if (!isEnv) throw new BitError(`the component ${envComp.id.toString()} is not an env`); const envIdStrNoVersion = envId.toStringWithoutVersion(); await this.unsetEnvFromComponents(componentIds); await Promise.all( @@ -1915,7 +1918,9 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`); return found.extensionId.toString(); } const comps = await this.importAndGetMany([envId], `to get the env ${envId.toString()}`); - return comps[0].id.toString(); + const comp = comps[0]; + if (!comp) throw new BitError(`unable to find ${envId.toString()} in the workspace or in the remote`); + return comp.id.toString(); } /** diff --git a/workspace.jsonc b/workspace.jsonc index 8f2cc82b95b9..8cba803b7485 100644 --- a/workspace.jsonc +++ b/workspace.jsonc @@ -13,6 +13,7 @@ "packageManager": "teambit.dependencies/pnpm", "policy": { "dependencies": { + "@apollo/gateway": "^2.7.2", "@apollo/server": "^4.10.2", "@babel/core": "7.19.6", "@babel/preset-react": "^7.23.3", @@ -22,37 +23,39 @@ "@bitdev/react.generators.react-templates": "^1.1.21", "@bitdev/symphony.generators.symphony-templates": "~0.0.11", "@graphql-tools/schema": "^10.0.3", + "@graphql-tools/utils": "^10.1.2", + "@graphql-tools/wrap": "^10.0.5", "@jest/test-result": "26.6.2", "@mdx-js/mdx": "1.6.21", "@mdx-js/react": "1.6.22", "@monaco-editor/react": "4.4.6", "@pmmmwh/react-refresh-webpack-plugin": "0.5.4", - "@pnpm/client": "10.0.47", + "@pnpm/client": "10.0.48", "@pnpm/colorize-semver-diff": "1.0.1", - "@pnpm/config": "20.4.2", - "@pnpm/core": "13.5.0", - "@pnpm/default-reporter": "12.4.13", + "@pnpm/config": "20.4.3", + "@pnpm/core": "13.5.1", + "@pnpm/default-reporter": "12.5.0", "@pnpm/dependency-path": "2.1.8", - "@pnpm/error": "5.0.2", + "@pnpm/error": "5.0.3", "@pnpm/fetch": "7.0.7", - "@pnpm/list": "^9.1.11", - "@pnpm/lockfile-file": "8.1.7", + "@pnpm/list": "^9.1.12", + "@pnpm/lockfile-file": "8.1.8", "@pnpm/logger": "5.0.0", "@pnpm/modules-yaml": "12.1.7", "@pnpm/network.ca-file": "1.0.2", - "@pnpm/package-store": "19.0.16", - "@pnpm/parse-overrides": "4.0.2", + "@pnpm/package-store": "19.0.17", + "@pnpm/parse-overrides": "4.0.3", "@pnpm/pick-registry-for-package": "5.0.6", - "@pnpm/plugin-commands-publishing": "7.5.4", - "@pnpm/plugin-commands-rebuild": "10.0.19", + "@pnpm/plugin-commands-publishing": "7.5.6", + "@pnpm/plugin-commands-rebuild": "10.0.21", "@pnpm/registry-mock": "3.4.0", - "@pnpm/reviewing.dependencies-hierarchy": "^2.1.10", + "@pnpm/reviewing.dependencies-hierarchy": "^2.1.11", "@pnpm/semver-diff": "1.1.0", "@pnpm/sort-packages": "5.0.9", - "@pnpm/store-connection-manager": "7.0.27", + "@pnpm/store-connection-manager": "7.0.28", "@pnpm/types": "9.4.2", - "@pnpm/worker": "0.3.14", - "@pnpm/workspace.pkgs-graph": "2.0.14", + "@pnpm/worker": "0.3.15", + "@pnpm/workspace.pkgs-graph": "2.0.15", "@prerenderer/prerenderer": "^1.2.0", "@prerenderer/renderer-jsdom": "^1.1.2", "@prerenderer/webpack-plugin": "^5.2.0", @@ -232,6 +235,7 @@ "@teambit/explorer.ui.gallery.component-grid": "0.0.496", "@teambit/git.modules.git-ignore": "^1.0.2", "@teambit/harmony": "0.4.6", + "@teambit/harmony.envs.core-aspect-env": "^0.0.27", "@teambit/html.generator.html-templates": "^1.0.8", "@teambit/html.modules.inject-html-element": "0.0.4", "@teambit/html.modules.render-template": "0.0.104", @@ -323,7 +327,7 @@ "@types/cors": "2.8.10", "@types/dagre": "0.7.44", "@types/didyoumean": "1.2.0", - "@types/eslint": "7.28.0", + "@types/eslint": "8.56.6", "@types/express": "4.17.13", "@types/find-root": "1.1.2", "@types/lodash.compact": "3.0.6", @@ -428,7 +432,7 @@ "junit-report-builder": "3.0.1", "less": "^4.1.1", "loader-utils": "2.0.4", - "lodash": "4.17.20", + "lodash": "4.17.21", "lodash.compact": "3.0.1", "lodash.head": "4.0.1", "lodash.orderby": "4.6.0", @@ -436,7 +440,7 @@ "map-obj": "4.2.1", "mime": "2.5.2", "mini-css-extract-plugin": "2.2.2", - "minimatch": "3.0.4", + "minimatch": "3.0.5", "mousetrap": "1.6.5", "multimatch": "5.0.0", "nerf-dart": "1.0.0", @@ -508,7 +512,7 @@ "peerDependencies": { "@apollo/client": "^3.9.0", "@teambit/base-react.navigation.link": "2.0.27", - "@teambit/legacy": "1.0.669", + "@teambit/legacy": "1.0.680", "@testing-library/react": "^12.1.5", "core-js": "^3.10.0", "graphql": "16.8.1", From cc2afd37cd892c3f42f5d83e8f46bcd7a4a2eb0b Mon Sep 17 00:00:00 2001 From: Luv Kapur Date: Fri, 5 Apr 2024 14:24:36 -0400 Subject: [PATCH 05/32] merge origin/master --- .../component-size/component-size.module.scss | 12 ------ .../ui/component-size/component-size.tsx | 37 ------------------- components/ui/component-size/index.ts | 1 - 3 files changed, 50 deletions(-) delete mode 100644 components/ui/component-size/component-size.module.scss delete mode 100644 components/ui/component-size/component-size.tsx delete mode 100644 components/ui/component-size/index.ts diff --git a/components/ui/component-size/component-size.module.scss b/components/ui/component-size/component-size.module.scss deleted file mode 100644 index 2be4eb53bb22..000000000000 --- a/components/ui/component-size/component-size.module.scss +++ /dev/null @@ -1,12 +0,0 @@ -.componentSizeTooltip { - padding: 0; - max-width: fit-content !important; -} - -.componentSizeTooltipContent { - font-size: var(--bit-p-xs, '14px'); -} - -.label { - padding: 4px 8px; -} diff --git a/components/ui/component-size/component-size.tsx b/components/ui/component-size/component-size.tsx deleted file mode 100644 index 4bbbecd8e77f..000000000000 --- a/components/ui/component-size/component-size.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import React from 'react'; -import fileSize from 'pretty-bytes'; -import { ComponentModel } from '@teambit/component'; -import { PillLabel } from '@teambit/design.ui.pill-label'; -import { Tooltip } from '@teambit/design.ui.tooltip'; -import styles from './component-size.module.scss'; - -export type ComponentSizeProps = { legacyComponentModel?: ComponentModel } & React.HTMLAttributes; - -export function ComponentSize({ legacyComponentModel, ...rest }: ComponentSizeProps) { - // const builderData = componentDescriptor.get('teambit.pipelines/builder'); - // const builder = builderData && BuilderData.fromJson(builderData); - // const size: ComponentPreviewSize = builder?.getDataByAspect('teambit.preview/preview')?.size; - const compressedSize = legacyComponentModel?.size?.compressedTotal; - - if (!compressedSize) return null; - - return ( - - Component bundle with dependencies, minified and gzipped - - } - > -
- - - {fileSize(compressedSize)} - -
-
- ); -} diff --git a/components/ui/component-size/index.ts b/components/ui/component-size/index.ts deleted file mode 100644 index 2707c88aea6e..000000000000 --- a/components/ui/component-size/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { ComponentSize, ComponentSizeProps } from './component-size'; From c3bdbba13fbe5a31fe1c1ab6e0d9394c8c0431af Mon Sep 17 00:00:00 2001 From: Luv Kapur Date: Fri, 5 Apr 2024 14:25:11 -0400 Subject: [PATCH 06/32] merge origin/master --- workspace.jsonc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/workspace.jsonc b/workspace.jsonc index a594fdad816b..7dbd33449487 100644 --- a/workspace.jsonc +++ b/workspace.jsonc @@ -42,11 +42,7 @@ "@pnpm/lockfile-file": "8.1.8", "@pnpm/logger": "5.0.0", "@pnpm/modules-yaml": "12.1.7", -<<<<<<< HEAD - "@pnpm/network.ca-file": "1.0.2", -======= "@pnpm/network.ca-file": "2.0.1", ->>>>>>> origin/master "@pnpm/package-store": "19.0.17", "@pnpm/parse-overrides": "4.0.3", "@pnpm/pick-registry-for-package": "5.0.6", From cc8435e0fa382c07f83f34a31623c3101830bedb Mon Sep 17 00:00:00 2001 From: Luv Kapur Date: Fri, 5 Apr 2024 14:28:21 -0400 Subject: [PATCH 07/32] uninstall subscription-transport --- workspace.jsonc | 1 - 1 file changed, 1 deletion(-) diff --git a/workspace.jsonc b/workspace.jsonc index 7dbd33449487..0b9b864cab49 100644 --- a/workspace.jsonc +++ b/workspace.jsonc @@ -482,7 +482,6 @@ "ssri": "10.0.1", "string_decoder": "^1.3.0", "strip-ansi": "6.0.0", - "subscriptions-transport-ws": "^0.11.0", "symlink-dir": "^5.1.1", "table": "6.7.3", "terser-webpack-plugin": "5.2.0", From 8079890ae194848169044a8b8be6acc42c292265 Mon Sep 17 00:00:00 2001 From: Luv Kapur Date: Fri, 5 Apr 2024 14:58:49 -0400 Subject: [PATCH 08/32] install subscription-transport back @apollo/client still uses it as peer in the latest --- workspace.jsonc | 1 + 1 file changed, 1 insertion(+) diff --git a/workspace.jsonc b/workspace.jsonc index 0b9b864cab49..7dbd33449487 100644 --- a/workspace.jsonc +++ b/workspace.jsonc @@ -482,6 +482,7 @@ "ssri": "10.0.1", "string_decoder": "^1.3.0", "strip-ansi": "6.0.0", + "subscriptions-transport-ws": "^0.11.0", "symlink-dir": "^5.1.1", "table": "6.7.3", "terser-webpack-plugin": "5.2.0", From dc551c31376e9c1fb6392ffeceb4239b48bd3f42 Mon Sep 17 00:00:00 2001 From: Luv Kapur Date: Fri, 5 Apr 2024 15:04:47 -0400 Subject: [PATCH 09/32] update gql imports --- components/hooks/use-lane-components/use-lane-components.tsx | 2 +- components/hooks/use-lanes/use-lanes.tsx | 2 +- .../use-lane-diff-status/use-lane-diff-status.ts | 2 +- components/ui/hooks/use-core-aspects/use-core-aspects.tsx | 2 +- scopes/api-reference/hooks/use-api/use-api.ts | 2 +- scopes/api-reference/hooks/use-schema/use-schema.ts | 2 +- scopes/cloud/cloud/cloud.main.runtime.ts | 1 + scopes/cloud/hooks/use-cloud-scopes/use-cloud-scopes.ts | 2 +- scopes/cloud/hooks/use-current-user/use-current-user.ts | 2 +- scopes/cloud/hooks/use-logout/use-logout.ts | 2 +- scopes/compilation/bundler/dev-server.graphql.ts | 2 +- scopes/component/component/host/use-component-host.ts | 2 +- scopes/component/component/ui/aspect-page/aspect-page.tsx | 2 +- scopes/component/component/ui/use-component.fragments.ts | 2 +- scopes/component/graph/ui/query/get-graph.query.ts | 2 +- scopes/workspace/workspace/ui/workspace/use-workspace.ts | 2 +- 16 files changed, 16 insertions(+), 15 deletions(-) diff --git a/components/hooks/use-lane-components/use-lane-components.tsx b/components/hooks/use-lane-components/use-lane-components.tsx index add12fbc746b..4334c3fe8b3d 100644 --- a/components/hooks/use-lane-components/use-lane-components.tsx +++ b/components/hooks/use-lane-components/use-lane-components.tsx @@ -1,5 +1,5 @@ import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query'; -import { gql } from '@apollo/client'; +import { gql } from 'graphql-tag'; import { ComponentID, ComponentModel, componentOverviewFields } from '@teambit/component'; import { LaneId } from '@teambit/lane-id'; import { ComponentDescriptor } from '@teambit/component-descriptor'; diff --git a/components/hooks/use-lanes/use-lanes.tsx b/components/hooks/use-lanes/use-lanes.tsx index b99fcde56b5c..4d1bab271220 100644 --- a/components/hooks/use-lanes/use-lanes.tsx +++ b/components/hooks/use-lanes/use-lanes.tsx @@ -1,7 +1,7 @@ import { useMemo, useCallback } from 'react'; import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query'; import { LaneModel, LanesModel, LanesQuery } from '@teambit/lanes.ui.models.lanes-model'; -import { gql } from '@apollo/client'; +import { gql } from 'graphql-tag'; import { LaneId } from '@teambit/lane-id'; import { isEqual } from 'lodash'; import { useLanesContext } from './lanes-context'; diff --git a/components/ui/compare/lane-compare-hooks/use-lane-diff-status/use-lane-diff-status.ts b/components/ui/compare/lane-compare-hooks/use-lane-diff-status/use-lane-diff-status.ts index 1139b4c70f85..646d00060b10 100644 --- a/components/ui/compare/lane-compare-hooks/use-lane-diff-status/use-lane-diff-status.ts +++ b/components/ui/compare/lane-compare-hooks/use-lane-diff-status/use-lane-diff-status.ts @@ -1,5 +1,5 @@ import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query'; -import { gql } from '@apollo/client'; +import { gql } from 'graphql-tag'; import { LaneId } from '@teambit/lane-id'; import { ComponentID, ComponentIdObj } from '@teambit/component-id'; import { LaneDiff, PlainLaneDiff, ChangeType } from '@teambit/lanes.entities.lane-diff'; diff --git a/components/ui/hooks/use-core-aspects/use-core-aspects.tsx b/components/ui/hooks/use-core-aspects/use-core-aspects.tsx index 6c4610fcc5fa..d248953638b7 100644 --- a/components/ui/hooks/use-core-aspects/use-core-aspects.tsx +++ b/components/ui/hooks/use-core-aspects/use-core-aspects.tsx @@ -1,5 +1,5 @@ import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query'; -import { gql } from '@apollo/client'; +import { gql } from 'graphql-tag'; export type CoreAspectIdByPackageName = { [packageName: string]: string; diff --git a/scopes/api-reference/hooks/use-api/use-api.ts b/scopes/api-reference/hooks/use-api/use-api.ts index 9b9d9e217034..2de023f53a94 100644 --- a/scopes/api-reference/hooks/use-api/use-api.ts +++ b/scopes/api-reference/hooks/use-api/use-api.ts @@ -1,5 +1,5 @@ import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query'; -import { gql } from '@apollo/client'; +import { gql } from 'graphql-tag'; import { APIReferenceModel } from '@teambit/api-reference.models.api-reference-model'; import { APINodeRenderer } from '@teambit/api-reference.models.api-node-renderer'; diff --git a/scopes/api-reference/hooks/use-schema/use-schema.ts b/scopes/api-reference/hooks/use-schema/use-schema.ts index 3b0cf00c09c0..75b00d2b8118 100644 --- a/scopes/api-reference/hooks/use-schema/use-schema.ts +++ b/scopes/api-reference/hooks/use-schema/use-schema.ts @@ -1,5 +1,5 @@ import { DataQueryResult, useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query'; -import { gql } from '@apollo/client'; +import { gql } from 'graphql-tag'; import { SchemaQueryResult, APIReferenceModel } from '@teambit/api-reference.models.api-reference-model'; import { APINodeRenderer } from '@teambit/api-reference.models.api-node-renderer'; diff --git a/scopes/cloud/cloud/cloud.main.runtime.ts b/scopes/cloud/cloud/cloud.main.runtime.ts index 7cd7fb2bc870..e193e3b93819 100644 --- a/scopes/cloud/cloud/cloud.main.runtime.ts +++ b/scopes/cloud/cloud/cloud.main.runtime.ts @@ -271,6 +271,7 @@ export class CloudMain { const { clientId: clientIdFromReq, redirectUri, username: usernameFromReq } = req.query; const username = typeof usernameFromReq === 'string' ? usernameFromReq : undefined; let { token } = req.query; + if (Array.isArray(token)) { token = token[0]; } diff --git a/scopes/cloud/hooks/use-cloud-scopes/use-cloud-scopes.ts b/scopes/cloud/hooks/use-cloud-scopes/use-cloud-scopes.ts index b129609c21bb..4b88c3bce1a1 100644 --- a/scopes/cloud/hooks/use-cloud-scopes/use-cloud-scopes.ts +++ b/scopes/cloud/hooks/use-cloud-scopes/use-cloud-scopes.ts @@ -1,5 +1,5 @@ import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query'; -import { gql } from '@apollo/client'; +import { gql } from 'graphql-tag'; import { ScopeDescriptor } from '@teambit/scopes.scope-descriptor'; import { ScopeID } from '@teambit/scopes.scope-id'; diff --git a/scopes/cloud/hooks/use-current-user/use-current-user.ts b/scopes/cloud/hooks/use-current-user/use-current-user.ts index 358067e59f5d..ff8db3c2e369 100644 --- a/scopes/cloud/hooks/use-current-user/use-current-user.ts +++ b/scopes/cloud/hooks/use-current-user/use-current-user.ts @@ -1,5 +1,5 @@ import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query'; -import { gql } from '@apollo/client'; +import { gql } from 'graphql-tag'; import { CloudUser } from '@teambit/cloud.models.cloud-user'; export const CURRENT_USER_QUERY = gql` diff --git a/scopes/cloud/hooks/use-logout/use-logout.ts b/scopes/cloud/hooks/use-logout/use-logout.ts index 05380984b3fe..730d9157c3dd 100644 --- a/scopes/cloud/hooks/use-logout/use-logout.ts +++ b/scopes/cloud/hooks/use-logout/use-logout.ts @@ -1,5 +1,5 @@ import { useMutation } from '@teambit/ui'; -import { gql } from '@apollo/client'; +import { gql } from 'graphql-tag'; export const LOGOUT_MUTATION = gql` mutation LogoutUser { diff --git a/scopes/compilation/bundler/dev-server.graphql.ts b/scopes/compilation/bundler/dev-server.graphql.ts index 2d46a0026ab4..87fed26600c3 100644 --- a/scopes/compilation/bundler/dev-server.graphql.ts +++ b/scopes/compilation/bundler/dev-server.graphql.ts @@ -1,6 +1,6 @@ import { Component } from '@teambit/component'; import { Schema } from '@teambit/graphql'; -import { gql } from '@apollo/client'; +import { gql } from 'graphql-tag'; import { BundlerMain } from './bundler.main.runtime'; diff --git a/scopes/component/component/host/use-component-host.ts b/scopes/component/component/host/use-component-host.ts index 3b70fffeaac0..e5eb6b17268d 100644 --- a/scopes/component/component/host/use-component-host.ts +++ b/scopes/component/component/host/use-component-host.ts @@ -1,5 +1,5 @@ import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query'; -import { gql } from '@apollo/client'; +import { gql } from 'graphql-tag'; import { ComponentHostModel } from './component-host-model'; diff --git a/scopes/component/component/ui/aspect-page/aspect-page.tsx b/scopes/component/component/ui/aspect-page/aspect-page.tsx index a3c0fea16ac4..91cfb012f2fa 100644 --- a/scopes/component/component/ui/aspect-page/aspect-page.tsx +++ b/scopes/component/component/ui/aspect-page/aspect-page.tsx @@ -1,7 +1,7 @@ import { AspectBox } from '@teambit/harmony.ui.aspect-box'; import React, { useContext } from 'react'; import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query'; -import { gql } from '@apollo/client'; +import { gql } from 'graphql-tag'; import { EmptyBox } from '@teambit/design.ui.empty-box'; import { H1 } from '@teambit/documenter.ui.heading'; import { Separator } from '@teambit/documenter.ui.separator'; diff --git a/scopes/component/component/ui/use-component.fragments.ts b/scopes/component/component/ui/use-component.fragments.ts index 5b2008af46bb..53e2602dac7d 100644 --- a/scopes/component/component/ui/use-component.fragments.ts +++ b/scopes/component/component/ui/use-component.fragments.ts @@ -1,4 +1,4 @@ -import { gql } from '@apollo/client'; +import { gql } from 'graphql-tag'; export const componentIdFields = gql` fragment componentIdFields on ComponentID { diff --git a/scopes/component/graph/ui/query/get-graph.query.ts b/scopes/component/graph/ui/query/get-graph.query.ts index 9da721c9b705..553a070b52f1 100644 --- a/scopes/component/graph/ui/query/get-graph.query.ts +++ b/scopes/component/graph/ui/query/get-graph.query.ts @@ -1,4 +1,4 @@ -import { gql } from '@apollo/client'; +import { gql } from 'graphql-tag'; import { EdgeType } from '../../edge-type'; // please update types when updating query, for added safety diff --git a/scopes/workspace/workspace/ui/workspace/use-workspace.ts b/scopes/workspace/workspace/ui/workspace/use-workspace.ts index 8df3a805f333..b687ba4dc54e 100644 --- a/scopes/workspace/workspace/ui/workspace/use-workspace.ts +++ b/scopes/workspace/workspace/ui/workspace/use-workspace.ts @@ -2,7 +2,7 @@ import { useEffect, useMemo } from 'react'; import { ComponentModel } from '@teambit/component'; import useLatest from '@react-hook/latest'; import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query'; -import { gql } from '@apollo/client'; +import { gql } from 'graphql-tag'; import { ComponentID, ComponentIdObj } from '@teambit/component-id'; import { Workspace } from './workspace-model'; From 027d5744e9e8052776fee46104ca989fb33b2377 Mon Sep 17 00:00:00 2001 From: Luv Kapur Date: Fri, 5 Apr 2024 15:12:39 -0400 Subject: [PATCH 10/32] setup proxy sub --- scopes/harmony/graphql/graphql.main.runtime.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scopes/harmony/graphql/graphql.main.runtime.ts b/scopes/harmony/graphql/graphql.main.runtime.ts index 5ac60251b17e..c537318f0761 100644 --- a/scopes/harmony/graphql/graphql.main.runtime.ts +++ b/scopes/harmony/graphql/graphql.main.runtime.ts @@ -275,7 +275,7 @@ export class GraphqlMain { ); await this.createSubscription(mergedSchema, httpServer); - + this.proxySubscription(httpServer, this.config.port); return httpServer; } From 2f81d31a97e7b437a69fad6fe46e6192f61f01aa Mon Sep 17 00:00:00 2001 From: Luv Kapur Date: Fri, 5 Apr 2024 17:59:17 -0400 Subject: [PATCH 11/32] fix proxy subscription --- .../harmony/graphql/graphql.main.runtime.ts | 112 +++++------------- workspace.jsonc | 4 +- 2 files changed, 34 insertions(+), 82 deletions(-) diff --git a/scopes/harmony/graphql/graphql.main.runtime.ts b/scopes/harmony/graphql/graphql.main.runtime.ts index c537318f0761..a3fdeb27235a 100644 --- a/scopes/harmony/graphql/graphql.main.runtime.ts +++ b/scopes/harmony/graphql/graphql.main.runtime.ts @@ -17,6 +17,7 @@ import httpProxy from 'http-proxy'; import compact from 'lodash.compact'; import cors from 'cors'; import { GraphQLServer } from './graphql-server'; +import { execute, subscribe } from 'graphql'; import { createRemoteSchemas } from './create-remote-schemas'; import { GraphqlAspect } from './graphql.aspect'; import { Schema } from './schema'; @@ -200,28 +201,18 @@ export class GraphqlMain { const { graphiql = true, disableIntrospection } = options; const app = options.app || express(); const httpServer = createServer(app); + const subscriptionsPort = options.subscriptionsPortRange || this.config.subscriptionsPortRange; + const subscriptionServerPort = await this.getPort(subscriptionsPort); const localSchema = this.createRootModule(options.schemaSlot); // const remoteSchemas = await createRemoteSchemas(options.remoteSchemas || this.graphQLServerSlot.values()); // const schemas = [localSchema.schema].concat(remoteSchemas).filter((x) => x); - const schemas = [localSchema.schema].concat([]).filter((x) => x); - const mergedSchema = mergeSchemas({ - schemas, - }); - // const gateway = new ApolloGateway({ - // supergraphSdl: new IntrospectAndCompose({ - // /** - // * include all the running services in the super-graph. - // */ - // subgraphs: context.services.map((service) => { - // return { - // name: service.appName || '', - // url: service.url || `http://localhost:${service.port}/graphql`, - // }; - // }), - // }), + // const schemas = [localSchema.schema].concat([]).filter((x) => x); + // const mergedSchema = mergeSchemas({ + // schemas, // }); + const subscriptionServerCleanup = await this.createSubscription(localSchema.schema, httpServer, options); const apolloServer = new ApolloServer({ gateway: { async load() { @@ -240,6 +231,15 @@ export class GraphqlMain { plugins: compact([ ApolloServerPluginDrainHttpServer({ httpServer }), !graphiql ? ApolloServerPluginLandingPageDisabled() : null, + { + async serverWillStart() { + return { + async drainServer() { + await subscriptionServerCleanup.dispose(); + }, + }; + }, + }, ]), introspection: !disableIntrospection, formatError: (err) => { @@ -274,14 +274,12 @@ export class GraphqlMain { }) ); - await this.createSubscription(mergedSchema, httpServer); - this.proxySubscription(httpServer, this.config.port); return httpServer; } - async createSubscription(schema, httpServer) { + async createSubscription(schema, httpServer, options) { const websocketServer = new WebSocketServer({ - noServer: true, // Use the HTTP server for handling WebSocket connections + noServer: true, path: this.config.subscriptionsPath, }); @@ -294,14 +292,13 @@ export class GraphqlMain { } }); - useServer( + return useServer( { schema, - onConnect: (ctx) => { - console.log('Connected!', ctx); - }, - onDisconnect(ctx, code, reason) { - console.log('Disconnected!', code, reason); + execute, + subscribe, + context: (ctx) => { + options?.onWsConnect && options.onWsConnect(ctx.connectionParams); }, }, websocketServer @@ -355,67 +352,20 @@ export class GraphqlMain { return Port.getPort(from, to); } - /** create Subscription server with different port */ - - // private async createSubscription(options: GraphQLServerOptions, port: number) { - // // Create WebSocket listener server - // const websocketServer = createServer((request, response) => { - // response.writeHead(404); - // response.end(); - // }); - - // // Bind it to port and start listening - // websocketServer.listen(port, () => - // this.logger.debug(`Websocket Server is now running on http://localhost:${port}`) - // ); - - // const localSchema = this.createRootModule(options.schemaSlot); - // const remoteSchemas = await createRemoteSchemas(options.remoteSchemas || this.graphQLServerSlot.values()); - // const schemas = [localSchema.schema].concat(remoteSchemas).filter((x) => x); - // const schema = mergeSchemas({ - // schemas, - // }); + /** proxy ws Subscription server to avoid conflict with different websocket connections */ - // // eslint-disable-next-line @typescript-eslint/no-unused-vars - // const subServer = SubscriptionServer.create( - // { - // execute, - // subscribe, - // schema, - // onConnect: options.onWsConnect, - // }, - // { - // server: websocketServer, - // path: this.config.subscriptionsPath, + // private proxySubscription(server: Server, port: number) { + // const proxServer = httpProxy.createProxyServer(); + // const subscriptionsPath = this.config.subscriptionsPath; + // server.on('upgrade', function (req, socket, head) { + // if (req.url === subscriptionsPath) { + // proxServer.ws(req, socket, head, { target: { host: 'localhost', port } }); // } - // ); - // return { subServer, port }; + // }); // } - /** proxy ws Subscription server to avoid conflict with different websocket connections */ - - private proxySubscription(server: Server, port: number) { - // const proxServer = httpProxy.createProxyServer(); - // const subscriptionsPath = this.config.subscriptionsPath; - // server.on('upgrade', function (req, socket, head) { - // if (req.url === subscriptionsPath) { - // proxServer.ws(req, socket, head, { target: { host: 'localhost', port } }); - // } - // }); - const proxy = httpProxy.createProxyServer({ ws: true, changeOrigin: true }); - - server.on('upgrade', (req, socket, head) => { - // Check if the upgrade request is for the GraphQL subscriptions endpoint - if (req.url?.startsWith(this.config.subscriptionsPath)) { - proxy.ws(req, socket, head, { - target: `ws://localhost:${port}${this.config.subscriptionsPath}`, - }); - } - }); - } private createRootModule(schemaSlot?: SchemaSlot): Application { const modules = this.buildModules(schemaSlot); - return createApplication({ modules }); } diff --git a/workspace.jsonc b/workspace.jsonc index 7dbd33449487..79a9df8413c1 100644 --- a/workspace.jsonc +++ b/workspace.jsonc @@ -330,6 +330,7 @@ "@types/eslint": "8.56.6", "@types/express": "4.17.13", "@types/find-root": "1.1.2", + "@types/http-proxy": "^1.17.14", "@types/lodash.compact": "3.0.6", "@types/lodash.flatten": "4.4.6", "@types/lodash.head": "4.0.6", @@ -352,6 +353,7 @@ "@types/url-join": "4.0.0", "@types/url-parse": "1.4.3", "@types/webpack": "5.28.1", + "@types/ws": "^8.5.10", "@yarnpkg/cli": "3.6.1", "@yarnpkg/core": "3.5.2", "@yarnpkg/fslib": "2.10.3", @@ -404,7 +406,7 @@ "graphql-disable-introspection": "^1.2.0", "graphql-http": "^1.22.0", "graphql-modules": "^2.3.0", - "graphql-subscriptions": "1.2.0", + "graphql-subscriptions": "2.0.0", "graphql-tag": "^2.12.6", "graphql-tools": "^9.0.1", "graphql-type-json": "0.3.2", From b4e2f7223d201b71223e5b4ae5bfcd2485c3dda9 Mon Sep 17 00:00:00 2001 From: Luv Kapur Date: Sat, 6 Apr 2024 21:09:10 -0400 Subject: [PATCH 12/32] update graphql client to not use subscription-transport-ws protocol from apollo-client. Create ws connection using graphql-ws --- scopes/harmony/graphql/create-link.ts | 5 ++- .../harmony/graphql/graphql.main.runtime.ts | 20 ++++++++--- scopes/harmony/graphql/graphql.ui.runtime.tsx | 35 +++++++++++++++---- .../workspace/ui/workspace/use-workspace.ts | 5 +-- .../workspace/workspace/workspace.graphql.ts | 5 ++- scopes/workspace/workspace/workspace.ts | 2 ++ 6 files changed, 55 insertions(+), 17 deletions(-) diff --git a/scopes/harmony/graphql/create-link.ts b/scopes/harmony/graphql/create-link.ts index c71264afe205..b5fedc95019f 100644 --- a/scopes/harmony/graphql/create-link.ts +++ b/scopes/harmony/graphql/create-link.ts @@ -1,13 +1,12 @@ -import { HttpLink, split } from '@apollo/client'; +import { HttpLink, split, ApolloLink } from '@apollo/client'; import { getMainDefinition } from '@apollo/client/utilities'; -import type { WebSocketLink } from '@apollo/client/link/ws'; /** * create a link which splits routes data depending on type of operation. * @param httpLink http link for apollo graphql * @param wsLink web socket link for apollo graphql */ -export function createSplitLink(httpLink: HttpLink, wsLink: WebSocketLink) { +export function createSplitLink(httpLink: HttpLink, wsLink: ApolloLink) { return split( // split based on operation type ({ query }) => { diff --git a/scopes/harmony/graphql/graphql.main.runtime.ts b/scopes/harmony/graphql/graphql.main.runtime.ts index a3fdeb27235a..07366191adf9 100644 --- a/scopes/harmony/graphql/graphql.main.runtime.ts +++ b/scopes/harmony/graphql/graphql.main.runtime.ts @@ -13,7 +13,6 @@ import express, { Express } from 'express'; import { Port } from '@teambit/toolbox.network.get-port'; import { PubSubEngine, PubSub } from 'graphql-subscriptions'; import { createServer, Server } from 'http'; -import httpProxy from 'http-proxy'; import compact from 'lodash.compact'; import cors from 'cors'; import { GraphQLServer } from './graphql-server'; @@ -201,8 +200,6 @@ export class GraphqlMain { const { graphiql = true, disableIntrospection } = options; const app = options.app || express(); const httpServer = createServer(app); - const subscriptionsPort = options.subscriptionsPortRange || this.config.subscriptionsPortRange; - const subscriptionServerPort = await this.getPort(subscriptionsPort); const localSchema = this.createRootModule(options.schemaSlot); // const remoteSchemas = await createRemoteSchemas(options.remoteSchemas || this.graphQLServerSlot.values()); @@ -281,14 +278,24 @@ export class GraphqlMain { const websocketServer = new WebSocketServer({ noServer: true, path: this.config.subscriptionsPath, + // server: httpServer, }); httpServer.on('upgrade', (request, socket, head) => { // Only handle upgrades for the specific path, otherwise ignore if (request.url.startsWith(this.config.subscriptionsPath)) { + websocketServer.on('error', (err) => { + console.error('Websocket error', err); + }); websocketServer.handleUpgrade(request, socket, head, (websocket) => { + console.log( + '🚀 ~ file: graphql.main.runtime.ts:288 ~ GraphqlMain ~ websocketServer.handleUpgrade ~ request:', + request.url + ); websocketServer.emit('connection', websocket, request); }); + } else { + console.log('Upgrade request not matched:', request.url); } }); @@ -297,6 +304,12 @@ export class GraphqlMain { schema, execute, subscribe, + onError: (err) => { + this.logger.error('graphql error ', err); + console.error('graphql error ', err); + }, + onConnect: () => console.error('Client connected to WebSocket.'), + onDisconnect: () => console.error('Client disconnected from WebSocket.'), context: (ctx) => { options?.onWsConnect && options.onWsConnect(ctx.connectionParams); }, @@ -388,7 +401,6 @@ export class GraphqlMain { static defaultConfig = { port: 4000, - subscriptionsPortRange: [2000, 2100], disableCors: false, subscriptionsPath: '/subscriptions', }; diff --git a/scopes/harmony/graphql/graphql.ui.runtime.tsx b/scopes/harmony/graphql/graphql.ui.runtime.tsx index ac7d19da427f..83fb743f8f2c 100644 --- a/scopes/harmony/graphql/graphql.ui.runtime.tsx +++ b/scopes/harmony/graphql/graphql.ui.runtime.tsx @@ -1,9 +1,11 @@ import React, { ReactNode } from 'react'; +import { createClient } from 'graphql-ws'; +import { print } from 'graphql'; +import { Observable } from '@apollo/client/utilities'; +import { FetchResult } from '@apollo/client/core'; import { UIRuntime } from '@teambit/ui'; - import { InMemoryCache, ApolloClient, ApolloLink, HttpLink, createHttpLink } from '@apollo/client'; import type { NormalizedCacheObject } from '@apollo/client'; -import { WebSocketLink } from '@apollo/client/link/ws'; import { onError } from '@apollo/client/link/error'; import crossFetch from 'cross-fetch'; @@ -59,18 +61,37 @@ export class GraphqlUI { private createCache({ state }: { state?: NormalizedCacheObject } = {}) { const cache = new InMemoryCache(); - if (state) cache.restore(state); - return cache; } private createLink(uri: string, { subscriptionUri }: { subscriptionUri?: string } = {}) { const httpLink = new HttpLink({ credentials: 'include', uri }); + const subsLink = subscriptionUri - ? new WebSocketLink({ - uri: subscriptionUri, - options: { reconnect: true }, + ? new ApolloLink((operation) => { + const observable = new Observable((observer) => { + const client = createClient({ url: subscriptionUri }); + + const { variables } = operation; + // @ts-ignore todo - update env to latest graphql version + const query = print(operation.query); + + const dispose = client.subscribe( + { query, variables }, + { + next: (data) => observer.next({ data }), + error: (error) => observer.error(error), + complete: () => observer.complete(), + } + ); + + return () => { + dispose(); + }; + }); + + return observable; }) : undefined; diff --git a/scopes/workspace/workspace/ui/workspace/use-workspace.ts b/scopes/workspace/workspace/ui/workspace/use-workspace.ts index b687ba4dc54e..28c73539d030 100644 --- a/scopes/workspace/workspace/ui/workspace/use-workspace.ts +++ b/scopes/workspace/workspace/ui/workspace/use-workspace.ts @@ -1,9 +1,10 @@ import { useEffect, useMemo } from 'react'; import { ComponentModel } from '@teambit/component'; import useLatest from '@react-hook/latest'; -import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query'; +// import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query'; import { gql } from 'graphql-tag'; import { ComponentID, ComponentIdObj } from '@teambit/component-id'; +import { useQuery } from '@apollo/client'; import { Workspace } from './workspace-model'; @@ -115,7 +116,7 @@ const COMPONENT_SUBSCRIPTION_REMOVED = gql` `; export function useWorkspace(options: UseWorkspaceOptions = {}) { - const { data, subscribeToMore, ...rest } = useDataQuery(WORKSPACE); + const { data, subscribeToMore, ...rest } = useQuery(WORKSPACE); const optionsRef = useLatest(options); useEffect(() => { diff --git a/scopes/workspace/workspace/workspace.graphql.ts b/scopes/workspace/workspace/workspace.graphql.ts index 0d6e6c801559..cdd7d2322472 100644 --- a/scopes/workspace/workspace/workspace.graphql.ts +++ b/scopes/workspace/workspace/workspace.graphql.ts @@ -88,7 +88,10 @@ export default (workspace: Workspace, graphql: GraphqlMain) => { resolvers: { Subscription: { componentAdded: { - subscribe: () => graphql.pubsub.asyncIterator(ComponentAdded), + subscribe: () => { + console.log('subscribing to componentAdded'); + return graphql.pubsub.asyncIterator(ComponentAdded); + }, }, componentChanged: { subscribe: () => graphql.pubsub.asyncIterator(ComponentChanged), diff --git a/scopes/workspace/workspace/workspace.ts b/scopes/workspace/workspace/workspace.ts index 21ab0b5d9a23..c8997ec6f1cf 100644 --- a/scopes/workspace/workspace/workspace.ts +++ b/scopes/workspace/workspace/workspace.ts @@ -798,7 +798,9 @@ it's possible that the version ${component.id.version} belong to ${idStr.split(' if (onAddResult) results.push({ extensionId: extension, results: onAddResult }); }); + console.log('🚀 ~ file: workspace.ts:803 ~ Workspace ~ triggerOnComponentAdd ~ ComponentAdded:', ComponentAdded); await this.graphql.pubsub.publish(ComponentAdded, { componentAdded: { component } }); + return results; } From e4593d9a259584f2552b848c6700c85861e0be2f Mon Sep 17 00:00:00 2001 From: Luv Kapur Date: Sun, 7 Apr 2024 07:36:07 -0400 Subject: [PATCH 13/32] successfully remove subscriptions-transport-ws --- scopes/harmony/graphql/create-link.ts | 4 +-- .../harmony/graphql/graphql.main.runtime.ts | 35 +++++++++++-------- scopes/harmony/graphql/graphql.ui.runtime.tsx | 13 ++++--- .../workspace/ui/workspace/use-workspace.ts | 3 ++ workspace.jsonc | 1 - 5 files changed, 33 insertions(+), 23 deletions(-) diff --git a/scopes/harmony/graphql/create-link.ts b/scopes/harmony/graphql/create-link.ts index b5fedc95019f..66b1ab9e4efc 100644 --- a/scopes/harmony/graphql/create-link.ts +++ b/scopes/harmony/graphql/create-link.ts @@ -1,4 +1,4 @@ -import { HttpLink, split, ApolloLink } from '@apollo/client'; +import { split, ApolloLink } from '@apollo/client'; import { getMainDefinition } from '@apollo/client/utilities'; /** @@ -6,7 +6,7 @@ import { getMainDefinition } from '@apollo/client/utilities'; * @param httpLink http link for apollo graphql * @param wsLink web socket link for apollo graphql */ -export function createSplitLink(httpLink: HttpLink, wsLink: ApolloLink) { +export function createSplitLink(httpLink: ApolloLink, wsLink: ApolloLink) { return split( // split based on operation type ({ query }) => { diff --git a/scopes/harmony/graphql/graphql.main.runtime.ts b/scopes/harmony/graphql/graphql.main.runtime.ts index 07366191adf9..eee3e5abca67 100644 --- a/scopes/harmony/graphql/graphql.main.runtime.ts +++ b/scopes/harmony/graphql/graphql.main.runtime.ts @@ -288,10 +288,6 @@ export class GraphqlMain { console.error('Websocket error', err); }); websocketServer.handleUpgrade(request, socket, head, (websocket) => { - console.log( - '🚀 ~ file: graphql.main.runtime.ts:288 ~ GraphqlMain ~ websocketServer.handleUpgrade ~ request:', - request.url - ); websocketServer.emit('connection', websocket, request); }); } else { @@ -302,17 +298,26 @@ export class GraphqlMain { return useServer( { schema, - execute, - subscribe, - onError: (err) => { - this.logger.error('graphql error ', err); - console.error('graphql error ', err); - }, - onConnect: () => console.error('Client connected to WebSocket.'), - onDisconnect: () => console.error('Client disconnected from WebSocket.'), - context: (ctx) => { - options?.onWsConnect && options.onWsConnect(ctx.connectionParams); - }, + // execute, + // subscribe, + // onError: (err) => { + // this.logger.error('graphql error ', err); + // console.error('graphql error ', err); + // }, + // onConnect: (ctx) => { + // console.log("🚀 ~ file: graphql.main.runtime.ts:313 ~ GraphqlMain ~ createSubscription ~ ctx:", ctx) + // console.error('Client connected to WebSocket.') + // return { + // ...ctx + // }; + // }, + // onDisconnect: () => {console.error('Client disconnected from WebSocket.')}, + // context: (ctx) => { + // this.logger.error('graphql error ', err); + // console.log("🚀 ~ file: graphql.main.runtime.ts:315 ~ GraphqlMain ~ createSubscription ~ ctx:", ctx) + // options?.onWsConnect && options.onWsConnect(ctx.connectionParams); + // return ctx; + // }, }, websocketServer ); diff --git a/scopes/harmony/graphql/graphql.ui.runtime.tsx b/scopes/harmony/graphql/graphql.ui.runtime.tsx index 83fb743f8f2c..5129ae2c53e8 100644 --- a/scopes/harmony/graphql/graphql.ui.runtime.tsx +++ b/scopes/harmony/graphql/graphql.ui.runtime.tsx @@ -66,18 +66,21 @@ export class GraphqlUI { } private createLink(uri: string, { subscriptionUri }: { subscriptionUri?: string } = {}) { - const httpLink = new HttpLink({ credentials: 'include', uri }); + const httpLink = createHttpLink({ + credentials: 'include', + uri, + fetch: crossFetch, + }); + const wsClient = subscriptionUri ? createClient({ url: subscriptionUri }) : undefined; const subsLink = subscriptionUri ? new ApolloLink((operation) => { const observable = new Observable((observer) => { - const client = createClient({ url: subscriptionUri }); - const { variables } = operation; // @ts-ignore todo - update env to latest graphql version const query = print(operation.query); - const dispose = client.subscribe( + const dispose = wsClient?.subscribe( { query, variables }, { next: (data) => observer.next({ data }), @@ -87,7 +90,7 @@ export class GraphqlUI { ); return () => { - dispose(); + dispose?.(); }; }); diff --git a/scopes/workspace/workspace/ui/workspace/use-workspace.ts b/scopes/workspace/workspace/ui/workspace/use-workspace.ts index 28c73539d030..5fdb77796f64 100644 --- a/scopes/workspace/workspace/ui/workspace/use-workspace.ts +++ b/scopes/workspace/workspace/ui/workspace/use-workspace.ts @@ -149,6 +149,9 @@ export function useWorkspace(options: UseWorkspaceOptions = {}) { document: COMPONENT_SUBSCRIPTION_CHANGED, updateQuery: (prev, { subscriptionData }) => { const update = subscriptionData.data; + + console.log('🚀 ~ file: use-workspace.ts:153 ~ useEffect ~ update:', update); + if (!update) return prev; const updatedComponent = update.componentChanged.component; diff --git a/workspace.jsonc b/workspace.jsonc index 79a9df8413c1..d80d4f045a5b 100644 --- a/workspace.jsonc +++ b/workspace.jsonc @@ -484,7 +484,6 @@ "ssri": "10.0.1", "string_decoder": "^1.3.0", "strip-ansi": "6.0.0", - "subscriptions-transport-ws": "^0.11.0", "symlink-dir": "^5.1.1", "table": "6.7.3", "terser-webpack-plugin": "5.2.0", From 0d3a0952329ab854a40fe3f43bfb370145c87dfb Mon Sep 17 00:00:00 2001 From: Luv Kapur Date: Mon, 8 Apr 2024 13:58:09 -0400 Subject: [PATCH 14/32] wip - fix subscriptions --- scopes/harmony/graphql/create-link.ts | 2 +- .../harmony/graphql/graphql.main.runtime.ts | 87 ++++++++++--------- workspace.jsonc | 5 +- 3 files changed, 50 insertions(+), 44 deletions(-) diff --git a/scopes/harmony/graphql/create-link.ts b/scopes/harmony/graphql/create-link.ts index 66b1ab9e4efc..fbaa63bf97e6 100644 --- a/scopes/harmony/graphql/create-link.ts +++ b/scopes/harmony/graphql/create-link.ts @@ -1,5 +1,5 @@ -import { split, ApolloLink } from '@apollo/client'; import { getMainDefinition } from '@apollo/client/utilities'; +import { ApolloLink, split } from '@apollo/client'; /** * create a link which splits routes data depending on type of operation. diff --git a/scopes/harmony/graphql/graphql.main.runtime.ts b/scopes/harmony/graphql/graphql.main.runtime.ts index eee3e5abca67..48f2b083963f 100644 --- a/scopes/harmony/graphql/graphql.main.runtime.ts +++ b/scopes/harmony/graphql/graphql.main.runtime.ts @@ -3,6 +3,7 @@ import { WebSocketServer } from 'ws'; import { ApolloServer } from '@apollo/server'; import { expressMiddleware } from '@apollo/server/express4'; import { ApolloServerPluginDrainHttpServer } from '@apollo/server/plugin/drainHttpServer'; +import httpProxy from 'http-proxy'; import { ApolloServerPluginLandingPageDisabled } from '@apollo/server/plugin/disabled'; import { useServer } from 'graphql-ws/lib/use/ws'; import { Module, createModule, createApplication, Application } from 'graphql-modules'; @@ -16,7 +17,7 @@ import { createServer, Server } from 'http'; import compact from 'lodash.compact'; import cors from 'cors'; import { GraphQLServer } from './graphql-server'; -import { execute, subscribe } from 'graphql'; +import { GraphQLSchema, subscribe as graphqlSubscribe } from 'graphql'; import { createRemoteSchemas } from './create-remote-schemas'; import { GraphqlAspect } from './graphql.aspect'; import { Schema } from './schema'; @@ -26,6 +27,8 @@ export enum Verb { READ = 'read', } +export type Subscribe = typeof graphqlSubscribe; + export type GraphQLConfig = { port: number; subscriptionsPortRange: number[]; @@ -202,6 +205,8 @@ export class GraphqlMain { const httpServer = createServer(app); const localSchema = this.createRootModule(options.schemaSlot); + const subscribe = localSchema.createSubscription(); + const execute = localSchema.createExecution(); // const remoteSchemas = await createRemoteSchemas(options.remoteSchemas || this.graphQLServerSlot.values()); // const schemas = [localSchema.schema].concat(remoteSchemas).filter((x) => x); // const schemas = [localSchema.schema].concat([]).filter((x) => x); @@ -209,9 +214,25 @@ export class GraphqlMain { // schemas, // }); - const subscriptionServerCleanup = await this.createSubscription(localSchema.schema, httpServer, options); + // const subscriptionsPort = options.subscriptionsPortRange || this.config.subscriptionsPortRange; + + // const subscriptionServerPort = await this.getPort(subscriptionsPort); + + // console.log("🚀 ~ file: graphql.main.runtime.ts:220 ~ GraphqlMain ~ createServer ~ subscriptionServerPort:", subscriptionServerPort) + + const subscriptionServerCleanup = await this.createSubscription( + localSchema.schema, + httpServer, + options, + subscribe, + execute + ); + + // this.proxySubscription(httpServer, subscriptionServerPort) + const apolloServer = new ApolloServer({ gateway: { + // @ts-ignore - todo this fixes when update graphql on the core-aspect-env async load() { return { executor: localSchema.createApolloExecutor() }; }, @@ -274,50 +295,33 @@ export class GraphqlMain { return httpServer; } - async createSubscription(schema, httpServer, options) { + async createSubscription( + schema: GraphQLSchema, + httpServer: Server, + options: GraphQLServerOptions, + subscribe: Subscribe, + execute + ) { const websocketServer = new WebSocketServer({ noServer: true, path: this.config.subscriptionsPath, - // server: httpServer, }); - httpServer.on('upgrade', (request, socket, head) => { - // Only handle upgrades for the specific path, otherwise ignore - if (request.url.startsWith(this.config.subscriptionsPath)) { - websocketServer.on('error', (err) => { - console.error('Websocket error', err); - }); + if (request.url?.startsWith(this.config.subscriptionsPath)) { websocketServer.handleUpgrade(request, socket, head, (websocket) => { websocketServer.emit('connection', websocket, request); }); - } else { - console.log('Upgrade request not matched:', request.url); } }); return useServer( { schema, - // execute, - // subscribe, - // onError: (err) => { - // this.logger.error('graphql error ', err); - // console.error('graphql error ', err); - // }, - // onConnect: (ctx) => { - // console.log("🚀 ~ file: graphql.main.runtime.ts:313 ~ GraphqlMain ~ createSubscription ~ ctx:", ctx) - // console.error('Client connected to WebSocket.') - // return { - // ...ctx - // }; - // }, - // onDisconnect: () => {console.error('Client disconnected from WebSocket.')}, - // context: (ctx) => { - // this.logger.error('graphql error ', err); - // console.log("🚀 ~ file: graphql.main.runtime.ts:315 ~ GraphqlMain ~ createSubscription ~ ctx:", ctx) - // options?.onWsConnect && options.onWsConnect(ctx.connectionParams); - // return ctx; - // }, + subscribe, + execute, + onConnect: () => { + options?.onWsConnect?.(); + }, }, websocketServer ); @@ -372,15 +376,15 @@ export class GraphqlMain { /** proxy ws Subscription server to avoid conflict with different websocket connections */ - // private proxySubscription(server: Server, port: number) { - // const proxServer = httpProxy.createProxyServer(); - // const subscriptionsPath = this.config.subscriptionsPath; - // server.on('upgrade', function (req, socket, head) { - // if (req.url === subscriptionsPath) { - // proxServer.ws(req, socket, head, { target: { host: 'localhost', port } }); - // } - // }); - // } + private proxySubscription(server: Server, port: number) { + const proxServer = httpProxy.createProxyServer(); + const subscriptionsPath = this.config.subscriptionsPath; + server.on('upgrade', function (req, socket, head) { + if (req.url === subscriptionsPath) { + proxServer.ws(req, socket, head, { target: { host: 'localhost', port } }); + } + }); + } private createRootModule(schemaSlot?: SchemaSlot): Application { const modules = this.buildModules(schemaSlot); @@ -408,6 +412,7 @@ export class GraphqlMain { port: 4000, disableCors: false, subscriptionsPath: '/subscriptions', + // subscriptionsPortRange: [2000, 2100], }; static runtime = MainRuntime; diff --git a/workspace.jsonc b/workspace.jsonc index d80d4f045a5b..7240bc1c1cd9 100644 --- a/workspace.jsonc +++ b/workspace.jsonc @@ -510,7 +510,7 @@ "yesno": "0.4.0" }, "peerDependencies": { - "@apollo/client": "^3.9.0", + "@apollo/client": "^3.9.7", "@teambit/base-react.navigation.link": "2.0.27", "@teambit/legacy": "1.0.680", "@testing-library/react": "^12.1.5", @@ -528,7 +528,8 @@ "signal-exit@4": "^4.0.2", "@types/react": "^17.0.67", "@types/react-dom": "^17.0.21", - "minio@7.0": "7.1.1" + "minio@7.0": "7.1.1", + "@apollo/client": "^3.9.7" }, "rootComponents": true, "nodeVersion": "20.11.1", From ba69c5cb094579f1f1d8b06684fdfae4218e54af Mon Sep 17 00:00:00 2001 From: Luv Kapur Date: Mon, 8 Apr 2024 13:58:28 -0400 Subject: [PATCH 15/32] clean up --- .../harmony/graphql/graphql.main.runtime.ts | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/scopes/harmony/graphql/graphql.main.runtime.ts b/scopes/harmony/graphql/graphql.main.runtime.ts index 48f2b083963f..584f13766ea5 100644 --- a/scopes/harmony/graphql/graphql.main.runtime.ts +++ b/scopes/harmony/graphql/graphql.main.runtime.ts @@ -374,17 +374,17 @@ export class GraphqlMain { return Port.getPort(from, to); } - /** proxy ws Subscription server to avoid conflict with different websocket connections */ - - private proxySubscription(server: Server, port: number) { - const proxServer = httpProxy.createProxyServer(); - const subscriptionsPath = this.config.subscriptionsPath; - server.on('upgrade', function (req, socket, head) { - if (req.url === subscriptionsPath) { - proxServer.ws(req, socket, head, { target: { host: 'localhost', port } }); - } - }); - } + // /** proxy ws Subscription server to avoid conflict with different websocket connections */ + + // private proxySubscription(server: Server, port: number) { + // const proxServer = httpProxy.createProxyServer(); + // const subscriptionsPath = this.config.subscriptionsPath; + // server.on('upgrade', function (req, socket, head) { + // if (req.url === subscriptionsPath) { + // proxServer.ws(req, socket, head, { target: { host: 'localhost', port } }); + // } + // }); + // } private createRootModule(schemaSlot?: SchemaSlot): Application { const modules = this.buildModules(schemaSlot); From 3342a6a931ebcae5bbceb54d8467dcd4d0681b52 Mon Sep 17 00:00:00 2001 From: Luv Kapur Date: Mon, 8 Apr 2024 15:57:03 -0400 Subject: [PATCH 16/32] wip - fix ws subscriptions --- .../compilation/bundler/dev-server.graphql.ts | 1 + .../harmony/graphql/graphql.main.runtime.ts | 19 +++++++++++-------- .../workspace/ui/workspace/use-workspace.ts | 10 +++++----- .../workspace/workspace/workspace.graphql.ts | 1 - 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/scopes/compilation/bundler/dev-server.graphql.ts b/scopes/compilation/bundler/dev-server.graphql.ts index 87fed26600c3..7b9fcd427c01 100644 --- a/scopes/compilation/bundler/dev-server.graphql.ts +++ b/scopes/compilation/bundler/dev-server.graphql.ts @@ -26,6 +26,7 @@ export function devServerSchema(bundler: BundlerMain): Schema { // the gotHost.get query is "id". // see it in scopes/component/component/component.graphql.ts const requestedId = context.body.variables.id; + console.log('🚀 ~ file: dev-server.graphql.ts:30 ~ devServerSchema ~ requestedId:', requestedId); // if we ask for specific id with specific version it means we want to fetch if from scope // so don't return the server url // see https://github.com/teambit/bit/issues/5328 diff --git a/scopes/harmony/graphql/graphql.main.runtime.ts b/scopes/harmony/graphql/graphql.main.runtime.ts index 584f13766ea5..5868c0995a87 100644 --- a/scopes/harmony/graphql/graphql.main.runtime.ts +++ b/scopes/harmony/graphql/graphql.main.runtime.ts @@ -17,7 +17,7 @@ import { createServer, Server } from 'http'; import compact from 'lodash.compact'; import cors from 'cors'; import { GraphQLServer } from './graphql-server'; -import { GraphQLSchema, subscribe as graphqlSubscribe } from 'graphql'; +import { GraphQLSchema, subscribe as graphqlSubscribe, execute as graphqlExecute } from 'graphql'; import { createRemoteSchemas } from './create-remote-schemas'; import { GraphqlAspect } from './graphql.aspect'; import { Schema } from './schema'; @@ -28,6 +28,7 @@ export enum Verb { } export type Subscribe = typeof graphqlSubscribe; +export type Execute = typeof graphqlExecute; export type GraphQLConfig = { port: number; @@ -245,7 +246,6 @@ export class GraphqlMain { async stop() {}, }, // schema: localSchema.schema, - // schema: localSchema.schema, plugins: compact([ ApolloServerPluginDrainHttpServer({ httpServer }), !graphiql ? ApolloServerPluginLandingPageDisabled() : null, @@ -300,7 +300,7 @@ export class GraphqlMain { httpServer: Server, options: GraphQLServerOptions, subscribe: Subscribe, - execute + execute: Execute ) { const websocketServer = new WebSocketServer({ noServer: true, @@ -369,10 +369,10 @@ export class GraphqlMain { return this; } - private async getPort(range: number[]) { - const [from, to] = range; - return Port.getPort(from, to); - } + // private async getPort(range: number[]) { + // const [from, to] = range; + // return Port.getPort(from, to); + // } // /** proxy ws Subscription server to avoid conflict with different websocket connections */ @@ -388,7 +388,9 @@ export class GraphqlMain { private createRootModule(schemaSlot?: SchemaSlot): Application { const modules = this.buildModules(schemaSlot); - return createApplication({ modules }); + return createApplication({ + modules, + }); } private buildModules(schemaSlot?: SchemaSlot) { @@ -426,6 +428,7 @@ export class GraphqlMain { ) { const logger = loggerFactory.createLogger(GraphqlAspect.id); const graphqlMain = new GraphqlMain(config, moduleSlot, context, logger, graphQLServerSlot, pubSubSlot); + graphqlMain.registerPubSub(new PubSub()); return graphqlMain; } } diff --git a/scopes/workspace/workspace/ui/workspace/use-workspace.ts b/scopes/workspace/workspace/ui/workspace/use-workspace.ts index 5fdb77796f64..51e180840502 100644 --- a/scopes/workspace/workspace/ui/workspace/use-workspace.ts +++ b/scopes/workspace/workspace/ui/workspace/use-workspace.ts @@ -56,10 +56,6 @@ const wcComponentFields = gql` isDeprecate newId } - server { - env - url - } env { id icon @@ -75,6 +71,10 @@ const WORKSPACE = gql` icon components { ...wcComponentFields + server { + env + url + } } } } @@ -123,7 +123,7 @@ export function useWorkspace(options: UseWorkspaceOptions = {}) { const unSubCompAddition = subscribeToMore({ document: COMPONENT_SUBSCRIPTION_ADDED, updateQuery: (prev, { subscriptionData }) => { - const update = subscriptionData.data; + const update = subscriptionData.data.data; const addedComponent = update?.componentAdded?.component; if (!addedComponent) return prev; diff --git a/scopes/workspace/workspace/workspace.graphql.ts b/scopes/workspace/workspace/workspace.graphql.ts index cdd7d2322472..02d61b9cd591 100644 --- a/scopes/workspace/workspace/workspace.graphql.ts +++ b/scopes/workspace/workspace/workspace.graphql.ts @@ -89,7 +89,6 @@ export default (workspace: Workspace, graphql: GraphqlMain) => { Subscription: { componentAdded: { subscribe: () => { - console.log('subscribing to componentAdded'); return graphql.pubsub.asyncIterator(ComponentAdded); }, }, From 76368d1dc63f4f619d588ff096a624c4ab8f434c Mon Sep 17 00:00:00 2001 From: Luv Kapur Date: Tue, 9 Apr 2024 13:19:43 -0400 Subject: [PATCH 17/32] integrate remote schema stitching --- .../compilation/bundler/dev-server.graphql.ts | 1 - .../harmony/graphql/graphql.main.runtime.ts | 135 ++---------------- scopes/ui-foundation/ui/ui-server.ts | 1 + scopes/workspace/workspace/workspace.ts | 1 - 4 files changed, 12 insertions(+), 126 deletions(-) diff --git a/scopes/compilation/bundler/dev-server.graphql.ts b/scopes/compilation/bundler/dev-server.graphql.ts index 7b9fcd427c01..87fed26600c3 100644 --- a/scopes/compilation/bundler/dev-server.graphql.ts +++ b/scopes/compilation/bundler/dev-server.graphql.ts @@ -26,7 +26,6 @@ export function devServerSchema(bundler: BundlerMain): Schema { // the gotHost.get query is "id". // see it in scopes/component/component/component.graphql.ts const requestedId = context.body.variables.id; - console.log('🚀 ~ file: dev-server.graphql.ts:30 ~ devServerSchema ~ requestedId:', requestedId); // if we ask for specific id with specific version it means we want to fetch if from scope // so don't return the server url // see https://github.com/teambit/bit/issues/5328 diff --git a/scopes/harmony/graphql/graphql.main.runtime.ts b/scopes/harmony/graphql/graphql.main.runtime.ts index 5868c0995a87..7e40e1813a7b 100644 --- a/scopes/harmony/graphql/graphql.main.runtime.ts +++ b/scopes/harmony/graphql/graphql.main.runtime.ts @@ -3,7 +3,6 @@ import { WebSocketServer } from 'ws'; import { ApolloServer } from '@apollo/server'; import { expressMiddleware } from '@apollo/server/express4'; import { ApolloServerPluginDrainHttpServer } from '@apollo/server/plugin/drainHttpServer'; -import httpProxy from 'http-proxy'; import { ApolloServerPluginLandingPageDisabled } from '@apollo/server/plugin/disabled'; import { useServer } from 'graphql-ws/lib/use/ws'; import { Module, createModule, createApplication, Application } from 'graphql-modules'; @@ -11,7 +10,6 @@ import { MainRuntime } from '@teambit/cli'; import { Harmony, Slot, SlotRegistry } from '@teambit/harmony'; import { Logger, LoggerAspect, LoggerMain } from '@teambit/logger'; import express, { Express } from 'express'; -import { Port } from '@teambit/toolbox.network.get-port'; import { PubSubEngine, PubSub } from 'graphql-subscriptions'; import { createServer, Server } from 'http'; import compact from 'lodash.compact'; @@ -112,117 +110,24 @@ export class GraphqlMain { }); } - // async createServer(options: GraphQLServerOptions) { - // const { graphiql = true, disableIntrospection } = options; - // const localSchema = this.createRootModule(options.schemaSlot); - // const remoteSchemas = await createRemoteSchemas(options.remoteSchemas || this.graphQLServerSlot.values()); - // const schemas = [localSchema.schema].concat(remoteSchemas).filter((x) => x); - // const schema = mergeSchemas({ - // schemas, - // }); - - // // TODO: @guy please consider to refactor to express extension. - // const app = options.app || express(); - // if (!this.config.disableCors) { - // app.use( - // // @ts-ignore todo: it's not clear what's the issue. - // cors({ - // origin(origin, callback) { - // callback(null, true); - // }, - // credentials: true, - // }) - // ); - // } - - // app.use( - // '/graphql', - // createGraphqlHandler({ - // schema, - // validationRules: disableIntrospection - // ? [ - // function NoIntrospection(context) { - // return { - // Field(node) { - // if (node.name.value === '__schema' || node.name.value === '__type') { - // context.reportError( - // new GraphQLError( - // 'GraphQL introspection is not allowed, but the query contained __schema or __type', - // [node] - // ) - // ); - // } - // }, - // }; - // }, - // ] - // : undefined, - // formatError: (err) => { - // this.logger.error('graphql error ', err); - // return Object.assign(err, { - // // @ts-ignore - // ERR_CODE: err?.originalError?.errors?.[0].ERR_CODE || err.originalError?.constructor?.name, - // // @ts-ignore - // HTTP_CODE: err?.originalError?.errors?.[0].HTTP_CODE || err.originalError?.code, - // }); - // }, - // }) - // ); - - // // todo - add graphiql middleware for playground - - // // app.use( - // // '/graphql', - // // // eslint-disable-next-line @typescript-eslint/no-misused-promises - // // graphqlHTTP((request, res, params) => ({ - // // customFormatErrorFn: (err) => { - // // this.logger.error('graphql got an error during running the following query:', params); - // // this.logger.error('graphql error ', err); - // // return Object.assign(err, { - // // // @ts-ignore - // // ERR_CODE: err?.originalError?.errors?.[0].ERR_CODE || err.originalError?.constructor?.name, - // // // @ts-ignore - // // HTTP_CODE: err?.originalError?.errors?.[0].HTTP_CODE || err.originalError?.code, s - // // }); - // // }, - // // schema, - // // rootValue: request, - // // graphiql, - // // validationRules: disableIntrospection ? [NoIntrospection] : undefined, - // // })) - - // const server = createServer(app); - // const subscriptionsPort = options.subscriptionsPortRange || this.config.subscriptionsPortRange; - // const subscriptionServerPort = await this.getPort(subscriptionsPort); - // const { port } = await this.createSubscription(options, subscriptionServerPort); - // this.proxySubscription(server, port); - - // return server; - // } - async createServer(options: GraphQLServerOptions) { const { graphiql = true, disableIntrospection } = options; const app = options.app || express(); const httpServer = createServer(app); - const localSchema = this.createRootModule(options.schemaSlot); - const subscribe = localSchema.createSubscription(); - const execute = localSchema.createExecution(); - // const remoteSchemas = await createRemoteSchemas(options.remoteSchemas || this.graphQLServerSlot.values()); - // const schemas = [localSchema.schema].concat(remoteSchemas).filter((x) => x); - // const schemas = [localSchema.schema].concat([]).filter((x) => x); - // const mergedSchema = mergeSchemas({ - // schemas, - // }); - - // const subscriptionsPort = options.subscriptionsPortRange || this.config.subscriptionsPortRange; + const remoteSchemas = await createRemoteSchemas(options.remoteSchemas || this.graphQLServerSlot.values()); + const application = this.createRootModule(options.schemaSlot); - // const subscriptionServerPort = await this.getPort(subscriptionsPort); + const subscribe = application.createSubscription(); + const execute = application.createExecution(); - // console.log("🚀 ~ file: graphql.main.runtime.ts:220 ~ GraphqlMain ~ createServer ~ subscriptionServerPort:", subscriptionServerPort) + const schemas = [application.schema].concat(remoteSchemas).filter((x) => x); + const mergedSchema = mergeSchemas({ + schemas, + }); const subscriptionServerCleanup = await this.createSubscription( - localSchema.schema, + mergedSchema, httpServer, options, subscribe, @@ -235,17 +140,16 @@ export class GraphqlMain { gateway: { // @ts-ignore - todo this fixes when update graphql on the core-aspect-env async load() { - return { executor: localSchema.createApolloExecutor() }; + return { executor: application.createApolloExecutor() }; }, onSchemaLoadOrUpdate(callback) { - const apiSchema = { apiSchema: localSchema.schema } as any; + const apiSchema = { apiSchema: mergedSchema } as any; callback(apiSchema); return () => {}; }, // eslint-disable-next-line @typescript-eslint/no-empty-function async stop() {}, }, - // schema: localSchema.schema, plugins: compact([ ApolloServerPluginDrainHttpServer({ httpServer }), !graphiql ? ApolloServerPluginLandingPageDisabled() : null, @@ -369,23 +273,6 @@ export class GraphqlMain { return this; } - // private async getPort(range: number[]) { - // const [from, to] = range; - // return Port.getPort(from, to); - // } - - // /** proxy ws Subscription server to avoid conflict with different websocket connections */ - - // private proxySubscription(server: Server, port: number) { - // const proxServer = httpProxy.createProxyServer(); - // const subscriptionsPath = this.config.subscriptionsPath; - // server.on('upgrade', function (req, socket, head) { - // if (req.url === subscriptionsPath) { - // proxServer.ws(req, socket, head, { target: { host: 'localhost', port } }); - // } - // }); - // } - private createRootModule(schemaSlot?: SchemaSlot): Application { const modules = this.buildModules(schemaSlot); return createApplication({ diff --git a/scopes/ui-foundation/ui/ui-server.ts b/scopes/ui-foundation/ui/ui-server.ts index db3a7dafa353..99cf6144bbf2 100644 --- a/scopes/ui-foundation/ui/ui-server.ts +++ b/scopes/ui-foundation/ui/ui-server.ts @@ -180,6 +180,7 @@ export class UIServer { */ async dev({ portRange }: StartOptions = {}) { const devServerPort = await this.selectPort(portRange); + await this.start({ portRange: [4100, 4200] }); const expressAppPort = this._port; diff --git a/scopes/workspace/workspace/workspace.ts b/scopes/workspace/workspace/workspace.ts index c8997ec6f1cf..f61751850131 100644 --- a/scopes/workspace/workspace/workspace.ts +++ b/scopes/workspace/workspace/workspace.ts @@ -798,7 +798,6 @@ it's possible that the version ${component.id.version} belong to ${idStr.split(' if (onAddResult) results.push({ extensionId: extension, results: onAddResult }); }); - console.log('🚀 ~ file: workspace.ts:803 ~ Workspace ~ triggerOnComponentAdd ~ ComponentAdded:', ComponentAdded); await this.graphql.pubsub.publish(ComponentAdded, { componentAdded: { component } }); return results; From 9f978244e19be8974ce06ca1161078981ffe7228 Mon Sep 17 00:00:00 2001 From: Luv Kapur Date: Tue, 9 Apr 2024 13:31:40 -0400 Subject: [PATCH 18/32] bump core aspect env version --- .bitmap | 480 ++++++++++++++---- scopes/defender/eslint/component.json | 2 +- .../harmony/graphql/graphql.main.runtime.ts | 5 - scopes/react/react-native/component.json | 2 +- scopes/ui-foundation/ui/component.json | 2 +- 5 files changed, 387 insertions(+), 104 deletions(-) diff --git a/.bitmap b/.bitmap index 6e118587e58d..72dd7dbb2d80 100644 --- a/.bitmap +++ b/.bitmap @@ -14,21 +14,30 @@ "scope": "teambit.api-reference", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/api-reference/api-reference" + "rootDir": "scopes/api-reference/api-reference", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "api-server": { "name": "api-server", "scope": "teambit.harmony", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/harmony/api-server" + "rootDir": "scopes/harmony/api-server", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "application": { "name": "application", "scope": "teambit.harmony", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/harmony/application" + "rootDir": "scopes/harmony/application", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "array/duplications-finder": { "name": "array/duplications-finder", @@ -42,7 +51,10 @@ "scope": "teambit.harmony", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/harmony/aspect" + "rootDir": "scopes/harmony/aspect", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "aspect-docs/babel": { "name": "aspect-docs/babel", @@ -196,14 +208,20 @@ "scope": "teambit.harmony", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/harmony/aspect-loader" + "rootDir": "scopes/harmony/aspect-loader", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "babel": { "name": "babel", "scope": "teambit.compilation", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/compilation/babel" + "rootDir": "scopes/compilation/babel", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "babel/bit-react-transformer": { "name": "babel/bit-react-transformer", @@ -217,14 +235,20 @@ "scope": "teambit.harmony", "version": "1.6.119", "mainFile": "index.ts", - "rootDir": "scopes/harmony/bit" + "rootDir": "scopes/harmony/bit", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "builder": { "name": "builder", "scope": "teambit.pipelines", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/pipelines/builder" + "rootDir": "scopes/pipelines/builder", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "builder-data": { "name": "builder-data", @@ -238,42 +262,60 @@ "scope": "teambit.compilation", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/compilation/bundler" + "rootDir": "scopes/compilation/bundler", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "cache": { "name": "cache", "scope": "teambit.harmony", "version": "0.0.952", "mainFile": "index.ts", - "rootDir": "scopes/harmony/cache" + "rootDir": "scopes/harmony/cache", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "changelog": { "name": "changelog", "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/changelog" + "rootDir": "scopes/component/changelog", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "checkout": { "name": "checkout", "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/checkout" + "rootDir": "scopes/component/checkout", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "clear-cache": { "name": "clear-cache", "scope": "teambit.workspace", "version": "0.0.405", "mainFile": "index.ts", - "rootDir": "scopes/workspace/clear-cache" + "rootDir": "scopes/workspace/clear-cache", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "cli": { "name": "cli", "scope": "teambit.harmony", "version": "0.0.859", "mainFile": "index.ts", - "rootDir": "scopes/harmony/cli" + "rootDir": "scopes/harmony/cli", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "cli-table": { "name": "cli-table", @@ -294,56 +336,80 @@ "scope": "teambit.cloud", "version": "0.0.502", "mainFile": "index.ts", - "rootDir": "scopes/cloud/cloud" + "rootDir": "scopes/cloud/cloud", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "code": { "name": "code", "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/code" + "rootDir": "scopes/component/code", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "command-bar": { "name": "command-bar", "scope": "teambit.explorer", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/explorer/command-bar" + "rootDir": "scopes/explorer/command-bar", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "community": { "name": "community", "scope": "teambit.community", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/community/community" + "rootDir": "scopes/community/community", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "compiler": { "name": "compiler", "scope": "teambit.compilation", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/compilation/compiler" + "rootDir": "scopes/compilation/compiler", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "component": { "name": "component", "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/component" + "rootDir": "scopes/component/component", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "component-compare": { "name": "component-compare", "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/component-compare" + "rootDir": "scopes/component/component-compare", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "component-descriptor": { "name": "component-descriptor", "scope": "teambit.component", "version": "0.0.417", "mainFile": "index.ts", - "rootDir": "scopes/component/component-descriptor" + "rootDir": "scopes/component/component-descriptor", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "component-issues": { "name": "component-issues", @@ -357,7 +423,10 @@ "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/component-log" + "rootDir": "scopes/component/component-log", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "component-package-version": { "name": "component-package-version", @@ -371,21 +440,30 @@ "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/component-sizer" + "rootDir": "scopes/component/component-sizer", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "component-tree": { "name": "component-tree", "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/component-tree" + "rootDir": "scopes/component/component-tree", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "component-writer": { "name": "component-writer", "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/component-writer" + "rootDir": "scopes/component/component-writer", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "composition-card": { "name": "composition-card", @@ -399,21 +477,30 @@ "scope": "teambit.compositions", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/compositions/compositions" + "rootDir": "scopes/compositions/compositions", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "config": { "name": "config", "scope": "teambit.harmony", "version": "0.0.977", "mainFile": "index.ts", - "rootDir": "scopes/harmony/config" + "rootDir": "scopes/harmony/config", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "config-merger": { "name": "config-merger", "scope": "teambit.workspace", "version": "0.0.93", "mainFile": "index.ts", - "rootDir": "scopes/workspace/config-merger" + "rootDir": "scopes/workspace/config-merger", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "content/cli-reference": { "name": "content/cli-reference", @@ -427,7 +514,10 @@ "scope": "teambit.dependencies", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/dependencies/dependencies" + "rootDir": "scopes/dependencies/dependencies", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "dependency-resolver": { "name": "dependency-resolver", @@ -441,35 +531,50 @@ "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/deprecation" + "rootDir": "scopes/component/deprecation", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "dev-files": { "name": "dev-files", "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/dev-files" + "rootDir": "scopes/component/dev-files", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "diagnostic": { "name": "diagnostic", "scope": "teambit.harmony", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/harmony/diagnostic" + "rootDir": "scopes/harmony/diagnostic", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "docs": { "name": "docs", "scope": "teambit.docs", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/docs/docs" + "rootDir": "scopes/docs/docs", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "eject": { "name": "eject", "scope": "teambit.workspace", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/workspace/eject" + "rootDir": "scopes/workspace/eject", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "entities/lane-diff": { "name": "entities/lane-diff", @@ -490,14 +595,20 @@ "scope": "teambit.envs", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/envs/env" + "rootDir": "scopes/envs/env", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "envs": { "name": "envs", "scope": "teambit.envs", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/envs/envs" + "rootDir": "scopes/envs/envs", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "eslint": { "name": "eslint", @@ -532,28 +643,40 @@ "scope": "teambit.scope", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/scope/export" + "rootDir": "scopes/scope/export", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "express": { "name": "express", "scope": "teambit.harmony", "version": "0.0.958", "mainFile": "index.ts", - "rootDir": "scopes/harmony/express" + "rootDir": "scopes/harmony/express", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "forking": { "name": "forking", "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/forking" + "rootDir": "scopes/component/forking", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "formatter": { "name": "formatter", "scope": "teambit.defender", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/defender/formatter" + "rootDir": "scopes/defender/formatter", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "fs/hard-link-directory": { "name": "fs/hard-link-directory", @@ -581,42 +704,60 @@ "scope": "teambit.generator", "version": "1.0.227", "mainFile": "index.ts", - "rootDir": "scopes/generator/generator" + "rootDir": "scopes/generator/generator", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "git": { "name": "git", "scope": "teambit.git", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/git/git" + "rootDir": "scopes/git/git", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "global-config": { "name": "global-config", "scope": "teambit.harmony", "version": "0.0.862", "mainFile": "index.ts", - "rootDir": "scopes/harmony/global-config" + "rootDir": "scopes/harmony/global-config", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "graph": { "name": "graph", "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/graph" + "rootDir": "scopes/component/graph", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "graphql": { "name": "graphql", "scope": "teambit.harmony", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/harmony/graphql" + "rootDir": "scopes/harmony/graphql", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "harmony-ui-app": { "name": "harmony-ui-app", "scope": "teambit.ui-foundation", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/ui-foundation/harmony-ui-app/harmony-ui-app" + "rootDir": "scopes/ui-foundation/harmony-ui-app/harmony-ui-app", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "hooks/use-api": { "name": "hooks/use-api", @@ -700,77 +841,110 @@ "scope": "teambit.scope", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/scope/importer" + "rootDir": "scopes/scope/importer", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "insights": { "name": "insights", "scope": "teambit.explorer", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/explorer/insights" + "rootDir": "scopes/explorer/insights", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "install": { "name": "install", "scope": "teambit.workspace", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/workspace/install" + "rootDir": "scopes/workspace/install", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "ipc-events": { "name": "ipc-events", "scope": "teambit.harmony", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/harmony/ipc-events" + "rootDir": "scopes/harmony/ipc-events", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "isolator": { "name": "isolator", "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/isolator" + "rootDir": "scopes/component/isolator", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "issues": { "name": "issues", "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/issues" + "rootDir": "scopes/component/issues", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "jest": { "name": "jest", "scope": "teambit.defender", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/defender/jest" + "rootDir": "scopes/defender/jest", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "lanes": { "name": "lanes", "scope": "teambit.lanes", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/lanes/lanes" + "rootDir": "scopes/lanes/lanes", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "linter": { "name": "linter", "scope": "teambit.defender", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/defender/linter" + "rootDir": "scopes/defender/linter", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "lister": { "name": "lister", "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/lister" + "rootDir": "scopes/component/lister", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "logger": { "name": "logger", "scope": "teambit.harmony", "version": "0.0.952", "mainFile": "index.ts", - "rootDir": "scopes/harmony/logger" + "rootDir": "scopes/harmony/logger", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "mdx": { "name": "mdx", @@ -784,21 +958,30 @@ "scope": "teambit.lanes", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/lanes/merge-lanes" + "rootDir": "scopes/lanes/merge-lanes", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "merging": { "name": "merging", "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/merging" + "rootDir": "scopes/component/merging", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "mocha": { "name": "mocha", "scope": "teambit.defender", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/defender/mocha" + "rootDir": "scopes/defender/mocha", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "model/composition-id": { "name": "model/composition-id", @@ -987,21 +1170,30 @@ "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/mover" + "rootDir": "scopes/component/mover", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "multi-compiler": { "name": "multi-compiler", "scope": "teambit.compilation", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/compilation/multi-compiler" + "rootDir": "scopes/compilation/multi-compiler", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "multi-tester": { "name": "multi-tester", "scope": "teambit.defender", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/defender/multi-tester" + "rootDir": "scopes/defender/multi-tester", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "network/get-port": { "name": "network/get-port", @@ -1015,7 +1207,10 @@ "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/new-component-helper" + "rootDir": "scopes/component/new-component-helper", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "node": { "name": "node", @@ -1029,7 +1224,10 @@ "scope": "teambit.ui-foundation", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/ui-foundation/notifications/aspect" + "rootDir": "scopes/ui-foundation/notifications/aspect", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "overview/api-reference-table-of-contents": { "name": "overview/api-reference-table-of-contents", @@ -1050,7 +1248,10 @@ "scope": "teambit.ui-foundation", "version": "0.0.861", "mainFile": "index.ts", - "rootDir": "scopes/ui-foundation/panels" + "rootDir": "scopes/ui-foundation/panels", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "panels/composition-gallery": { "name": "panels/composition-gallery", @@ -1092,7 +1293,10 @@ "scope": "teambit.pkg", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/pkg/pkg" + "rootDir": "scopes/pkg/pkg", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "plugins/inject-head-webpack-plugin": { "name": "plugins/inject-head-webpack-plugin", @@ -1106,14 +1310,20 @@ "scope": "teambit.dependencies", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/dependencies/pnpm" + "rootDir": "scopes/dependencies/pnpm", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "prettier": { "name": "prettier", "scope": "teambit.defender", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/defender/prettier" + "rootDir": "scopes/defender/prettier", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "prettier/config-mutator": { "name": "prettier/config-mutator", @@ -1127,14 +1337,20 @@ "scope": "teambit.preview", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/preview/preview" + "rootDir": "scopes/preview/preview", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "pubsub": { "name": "pubsub", "scope": "teambit.harmony", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/harmony/pubsub" + "rootDir": "scopes/harmony/pubsub", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "react": { "name": "react", @@ -1155,7 +1371,10 @@ "scope": "teambit.ui-foundation", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/ui-foundation/react-router/react-router" + "rootDir": "scopes/ui-foundation/react-router/react-router", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "readme": { "name": "readme", @@ -1169,21 +1388,30 @@ "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/refactoring" + "rootDir": "scopes/component/refactoring", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "remove": { "name": "remove", "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/remove" + "rootDir": "scopes/component/remove", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "renaming": { "name": "renaming", "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/renaming" + "rootDir": "scopes/component/renaming", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "renderers/api-node-details": { "name": "renderers/api-node-details", @@ -1337,14 +1565,20 @@ "scope": "teambit.semantics", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/semantics/schema" + "rootDir": "scopes/semantics/schema", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "scope": { "name": "scope", "scope": "teambit.scope", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/scope/scope" + "rootDir": "scopes/scope/scope", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "sections/api-reference-page": { "name": "sections/api-reference-page", @@ -1365,35 +1599,50 @@ "scope": "teambit.ui-foundation", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/ui-foundation/sidebar" + "rootDir": "scopes/ui-foundation/sidebar", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "sign": { "name": "sign", "scope": "teambit.scope", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/scope/sign" + "rootDir": "scopes/scope/sign", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "snapping": { "name": "snapping", "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/snapping" + "rootDir": "scopes/component/snapping", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "stash": { "name": "stash", "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/stash" + "rootDir": "scopes/component/stash", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "status": { "name": "status", "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/status" + "rootDir": "scopes/component/status", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "string/capitalize": { "name": "string/capitalize", @@ -1442,7 +1691,10 @@ "scope": "teambit.defender", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/defender/tester" + "rootDir": "scopes/defender/tester", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "testing/load-aspect": { "name": "testing/load-aspect", @@ -1477,7 +1729,10 @@ "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/tracker" + "rootDir": "scopes/component/tracker", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "ts-server": { "name": "ts-server", @@ -1498,7 +1753,10 @@ "scope": "teambit.typescript", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/typescript/typescript" + "rootDir": "scopes/typescript/typescript", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "ui": { "name": "ui", @@ -1876,7 +2134,10 @@ "scope": "teambit.scope", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/scope/update-dependencies" + "rootDir": "scopes/scope/update-dependencies", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "url/add-avatar-query-params": { "name": "url/add-avatar-query-params", @@ -1897,7 +2158,10 @@ "scope": "teambit.ui-foundation", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/ui-foundation/user-agent" + "rootDir": "scopes/ui-foundation/user-agent", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "utils/code-editor-options": { "name": "utils/code-editor-options", @@ -1946,56 +2210,80 @@ "scope": "teambit.workspace", "version": "0.0.1070", "mainFile": "index.ts", - "rootDir": "scopes/workspace/variants" + "rootDir": "scopes/workspace/variants", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "version-history": { "name": "version-history", "scope": "teambit.scope", "version": "0.0.18", "mainFile": "index.ts", - "rootDir": "scopes/scope/version-history" + "rootDir": "scopes/scope/version-history", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "watcher": { "name": "watcher", "scope": "teambit.workspace", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/workspace/watcher" + "rootDir": "scopes/workspace/watcher", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "webpack": { "name": "webpack", "scope": "teambit.webpack", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/webpack/webpack" + "rootDir": "scopes/webpack/webpack", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "worker": { "name": "worker", "scope": "teambit.harmony", "version": "0.0.1163", "mainFile": "index.ts", - "rootDir": "scopes/harmony/worker" + "rootDir": "scopes/harmony/worker", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "workspace": { "name": "workspace", "scope": "teambit.workspace", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/workspace/workspace" + "rootDir": "scopes/workspace/workspace", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "workspace-config-files": { "name": "workspace-config-files", "scope": "teambit.workspace", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/workspace/workspace-config-files" + "rootDir": "scopes/workspace/workspace-config-files", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "yarn": { "name": "yarn", "scope": "teambit.dependencies", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/dependencies/yarn" + "rootDir": "scopes/dependencies/yarn", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "$schema-version": "17.0.0" } \ No newline at end of file diff --git a/scopes/defender/eslint/component.json b/scopes/defender/eslint/component.json index c303ff4a4974..0cae58be23c9 100644 --- a/scopes/defender/eslint/component.json +++ b/scopes/defender/eslint/component.json @@ -18,6 +18,6 @@ "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" }, - "teambit.harmony/envs/core-aspect-env@0.0.27": {} + "teambit.harmony/envs/core-aspect-env@0.0.31": {} } } diff --git a/scopes/harmony/graphql/graphql.main.runtime.ts b/scopes/harmony/graphql/graphql.main.runtime.ts index 7e40e1813a7b..aa47a952031f 100644 --- a/scopes/harmony/graphql/graphql.main.runtime.ts +++ b/scopes/harmony/graphql/graphql.main.runtime.ts @@ -134,11 +134,8 @@ export class GraphqlMain { execute ); - // this.proxySubscription(httpServer, subscriptionServerPort) - const apolloServer = new ApolloServer({ gateway: { - // @ts-ignore - todo this fixes when update graphql on the core-aspect-env async load() { return { executor: application.createApolloExecutor() }; }, @@ -179,7 +176,6 @@ export class GraphqlMain { if (!this.config.disableCors) { app.use( - // @ts-ignore todo: it's not clear what's the issue. cors({ origin(origin, callback) { callback(null, true); @@ -301,7 +297,6 @@ export class GraphqlMain { port: 4000, disableCors: false, subscriptionsPath: '/subscriptions', - // subscriptionsPortRange: [2000, 2100], }; static runtime = MainRuntime; diff --git a/scopes/react/react-native/component.json b/scopes/react/react-native/component.json index 5e73a9245c28..9f7976296064 100644 --- a/scopes/react/react-native/component.json +++ b/scopes/react/react-native/component.json @@ -27,6 +27,6 @@ "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" }, - "teambit.harmony/envs/core-aspect-env@0.0.27": {} + "teambit.harmony/envs/core-aspect-env@0.0.31": {} } } diff --git a/scopes/ui-foundation/ui/component.json b/scopes/ui-foundation/ui/component.json index 51d7c55a6f9f..88059bb90bff 100644 --- a/scopes/ui-foundation/ui/component.json +++ b/scopes/ui-foundation/ui/component.json @@ -31,6 +31,6 @@ "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" }, - "teambit.harmony/envs/core-aspect-env@0.0.27": {} + "teambit.harmony/envs/core-aspect-env@0.0.31": {} } } From 0b54cbbed6d96aa57867d2b84199226d4ad10895 Mon Sep 17 00:00:00 2001 From: Luv Kapur Date: Tue, 9 Apr 2024 13:56:53 -0400 Subject: [PATCH 19/32] lint fix --- scopes/harmony/graphql/graphql.ui.runtime.tsx | 2 +- scopes/workspace/workspace/ui/workspace/use-workspace.ts | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/scopes/harmony/graphql/graphql.ui.runtime.tsx b/scopes/harmony/graphql/graphql.ui.runtime.tsx index 5129ae2c53e8..6a0cc66e52fa 100644 --- a/scopes/harmony/graphql/graphql.ui.runtime.tsx +++ b/scopes/harmony/graphql/graphql.ui.runtime.tsx @@ -4,7 +4,7 @@ import { print } from 'graphql'; import { Observable } from '@apollo/client/utilities'; import { FetchResult } from '@apollo/client/core'; import { UIRuntime } from '@teambit/ui'; -import { InMemoryCache, ApolloClient, ApolloLink, HttpLink, createHttpLink } from '@apollo/client'; +import { InMemoryCache, ApolloClient, ApolloLink, createHttpLink } from '@apollo/client'; import type { NormalizedCacheObject } from '@apollo/client'; import { onError } from '@apollo/client/link/error'; diff --git a/scopes/workspace/workspace/ui/workspace/use-workspace.ts b/scopes/workspace/workspace/ui/workspace/use-workspace.ts index 51e180840502..7f486b640b42 100644 --- a/scopes/workspace/workspace/ui/workspace/use-workspace.ts +++ b/scopes/workspace/workspace/ui/workspace/use-workspace.ts @@ -150,8 +150,6 @@ export function useWorkspace(options: UseWorkspaceOptions = {}) { updateQuery: (prev, { subscriptionData }) => { const update = subscriptionData.data; - console.log('🚀 ~ file: use-workspace.ts:153 ~ useEffect ~ update:', update); - if (!update) return prev; const updatedComponent = update.componentChanged.component; From ba1fbbc4ce2d3927053d85b506003b9b28085c44 Mon Sep 17 00:00:00 2001 From: Luv Kapur Date: Tue, 9 Apr 2024 14:12:13 -0400 Subject: [PATCH 20/32] merge origin/master --- .bitmap | 460 ++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 368 insertions(+), 92 deletions(-) diff --git a/.bitmap b/.bitmap index 26f08449ec01..95d689251be7 100644 --- a/.bitmap +++ b/.bitmap @@ -208,14 +208,20 @@ "scope": "teambit.harmony", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/harmony/aspect-loader" + "rootDir": "scopes/harmony/aspect-loader", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "babel": { "name": "babel", "scope": "teambit.compilation", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/compilation/babel" + "rootDir": "scopes/compilation/babel", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "babel/bit-react-transformer": { "name": "babel/bit-react-transformer", @@ -229,14 +235,20 @@ "scope": "teambit.harmony", "version": "1.6.119", "mainFile": "index.ts", - "rootDir": "scopes/harmony/bit" + "rootDir": "scopes/harmony/bit", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "builder": { "name": "builder", "scope": "teambit.pipelines", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/pipelines/builder" + "rootDir": "scopes/pipelines/builder", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "builder-data": { "name": "builder-data", @@ -250,42 +262,60 @@ "scope": "teambit.compilation", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/compilation/bundler" + "rootDir": "scopes/compilation/bundler", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "cache": { "name": "cache", "scope": "teambit.harmony", "version": "0.0.952", "mainFile": "index.ts", - "rootDir": "scopes/harmony/cache" + "rootDir": "scopes/harmony/cache", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "changelog": { "name": "changelog", "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/changelog" + "rootDir": "scopes/component/changelog", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "checkout": { "name": "checkout", "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/checkout" + "rootDir": "scopes/component/checkout", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "clear-cache": { "name": "clear-cache", "scope": "teambit.workspace", "version": "0.0.405", "mainFile": "index.ts", - "rootDir": "scopes/workspace/clear-cache" + "rootDir": "scopes/workspace/clear-cache", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "cli": { "name": "cli", "scope": "teambit.harmony", "version": "0.0.859", "mainFile": "index.ts", - "rootDir": "scopes/harmony/cli" + "rootDir": "scopes/harmony/cli", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "cli-table": { "name": "cli-table", @@ -306,56 +336,80 @@ "scope": "teambit.cloud", "version": "0.0.502", "mainFile": "index.ts", - "rootDir": "scopes/cloud/cloud" + "rootDir": "scopes/cloud/cloud", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "code": { "name": "code", "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/code" + "rootDir": "scopes/component/code", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "command-bar": { "name": "command-bar", "scope": "teambit.explorer", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/explorer/command-bar" + "rootDir": "scopes/explorer/command-bar", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "community": { "name": "community", "scope": "teambit.community", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/community/community" + "rootDir": "scopes/community/community", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "compiler": { "name": "compiler", "scope": "teambit.compilation", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/compilation/compiler" + "rootDir": "scopes/compilation/compiler", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "component": { "name": "component", "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/component" + "rootDir": "scopes/component/component", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "component-compare": { "name": "component-compare", "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/component-compare" + "rootDir": "scopes/component/component-compare", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "component-descriptor": { "name": "component-descriptor", "scope": "teambit.component", "version": "0.0.417", "mainFile": "index.ts", - "rootDir": "scopes/component/component-descriptor" + "rootDir": "scopes/component/component-descriptor", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "component-issues": { "name": "component-issues", @@ -369,7 +423,10 @@ "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/component-log" + "rootDir": "scopes/component/component-log", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "component-package-version": { "name": "component-package-version", @@ -383,21 +440,30 @@ "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/component-sizer" + "rootDir": "scopes/component/component-sizer", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "component-tree": { "name": "component-tree", "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/component-tree" + "rootDir": "scopes/component/component-tree", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "component-writer": { "name": "component-writer", "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/component-writer" + "rootDir": "scopes/component/component-writer", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "composition-card": { "name": "composition-card", @@ -411,21 +477,30 @@ "scope": "teambit.compositions", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/compositions/compositions" + "rootDir": "scopes/compositions/compositions", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "config": { "name": "config", "scope": "teambit.harmony", "version": "0.0.977", "mainFile": "index.ts", - "rootDir": "scopes/harmony/config" + "rootDir": "scopes/harmony/config", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "config-merger": { "name": "config-merger", "scope": "teambit.workspace", "version": "0.0.93", "mainFile": "index.ts", - "rootDir": "scopes/workspace/config-merger" + "rootDir": "scopes/workspace/config-merger", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "content/cli-reference": { "name": "content/cli-reference", @@ -439,7 +514,10 @@ "scope": "teambit.dependencies", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/dependencies/dependencies" + "rootDir": "scopes/dependencies/dependencies", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "dependency-resolver": { "name": "dependency-resolver", @@ -456,35 +534,50 @@ "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/deprecation" + "rootDir": "scopes/component/deprecation", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "dev-files": { "name": "dev-files", "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/dev-files" + "rootDir": "scopes/component/dev-files", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "diagnostic": { "name": "diagnostic", "scope": "teambit.harmony", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/harmony/diagnostic" + "rootDir": "scopes/harmony/diagnostic", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "docs": { "name": "docs", "scope": "teambit.docs", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/docs/docs" + "rootDir": "scopes/docs/docs", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "eject": { "name": "eject", "scope": "teambit.workspace", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/workspace/eject" + "rootDir": "scopes/workspace/eject", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "entities/lane-diff": { "name": "entities/lane-diff", @@ -505,14 +598,20 @@ "scope": "teambit.envs", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/envs/env" + "rootDir": "scopes/envs/env", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "envs": { "name": "envs", "scope": "teambit.envs", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/envs/envs" + "rootDir": "scopes/envs/envs", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "eslint": { "name": "eslint", @@ -547,28 +646,40 @@ "scope": "teambit.scope", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/scope/export" + "rootDir": "scopes/scope/export", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "express": { "name": "express", "scope": "teambit.harmony", "version": "0.0.958", "mainFile": "index.ts", - "rootDir": "scopes/harmony/express" + "rootDir": "scopes/harmony/express", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "forking": { "name": "forking", "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/forking" + "rootDir": "scopes/component/forking", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "formatter": { "name": "formatter", "scope": "teambit.defender", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/defender/formatter" + "rootDir": "scopes/defender/formatter", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "fs/hard-link-directory": { "name": "fs/hard-link-directory", @@ -596,42 +707,60 @@ "scope": "teambit.generator", "version": "1.0.227", "mainFile": "index.ts", - "rootDir": "scopes/generator/generator" + "rootDir": "scopes/generator/generator", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "git": { "name": "git", "scope": "teambit.git", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/git/git" + "rootDir": "scopes/git/git", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "global-config": { "name": "global-config", "scope": "teambit.harmony", "version": "0.0.862", "mainFile": "index.ts", - "rootDir": "scopes/harmony/global-config" + "rootDir": "scopes/harmony/global-config", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "graph": { "name": "graph", "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/graph" + "rootDir": "scopes/component/graph", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "graphql": { "name": "graphql", "scope": "teambit.harmony", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/harmony/graphql" + "rootDir": "scopes/harmony/graphql", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "harmony-ui-app": { "name": "harmony-ui-app", "scope": "teambit.ui-foundation", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/ui-foundation/harmony-ui-app/harmony-ui-app" + "rootDir": "scopes/ui-foundation/harmony-ui-app/harmony-ui-app", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "hooks/use-api": { "name": "hooks/use-api", @@ -715,77 +844,110 @@ "scope": "teambit.scope", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/scope/importer" + "rootDir": "scopes/scope/importer", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "insights": { "name": "insights", "scope": "teambit.explorer", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/explorer/insights" + "rootDir": "scopes/explorer/insights", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "install": { "name": "install", "scope": "teambit.workspace", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/workspace/install" + "rootDir": "scopes/workspace/install", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "ipc-events": { "name": "ipc-events", "scope": "teambit.harmony", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/harmony/ipc-events" + "rootDir": "scopes/harmony/ipc-events", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "isolator": { "name": "isolator", "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/isolator" + "rootDir": "scopes/component/isolator", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "issues": { "name": "issues", "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/issues" + "rootDir": "scopes/component/issues", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "jest": { "name": "jest", "scope": "teambit.defender", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/defender/jest" + "rootDir": "scopes/defender/jest", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "lanes": { "name": "lanes", "scope": "teambit.lanes", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/lanes/lanes" + "rootDir": "scopes/lanes/lanes", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "linter": { "name": "linter", "scope": "teambit.defender", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/defender/linter" + "rootDir": "scopes/defender/linter", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "lister": { "name": "lister", "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/lister" + "rootDir": "scopes/component/lister", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "logger": { "name": "logger", "scope": "teambit.harmony", "version": "0.0.952", "mainFile": "index.ts", - "rootDir": "scopes/harmony/logger" + "rootDir": "scopes/harmony/logger", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "mdx": { "name": "mdx", @@ -799,21 +961,30 @@ "scope": "teambit.lanes", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/lanes/merge-lanes" + "rootDir": "scopes/lanes/merge-lanes", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "merging": { "name": "merging", "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/merging" + "rootDir": "scopes/component/merging", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "mocha": { "name": "mocha", "scope": "teambit.defender", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/defender/mocha" + "rootDir": "scopes/defender/mocha", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "model/composition-id": { "name": "model/composition-id", @@ -1002,21 +1173,30 @@ "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/mover" + "rootDir": "scopes/component/mover", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "multi-compiler": { "name": "multi-compiler", "scope": "teambit.compilation", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/compilation/multi-compiler" + "rootDir": "scopes/compilation/multi-compiler", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "multi-tester": { "name": "multi-tester", "scope": "teambit.defender", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/defender/multi-tester" + "rootDir": "scopes/defender/multi-tester", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "network/get-port": { "name": "network/get-port", @@ -1030,7 +1210,10 @@ "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/new-component-helper" + "rootDir": "scopes/component/new-component-helper", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "node": { "name": "node", @@ -1044,7 +1227,10 @@ "scope": "teambit.ui-foundation", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/ui-foundation/notifications/aspect" + "rootDir": "scopes/ui-foundation/notifications/aspect", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "overview/api-reference-table-of-contents": { "name": "overview/api-reference-table-of-contents", @@ -1065,7 +1251,10 @@ "scope": "teambit.ui-foundation", "version": "0.0.861", "mainFile": "index.ts", - "rootDir": "scopes/ui-foundation/panels" + "rootDir": "scopes/ui-foundation/panels", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "panels/composition-gallery": { "name": "panels/composition-gallery", @@ -1107,7 +1296,10 @@ "scope": "teambit.pkg", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/pkg/pkg" + "rootDir": "scopes/pkg/pkg", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "plugins/inject-head-webpack-plugin": { "name": "plugins/inject-head-webpack-plugin", @@ -1121,14 +1313,20 @@ "scope": "teambit.dependencies", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/dependencies/pnpm" + "rootDir": "scopes/dependencies/pnpm", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "prettier": { "name": "prettier", "scope": "teambit.defender", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/defender/prettier" + "rootDir": "scopes/defender/prettier", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "prettier/config-mutator": { "name": "prettier/config-mutator", @@ -1142,14 +1340,20 @@ "scope": "teambit.preview", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/preview/preview" + "rootDir": "scopes/preview/preview", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "pubsub": { "name": "pubsub", "scope": "teambit.harmony", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/harmony/pubsub" + "rootDir": "scopes/harmony/pubsub", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "react": { "name": "react", @@ -1170,7 +1374,10 @@ "scope": "teambit.ui-foundation", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/ui-foundation/react-router/react-router" + "rootDir": "scopes/ui-foundation/react-router/react-router", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "readme": { "name": "readme", @@ -1184,21 +1391,30 @@ "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/refactoring" + "rootDir": "scopes/component/refactoring", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "remove": { "name": "remove", "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/remove" + "rootDir": "scopes/component/remove", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "renaming": { "name": "renaming", "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/renaming" + "rootDir": "scopes/component/renaming", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "renderers/api-node-details": { "name": "renderers/api-node-details", @@ -1352,14 +1568,20 @@ "scope": "teambit.semantics", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/semantics/schema" + "rootDir": "scopes/semantics/schema", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "scope": { "name": "scope", "scope": "teambit.scope", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/scope/scope" + "rootDir": "scopes/scope/scope", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "sections/api-reference-page": { "name": "sections/api-reference-page", @@ -1380,35 +1602,50 @@ "scope": "teambit.ui-foundation", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/ui-foundation/sidebar" + "rootDir": "scopes/ui-foundation/sidebar", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "sign": { "name": "sign", "scope": "teambit.scope", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/scope/sign" + "rootDir": "scopes/scope/sign", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "snapping": { "name": "snapping", "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/snapping" + "rootDir": "scopes/component/snapping", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "stash": { "name": "stash", "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/stash" + "rootDir": "scopes/component/stash", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "status": { "name": "status", "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/status" + "rootDir": "scopes/component/status", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "string/capitalize": { "name": "string/capitalize", @@ -1457,7 +1694,10 @@ "scope": "teambit.defender", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/defender/tester" + "rootDir": "scopes/defender/tester", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "testing/load-aspect": { "name": "testing/load-aspect", @@ -1492,7 +1732,10 @@ "scope": "teambit.component", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/component/tracker" + "rootDir": "scopes/component/tracker", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "ts-server": { "name": "ts-server", @@ -1513,7 +1756,10 @@ "scope": "teambit.typescript", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/typescript/typescript" + "rootDir": "scopes/typescript/typescript", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "ui": { "name": "ui", @@ -1891,7 +2137,10 @@ "scope": "teambit.scope", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/scope/update-dependencies" + "rootDir": "scopes/scope/update-dependencies", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "url/add-avatar-query-params": { "name": "url/add-avatar-query-params", @@ -1912,7 +2161,10 @@ "scope": "teambit.ui-foundation", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/ui-foundation/user-agent" + "rootDir": "scopes/ui-foundation/user-agent", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "utils/code-editor-options": { "name": "utils/code-editor-options", @@ -1961,56 +2213,80 @@ "scope": "teambit.workspace", "version": "0.0.1070", "mainFile": "index.ts", - "rootDir": "scopes/workspace/variants" + "rootDir": "scopes/workspace/variants", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "version-history": { "name": "version-history", "scope": "teambit.scope", "version": "0.0.18", "mainFile": "index.ts", - "rootDir": "scopes/scope/version-history" + "rootDir": "scopes/scope/version-history", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "watcher": { "name": "watcher", "scope": "teambit.workspace", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/workspace/watcher" + "rootDir": "scopes/workspace/watcher", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "webpack": { "name": "webpack", "scope": "teambit.webpack", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/webpack/webpack" + "rootDir": "scopes/webpack/webpack", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "worker": { "name": "worker", "scope": "teambit.harmony", "version": "0.0.1163", "mainFile": "index.ts", - "rootDir": "scopes/harmony/worker" + "rootDir": "scopes/harmony/worker", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "workspace": { "name": "workspace", "scope": "teambit.workspace", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/workspace/workspace" + "rootDir": "scopes/workspace/workspace", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "workspace-config-files": { "name": "workspace-config-files", "scope": "teambit.workspace", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/workspace/workspace-config-files" + "rootDir": "scopes/workspace/workspace-config-files", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "yarn": { "name": "yarn", "scope": "teambit.dependencies", "version": "1.0.226", "mainFile": "index.ts", - "rootDir": "scopes/dependencies/yarn" + "rootDir": "scopes/dependencies/yarn", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {} + } }, "$schema-version": "17.0.0" } \ No newline at end of file From 6bfad5e8ba380d9c2f1037c0653fbb799ccf68c3 Mon Sep 17 00:00:00 2001 From: Luv Kapur Date: Tue, 9 Apr 2024 14:48:21 -0400 Subject: [PATCH 21/32] bump teambit.harmony/envs/core-aspect-env-jest --- .bitmap | 2 +- .../use-lane-diff-status/use-lane-diff-status.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.bitmap b/.bitmap index 95d689251be7..ac528a7fe45d 100644 --- a/.bitmap +++ b/.bitmap @@ -526,7 +526,7 @@ "mainFile": "index.ts", "rootDir": "scopes/dependencies/dependency-resolver", "config": { - "teambit.harmony/envs/core-aspect-env-jest@0.0.11": {} + "teambit.harmony/envs/core-aspect-env-jest@0.0.12": {} } }, "deprecation": { diff --git a/components/ui/compare/lane-compare-hooks/use-lane-diff-status/use-lane-diff-status.ts b/components/ui/compare/lane-compare-hooks/use-lane-diff-status/use-lane-diff-status.ts index 646d00060b10..d8c08b3ca585 100644 --- a/components/ui/compare/lane-compare-hooks/use-lane-diff-status/use-lane-diff-status.ts +++ b/components/ui/compare/lane-compare-hooks/use-lane-diff-status/use-lane-diff-status.ts @@ -1,6 +1,7 @@ import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query'; import { gql } from 'graphql-tag'; import { LaneId } from '@teambit/lane-id'; +import { DocumentNode } from 'graphql'; import { ComponentID, ComponentIdObj } from '@teambit/component-id'; import { LaneDiff, PlainLaneDiff, ChangeType } from '@teambit/lanes.entities.lane-diff'; @@ -21,7 +22,7 @@ export type LaneDiffStatusQueryResponse = { }; }; -export const QUERY_LANE_DIFF_STATUS = gql` +export const QUERY_LANE_DIFF_STATUS: DocumentNode = gql` query LaneDiffStatus($source: String!, $target: String!, $options: DiffStatusOptions) { lanes { id From a6cf185b389e0f8425247418a0fe7cb3de813c6b Mon Sep 17 00:00:00 2001 From: Luv Kapur Date: Tue, 9 Apr 2024 14:57:00 -0400 Subject: [PATCH 22/32] add explicit types for DocumentNode in hooks --- .../use-lane-components.tsx | 3 ++- components/hooks/use-lanes/use-lanes.tsx | 3 ++- .../use-core-aspects/use-core-aspects.tsx | 3 ++- scopes/api-reference/hooks/use-api/use-api.ts | 3 ++- .../hooks/use-schema/use-schema.ts | 3 ++- .../use-cloud-scopes/use-cloud-scopes.ts | 3 ++- .../use-current-user/use-current-user.ts | 3 ++- scopes/cloud/hooks/use-logout/use-logout.ts | 3 ++- .../component/host/use-component-host.ts | 3 ++- .../component/ui/aspect-page/aspect-page.tsx | 3 ++- .../component/ui/use-component.fragments.ts | 19 ++++++++++--------- .../graph/ui/query/get-graph.query.ts | 3 ++- .../workspace/ui/workspace/use-workspace.ts | 12 ++++++------ 13 files changed, 38 insertions(+), 26 deletions(-) diff --git a/components/hooks/use-lane-components/use-lane-components.tsx b/components/hooks/use-lane-components/use-lane-components.tsx index 4334c3fe8b3d..96a4d2087802 100644 --- a/components/hooks/use-lane-components/use-lane-components.tsx +++ b/components/hooks/use-lane-components/use-lane-components.tsx @@ -1,11 +1,12 @@ import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query'; import { gql } from 'graphql-tag'; +import { DocumentNode } from 'graphql'; import { ComponentID, ComponentModel, componentOverviewFields } from '@teambit/component'; import { LaneId } from '@teambit/lane-id'; import { ComponentDescriptor } from '@teambit/component-descriptor'; import { compact } from 'lodash'; -const GET_LANE_COMPONENTS = gql` +const GET_LANE_COMPONENTS: DocumentNode = gql` query LaneComponent($ids: [String!], $extensionId: String, $skipList: Boolean!) { lanes { id diff --git a/components/hooks/use-lanes/use-lanes.tsx b/components/hooks/use-lanes/use-lanes.tsx index 4d1bab271220..d433470d34bf 100644 --- a/components/hooks/use-lanes/use-lanes.tsx +++ b/components/hooks/use-lanes/use-lanes.tsx @@ -2,11 +2,12 @@ import { useMemo, useCallback } from 'react'; import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query'; import { LaneModel, LanesModel, LanesQuery } from '@teambit/lanes.ui.models.lanes-model'; import { gql } from 'graphql-tag'; +import { DocumentNode } from 'graphql'; import { LaneId } from '@teambit/lane-id'; import { isEqual } from 'lodash'; import { useLanesContext } from './lanes-context'; -const GET_LANES = gql` +const GET_LANES: DocumentNode = gql` query Lanes( $extensionId: String $laneIds: [String!] diff --git a/components/ui/hooks/use-core-aspects/use-core-aspects.tsx b/components/ui/hooks/use-core-aspects/use-core-aspects.tsx index d248953638b7..dce291244761 100644 --- a/components/ui/hooks/use-core-aspects/use-core-aspects.tsx +++ b/components/ui/hooks/use-core-aspects/use-core-aspects.tsx @@ -1,11 +1,12 @@ import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query'; import { gql } from 'graphql-tag'; +import { DocumentNode } from 'graphql'; export type CoreAspectIdByPackageName = { [packageName: string]: string; }; -const GET_CORE_ASPECTS = gql` +const GET_CORE_ASPECTS: DocumentNode = gql` query CoreAspects { coreAspects } diff --git a/scopes/api-reference/hooks/use-api/use-api.ts b/scopes/api-reference/hooks/use-api/use-api.ts index 2de023f53a94..9cd0d3a640e3 100644 --- a/scopes/api-reference/hooks/use-api/use-api.ts +++ b/scopes/api-reference/hooks/use-api/use-api.ts @@ -1,9 +1,10 @@ import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query'; import { gql } from 'graphql-tag'; +import { DocumentNode } from 'graphql'; import { APIReferenceModel } from '@teambit/api-reference.models.api-reference-model'; import { APINodeRenderer } from '@teambit/api-reference.models.api-node-renderer'; -const GET_SCHEMA = gql` +const GET_SCHEMA: DocumentNode = gql` query Schema($componentId: String!, $skipInternals: Boolean) { getHost { id # used for GQL caching diff --git a/scopes/api-reference/hooks/use-schema/use-schema.ts b/scopes/api-reference/hooks/use-schema/use-schema.ts index 75b00d2b8118..3a51eb739b6c 100644 --- a/scopes/api-reference/hooks/use-schema/use-schema.ts +++ b/scopes/api-reference/hooks/use-schema/use-schema.ts @@ -1,9 +1,10 @@ import { DataQueryResult, useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query'; import { gql } from 'graphql-tag'; +import { DocumentNode } from 'graphql'; import { SchemaQueryResult, APIReferenceModel } from '@teambit/api-reference.models.api-reference-model'; import { APINodeRenderer } from '@teambit/api-reference.models.api-node-renderer'; -const GET_SCHEMA = gql` +const GET_SCHEMA: DocumentNode = gql` query Schema($extensionId: String!, $componentId: String!) { getHost(id: $extensionId) { id # used for GQL caching diff --git a/scopes/cloud/hooks/use-cloud-scopes/use-cloud-scopes.ts b/scopes/cloud/hooks/use-cloud-scopes/use-cloud-scopes.ts index 4b88c3bce1a1..05e6c54c8e53 100644 --- a/scopes/cloud/hooks/use-cloud-scopes/use-cloud-scopes.ts +++ b/scopes/cloud/hooks/use-cloud-scopes/use-cloud-scopes.ts @@ -1,9 +1,10 @@ import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query'; import { gql } from 'graphql-tag'; +import { DocumentNode } from 'graphql'; import { ScopeDescriptor } from '@teambit/scopes.scope-descriptor'; import { ScopeID } from '@teambit/scopes.scope-id'; -export const GET_CLOUD_SCOPES_QUERY = gql` +export const GET_CLOUD_SCOPES_QUERY: DocumentNode = gql` query GET_CLOUD_SCOPES($ids: [String!]) { getCloudScopes(ids: $ids) { id diff --git a/scopes/cloud/hooks/use-current-user/use-current-user.ts b/scopes/cloud/hooks/use-current-user/use-current-user.ts index ff8db3c2e369..f32560f94f26 100644 --- a/scopes/cloud/hooks/use-current-user/use-current-user.ts +++ b/scopes/cloud/hooks/use-current-user/use-current-user.ts @@ -1,8 +1,9 @@ import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query'; import { gql } from 'graphql-tag'; +import { DocumentNode } from 'graphql'; import { CloudUser } from '@teambit/cloud.models.cloud-user'; -export const CURRENT_USER_QUERY = gql` +export const CURRENT_USER_QUERY: DocumentNode = gql` query CurrentUser($redirectUrl: String!) { getCurrentUser { username diff --git a/scopes/cloud/hooks/use-logout/use-logout.ts b/scopes/cloud/hooks/use-logout/use-logout.ts index 730d9157c3dd..980a5d6c9b3a 100644 --- a/scopes/cloud/hooks/use-logout/use-logout.ts +++ b/scopes/cloud/hooks/use-logout/use-logout.ts @@ -1,7 +1,8 @@ import { useMutation } from '@teambit/ui'; import { gql } from 'graphql-tag'; +import { DocumentNode } from 'graphql'; -export const LOGOUT_MUTATION = gql` +export const LOGOUT_MUTATION: DocumentNode = gql` mutation LogoutUser { logout } diff --git a/scopes/component/component/host/use-component-host.ts b/scopes/component/component/host/use-component-host.ts index e5eb6b17268d..f62086d190a2 100644 --- a/scopes/component/component/host/use-component-host.ts +++ b/scopes/component/component/host/use-component-host.ts @@ -1,9 +1,10 @@ import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query'; import { gql } from 'graphql-tag'; +import { DocumentNode } from 'graphql'; import { ComponentHostModel } from './component-host-model'; -const COMPONENT_HOST = gql` +const COMPONENT_HOST: DocumentNode = gql` { getHost { id # used for GQL caching diff --git a/scopes/component/component/ui/aspect-page/aspect-page.tsx b/scopes/component/component/ui/aspect-page/aspect-page.tsx index 91cfb012f2fa..42e9885a4428 100644 --- a/scopes/component/component/ui/aspect-page/aspect-page.tsx +++ b/scopes/component/component/ui/aspect-page/aspect-page.tsx @@ -2,13 +2,14 @@ import { AspectBox } from '@teambit/harmony.ui.aspect-box'; import React, { useContext } from 'react'; import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query'; import { gql } from 'graphql-tag'; +import { DocumentNode } from 'graphql'; import { EmptyBox } from '@teambit/design.ui.empty-box'; import { H1 } from '@teambit/documenter.ui.heading'; import { Separator } from '@teambit/documenter.ui.separator'; import styles from './aspect-page.module.scss'; import { ComponentContext } from '../context'; -const GET_COMPONENT = gql` +const GET_COMPONENT: DocumentNode = gql` query ($id: String!) { getHost { get(id: $id) { diff --git a/scopes/component/component/ui/use-component.fragments.ts b/scopes/component/component/ui/use-component.fragments.ts index 53e2602dac7d..0bf992e40afe 100644 --- a/scopes/component/component/ui/use-component.fragments.ts +++ b/scopes/component/component/ui/use-component.fragments.ts @@ -1,6 +1,7 @@ import { gql } from 'graphql-tag'; +import { DocumentNode } from 'graphql'; -export const componentIdFields = gql` +export const componentIdFields: DocumentNode = gql` fragment componentIdFields on ComponentID { name version @@ -8,7 +9,7 @@ export const componentIdFields = gql` } `; -export const componentOverviewFields = gql` +export const componentOverviewFields: DocumentNode = gql` fragment componentOverviewFields on Component { id { ...componentIdFields @@ -58,7 +59,7 @@ export const componentOverviewFields = gql` ${componentIdFields} `; -export const componentFields = gql` +export const componentFields: DocumentNode = gql` fragment componentFields on Component { ...componentOverviewFields packageName @@ -74,7 +75,7 @@ export const componentFields = gql` ${componentOverviewFields} `; -export const componentFieldsWithLogs = gql` +export const componentFieldsWithLogs: DocumentNode = gql` fragment componentFieldWithLogs on Component { id { ...componentIdFields @@ -111,7 +112,7 @@ export const COMPONENT_QUERY_LOG_FIELDS = ` $logTakeHeadFromComponent: Boolean `; -export const GET_COMPONENT = gql` +export const GET_COMPONENT: DocumentNode = gql` query Component($extensionId: String!, $id: String!) { getHost(id: $extensionId) { id # used for GQL caching @@ -123,7 +124,7 @@ export const GET_COMPONENT = gql` ${componentFields} `; -export const GET_COMPONENT_WITH_LOGS = gql` +export const GET_COMPONENT_WITH_LOGS: DocumentNode = gql` query Component( $extensionId: String! $id: String! @@ -139,7 +140,7 @@ export const GET_COMPONENT_WITH_LOGS = gql` ${componentFieldsWithLogs} `; -export const SUB_SUBSCRIPTION_ADDED = gql` +export const SUB_SUBSCRIPTION_ADDED: DocumentNode = gql` subscription OnComponentAdded { componentAdded { component { @@ -150,7 +151,7 @@ export const SUB_SUBSCRIPTION_ADDED = gql` ${componentFields} `; -export const SUB_COMPONENT_CHANGED = gql` +export const SUB_COMPONENT_CHANGED: DocumentNode = gql` subscription OnComponentChanged { componentChanged { component { @@ -161,7 +162,7 @@ export const SUB_COMPONENT_CHANGED = gql` ${componentFields} `; -export const SUB_COMPONENT_REMOVED = gql` +export const SUB_COMPONENT_REMOVED: DocumentNode = gql` subscription OnComponentRemoved { componentRemoved { componentIds { diff --git a/scopes/component/graph/ui/query/get-graph.query.ts b/scopes/component/graph/ui/query/get-graph.query.ts index 553a070b52f1..4bdb5ebed8be 100644 --- a/scopes/component/graph/ui/query/get-graph.query.ts +++ b/scopes/component/graph/ui/query/get-graph.query.ts @@ -1,9 +1,10 @@ import { gql } from 'graphql-tag'; +import { DocumentNode } from 'graphql'; import { EdgeType } from '../../edge-type'; // please update types when updating query, for added safety -export const GET_GRAPH = gql` +export const GET_GRAPH: DocumentNode = gql` query graph($ids: [String], $filter: String) { graph(ids: $ids, filter: $filter) { nodes { diff --git a/scopes/workspace/workspace/ui/workspace/use-workspace.ts b/scopes/workspace/workspace/ui/workspace/use-workspace.ts index 7f486b640b42..b0fdf2111d1a 100644 --- a/scopes/workspace/workspace/ui/workspace/use-workspace.ts +++ b/scopes/workspace/workspace/ui/workspace/use-workspace.ts @@ -1,8 +1,8 @@ import { useEffect, useMemo } from 'react'; import { ComponentModel } from '@teambit/component'; import useLatest from '@react-hook/latest'; -// import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query'; import { gql } from 'graphql-tag'; +import { DocumentNode } from 'graphql'; import { ComponentID, ComponentIdObj } from '@teambit/component-id'; import { useQuery } from '@apollo/client'; @@ -15,7 +15,7 @@ type UseWorkspaceOptions = { }; type RawComponent = { id: ComponentIdObj }; -const wcComponentFields = gql` +const wcComponentFields: DocumentNode = gql` fragment wcComponentFields on Component { id { name @@ -63,7 +63,7 @@ const wcComponentFields = gql` } `; -const WORKSPACE = gql` +const WORKSPACE: DocumentNode = gql` query workspace { workspace { name @@ -81,7 +81,7 @@ const WORKSPACE = gql` ${wcComponentFields} `; -const COMPONENT_SUBSCRIPTION_ADDED = gql` +const COMPONENT_SUBSCRIPTION_ADDED: DocumentNode = gql` subscription OnComponentAdded { componentAdded { component { @@ -92,7 +92,7 @@ const COMPONENT_SUBSCRIPTION_ADDED = gql` ${wcComponentFields} `; -const COMPONENT_SUBSCRIPTION_CHANGED = gql` +const COMPONENT_SUBSCRIPTION_CHANGED: DocumentNode = gql` subscription OnComponentChanged { componentChanged { component { @@ -103,7 +103,7 @@ const COMPONENT_SUBSCRIPTION_CHANGED = gql` ${wcComponentFields} `; -const COMPONENT_SUBSCRIPTION_REMOVED = gql` +const COMPONENT_SUBSCRIPTION_REMOVED: DocumentNode = gql` subscription OnComponentRemoved { componentRemoved { componentIds { From 631df4a44b6fbe9c8f234dbc3ba1427a34a52a60 Mon Sep 17 00:00:00 2001 From: Luv Kapur Date: Tue, 9 Apr 2024 15:35:14 -0400 Subject: [PATCH 23/32] fix hooks to use useQuery from @apollo/client --- .../use-lane-components.tsx | 2 +- components/hooks/use-lanes/use-lanes.tsx | 2 +- .../use-lane-diff-status.ts | 96 +++++++++++++++++++ .../use-core-aspects/use-core-aspects.tsx | 2 +- scopes/api-reference/hooks/use-api/use-api.ts | 2 +- .../use-cloud-scopes/use-cloud-scopes.ts | 2 +- .../use-current-user/use-current-user.ts | 2 +- .../component/host/use-component-host.ts | 2 +- .../component/ui/aspect-page/aspect-page.tsx | 2 +- .../component/ui/use-component-logs.ts | 2 +- .../component/ui/use-component-query.ts | 2 +- .../graph/ui/query/use-graph-query.ts | 2 +- 12 files changed, 107 insertions(+), 11 deletions(-) create mode 100644 components/ui/compare/lane-compare-hooks/use-lane-diff-status/use-lane-diff-status.ts diff --git a/components/hooks/use-lane-components/use-lane-components.tsx b/components/hooks/use-lane-components/use-lane-components.tsx index 96a4d2087802..f3d23cc5e0cd 100644 --- a/components/hooks/use-lane-components/use-lane-components.tsx +++ b/components/hooks/use-lane-components/use-lane-components.tsx @@ -1,4 +1,4 @@ -import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query'; +import { useQuery as useDataQuery } from '@apollo/client'; import { gql } from 'graphql-tag'; import { DocumentNode } from 'graphql'; import { ComponentID, ComponentModel, componentOverviewFields } from '@teambit/component'; diff --git a/components/hooks/use-lanes/use-lanes.tsx b/components/hooks/use-lanes/use-lanes.tsx index d433470d34bf..b543833ed464 100644 --- a/components/hooks/use-lanes/use-lanes.tsx +++ b/components/hooks/use-lanes/use-lanes.tsx @@ -1,5 +1,5 @@ import { useMemo, useCallback } from 'react'; -import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query'; +import { useQuery as useDataQuery } from '@apollo/client'; import { LaneModel, LanesModel, LanesQuery } from '@teambit/lanes.ui.models.lanes-model'; import { gql } from 'graphql-tag'; import { DocumentNode } from 'graphql'; diff --git a/components/ui/compare/lane-compare-hooks/use-lane-diff-status/use-lane-diff-status.ts b/components/ui/compare/lane-compare-hooks/use-lane-diff-status/use-lane-diff-status.ts new file mode 100644 index 000000000000..9ce425ca51a6 --- /dev/null +++ b/components/ui/compare/lane-compare-hooks/use-lane-diff-status/use-lane-diff-status.ts @@ -0,0 +1,96 @@ +import { useQuery as useDataQuery } from '@apollo/client'; +import { gql } from 'graphql-tag'; +import { LaneId } from '@teambit/lane-id'; +import { DocumentNode } from 'graphql'; +import { ComponentID, ComponentIdObj } from '@teambit/component-id'; +import { LaneDiff, PlainLaneDiff, ChangeType } from '@teambit/lanes.entities.lane-diff'; + +export type LaneDiffStatusQueryResponse = { + lanes: { + diffStatus: { + source: { name: string; scope: string }; + target: { name: string; scope: string }; + upToDate: boolean; + componentsStatus: Array<{ + componentId: ComponentIdObj; + changes: ChangeType[]; + upToDate: boolean; + sourceHead: string; + targetHead?: string; + }>; + }; + }; +}; + +export const QUERY_LANE_DIFF_STATUS: DocumentNode = gql` + query LaneDiffStatus($source: String!, $target: String!, $options: DiffStatusOptions) { + lanes { + id + diffStatus(source: $source, target: $target, options: $options) { + id + source { + name + scope + } + target { + name + scope + } + componentsStatus { + id + componentId { + scope + name + version + } + sourceHead + targetHead + changes + upToDate + unrelated + } + } + } + } +`; + +export type UseLaneDiffStatusResult = { loading?: boolean; laneDiff?: LaneDiff }; +export type UseLaneDiffStatus = (props: UseLaneDiffStatusProps) => UseLaneDiffStatusResult; +export type UseLaneDiffStatusOptions = { + skipChanges?: boolean; + skipUpToDate?: boolean; +}; + +export type UseLaneDiffStatusProps = { + baseId?: string; + compareId?: string; + options?: UseLaneDiffStatusOptions; +}; + +export const useLaneDiffStatus: UseLaneDiffStatus = ({ baseId, compareId, options }) => { + const { data, loading } = useDataQuery(QUERY_LANE_DIFF_STATUS, { + variables: { + source: compareId, + target: baseId, + options, + }, + skip: !baseId || !compareId, + }); + + const plainLaneDiff: PlainLaneDiff | undefined = data?.lanes.diffStatus && { + sourceLane: LaneId.from(data.lanes.diffStatus.source.name, data.lanes.diffStatus.source.scope).toString(), + targetLane: LaneId.from(data.lanes.diffStatus.target.name, data.lanes.diffStatus.target.scope).toString(), + diff: data.lanes.diffStatus.componentsStatus.map((c) => ({ + ...c, + changes: c.changes || [], + componentId: ComponentID.fromObject(c.componentId).toString(), + })), + }; + + const laneDiff = plainLaneDiff && LaneDiff.from(plainLaneDiff); + + return { + loading, + laneDiff, + }; +}; diff --git a/components/ui/hooks/use-core-aspects/use-core-aspects.tsx b/components/ui/hooks/use-core-aspects/use-core-aspects.tsx index dce291244761..36184050bedd 100644 --- a/components/ui/hooks/use-core-aspects/use-core-aspects.tsx +++ b/components/ui/hooks/use-core-aspects/use-core-aspects.tsx @@ -1,4 +1,4 @@ -import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query'; +import { useQuery as useDataQuery } from '@apollo/client'; import { gql } from 'graphql-tag'; import { DocumentNode } from 'graphql'; diff --git a/scopes/api-reference/hooks/use-api/use-api.ts b/scopes/api-reference/hooks/use-api/use-api.ts index 9cd0d3a640e3..a45785875848 100644 --- a/scopes/api-reference/hooks/use-api/use-api.ts +++ b/scopes/api-reference/hooks/use-api/use-api.ts @@ -1,4 +1,4 @@ -import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query'; +import { useQuery as useDataQuery } from '@apollo/client'; import { gql } from 'graphql-tag'; import { DocumentNode } from 'graphql'; import { APIReferenceModel } from '@teambit/api-reference.models.api-reference-model'; diff --git a/scopes/cloud/hooks/use-cloud-scopes/use-cloud-scopes.ts b/scopes/cloud/hooks/use-cloud-scopes/use-cloud-scopes.ts index 05e6c54c8e53..8327343c6cf9 100644 --- a/scopes/cloud/hooks/use-cloud-scopes/use-cloud-scopes.ts +++ b/scopes/cloud/hooks/use-cloud-scopes/use-cloud-scopes.ts @@ -1,4 +1,4 @@ -import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query'; +import { useQuery as useDataQuery } from '@apollo/client'; import { gql } from 'graphql-tag'; import { DocumentNode } from 'graphql'; import { ScopeDescriptor } from '@teambit/scopes.scope-descriptor'; diff --git a/scopes/cloud/hooks/use-current-user/use-current-user.ts b/scopes/cloud/hooks/use-current-user/use-current-user.ts index f32560f94f26..388b769c1af5 100644 --- a/scopes/cloud/hooks/use-current-user/use-current-user.ts +++ b/scopes/cloud/hooks/use-current-user/use-current-user.ts @@ -1,4 +1,4 @@ -import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query'; +import { useQuery as useDataQuery } from '@apollo/client'; import { gql } from 'graphql-tag'; import { DocumentNode } from 'graphql'; import { CloudUser } from '@teambit/cloud.models.cloud-user'; diff --git a/scopes/component/component/host/use-component-host.ts b/scopes/component/component/host/use-component-host.ts index f62086d190a2..bb58d184eeb5 100644 --- a/scopes/component/component/host/use-component-host.ts +++ b/scopes/component/component/host/use-component-host.ts @@ -1,4 +1,4 @@ -import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query'; +import { useQuery as useDataQuery } from '@apollo/client'; import { gql } from 'graphql-tag'; import { DocumentNode } from 'graphql'; diff --git a/scopes/component/component/ui/aspect-page/aspect-page.tsx b/scopes/component/component/ui/aspect-page/aspect-page.tsx index 42e9885a4428..4453aa447396 100644 --- a/scopes/component/component/ui/aspect-page/aspect-page.tsx +++ b/scopes/component/component/ui/aspect-page/aspect-page.tsx @@ -1,6 +1,6 @@ import { AspectBox } from '@teambit/harmony.ui.aspect-box'; import React, { useContext } from 'react'; -import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query'; +import { useQuery as useDataQuery } from '@apollo/client'; import { gql } from 'graphql-tag'; import { DocumentNode } from 'graphql'; import { EmptyBox } from '@teambit/design.ui.empty-box'; diff --git a/scopes/component/component/ui/use-component-logs.ts b/scopes/component/component/ui/use-component-logs.ts index b5780d7a2932..7f39ec6f0a2b 100644 --- a/scopes/component/component/ui/use-component-logs.ts +++ b/scopes/component/component/ui/use-component-logs.ts @@ -1,6 +1,6 @@ import { useMemo } from 'react'; import { LegacyComponentLog } from '@teambit/legacy-component-log'; -import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query'; +import { useQuery as useDataQuery } from '@apollo/client'; import { ComponentLogsResult, Filters } from './use-component.model'; import { GET_COMPONENT_WITH_LOGS } from './use-component.fragments'; import { ComponentError } from './component-error'; diff --git a/scopes/component/component/ui/use-component-query.ts b/scopes/component/component/ui/use-component-query.ts index ff5d2e84e68f..b3a3d2a62baa 100644 --- a/scopes/component/component/ui/use-component-query.ts +++ b/scopes/component/component/ui/use-component-query.ts @@ -1,5 +1,5 @@ import { useMemo, useEffect, useRef } from 'react'; -import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query'; +import { useQuery as useDataQuery } from '@apollo/client'; import { ComponentID, ComponentIdObj } from '@teambit/component-id'; import { ComponentDescriptor } from '@teambit/component-descriptor'; import { ComponentModel } from './component-model'; diff --git a/scopes/component/graph/ui/query/use-graph-query.ts b/scopes/component/graph/ui/query/use-graph-query.ts index cef26651bec7..342aa1f19861 100644 --- a/scopes/component/graph/ui/query/use-graph-query.ts +++ b/scopes/component/graph/ui/query/use-graph-query.ts @@ -1,5 +1,5 @@ import { useMemo } from 'react'; -import { useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query'; +import { useQuery as useDataQuery } from '@apollo/client'; import { GraphQlError } from '@teambit/graphql'; import { GET_GRAPH, RawGraphQuery } from './get-graph.query'; import { GraphModel } from './graph-model'; From 5fe68b74cc0dd27d240dadeaaeee2eaceac154bf Mon Sep 17 00:00:00 2001 From: Luv Kapur Date: Tue, 9 Apr 2024 16:08:47 -0400 Subject: [PATCH 24/32] build fix --- components/hooks/use-lanes/use-lanes.tsx | 4 ++-- scopes/component/graph/ui/query/use-graph-query.ts | 9 ++------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/components/hooks/use-lanes/use-lanes.tsx b/components/hooks/use-lanes/use-lanes.tsx index b543833ed464..401ae8d5e08b 100644 --- a/components/hooks/use-lanes/use-lanes.tsx +++ b/components/hooks/use-lanes/use-lanes.tsx @@ -171,7 +171,7 @@ type UseRootLanes = ( const useRootLanes: UseRootLanes = (viewedLaneId, skip, options = {}, scope) => { const { ids, offset, limit, sort } = options; - const { data, fetchMore, loading } = useDataQuery(GET_LANES, { + const { data, fetchMore, loading } = useDataQuery(GET_LANES, { variables: { laneIds: ids, offset, @@ -259,7 +259,7 @@ const useRootLanes: UseRootLanes = (viewedLaneId, skip, options = {}, scope) => }; export const useSearchLanes: SearchLanes = (search, skip) => { - const { data: searchData, loading: loadingSearch } = useDataQuery(GET_LANES, { + const { data: searchData, loading: loadingSearch } = useDataQuery(GET_LANES, { variables: { search, skipViewedLane: true, diff --git a/scopes/component/graph/ui/query/use-graph-query.ts b/scopes/component/graph/ui/query/use-graph-query.ts index 342aa1f19861..dc86da3b33e0 100644 --- a/scopes/component/graph/ui/query/use-graph-query.ts +++ b/scopes/component/graph/ui/query/use-graph-query.ts @@ -1,17 +1,12 @@ import { useMemo } from 'react'; import { useQuery as useDataQuery } from '@apollo/client'; import { GraphQlError } from '@teambit/graphql'; -import { GET_GRAPH, RawGraphQuery } from './get-graph.query'; +import { GET_GRAPH } from './get-graph.query'; import { GraphModel } from './graph-model'; -type QueryVariables = { - ids?: string[]; - filter?: string; -}; - /** provides dependencies graph data from graphQL */ export function useGraphQuery(componentId?: string[], filter?: string) { - const { data, error, loading } = useDataQuery(GET_GRAPH, { + const { data, error, loading } = useDataQuery(GET_GRAPH, { variables: { ids: componentId, filter }, skip: !componentId, }); From 6949fe0d3d9994188db3d1ce65afb12de097950c Mon Sep 17 00:00:00 2001 From: Luv Kapur Date: Tue, 9 Apr 2024 16:36:37 -0400 Subject: [PATCH 25/32] lint fix --- components/hooks/use-lanes/use-lanes.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/hooks/use-lanes/use-lanes.tsx b/components/hooks/use-lanes/use-lanes.tsx index 401ae8d5e08b..63f792f0b7b2 100644 --- a/components/hooks/use-lanes/use-lanes.tsx +++ b/components/hooks/use-lanes/use-lanes.tsx @@ -1,6 +1,6 @@ import { useMemo, useCallback } from 'react'; import { useQuery as useDataQuery } from '@apollo/client'; -import { LaneModel, LanesModel, LanesQuery } from '@teambit/lanes.ui.models.lanes-model'; +import { LaneModel, LanesModel } from '@teambit/lanes.ui.models.lanes-model'; import { gql } from 'graphql-tag'; import { DocumentNode } from 'graphql'; import { LaneId } from '@teambit/lane-id'; From 8e4f08a1e5e13d3109299f7c934556ceb6274bf0 Mon Sep 17 00:00:00 2001 From: Gilad Shoham Date: Wed, 10 Apr 2024 11:31:41 +0300 Subject: [PATCH 26/32] bump teambit.harmony/envs/core-aspect-env-jest to v0.0.13 --- .bitmap | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.bitmap b/.bitmap index d4bb8fc7e6e6..cd7385f03ab1 100644 --- a/.bitmap +++ b/.bitmap @@ -526,7 +526,7 @@ "mainFile": "index.ts", "rootDir": "scopes/dependencies/dependency-resolver", "config": { - "teambit.harmony/envs/core-aspect-env-jest@0.0.12": {} + "teambit.harmony/envs/core-aspect-env-jest@0.0.13": {} } }, "deprecation": { @@ -2247,4 +2247,4 @@ } }, "$schema-version": "17.0.0" -} \ No newline at end of file +} From 3d45d975dfe4449abc0a66461588a617282ad090 Mon Sep 17 00:00:00 2001 From: Luv Kapur Date: Mon, 15 Apr 2024 21:32:56 -0400 Subject: [PATCH 27/32] fix writing subscription data to client cache --- .../component/ui/use-component-query.ts | 97 +------------------ .../harmony/graphql/graphql.main.runtime.ts | 18 +++- scopes/harmony/graphql/graphql.ui.runtime.tsx | 5 +- .../workspace/ui/workspace/use-workspace.ts | 4 +- .../workspace/workspace/workspace.graphql.ts | 7 +- workspace.jsonc | 12 +-- 6 files changed, 30 insertions(+), 113 deletions(-) diff --git a/scopes/component/component/ui/use-component-query.ts b/scopes/component/component/ui/use-component-query.ts index b3a3d2a62baa..867ad11cb30c 100644 --- a/scopes/component/component/ui/use-component-query.ts +++ b/scopes/component/component/ui/use-component-query.ts @@ -1,15 +1,10 @@ -import { useMemo, useEffect, useRef } from 'react'; +import { useMemo, useRef } from 'react'; import { useQuery as useDataQuery } from '@apollo/client'; -import { ComponentID, ComponentIdObj } from '@teambit/component-id'; +import { ComponentID } from '@teambit/component-id'; import { ComponentDescriptor } from '@teambit/component-descriptor'; import { ComponentModel } from './component-model'; import { ComponentQueryResult, Filters } from './use-component.model'; -import { - GET_COMPONENT, - SUB_COMPONENT_CHANGED, - SUB_COMPONENT_REMOVED, - SUB_SUBSCRIPTION_ADDED, -} from './use-component.fragments'; +import { GET_COMPONENT } from './use-component.fragments'; import { useComponentLogs } from './use-component-logs'; import { ComponentError } from './component-error'; @@ -27,7 +22,7 @@ export function useComponentQuery( extensionId: host, }; - const { data, error, loading, subscribeToMore } = useDataQuery(GET_COMPONENT, { + const { data, error, loading } = useDataQuery(GET_COMPONENT, { variables, skip, errorPolicy: 'all', @@ -37,90 +32,6 @@ export function useComponentQuery( const rawComponent = data?.getHost?.get; - useEffect(() => { - // @TODO @Kutner fix subscription for scope - if (host !== 'teambit.workspace/workspace') { - return () => {}; - } - - const unsubAddition = subscribeToMore({ - document: SUB_SUBSCRIPTION_ADDED, - updateQuery: (prev, { subscriptionData }) => { - const prevComponent = prev?.getHost?.get; - const addedComponent = subscriptionData?.data?.componentAdded?.component; - - if (!addedComponent || prevComponent) return prev; - - if (idRef.current === addedComponent.id.name) { - return { - ...prev, - getHost: { - ...prev.getHost, - get: addedComponent, - }, - }; - } - - return prev; - }, - }); - - const unsubChanges = subscribeToMore({ - document: SUB_COMPONENT_CHANGED, - updateQuery: (prev, { subscriptionData }) => { - if (!subscriptionData.data) return prev; - - const prevComponent = prev?.getHost?.get; - const updatedComponent = subscriptionData?.data?.componentChanged?.component; - - const isUpdated = updatedComponent && ComponentID.isEqualObj(prevComponent?.id, updatedComponent?.id); - - if (isUpdated) { - return { - ...prev, - getHost: { - ...prev.getHost, - get: updatedComponent, - }, - }; - } - - return prev; - }, - }); - - const unsubRemoval = subscribeToMore({ - document: SUB_COMPONENT_REMOVED, - updateQuery: (prev, { subscriptionData }) => { - if (!subscriptionData.data) return prev; - - const prevComponent = prev?.getHost?.get; - const removedIds: ComponentIdObj[] | undefined = subscriptionData?.data?.componentRemoved?.componentIds; - if (!prevComponent || !removedIds?.length) return prev; - - const isRemoved = removedIds.some((removedId) => ComponentID.isEqualObj(removedId, prevComponent.id)); - - if (isRemoved) { - return { - ...prev, - getHost: { - ...prev.getHost, - get: null, - }, - }; - } - - return prev; - }, - }); - - return () => { - unsubChanges(); - unsubAddition(); - unsubRemoval(); - }; - }, []); - const idDepKey = rawComponent?.id ? `${rawComponent?.id?.scope}/${rawComponent?.id?.name}@${rawComponent?.id?.version}}` : undefined; diff --git a/scopes/harmony/graphql/graphql.main.runtime.ts b/scopes/harmony/graphql/graphql.main.runtime.ts index aa47a952031f..718b7004d327 100644 --- a/scopes/harmony/graphql/graphql.main.runtime.ts +++ b/scopes/harmony/graphql/graphql.main.runtime.ts @@ -5,6 +5,7 @@ import { expressMiddleware } from '@apollo/server/express4'; import { ApolloServerPluginDrainHttpServer } from '@apollo/server/plugin/drainHttpServer'; import { ApolloServerPluginLandingPageDisabled } from '@apollo/server/plugin/disabled'; import { useServer } from 'graphql-ws/lib/use/ws'; +import { GRAPHQL_TRANSPORT_WS_PROTOCOL } from 'graphql-ws'; import { Module, createModule, createApplication, Application } from 'graphql-modules'; import { MainRuntime } from '@teambit/cli'; import { Harmony, Slot, SlotRegistry } from '@teambit/harmony'; @@ -206,11 +207,15 @@ export class GraphqlMain { noServer: true, path: this.config.subscriptionsPath, }); + httpServer.on('upgrade', (request, socket, head) => { if (request.url?.startsWith(this.config.subscriptionsPath)) { - websocketServer.handleUpgrade(request, socket, head, (websocket) => { - websocketServer.emit('connection', websocket, request); - }); + const protocols = request.headers['sec-websocket-protocol']; + if (protocols?.includes(GRAPHQL_TRANSPORT_WS_PROTOCOL)) { + websocketServer.handleUpgrade(request, socket, head, (websocket) => { + websocketServer.emit('connection', websocket, request); + }); + } } }); @@ -222,6 +227,13 @@ export class GraphqlMain { onConnect: () => { options?.onWsConnect?.(); }, + context: async (ctx, msgs, args) => { + return { + ctx, + msgs, + args, + }; + }, }, websocketServer ); diff --git a/scopes/harmony/graphql/graphql.ui.runtime.tsx b/scopes/harmony/graphql/graphql.ui.runtime.tsx index 6a0cc66e52fa..7b14c1cf203c 100644 --- a/scopes/harmony/graphql/graphql.ui.runtime.tsx +++ b/scopes/harmony/graphql/graphql.ui.runtime.tsx @@ -4,7 +4,7 @@ import { print } from 'graphql'; import { Observable } from '@apollo/client/utilities'; import { FetchResult } from '@apollo/client/core'; import { UIRuntime } from '@teambit/ui'; -import { InMemoryCache, ApolloClient, ApolloLink, createHttpLink } from '@apollo/client'; +import { InMemoryCache, ApolloClient, createHttpLink, ApolloLink } from '@apollo/client'; import type { NormalizedCacheObject } from '@apollo/client'; import { onError } from '@apollo/client/link/error'; @@ -77,13 +77,12 @@ export class GraphqlUI { ? new ApolloLink((operation) => { const observable = new Observable((observer) => { const { variables } = operation; - // @ts-ignore todo - update env to latest graphql version const query = print(operation.query); const dispose = wsClient?.subscribe( { query, variables }, { - next: (data) => observer.next({ data }), + next: ({ data }) => observer.next({ data }), error: (error) => observer.error(error), complete: () => observer.complete(), } diff --git a/scopes/workspace/workspace/ui/workspace/use-workspace.ts b/scopes/workspace/workspace/ui/workspace/use-workspace.ts index b0fdf2111d1a..d03fba0f1988 100644 --- a/scopes/workspace/workspace/ui/workspace/use-workspace.ts +++ b/scopes/workspace/workspace/ui/workspace/use-workspace.ts @@ -123,7 +123,7 @@ export function useWorkspace(options: UseWorkspaceOptions = {}) { const unSubCompAddition = subscribeToMore({ document: COMPONENT_SUBSCRIPTION_ADDED, updateQuery: (prev, { subscriptionData }) => { - const update = subscriptionData.data.data; + const update = subscriptionData.data; const addedComponent = update?.componentAdded?.component; if (!addedComponent) return prev; @@ -171,7 +171,7 @@ export function useWorkspace(options: UseWorkspaceOptions = {}) { const unSubCompRemoved = subscribeToMore({ document: COMPONENT_SUBSCRIPTION_REMOVED, updateQuery: (prev, { subscriptionData }) => { - const idsToRemove: ComponentIdObj[] | undefined = subscriptionData.data?.componentRemoved?.componentIds; + const idsToRemove: ComponentIdObj[] | undefined = subscriptionData?.data?.componentRemoved?.componentIds; if (!idsToRemove || idsToRemove.length === 0) return prev; // side effect - trigger observers diff --git a/scopes/workspace/workspace/workspace.graphql.ts b/scopes/workspace/workspace/workspace.graphql.ts index 02d61b9cd591..a67ef7f862fb 100644 --- a/scopes/workspace/workspace/workspace.graphql.ts +++ b/scopes/workspace/workspace/workspace.graphql.ts @@ -88,15 +88,16 @@ export default (workspace: Workspace, graphql: GraphqlMain) => { resolvers: { Subscription: { componentAdded: { - subscribe: () => { - return graphql.pubsub.asyncIterator(ComponentAdded); - }, + subscribe: () => graphql.pubsub.asyncIterator(ComponentAdded), + resolve: (payload) => payload.componentAdded, }, componentChanged: { subscribe: () => graphql.pubsub.asyncIterator(ComponentChanged), + resolve: (payload) => payload.componentChanged, }, componentRemoved: { subscribe: () => graphql.pubsub.asyncIterator(ComponentRemoved), + resolve: (payload) => payload.componentRemoved, }, }, Component: { diff --git a/workspace.jsonc b/workspace.jsonc index a87f5e7014b0..dc9e46e2205a 100644 --- a/workspace.jsonc +++ b/workspace.jsonc @@ -29,7 +29,7 @@ "@mdx-js/mdx": "1.6.21", "@mdx-js/react": "1.6.22", "@monaco-editor/react": "4.4.6", - "@pmmmwh/react-refresh-webpack-plugin": "0.5.4", + "@pmmmwh/react-refresh-webpack-plugin": "0.5.11", "@pnpm/client": "10.0.48", "@pnpm/colorize-semver-diff": "1.0.1", "@pnpm/config": "20.4.3", @@ -367,12 +367,6 @@ "@yarnpkg/plugin-npm": "2.7.4", "@yarnpkg/plugin-pack": "3.2.0", "ansi-to-html": "0.6.14", - "apollo-link": "^1.2.14", - "apollo-link-context": "^1.0.20", - "apollo-link-http": "^1.5.17", - "apollo-link-ws": "^1.0.20", - "apollo-server": "^3.13.0", - "apollo-utilities": "^1.3.4", "archiver": "5.3.1", "archy": "1.0.0", "assert": "^2.1.0", @@ -508,11 +502,11 @@ "vscode-languageserver-types": "3.16.0", "webpack": "5.84.1", "webpack-assets-manifest": "5.1.0", - "webpack-dev-server": "4.15.0", + "webpack-dev-server": "4.15.2", "webpack-manifest-plugin": "5.0.0", "webpack-merge": "5.8.0", "workbox-webpack-plugin": "6.2.4", - "ws": "^8.16.0", + "ws": "8.16.0", "yesno": "0.4.0" }, "peerDependencies": { From 6abcb0d0a94a7dfdb9c98cb6930680432cc83aae Mon Sep 17 00:00:00 2001 From: Luv Kapur Date: Tue, 16 Apr 2024 10:29:35 -0400 Subject: [PATCH 28/32] sync core-aspect-env version --- .bitmap | 778 +++++++++++++++--- scopes/cloud/hooks/use-logout/use-logout.ts | 2 +- .../compilation/bundler/dev-server.graphql.ts | 1 + scopes/defender/eslint/component.json | 4 +- scopes/react/react-native/component.json | 4 +- scopes/ui-foundation/ui/component.json | 4 +- .../workspace/ui/workspace/use-workspace.ts | 8 +- workspace.jsonc | 14 +- 8 files changed, 699 insertions(+), 116 deletions(-) diff --git a/.bitmap b/.bitmap index 57686a0bd9f7..e96ca394de65 100644 --- a/.bitmap +++ b/.bitmap @@ -14,21 +14,39 @@ "scope": "teambit.api-reference", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/api-reference/api-reference" + "rootDir": "scopes/api-reference/api-reference", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "api-server": { "name": "api-server", "scope": "teambit.harmony", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/harmony/api-server" + "rootDir": "scopes/harmony/api-server", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "application": { "name": "application", "scope": "teambit.harmony", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/harmony/application" + "rootDir": "scopes/harmony/application", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "array/duplications-finder": { "name": "array/duplications-finder", @@ -42,7 +60,13 @@ "scope": "teambit.harmony", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/harmony/aspect" + "rootDir": "scopes/harmony/aspect", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "aspect-docs/babel": { "name": "aspect-docs/babel", @@ -196,14 +220,26 @@ "scope": "teambit.harmony", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/harmony/aspect-loader" + "rootDir": "scopes/harmony/aspect-loader", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "babel": { "name": "babel", "scope": "teambit.compilation", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/compilation/babel" + "rootDir": "scopes/compilation/babel", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "babel/bit-react-transformer": { "name": "babel/bit-react-transformer", @@ -217,14 +253,26 @@ "scope": "teambit.harmony", "version": "1.6.126", "mainFile": "index.ts", - "rootDir": "scopes/harmony/bit" + "rootDir": "scopes/harmony/bit", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "builder": { "name": "builder", "scope": "teambit.pipelines", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/pipelines/builder" + "rootDir": "scopes/pipelines/builder", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "builder-data": { "name": "builder-data", @@ -238,42 +286,78 @@ "scope": "teambit.compilation", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/compilation/bundler" + "rootDir": "scopes/compilation/bundler", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "cache": { "name": "cache", "scope": "teambit.harmony", "version": "0.0.955", "mainFile": "index.ts", - "rootDir": "scopes/harmony/cache" + "rootDir": "scopes/harmony/cache", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "changelog": { "name": "changelog", "scope": "teambit.component", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/component/changelog" + "rootDir": "scopes/component/changelog", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "checkout": { "name": "checkout", "scope": "teambit.component", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/component/checkout" + "rootDir": "scopes/component/checkout", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "clear-cache": { "name": "clear-cache", "scope": "teambit.workspace", "version": "0.0.407", "mainFile": "index.ts", - "rootDir": "scopes/workspace/clear-cache" + "rootDir": "scopes/workspace/clear-cache", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "cli": { "name": "cli", "scope": "teambit.harmony", "version": "0.0.862", "mainFile": "index.ts", - "rootDir": "scopes/harmony/cli" + "rootDir": "scopes/harmony/cli", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "cli-table": { "name": "cli-table", @@ -294,56 +378,104 @@ "scope": "teambit.cloud", "version": "0.0.509", "mainFile": "index.ts", - "rootDir": "scopes/cloud/cloud" + "rootDir": "scopes/cloud/cloud", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "code": { "name": "code", "scope": "teambit.component", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/component/code" + "rootDir": "scopes/component/code", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "command-bar": { "name": "command-bar", "scope": "teambit.explorer", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/explorer/command-bar" + "rootDir": "scopes/explorer/command-bar", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "community": { "name": "community", "scope": "teambit.community", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/community/community" + "rootDir": "scopes/community/community", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "compiler": { "name": "compiler", "scope": "teambit.compilation", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/compilation/compiler" + "rootDir": "scopes/compilation/compiler", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "component": { "name": "component", "scope": "teambit.component", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/component/component" + "rootDir": "scopes/component/component", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "component-compare": { "name": "component-compare", "scope": "teambit.component", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/component/component-compare" + "rootDir": "scopes/component/component-compare", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "component-descriptor": { "name": "component-descriptor", "scope": "teambit.component", "version": "0.0.419", "mainFile": "index.ts", - "rootDir": "scopes/component/component-descriptor" + "rootDir": "scopes/component/component-descriptor", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "component-issues": { "name": "component-issues", @@ -357,7 +489,13 @@ "scope": "teambit.component", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/component/component-log" + "rootDir": "scopes/component/component-log", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "component-package-version": { "name": "component-package-version", @@ -371,21 +509,39 @@ "scope": "teambit.component", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/component/component-sizer" + "rootDir": "scopes/component/component-sizer", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "component-tree": { "name": "component-tree", "scope": "teambit.component", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/component/component-tree" + "rootDir": "scopes/component/component-tree", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "component-writer": { "name": "component-writer", "scope": "teambit.component", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/component/component-writer" + "rootDir": "scopes/component/component-writer", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "composition-card": { "name": "composition-card", @@ -399,21 +555,39 @@ "scope": "teambit.compositions", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/compositions/compositions" + "rootDir": "scopes/compositions/compositions", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "config": { "name": "config", "scope": "teambit.harmony", "version": "0.0.984", "mainFile": "index.ts", - "rootDir": "scopes/harmony/config" + "rootDir": "scopes/harmony/config", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "config-merger": { "name": "config-merger", "scope": "teambit.workspace", "version": "0.0.100", "mainFile": "index.ts", - "rootDir": "scopes/workspace/config-merger" + "rootDir": "scopes/workspace/config-merger", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "content/cli-reference": { "name": "content/cli-reference", @@ -427,49 +601,91 @@ "scope": "teambit.dependencies", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/dependencies/dependencies" + "rootDir": "scopes/dependencies/dependencies", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "dependency-resolver": { "name": "dependency-resolver", "scope": "teambit.dependencies", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/dependencies/dependency-resolver" + "rootDir": "scopes/dependencies/dependency-resolver", + "config": { + "teambit.harmony/envs/core-aspect-env-jest@0.0.13": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env-jest" + } + } }, "deprecation": { "name": "deprecation", "scope": "teambit.component", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/component/deprecation" + "rootDir": "scopes/component/deprecation", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "dev-files": { "name": "dev-files", "scope": "teambit.component", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/component/dev-files" + "rootDir": "scopes/component/dev-files", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "diagnostic": { "name": "diagnostic", "scope": "teambit.harmony", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/harmony/diagnostic" + "rootDir": "scopes/harmony/diagnostic", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "docs": { "name": "docs", "scope": "teambit.docs", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/docs/docs" + "rootDir": "scopes/docs/docs", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "eject": { "name": "eject", "scope": "teambit.workspace", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/workspace/eject" + "rootDir": "scopes/workspace/eject", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "entities/lane-diff": { "name": "entities/lane-diff", @@ -490,14 +706,26 @@ "scope": "teambit.envs", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/envs/env" + "rootDir": "scopes/envs/env", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "envs": { "name": "envs", "scope": "teambit.envs", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/envs/envs" + "rootDir": "scopes/envs/envs", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "eslint": { "name": "eslint", @@ -532,28 +760,52 @@ "scope": "teambit.scope", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/scope/export" + "rootDir": "scopes/scope/export", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "express": { "name": "express", "scope": "teambit.harmony", "version": "0.0.961", "mainFile": "index.ts", - "rootDir": "scopes/harmony/express" + "rootDir": "scopes/harmony/express", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "forking": { "name": "forking", "scope": "teambit.component", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/component/forking" + "rootDir": "scopes/component/forking", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "formatter": { "name": "formatter", "scope": "teambit.defender", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/defender/formatter" + "rootDir": "scopes/defender/formatter", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "fs/hard-link-directory": { "name": "fs/hard-link-directory", @@ -581,42 +833,78 @@ "scope": "teambit.generator", "version": "1.0.234", "mainFile": "index.ts", - "rootDir": "scopes/generator/generator" + "rootDir": "scopes/generator/generator", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "git": { "name": "git", "scope": "teambit.git", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/git/git" + "rootDir": "scopes/git/git", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "global-config": { "name": "global-config", "scope": "teambit.harmony", "version": "0.0.865", "mainFile": "index.ts", - "rootDir": "scopes/harmony/global-config" + "rootDir": "scopes/harmony/global-config", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "graph": { "name": "graph", "scope": "teambit.component", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/component/graph" + "rootDir": "scopes/component/graph", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "graphql": { "name": "graphql", "scope": "teambit.harmony", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/harmony/graphql" + "rootDir": "scopes/harmony/graphql", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "harmony-ui-app": { "name": "harmony-ui-app", "scope": "teambit.ui-foundation", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/ui-foundation/harmony-ui-app/harmony-ui-app" + "rootDir": "scopes/ui-foundation/harmony-ui-app/harmony-ui-app", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "hooks/use-api": { "name": "hooks/use-api", @@ -700,77 +988,143 @@ "scope": "teambit.scope", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/scope/importer" + "rootDir": "scopes/scope/importer", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "insights": { "name": "insights", "scope": "teambit.explorer", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/explorer/insights" + "rootDir": "scopes/explorer/insights", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "install": { "name": "install", "scope": "teambit.workspace", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/workspace/install" + "rootDir": "scopes/workspace/install", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "ipc-events": { "name": "ipc-events", "scope": "teambit.harmony", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/harmony/ipc-events" + "rootDir": "scopes/harmony/ipc-events", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "isolator": { "name": "isolator", "scope": "teambit.component", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/component/isolator" + "rootDir": "scopes/component/isolator", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "issues": { "name": "issues", "scope": "teambit.component", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/component/issues" + "rootDir": "scopes/component/issues", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "jest": { "name": "jest", "scope": "teambit.defender", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/defender/jest" + "rootDir": "scopes/defender/jest", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "lanes": { "name": "lanes", "scope": "teambit.lanes", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/lanes/lanes" + "rootDir": "scopes/lanes/lanes", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "linter": { "name": "linter", "scope": "teambit.defender", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/defender/linter" + "rootDir": "scopes/defender/linter", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "lister": { "name": "lister", "scope": "teambit.component", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/component/lister" + "rootDir": "scopes/component/lister", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "logger": { "name": "logger", "scope": "teambit.harmony", "version": "0.0.955", "mainFile": "index.ts", - "rootDir": "scopes/harmony/logger" + "rootDir": "scopes/harmony/logger", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "mdx": { "name": "mdx", @@ -784,21 +1138,39 @@ "scope": "teambit.lanes", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/lanes/merge-lanes" + "rootDir": "scopes/lanes/merge-lanes", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "merging": { "name": "merging", "scope": "teambit.component", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/component/merging" + "rootDir": "scopes/component/merging", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "mocha": { "name": "mocha", "scope": "teambit.defender", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/defender/mocha" + "rootDir": "scopes/defender/mocha", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "model/composition-id": { "name": "model/composition-id", @@ -987,21 +1359,39 @@ "scope": "teambit.component", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/component/mover" + "rootDir": "scopes/component/mover", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "multi-compiler": { "name": "multi-compiler", "scope": "teambit.compilation", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/compilation/multi-compiler" + "rootDir": "scopes/compilation/multi-compiler", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "multi-tester": { "name": "multi-tester", "scope": "teambit.defender", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/defender/multi-tester" + "rootDir": "scopes/defender/multi-tester", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "network/get-port": { "name": "network/get-port", @@ -1015,7 +1405,13 @@ "scope": "teambit.component", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/component/new-component-helper" + "rootDir": "scopes/component/new-component-helper", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "node": { "name": "node", @@ -1029,7 +1425,13 @@ "scope": "teambit.ui-foundation", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/ui-foundation/notifications/aspect" + "rootDir": "scopes/ui-foundation/notifications/aspect", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "overview/api-reference-table-of-contents": { "name": "overview/api-reference-table-of-contents", @@ -1050,7 +1452,13 @@ "scope": "teambit.ui-foundation", "version": "0.0.864", "mainFile": "index.ts", - "rootDir": "scopes/ui-foundation/panels" + "rootDir": "scopes/ui-foundation/panels", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "panels/composition-gallery": { "name": "panels/composition-gallery", @@ -1092,7 +1500,13 @@ "scope": "teambit.pkg", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/pkg/pkg" + "rootDir": "scopes/pkg/pkg", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "plugins/inject-head-webpack-plugin": { "name": "plugins/inject-head-webpack-plugin", @@ -1106,14 +1520,26 @@ "scope": "teambit.dependencies", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/dependencies/pnpm" + "rootDir": "scopes/dependencies/pnpm", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "prettier": { "name": "prettier", "scope": "teambit.defender", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/defender/prettier" + "rootDir": "scopes/defender/prettier", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "prettier/config-mutator": { "name": "prettier/config-mutator", @@ -1127,14 +1553,26 @@ "scope": "teambit.preview", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/preview/preview" + "rootDir": "scopes/preview/preview", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "pubsub": { "name": "pubsub", "scope": "teambit.harmony", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/harmony/pubsub" + "rootDir": "scopes/harmony/pubsub", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "react": { "name": "react", @@ -1155,7 +1593,13 @@ "scope": "teambit.ui-foundation", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/ui-foundation/react-router/react-router" + "rootDir": "scopes/ui-foundation/react-router/react-router", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "readme": { "name": "readme", @@ -1169,21 +1613,39 @@ "scope": "teambit.component", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/component/refactoring" + "rootDir": "scopes/component/refactoring", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "remove": { "name": "remove", "scope": "teambit.component", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/component/remove" + "rootDir": "scopes/component/remove", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "renaming": { "name": "renaming", "scope": "teambit.component", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/component/renaming" + "rootDir": "scopes/component/renaming", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "renderers/api-node-details": { "name": "renderers/api-node-details", @@ -1337,14 +1799,26 @@ "scope": "teambit.semantics", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/semantics/schema" + "rootDir": "scopes/semantics/schema", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "scope": { "name": "scope", "scope": "teambit.scope", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/scope/scope" + "rootDir": "scopes/scope/scope", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "sections/api-reference-page": { "name": "sections/api-reference-page", @@ -1365,35 +1839,65 @@ "scope": "teambit.ui-foundation", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/ui-foundation/sidebar" + "rootDir": "scopes/ui-foundation/sidebar", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "sign": { "name": "sign", "scope": "teambit.scope", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/scope/sign" + "rootDir": "scopes/scope/sign", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "snapping": { "name": "snapping", "scope": "teambit.component", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/component/snapping" + "rootDir": "scopes/component/snapping", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "stash": { "name": "stash", "scope": "teambit.component", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/component/stash" + "rootDir": "scopes/component/stash", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "status": { "name": "status", "scope": "teambit.component", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/component/status" + "rootDir": "scopes/component/status", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "string/capitalize": { "name": "string/capitalize", @@ -1442,7 +1946,13 @@ "scope": "teambit.defender", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/defender/tester" + "rootDir": "scopes/defender/tester", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "testing/load-aspect": { "name": "testing/load-aspect", @@ -1477,7 +1987,13 @@ "scope": "teambit.component", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/component/tracker" + "rootDir": "scopes/component/tracker", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "ts-server": { "name": "ts-server", @@ -1498,7 +2014,13 @@ "scope": "teambit.typescript", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/typescript/typescript" + "rootDir": "scopes/typescript/typescript", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "ui": { "name": "ui", @@ -1855,7 +2377,13 @@ "scope": "teambit.scope", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/scope/update-dependencies" + "rootDir": "scopes/scope/update-dependencies", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "url/add-avatar-query-params": { "name": "url/add-avatar-query-params", @@ -1876,7 +2404,13 @@ "scope": "teambit.ui-foundation", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/ui-foundation/user-agent" + "rootDir": "scopes/ui-foundation/user-agent", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "utils/code-editor-options": { "name": "utils/code-editor-options", @@ -1925,56 +2459,104 @@ "scope": "teambit.workspace", "version": "0.0.1077", "mainFile": "index.ts", - "rootDir": "scopes/workspace/variants" + "rootDir": "scopes/workspace/variants", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "version-history": { "name": "version-history", "scope": "teambit.scope", "version": "0.0.25", "mainFile": "index.ts", - "rootDir": "scopes/scope/version-history" + "rootDir": "scopes/scope/version-history", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "watcher": { "name": "watcher", "scope": "teambit.workspace", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/workspace/watcher" + "rootDir": "scopes/workspace/watcher", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "webpack": { "name": "webpack", "scope": "teambit.webpack", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/webpack/webpack" + "rootDir": "scopes/webpack/webpack", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "worker": { "name": "worker", "scope": "teambit.harmony", "version": "0.0.1166", "mainFile": "index.ts", - "rootDir": "scopes/harmony/worker" + "rootDir": "scopes/harmony/worker", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "workspace": { "name": "workspace", "scope": "teambit.workspace", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/workspace/workspace" + "rootDir": "scopes/workspace/workspace", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "workspace-config-files": { "name": "workspace-config-files", "scope": "teambit.workspace", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/workspace/workspace-config-files" + "rootDir": "scopes/workspace/workspace-config-files", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "yarn": { "name": "yarn", "scope": "teambit.dependencies", "version": "1.0.233", "mainFile": "index.ts", - "rootDir": "scopes/dependencies/yarn" + "rootDir": "scopes/dependencies/yarn", + "config": { + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, + "teambit.envs/envs": { + "env": "teambit.harmony/envs/core-aspect-env" + } + } }, "$schema-version": "17.0.0" -} +} \ No newline at end of file diff --git a/scopes/cloud/hooks/use-logout/use-logout.ts b/scopes/cloud/hooks/use-logout/use-logout.ts index 980a5d6c9b3a..6c0f20b8f694 100644 --- a/scopes/cloud/hooks/use-logout/use-logout.ts +++ b/scopes/cloud/hooks/use-logout/use-logout.ts @@ -1,5 +1,5 @@ import { useMutation } from '@teambit/ui'; -import { gql } from 'graphql-tag'; +import { gql } from '@apollo/client'; import { DocumentNode } from 'graphql'; export const LOGOUT_MUTATION: DocumentNode = gql` diff --git a/scopes/compilation/bundler/dev-server.graphql.ts b/scopes/compilation/bundler/dev-server.graphql.ts index 87fed26600c3..da6b601a21d2 100644 --- a/scopes/compilation/bundler/dev-server.graphql.ts +++ b/scopes/compilation/bundler/dev-server.graphql.ts @@ -26,6 +26,7 @@ export function devServerSchema(bundler: BundlerMain): Schema { // the gotHost.get query is "id". // see it in scopes/component/component/component.graphql.ts const requestedId = context.body.variables.id; + // if we ask for specific id with specific version it means we want to fetch if from scope // so don't return the server url // see https://github.com/teambit/bit/issues/5328 diff --git a/scopes/defender/eslint/component.json b/scopes/defender/eslint/component.json index ccd55239bee1..7871602b3b5b 100644 --- a/scopes/defender/eslint/component.json +++ b/scopes/defender/eslint/component.json @@ -15,9 +15,9 @@ } } }, + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - }, - "teambit.harmony/envs/core-aspect-env@0.0.33": {} + } } } diff --git a/scopes/react/react-native/component.json b/scopes/react/react-native/component.json index f5eef31869a9..a268d1aa6ffa 100644 --- a/scopes/react/react-native/component.json +++ b/scopes/react/react-native/component.json @@ -24,9 +24,9 @@ } } }, + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - }, - "teambit.harmony/envs/core-aspect-env@0.0.33": {} + } } } diff --git a/scopes/ui-foundation/ui/component.json b/scopes/ui-foundation/ui/component.json index 0b5a7230e438..7154ca4a4152 100644 --- a/scopes/ui-foundation/ui/component.json +++ b/scopes/ui-foundation/ui/component.json @@ -28,9 +28,9 @@ } } }, + "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - }, - "teambit.harmony/envs/core-aspect-env@0.0.33": {} + } } } diff --git a/scopes/workspace/workspace/ui/workspace/use-workspace.ts b/scopes/workspace/workspace/ui/workspace/use-workspace.ts index d03fba0f1988..2eabe7eb703f 100644 --- a/scopes/workspace/workspace/ui/workspace/use-workspace.ts +++ b/scopes/workspace/workspace/ui/workspace/use-workspace.ts @@ -60,6 +60,10 @@ const wcComponentFields: DocumentNode = gql` id icon } + server { + env + url + } } `; @@ -71,10 +75,6 @@ const WORKSPACE: DocumentNode = gql` icon components { ...wcComponentFields - server { - env - url - } } } } diff --git a/workspace.jsonc b/workspace.jsonc index 265416792dc0..dbbff4453372 100644 --- a/workspace.jsonc +++ b/workspace.jsonc @@ -94,7 +94,7 @@ "@teambit/base-ui.utils.string.affix": "1.0.0", "@teambit/base-ui.utils.time-ago": "1.0.1", "@teambit/bit.content.what-is-bit": "1.96.2", - "@teambit/bvm.config": "^0.2.3", + "@teambit/bvm.config": "^0.2.5", "@teambit/bvm.path": "^0.1.2", "@teambit/capsule": "0.0.12", "@teambit/code.ui.code-compare-section": "0.0.5", @@ -235,8 +235,8 @@ "@teambit/explorer.ui.gallery.component-grid": "0.0.496", "@teambit/git.modules.git-ignore": "^1.0.2", "@teambit/harmony": "0.4.6", - "@teambit/harmony.envs.core-aspect-env": "^0.0.27", - "@teambit/html.generator.html-templates": "^1.0.8", + "@teambit/harmony.envs.core-aspect-env": "0.0.33", + "@teambit/html.generator.html-templates": "^1.0.11", "@teambit/html.modules.inject-html-element": "0.0.4", "@teambit/html.modules.render-template": "0.0.104", "@teambit/lanes.ui.compare.lane-compare": "^0.0.193", @@ -248,8 +248,8 @@ "@teambit/lanes.ui.icons.lane-icon": "^0.0.9", "@teambit/lanes.ui.lane-details": "^0.0.204", "@teambit/lanes.ui.menus.lanes-overview-menu": "^0.0.10", - "@teambit/mdx.compilers.mdx-transpiler": "^1.0.6", - "@teambit/mdx.generator.mdx-templates": "^1.0.9", + "@teambit/mdx.compilers.mdx-transpiler": "^1.0.7", + "@teambit/mdx.generator.mdx-templates": "^1.0.10", "@teambit/mdx.modules.mdx-loader": "^1.0.14", "@teambit/mdx.ui.docs.link": "0.0.500", "@teambit/mdx.ui.docs.snippet": "^0.0.509", @@ -259,7 +259,7 @@ "@teambit/pkg.content.packages-overview": "1.95.9", "@teambit/preview.modules.preview-modules": "^1.0.3", "@teambit/react.content.react-overview": "1.95.0", - "@teambit/react.generator.react-native-templates": "^1.0.7", + "@teambit/react.generator.react-native-templates": "^1.0.10", "@teambit/react.instructions.react-native.adding-tests": "0.0.1", "@teambit/react.instructions.react.adding-compositions": "0.0.6", "@teambit/react.instructions.react.adding-tests": "0.0.6", @@ -275,7 +275,7 @@ "@teambit/scope.ui.scope-title": "^0.0.515", "@teambit/scopes.scope-descriptor": "^0.0.24", "@teambit/scopes.scope-id": "^0.0.7", - "@teambit/semantics.entities.semantic-schema": "^0.0.65", + "@teambit/semantics.entities.semantic-schema": "0.0.68", "@teambit/tests-results": "^1.0.4", "@teambit/typescript.typescript-compiler": "^2.0.22", "@teambit/ui-foundation.ui.constants.z-indexes": "^0.0.504", From c8a31507e609b1885b3996d26d6c153844266c6b Mon Sep 17 00:00:00 2001 From: Luv Kapur Date: Tue, 16 Apr 2024 11:48:15 -0400 Subject: [PATCH 29/32] update hooks to use types from @apollo/client instead of graphql --- .../use-lane-components/use-lane-components.tsx | 3 +-- components/hooks/use-lanes/use-lanes.tsx | 3 +-- .../use-lane-diff-status/use-lane-diff-status.ts | 3 +-- .../ui/hooks/use-core-aspects/use-core-aspects.tsx | 3 +-- scopes/api-reference/hooks/use-api/use-api.ts | 3 +-- .../api-reference/hooks/use-schema/use-schema.ts | 14 +++++--------- .../hooks/use-cloud-scopes/use-cloud-scopes.ts | 3 +-- .../hooks/use-current-user/use-current-user.ts | 3 +-- scopes/cloud/hooks/use-logout/use-logout.ts | 3 +-- .../component/component/host/use-component-host.ts | 3 +-- .../component/ui/aspect-page/aspect-page.tsx | 3 +-- .../component/ui/use-component.fragments.ts | 2 +- scopes/component/graph/ui/query/get-graph.query.ts | 2 +- .../ui/webpack/webpack.base.config.ts | 1 + .../workspace/ui/workspace/use-workspace.ts | 3 +-- 15 files changed, 19 insertions(+), 33 deletions(-) diff --git a/components/hooks/use-lane-components/use-lane-components.tsx b/components/hooks/use-lane-components/use-lane-components.tsx index f3d23cc5e0cd..8ecffaac96ed 100644 --- a/components/hooks/use-lane-components/use-lane-components.tsx +++ b/components/hooks/use-lane-components/use-lane-components.tsx @@ -1,6 +1,5 @@ -import { useQuery as useDataQuery } from '@apollo/client'; +import { useQuery as useDataQuery, DocumentNode } from '@apollo/client'; import { gql } from 'graphql-tag'; -import { DocumentNode } from 'graphql'; import { ComponentID, ComponentModel, componentOverviewFields } from '@teambit/component'; import { LaneId } from '@teambit/lane-id'; import { ComponentDescriptor } from '@teambit/component-descriptor'; diff --git a/components/hooks/use-lanes/use-lanes.tsx b/components/hooks/use-lanes/use-lanes.tsx index 63f792f0b7b2..5c825898ca88 100644 --- a/components/hooks/use-lanes/use-lanes.tsx +++ b/components/hooks/use-lanes/use-lanes.tsx @@ -1,8 +1,7 @@ import { useMemo, useCallback } from 'react'; -import { useQuery as useDataQuery } from '@apollo/client'; +import { useQuery as useDataQuery, DocumentNode } from '@apollo/client'; import { LaneModel, LanesModel } from '@teambit/lanes.ui.models.lanes-model'; import { gql } from 'graphql-tag'; -import { DocumentNode } from 'graphql'; import { LaneId } from '@teambit/lane-id'; import { isEqual } from 'lodash'; import { useLanesContext } from './lanes-context'; diff --git a/components/ui/compare/lane-compare-hooks/use-lane-diff-status/use-lane-diff-status.ts b/components/ui/compare/lane-compare-hooks/use-lane-diff-status/use-lane-diff-status.ts index 9ce425ca51a6..b61dce77b3ff 100644 --- a/components/ui/compare/lane-compare-hooks/use-lane-diff-status/use-lane-diff-status.ts +++ b/components/ui/compare/lane-compare-hooks/use-lane-diff-status/use-lane-diff-status.ts @@ -1,7 +1,6 @@ -import { useQuery as useDataQuery } from '@apollo/client'; +import { useQuery as useDataQuery, DocumentNode } from '@apollo/client'; import { gql } from 'graphql-tag'; import { LaneId } from '@teambit/lane-id'; -import { DocumentNode } from 'graphql'; import { ComponentID, ComponentIdObj } from '@teambit/component-id'; import { LaneDiff, PlainLaneDiff, ChangeType } from '@teambit/lanes.entities.lane-diff'; diff --git a/components/ui/hooks/use-core-aspects/use-core-aspects.tsx b/components/ui/hooks/use-core-aspects/use-core-aspects.tsx index 36184050bedd..0ced32744d8b 100644 --- a/components/ui/hooks/use-core-aspects/use-core-aspects.tsx +++ b/components/ui/hooks/use-core-aspects/use-core-aspects.tsx @@ -1,6 +1,5 @@ -import { useQuery as useDataQuery } from '@apollo/client'; +import { useQuery as useDataQuery, DocumentNode } from '@apollo/client'; import { gql } from 'graphql-tag'; -import { DocumentNode } from 'graphql'; export type CoreAspectIdByPackageName = { [packageName: string]: string; diff --git a/scopes/api-reference/hooks/use-api/use-api.ts b/scopes/api-reference/hooks/use-api/use-api.ts index a45785875848..867a863191b6 100644 --- a/scopes/api-reference/hooks/use-api/use-api.ts +++ b/scopes/api-reference/hooks/use-api/use-api.ts @@ -1,6 +1,5 @@ -import { useQuery as useDataQuery } from '@apollo/client'; +import { useQuery as useDataQuery, DocumentNode } from '@apollo/client'; import { gql } from 'graphql-tag'; -import { DocumentNode } from 'graphql'; import { APIReferenceModel } from '@teambit/api-reference.models.api-reference-model'; import { APINodeRenderer } from '@teambit/api-reference.models.api-node-renderer'; diff --git a/scopes/api-reference/hooks/use-schema/use-schema.ts b/scopes/api-reference/hooks/use-schema/use-schema.ts index 3a51eb739b6c..d839c2919af9 100644 --- a/scopes/api-reference/hooks/use-schema/use-schema.ts +++ b/scopes/api-reference/hooks/use-schema/use-schema.ts @@ -1,7 +1,6 @@ -import { DataQueryResult, useDataQuery } from '@teambit/ui-foundation.ui.hooks.use-data-query'; +import { useQuery as useDataQuery, DocumentNode } from '@apollo/client'; import { gql } from 'graphql-tag'; -import { DocumentNode } from 'graphql'; -import { SchemaQueryResult, APIReferenceModel } from '@teambit/api-reference.models.api-reference-model'; +import { APIReferenceModel } from '@teambit/api-reference.models.api-reference-model'; import { APINodeRenderer } from '@teambit/api-reference.models.api-node-renderer'; const GET_SCHEMA: DocumentNode = gql` @@ -17,11 +16,8 @@ export function useSchema( host: string, componentId: string, apiNodeRenderers: APINodeRenderer[] -): { apiModel?: APIReferenceModel } & Omit< - DataQueryResult, - 'data' -> { - const { data, ...rest } = useDataQuery(GET_SCHEMA, { +): { apiModel?: APIReferenceModel; loading?: boolean } { + const { data, loading } = useDataQuery(GET_SCHEMA, { variables: { extensionId: host, componentId, @@ -31,7 +27,7 @@ export function useSchema( const apiModel = data?.getHost?.getSchema ? APIReferenceModel.from(data, apiNodeRenderers) : undefined; return { - ...rest, + loading, apiModel, }; } diff --git a/scopes/cloud/hooks/use-cloud-scopes/use-cloud-scopes.ts b/scopes/cloud/hooks/use-cloud-scopes/use-cloud-scopes.ts index 8327343c6cf9..d40f133d8f03 100644 --- a/scopes/cloud/hooks/use-cloud-scopes/use-cloud-scopes.ts +++ b/scopes/cloud/hooks/use-cloud-scopes/use-cloud-scopes.ts @@ -1,6 +1,5 @@ -import { useQuery as useDataQuery } from '@apollo/client'; +import { useQuery as useDataQuery, DocumentNode } from '@apollo/client'; import { gql } from 'graphql-tag'; -import { DocumentNode } from 'graphql'; import { ScopeDescriptor } from '@teambit/scopes.scope-descriptor'; import { ScopeID } from '@teambit/scopes.scope-id'; diff --git a/scopes/cloud/hooks/use-current-user/use-current-user.ts b/scopes/cloud/hooks/use-current-user/use-current-user.ts index 388b769c1af5..060aa4eefc09 100644 --- a/scopes/cloud/hooks/use-current-user/use-current-user.ts +++ b/scopes/cloud/hooks/use-current-user/use-current-user.ts @@ -1,6 +1,5 @@ -import { useQuery as useDataQuery } from '@apollo/client'; +import { useQuery as useDataQuery, DocumentNode } from '@apollo/client'; import { gql } from 'graphql-tag'; -import { DocumentNode } from 'graphql'; import { CloudUser } from '@teambit/cloud.models.cloud-user'; export const CURRENT_USER_QUERY: DocumentNode = gql` diff --git a/scopes/cloud/hooks/use-logout/use-logout.ts b/scopes/cloud/hooks/use-logout/use-logout.ts index 6c0f20b8f694..0eca401aa55e 100644 --- a/scopes/cloud/hooks/use-logout/use-logout.ts +++ b/scopes/cloud/hooks/use-logout/use-logout.ts @@ -1,6 +1,5 @@ import { useMutation } from '@teambit/ui'; -import { gql } from '@apollo/client'; -import { DocumentNode } from 'graphql'; +import { gql, DocumentNode } from '@apollo/client'; export const LOGOUT_MUTATION: DocumentNode = gql` mutation LogoutUser { diff --git a/scopes/component/component/host/use-component-host.ts b/scopes/component/component/host/use-component-host.ts index bb58d184eeb5..434c17636244 100644 --- a/scopes/component/component/host/use-component-host.ts +++ b/scopes/component/component/host/use-component-host.ts @@ -1,6 +1,5 @@ -import { useQuery as useDataQuery } from '@apollo/client'; +import { useQuery as useDataQuery, DocumentNode } from '@apollo/client'; import { gql } from 'graphql-tag'; -import { DocumentNode } from 'graphql'; import { ComponentHostModel } from './component-host-model'; diff --git a/scopes/component/component/ui/aspect-page/aspect-page.tsx b/scopes/component/component/ui/aspect-page/aspect-page.tsx index 4453aa447396..ddc870fd5fef 100644 --- a/scopes/component/component/ui/aspect-page/aspect-page.tsx +++ b/scopes/component/component/ui/aspect-page/aspect-page.tsx @@ -1,8 +1,7 @@ import { AspectBox } from '@teambit/harmony.ui.aspect-box'; import React, { useContext } from 'react'; -import { useQuery as useDataQuery } from '@apollo/client'; +import { useQuery as useDataQuery, DocumentNode } from '@apollo/client'; import { gql } from 'graphql-tag'; -import { DocumentNode } from 'graphql'; import { EmptyBox } from '@teambit/design.ui.empty-box'; import { H1 } from '@teambit/documenter.ui.heading'; import { Separator } from '@teambit/documenter.ui.separator'; diff --git a/scopes/component/component/ui/use-component.fragments.ts b/scopes/component/component/ui/use-component.fragments.ts index 0bf992e40afe..544d6becc149 100644 --- a/scopes/component/component/ui/use-component.fragments.ts +++ b/scopes/component/component/ui/use-component.fragments.ts @@ -1,5 +1,5 @@ import { gql } from 'graphql-tag'; -import { DocumentNode } from 'graphql'; +import { DocumentNode } from '@apollo/client'; export const componentIdFields: DocumentNode = gql` fragment componentIdFields on ComponentID { diff --git a/scopes/component/graph/ui/query/get-graph.query.ts b/scopes/component/graph/ui/query/get-graph.query.ts index 4bdb5ebed8be..94039ee2d03d 100644 --- a/scopes/component/graph/ui/query/get-graph.query.ts +++ b/scopes/component/graph/ui/query/get-graph.query.ts @@ -1,5 +1,5 @@ import { gql } from 'graphql-tag'; -import { DocumentNode } from 'graphql'; +import { DocumentNode } from '@apollo/client'; import { EdgeType } from '../../edge-type'; // please update types when updating query, for added safety diff --git a/scopes/ui-foundation/ui/webpack/webpack.base.config.ts b/scopes/ui-foundation/ui/webpack/webpack.base.config.ts index 5f0bf795ace7..f49616ba0199 100644 --- a/scopes/ui-foundation/ui/webpack/webpack.base.config.ts +++ b/scopes/ui-foundation/ui/webpack/webpack.base.config.ts @@ -101,6 +101,7 @@ export default function createWebpackConfig( 'react-dom$': 'react-dom/profiling', 'scheduler/tracing': 'scheduler/tracing-profiling', }), + '@teambit/base-react.navigation.link': require.resolve('@teambit/base-react.navigation.link'), }, fallback: { module: false, diff --git a/scopes/workspace/workspace/ui/workspace/use-workspace.ts b/scopes/workspace/workspace/ui/workspace/use-workspace.ts index 2eabe7eb703f..3f04b1550990 100644 --- a/scopes/workspace/workspace/ui/workspace/use-workspace.ts +++ b/scopes/workspace/workspace/ui/workspace/use-workspace.ts @@ -2,9 +2,8 @@ import { useEffect, useMemo } from 'react'; import { ComponentModel } from '@teambit/component'; import useLatest from '@react-hook/latest'; import { gql } from 'graphql-tag'; -import { DocumentNode } from 'graphql'; import { ComponentID, ComponentIdObj } from '@teambit/component-id'; -import { useQuery } from '@apollo/client'; +import { useQuery, DocumentNode } from '@apollo/client'; import { Workspace } from './workspace-model'; From 388ebd429cd263e259825fb398085c773ccad448 Mon Sep 17 00:00:00 2001 From: Luv Kapur Date: Tue, 30 Apr 2024 12:55:39 -0400 Subject: [PATCH 30/32] remove deprecated graphql-types-json and replace it with graphql-scalars --- scopes/component/component/component.graphql.ts | 2 +- scopes/semantics/schema/schema.graphql.ts | 2 +- workspace.jsonc | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scopes/component/component/component.graphql.ts b/scopes/component/component/component.graphql.ts index c361fc31bb34..a1a66c294e62 100644 --- a/scopes/component/component/component.graphql.ts +++ b/scopes/component/component/component.graphql.ts @@ -1,6 +1,6 @@ import stripAnsi from 'strip-ansi'; import { gql } from 'graphql-tag'; -import { GraphQLJSONObject } from 'graphql-type-json'; +import { GraphQLJSONObject } from 'graphql-scalars'; import { ComponentID, ComponentIdObj } from '@teambit/component-id'; import { pathNormalizeToLinux } from '@teambit/legacy/dist/utils'; import { ComponentLog } from '@teambit/legacy/dist/scope/models/model-component'; diff --git a/scopes/semantics/schema/schema.graphql.ts b/scopes/semantics/schema/schema.graphql.ts index ca672993bd6b..efb1f8470b15 100644 --- a/scopes/semantics/schema/schema.graphql.ts +++ b/scopes/semantics/schema/schema.graphql.ts @@ -1,5 +1,5 @@ import { ComponentFactory } from '@teambit/component'; -import { GraphQLJSONObject } from 'graphql-type-json'; +import { GraphQLJSONObject } from 'graphql-scalars'; import { gql } from 'graphql-tag'; import { APISchema, UnImplementedSchema } from '@teambit/semantics.entities.semantic-schema'; import { Schema } from '@teambit/graphql'; diff --git a/workspace.jsonc b/workspace.jsonc index 59e2681edde2..0b04958bf783 100644 --- a/workspace.jsonc +++ b/workspace.jsonc @@ -19,12 +19,12 @@ "@babel/preset-react": "^7.23.3", "@babel/preset-typescript": "^7.23.3", "@babel/types": "7.22.3", - "@graphql-tools/schema": "^10.0.3", - "@graphql-tools/utils": "^10.1.2", - "@graphql-tools/wrap": "^10.0.5", "@bitdev/node.generators.node-templates": "^2.0.2", "@bitdev/react.generators.react-templates": "^2.0.1", "@bitdev/symphony.generators.symphony-templates": "^1.0.0", + "@graphql-tools/schema": "^10.0.3", + "@graphql-tools/utils": "^10.1.2", + "@graphql-tools/wrap": "^10.0.5", "@jest/test-result": "26.6.2", "@mdx-js/mdx": "1.6.21", "@mdx-js/react": "1.6.22", @@ -405,10 +405,10 @@ "graphql-disable-introspection": "^1.2.0", "graphql-http": "^1.22.0", "graphql-modules": "^2.3.0", + "graphql-scalars": "^1.23.0", "graphql-subscriptions": "2.0.0", "graphql-tag": "^2.12.6", "graphql-tools": "^9.0.1", - "graphql-type-json": "0.3.2", "graphql-ws": "^5.15.0", "history": "5.3.0", "html-escaper": "3.0.0", From 62616018798a6dd2c79ba5b3c7c0b71547fd520f Mon Sep 17 00:00:00 2001 From: Luv Kapur Date: Thu, 1 Aug 2024 10:56:59 -0400 Subject: [PATCH 31/32] upgrade core aspect env --- .bitmap | 384 +++++++++++------------ scopes/defender/eslint/component.json | 2 +- scopes/react/react-native/component.json | 2 +- scopes/ui-foundation/ui/component.json | 2 +- 4 files changed, 195 insertions(+), 195 deletions(-) diff --git a/.bitmap b/.bitmap index 99f25eb382de..c59863244839 100644 --- a/.bitmap +++ b/.bitmap @@ -23,10 +23,10 @@ "mainFile": "index.ts", "rootDir": "scopes/api-reference/api-reference", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "api-server": { @@ -36,10 +36,10 @@ "mainFile": "index.ts", "rootDir": "scopes/harmony/api-server", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "application": { @@ -49,10 +49,10 @@ "mainFile": "index.ts", "rootDir": "scopes/harmony/application", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "array/duplications-finder": { @@ -69,10 +69,10 @@ "mainFile": "index.ts", "rootDir": "scopes/harmony/aspect", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "aspect-docs/babel": { @@ -229,10 +229,10 @@ "mainFile": "index.ts", "rootDir": "scopes/harmony/aspect-loader", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "babel": { @@ -242,10 +242,10 @@ "mainFile": "index.ts", "rootDir": "scopes/compilation/babel", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "babel/bit-react-transformer": { @@ -262,10 +262,10 @@ "mainFile": "index.ts", "rootDir": "scopes/harmony/bit", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "bit-map": { @@ -282,10 +282,10 @@ "mainFile": "index.ts", "rootDir": "scopes/pipelines/builder", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "builder-data": { @@ -302,10 +302,10 @@ "mainFile": "index.ts", "rootDir": "scopes/compilation/bundler", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "cache": { @@ -315,10 +315,10 @@ "mainFile": "index.ts", "rootDir": "scopes/harmony/cache", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "changelog": { @@ -328,10 +328,10 @@ "mainFile": "index.ts", "rootDir": "scopes/component/changelog", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "checkout": { @@ -341,10 +341,10 @@ "mainFile": "index.ts", "rootDir": "scopes/component/checkout", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "clear-cache": { @@ -354,10 +354,10 @@ "mainFile": "index.ts", "rootDir": "scopes/workspace/clear-cache", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "cli": { @@ -367,10 +367,10 @@ "mainFile": "index.ts", "rootDir": "scopes/harmony/cli", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "cli-table": { @@ -401,10 +401,10 @@ "mainFile": "index.ts", "rootDir": "scopes/cloud/cloud", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "code": { @@ -414,10 +414,10 @@ "mainFile": "index.ts", "rootDir": "scopes/component/code", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "command-bar": { @@ -427,10 +427,10 @@ "mainFile": "index.ts", "rootDir": "scopes/explorer/command-bar", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "community": { @@ -440,10 +440,10 @@ "mainFile": "index.ts", "rootDir": "scopes/community/community", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "compiler": { @@ -453,10 +453,10 @@ "mainFile": "index.ts", "rootDir": "scopes/compilation/compiler", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "component": { @@ -466,10 +466,10 @@ "mainFile": "index.ts", "rootDir": "scopes/component/component", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "component-compare": { @@ -479,10 +479,10 @@ "mainFile": "index.ts", "rootDir": "scopes/component/component-compare", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "component-descriptor": { @@ -492,10 +492,10 @@ "mainFile": "index.ts", "rootDir": "scopes/component/component-descriptor", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "component-diff": { @@ -526,10 +526,10 @@ "mainFile": "index.ts", "rootDir": "scopes/component/component-log", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "component-package-version": { @@ -546,10 +546,10 @@ "mainFile": "index.ts", "rootDir": "scopes/component/component-sizer", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "component-tree": { @@ -559,10 +559,10 @@ "mainFile": "index.ts", "rootDir": "scopes/component/component-tree", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "component-writer": { @@ -572,10 +572,10 @@ "mainFile": "index.ts", "rootDir": "scopes/component/component-writer", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "composition-card": { @@ -592,10 +592,10 @@ "mainFile": "index.ts", "rootDir": "scopes/compositions/compositions", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "config": { @@ -605,10 +605,10 @@ "mainFile": "index.ts", "rootDir": "scopes/harmony/config", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "config-merger": { @@ -618,10 +618,10 @@ "mainFile": "index.ts", "rootDir": "scopes/workspace/config-merger", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "content/cli-reference": { @@ -645,10 +645,10 @@ "mainFile": "index.ts", "rootDir": "scopes/dependencies/dependencies", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "dependency-resolver": { @@ -671,10 +671,10 @@ "mainFile": "index.ts", "rootDir": "scopes/component/deprecation", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "dev-files": { @@ -684,10 +684,10 @@ "mainFile": "index.ts", "rootDir": "scopes/component/dev-files", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "diagnostic": { @@ -697,10 +697,10 @@ "mainFile": "index.ts", "rootDir": "scopes/harmony/diagnostic", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "docs": { @@ -710,10 +710,10 @@ "mainFile": "index.ts", "rootDir": "scopes/docs/docs", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "doctor": { @@ -730,10 +730,10 @@ "mainFile": "index.ts", "rootDir": "scopes/workspace/eject", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "entities/lane-diff": { @@ -757,10 +757,10 @@ "mainFile": "index.ts", "rootDir": "scopes/envs/env", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "envs": { @@ -770,10 +770,10 @@ "mainFile": "index.ts", "rootDir": "scopes/envs/envs", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "eslint": { @@ -811,10 +811,10 @@ "mainFile": "index.ts", "rootDir": "scopes/scope/export", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "express": { @@ -824,10 +824,10 @@ "mainFile": "index.ts", "rootDir": "scopes/harmony/express", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "forking": { @@ -837,10 +837,10 @@ "mainFile": "index.ts", "rootDir": "scopes/component/forking", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "formatter": { @@ -850,10 +850,10 @@ "mainFile": "index.ts", "rootDir": "scopes/defender/formatter", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "fs/extension-getter": { @@ -912,10 +912,10 @@ "mainFile": "index.ts", "rootDir": "scopes/generator/generator", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "get-bit-version": { @@ -932,10 +932,10 @@ "mainFile": "index.ts", "rootDir": "scopes/git/git", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "global-config": { @@ -945,10 +945,10 @@ "mainFile": "index.ts", "rootDir": "scopes/harmony/global-config", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "graph": { @@ -958,10 +958,10 @@ "mainFile": "index.ts", "rootDir": "scopes/component/graph", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "graphql": { @@ -971,10 +971,10 @@ "mainFile": "index.ts", "rootDir": "scopes/harmony/graphql", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "harmony-ui-app": { @@ -984,10 +984,10 @@ "mainFile": "index.ts", "rootDir": "scopes/ui-foundation/harmony-ui-app/harmony-ui-app", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "hooks/use-api": { @@ -1081,10 +1081,10 @@ "mainFile": "index.ts", "rootDir": "scopes/scope/importer", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "insights": { @@ -1094,10 +1094,10 @@ "mainFile": "index.ts", "rootDir": "scopes/explorer/insights", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "install": { @@ -1107,10 +1107,10 @@ "mainFile": "index.ts", "rootDir": "scopes/workspace/install", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "ipc-events": { @@ -1120,10 +1120,10 @@ "mainFile": "index.ts", "rootDir": "scopes/harmony/ipc-events", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "isolator": { @@ -1133,10 +1133,10 @@ "mainFile": "index.ts", "rootDir": "scopes/component/isolator", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "issues": { @@ -1146,10 +1146,10 @@ "mainFile": "index.ts", "rootDir": "scopes/component/issues", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "jest": { @@ -1159,10 +1159,10 @@ "mainFile": "index.ts", "rootDir": "scopes/defender/jest", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "lanes": { @@ -1172,10 +1172,10 @@ "mainFile": "index.ts", "rootDir": "scopes/lanes/lanes", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "legacy-component-log": { @@ -1192,10 +1192,10 @@ "mainFile": "index.ts", "rootDir": "scopes/defender/linter", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "lister": { @@ -1205,10 +1205,10 @@ "mainFile": "index.ts", "rootDir": "scopes/component/lister", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "logger": { @@ -1218,10 +1218,10 @@ "mainFile": "index.ts", "rootDir": "scopes/harmony/logger", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "mdx": { @@ -1238,10 +1238,10 @@ "mainFile": "index.ts", "rootDir": "scopes/lanes/merge-lanes", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "merging": { @@ -1251,10 +1251,10 @@ "mainFile": "index.ts", "rootDir": "scopes/component/merging", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "mocha": { @@ -1264,10 +1264,10 @@ "mainFile": "index.ts", "rootDir": "scopes/defender/mocha", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "model/composition-id": { @@ -1522,10 +1522,10 @@ "mainFile": "index.ts", "rootDir": "scopes/component/mover", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "multi-compiler": { @@ -1535,10 +1535,10 @@ "mainFile": "index.ts", "rootDir": "scopes/compilation/multi-compiler", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "multi-tester": { @@ -1548,10 +1548,10 @@ "mainFile": "index.ts", "rootDir": "scopes/defender/multi-tester", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "network/get-port": { @@ -1568,10 +1568,10 @@ "mainFile": "index.ts", "rootDir": "scopes/component/new-component-helper", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "node": { @@ -1588,10 +1588,10 @@ "mainFile": "index.ts", "rootDir": "scopes/ui-foundation/notifications/aspect", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "overview/api-reference-table-of-contents": { @@ -1615,10 +1615,10 @@ "mainFile": "index.ts", "rootDir": "scopes/ui-foundation/panels", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "panels/composition-gallery": { @@ -1670,10 +1670,10 @@ "mainFile": "index.ts", "rootDir": "scopes/pkg/pkg", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "plugins/inject-head-webpack-plugin": { @@ -1690,10 +1690,10 @@ "mainFile": "index.ts", "rootDir": "scopes/dependencies/pnpm", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "prettier": { @@ -1703,10 +1703,10 @@ "mainFile": "index.ts", "rootDir": "scopes/defender/prettier", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "prettier/config-mutator": { @@ -1723,10 +1723,10 @@ "mainFile": "index.ts", "rootDir": "scopes/preview/preview", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "promise/map-pool": { @@ -1743,10 +1743,10 @@ "mainFile": "index.ts", "rootDir": "scopes/harmony/pubsub", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "react": { @@ -1770,10 +1770,10 @@ "mainFile": "index.ts", "rootDir": "scopes/ui-foundation/react-router/react-router", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "readme": { @@ -1790,10 +1790,10 @@ "mainFile": "index.ts", "rootDir": "scopes/component/refactoring", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "remove": { @@ -1803,10 +1803,10 @@ "mainFile": "index.ts", "rootDir": "scopes/component/remove", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "renaming": { @@ -1816,10 +1816,10 @@ "mainFile": "index.ts", "rootDir": "scopes/component/renaming", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "renderers/api-node-details": { @@ -1976,10 +1976,10 @@ "mainFile": "index.ts", "rootDir": "scopes/semantics/schema", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "scope": { @@ -1989,10 +1989,10 @@ "mainFile": "index.ts", "rootDir": "scopes/scope/scope", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "scope-api": { @@ -2023,10 +2023,10 @@ "mainFile": "index.ts", "rootDir": "scopes/ui-foundation/sidebar", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "sign": { @@ -2036,10 +2036,10 @@ "mainFile": "index.ts", "rootDir": "scopes/scope/sign", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "snapping": { @@ -2049,10 +2049,10 @@ "mainFile": "index.ts", "rootDir": "scopes/component/snapping", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "sources": { @@ -2069,10 +2069,10 @@ "mainFile": "index.ts", "rootDir": "scopes/component/stash", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "status": { @@ -2082,10 +2082,10 @@ "mainFile": "index.ts", "rootDir": "scopes/component/status", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "string/capitalize": { @@ -2144,10 +2144,10 @@ "mainFile": "index.ts", "rootDir": "scopes/defender/tester", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "testing/load-aspect": { @@ -2192,10 +2192,10 @@ "mainFile": "index.ts", "rootDir": "scopes/component/tracker", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "ts-server": { @@ -2219,10 +2219,10 @@ "mainFile": "index.ts", "rootDir": "scopes/typescript/typescript", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "ui": { @@ -2603,10 +2603,10 @@ "mainFile": "index.ts", "rootDir": "scopes/scope/update-dependencies", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "url/add-avatar-query-params": { @@ -2630,10 +2630,10 @@ "mainFile": "index.ts", "rootDir": "scopes/ui-foundation/user-agent", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "utils": { @@ -2692,10 +2692,10 @@ "mainFile": "index.ts", "rootDir": "scopes/workspace/variants", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "version-history": { @@ -2705,10 +2705,10 @@ "mainFile": "index.ts", "rootDir": "scopes/scope/version-history", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "watcher": { @@ -2718,10 +2718,10 @@ "mainFile": "index.ts", "rootDir": "scopes/workspace/watcher", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "webpack": { @@ -2731,10 +2731,10 @@ "mainFile": "index.ts", "rootDir": "scopes/webpack/webpack", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "worker": { @@ -2744,10 +2744,10 @@ "mainFile": "index.ts", "rootDir": "scopes/harmony/worker", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "workspace": { @@ -2757,10 +2757,10 @@ "mainFile": "index.ts", "rootDir": "scopes/workspace/workspace", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "workspace-config-files": { @@ -2770,10 +2770,10 @@ "mainFile": "index.ts", "rootDir": "scopes/workspace/workspace-config-files", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "yarn": { @@ -2783,10 +2783,10 @@ "mainFile": "index.ts", "rootDir": "scopes/dependencies/yarn", "config": { - "teambit.harmony/envs/core-aspect-env@0.0.31": {}, "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" - } + }, + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } }, "$schema-version": "17.0.0" diff --git a/scopes/defender/eslint/component.json b/scopes/defender/eslint/component.json index 57bb1f3baef1..be5db0a35b2d 100644 --- a/scopes/defender/eslint/component.json +++ b/scopes/defender/eslint/component.json @@ -18,6 +18,6 @@ "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" }, - "teambit.harmony/envs/core-aspect-env@0.0.42": {} + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } } diff --git a/scopes/react/react-native/component.json b/scopes/react/react-native/component.json index a130fe0f9fbb..5414c60af4ce 100644 --- a/scopes/react/react-native/component.json +++ b/scopes/react/react-native/component.json @@ -27,6 +27,6 @@ "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" }, - "teambit.harmony/envs/core-aspect-env@0.0.42": {} + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } } diff --git a/scopes/ui-foundation/ui/component.json b/scopes/ui-foundation/ui/component.json index 313ba67902af..cbfd98f12cce 100644 --- a/scopes/ui-foundation/ui/component.json +++ b/scopes/ui-foundation/ui/component.json @@ -31,6 +31,6 @@ "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" }, - "teambit.harmony/envs/core-aspect-env@0.0.42": {} + "teambit.harmony/envs/core-aspect-env@0.0.44": {} } } From ce6ff1122c32b1205416382f8ccc27e8945e8f7b Mon Sep 17 00:00:00 2001 From: Luv Kapur Date: Fri, 23 Aug 2024 15:48:48 -0400 Subject: [PATCH 32/32] add resolver adapter to pass context as first param --- .bitmap | 19 ++++- .../create-remote-schemas.ts | 13 +++- .../harmony/graphql/graphql.main.runtime.ts | 73 +++++++++++++++++-- workspace.jsonc | 7 +- 4 files changed, 100 insertions(+), 12 deletions(-) diff --git a/.bitmap b/.bitmap index c59863244839..e2db1cbdb0c5 100644 --- a/.bitmap +++ b/.bitmap @@ -974,7 +974,24 @@ "teambit.envs/envs": { "env": "teambit.harmony/envs/core-aspect-env" }, - "teambit.harmony/envs/core-aspect-env@0.0.44": {} + "teambit.harmony/envs/core-aspect-env@0.0.44": {}, + "teambit.dependencies/dependency-resolver": { + "policy": { + "dependencies": { + "@teambit/legacy": "-", + "bufferutil": "4.0.3", + "utf-8-validate": "5.0.5" + }, + "devDependencies": { + "@types/mocha": "9.1.0", + "@teambit/legacy": "-" + }, + "peerDependencies": { + "@teambit/legacy": "1.0.624", + "graphql": "16.8.1" + } + } + } } }, "harmony-ui-app": { diff --git a/scopes/harmony/graphql/create-remote-schemas/create-remote-schemas.ts b/scopes/harmony/graphql/create-remote-schemas/create-remote-schemas.ts index 553fc665643e..4a7014b8212d 100644 --- a/scopes/harmony/graphql/create-remote-schemas/create-remote-schemas.ts +++ b/scopes/harmony/graphql/create-remote-schemas/create-remote-schemas.ts @@ -38,6 +38,8 @@ async function createApolloClient( const contextLink = setContext((_, prevContext) => { return { headers: prevContext.graphqlContext?.req?.headers, + req: prevContext.graphqlContext?.req, + rootValue: { req: prevContext.graphqlContext?.req }, }; }); @@ -89,8 +91,15 @@ async function getRemoteSchema({ return wrapSchema({ schema: remoteSchema, - executor: async ({ document, variables }) => { - const fetchResult = await client.query({ query: document, variables, fetchPolicy: 'network-only' }); + executor: async ({ document, variables, context }) => { + const fetchResult: any = await client.query({ + query: document, + variables, + fetchPolicy: 'network-only', + context: { + graphqlContext: context, + }, + }); return fetchResult as any; }, }); diff --git a/scopes/harmony/graphql/graphql.main.runtime.ts b/scopes/harmony/graphql/graphql.main.runtime.ts index 47522e86ac5d..4b1afd1fa486 100644 --- a/scopes/harmony/graphql/graphql.main.runtime.ts +++ b/scopes/harmony/graphql/graphql.main.runtime.ts @@ -1,7 +1,7 @@ import { mergeSchemas } from '@graphql-tools/schema'; import { GraphQLUUID, GraphQLJSONObject } from 'graphql-scalars'; import { WebSocketServer } from 'ws'; -import { ApolloServer } from '@apollo/server'; +import { ApolloServer, ApolloServerPlugin } from '@apollo/server'; import { expressMiddleware } from '@apollo/server/express4'; import { ApolloServerPluginDrainHttpServer } from '@apollo/server/plugin/drainHttpServer'; import { ApolloServerPluginLandingPageDisabled } from '@apollo/server/plugin/disabled'; @@ -17,7 +17,7 @@ import { createServer, Server } from 'http'; import compact from 'lodash.compact'; import cors from 'cors'; import { GraphQLServer } from './graphql-server'; -import { GraphQLSchema, subscribe as graphqlSubscribe, execute as graphqlExecute } from 'graphql'; +import { GraphQLSchema, subscribe as graphqlSubscribe, execute as graphqlExecute, isObjectType } from 'graphql'; import { createRemoteSchemas } from './create-remote-schemas'; import { GraphqlAspect } from './graphql.aspect'; import { Schema } from './schema'; @@ -118,13 +118,17 @@ export class GraphqlMain { const httpServer = createServer(app); const remoteSchemas = await createRemoteSchemas(options.remoteSchemas || this.graphQLServerSlot.values()); - const application = this.createRootModule(options.schemaSlot); + // const wrappedRemoteSchemas = remoteSchemas.map(this.wrapSchemaResolvers); + const wrappedRemoteSchemas = remoteSchemas; + const application = this.createRootModule(options.schemaSlot); + // const wrappedLocalSchema = this.wrapSchemaResolvers(application.schema); + const wrappedLocalSchema = application.schema; const subscribe = application.createSubscription(); const execute = application.createExecution(); const schemas = compact( - [application.schema].concat(remoteSchemas).filter((x) => { + [wrappedLocalSchema].concat(wrappedRemoteSchemas).filter((x) => { return Boolean(x && (x.getQueryType() || x.getMutationType() || x.getSubscriptionType())); }) ); @@ -200,7 +204,7 @@ export class GraphqlMain { app.use( '/graphql', expressMiddleware(apolloServer, { - context: async ({ req }) => req, + context: async ({ req }) => ({ req }), }) ); @@ -306,13 +310,70 @@ export class GraphqlMain { }; } + wrapResolver = (resolver) => { + return (_source, args, context, info) => { + return resolver(context, args, context, info); + }; + }; + + wrapSchemaResolvers = (schema: GraphQLSchema) => { + const typeMap = schema.getTypeMap(); + Object.keys(typeMap).forEach((typeName) => { + const type = typeMap[typeName]; + + // Check if the type is an object type (e.g., Query, Mutation, Subscription) + if (isObjectType(type)) { + const fields = type.getFields(); + Object.keys(fields).forEach((fieldName) => { + const field = fields[fieldName]; + + // Only wrap if the field has a resolve function + if (typeof field.resolve === 'function') { + field.resolve = this.wrapResolver(field.resolve); + } + }); + } + }); + return schema; + }; + + private wrapResolvers = (resolvers: any) => { + const wrappedResolvers = {}; + for (const [typeName, fields] of Object.entries(resolvers) as any) { + // Only wrap resolvers for Query, Mutation, and Subscription types + if (typeName === 'Query' || typeName === 'Mutation' || typeName === 'Subscription') { + wrappedResolvers[typeName] = {}; + for (const [fieldName, resolver] of Object.entries(fields)) { + if (typeof resolver === 'function') { + wrappedResolvers[typeName][fieldName] = this.wrapResolver(resolver); + } + } + } else { + // Copy the scalar and other non-object type resolvers as is + wrappedResolvers[typeName] = fields; + } + } + return wrappedResolvers; + }; + private buildModules(schemaSlot?: SchemaSlot) { const schemaSlots = schemaSlot ? schemaSlot.toArray() : this.moduleSlot.toArray(); return schemaSlots.map(([extensionId, schema]) => { + const wrappedResolvers = this.wrapResolvers(schema.resolvers); + + console.log( + '🚀 ~ file: graphql.main.runtime.ts:398 ~ GraphqlMain ~ returnschemaSlots.map ~ schema.resolvers,:', + schema.resolvers + ); + console.log( + '🚀 ~ file: graphql.main.runtime.ts:410 ~ GraphqlMain ~ returnschemaSlots.map ~ wrappedResolvers:', + wrappedResolvers + ); + const module = createModule({ id: extensionId, typeDefs: schema.typeDefs, - resolvers: schema.resolvers, + resolvers: wrappedResolvers, }); this.modules.set(extensionId, module); diff --git a/workspace.jsonc b/workspace.jsonc index 8dd34f8328e7..40bca49bfb18 100644 --- a/workspace.jsonc +++ b/workspace.jsonc @@ -22,15 +22,16 @@ "@bitdev/node.generators.node-templates": "^2.0.5", "@bitdev/react.generators.react-templates": "^2.0.5", "@bitdev/symphony.generators.symphony-templates": "^1.0.0", + "@dagrejs/dagre": "^1.1.2", + "@graphql-tools/delegate": "^10.0.19", "@graphql-tools/schema": "^10.0.3", "@graphql-tools/utils": "^10.1.2", "@graphql-tools/wrap": "^10.0.5", + "@jest/test-result": "29.3.1", "@mdx-js/mdx": "1.6.21", "@mdx-js/react": "1.6.22", "@monaco-editor/react": "4.4.6", "@pmmmwh/react-refresh-webpack-plugin": "0.5.11", - "@dagrejs/dagre": "^1.1.2", - "@jest/test-result": "29.3.1", "@pnpm/client": "11.1.3", "@pnpm/colorize-semver-diff": "1.0.1", "@pnpm/config": "21.6.0", @@ -251,9 +252,9 @@ "@teambit/lanes.ui.icons.lane-icon": "^0.0.9", "@teambit/lanes.ui.lane-details": "^0.0.204", "@teambit/lanes.ui.menus.lanes-overview-menu": "^0.0.10", + "@teambit/lanes.ui.navigation.lane-switcher": "^0.0.225", "@teambit/mdx.compilers.mdx-transpiler": "^1.0.7", "@teambit/mdx.generator.mdx-templates": "^1.0.10", - "@teambit/lanes.ui.navigation.lane-switcher": "^0.0.225", "@teambit/mdx.modules.mdx-loader": "^1.0.14", "@teambit/mdx.ui.docs.link": "0.0.500", "@teambit/mdx.ui.docs.snippet": "^0.0.509",