@webiny/project 0.0.0-unstable.ac6ebf63c6 → 0.0.0-unstable.c27f4d8a31
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/ProjectSdk.d.ts +1 -0
- package/ProjectSdk.js +4 -1
- package/ProjectSdk.js.map +1 -1
- package/abstractions/features/GetFeatureFlags.d.ts +8 -0
- package/abstractions/features/GetFeatureFlags.js +4 -0
- package/abstractions/features/GetFeatureFlags.js.map +1 -0
- package/abstractions/features/index.d.ts +1 -0
- package/abstractions/features/index.js +1 -0
- package/abstractions/features/index.js.map +1 -1
- package/abstractions/services/WatchedLambdaFunctionsService.d.ts +12 -7
- package/abstractions/services/WatchedLambdaFunctionsService.js.map +1 -1
- package/components/Wcp.d.ts +2 -0
- package/components/Wcp.js +8 -1
- package/components/Wcp.js.map +1 -1
- package/createProjectSdkContainer.js +4 -1
- package/createProjectSdkContainer.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/decorators/GetFeatureFlagsWithLicense.d.ts +13 -0
- package/decorators/GetFeatureFlagsWithLicense.js +71 -0
- package/decorators/GetFeatureFlagsWithLicense.js.map +1 -0
- package/decorators/index.d.ts +1 -0
- package/decorators/index.js +1 -0
- package/decorators/index.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/defineExtension/models/ExtensionDefinitionModel.d.ts +4 -4
- package/defineExtension/models/ExtensionDefinitionModel.js.map +1 -1
- package/defineExtension/models/ExtensionInstanceModel.js +1 -1
- package/defineExtension/models/ExtensionInstanceModel.js.map +1 -1
- package/defineExtension/zodTypes/zodSrcPath.d.ts +2 -1
- package/defineExtension/zodTypes/zodSrcPath.js +7 -14
- package/defineExtension/zodTypes/zodSrcPath.js.map +1 -1
- package/exports/infra/index.d.ts +1 -1
- package/exports/infra/index.js +1 -1
- package/exports/infra/index.js.map +1 -1
- package/extensions/AdminBuildParam.d.ts +5 -0
- package/extensions/AdminBuildParam.js +184 -0
- package/extensions/AdminBuildParam.js.map +1 -0
- package/extensions/AdminExtension.d.ts +5 -0
- package/extensions/AdminExtension.js +99 -0
- package/extensions/AdminExtension.js.map +1 -0
- package/extensions/ApiBuildParam.d.ts +5 -0
- package/extensions/ApiBuildParam.js +119 -0
- package/extensions/ApiBuildParam.js.map +1 -0
- package/extensions/ApiExtension.d.ts +5 -0
- package/{defineExtension/defineApiExtension.js → extensions/ApiExtension.js} +14 -22
- package/extensions/ApiExtension.js.map +1 -0
- package/extensions/DatabaseSetup.d.ts +6 -6
- package/extensions/EnvVar.d.ts +1 -7
- package/extensions/ExtensionDefinitions.d.ts +1 -5
- package/extensions/FeatureFlags.d.ts +18 -0
- package/extensions/FeatureFlags.js +43 -0
- package/extensions/FeatureFlags.js.map +1 -0
- package/extensions/Project/EnsureTelemetryEnabledForOss.js +1 -1
- package/extensions/Project/EnsureTelemetryEnabledForOss.js.map +1 -1
- package/extensions/Project/SetAdminAppEnvVarsBeforeBuild.js +1 -0
- package/extensions/Project/SetAdminAppEnvVarsBeforeBuild.js.map +1 -1
- package/extensions/Project/SetAdminAppEnvVarsBeforeWatch.js +1 -0
- package/extensions/Project/SetAdminAppEnvVarsBeforeWatch.js.map +1 -1
- package/extensions/ProjectDecorator.d.ts +2 -6
- package/extensions/ProjectId.d.ts +2 -6
- package/extensions/ProjectImplementation.d.ts +2 -8
- package/extensions/Telemetry.d.ts +1 -5
- package/extensions/hooks/AdminAfterBuild.d.ts +2 -6
- package/extensions/hooks/AdminAfterDeploy.d.ts +2 -6
- package/extensions/hooks/AdminBeforeBuild.d.ts +2 -6
- package/extensions/hooks/AdminBeforeDeploy.d.ts +2 -6
- package/extensions/hooks/AdminBeforeWatch.d.ts +2 -6
- package/extensions/hooks/AfterBuild.d.ts +2 -6
- package/extensions/hooks/AfterDeploy.d.ts +2 -6
- package/extensions/hooks/ApiAfterBuild.d.ts +2 -6
- package/extensions/hooks/ApiAfterDeploy.d.ts +2 -6
- package/extensions/hooks/ApiBeforeBuild.d.ts +2 -6
- package/extensions/hooks/ApiBeforeDeploy.d.ts +2 -6
- package/extensions/hooks/ApiBeforeWatch.d.ts +2 -6
- package/extensions/hooks/BeforeBuild.d.ts +2 -6
- package/extensions/hooks/BeforeDeploy.d.ts +2 -6
- package/extensions/hooks/BeforeWatch.d.ts +2 -6
- package/extensions/hooks/CoreAfterBuild.d.ts +2 -6
- package/extensions/hooks/CoreAfterDeploy.d.ts +2 -6
- package/extensions/hooks/CoreBeforeBuild.d.ts +2 -6
- package/extensions/hooks/CoreBeforeDeploy.d.ts +2 -6
- package/extensions/hooks/CoreBeforeWatch.d.ts +2 -6
- package/extensions/index.d.ts +46 -53
- package/extensions/index.js +12 -2
- package/extensions/index.js.map +1 -1
- package/extensions/pulumi/AdminPulumi.d.ts +2 -6
- package/extensions/pulumi/AdminStackOutputValue.d.ts +1 -7
- package/extensions/pulumi/ApiPulumi.d.ts +2 -6
- package/extensions/pulumi/ApiStackOutputValue.d.ts +1 -7
- package/extensions/pulumi/CorePulumi.d.ts +2 -6
- package/extensions/pulumi/CoreStackOutputValue.d.ts +1 -7
- package/extensions/pulumi/ProductionEnvironments.d.ts +2 -6
- package/extensions/pulumi/PulumiResourceNamePrefix.d.ts +1 -5
- package/features/BuildApp/PackagesBuilder/worker.js +1 -1
- package/features/BuildApp/PackagesBuilder/worker.js.map +1 -1
- package/features/GetFeatureFlags/GetFeatureFlags.d.ts +10 -0
- package/features/GetFeatureFlags/GetFeatureFlags.js +29 -0
- package/features/GetFeatureFlags/GetFeatureFlags.js.map +1 -0
- package/features/GetFeatureFlags/index.d.ts +1 -0
- package/features/GetFeatureFlags/index.js +3 -0
- package/features/GetFeatureFlags/index.js.map +1 -0
- package/features/Watch/Watch.js +1 -0
- package/features/Watch/Watch.js.map +1 -1
- package/features/Watch/localInvocationWorker.js +5 -1
- package/features/Watch/localInvocationWorker.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/features/index.d.ts +1 -0
- package/features/index.js +1 -0
- package/features/index.js.map +1 -1
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/index.js.map +1 -1
- package/package.json +22 -20
- package/services/GetProjectConfigService/GetProjectConfigService.js +2 -1
- package/services/GetProjectConfigService/GetProjectConfigService.js.map +1 -1
- package/services/GetProjectConfigService/WcpProjectLicenseContext.d.ts +1 -0
- package/services/GetProjectConfigService/WcpProjectLicenseContext.js +2 -1
- package/services/GetProjectConfigService/WcpProjectLicenseContext.js.map +1 -1
- package/services/GetProjectConfigService/renderConfigWorker.js +12 -3
- package/services/GetProjectConfigService/renderConfigWorker.js.map +1 -1
- package/services/GetProjectIdService/GetProjectIdService.js +1 -1
- package/services/GetProjectIdService/GetProjectIdService.js.map +1 -1
- package/services/InitProjectSdkService/applyWcpEnvVars.js +10 -8
- package/services/InitProjectSdkService/applyWcpEnvVars.js.map +1 -1
- package/services/InitProjectSdkService/registerDecorators.js +2 -2
- package/services/InitProjectSdkService/registerDecorators.js.map +1 -1
- package/services/InitProjectSdkService/registerHooks.js +2 -2
- package/services/InitProjectSdkService/registerHooks.js.map +1 -1
- package/services/InitProjectSdkService/registerImplementations.js +2 -2
- package/services/InitProjectSdkService/registerImplementations.js.map +1 -1
- package/services/InitProjectSdkService/registerPulumiExtensions.js +2 -2
- package/services/InitProjectSdkService/registerPulumiExtensions.js.map +1 -1
- package/services/InstallExtensionService/InstallExtensionService.d.ts +1 -1
- package/services/InstallExtensionService/InstallExtensionService.js +4 -4
- package/services/InstallExtensionService/InstallExtensionService.js.map +1 -1
- package/services/InstallExtensionService/mergePackageJson.js +4 -4
- package/services/InstallExtensionService/mergePackageJson.js.map +1 -1
- package/services/InstallExtensionService/types.d.ts +4 -0
- package/services/InstallExtensionService/types.js.map +1 -1
- package/services/InstallExtensionService/updateWebinyConfig.js +74 -47
- package/services/InstallExtensionService/updateWebinyConfig.js.map +1 -1
- package/services/ListAppLambdaFunctionsService/ListAppLambdaFunctionsService.js +1 -1
- package/services/ListAppLambdaFunctionsService/ListAppLambdaFunctionsService.js.map +1 -1
- package/services/ProjectInfoService/ProjectInfoService.js +2 -2
- package/services/ProjectInfoService/ProjectInfoService.js.map +1 -1
- 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/utils/ExtensionSrcResolver.d.ts +33 -0
- package/utils/ExtensionSrcResolver.js +120 -0
- package/utils/ExtensionSrcResolver.js.map +1 -0
- package/utils/index.d.ts +2 -1
- package/utils/index.js +2 -1
- package/utils/index.js.map +1 -1
- package/utils/requireConfig.js +9 -5
- package/utils/requireConfig.js.map +1 -1
- package/utils/toImportSpecifier.d.ts +5 -0
- package/utils/toImportSpecifier.js +12 -0
- package/utils/toImportSpecifier.js.map +1 -0
- package/defineExtension/defineApiExtension.d.ts +0 -17
- package/defineExtension/defineApiExtension.js.map +0 -1
- package/exports/extensions.d.ts +0 -1
- package/exports/extensions.js +0 -3
- package/exports/extensions.js.map +0 -1
- package/features/BuildApp/PackagesBuilder/utils/requireConfig.d.ts +0 -18
- package/features/BuildApp/PackagesBuilder/utils/requireConfig.js +0 -15
- package/features/BuildApp/PackagesBuilder/utils/requireConfig.js.map +0 -1
- package/features/Watch/watchers/utils/requireConfig.d.ts +0 -18
- package/features/Watch/watchers/utils/requireConfig.js +0 -15
- package/features/Watch/watchers/utils/requireConfig.js.map +0 -1
- package/utils/ImplPathResolver.d.ts +0 -10
- package/utils/ImplPathResolver.js +0 -27
- package/utils/ImplPathResolver.js.map +0 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createImplementation } from "@webiny/di";
|
|
2
|
+
import { FeatureFlags } from "@webiny/feature-flags";
|
|
3
|
+
import { GetFeatureFlags } from "../../abstractions/index.js";
|
|
4
|
+
import { GetProjectConfig } from "../../abstractions/index.js";
|
|
5
|
+
import { FeatureFlags as FeatureFlagsExtension } from "../../extensions/FeatureFlags.js";
|
|
6
|
+
class DefaultGetFeatureFlags {
|
|
7
|
+
constructor(getProjectConfig) {
|
|
8
|
+
this.getProjectConfig = getProjectConfig;
|
|
9
|
+
}
|
|
10
|
+
async execute() {
|
|
11
|
+
const projectConfig = await this.getProjectConfig.execute({
|
|
12
|
+
tags: {
|
|
13
|
+
runtimeContext: "project"
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
const extensions = projectConfig.extensionsByType(FeatureFlagsExtension);
|
|
17
|
+
if (extensions.length === 0) {
|
|
18
|
+
return new FeatureFlags({});
|
|
19
|
+
}
|
|
20
|
+
return FeatureFlags.fromDto(extensions[0].params.features);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export const getFeatureFlags = createImplementation({
|
|
24
|
+
abstraction: GetFeatureFlags,
|
|
25
|
+
implementation: DefaultGetFeatureFlags,
|
|
26
|
+
dependencies: [GetProjectConfig]
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=GetFeatureFlags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createImplementation","FeatureFlags","GetFeatureFlags","GetProjectConfig","FeatureFlagsExtension","DefaultGetFeatureFlags","constructor","getProjectConfig","execute","projectConfig","tags","runtimeContext","extensions","extensionsByType","length","fromDto","params","features","getFeatureFlags","abstraction","implementation","dependencies"],"sources":["GetFeatureFlags.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport { FeatureFlags } from \"@webiny/feature-flags\";\nimport { GetFeatureFlags } from \"~/abstractions/index.js\";\nimport { GetProjectConfig } from \"~/abstractions/index.js\";\nimport { FeatureFlags as FeatureFlagsExtension } from \"~/extensions/FeatureFlags.js\";\n\nclass DefaultGetFeatureFlags implements GetFeatureFlags.Interface {\n constructor(private getProjectConfig: GetProjectConfig.Interface) {}\n\n async execute(): Promise<FeatureFlags> {\n const projectConfig = await this.getProjectConfig.execute({\n tags: { runtimeContext: \"project\" }\n });\n\n const extensions = projectConfig.extensionsByType(FeatureFlagsExtension);\n\n if (extensions.length === 0) {\n return new FeatureFlags({});\n }\n\n return FeatureFlags.fromDto(extensions[0].params.features);\n }\n}\n\nexport const getFeatureFlags = createImplementation({\n abstraction: GetFeatureFlags,\n implementation: DefaultGetFeatureFlags,\n dependencies: [GetProjectConfig]\n});\n"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,YAAY;AACjD,SAASC,YAAY,QAAQ,uBAAuB;AACpD,SAASC,eAAe;AACxB,SAASC,gBAAgB;AACzB,SAASF,YAAY,IAAIG,qBAAqB;AAE9C,MAAMC,sBAAsB,CAAsC;EAC9DC,WAAWA,CAASC,gBAA4C,EAAE;IAAA,KAA9CA,gBAA4C,GAA5CA,gBAA4C;EAAG;EAEnE,MAAMC,OAAOA,CAAA,EAA0B;IACnC,MAAMC,aAAa,GAAG,MAAM,IAAI,CAACF,gBAAgB,CAACC,OAAO,CAAC;MACtDE,IAAI,EAAE;QAAEC,cAAc,EAAE;MAAU;IACtC,CAAC,CAAC;IAEF,MAAMC,UAAU,GAAGH,aAAa,CAACI,gBAAgB,CAACT,qBAAqB,CAAC;IAExE,IAAIQ,UAAU,CAACE,MAAM,KAAK,CAAC,EAAE;MACzB,OAAO,IAAIb,YAAY,CAAC,CAAC,CAAC,CAAC;IAC/B;IAEA,OAAOA,YAAY,CAACc,OAAO,CAACH,UAAU,CAAC,CAAC,CAAC,CAACI,MAAM,CAACC,QAAQ,CAAC;EAC9D;AACJ;AAEA,OAAO,MAAMC,eAAe,GAAGlB,oBAAoB,CAAC;EAChDmB,WAAW,EAAEjB,eAAe;EAC5BkB,cAAc,EAAEf,sBAAsB;EACtCgB,YAAY,EAAE,CAAClB,gBAAgB;AACnC,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./GetFeatureFlags.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./GetFeatureFlags.js\";\n"],"mappings":"AAAA","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,KAdUb,MAAwB,GAAxBA,MAAwB;IAAA,KACxBC,MAA+B,GAA/BA,MAA+B;IAAA,KAC/BC,6BAAsE,GAAtEA,6BAAsE;IAAA,KACtEC,mBAAkD,GAAlDA,mBAAkD;IAAA,KAClDC,UAAgC,GAAhCA,UAAgC;IAAA,KAChCC,uBAA0D,GAA1DA,uBAA0D;IAAA,KAC1DC,4BAAoE,GAApEA,4BAAoE;IAAA,KACpEC,y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rCA,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,yBAA8D,EAC9DC,EAAuB,EACvBC,2BAAkE,EAClEC,mBAAkD,EAClDC,6BAAsE,EACtEC,wBAA4D,EAC5DC,uBAA0D,EACpE;IAAA,KAdUb,MAAwB,GAAxBA,MAAwB;IAAA,KACxBC,MAA+B,GAA/BA,MAA+B;IAAA,KAC/BC,6BAAsE,GAAtEA,6BAAsE;IAAA,KACtEC,mBAAkD,GAAlDA,mBAAkD;IAAA,KACl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AAC;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,11 +1,15 @@
|
|
|
1
1
|
import { parentPort, workerData } from "worker_threads";
|
|
2
|
+
import { pathToFileURL } from "node:url";
|
|
3
|
+
import path from "node:path";
|
|
2
4
|
const {
|
|
3
5
|
handler: handlerParams
|
|
4
6
|
} = workerData;
|
|
5
7
|
try {
|
|
8
|
+
const handlerPath = handlerParams.path;
|
|
9
|
+
const importSpecifier = path.isAbsolute(handlerPath) ? pathToFileURL(handlerPath).href : handlerPath;
|
|
6
10
|
const {
|
|
7
11
|
handler
|
|
8
|
-
} = await import(
|
|
12
|
+
} = await import(importSpecifier);
|
|
9
13
|
const result = await handler(...handlerParams.args);
|
|
10
14
|
parentPort.postMessage(JSON.stringify({
|
|
11
15
|
success: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["parentPort","workerData","handler","handlerParams","
|
|
1
|
+
{"version":3,"names":["parentPort","workerData","pathToFileURL","path","handler","handlerParams","handlerPath","importSpecifier","isAbsolute","href","result","args","postMessage","JSON","stringify","success","error","message","code","data","stack","process","exit"],"sources":["localInvocationWorker.ts"],"sourcesContent":["import { parentPort, workerData } from \"worker_threads\";\nimport { pathToFileURL } from \"node:url\";\nimport path from \"node:path\";\n\nconst { handler: handlerParams } = workerData;\n\ntry {\n const handlerPath = handlerParams.path;\n const importSpecifier = path.isAbsolute(handlerPath)\n ? pathToFileURL(handlerPath).href\n : handlerPath;\n const { handler } = await import(importSpecifier);\n\n const result = await handler(...handlerParams.args);\n parentPort!.postMessage(JSON.stringify({ success: true, result, error: null }));\n} catch (error) {\n const { message, code, data, stack } = error;\n\n parentPort!.postMessage(\n JSON.stringify({\n success: false,\n result: null,\n error: { message, code, data, stack }\n })\n );\n} finally {\n process.exit(0);\n}\n"],"mappings":"AAAA,SAASA,UAAU,EAAEC,UAAU,QAAQ,gBAAgB;AACvD,SAASC,aAAa,QAAQ,UAAU;AACxC,OAAOC,IAAI,MAAM,WAAW;AAE5B,MAAM;EAAEC,OAAO,EAAEC;AAAc,CAAC,GAAGJ,UAAU;AAE7C,IAAI;EACA,MAAMK,WAAW,GAAGD,aAAa,CAACF,IAAI;EACtC,MAAMI,eAAe,GAAGJ,IAAI,CAACK,UAAU,CAACF,WAAW,CAAC,GAC9CJ,aAAa,CAACI,WAAW,CAAC,CAACG,IAAI,GAC/BH,WAAW;EACjB,MAAM;IAAEF;EAAQ,CAAC,GAAG,MAAM,MAAM,CAACG,eAAe,CAAC;EAEjD,MAAMG,MAAM,GAAG,MAAMN,OAAO,CAAC,GAAGC,aAAa,CAACM,IAAI,CAAC;EACnDX,UAAU,CAAEY,WAAW,CAACC,IAAI,CAACC,SAAS,CAAC;IAAEC,OAAO,EAAE,IAAI;IAAEL,MAAM;IAAEM,KAAK,EAAE;EAAK,CAAC,CAAC,CAAC;AACnF,CAAC,CAAC,OAAOA,KAAK,EAAE;EACZ,MAAM;IAAEC,OAAO;IAAEC,IAAI;IAAEC,IAAI;IAAEC;EAAM,CAAC,GAAGJ,KAAK;EAE5ChB,UAAU,CAAEY,WAAW,CACnBC,IAAI,CAACC,SAAS,CAAC;IACXC,OAAO,EAAE,KAAK;IACdL,MAAM,EAAE,IAAI;IACZM,KAAK,EAAE;MAAEC,OAAO;MAAEC,IAAI;MAAEC,IAAI;MAAEC;IAAM;EACxC,CAAC,CACL,CAAC;AACL,CAAC,SAAS;EACNC,OAAO,CAACC,IAAI,CAAC,CAAC,CAAC;AACnB","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,EACzBC,kCAAkC,QAC/B,wCAAwC;AAU/C,MAAMC,8BAA8B,GAAG,kDAAkD;AACzF,MAAMC,wBAAwB,GAAG,GAAG;AAmBpC,OAAO,MAAMC,sBAAsB,GAAG,MAAAA,CAAO;EACzCC,GAAG;EACHC,YAAY;EACZC,WAAW;EACXC,gBAAgB;EAChBC,SAAS;EACTC,aAAa;EACbC,eAAe;EACfC,8BAA8B;EAC9BC;AAC2B,CAAC,KAAK;EACjC,MAAM;IACFC,aAAa,EAAEC,MAAM;IACrBC,mBAAmB,EAAEC,gBAAgB;IACrCC;EACJ,CAAC,GAAGL,YAAY;EAEhB,MAAMM,WAAW,GAAG,MAAMF,gBAAgB,CAACG,OAAO,CAACf,GAAG,CAAC;EACvD,IAAI,CAACc,WAAW,EAAE;IACd;IACA;IACAJ,MAAM,CAACM,IAAI,CAAC,qCAAqC,CAAC;IAClD,OAAO,EAAE;EACb;;EAEA;EACA,MAAMC,qBAAqB,GAAGZ,aAAa,CAACa,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AErE,MAAMI,eAAe,GAAG,IAAIhD,yBAAyB,CAAC;MAClD6C,YAAY,EAAEpB,EAAE,CAACC,IAAI;MACrBuB,OAAO,EAAErD,EAAE,CAACsD,YAAY,CAACC,MAAM,CAACX,IAAI,CAACY,OAAO,GAAG,sBAAsB;IACzE,CAAC,CAAC;IAEF,MAAMV,YAAY,CAACK,IAAI,CAACC,eAAe,CAAC;IAExC,IAAIK,WAAW,GAAGP,qBAAqB,CAACO,WAAW,IAAI,EAAE;IACzD,IAAI,CAACA,WAAW,CAACC,QAAQ,CAACpD,8BAA8B,CAAC,EAAE;MACvDmD,WAAW,IAAInD,8BAA8B;IACjD;IAEA,MAAMqD,OAAO,GAAG5C,eAAe,IAAIR,wBAAwB;IAE3D,MAAMN,MAAM,CAAC,MACT6C,YAAY,CAACK,IAAI,CACb,IAAI9C,kCAAkC,CAAC;MACnC4C,YAAY,EAAEpB,EAAE,CAACC,IAAI;MACrB6B,OAAO;MACPF,WAAW;MACXG,WAAW,EAAE;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/features/index.d.ts
CHANGED
package/features/index.js
CHANGED
package/features/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./hooks/index.js\";\nexport * from \"./pulumi/index.js\";\nexport * from \"./BuildApp/index.js\";\nexport * from \"./DeployApp/index.js\";\nexport * from \"./DestroyApp/index.js\";\nexport * from \"./ExportStack/index.js\";\nexport * from \"./GetApp/index.js\";\nexport * from \"./GetAppOutput/index.js\";\nexport * from \"./GetAppStackOutput/index.js\";\nexport * from \"./GetLogger/index.js\";\nexport * from \"./GetProductionEnvironments/index.js\";\nexport * from \"./GetProject/index.js\";\nexport * from \"./GetProjectConfig/index.js\";\nexport * from \"./GetProjectInfo/index.js\";\nexport * from \"./GetPulumiResourceNamePrefix/index.js\";\nexport * from \"./InstallExtension/index.js\";\nexport * from \"./IsCi/index.js\";\nexport * from \"./IsTelemetryEnabled/index.js\";\nexport * from \"./IsWcpEnabled/index.js\";\nexport * from \"./IsWebinyJsRepo/index.js\";\nexport * from \"./RefreshApp/index.js\";\nexport * from \"./RunPulumiCommand/index.js\";\nexport * from \"./ValidateProjectConfig/index.js\";\nexport * from \"./Watch/index.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./hooks/index.js\";\nexport * from \"./pulumi/index.js\";\nexport * from \"./BuildApp/index.js\";\nexport * from \"./DeployApp/index.js\";\nexport * from \"./DestroyApp/index.js\";\nexport * from \"./ExportStack/index.js\";\nexport * from \"./GetApp/index.js\";\nexport * from \"./GetAppOutput/index.js\";\nexport * from \"./GetAppStackOutput/index.js\";\nexport * from \"./GetLogger/index.js\";\nexport * from \"./GetProductionEnvironments/index.js\";\nexport * from \"./GetProject/index.js\";\nexport * from \"./GetProjectConfig/index.js\";\nexport * from \"./GetProjectInfo/index.js\";\nexport * from \"./GetPulumiResourceNamePrefix/index.js\";\nexport * from \"./InstallExtension/index.js\";\nexport * from \"./IsCi/index.js\";\nexport * from \"./IsTelemetryEnabled/index.js\";\nexport * from \"./IsWcpEnabled/index.js\";\nexport * from \"./IsWebinyJsRepo/index.js\";\nexport * from \"./RefreshApp/index.js\";\nexport * from \"./RunPulumiCommand/index.js\";\nexport * from \"./ValidateProjectConfig/index.js\";\nexport * from \"./Watch/index.js\";\nexport * from \"./GetFeatureFlags/index.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
package/index.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ export type * from "./abstractions/models/index.js";
|
|
|
9
9
|
export type { IStackOutput } from "./abstractions/features/GetAppStackOutput.js";
|
|
10
10
|
export { PackageJson } from "@webiny/build-tools/utils/PackageJson.js";
|
|
11
11
|
export { createPathResolver } from "./utils/createPathResolver.js";
|
|
12
|
+
export { ExtensionSrcResolver } from "./utils/ExtensionSrcResolver.js";
|
|
12
13
|
export { GracefulError } from "./GracefulError.js";
|
|
14
|
+
export { toImportSpecifier } from "./utils/toImportSpecifier.js";
|
|
13
15
|
export { Wcp } from "./components/Wcp.js";
|
|
14
16
|
export { WcpProjectLicenseProvider, useWcpProjectLicense } from "./services/GetProjectConfigService/WcpProjectLicenseContext.js";
|
package/index.js
CHANGED
|
@@ -12,7 +12,9 @@ export const getStackOutput = async appName => {
|
|
|
12
12
|
export { ProjectSdk };
|
|
13
13
|
export { PackageJson } from "@webiny/build-tools/utils/PackageJson.js";
|
|
14
14
|
export { createPathResolver } from "./utils/createPathResolver.js";
|
|
15
|
+
export { ExtensionSrcResolver } from "./utils/ExtensionSrcResolver.js";
|
|
15
16
|
export { GracefulError } from "./GracefulError.js";
|
|
17
|
+
export { toImportSpecifier } from "./utils/toImportSpecifier.js";
|
|
16
18
|
export { Wcp } from "./components/Wcp.js";
|
|
17
19
|
export { WcpProjectLicenseProvider, useWcpProjectLicense } from "./services/GetProjectConfigService/WcpProjectLicenseContext.js";
|
|
18
20
|
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ProjectSdk","getProjectSdk","params","init","getStackOutput","appName","sdk","getAppStackOutput","PackageJson","createPathResolver","GracefulError","Wcp","WcpProjectLicenseProvider","useWcpProjectLicense"],"sources":["index.ts"],"sourcesContent":["import { ProjectSdk } from \"./ProjectSdk.js\";\nimport { type GetAppStackOutput } from \"~/abstractions/index.js\";\nimport { type AppName } from \"~/abstractions/types.js\";\n\nexport const getProjectSdk = (...params: Parameters<(typeof ProjectSdk)[\"init\"]>) => {\n return ProjectSdk.init(...params);\n};\n\n// A temporary convenience function to get the stack output for a specific app. We might revisit this in the\n// future and double check if there's a better way to expose this functionality.\nexport const getStackOutput = async <\n TOutput extends GetAppStackOutput.StackOutput = GetAppStackOutput.StackOutput\n>(\n appName: AppName\n) => {\n const sdk = await getProjectSdk();\n return sdk.getAppStackOutput<TOutput>(appName);\n};\n\nexport { ProjectSdk };\n\nexport type { AppName } from \"./abstractions/types.js\";\nexport type * from \"./abstractions/models/index.js\";\n\nexport type { IStackOutput } from \"~/abstractions/features/GetAppStackOutput.js\";\n\nexport { PackageJson } from \"@webiny/build-tools/utils/PackageJson.js\";\n\nexport { createPathResolver } from \"./utils/createPathResolver.js\";\n\nexport { GracefulError } from \"./GracefulError.js\";\n\nexport { Wcp } from \"./components/Wcp.js\";\nexport {\n WcpProjectLicenseProvider,\n useWcpProjectLicense\n} from \"./services/GetProjectConfigService/WcpProjectLicenseContext.js\";\n"],"mappings":"AAAA,SAASA,UAAU;AAInB,OAAO,MAAMC,aAAa,GAAGA,CAAC,GAAGC,MAA+C,KAAK;EACjF,OAAOF,UAAU,CAACG,IAAI,CAAC,GAAGD,MAAM,CAAC;AACrC,CAAC;;AAED;AACA;AACA,OAAO,MAAME,cAAc,GAAG,MAG1BC,OAAgB,IACf;EACD,MAAMC,GAAG,GAAG,MAAML,aAAa,CAAC,CAAC;EACjC,OAAOK,GAAG,CAACC,iBAAiB,CAAUF,OAAO,CAAC;AAClD,CAAC;AAED,SAASL,UAAU;AAOnB,SAASQ,WAAW,QAAQ,0CAA0C;AAEtE,SAASC,kBAAkB;AAE3B,SAASC,aAAa;AAEtB,SAASC,GAAG;AACZ,SACIC,yBAAyB,EACzBC,oBAAoB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["ProjectSdk","getProjectSdk","params","init","getStackOutput","appName","sdk","getAppStackOutput","PackageJson","createPathResolver","ExtensionSrcResolver","GracefulError","toImportSpecifier","Wcp","WcpProjectLicenseProvider","useWcpProjectLicense"],"sources":["index.ts"],"sourcesContent":["import { ProjectSdk } from \"./ProjectSdk.js\";\nimport { type GetAppStackOutput } from \"~/abstractions/index.js\";\nimport { type AppName } from \"~/abstractions/types.js\";\n\nexport const getProjectSdk = (...params: Parameters<(typeof ProjectSdk)[\"init\"]>) => {\n return ProjectSdk.init(...params);\n};\n\n// A temporary convenience function to get the stack output for a specific app. We might revisit this in the\n// future and double check if there's a better way to expose this functionality.\nexport const getStackOutput = async <\n TOutput extends GetAppStackOutput.StackOutput = GetAppStackOutput.StackOutput\n>(\n appName: AppName\n) => {\n const sdk = await getProjectSdk();\n return sdk.getAppStackOutput<TOutput>(appName);\n};\n\nexport { ProjectSdk };\n\nexport type { AppName } from \"./abstractions/types.js\";\nexport type * from \"./abstractions/models/index.js\";\n\nexport type { IStackOutput } from \"~/abstractions/features/GetAppStackOutput.js\";\n\nexport { PackageJson } from \"@webiny/build-tools/utils/PackageJson.js\";\n\nexport { createPathResolver } from \"./utils/createPathResolver.js\";\n\nexport { ExtensionSrcResolver } from \"./utils/ExtensionSrcResolver.js\";\n\nexport { GracefulError } from \"./GracefulError.js\";\n\nexport { toImportSpecifier } from \"./utils/toImportSpecifier.js\";\n\nexport { Wcp } from \"./components/Wcp.js\";\nexport {\n WcpProjectLicenseProvider,\n useWcpProjectLicense\n} from \"./services/GetProjectConfigService/WcpProjectLicenseContext.js\";\n"],"mappings":"AAAA,SAASA,UAAU;AAInB,OAAO,MAAMC,aAAa,GAAGA,CAAC,GAAGC,MAA+C,KAAK;EACjF,OAAOF,UAAU,CAACG,IAAI,CAAC,GAAGD,MAAM,CAAC;AACrC,CAAC;;AAED;AACA;AACA,OAAO,MAAME,cAAc,GAAG,MAG1BC,OAAgB,IACf;EACD,MAAMC,GAAG,GAAG,MAAML,aAAa,CAAC,CAAC;EACjC,OAAOK,GAAG,CAACC,iBAAiB,CAAUF,OAAO,CAAC;AAClD,CAAC;AAED,SAASL,UAAU;AAOnB,SAASQ,WAAW,QAAQ,0CAA0C;AAEtE,SAASC,kBAAkB;AAE3B,SAASC,oBAAoB;AAE7B,SAASC,aAAa;AAEtB,SAASC,iBAAiB;AAE1B,SAASC,GAAG;AACZ,SACIC,yBAAyB,EACzBC,oBAAoB","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/project",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.c27f4d8a31",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -10,16 +10,17 @@
|
|
|
10
10
|
"description": "An SDK for managing Webiny projects.",
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@webiny/aws-sdk": "0.0.0-unstable.
|
|
14
|
-
"@webiny/build-tools": "0.0.0-unstable.
|
|
13
|
+
"@webiny/aws-sdk": "0.0.0-unstable.c27f4d8a31",
|
|
14
|
+
"@webiny/build-tools": "0.0.0-unstable.c27f4d8a31",
|
|
15
15
|
"@webiny/di": "0.2.3",
|
|
16
|
-
"@webiny/
|
|
17
|
-
"@webiny/
|
|
18
|
-
"@webiny/
|
|
19
|
-
"@webiny/
|
|
20
|
-
"@webiny/
|
|
21
|
-
"@webiny/
|
|
22
|
-
"@webiny/
|
|
16
|
+
"@webiny/feature-flags": "0.0.0-unstable.c27f4d8a31",
|
|
17
|
+
"@webiny/global-config": "0.0.0-unstable.c27f4d8a31",
|
|
18
|
+
"@webiny/pulumi-sdk": "0.0.0-unstable.c27f4d8a31",
|
|
19
|
+
"@webiny/react-properties": "0.0.0-unstable.c27f4d8a31",
|
|
20
|
+
"@webiny/system-requirements": "0.0.0-unstable.c27f4d8a31",
|
|
21
|
+
"@webiny/telemetry": "0.0.0-unstable.c27f4d8a31",
|
|
22
|
+
"@webiny/utils": "0.0.0-unstable.c27f4d8a31",
|
|
23
|
+
"@webiny/wcp": "0.0.0-unstable.c27f4d8a31",
|
|
23
24
|
"chalk": "4.1.2",
|
|
24
25
|
"chokidar": "4.0.3",
|
|
25
26
|
"ci-info": "4.4.0",
|
|
@@ -30,32 +31,33 @@
|
|
|
30
31
|
"exit-hook": "4.0.0",
|
|
31
32
|
"fast-glob": "3.3.3",
|
|
32
33
|
"find-up": "5.0.0",
|
|
34
|
+
"get-tsconfig": "4.13.6",
|
|
33
35
|
"graphql-request": "7.4.0",
|
|
34
36
|
"humanize-duration": "3.33.2",
|
|
35
|
-
"
|
|
37
|
+
"jsdom": "28.1.0",
|
|
38
|
+
"load-json-file": "7.0.1",
|
|
36
39
|
"lodash": "4.17.23",
|
|
37
|
-
"minimatch": "
|
|
40
|
+
"minimatch": "10.2.4",
|
|
38
41
|
"mqtt": "5.15.0",
|
|
39
42
|
"neverthrow": "8.2.0",
|
|
40
43
|
"p-retry": "7.1.1",
|
|
41
44
|
"pino": "9.14.0",
|
|
42
45
|
"pino-pretty": "9.4.1",
|
|
43
|
-
"react": "18.
|
|
44
|
-
"react-
|
|
46
|
+
"react": "18.3.1",
|
|
47
|
+
"react-dom": "18.3.1",
|
|
45
48
|
"read-json-sync": "2.0.1",
|
|
46
49
|
"replace-in-path": "1.1.0",
|
|
47
50
|
"serialize-error": "12.0.0",
|
|
48
51
|
"ts-morph": "27.0.2",
|
|
49
52
|
"tsx": "4.21.0",
|
|
50
|
-
"write-json-file": "
|
|
51
|
-
"zod": "3.
|
|
53
|
+
"write-json-file": "7.0.0",
|
|
54
|
+
"zod": "4.3.6"
|
|
52
55
|
},
|
|
53
56
|
"devDependencies": {
|
|
54
57
|
"@types/debounce": "1.2.4",
|
|
55
58
|
"@types/humanize-duration": "3.27.4",
|
|
56
|
-
"@types/jsdom": "
|
|
57
|
-
"@types/lodash": "4.17.
|
|
58
|
-
"@types/react-test-renderer": "18.3.1",
|
|
59
|
+
"@types/jsdom": "28.0.0",
|
|
60
|
+
"@types/lodash": "4.17.24",
|
|
59
61
|
"@types/read-json-sync": "2.0.3",
|
|
60
62
|
"rimraf": "6.1.3",
|
|
61
63
|
"type-fest": "5.4.4",
|
|
@@ -75,5 +77,5 @@
|
|
|
75
77
|
"access": "public",
|
|
76
78
|
"directory": "dist"
|
|
77
79
|
},
|
|
78
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "c27f4d8a31c3af1570817797441855292b6c1f20"
|
|
79
81
|
}
|
|
@@ -3,6 +3,7 @@ import { GetProjectConfigService, GetProjectService, LoggerService, ProjectSdkPa
|
|
|
3
3
|
import { ExtensionDefinitions as ExtensionDefinitionsExtension } from "../../extensions/ExtensionDefinitions.js";
|
|
4
4
|
import { ExtensionInstanceModel } from "../../defineExtension/index.js";
|
|
5
5
|
import { ProjectConfigModel } from "../../models/ProjectConfigModel.js";
|
|
6
|
+
import { toImportSpecifier } from "../../utils/index.js";
|
|
6
7
|
import { renderConfig } from "./renderConfig.js";
|
|
7
8
|
export class DefaultGetProjectConfigService {
|
|
8
9
|
cachedRenderedConfigs = {};
|
|
@@ -62,7 +63,7 @@ export class DefaultGetProjectConfigService {
|
|
|
62
63
|
// Treat as absolute path.
|
|
63
64
|
importPath = filePath;
|
|
64
65
|
}
|
|
65
|
-
return import(importPath);
|
|
66
|
+
return import(toImportSpecifier(importPath));
|
|
66
67
|
};
|
|
67
68
|
const tagsFilters = params?.tags || {};
|
|
68
69
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createImplementation","GetProjectConfigService","GetProjectService","LoggerService","ProjectSdkParamsService","ExtensionDefinitions","ExtensionDefinitionsExtension","ExtensionInstanceModel","ProjectConfigModel","renderConfig","DefaultGetProjectConfigService","cachedRenderedConfigs","constructor","getProjectService","projectSdkParamsService","loggerService","execute","params","project","currentTime","Date","now","cacheKey","JSON","stringify","renderArgs","info","projectSdkParams","get","args","sdkParams","err","error","Error","message","renderedConfig","debug","config","hydratedConfig","hydrateConfig","model","create","duration","configDto","importFromPath","filePath","importPath","startsWith","paths","rootFolder","join","toString","tagsFilters","tags","extensionDefinitionsType","def","type","extensionsTypes","Object","keys","filter","key","allExtensionDefinitions","extensions","extensionDefinitionsExtensions","ext","default","importedExtensionDefinitions","src","push","scopesFilter","reduce","acc","extensionType","oneOrMoreExtensions","extensionsArray","Array","isArray","matchedExtensions","map","extensionParams","extDef","find","e","warn","length","extDefTags","hasMatchingTags","every","tag","filterValue","extDefValue","Boolean","getProjectConfigService","abstraction","implementation","dependencies"],"sources":["GetProjectConfigService.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport {\n GetProjectConfigService,\n GetProjectService,\n LoggerService,\n ProjectSdkParamsService\n} from \"~/abstractions/index.js\";\nimport {\n type ExtensionDto,\n type ExtensionType,\n type IHydratedProjectConfig,\n type IProjectConfigDto\n} from \"~/abstractions/models/index.js\";\nimport { ExtensionDefinitions as ExtensionDefinitionsExtension } from \"~/extensions/ExtensionDefinitions.js\";\nimport { ExtensionInstanceModel } from \"~/defineExtension/index.js\";\nimport { ProjectConfigModel } from \"~/models/ProjectConfigModel.js\";\nimport { renderConfig } from \"./renderConfig.js\";\n\nexport class DefaultGetProjectConfigService implements GetProjectConfigService.Interface {\n cachedRenderedConfigs: Record<string, IProjectConfigDto> = {};\n\n constructor(\n private readonly getProjectService: GetProjectService.Interface,\n private readonly projectSdkParamsService: ProjectSdkParamsService.Interface,\n private readonly loggerService: LoggerService.Interface\n ) {}\n\n async execute(\n params: GetProjectConfigService.Params = {}\n ): Promise<GetProjectConfigService.Result> {\n const project = this.getProjectService.execute();\n\n const currentTime = Date.now();\n const cacheKey = JSON.stringify(params.renderArgs);\n if (!this.cachedRenderedConfigs[cacheKey]) {\n this.loggerService.info(\n { renderArgs: params.renderArgs },\n `Rendering project config...`\n );\n\n try {\n const projectSdkParams = this.projectSdkParamsService.get();\n this.cachedRenderedConfigs[cacheKey] = await renderConfig({\n project,\n args: params.renderArgs,\n sdkParams: projectSdkParams\n });\n } catch (err) {\n this.loggerService.error(\n { err },\n `There was an error while rendering the project config. `\n );\n\n throw new Error(\n `An error occurred while rendering \"webiny.config.tsx\" config file:\\n${err.message}`\n );\n }\n } else {\n this.loggerService.info(\n { renderArgs: params.renderArgs },\n `Skipping rendering project config (cache hit)...`\n );\n }\n\n const renderedConfig = this.cachedRenderedConfigs[cacheKey];\n this.loggerService.debug({ config: renderedConfig }, `Project config rendering complete.`);\n\n const hydratedConfig = await this.hydrateConfig(renderedConfig, params);\n this.loggerService.debug({ config: hydratedConfig }, `Project config hydration complete.`);\n\n const model = ProjectConfigModel.create(hydratedConfig);\n\n const duration = Date.now() - currentTime;\n this.loggerService.info(`Project config rendered and hydrated in ${duration}ms.`);\n\n return model;\n }\n\n private async hydrateConfig(\n configDto: IProjectConfigDto,\n params: GetProjectConfigService.Params\n ): Promise<IHydratedProjectConfig> {\n const projectSdkParams = this.projectSdkParamsService.get();\n const project = this.getProjectService.execute();\n\n const importFromPath = (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 return import(importPath);\n };\n\n const tagsFilters = params?.tags || {};\n\n // Exclude extra extension definitions because we are handling these separately.\n const extensionDefinitionsType = ExtensionDefinitionsExtension.def.type;\n\n const extensionsTypes = Object.keys(configDto).filter(\n key => key !== extensionDefinitionsType\n ) as ExtensionType[];\n\n const allExtensionDefinitions = projectSdkParams.extensions;\n\n // Extra definitions registered via config (e.g. `packages/project-aws/src/Webiny.tsx`).\n const extensionDefinitionsExtensions = (configDto[extensionDefinitionsType] ||\n []) as ExtensionDto[];\n\n for (const ext of extensionDefinitionsExtensions) {\n // Load the extension from give `src`.\n const { default: importedExtensionDefinitions } = await importFromPath(ext.src);\n\n allExtensionDefinitions?.push(...importedExtensionDefinitions);\n }\n\n this.loggerService.info({ scopesFilter: tagsFilters }, `Hydrating project config...`);\n\n return extensionsTypes.reduce<IHydratedProjectConfig>(\n (acc, extensionType: ExtensionType) => {\n const oneOrMoreExtensions = configDto[extensionType];\n const extensionsArray = Array.isArray(oneOrMoreExtensions)\n ? [...oneOrMoreExtensions]\n : [oneOrMoreExtensions];\n\n const matchedExtensions = extensionsArray\n .map(extensionParams => {\n const extDef = projectSdkParams.extensions?.find(e => {\n return e.type === extensionType;\n });\n\n if (!extDef) {\n this.loggerService.warn(\n `Could not find extension definition for type: ${extensionType}. Skipping...`\n );\n return null;\n }\n\n if (Object.keys(tagsFilters).length > 0) {\n const extDefTags = extDef.tags;\n\n const hasMatchingTags = Object.keys(tagsFilters).every(tag => {\n const filterValue = tagsFilters[tag];\n const extDefValue = extDefTags[tag];\n\n // Otherwise, check for strict equality.\n return extDefValue === filterValue;\n });\n\n if (!hasMatchingTags) {\n return null;\n }\n }\n\n return new ExtensionInstanceModel(extDef, extensionParams, { project });\n })\n .filter(Boolean) as ExtensionInstanceModel<any>[];\n\n if (matchedExtensions.length > 0) {\n acc[extensionType] = matchedExtensions;\n }\n\n return acc;\n },\n {} as IHydratedProjectConfig\n );\n }\n}\n\nexport const getProjectConfigService = createImplementation({\n abstraction: GetProjectConfigService,\n implementation: DefaultGetProjectConfigService,\n dependencies: [GetProjectService, ProjectSdkParamsService, LoggerService]\n});\n"],"mappings":"AAAA,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C3B,IAAI,KAAKiB,aAAa;QACnC,CAAC,CAAC;QAEF,IAAI,CAACQ,MAAM,EAAE;UACT,IAAI,CAAClE,aAAa,CAACqE,IAAI,CACnB,iDAAiDX,aAAa,eAClE,CAAC;UACD,OAAO,IAAI;QACf;QAEA,IAAIf,MAAM,CAACC,IAAI,CAACP,WAAW,CAAC,CAACiC,MAAM,GAAG,CAAC,EAAE;UACrC,MAAMC,UAAU,GAAGL,MAAM,CAAC5B,IAAI;UAE9B,MAAMkC,eAAe,GAAG7B,MAAM,CAACC,IAAI,CAACP,WAAW,CAAC,CAACoC,KAAK,CAACC,GAAG,IAAI;YAC1D,MAAMC,WAAW,GAAGtC,WAAW,CAACqC,GAAG,CAAC;YACpC,MAAME,WAAW,GAAGL,UAAU,CAACG,GAAG,CAAC;;YAEnC;YACA,OAAOE,WAAW,KAAKD,WAAW;UACtC,CAAC,CAAC;UAEF,IAAI,CAACH,eAAe,EAAE;YAClB,OAAO,IAAI;UACf;QACJ;QAEA,OAAO,IAAIhF,sBAAsB,CAAC0E,MAAM,EAAED,eAAe,EAAE;UAAE9D;QAAQ,CAAC,CAAC;MAC3E,CAAC,CAAC,CACD0C,MAAM,CAACgC,OAAO,CAAkC;MAErD,IAAId,iBAAiB,CAACO,MAAM,GAAG,CAAC,EAAE;QAC9Bb,GAAG,CAACC,aAAa,CAAC,GAAGK,iBAAiB;MAC1C;MAEA,OAAON,GAAG;IACd,CAAC,EACD,CAAC,CACL,CAAC;EACL;AACJ;AAEA,OAAO,MAAMqB,uBAAuB,GAAG7F,oBAAoB,CAAC;EACxD8F,WAAW,EAAE7F,uBAAuB;EACpC8F,cAAc,EAAErF,8BAA8B;EAC9CsF,YAAY,EAAE,CAAC9F,iBAAiB,EAAEE,uBAAuB,EAAED,aAAa;AAC5E,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["createImplementation","GetProjectConfigService","GetProjectService","LoggerService","ProjectSdkParamsService","ExtensionDefinitions","ExtensionDefinitionsExtension","ExtensionInstanceModel","ProjectConfigModel","toImportSpecifier","renderConfig","DefaultGetProjectConfigService","cachedRenderedConfigs","constructor","getProjectService","projectSdkParamsService","loggerService","execute","params","project","currentTime","Date","now","cacheKey","JSON","stringify","renderArgs","info","projectSdkParams","get","args","sdkParams","err","error","Error","message","renderedConfig","debug","config","hydratedConfig","hydrateConfig","model","create","duration","configDto","importFromPath","filePath","importPath","startsWith","paths","rootFolder","join","toString","tagsFilters","tags","extensionDefinitionsType","def","type","extensionsTypes","Object","keys","filter","key","allExtensionDefinitions","extensions","extensionDefinitionsExtensions","ext","default","importedExtensionDefinitions","src","push","scopesFilter","reduce","acc","extensionType","oneOrMoreExtensions","extensionsArray","Array","isArray","matchedExtensions","map","extensionParams","extDef","find","e","warn","length","extDefTags","hasMatchingTags","every","tag","filterValue","extDefValue","Boolean","getProjectConfigService","abstraction","implementation","dependencies"],"sources":["GetProjectConfigService.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport {\n GetProjectConfigService,\n GetProjectService,\n LoggerService,\n ProjectSdkParamsService\n} from \"~/abstractions/index.js\";\nimport {\n type ExtensionDto,\n type ExtensionType,\n type IHydratedProjectConfig,\n type IProjectConfigDto\n} from \"~/abstractions/models/index.js\";\nimport { ExtensionDefinitions as ExtensionDefinitionsExtension } from \"~/extensions/ExtensionDefinitions.js\";\nimport { ExtensionInstanceModel } from \"~/defineExtension/index.js\";\nimport { ProjectConfigModel } from \"~/models/ProjectConfigModel.js\";\nimport { toImportSpecifier } from \"~/utils/index.js\";\nimport { renderConfig } from \"./renderConfig.js\";\n\nexport class DefaultGetProjectConfigService implements GetProjectConfigService.Interface {\n cachedRenderedConfigs: Record<string, IProjectConfigDto> = {};\n\n constructor(\n private readonly getProjectService: GetProjectService.Interface,\n private readonly projectSdkParamsService: ProjectSdkParamsService.Interface,\n private readonly loggerService: LoggerService.Interface\n ) {}\n\n async execute(\n params: GetProjectConfigService.Params = {}\n ): Promise<GetProjectConfigService.Result> {\n const project = this.getProjectService.execute();\n\n const currentTime = Date.now();\n const cacheKey = JSON.stringify(params.renderArgs);\n if (!this.cachedRenderedConfigs[cacheKey]) {\n this.loggerService.info(\n { renderArgs: params.renderArgs },\n `Rendering project config...`\n );\n\n try {\n const projectSdkParams = this.projectSdkParamsService.get();\n this.cachedRenderedConfigs[cacheKey] = await renderConfig({\n project,\n args: params.renderArgs,\n sdkParams: projectSdkParams\n });\n } catch (err) {\n this.loggerService.error(\n { err },\n `There was an error while rendering the project config. `\n );\n\n throw new Error(\n `An error occurred while rendering \"webiny.config.tsx\" config file:\\n${err.message}`\n );\n }\n } else {\n this.loggerService.info(\n { renderArgs: params.renderArgs },\n `Skipping rendering project config (cache hit)...`\n );\n }\n\n const renderedConfig = this.cachedRenderedConfigs[cacheKey];\n this.loggerService.debug({ config: renderedConfig }, `Project config rendering complete.`);\n\n const hydratedConfig = await this.hydrateConfig(renderedConfig, params);\n this.loggerService.debug({ config: hydratedConfig }, `Project config hydration complete.`);\n\n const model = ProjectConfigModel.create(hydratedConfig);\n\n const duration = Date.now() - currentTime;\n this.loggerService.info(`Project config rendered and hydrated in ${duration}ms.`);\n\n return model;\n }\n\n private async hydrateConfig(\n configDto: IProjectConfigDto,\n params: GetProjectConfigService.Params\n ): Promise<IHydratedProjectConfig> {\n const projectSdkParams = this.projectSdkParamsService.get();\n const project = this.getProjectService.execute();\n\n const importFromPath = (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 return import(toImportSpecifier(importPath));\n };\n\n const tagsFilters = params?.tags || {};\n\n // Exclude extra extension definitions because we are handling these separately.\n const extensionDefinitionsType = ExtensionDefinitionsExtension.def.type;\n\n const extensionsTypes = Object.keys(configDto).filter(\n key => key !== extensionDefinitionsType\n ) as ExtensionType[];\n\n const allExtensionDefinitions = projectSdkParams.extensions;\n\n // Extra definitions registered via config (e.g. `packages/project-aws/src/Webiny.tsx`).\n const extensionDefinitionsExtensions = (configDto[extensionDefinitionsType] ||\n []) as ExtensionDto[];\n\n for (const ext of extensionDefinitionsExtensions) {\n // Load the extension from give `src`.\n const { default: importedExtensionDefinitions } = await importFromPath(ext.src);\n\n allExtensionDefinitions?.push(...importedExtensionDefinitions);\n }\n\n this.loggerService.info({ scopesFilter: tagsFilters }, `Hydrating project config...`);\n\n return extensionsTypes.reduce<IHydratedProjectConfig>(\n (acc, extensionType: ExtensionType) => {\n const oneOrMoreExtensions = configDto[extensionType];\n const extensionsArray = Array.isArray(oneOrMoreExtensions)\n ? [...oneOrMoreExtensions]\n : [oneOrMoreExtensions];\n\n const matchedExtensions = extensionsArray\n .map(extensionParams => {\n const extDef = projectSdkParams.extensions?.find(e => {\n return e.type === extensionType;\n });\n\n if (!extDef) {\n this.loggerService.warn(\n `Could not find extension definition for type: ${extensionType}. Skipping...`\n );\n return null;\n }\n\n if (Object.keys(tagsFilters).length > 0) {\n const extDefTags = extDef.tags;\n\n const hasMatchingTags = Object.keys(tagsFilters).every(tag => {\n const filterValue = tagsFilters[tag];\n const extDefValue = extDefTags[tag];\n\n // Otherwise, check for strict equality.\n return extDefValue === filterValue;\n });\n\n if (!hasMatchingTags) {\n return null;\n }\n }\n\n return new ExtensionInstanceModel(extDef, extensionParams, { project });\n })\n .filter(Boolean) as ExtensionInstanceModel<any>[];\n\n if (matchedExtensions.length > 0) {\n acc[extensionType] = matchedExtensions;\n }\n\n return acc;\n },\n {} as IHydratedProjectConfig\n );\n }\n}\n\nexport const getProjectConfigService = createImplementation({\n abstraction: GetProjectConfigService,\n implementation: DefaultGetProjectConfigService,\n dependencies: [GetProjectService, ProjectSdkParamsService, LoggerService]\n});\n"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,YAAY;AACjD,SACIC,uBAAuB,EACvBC,iBAAiB,EACjBC,aAAa,EACbC,uBAAuB;AAQ3B,SAASC,oBAAoB,IAAIC,6BAA6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,CAAClE,aAAa,CAACqE,IAAI,CACnB,iDAAiDX,aAAa,eAClE,CAAC;UACD,OAAO,IAAI;QACf;QAEA,IAAIf,MAAM,CAACC,IAAI,CAACP,WAAW,CAAC,CAACiC,MAAM,GAAG,CAAC,EAAE;UACrC,MAAMC,UAAU,GAAGL,MAAM,CAAC5B,IAAI;UAE9B,MAAMkC,eAAe,GAAG7B,MAAM,CAACC,IAAI,CAACP,WAAW,CAAC,CAACoC,KAAK,CAACC,GAAG,IAAI;YAC1D,MAAMC,WAAW,GAAGtC,WAAW,CAACqC,GAAG,CAAC;YACpC,MAAME,WAAW,GAAGL,UAAU,CAACG,GAAG,CAAC;;YAEnC;YACA,OAAOE,WAAW,KAAKD,WAAW;UACtC,CAAC,CAAC;UAEF,IAAI,CAACH,eAAe,EAAE;YAClB,OAAO,IAAI;UACf;QACJ;QAEA,OAAO,IAAIjF,sBAAsB,CAAC2E,MAAM,EAAED,eAAe,EAAE;UAAE9D;QAAQ,CAAC,CAAC;MAC3E,CAAC,CAAC,CACD0C,MAAM,CAACgC,OAAO,CAAkC;MAErD,IAAId,iBAAiB,CAACO,MAAM,GAAG,CAAC,EAAE;QAC9Bb,GAAG,CAACC,aAAa,CAAC,GAAGK,iBAAiB;MAC1C;MAEA,OAAON,GAAG;IACd,CAAC,EACD,CAAC,CACL,CAAC;EACL;AACJ;AAEA,OAAO,MAAMqB,uBAAuB,GAAG9F,oBAAoB,CAAC;EACxD+F,WAAW,EAAE9F,uBAAuB;EACpC+F,cAAc,EAAErF,8BAA8B;EAC9CsF,YAAY,EAAE,CAAC/F,iBAAiB,EAAEE,uBAAuB,EAAED,aAAa;AAC5E,CAAC,CAAC","ignoreList":[]}
|
|
@@ -6,6 +6,7 @@ export interface WcpProjectLicenseContextValue {
|
|
|
6
6
|
canUsePrivateFiles: () => boolean;
|
|
7
7
|
canUseFileManagerThreatDetection: () => boolean;
|
|
8
8
|
canUseWorkflows: () => boolean;
|
|
9
|
+
canUseHcmsFieldPermissions: () => boolean;
|
|
9
10
|
}
|
|
10
11
|
export declare const WcpProjectLicenseProvider: React.FC<{
|
|
11
12
|
children: React.ReactNode;
|
|
@@ -24,7 +24,8 @@ export const WcpProjectLicenseProvider = ({
|
|
|
24
24
|
canUseTeams: () => license?.canUseTeams() ?? false,
|
|
25
25
|
canUsePrivateFiles: () => license?.canUsePrivateFiles() ?? false,
|
|
26
26
|
canUseFileManagerThreatDetection: () => license?.canUseFileManagerThreatDetection() ?? false,
|
|
27
|
-
canUseWorkflows: () => license?.canUseWorkflows() ?? false
|
|
27
|
+
canUseWorkflows: () => license?.canUseWorkflows() ?? false,
|
|
28
|
+
canUseHcmsFieldPermissions: () => license?.canUseHcmsFieldPermissions() ?? false
|
|
28
29
|
};
|
|
29
30
|
return /*#__PURE__*/React.createElement(WcpProjectLicenseContext.Provider, {
|
|
30
31
|
value: value
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","createContext","useContext","useMemo","License","WcpProjectLicenseContext","WcpProjectLicenseProvider","children","license","licenseEnv","process","env","WCP_PROJECT_LICENSE","licenseDto","JSON","parse","fromLicenseDto","e","console","warn","hasLicense","value","canUseMultiTenancy","canUseTeams","canUsePrivateFiles","canUseFileManagerThreatDetection","canUseWorkflows","createElement","Provider","useWcpProjectLicense","context","Error"],"sources":["WcpProjectLicenseContext.tsx"],"sourcesContent":["import React, { createContext, useContext, useMemo } from \"react\";\nimport { License } from \"@webiny/wcp\";\nimport type { DecryptedWcpProjectLicense } from \"@webiny/wcp/types.js\";\n\nexport interface WcpProjectLicenseContextValue {\n hasLicense: boolean;\n canUseMultiTenancy: () => boolean;\n canUseTeams: () => boolean;\n canUsePrivateFiles: () => boolean;\n canUseFileManagerThreatDetection: () => boolean;\n canUseWorkflows: () => boolean;\n}\n\nconst WcpProjectLicenseContext = createContext<WcpProjectLicenseContextValue | null>(null);\n\nexport const WcpProjectLicenseProvider: React.FC<{ children: React.ReactNode }> = ({\n children\n}) => {\n const license = useMemo(() => {\n const licenseEnv = process.env.WCP_PROJECT_LICENSE;\n if (!licenseEnv) {\n return null;\n }\n\n try {\n const licenseDto = JSON.parse(licenseEnv) as DecryptedWcpProjectLicense;\n return License.fromLicenseDto(licenseDto);\n } catch (e) {\n console.warn(\n \"Failed to parse WCP_PROJECT_LICENSE environment variable. Expected valid JSON with DecryptedWcpProjectLicense format:\",\n e\n );\n return null;\n }\n }, []);\n\n const hasLicense = !!license;\n\n const value: WcpProjectLicenseContextValue = {\n hasLicense,\n canUseMultiTenancy: () => hasLicense,\n canUseTeams: () => license?.canUseTeams() ?? false,\n canUsePrivateFiles: () => license?.canUsePrivateFiles() ?? false,\n canUseFileManagerThreatDetection: () =>\n license?.canUseFileManagerThreatDetection() ?? false,\n canUseWorkflows: () => license?.canUseWorkflows() ?? false\n };\n\n return (\n <WcpProjectLicenseContext.Provider value={value}>\n {children}\n </WcpProjectLicenseContext.Provider>\n );\n};\n\nexport const useWcpProjectLicense = () => {\n const context = useContext(WcpProjectLicenseContext);\n if (!context) {\n throw new Error(\"useWcpProjectLicense must be used within a WcpProjectLicenseProvider\");\n }\n return context;\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,aAAa,EAAEC,UAAU,EAAEC,OAAO,QAAQ,OAAO;AACjE,SAASC,OAAO,QAAQ,aAAa;
|
|
1
|
+
{"version":3,"names":["React","createContext","useContext","useMemo","License","WcpProjectLicenseContext","WcpProjectLicenseProvider","children","license","licenseEnv","process","env","WCP_PROJECT_LICENSE","licenseDto","JSON","parse","fromLicenseDto","e","console","warn","hasLicense","value","canUseMultiTenancy","canUseTeams","canUsePrivateFiles","canUseFileManagerThreatDetection","canUseWorkflows","canUseHcmsFieldPermissions","createElement","Provider","useWcpProjectLicense","context","Error"],"sources":["WcpProjectLicenseContext.tsx"],"sourcesContent":["import React, { createContext, useContext, useMemo } from \"react\";\nimport { License } from \"@webiny/wcp\";\nimport type { DecryptedWcpProjectLicense } from \"@webiny/wcp/types.js\";\n\nexport interface WcpProjectLicenseContextValue {\n hasLicense: boolean;\n canUseMultiTenancy: () => boolean;\n canUseTeams: () => boolean;\n canUsePrivateFiles: () => boolean;\n canUseFileManagerThreatDetection: () => boolean;\n canUseWorkflows: () => boolean;\n canUseHcmsFieldPermissions: () => boolean;\n}\n\nconst WcpProjectLicenseContext = createContext<WcpProjectLicenseContextValue | null>(null);\n\nexport const WcpProjectLicenseProvider: React.FC<{ children: React.ReactNode }> = ({\n children\n}) => {\n const license = useMemo(() => {\n const licenseEnv = process.env.WCP_PROJECT_LICENSE;\n if (!licenseEnv) {\n return null;\n }\n\n try {\n const licenseDto = JSON.parse(licenseEnv) as DecryptedWcpProjectLicense;\n return License.fromLicenseDto(licenseDto);\n } catch (e) {\n console.warn(\n \"Failed to parse WCP_PROJECT_LICENSE environment variable. Expected valid JSON with DecryptedWcpProjectLicense format:\",\n e\n );\n return null;\n }\n }, []);\n\n const hasLicense = !!license;\n\n const value: WcpProjectLicenseContextValue = {\n hasLicense,\n canUseMultiTenancy: () => hasLicense,\n canUseTeams: () => license?.canUseTeams() ?? false,\n canUsePrivateFiles: () => license?.canUsePrivateFiles() ?? false,\n canUseFileManagerThreatDetection: () =>\n license?.canUseFileManagerThreatDetection() ?? false,\n canUseWorkflows: () => license?.canUseWorkflows() ?? false,\n canUseHcmsFieldPermissions: () => license?.canUseHcmsFieldPermissions() ?? false\n };\n\n return (\n <WcpProjectLicenseContext.Provider value={value}>\n {children}\n </WcpProjectLicenseContext.Provider>\n );\n};\n\nexport const useWcpProjectLicense = () => {\n const context = useContext(WcpProjectLicenseContext);\n if (!context) {\n throw new Error(\"useWcpProjectLicense must be used within a WcpProjectLicenseProvider\");\n }\n return context;\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,aAAa,EAAEC,UAAU,EAAEC,OAAO,QAAQ,OAAO;AACjE,SAASC,OAAO,QAAQ,aAAa;AAarC,MAAMC,wBAAwB,gBAAGJ,aAAa,CAAuC,IAAI,CAAC;AAE1F,OAAO,MAAMK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wBAAwB,CAAC;EACpD,IAAI,CAAC0B,OAAO,EAAE;IACV,MAAM,IAAIC,KAAK,CAAC,sEAAsE,CAAC;EAC3F;EACA,OAAOD,OAAO;AAClB,CAAC","ignoreList":[]}
|
|
@@ -2,9 +2,11 @@ import "tsx/esm";
|
|
|
2
2
|
import { Properties, toObject } from "@webiny/react-properties";
|
|
3
3
|
import debounce from "debounce";
|
|
4
4
|
import React from "react";
|
|
5
|
-
import
|
|
5
|
+
import { createRoot } from "react-dom/client";
|
|
6
|
+
import { JSDOM } from "jsdom";
|
|
6
7
|
import { serializeError } from "serialize-error";
|
|
7
8
|
import { ProjectModel } from "../../models/ProjectModel.js";
|
|
9
|
+
import { toImportSpecifier } from "../../utils/index.js";
|
|
8
10
|
import { EnvProvider } from "./EnvContext.js";
|
|
9
11
|
import { WcpProjectLicenseProvider } from "./WcpProjectLicenseContext.js";
|
|
10
12
|
const sendError = err => {
|
|
@@ -46,12 +48,19 @@ const {
|
|
|
46
48
|
const project = ProjectModel.fromDto(projectModelDto);
|
|
47
49
|
const {
|
|
48
50
|
Extensions
|
|
49
|
-
} = await import(project.paths.webinyConfigBaseFile.toString());
|
|
51
|
+
} = await import(toImportSpecifier(project.paths.webinyConfigBaseFile.toString()));
|
|
50
52
|
const onChange = debounce(value => {
|
|
51
53
|
sendSuccess(toObject(value));
|
|
52
54
|
process.exit(0);
|
|
53
55
|
});
|
|
54
|
-
|
|
56
|
+
const {
|
|
57
|
+
window
|
|
58
|
+
} = new JSDOM(`<div id="root"/>`);
|
|
59
|
+
global.window = window;
|
|
60
|
+
global.document = window.document;
|
|
61
|
+
const root = window.document.getElementById("root");
|
|
62
|
+
const reactRoot = createRoot(root);
|
|
63
|
+
reactRoot.render(/*#__PURE__*/React.createElement(WcpProjectLicenseProvider, null, /*#__PURE__*/React.createElement(EnvProvider, null, /*#__PURE__*/React.createElement(Properties, {
|
|
55
64
|
onChange: onChange
|
|
56
65
|
}, /*#__PURE__*/React.createElement(Extensions, null)))));
|
|
57
66
|
|