@webiny/cli-core 0.0.0-unstable.0d717d18dd → 0.0.0-unstable.33e4fd9647

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.
Files changed (48) hide show
  1. package/createCliContainer.js +17 -12
  2. package/createCliContainer.js.map +1 -1
  3. package/features/DepsSync/ListAllPackages.d.ts +1 -1
  4. package/features/DepsSync/ListAllPackages.js +2 -2
  5. package/features/DepsSync/ListAllPackages.js.map +1 -1
  6. package/features/DepsSync/commands/SyncDepsCommand.js +1 -1
  7. package/features/DepsSync/commands/SyncDepsCommand.js.map +1 -1
  8. package/features/DepsSync/commands/VerifyDepsCommand.js +1 -1
  9. package/features/DepsSync/commands/VerifyDepsCommand.js.map +1 -1
  10. package/features/DepsSync/createDependencyTree.d.ts +1 -1
  11. package/features/DepsSync/createDependencyTree.js +8 -5
  12. package/features/DepsSync/createDependencyTree.js.map +1 -1
  13. package/features/InfoCommand/InfoCommand.js +5 -1
  14. package/features/InfoCommand/InfoCommand.js.map +1 -1
  15. package/features/Wcp/LinkProjectCommand.js +1 -1
  16. package/features/Wcp/LinkProjectCommand.js.map +1 -1
  17. package/features/globalOptions/TraceGlobalOption.d.ts +5 -0
  18. package/features/globalOptions/TraceGlobalOption.js +22 -0
  19. package/features/globalOptions/TraceGlobalOption.js.map +1 -0
  20. package/features/globalOptions/index.d.ts +1 -0
  21. package/features/globalOptions/index.js +1 -0
  22. package/package.json +14 -11
  23. package/services/GetCliRunnerService/GetCliRunnerService.js +5 -1
  24. package/services/GetCliRunnerService/GetCliRunnerService.js.map +1 -1
  25. package/services/UiService/UiService.d.ts +18 -0
  26. package/services/UiService/UiService.js +18 -2
  27. package/services/UiService/UiService.js.map +1 -1
  28. package/utils/{ensureSameWebinyPackageVersions.js → ensureSameWebinyPackageVersions/ensureSameWebinyPackageVersions.js} +12 -22
  29. package/utils/ensureSameWebinyPackageVersions/ensureSameWebinyPackageVersions.js.map +1 -0
  30. package/utils/ensureSameWebinyPackageVersions/getCacheFilePath.d.ts +1 -0
  31. package/utils/ensureSameWebinyPackageVersions/getCacheFilePath.js +12 -0
  32. package/utils/ensureSameWebinyPackageVersions/getCacheFilePath.js.map +1 -0
  33. package/utils/ensureSameWebinyPackageVersions/hashYarnLock.d.ts +1 -0
  34. package/utils/ensureSameWebinyPackageVersions/hashYarnLock.js +16 -0
  35. package/utils/ensureSameWebinyPackageVersions/hashYarnLock.js.map +1 -0
  36. package/utils/ensureSameWebinyPackageVersions/index.d.ts +6 -0
  37. package/utils/ensureSameWebinyPackageVersions/index.js +6 -0
  38. package/utils/ensureSameWebinyPackageVersions/listWebinyPackageVersions.d.ts +1 -0
  39. package/utils/ensureSameWebinyPackageVersions/listWebinyPackageVersions.js +31 -0
  40. package/utils/ensureSameWebinyPackageVersions/listWebinyPackageVersions.js.map +1 -0
  41. package/utils/ensureSameWebinyPackageVersions/readClearedYarnLockHash.d.ts +1 -0
  42. package/utils/ensureSameWebinyPackageVersions/readClearedYarnLockHash.js +13 -0
  43. package/utils/ensureSameWebinyPackageVersions/readClearedYarnLockHash.js.map +1 -0
  44. package/utils/ensureSameWebinyPackageVersions/writeClearedYarnLockHash.d.ts +1 -0
  45. package/utils/ensureSameWebinyPackageVersions/writeClearedYarnLockHash.js +24 -0
  46. package/utils/ensureSameWebinyPackageVersions/writeClearedYarnLockHash.js.map +1 -0
  47. package/utils/ensureSameWebinyPackageVersions.js.map +0 -1
  48. /package/utils/{ensureSameWebinyPackageVersions.d.ts → ensureSameWebinyPackageVersions/ensureSameWebinyPackageVersions.d.ts} +0 -0
@@ -1,10 +1,11 @@
1
1
  import path from "path";
2
2
  import { Container } from "@webiny/di";
3
3
  import { argvParserService, cliParamsService, commandsRegistryService, defaultAppsService, getArgvService, getCliRunnerService, getIsCiService, getProjectSdkService, globalOptionsRegistryService, loggerService, runCliRunnerService, stdioService, uiService } from "./services/index.js";
4
- import { UpgradeCommandFeature, aboutCommand, buildCommand, configCommand, disableTelemetryCommand, enableTelemetryCommand, extensionCommand, infoCommand, isCi, linkProjectCommand, logLevelGlobalOption, loginCommand, logoutCommand, missingFilesInBuildGracefulErrorHandler, openCommand, showLogsGlobalOption, stackTraceGlobalOption, syncDepsCommand, verifyDepsCommand, whoAmICommand } from "./features/index.js";
4
+ import { UpgradeCommandFeature, aboutCommand, buildCommand, configCommand, disableTelemetryCommand, enableTelemetryCommand, extensionCommand, infoCommand, isCi, linkProjectCommand, logLevelGlobalOption, loginCommand, logoutCommand, missingFilesInBuildGracefulErrorHandler, openCommand, showLogsGlobalOption, stackTraceGlobalOption, syncDepsCommand, traceGlobalOption, verifyDepsCommand, whoAmICommand } from "./features/index.js";
5
5
  import chalk from "chalk";
6
6
  import { CliParamsService, GetArgvService, GetProjectSdkService, UiService } from "./abstractions/index.js";
7
7
  import { GracefulError, toImportSpecifier } from "@webiny/project";
8
+ import { traceAsync } from "@webiny/project/utils/trace/index.js";
8
9
  import { commandsWithGracefulErrorHandling } from "./decorators/index.js";
9
10
  import { CliCommand } from "./extensions/index.js";
10
11
  const { bgYellow: bgYellow, bold: bold } = chalk;
@@ -30,6 +31,7 @@ const createCliContainer = async (params, register)=>{
30
31
  container.register(showLogsGlobalOption).inSingletonScope();
31
32
  container.register(logLevelGlobalOption).inSingletonScope();
32
33
  container.register(stackTraceGlobalOption).inSingletonScope();
34
+ container.register(traceGlobalOption).inSingletonScope();
33
35
  container.register(argvParserService).inSingletonScope();
34
36
  container.register(cliParamsService).inSingletonScope();
35
37
  container.register(commandsRegistryService).inSingletonScope();
@@ -47,13 +49,14 @@ const createCliContainer = async (params, register)=>{
47
49
  const ui = container.resolve(UiService);
48
50
  try {
49
51
  container.resolve(CliParamsService).set(params);
50
- const projectSdk = await container.resolve(GetProjectSdkService).execute();
51
- const projectConfig = await projectSdk.getProjectConfig({
52
- tags: {
53
- runtimeContext: "cli"
54
- }
55
- });
56
- await projectSdk.validateProjectConfig(projectConfig);
52
+ const getProjectSdk = container.resolve(GetProjectSdkService);
53
+ const projectSdk = await traceAsync("initialize project SDK", ()=>getProjectSdk.execute());
54
+ const projectConfig = await traceAsync("get project config", ()=>projectSdk.getProjectConfig({
55
+ tags: {
56
+ runtimeContext: "cli"
57
+ }
58
+ }));
59
+ await traceAsync("validate project config", ()=>projectSdk.validateProjectConfig(projectConfig));
57
60
  const project = projectSdk.getProject();
58
61
  const importFromPath = async (filePath)=>{
59
62
  let importPath;
@@ -63,10 +66,12 @@ const createCliContainer = async (params, register)=>{
63
66
  return "default" in importedModule && importedModule.default || importedModule[exportName];
64
67
  };
65
68
  const commands = projectConfig.extensionsByType(CliCommand);
66
- for (const command of commands){
67
- const commandImplementation = await importFromPath(command.params.src);
68
- container.register(commandImplementation).inSingletonScope();
69
- }
69
+ await traceAsync("import project CLI commands", async ()=>{
70
+ for (const command of commands){
71
+ const commandImplementation = await importFromPath(command.params.src);
72
+ container.register(commandImplementation).inSingletonScope();
73
+ }
74
+ });
70
75
  } catch (error) {
71
76
  let realError = error;
72
77
  if (error.cause) realError = error.cause;
@@ -1 +1 @@
1
- {"version":3,"file":"createCliContainer.js","sources":["../src/createCliContainer.ts"],"sourcesContent":["import path from \"path\";\nimport { Container } from \"@webiny/di\";\nimport {\n argvParserService,\n cliParamsService,\n commandsRegistryService,\n defaultAppsService,\n getArgvService,\n getCliRunnerService,\n getIsCiService,\n getProjectSdkService,\n globalOptionsRegistryService,\n loggerService,\n runCliRunnerService,\n stdioService,\n uiService\n} from \"./services/index.js\";\n\nimport {\n aboutCommand,\n buildCommand,\n configCommand,\n disableTelemetryCommand,\n enableTelemetryCommand,\n extensionCommand,\n infoCommand,\n isCi,\n linkProjectCommand,\n loginCommand,\n logLevelGlobalOption,\n logoutCommand,\n missingFilesInBuildGracefulErrorHandler,\n openCommand,\n showLogsGlobalOption,\n stackTraceGlobalOption,\n syncDepsCommand,\n UpgradeCommandFeature,\n verifyDepsCommand,\n whoAmICommand\n} from \"./features/index.js\";\n\nimport chalk from \"chalk\";\nimport {\n CliParamsService,\n GetArgvService,\n GetProjectSdkService,\n UiService\n} from \"~/abstractions/index.js\";\nimport { GracefulError, toImportSpecifier } from \"@webiny/project\";\nimport { commandsWithGracefulErrorHandling } from \"./decorators/index.js\";\nimport { CliCommand } from \"~/extensions/index.js\";\n\nconst { bgYellow, bold } = chalk;\n\nexport const createCliContainer = async (\n params: CliParamsService.Params,\n register?: (container: Container) => void\n) => {\n const container = new Container();\n\n // Core commands.\n container.register(aboutCommand).inSingletonScope();\n container.register(buildCommand).inSingletonScope();\n container.register(configCommand).inSingletonScope();\n container.register(enableTelemetryCommand).inSingletonScope();\n container.register(disableTelemetryCommand).inSingletonScope();\n container.register(extensionCommand).inSingletonScope();\n container.register(syncDepsCommand).inSingletonScope();\n container.register(verifyDepsCommand).inSingletonScope();\n container.register(infoCommand).inSingletonScope();\n container.register(isCi).inSingletonScope();\n container.register(openCommand).inSingletonScope();\n UpgradeCommandFeature.register(container);\n\n container.register(linkProjectCommand).inSingletonScope();\n container.register(loginCommand).inSingletonScope();\n container.register(logoutCommand).inSingletonScope();\n container.register(whoAmICommand).inSingletonScope();\n\n // Graceful error handlers.\n container.register(missingFilesInBuildGracefulErrorHandler).inSingletonScope();\n\n // Global options.\n container.register(showLogsGlobalOption).inSingletonScope();\n container.register(logLevelGlobalOption).inSingletonScope();\n container.register(stackTraceGlobalOption).inSingletonScope();\n\n // Services.\n container.register(argvParserService).inSingletonScope();\n container.register(cliParamsService).inSingletonScope();\n container.register(commandsRegistryService).inSingletonScope();\n container.register(defaultAppsService).inSingletonScope();\n container.register(getArgvService).inSingletonScope();\n container.register(getCliRunnerService).inSingletonScope();\n container.register(getIsCiService).inSingletonScope();\n container.register(globalOptionsRegistryService).inSingletonScope();\n container.register(getProjectSdkService).inSingletonScope();\n container.register(loggerService).inSingletonScope();\n container.register(runCliRunnerService).inSingletonScope();\n container.register(stdioService).inSingletonScope();\n container.register(uiService).inSingletonScope();\n\n // Allow hosting-specific registrations (e.g. cli-aws, cli-server).\n register?.(container);\n\n // Extensions.\n const ui = container.resolve(UiService);\n\n try {\n // Immediately set CLI instance params via the `CliParamsService`.\n container.resolve(CliParamsService).set(params);\n\n const projectSdk = await container.resolve(GetProjectSdkService).execute();\n\n const projectConfig = await projectSdk.getProjectConfig({\n tags: { runtimeContext: \"cli\" }\n });\n\n await projectSdk.validateProjectConfig(projectConfig);\n\n const project = projectSdk.getProject();\n\n const importFromPath = async (filePath: string) => {\n let importPath: string;\n if (filePath.startsWith(\"/extensions/\")) {\n // Resolve from project root.\n importPath = project.paths.rootFolder.join(filePath).toString();\n } else {\n // Treat as absolute path.\n importPath = filePath;\n }\n\n const exportName = path.basename(filePath).replace(path.extname(filePath), \"\");\n\n const importedModule = await import(toImportSpecifier(importPath));\n\n // Support both default and named exports.\n // Check for 'default' property existence rather than truthiness.\n return (\n (\"default\" in importedModule && importedModule.default) ||\n importedModule[exportName]\n );\n };\n\n const commands = projectConfig.extensionsByType(CliCommand);\n for (const command of commands) {\n const commandImplementation = await importFromPath(command.params.src);\n\n container.register(commandImplementation).inSingletonScope();\n }\n } catch (error) {\n let realError = error;\n if (error.cause) {\n realError = error.cause as Error;\n }\n\n ui.error(realError.message);\n\n const argv = container.resolve(GetArgvService).execute();\n if (argv.showStackTrace && realError.stack) {\n ui.emptyLine();\n ui.debug(\"Stack trace:\");\n ui.text(realError.stack);\n }\n\n if (error && error instanceof GracefulError) {\n ui.emptyLine();\n ui.text(bgYellow(bold(\"💡 How can I resolve this?\")));\n ui.text(error.message);\n }\n\n process.exit(1);\n }\n\n // Decorators (must be registered after all commands).\n container.registerDecorator(commandsWithGracefulErrorHandling);\n\n return container;\n};\n"],"names":["bgYellow","bold","chalk","createCliContainer","params","register","container","Container","aboutCommand","buildCommand","configCommand","enableTelemetryCommand","disableTelemetryCommand","extensionCommand","syncDepsCommand","verifyDepsCommand","infoCommand","isCi","openCommand","UpgradeCommandFeature","linkProjectCommand","loginCommand","logoutCommand","whoAmICommand","missingFilesInBuildGracefulErrorHandler","showLogsGlobalOption","logLevelGlobalOption","stackTraceGlobalOption","argvParserService","cliParamsService","commandsRegistryService","defaultAppsService","getArgvService","getCliRunnerService","getIsCiService","globalOptionsRegistryService","getProjectSdkService","loggerService","runCliRunnerService","stdioService","uiService","ui","UiService","CliParamsService","projectSdk","GetProjectSdkService","projectConfig","project","importFromPath","filePath","importPath","exportName","path","importedModule","toImportSpecifier","commands","CliCommand","command","commandImplementation","error","realError","argv","GetArgvService","GracefulError","process","commandsWithGracefulErrorHandling"],"mappings":";;;;;;;;;AAoDA,MAAM,EAAEA,UAAAA,QAAQ,EAAEC,MAAAA,IAAI,EAAE,GAAGC;AAEpB,MAAMC,qBAAqB,OAC9BC,QACAC;IAEA,MAAMC,YAAY,IAAIC;IAGtBD,UAAU,QAAQ,CAACE,cAAc,gBAAgB;IACjDF,UAAU,QAAQ,CAACG,cAAc,gBAAgB;IACjDH,UAAU,QAAQ,CAACI,eAAe,gBAAgB;IAClDJ,UAAU,QAAQ,CAACK,wBAAwB,gBAAgB;IAC3DL,UAAU,QAAQ,CAACM,yBAAyB,gBAAgB;IAC5DN,UAAU,QAAQ,CAACO,kBAAkB,gBAAgB;IACrDP,UAAU,QAAQ,CAACQ,iBAAiB,gBAAgB;IACpDR,UAAU,QAAQ,CAACS,mBAAmB,gBAAgB;IACtDT,UAAU,QAAQ,CAACU,aAAa,gBAAgB;IAChDV,UAAU,QAAQ,CAACW,MAAM,gBAAgB;IACzCX,UAAU,QAAQ,CAACY,aAAa,gBAAgB;IAChDC,sBAAsB,QAAQ,CAACb;IAE/BA,UAAU,QAAQ,CAACc,oBAAoB,gBAAgB;IACvDd,UAAU,QAAQ,CAACe,cAAc,gBAAgB;IACjDf,UAAU,QAAQ,CAACgB,eAAe,gBAAgB;IAClDhB,UAAU,QAAQ,CAACiB,eAAe,gBAAgB;IAGlDjB,UAAU,QAAQ,CAACkB,yCAAyC,gBAAgB;IAG5ElB,UAAU,QAAQ,CAACmB,sBAAsB,gBAAgB;IACzDnB,UAAU,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CAACH,WAAW;YAE3E,MAAMI,iBAAiB,MAAM,MAAM,CAACC,kBAAkBJ;YAItD,OACK,aAAaG,kBAAkBA,eAAe,OAAO,IACtDA,cAAc,CAACF,WAAW;QAElC;QAEA,MAAMI,WAAWT,cAAc,gBAAgB,CAACU;QAChD,KAAK,MAAMC,WAAWF,SAAU;YAC5B,MAAMG,wBAAwB,MAAMV,eAAeS,QAAQ,MAAM,CAAC,GAAG;YAErEnD,UAAU,QAAQ,CAACoD,uBAAuB,gBAAgB;QAC9D;IACJ,EAAE,OAAOC,OAAO;QACZ,IAAIC,YAAYD;QAChB,IAAIA,MAAM,KAAK,EACXC,YAAYD,MAAM,KAAK;QAG3BlB,GAAG,KAAK,CAACmB,UAAU,OAAO;QAE1B,MAAMC,OAAOvD,UAAU,OAAO,CAACwD,gBAAgB,OAAO;QACtD,IAAID,KAAK,cAAc,IAAID,UAAU,KAAK,EAAE;YACxCnB,GAAG,SAAS;YACZA,GAAG,KAAK,CAAC;YACTA,GAAG,IAAI,CAACmB,UAAU,KAAK;QAC3B;QAEA,IAAID,SAASA,iBAAiBI,eAAe;YACzCtB,GAAG,SAAS;YACZA,GAAG,IAAI,CAACzC,SAASC,KAAK;YACtBwC,GAAG,IAAI,CAACkB,MAAM,OAAO;QACzB;QAEAK,QAAQ,IAAI,CAAC;IACjB;IAGA1D,UAAU,iBAAiB,CAAC2D;IAE5B,OAAO3D;AACX"}
1
+ {"version":3,"file":"createCliContainer.js","sources":["../src/createCliContainer.ts"],"sourcesContent":["import path from \"path\";\nimport { Container } from \"@webiny/di\";\nimport {\n argvParserService,\n cliParamsService,\n commandsRegistryService,\n defaultAppsService,\n getArgvService,\n getCliRunnerService,\n getIsCiService,\n getProjectSdkService,\n globalOptionsRegistryService,\n loggerService,\n runCliRunnerService,\n stdioService,\n uiService\n} from \"./services/index.js\";\n\nimport {\n aboutCommand,\n buildCommand,\n configCommand,\n disableTelemetryCommand,\n enableTelemetryCommand,\n extensionCommand,\n infoCommand,\n isCi,\n linkProjectCommand,\n loginCommand,\n logLevelGlobalOption,\n logoutCommand,\n missingFilesInBuildGracefulErrorHandler,\n openCommand,\n showLogsGlobalOption,\n stackTraceGlobalOption,\n syncDepsCommand,\n traceGlobalOption,\n UpgradeCommandFeature,\n verifyDepsCommand,\n whoAmICommand\n} from \"./features/index.js\";\n\nimport chalk from \"chalk\";\nimport {\n CliParamsService,\n GetArgvService,\n GetProjectSdkService,\n UiService\n} from \"~/abstractions/index.js\";\nimport { GracefulError, toImportSpecifier } from \"@webiny/project\";\nimport { traceAsync } from \"@webiny/project/utils/trace/index.js\";\nimport { commandsWithGracefulErrorHandling } from \"./decorators/index.js\";\nimport { CliCommand } from \"~/extensions/index.js\";\n\nconst { bgYellow, bold } = chalk;\n\nexport const createCliContainer = async (\n params: CliParamsService.Params,\n register?: (container: Container) => void\n) => {\n const container = new Container();\n\n // Core commands.\n container.register(aboutCommand).inSingletonScope();\n container.register(buildCommand).inSingletonScope();\n container.register(configCommand).inSingletonScope();\n container.register(enableTelemetryCommand).inSingletonScope();\n container.register(disableTelemetryCommand).inSingletonScope();\n container.register(extensionCommand).inSingletonScope();\n container.register(syncDepsCommand).inSingletonScope();\n container.register(verifyDepsCommand).inSingletonScope();\n container.register(infoCommand).inSingletonScope();\n container.register(isCi).inSingletonScope();\n container.register(openCommand).inSingletonScope();\n UpgradeCommandFeature.register(container);\n\n container.register(linkProjectCommand).inSingletonScope();\n container.register(loginCommand).inSingletonScope();\n container.register(logoutCommand).inSingletonScope();\n container.register(whoAmICommand).inSingletonScope();\n\n // Graceful error handlers.\n container.register(missingFilesInBuildGracefulErrorHandler).inSingletonScope();\n\n // Global options.\n container.register(showLogsGlobalOption).inSingletonScope();\n container.register(logLevelGlobalOption).inSingletonScope();\n container.register(stackTraceGlobalOption).inSingletonScope();\n container.register(traceGlobalOption).inSingletonScope();\n\n // Services.\n container.register(argvParserService).inSingletonScope();\n container.register(cliParamsService).inSingletonScope();\n container.register(commandsRegistryService).inSingletonScope();\n container.register(defaultAppsService).inSingletonScope();\n container.register(getArgvService).inSingletonScope();\n container.register(getCliRunnerService).inSingletonScope();\n container.register(getIsCiService).inSingletonScope();\n container.register(globalOptionsRegistryService).inSingletonScope();\n container.register(getProjectSdkService).inSingletonScope();\n container.register(loggerService).inSingletonScope();\n container.register(runCliRunnerService).inSingletonScope();\n container.register(stdioService).inSingletonScope();\n container.register(uiService).inSingletonScope();\n\n // Allow hosting-specific registrations (e.g. cli-aws, cli-server).\n register?.(container);\n\n // Extensions.\n const ui = container.resolve(UiService);\n\n try {\n // Immediately set CLI instance params via the `CliParamsService`.\n container.resolve(CliParamsService).set(params);\n\n const getProjectSdk = container.resolve(GetProjectSdkService);\n const projectSdk = await traceAsync(\"initialize project SDK\", () =>\n getProjectSdk.execute()\n );\n\n const projectConfig = await traceAsync(\"get project config\", () => {\n return projectSdk.getProjectConfig({\n tags: { runtimeContext: \"cli\" }\n });\n });\n\n await traceAsync(\"validate project config\", () => {\n return projectSdk.validateProjectConfig(projectConfig);\n });\n\n const project = projectSdk.getProject();\n\n const importFromPath = async (filePath: string) => {\n let importPath: string;\n if (filePath.startsWith(\"/extensions/\")) {\n // Resolve from project root.\n importPath = project.paths.rootFolder.join(filePath).toString();\n } else {\n // Treat as absolute path.\n importPath = filePath;\n }\n\n const exportName = path.basename(filePath).replace(path.extname(filePath), \"\");\n\n const importedModule = await import(toImportSpecifier(importPath));\n\n // Support both default and named exports.\n // Check for 'default' property existence rather than truthiness.\n return (\n (\"default\" in importedModule && importedModule.default) ||\n importedModule[exportName]\n );\n };\n\n const commands = projectConfig.extensionsByType(CliCommand);\n await traceAsync(\"import project CLI commands\", async () => {\n for (const command of commands) {\n const commandImplementation = await importFromPath(command.params.src);\n\n container.register(commandImplementation).inSingletonScope();\n }\n });\n } catch (error) {\n let realError = error;\n if (error.cause) {\n realError = error.cause as Error;\n }\n\n ui.error(realError.message);\n\n const argv = container.resolve(GetArgvService).execute();\n if (argv.showStackTrace && realError.stack) {\n ui.emptyLine();\n ui.debug(\"Stack trace:\");\n ui.text(realError.stack);\n }\n\n if (error && error instanceof GracefulError) {\n ui.emptyLine();\n ui.text(bgYellow(bold(\"💡 How can I resolve this?\")));\n ui.text(error.message);\n }\n\n process.exit(1);\n }\n\n // Decorators (must be registered after all commands).\n container.registerDecorator(commandsWithGracefulErrorHandling);\n\n return container;\n};\n"],"names":["bgYellow","bold","chalk","createCliContainer","params","register","container","Container","aboutCommand","buildCommand","configCommand","enableTelemetryCommand","disableTelemetryCommand","extensionCommand","syncDepsCommand","verifyDepsCommand","infoCommand","isCi","openCommand","UpgradeCommandFeature","linkProjectCommand","loginCommand","logoutCommand","whoAmICommand","missingFilesInBuildGracefulErrorHandler","showLogsGlobalOption","logLevelGlobalOption","stackTraceGlobalOption","traceGlobalOption","argvParserService","cliParamsService","commandsRegistryService","defaultAppsService","getArgvService","getCliRunnerService","getIsCiService","globalOptionsRegistryService","getProjectSdkService","loggerService","runCliRunnerService","stdioService","uiService","ui","UiService","CliParamsService","getProjectSdk","GetProjectSdkService","projectSdk","traceAsync","projectConfig","project","importFromPath","filePath","importPath","exportName","path","importedModule","toImportSpecifier","commands","CliCommand","command","commandImplementation","error","realError","argv","GetArgvService","GracefulError","process","commandsWithGracefulErrorHandling"],"mappings":";;;;;;;;;;AAsDA,MAAM,EAAEA,UAAAA,QAAQ,EAAEC,MAAAA,IAAI,EAAE,GAAGC;AAEpB,MAAMC,qBAAqB,OAC9BC,QACAC;IAEA,MAAMC,YAAY,IAAIC;IAGtBD,UAAU,QAAQ,CAACE,cAAc,gBAAgB;IACjDF,UAAU,QAAQ,CAACG,cAAc,gBAAgB;IACjDH,UAAU,QAAQ,CAACI,eAAe,gBAAgB;IAClDJ,UAAU,QAAQ,CAACK,wBAAwB,gBAAgB;IAC3DL,UAAU,QAAQ,CAACM,yBAAyB,gBAAgB;IAC5DN,UAAU,QAAQ,CAACO,kBAAkB,gBAAgB;IACrDP,UAAU,QAAQ,CAACQ,iBAAiB,gBAA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AG,SAAS;YACZA,GAAG,KAAK,CAAC;YACTA,GAAG,IAAI,CAACqB,UAAU,KAAK;QAC3B;QAEA,IAAID,SAASA,iBAAiBI,eAAe;YACzCxB,GAAG,SAAS;YACZA,GAAG,IAAI,CAAC1C,SAASC,KAAK;YACtByC,GAAG,IAAI,CAACoB,MAAM,OAAO;QACzB;QAEAK,QAAQ,IAAI,CAAC;IACjB;IAGA7D,UAAU,iBAAiB,CAAC8D;IAE5B,OAAO9D;AACX"}
@@ -1,3 +1,3 @@
1
1
  export declare class ListAllPackages {
2
- list(paths: string[]): string[];
2
+ list(paths: string[]): Promise<string[]>;
3
3
  }
@@ -1,6 +1,6 @@
1
- import { listWorkspaces } from "@webiny/stdlib/node";
2
1
  class ListAllPackages {
3
- list(paths) {
2
+ async list(paths) {
3
+ const { listWorkspaces } = await import("@webiny/stdlib/node");
4
4
  const results = [];
5
5
  for (const p of paths)results.push(...listWorkspaces({
6
6
  cwd: p
@@ -1 +1 @@
1
- {"version":3,"file":"features/DepsSync/ListAllPackages.js","sources":["../../../src/features/DepsSync/ListAllPackages.ts"],"sourcesContent":["import { listWorkspaces } from \"@webiny/stdlib/node\";\n\nexport class ListAllPackages {\n public list(paths: string[]): string[] {\n const results: string[] = [];\n for (const p of paths) {\n results.push(\n ...listWorkspaces({\n cwd: p\n }).map(pkg => {\n return pkg.path;\n })\n );\n }\n return results;\n }\n}\n"],"names":["ListAllPackages","paths","results","p","listWorkspaces","pkg"],"mappings":";AAEO,MAAMA;IACF,KAAKC,KAAe,EAAY;QACnC,MAAMC,UAAoB,EAAE;QAC5B,KAAK,MAAMC,KAAKF,MACZC,QAAQ,IAAI,IACLE,eAAe;YACd,KAAKD;QACT,GAAG,GAAG,CAACE,CAAAA,MACIA,IAAI,IAAI;QAI3B,OAAOH;IACX;AACJ"}
1
+ {"version":3,"file":"features/DepsSync/ListAllPackages.js","sources":["../../../src/features/DepsSync/ListAllPackages.ts"],"sourcesContent":["export class ListAllPackages {\n public async list(paths: string[]): Promise<string[]> {\n // Imported here rather than at the top of the file. The CLI imports every command's code\n // on every run, even `webiny --help`, and `@webiny/stdlib/node` is about 60 modules that only\n // `sync-dependencies` and `verify-dependencies` ever need.\n const { listWorkspaces } = await import(\"@webiny/stdlib/node\");\n\n const results: string[] = [];\n for (const p of paths) {\n results.push(\n ...listWorkspaces({\n cwd: p\n }).map(pkg => {\n return pkg.path;\n })\n );\n }\n return results;\n }\n}\n"],"names":["ListAllPackages","paths","listWorkspaces","results","p","pkg"],"mappings":"AAAO,MAAMA;IACT,MAAa,KAAKC,KAAe,EAAqB;QAIlD,MAAM,EAAEC,cAAc,EAAE,GAAG,MAAM,MAAM,CAAC;QAExC,MAAMC,UAAoB,EAAE;QAC5B,KAAK,MAAMC,KAAKH,MACZE,QAAQ,IAAI,IACLD,eAAe;YACd,KAAKE;QACT,GAAG,GAAG,CAACC,CAAAA,MACIA,IAAI,IAAI;QAI3B,OAAOF;IACX;AACJ"}
@@ -17,7 +17,7 @@ class SyncDepsCommand {
17
17
  ],
18
18
  handler: async ()=>{
19
19
  const project = projectSdk.getProject();
20
- const tree = createDependencyTree(project);
20
+ const tree = await createDependencyTree(project);
21
21
  return createReferenceFile(project, tree, {
22
22
  uiService: this.uiService
23
23
  });
@@ -1 +1 @@
1
- {"version":3,"file":"features/DepsSync/commands/SyncDepsCommand.js","sources":["../../../../src/features/DepsSync/commands/SyncDepsCommand.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport { CliCommandFactory, GetProjectSdkService, UiService } from \"~/abstractions/index.js\";\n\nimport { createDependencyTree } from \"../createDependencyTree.js\";\nimport { createReferenceFile } from \"../createReferenceFile.js\";\n\nexport class SyncDepsCommand implements CliCommandFactory.Interface<unknown> {\n constructor(\n private getProjectSdkService: GetProjectSdkService.Interface,\n private uiService: UiService.Interface\n ) {}\n\n async execute() {\n const projectSdk = await this.getProjectSdkService.execute();\n\n return {\n name: \"sync-dependencies\",\n description: \"Sync dependencies for all packages.\",\n examples: [\"$0 sync-dependencies\"],\n handler: async () => {\n const project = projectSdk.getProject();\n const tree = createDependencyTree(project);\n\n return createReferenceFile(project, tree, { uiService: this.uiService });\n }\n };\n }\n}\n\nexport const syncDepsCommand = createImplementation({\n abstraction: CliCommandFactory,\n implementation: SyncDepsCommand,\n dependencies: [GetProjectSdkService, UiService]\n});\n"],"names":["SyncDepsCommand","getProjectSdkService","uiService","projectSdk","project","tree","createDependencyTree","createReferenceFile","syncDepsCommand","createImplementation","CliCommandFactory","GetProjectSdkService","UiService"],"mappings":";;;;AAMO,MAAMA;IACT,YACYC,oBAAoD,EACpDC,SAA8B,CACxC;aAFUD,oBAAoB,GAApBA;aACAC,SAAS,GAATA;IACT;IAEH,MAAM,UAAU;QACZ,MAAMC,aAAa,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO;QAE1D,OAAO;YACH,MAAM;YACN,aAAa;YACb,UAAU;gBAAC;aAAuB;YAClC,SAAS;gBACL,MAAMC,UAAUD,WAAW,UAAU;gBACrC,MAAME,OAAOC,qBAAqBF;gBAElC,OAAOG,oBAAoBH,SAASC,MAAM;oBAAE,WAAW,IAAI,CAAC,SAAS;gBAAC;YAC1E;QACJ;IACJ;AACJ;AAEO,MAAMG,kBAAkBC,qBAAqB;IAChD,aAAaC;IACb,gBAAgBV;IAChB,cAAc;QAACW;QAAsBC;KAAU;AACnD"}
1
+ {"version":3,"file":"features/DepsSync/commands/SyncDepsCommand.js","sources":["../../../../src/features/DepsSync/commands/SyncDepsCommand.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport { CliCommandFactory, GetProjectSdkService, UiService } from \"~/abstractions/index.js\";\n\nimport { createDependencyTree } from \"../createDependencyTree.js\";\nimport { createReferenceFile } from \"../createReferenceFile.js\";\n\nexport class SyncDepsCommand implements CliCommandFactory.Interface<unknown> {\n constructor(\n private getProjectSdkService: GetProjectSdkService.Interface,\n private uiService: UiService.Interface\n ) {}\n\n async execute() {\n const projectSdk = await this.getProjectSdkService.execute();\n\n return {\n name: \"sync-dependencies\",\n description: \"Sync dependencies for all packages.\",\n examples: [\"$0 sync-dependencies\"],\n handler: async () => {\n const project = projectSdk.getProject();\n const tree = await createDependencyTree(project);\n\n return createReferenceFile(project, tree, { uiService: this.uiService });\n }\n };\n }\n}\n\nexport const syncDepsCommand = createImplementation({\n abstraction: CliCommandFactory,\n implementation: SyncDepsCommand,\n dependencies: [GetProjectSdkService, UiService]\n});\n"],"names":["SyncDepsCommand","getProjectSdkService","uiService","projectSdk","project","tree","createDependencyTree","createReferenceFile","syncDepsCommand","createImplementation","CliCommandFactory","GetProjectSdkService","UiService"],"mappings":";;;;AAMO,MAAMA;IACT,YACYC,oBAAoD,EACpDC,SAA8B,CACxC;aAFUD,oBAAoB,GAApBA;aACAC,SAAS,GAATA;IACT;IAEH,MAAM,UAAU;QACZ,MAAMC,aAAa,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO;QAE1D,OAAO;YACH,MAAM;YACN,aAAa;YACb,UAAU;gBAAC;aAAuB;YAClC,SAAS;gBACL,MAAMC,UAAUD,WAAW,UAAU;gBACrC,MAAME,OAAO,MAAMC,qBAAqBF;gBAExC,OAAOG,oBAAoBH,SAASC,MAAM;oBAAE,WAAW,IAAI,CAAC,SAAS;gBAAC;YAC1E;QACJ;IACJ;AACJ;AAEO,MAAMG,kBAAkBC,qBAAqB;IAChD,aAAaC;IACb,gBAAgBV;IAChB,cAAc;QAACW;QAAsBC;KAAU;AACnD"}
@@ -22,7 +22,7 @@ class VerifyDepsCommand {
22
22
  const project = projectSdk.getProject();
23
23
  const referencesFile = getReferencesFilePath(project);
24
24
  const duplicatesFile = getDuplicatesFilePath(project);
25
- const tree = createDependencyTree(project);
25
+ const tree = await createDependencyTree(project);
26
26
  const references = {
27
27
  dependencies: tree.dependencies,
28
28
  devDependencies: tree.devDependencies,
@@ -1 +1 @@
1
- {"version":3,"file":"features/DepsSync/commands/VerifyDepsCommand.js","sources":["../../../../src/features/DepsSync/commands/VerifyDepsCommand.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport { CliCommandFactory, GetProjectSdkService, UiService } from \"~/abstractions/index.js\";\nimport { loadJsonFileSync } from \"load-json-file\";\nimport { getDuplicatesFilePath, getReferencesFilePath } from \"../paths.js\";\nimport fs from \"fs\";\nimport { createDependencyTree } from \"../createDependencyTree.js\";\nimport type { IDependencyCollection } from \"~/features/DepsSync/types.js\";\n\nexport class VerifyDepsCommand implements CliCommandFactory.Interface<unknown> {\n constructor(\n private getProjectSdkService: GetProjectSdkService.Interface,\n private uiService: UiService.Interface\n ) {}\n\n async execute() {\n return {\n name: \"verify-dependencies\",\n description: \"Verify dependencies for all packages.\",\n examples: [\"$0 verify-dependencies\"],\n handler: async () => {\n const ui = this.uiService;\n const projectSdk = await this.getProjectSdkService.execute();\n const project = projectSdk.getProject();\n const referencesFile = getReferencesFilePath(project);\n const duplicatesFile = getDuplicatesFilePath(project);\n\n const tree = createDependencyTree(project);\n\n const references: IDependencyCollection = {\n dependencies: tree.dependencies,\n devDependencies: tree.devDependencies,\n peerDependencies: tree.peerDependencies,\n resolutions: tree.resolutions,\n references: tree.references\n };\n\n ui.info(\"Checking references file...\");\n\n if (fs.existsSync(referencesFile)) {\n const json = loadJsonFileSync<IDependencyCollection>(referencesFile)!;\n if (JSON.stringify(references) !== JSON.stringify(json)) {\n for (const type in references) {\n const refDependencies = references[type as keyof typeof references];\n const fileDependencies = json[type as keyof typeof json];\n for (const dep in refDependencies) {\n const refDep = refDependencies[dep];\n const fileDep = fileDependencies[dep];\n if (!fileDep) {\n console.log(\"Missing dependency:\", refDep.name, \"in\", type);\n continue;\n }\n if (JSON.stringify(refDep) !== JSON.stringify(fileDep)) {\n console.log(\"Mismatch in dependency:\", refDep.name, \"in\", type);\n console.log({\n refDep: JSON.stringify(refDep),\n fileDep: JSON.stringify(fileDep)\n });\n }\n }\n }\n throw new Error(\n \"References are not in sync. Please run `yarn webiny sync-dependencies` command.\"\n );\n }\n } else {\n throw new Error(\n \"References file does not exist. Please run `yarn webiny sync-dependencies` command.\"\n );\n }\n\n ui.info(\"Checking duplicates file...\");\n\n if (fs.existsSync(duplicatesFile)) {\n const json = loadJsonFileSync(duplicatesFile);\n if (JSON.stringify(tree.duplicates) !== JSON.stringify(json)) {\n throw new Error(\n \"Duplicates are not in sync. Please run `yarn webiny sync-dependencies` command.\"\n );\n } else if (Array.isArray(json) && json.length > 0) {\n throw new Error(\n \"There are still duplicates in the project. Please sort them out and run `yarn webiny sync-dependencies` command to regenerate files.\"\n );\n }\n } else {\n throw new Error(\n \"Duplicates file does not exist. Please run `yarn webiny sync-dependencies` command.\"\n );\n }\n\n ui.info(\"✅ All package reference files are in sync.\");\n }\n };\n }\n}\n\nexport const verifyDepsCommand = createImplementation({\n abstraction: CliCommandFactory,\n implementation: VerifyDepsCommand,\n dependencies: [GetProjectSdkService, UiService]\n});\n"],"names":["VerifyDepsCommand","getProjectSdkService","uiService","ui","projectSdk","project","referencesFile","getReferencesFilePath","duplicatesFile","getDuplicatesFilePath","tree","createDependencyTree","references","fs","json","loadJsonFileSync","JSON","type","refDependencies","fileDependencies","dep","refDep","fileDep","console","Error","Array","verifyDepsCommand","createImplementation","CliCommandFactory","GetProjectSdkService","UiService"],"mappings":";;;;;;AAQO,MAAMA;IACT,YACYC,oBAAoD,EACpDC,SAA8B,CACxC;aAFUD,oBAAoB,GAApBA;aACAC,SAAS,GAATA;IACT;IAEH,MAAM,UAAU;QACZ,OAAO;YACH,MAAM;YACN,aAAa;YACb,UAAU;gBAAC;aAAyB;YACpC,SAAS;gBACL,MAAMC,KAAK,IAAI,CAAC,SAAS;gBACzB,MAAMC,aAAa,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO;gBAC1D,MAAMC,UAAUD,WAAW,UAAU;gBACrC,MAAME,iBAAiBC,sBAAsBF;gBAC7C,MAAMG,iBAAiBC,sBAAsBJ;gBAE7C,MAAMK,OAAOC,qBAAqBN;gBAElC,MAAMO,aAAoC;oBACt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ACN;gBAGZ,OACI,MAAM,IAAIA,MACN;gBAIRrB,GAAG,IAAI,CAAC;YACZ;QACJ;IACJ;AACJ;AAEO,MAAMuB,oBAAoBC,qBAAqB;IAClD,aAAaC;IACb,gBAAgB5B;IAChB,cAAc;QAAC6B;QAAsBC;KAAU;AACnD"}
1
+ {"version":3,"file":"features/DepsSync/commands/VerifyDepsCommand.js","sources":["../../../../src/features/DepsSync/commands/VerifyDepsCommand.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport { CliCommandFactory, GetProjectSdkService, UiService } from \"~/abstractions/index.js\";\nimport { loadJsonFileSync } from \"load-json-file\";\nimport { getDuplicatesFilePath, getReferencesFilePath } from \"../paths.js\";\nimport fs from \"fs\";\nimport { createDependencyTree } from \"../createDependencyTree.js\";\nimport type { IDependencyCollection } from \"~/features/DepsSync/types.js\";\n\nexport class VerifyDepsCommand implements CliCommandFactory.Interface<unknown> {\n constructor(\n private getProjectSdkService: GetProjectSdkService.Interface,\n private uiService: UiService.Interface\n ) {}\n\n async execute() {\n return {\n name: \"verify-dependencies\",\n description: \"Verify dependencies for all packages.\",\n examples: [\"$0 verify-dependencies\"],\n handler: async () => {\n const ui = this.uiService;\n const projectSdk = await this.getProjectSdkService.execute();\n const project = projectSdk.getProject();\n const referencesFile = getReferencesFilePath(project);\n const duplicatesFile = getDuplicatesFilePath(project);\n\n const tree = await createDependencyTree(project);\n\n const references: IDependencyCollection = {\n dependencies: tree.dependencies,\n devDependencies: tree.devDependencies,\n peerDependencies: tree.peerDependencies,\n resolutions: tree.resolutions,\n references: tree.references\n };\n\n ui.info(\"Checking references file...\");\n\n if (fs.existsSync(referencesFile)) {\n const json = loadJsonFileSync<IDependencyCollection>(referencesFile)!;\n if (JSON.stringify(references) !== JSON.stringify(json)) {\n for (const type in references) {\n const refDependencies = references[type as keyof typeof references];\n const fileDependencies = json[type as keyof typeof json];\n for (const dep in refDependencies) {\n const refDep = refDependencies[dep];\n const fileDep = fileDependencies[dep];\n if (!fileDep) {\n console.log(\"Missing dependency:\", refDep.name, \"in\", type);\n continue;\n }\n if (JSON.stringify(refDep) !== JSON.stringify(fileDep)) {\n console.log(\"Mismatch in dependency:\", refDep.name, \"in\", type);\n console.log({\n refDep: JSON.stringify(refDep),\n fileDep: JSON.stringify(fileDep)\n });\n }\n }\n }\n throw new Error(\n \"References are not in sync. Please run `yarn webiny sync-dependencies` command.\"\n );\n }\n } else {\n throw new Error(\n \"References file does not exist. Please run `yarn webiny sync-dependencies` command.\"\n );\n }\n\n ui.info(\"Checking duplicates file...\");\n\n if (fs.existsSync(duplicatesFile)) {\n const json = loadJsonFileSync(duplicatesFile);\n if (JSON.stringify(tree.duplicates) !== JSON.stringify(json)) {\n throw new Error(\n \"Duplicates are not in sync. Please run `yarn webiny sync-dependencies` command.\"\n );\n } else if (Array.isArray(json) && json.length > 0) {\n throw new Error(\n \"There are still duplicates in the project. Please sort them out and run `yarn webiny sync-dependencies` command to regenerate files.\"\n );\n }\n } else {\n throw new Error(\n \"Duplicates file does not exist. Please run `yarn webiny sync-dependencies` command.\"\n );\n }\n\n ui.info(\"✅ All package reference files are in sync.\");\n }\n };\n }\n}\n\nexport const verifyDepsCommand = createImplementation({\n abstraction: CliCommandFactory,\n implementation: VerifyDepsCommand,\n dependencies: [GetProjectSdkService, UiService]\n});\n"],"names":["VerifyDepsCommand","getProjectSdkService","uiService","ui","projectSdk","project","referencesFile","getReferencesFilePath","duplicatesFile","getDuplicatesFilePath","tree","createDependencyTree","references","fs","json","loadJsonFileSync","JSON","type","refDependencies","fileDependencies","dep","refDep","fileDep","console","Error","Array","verifyDepsCommand","createImplementation","CliCommandFactory","GetProjectSdkService","UiService"],"mappings":";;;;;;AAQO,MAAMA;IACT,YACYC,oBAAoD,EACpDC,SAA8B,CACxC;aAFUD,oBAAoB,GAApBA;aACAC,SAAS,GAATA;IACT;IAEH,MAAM,UAAU;QACZ,OAAO;YACH,MAAM;YACN,aAAa;YACb,UAAU;gBAAC;aAAyB;YAC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;gBAIRrB,GAAG,IAAI,CAAC;gBAER,IAAIU,GAAG,UAAU,CAACL,iBAAiB;oBAC/B,MAAMM,OAAOC,iBAAiBP;oBAC9B,IAAIQ,KAAK,SAAS,CAACN,KAAK,UAAU,MAAMM,KAAK,SAAS,CAACF,OACnD,MAAM,IAAIU,MACN;oBAED,IAAIC,MAAM,OAAO,CAACX,SAASA,KAAK,MAAM,GAAG,GAC5C,MAAM,IAAIU,MACN;gBAGZ,OACI,MAAM,IAAIA,MACN;gBAIRrB,GAAG,IAAI,CAAC;YACZ;QACJ;IACJ;AACJ;AAEO,MAAMuB,oBAAoBC,qBAAqB;IAClD,aAAaC;IACb,gBAAgB5B;IAChB,cAAc;QAAC6B;QAAsBC;KAAU;AACnD"}
@@ -1,3 +1,3 @@
1
1
  import type { IDependencyTree } from "./types.js";
2
2
  import { IProjectModel } from "@webiny/project";
3
- export declare const createDependencyTree: (project: IProjectModel) => IDependencyTree;
3
+ export declare const createDependencyTree: (project: IProjectModel) => Promise<IDependencyTree>;
@@ -1,18 +1,18 @@
1
+ import fs from "fs";
1
2
  import { ListAllPackages } from "./ListAllPackages.js";
2
3
  import { ListAllPackageJsonFiles } from "./ListAllPackageJsonFiles.js";
3
4
  import { BuildDependencyTree } from "./BuildDependencyTree.js";
4
- const createDependencyTree = (project)=>{
5
+ const createDependencyTree = async (project)=>{
5
6
  const projectRoot = project.paths.rootFolder;
6
7
  const basePath = projectRoot.toString();
7
8
  const packagesFolderPath = projectRoot.join("packages").toString();
8
- const cypressFolderPath = projectRoot.join("cypress").toString();
9
9
  const packageJsonFilePath = projectRoot.join("package.json").toString();
10
+ const e2ePackageJsonFilePath = projectRoot.join("e2e/package.json").toString();
10
11
  const listAllPackages = new ListAllPackages();
11
12
  const listAllPackageJsonFiles = new ListAllPackageJsonFiles();
12
13
  const buildDependencyTree = new BuildDependencyTree();
13
- const allPackages = listAllPackages.list([
14
- packagesFolderPath,
15
- cypressFolderPath
14
+ const allPackages = await listAllPackages.list([
15
+ packagesFolderPath
16
16
  ]);
17
17
  const allPackageJsonFiles = listAllPackageJsonFiles.list({
18
18
  targets: allPackages
@@ -21,6 +21,9 @@ const createDependencyTree = (project)=>{
21
21
  basePath,
22
22
  files: [
23
23
  packageJsonFilePath,
24
+ ...fs.existsSync(e2ePackageJsonFilePath) ? [
25
+ e2ePackageJsonFilePath
26
+ ] : [],
24
27
  ...allPackageJsonFiles
25
28
  ],
26
29
  ignore: /^@webiny\//
@@ -1 +1 @@
1
- {"version":3,"file":"features/DepsSync/createDependencyTree.js","sources":["../../../src/features/DepsSync/createDependencyTree.ts"],"sourcesContent":["import type { IDependencyTree } from \"./types.js\";\nimport { ListAllPackages } from \"./ListAllPackages.js\";\nimport { ListAllPackageJsonFiles } from \"./ListAllPackageJsonFiles.js\";\nimport { BuildDependencyTree } from \"./BuildDependencyTree.js\";\nimport { IProjectModel } from \"@webiny/project\";\n\nexport const createDependencyTree = (project: IProjectModel): IDependencyTree => {\n const projectRoot = project.paths.rootFolder;\n const basePath = projectRoot.toString();\n const packagesFolderPath = projectRoot.join(\"packages\").toString();\n const cypressFolderPath = projectRoot.join(\"cypress\").toString();\n const packageJsonFilePath = projectRoot.join(\"package.json\").toString();\n\n const listAllPackages = new ListAllPackages();\n const listAllPackageJsonFiles = new ListAllPackageJsonFiles();\n const buildDependencyTree = new BuildDependencyTree();\n\n const allPackages = listAllPackages.list([packagesFolderPath, cypressFolderPath]);\n\n const allPackageJsonFiles = listAllPackageJsonFiles.list({\n targets: allPackages\n });\n\n return buildDependencyTree.build({\n basePath,\n files: [packageJsonFilePath, ...allPackageJsonFiles],\n ignore: /^@webiny\\//\n });\n};\n"],"names":["createDependencyTree","project","projectRoot","basePath","packagesFolderPath","cypressFolderPath","packageJsonFilePath","listAllPackages","ListAllPackages","listAllPackageJsonFiles","ListAllPackageJsonFiles","buildDependencyTree","BuildDependencyTree","allPackages","allPackageJsonFiles"],"mappings":";;;AAMO,MAAMA,uBAAuB,CAACC;IACjC,MAAMC,cAAcD,QAAQ,KAAK,CAAC,UAAU;IAC5C,MAAME,WAAWD,YAAY,QAAQ;IACrC,MAAME,qBAAqBF,YAAY,IAAI,CAAC,YAAY,QAAQ;IAChE,MAAMG,oBAAoBH,YAAY,IAAI,CAAC,WAAW,QAAQ;IAC9D,MAAMI,sBAAsBJ,YAAY,IAAI,CAAC,gBAAgB,QAAQ;IAErE,MAAMK,kBAAkB,IAAIC;IAC5B,MAAMC,0BAA0B,IAAIC;IACpC,MAAMC,sBAAsB,IAAIC;IAEhC,MAAMC,cAAcN,gBAAgB,IAAI,CAAC;QAACH;QAAoBC;KAAkB;IAEhF,MAAMS,sBAAsBL,wBAAwB,IAAI,CAAC;QACrD,SAASI;IACb;IAEA,OAAOF,oBAAoB,KAAK,CAAC;QAC7BR;QACA,OAAO;YAACG;eAAwBQ;SAAoB;QACpD,QAAQ;IACZ;AACJ"}
1
+ {"version":3,"file":"features/DepsSync/createDependencyTree.js","sources":["../../../src/features/DepsSync/createDependencyTree.ts"],"sourcesContent":["import fs from \"fs\";\nimport type { IDependencyTree } from \"./types.js\";\nimport { ListAllPackages } from \"./ListAllPackages.js\";\nimport { ListAllPackageJsonFiles } from \"./ListAllPackageJsonFiles.js\";\nimport { BuildDependencyTree } from \"./BuildDependencyTree.js\";\nimport { IProjectModel } from \"@webiny/project\";\n\nexport const createDependencyTree = async (project: IProjectModel): Promise<IDependencyTree> => {\n const projectRoot = project.paths.rootFolder;\n const basePath = projectRoot.toString();\n const packagesFolderPath = projectRoot.join(\"packages\").toString();\n const packageJsonFilePath = projectRoot.join(\"package.json\").toString();\n // The e2e tests share deps with the packages (zod, ai), so their versions are checked too.\n const e2ePackageJsonFilePath = projectRoot.join(\"e2e/package.json\").toString();\n\n const listAllPackages = new ListAllPackages();\n const listAllPackageJsonFiles = new ListAllPackageJsonFiles();\n const buildDependencyTree = new BuildDependencyTree();\n\n const allPackages = await listAllPackages.list([packagesFolderPath]);\n\n const allPackageJsonFiles = listAllPackageJsonFiles.list({\n targets: allPackages\n });\n\n return buildDependencyTree.build({\n basePath,\n files: [\n packageJsonFilePath,\n ...(fs.existsSync(e2ePackageJsonFilePath) ? [e2ePackageJsonFilePath] : []),\n ...allPackageJsonFiles\n ],\n ignore: /^@webiny\\//\n });\n};\n"],"names":["createDependencyTree","project","projectRoot","basePath","packagesFolderPath","packageJsonFilePath","e2ePackageJsonFilePath","listAllPackages","ListAllPackages","listAllPackageJsonFiles","ListAllPackageJsonFiles","buildDependencyTree","BuildDependencyTree","allPackages","allPackageJsonFiles","fs"],"mappings":";;;;AAOO,MAAMA,uBAAuB,OAAOC;IACvC,MAAMC,cAAcD,QAAQ,KAAK,CAAC,UAAU;IAC5C,MAAME,WAAWD,YAAY,QAAQ;IACrC,MAAME,qBAAqBF,YAAY,IAAI,CAAC,YAAY,QAAQ;IAChE,MAAMG,sBAAsBH,YAAY,IAAI,CAAC,gBAAgB,QAAQ;IAErE,MAAMI,yBAAyBJ,YAAY,IAAI,CAAC,oBAAoB,QAAQ;IAE5E,MAAMK,kBAAkB,IAAIC;IAC5B,MAAMC,0BAA0B,IAAIC;IACpC,MAAMC,sBAAsB,IAAIC;IAEhC,MAAMC,cAAc,MAAMN,gBAAgB,IAAI,CAAC;QAACH;KAAmB;IAEnE,MAAMU,sBAAsBL,wBAAwB,IAAI,CAAC;QACrD,SAASI;IACb;IAEA,OAAOF,oBAAoB,KAAK,CAAC;QAC7BR;QACA,OAAO;YACHE;eACIU,GAAG,UAAU,CAACT,0BAA0B;gBAACA;aAAuB,GAAG,EAAE;eACtEQ;SACN;QACD,QAAQ;IACZ;AACJ"}
@@ -12,7 +12,11 @@ class InfoCommand {
12
12
  return {
13
13
  name: "info",
14
14
  description: "Lists relevant URLs for your Webiny project",
15
- options: createBaseAppOptions(projectSdk),
15
+ options: createBaseAppOptions(projectSdk, {
16
+ env: {
17
+ default: void 0
18
+ }
19
+ }),
16
20
  handler: async (params)=>{
17
21
  const ui = this.uiService;
18
22
  const printInfoForEnv = new PrintInfoForEnv({
@@ -1 +1 @@
1
- {"version":3,"file":"features/InfoCommand/InfoCommand.js","sources":["../../../src/features/InfoCommand/InfoCommand.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport { CliCommandFactory, GetProjectSdkService, UiService } from \"~/abstractions/index.js\";\nimport { IBaseAppParams } from \"~/abstractions/features/types.js\";\nimport { PrintInfoForEnv } from \"./PrintInfoForEnv.js\";\nimport { createBaseAppOptions } from \"~/features/common/index.js\";\n\nexport type IInfoCommandParams = Omit<IBaseAppParams, \"app\">;\n\nexport class InfoCommand implements CliCommandFactory.Interface<IInfoCommandParams> {\n constructor(\n private getProjectSdkService: GetProjectSdkService.Interface,\n private uiService: UiService.Interface\n ) {}\n\n async execute(): Promise<CliCommandFactory.CommandDefinition<IInfoCommandParams>> {\n const projectSdk = await this.getProjectSdkService.execute();\n\n return {\n name: \"info\",\n description: \"Lists relevant URLs for your Webiny project\",\n options: createBaseAppOptions(projectSdk),\n handler: async params => {\n const ui = this.uiService;\n\n const printInfoForEnv = new PrintInfoForEnv({\n getProjectSdkService: this.getProjectSdkService,\n uiService: this.uiService\n });\n\n if (params.env) {\n await printInfoForEnv.execute({ env: params.env, variant: params.variant });\n ui.emptyLine();\n } else {\n const existingEnvs = await projectSdk.listDeployedEnvironments();\n\n if (existingEnvs.length === 0) {\n ui.info(\n \"It seems that no environments have been deployed yet. Please deploy the project first.\"\n );\n return;\n }\n\n if (existingEnvs.length === 1) {\n ui.info(\"There is one deployed environment.\");\n ui.info(\"Here is the information for the environment.\");\n } else {\n ui.info(\n \"There's a total of %d deployed environments.\",\n existingEnvs.length\n );\n ui.info(\"Here is the information for each environment.\");\n console.log();\n }\n\n for (const { env, variant } of existingEnvs) {\n await printInfoForEnv.execute({ env, variant });\n ui.emptyLine();\n }\n }\n\n ui.info(\n \"If some of the information is missing for a particular environment, make sure that the project has been fully deployed into that environment. You can do that by running the %s command.\",\n \"yarn webiny deploy --env {ENVIRONMENT_NAME}\"\n );\n }\n };\n }\n}\n\nexport const infoCommand = createImplementation({\n abstraction: CliCommandFactory,\n implementation: InfoCommand,\n dependencies: [GetProjectSdkService, UiService]\n});\n"],"names":["InfoCommand","getProjectSdkService","uiService","projectSdk","createBaseAppOptions","params","ui","printInfoForEnv","PrintInfoForEnv","existingEnvs","console","env","variant","infoCommand","createImplementation","CliCommandFactory","GetProjectSdkService","UiService"],"mappings":";;;;AAQO,MAAMA;IACT,YACYC,oBAAoD,EACpDC,SAA8B,CACxC;aAFUD,oBAAoB,GAApBA;aACAC,SAAS,GAATA;IACT;IAEH,MAAM,UAA4E;QAC9E,MAAMC,aAAa,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO;QAE1D,OAAO;YACH,MAAM;YACN,aAAa;YACb,SAASC,qBAAqBD;YAC9B,SAAS,OAAME;gBACX,MAAMC,KAAK,IAAI,CAAC,SAAS;gBAEzB,MAAMC,kBAAkB,IAAIC,gBAAgB;oBACxC,sBAAsB,IAAI,CAAC,oBAAoB;oBAC/C,WAAW,IAAI,CAAC,SAAS;gBAC7B;gBAEA,IAAIH,OAAO,GAAG,EAAE;oBACZ,MAAME,gBAAgB,OAAO,CAAC;wBAAE,KAAKF,OAAO,GAAG;wBAAE,SAASA,OAAO,OAAO;oBAAC;oBACzEC,GAAG,SAAS;gBAChB,OAAO;oBACH,MAAMG,eAAe,MAAMN,WAAW,wBAAwB;oBAE9D,IAAIM,AAAwB,MAAxBA,aAAa,MAAM,EAAQ,YAC3BH,GAAG,IAAI,CACH;oBAKR,IAAIG,AAAwB,MAAxBA,aAAa,MAAM,EAAQ;wBAC3BH,GAAG,IAAI,CAAC;wBACRA,GAAG,IAAI,CAAC;oBACZ,OAAO;wBACHA,GAAG,IAAI,CACH,gDACAG,aAAa,MAAM;wBAEvBH,GAAG,IAAI,CAAC;wBACRI,QAAQ,GAAG;oBACf;oBAEA,KAAK,MAAM,EAAEC,GAAG,EAAEC,OAAO,EAAE,IAAIH,aAAc;wBACzC,MAAMF,gBAAgB,OAAO,CAAC;4BAAEI;4BAAKC;wBAAQ;wBAC7CN,GAAG,SAAS;oBAChB;gBACJ;gBAEAA,GAAG,IAAI,CACH,4LACA;YAER;QACJ;IACJ;AACJ;AAEO,MAAMO,cAAcC,qBAAqB;IAC5C,aAAaC;IACb,gBAAgBf;IAChB,cAAc;QAACgB;QAAsBC;KAAU;AACnD"}
1
+ {"version":3,"file":"features/InfoCommand/InfoCommand.js","sources":["../../../src/features/InfoCommand/InfoCommand.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport { CliCommandFactory, GetProjectSdkService, UiService } from \"~/abstractions/index.js\";\nimport { IBaseAppParams } from \"~/abstractions/features/types.js\";\nimport { PrintInfoForEnv } from \"./PrintInfoForEnv.js\";\nimport { createBaseAppOptions } from \"~/features/common/index.js\";\n\nexport type IInfoCommandParams = Omit<IBaseAppParams, \"app\">;\n\nexport class InfoCommand implements CliCommandFactory.Interface<IInfoCommandParams> {\n constructor(\n private getProjectSdkService: GetProjectSdkService.Interface,\n private uiService: UiService.Interface\n ) {}\n\n async execute(): Promise<CliCommandFactory.CommandDefinition<IInfoCommandParams>> {\n const projectSdk = await this.getProjectSdkService.execute();\n\n return {\n name: \"info\",\n description: \"Lists relevant URLs for your Webiny project\",\n // No default env here: without `--env`, we list info for all deployed environments.\n options: createBaseAppOptions(projectSdk, { env: { default: undefined } }),\n handler: async params => {\n const ui = this.uiService;\n\n const printInfoForEnv = new PrintInfoForEnv({\n getProjectSdkService: this.getProjectSdkService,\n uiService: this.uiService\n });\n\n if (params.env) {\n await printInfoForEnv.execute({ env: params.env, variant: params.variant });\n ui.emptyLine();\n } else {\n const existingEnvs = await projectSdk.listDeployedEnvironments();\n\n if (existingEnvs.length === 0) {\n ui.info(\n \"It seems that no environments have been deployed yet. Please deploy the project first.\"\n );\n return;\n }\n\n if (existingEnvs.length === 1) {\n ui.info(\"There is one deployed environment.\");\n ui.info(\"Here is the information for the environment.\");\n } else {\n ui.info(\n \"There's a total of %d deployed environments.\",\n existingEnvs.length\n );\n ui.info(\"Here is the information for each environment.\");\n console.log();\n }\n\n for (const { env, variant } of existingEnvs) {\n await printInfoForEnv.execute({ env, variant });\n ui.emptyLine();\n }\n }\n\n ui.info(\n \"If some of the information is missing for a particular environment, make sure that the project has been fully deployed into that environment. You can do that by running the %s command.\",\n \"yarn webiny deploy --env {ENVIRONMENT_NAME}\"\n );\n }\n };\n }\n}\n\nexport const infoCommand = createImplementation({\n abstraction: CliCommandFactory,\n implementation: InfoCommand,\n dependencies: [GetProjectSdkService, UiService]\n});\n"],"names":["InfoCommand","getProjectSdkService","uiService","projectSdk","createBaseAppOptions","undefined","params","ui","printInfoForEnv","PrintInfoForEnv","existingEnvs","console","env","variant","infoCommand","createImplementation","CliCommandFactory","GetProjectSdkService","UiService"],"mappings":";;;;AAQO,MAAMA;IACT,YACYC,oBAAoD,EACpDC,SAA8B,CACxC;aAFUD,oBAAoB,GAApBA;aACAC,SAAS,GAATA;IACT;IAEH,MAAM,UAA4E;QAC9E,MAAMC,aAAa,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO;QAE1D,OAAO;YACH,MAAM;YACN,aAAa;YAEb,SAASC,qBAAqBD,YAAY;gBAAE,KAAK;oBAAE,SAASE;gBAAU;YAAE;YACxE,SAAS,OAAMC;gBACX,MAAMC,KAAK,IAAI,CAAC,SAAS;gBAEzB,MAAMC,kBAAkB,IAAIC,gBAAgB;oBACxC,sBAAsB,IAAI,CAAC,oBAAoB;oBAC/C,WAAW,IAAI,CAAC,SAAS;gBAC7B;gBAEA,IAAIH,OAAO,GAAG,EAAE;oBACZ,MAAME,gBAAgB,OAAO,CAAC;wBAAE,KAAKF,OAAO,GAAG;wBAAE,SAASA,OAAO,OAAO;oBAAC;oBACzEC,GAAG,SAAS;gBAChB,OAAO;oBACH,MAAMG,eAAe,MAAMP,WAAW,wBAAwB;oBAE9D,IAAIO,AAAwB,MAAxBA,aAAa,MAAM,EAAQ,YAC3BH,GAAG,IAAI,CACH;oBAKR,IAAIG,AAAwB,MAAxBA,aAAa,MAAM,EAAQ;wBAC3BH,GAAG,IAAI,CAAC;wBACRA,GAAG,IAAI,CAAC;oBACZ,OAAO;wBACHA,GAAG,IAAI,CACH,gDACAG,aAAa,MAAM;wBAEvBH,GAAG,IAAI,CAAC;wBACRI,QAAQ,GAAG;oBACf;oBAEA,KAAK,MAAM,EAAEC,GAAG,EAAEC,OAAO,EAAE,IAAIH,aAAc;wBACzC,MAAMF,gBAAgB,OAAO,CAAC;4BAAEI;4BAAKC;wBAAQ;wBAC7CN,GAAG,SAAS;oBAChB;gBACJ;gBAEAA,GAAG,IAAI,CACH,4LACA;YAER;QACJ;IACJ;AACJ;AAEO,MAAMO,cAAcC,qBAAqB;IAC5C,aAAaC;IACb,gBAAgBhB;IAChB,cAAc;QAACiB;QAAsBC;KAAU;AACnD"}
@@ -1,5 +1,4 @@
1
1
  import { createImplementation } from "@webiny/di";
2
- import inquirer from "inquirer";
3
2
  import { CliCommandFactory, GetProjectSdkService, UiService } from "../../abstractions/index.js";
4
3
  import { setTimeout as promises_setTimeout } from "node:timers/promises";
5
4
  const sleep = (ms = 1500)=>promises_setTimeout(ms);
@@ -19,6 +18,7 @@ class LinkProjectCommand {
19
18
  "$0 link-project"
20
19
  ],
21
20
  handler: async ()=>{
21
+ const { default: inquirer } = await import("inquirer");
22
22
  const user = await wcp.getUser();
23
23
  if (!user) return void ui.error("You must be logged in to link a project.");
24
24
  const orgProjectId = await projectSdk.getProjectId();
@@ -1 +1 @@
1
- {"version":3,"file":"features/Wcp/LinkProjectCommand.js","sources":["../../../src/features/Wcp/LinkProjectCommand.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport inquirer from \"inquirer\";\nimport { CliCommandFactory, GetProjectSdkService, UiService } from \"~/abstractions/index.js\";\nimport { setTimeout } from \"node:timers/promises\";\n\nconst sleep = (ms: number = 1500) => setTimeout(ms);\n\nexport class LinkProjectCommand implements CliCommandFactory.Interface<void> {\n constructor(\n private getProjectSdkService: GetProjectSdkService.Interface,\n private uiService: UiService.Interface\n ) {}\n\n async execute() {\n const projectSdk = await this.getProjectSdkService.execute();\n const wcp = projectSdk.wcp;\n const ui = this.uiService;\n\n return {\n name: \"link-project\",\n description: \"Link a Webiny project with Webiny Control Panel\",\n examples: [\"$0 link-project\"],\n handler: async () => {\n const user = await wcp.getUser();\n\n if (!user) {\n ui.error(\"You must be logged in to link a project.\");\n return;\n }\n\n // User already linked a project?\n const orgProjectId = await projectSdk.getProjectId();\n if (orgProjectId) {\n const [, projectId] = orgProjectId.split(\"/\");\n const project = user.projects.find(item => item.id === projectId);\n if (project) {\n ui.info(\"Your %s project is already linked.\", orgProjectId);\n\n const prompt = inquirer.createPromptModule();\n const { proceed } = await prompt({\n name: \"proceed\",\n message: \"Would you like to re-link it?\",\n type: \"confirm\",\n default: false\n });\n\n if (!proceed) {\n return;\n }\n\n ui.emptyLine();\n }\n }\n\n const wcpAppUrl = projectSdk.wcp.getWcpAppUrl().toString();\n\n // Get user's organizations.\n if (!user.orgs.length) {\n ui.info(\n \"It seems you're not part of any organization. Please log in to Webiny Control Panel and create one.\"\n );\n\n const prompt = inquirer.createPromptModule();\n const { proceed } = await prompt({\n name: \"proceed\",\n message: \"Would you like to do that now?\",\n type: \"confirm\",\n default: false\n });\n\n if (proceed) {\n open(wcpAppUrl);\n }\n return;\n }\n\n let selectedOrg;\n if (user.orgs.length === 1) {\n selectedOrg = user.orgs[0];\n } else {\n ui.info(\"It seems you're part of multiple organizations. \");\n const choices = user.orgs.map(item => ({\n name: item.name,\n value: item\n }));\n\n const prompt = inquirer.createPromptModule();\n selectedOrg = await prompt({\n name: \"org\",\n message: \"Select organization:\",\n type: \"select\",\n choices,\n default: choices[0].value\n }).then(result => result.org);\n }\n\n const orgProjects = user.projects.filter(item => item.org.id === selectedOrg.id);\n\n // Get user's projects.\n if (!orgProjects.length) {\n ui.info(\n \"It seems there are no projects created within the %s organization.\",\n selectedOrg.name\n );\n\n const prompt = inquirer.createPromptModule();\n const { proceed } = await prompt({\n name: \"proceed\",\n message: \"Would you like to create one now?\",\n type: \"confirm\",\n default: false\n });\n\n if (proceed) {\n open(wcpAppUrl);\n }\n return;\n }\n\n let selectedProject;\n if (orgProjects.length === 1) {\n selectedProject = user.projects[0];\n } else {\n ui.info(\n `It seems there are multiple projects created within the organization.`,\n selectedOrg.name\n );\n const choices = orgProjects.map(item => ({\n name: item.name,\n value: item\n }));\n const prompt = inquirer.createPromptModule();\n selectedProject = await prompt({\n name: \"project\",\n message: \"Select project:\",\n type: \"select\",\n choices,\n default: choices[0].value\n }).then(result => result.project);\n }\n\n await sleep();\n ui.emptyLine();\n\n ui.info(\"Linking %s project...\", selectedProject.name);\n\n await sleep();\n\n // Assign the necessary IDs into root `webiny.project.ts` project file.\n await projectSdk.setProjectId(`${selectedOrg.id}/${selectedProject.id}`, {\n force: true\n });\n\n ui.success(`%s Project %s linked successfully.`, \"✔\", selectedProject.name);\n\n await sleep();\n\n ui.emptyLine();\n ui.textBold(\"Next Steps\");\n\n ui.text(`‣ deploy your project via the yarn webiny deploy command`);\n }\n };\n }\n}\n\nexport const linkProjectCommand = createImplementation({\n abstraction: CliCommandFactory,\n implementation: LinkProjectCommand,\n dependencies: [GetProjectSdkService, UiService]\n});\n"],"names":["sleep","ms","setTimeout","LinkProjectCommand","getProjectSdkService","uiService","projectSdk","wcp","ui","user","orgProjectId","projectId","project","item","prompt","inquirer","proceed","wcpAppUrl","open","selectedOrg","choices","result","orgProjects","selectedProject","linkProjectCommand","createImplementation","CliCommandFactory","GetProjectSdkService","UiService"],"mappings":";;;;AAKA,MAAMA,QAAQ,CAACC,KAAa,IAAI,GAAKC,oBAAWD;AAEzC,MAAME;IACT,YACYC,oBAAoD,EACpDC,SAA8B,CACxC;aAFUD,oBAAoB,GAApBA;aACAC,SAAS,GAATA;IACT;IAEH,MAAM,UAAU;QACZ,MAAMC,aAAa,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO;QAC1D,M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AC,EAAEI,gBAAgB,EAAE,EAAE,EAAE;oBACrE,OAAO;gBACX;gBAEAf,GAAG,OAAO,CAAC,sCAAsC,KAAKe,gBAAgB,IAAI;gBAE1E,MAAMvB;gBAENQ,GAAG,SAAS;gBACZA,GAAG,QAAQ,CAAC;gBAEZA,GAAG,IAAI,CAAC;YACZ;QACJ;IACJ;AACJ;AAEO,MAAMgB,qBAAqBC,qBAAqB;IACnD,aAAaC;IACb,gBAAgBvB;IAChB,cAAc;QAACwB;QAAsBC;KAAU;AACnD"}
1
+ {"version":3,"file":"features/Wcp/LinkProjectCommand.js","sources":["../../../src/features/Wcp/LinkProjectCommand.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport { CliCommandFactory, GetProjectSdkService, UiService } from \"~/abstractions/index.js\";\nimport { setTimeout } from \"node:timers/promises\";\n\nconst sleep = (ms: number = 1500) => setTimeout(ms);\n\nexport class LinkProjectCommand implements CliCommandFactory.Interface<void> {\n constructor(\n private getProjectSdkService: GetProjectSdkService.Interface,\n private uiService: UiService.Interface\n ) {}\n\n async execute() {\n const projectSdk = await this.getProjectSdkService.execute();\n const wcp = projectSdk.wcp;\n const ui = this.uiService;\n\n return {\n name: \"link-project\",\n description: \"Link a Webiny project with Webiny Control Panel\",\n examples: [\"$0 link-project\"],\n handler: async () => {\n // Imported here rather than at the top of the file. The CLI imports every command's\n // code on every run, even `webiny --help`, and inquirer with its dependencies is about\n // 60 modules that only this command's prompts ever need.\n const { default: inquirer } = await import(\"inquirer\");\n\n const user = await wcp.getUser();\n\n if (!user) {\n ui.error(\"You must be logged in to link a project.\");\n return;\n }\n\n // User already linked a project?\n const orgProjectId = await projectSdk.getProjectId();\n if (orgProjectId) {\n const [, projectId] = orgProjectId.split(\"/\");\n const project = user.projects.find(item => item.id === projectId);\n if (project) {\n ui.info(\"Your %s project is already linked.\", orgProjectId);\n\n const prompt = inquirer.createPromptModule();\n const { proceed } = await prompt({\n name: \"proceed\",\n message: \"Would you like to re-link it?\",\n type: \"confirm\",\n default: false\n });\n\n if (!proceed) {\n return;\n }\n\n ui.emptyLine();\n }\n }\n\n const wcpAppUrl = projectSdk.wcp.getWcpAppUrl().toString();\n\n // Get user's organizations.\n if (!user.orgs.length) {\n ui.info(\n \"It seems you're not part of any organization. Please log in to Webiny Control Panel and create one.\"\n );\n\n const prompt = inquirer.createPromptModule();\n const { proceed } = await prompt({\n name: \"proceed\",\n message: \"Would you like to do that now?\",\n type: \"confirm\",\n default: false\n });\n\n if (proceed) {\n open(wcpAppUrl);\n }\n return;\n }\n\n let selectedOrg;\n if (user.orgs.length === 1) {\n selectedOrg = user.orgs[0];\n } else {\n ui.info(\"It seems you're part of multiple organizations. \");\n const choices = user.orgs.map(item => ({\n name: item.name,\n value: item\n }));\n\n const prompt = inquirer.createPromptModule();\n selectedOrg = await prompt({\n name: \"org\",\n message: \"Select organization:\",\n type: \"select\",\n choices,\n default: choices[0].value\n }).then(result => result.org);\n }\n\n const orgProjects = user.projects.filter(item => item.org.id === selectedOrg.id);\n\n // Get user's projects.\n if (!orgProjects.length) {\n ui.info(\n \"It seems there are no projects created within the %s organization.\",\n selectedOrg.name\n );\n\n const prompt = inquirer.createPromptModule();\n const { proceed } = await prompt({\n name: \"proceed\",\n message: \"Would you like to create one now?\",\n type: \"confirm\",\n default: false\n });\n\n if (proceed) {\n open(wcpAppUrl);\n }\n return;\n }\n\n let selectedProject;\n if (orgProjects.length === 1) {\n selectedProject = user.projects[0];\n } else {\n ui.info(\n `It seems there are multiple projects created within the organization.`,\n selectedOrg.name\n );\n const choices = orgProjects.map(item => ({\n name: item.name,\n value: item\n }));\n const prompt = inquirer.createPromptModule();\n selectedProject = await prompt({\n name: \"project\",\n message: \"Select project:\",\n type: \"select\",\n choices,\n default: choices[0].value\n }).then(result => result.project);\n }\n\n await sleep();\n ui.emptyLine();\n\n ui.info(\"Linking %s project...\", selectedProject.name);\n\n await sleep();\n\n // Assign the necessary IDs into root `webiny.project.ts` project file.\n await projectSdk.setProjectId(`${selectedOrg.id}/${selectedProject.id}`, {\n force: true\n });\n\n ui.success(`%s Project %s linked successfully.`, \"✔\", selectedProject.name);\n\n await sleep();\n\n ui.emptyLine();\n ui.textBold(\"Next Steps\");\n\n ui.text(`‣ deploy your project via the yarn webiny deploy command`);\n }\n };\n }\n}\n\nexport const linkProjectCommand = createImplementation({\n abstraction: CliCommandFactory,\n implementation: LinkProjectCommand,\n dependencies: [GetProjectSdkService, UiService]\n});\n"],"names":["sleep","ms","setTimeout","LinkProjectCommand","getProjectSdkService","uiService","projectSdk","wcp","ui","inquirer","user","orgProjectId","projectId","project","item","prompt","proceed","wcpAppUrl","open","selectedOrg","choices","result","orgProjects","selectedProject","linkProjectCommand","createImplementation","CliCommandFactory","GetProjectSdkService","UiService"],"mappings":";;;AAIA,MAAMA,QAAQ,CAACC,KAAa,IAAI,GAAKC,oBAAWD;AAEzC,MAAME;IACT,YACYC,oBAAoD,EACpDC,SAA8B,CACxC;aAFUD,oBAAoB,GAApBA;aACAC,SAAS,GAATA;IACT;IAEH,MAAM,UAAU;QACZ,MAAMC,aAAa,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO;QAC1D,MAAMC,MAAMD,WAAW,GAAG;QAC1B,MAAME,KAAK,IAAI,CAAC,SAAS;QAEzB,OAAO;YACH,MAAM;YACN,aAAa;YACb,UAAU;gBAAC;aAAkB;YAC7B,SAAS;gBAIL,MAAM,EAAE,SAASC,QAAQ,EAAE,GAAG,MAAM,MAAM,CAAC;gBAE3C,MAAMC,OAAO,MAAMH,IAAI,OAAO;gBAE9B,IAAI,CAACG,MAAM,YACPF,GAAG,KAAK,CAAC;gBAKb,MAAMG,eAAe,MAAML,WAAW,YAAY;gBAClD,IAAIK,cAAc;oBACd,MAAM,GAAGC,UAAU,GAAGD,aAAa,KAAK,CAAC;oBACzC,MAAME,UAAUH,KAAK,QAAQ,CAAC,IAAI,CAACI,CAAAA,OAAQA,KAAK,EAAE,KAAKF;oBACvD,IAAIC,SAAS;wB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ASN,SAAS,kBAAkB;oBAC1C,MAAM,EAAEO,OAAO,EAAE,GAAG,MAAMD,OAAO;wBAC7B,MAAM;wBACN,SAAS;wBACT,MAAM;wBACN,SAAS;oBACb;oBAEA,IAAIC,SACAE,KAAKD;oBAET;gBACJ;gBAEA,IAAIM;gBACJ,IAAID,AAAuB,MAAvBA,YAAY,MAAM,EAClBC,kBAAkBb,KAAK,QAAQ,CAAC,EAAE;qBAC/B;oBACHF,GAAG,IAAI,CACH,yEACAW,YAAY,IAAI;oBAEpB,MAAMC,UAAUE,YAAY,GAAG,CAACR,CAAAA,OAAS;4BACrC,MAAMA,KAAK,IAAI;4BACf,OAAOA;wBACX;oBACA,MAAMC,SAASN,SAAS,kBAAkB;oBAC1Cc,kBAAkB,MAAMR,OAAO;wBAC3B,MAAM;wBACN,SAAS;wBACT,MAAM;wBACNK;wBACA,SAASA,OAAO,CAAC,EAAE,CAAC,KAAK;oBAC7B,GAAG,IAAI,CAACC,CAAAA,SAAUA,OAAO,OAAO;gBACpC;gBAEA,MAAMrB;gBACNQ,GAAG,SAAS;gBAEZA,GAAG,IAAI,CAAC,yBAAyBe,gBAAgB,IAAI;gBAErD,MAAMvB;gBAGN,MAAMM,WAAW,YAAY,CAAC,GAAGa,YAAY,EAAE,CAAC,CAAC,EAAEI,gBAAgB,EAAE,EAAE,EAAE;oBACrE,OAAO;gBACX;gBAEAf,GAAG,OAAO,CAAC,sCAAsC,KAAKe,gBAAgB,IAAI;gBAE1E,MAAMvB;gBAENQ,GAAG,SAAS;gBACZA,GAAG,QAAQ,CAAC;gBAEZA,GAAG,IAAI,CAAC;YACZ;QACJ;IACJ;AACJ;AAEO,MAAMgB,qBAAqBC,qBAAqB;IACnD,aAAaC;IACb,gBAAgBvB;IAChB,cAAc;QAACwB;QAAsBC;KAAU;AACnD"}
@@ -0,0 +1,5 @@
1
+ import { GlobalCliOption } from "../../abstractions/index.js";
2
+ export declare class TraceGlobalOption implements GlobalCliOption.Interface {
3
+ execute(): GlobalCliOption.Definition;
4
+ }
5
+ export declare const traceGlobalOption: import("@webiny/di").Implementation<typeof TraceGlobalOption>;
@@ -0,0 +1,22 @@
1
+ import { createImplementation } from "@webiny/di";
2
+ import { GlobalCliOption } from "../../abstractions/index.js";
3
+ class TraceGlobalOption {
4
+ execute() {
5
+ return {
6
+ name: "trace",
7
+ config: {
8
+ type: "boolean",
9
+ default: false,
10
+ description: "Print a timing breakdown of the run"
11
+ }
12
+ };
13
+ }
14
+ }
15
+ const traceGlobalOption = createImplementation({
16
+ abstraction: GlobalCliOption,
17
+ implementation: TraceGlobalOption,
18
+ dependencies: []
19
+ });
20
+ export { TraceGlobalOption, traceGlobalOption };
21
+
22
+ //# sourceMappingURL=TraceGlobalOption.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/globalOptions/TraceGlobalOption.js","sources":["../../../src/features/globalOptions/TraceGlobalOption.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport { GlobalCliOption } from \"~/abstractions/index.js\";\n\n/*\n * Declared here only so the flag shows up in `webiny --help`. The CLI entrypoint reads it straight\n * off `process.argv`, because tracing has to be on before yargs is built.\n */\nexport class TraceGlobalOption implements GlobalCliOption.Interface {\n execute(): GlobalCliOption.Definition {\n return {\n name: \"trace\",\n config: {\n type: \"boolean\",\n default: false,\n description: \"Print a timing breakdown of the run\"\n }\n };\n }\n}\n\nexport const traceGlobalOption = createImplementation({\n abstraction: GlobalCliOption,\n implementation: TraceGlobalOption,\n dependencies: []\n});\n"],"names":["TraceGlobalOption","traceGlobalOption","createImplementation","GlobalCliOption"],"mappings":";;AAOO,MAAMA;IACT,UAAsC;QAClC,OAAO;YACH,MAAM;YACN,QAAQ;gBACJ,MAAM;gBACN,SAAS;gBACT,aAAa;YACjB;QACJ;IACJ;AACJ;AAEO,MAAMC,oBAAoBC,qBAAqB;IAClD,aAAaC;IACb,gBAAgBH;IAChB,cAAc,EAAE;AACpB"}
@@ -1,3 +1,4 @@
1
1
  export * from "./ShowLogsGlobalOption.js";
2
2
  export * from "./LogLevelGlobalOption.js";
3
3
  export * from "./StackTraceGlobalOption.js";
4
+ export * from "./TraceGlobalOption.js";
@@ -1,3 +1,4 @@
1
1
  export * from "./ShowLogsGlobalOption.js";
2
2
  export * from "./LogLevelGlobalOption.js";
3
3
  export * from "./StackTraceGlobalOption.js";
4
+ export * from "./TraceGlobalOption.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/cli-core",
3
- "version": "0.0.0-unstable.0d717d18dd",
3
+ "version": "0.0.0-unstable.33e4fd9647",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -13,34 +13,37 @@
13
13
  "description": "A command line interface (CLI) for managing Webiny projects.",
14
14
  "license": "MIT",
15
15
  "dependencies": {
16
- "@webiny/di": "1.0.2",
17
- "@webiny/feature": "0.0.0-unstable.0d717d18dd",
18
- "@webiny/project": "0.0.0-unstable.0d717d18dd",
19
- "@webiny/stdlib": "0.0.15",
20
- "@webiny/telemetry": "0.0.0-unstable.0d717d18dd",
16
+ "@webiny/di": "2.0.0",
17
+ "@webiny/feature": "0.0.0-unstable.33e4fd9647",
18
+ "@webiny/project": "0.0.0-unstable.33e4fd9647",
19
+ "@webiny/stdlib": "0.0.21",
20
+ "@webiny/telemetry": "0.0.0-unstable.33e4fd9647",
21
21
  "chalk": "6.0.0",
22
22
  "ci-info": "4.4.0",
23
23
  "execa": "10.0.1",
24
24
  "fast-glob": "3.3.3",
25
25
  "find-up": "8.0.0",
26
- "humanize-duration": "3.34.0",
27
- "inquirer": "14.0.2",
26
+ "humanize-duration": "3.34.1",
27
+ "inquirer": "14.1.0",
28
28
  "load-json-file": "7.0.1",
29
- "open": "11.0.0",
29
+ "open": "11.0.1",
30
30
  "ora": "9.4.1",
31
31
  "pino": "10.3.1",
32
32
  "pino-pretty": "13.1.3",
33
33
  "semver": "7.8.5",
34
34
  "type-fest": "5.8.0",
35
+ "wrap-ansi": "9.0.2",
35
36
  "write-json-file": "7.0.0",
36
37
  "yargs": "18.1.0",
37
38
  "zod": "4.4.3"
38
39
  },
39
40
  "devDependencies": {
40
41
  "@types/lodash": "4.17.25",
41
- "@webiny/build-tools": "0.0.0-unstable.0d717d18dd",
42
+ "@webiny/build-tools": "0.0.0-unstable.33e4fd9647",
42
43
  "rimraf": "6.1.3",
43
- "typescript": "7.0.2"
44
+ "strip-ansi": "7.2.0",
45
+ "typescript": "7.0.2",
46
+ "vitest": "4.1.11"
44
47
  },
45
48
  "publishConfig": {
46
49
  "access": "public"
@@ -3,6 +3,7 @@ import { CommandsRegistryService, GetArgvService, GetCliRunnerService, GetProjec
3
3
  import yargs_yargs from "yargs/yargs";
4
4
  import chalk from "chalk";
5
5
  import { GracefulError } from "@webiny/project";
6
+ import { traceRecorder } from "@webiny/project/utils/trace/index.js";
6
7
  import { ManuallyReportedError } from "../../utils/ManuallyReportedError.js";
7
8
  const { blue: blue, bgYellow: bgYellow, bold: bold } = chalk;
8
9
  class DefaultGetCliRunnerService {
@@ -75,7 +76,10 @@ class DefaultGetCliRunnerService {
75
76
  });
76
77
  const commands = this.commandsRegistryService.execute();
77
78
  for (const command of commands){
78
- const { name, description, params = [], options = [], handler } = await command.execute();
79
+ const startedAt = performance.now();
80
+ const definition = await command.execute();
81
+ const { name, description, params = [], options = [], handler } = definition;
82
+ traceRecorder.record(`build "${name}" command`, startedAt, performance.now());
79
83
  let yargsCommand = name;
80
84
  const paramVersionExists = params.some((p)=>"version" === p.name);
81
85
  if (paramVersionExists) {
@@ -1 +1 @@
1
- {"version":3,"file":"services/GetCliRunnerService/GetCliRunnerService.js","sources":["../../../src/services/GetCliRunnerService/GetCliRunnerService.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport {\n CliCommandFactory,\n CommandsRegistryService,\n GetArgvService,\n GetCliRunnerService,\n GlobalOptionsRegistryService,\n GetProjectSdkService,\n UiService\n} from \"~/abstractions/index.js\";\nimport yargs from \"yargs/yargs\";\nimport chalk from \"chalk\";\nimport { Argv } from \"yargs\";\nimport { GracefulError } from \"@webiny/project\";\nimport { ManuallyReportedError } from \"~/utils/ManuallyReportedError.js\";\n\nconst { blue, bgYellow, bold } = chalk;\n\nexport class DefaultGetCliRunnerService implements GetCliRunnerService.Interface {\n constructor(\n private readonly commandsRegistryService: CommandsRegistryService.Interface,\n private readonly globalOptionsRegistryService: GlobalOptionsRegistryService.Interface,\n private readonly uiService: UiService.Interface,\n private readonly getProjectSdkService: GetProjectSdkService.Interface,\n private readonly getArgvService: GetArgvService.Interface\n ) {}\n\n private yargsRunner: Argv | null = null;\n\n async execute() {\n if (this.yargsRunner) {\n return this.yargsRunner;\n }\n\n const ui = this.uiService;\n const projectSdk = await this.getProjectSdkService.execute();\n\n const yargsRunner = yargs()\n .usage(\"Usage: $0 <command> [options]\")\n .help(false)\n .demandCommand(1)\n .recommendCommands()\n .scriptName(\"webiny\")\n .epilogue(\n `To find more information, docs and tutorials, see ${blue(\n \"https://www.webiny.com/docs\"\n )}.`\n )\n .epilogue(`Want to contribute? ${blue(\"https://github.com/webiny/webiny-js\")}.`);\n\n // Register global options.\n const globalOptions = this.globalOptionsRegistryService.execute();\n for (const globalOption of globalOptions) {\n const { name, config } = await globalOption.execute();\n yargsRunner.option(name, {\n type: config.type,\n default: config.default,\n desc: config.description,\n alias: config.alias,\n choices: config.choices,\n global: true\n });\n }\n\n yargsRunner.fail((invalidParamsMessage, error) => {\n if (invalidParamsMessage) {\n if (invalidParamsMessage.includes(\"Not enough non-option arguments\")) {\n ui.emptyLine();\n ui.error(\"Command was not invoked as expected.\");\n ui.info(\n `Some non-optional arguments are missing. See the usage examples printed below.`\n );\n ui.emptyLine();\n yargsRunner.showHelp();\n process.exit(1);\n }\n\n if (invalidParamsMessage.includes(\"Missing required argument\")) {\n const args = invalidParamsMessage\n .split(\":\")[1]\n .split(\",\")\n .map(v => v.trim());\n\n ui.emptyLine();\n ui.error(\"Command was not invoked as expected.\");\n ui.info(\n `Missing required argument(s): ${args.join(\n \", \"\n )}. See the usage examples printed below.`\n );\n ui.emptyLine();\n yargsRunner.showHelp();\n process.exit(1);\n }\n\n ui.emptyLine();\n ui.error(invalidParamsMessage);\n\n process.exit(1);\n }\n\n const logger = projectSdk.getLogger();\n logger.error({ err: error }, \"CLI command execution failed.\");\n\n const realError = (error.cause as Error) || error;\n\n if (realError instanceof ManuallyReportedError) {\n // Do nothing as the error reporting has already been\n // handled within the invoked CLI command.\n } else {\n ui.error(realError.message);\n }\n\n const argv = this.getArgvService.execute();\n if (argv.showStackTrace && realError.stack) {\n ui.emptyLine();\n ui.debug(\"Stack trace:\");\n ui.text(realError.stack);\n }\n\n if (error instanceof GracefulError) {\n ui.emptyLine();\n ui.text(bgYellow(bold(\"💡 How can I resolve this?\")));\n ui.text(error.message);\n }\n\n process.exit(1);\n });\n\n const commands = this.commandsRegistryService.execute();\n\n for (const command of commands) {\n const {\n name,\n description,\n params = [],\n options = [],\n handler\n } = await command.execute();\n\n let yargsCommand = name;\n const paramVersionExists = params.some(p => {\n return p.name === \"version\";\n });\n if (paramVersionExists) {\n ui.error(\n `The command \"${name}\" cannot have a parameter named \"version\" as it conflicts with the global --version option.`\n );\n process.exit();\n }\n\n if (params.length > 0) {\n yargsCommand +=\n \" \" +\n params\n .map(param => {\n const paramName = param.array ? `${param.name}..` : param.name;\n return param.required ? `<${paramName}>` : `[${paramName}]`;\n })\n .join(\" \");\n }\n\n yargsRunner.command(\n yargsCommand,\n description,\n yargs => {\n params.forEach((param: CliCommandFactory.ParamDefinition<unknown>) => {\n const { name, required, validation, array, ...rest } = param;\n\n const yargsParam = yargs.positional(name, {\n ...rest,\n ...(array && { array: true }),\n demandOption: required\n });\n\n if (validation) {\n yargsParam.check(validation);\n }\n });\n\n options.forEach((option: CliCommandFactory.OptionDefinition<unknown>) => {\n const { name, required, validation, ...rest } = option;\n\n const yargsOption = yargs.option(name, {\n ...rest,\n demandOption: required\n });\n\n if (option.group) {\n yargsOption.group(option.name, option.group);\n }\n\n if (validation) {\n yargsOption.check(validation);\n }\n });\n },\n handler\n );\n }\n\n yargsRunner.help(true);\n yargsRunner.version(projectSdk.getProjectVersion());\n this.yargsRunner = yargsRunner;\n return this.yargsRunner;\n }\n}\n\nexport const getCliRunnerService = createImplementation({\n abstraction: GetCliRunnerService,\n implementation: DefaultGetCliRunnerService,\n dependencies: [\n CommandsRegistryService,\n GlobalOptionsRegistryService,\n UiService,\n GetProjectSdkService,\n GetArgvService\n ]\n});\n"],"names":["blue","bgYellow","bold","chalk","DefaultGetCliRunnerService","commandsRegistryService","globalOptionsRegistryService","uiService","getProjectSdkService","getArgvService","ui","projectSdk","yargsRunner","yargs","globalOptions","globalOption","name","config","invalidParamsMessage","error","process","args","v","logger","realError","ManuallyReportedError","argv","GracefulError","commands","command","description","params","options","handler","yargsCommand","paramVersionExists","p","param","paramName","required","validation","array","rest","yargsParam","option","yargsOption","getCliRunnerService","createImplementation","GetCliRunnerService","CommandsRegistryService","GlobalOptionsRegistryService","UiService","GetProjectSdkService","GetArgvService"],"mappings":";;;;;;AAgBA,MAAM,EAAEA,MAAAA,IAAI,EAAEC,UAAAA,QAAQ,EAAEC,MAAAA,IAAI,EAAE,GAAGC;AAE1B,MAAMC;IACT,YACqBC,uBAA0D,EAC1DC,4BAAoE,EACpEC,SAA8B,EAC9BC,oBAAoD,EACpDC,cAAwC,CAC3D;aALmBJ,uBAAuB,GAAvBA;aACAC,4BAA4B,GAA5BA;aACAC,SAAS,GAATA;aACAC,oBAAoB,GAApBA;aACAC,cAAc,GAAdA;aAGb,WAAW,GAAgB;IAFhC;IAIH,MAAM,UAAU;QACZ,IAAI,IAAI,CAAC,WAAW,EAChB,OAAO,IAAI,CAAC,WAAW;QAG3B,MAAMC,KAAK,IAAI,CAAC,SAAS;QACzB,MAAMC,aAAa,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO;QAE1D,MAAMC,cAAcC,cACf,KAAK,CAAC,iCACN,IAAI,CAAC,OACL,aAAa,CA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CAAC;YAC/D,GACC,IAAI,CAAC;YAGlB1B,YAAY,OAAO,CACfsB,cACAJ,aACAjB,CAAAA;gBACIkB,OAAO,OAAO,CAAC,CAACM;oBACZ,MAAM,EAAErB,IAAI,EAAEuB,QAAQ,EAAEC,UAAU,EAAEC,KAAK,EAAE,GAAGC,MAAM,GAAGL;oBAEvD,MAAMM,aAAa9B,MAAM,UAAU,CAACG,MAAM;wBACtC,GAAG0B,IAAI;wBACP,GAAID,SAAS;4BAAE,OAAO;wBAAK,CAAC;wBAC5B,cAAcF;oBAClB;oBAEA,IAAIC,YACAG,WAAW,KAAK,CAACH;gBAEzB;gBAEAR,QAAQ,OAAO,CAAC,CAACY;oBACb,MAAM,EAAE5B,IAAI,EAAEuB,QAAQ,EAAEC,UAAU,EAAE,GAAGE,MAAM,GAAGE;oBAEhD,MAAMC,cAAchC,MAAM,MAAM,CAACG,MAAM;wBACnC,GAAG0B,IAAI;wBACP,cAAcH;oBAClB;oBAEA,IAAIK,OAAO,KAAK,EACZC,YAAY,KAAK,CAACD,OAAO,IAAI,EAAEA,OAAO,KAAK;oBAG/C,IAAIJ,YACAK,YAAY,KAAK,CAACL;gBAE1B;YACJ,GACAP;QAER;QAEArB,YAAY,IAAI,CAAC;QACjBA,YAAY,OAAO,CAACD,WAAW,iBAAiB;QAChD,IAAI,CAAC,WAAW,GAAGC;QACnB,OAAO,IAAI,CAAC,WAAW;IAC3B;AACJ;AAEO,MAAMkC,sBAAsBC,qBAAqB;IACpD,aAAaC;IACb,gBAAgB5C;IAChB,cAAc;QACV6C;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
1
+ {"version":3,"file":"services/GetCliRunnerService/GetCliRunnerService.js","sources":["../../../src/services/GetCliRunnerService/GetCliRunnerService.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport {\n CliCommandFactory,\n CommandsRegistryService,\n GetArgvService,\n GetCliRunnerService,\n GlobalOptionsRegistryService,\n GetProjectSdkService,\n UiService\n} from \"~/abstractions/index.js\";\nimport yargs from \"yargs/yargs\";\nimport chalk from \"chalk\";\nimport { Argv } from \"yargs\";\nimport { GracefulError } from \"@webiny/project\";\nimport { traceRecorder } from \"@webiny/project/utils/trace/index.js\";\nimport { ManuallyReportedError } from \"~/utils/ManuallyReportedError.js\";\n\nconst { blue, bgYellow, bold } = chalk;\n\nexport class DefaultGetCliRunnerService implements GetCliRunnerService.Interface {\n constructor(\n private readonly commandsRegistryService: CommandsRegistryService.Interface,\n private readonly globalOptionsRegistryService: GlobalOptionsRegistryService.Interface,\n private readonly uiService: UiService.Interface,\n private readonly getProjectSdkService: GetProjectSdkService.Interface,\n private readonly getArgvService: GetArgvService.Interface\n ) {}\n\n private yargsRunner: Argv | null = null;\n\n async execute() {\n if (this.yargsRunner) {\n return this.yargsRunner;\n }\n\n const ui = this.uiService;\n const projectSdk = await this.getProjectSdkService.execute();\n\n const yargsRunner = yargs()\n .usage(\"Usage: $0 <command> [options]\")\n .help(false)\n .demandCommand(1)\n .recommendCommands()\n .scriptName(\"webiny\")\n .epilogue(\n `To find more information, docs and tutorials, see ${blue(\n \"https://www.webiny.com/docs\"\n )}.`\n )\n .epilogue(`Want to contribute? ${blue(\"https://github.com/webiny/webiny-js\")}.`);\n\n // Register global options.\n const globalOptions = this.globalOptionsRegistryService.execute();\n for (const globalOption of globalOptions) {\n const { name, config } = await globalOption.execute();\n yargsRunner.option(name, {\n type: config.type,\n default: config.default,\n desc: config.description,\n alias: config.alias,\n choices: config.choices,\n global: true\n });\n }\n\n yargsRunner.fail((invalidParamsMessage, error) => {\n if (invalidParamsMessage) {\n if (invalidParamsMessage.includes(\"Not enough non-option arguments\")) {\n ui.emptyLine();\n ui.error(\"Command was not invoked as expected.\");\n ui.info(\n `Some non-optional arguments are missing. See the usage examples printed below.`\n );\n ui.emptyLine();\n yargsRunner.showHelp();\n process.exit(1);\n }\n\n if (invalidParamsMessage.includes(\"Missing required argument\")) {\n const args = invalidParamsMessage\n .split(\":\")[1]\n .split(\",\")\n .map(v => v.trim());\n\n ui.emptyLine();\n ui.error(\"Command was not invoked as expected.\");\n ui.info(\n `Missing required argument(s): ${args.join(\n \", \"\n )}. See the usage examples printed below.`\n );\n ui.emptyLine();\n yargsRunner.showHelp();\n process.exit(1);\n }\n\n ui.emptyLine();\n ui.error(invalidParamsMessage);\n\n process.exit(1);\n }\n\n const logger = projectSdk.getLogger();\n logger.error({ err: error }, \"CLI command execution failed.\");\n\n const realError = (error.cause as Error) || error;\n\n if (realError instanceof ManuallyReportedError) {\n // Do nothing as the error reporting has already been\n // handled within the invoked CLI command.\n } else {\n ui.error(realError.message);\n }\n\n const argv = this.getArgvService.execute();\n if (argv.showStackTrace && realError.stack) {\n ui.emptyLine();\n ui.debug(\"Stack trace:\");\n ui.text(realError.stack);\n }\n\n if (error instanceof GracefulError) {\n ui.emptyLine();\n ui.text(bgYellow(bold(\"💡 How can I resolve this?\")));\n ui.text(error.message);\n }\n\n process.exit(1);\n });\n\n const commands = this.commandsRegistryService.execute();\n\n // Every registered command's definition is built on every run, no matter which command was\n // actually invoked, so each one is timed separately.\n for (const command of commands) {\n const startedAt = performance.now();\n const definition = await command.execute();\n\n const { name, description, params = [], options = [], handler } = definition;\n\n traceRecorder.record(`build \"${name}\" command`, startedAt, performance.now());\n\n let yargsCommand = name;\n const paramVersionExists = params.some(p => {\n return p.name === \"version\";\n });\n if (paramVersionExists) {\n ui.error(\n `The command \"${name}\" cannot have a parameter named \"version\" as it conflicts with the global --version option.`\n );\n process.exit();\n }\n\n if (params.length > 0) {\n yargsCommand +=\n \" \" +\n params\n .map(param => {\n const paramName = param.array ? `${param.name}..` : param.name;\n return param.required ? `<${paramName}>` : `[${paramName}]`;\n })\n .join(\" \");\n }\n\n yargsRunner.command(\n yargsCommand,\n description,\n yargs => {\n params.forEach((param: CliCommandFactory.ParamDefinition<unknown>) => {\n const { name, required, validation, array, ...rest } = param;\n\n const yargsParam = yargs.positional(name, {\n ...rest,\n ...(array && { array: true }),\n demandOption: required\n });\n\n if (validation) {\n yargsParam.check(validation);\n }\n });\n\n options.forEach((option: CliCommandFactory.OptionDefinition<unknown>) => {\n const { name, required, validation, ...rest } = option;\n\n const yargsOption = yargs.option(name, {\n ...rest,\n demandOption: required\n });\n\n if (option.group) {\n yargsOption.group(option.name, option.group);\n }\n\n if (validation) {\n yargsOption.check(validation);\n }\n });\n },\n handler\n );\n }\n\n yargsRunner.help(true);\n yargsRunner.version(projectSdk.getProjectVersion());\n this.yargsRunner = yargsRunner;\n return this.yargsRunner;\n }\n}\n\nexport const getCliRunnerService = createImplementation({\n abstraction: GetCliRunnerService,\n implementation: DefaultGetCliRunnerService,\n dependencies: [\n CommandsRegistryService,\n GlobalOptionsRegistryService,\n UiService,\n GetProjectSdkService,\n GetArgvService\n ]\n});\n"],"names":["blue","bgYellow","bold","chalk","DefaultGetCliRunnerService","commandsRegistryService","globalOptionsRegistryService","uiService","getProjectSdkService","getArgvService","ui","projectSdk","yargsRunner","yargs","globalOptions","globalOption","name","config","invalidParamsMessage","error","process","args","v","logger","realError","ManuallyReportedError","argv","GracefulError","commands","command","startedAt","performance","definition","description","params","options","handler","traceRecorder","yargsCommand","paramVersionExists","p","param","paramName","required","validation","array","rest","yargsParam","option","yargsOption","getCliRunnerService","createImplementation","GetCliRunnerService","CommandsRegistryService","GlobalOptionsRegistryService","UiService","GetProjectSdkService","GetArgvService"],"mappings":";;;;;;;AAiBA,MAAM,EAAEA,MAAAA,IAAI,EAAEC,UAAAA,QAAQ,EAAEC,MAAAA,IAAI,EAAE,GAAGC;AAE1B,MAAMC;IACT,YACqBC,uBAA0D,EAC1DC,4BAAoE,EACpEC,SAA8B,EAC9BC,oBAAoD,EACpDC,cAAwC,CAC3D;aALmBJ,uBAAuB,GAAvBA;aACAC,4BAA4B,GAA5BA;aACAC,SAAS,GAATA;aACAC,oBAAoB,GAApBA;aACAC,cAAc,GAAdA;aAGb,WAAW,GAAgB;IAFhC;IAIH,MAAM,UAAU;QACZ,IAAI,IAAI,CAA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AACJ;AAEO,MAAMsC,sBAAsBC,qBAAqB;IACpD,aAAaC;IACb,gBAAgBhD;IAChB,cAAc;QACViD;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
@@ -13,5 +13,23 @@ export declare class DefaultUiService implements UiService.Interface {
13
13
  error(text: string, ...args: any[]): void;
14
14
  debug(text: string, ...args: any[]): void;
15
15
  private typedColorizedText;
16
+ /**
17
+ * Prefixes every line of `message` with the gutter, wrapping the text to the terminal width
18
+ * first.
19
+ *
20
+ * The wrap has to happen here rather than being left to the terminal. Writing the whole message
21
+ * as one long line means the terminal wraps it at column 0, with no knowledge of the gutter -
22
+ * so continuation lines start underneath the pipe instead of underneath the text, and a wrapped
23
+ * sentence reads as though it belongs to a different paragraph.
24
+ */
25
+ private applyGutter;
26
+ /**
27
+ * Width available for the text itself, or `null` when there is nothing to wrap to.
28
+ *
29
+ * `columns` is undefined whenever stdout is not a TTY - piped to a file, or read by another
30
+ * process. Wrapping to a guessed width there would bake line breaks into output that something
31
+ * else is going to reflow anyway, so the message is left as a single line.
32
+ */
33
+ private getTextWidth;
16
34
  }
17
35
  export declare const uiService: import("@webiny/di").Implementation<typeof DefaultUiService>;
@@ -1,9 +1,12 @@
1
1
  import { createImplementation } from "@webiny/di";
2
2
  import chalk from "chalk";
3
3
  import util from "util";
4
+ import wrap_ansi from "wrap-ansi";
4
5
  import { IsCi, StdioService, UiService } from "../../abstractions/index.js";
5
6
  const NEW_LINE = "\n";
6
7
  const PIPE_SYMBOL = "┃";
8
+ const GUTTER_WIDTH = 2;
9
+ const MIN_TEXT_WIDTH = 20;
7
10
  const LOG_COLORS = {
8
11
  info: chalk.blueBright,
9
12
  error: chalk.red,
@@ -49,9 +52,22 @@ class DefaultUiService {
49
52
  const prefix = `${type}: `;
50
53
  return this.text(prefix + util.format(text, ...args));
51
54
  }
52
- const prefix = `${LOG_COLORS[type](PIPE_SYMBOL)} `;
55
+ const gutter = `${LOG_COLORS[type](PIPE_SYMBOL)} `;
53
56
  const textWithColorizedPlaceholders = text.replace(/%[a-zA-Z]/g, (match)=>LOG_COLORS[type](match));
54
- return this.text(prefix + util.format(textWithColorizedPlaceholders, ...args));
57
+ const message = util.format(textWithColorizedPlaceholders, ...args);
58
+ return this.text(this.applyGutter(message, gutter));
59
+ }
60
+ applyGutter(message, gutter) {
61
+ const textWidth = this.getTextWidth();
62
+ const wrapped = textWidth ? wrap_ansi(message, textWidth, {
63
+ hard: true
64
+ }) : message;
65
+ return wrapped.split(NEW_LINE).map((line)=>gutter + line).join(NEW_LINE);
66
+ }
67
+ getTextWidth() {
68
+ const columns = this.stdio.getStdout().columns;
69
+ if (!columns) return null;
70
+ return Math.max(columns - GUTTER_WIDTH, MIN_TEXT_WIDTH);
55
71
  }
56
72
  }
57
73
  const uiService = createImplementation({
@@ -1 +1 @@
1
- {"version":3,"file":"services/UiService/UiService.js","sources":["../../../src/services/UiService/UiService.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport chalk from \"chalk\";\nimport util from \"util\";\nimport { UiService, StdioService, IsCi } from \"~/abstractions/index.js\";\n\nconst NEW_LINE = \"\\n\";\nconst PIPE_SYMBOL = \"┃\";\n\nconst LOG_COLORS = {\n info: chalk.blueBright,\n error: chalk.red,\n warning: chalk.yellow,\n success: chalk.green,\n debug: chalk.gray\n} as const;\n\nexport class DefaultUiService implements UiService.Interface {\n constructor(\n private readonly stdio: StdioService.Interface,\n private readonly isCi: IsCi.Interface\n ) {}\n\n raw(text: string) {\n this.stdio.getStdout().write(text);\n }\n\n text(text: string) {\n this.stdio.getStdout().write(text);\n this.stdio.getStdout().write(NEW_LINE);\n }\n\n textBold(text: string) {\n this.text(chalk.bold(text));\n }\n\n emptyLine() {\n this.stdio.getStdout().write(chalk.gray(\"∙\") + NEW_LINE);\n }\n\n // The following methods are used to print texts with a specific type prefix.\n success(text: string, ...args: any[]) {\n this.typedColorizedText(\"success\", text, ...args);\n }\n\n info(text: string, ...args: any[]) {\n this.typedColorizedText(\"info\", text, ...args);\n }\n\n warning(text: string, ...args: any[]) {\n this.typedColorizedText(\"warning\", text, ...args);\n }\n\n error(text: string, ...args: any[]) {\n this.typedColorizedText(\"error\", text, ...args);\n }\n\n debug(text: string, ...args: any[]) {\n this.typedColorizedText(\"debug\", text, ...args);\n }\n\n private typedColorizedText(type: keyof typeof LOG_COLORS, text: string, ...args: any[]) {\n // Use plain text format in CI environments.\n if (this.isCi.execute()) {\n const prefix = `${type}: `;\n return this.text(prefix + util.format(text, ...args));\n }\n\n const prefix = `${LOG_COLORS[type](PIPE_SYMBOL)} `;\n\n // Replace all placeholders (match with `/%[a-zA-Z]/g` regex) with colorized values.\n const textWithColorizedPlaceholders = text.replace(/%[a-zA-Z]/g, match => {\n return LOG_COLORS[type](match);\n });\n\n return this.text(prefix + util.format(textWithColorizedPlaceholders, ...args));\n }\n}\n\nexport const uiService = createImplementation({\n abstraction: UiService,\n implementation: DefaultUiService,\n dependencies: [StdioService, IsCi]\n});\n"],"names":["NEW_LINE","PIPE_SYMBOL","LOG_COLORS","chalk","DefaultUiService","stdio","isCi","text","args","type","prefix","util","textWithColorizedPlaceholders","match","uiService","createImplementation","UiService","StdioService","IsCi"],"mappings":";;;;AAKA,MAAMA,WAAW;AACjB,MAAMC,cAAc;AAEpB,MAAMC,aAAa;IACf,MAAMC,MAAM,UAAU;IACtB,OAAOA,MAAM,GAAG;IAChB,SAASA,MAAM,MAAM;IACrB,SAASA,MAAM,KAAK;IACpB,OAAOA,MAAM,IAAI;AACrB;AAEO,MAAMC;IACT,YACqBC,KAA6B,EAC7BC,IAAoB,CACvC;aAFmBD,KAAK,GAALA;aACAC,IAAI,GAAJA;IAClB;IAEH,IAAIC,IAAY,EAAE;QACd,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,KAAK,CAACA;IACjC;IAEA,KAAKA,IAAY,EAAE;QACf,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,KAAK,CAACA;QAC7B,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG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C;KAAK;AACtC"}
1
+ {"version":3,"file":"services/UiService/UiService.js","sources":["../../../src/services/UiService/UiService.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport chalk from \"chalk\";\nimport util from \"util\";\nimport wrapAnsi from \"wrap-ansi\";\nimport { UiService, StdioService, IsCi } from \"~/abstractions/index.js\";\n\nconst NEW_LINE = \"\\n\";\nconst PIPE_SYMBOL = \"┃\";\n\n// Visible width of the `┃ ` gutter that prefixes every line of a typed message. Hardcoded rather\n// than measured because the pipe is a single-column glyph and the colour codes around it occupy no\n// columns at all.\nconst GUTTER_WIDTH = 2;\n\n// A floor for very narrow terminals, so the wrap width can never go to zero or negative.\nconst MIN_TEXT_WIDTH = 20;\n\nconst LOG_COLORS = {\n info: chalk.blueBright,\n error: chalk.red,\n warning: chalk.yellow,\n success: chalk.green,\n debug: chalk.gray\n} as const;\n\nexport class DefaultUiService implements UiService.Interface {\n constructor(\n private readonly stdio: StdioService.Interface,\n private readonly isCi: IsCi.Interface\n ) {}\n\n raw(text: string) {\n this.stdio.getStdout().write(text);\n }\n\n text(text: string) {\n this.stdio.getStdout().write(text);\n this.stdio.getStdout().write(NEW_LINE);\n }\n\n textBold(text: string) {\n this.text(chalk.bold(text));\n }\n\n emptyLine() {\n this.stdio.getStdout().write(chalk.gray(\"∙\") + NEW_LINE);\n }\n\n // The following methods are used to print texts with a specific type prefix.\n success(text: string, ...args: any[]) {\n this.typedColorizedText(\"success\", text, ...args);\n }\n\n info(text: string, ...args: any[]) {\n this.typedColorizedText(\"info\", text, ...args);\n }\n\n warning(text: string, ...args: any[]) {\n this.typedColorizedText(\"warning\", text, ...args);\n }\n\n error(text: string, ...args: any[]) {\n this.typedColorizedText(\"error\", text, ...args);\n }\n\n debug(text: string, ...args: any[]) {\n this.typedColorizedText(\"debug\", text, ...args);\n }\n\n private typedColorizedText(type: keyof typeof LOG_COLORS, text: string, ...args: any[]) {\n // Use plain text format in CI environments.\n if (this.isCi.execute()) {\n const prefix = `${type}: `;\n return this.text(prefix + util.format(text, ...args));\n }\n\n const gutter = `${LOG_COLORS[type](PIPE_SYMBOL)} `;\n\n // Replace all placeholders (match with `/%[a-zA-Z]/g` regex) with colorized values.\n const textWithColorizedPlaceholders = text.replace(/%[a-zA-Z]/g, match => {\n return LOG_COLORS[type](match);\n });\n\n const message = util.format(textWithColorizedPlaceholders, ...args);\n\n return this.text(this.applyGutter(message, gutter));\n }\n\n /**\n * Prefixes every line of `message` with the gutter, wrapping the text to the terminal width\n * first.\n *\n * The wrap has to happen here rather than being left to the terminal. Writing the whole message\n * as one long line means the terminal wraps it at column 0, with no knowledge of the gutter -\n * so continuation lines start underneath the pipe instead of underneath the text, and a wrapped\n * sentence reads as though it belongs to a different paragraph.\n */\n private applyGutter(message: string, gutter: string) {\n const textWidth = this.getTextWidth();\n\n // `hard` also breaks words longer than a whole line - a long file path, or a URL. Letting\n // those overflow would hand them straight back to the terminal's own wrapping, which is\n // the column-0 behaviour this method exists to avoid.\n const wrapped = textWidth ? wrapAnsi(message, textWidth, { hard: true }) : message;\n\n return wrapped\n .split(NEW_LINE)\n .map(line => gutter + line)\n .join(NEW_LINE);\n }\n\n /**\n * Width available for the text itself, or `null` when there is nothing to wrap to.\n *\n * `columns` is undefined whenever stdout is not a TTY - piped to a file, or read by another\n * process. Wrapping to a guessed width there would bake line breaks into output that something\n * else is going to reflow anyway, so the message is left as a single line.\n */\n private getTextWidth() {\n const columns = this.stdio.getStdout().columns;\n if (!columns) {\n return null;\n }\n\n return Math.max(columns - GUTTER_WIDTH, MIN_TEXT_WIDTH);\n }\n}\n\nexport const uiService = createImplementation({\n abstraction: UiService,\n implementation: DefaultUiService,\n dependencies: [StdioService, IsCi]\n});\n"],"names":["NEW_LINE","PIPE_SYMBOL","GUTTER_WIDTH","MIN_TEXT_WIDTH","LOG_COLORS","chalk","DefaultUiService","stdio","isCi","text","args","type","prefix","util","gutter","textWithColorizedPlaceholders","match","message","textWidth","wrapped","wrapAnsi","line","columns","Math","u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AAC,SAASD,SAASC;IAC9C;IAEQ,mBAAmBC,IAA6B,EAAEF,IAAY,EAAE,GAAGC,IAAW,EAAE;QAEpF,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI;YACrB,MAAME,SAAS,GAAGD,KAAK,EAAE,CAAC;YAC1B,OAAO,IAAI,CAAC,IAAI,CAACC,SAASC,KAAK,MAAM,CAACJ,SAASC;QACnD;QAEA,MAAMI,SAAS,GAAGV,UAAU,CAACO,KAAK,CAACV,aAAa,CAAC,CAAC;QAGlD,MAAMc,gCAAgCN,KAAK,OAAO,CAAC,cAAcO,CAAAA,QACtDZ,UAAU,CAACO,KAAK,CAACK;QAG5B,MAAMC,UAAUJ,KAAK,MAAM,CAACE,kCAAkCL;QAE9D,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAACO,SAASH;IAC/C;IAWQ,YAAYG,OAAe,EAAEH,MAAc,EAAE;QACjD,MAAMI,YAAY,IAAI,CAAC,YAAY;QAKnC,MAAMC,UAAUD,YAAYE,UAASH,SAASC,WAAW;YAAE,MAAM;QAAK,KAAKD;QAE3E,OAAOE,QACF,KAAK,CAACnB,UACN,GAAG,CAACqB,CAAAA,OAAQP,SAASO,MACrB,IAAI,CAACrB;IACd;IASQ,eAAe;QACnB,MAAMsB,UAAU,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,OAAO;QAC9C,IAAI,CAACA,SACD,OAAO;QAGX,OAAOC,KAAK,GAAG,CAACD,UAAUpB,cAAcC;IAC5C;AACJ;AAEO,MAAMqB,YAAYC,qBAAqB;IAC1C,aAAaC;IACb,gBAAgBpB;IAChB,cAAc;QAACqB;QAAcC;KAAK;AACtC"}
@@ -1,32 +1,21 @@
1
- import { execaSync } from "execa";
2
1
  import chalk from "chalk";
2
+ import { getCacheFilePath } from "./getCacheFilePath.js";
3
+ import { hashYarnLock } from "./hashYarnLock.js";
4
+ import { listWebinyPackageVersions } from "./listWebinyPackageVersions.js";
5
+ import { readClearedYarnLockHash } from "./readClearedYarnLockHash.js";
6
+ import { writeClearedYarnLockHash } from "./writeClearedYarnLockHash.js";
3
7
  const DEBUG_FLAG = "--debug";
4
8
  const usingDebugFlag = process.argv.includes(DEBUG_FLAG);
5
9
  const SKIP_WEBINY_VERSIONS_CHECK_FLAG = "--no-package-versions-check";
6
10
  const skippingWebinyVersionsCheck = process.argv.includes(SKIP_WEBINY_VERSIONS_CHECK_FLAG);
7
- const listWebinyPackageVersions = ()=>{
8
- const { stdout } = execaSync("yarn", [
9
- "info",
10
- "@webiny/*",
11
- "--name-only",
12
- "--all",
13
- "--json"
14
- ], {
15
- encoding: "utf8"
16
- });
17
- const lines = stdout.trim().split("\n").map((line)=>JSON.parse(line));
18
- const versionMap = new Map();
19
- for (const entry of lines){
20
- const match = entry.match(/^(@webiny\/[^@]+)@npm:(.+)$/);
21
- if (!match) continue;
22
- const [, pkg, version] = match;
23
- if (!versionMap.has(pkg)) versionMap.set(pkg, new Set());
24
- versionMap.get(pkg).add(version);
25
- }
26
- return versionMap;
27
- };
28
11
  const ensureSameWebinyPackageVersions = ()=>{
29
12
  if (skippingWebinyVersionsCheck) return;
13
+ const cacheFilePath = getCacheFilePath();
14
+ const yarnLockHash = hashYarnLock();
15
+ if (cacheFilePath && yarnLockHash) {
16
+ const clearedYarnLockHash = readClearedYarnLockHash(cacheFilePath);
17
+ if (clearedYarnLockHash === yarnLockHash) return;
18
+ }
30
19
  let webinyVersions;
31
20
  try {
32
21
  webinyVersions = listWebinyPackageVersions();
@@ -57,6 +46,7 @@ const ensureSameWebinyPackageVersions = ()=>{
57
46
  console.error(chalk.red(message.join("\n")));
58
47
  process.exit(1);
59
48
  }
49
+ if (cacheFilePath && yarnLockHash) writeClearedYarnLockHash(cacheFilePath, yarnLockHash);
60
50
  };
61
51
  export { ensureSameWebinyPackageVersions };
62
52
 
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils/ensureSameWebinyPackageVersions/ensureSameWebinyPackageVersions.js","sources":["../../../src/utils/ensureSameWebinyPackageVersions/ensureSameWebinyPackageVersions.ts"],"sourcesContent":["import chalk from \"chalk\";\nimport { getCacheFilePath } from \"./getCacheFilePath.js\";\nimport { hashYarnLock } from \"./hashYarnLock.js\";\nimport { listWebinyPackageVersions } from \"./listWebinyPackageVersions.js\";\nimport { readClearedYarnLockHash } from \"./readClearedYarnLockHash.js\";\nimport { writeClearedYarnLockHash } from \"./writeClearedYarnLockHash.js\";\n\nconst DEBUG_FLAG = \"--debug\";\nconst usingDebugFlag = process.argv.includes(DEBUG_FLAG);\n\nconst SKIP_WEBINY_VERSIONS_CHECK_FLAG = \"--no-package-versions-check\";\nconst skippingWebinyVersionsCheck = process.argv.includes(SKIP_WEBINY_VERSIONS_CHECK_FLAG);\n\n/*\n * Two `@webiny/*` packages on different versions in one install produce failures that are hard to\n * read, so the CLI refuses to start on a mismatch. The check runs on every invocation and the `yarn\n * info` call behind it is slow, so a pass is remembered against the lockfile hash and skipped while\n * that hash holds.\n *\n * Only a pass is cached. A failed `yarn info` warns and returns, and a mismatch exits, so neither\n * writes the file and the next run checks again.\n */\nexport const ensureSameWebinyPackageVersions = (): void => {\n // Just in case, we want to allow users to skip the check.\n if (skippingWebinyVersionsCheck) {\n return;\n }\n\n const cacheFilePath = getCacheFilePath();\n const yarnLockHash = hashYarnLock();\n\n if (cacheFilePath && yarnLockHash) {\n const clearedYarnLockHash = readClearedYarnLockHash(cacheFilePath);\n if (clearedYarnLockHash === yarnLockHash) {\n return;\n }\n }\n\n let webinyVersions: Map<string, Set<string>>;\n try {\n webinyVersions = listWebinyPackageVersions();\n } catch (e) {\n const message = [\"Failed to inspect Webiny package versions.\"];\n\n if (!usingDebugFlag) {\n message.push(`For more information, try running with ${chalk.yellow(DEBUG_FLAG)}.`);\n }\n\n message.push(\"Learn more: https://webiny.link/webiny-package-versions-check\");\n\n console.warn(chalk.yellow(message.join(\" \")));\n if (usingDebugFlag) {\n console.warn(e);\n }\n\n console.log();\n return;\n }\n\n const mismatchedPackages: Array<[string, Set<string>]> = [];\n for (const [pkg, versions] of webinyVersions.entries()) {\n if (versions.size > 1) {\n mismatchedPackages.push([pkg, versions]);\n }\n }\n\n if (mismatchedPackages.length > 0) {\n const message = [\n \"The following Webiny packages have mismatched versions:\",\n \"\",\n ...mismatchedPackages.map(([pkg, versions]) => {\n return `‣ ${pkg}: ${Array.from(versions).join(\", \")}`;\n }),\n \"\",\n `Please ensure all Webiny packages are using the same version. If you think this is a mistake, you can also skip this check by appending the ${chalk.red(\n SKIP_WEBINY_VERSIONS_CHECK_FLAG\n )} flag. Learn more: https://webiny.link/webiny-package-versions-check`\n ];\n\n console.error(chalk.red(message.join(\"\\n\")));\n process.exit(1);\n }\n\n if (cacheFilePath && yarnLockHash) {\n writeClearedYarnLockHash(cacheFilePath, yarnLockHash);\n }\n};\n"],"names":["DEBUG_FLAG","usingDebugFlag","process","SKIP_WEBINY_VERSIONS_CHECK_FLAG","skippingWebinyVersionsCheck","ensureSameWebinyPackageVersions","cacheFilePath","getCacheFilePath","yarnLockHash","hashYarnLock","clearedYarnLockHash","readClearedYarnLockHash","webinyVersions","listWebinyPackageVersions","e","message","chalk","console","mismatchedPackages","pkg","versions","Array","writeClearedYarnLockHash"],"mappings":";;;;;;AAOA,MAAMA,aAAa;AACnB,MAAMC,iBAAiBC,QAAQ,IAAI,CAAC,QAAQ,CAACF;AAE7C,MAAMG,kCAAkC;AACxC,MAAMC,8BAA8BF,QAAQ,IAAI,CAAC,QAAQ,CAACC;AAWnD,MAAME,kCAAkC;IAE3C,IAAID,6BACA;IAGJ,MAAME,gBAAgBC;IACtB,MAAMC,eAAeC;IAErB,IAAIH,iBAAiBE,cAAc;QAC/B,MAAME,sBAAsBC,wBAAwBL;QACpD,IAAII,wBAAwBF,cACxB;IAER;IAEA,IAAII;IACJ,IAAI;QACAA,iBAAiBC;IACrB,EAAE,OAAOC,GAAG;QACR,MAAMC,UAAU;YAAC;SAA6C;QAE9D,IAAI,CAACd,gBACDc,QAAQ,IAAI,CAAC,CAAC,uCAAuC,EAAEC,MAAM,MAAM,CAAChB,YAAY,CAAC,CAAC;QAGtFe,QAAQ,IAAI,CAAC;QAEbE,QAAQ,IAAI,CAACD,MAAM,MAAM,CAACD,QAAQ,IAAI,CAAC;QACvC,IAAId,gBACAgB,QAAQ,IAAI,CAACH;QAGjBG,QAAQ,GAAG;QACX;IACJ;IAEA,MAAMC,qBAAmD,EAAE;IAC3D,KAAK,MAAM,CAACC,KAAKC,SAAS,IAAIR,eAAe,OAAO,GAChD,IAAIQ,SAAS,IAAI,GAAG,GAChBF,mBAAmB,IAAI,CAAC;QAACC;QAAKC;KAAS;IAI/C,IAAIF,mBAAmB,MAAM,GAAG,GAAG;QAC/B,MAAMH,UAAU;YACZ;YACA;eACGG,mBAAmB,GAAG,CAAC,CAAC,CAACC,KAAKC,SAAS,GAC/B,CAAC,EAAE,EAAED,IAAI,EAAE,EAAEE,MAAM,IAAI,CAACD,UAAU,IAAI,CAAC,OAAO;YAEzD;YACA,CAAC,4IAA4I,EAAEJ,MAAM,GAAG,CACpJb,iCACF,oEAAoE,CAAC;SAC1E;QAEDc,QAAQ,KAAK,CAACD,MAAM,GAAG,CAACD,QAAQ,IAAI,CAAC;QACrCb,QAAQ,IAAI,CAAC;IACjB;IAEA,IAAII,iBAAiBE,cACjBc,yBAAyBhB,eAAeE;AAEhD"}
@@ -0,0 +1 @@
1
+ export declare const getCacheFilePath: () => string | null;
@@ -0,0 +1,12 @@
1
+ import path from "path";
2
+ import { findUpSync } from "find-up";
3
+ const CACHE_FILE_NAME = "package-versions-check.json";
4
+ const getCacheFilePath = ()=>{
5
+ const webinyConfigFilePath = findUpSync("webiny.config.tsx");
6
+ if (!webinyConfigFilePath) return null;
7
+ const projectRootFolderPath = path.dirname(webinyConfigFilePath);
8
+ return path.join(projectRootFolderPath, ".webiny", CACHE_FILE_NAME);
9
+ };
10
+ export { getCacheFilePath };
11
+
12
+ //# sourceMappingURL=getCacheFilePath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils/ensureSameWebinyPackageVersions/getCacheFilePath.js","sources":["../../../src/utils/ensureSameWebinyPackageVersions/getCacheFilePath.ts"],"sourcesContent":["import path from \"path\";\nimport { findUpSync } from \"find-up\";\n\nconst CACHE_FILE_NAME = \"package-versions-check.json\";\n\n/*\n * Locates `.webiny/package-versions-check.json` for the project the CLI was invoked in.\n *\n * The version check runs before the CLI has a DI container, so this cannot go through\n * `LocalStorageService`. It finds the project root the same way `GetProjectService` does, by walking\n * up to `webiny.config.tsx`, so both agree on which project is being written to. Returns null outside\n * a project, where there is nowhere to cache.\n */\nexport const getCacheFilePath = (): string | null => {\n const webinyConfigFilePath = findUpSync(\"webiny.config.tsx\");\n if (!webinyConfigFilePath) {\n return null;\n }\n\n const projectRootFolderPath = path.dirname(webinyConfigFilePath);\n\n return path.join(projectRootFolderPath, \".webiny\", CACHE_FILE_NAME);\n};\n"],"names":["CACHE_FILE_NAME","getCacheFilePath","webinyConfigFilePath","findUpSync","projectRootFolderPath","path"],"mappings":";;AAGA,MAAMA,kBAAkB;AAUjB,MAAMC,mBAAmB;IAC5B,MAAMC,uBAAuBC,WAAW;IACxC,IAAI,CAACD,sBACD,OAAO;IAGX,MAAME,wBAAwBC,KAAK,OAAO,CAACH;IAE3C,OAAOG,KAAK,IAAI,CAACD,uBAAuB,WAAWJ;AACvD"}
@@ -0,0 +1 @@
1
+ export declare const hashYarnLock: () => string | null;
@@ -0,0 +1,16 @@
1
+ import crypto_0 from "crypto";
2
+ import fs from "fs";
3
+ import { findUpSync } from "find-up";
4
+ const hashYarnLock = ()=>{
5
+ const yarnLockFilePath = findUpSync("yarn.lock");
6
+ if (!yarnLockFilePath) return null;
7
+ try {
8
+ const contents = fs.readFileSync(yarnLockFilePath);
9
+ return crypto_0.createHash("sha1").update(contents).digest("hex");
10
+ } catch {
11
+ return null;
12
+ }
13
+ };
14
+ export { hashYarnLock };
15
+
16
+ //# sourceMappingURL=hashYarnLock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils/ensureSameWebinyPackageVersions/hashYarnLock.js","sources":["../../../src/utils/ensureSameWebinyPackageVersions/hashYarnLock.ts"],"sourcesContent":["import crypto from \"crypto\";\nimport fs from \"fs\";\nimport { findUpSync } from \"find-up\";\n\n/*\n * Hashes the lockfile, which is what keys the cached result of the version check.\n *\n * `yarn info` resolves from the install state, so its answer can only change when `yarn.lock` does.\n * That makes the lockfile hash a faithful key: a manifest edit that has not been installed yet cannot\n * change what the check sees.\n *\n * Returns null when there is no lockfile, and also when one exists but cannot be read, which happens\n * if an install is rewriting it. Callers treat null as a cache miss, because the cache exists to skip\n * work and must never be the reason the CLI fails to start.\n */\nexport const hashYarnLock = (): string | null => {\n const yarnLockFilePath = findUpSync(\"yarn.lock\");\n if (!yarnLockFilePath) {\n return null;\n }\n\n try {\n const contents = fs.readFileSync(yarnLockFilePath);\n\n return crypto.createHash(\"sha1\").update(contents).digest(\"hex\");\n } catch {\n return null;\n }\n};\n"],"names":["hashYarnLock","yarnLockFilePath","findUpSync","contents","fs","crypto"],"mappings":";;;AAeO,MAAMA,eAAe;IACxB,MAAMC,mBAAmBC,WAAW;IACpC,IAAI,CAACD,kBACD,OAAO;IAGX,IAAI;QACA,MAAME,WAAWC,GAAG,YAAY,CAACH;QAEjC,OAAOI,SAAAA,UAAiB,CAAC,QAAQ,MAAM,CAACF,UAAU,MAAM,CAAC;IAC7D,EAAE,OAAM;QACJ,OAAO;IACX;AACJ"}
@@ -0,0 +1,6 @@
1
+ export * from "./ensureSameWebinyPackageVersions.js";
2
+ export * from "./getCacheFilePath.js";
3
+ export * from "./hashYarnLock.js";
4
+ export * from "./listWebinyPackageVersions.js";
5
+ export * from "./readClearedYarnLockHash.js";
6
+ export * from "./writeClearedYarnLockHash.js";
@@ -0,0 +1,6 @@
1
+ export * from "./ensureSameWebinyPackageVersions.js";
2
+ export * from "./getCacheFilePath.js";
3
+ export * from "./hashYarnLock.js";
4
+ export * from "./listWebinyPackageVersions.js";
5
+ export * from "./readClearedYarnLockHash.js";
6
+ export * from "./writeClearedYarnLockHash.js";
@@ -0,0 +1 @@
1
+ export declare const listWebinyPackageVersions: () => Map<string, Set<string>>;
@@ -0,0 +1,31 @@
1
+ import { execaSync } from "execa";
2
+ const listWebinyPackageVersions = ()=>{
3
+ const patterns = [
4
+ "@webiny/*",
5
+ "webiny"
6
+ ];
7
+ const args = [
8
+ "info",
9
+ ...patterns,
10
+ "--name-only",
11
+ "--all",
12
+ "--recursive",
13
+ "--json"
14
+ ];
15
+ const { stdout } = execaSync("yarn", args, {
16
+ encoding: "utf8"
17
+ });
18
+ const lines = stdout.trim().split("\n").map((line)=>JSON.parse(line));
19
+ const versionMap = new Map();
20
+ for (const entry of lines){
21
+ const match = entry.match(/^(webiny|@webiny\/[^@]+)@npm:(.+)$/);
22
+ if (!match) continue;
23
+ const [, pkg, version] = match;
24
+ if (!versionMap.has(pkg)) versionMap.set(pkg, new Set());
25
+ versionMap.get(pkg).add(version);
26
+ }
27
+ return versionMap;
28
+ };
29
+ export { listWebinyPackageVersions };
30
+
31
+ //# sourceMappingURL=listWebinyPackageVersions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils/ensureSameWebinyPackageVersions/listWebinyPackageVersions.js","sources":["../../../src/utils/ensureSameWebinyPackageVersions/listWebinyPackageVersions.ts"],"sourcesContent":["import { execaSync } from \"execa\";\n\n/*\n * Asks yarn which versions of each Webiny package the install resolved to, keyed by package name.\n * More than one version in a set is the mismatch the check is looking for.\n *\n * Both patterns are needed. `@webiny/*` covers the scoped packages, and `webiny` covers the unscoped\n * umbrella package, which is the one a generated project actually depends on: `template.package.json`\n * ships `webiny` and `@webiny/mcp` and nothing else. A scoped-only glob leaves the single most\n * important package in a user's project out of the comparison.\n *\n * `--recursive` is what makes this work outside this monorepo. `--all` on its own reports only the\n * direct dependencies of the workspaces, and in a generated project the only direct Webiny\n * dependencies are `webiny` and `@webiny/mcp`; every scoped package is transitive underneath them.\n * Without it the check would compare two packages and call that a pass. It costs nothing measurable,\n * and in this repo the two flags return the same set because every package here is a workspace.\n *\n * This is the expensive call the cache exists to avoid: it takes the better part of a second in a\n * project of any size.\n */\nexport const listWebinyPackageVersions = (): Map<string, Set<string>> => {\n const patterns = [\"@webiny/*\", \"webiny\"];\n const args = [\"info\", ...patterns, \"--name-only\", \"--all\", \"--recursive\", \"--json\"];\n\n const { stdout } = execaSync(\"yarn\", args, {\n encoding: \"utf8\"\n });\n\n // Each line is a JSON string, so parse them individually.\n const lines = stdout\n .trim()\n .split(\"\\n\")\n .map(line => JSON.parse(line) as string);\n\n const versionMap = new Map<string, Set<string>>();\n\n for (const entry of lines) {\n // Example entries: \"@webiny/cli@npm:5.42.3\" and \"webiny@npm:5.42.3\". Anything resolved to\n // something other than npm, a workspace in this repo for instance, has no version to compare.\n const match = entry.match(/^(webiny|@webiny\\/[^@]+)@npm:(.+)$/);\n if (!match) {\n continue;\n }\n\n const [, pkg, version] = match;\n if (!versionMap.has(pkg)) {\n versionMap.set(pkg, new Set());\n }\n\n versionMap.get(pkg)!.add(version);\n }\n\n return versionMap;\n};\n"],"names":["listWebinyPackageVersions","patterns","args","stdout","execaSync","lines","line","JSON","versionMap","Map","entry","match","pkg","version","Set"],"mappings":";AAoBO,MAAMA,4BAA4B;IACrC,MAAMC,WAAW;QAAC;QAAa;KAAS;IACxC,MAAMC,OAAO;QAAC;WAAWD;QAAU;QAAe;QAAS;QAAe;KAAS;IAEnF,MAAM,EAAEE,MAAM,EAAE,GAAGC,UAAU,QAAQF,MAAM;QACvC,UAAU;IACd;IAGA,MAAMG,QAAQF,OACT,IAAI,GACJ,KAAK,CAAC,MACN,GAAG,CAACG,CAAAA,OAAQC,KAAK,KAAK,CAACD;IAE5B,MAAME,aAAa,IAAIC;IAEvB,KAAK,MAAMC,SAASL,MAAO;QAGvB,MAAMM,QAAQD,MAAM,KAAK,CAAC;QAC1B,IAAI,CAACC,OACD;QAGJ,MAAM,GAAGC,KAAKC,QAAQ,GAAGF;QACzB,IAAI,CAACH,WAAW,GAAG,CAACI,MAChBJ,WAAW,GAAG,CAACI,KAAK,IAAIE;QAG5BN,WAAW,GAAG,CAACI,KAAM,GAAG,CAACC;IAC7B;IAEA,OAAOL;AACX"}
@@ -0,0 +1 @@
1
+ export declare const readClearedYarnLockHash: (cacheFilePath: string) => string | null;
@@ -0,0 +1,13 @@
1
+ import fs from "fs";
2
+ const readClearedYarnLockHash = (cacheFilePath)=>{
3
+ try {
4
+ const contents = fs.readFileSync(cacheFilePath, "utf8");
5
+ const cache = JSON.parse(contents);
6
+ return cache.yarnLockHash ?? null;
7
+ } catch {
8
+ return null;
9
+ }
10
+ };
11
+ export { readClearedYarnLockHash };
12
+
13
+ //# sourceMappingURL=readClearedYarnLockHash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils/ensureSameWebinyPackageVersions/readClearedYarnLockHash.js","sources":["../../../src/utils/ensureSameWebinyPackageVersions/readClearedYarnLockHash.ts"],"sourcesContent":["import fs from \"fs\";\n\n/*\n * Reads the lockfile hash recorded the last time the version check passed. Null means \"no usable\n * record\", covering a first run, a deleted cache and a file we cannot read or parse, all of which\n * should simply run the check again.\n */\nexport const readClearedYarnLockHash = (cacheFilePath: string): string | null => {\n try {\n const contents = fs.readFileSync(cacheFilePath, \"utf8\");\n const cache = JSON.parse(contents) as { yarnLockHash?: string };\n\n return cache.yarnLockHash ?? null;\n } catch {\n return null;\n }\n};\n"],"names":["readClearedYarnLockHash","cacheFilePath","contents","fs","cache","JSON"],"mappings":";AAOO,MAAMA,0BAA0B,CAACC;IACpC,IAAI;QACA,MAAMC,WAAWC,GAAG,YAAY,CAACF,eAAe;QAChD,MAAMG,QAAQC,KAAK,KAAK,CAACH;QAEzB,OAAOE,MAAM,YAAY,IAAI;IACjC,EAAE,OAAM;QACJ,OAAO;IACX;AACJ"}
@@ -0,0 +1 @@
1
+ export declare const writeClearedYarnLockHash: (cacheFilePath: string, yarnLockHash: string) => void;
@@ -0,0 +1,24 @@
1
+ import crypto_0 from "crypto";
2
+ import fs from "fs";
3
+ import path from "path";
4
+ const writeClearedYarnLockHash = (cacheFilePath, yarnLockHash)=>{
5
+ const temporaryFilePath = `${cacheFilePath}.${process.pid}.${crypto_0.randomUUID()}.tmp`;
6
+ try {
7
+ fs.mkdirSync(path.dirname(cacheFilePath), {
8
+ recursive: true
9
+ });
10
+ fs.writeFileSync(temporaryFilePath, JSON.stringify({
11
+ yarnLockHash
12
+ }));
13
+ fs.renameSync(temporaryFilePath, cacheFilePath);
14
+ } catch {
15
+ try {
16
+ fs.rmSync(temporaryFilePath, {
17
+ force: true
18
+ });
19
+ } catch {}
20
+ }
21
+ };
22
+ export { writeClearedYarnLockHash };
23
+
24
+ //# sourceMappingURL=writeClearedYarnLockHash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils/ensureSameWebinyPackageVersions/writeClearedYarnLockHash.js","sources":["../../../src/utils/ensureSameWebinyPackageVersions/writeClearedYarnLockHash.ts"],"sourcesContent":["import crypto from \"crypto\";\nimport fs from \"fs\";\nimport path from \"path\";\n\n/*\n * Records the lockfile hash that the version check just passed on.\n *\n * Written to a temporary file and renamed into place, because `webiny watch` can be running while\n * another command starts. A plain write truncates first, so a reader arriving in that window would\n * parse a half-written file, treat it as a miss and pay for `yarn info` again. The rename is atomic,\n * and the temporary file sits in the same directory so it never crosses a filesystem boundary.\n */\nexport const writeClearedYarnLockHash = (cacheFilePath: string, yarnLockHash: string): void => {\n const temporaryFilePath = `${cacheFilePath}.${process.pid}.${crypto.randomUUID()}.tmp`;\n\n try {\n fs.mkdirSync(path.dirname(cacheFilePath), { recursive: true });\n fs.writeFileSync(temporaryFilePath, JSON.stringify({ yarnLockHash }));\n fs.renameSync(temporaryFilePath, cacheFilePath);\n } catch {\n // A read-only or otherwise unwritable project just pays for the check every time. Clear the\n // temporary file if we got as far as creating one, so failures don't pile up in `.webiny/`.\n try {\n fs.rmSync(temporaryFilePath, { force: true });\n } catch {\n // Nothing further to try.\n }\n }\n};\n"],"names":["writeClearedYarnLockHash","cacheFilePath","yarnLockHash","temporaryFilePath","process","crypto","fs","path","JSON"],"mappings":";;;AAYO,MAAMA,2BAA2B,CAACC,eAAuBC;IAC5D,MAAMC,oBAAoB,GAAGF,cAAc,CAAC,EAAEG,QAAQ,GAAG,CAAC,CAAC,EAAEC,SAAAA,UAAiB,GAAG,IAAI,CAAC;IAEtF,IAAI;QACAC,GAAG,SAAS,CAACC,KAAK,OAAO,CAACN,gBAAgB;YAAE,WAAW;QAAK;QAC5DK,GAAG,aAAa,CAACH,mBAAmBK,KAAK,SAAS,CAAC;YAAEN;QAAa;QAClEI,GAAG,UAAU,CAACH,mBAAmBF;IACrC,EAAE,OAAM;QAGJ,IAAI;YACAK,GAAG,MAAM,CAACH,mBAAmB;gBAAE,OAAO;YAAK;QAC/C,EAAE,OAAM,CAER;IACJ;AACJ"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils/ensureSameWebinyPackageVersions.js","sources":["../../src/utils/ensureSameWebinyPackageVersions.ts"],"sourcesContent":["import { execaSync } from \"execa\";\nimport chalk from \"chalk\";\n\nconst DEBUG_FLAG = \"--debug\";\nconst usingDebugFlag = process.argv.includes(DEBUG_FLAG);\n\nconst SKIP_WEBINY_VERSIONS_CHECK_FLAG = \"--no-package-versions-check\";\nconst skippingWebinyVersionsCheck = process.argv.includes(SKIP_WEBINY_VERSIONS_CHECK_FLAG);\n\nconst listWebinyPackageVersions = (): Map<string, Set<string>> => {\n const { stdout } = execaSync(\"yarn\", [\"info\", \"@webiny/*\", \"--name-only\", \"--all\", \"--json\"], {\n encoding: \"utf8\"\n });\n\n // Each line is a JSON string, so parse them individually.\n const lines = stdout\n .trim()\n .split(\"\\n\")\n .map(line => JSON.parse(line) as string);\n\n const versionMap = new Map<string, Set<string>>();\n\n for (const entry of lines) {\n // An example entry: \"@webiny/cli@npm:5.42.3\".\n const match = entry.match(/^(@webiny\\/[^@]+)@npm:(.+)$/);\n if (!match) {\n continue;\n }\n\n const [, pkg, version] = match;\n if (!versionMap.has(pkg)) {\n versionMap.set(pkg, new Set());\n }\n\n versionMap.get(pkg)!.add(version);\n }\n\n return versionMap;\n};\n\nexport const ensureSameWebinyPackageVersions = (): void => {\n // Just in case, we want to allow users to skip the check.\n if (skippingWebinyVersionsCheck) {\n return;\n }\n\n let webinyVersions: Map<string, Set<string>>;\n try {\n webinyVersions = listWebinyPackageVersions();\n } catch (e) {\n const message = [\"Failed to inspect Webiny package versions.\"];\n\n if (!usingDebugFlag) {\n message.push(`For more information, try running with ${chalk.yellow(DEBUG_FLAG)}.`);\n }\n\n message.push(\"Learn more: https://webiny.link/webiny-package-versions-check\");\n\n console.warn(chalk.yellow(message.join(\" \")));\n if (usingDebugFlag) {\n console.warn(e);\n }\n\n console.log();\n return;\n }\n\n const mismatchedPackages: Array<[string, Set<string>]> = [];\n for (const [pkg, versions] of webinyVersions.entries()) {\n if (versions.size > 1) {\n mismatchedPackages.push([pkg, versions]);\n }\n }\n\n if (mismatchedPackages.length > 0) {\n const message = [\n \"The following Webiny packages have mismatched versions:\",\n \"\",\n ...mismatchedPackages.map(([pkg, versions]) => {\n return `‣ ${pkg}: ${Array.from(versions).join(\", \")}`;\n }),\n \"\",\n `Please ensure all Webiny packages are using the same version. If you think this is a mistake, you can also skip this check by appending the ${chalk.red(\n SKIP_WEBINY_VERSIONS_CHECK_FLAG\n )} flag. Learn more: https://webiny.link/webiny-package-versions-check`\n ];\n\n console.error(chalk.red(message.join(\"\\n\")));\n process.exit(1);\n }\n};\n"],"names":["DEBUG_FLAG","usingDebugFlag","process","SKIP_WEBINY_VERSIONS_CHECK_FLAG","skippingWebinyVersionsCheck","listWebinyPackageVersions","stdout","execaSync","lines","line","JSON","versionMap","Map","entry","match","pkg","version","Set","ensureSameWebinyPackageVersions","webinyVersions","e","message","chalk","console","mismatchedPackages","versions","Array"],"mappings":";;AAGA,MAAMA,aAAa;AACnB,MAAMC,iBAAiBC,QAAQ,IAAI,CAAC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