@naturalcycles/backend-lib 4.21.0 → 4.22.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/dist/admin/base.admin.service.js +1 -1
- package/dist/deploy/deploy.util.js +5 -4
- package/dist/deploy/deployPrepare.js +4 -4
- package/dist/sentry/sentry.shared.service.js +3 -3
- package/dist/testing/express.test.service.js +2 -2
- package/package.json +2 -2
- package/src/deploy/deploy.util.ts +10 -6
|
@@ -55,6 +55,9 @@ async function createDeployInfo(backendCfg) {
|
|
|
55
55
|
].join('-');
|
|
56
56
|
}
|
|
57
57
|
const versionUrl = `https://${[gaeVersion, gaeService, gaeProject].join('-dot-')}.appspot.com`;
|
|
58
|
+
// Check the 63-char limit
|
|
59
|
+
const versionUrlString = [gaeVersion, gaeService, gaeProject].join('-dot-');
|
|
60
|
+
(0, js_lib_1._assert)(versionUrlString.length <= 63, `versionUrl length should be <= 63 characters, but it's ${versionUrlString.length} instead: ${versionUrlString}`);
|
|
58
61
|
const serviceUrl = `https://${[gaeService, gaeProject].join('-dot-')}.appspot.com`;
|
|
59
62
|
const deployInfo = {
|
|
60
63
|
gaeProject,
|
|
@@ -138,12 +141,10 @@ function redactedAppYaml(appYaml) {
|
|
|
138
141
|
}
|
|
139
142
|
function validateGAEServiceName(serviceName) {
|
|
140
143
|
// May only contain lowercase letters, digits, and hyphens. Must begin and end with a letter or digit. Must not exceed 63 characters.
|
|
141
|
-
return
|
|
144
|
+
return serviceName
|
|
145
|
+
.replaceAll('_', '-')
|
|
142
146
|
.toLowerCase()
|
|
143
147
|
.replaceAll(/[^0-9a-z-]/gi, '')
|
|
144
148
|
.slice(0, 40);
|
|
145
149
|
}
|
|
146
150
|
exports.validateGAEServiceName = validateGAEServiceName;
|
|
147
|
-
function replaceAll(str, search, replacement) {
|
|
148
|
-
return str.split(search).join(replacement);
|
|
149
|
-
}
|
|
@@ -30,7 +30,7 @@ const DEFAULT_FILES = [
|
|
|
30
30
|
// '!dist/**/*.test.*',
|
|
31
31
|
// '!dist/**/*.mock.*',
|
|
32
32
|
'!dist/**/*.script.*',
|
|
33
|
-
'src',
|
|
33
|
+
'src', // For Sentry
|
|
34
34
|
'!src/test',
|
|
35
35
|
'!src/**/*.test.*',
|
|
36
36
|
'!src/**/*.mock.*',
|
|
@@ -38,15 +38,15 @@ const DEFAULT_FILES = [
|
|
|
38
38
|
'!**/__snapshots__',
|
|
39
39
|
'!**/__exclude',
|
|
40
40
|
'static',
|
|
41
|
-
'secret/**/*.enc',
|
|
41
|
+
'secret/**/*.enc', // encrypted secrets
|
|
42
42
|
'package.json',
|
|
43
43
|
'yarn.lock',
|
|
44
44
|
'.yarnrc',
|
|
45
|
-
'tsconfig.json',
|
|
45
|
+
'tsconfig.json', // for path-mapping to work!
|
|
46
46
|
'tsconfig.dist.json',
|
|
47
47
|
'.gcloudignore',
|
|
48
48
|
'app.yaml',
|
|
49
|
-
'patches',
|
|
49
|
+
'patches', // to allow patch-package
|
|
50
50
|
'resources',
|
|
51
51
|
];
|
|
52
52
|
const defaultFilesDir = `${paths_cnst_1.srcDir}/deploy/files-default`;
|
|
@@ -35,7 +35,7 @@ class SentrySharedService {
|
|
|
35
35
|
console.log('SentryService init...');
|
|
36
36
|
}
|
|
37
37
|
sentry.init({
|
|
38
|
-
maxValueLength: 2000,
|
|
38
|
+
maxValueLength: 2000, // default is 250 characters
|
|
39
39
|
...this.sentryServiceCfg,
|
|
40
40
|
});
|
|
41
41
|
return sentry;
|
|
@@ -113,8 +113,8 @@ class SentrySharedService {
|
|
|
113
113
|
*/
|
|
114
114
|
getCommonLogger() {
|
|
115
115
|
return {
|
|
116
|
-
log: () => { },
|
|
117
|
-
warn: () => { },
|
|
116
|
+
log: () => { }, // noop
|
|
117
|
+
warn: () => { }, // noop
|
|
118
118
|
error: (...args) => {
|
|
119
119
|
const message = args.map(arg => (0, nodejs_lib_1._inspect)(arg, INSPECT_OPT)).join(' ');
|
|
120
120
|
this.sentry().addBreadcrumb({
|
|
@@ -31,8 +31,8 @@ class ExpressTestService {
|
|
|
31
31
|
retry: { count: 0 },
|
|
32
32
|
logRequest: true,
|
|
33
33
|
logResponse: true,
|
|
34
|
-
logWithBaseUrl: false,
|
|
35
|
-
fetchFn: nativeFetchFn,
|
|
34
|
+
logWithBaseUrl: false, // for stable error snapshots
|
|
35
|
+
fetchFn: nativeFetchFn, // this is to make it NOT mockable
|
|
36
36
|
...opt,
|
|
37
37
|
}).onAfterResponse(async () => {
|
|
38
38
|
// This "empty" hook exists to act like `await pDelay`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/backend-lib",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.22.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"prepare": "husky install",
|
|
6
6
|
"serve": "APP_ENV=dev nodemon",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"ejs": "^3.0.1",
|
|
30
30
|
"express": "^4.16.4",
|
|
31
31
|
"express-promise-router": "^4.0.0",
|
|
32
|
-
"firebase-admin": "^
|
|
32
|
+
"firebase-admin": "^12.0.0",
|
|
33
33
|
"helmet": "^7.0.0",
|
|
34
34
|
"js-yaml": "^4.0.0",
|
|
35
35
|
"on-finished": "^2.3.0",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import fs from 'node:fs'
|
|
2
|
-
import { _mapValues, _merge, _truncate, localTimeNow } from '@naturalcycles/js-lib'
|
|
2
|
+
import { _assert, _mapValues, _merge, _truncate, localTimeNow } from '@naturalcycles/js-lib'
|
|
3
3
|
import { dimGrey, white } from '@naturalcycles/nodejs-lib'
|
|
4
4
|
import yaml from 'js-yaml'
|
|
5
5
|
import { BackendCfg } from './backend.cfg.util'
|
|
@@ -79,6 +79,13 @@ export async function createDeployInfo(backendCfg: BackendCfg): Promise<DeployIn
|
|
|
79
79
|
|
|
80
80
|
const versionUrl = `https://${[gaeVersion, gaeService, gaeProject].join('-dot-')}.appspot.com`
|
|
81
81
|
|
|
82
|
+
// Check the 63-char limit
|
|
83
|
+
const versionUrlString = [gaeVersion, gaeService, gaeProject].join('-dot-')
|
|
84
|
+
_assert(
|
|
85
|
+
versionUrlString.length <= 63,
|
|
86
|
+
`versionUrl length should be <= 63 characters, but it's ${versionUrlString.length} instead: ${versionUrlString}`,
|
|
87
|
+
)
|
|
88
|
+
|
|
82
89
|
const serviceUrl = `https://${[gaeService, gaeProject].join('-dot-')}.appspot.com`
|
|
83
90
|
|
|
84
91
|
const deployInfo: DeployInfo = {
|
|
@@ -198,12 +205,9 @@ function redactedAppYaml(appYaml: AppYaml): AppYaml {
|
|
|
198
205
|
|
|
199
206
|
export function validateGAEServiceName(serviceName: string): string {
|
|
200
207
|
// May only contain lowercase letters, digits, and hyphens. Must begin and end with a letter or digit. Must not exceed 63 characters.
|
|
201
|
-
return
|
|
208
|
+
return serviceName
|
|
209
|
+
.replaceAll('_', '-')
|
|
202
210
|
.toLowerCase()
|
|
203
211
|
.replaceAll(/[^0-9a-z-]/gi, '')
|
|
204
212
|
.slice(0, 40)
|
|
205
213
|
}
|
|
206
|
-
|
|
207
|
-
function replaceAll(str: string, search: string, replacement: string): string {
|
|
208
|
-
return str.split(search).join(replacement)
|
|
209
|
-
}
|