@pwrdrvr/microapps-publish 0.2.5 → 0.2.6

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.
Files changed (2) hide show
  1. package/README.md +256 -73
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,117 +1,300 @@
1
1
  # Overview
2
2
 
3
- `microapps-publish` is used to deploy new apps and new versions for existing apps using the [MicroApps framework](https://github.com/pwrdrvr/microapps-core/).
3
+ `microapps-publish` is used to deploy new MicroApps and new versions for existing MicroApps using the [MicroApps framework](https://github.com/pwrdrvr/microapps-core/).
4
4
 
5
- # Getting Started
5
+ # Installation
6
6
 
7
- ## Next.js Apps
7
+ `npm i -g @pwrdrvr/microapps-publish`
8
8
 
9
- Create a Next.js app then follow the steps in this section to set it up for publishing to AWS Lambda @ Origin as a MicroApp. To publish new versions of the app use `npx microapps-publish --new-version x.y.z` when logged in to the target AWS account.
9
+ # Usage
10
10
 
11
- ### Modify package.json
11
+ ## Command - help
12
12
 
13
- Replace the version with `0.0.0` so it can be modified by the `microapps-publish` tool.
13
+ `npx microapps-publish help`
14
14
 
15
- ### Install Dependencies
15
+ ```
16
+ Publish tool for deploying apps and updates
17
+
18
+ VERSION
19
+ @pwrdrvr/microapps-publish/0.0.0 darwin-x64 node-v16.13.1
20
+
21
+ USAGE
22
+ $ microapps-publish [COMMAND]
23
+
24
+ COMMANDS
25
+ delete Delete app/version
26
+ help display help for microapps-publish
27
+ nextjs-docker-auto Fully automatic publishing of Docker-based Lambda
28
+ function using Next.js and serverless-nextjs-router
29
+ nextjs-version Apply version to next.config.js overtop of 0.0.0
30
+ placeholder
31
+ nextjs-version-restore Restore next.config.js
32
+ preflight Check if app/version are available
33
+ publish Publish arbitrary framework app - deploy static
34
+ assets to S3, alias the $LATEST Lambda function, and
35
+ add integration/route to API Gateway.
36
+ publish-static Publish arbitrary framework static app - deploy
37
+ static assets to S3 only.
38
+ ```
39
+
40
+ ## Command - preflight
41
+
42
+ `npx microapps-publish preflight help`
43
+
44
+ ```
45
+ Check if app/version are available
46
+
47
+ USAGE
48
+ $ microapps-publish preflight
49
+
50
+ OPTIONS
51
+ -a, --appName=appName Name of the MicroApp
52
+ -d, --deployerLambdaName=deployerLambdaName (required) Name of the deployer lambda function
53
+ -n, --newVersion=newVersion (required) New semantic version to apply
54
+
55
+ -o, --overwrite Allow overwrite - Warn but do not fail if version exists.
56
+ Discouraged outside of test envs if cacheable static files
57
+ have changed.
58
+
59
+ -v, --version show CLI version
60
+
61
+ --help show CLI help
16
62
 
63
+ EXAMPLE
64
+ $ microapps-publish preflight -d microapps-deployer-dev -a release -n 0.0.13
65
+ ✔ Preflight Version Check [0.2s]
17
66
  ```
18
- npm i --save-dev @sls-next/serverless-component@1.19.0 @pwrdrvr/serverless-nextjs-router @pwrdrvr/microapps-publish
67
+
68
+ ## Command - publish
69
+
70
+ `npx microapps-publish publish help`
71
+
72
+ ```
73
+ Publish arbitrary framework app - deploy static assets to S3, alias the $LATEST Lambda function, and add integration/route to API Gateway.
74
+
75
+ USAGE
76
+ $ microapps-publish publish
77
+
78
+ OPTIONS
79
+ -a, --appName=appName MicroApps app name
80
+ -d, --deployerLambdaName=deployerLambdaName (required) Name of the deployer lambda function
81
+
82
+ -i, --defaultFile=defaultFile Default file to return when the app is loaded via the
83
+ router without a version (e.g. when app/ is requested).
84
+
85
+ -l, --appLambdaName=appLambdaName Name of the application lambda function
86
+
87
+ -n, --newVersion=newVersion (required) New semantic version to apply
88
+
89
+ -o, --overwrite Allow overwrite - Warn but do not fail if version exists.
90
+ Discouraged outside of test envs if cacheable static files
91
+ have changed.
92
+
93
+ -s, --staticAssetsPath=staticAssetsPath Path to files to be uploaded to S3 static bucket at
94
+ app/version/ path. Do include app/version/ in path if
95
+ files are already "rooted" under that path locally.
96
+
97
+ -v, --version show CLI version
98
+
99
+ --help show CLI help
100
+
101
+ --noCache Force revalidation of CloudFront and browser caching of
102
+ static assets
103
+
104
+ EXAMPLE
105
+ $ microapps-publish publish -d microapps-deployer-dev -l microapps-app-release-dev -a release -n 0.0.21
106
+ ✔ Get S3 Temp Credentials [1s]
107
+ ✔ Deploy to Lambda [0.6s]
108
+ ✔ Confirm Static Assets Folder Exists [0.0s]
109
+ ✔ Copy Static Files to Local Upload Dir [0.0s]
110
+ ✔ Enumerate Files to Upload to S3 [0.0s]
111
+ ✔ Upload Static Files to S3 [1s]
112
+ ✔ Creating MicroApp Application: release [0.0s]
113
+ ✔ Creating MicroApp Version: 0.0.21 [1s]
19
114
  ```
20
115
 
21
- ### Dockerfile
116
+ ## Command - publish-static
22
117
 
23
- Add this file to the root of the app.
118
+ `npx microapps-publish publish-static help`
24
119
 
25
- ```Dockerfile
26
- FROM node:15-slim as base
120
+ ```
121
+ Publish arbitrary framework static app - deploy static assets to S3 only.
27
122
 
28
- WORKDIR /app
123
+ USAGE
124
+ $ microapps-publish publish-static
29
125
 
30
- # Download the sharp libs once to save time
31
- # Do this before copying anything else in
32
- RUN mkdir -p image-lambda-npms && \
33
- cd image-lambda-npms && npm i sharp && \
34
- rm -rf node_modules/sharp/vendor/*/include/
126
+ OPTIONS
127
+ -a, --appName=appName MicroApps app name
128
+ -d, --deployerLambdaName=deployerLambdaName (required) Name of the deployer lambda function
35
129
 
36
- # Copy in the build output from `npx serverless`
37
- COPY .serverless_nextjs .
38
- COPY config.json .
130
+ -i, --defaultFile=defaultFile Default file to return when the app is loaded via the
131
+ router without a version (e.g. when app/ is requested).
39
132
 
40
- # Move the sharp libs into place
41
- RUN rm -rf image-lambda/node_modules/ && \
42
- mv image-lambda-npms/node_modules image-labmda/ && \
43
- rm -rf image-lambda-npms
133
+ -n, --newVersion=newVersion (required) New semantic version to apply
44
134
 
135
+ -o, --overwrite Allow overwrite - Warn but do not fail if version exists.
136
+ Discouraged outside of test envs if cacheable static files
137
+ have changed.
45
138
 
139
+ -s, --staticAssetsPath=staticAssetsPath Path to files to be uploaded to S3 static bucket at
140
+ app/version/ path. Do include app/version/ in path if
141
+ files are already "rooted" under that path locally.
46
142
 
47
- FROM public.ecr.aws/lambda/nodejs:14 AS final
143
+ -v, --version show CLI version
48
144
 
49
- # Copy in the munged code
50
- COPY --from=base /app .
145
+ --help show CLI help
51
146
 
52
- CMD [ "./index.handler" ]
147
+ --noCache Force revalidation of CloudFront and browser caching of
148
+ static assets
149
+
150
+ EXAMPLE
151
+ $ microapps-publish publish-static -d microapps-deployer-dev -l microapps-app-release-dev -a release -n
152
+ 0.0.21
153
+ ✔ Get S3 Temp Credentials [1s]
154
+ ✔ Confirm Static Assets Folder Exists [0.0s]
155
+ ✔ Copy Static Files to Local Upload Dir [0.0s]
156
+ ✔ Enumerate Files to Upload to S3 [0.0s]
157
+ ✔ Upload Static Files to S3 [1s]
158
+ ✔ Creating MicroApp Application: release [0.0s]
159
+ ✔ Creating MicroApp Version: 0.0.21 [1s]
53
160
  ```
54
161
 
55
- ### next.config.js
162
+ ## Command - nextjs-version
163
+
164
+ `npx microapps-publish nextjs-version help`
56
165
 
57
- Add this file to the root of the app.
166
+ ```
167
+ Apply version to next.config.js overtop of 0.0.0 placeholder
58
168
 
59
- Replace `appname` with your URL path-compatible application name.
169
+ USAGE
170
+ $ microapps-publish nextjs-version
60
171
 
61
- ```js
62
- const appRoot = '/appname/0.0.0';
172
+ OPTIONS
173
+ -l, --leaveCopy Leave a copy of the modifed files as .modified
174
+ -n, --newVersion=newVersion (required) New semantic version to apply
175
+ -v, --version show CLI version
176
+ --help show CLI help
63
177
 
64
- // eslint-disable-next-line no-undef
65
- module.exports = {
66
- target: 'serverless',
67
- webpack: (config, _options) => {
68
- return config;
69
- },
70
- basePath: appRoot,
71
- publicRuntimeConfig: {
72
- // Will be available on both server and client
73
- staticFolder: appRoot,
74
- },
75
- };
178
+ EXAMPLE
179
+ $ microapps-publish nextjs-version -n 0.0.13
180
+ Modifying Config Files [0.0s]
76
181
  ```
77
182
 
78
- ### deploy.json
183
+ ## Command - nextjs-version-restore
79
184
 
80
- Add this file to the root of the app.
185
+ `npx microapps-publish nextjs-version-restore help`
186
+
187
+ ```
188
+ Apply version to next.config.js overtop of 0.0.0 placeholder
81
189
 
82
- Replace `appname` with your URL path-compatible application name.
190
+ USAGE
191
+ $ microapps-publish nextjs-version
83
192
 
84
- ```json
85
- {
86
- "AppName": "appname",
87
- "SemVer": "0.0.0",
88
- "DefaultFile": "",
89
- "StaticAssetsPath": "./.serverless_nextjs/assets/appname/0.0.0/",
90
- "LambdaARN": "arn:aws:lambda:us-east-1:123456789012:function:appname:v0_0_0",
91
- "AWSAccountID": "123456789012",
92
- "AWSRegion": "us-east-2",
93
- "ServerlessNextRouterPath": "./node_modules/@pwrdrvr/serverless-nextjs-router/dist/index.js"
94
- }
193
+ OPTIONS
194
+ -l, --leaveCopy Leave a copy of the modifed files as .modified
195
+ -n, --newVersion=newVersion (required) New semantic version to apply
196
+ -v, --version show CLI version
197
+ --help show CLI help
198
+
199
+ EXAMPLE
200
+ $ microapps-publish nextjs-version -n 0.0.13
201
+ Modifying Config Files [0.0s]
95
202
  ```
96
203
 
97
- ### serverless.yaml
204
+ ## Command - delete
98
205
 
99
- Add this file to the root of the app.
206
+ `npx microapps-publish delete help`
100
207
 
101
- ```yaml
102
- nextApp:
103
- component: './node_modules/@sls-next/serverless-component'
104
- inputs:
105
- deploy: false
106
- uploadStaticAssetsFromBuild: false
107
208
  ```
209
+ Delete app/version
210
+
211
+ USAGE
212
+ $ microapps-publish delete
213
+
214
+ OPTIONS
215
+ -a, --appName=appName Name of the MicroApp
216
+
217
+ -d, --deployerLambdaName=deployerLambdaName (required) Name of the deployer
218
+ lambda function
219
+
220
+ -n, --newVersion=newVersion (required) New semantic version
221
+ to apply
108
222
 
109
- # Current Limitations
223
+ -v, --version show CLI version
110
224
 
111
- # Supports Only Docker-based Lambda Function
225
+ --help show CLI help
112
226
 
113
- As of 2021-06-20, the tool invokes a Docker build to publish an app or an updated version of an existing app. This was convenient during initial development of the tool but can easily be de-coupled to allow the end user to publish their own Lambda version and simply pass the ARN as a reference to this publishing tool.
227
+ EXAMPLE
228
+ $ microapps-publish delete -d microapps-deployer-dev -a release -n 0.0.13
229
+ ✔ App/Version deleted: release/0.0.13 [1.2s]
230
+ ```
231
+
232
+ ## Command - nextjs-docker-auto
233
+
234
+ Note: semi-deprecated as of 2022-01-27. This command may still work but it performs too many tasks that needed to be split out into individual commands to allow for integration into various build processes.
114
235
 
115
- # Supports Only for Next.js Apps
236
+ `npx microapps-publish nextjs-docker-auto help`
116
237
 
117
- As of 2021-06-20, the tool is more tightly coupled with Next.js than it should be (i.e. it invokes a build using [serverless-next.js](https://github.com/serverless-nextjs/serverless-next.js) to build the Next.js app and it modifies versions in files needed to get Next.js apps to run in re-rooted directories). There is nothing that inherintly requires that apps use Next.js at all so this will be generalized to additional frameworks soon.
238
+ ```
239
+ Fully automatic publishing of Docker-based Lambda function using Next.js and serverless-nextjs-router
240
+
241
+ USAGE
242
+ $ microapps-publish nextjs-docker-auto
243
+
244
+ OPTIONS
245
+ -a, --appName=appName
246
+ MicroApps app name
247
+
248
+ -d, --deployerLambdaName=deployerLambdaName
249
+ (required) Name of the deployer lambda function
250
+
251
+ -f, --leaveCopy
252
+ Leave a copy of the modifed files as .modified
253
+
254
+ -i, --defaultFile=defaultFile
255
+ Default file to return when the app is loaded via the router without a
256
+ version (e.g. when app/ is requested).
257
+
258
+ -l, --appLambdaName=appLambdaName
259
+ Name of the application lambda function
260
+
261
+ -n, --newVersion=newVersion
262
+ (required) New semantic version to apply
263
+
264
+ -o, --overwrite
265
+ Allow overwrite - Warn but do not fail if version exists. Discouraged
266
+ outside of test envs if cacheable static files have changed.
267
+
268
+ -r, --repoName=repoName
269
+ (required) Name (not URI) of the Docker repo for the app
270
+
271
+ -s, --staticAssetsPath=staticAssetsPath
272
+ Path to files to be uploaded to S3 static bucket at app/version/ path. Do
273
+ include app/version/ in path if files are already "rooted" under that path
274
+ locally.
275
+
276
+ -v, --version
277
+ show CLI version
278
+
279
+ --help
280
+ show CLI help
281
+
282
+ --noCache
283
+ Force revalidation of CloudFront and browser caching of static assets
284
+
285
+ EXAMPLE
286
+ $ microapps-publish nextjs-docker-auto -d microapps-deployer-dev -r
287
+ microapps-app-release-dev-repo -n 0.0.14
288
+ ✔ Logging into ECR [2s]
289
+ ✔ Modifying Config Files [0.0s]
290
+ ✔ Preflight Version Check [1s]
291
+ ✔ Serverless Next.js Build [1m16s]
292
+ ✔ Publish to ECR [32s]
293
+ ✔ Deploy to Lambda [11s]
294
+ ✔ Confirm Static Assets Folder Exists [0.0s]
295
+ ✔ Copy Static Files to Local Upload Dir [0.0s]
296
+ ✔ Enumerate Files to Upload to S3 [0.0s]
297
+ ✔ Upload Static Files to S3 [1s]
298
+ ✔ Creating MicroApp Application: release [0.2s]
299
+ ✔ Creating MicroApp Version: 0.0.14 [1s]
300
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pwrdrvr/microapps-publish",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "Publish tool for deploying apps and updates",
5
5
  "main": "dist/index.js",
6
6
  "source": "src/index.ts",