@aligent/nx-cdk 0.8.1 → 0.9.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/package.json +2 -2
- package/src/generators/helpers/configs/base-package/package.json +33 -36
- package/src/generators/helpers/configs/nxJson.js +2 -2
- package/src/generators/helpers/configs/tsConfigs.js +4 -5
- package/src/generators/helpers/utilities.d.ts +4 -1
- package/src/generators/helpers/utilities.js +2 -1
- package/src/generators/preset/files/.gitignore.template +1 -2
- package/src/generators/preset/files/.yarnrc.yml.template +4 -0
- package/src/generators/preset/files/application/package.json.template +1 -0
- package/src/generators/preset/files/eslint.config.mjs.template +11 -2
- package/src/generators/preset/files/libs/infra/eslint.config.mjs.template +1 -18
- package/src/generators/preset/files/libs/infra/package.json.template +1 -0
- package/src/generators/preset/files/vite.config.base.mjs.template +106 -0
- package/src/generators/preset/preset.js +4 -1
- package/src/generators/service/files/eslint.config.mjs.template +1 -18
- package/src/generators/service/files/package.json.template +6 -5
- package/src/generators/service/files/src/index.ts.template +3 -3
- package/src/generators/service/files/{vitest.config.mjs.template → vite.config.mjs.template} +8 -3
- package/src/generators/preset/files/rolldown.config.base.mjs.template +0 -46
- package/src/generators/preset/files/vitest.config.base.mjs.template +0 -39
- package/src/generators/service/files/rolldown.config.mjs.template +0 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aligent/nx-cdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"typings": "./src/index.d.ts",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"directory": "packages/nx-cdk"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@nx/devkit": "22.
|
|
13
|
+
"@nx/devkit": "22.7.5",
|
|
14
14
|
"ts-morph": "^27.0.2"
|
|
15
15
|
},
|
|
16
16
|
"generators": "./generators.json",
|
|
@@ -11,53 +11,50 @@
|
|
|
11
11
|
"typecheck": "nx affected -t typecheck",
|
|
12
12
|
"typecheck:all": "nx run-many -t typecheck",
|
|
13
13
|
"audit": "nx run-many -t lint typecheck test --configuration coverage --skip-nx-cache",
|
|
14
|
-
"pg:synth": "nx run application:pg:synth --
|
|
15
|
-
"pg:deploy": "nx run application:pg:deploy --
|
|
16
|
-
"pg:diff": "nx run application:pg:diff --profile playground",
|
|
17
|
-
"pg:destroy": "nx run application:pg:destroy --profile playground",
|
|
14
|
+
"pg:synth": "nx run application:pg:synth --mode=development --profile playground",
|
|
15
|
+
"pg:deploy": "nx run application:pg:deploy --mode=development --method=direct --require-approval never --profile playground",
|
|
16
|
+
"pg:diff": "nx run application:pg:diff --mode=development --profile playground",
|
|
17
|
+
"pg:destroy": "nx run application:pg:destroy --mode=development --profile playground",
|
|
18
18
|
"postinstall": "[ -d .git ] && git config core.hooksPath '.git-hooks' && chmod +x .git-hooks/* || true"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@aligent/microservice-util-lib": "^1.2.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@aligent/cdk-aspects": "^0.
|
|
25
|
-
"@aligent/cdk-nodejs-function-from-entry": "^0.2.
|
|
26
|
-
"@aligent/cdk-step-function-from-file": "^0.5.
|
|
27
|
-
"@aligent/nx-openapi": "^2.1.
|
|
28
|
-
"@aligent/ts-code-standards": "^
|
|
29
|
-
"@nx/eslint": "22.
|
|
30
|
-
"@nx/eslint-plugin": "22.
|
|
31
|
-
"@nx/js": "22.
|
|
32
|
-
"@nx/
|
|
33
|
-
"@nx/workspace": "22.
|
|
34
|
-
"@swc-node/register": "
|
|
35
|
-
"@swc/core": "
|
|
36
|
-
"@swc/helpers": "
|
|
37
|
-
"@types/aws-lambda": "^8.10.
|
|
38
|
-
"@
|
|
39
|
-
"@typescript-eslint/
|
|
40
|
-
"@
|
|
41
|
-
"@vitest/
|
|
42
|
-
"@vitest/ui": "^3.2.4",
|
|
24
|
+
"@aligent/cdk-aspects": "^0.6.3",
|
|
25
|
+
"@aligent/cdk-nodejs-function-from-entry": "^0.2.3",
|
|
26
|
+
"@aligent/cdk-step-function-from-file": "^0.5.3",
|
|
27
|
+
"@aligent/nx-openapi": "^2.1.2",
|
|
28
|
+
"@aligent/ts-code-standards": "^5.0.0",
|
|
29
|
+
"@nx/eslint": "22.7.3",
|
|
30
|
+
"@nx/eslint-plugin": "22.7.3",
|
|
31
|
+
"@nx/js": "22.7.3",
|
|
32
|
+
"@nx/vite": "22.7.3",
|
|
33
|
+
"@nx/workspace": "22.7.3",
|
|
34
|
+
"@swc-node/register": "1.11.1",
|
|
35
|
+
"@swc/core": "1.15.8",
|
|
36
|
+
"@swc/helpers": "0.5.21",
|
|
37
|
+
"@types/aws-lambda": "^8.10.161",
|
|
38
|
+
"@typescript-eslint/eslint-plugin": "8.60.1",
|
|
39
|
+
"@typescript-eslint/parser": "8.60.1",
|
|
40
|
+
"@vitest/coverage-v8": "^4.1.8",
|
|
41
|
+
"@vitest/ui": "^4.1.8",
|
|
43
42
|
"aws-cdk": "^2.1120.0",
|
|
44
43
|
"aws-cdk-lib": "^2.251.0",
|
|
45
44
|
"cdk-nag": "^2.38.2",
|
|
46
45
|
"constructs": "^10.6.0",
|
|
47
|
-
"eslint": "^
|
|
46
|
+
"eslint": "^10.4.0",
|
|
48
47
|
"eslint-config-prettier": "^10.1.8",
|
|
49
|
-
"eslint-plugin-import": "^
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"prettier": "^3.6.2",
|
|
55
|
-
"rolldown": "1.0.0-rc.1",
|
|
48
|
+
"eslint-plugin-import-x": "^4.16.2",
|
|
49
|
+
"jiti": "^2.7.0",
|
|
50
|
+
"jsonc-eslint-parser": "^3.1.0",
|
|
51
|
+
"nx": "22.7.3",
|
|
52
|
+
"prettier": "^3.8.3",
|
|
56
53
|
"tslib": "^2.8.1",
|
|
57
|
-
"tsx": "^4.
|
|
58
|
-
"typescript": "~
|
|
59
|
-
"vite": "^
|
|
60
|
-
"vitest": "^
|
|
54
|
+
"tsx": "^4.22.3",
|
|
55
|
+
"typescript": "~6.0.3",
|
|
56
|
+
"vite": "^8.0.14",
|
|
57
|
+
"vitest": "^4.1.7"
|
|
61
58
|
},
|
|
62
59
|
"nx": {
|
|
63
60
|
"includedScripts": []
|
|
@@ -68,5 +65,5 @@
|
|
|
68
65
|
"libs/*",
|
|
69
66
|
"services/*"
|
|
70
67
|
],
|
|
71
|
-
"packageManager": "yarn@4.
|
|
68
|
+
"packageManager": "yarn@4.16.0+sha512.5374c94eb4ef6aa8188fb112f20c1aa6569f248d676c5e576e1fd2a1a4d8d87a96df65d9dfe1c2a0252cbe38bda46cf18d955005b81b43cc7607a5c9d56fd2b6"
|
|
72
69
|
}
|
|
@@ -9,7 +9,7 @@ exports.NX_JSON = {
|
|
|
9
9
|
plugins: [
|
|
10
10
|
{ plugin: '@nx/eslint/plugin', options: {} },
|
|
11
11
|
{ plugin: '@nx/js/typescript', options: { build: false } },
|
|
12
|
-
{ plugin: '@nx/
|
|
12
|
+
{ plugin: '@nx/vite', options: {} },
|
|
13
13
|
],
|
|
14
14
|
namedInputs: {
|
|
15
15
|
default: ['{projectRoot}/**/*', 'sharedGlobals'],
|
|
@@ -18,7 +18,7 @@ exports.NX_JSON = {
|
|
|
18
18
|
'!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)',
|
|
19
19
|
'!{projectRoot}/tests/*',
|
|
20
20
|
'!{projectRoot}/tsconfig.spec.json',
|
|
21
|
-
'!{projectRoot}/
|
|
21
|
+
'!{projectRoot}/vite.config.m[jt]s',
|
|
22
22
|
],
|
|
23
23
|
sharedGlobals: [],
|
|
24
24
|
},
|
|
@@ -9,12 +9,11 @@ exports.TS_CONFIG_JSON = {
|
|
|
9
9
|
references: [],
|
|
10
10
|
};
|
|
11
11
|
exports.TS_CONFIG_LIB_JSON = {
|
|
12
|
-
extends:
|
|
12
|
+
extends: './tsconfig.json',
|
|
13
13
|
compilerOptions: {
|
|
14
|
-
baseUrl: '.',
|
|
15
14
|
rootDir: 'src',
|
|
16
|
-
outDir: '
|
|
17
|
-
tsBuildInfoFile: '
|
|
15
|
+
outDir: 'out-tsc/lib',
|
|
16
|
+
tsBuildInfoFile: 'out-tsc/tsconfig.lib.tsbuildinfo',
|
|
18
17
|
types: ['node'],
|
|
19
18
|
},
|
|
20
19
|
include: ['src/**/*.ts'],
|
|
@@ -22,7 +21,7 @@ exports.TS_CONFIG_LIB_JSON = {
|
|
|
22
21
|
references: [],
|
|
23
22
|
};
|
|
24
23
|
exports.TS_CONFIG_SPEC_JSON = {
|
|
25
|
-
extends:
|
|
24
|
+
extends: './tsconfig.json',
|
|
26
25
|
compilerOptions: {
|
|
27
26
|
outDir: './out-tsc/vitest',
|
|
28
27
|
types: ['vitest/globals', 'vitest/importMeta', 'node', 'vitest'],
|
|
@@ -29,6 +29,7 @@ function constructPackageJsonFile(input) {
|
|
|
29
29
|
const config = readPackageJsonConfig();
|
|
30
30
|
const devDependencies = Object.fromEntries(Object.entries({
|
|
31
31
|
'@aligent/nx-cdk': input.version,
|
|
32
|
+
'@types/node': `^${input.nodeVersion.major}`,
|
|
32
33
|
...config.devDependencies,
|
|
33
34
|
}).sort());
|
|
34
35
|
const packageJson = Object.fromEntries(Object.entries({
|
|
@@ -37,7 +38,7 @@ function constructPackageJsonFile(input) {
|
|
|
37
38
|
version: input.version,
|
|
38
39
|
...config,
|
|
39
40
|
devDependencies,
|
|
40
|
-
engines: { node: `^${input.nodeVersion}` },
|
|
41
|
+
engines: { node: `^${input.nodeVersion.full}` },
|
|
41
42
|
nx: { name: `${input.name}-int`, ...config.nx },
|
|
42
43
|
}));
|
|
43
44
|
return packageJson;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
enableScripts: true
|
|
2
|
+
|
|
1
3
|
nodeLinker: node-modules
|
|
2
4
|
|
|
5
|
+
npmMinimalAgeGate: '3d'
|
|
6
|
+
|
|
3
7
|
plugins:
|
|
4
8
|
- checksum: e5e6e2885ab0e6521b70b0af7c6d8ca2c75dcae2403706fc4600a783b339a6530a476dafb9450c9436ca4050eb6bdee9b62e6e2cebfecf1e81dd709a2480dc07
|
|
5
9
|
path: .yarn/plugins/@yarnpkg/plugin-engines.cjs
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { eslintConfigs } from '@aligent/ts-code-standards';
|
|
2
2
|
import nxEslintPlugin from '@nx/eslint-plugin';
|
|
3
|
-
import
|
|
3
|
+
import { importX } from 'eslint-plugin-import-x';
|
|
4
|
+
import * as jsonParser from 'jsonc-eslint-parser';
|
|
4
5
|
|
|
5
6
|
const eslintBaseConfig = [
|
|
6
7
|
...eslintConfigs.base,
|
|
@@ -18,7 +19,7 @@ const eslintBaseConfig = [
|
|
|
18
19
|
},
|
|
19
20
|
{
|
|
20
21
|
files: ['**/*.ts'],
|
|
21
|
-
plugins: { '@nx': nxEslintPlugin },
|
|
22
|
+
plugins: { '@nx': nxEslintPlugin, 'import-x': importX },
|
|
22
23
|
rules: {
|
|
23
24
|
'@nx/enforce-module-boundaries': [
|
|
24
25
|
'error',
|
|
@@ -40,6 +41,14 @@ const eslintBaseConfig = [
|
|
|
40
41
|
],
|
|
41
42
|
},
|
|
42
43
|
],
|
|
44
|
+
'import-x/no-extraneous-dependencies': [
|
|
45
|
+
'warn',
|
|
46
|
+
{
|
|
47
|
+
optionalDependencies: false,
|
|
48
|
+
peerDependencies: false,
|
|
49
|
+
packageDir: ['.', '..', '../..'],
|
|
50
|
+
},
|
|
51
|
+
],
|
|
43
52
|
'no-console': 'warn',
|
|
44
53
|
},
|
|
45
54
|
},
|
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
import eslintPluginImport from 'eslint-plugin-import';
|
|
2
1
|
import baseConfig from '../../eslint.config.mjs';
|
|
3
2
|
|
|
4
|
-
export default [
|
|
5
|
-
...baseConfig,
|
|
6
|
-
{
|
|
7
|
-
files: ['**/*.ts'],
|
|
8
|
-
plugins: { import: eslintPluginImport },
|
|
9
|
-
rules: {
|
|
10
|
-
'import/no-extraneous-dependencies': [
|
|
11
|
-
'warn',
|
|
12
|
-
{
|
|
13
|
-
optionalDependencies: false,
|
|
14
|
-
peerDependencies: false,
|
|
15
|
-
packageDir: ['.', '..', '../..'],
|
|
16
|
-
},
|
|
17
|
-
],
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
];
|
|
3
|
+
export default [...baseConfig];
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { globSync } from 'node:fs';
|
|
2
|
+
import { builtinModules } from 'node:module';
|
|
3
|
+
import { extname, resolve } from 'node:path';
|
|
4
|
+
import { defineConfig } from 'vite';
|
|
5
|
+
|
|
6
|
+
export const baseConfig = defineConfig(() => {
|
|
7
|
+
return {
|
|
8
|
+
test: {
|
|
9
|
+
globals: true,
|
|
10
|
+
watch: false,
|
|
11
|
+
environment: 'node',
|
|
12
|
+
reporters: ['default'],
|
|
13
|
+
coverage: {
|
|
14
|
+
provider: 'v8',
|
|
15
|
+
exclude: [
|
|
16
|
+
'node_modules/',
|
|
17
|
+
'**/types',
|
|
18
|
+
'*.mjs',
|
|
19
|
+
'**/__data__',
|
|
20
|
+
'**/dist',
|
|
21
|
+
'**/out-tsc',
|
|
22
|
+
],
|
|
23
|
+
thresholds: {
|
|
24
|
+
branches: 80,
|
|
25
|
+
functions: 80,
|
|
26
|
+
lines: 80,
|
|
27
|
+
statements: 80,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
include: [
|
|
31
|
+
'src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}',
|
|
32
|
+
'tests/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}',
|
|
33
|
+
],
|
|
34
|
+
setupFiles: [
|
|
35
|
+
// Include the root setup file in all tests that extend this config
|
|
36
|
+
resolve(import.meta.dirname, './vitest.global.setup.mjs'),
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// ESM doesn't define __dirname/__filename. This shim ensures bundled CJS dependencies
|
|
43
|
+
// that reference them won't throw a ReferenceError at runtime.
|
|
44
|
+
// TODO: [MI-251] Support shims only when needed instead consider looking at tsup, tsdown and rollup shims plugins
|
|
45
|
+
const shimBanner = `import { fileURLToPath as __shim_fileURLToPath } from 'node:url';
|
|
46
|
+
import { dirname as __shim_dirname } from 'node:path';
|
|
47
|
+
const __filename = __shim_fileURLToPath(import.meta.url);
|
|
48
|
+
const __dirname = __shim_dirname(__filename);`;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Creates Vite environments for bundling Lambda handlers using the Vite Environment API.
|
|
52
|
+
* Each handler file gets its own environment that outputs to dist/<entryName>/index.mjs.
|
|
53
|
+
*
|
|
54
|
+
* This uses Vite's built-in `mode` to control build behaviour.
|
|
55
|
+
* See https://vite.dev/guide/env-and-mode
|
|
56
|
+
*/
|
|
57
|
+
export function defineLambdaEnvironments(subPath, options = {}, envPrefix = 'lambda') {
|
|
58
|
+
// When running vitest, skip the Lambda environments entirely
|
|
59
|
+
if (process.env.VITEST === 'true') return {};
|
|
60
|
+
|
|
61
|
+
if (subPath.includes('..')) throw new Error('Invalid path provided');
|
|
62
|
+
|
|
63
|
+
const handlersPath = resolve(process.cwd(), subPath);
|
|
64
|
+
const handlers = globSync(`${handlersPath}/**/*.ts`);
|
|
65
|
+
|
|
66
|
+
const environments = {};
|
|
67
|
+
for (const handler of handlers) {
|
|
68
|
+
const bundledPath = handler.replace(`${handlersPath}/`, '');
|
|
69
|
+
const entryName = bundledPath.replace(extname(bundledPath), '');
|
|
70
|
+
const envName = `${envPrefix}_${entryName.replace(/[\\/]/g, '_')}`;
|
|
71
|
+
|
|
72
|
+
environments[envName] = {
|
|
73
|
+
resolve: { noExternal: true },
|
|
74
|
+
build: {
|
|
75
|
+
outDir: `dist/${entryName}`,
|
|
76
|
+
minify: options.mode === 'development' ? 'oxc' : false,
|
|
77
|
+
sourcemap: options.mode !== 'production',
|
|
78
|
+
platform: 'node',
|
|
79
|
+
rollupOptions: {
|
|
80
|
+
input: { index: handler },
|
|
81
|
+
moduleTypes: { ...options.moduleTypes },
|
|
82
|
+
external: [...builtinModules, ...builtinModules.map(m => `node:${m}`)],
|
|
83
|
+
output: {
|
|
84
|
+
entryFileNames: 'index.mjs',
|
|
85
|
+
format: 'esm',
|
|
86
|
+
comments: { legal: false },
|
|
87
|
+
codeSplitting: false,
|
|
88
|
+
banner: shimBanner,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
environments,
|
|
97
|
+
builder: {
|
|
98
|
+
buildApp: async builder => {
|
|
99
|
+
const lambdaEnvs = Object.entries(builder.environments)
|
|
100
|
+
.filter(([name]) => name.startsWith(`${envPrefix}_`))
|
|
101
|
+
.map(([, env]) => env);
|
|
102
|
+
await Promise.all(lambdaEnvs.map(env => builder.build(env)));
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
}
|
|
@@ -11,6 +11,9 @@ async function presetGenerator(tree, options) {
|
|
|
11
11
|
const [nodeVersionMajor] = nodeVersion.split('.');
|
|
12
12
|
const nameParts = (0, utilities_1.splitInputName)(name);
|
|
13
13
|
const projectName = nameParts.join(' ');
|
|
14
|
+
if (!nodeVersionMajor) {
|
|
15
|
+
throw new Error(`Malformed NodeJs Version: ${nodeVersion}`);
|
|
16
|
+
}
|
|
14
17
|
const templateVars = {
|
|
15
18
|
...options,
|
|
16
19
|
projectName,
|
|
@@ -27,7 +30,7 @@ async function presetGenerator(tree, options) {
|
|
|
27
30
|
name: options.name,
|
|
28
31
|
projectName,
|
|
29
32
|
version: (0, utilities_1.getGeneratorVersion)(),
|
|
30
|
-
nodeVersion,
|
|
33
|
+
nodeVersion: { major: nodeVersionMajor, full: nodeVersion },
|
|
31
34
|
});
|
|
32
35
|
(0, devkit_1.writeJson)(tree, 'package.json', packageJson);
|
|
33
36
|
// Generate application's tsconfigs
|
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
import eslintPluginImport from 'eslint-plugin-import';
|
|
2
1
|
import baseConfig from '../../eslint.config.mjs';
|
|
3
2
|
|
|
4
|
-
export default [
|
|
5
|
-
...baseConfig,
|
|
6
|
-
{
|
|
7
|
-
files: ['**/*.ts'],
|
|
8
|
-
plugins: { import: eslintPluginImport },
|
|
9
|
-
rules: {
|
|
10
|
-
'import/no-extraneous-dependencies': [
|
|
11
|
-
'warn',
|
|
12
|
-
{
|
|
13
|
-
optionalDependencies: false,
|
|
14
|
-
peerDependencies: false,
|
|
15
|
-
packageDir: ['.', '..', '../..'],
|
|
16
|
-
},
|
|
17
|
-
],
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
];
|
|
3
|
+
export default [...baseConfig];
|
|
@@ -16,18 +16,19 @@
|
|
|
16
16
|
"@libs/infra"
|
|
17
17
|
],
|
|
18
18
|
"nx": {
|
|
19
|
+
"projectType": "library",
|
|
20
|
+
"tags": [
|
|
21
|
+
"scope:services"
|
|
22
|
+
],
|
|
19
23
|
"targets": {
|
|
20
24
|
"build": {
|
|
21
25
|
"executor": "nx:run-commands",
|
|
22
26
|
"options": {
|
|
23
|
-
"command": "
|
|
27
|
+
"command": "vite build --mode {args.mode}",
|
|
24
28
|
"color": true,
|
|
25
29
|
"cwd": "{projectRoot}"
|
|
26
30
|
}
|
|
27
31
|
}
|
|
28
|
-
}
|
|
29
|
-
"tags": [
|
|
30
|
-
"scope:services"
|
|
31
|
-
]
|
|
32
|
+
}
|
|
32
33
|
}
|
|
33
34
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { SharedInfraProps } from '@libs/infra';
|
|
2
|
-
import { Stack, StackProps, Stage, Tags } from 'aws-cdk-lib';
|
|
3
|
-
import { Construct } from 'constructs';
|
|
1
|
+
import { type SharedInfraProps } from '@libs/infra';
|
|
2
|
+
import { Stack, type StackProps, Stage, Tags } from 'aws-cdk-lib';
|
|
3
|
+
import { type Construct } from 'constructs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @important
|
package/src/generators/service/files/{vitest.config.mjs.template → vite.config.mjs.template}
RENAMED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import { defineConfig, mergeConfig } from '
|
|
2
|
-
import {
|
|
1
|
+
import { defineConfig, mergeConfig } from 'vite';
|
|
2
|
+
import { baseConfig, defineLambdaEnvironments } from '../../vite.config.base.mjs';
|
|
3
3
|
|
|
4
4
|
export default defineConfig(configEnv => {
|
|
5
|
+
const lambdaConfig = defineLambdaEnvironments('src/runtime/handlers', {
|
|
6
|
+
mode: configEnv.mode,
|
|
7
|
+
});
|
|
8
|
+
|
|
5
9
|
return mergeConfig(
|
|
6
|
-
|
|
10
|
+
baseConfig(configEnv),
|
|
7
11
|
defineConfig({
|
|
12
|
+
...lambdaConfig,
|
|
8
13
|
cacheDir: '../../node_modules/.vitest/<%= name %>',
|
|
9
14
|
test: {
|
|
10
15
|
env: {
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import fg from 'fast-glob';
|
|
2
|
-
import { builtinModules } from 'node:module';
|
|
3
|
-
import { extname, resolve } from 'node:path';
|
|
4
|
-
import { defineConfig } from 'rolldown';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Prepare Rolldown config that bundles all typescript files in a single directory in to separate files
|
|
8
|
-
* This is used to bundle lambda handlers with their own dependencies for separate upload to AWS Lambda
|
|
9
|
-
*
|
|
10
|
-
* @param {string} subPath Relative path to the handlers directory
|
|
11
|
-
* @returns Rolldown config for multiple lambda handlers
|
|
12
|
-
*/
|
|
13
|
-
export function defineLambdaConfig(subPath) {
|
|
14
|
-
if (subPath.includes('..')) throw new Error('Invalid path provided');
|
|
15
|
-
const handlersPath = resolve(process.cwd(), subPath);
|
|
16
|
-
const handlers = fg.sync(`${handlersPath}/**/*.ts`);
|
|
17
|
-
|
|
18
|
-
return handlers.map(handler => {
|
|
19
|
-
const bundledPath = handler.replace(`${handlersPath}/`, '');
|
|
20
|
-
const entryName = bundledPath.replace(extname(bundledPath), '');
|
|
21
|
-
const bundleMode = process.env.BUNDLE_MODE?.toLowerCase() || 'prd';
|
|
22
|
-
|
|
23
|
-
return defineConfig({
|
|
24
|
-
input: { [entryName]: handler },
|
|
25
|
-
platform: 'node',
|
|
26
|
-
tsconfig: 'tsconfig.lib.json',
|
|
27
|
-
logLevel: 'info',
|
|
28
|
-
watch: false,
|
|
29
|
-
external: [...builtinModules],
|
|
30
|
-
output: {
|
|
31
|
-
entryFileNames: '[name]/index.mjs',
|
|
32
|
-
format: 'esm',
|
|
33
|
-
sourcemap: bundleMode === 'prd' ? false : true,
|
|
34
|
-
// FIXME: [MI-251] Rolldown is still in RC and built-in minification is not production ready yet
|
|
35
|
-
minify: false,
|
|
36
|
-
legalComments: 'none',
|
|
37
|
-
inlineDynamicImports: true,
|
|
38
|
-
// TODO: [MI-251] Support shims only when needed instead consider looking at tsup, tsdown and rollup shims plugins
|
|
39
|
-
banner: `import { fileURLToPath } from 'node:url';
|
|
40
|
-
import { dirname } from 'node:path';
|
|
41
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
42
|
-
const __dirname = dirname(__filename);`,
|
|
43
|
-
},
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { resolve } from 'node:path';
|
|
2
|
-
import { defineConfig } from 'vitest/config';
|
|
3
|
-
|
|
4
|
-
// More information about mode: https://vite.dev/guide/env-and-mode.html#node-env-and-modes
|
|
5
|
-
export const vitestBaseConfig = defineConfig(({ command, mode }) => {
|
|
6
|
-
return {
|
|
7
|
-
test: {
|
|
8
|
-
globals: true,
|
|
9
|
-
watch: false,
|
|
10
|
-
environment: 'node',
|
|
11
|
-
reporters: ['default'],
|
|
12
|
-
coverage: {
|
|
13
|
-
provider: 'v8',
|
|
14
|
-
exclude: [
|
|
15
|
-
'node_modules/',
|
|
16
|
-
'**/types',
|
|
17
|
-
'*.mjs',
|
|
18
|
-
'**/__data__',
|
|
19
|
-
'**/dist',
|
|
20
|
-
'**/out-tsc',
|
|
21
|
-
],
|
|
22
|
-
thresholds: {
|
|
23
|
-
branches: 80,
|
|
24
|
-
functions: 80,
|
|
25
|
-
lines: 80,
|
|
26
|
-
statements: 80,
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
include: [
|
|
30
|
-
'src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}',
|
|
31
|
-
'tests/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}',
|
|
32
|
-
],
|
|
33
|
-
setupFiles: [
|
|
34
|
-
// Include the root setup file in all tests that extend this config
|
|
35
|
-
resolve(import.meta.dirname, './vitest.global.setup.mjs'),
|
|
36
|
-
],
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
});
|