@base44-preview/cli 0.0.30-pr.214.2479e76 → 0.0.30-pr.214.355c0d7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/index.js CHANGED
@@ -153967,6 +153967,7 @@ async function removeConnector(integrationType) {
153967
153967
  }
153968
153968
  // src/core/resources/connector/config.ts
153969
153969
  import { join as join3 } from "node:path";
153970
+ import { isDeepStrictEqual } from "node:util";
153970
153971
  async function readConnectorFile(connectorPath) {
153971
153972
  const parsed = await readJsonFile(connectorPath);
153972
153973
  const result = ConnectorResourceSchema.safeParse(parsed);
@@ -153975,7 +153976,7 @@ async function readConnectorFile(connectorPath) {
153975
153976
  }
153976
153977
  return result.data;
153977
153978
  }
153978
- async function readAllConnectors(connectorsDir) {
153979
+ async function readConnectorFiles(connectorsDir) {
153979
153980
  if (!await pathExists(connectorsDir)) {
153980
153981
  return [];
153981
153982
  }
@@ -153983,45 +153984,65 @@ async function readAllConnectors(connectorsDir) {
153983
153984
  cwd: connectorsDir,
153984
153985
  absolute: true
153985
153986
  });
153986
- const connectors = await Promise.all(files.map((filePath) => readConnectorFile(filePath)));
153987
+ return await Promise.all(files.map(async (filePath) => ({
153988
+ data: await readConnectorFile(filePath),
153989
+ filePath
153990
+ })));
153991
+ }
153992
+ async function readAllConnectors(connectorsDir) {
153993
+ const entries = await readConnectorFiles(connectorsDir);
153987
153994
  const types = new Set;
153988
- for (const connector of connectors) {
153989
- if (types.has(connector.type)) {
153990
- throw new InvalidInputError(`Duplicate connector type "${connector.type}"`, {
153995
+ for (const { data } of entries) {
153996
+ if (types.has(data.type)) {
153997
+ throw new InvalidInputError(`Duplicate connector type "${data.type}"`, {
153991
153998
  hints: [
153992
153999
  {
153993
- message: `Remove duplicate connectors with type "${connector.type}" - only one connector per type is allowed`
154000
+ message: `Remove duplicate connectors with type "${data.type}" - only one connector per type is allowed`
153994
154001
  }
153995
154002
  ]
153996
154003
  });
153997
154004
  }
153998
- types.add(connector.type);
154005
+ types.add(data.type);
153999
154006
  }
154000
- return connectors;
154007
+ return entries.map((e2) => e2.data);
154001
154008
  }
154002
154009
  async function writeConnectors(connectorsDir, remoteConnectors) {
154003
- const existingConnectors = await readAllConnectors(connectorsDir);
154010
+ const entries = await readConnectorFiles(connectorsDir);
154011
+ const typeToEntry = new Map;
154012
+ for (const entry of entries) {
154013
+ if (typeToEntry.has(entry.data.type)) {
154014
+ throw new InvalidInputError(`Duplicate connector type "${entry.data.type}"`, {
154015
+ hints: [
154016
+ {
154017
+ message: `Remove duplicate connectors with type "${entry.data.type}" - only one connector per type is allowed`
154018
+ }
154019
+ ]
154020
+ });
154021
+ }
154022
+ typeToEntry.set(entry.data.type, entry);
154023
+ }
154004
154024
  const newTypes = new Set(remoteConnectors.map((c) => c.integration_type));
154005
- const toDelete = existingConnectors.filter((c) => !newTypes.has(c.type));
154006
- for (const connector of toDelete) {
154007
- const files = await globby(`${connector.type}.${CONFIG_FILE_EXTENSION_GLOB}`, {
154008
- cwd: connectorsDir,
154009
- absolute: true
154010
- });
154011
- for (const filePath of files) {
154012
- await deleteFile(filePath);
154025
+ const deleted = [];
154026
+ for (const [type, entry] of typeToEntry) {
154027
+ if (!newTypes.has(type)) {
154028
+ await deleteFile(entry.filePath);
154029
+ deleted.push(type);
154013
154030
  }
154014
154031
  }
154032
+ const written = [];
154015
154033
  for (const connector of remoteConnectors) {
154016
- const filePath = join3(connectorsDir, `${connector.integration_type}.${CONFIG_FILE_EXTENSION}`);
154034
+ const existing = typeToEntry.get(connector.integration_type);
154017
154035
  const localConnector = {
154018
154036
  type: connector.integration_type,
154019
154037
  scopes: connector.scopes
154020
154038
  };
154039
+ if (existing && isDeepStrictEqual(existing.data, localConnector)) {
154040
+ continue;
154041
+ }
154042
+ const filePath = existing?.filePath ?? join3(connectorsDir, `${connector.integration_type}.${CONFIG_FILE_EXTENSION}`);
154021
154043
  await writeJsonFile(filePath, localConnector);
154044
+ written.push(connector.integration_type);
154022
154045
  }
154023
- const written = remoteConnectors.map((c) => c.integration_type);
154024
- const deleted = toDelete.map((c) => c.type);
154025
154046
  return { written, deleted };
154026
154047
  }
154027
154048
  // node_modules/open/index.js
@@ -169943,6 +169964,9 @@ async function pullConnectorsAction() {
169943
169964
  if (deleted.length > 0) {
169944
169965
  M2.warn(`Deleted: ${deleted.join(", ")}`);
169945
169966
  }
169967
+ if (written.length === 0 && deleted.length === 0) {
169968
+ M2.info("All connectors are already up to date");
169969
+ }
169946
169970
  return {
169947
169971
  outroMessage: `Pulled ${remoteConnectors.integrations.length} connectors to ${connectorsDir}`
169948
169972
  };
@@ -174998,4 +175022,4 @@ export {
174998
175022
  CLIExitError
174999
175023
  };
175000
175024
 
175001
- //# debugId=32B5EDD5767F60C664756E2164756E21
175025
+ //# debugId=1AA228373AD0C78A64756E2164756E21