@webiny/project 6.0.0-rc.1 → 6.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/abstractions/services/WatchedLambdaFunctionsService.d.ts +12 -7
- package/abstractions/services/WatchedLambdaFunctionsService.js.map +1 -1
- package/decorators/DeployAppClearWatchedLambdaFunctions.d.ts +3 -2
- package/decorators/DeployAppClearWatchedLambdaFunctions.js +11 -5
- package/decorators/DeployAppClearWatchedLambdaFunctions.js.map +1 -1
- package/decorators/DeployAppWithWatchedLambdaReplacement.d.ts +3 -2
- package/decorators/DeployAppWithWatchedLambdaReplacement.js +16 -7
- package/decorators/DeployAppWithWatchedLambdaReplacement.js.map +1 -1
- package/defineExtension/createExtensionReactComponent.js +2 -6
- package/defineExtension/createExtensionReactComponent.js.map +1 -1
- package/defineExtension/index.d.ts +0 -1
- package/defineExtension/index.js +0 -1
- package/defineExtension/index.js.map +1 -1
- package/exports/extensions.d.ts +1 -0
- package/exports/extensions.js +1 -0
- package/exports/extensions.js.map +1 -1
- package/extensions/AdminBuildParam.d.ts +11 -0
- package/extensions/AdminBuildParam.js +184 -0
- package/extensions/AdminBuildParam.js.map +1 -0
- package/extensions/AdminExtension.d.ts +11 -0
- package/extensions/AdminExtension.js +99 -0
- package/extensions/AdminExtension.js.map +1 -0
- package/extensions/ApiBuildParam.d.ts +11 -0
- package/extensions/ApiBuildParam.js +119 -0
- package/extensions/ApiBuildParam.js.map +1 -0
- package/extensions/ApiExtension.d.ts +11 -0
- package/{defineExtension/defineApiExtension.js → extensions/ApiExtension.js} +13 -15
- package/extensions/ApiExtension.js.map +1 -0
- package/extensions/FeatureFlags.d.ts +85 -0
- package/extensions/FeatureFlags.js +42 -0
- package/extensions/FeatureFlags.js.map +1 -0
- package/extensions/index.d.ts +102 -0
- package/extensions/index.js +12 -2
- package/extensions/index.js.map +1 -1
- package/features/Watch/Watch.js +1 -0
- package/features/Watch/Watch.js.map +1 -1
- package/features/Watch/replaceLambdaFunctions.d.ts +2 -1
- package/features/Watch/replaceLambdaFunctions.js +5 -1
- package/features/Watch/replaceLambdaFunctions.js.map +1 -1
- package/package.json +13 -13
- package/services/SetProjectIdService/SetProjectIdService.js +28 -18
- package/services/SetProjectIdService/SetProjectIdService.js.map +1 -1
- package/services/WatchedLambdaFunctionsService/WatchedLambdaFunctionsService.d.ts +4 -4
- package/services/WatchedLambdaFunctionsService/WatchedLambdaFunctionsService.js +26 -20
- package/services/WatchedLambdaFunctionsService/WatchedLambdaFunctionsService.js.map +1 -1
- package/defineExtension/defineApiExtension.d.ts +0 -17
- package/defineExtension/defineApiExtension.js.map +0 -1
package/extensions/index.js
CHANGED
|
@@ -5,6 +5,11 @@ import { ProjectId } from "./ProjectId.js";
|
|
|
5
5
|
import { Telemetry } from "./Telemetry.js";
|
|
6
6
|
import { EnvVar } from "./EnvVar.js";
|
|
7
7
|
import { DatabaseSetup } from "./DatabaseSetup.js";
|
|
8
|
+
import { FeatureFlags } from "./FeatureFlags.js";
|
|
9
|
+
import { BuildParam } from "./ApiBuildParam.js";
|
|
10
|
+
import { AdminBuildParam } from "./AdminBuildParam.js";
|
|
11
|
+
import { AdminExtension } from "./AdminExtension.js";
|
|
12
|
+
import { ApiExtension } from "./ApiExtension.js";
|
|
8
13
|
|
|
9
14
|
// Hooks.
|
|
10
15
|
import { AdminAfterBuild, AdminAfterDeploy, AdminBeforeBuild, AdminBeforeDeploy, AdminBeforeWatch, AfterBuild, AfterDeploy, BeforeDeploy, BeforeWatch, ApiAfterBuild, ApiAfterDeploy, ApiBeforeBuild, ApiBeforeDeploy, ApiBeforeWatch, BeforeBuild, CoreAfterBuild, CoreAfterDeploy, CoreBeforeBuild, CoreBeforeDeploy, CoreBeforeWatch } from "./hooks/index.js";
|
|
@@ -19,7 +24,12 @@ export { ProjectDecorator };
|
|
|
19
24
|
export { ProjectImplementation };
|
|
20
25
|
export { ExtensionDefinitions };
|
|
21
26
|
export { EnvVar };
|
|
27
|
+
export { FeatureFlags };
|
|
22
28
|
export { DatabaseSetup };
|
|
29
|
+
export { BuildParam };
|
|
30
|
+
export { AdminBuildParam };
|
|
31
|
+
export { AdminExtension };
|
|
32
|
+
export { ApiExtension };
|
|
23
33
|
|
|
24
34
|
// Hooks.
|
|
25
35
|
export { BeforeBuild };
|
|
@@ -54,11 +64,11 @@ export { ApiStackOutputValue };
|
|
|
54
64
|
export { AdminStackOutputValue };
|
|
55
65
|
|
|
56
66
|
// Definitions (used internally). 👇
|
|
57
|
-
export const definitions = [Telemetry.def, ProjectId.def, ProjectDecorator.def, ProjectImplementation.def, ExtensionDefinitions.def, EnvVar.def,
|
|
67
|
+
export const definitions = [Telemetry.def, ProjectId.def, ProjectDecorator.def, ProjectImplementation.def, ExtensionDefinitions.def, EnvVar.def, FeatureFlags.def,
|
|
58
68
|
// Hooks.
|
|
59
69
|
AdminAfterBuild.def, AdminAfterDeploy.def, BeforeBuild.def, BeforeDeploy.def, BeforeWatch.def, AfterBuild.def, AfterDeploy.def, AdminBeforeBuild.def, AdminBeforeDeploy.def, AdminBeforeWatch.def, ApiAfterBuild.def, ApiAfterDeploy.def, ApiBeforeBuild.def, ApiBeforeDeploy.def, ApiBeforeWatch.def, CoreAfterBuild.def, CoreAfterDeploy.def, CoreBeforeBuild.def, CoreBeforeDeploy.def, CoreBeforeWatch.def,
|
|
60
70
|
// Pulumi.
|
|
61
|
-
CorePulumi.def, PulumiResourceNamePrefix.def, ProductionEnvironments.def, CoreStackOutputValue.def, ApiStackOutputValue.def, AdminStackOutputValue.def, DatabaseSetup.def];
|
|
71
|
+
AdminPulumi.def, ApiPulumi.def, CorePulumi.def, PulumiResourceNamePrefix.def, ProductionEnvironments.def, CoreStackOutputValue.def, ApiStackOutputValue.def, AdminStackOutputValue.def, DatabaseSetup.def, BuildParam.def, AdminBuildParam.def, AdminExtension.def, ApiExtension.def];
|
|
62
72
|
export { Project } from "./Project.js";
|
|
63
73
|
export * from "../defineExtension/index.js";
|
|
64
74
|
|
package/extensions/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ExtensionDefinitions","ProjectDecorator","ProjectImplementation","ProjectId","Telemetry","EnvVar","DatabaseSetup","AdminAfterBuild","AdminAfterDeploy","AdminBeforeBuild","AdminBeforeDeploy","AdminBeforeWatch","AfterBuild","AfterDeploy","BeforeDeploy","BeforeWatch","ApiAfterBuild","ApiAfterDeploy","ApiBeforeBuild","ApiBeforeDeploy","ApiBeforeWatch","BeforeBuild","CoreAfterBuild","CoreAfterDeploy","CoreBeforeBuild","CoreBeforeDeploy","CoreBeforeWatch","AdminPulumi","ApiPulumi","CorePulumi","ProductionEnvironments","PulumiResourceNamePrefix","CoreStackOutputValue","ApiStackOutputValue","AdminStackOutputValue","definitions","def","Project"],"sources":["index.ts"],"sourcesContent":["import { ExtensionDefinitions } from \"./ExtensionDefinitions.js\";\nimport { ProjectDecorator } from \"./ProjectDecorator.js\";\nimport { ProjectImplementation } from \"./ProjectImplementation.js\";\nimport { ProjectId } from \"./ProjectId.js\";\nimport { Telemetry } from \"./Telemetry.js\";\nimport { EnvVar } from \"./EnvVar.js\";\nimport { DatabaseSetup } from \"./DatabaseSetup.js\";\n\n// Hooks.\nimport {\n AdminAfterBuild,\n AdminAfterDeploy,\n AdminBeforeBuild,\n AdminBeforeDeploy,\n AdminBeforeWatch,\n AfterBuild,\n AfterDeploy,\n BeforeDeploy,\n BeforeWatch,\n ApiAfterBuild,\n ApiAfterDeploy,\n ApiBeforeBuild,\n ApiBeforeDeploy,\n ApiBeforeWatch,\n BeforeBuild,\n CoreAfterBuild,\n CoreAfterDeploy,\n CoreBeforeBuild,\n CoreBeforeDeploy,\n CoreBeforeWatch\n} from \"./hooks/index.js\";\n\n// Pulumi.\nimport {\n AdminPulumi,\n ApiPulumi,\n CorePulumi,\n ProductionEnvironments,\n PulumiResourceNamePrefix,\n CoreStackOutputValue,\n ApiStackOutputValue,\n AdminStackOutputValue\n} from \"./pulumi/index.js\";\n\n// Exports.\nexport { Telemetry };\nexport { ProjectId };\nexport { ProjectDecorator };\nexport { ProjectImplementation };\nexport { ExtensionDefinitions };\nexport { EnvVar };\nexport { DatabaseSetup };\n\n// Hooks.\nexport { BeforeBuild };\nexport { BeforeDeploy };\nexport { BeforeWatch };\nexport { AfterBuild };\nexport { AfterDeploy };\nexport { AdminBeforeBuild };\nexport { AdminBeforeDeploy };\nexport { AdminBeforeWatch };\nexport { AdminAfterBuild };\nexport { AdminAfterDeploy };\nexport { ApiBeforeBuild };\nexport { ApiBeforeDeploy };\nexport { ApiBeforeWatch };\nexport { ApiAfterBuild };\nexport { ApiAfterDeploy };\nexport { CoreBeforeBuild };\nexport { CoreBeforeDeploy };\nexport { CoreBeforeWatch };\nexport { CoreAfterBuild };\nexport { CoreAfterDeploy };\n\n// Pulumi.\nexport { CorePulumi };\nexport { AdminPulumi };\nexport { ApiPulumi };\nexport { PulumiResourceNamePrefix };\nexport { ProductionEnvironments };\nexport { CoreStackOutputValue };\nexport { ApiStackOutputValue };\nexport { AdminStackOutputValue };\n\n// Definitions (used internally). 👇\nexport const definitions = [\n Telemetry.def,\n ProjectId.def,\n ProjectDecorator.def,\n ProjectImplementation.def,\n ExtensionDefinitions.def,\n EnvVar.def,\n\n // Hooks.\n AdminAfterBuild.def,\n AdminAfterDeploy.def,\n BeforeBuild.def,\n BeforeDeploy.def,\n BeforeWatch.def,\n AfterBuild.def,\n AfterDeploy.def,\n AdminBeforeBuild.def,\n AdminBeforeDeploy.def,\n AdminBeforeWatch.def,\n ApiAfterBuild.def,\n ApiAfterDeploy.def,\n ApiBeforeBuild.def,\n ApiBeforeDeploy.def,\n ApiBeforeWatch.def,\n CoreAfterBuild.def,\n CoreAfterDeploy.def,\n CoreBeforeBuild.def,\n CoreBeforeDeploy.def,\n CoreBeforeWatch.def,\n\n // Pulumi.\n CorePulumi.def,\n PulumiResourceNamePrefix.def,\n ProductionEnvironments.def,\n CoreStackOutputValue.def,\n ApiStackOutputValue.def,\n AdminStackOutputValue.def,\n DatabaseSetup.def\n];\n\nexport { Project } from \"./Project.js\";\n\nexport * from \"../defineExtension/index.js\";\n"],"mappings":"AAAA,SAASA,oBAAoB;AAC7B,SAASC,gBAAgB;AACzB,SAASC,qBAAqB;AAC9B,SAASC,SAAS;AAClB,SAASC,SAAS;AAClB,SAASC,MAAM;AACf,SAASC,aAAa;;
|
|
1
|
+
{"version":3,"names":["ExtensionDefinitions","ProjectDecorator","ProjectImplementation","ProjectId","Telemetry","EnvVar","DatabaseSetup","FeatureFlags","BuildParam","AdminBuildParam","AdminExtension","ApiExtension","AdminAfterBuild","AdminAfterDeploy","AdminBeforeBuild","AdminBeforeDeploy","AdminBeforeWatch","AfterBuild","AfterDeploy","BeforeDeploy","BeforeWatch","ApiAfterBuild","ApiAfterDeploy","ApiBeforeBuild","ApiBeforeDeploy","ApiBeforeWatch","BeforeBuild","CoreAfterBuild","CoreAfterDeploy","CoreBeforeBuild","CoreBeforeDeploy","CoreBeforeWatch","AdminPulumi","ApiPulumi","CorePulumi","ProductionEnvironments","PulumiResourceNamePrefix","CoreStackOutputValue","ApiStackOutputValue","AdminStackOutputValue","definitions","def","Project"],"sources":["index.ts"],"sourcesContent":["import { ExtensionDefinitions } from \"./ExtensionDefinitions.js\";\nimport { ProjectDecorator } from \"./ProjectDecorator.js\";\nimport { ProjectImplementation } from \"./ProjectImplementation.js\";\nimport { ProjectId } from \"./ProjectId.js\";\nimport { Telemetry } from \"./Telemetry.js\";\nimport { EnvVar } from \"./EnvVar.js\";\nimport { DatabaseSetup } from \"./DatabaseSetup.js\";\nimport { FeatureFlags } from \"./FeatureFlags.js\";\nimport { BuildParam } from \"./ApiBuildParam.js\";\nimport { AdminBuildParam } from \"./AdminBuildParam.js\";\nimport { AdminExtension } from \"./AdminExtension.js\";\nimport { ApiExtension } from \"./ApiExtension.js\";\n\n// Hooks.\nimport {\n AdminAfterBuild,\n AdminAfterDeploy,\n AdminBeforeBuild,\n AdminBeforeDeploy,\n AdminBeforeWatch,\n AfterBuild,\n AfterDeploy,\n BeforeDeploy,\n BeforeWatch,\n ApiAfterBuild,\n ApiAfterDeploy,\n ApiBeforeBuild,\n ApiBeforeDeploy,\n ApiBeforeWatch,\n BeforeBuild,\n CoreAfterBuild,\n CoreAfterDeploy,\n CoreBeforeBuild,\n CoreBeforeDeploy,\n CoreBeforeWatch\n} from \"./hooks/index.js\";\n\n// Pulumi.\nimport {\n AdminPulumi,\n ApiPulumi,\n CorePulumi,\n ProductionEnvironments,\n PulumiResourceNamePrefix,\n CoreStackOutputValue,\n ApiStackOutputValue,\n AdminStackOutputValue\n} from \"./pulumi/index.js\";\n\n// Exports.\nexport { Telemetry };\nexport { ProjectId };\nexport { ProjectDecorator };\nexport { ProjectImplementation };\nexport { ExtensionDefinitions };\nexport { EnvVar };\nexport { FeatureFlags };\nexport { DatabaseSetup };\nexport { BuildParam };\nexport { AdminBuildParam };\nexport { AdminExtension };\nexport { ApiExtension };\n\n// Hooks.\nexport { BeforeBuild };\nexport { BeforeDeploy };\nexport { BeforeWatch };\nexport { AfterBuild };\nexport { AfterDeploy };\nexport { AdminBeforeBuild };\nexport { AdminBeforeDeploy };\nexport { AdminBeforeWatch };\nexport { AdminAfterBuild };\nexport { AdminAfterDeploy };\nexport { ApiBeforeBuild };\nexport { ApiBeforeDeploy };\nexport { ApiBeforeWatch };\nexport { ApiAfterBuild };\nexport { ApiAfterDeploy };\nexport { CoreBeforeBuild };\nexport { CoreBeforeDeploy };\nexport { CoreBeforeWatch };\nexport { CoreAfterBuild };\nexport { CoreAfterDeploy };\n\n// Pulumi.\nexport { CorePulumi };\nexport { AdminPulumi };\nexport { ApiPulumi };\nexport { PulumiResourceNamePrefix };\nexport { ProductionEnvironments };\nexport { CoreStackOutputValue };\nexport { ApiStackOutputValue };\nexport { AdminStackOutputValue };\n\n// Definitions (used internally). 👇\nexport const definitions = [\n Telemetry.def,\n ProjectId.def,\n ProjectDecorator.def,\n ProjectImplementation.def,\n ExtensionDefinitions.def,\n EnvVar.def,\n FeatureFlags.def,\n\n // Hooks.\n AdminAfterBuild.def,\n AdminAfterDeploy.def,\n BeforeBuild.def,\n BeforeDeploy.def,\n BeforeWatch.def,\n AfterBuild.def,\n AfterDeploy.def,\n AdminBeforeBuild.def,\n AdminBeforeDeploy.def,\n AdminBeforeWatch.def,\n ApiAfterBuild.def,\n ApiAfterDeploy.def,\n ApiBeforeBuild.def,\n ApiBeforeDeploy.def,\n ApiBeforeWatch.def,\n CoreAfterBuild.def,\n CoreAfterDeploy.def,\n CoreBeforeBuild.def,\n CoreBeforeDeploy.def,\n CoreBeforeWatch.def,\n\n // Pulumi.\n AdminPulumi.def,\n ApiPulumi.def,\n CorePulumi.def,\n PulumiResourceNamePrefix.def,\n ProductionEnvironments.def,\n CoreStackOutputValue.def,\n ApiStackOutputValue.def,\n AdminStackOutputValue.def,\n DatabaseSetup.def,\n BuildParam.def,\n AdminBuildParam.def,\n AdminExtension.def,\n ApiExtension.def\n];\n\nexport { Project } from \"./Project.js\";\n\nexport * from \"../defineExtension/index.js\";\n"],"mappings":"AAAA,SAASA,oBAAoB;AAC7B,SAASC,gBAAgB;AACzB,SAASC,qBAAqB;AAC9B,SAASC,SAAS;AAClB,SAASC,SAAS;AAClB,SAASC,MAAM;AACf,SAASC,aAAa;AACtB,SAASC,YAAY;AACrB,SAASC,UAAU;AACnB,SAASC,eAAe;AACxB,SAASC,cAAc;AACvB,SAASC,YAAY;;AAErB;AACA,SACIC,eAAe,EACfC,gBAAgB,EAChBC,gBAAgB,EAChBC,iBAAiB,EACjBC,gBAAgB,EAChBC,UAAU,EACVC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,aAAa,EACbC,cAAc,EACdC,cAAc,EACdC,eAAe,EACfC,cAAc,EACdC,WAAW,EACXC,cAAc,EACdC,eAAe,EACfC,eAAe,EACfC,gBAAgB,EAChBC,eAAe;;AAGnB;AACA,SACIC,WAAW,EACXC,SAAS,EACTC,UAAU,EACVC,sBAAsB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xB,UAAU,CAACwB,GAAG,EACdvB,WAAW,CAACuB,GAAG,EACf3B,gBAAgB,CAAC2B,GAAG,EACpB1B,iBAAiB,CAAC0B,GAAG,EACrBzB,gBAAgB,CAACyB,GAAG,EACpBpB,aAAa,CAACoB,GAAG,EACjBnB,cAAc,CAACmB,GAAG,EAClBlB,cAAc,CAACkB,GAAG,EAClBjB,eAAe,CAACiB,GAAG,EACnBhB,cAAc,CAACgB,GAAG,EAClBd,cAAc,CAACc,GAAG,EAClBb,eAAe,CAACa,GAAG,EACnBZ,eAAe,CAACY,GAAG,EACnBX,gBAAgB,CAACW,GAAG,EACpBV,eAAe,CAACU,GAAG;AAEnB;AACAT,WAAW,CAACS,GAAG,EACfR,SAAS,CAACQ,GAAG,EACbP,UAAU,CAACO,GAAG,EACdL,wBAAwB,CAACK,GAAG,EAC5BN,sBAAsB,CAACM,GAAG,EAC1BJ,oBAAoB,CAACI,GAAG,EACxBH,mBAAmB,CAACG,GAAG,EACvBF,qBAAqB,CAACE,GAAG,EACzBnC,aAAa,CAACmC,GAAG,EACjBjC,UAAU,CAACiC,GAAG,EACdhC,eAAe,CAACgC,GAAG,EACnB/B,cAAc,CAAC+B,GAAG,EAClB9B,YAAY,CAAC8B,GAAG,CACnB;AAED,SAASC,OAAO;AAEhB","ignoreList":[]}
|
package/features/Watch/Watch.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createImplementation","BuildAppWorkspaceService","WatchedLambdaFunctionsService","GetApp","GetProductionEnvironments","GetProject","GetProjectConfigService","ListAppLambdaFunctionsService","ListPackagesService","LoggerService","ProjectSdkParamsService","PulumiExportService","PulumiGetStackOutputService","UiService","ValidateProjectConfigService","Watch","chalk","PackagesWatcher","WebinyConfigWatcher","getIotEndpoint","replaceLambdaFunctions","initInvocationForwarding","DefaultWatch","constructor","getApp","logger","listAppLambdaFunctionsService","listPackagesService","getProject","getProjectConfigService","validateProjectConfigService","getProductionEnvironments","ui","pulumiGetStackOutputService","pulumiExportService","watchedLambdaFunctionsService","buildAppWorkspaceService","projectSdkParamsService","execute","params","hasAppOrPackage","Error","whitelistArray","Array","isArray","package","filter","Boolean","packages","packageWhitelist","packagesWatcher","app","sdkParams","get","env","productionEnvironments","includes","allowProduction","red","increaseTimeout","forceRebuild","project","projectConfig","tags","appName","runtimeContext","renderArgs","extensionType","config","oneOrMoreExtensions","extensionsArray","extensionInstance","build","webinyConfigWatcher","webinyConfigPath","paths","webinyConfigFile","toString","packagesWhitelist","functionsWhitelist","function","packagesList","name","functionsList","whitelist","deployCommand","learnMoreLink","troubleshootingLink","meta","count","totalCount","info","join","warning","getDisplayName","debug","list","map","fn","emptyLine","default","exitHook","console","log","coreApp","coreStackOutput","bold","deploymentId","iotEndpointTopic","iotEndpoint","sessionId","Date","getTime","localExecutionHandshakeTimeout","increaseHandshakeTimeout","dependencies","uiService","loggerService","inspector","undefined","inspect","open","close","watch","abstraction","implementation"],"sources":["Watch.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport {\n BuildAppWorkspaceService,\n WatchedLambdaFunctionsService,\n GetApp,\n GetProductionEnvironments,\n GetProject,\n GetProjectConfigService,\n ListAppLambdaFunctionsService,\n ListPackagesService,\n LoggerService,\n ProjectSdkParamsService,\n PulumiExportService,\n PulumiGetStackOutputService,\n UiService,\n ValidateProjectConfigService,\n Watch\n} from \"~/abstractions/index.js\";\nimport chalk from \"chalk\";\nimport type inspectorType from \"inspector\";\nimport { PackagesWatcher } from \"./watchers/PackagesWatcher.js\";\nimport { WebinyConfigWatcher } from \"~/features/Watch/watchers/WebinyConfigWatcher.js\";\nimport { type ICoreStackOutput } from \"~/abstractions/features/GetAppStackOutput.js\";\nimport { getIotEndpoint } from \"./getIotEndpoint.js\";\nimport { replaceLambdaFunctions } from \"~/features/Watch/replaceLambdaFunctions.js\";\nimport { initInvocationForwarding } from \"./initInvocationForwarding.js\";\n\nexport class DefaultWatch implements Watch.Interface {\n constructor(\n private getApp: GetApp.Interface,\n private logger: LoggerService.Interface,\n private listAppLambdaFunctionsService: ListAppLambdaFunctionsService.Interface,\n private listPackagesService: ListPackagesService.Interface,\n private getProject: GetProject.Interface,\n private getProjectConfigService: GetProjectConfigService.Interface,\n private validateProjectConfigService: ValidateProjectConfigService.Interface,\n private getProductionEnvironments: GetProductionEnvironments.Interface,\n private ui: UiService.Interface,\n private pulumiGetStackOutputService: PulumiGetStackOutputService.Interface,\n private pulumiExportService: PulumiExportService.Interface,\n private watchedLambdaFunctionsService: WatchedLambdaFunctionsService.Interface,\n private buildAppWorkspaceService: BuildAppWorkspaceService.Interface,\n private projectSdkParamsService: ProjectSdkParamsService.Interface\n ) {}\n\n async execute(params: Watch.Params) {\n const hasAppOrPackage = \"app\" in params || \"package\" in params;\n if (!hasAppOrPackage) {\n throw new Error(\n `Either \"app\" or \"package\" arguments must be passed. Cannot have both undefined.`\n );\n }\n\n // If we're not watching a specific app, we can only watch packages.\n if (!(\"app\" in params)) {\n const whitelistArray = Array.isArray(params.package)\n ? params.package\n : ([params.package].filter(Boolean) as string[]);\n\n const packages = await this.listPackagesService.execute({\n packageWhitelist: whitelistArray\n });\n\n const packagesWatcher = new PackagesWatcher({ packages, params, logger: this.logger });\n\n return { packagesWatcher };\n }\n\n // Get project application metadata. Will throw an error if an invalid folder is specified.\n const app = this.getApp.execute(params.app);\n\n if (!app) {\n throw new Error(\n `Invalid app name \"${params.app}\". Please specify a valid app name (core, api, or admin).`\n );\n }\n\n const sdkParams = this.projectSdkParamsService.get();\n\n if (!sdkParams.env) {\n throw new Error(`Please specify environment, for example \"dev\".`);\n }\n\n const productionEnvironments = await this.getProductionEnvironments.execute();\n\n if (productionEnvironments.includes(sdkParams.env)) {\n if (!params.allowProduction) {\n throw new Error(\n `${chalk.red(\n \"webiny watch\"\n )} command cannot be used with production environments.`\n );\n }\n }\n\n // A maximum of 15 minutes in seconds can be passed.\n if (params.increaseTimeout && params.increaseTimeout > 900) {\n throw new Error(\n `When increasing the timeout, the maximum value that can be passed is 900 seconds (15 minutes).`\n );\n }\n\n await this.buildAppWorkspaceService.execute(params.app, { forceRebuild: true });\n\n const ui = this.ui;\n const logger = this.logger;\n const project = this.getProject.execute();\n const getProjectConfigService = this.getProjectConfigService;\n const validateProjectConfigService = this.validateProjectConfigService;\n\n const projectConfig = await getProjectConfigService.execute({\n tags: { appName: params.app, runtimeContext: \"app-build\" },\n renderArgs: params\n });\n\n await validateProjectConfigService.execute(projectConfig);\n\n for (const extensionType in projectConfig.config) {\n const oneOrMoreExtensions = projectConfig.config[extensionType];\n const extensionsArray = Array.isArray(oneOrMoreExtensions)\n ? [...oneOrMoreExtensions]\n : [oneOrMoreExtensions];\n\n for (const extensionInstance of extensionsArray) {\n await extensionInstance.build();\n }\n }\n\n const webinyConfigWatcher = new WebinyConfigWatcher({\n webinyConfigPath: project.paths.webinyConfigFile.toString(),\n appName: params.app,\n getProjectConfigService,\n validateProjectConfigService\n });\n\n const packagesWhitelist = Array.isArray(params.package)\n ? params.package\n : ([params.package].filter(Boolean) as string[]);\n\n const functionsWhitelist = Array.isArray(params.function)\n ? params.function\n : ([params.function].filter(Boolean) as string[]);\n\n const packagesList = await this.listPackagesService.execute({\n appName: app.name,\n packageWhitelist: packagesWhitelist\n });\n\n const packagesWatcher = new PackagesWatcher({\n packages: packagesList,\n params,\n logger\n });\n\n const functionsList = await this.listAppLambdaFunctionsService.execute(app, {\n whitelist: functionsWhitelist\n });\n\n const deployCommand = `yarn webiny deploy ${app.name} --env ${sdkParams.env}`;\n const learnMoreLink = \"https://webiny.link/local-aws-lambda-development\";\n const troubleshootingLink = learnMoreLink + \"#troubleshooting\";\n\n if (functionsList.meta.count === 0) {\n // If functions exist, but none are selected for watching, show a warning.\n if (functionsList.meta.totalCount > 0) {\n ui.info(\n [\n \"No AWS Lambda functions will be invoked locally. If this is unexpected, you can try the following:\",\n \" ‣ stop the current development session\",\n \" ‣ redeploy the %s application by running %s command\",\n \" ‣ start a new %s session by rerunning %s command\",\n \"\",\n \"Learn more: %s\"\n ].join(\"\\n\"),\n app.name,\n deployCommand,\n \"webiny watch\",\n \"webiny watch\",\n troubleshootingLink\n );\n }\n return { packagesWatcher, webinyConfigWatcher };\n }\n\n ui.info(`Local AWS Lambda development session started.`);\n ui.warning(\n `Note that once the session is terminated, the %s application will no longer work. To fix this, you %s redeploy it via the %s command. Learn more: %s.`,\n app.getDisplayName(),\n \"MUST\",\n deployCommand,\n learnMoreLink\n );\n\n logger.debug(\n \"The events for following AWS Lambda functions will be forwarded locally: \",\n functionsList.list.map(fn => fn.name)\n );\n\n ui.emptyLine();\n const { default: exitHook } = await import(/* webpackChunkName: \"exit-hook\" */ \"exit-hook\");\n\n exitHook(() => {\n console.log();\n console.log();\n\n ui.info(`Terminating local AWS Lambda development session.`);\n ui.warning(\n `Note that once the session is terminated, the %s application will no longer work. To fix this, you %s redeploy it via the %s command. Learn more: %s.`,\n app?.getDisplayName(),\n \"MUST\",\n deployCommand,\n learnMoreLink\n );\n });\n\n const coreApp = this.getApp.execute(\"core\");\n const coreStackOutput =\n await this.pulumiGetStackOutputService.execute<ICoreStackOutput>(coreApp);\n\n if (!coreStackOutput) {\n throw new Error(\n `You must deploy the ${chalk.bold(\n \"core\"\n )} app before you can start a watch session. To do that, run: ${chalk.bold(\n `yarn webiny deploy core --env ${sdkParams.env}`\n )}`\n );\n }\n\n const deploymentId = coreStackOutput?.deploymentId;\n\n const iotEndpointTopic = `webiny-watch-${deploymentId}`;\n const iotEndpoint = await getIotEndpoint(coreStackOutput);\n\n const sessionId = new Date().getTime();\n const increaseTimeout = params.increaseTimeout;\n const localExecutionHandshakeTimeout = params.increaseHandshakeTimeout || 5; // Default to 5 seconds.\n\n // Ignore promise, we don't need to wait for this to finish.\n replaceLambdaFunctions({\n app,\n dependencies: {\n uiService: ui,\n loggerService: logger,\n pulumiExportService: this.pulumiExportService,\n watchedLambdaFunctionsService: this.watchedLambdaFunctionsService\n },\n iotEndpoint,\n iotEndpointTopic,\n sessionId,\n functionsList,\n increaseTimeout,\n localExecutionHandshakeTimeout\n });\n\n let inspector: typeof inspectorType | undefined = undefined;\n if (params.inspect) {\n inspector = await import(\"inspector\");\n inspector!.open(9229, \"127.0.0.1\");\n ui.emptyLine();\n\n exitHook(() => {\n inspector!.close();\n });\n }\n\n // Ignore promise, we don't need to wait for this to finish.\n initInvocationForwarding({\n iotEndpoint,\n iotEndpointTopic,\n functionsList,\n sessionId\n });\n\n return { packagesWatcher };\n }\n}\n\nexport const watch = createImplementation({\n abstraction: Watch,\n implementation: DefaultWatch,\n dependencies: [\n GetApp,\n LoggerService,\n ListAppLambdaFunctionsService,\n ListPackagesService,\n GetProject,\n GetProjectConfigService,\n ValidateProjectConfigService,\n GetProductionEnvironments,\n UiService,\n PulumiGetStackOutputService,\n PulumiExportService,\n WatchedLambdaFunctionsService,\n BuildAppWorkspaceService,\n ProjectSdkParamsService\n ]\n});\n"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,YAAY;AACjD,SACIC,wBAAwB,EACxBC,6BAA6B,EAC7BC,MAAM,EACNC,yBAAyB,EACzBC,UAAU,EACVC,uBAAuB,EACvBC,6BAA6B,EAC7BC,mBAAmB,EACnBC,aAAa,EACbC,uBAAuB,EACvBC,mBAAmB,EACnBC,2BAA2B,EAC3BC,SAAS,EACTC,4BAA4B,EAC5BC,KAAK;AAET,OAAOC,KAAK,MAAM,OAAO;AAEzB,SAASC,eAAe;AACxB,SAASC,mBAAmB;AAE5B,SAASC,cAAc;AACvB,SAASC,sBAAsB;AAC/B,SAASC,wBAAwB;AAEjC,OAAO,MAAMC,YAAY,CAA4B;EACjDC,WAAWA,CACCC,MAAwB,EACxBC,MAA+B,EAC/BC,6BAAsE,EACtEC,mBAAkD,EAClDC,UAAgC,EAChCC,uBAA0D,EAC1DC,4BAAoE,EACpEC,yBAA8D,EAC9DC,EAAuB,EACvBC,2BAAkE,EAClEC,mBAAkD,EAClDC,6BAAsE,EACtEC,wBAA4D,EAC5DC,uBAA0D,EACpE;IAAA,K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AmB;QAC7CC,6BAA6B,EAAE,IAAI,CAACA;MACxC,CAAC;MACD0E,WAAW;MACXD,gBAAgB;MAChBE,SAAS;MACT3B,aAAa;MACbxB,eAAe;MACfsD;IACJ,CAAC,CAAC;IAEF,IAAIK,SAA2C,GAAGC,SAAS;IAC3D,IAAIhF,MAAM,CAACiF,OAAO,EAAE;MAChBF,SAAS,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC;MACrCA,SAAS,CAAEG,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC;MAClCzF,EAAE,CAACmE,SAAS,CAAC,CAAC;MAEdE,QAAQ,CAAC,MAAM;QACXiB,SAAS,CAAEI,KAAK,CAAC,CAAC;MACtB,CAAC,CAAC;IACN;;IAEA;IACArG,wBAAwB,CAAC;MACrBwF,WAAW;MACXD,gBAAgB;MAChBzB,aAAa;MACb2B;IACJ,CAAC,CAAC;IAEF,OAAO;MAAE5D;IAAgB,CAAC;EAC9B;AACJ;AAEA,OAAO,MAAMyE,KAAK,GAAG3H,oBAAoB,CAAC;EACtC4H,WAAW,EAAE7G,KAAK;EAClB8G,cAAc,EAAEvG,YAAY;EAC5B6F,YAAY,EAAE,CACVhH,MAAM,EACNM,aAAa,EACbF,6BAA6B,EAC7BC,mBAAmB,EACnBH,UAAU,EACVC,uBAAuB,EACvBQ,4BAA4B,EAC5BV,yBAAyB,EACzBS,SAAS,EACTD,2BAA2B,EAC3BD,mBAAmB,EACnBT,6BAA6B,EAC7BD,wBAAwB,EACxBS,uBAAuB;AAE/B,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["createImplementation","BuildAppWorkspaceService","WatchedLambdaFunctionsService","GetApp","GetProductionEnvironments","GetProject","GetProjectConfigService","ListAppLambdaFunctionsService","ListPackagesService","LoggerService","ProjectSdkParamsService","PulumiExportService","PulumiGetStackOutputService","UiService","ValidateProjectConfigService","Watch","chalk","PackagesWatcher","WebinyConfigWatcher","getIotEndpoint","replaceLambdaFunctions","initInvocationForwarding","DefaultWatch","constructor","getApp","logger","listAppLambdaFunctionsService","listPackagesService","getProject","getProjectConfigService","validateProjectConfigService","getProductionEnvironments","ui","pulumiGetStackOutputService","pulumiExportService","watchedLambdaFunctionsService","buildAppWorkspaceService","projectSdkParamsService","execute","params","hasAppOrPackage","Error","whitelistArray","Array","isArray","package","filter","Boolean","packages","packageWhitelist","packagesWatcher","app","sdkParams","get","env","productionEnvironments","includes","allowProduction","red","increaseTimeout","forceRebuild","project","projectConfig","tags","appName","runtimeContext","renderArgs","extensionType","config","oneOrMoreExtensions","extensionsArray","extensionInstance","build","webinyConfigWatcher","webinyConfigPath","paths","webinyConfigFile","toString","packagesWhitelist","functionsWhitelist","function","packagesList","name","functionsList","whitelist","deployCommand","learnMoreLink","troubleshootingLink","meta","count","totalCount","info","join","warning","getDisplayName","debug","list","map","fn","emptyLine","default","exitHook","console","log","coreApp","coreStackOutput","bold","deploymentId","iotEndpointTopic","iotEndpoint","sessionId","Date","getTime","localExecutionHandshakeTimeout","increaseHandshakeTimeout","dependencies","uiService","loggerService","inspector","undefined","inspect","open","close","watch","abstraction","implementation"],"sources":["Watch.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport {\n BuildAppWorkspaceService,\n WatchedLambdaFunctionsService,\n GetApp,\n GetProductionEnvironments,\n GetProject,\n GetProjectConfigService,\n ListAppLambdaFunctionsService,\n ListPackagesService,\n LoggerService,\n ProjectSdkParamsService,\n PulumiExportService,\n PulumiGetStackOutputService,\n UiService,\n ValidateProjectConfigService,\n Watch\n} from \"~/abstractions/index.js\";\nimport chalk from \"chalk\";\nimport type inspectorType from \"inspector\";\nimport { PackagesWatcher } from \"./watchers/PackagesWatcher.js\";\nimport { WebinyConfigWatcher } from \"~/features/Watch/watchers/WebinyConfigWatcher.js\";\nimport { type ICoreStackOutput } from \"~/abstractions/features/GetAppStackOutput.js\";\nimport { getIotEndpoint } from \"./getIotEndpoint.js\";\nimport { replaceLambdaFunctions } from \"~/features/Watch/replaceLambdaFunctions.js\";\nimport { initInvocationForwarding } from \"./initInvocationForwarding.js\";\n\nexport class DefaultWatch implements Watch.Interface {\n constructor(\n private getApp: GetApp.Interface,\n private logger: LoggerService.Interface,\n private listAppLambdaFunctionsService: ListAppLambdaFunctionsService.Interface,\n private listPackagesService: ListPackagesService.Interface,\n private getProject: GetProject.Interface,\n private getProjectConfigService: GetProjectConfigService.Interface,\n private validateProjectConfigService: ValidateProjectConfigService.Interface,\n private getProductionEnvironments: GetProductionEnvironments.Interface,\n private ui: UiService.Interface,\n private pulumiGetStackOutputService: PulumiGetStackOutputService.Interface,\n private pulumiExportService: PulumiExportService.Interface,\n private watchedLambdaFunctionsService: WatchedLambdaFunctionsService.Interface,\n private buildAppWorkspaceService: BuildAppWorkspaceService.Interface,\n private projectSdkParamsService: ProjectSdkParamsService.Interface\n ) {}\n\n async execute(params: Watch.Params) {\n const hasAppOrPackage = \"app\" in params || \"package\" in params;\n if (!hasAppOrPackage) {\n throw new Error(\n `Either \"app\" or \"package\" arguments must be passed. Cannot have both undefined.`\n );\n }\n\n // If we're not watching a specific app, we can only watch packages.\n if (!(\"app\" in params)) {\n const whitelistArray = Array.isArray(params.package)\n ? params.package\n : ([params.package].filter(Boolean) as string[]);\n\n const packages = await this.listPackagesService.execute({\n packageWhitelist: whitelistArray\n });\n\n const packagesWatcher = new PackagesWatcher({ packages, params, logger: this.logger });\n\n return { packagesWatcher };\n }\n\n // Get project application metadata. Will throw an error if an invalid folder is specified.\n const app = this.getApp.execute(params.app);\n\n if (!app) {\n throw new Error(\n `Invalid app name \"${params.app}\". Please specify a valid app name (core, api, or admin).`\n );\n }\n\n const sdkParams = this.projectSdkParamsService.get();\n\n if (!sdkParams.env) {\n throw new Error(`Please specify environment, for example \"dev\".`);\n }\n\n const productionEnvironments = await this.getProductionEnvironments.execute();\n\n if (productionEnvironments.includes(sdkParams.env)) {\n if (!params.allowProduction) {\n throw new Error(\n `${chalk.red(\n \"webiny watch\"\n )} command cannot be used with production environments.`\n );\n }\n }\n\n // A maximum of 15 minutes in seconds can be passed.\n if (params.increaseTimeout && params.increaseTimeout > 900) {\n throw new Error(\n `When increasing the timeout, the maximum value that can be passed is 900 seconds (15 minutes).`\n );\n }\n\n await this.buildAppWorkspaceService.execute(params.app, { forceRebuild: true });\n\n const ui = this.ui;\n const logger = this.logger;\n const project = this.getProject.execute();\n const getProjectConfigService = this.getProjectConfigService;\n const validateProjectConfigService = this.validateProjectConfigService;\n\n const projectConfig = await getProjectConfigService.execute({\n tags: { appName: params.app, runtimeContext: \"app-build\" },\n renderArgs: params\n });\n\n await validateProjectConfigService.execute(projectConfig);\n\n for (const extensionType in projectConfig.config) {\n const oneOrMoreExtensions = projectConfig.config[extensionType];\n const extensionsArray = Array.isArray(oneOrMoreExtensions)\n ? [...oneOrMoreExtensions]\n : [oneOrMoreExtensions];\n\n for (const extensionInstance of extensionsArray) {\n await extensionInstance.build();\n }\n }\n\n const webinyConfigWatcher = new WebinyConfigWatcher({\n webinyConfigPath: project.paths.webinyConfigFile.toString(),\n appName: params.app,\n getProjectConfigService,\n validateProjectConfigService\n });\n\n const packagesWhitelist = Array.isArray(params.package)\n ? params.package\n : ([params.package].filter(Boolean) as string[]);\n\n const functionsWhitelist = Array.isArray(params.function)\n ? params.function\n : ([params.function].filter(Boolean) as string[]);\n\n const packagesList = await this.listPackagesService.execute({\n appName: app.name,\n packageWhitelist: packagesWhitelist\n });\n\n const packagesWatcher = new PackagesWatcher({\n packages: packagesList,\n params,\n logger\n });\n\n const functionsList = await this.listAppLambdaFunctionsService.execute(app, {\n whitelist: functionsWhitelist\n });\n\n const deployCommand = `yarn webiny deploy ${app.name} --env ${sdkParams.env}`;\n const learnMoreLink = \"https://webiny.link/local-aws-lambda-development\";\n const troubleshootingLink = learnMoreLink + \"#troubleshooting\";\n\n if (functionsList.meta.count === 0) {\n // If functions exist, but none are selected for watching, show a warning.\n if (functionsList.meta.totalCount > 0) {\n ui.info(\n [\n \"No AWS Lambda functions will be invoked locally. If this is unexpected, you can try the following:\",\n \" ‣ stop the current development session\",\n \" ‣ redeploy the %s application by running %s command\",\n \" ‣ start a new %s session by rerunning %s command\",\n \"\",\n \"Learn more: %s\"\n ].join(\"\\n\"),\n app.name,\n deployCommand,\n \"webiny watch\",\n \"webiny watch\",\n troubleshootingLink\n );\n }\n return { packagesWatcher, webinyConfigWatcher };\n }\n\n ui.info(`Local AWS Lambda development session started.`);\n ui.warning(\n `Note that once the session is terminated, the %s application will no longer work. To fix this, you %s redeploy it via the %s command. Learn more: %s.`,\n app.getDisplayName(),\n \"MUST\",\n deployCommand,\n learnMoreLink\n );\n\n logger.debug(\n \"The events for following AWS Lambda functions will be forwarded locally: \",\n functionsList.list.map(fn => fn.name)\n );\n\n ui.emptyLine();\n const { default: exitHook } = await import(/* webpackChunkName: \"exit-hook\" */ \"exit-hook\");\n\n exitHook(() => {\n console.log();\n console.log();\n\n ui.info(`Terminating local AWS Lambda development session.`);\n ui.warning(\n `Note that once the session is terminated, the %s application will no longer work. To fix this, you %s redeploy it via the %s command. Learn more: %s.`,\n app?.getDisplayName(),\n \"MUST\",\n deployCommand,\n learnMoreLink\n );\n });\n\n const coreApp = this.getApp.execute(\"core\");\n const coreStackOutput =\n await this.pulumiGetStackOutputService.execute<ICoreStackOutput>(coreApp);\n\n if (!coreStackOutput) {\n throw new Error(\n `You must deploy the ${chalk.bold(\n \"core\"\n )} app before you can start a watch session. To do that, run: ${chalk.bold(\n `yarn webiny deploy core --env ${sdkParams.env}`\n )}`\n );\n }\n\n const deploymentId = coreStackOutput?.deploymentId;\n\n const iotEndpointTopic = `webiny-watch-${deploymentId}`;\n const iotEndpoint = await getIotEndpoint(coreStackOutput);\n\n const sessionId = new Date().getTime();\n const increaseTimeout = params.increaseTimeout;\n const localExecutionHandshakeTimeout = params.increaseHandshakeTimeout || 5; // Default to 5 seconds.\n\n // Ignore promise, we don't need to wait for this to finish.\n replaceLambdaFunctions({\n app,\n deploymentId,\n dependencies: {\n uiService: ui,\n loggerService: logger,\n pulumiExportService: this.pulumiExportService,\n watchedLambdaFunctionsService: this.watchedLambdaFunctionsService\n },\n iotEndpoint,\n iotEndpointTopic,\n sessionId,\n functionsList,\n increaseTimeout,\n localExecutionHandshakeTimeout\n });\n\n let inspector: typeof inspectorType | undefined = undefined;\n if (params.inspect) {\n inspector = await import(\"inspector\");\n inspector!.open(9229, \"127.0.0.1\");\n ui.emptyLine();\n\n exitHook(() => {\n inspector!.close();\n });\n }\n\n // Ignore promise, we don't need to wait for this to finish.\n initInvocationForwarding({\n iotEndpoint,\n iotEndpointTopic,\n functionsList,\n sessionId\n });\n\n return { packagesWatcher };\n }\n}\n\nexport const watch = createImplementation({\n abstraction: Watch,\n implementation: DefaultWatch,\n dependencies: [\n GetApp,\n LoggerService,\n ListAppLambdaFunctionsService,\n ListPackagesService,\n GetProject,\n GetProjectConfigService,\n ValidateProjectConfigService,\n GetProductionEnvironments,\n UiService,\n PulumiGetStackOutputService,\n PulumiExportService,\n WatchedLambdaFunctionsService,\n BuildAppWorkspaceService,\n ProjectSdkParamsService\n ]\n});\n"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,YAAY;AACjD,SACIC,wBAAwB,EACxBC,6BAA6B,EAC7BC,MAAM,EACNC,yBAAyB,EACzBC,UAAU,EACVC,uBAAuB,EACvBC,6BAA6B,EAC7BC,mBAAmB,EACnBC,aAAa,EACbC,uBAAuB,EACvBC,mBAAmB,EACnBC,2BAA2B,EAC3BC,SAAS,EACTC,4BAA4B,EAC5BC,KAAK;AAET,OAAOC,KAAK,MAAM,OAAO;AAEzB,SAASC,eAAe;AACxB,SAASC,mBAAmB;AAE5B,SAASC,cAAc;AACvB,SAASC,sBAAsB;AAC/B,SAASC,wBAAwB;AAEjC,OAAO,MAAMC,YAAY,CAA4B;EACjDC,WAAWA,CACCC,MAAwB,EACxBC,MAA+B,EAC/BC,6BAAsE,EACtEC,mBAAkD,EAClDC,UAAgC,EAChCC,uBAA0D,EAC1DC,4BAAoE,EACpEC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,GAAG;MACHwD,YAAY;MACZQ,YAAY,EAAE;QACVC,SAAS,EAAEpF,EAAE;QACbqF,aAAa,EAAE5F,MAAM;QACrBS,mBAAmB,EAAE,IAAI,CAACA,mBAAmB;QAC7CC,6BAA6B,EAAE,IAAI,CAACA;MACxC,CAAC;MACD0E,WAAW;MACXD,gBAAgB;MAChBE,SAAS;MACT3B,aAAa;MACbxB,eAAe;MACfsD;IACJ,CAAC,CAAC;IAEF,IAAIK,SAA2C,GAAGC,SAAS;IAC3D,IAAIhF,MAAM,CAACiF,OAAO,EAAE;MAChBF,SAAS,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC;MACrCA,SAAS,CAAEG,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC;MAClCzF,EAAE,CAACmE,SAAS,CAAC,CAAC;MAEdE,QAAQ,CAAC,MAAM;QACXiB,SAAS,CAAEI,KAAK,CAAC,CAAC;MACtB,CAAC,CAAC;IACN;;IAEA;IACArG,wBAAwB,CAAC;MACrBwF,WAAW;MACXD,gBAAgB;MAChBzB,aAAa;MACb2B;IACJ,CAAC,CAAC;IAEF,OAAO;MAAE5D;IAAgB,CAAC;EAC9B;AACJ;AAEA,OAAO,MAAMyE,KAAK,GAAG3H,oBAAoB,CAAC;EACtC4H,WAAW,EAAE7G,KAAK;EAClB8G,cAAc,EAAEvG,YAAY;EAC5B6F,YAAY,EAAE,CACVhH,MAAM,EACNM,aAAa,EACbF,6BAA6B,EAC7BC,mBAAmB,EACnBH,UAAU,EACVC,uBAAuB,EACvBQ,4BAA4B,EAC5BV,yBAAyB,EACzBS,SAAS,EACTD,2BAA2B,EAC3BD,mBAAmB,EACnBT,6BAA6B,EAC7BD,wBAAwB,EACxBS,uBAAuB;AAE/B,CAAC,CAAC","ignoreList":[]}
|
|
@@ -2,6 +2,7 @@ import { type ListAppLambdaFunctionsService, type LoggerService, type PulumiExpo
|
|
|
2
2
|
import { type AppModel } from "../../models/index.js";
|
|
3
3
|
export interface IReplaceLambdaFunctionsParams {
|
|
4
4
|
app: AppModel;
|
|
5
|
+
deploymentId: string | undefined;
|
|
5
6
|
iotEndpoint: string;
|
|
6
7
|
iotEndpointTopic: string;
|
|
7
8
|
sessionId: number;
|
|
@@ -15,4 +16,4 @@ export interface IReplaceLambdaFunctionsParams {
|
|
|
15
16
|
watchedLambdaFunctionsService: WatchedLambdaFunctionsService.Interface;
|
|
16
17
|
};
|
|
17
18
|
}
|
|
18
|
-
export declare const replaceLambdaFunctions: ({ app, iotEndpoint, iotEndpointTopic, sessionId, functionsList, increaseTimeout, localExecutionHandshakeTimeout, dependencies }: IReplaceLambdaFunctionsParams) => Promise<void[]>;
|
|
19
|
+
export declare const replaceLambdaFunctions: ({ app, deploymentId, iotEndpoint, iotEndpointTopic, sessionId, functionsList, increaseTimeout, localExecutionHandshakeTimeout, dependencies }: IReplaceLambdaFunctionsParams) => Promise<void[]>;
|
|
@@ -5,6 +5,7 @@ const WATCH_MODE_NOTE_IN_DESCRIPTION = " (💡 local development mode, redeploy
|
|
|
5
5
|
const DEFAULT_INCREASE_TIMEOUT = 120;
|
|
6
6
|
export const replaceLambdaFunctions = async ({
|
|
7
7
|
app,
|
|
8
|
+
deploymentId,
|
|
8
9
|
iotEndpoint,
|
|
9
10
|
iotEndpointTopic,
|
|
10
11
|
sessionId,
|
|
@@ -43,7 +44,10 @@ export const replaceLambdaFunctions = async ({
|
|
|
43
44
|
|
|
44
45
|
// Mark these functions as needing replacement on next deployment
|
|
45
46
|
if (replacedFunctionUrns.length > 0) {
|
|
46
|
-
watchedLambdaFunctionsService.markDirty(
|
|
47
|
+
watchedLambdaFunctionsService.markDirty({
|
|
48
|
+
name: app.name,
|
|
49
|
+
deploymentId
|
|
50
|
+
}, replacedFunctionUrns);
|
|
47
51
|
logger.info(`Marked ${replacedFunctionUrns.length} Lambda function(s) for replacement on next deployment.`);
|
|
48
52
|
}
|
|
49
53
|
logger.info("replacing %s AWS Lambda function(s).", functionsList.meta.count);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["fs","pRetry","GetFunctionConfigurationCommand","LambdaClient","UpdateFunctionCodeCommand","UpdateFunctionConfigurationCommand","WATCH_MODE_NOTE_IN_DESCRIPTION","DEFAULT_INCREASE_TIMEOUT","replaceLambdaFunctions","app","iotEndpoint","iotEndpointTopic","sessionId","functionsList","increaseTimeout","localExecutionHandshakeTimeout","dependencies","loggerService","logger","pulumiExportService","exportStackState","watchedLambdaFunctionsService","stackExport","execute","info","functionNamesToUpdate","list","map","fn","name","replacedFunctionUrns","deployment","resources","resource","type","functionName","inputs","includes","push","urn","debug","length","markDirty","meta","count","lambdaClient","replacementsPromises","getFnConfigCmd","FunctionName","lambdaFnConfiguration","send","updateFnCodeCmd","ZipFile","readFileSync","import","dirname","Description","endsWith","Timeout","Environment","Variables","WEBINY_WATCH","JSON","stringify","enabled","Promise","all","then","res"],"sources":["replaceLambdaFunctions.ts"],"sourcesContent":["import fs from \"fs\";\nimport pRetry from \"p-retry\";\nimport {\n GetFunctionConfigurationCommand,\n LambdaClient,\n UpdateFunctionCodeCommand,\n UpdateFunctionConfigurationCommand\n} from \"@webiny/aws-sdk/client-lambda/index.js\";\nimport {\n type ListAppLambdaFunctionsService,\n type LoggerService,\n type PulumiExportService,\n type WatchedLambdaFunctionsService,\n type UiService\n} from \"~/abstractions/index.js\";\nimport { type AppModel } from \"~/models/index.js\";\n\nconst WATCH_MODE_NOTE_IN_DESCRIPTION = \" (💡 local development mode, redeploy to remove)\";\nconst DEFAULT_INCREASE_TIMEOUT = 120;\n\nexport interface IReplaceLambdaFunctionsParams {\n app: AppModel;\n iotEndpoint: string;\n iotEndpointTopic: string;\n sessionId: number;\n functionsList: ListAppLambdaFunctionsService.Result;\n increaseTimeout?: number;\n localExecutionHandshakeTimeout?: number;\n dependencies: {\n uiService: UiService.Interface;\n loggerService: LoggerService.Interface;\n pulumiExportService: PulumiExportService.Interface;\n watchedLambdaFunctionsService: WatchedLambdaFunctionsService.Interface;\n };\n}\n\nexport const replaceLambdaFunctions = async ({\n app,\n iotEndpoint,\n iotEndpointTopic,\n sessionId,\n functionsList,\n increaseTimeout,\n localExecutionHandshakeTimeout,\n dependencies\n}: IReplaceLambdaFunctionsParams) => {\n const {\n loggerService: logger,\n pulumiExportService: exportStackState,\n watchedLambdaFunctionsService\n } = dependencies;\n\n const stackExport = await exportStackState.execute(app);\n if (!stackExport) {\n // If no stack export is found, return an empty array. This is a valid scenario.\n // For example, watching the Admin app locally, but not deploying it.\n logger.info(\"No AWS Lambda functions to replace.\");\n return [];\n }\n\n // Find the URNs of Lambda functions that will be replaced\n const functionNamesToUpdate = functionsList.list.map(fn => fn.name);\n const replacedFunctionUrns: string[] = [];\n\n if (stackExport.deployment?.resources) {\n for (const resource of stackExport.deployment.resources) {\n if (resource.type === \"aws:lambda/function:Function\") {\n const functionName = resource.inputs?.name;\n if (functionName && functionNamesToUpdate.includes(functionName)) {\n replacedFunctionUrns.push(resource.urn);\n logger.debug(`Will replace Lambda function: ${functionName} (${resource.urn})`);\n }\n }\n }\n }\n\n // Mark these functions as needing replacement on next deployment\n if (replacedFunctionUrns.length > 0) {\n watchedLambdaFunctionsService.markDirty(app.name, replacedFunctionUrns);\n logger.info(\n `Marked ${replacedFunctionUrns.length} Lambda function(s) for replacement on next deployment.`\n );\n }\n\n logger.info(\"replacing %s AWS Lambda function(s).\", functionsList.meta.count);\n const lambdaClient = new LambdaClient();\n\n const replacementsPromises = functionsList.list.map(async fn => {\n const getFnConfigCmd = new GetFunctionConfigurationCommand({ FunctionName: fn.name });\n const lambdaFnConfiguration = await lambdaClient.send(getFnConfigCmd);\n\n const updateFnCodeCmd = new UpdateFunctionCodeCommand({\n FunctionName: fn.name,\n ZipFile: fs.readFileSync(import.meta.dirname + \"/handler/handler.zip\")\n });\n\n await lambdaClient.send(updateFnCodeCmd);\n\n let Description = lambdaFnConfiguration.Description || \"\";\n if (!Description.endsWith(WATCH_MODE_NOTE_IN_DESCRIPTION)) {\n Description += WATCH_MODE_NOTE_IN_DESCRIPTION;\n }\n\n const Timeout = increaseTimeout || DEFAULT_INCREASE_TIMEOUT;\n\n await pRetry(() =>\n lambdaClient.send(\n new UpdateFunctionConfigurationCommand({\n FunctionName: fn.name,\n Timeout,\n Description,\n Environment: {\n Variables: {\n ...lambdaFnConfiguration.Environment?.Variables,\n WEBINY_WATCH: JSON.stringify({\n enabled: true,\n localExecutionHandshakeTimeout,\n sessionId,\n iotEndpoint,\n iotEndpointTopic,\n functionName: fn.name\n })\n }\n }\n })\n )\n );\n });\n\n return Promise.all(replacementsPromises).then(res => {\n logger.info(\"%s AWS Lambda function(s) replaced.\", functionsList.meta.count);\n return res;\n });\n};\n"],"mappings":"AAAA,OAAOA,EAAE,MAAM,IAAI;AACnB,OAAOC,MAAM,MAAM,SAAS;AAC5B,SACIC,+BAA+B,EAC/BC,YAAY,EACZC,yBAAyB,EACzBC,kCAAkC,QAC/B,wCAAwC;AAU/C,MAAMC,8BAA8B,GAAG,kDAAkD;AACzF,MAAMC,wBAAwB,GAAG,GAAG;
|
|
1
|
+
{"version":3,"names":["fs","pRetry","GetFunctionConfigurationCommand","LambdaClient","UpdateFunctionCodeCommand","UpdateFunctionConfigurationCommand","WATCH_MODE_NOTE_IN_DESCRIPTION","DEFAULT_INCREASE_TIMEOUT","replaceLambdaFunctions","app","deploymentId","iotEndpoint","iotEndpointTopic","sessionId","functionsList","increaseTimeout","localExecutionHandshakeTimeout","dependencies","loggerService","logger","pulumiExportService","exportStackState","watchedLambdaFunctionsService","stackExport","execute","info","functionNamesToUpdate","list","map","fn","name","replacedFunctionUrns","deployment","resources","resource","type","functionName","inputs","includes","push","urn","debug","length","markDirty","meta","count","lambdaClient","replacementsPromises","getFnConfigCmd","FunctionName","lambdaFnConfiguration","send","updateFnCodeCmd","ZipFile","readFileSync","import","dirname","Description","endsWith","Timeout","Environment","Variables","WEBINY_WATCH","JSON","stringify","enabled","Promise","all","then","res"],"sources":["replaceLambdaFunctions.ts"],"sourcesContent":["import fs from \"fs\";\nimport pRetry from \"p-retry\";\nimport {\n GetFunctionConfigurationCommand,\n LambdaClient,\n UpdateFunctionCodeCommand,\n UpdateFunctionConfigurationCommand\n} from \"@webiny/aws-sdk/client-lambda/index.js\";\nimport {\n type ListAppLambdaFunctionsService,\n type LoggerService,\n type PulumiExportService,\n type WatchedLambdaFunctionsService,\n type UiService\n} from \"~/abstractions/index.js\";\nimport { type AppModel } from \"~/models/index.js\";\n\nconst WATCH_MODE_NOTE_IN_DESCRIPTION = \" (💡 local development mode, redeploy to remove)\";\nconst DEFAULT_INCREASE_TIMEOUT = 120;\n\nexport interface IReplaceLambdaFunctionsParams {\n app: AppModel;\n deploymentId: string | undefined;\n iotEndpoint: string;\n iotEndpointTopic: string;\n sessionId: number;\n functionsList: ListAppLambdaFunctionsService.Result;\n increaseTimeout?: number;\n localExecutionHandshakeTimeout?: number;\n dependencies: {\n uiService: UiService.Interface;\n loggerService: LoggerService.Interface;\n pulumiExportService: PulumiExportService.Interface;\n watchedLambdaFunctionsService: WatchedLambdaFunctionsService.Interface;\n };\n}\n\nexport const replaceLambdaFunctions = async ({\n app,\n deploymentId,\n iotEndpoint,\n iotEndpointTopic,\n sessionId,\n functionsList,\n increaseTimeout,\n localExecutionHandshakeTimeout,\n dependencies\n}: IReplaceLambdaFunctionsParams) => {\n const {\n loggerService: logger,\n pulumiExportService: exportStackState,\n watchedLambdaFunctionsService\n } = dependencies;\n\n const stackExport = await exportStackState.execute(app);\n if (!stackExport) {\n // If no stack export is found, return an empty array. This is a valid scenario.\n // For example, watching the Admin app locally, but not deploying it.\n logger.info(\"No AWS Lambda functions to replace.\");\n return [];\n }\n\n // Find the URNs of Lambda functions that will be replaced\n const functionNamesToUpdate = functionsList.list.map(fn => fn.name);\n const replacedFunctionUrns: string[] = [];\n\n if (stackExport.deployment?.resources) {\n for (const resource of stackExport.deployment.resources) {\n if (resource.type === \"aws:lambda/function:Function\") {\n const functionName = resource.inputs?.name;\n if (functionName && functionNamesToUpdate.includes(functionName)) {\n replacedFunctionUrns.push(resource.urn);\n logger.debug(`Will replace Lambda function: ${functionName} (${resource.urn})`);\n }\n }\n }\n }\n\n // Mark these functions as needing replacement on next deployment\n if (replacedFunctionUrns.length > 0) {\n watchedLambdaFunctionsService.markDirty(\n { name: app.name, deploymentId },\n replacedFunctionUrns\n );\n logger.info(\n `Marked ${replacedFunctionUrns.length} Lambda function(s) for replacement on next deployment.`\n );\n }\n\n logger.info(\"replacing %s AWS Lambda function(s).\", functionsList.meta.count);\n const lambdaClient = new LambdaClient();\n\n const replacementsPromises = functionsList.list.map(async fn => {\n const getFnConfigCmd = new GetFunctionConfigurationCommand({ FunctionName: fn.name });\n const lambdaFnConfiguration = await lambdaClient.send(getFnConfigCmd);\n\n const updateFnCodeCmd = new UpdateFunctionCodeCommand({\n FunctionName: fn.name,\n ZipFile: fs.readFileSync(import.meta.dirname + \"/handler/handler.zip\")\n });\n\n await lambdaClient.send(updateFnCodeCmd);\n\n let Description = lambdaFnConfiguration.Description || \"\";\n if (!Description.endsWith(WATCH_MODE_NOTE_IN_DESCRIPTION)) {\n Description += WATCH_MODE_NOTE_IN_DESCRIPTION;\n }\n\n const Timeout = increaseTimeout || DEFAULT_INCREASE_TIMEOUT;\n\n await pRetry(() =>\n lambdaClient.send(\n new UpdateFunctionConfigurationCommand({\n FunctionName: fn.name,\n Timeout,\n Description,\n Environment: {\n Variables: {\n ...lambdaFnConfiguration.Environment?.Variables,\n WEBINY_WATCH: JSON.stringify({\n enabled: true,\n localExecutionHandshakeTimeout,\n sessionId,\n iotEndpoint,\n iotEndpointTopic,\n functionName: fn.name\n })\n }\n }\n })\n )\n );\n });\n\n return Promise.all(replacementsPromises).then(res => {\n logger.info(\"%s AWS Lambda function(s) replaced.\", functionsList.meta.count);\n return res;\n });\n};\n"],"mappings":"AAAA,OAAOA,EAAE,MAAM,IAAI;AACnB,OAAOC,MAAM,MAAM,SAAS;AAC5B,SACIC,+BAA+B,EAC/BC,YAAY,EACZC,yBAAyB,E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;QACTC,SAAS,EAAE;UACP,GAAGX,qBAAqB,CAACU,WAAW,EAAEC,SAAS;UAC/CC,YAAY,EAAEC,IAAI,CAACC,SAAS,CAAC;YACzBC,OAAO,EAAE,IAAI;YACbjD,8BAA8B;YAC9BH,SAAS;YACTF,WAAW;YACXC,gBAAgB;YAChBwB,YAAY,EAAEP,EAAE,CAACC;UACrB,CAAC;QACL;MACJ;IACJ,CAAC,CACL,CACJ,CAAC;EACL,CAAC,CAAC;EAEF,OAAOoC,OAAO,CAACC,GAAG,CAACpB,oBAAoB,CAAC,CAACqB,IAAI,CAACC,GAAG,IAAI;IACjDlD,MAAM,CAACM,IAAI,CAAC,qCAAqC,EAAEX,aAAa,CAAC8B,IAAI,CAACC,KAAK,CAAC;IAC5E,OAAOwB,GAAG;EACd,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/project",
|
|
3
|
-
"version": "6.0.0-rc.
|
|
3
|
+
"version": "6.0.0-rc.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -10,16 +10,16 @@
|
|
|
10
10
|
"description": "An SDK for managing Webiny projects.",
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@webiny/aws-sdk": "6.0.0-rc.
|
|
14
|
-
"@webiny/build-tools": "6.0.0-rc.
|
|
13
|
+
"@webiny/aws-sdk": "6.0.0-rc.2",
|
|
14
|
+
"@webiny/build-tools": "6.0.0-rc.2",
|
|
15
15
|
"@webiny/di": "0.2.3",
|
|
16
|
-
"@webiny/global-config": "6.0.0-rc.
|
|
17
|
-
"@webiny/pulumi-sdk": "6.0.0-rc.
|
|
18
|
-
"@webiny/react-properties": "6.0.0-rc.
|
|
19
|
-
"@webiny/system-requirements": "6.0.0-rc.
|
|
20
|
-
"@webiny/telemetry": "6.0.0-rc.
|
|
21
|
-
"@webiny/utils": "6.0.0-rc.
|
|
22
|
-
"@webiny/wcp": "6.0.0-rc.
|
|
16
|
+
"@webiny/global-config": "6.0.0-rc.2",
|
|
17
|
+
"@webiny/pulumi-sdk": "6.0.0-rc.2",
|
|
18
|
+
"@webiny/react-properties": "6.0.0-rc.2",
|
|
19
|
+
"@webiny/system-requirements": "6.0.0-rc.2",
|
|
20
|
+
"@webiny/telemetry": "6.0.0-rc.2",
|
|
21
|
+
"@webiny/utils": "6.0.0-rc.2",
|
|
22
|
+
"@webiny/wcp": "6.0.0-rc.2",
|
|
23
23
|
"chalk": "4.1.2",
|
|
24
24
|
"chokidar": "4.0.3",
|
|
25
25
|
"ci-info": "4.4.0",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"humanize-duration": "3.33.2",
|
|
36
36
|
"load-json-file": "7.0.1",
|
|
37
37
|
"lodash": "4.17.23",
|
|
38
|
-
"minimatch": "10.2.
|
|
38
|
+
"minimatch": "10.2.4",
|
|
39
39
|
"mqtt": "5.15.0",
|
|
40
40
|
"neverthrow": "8.2.0",
|
|
41
41
|
"p-retry": "7.1.1",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/debounce": "1.2.4",
|
|
56
56
|
"@types/humanize-duration": "3.27.4",
|
|
57
|
-
"@types/lodash": "4.17.
|
|
57
|
+
"@types/lodash": "4.17.24",
|
|
58
58
|
"@types/react-test-renderer": "18.3.1",
|
|
59
59
|
"@types/read-json-sync": "2.0.3",
|
|
60
60
|
"rimraf": "6.1.3",
|
|
@@ -75,5 +75,5 @@
|
|
|
75
75
|
"access": "public",
|
|
76
76
|
"directory": "dist"
|
|
77
77
|
},
|
|
78
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "5facada4cbb8617cc60e3c98be0f1839f44be38e"
|
|
79
79
|
}
|
|
@@ -11,7 +11,7 @@ class DefaultSetProjectIdService {
|
|
|
11
11
|
const tsMorphProject = new TsMorphProject();
|
|
12
12
|
const sourceFile = tsMorphProject.addSourceFileAtPath(webinyConfigFileTsx);
|
|
13
13
|
|
|
14
|
-
// Ensure import { Project } from "webiny/extensions"
|
|
14
|
+
// Ensure import { Project } from "webiny/extensions".
|
|
15
15
|
const hasProjectImport = sourceFile.getImportDeclarations().some(decl => decl.getModuleSpecifierValue() === "webiny/extensions" && decl.getNamedImports().some(imp => imp.getName() === "Project"));
|
|
16
16
|
if (!hasProjectImport) {
|
|
17
17
|
sourceFile.insertImportDeclaration(0, {
|
|
@@ -19,31 +19,41 @@ class DefaultSetProjectIdService {
|
|
|
19
19
|
moduleSpecifier: "webiny/extensions"
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
// Find <Webiny />
|
|
24
22
|
const jsxElements = sourceFile.getDescendantsOfKind(SyntaxKind.JsxSelfClosingElement);
|
|
25
|
-
const webinyEl = jsxElements.find(el => el.getTagNameNode().getText() === "Webiny");
|
|
26
|
-
if (!webinyEl) {
|
|
27
|
-
throw new Error(`Could not find <Webiny /> in ${webinyConfigFileTsx}`);
|
|
28
|
-
}
|
|
29
23
|
|
|
30
|
-
// Check for <Project.Id
|
|
31
|
-
const
|
|
32
|
-
if (
|
|
24
|
+
// Check for existing <Project.Id />.
|
|
25
|
+
const existingProjectIdEl = jsxElements.find(el => el.getTagNameNode().getText() === "Project.Id");
|
|
26
|
+
if (existingProjectIdEl) {
|
|
33
27
|
if (options.force !== true) {
|
|
34
28
|
throw new Error("Project.Id already exists in the file.");
|
|
29
|
+
}
|
|
30
|
+
// Update the id attribute in-place.
|
|
31
|
+
const idAttr = existingProjectIdEl.getAttributes().find(attr => attr.getFirstChildByKind(SyntaxKind.Identifier)?.getText() === "id");
|
|
32
|
+
if (idAttr) {
|
|
33
|
+
idAttr.replaceWithText(`id={"${id}"}`);
|
|
35
34
|
} else {
|
|
36
|
-
|
|
37
|
-
const projectIdEl = jsxElements.find(el => el.getTagNameNode().getText() === "Project.Id");
|
|
38
|
-
if (projectIdEl) {
|
|
39
|
-
projectIdEl.replaceWithText("");
|
|
40
|
-
}
|
|
35
|
+
existingProjectIdEl.replaceWithText(`<Project.Id id={"${id}"} />`);
|
|
41
36
|
}
|
|
37
|
+
await sourceFile.save();
|
|
38
|
+
return;
|
|
42
39
|
}
|
|
43
40
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
/* Determine the insertion point — after the last <Project.*> element that is a
|
|
42
|
+
direct child of the outermost JSX fragment (i.e. not inside a conditional expression).
|
|
43
|
+
Fall back to inserting after the opening tag of the outermost JSX fragment. */
|
|
44
|
+
const fragment = sourceFile.getFirstDescendantByKind(SyntaxKind.JsxFragment);
|
|
45
|
+
const projectEls = jsxElements.filter(el => el.getTagNameNode().getText().startsWith("Project.") && el.getParent()?.getParent() === fragment);
|
|
46
|
+
if (projectEls.length > 0) {
|
|
47
|
+
const lastProjectEl = projectEls[projectEls.length - 1];
|
|
48
|
+
sourceFile.insertText(lastProjectEl.getEnd(), `\n <Project.Id id={"${id}"} />`);
|
|
49
|
+
} else {
|
|
50
|
+
// Fallback: insert as first child of the outermost JSX fragment.
|
|
51
|
+
if (!fragment) {
|
|
52
|
+
throw new Error(`Could not find a JSX fragment or <Project.*> element to anchor <Project.Id /> in ${webinyConfigFileTsx}`);
|
|
53
|
+
}
|
|
54
|
+
const openingFragment = fragment.getOpeningFragment();
|
|
55
|
+
sourceFile.insertText(openingFragment.getEnd(), `\n <Project.Id id={"${id}"} />`);
|
|
56
|
+
}
|
|
47
57
|
await sourceFile.save();
|
|
48
58
|
}
|
|
49
59
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createImplementation","GetProjectService","SetProjectIdService","Project","TsMorphProject","SyntaxKind","DefaultSetProjectIdService","constructor","getProjectService","execute","id","options","project","webinyConfigFileTsx","paths","webinyConfigFile","toString","tsMorphProject","sourceFile","addSourceFileAtPath","hasProjectImport","getImportDeclarations","some","decl","getModuleSpecifierValue","getNamedImports","imp","getName","insertImportDeclaration","namedImports","moduleSpecifier","jsxElements","getDescendantsOfKind","JsxSelfClosingElement","
|
|
1
|
+
{"version":3,"names":["createImplementation","GetProjectService","SetProjectIdService","Project","TsMorphProject","SyntaxKind","DefaultSetProjectIdService","constructor","getProjectService","execute","id","options","project","webinyConfigFileTsx","paths","webinyConfigFile","toString","tsMorphProject","sourceFile","addSourceFileAtPath","hasProjectImport","getImportDeclarations","some","decl","getModuleSpecifierValue","getNamedImports","imp","getName","insertImportDeclaration","namedImports","moduleSpecifier","jsxElements","getDescendantsOfKind","JsxSelfClosingElement","existingProjectIdEl","find","el","getTagNameNode","getText","force","Error","idAttr","getAttributes","attr","getFirstChildByKind","Identifier","replaceWithText","save","fragment","getFirstDescendantByKind","JsxFragment","projectEls","filter","startsWith","getParent","length","lastProjectEl","insertText","getEnd","openingFragment","getOpeningFragment","setProjectIdService","abstraction","implementation","dependencies"],"sources":["SetProjectIdService.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport { GetProjectService, SetProjectIdService } from \"~/abstractions/index.js\";\nimport { Project as TsMorphProject, SyntaxKind } from \"ts-morph\";\n\nclass DefaultSetProjectIdService implements SetProjectIdService.Interface {\n constructor(private getProjectService: GetProjectService.Interface) {}\n\n async execute(id: string, options: SetProjectIdService.Options = {}) {\n const project = this.getProjectService.execute();\n const webinyConfigFileTsx = project.paths.webinyConfigFile.toString();\n\n const tsMorphProject = new TsMorphProject();\n const sourceFile = tsMorphProject.addSourceFileAtPath(webinyConfigFileTsx);\n\n // Ensure import { Project } from \"webiny/extensions\".\n const hasProjectImport = sourceFile\n .getImportDeclarations()\n .some(\n decl =>\n decl.getModuleSpecifierValue() === \"webiny/extensions\" &&\n decl.getNamedImports().some(imp => imp.getName() === \"Project\")\n );\n if (!hasProjectImport) {\n sourceFile.insertImportDeclaration(0, {\n namedImports: [\"Project\"],\n moduleSpecifier: \"webiny/extensions\"\n });\n }\n\n const jsxElements = sourceFile.getDescendantsOfKind(SyntaxKind.JsxSelfClosingElement);\n\n // Check for existing <Project.Id />.\n const existingProjectIdEl = jsxElements.find(\n el => el.getTagNameNode().getText() === \"Project.Id\"\n );\n if (existingProjectIdEl) {\n if (options.force !== true) {\n throw new Error(\"Project.Id already exists in the file.\");\n }\n // Update the id attribute in-place.\n const idAttr = existingProjectIdEl\n .getAttributes()\n .find(attr => attr.getFirstChildByKind(SyntaxKind.Identifier)?.getText() === \"id\");\n if (idAttr) {\n idAttr.replaceWithText(`id={\"${id}\"}`);\n } else {\n existingProjectIdEl.replaceWithText(`<Project.Id id={\"${id}\"} />`);\n }\n await sourceFile.save();\n return;\n }\n\n /* Determine the insertion point — after the last <Project.*> element that is a\n direct child of the outermost JSX fragment (i.e. not inside a conditional expression).\n Fall back to inserting after the opening tag of the outermost JSX fragment. */\n const fragment = sourceFile.getFirstDescendantByKind(SyntaxKind.JsxFragment);\n const projectEls = jsxElements.filter(\n el =>\n el.getTagNameNode().getText().startsWith(\"Project.\") &&\n el.getParent()?.getParent() === fragment\n );\n\n if (projectEls.length > 0) {\n const lastProjectEl = projectEls[projectEls.length - 1];\n sourceFile.insertText(\n lastProjectEl.getEnd(),\n `\\n <Project.Id id={\"${id}\"} />`\n );\n } else {\n // Fallback: insert as first child of the outermost JSX fragment.\n if (!fragment) {\n throw new Error(\n `Could not find a JSX fragment or <Project.*> element to anchor <Project.Id /> in ${webinyConfigFileTsx}`\n );\n }\n const openingFragment = fragment.getOpeningFragment();\n sourceFile.insertText(\n openingFragment.getEnd(),\n `\\n <Project.Id id={\"${id}\"} />`\n );\n }\n\n await sourceFile.save();\n }\n}\n\nexport const setProjectIdService = createImplementation({\n abstraction: SetProjectIdService,\n implementation: DefaultSetProjectIdService,\n dependencies: [GetProjectService]\n});\n"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,YAAY;AACjD,SAASC,iBAAiB,EAAEC,mBAAmB;AAC/C,SAASC,OAAO,IAAIC,cAAc,EAAEC,UAAU,QAAQ,UAAU;AAEhE,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,CAAC,EACxB,kCAAkChD,EAAE,OACxC,CAAC;IACL;IAEA,MAAMQ,UAAU,CAAC6B,IAAI,CAAC,CAAC;EAC3B;AACJ;AAEA,OAAO,MAAMc,mBAAmB,GAAG7D,oBAAoB,CAAC;EACpD8D,WAAW,EAAE5D,mBAAmB;EAChC6D,cAAc,EAAEzD,0BAA0B;EAC1C0D,YAAY,EAAE,CAAC/D,iBAAiB;AACpC,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { WatchedLambdaFunctionsService, LocalStorageService } from "../../abstractions/index.js";
|
|
2
|
-
import { type AppName } from "../../abstractions/types.js";
|
|
3
2
|
export declare class DefaultWatchedLambdaFunctionsService implements WatchedLambdaFunctionsService.Interface {
|
|
4
3
|
private localStorageService;
|
|
5
4
|
constructor(localStorageService: LocalStorageService.Interface);
|
|
6
|
-
markDirty(
|
|
7
|
-
getDirty(
|
|
8
|
-
clearDirty(
|
|
5
|
+
markDirty(params: WatchedLambdaFunctionsService.Params, functionUrns: string[]): void;
|
|
6
|
+
getDirty(params: WatchedLambdaFunctionsService.Params): string[];
|
|
7
|
+
clearDirty(params: WatchedLambdaFunctionsService.Params): void;
|
|
9
8
|
clearAll(): void;
|
|
9
|
+
private getCacheKey;
|
|
10
10
|
private getData;
|
|
11
11
|
private setData;
|
|
12
12
|
}
|
|
@@ -5,34 +5,40 @@ export class DefaultWatchedLambdaFunctionsService {
|
|
|
5
5
|
constructor(localStorageService) {
|
|
6
6
|
this.localStorageService = localStorageService;
|
|
7
7
|
}
|
|
8
|
-
markDirty(
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
markDirty(params, functionUrns) {
|
|
9
|
+
const key = this.getCacheKey(params);
|
|
10
|
+
const data = this.getData(key);
|
|
11
|
+
if (!data[params.name]) {
|
|
12
|
+
data[params.name] = [];
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
// Add new URNs, avoiding duplicates
|
|
15
|
+
// Add new URNs, avoiding duplicates.
|
|
15
16
|
for (const urn of functionUrns) {
|
|
16
|
-
if (!data[
|
|
17
|
-
data[
|
|
17
|
+
if (!data[params.name].includes(urn)) {
|
|
18
|
+
data[params.name].push(urn);
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
|
-
this.setData(data);
|
|
21
|
+
this.setData(key, data);
|
|
21
22
|
}
|
|
22
|
-
getDirty(
|
|
23
|
-
const
|
|
24
|
-
|
|
23
|
+
getDirty(params) {
|
|
24
|
+
const key = this.getCacheKey(params);
|
|
25
|
+
const data = this.getData(key);
|
|
26
|
+
return data[params.name] || [];
|
|
25
27
|
}
|
|
26
|
-
clearDirty(
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
clearDirty(params) {
|
|
29
|
+
const key = this.getCacheKey(params);
|
|
30
|
+
const data = this.getData(key);
|
|
31
|
+
delete data[params.name];
|
|
32
|
+
this.setData(key, data);
|
|
30
33
|
}
|
|
31
34
|
clearAll() {
|
|
32
|
-
this.setData({});
|
|
35
|
+
this.setData(WATCHED_LAMBDA_FUNCTIONS_KEY, {});
|
|
33
36
|
}
|
|
34
|
-
|
|
35
|
-
|
|
37
|
+
getCacheKey(params) {
|
|
38
|
+
return params.deploymentId ? `${WATCHED_LAMBDA_FUNCTIONS_KEY}-${params.deploymentId}` : WATCHED_LAMBDA_FUNCTIONS_KEY;
|
|
39
|
+
}
|
|
40
|
+
getData(key) {
|
|
41
|
+
const data = this.localStorageService.get(key);
|
|
36
42
|
if (!data) {
|
|
37
43
|
return {};
|
|
38
44
|
}
|
|
@@ -42,8 +48,8 @@ export class DefaultWatchedLambdaFunctionsService {
|
|
|
42
48
|
return {};
|
|
43
49
|
}
|
|
44
50
|
}
|
|
45
|
-
setData(data) {
|
|
46
|
-
this.localStorageService.set(
|
|
51
|
+
setData(key, data) {
|
|
52
|
+
this.localStorageService.set(key, data);
|
|
47
53
|
}
|
|
48
54
|
}
|
|
49
55
|
export const watchedLambdaFunctionsService = createImplementation({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createImplementation","WatchedLambdaFunctionsService","LocalStorageService","WATCHED_LAMBDA_FUNCTIONS_KEY","DefaultWatchedLambdaFunctionsService","constructor","localStorageService","markDirty","
|
|
1
|
+
{"version":3,"names":["createImplementation","WatchedLambdaFunctionsService","LocalStorageService","WATCHED_LAMBDA_FUNCTIONS_KEY","DefaultWatchedLambdaFunctionsService","constructor","localStorageService","markDirty","params","functionUrns","key","getCacheKey","data","getData","name","urn","includes","push","setData","getDirty","clearDirty","clearAll","deploymentId","get","JSON","parse","set","watchedLambdaFunctionsService","abstraction","implementation","dependencies"],"sources":["WatchedLambdaFunctionsService.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport { WatchedLambdaFunctionsService, LocalStorageService } from \"~/abstractions/index.js\";\n\nconst WATCHED_LAMBDA_FUNCTIONS_KEY = \"watchedLambdaFunctions\";\n\ninterface WatchedLambdaFunctionsData {\n [app: string]: string[]; // app name -> array of Lambda URNs\n}\n\nexport class DefaultWatchedLambdaFunctionsService\n implements WatchedLambdaFunctionsService.Interface\n{\n constructor(private localStorageService: LocalStorageService.Interface) {}\n\n markDirty(params: WatchedLambdaFunctionsService.Params, functionUrns: string[]): void {\n const key = this.getCacheKey(params);\n const data = this.getData(key);\n\n if (!data[params.name]) {\n data[params.name] = [];\n }\n\n // Add new URNs, avoiding duplicates.\n for (const urn of functionUrns) {\n if (!data[params.name].includes(urn)) {\n data[params.name].push(urn);\n }\n }\n\n this.setData(key, data);\n }\n\n getDirty(params: WatchedLambdaFunctionsService.Params): string[] {\n const key = this.getCacheKey(params);\n const data = this.getData(key);\n return data[params.name] || [];\n }\n\n clearDirty(params: WatchedLambdaFunctionsService.Params): void {\n const key = this.getCacheKey(params);\n const data = this.getData(key);\n delete data[params.name];\n this.setData(key, data);\n }\n\n clearAll(): void {\n this.setData(WATCHED_LAMBDA_FUNCTIONS_KEY, {});\n }\n\n private getCacheKey(params: WatchedLambdaFunctionsService.Params): string {\n return params.deploymentId\n ? `${WATCHED_LAMBDA_FUNCTIONS_KEY}-${params.deploymentId}`\n : WATCHED_LAMBDA_FUNCTIONS_KEY;\n }\n\n private getData(key: string): WatchedLambdaFunctionsData {\n const data = this.localStorageService.get(key);\n if (!data) {\n return {};\n }\n\n try {\n return typeof data === \"string\" ? JSON.parse(data) : data;\n } catch {\n return {};\n }\n }\n\n private setData(key: string, data: WatchedLambdaFunctionsData): void {\n this.localStorageService.set(key, data);\n }\n}\n\nexport const watchedLambdaFunctionsService = createImplementation({\n abstraction: WatchedLambdaFunctionsService,\n implementation: DefaultWatchedLambdaFunctionsService,\n dependencies: [LocalStorageService]\n});\n"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,YAAY;AACjD,SAASC,6BAA6B,EAAEC,mBAAmB;AAE3D,MAAMC,4BAA4B,GAAG,wBAAwB;AAM7D,OAAO,MAAMC,oCAAoC,CAEjD;EACIC,WAAWA,CAASC,mBAAkD,EAAE;IAAA,KAApDA,mBAAkD,GAAlDA,mBAAkD;EAAG;EAEzEC,SAASA,CAACC,MAA4C,EAAEC,YAAsB,EAAQ;IAClF,MAAMC,GAAG,GAAG,IAAI,CAACC,WAAW,CAACH,MAAM,CAAC;IACpC,MAAMI,IAAI,GAAG,IAAI,CAACC,OAAO,CAACH,GAAG,CAAC;IAE9B,IAAI,CAACE,IAAI,CAACJ,MAAM,CAACM,IAAI,CAAC,EAAE;MACpBF,IAAI,CAACJ,MAAM,CAACM,IAAI,CAAC,GAAG,EAAE;IAC1B;;IAEA;IACA,KAAK,MAAMC,GAAG,IAAIN,YAAY,EAAE;MAC5B,IAAI,CAACG,IAAI,CAACJ,MAAM,CAACM,IAAI,CAAC,CAACE,QAAQ,CAACD,GAAG,CAAC,EAAE;QAClCH,IAAI,CAACJ,MAAM,CAACM,IAAI,CAAC,CAACG,IAAI,CAACF,GAAG,CAAC;MAC/B;IACJ;IAEA,IAAI,CAACG,OAAO,CAACR,G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J;AAEA,OAAO,MAAMe,6BAA6B,GAAG3B,oBAAoB,CAAC;EAC9D4B,WAAW,EAAE3B,6BAA6B;EAC1C4B,cAAc,EAAEzB,oCAAoC;EACpD0B,YAAY,EAAE,CAAC5B,mBAAmB;AACtC,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { Abstraction } from "@webiny/di";
|
|
3
|
-
export type DefineApiExtensionParams = {
|
|
4
|
-
type: string;
|
|
5
|
-
description?: string;
|
|
6
|
-
abstraction?: Abstraction<any>;
|
|
7
|
-
};
|
|
8
|
-
export declare const defineApiExtension: (params: DefineApiExtensionParams) => import("~/defineExtension/index.js").ExtensionComponent<z.ZodObject<{
|
|
9
|
-
src: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
10
|
-
exportName: z.ZodOptional<z.ZodString>;
|
|
11
|
-
}, "strip", z.ZodTypeAny, {
|
|
12
|
-
src: string;
|
|
13
|
-
exportName?: string | undefined;
|
|
14
|
-
}, {
|
|
15
|
-
src: string;
|
|
16
|
-
exportName?: string | undefined;
|
|
17
|
-
}>>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["z","Node","Project","defineExtension","zodSrcPath","ExtensionSrcResolver","path","crypto","defineApiExtension","params","type","tags","runtimeContext","appName","description","multiple","paramsSchema","project","object","src","abstraction","exportName","string","optional","build","ctx","extensionsTsFilePath","paths","workspaceFolder","join","toString","extensionFilePath","absoluteExtensionFilePath","resolvePath","extensionFileName","basename","parse","name","hash","createHash","update","digest","exportNameAlias","slice","importPath","relative","dirname","replace","addSourceFileAtPath","source","getSourceFileOrThrow","existingImportDeclaration","getImportDeclaration","index","importDeclarations","getImportDeclarations","length","last","getChildIndex","extensionProject","extensionSource","hasDefaultExport","getDefaultExportSymbol","undefined","insertImportDeclaration","defaultImport","moduleSpecifier","namedImports","alias","pluginsArray","getFirstDescendant","node","isArrayLiteralExpression","addElement","contextPluginImportPath","existingContextPluginImport","save"],"sources":["defineApiExtension.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { Node, Project, ArrayLiteralExpression } from \"ts-morph\";\nimport { Abstraction } from \"@webiny/di\";\nimport { defineExtension } from \"~/defineExtension/index.js\";\nimport { zodSrcPath } from \"~/defineExtension/zodTypes/zodSrcPath.js\";\nimport { ExtensionSrcResolver } from \"~/utils/index.js\";\nimport path from \"path\";\nimport crypto from \"crypto\";\n\nexport type DefineApiExtensionParams = {\n type: string;\n description?: string;\n abstraction?: Abstraction<any>;\n};\n\nexport const defineApiExtension = (params: DefineApiExtensionParams) =>\n defineExtension({\n type: params.type,\n tags: { runtimeContext: \"app-build\", appName: \"api\" },\n description: params.description,\n multiple: true,\n paramsSchema: ({ project }) => {\n return z.object({\n src: zodSrcPath({ project, abstraction: params.abstraction }),\n exportName: z.string().optional()\n });\n },\n async build(params, ctx) {\n const extensionsTsFilePath = ctx.project.paths.workspaceFolder\n .join(\"apps\", \"api\", \"graphql\", \"src\", \"extensions.ts\")\n .toString();\n\n const { src: extensionFilePath } = params;\n\n // Resolve to absolute path for file operations\n const absoluteExtensionFilePath = ExtensionSrcResolver.resolvePath(\n extensionFilePath,\n ctx.project\n );\n\n const extensionFileName = path.basename(absoluteExtensionFilePath);\n\n // 1. Export name is always the file name without extension.\n const exportName = params.exportName ?? path.parse(extensionFileName).name;\n\n // 2. Alias name is \"ApiExtension_\" + hash of the file path. This way we\n // avoid potential naming conflicts and keep the identifier constant.\n const hash = crypto.createHash(\"sha256\").update(extensionFilePath).digest(\"hex\");\n const exportNameAlias = `ApiExtension_${hash.slice(-10)}`;\n\n // 3. Calculate import path relative to `extensions.ts` file.\n const importPath = path\n .relative(path.dirname(extensionsTsFilePath), absoluteExtensionFilePath)\n .replace(/\\.tsx?$/, \".js\");\n\n const project = new Project();\n project.addSourceFileAtPath(extensionsTsFilePath);\n\n const source = project.getSourceFileOrThrow(extensionsTsFilePath);\n\n const existingImportDeclaration = source.getImportDeclaration(importPath);\n if (existingImportDeclaration) {\n return;\n }\n\n let index = 1;\n\n const importDeclarations = source.getImportDeclarations();\n if (importDeclarations.length) {\n const last = importDeclarations[importDeclarations.length - 1];\n index = last.getChildIndex() + 1;\n }\n\n // Check if the file has a default export using AST parsing.\n const extensionProject = new Project();\n extensionProject.addSourceFileAtPath(absoluteExtensionFilePath);\n const extensionSource =\n extensionProject.getSourceFileOrThrow(absoluteExtensionFilePath);\n const hasDefaultExport = extensionSource.getDefaultExportSymbol() !== undefined;\n\n // Support both default and named exports.\n if (hasDefaultExport) {\n source.insertImportDeclaration(index, {\n defaultImport: exportNameAlias,\n moduleSpecifier: importPath\n });\n } else {\n source.insertImportDeclaration(index, {\n namedImports: [{ name: exportName, alias: exportNameAlias }],\n moduleSpecifier: importPath\n });\n }\n\n const pluginsArray = source.getFirstDescendant(node =>\n Node.isArrayLiteralExpression(node)\n ) as ArrayLiteralExpression;\n\n pluginsArray.addElement(\n `\\ncreateContextPlugin(ctx => {\\n\\tregisterExtension(ctx.container, ${exportNameAlias});\\n})`\n );\n\n {\n let index = 1;\n\n const importDeclarations = source.getImportDeclarations();\n if (importDeclarations.length) {\n const last = importDeclarations[importDeclarations.length - 1];\n index = last.getChildIndex() + 1;\n }\n\n const contextPluginImportPath = \"@webiny/api/plugins/ContextPlugin\";\n const existingContextPluginImport =\n source.getImportDeclaration(contextPluginImportPath);\n if (!existingContextPluginImport) {\n source.insertImportDeclaration(index, {\n namedImports: [\"createContextPlugin\"],\n moduleSpecifier: contextPluginImportPath\n });\n }\n }\n\n await source.save();\n }\n });\n"],"mappings":"AAAA,SAASA,CAAC,QAAQ,KAAK;AACvB,SAASC,IAAI,EAAEC,OAAO,QAAgC,UAAU;AAEhE,SAASC,eAAe;AACxB,SAASC,UAAU;AACnB,SAASC,oBAAoB;AAC7B,OAAOC,IAAI,MAAM,MAAM;AACvB,OAAOC,MAAM,MAAM,QAAQ;AAQ3B,OAAO,MAAMC,kBAAkB,GAA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