Skip to content

Commit 5510d13

Browse files
authored
Merge pull request #6 from mococa/deploy/npm-publish-first-setup
🚀 deploy: npm publish first setup
2 parents 707fd05 + 2bce919 commit 5510d13

File tree

8 files changed

+116
-77
lines changed

8 files changed

+116
-77
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Publish to NPM
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v2
13+
- name: Setup Node
14+
uses: actions/setup-node@v2
15+
with:
16+
node-version: "18.x"
17+
registry-url: "https://registry.npmjs.org"
18+
- name: Publish package on NPM 📦
19+
run: |
20+
cd infrastructure
21+
npm publish
22+
env:
23+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

infrastructure/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
*.d.ts
55
node_modules
66

7-
# CDK asset staging directory
87
.cdk.staging
98
cdk.out
109
nullstack-build
1110
nullstack-build.zip
11+
dist
12+
yarn-error.log

infrastructure/cdk.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"app": "npx ts-node --prefer-ts-exts src/index.ts",
2+
"app": "npx ts-node --prefer-ts-exts test/index.ts",
33
"watch": {
44
"include": [
55
"**"

infrastructure/package.json

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,32 @@
11
{
2-
"name": "infrastructure",
3-
"version": "0.1.0",
4-
"bin": {
5-
"infrastructure": "src/index.ts"
2+
"name": "nullstack-serverless",
3+
"version": "0.0.1",
4+
"description": "Nullstack construct for CDK",
5+
"author": "mococa <[email protected]>",
6+
"license": "MIT",
7+
"homepage": "https://github.com/mococa/nullstack-serverless",
8+
"repository": {
9+
"url": "https://github.com/mococa/nullstack-serverless.git"
610
},
11+
"keywords": [
12+
"nullstack",
13+
"cdk",
14+
"serverless",
15+
"lambda",
16+
"s3",
17+
"bucket",
18+
"ssr",
19+
"ssg",
20+
"spa"
21+
],
22+
"main": "dist/index.js",
23+
"module": "dist/index.js",
24+
"types": "dist/index.d.ts",
725
"scripts": {
826
"build": "tsc",
927
"watch": "tsc -w",
10-
"cdk": "cdk",
11-
"synth": "cdk synth",
28+
"test": "echo \"Error: no test specified\" && exit 1",
29+
"prepublishOnly": "npm run build",
1230
"prebootstrap": "yarn synth",
1331
"bootstrap": "cdk bootstrap",
1432
"predeploy": "yarn bootstrap",
@@ -19,17 +37,21 @@
1937
},
2038
"devDependencies": {
2139
"@types/adm-zip": "^0.5.0",
22-
"@types/node": "20.1.7",
40+
"@types/node": "^14.14.37",
2341
"aws-cdk": "2.82.0",
2442
"ts-node": "^10.9.1",
25-
"typescript": "~5.0.4"
43+
"typescript": "~4.4.2"
44+
},
45+
"peerDependencies": {
46+
"aws-cdk": "2.82.0",
47+
"aws-cdk-lib": "2.82.0",
48+
"constructs": "^10.0.0"
2649
},
2750
"dependencies": {
2851
"@vendia/serverless-express": "^4.10.4",
2952
"adm-zip": "^0.5.10",
3053
"aws-cdk-lib": "2.82.0",
3154
"aws-serverless-express": "^3.4.0",
32-
"constructs": "^10.0.0",
3355
"express": "^4.18.2",
3456
"source-map-support": "^0.5.21"
3557
}

infrastructure/src/index.ts

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,4 @@
1-
import * as cdk from "aws-cdk-lib";
21
import { NullstackAppStack } from "../lib/null-stack";
32
import { zip_nullstack } from "../utils/zip_nullstack";
43

5-
const app = new cdk.App();
6-
7-
const main = async () => {
8-
const app_dir = process.env.NULLSTACK_APP_DIR || "../web";
9-
10-
await zip_nullstack(app_dir);
11-
12-
new NullstackAppStack(app, "NullstackAppStack", {
13-
environment: "development",
14-
build_bucket: { id: "Nullstack-App-Build", name: "nullstack-app-build" }, // bucket: -> nullstack-app-build-development
15-
public_bucket: { id: "Nullstack-App-Public", name: "nullstack-app-public" }, // bucket: -> nullstack-app-public-development
16-
env: {
17-
region: "sa-east-1",
18-
},
19-
app_dir,
20-
app_env: {
21-
NULLSTACK_PROJECT_NAME: "[dev] Web",
22-
NULLSTACK_PROJECT_COLOR: "#D22365",
23-
},
24-
});
25-
};
26-
27-
main();
4+
export { NullstackAppStack, zip_nullstack };

infrastructure/test/index.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import * as cdk from "aws-cdk-lib";
2+
import { NullstackAppStack, zip_nullstack } from "../src";
3+
4+
const main = async () => {
5+
const app_dir = process.env.NULLSTACK_APP_DIR || "../web";
6+
7+
await zip_nullstack(app_dir);
8+
9+
const app = new cdk.App();
10+
11+
new NullstackAppStack(app, "NullstackAppStack", {
12+
environment: "development",
13+
build_bucket: { id: "Nullstack-App-Build", name: "nullstack-app-build" }, // bucket: -> nullstack-app-build-development
14+
public_bucket: { id: "Nullstack-App-Public", name: "nullstack-app-public" }, // bucket: -> nullstack-app-public-development
15+
env: {
16+
region: "sa-east-1",
17+
},
18+
app_dir,
19+
app_env: {
20+
NULLSTACK_PROJECT_NAME: "[dev] Web",
21+
NULLSTACK_PROJECT_COLOR: "#D22365",
22+
},
23+
build_type: "ssr",
24+
});
25+
};
26+
27+
main();

infrastructure/tsconfig.json

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
"compilerOptions": {
33
"target": "ES2020",
44
"module": "commonjs",
5-
"lib": [
6-
"es2020",
7-
"dom"
8-
],
5+
"lib": ["es2020", "dom"],
96
"declaration": true,
107
"strict": true,
118
"noImplicitAny": true,
@@ -21,12 +18,9 @@
2118
"experimentalDecorators": true,
2219
"strictPropertyInitialization": false,
2320
"esModuleInterop": true,
24-
"typeRoots": [
25-
"./node_modules/@types"
26-
]
21+
"typeRoots": ["./node_modules/@types"],
22+
"noEmit": false,
23+
"outDir": "./dist"
2724
},
28-
"exclude": [
29-
"node_modules",
30-
"cdk.out"
31-
]
25+
"exclude": ["node_modules", "cdk.out", "dist"]
3226
}

infrastructure/yarn.lock

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33

44

55
"@aws-cdk/asset-awscli-v1@^2.2.177":
6-
version "2.2.186"
7-
resolved "https://registry.yarnpkg.com/@aws-cdk/asset-awscli-v1/-/asset-awscli-v1-2.2.186.tgz#97e3145f1a9f341597b0e3f3463fd017d15d5fb6"
8-
integrity sha512-2wSuOWQlrWc0AFuPCzXYn2Y8oK2vTfpNrVa8dxBxfswbwUrXMAirhpsP1f1J/4KEhA/4Hs4l27dKiC/IcDrvIQ==
6+
version "2.2.200"
7+
resolved "https://registry.yarnpkg.com/@aws-cdk/asset-awscli-v1/-/asset-awscli-v1-2.2.200.tgz#6ead533f73f705ad7350eb46955e2538e50cd013"
8+
integrity sha512-Kf5J8DfJK4wZFWT2Myca0lhwke7LwHcHBo+4TvWOGJrFVVKVuuiLCkzPPRBQQVDj0Vtn2NBokZAz8pfMpAqAKg==
99

1010
"@aws-cdk/asset-kubectl-v20@^2.1.1":
11-
version "2.1.1"
12-
resolved "https://registry.yarnpkg.com/@aws-cdk/asset-kubectl-v20/-/asset-kubectl-v20-2.1.1.tgz#d01c1efb867fb7f2cfd8c8b230b8eae16447e156"
13-
integrity sha512-U1ntiX8XiMRRRH5J1IdC+1t5CE89015cwyt5U63Cpk0GnMlN5+h9WsWMlKlPXZR4rdq/m806JRlBMRpBUB2Dhw==
11+
version "2.1.2"
12+
resolved "https://registry.yarnpkg.com/@aws-cdk/asset-kubectl-v20/-/asset-kubectl-v20-2.1.2.tgz#d8e20b5f5dc20128ea2000dc479ca3c7ddc27248"
13+
integrity sha512-3M2tELJOxQv0apCIiuKQ4pAbncz9GuLwnKFqxifWfe77wuMxyTRPmxssYHs42ePqzap1LT6GDcPygGs+hHstLg==
1414

1515
"@aws-cdk/asset-node-proxy-agent-v5@^2.0.148":
16-
version "2.0.155"
17-
resolved "https://registry.yarnpkg.com/@aws-cdk/asset-node-proxy-agent-v5/-/asset-node-proxy-agent-v5-2.0.155.tgz#b6541c56b21dbf1c5a5ba41bb144b0a827d23e2e"
18-
integrity sha512-Q+Ny25hUPINlBbS6lmbUr4m6Tr6ToEJBla7sXA3FO3JUD0Z69ddcgbhuEBF8Rh1a2xmPONm89eX77kwK2fb4vQ==
16+
version "2.0.165"
17+
resolved "https://registry.yarnpkg.com/@aws-cdk/asset-node-proxy-agent-v5/-/asset-node-proxy-agent-v5-2.0.165.tgz#c169599d83beceea7e638082ef9833997f04c85d"
18+
integrity sha512-bsyLQD/vqXQcc9RDmlM1XqiFNO/yewgVFXmkMcQkndJbmE/jgYkzewwYGrBlfL725hGLQipXq19+jwWwdsXQqg==
1919

2020
"@balena/dockerignore@^1.0.2":
2121
version "1.0.2"
@@ -75,14 +75,14 @@
7575
"@types/node" "*"
7676

7777
"@types/node@*":
78-
version "20.3.3"
79-
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.3.3.tgz#329842940042d2b280897150e023e604d11657d6"
80-
integrity sha512-wheIYdr4NYML61AjC8MKj/2jrR/kDQri/CIpVoZwldwhnIrD/j9jIU5bJ8yBKuB2VhpFV7Ab6G2XkBjv9r9Zzw==
78+
version "20.4.0"
79+
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.4.0.tgz#01d637d1891e419bc85763b46f42809cd2d5addb"
80+
integrity sha512-jfT7iTf/4kOQ9S7CHV9BIyRaQqHu67mOjsIQBC3BKZvzvUB6zLxEwJ6sBE3ozcvP8kF6Uk5PXN0Q+c0dfhGX0g==
8181

82-
"@types/node@20.1.7":
83-
version "20.1.7"
84-
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.1.7.tgz#ce10c802f7731909d0a44ac9888e8b3a9125eb62"
85-
integrity sha512-WCuw/o4GSwDGMoonES8rcvwsig77dGCMbZDrZr2x4ZZiNW4P/gcoZXe/0twgtobcTkmg9TuKflxYL/DuwDyJzg==
82+
"@types/node@^14.14.37":
83+
version "14.18.53"
84+
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.18.53.tgz#42855629b8773535ab868238718745bf56c56219"
85+
integrity sha512-soGmOpVBUq+gaBMwom1M+krC/NNbWlosh4AtGA03SyWNDiqSKtwp7OulO1M6+mg8YkHMvJ/y0AkCeO8d1hNb7A==
8686

8787
"@vendia/serverless-express@^3.4.0":
8888
version "3.4.0"
@@ -111,9 +111,9 @@ acorn-walk@^8.1.1:
111111
integrity sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==
112112

113113
acorn@^8.4.1:
114-
version "8.8.2"
115-
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.2.tgz#1b2f25db02af965399b9776b0c2c391276d37c4a"
116-
integrity sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==
114+
version "8.10.0"
115+
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.10.0.tgz#8be5b3907a67221a81ab23c7889c4c5526b62ec5"
116+
integrity sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==
117117

118118
adm-zip@^0.5.10:
119119
version "0.5.10"
@@ -268,11 +268,6 @@ [email protected]:
268268
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
269269
integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==
270270

271-
constructs@^10.0.0:
272-
version "10.2.44"
273-
resolved "https://registry.yarnpkg.com/constructs/-/constructs-10.2.44.tgz#748afaad06586fc9668081ee4837aa0bf4e3d630"
274-
integrity sha512-7v4KnradGM1JeOuuhey4m9t6pLkwc0XOlgO1TrjB8HLRbfxDHeJ10Tt6IfxihgkrDjYN1SOMmpeVFzLLNjGRQw==
275-
276271
277272
version "0.5.4"
278273
resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.4.tgz#8b82b4efac82512a02bb0b1dcec9d2c5e8eb5bfe"
@@ -664,9 +659,9 @@ [email protected]:
664659
integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==
665660

666661
semver@^7.5.1:
667-
version "7.5.1"
668-
resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.1.tgz#c90c4d631cf74720e46b21c1d37ea07edfab91ec"
669-
integrity sha512-Wvss5ivl8TMRZXXESstBA4uR5iXgEN/VC5/sOcuXdVLzcdkz4HWetIoRfG5gb5X+ij/G9rw9YoGn3QoQ8OCSpw==
662+
version "7.5.3"
663+
resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.3.tgz#161ce8c2c6b4b3bdca6caadc9fa3317a4c4fe88e"
664+
integrity sha512-QBlUtyVk/5EeHbi7X0fw6liDZc7BBmEaSYn01fMU1OUYbf6GPsbTtd8WmnqbI20SeycoHSeiybkE/q1Q+qlThQ==
670665
dependencies:
671666
lru-cache "^6.0.0"
672667

@@ -799,10 +794,10 @@ type-is@^1.6.16, type-is@~1.6.18:
799794
media-typer "0.3.0"
800795
mime-types "~2.1.24"
801796

802-
typescript@~5.0.4:
803-
version "5.0.4"
804-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.0.4.tgz#b217fd20119bd61a94d4011274e0ab369058da3b"
805-
integrity sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==
797+
typescript@~4.4.2:
798+
version "4.4.4"
799+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.4.4.tgz#2cd01a1a1f160704d3101fd5a58ff0f9fcb8030c"
800+
integrity sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA==
806801

807802
universalify@^2.0.0:
808803
version "2.0.0"

0 commit comments

Comments
 (0)