@goldstack/template-ssr-cli 0.1.12 → 0.3.0
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/src/buildBundles.d.ts +10 -10
- package/dist/src/buildBundles.d.ts.map +1 -1
- package/dist/src/buildBundles.js +39 -43
- package/dist/src/buildBundles.js.map +1 -1
- package/dist/src/deployToS3.d.ts +9 -9
- package/dist/src/deployToS3.js +33 -33
- package/dist/src/templateS3Deploy.d.ts +3 -0
- package/dist/src/templateS3Deploy.d.ts.map +1 -0
- package/dist/src/templateS3Deploy.js +8 -0
- package/dist/src/templateS3Deploy.js.map +1 -0
- package/dist/src/templateSSRCli.d.ts +2 -2
- package/dist/src/templateSSRCli.js +106 -106
- package/dist/src/templateSSRConsts.d.ts +1 -1
- package/dist/src/templateSSRConsts.js +4 -4
- package/package.json +19 -19
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { BuildConfiguration, ClientBuildOptionsArgs, ServerBuildOptionsArgs } from '@goldstack/template-ssr-server-compile-bundle';
|
|
2
|
-
export type { BuildConfiguration, ClientBuildOptionsArgs, ServerBuildOptionsArgs, };
|
|
3
|
-
import { LambdaConfig } from '@goldstack/utils-aws-lambda';
|
|
4
|
-
export declare const buildBundles: ({ routesDir, configs, lambdaNamePrefix, buildConfig, deploymentName, }: {
|
|
5
|
-
routesDir: string;
|
|
6
|
-
configs: LambdaConfig[];
|
|
7
|
-
lambdaNamePrefix: string;
|
|
8
|
-
buildConfig: BuildConfiguration;
|
|
9
|
-
deploymentName: string;
|
|
10
|
-
}) => Promise<void>;
|
|
1
|
+
import type { BuildConfiguration, ClientBuildOptionsArgs, ServerBuildOptionsArgs } from '@goldstack/template-ssr-server-compile-bundle';
|
|
2
|
+
export type { BuildConfiguration, ClientBuildOptionsArgs, ServerBuildOptionsArgs, };
|
|
3
|
+
import { LambdaConfig } from '@goldstack/utils-aws-lambda';
|
|
4
|
+
export declare const buildBundles: ({ routesDir, configs, lambdaNamePrefix, buildConfig, deploymentName, }: {
|
|
5
|
+
routesDir: string;
|
|
6
|
+
configs: LambdaConfig[];
|
|
7
|
+
lambdaNamePrefix: string;
|
|
8
|
+
buildConfig: BuildConfiguration;
|
|
9
|
+
deploymentName: string;
|
|
10
|
+
}) => Promise<void>;
|
|
11
11
|
//# sourceMappingURL=buildBundles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildBundles.d.ts","sourceRoot":"","sources":["../../src/buildBundles.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACvB,MAAM,+CAA+C,CAAC;AACvD,YAAY,EACV,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,GACvB,CAAC;AAEF,OAAO,EAGL,YAAY,EACb,MAAM,6BAA6B,CAAC;AAGrC,eAAO,MAAM,YAAY;eAOZ,MAAM;aACR,YAAY,EAAE;sBACL,MAAM;iBACX,kBAAkB;oBACf,MAAM;MACpB,QAAQ,IAAI,
|
|
1
|
+
{"version":3,"file":"buildBundles.d.ts","sourceRoot":"","sources":["../../src/buildBundles.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACvB,MAAM,+CAA+C,CAAC;AACvD,YAAY,EACV,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,GACvB,CAAC;AAEF,OAAO,EAGL,YAAY,EACb,MAAM,6BAA6B,CAAC;AAGrC,eAAO,MAAM,YAAY;eAOZ,MAAM;aACR,YAAY,EAAE;sBACL,MAAM;iBACX,kBAAkB;oBACf,MAAM;MACpB,QAAQ,IAAI,CAiCf,CAAC"}
|
package/dist/src/buildBundles.js
CHANGED
|
@@ -1,44 +1,40 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildBundles = void 0;
|
|
4
|
-
const template_ssr_server_1 = require("@goldstack/template-ssr-server");
|
|
5
|
-
const template_ssr_server_compile_bundle_1 = require("@goldstack/template-ssr-server-compile-bundle");
|
|
6
|
-
const utils_aws_lambda_1 = require("@goldstack/utils-aws-lambda");
|
|
7
|
-
const utils_sh_1 = require("@goldstack/utils-sh");
|
|
8
|
-
const buildBundles = async ({ routesDir, configs, lambdaNamePrefix, buildConfig, deploymentName, }) => {
|
|
9
|
-
for await (const config of configs) {
|
|
10
|
-
const destDir = (0, utils_aws_lambda_1.getOutDirForLambda)(config);
|
|
11
|
-
(0, utils_sh_1.mkdir)('-p', destDir);
|
|
12
|
-
const functionName = (0, utils_aws_lambda_1.generateFunctionName)(lambdaNamePrefix, config);
|
|
13
|
-
const compileResult = await (0, template_ssr_server_compile_bundle_1.compileBundle)({
|
|
14
|
-
entryPoint: `${routesDir}/${config.relativeFilePath}`,
|
|
15
|
-
buildOptions: {
|
|
16
|
-
includeCss: false,
|
|
17
|
-
deploymentName,
|
|
18
|
-
},
|
|
19
|
-
buildConfig,
|
|
20
|
-
});
|
|
21
|
-
const clientJsBundleFileName = `${destDir}/${template_ssr_server_1.clientBundleFileName}`;
|
|
22
|
-
(0, utils_sh_1.write)(compileResult.bundle, clientJsBundleFileName);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
exports.buildBundles = buildBundles;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildBundles = void 0;
|
|
4
|
+
const template_ssr_server_1 = require("@goldstack/template-ssr-server");
|
|
5
|
+
const template_ssr_server_compile_bundle_1 = require("@goldstack/template-ssr-server-compile-bundle");
|
|
6
|
+
const utils_aws_lambda_1 = require("@goldstack/utils-aws-lambda");
|
|
7
|
+
const utils_sh_1 = require("@goldstack/utils-sh");
|
|
8
|
+
const buildBundles = async ({ routesDir, configs, lambdaNamePrefix, buildConfig, deploymentName, }) => {
|
|
9
|
+
for await (const config of configs) {
|
|
10
|
+
const destDir = (0, utils_aws_lambda_1.getOutDirForLambda)(config);
|
|
11
|
+
(0, utils_sh_1.mkdir)('-p', destDir);
|
|
12
|
+
const functionName = (0, utils_aws_lambda_1.generateFunctionName)(lambdaNamePrefix, config);
|
|
13
|
+
const compileResult = await (0, template_ssr_server_compile_bundle_1.compileBundle)({
|
|
14
|
+
entryPoint: `${routesDir}/${config.relativeFilePath}`,
|
|
15
|
+
buildOptions: {
|
|
16
|
+
includeCss: false,
|
|
17
|
+
deploymentName,
|
|
18
|
+
},
|
|
19
|
+
buildConfig,
|
|
20
|
+
});
|
|
21
|
+
const clientJsBundleFileName = `${destDir}/${template_ssr_server_1.clientBundleFileName}`;
|
|
22
|
+
(0, utils_sh_1.write)(compileResult.bundle, clientJsBundleFileName);
|
|
23
|
+
const sourceMapFileName = `${functionName}.map`;
|
|
24
|
+
if (compileResult.sourceMap) {
|
|
25
|
+
buildConfig.staticFileMapper.put({
|
|
26
|
+
name: sourceMapFileName,
|
|
27
|
+
generatedName: `${functionName}.[hash].map.json`,
|
|
28
|
+
content: compileResult.sourceMap,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
buildConfig.staticFileMapper.remove({ name: sourceMapFileName });
|
|
33
|
+
}
|
|
34
|
+
if (compileResult.metaFile) {
|
|
35
|
+
(0, utils_sh_1.write)(compileResult.metaFile, `./distLambda/zips/${functionName}.client.meta.json`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
exports.buildBundles = buildBundles;
|
|
44
40
|
//# sourceMappingURL=buildBundles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildBundles.js","sourceRoot":"","sources":["../../src/buildBundles.ts"],"names":[],"mappings":";;;AAAA,wEAAsE;AACtE,sGAA8E;AAY9E,kEAIqC;AACrC,kDAAmD;AAE5C,MAAM,YAAY,GAAG,KAAK,EAAE,EACjC,SAAS,EACT,OAAO,EACP,gBAAgB,EAChB,WAAW,EACX,cAAc,GAOf,EAAiB,EAAE;IAClB,IAAI,KAAK,EAAE,MAAM,MAAM,IAAI,OAAO,EAAE;QAClC,MAAM,OAAO,GAAG,IAAA,qCAAkB,EAAC,MAAM,CAAC,CAAC;QAC3C,IAAA,gBAAK,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACrB,MAAM,YAAY,GAAG,IAAA,uCAAoB,EAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;QACpE,MAAM,aAAa,GAAG,MAAM,IAAA,kDAAa,EAAC;YACxC,UAAU,EAAE,GAAG,SAAS,IAAI,MAAM,CAAC,gBAAgB,EAAE;YACrD,YAAY,EAAE;gBACZ,UAAU,EAAE,KAAK;gBACjB,cAAc;aACf;YACD,WAAW;SACZ,CAAC,CAAC;QACH,MAAM,sBAAsB,GAAG,GAAG,OAAO,IAAI,0CAAoB,EAAE,CAAC;QACpE,IAAA,gBAAK,EAAC,aAAa,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"buildBundles.js","sourceRoot":"","sources":["../../src/buildBundles.ts"],"names":[],"mappings":";;;AAAA,wEAAsE;AACtE,sGAA8E;AAY9E,kEAIqC;AACrC,kDAAmD;AAE5C,MAAM,YAAY,GAAG,KAAK,EAAE,EACjC,SAAS,EACT,OAAO,EACP,gBAAgB,EAChB,WAAW,EACX,cAAc,GAOf,EAAiB,EAAE;IAClB,IAAI,KAAK,EAAE,MAAM,MAAM,IAAI,OAAO,EAAE;QAClC,MAAM,OAAO,GAAG,IAAA,qCAAkB,EAAC,MAAM,CAAC,CAAC;QAC3C,IAAA,gBAAK,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACrB,MAAM,YAAY,GAAG,IAAA,uCAAoB,EAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;QACpE,MAAM,aAAa,GAAG,MAAM,IAAA,kDAAa,EAAC;YACxC,UAAU,EAAE,GAAG,SAAS,IAAI,MAAM,CAAC,gBAAgB,EAAE;YACrD,YAAY,EAAE;gBACZ,UAAU,EAAE,KAAK;gBACjB,cAAc;aACf;YACD,WAAW;SACZ,CAAC,CAAC;QACH,MAAM,sBAAsB,GAAG,GAAG,OAAO,IAAI,0CAAoB,EAAE,CAAC;QACpE,IAAA,gBAAK,EAAC,aAAa,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;QACpD,MAAM,iBAAiB,GAAG,GAAG,YAAY,MAAM,CAAC;QAChD,IAAI,aAAa,CAAC,SAAS,EAAE;YAC3B,WAAW,CAAC,gBAAgB,CAAC,GAAG,CAAC;gBAC/B,IAAI,EAAE,iBAAiB;gBACvB,aAAa,EAAE,GAAG,YAAY,kBAAkB;gBAChD,OAAO,EAAE,aAAa,CAAC,SAAS;aACjC,CAAC,CAAC;SACJ;aAAM;YACL,WAAW,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAC,CAAC;SAClE;QAED,IAAI,aAAa,CAAC,QAAQ,EAAE;YAC1B,IAAA,gBAAK,EACH,aAAa,CAAC,QAAQ,EACtB,qBAAqB,YAAY,mBAAmB,CACrD,CAAC;SACH;KACF;AACH,CAAC,CAAC;AA7CW,QAAA,YAAY,gBA6CvB"}
|
package/dist/src/deployToS3.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { LambdaApiDeploymentConfiguration } from '@goldstack/utils-aws-lambda';
|
|
2
|
-
import type { AWSDeployment } from '@goldstack/infra-aws';
|
|
3
|
-
export interface DeployToS3Params {
|
|
4
|
-
configuration: LambdaApiDeploymentConfiguration;
|
|
5
|
-
deployment: AWSDeployment;
|
|
6
|
-
staticFilesBucket: string;
|
|
7
|
-
publicFilesBucket: string;
|
|
8
|
-
}
|
|
9
|
-
export declare const deployToS3: (params: DeployToS3Params) => Promise<void>;
|
|
1
|
+
import { LambdaApiDeploymentConfiguration } from '@goldstack/utils-aws-lambda';
|
|
2
|
+
import type { AWSDeployment } from '@goldstack/infra-aws';
|
|
3
|
+
export interface DeployToS3Params {
|
|
4
|
+
configuration: LambdaApiDeploymentConfiguration;
|
|
5
|
+
deployment: AWSDeployment;
|
|
6
|
+
staticFilesBucket: string;
|
|
7
|
+
publicFilesBucket: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const deployToS3: (params: DeployToS3Params) => Promise<void>;
|
|
10
10
|
//# sourceMappingURL=deployToS3.d.ts.map
|
package/dist/src/deployToS3.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deployToS3 = void 0;
|
|
4
|
-
const utils_s3_deployment_1 = require("@goldstack/utils-s3-deployment");
|
|
5
|
-
const deployToS3 = async (params) => {
|
|
6
|
-
await Promise.all([
|
|
7
|
-
(0, utils_s3_deployment_1.upload)({
|
|
8
|
-
bucket: params.publicFilesBucket,
|
|
9
|
-
bucketPath: '/',
|
|
10
|
-
localPath: 'public/',
|
|
11
|
-
region: params.deployment.awsRegion,
|
|
12
|
-
userName: params.deployment.awsUser,
|
|
13
|
-
}),
|
|
14
|
-
// uploading files again to allow CloudFront routing both to the root
|
|
15
|
-
// and the subdirectory
|
|
16
|
-
(0, utils_s3_deployment_1.upload)({
|
|
17
|
-
bucket: params.staticFilesBucket,
|
|
18
|
-
bucketPath: '/_goldstack/public',
|
|
19
|
-
localPath: 'public/',
|
|
20
|
-
region: params.deployment.awsRegion,
|
|
21
|
-
userName: params.deployment.awsUser,
|
|
22
|
-
}),
|
|
23
|
-
(0, utils_s3_deployment_1.upload)({
|
|
24
|
-
bucket: params.staticFilesBucket,
|
|
25
|
-
bucketPath: '/_goldstack/static',
|
|
26
|
-
localPath: 'static/',
|
|
27
|
-
region: params.deployment.awsRegion,
|
|
28
|
-
userName: params.deployment.awsUser,
|
|
29
|
-
skipDelete: true, // we want to keep static files in place
|
|
30
|
-
}),
|
|
31
|
-
]);
|
|
32
|
-
};
|
|
33
|
-
exports.deployToS3 = deployToS3;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deployToS3 = void 0;
|
|
4
|
+
const utils_s3_deployment_1 = require("@goldstack/utils-s3-deployment");
|
|
5
|
+
const deployToS3 = async (params) => {
|
|
6
|
+
await Promise.all([
|
|
7
|
+
(0, utils_s3_deployment_1.upload)({
|
|
8
|
+
bucket: params.publicFilesBucket,
|
|
9
|
+
bucketPath: '/',
|
|
10
|
+
localPath: 'public/',
|
|
11
|
+
region: params.deployment.awsRegion,
|
|
12
|
+
userName: params.deployment.awsUser,
|
|
13
|
+
}),
|
|
14
|
+
// uploading files again to allow CloudFront routing both to the root
|
|
15
|
+
// and the subdirectory
|
|
16
|
+
(0, utils_s3_deployment_1.upload)({
|
|
17
|
+
bucket: params.staticFilesBucket,
|
|
18
|
+
bucketPath: '/_goldstack/public',
|
|
19
|
+
localPath: 'public/',
|
|
20
|
+
region: params.deployment.awsRegion,
|
|
21
|
+
userName: params.deployment.awsUser,
|
|
22
|
+
}),
|
|
23
|
+
(0, utils_s3_deployment_1.upload)({
|
|
24
|
+
bucket: params.staticFilesBucket,
|
|
25
|
+
bucketPath: '/_goldstack/static',
|
|
26
|
+
localPath: 'static/',
|
|
27
|
+
region: params.deployment.awsRegion,
|
|
28
|
+
userName: params.deployment.awsUser,
|
|
29
|
+
skipDelete: true, // we want to keep static files in place
|
|
30
|
+
}),
|
|
31
|
+
]);
|
|
32
|
+
};
|
|
33
|
+
exports.deployToS3 = deployToS3;
|
|
34
34
|
//# sourceMappingURL=deployToS3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templateS3Deploy.d.ts","sourceRoot":"","sources":["../../src/templateS3Deploy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,eAAO,MAAM,SAAS,WACZ,gBAAgB,QAClB,MAAM,EAAE,KACb,QAAQ,IAAI,CAEd,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deployCli = void 0;
|
|
4
|
+
const deployCli = async (config, args) => {
|
|
5
|
+
throw new Error('Deploy not supported yet.');
|
|
6
|
+
};
|
|
7
|
+
exports.deployCli = deployCli;
|
|
8
|
+
//# sourceMappingURL=templateS3Deploy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templateS3Deploy.js","sourceRoot":"","sources":["../../src/templateS3Deploy.ts"],"names":[],"mappings":";;;AAEO,MAAM,SAAS,GAAG,KAAK,EAC5B,MAAwB,EACxB,IAAc,EACC,EAAE;IACjB,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;AAC/C,CAAC,CAAC;AALW,QAAA,SAAS,aAKpB"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { BuildConfiguration } from '@goldstack/template-ssr';
|
|
2
|
-
export declare const run: (args: string[], buildConfig: BuildConfiguration) => Promise<void>;
|
|
1
|
+
import type { BuildConfiguration } from '@goldstack/template-ssr';
|
|
2
|
+
export declare const run: (args: string[], buildConfig: BuildConfiguration) => Promise<void>;
|
|
3
3
|
//# sourceMappingURL=templateSSRCli.d.ts.map
|
|
@@ -1,107 +1,107 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.run = void 0;
|
|
7
|
-
const utils_package_1 = require("@goldstack/utils-package");
|
|
8
|
-
const utils_cli_1 = require("@goldstack/utils-cli");
|
|
9
|
-
const utils_terraform_1 = require("@goldstack/utils-terraform");
|
|
10
|
-
const utils_terraform_aws_1 = require("@goldstack/utils-terraform-aws");
|
|
11
|
-
const utils_package_config_1 = require("@goldstack/utils-package-config");
|
|
12
|
-
const utils_package_2 = require("@goldstack/utils-package");
|
|
13
|
-
const infra_1 = require("@goldstack/infra");
|
|
14
|
-
const yargs_1 = __importDefault(require("yargs"));
|
|
15
|
-
const fs_1 = __importDefault(require("fs"));
|
|
16
|
-
const template_ssr_1 = require("@goldstack/template-ssr");
|
|
17
|
-
const utils_aws_lambda_1 = require("@goldstack/utils-aws-lambda");
|
|
18
|
-
const templateSSRConsts_1 = require("./templateSSRConsts");
|
|
19
|
-
const buildBundles_1 = require("./buildBundles");
|
|
20
|
-
const deployToS3_1 = require("./deployToS3");
|
|
21
|
-
const run = async (args, buildConfig) => {
|
|
22
|
-
await (0, utils_cli_1.wrapCli)(async () => {
|
|
23
|
-
const argv = await (0, utils_package_1.buildCli)({
|
|
24
|
-
yargs: yargs_1.default,
|
|
25
|
-
deployCommands: (0, utils_package_1.buildDeployCommands)(),
|
|
26
|
-
infraCommands: (0, utils_terraform_1.infraCommands)(),
|
|
27
|
-
})
|
|
28
|
-
.command('build [deployment]', 'Build all lambdas', () => {
|
|
29
|
-
return yargs_1.default.positional('deployment', {
|
|
30
|
-
type: 'string',
|
|
31
|
-
describe: 'Name of the deployment this command should be applied to',
|
|
32
|
-
default: '',
|
|
33
|
-
});
|
|
34
|
-
})
|
|
35
|
-
.help()
|
|
36
|
-
.parse();
|
|
37
|
-
const packageConfig = new utils_package_config_1.PackageConfig({
|
|
38
|
-
packagePath: './',
|
|
39
|
-
});
|
|
40
|
-
const config = packageConfig.getConfig();
|
|
41
|
-
// update routes
|
|
42
|
-
if (!fs_1.default.existsSync(templateSSRConsts_1.defaultRoutesPath)) {
|
|
43
|
-
throw new Error(`Please specify lambda function handlers in ${templateSSRConsts_1.defaultRoutesPath} so that API Gateway route configuration can be generated.`);
|
|
44
|
-
}
|
|
45
|
-
const lambdaRoutes = (0, utils_aws_lambda_1.readLambdaConfig)(templateSSRConsts_1.defaultRoutesPath);
|
|
46
|
-
config.deployments = config.deployments.map((e) => {
|
|
47
|
-
const lambdasConfigs = (0, utils_aws_lambda_1.generateLambdaConfig)((0, template_ssr_1.createLambdaAPIDeploymentConfiguration)(e.configuration), lambdaRoutes);
|
|
48
|
-
e.configuration.lambdas = lambdasConfigs;
|
|
49
|
-
(0, utils_aws_lambda_1.validateDeployment)((0, template_ssr_1.createLambdaAPIDeploymentConfiguration)(e.configuration).lambdas);
|
|
50
|
-
return e;
|
|
51
|
-
});
|
|
52
|
-
(0, utils_package_2.writePackageConfig)(config);
|
|
53
|
-
const command = argv._[0];
|
|
54
|
-
const [, , , ...opArgs] = args;
|
|
55
|
-
if (command === 'infra') {
|
|
56
|
-
await (0, utils_terraform_aws_1.terraformAwsCli)(opArgs, {
|
|
57
|
-
// temporary workaround for https://github.com/goldstack/goldstack/issues/40
|
|
58
|
-
parallelism: 1,
|
|
59
|
-
});
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
if (command === 'build') {
|
|
63
|
-
const deployment = packageConfig.getDeployment(opArgs[0]);
|
|
64
|
-
const lambdaNamePrefix = deployment.configuration.lambdaNamePrefix;
|
|
65
|
-
await (0, utils_aws_lambda_1.buildFunctions)({
|
|
66
|
-
routesDir: templateSSRConsts_1.defaultRoutesPath,
|
|
67
|
-
deploymentName: deployment.name,
|
|
68
|
-
buildOptions: buildConfig.createServerBuildOptions,
|
|
69
|
-
configs: lambdaRoutes,
|
|
70
|
-
lambdaNamePrefix: lambdaNamePrefix || '',
|
|
71
|
-
});
|
|
72
|
-
await (0, buildBundles_1.buildBundles)({
|
|
73
|
-
routesDir: templateSSRConsts_1.defaultRoutesPath,
|
|
74
|
-
configs: lambdaRoutes,
|
|
75
|
-
deploymentName: deployment.name,
|
|
76
|
-
lambdaNamePrefix: lambdaNamePrefix || '',
|
|
77
|
-
buildConfig,
|
|
78
|
-
});
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
if (command === 'deploy') {
|
|
82
|
-
const deployment = packageConfig.getDeployment(opArgs[0]);
|
|
83
|
-
const config = deployment.configuration;
|
|
84
|
-
const deploymentState = (0, infra_1.readDeploymentState)('./', deployment.name);
|
|
85
|
-
const staticFilesBucket = (0, infra_1.readTerraformStateVariable)(deploymentState, 'static_files_bucket');
|
|
86
|
-
const publicFilesBucket = (0, infra_1.readTerraformStateVariable)(deploymentState, 'public_files_bucket');
|
|
87
|
-
await Promise.all([
|
|
88
|
-
(0, utils_aws_lambda_1.deployFunctions)({
|
|
89
|
-
routesPath: templateSSRConsts_1.defaultRoutesPath,
|
|
90
|
-
configuration: (0, template_ssr_1.createLambdaAPIDeploymentConfiguration)(config),
|
|
91
|
-
deployment: packageConfig.getDeployment(opArgs[0]),
|
|
92
|
-
config: lambdaRoutes,
|
|
93
|
-
}),
|
|
94
|
-
(0, deployToS3_1.deployToS3)({
|
|
95
|
-
configuration: (0, template_ssr_1.createLambdaAPIDeploymentConfiguration)(config),
|
|
96
|
-
deployment: packageConfig.getDeployment(opArgs[0]),
|
|
97
|
-
staticFilesBucket,
|
|
98
|
-
publicFilesBucket,
|
|
99
|
-
}),
|
|
100
|
-
]);
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
throw new Error('Unknown command: ' + command);
|
|
104
|
-
});
|
|
105
|
-
};
|
|
106
|
-
exports.run = run;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.run = void 0;
|
|
7
|
+
const utils_package_1 = require("@goldstack/utils-package");
|
|
8
|
+
const utils_cli_1 = require("@goldstack/utils-cli");
|
|
9
|
+
const utils_terraform_1 = require("@goldstack/utils-terraform");
|
|
10
|
+
const utils_terraform_aws_1 = require("@goldstack/utils-terraform-aws");
|
|
11
|
+
const utils_package_config_1 = require("@goldstack/utils-package-config");
|
|
12
|
+
const utils_package_2 = require("@goldstack/utils-package");
|
|
13
|
+
const infra_1 = require("@goldstack/infra");
|
|
14
|
+
const yargs_1 = __importDefault(require("yargs"));
|
|
15
|
+
const fs_1 = __importDefault(require("fs"));
|
|
16
|
+
const template_ssr_1 = require("@goldstack/template-ssr");
|
|
17
|
+
const utils_aws_lambda_1 = require("@goldstack/utils-aws-lambda");
|
|
18
|
+
const templateSSRConsts_1 = require("./templateSSRConsts");
|
|
19
|
+
const buildBundles_1 = require("./buildBundles");
|
|
20
|
+
const deployToS3_1 = require("./deployToS3");
|
|
21
|
+
const run = async (args, buildConfig) => {
|
|
22
|
+
await (0, utils_cli_1.wrapCli)(async () => {
|
|
23
|
+
const argv = await (0, utils_package_1.buildCli)({
|
|
24
|
+
yargs: yargs_1.default,
|
|
25
|
+
deployCommands: (0, utils_package_1.buildDeployCommands)(),
|
|
26
|
+
infraCommands: (0, utils_terraform_1.infraCommands)(),
|
|
27
|
+
})
|
|
28
|
+
.command('build [deployment]', 'Build all lambdas', () => {
|
|
29
|
+
return yargs_1.default.positional('deployment', {
|
|
30
|
+
type: 'string',
|
|
31
|
+
describe: 'Name of the deployment this command should be applied to',
|
|
32
|
+
default: '',
|
|
33
|
+
});
|
|
34
|
+
})
|
|
35
|
+
.help()
|
|
36
|
+
.parse();
|
|
37
|
+
const packageConfig = new utils_package_config_1.PackageConfig({
|
|
38
|
+
packagePath: './',
|
|
39
|
+
});
|
|
40
|
+
const config = packageConfig.getConfig();
|
|
41
|
+
// update routes
|
|
42
|
+
if (!fs_1.default.existsSync(templateSSRConsts_1.defaultRoutesPath)) {
|
|
43
|
+
throw new Error(`Please specify lambda function handlers in ${templateSSRConsts_1.defaultRoutesPath} so that API Gateway route configuration can be generated.`);
|
|
44
|
+
}
|
|
45
|
+
const lambdaRoutes = (0, utils_aws_lambda_1.readLambdaConfig)(templateSSRConsts_1.defaultRoutesPath);
|
|
46
|
+
config.deployments = config.deployments.map((e) => {
|
|
47
|
+
const lambdasConfigs = (0, utils_aws_lambda_1.generateLambdaConfig)((0, template_ssr_1.createLambdaAPIDeploymentConfiguration)(e.configuration), lambdaRoutes);
|
|
48
|
+
e.configuration.lambdas = lambdasConfigs;
|
|
49
|
+
(0, utils_aws_lambda_1.validateDeployment)((0, template_ssr_1.createLambdaAPIDeploymentConfiguration)(e.configuration).lambdas);
|
|
50
|
+
return e;
|
|
51
|
+
});
|
|
52
|
+
(0, utils_package_2.writePackageConfig)(config);
|
|
53
|
+
const command = argv._[0];
|
|
54
|
+
const [, , , ...opArgs] = args;
|
|
55
|
+
if (command === 'infra') {
|
|
56
|
+
await (0, utils_terraform_aws_1.terraformAwsCli)(opArgs, {
|
|
57
|
+
// temporary workaround for https://github.com/goldstack/goldstack/issues/40
|
|
58
|
+
parallelism: 1,
|
|
59
|
+
});
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (command === 'build') {
|
|
63
|
+
const deployment = packageConfig.getDeployment(opArgs[0]);
|
|
64
|
+
const lambdaNamePrefix = deployment.configuration.lambdaNamePrefix;
|
|
65
|
+
await (0, utils_aws_lambda_1.buildFunctions)({
|
|
66
|
+
routesDir: templateSSRConsts_1.defaultRoutesPath,
|
|
67
|
+
deploymentName: deployment.name,
|
|
68
|
+
buildOptions: buildConfig.createServerBuildOptions,
|
|
69
|
+
configs: lambdaRoutes,
|
|
70
|
+
lambdaNamePrefix: lambdaNamePrefix || '',
|
|
71
|
+
});
|
|
72
|
+
await (0, buildBundles_1.buildBundles)({
|
|
73
|
+
routesDir: templateSSRConsts_1.defaultRoutesPath,
|
|
74
|
+
configs: lambdaRoutes,
|
|
75
|
+
deploymentName: deployment.name,
|
|
76
|
+
lambdaNamePrefix: lambdaNamePrefix || '',
|
|
77
|
+
buildConfig,
|
|
78
|
+
});
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (command === 'deploy') {
|
|
82
|
+
const deployment = packageConfig.getDeployment(opArgs[0]);
|
|
83
|
+
const config = deployment.configuration;
|
|
84
|
+
const deploymentState = (0, infra_1.readDeploymentState)('./', deployment.name);
|
|
85
|
+
const staticFilesBucket = (0, infra_1.readTerraformStateVariable)(deploymentState, 'static_files_bucket');
|
|
86
|
+
const publicFilesBucket = (0, infra_1.readTerraformStateVariable)(deploymentState, 'public_files_bucket');
|
|
87
|
+
await Promise.all([
|
|
88
|
+
(0, utils_aws_lambda_1.deployFunctions)({
|
|
89
|
+
routesPath: templateSSRConsts_1.defaultRoutesPath,
|
|
90
|
+
configuration: (0, template_ssr_1.createLambdaAPIDeploymentConfiguration)(config),
|
|
91
|
+
deployment: packageConfig.getDeployment(opArgs[0]),
|
|
92
|
+
config: lambdaRoutes,
|
|
93
|
+
}),
|
|
94
|
+
(0, deployToS3_1.deployToS3)({
|
|
95
|
+
configuration: (0, template_ssr_1.createLambdaAPIDeploymentConfiguration)(config),
|
|
96
|
+
deployment: packageConfig.getDeployment(opArgs[0]),
|
|
97
|
+
staticFilesBucket,
|
|
98
|
+
publicFilesBucket,
|
|
99
|
+
}),
|
|
100
|
+
]);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
throw new Error('Unknown command: ' + command);
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
exports.run = run;
|
|
107
107
|
//# sourceMappingURL=templateSSRCli.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const defaultRoutesPath = "./src/routes";
|
|
1
|
+
export declare const defaultRoutesPath = "./src/routes";
|
|
2
2
|
//# sourceMappingURL=templateSSRConsts.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defaultRoutesPath = void 0;
|
|
4
|
-
exports.defaultRoutesPath = './src/routes';
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defaultRoutesPath = void 0;
|
|
4
|
+
exports.defaultRoutesPath = './src/routes';
|
|
5
5
|
//# sourceMappingURL=templateSSRConsts.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goldstack/template-ssr-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "CLI tools for server-side rendering template",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"goldstack",
|
|
@@ -38,29 +38,29 @@
|
|
|
38
38
|
"version:apply:force": "yarn version $@ && yarn version apply"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@goldstack/infra": "0.
|
|
42
|
-
"@goldstack/infra-aws": "0.
|
|
43
|
-
"@goldstack/template-ssr": "0.
|
|
44
|
-
"@goldstack/template-ssr-server": "0.
|
|
45
|
-
"@goldstack/template-ssr-server-compile-bundle": "0.
|
|
46
|
-
"@goldstack/utils-aws-lambda": "0.
|
|
47
|
-
"@goldstack/utils-cli": "0.
|
|
48
|
-
"@goldstack/utils-docker": "0.
|
|
49
|
-
"@goldstack/utils-log": "0.
|
|
50
|
-
"@goldstack/utils-package": "0.
|
|
51
|
-
"@goldstack/utils-package-config": "0.
|
|
52
|
-
"@goldstack/utils-s3-deployment": "0.
|
|
53
|
-
"@goldstack/utils-sh": "0.
|
|
54
|
-
"@goldstack/utils-template": "0.
|
|
55
|
-
"@goldstack/utils-terraform": "0.
|
|
56
|
-
"@goldstack/utils-terraform-aws": "0.
|
|
41
|
+
"@goldstack/infra": "0.4.0",
|
|
42
|
+
"@goldstack/infra-aws": "0.4.0",
|
|
43
|
+
"@goldstack/template-ssr": "0.3.0",
|
|
44
|
+
"@goldstack/template-ssr-server": "0.3.0",
|
|
45
|
+
"@goldstack/template-ssr-server-compile-bundle": "0.3.0",
|
|
46
|
+
"@goldstack/utils-aws-lambda": "0.3.0",
|
|
47
|
+
"@goldstack/utils-cli": "0.3.0",
|
|
48
|
+
"@goldstack/utils-docker": "0.4.0",
|
|
49
|
+
"@goldstack/utils-log": "0.3.0",
|
|
50
|
+
"@goldstack/utils-package": "0.4.0",
|
|
51
|
+
"@goldstack/utils-package-config": "0.4.0",
|
|
52
|
+
"@goldstack/utils-s3-deployment": "0.5.0",
|
|
53
|
+
"@goldstack/utils-sh": "0.5.0",
|
|
54
|
+
"@goldstack/utils-template": "0.4.0",
|
|
55
|
+
"@goldstack/utils-terraform": "0.4.0",
|
|
56
|
+
"@goldstack/utils-terraform-aws": "0.4.0",
|
|
57
57
|
"source-map-support": "^0.5.21",
|
|
58
58
|
"yargs": "^17.5.1"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@goldstack/utils-docs-cli": "0.3.11",
|
|
62
|
-
"@goldstack/utils-git": "0.
|
|
63
|
-
"@goldstack/utils-package-config-generate": "0.
|
|
62
|
+
"@goldstack/utils-git": "0.2.0",
|
|
63
|
+
"@goldstack/utils-package-config-generate": "0.3.0",
|
|
64
64
|
"@types/jest": "^28.1.8",
|
|
65
65
|
"@types/node": "^18.7.13",
|
|
66
66
|
"@types/yargs": "^17.0.10",
|