construct-hub-webapp 0.1.880 → 0.1.882

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/.gitattributes CHANGED
@@ -1,4 +1,4 @@
1
- # ~~ Generated by projen. To modify, edit .projenrc.js and run "npx projen".
1
+ # ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen".
2
2
 
3
3
  /.eslintrc.json linguist-generated
4
4
  /.gitattributes linguist-generated
@@ -14,6 +14,8 @@
14
14
  /.mergify.yml linguist-generated
15
15
  /.npmignore linguist-generated
16
16
  /.npmrc linguist-generated
17
+ /.prettierignore linguist-generated
18
+ /.prettierrc.json linguist-generated
17
19
  /.projen/** linguist-generated
18
20
  /.projen/deps.json linguist-generated
19
21
  /.projen/files.json linguist-generated
@@ -0,0 +1 @@
1
+ # ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen".
@@ -0,0 +1,3 @@
1
+ {
2
+ "overrides": []
3
+ }
package/.projenrc.ts ADDED
@@ -0,0 +1,360 @@
1
+ import { github, web } from "projen";
2
+ import { workflows } from "projen/lib/github";
3
+
4
+ const PROXY_URL = "https://constructs.dev/";
5
+
6
+ const project = new web.ReactTypeScriptProject({
7
+ defaultReleaseBranch: "main",
8
+ name: "construct-hub-webapp",
9
+ projenrcTs: true,
10
+
11
+ // Author metadata
12
+ authorEmail: "construct-ecosystem-team@amazon.com",
13
+ authorName: "Amazon Web Services, Inc.",
14
+
15
+ // Repository information
16
+ repository: "https://github.com/cdklabs/construct-hub-webapp.git",
17
+
18
+ // since this is an app project, we need to enable these explicitly
19
+ // in order to be able to publish this as an npm module.
20
+ releaseToNpm: true,
21
+ releaseWorkflow: true,
22
+ package: true,
23
+ tsconfig: {
24
+ compilerOptions: {
25
+ target: "es6",
26
+ },
27
+ },
28
+
29
+ minNodeVersion: "16.16.0",
30
+
31
+ eslint: true,
32
+ prettier: true,
33
+
34
+ deps: [
35
+ "@chakra-ui/anatomy",
36
+ "@chakra-ui/icons",
37
+ "@chakra-ui/react",
38
+ "@chakra-ui/theme-tools",
39
+ "@emotion/react@^11",
40
+ "@emotion/styled@^11",
41
+ "hast-util-sanitize",
42
+ "@jsii/spec",
43
+ "copy-to-clipboard", // Used by Chakra-UI, included for testing
44
+ "date-fns",
45
+ "framer-motion@^4",
46
+ "jsii-reflect",
47
+ "lunr",
48
+ "node-emoji",
49
+ "prism-react-renderer",
50
+ "react-query",
51
+ "react-helmet",
52
+ "react-markdown",
53
+ "react-router-dom",
54
+ "rehype-raw",
55
+ "rehype-sanitize",
56
+ "remark-emoji",
57
+ "remark-gfm",
58
+ "semver",
59
+ "spdx-license-list",
60
+ // PWA Functionality
61
+ "workbox-core",
62
+ "workbox-expiration",
63
+ "workbox-precaching",
64
+ "workbox-routing",
65
+ "workbox-strategies",
66
+ ],
67
+
68
+ devDeps: [
69
+ "@types/lunr",
70
+ "@types/node-emoji",
71
+ "@types/react-helmet",
72
+ "@types/react-router-dom",
73
+ "@types/semver",
74
+ "eslint-plugin-jsx-a11y",
75
+ "eslint-plugin-prefer-arrow",
76
+ "eslint-plugin-react-hooks",
77
+ "eslint-plugin-react",
78
+ "react-app-rewired",
79
+ "jsii-docgen",
80
+ "util",
81
+ ],
82
+
83
+ autoApproveOptions: {
84
+ allowedUsernames: ["cdklabs-automation"],
85
+ secret: "GITHUB_TOKEN",
86
+ },
87
+
88
+ autoApproveUpgrades: true,
89
+ });
90
+
91
+ project.package.addField("resolutions", {
92
+ // addressing https://github.com/advisories/GHSA-rp65-9cf3-cjxr forcefully until
93
+ // react-scripts fixes the dependency chain.
94
+ // if test pass, we should be ok with this override, even though its a different major version.
95
+ "nth-check": "2.0.1",
96
+ // addressing https://github.com/facebook/react/issues/24304
97
+ "@types/react": "17.0.45",
98
+ // not sure why this is needed, but some dependencies have a transient dependency
99
+ // on wrap-ansi@8 which is an ESM module. When performing `yarn upgrade npm-check-updates`
100
+ // yarn gets confused somehow and uses the @8 one which causes things to break
101
+ "wrap-ansi": "7.0.0",
102
+ });
103
+
104
+ project.gitignore.addPatterns("/.vscode/");
105
+ project.npmignore?.addPatterns("/.vscode/");
106
+
107
+ (function addCypress() {
108
+ project.addDevDeps("cypress");
109
+
110
+ project.addTask("cypress:open", {
111
+ exec: "cypress open",
112
+ description: "open the cypress test runner UI",
113
+ });
114
+
115
+ project.addTask("cypress:run", {
116
+ exec: "cypress run",
117
+ description: "run the cypress suite in CLI",
118
+ });
119
+
120
+ project.gitignore.addPatterns("cypress/videos/", "cypress/screenshots/");
121
+ project.eslint?.addIgnorePattern("cypress/");
122
+
123
+ // Express is used to create a local proxy server used in CI + local build testing
124
+ (function addExpress() {
125
+ project.addDevDeps("express", "express-http-proxy");
126
+ project.addTask("proxy-server", {
127
+ exec: "node ./scripts/proxy-server",
128
+ });
129
+
130
+ project.addTask("proxy-server:ci", {
131
+ exec: "npx react-app-rewired build && CI=true yarn proxy-server",
132
+ });
133
+ })();
134
+
135
+ const cypressRunSteps = [
136
+ {
137
+ name: "Checkout",
138
+ uses: "actions/checkout@v3",
139
+ },
140
+ {
141
+ name: "Cypress Run",
142
+ uses: "cypress-io/github-action@v3",
143
+ env: {
144
+ DEBUG: "@cypress/github-action",
145
+ },
146
+ with: {
147
+ start: "yarn proxy-server:ci",
148
+ "wait-on": "http://localhost:3000",
149
+ "wait-on-timeout": 150,
150
+ },
151
+ },
152
+ {
153
+ uses: "actions/upload-artifact@v3",
154
+ if: "failure()",
155
+ with: {
156
+ name: "cypress-screenshots",
157
+ path: "cypress/screenshots",
158
+ },
159
+ },
160
+ {
161
+ uses: "actions/upload-artifact@v3",
162
+ if: "always()",
163
+ with: {
164
+ name: "cypress-videos",
165
+ path: "cypress/videos",
166
+ },
167
+ },
168
+ ];
169
+
170
+ const integWorkflow = project.github?.addWorkflow("integ")!;
171
+ const e2e = "e2e";
172
+ integWorkflow.on({ workflowDispatch: {}, pullRequest: {} });
173
+ integWorkflow.addJob(e2e, {
174
+ name: e2e,
175
+ runsOn: ["ubuntu-latest"],
176
+ permissions: {
177
+ checks: github.workflows.JobPermission.WRITE,
178
+ contents: github.workflows.JobPermission.READ,
179
+ },
180
+ steps: cypressRunSteps,
181
+ });
182
+
183
+ project.autoMerge?.addConditions(`status-success=${e2e}`);
184
+
185
+ // Set up a canary that tests that the latest code on our main branch
186
+ // works against data on https://constructs.dev.
187
+ //
188
+ // We need to use the version of the front-end from the main branch
189
+ // and not the version that is live, otherwise it's possible for newer
190
+ // tests to run against an older (incompatible) version of the frontend
191
+ // due to deployment delays and give us false positives.
192
+ const e2eCanary = project.github?.addWorkflow("e2e-canary")!;
193
+ e2eCanary.on({
194
+ schedule: [
195
+ {
196
+ cron: "*/30 * * * *", // run every 30 minutes
197
+ },
198
+ ],
199
+ workflowDispatch: {},
200
+ });
201
+ e2eCanary.addJobs({
202
+ test: {
203
+ name: "constructs.dev canary",
204
+ runsOn: ["ubuntu-latest"],
205
+ permissions: {
206
+ checks: github.workflows.JobPermission.WRITE,
207
+ contents: github.workflows.JobPermission.READ,
208
+ },
209
+ steps: [
210
+ ...cypressRunSteps,
211
+ {
212
+ name: "Create failure issue",
213
+ if: "failure()",
214
+ uses: "imjohnbo/issue-bot@v3",
215
+ with: {
216
+ labels: "failed-release",
217
+ title: `E2E Canary for https://constructs.dev failed.`,
218
+ body: "See https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
219
+ },
220
+ env: {
221
+ GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}",
222
+ },
223
+ },
224
+ ],
225
+ },
226
+ });
227
+ })();
228
+
229
+ (function addJest() {
230
+ project.addDevDeps(
231
+ // "jest",
232
+ // "babel-jest",
233
+ // "ts-node",
234
+ "@testing-library/react",
235
+ "@testing-library/jest-dom",
236
+ "@testing-library/react-hooks",
237
+ "@testing-library/user-event"
238
+ );
239
+
240
+ project.addTask("test:unit", {
241
+ // exec: "jest",
242
+ exec: "npx react-app-rewired test",
243
+ });
244
+
245
+ project.addTask("test:update", {
246
+ exec: "npx react-app-rewired test -u",
247
+ });
248
+
249
+ project.eslint?.addIgnorePattern("jest.config.ts");
250
+ })();
251
+
252
+ // This task is used to analyze dead code
253
+ (function addAnalyzeExports() {
254
+ project.addDevDeps("ts-unused-exports");
255
+ project.addTask("analyze-exports", { exec: "node scripts/analyze-exports" });
256
+ })();
257
+
258
+ // npm tarball will only include the contents of the "build"
259
+ // directory, which is the output of our static website.
260
+ project.npmignore?.addPatterns("!/build");
261
+ project.npmignore?.addPatterns("/public");
262
+
263
+ // Ignore local config.json
264
+ project.npmignore?.addPatterns("/build/config.json");
265
+ project.gitignore.addPatterns("/public/config.json");
266
+
267
+ // test fixtures
268
+ project.npmignore?.addPatterns("src/__fixtures__");
269
+
270
+ // these are development assemblies fetched specifically
271
+ // by each developer.
272
+ project.gitignore.exclude("public/data");
273
+
274
+ // Proxy requests to awscdk.io for local testing
275
+ project.package.addField("proxy", PROXY_URL);
276
+
277
+ // setup linting for create-react-app specific tools
278
+ project.eslint?.addRules({
279
+ "import/no-extraneous-dependencies": [
280
+ "error",
281
+ {
282
+ devDependencies: ["**/setupTests.ts", "**/*.test.tsx", "**/*.test.ts"],
283
+ optionalDependencies: false,
284
+ peerDependencies: true,
285
+ },
286
+ ],
287
+ });
288
+
289
+ // React specific overrides
290
+ project.eslint?.addOverride({
291
+ files: ["src/**/*.tsx", "src/**/*.ts"],
292
+ extends: [
293
+ "plugin:react/recommended",
294
+ "plugin:react-hooks/recommended",
295
+ "plugin:jsx-a11y/recommended",
296
+ ],
297
+ plugins: ["jsx-a11y", "prefer-arrow"],
298
+ rules: {
299
+ "@typescript-eslint/no-use-before-define": ["error"],
300
+ "no-use-before-define": "off",
301
+ "prefer-arrow/prefer-arrow-functions": [
302
+ "error",
303
+ {
304
+ singleReturnOnly: false,
305
+ },
306
+ ],
307
+ "react/jsx-sort-props": ["warn"],
308
+ "react/prop-types": ["off"],
309
+ "react/react-in-jsx-scope": ["off"],
310
+ },
311
+ } as any);
312
+
313
+ // rewire cra tasks, all apart from eject.
314
+ rewireCRA(project.tasks.tryFind("build"));
315
+ rewireCRA(project.tasks.tryFind("test"));
316
+ rewireCRA(project.tasks.tryFind("dev"));
317
+
318
+ // trigger construct-hub to pick up changes from construct-hub-webapp
319
+ // whenever a new release is made
320
+ project.release?.addJobs({
321
+ upgrade_construct_hub: {
322
+ name: "Upgrade construct-hub",
323
+ runsOn: ["ubuntu-latest"],
324
+ permissions: {
325
+ actions: workflows.JobPermission.WRITE,
326
+ },
327
+ needs: ["release", "release_github", "release_npm"],
328
+ steps: [
329
+ {
330
+ name: "Trigger upgrade workflow",
331
+ run: 'gh api -X POST /repos/cdklabs/construct-hub/actions/workflows/upgrade-main.yml/dispatches --field ref="main"',
332
+ env: {
333
+ GITHUB_TOKEN: "${{ secrets.PROJEN_GITHUB_TOKEN }}",
334
+ },
335
+ },
336
+ ],
337
+ },
338
+ });
339
+
340
+ // replace default service worker script with no-op worker
341
+ const replaceWorker = project.addTask("replace-worker");
342
+ replaceWorker.exec("cp src/no-op-sw.js build/service-worker.js");
343
+ replaceWorker.exec("rm build/service-worker.js.map");
344
+ project.compileTask.spawn(replaceWorker);
345
+
346
+ project.synth();
347
+
348
+ /**
349
+ * Rewire a create-react-app task to use 'react-app-rewired` instead of 'react-scripts'
350
+ * so that our configuration overrides will take affect.
351
+ *
352
+ * @see https://www.npmjs.com/package/react-app-rewired
353
+ */
354
+ function rewireCRA(craTask: any) {
355
+ for (const step of craTask.steps) {
356
+ if (step.exec && step.exec.startsWith("react-scripts")) {
357
+ step.exec = step.exec.replace("react-scripts", "react-app-rewired");
358
+ }
359
+ }
360
+ }