@goldstack/template-ssr-cli 0.1.1
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/bin/template +11 -0
- package/dist/src/buildBundles.d.ts +7 -0
- package/dist/src/buildBundles.d.ts.map +1 -0
- package/dist/src/buildBundles.js +26 -0
- package/dist/src/buildBundles.js.map +1 -0
- package/dist/src/templateSSRCli.d.ts +2 -0
- package/dist/src/templateSSRCli.d.ts.map +1 -0
- package/dist/src/templateSSRCli.js +87 -0
- package/dist/src/templateSSRCli.js.map +1 -0
- package/dist/src/templateSSRConsts.d.ts +2 -0
- package/dist/src/templateSSRConsts.d.ts.map +1 -0
- package/dist/src/templateSSRConsts.js +5 -0
- package/dist/src/templateSSRConsts.js.map +1 -0
- package/package.json +76 -0
package/bin/template
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
4
|
+
require('source-map-support').install();
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
6
|
+
require('./../dist/src/templateSSRCli')
|
|
7
|
+
.run(process.argv)
|
|
8
|
+
.catch((e) => {
|
|
9
|
+
console.log(e);
|
|
10
|
+
process.exit(1);
|
|
11
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { LambdaConfig } from '@goldstack/utils-aws-lambda';
|
|
2
|
+
export declare const buildBundles: ({ routesDir, configs, lambdaNamePrefix, }: {
|
|
3
|
+
routesDir: string;
|
|
4
|
+
configs: LambdaConfig[];
|
|
5
|
+
lambdaNamePrefix?: string | undefined;
|
|
6
|
+
}) => Promise<void>;
|
|
7
|
+
//# sourceMappingURL=buildBundles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildBundles.d.ts","sourceRoot":"","sources":["../../src/buildBundles.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,YAAY,EACb,MAAM,6BAA6B,CAAC;AAGrC,eAAO,MAAM,YAAY;eAKZ,MAAM;aACR,YAAY,EAAE;;MAErB,QAAQ,IAAI,CAmBf,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
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 compileBundle_1 = require("@goldstack/template-ssr-server/src/compileBundle");
|
|
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, }) => {
|
|
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, compileBundle_1.compileBundle)({
|
|
14
|
+
entryPoint: `${routesDir}/${config.relativeFilePath}`,
|
|
15
|
+
sourceMap: true,
|
|
16
|
+
metaFile: true,
|
|
17
|
+
});
|
|
18
|
+
const clientJsBundleFileName = `${destDir}/${template_ssr_server_1.clientBundleFileName}`;
|
|
19
|
+
(0, utils_sh_1.write)(compileResult.bundle, clientJsBundleFileName);
|
|
20
|
+
const sourceMapFileName = `${clientJsBundleFileName}.map`;
|
|
21
|
+
(0, utils_sh_1.write)(compileResult.sourceMap || '', sourceMapFileName);
|
|
22
|
+
(0, utils_sh_1.write)(compileResult.metaFile || '', `./distLambda/zips/${functionName}.client.meta.json`);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
exports.buildBundles = buildBundles;
|
|
26
|
+
//# sourceMappingURL=buildBundles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildBundles.js","sourceRoot":"","sources":["../../src/buildBundles.ts"],"names":[],"mappings":";;;AAAA,wEAAsE;AACtE,oFAAiF;AACjF,kEAIqC;AACrC,kDAAmD;AAE5C,MAAM,YAAY,GAAG,KAAK,EAAE,EACjC,SAAS,EACT,OAAO,EACP,gBAAgB,GAKjB,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,6BAAa,EAAC;YACxC,UAAU,EAAE,GAAG,SAAS,IAAI,MAAM,CAAC,gBAAgB,EAAE;YACrD,SAAS,EAAE,IAAI;YACf,QAAQ,EAAE,IAAI;SACf,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,sBAAsB,MAAM,CAAC;QAC1D,IAAA,gBAAK,EAAC,aAAa,CAAC,SAAS,IAAI,EAAE,EAAE,iBAAiB,CAAC,CAAC;QACxD,IAAA,gBAAK,EACH,aAAa,CAAC,QAAQ,IAAI,EAAE,EAC5B,qBAAqB,YAAY,mBAAmB,CACrD,CAAC;KACH;AACH,CAAC,CAAC;AA3BW,QAAA,YAAY,gBA2BvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templateSSRCli.d.ts","sourceRoot":"","sources":["../../src/templateSSRCli.ts"],"names":[],"mappings":"AAmBA,eAAO,MAAM,GAAG,SAAgB,MAAM,EAAE,KAAG,QAAQ,IAAI,CAgFtD,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
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 yargs_1 = __importDefault(require("yargs"));
|
|
14
|
+
const fs_1 = __importDefault(require("fs"));
|
|
15
|
+
const utils_aws_lambda_1 = require("@goldstack/utils-aws-lambda");
|
|
16
|
+
const templateSSRConsts_1 = require("./templateSSRConsts");
|
|
17
|
+
const buildBundles_1 = require("./buildBundles");
|
|
18
|
+
const run = async (args) => {
|
|
19
|
+
await (0, utils_cli_1.wrapCli)(async () => {
|
|
20
|
+
const argv = await (0, utils_package_1.buildCli)({
|
|
21
|
+
yargs: yargs_1.default,
|
|
22
|
+
deployCommands: (0, utils_package_1.buildDeployCommands)(),
|
|
23
|
+
infraCommands: (0, utils_terraform_1.infraCommands)(),
|
|
24
|
+
})
|
|
25
|
+
.command('build [deployment]', 'Build all lambdas', () => {
|
|
26
|
+
return yargs_1.default.positional('deployment', {
|
|
27
|
+
type: 'string',
|
|
28
|
+
describe: 'Name of the deployment this command should be applied to',
|
|
29
|
+
default: '',
|
|
30
|
+
});
|
|
31
|
+
})
|
|
32
|
+
.help()
|
|
33
|
+
.parse();
|
|
34
|
+
const packageConfig = new utils_package_config_1.PackageConfig({
|
|
35
|
+
packagePath: './',
|
|
36
|
+
});
|
|
37
|
+
const config = packageConfig.getConfig();
|
|
38
|
+
// update routes
|
|
39
|
+
if (!fs_1.default.existsSync(templateSSRConsts_1.defaultRoutesPath)) {
|
|
40
|
+
throw new Error(`Please specify lambda function handlers in ${templateSSRConsts_1.defaultRoutesPath} so that API Gateway route configuration can be generated.`);
|
|
41
|
+
}
|
|
42
|
+
const lambdaRoutes = (0, utils_aws_lambda_1.readLambdaConfig)(templateSSRConsts_1.defaultRoutesPath);
|
|
43
|
+
config.deployments = config.deployments.map((e) => {
|
|
44
|
+
const lambdasConfigs = (0, utils_aws_lambda_1.generateLambdaConfig)(e.configuration, lambdaRoutes);
|
|
45
|
+
e.configuration.lambdas = lambdasConfigs;
|
|
46
|
+
(0, utils_aws_lambda_1.validateDeployment)(e.configuration.lambdas);
|
|
47
|
+
return e;
|
|
48
|
+
});
|
|
49
|
+
(0, utils_package_2.writePackageConfig)(config);
|
|
50
|
+
const command = argv._[0];
|
|
51
|
+
const [, , , ...opArgs] = args;
|
|
52
|
+
if (command === 'infra') {
|
|
53
|
+
await (0, utils_terraform_aws_1.terraformAwsCli)(opArgs, {
|
|
54
|
+
// temporary workaround for https://github.com/goldstack/goldstack/issues/40
|
|
55
|
+
parallelism: 1,
|
|
56
|
+
});
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (command === 'build') {
|
|
60
|
+
const lambdaNamePrefix = packageConfig.getDeployment(opArgs[0])
|
|
61
|
+
.configuration.lambdaNamePrefix;
|
|
62
|
+
await (0, utils_aws_lambda_1.buildFunctions)({
|
|
63
|
+
routesDir: templateSSRConsts_1.defaultRoutesPath,
|
|
64
|
+
configs: lambdaRoutes,
|
|
65
|
+
lambdaNamePrefix,
|
|
66
|
+
});
|
|
67
|
+
await (0, buildBundles_1.buildBundles)({
|
|
68
|
+
routesDir: templateSSRConsts_1.defaultRoutesPath,
|
|
69
|
+
configs: lambdaRoutes,
|
|
70
|
+
lambdaNamePrefix,
|
|
71
|
+
});
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (command === 'deploy') {
|
|
75
|
+
await (0, utils_aws_lambda_1.deployFunctions)({
|
|
76
|
+
routesPath: templateSSRConsts_1.defaultRoutesPath,
|
|
77
|
+
configuration: packageConfig.getDeployment(opArgs[0]).configuration,
|
|
78
|
+
deployment: packageConfig.getDeployment(opArgs[0]),
|
|
79
|
+
config: lambdaRoutes,
|
|
80
|
+
});
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
throw new Error('Unknown command: ' + command);
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
exports.run = run;
|
|
87
|
+
//# sourceMappingURL=templateSSRCli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templateSSRCli.js","sourceRoot":"","sources":["../../src/templateSSRCli.ts"],"names":[],"mappings":";;;;;;AAAA,4DAAyE;AACzE,oDAA+C;AAC/C,gEAA2D;AAC3D,wEAAiE;AACjE,0EAAgE;AAChE,4DAA8D;AAC9D,kDAA0B;AAC1B,4CAAoB;AAEpB,kEAMqC;AACrC,2DAAwD;AACxD,iDAA8C;AAEvC,MAAM,GAAG,GAAG,KAAK,EAAE,IAAc,EAAiB,EAAE;IACzD,MAAM,IAAA,mBAAO,EAAC,KAAK,IAAI,EAAE;QACvB,MAAM,IAAI,GAAG,MAAM,IAAA,wBAAQ,EAAC;YAC1B,KAAK,EAAL,eAAK;YACL,cAAc,EAAE,IAAA,mCAAmB,GAAE;YACrC,aAAa,EAAE,IAAA,+BAAa,GAAE;SAC/B,CAAC;aACC,OAAO,CAAC,oBAAoB,EAAE,mBAAmB,EAAE,GAAG,EAAE;YACvD,OAAO,eAAK,CAAC,UAAU,CAAC,YAAY,EAAE;gBACpC,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,0DAA0D;gBACpE,OAAO,EAAE,EAAE;aACZ,CAAC,CAAC;QACL,CAAC,CAAC;aACD,IAAI,EAAE;aACN,KAAK,EAAE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c,EAAC;gBACnB,SAAS,EAAE,qCAAiB;gBAC5B,OAAO,EAAE,YAAY;gBACrB,gBAAgB;aACjB,CAAC,CAAC;YACH,MAAM,IAAA,2BAAY,EAAC;gBACjB,SAAS,EAAE,qCAAiB;gBAC5B,OAAO,EAAE,YAAY;gBACrB,gBAAgB;aACjB,CAAC,CAAC;YACH,OAAO;SACR;QAED,IAAI,OAAO,KAAK,QAAQ,EAAE;YACxB,MAAM,IAAA,kCAAe,EAAC;gBACpB,UAAU,EAAE,qCAAiB;gBAC7B,aAAa,EAAE,aAAa,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa;gBACnE,UAAU,EAAE,aAAa,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;gBAClD,MAAM,EAAE,YAAY;aACrB,CAAC,CAAC;YACH,OAAO;SACR;QAED,MAAM,IAAI,KAAK,CAAC,mBAAmB,GAAG,OAAO,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAhFW,QAAA,GAAG,OAgFd"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templateSSRConsts.d.ts","sourceRoot":"","sources":["../../src/templateSSRConsts.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templateSSRConsts.js","sourceRoot":"","sources":["../../src/templateSSRConsts.ts"],"names":[],"mappings":";;;AAAa,QAAA,iBAAiB,GAAG,cAAc,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@goldstack/template-ssr-cli",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "CLI tools for server-side rendering template",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"goldstack",
|
|
7
|
+
"utility",
|
|
8
|
+
"infrastructure",
|
|
9
|
+
"ssr",
|
|
10
|
+
"aws",
|
|
11
|
+
"IaC",
|
|
12
|
+
"configuration"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://goldstack.party",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/goldstack/goldstack/issues"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/goldstack/goldstack.git"
|
|
21
|
+
},
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"author": "Max Rohde",
|
|
24
|
+
"sideEffects": false,
|
|
25
|
+
"main": "dist/src/templateSSRCli.js",
|
|
26
|
+
"bin": {
|
|
27
|
+
"template": "./bin/template",
|
|
28
|
+
"template-s3": "./bin/template"
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "yarn clean && yarn compile",
|
|
32
|
+
"build:watch": "yarn clean && yarn compile-watch",
|
|
33
|
+
"clean": "rimraf ./dist",
|
|
34
|
+
"compile": "tsc -p tsconfig.json",
|
|
35
|
+
"compile-watch": "tsc -p tsconfig.json --watch",
|
|
36
|
+
"compile-watch:light": "nodemon --watch ./src/ -e '*' --exec 'yarn compile'",
|
|
37
|
+
"coverage": "jest --collect-coverage --passWithNoTests --config=./jest.config.js --runInBand",
|
|
38
|
+
"prepublishOnly": "yarn run build",
|
|
39
|
+
"publish": "utils-git changed --exec \"yarn npm publish $@\"",
|
|
40
|
+
"test-ci": "jest --passWithNoTests --config=./jest.config.js --runInBand",
|
|
41
|
+
"version:apply": "utils-git changed --exec \"yarn version $@ && yarn version apply\"",
|
|
42
|
+
"version:apply:force": "yarn version $@ && yarn version apply"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@goldstack/template-ssr": "0.1.1",
|
|
46
|
+
"@goldstack/template-ssr-server": "0.1.1",
|
|
47
|
+
"@goldstack/utils-aws-lambda": "0.1.32",
|
|
48
|
+
"@goldstack/utils-cli": "0.2.15",
|
|
49
|
+
"@goldstack/utils-docker": "0.3.40",
|
|
50
|
+
"@goldstack/utils-log": "0.2.16",
|
|
51
|
+
"@goldstack/utils-package": "0.3.41",
|
|
52
|
+
"@goldstack/utils-package-config": "0.3.42",
|
|
53
|
+
"@goldstack/utils-sh": "0.4.33",
|
|
54
|
+
"@goldstack/utils-template": "0.3.37",
|
|
55
|
+
"@goldstack/utils-terraform": "0.3.71",
|
|
56
|
+
"@goldstack/utils-terraform-aws": "0.3.70",
|
|
57
|
+
"source-map-support": "^0.5.21",
|
|
58
|
+
"yargs": "^17.5.1"
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@goldstack/utils-docs-cli": "0.3.11",
|
|
62
|
+
"@goldstack/utils-git": "0.1.36",
|
|
63
|
+
"@goldstack/utils-package-config-generate": "0.2.17",
|
|
64
|
+
"@types/jest": "^27.5.1",
|
|
65
|
+
"@types/node": "^17.0.33",
|
|
66
|
+
"@types/yargs": "^17.0.10",
|
|
67
|
+
"jest": "^28.1.0",
|
|
68
|
+
"rimraf": "^3.0.2",
|
|
69
|
+
"ts-jest": "^28.0.2",
|
|
70
|
+
"ts-node": "^10.8.0",
|
|
71
|
+
"typescript": "^4.7.4"
|
|
72
|
+
},
|
|
73
|
+
"publishConfig": {
|
|
74
|
+
"main": "dist/src/templateSSRCli.js"
|
|
75
|
+
}
|
|
76
|
+
}
|