@codedazur/cdk-next-app 0.0.2 → 0.2.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/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @codedazur/cdk-next-app
2
2
 
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`36a8727`](https://github.com/codedazur/toolkit/commit/36a87277e9150970420b6ac046f297653f95f087) Thanks [@thijsdaniels](https://github.com/thijsdaniels)! - The NextApp now uses a DockerCluster instead of an AmplifyApp. This completely changes the entire infrastructure and is a major breaking change.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [[`bcb3361`](https://github.com/codedazur/toolkit/commit/bcb33613b40edcfb0097d961fa16511035c18b83)]:
12
+ - @codedazur/cdk-docker-cluster@0.1.0
13
+
14
+ ## 0.1.0
15
+
16
+ ### Minor Changes
17
+
18
+ - [`dd2a6c9`](https://github.com/codedazur/toolkit/commit/dd2a6c9934b9b0ad2fb63e45e963d94d3ebf6dca) Thanks [@thijsdaniels](https://github.com/thijsdaniels)! - Transpile TypeScript to CJS and ESM.
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies [[`dd2a6c9`](https://github.com/codedazur/toolkit/commit/dd2a6c9934b9b0ad2fb63e45e963d94d3ebf6dca)]:
23
+ - @codedazur/cdk-amplify-app@0.1.0
24
+
3
25
  ## 0.0.2
4
26
 
5
27
  ### Patch Changes
package/README.md CHANGED
@@ -1 +1,15 @@
1
- # @codedazur/cdk-next-app
1
+ # NextApp
2
+
3
+ The NextApp CDK construct deploys a standalone Next.js build to a load balanced Fargate service on AWS.
4
+
5
+ ## Example
6
+
7
+ ```ts
8
+ new NextApp(this, "Next", {
9
+ path: "../next", // Must contain a Dockerfile.
10
+ });
11
+ ```
12
+
13
+ ## Docker
14
+
15
+ In order to use this construct, your Next.js application needs to be configure for Docker deployments. See the [official documentation](https://nextjs.org/docs/pages/building-your-application/deploying#docker-image) for more information.
@@ -0,0 +1,14 @@
1
+ import { DockerClusterProps, DockerCluster } from '@codedazur/cdk-docker-cluster';
2
+ import { Construct } from 'constructs';
3
+
4
+ interface NextDockerClusterProps extends DockerClusterProps {
5
+ }
6
+ /**
7
+ * A docker cluster preconfigured for running a Next.js application with support
8
+ * for private NPM packages using a build-time secret.
9
+ */
10
+ declare class NextDockerCluster extends DockerCluster {
11
+ constructor(scope: Construct, id: string, { port, secrets, ...props }: NextDockerClusterProps);
12
+ }
13
+
14
+ export { NextDockerCluster, NextDockerClusterProps };
@@ -0,0 +1,14 @@
1
+ import { DockerClusterProps, DockerCluster } from '@codedazur/cdk-docker-cluster';
2
+ import { Construct } from 'constructs';
3
+
4
+ interface NextDockerClusterProps extends DockerClusterProps {
5
+ }
6
+ /**
7
+ * A docker cluster preconfigured for running a Next.js application with support
8
+ * for private NPM packages using a build-time secret.
9
+ */
10
+ declare class NextDockerCluster extends DockerCluster {
11
+ constructor(scope: Construct, id: string, { port, secrets, ...props }: NextDockerClusterProps);
12
+ }
13
+
14
+ export { NextDockerCluster, NextDockerClusterProps };
package/dist/index.js ADDED
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ NextDockerCluster: () => NextDockerCluster
34
+ });
35
+ module.exports = __toCommonJS(src_exports);
36
+
37
+ // src/constructs/NextApp.ts
38
+ var import_os = __toESM(require("os"));
39
+ var import_path = __toESM(require("path"));
40
+ var import_cdk_docker_cluster = require("@codedazur/cdk-docker-cluster");
41
+ var import_aws_cdk_lib = require("aws-cdk-lib");
42
+ var NextDockerCluster = class extends import_cdk_docker_cluster.DockerCluster {
43
+ constructor(scope, id, { port = 3e3, secrets, ...props }) {
44
+ super(scope, id, {
45
+ port,
46
+ secrets: {
47
+ npmrc: import_aws_cdk_lib.DockerBuildSecret.fromSrc(import_path.default.join(import_os.default.homedir(), "/.npmrc")),
48
+ ...secrets
49
+ },
50
+ ...props
51
+ });
52
+ }
53
+ };
54
+ // Annotate the CommonJS export names for ESM import in node:
55
+ 0 && (module.exports = {
56
+ NextDockerCluster
57
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,22 @@
1
+ // src/constructs/NextApp.ts
2
+ import os from "os";
3
+ import path from "path";
4
+ import {
5
+ DockerCluster
6
+ } from "@codedazur/cdk-docker-cluster";
7
+ import { DockerBuildSecret } from "aws-cdk-lib";
8
+ var NextDockerCluster = class extends DockerCluster {
9
+ constructor(scope, id, { port = 3e3, secrets, ...props }) {
10
+ super(scope, id, {
11
+ port,
12
+ secrets: {
13
+ npmrc: DockerBuildSecret.fromSrc(path.join(os.homedir(), "/.npmrc")),
14
+ ...secrets
15
+ },
16
+ ...props
17
+ });
18
+ }
19
+ };
20
+ export {
21
+ NextDockerCluster
22
+ };
package/package.json CHANGED
@@ -1,29 +1,42 @@
1
1
  {
2
2
  "name": "@codedazur/cdk-next-app",
3
- "version": "0.0.2",
4
- "main": "./index.ts",
5
- "types": "./index.ts",
3
+ "version": "0.2.0",
4
+ "main": ".dist/index.js",
5
+ "module": "./dist/index.mjs",
6
+ "types": "./dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "require": "./dist/index.js",
10
+ "import": "./dist/index.mjs"
11
+ }
12
+ },
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
6
16
  "license": "MIT",
7
17
  "scripts": {
18
+ "develop": "tsup src/index.ts --format esm,cjs --dts --watch",
19
+ "build": "tsup src/index.ts --format esm,cjs --dts",
20
+ "audit": "npm audit --omit dev",
8
21
  "lint": "TIMING=1 eslint \"**/*.ts*\"",
9
- "test": "echo \"No tests configured.\"",
10
- "release": "echo \"No releases configured.\""
22
+ "types": "tsc --noEmit",
23
+ "test": "vitest run --passWithNoTests"
11
24
  },
12
25
  "dependencies": {
13
- "@codedazur/cdk-amplify-app": "*"
26
+ "@codedazur/cdk-docker-cluster": "*"
14
27
  },
15
28
  "peerDependencies": {
16
29
  "aws-cdk-lib": ">=2",
17
30
  "constructs": ">=10"
18
31
  },
19
32
  "devDependencies": {
20
- "@types/node": "^16.18.3 || ^18.18.0",
21
- "aws-cdk-lib": "^2.55.1",
22
- "constructs": "^10.1.194",
23
- "esbuild": "^0.16.9 || ^0.19.1",
33
+ "@codedazur/eslint-config": "*",
34
+ "@codedazur/tsconfig": "*",
35
+ "@types/node": "^20.12.8",
36
+ "aws-cdk-lib": "^2.139.1",
37
+ "constructs": "^10.3.0",
38
+ "esbuild": "^0.20.2",
24
39
  "eslint": "^8.30.0",
25
- "eslint-config-custom": "*",
26
- "tsconfig": "*",
27
- "typescript": "^4.9.4 || ^5.2.2"
40
+ "typescript": "^5.4.5"
28
41
  }
29
42
  }
@@ -1,16 +0,0 @@
1
-
2
- > @codedazur/cdk-next-app@0.0.2 lint
3
- > TIMING=1 eslint "**/*.ts*"
4
-
5
- Rule | Time (ms) | Relative
6
- :------------------------------|----------:|--------:
7
- react/display-name | 110.889 | 76.6%
8
- turbo/no-undeclared-env-vars | 14.348 | 9.9%
9
- react/no-direct-mutation-state | 10.400 | 7.2%
10
- react/require-render-return | 4.000 | 2.8%
11
- react/no-string-refs | 1.033 | 0.7%
12
- react/no-deprecated | 0.883 | 0.6%
13
- react-hooks/rules-of-hooks | 0.540 | 0.4%
14
- react-hooks/exhaustive-deps | 0.275 | 0.2%
15
- react/jsx-no-comment-textnodes | 0.272 | 0.2%
16
- react/no-render-return-value | 0.214 | 0.1%
@@ -1,5 +0,0 @@
1
-
2
- > @codedazur/cdk-next-app@0.0.2 test
3
- > echo "No tests configured."
4
-
5
- No tests configured.
@@ -1,86 +0,0 @@
1
- import { Construct } from "constructs";
2
- import {
3
- AmplifyApp,
4
- AmplifyAppProps,
5
- Framework,
6
- Platform,
7
- RewriteStatus,
8
- } from "@codedazur/cdk-amplify-app";
9
-
10
- export interface NextAppProps
11
- extends Omit<
12
- AmplifyAppProps,
13
- "platform" | "framework" | "buildSpec" | "headers"
14
- > {}
15
-
16
- /**
17
- * @todo Document that if this is used with a monorepo, the `next.config.js`
18
- * needs to contain
19
- * ```
20
- * {
21
- * experimental: {
22
- * outputFileTracingRoot: path.join(__dirname, "../../"),
23
- * },
24
- * }
25
- * ```
26
- * assuming that the project root is at `"../../"` relative to the the
27
- * `next.config.js` file.
28
- * @see https://github.com/aws-amplify/amplify-hosting/issues/3179
29
- * @see https://nextjs.org/docs/advanced-features/output-file-tracing#caveats
30
- */
31
- export class NextApp extends AmplifyApp {
32
- constructor(scope: Construct, id: string, props: NextAppProps) {
33
- super(scope, id, {
34
- platform: Platform.WEB_COMPUTE,
35
- framework: Framework.NEXTJS_SSR,
36
- buildSpec: {
37
- version: 1,
38
- applications: [
39
- {
40
- appRoot: props.source.directory,
41
- frontend: {
42
- phases: {
43
- preBuild: {
44
- commands: [
45
- "npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}",
46
- "npm install",
47
- ],
48
- },
49
- build: {
50
- commands: ["npm run build"],
51
- },
52
- postBuild: {
53
- commands: [
54
- /**
55
- * This command moves the Next.js `standalone` directory
56
- * into the right location for AWS to recognize it.
57
- * @todo Remove this command when AWS has implemented a fix.
58
- * @see https://github.com/aws-amplify/amplify-hosting/issues/3179
59
- */
60
- `cp -r .next/standalone/${props.source.directory}/. .next/standalone`,
61
- ],
62
- },
63
- },
64
- artifacts: {
65
- baseDirectory: ".next",
66
- files: ["**/*"],
67
- },
68
- cache: {
69
- paths: ["node_modules/**/*"],
70
- },
71
- },
72
- },
73
- ],
74
- },
75
- rewrites: [
76
- {
77
- source: "/<*>",
78
- status: RewriteStatus.NOT_FOUND,
79
- target: "/index.html",
80
- },
81
- ...(props.rewrites ?? []),
82
- ],
83
- ...props,
84
- });
85
- }
86
- }
package/index.ts DELETED
@@ -1,13 +0,0 @@
1
- export {
2
- type GitSource,
3
- type GitRegistry,
4
- type Environment,
5
- type Rewrite,
6
- type RewriteStatus,
7
- type Redirect,
8
- type RedirectStatus,
9
- type BasicAuth,
10
- type Branch,
11
- } from "@codedazur/cdk-amplify-app";
12
-
13
- export * from "./constructs/NextApp";