@naturalcycles/backend-lib 5.15.0 → 5.16.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.
@@ -17,6 +17,10 @@ export interface BackendCfg {
17
17
  * List of branches to use timestamps in gae version names (to keep previous versions).
18
18
  */
19
19
  branchesWithTimestampVersions?: string[];
20
+ /**
21
+ * If true - branch names are not passed into deployed urls as is, but are hashed.
22
+ */
23
+ hashedBranches?: boolean;
20
24
  /**
21
25
  * Comma-separated list of env variables that will be passed to app.yaml from process.env
22
26
  */
@@ -44,7 +44,12 @@ async function createDeployInfo(backendCfg, overrideBranch) {
44
44
  gaeService = validateGAEServiceName(gaeServiceByBranch[gitBranch]);
45
45
  }
46
46
  else {
47
- gaeService = validateGAEServiceName([gitBranch, gaeService].join('--'));
47
+ let branchName = gitBranch;
48
+ if (backendCfg.hashedBranches) {
49
+ // todo: jira
50
+ branchName = (0, nodejs_lib_1.md5)(gitBranch).slice(0, 10);
51
+ }
52
+ gaeService = validateGAEServiceName([branchName, gaeService].join('--'));
48
53
  }
49
54
  let gaeVersion = '1';
50
55
  if (branchesWithTimestampVersions.includes(gitBranch)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/backend-lib",
3
- "version": "5.15.0",
3
+ "version": "5.16.0",
4
4
  "scripts": {
5
5
  "prepare": "husky",
6
6
  "build": "dev-lib build",
@@ -32,6 +32,9 @@
32
32
  "type": "array",
33
33
  "items": { "type": "string" }
34
34
  },
35
+ "hashedBranches": {
36
+ "type": "boolean"
37
+ },
35
38
  "appYamlPassEnv": { "type": "string" }
36
39
  },
37
40
  "required": ["gaeProject", "gaeService", "appEnvDefault"]
@@ -25,6 +25,11 @@ export interface BackendCfg {
25
25
  */
26
26
  branchesWithTimestampVersions?: string[]
27
27
 
28
+ /**
29
+ * If true - branch names are not passed into deployed urls as is, but are hashed.
30
+ */
31
+ hashedBranches?: boolean
32
+
28
33
  /**
29
34
  * Comma-separated list of env variables that will be passed to app.yaml from process.env
30
35
  */
@@ -1,5 +1,5 @@
1
1
  import { _assert, _mapValues, _merge, _truncate, localTime } from '@naturalcycles/js-lib'
2
- import { dimGrey, fs2, white } from '@naturalcycles/nodejs-lib'
2
+ import { dimGrey, fs2, md5, white } from '@naturalcycles/nodejs-lib'
3
3
  import { BackendCfg } from './backend.cfg.util'
4
4
  import { AppYaml, DeployInfo } from './deploy.model'
5
5
 
@@ -57,7 +57,14 @@ export async function createDeployInfo(
57
57
  if (gaeServiceByBranch[gitBranch]) {
58
58
  gaeService = validateGAEServiceName(gaeServiceByBranch[gitBranch])
59
59
  } else {
60
- gaeService = validateGAEServiceName([gitBranch, gaeService].join('--'))
60
+ let branchName = gitBranch
61
+
62
+ if (backendCfg.hashedBranches) {
63
+ // todo: jira
64
+ branchName = md5(gitBranch).slice(0, 10)
65
+ }
66
+
67
+ gaeService = validateGAEServiceName([branchName, gaeService].join('--'))
61
68
  }
62
69
 
63
70
  let gaeVersion = '1'