serverless-plugin-module-registry 1.0.12 → 1.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +12 -0
- package/dist/index.js +150 -5
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
- package/src/internal-infrastructure/__tests__/custom-stream-enabler.test.ts +214 -0
- package/src/internal-infrastructure/__tests__/eventbridge-config.test.ts +135 -0
- package/src/internal-infrastructure/__tests__/role-updater.test.ts +781 -0
- package/src/internal-infrastructure/__tests__/stream-processor.test.ts +994 -0
- package/src/internal-infrastructure/handlers/custom-stream-enabler.ts +163 -0
- package/src/internal-infrastructure/handlers/role-updater.ts +402 -0
- package/src/internal-infrastructure/handlers/shared/logger.ts +48 -0
- package/src/internal-infrastructure/handlers/shared/types.ts +31 -0
- package/src/internal-infrastructure/handlers/stream-processor.ts +371 -0
- package/src/internal-infrastructure/resources/cloudwatch.yml +36 -0
- package/src/internal-infrastructure/resources/custom-stream-enabler.yml +106 -0
- package/src/internal-infrastructure/resources/dynamodb.yml +74 -0
- package/src/internal-infrastructure/resources/eventbridge.yml +26 -0
- package/src/internal-infrastructure/resources/iam.yml +110 -0
- package/src/internal-infrastructure/resources/outputs.yml +13 -0
- package/src/internal-infrastructure/resources/sqs.yml +57 -0
- package/src/internal-infrastructure/serverless.yml +69 -0
package/dist/index.d.ts
CHANGED
|
@@ -458,6 +458,18 @@ declare class ServerlessModuleRegistryPlugin {
|
|
|
458
458
|
* Runs BEFORE main deployment to ensure table exists
|
|
459
459
|
*/
|
|
460
460
|
private deployInternalInfrastructure;
|
|
461
|
+
/**
|
|
462
|
+
* Standalone command handler: deploy module registry infrastructure
|
|
463
|
+
* Bypasses the `enabled: false` check — deploys the DynamoDB table, EventBridge bus, SQS, and Lambda processors.
|
|
464
|
+
* Usage: `npx serverless@4 registryDeployInfra --stage dev --region sa-east-1`
|
|
465
|
+
*/
|
|
466
|
+
private registryDeployInfraHandler;
|
|
467
|
+
/**
|
|
468
|
+
* Standalone command handler: validate/package module registry infrastructure
|
|
469
|
+
* Validates configuration and checks that internal-infrastructure directory exists.
|
|
470
|
+
* Usage: `npx serverless@4 registryPackageInfra --stage dev --region sa-east-1`
|
|
471
|
+
*/
|
|
472
|
+
private registryPackageInfraHandler;
|
|
461
473
|
/**
|
|
462
474
|
* Handler for the registryGenerate command
|
|
463
475
|
*/
|
package/dist/index.js
CHANGED
|
@@ -16069,6 +16069,42 @@ var PLUGIN_COMMANDS = {
|
|
|
16069
16069
|
type: "boolean"
|
|
16070
16070
|
}
|
|
16071
16071
|
}
|
|
16072
|
+
},
|
|
16073
|
+
registryDeployInfra: {
|
|
16074
|
+
usage: "Deploy the module registry internal infrastructure stack (DynamoDB, EventBridge, SQS, Lambda)",
|
|
16075
|
+
lifecycleEvents: ["deploy"],
|
|
16076
|
+
options: {
|
|
16077
|
+
module: {
|
|
16078
|
+
usage: "Scope composer plugin to a single module during init (avoids loading all modules)",
|
|
16079
|
+
shortcut: "m",
|
|
16080
|
+
required: false,
|
|
16081
|
+
type: "string"
|
|
16082
|
+
},
|
|
16083
|
+
force: {
|
|
16084
|
+
usage: "Force deploy even if internalInfrastructure.enabled is false",
|
|
16085
|
+
shortcut: "f",
|
|
16086
|
+
required: false,
|
|
16087
|
+
type: "boolean"
|
|
16088
|
+
}
|
|
16089
|
+
}
|
|
16090
|
+
},
|
|
16091
|
+
registryPackageInfra: {
|
|
16092
|
+
usage: "Validate and package the module registry internal infrastructure",
|
|
16093
|
+
lifecycleEvents: ["package"],
|
|
16094
|
+
options: {
|
|
16095
|
+
module: {
|
|
16096
|
+
usage: "Scope composer plugin to a single module during init",
|
|
16097
|
+
shortcut: "m",
|
|
16098
|
+
required: false,
|
|
16099
|
+
type: "string"
|
|
16100
|
+
},
|
|
16101
|
+
verbose: {
|
|
16102
|
+
usage: "Show detailed validation information",
|
|
16103
|
+
shortcut: "v",
|
|
16104
|
+
required: false,
|
|
16105
|
+
type: "boolean"
|
|
16106
|
+
}
|
|
16107
|
+
}
|
|
16072
16108
|
}
|
|
16073
16109
|
};
|
|
16074
16110
|
var PLUGIN_HOOKS = {
|
|
@@ -16076,7 +16112,9 @@ var PLUGIN_HOOKS = {
|
|
|
16076
16112
|
"before:package:initialize": "processModuleRegistryWithVariableResolution",
|
|
16077
16113
|
"after:aws:deploy:deploy:updateStack": "ensureTableAndUpdateData",
|
|
16078
16114
|
"registryGenerate:generate": "registryGenerateHandler",
|
|
16079
|
-
"registryGeneratePackage:create": "generateServicePackageCommand"
|
|
16115
|
+
"registryGeneratePackage:create": "generateServicePackageCommand",
|
|
16116
|
+
"registryDeployInfra:deploy": "registryDeployInfraHandler",
|
|
16117
|
+
"registryPackageInfra:package": "registryPackageInfraHandler"
|
|
16080
16118
|
};
|
|
16081
16119
|
|
|
16082
16120
|
// src/core/config.ts
|
|
@@ -17812,8 +17850,27 @@ async function deployInternalInfrastructure(config, logger) {
|
|
|
17812
17850
|
}
|
|
17813
17851
|
async function runServerlessDeploy(cwd, params, logger) {
|
|
17814
17852
|
const { execa: execa2 } = await Promise.resolve().then(() => (init_execa(), execa_exports));
|
|
17815
|
-
const
|
|
17816
|
-
|
|
17853
|
+
const candidates = [
|
|
17854
|
+
import_path6.default.join(cwd, "../../node_modules", ".bin", "serverless"),
|
|
17855
|
+
// module-registry's own node_modules
|
|
17856
|
+
import_path6.default.join(cwd, "../../../../node_modules", ".bin", "serverless"),
|
|
17857
|
+
// project root node_modules
|
|
17858
|
+
"npx"
|
|
17859
|
+
// fallback to npx
|
|
17860
|
+
];
|
|
17861
|
+
let serverlessBin = "npx";
|
|
17862
|
+
for (const candidate of candidates) {
|
|
17863
|
+
try {
|
|
17864
|
+
const fs7 = await import("fs");
|
|
17865
|
+
if (candidate !== "npx" && fs7.existsSync(candidate)) {
|
|
17866
|
+
serverlessBin = candidate;
|
|
17867
|
+
break;
|
|
17868
|
+
}
|
|
17869
|
+
} catch {
|
|
17870
|
+
}
|
|
17871
|
+
}
|
|
17872
|
+
const isNpx = serverlessBin === "npx";
|
|
17873
|
+
const slsArgs = [
|
|
17817
17874
|
"deploy",
|
|
17818
17875
|
"--stage",
|
|
17819
17876
|
params.stage,
|
|
@@ -17826,10 +17883,12 @@ async function runServerlessDeploy(cwd, params, logger) {
|
|
|
17826
17883
|
"--param",
|
|
17827
17884
|
`tableName=${params.tableName}`,
|
|
17828
17885
|
"--param",
|
|
17829
|
-
`policyPrefix=${params.policyPrefix}`,
|
|
17886
|
+
`policyPrefix=${params.policyPrefix || "none"}`,
|
|
17830
17887
|
"--param",
|
|
17831
|
-
`accountId=${params.accountId}`
|
|
17888
|
+
`accountId=${params.accountId || "auto"}`
|
|
17832
17889
|
];
|
|
17890
|
+
const args = isNpx ? ["serverless@4", ...slsArgs] : slsArgs;
|
|
17891
|
+
logger.info(` Using: ${serverlessBin}${isNpx ? " serverless@4" : ""}`);
|
|
17833
17892
|
try {
|
|
17834
17893
|
const result = await execa2(serverlessBin, args, {
|
|
17835
17894
|
cwd,
|
|
@@ -19590,6 +19649,92 @@ var ServerlessModuleRegistryPlugin = class {
|
|
|
19590
19649
|
throw new Error(`Infrastructure deployment failed: ${errorMessage}`);
|
|
19591
19650
|
}
|
|
19592
19651
|
}
|
|
19652
|
+
/**
|
|
19653
|
+
* Standalone command handler: deploy module registry infrastructure
|
|
19654
|
+
* Bypasses the `enabled: false` check — deploys the DynamoDB table, EventBridge bus, SQS, and Lambda processors.
|
|
19655
|
+
* Usage: `npx serverless@4 registryDeployInfra --stage dev --region sa-east-1`
|
|
19656
|
+
*/
|
|
19657
|
+
async registryDeployInfraHandler() {
|
|
19658
|
+
var _a4;
|
|
19659
|
+
this.pluginLogger.trackHookCall("registryDeployInfra:deploy");
|
|
19660
|
+
try {
|
|
19661
|
+
this.logger.info("\u{1F680} Force-deploying Module Registry internal infrastructure...");
|
|
19662
|
+
const service = ((_a4 = this.serverless.service.initialServerlessConfig) == null ? void 0 : _a4.service) || this.serverless.service.service;
|
|
19663
|
+
const stage = this.serverless.service.provider.stage || "dev";
|
|
19664
|
+
const region = this.serverless.service.provider.region || "us-east-1";
|
|
19665
|
+
const accountId = await this.getAwsAccountId();
|
|
19666
|
+
const prefix = `${service}-${stage}`;
|
|
19667
|
+
const tableName = `${prefix}-module-registry`;
|
|
19668
|
+
const policyPrefix = prefix;
|
|
19669
|
+
const infraStackName = `${prefix}-module-registry`;
|
|
19670
|
+
this.logger.info(` Service: ${service}`);
|
|
19671
|
+
this.logger.info(` Stack: ${infraStackName}`);
|
|
19672
|
+
this.logger.info(` Stage: ${stage}`);
|
|
19673
|
+
this.logger.info(` Region: ${region}`);
|
|
19674
|
+
this.logger.info(` Table: ${tableName}`);
|
|
19675
|
+
this.logger.info(` Account: ${accountId || "(auto-detect)"}`);
|
|
19676
|
+
const updatedInfraConfig = {
|
|
19677
|
+
enabled: true,
|
|
19678
|
+
stackName: infraStackName,
|
|
19679
|
+
stage,
|
|
19680
|
+
region,
|
|
19681
|
+
tableName,
|
|
19682
|
+
tableArn: `arn:aws:dynamodb:${region}:${accountId}:table/${tableName}`
|
|
19683
|
+
};
|
|
19684
|
+
this.configManager._config.internalInfrastructure = updatedInfraConfig;
|
|
19685
|
+
this.configManager._config.tableName = tableName;
|
|
19686
|
+
this.configManager._config.policyPrefix = policyPrefix;
|
|
19687
|
+
if (accountId) {
|
|
19688
|
+
process.env.AWS_ACCOUNT_ID = accountId;
|
|
19689
|
+
}
|
|
19690
|
+
const metadata = await deployInternalInfrastructure(this.configManager.config, this.logger);
|
|
19691
|
+
this.logger.info("\u2705 Module Registry infrastructure deployed successfully");
|
|
19692
|
+
this.logger.info(` Stack: ${metadata.stackName}`);
|
|
19693
|
+
this.logger.info(` Stream ARN: ${metadata.streamArn}`);
|
|
19694
|
+
this.logger.info(` Queue URL: ${metadata.queueUrl}`);
|
|
19695
|
+
} catch (error) {
|
|
19696
|
+
const errorMessage = error.message || String(error);
|
|
19697
|
+
this.logger.error(`\u274C Module Registry infrastructure deployment failed: ${errorMessage}`);
|
|
19698
|
+
throw new Error(`Module Registry infrastructure deployment failed: ${errorMessage}`);
|
|
19699
|
+
}
|
|
19700
|
+
}
|
|
19701
|
+
/**
|
|
19702
|
+
* Standalone command handler: validate/package module registry infrastructure
|
|
19703
|
+
* Validates configuration and checks that internal-infrastructure directory exists.
|
|
19704
|
+
* Usage: `npx serverless@4 registryPackageInfra --stage dev --region sa-east-1`
|
|
19705
|
+
*/
|
|
19706
|
+
async registryPackageInfraHandler() {
|
|
19707
|
+
var _a4;
|
|
19708
|
+
this.pluginLogger.trackHookCall("registryPackageInfra:package");
|
|
19709
|
+
try {
|
|
19710
|
+
this.logger.info("\u{1F4E6} Validating Module Registry infrastructure configuration...");
|
|
19711
|
+
const config = this.configManager.config;
|
|
19712
|
+
const serviceName = this.serverless.service.service;
|
|
19713
|
+
const stage = this.serverless.service.provider.stage || "dev";
|
|
19714
|
+
const region = config.region || this.serverless.service.provider.region || "us-east-1";
|
|
19715
|
+
const tableName = config.tableName;
|
|
19716
|
+
const infraStackName = ((_a4 = config.internalInfrastructure) == null ? void 0 : _a4.stackName) || `${serviceName}-${stage}-module-registry`;
|
|
19717
|
+
this.logger.info(` Service: ${serviceName}`);
|
|
19718
|
+
this.logger.info(` Stack: ${infraStackName}`);
|
|
19719
|
+
this.logger.info(` Stage: ${stage}`);
|
|
19720
|
+
this.logger.info(` Region: ${region}`);
|
|
19721
|
+
this.logger.info(` Table: ${tableName}`);
|
|
19722
|
+
const infraDir = import_path7.default.join(__dirname, "..", "src", "internal-infrastructure");
|
|
19723
|
+
if (!import_fs7.default.existsSync(infraDir)) {
|
|
19724
|
+
throw new Error(`Internal infrastructure directory not found at: ${infraDir}. Ensure src/internal-infrastructure/ is included in the plugin package.`);
|
|
19725
|
+
}
|
|
19726
|
+
const slsYml = import_path7.default.join(infraDir, "serverless.yml");
|
|
19727
|
+
if (!import_fs7.default.existsSync(slsYml)) {
|
|
19728
|
+
throw new Error(`serverless.yml not found at: ${slsYml}`);
|
|
19729
|
+
}
|
|
19730
|
+
this.logger.info(` Infrastructure dir: ${infraDir}`);
|
|
19731
|
+
this.logger.info("\u2705 Infrastructure configuration validated \u2014 ready for deploy");
|
|
19732
|
+
} catch (error) {
|
|
19733
|
+
const errorMessage = error.message || String(error);
|
|
19734
|
+
this.logger.error(`\u274C Infrastructure validation failed: ${errorMessage}`);
|
|
19735
|
+
throw error;
|
|
19736
|
+
}
|
|
19737
|
+
}
|
|
19593
19738
|
/**
|
|
19594
19739
|
* Handler for the registryGenerate command
|
|
19595
19740
|
*/
|