@naturalcycles/backend-lib 4.17.9 → 4.17.11
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.
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getBackendCfg = void 0;
|
|
4
4
|
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
5
|
-
const fs = require("fs-extra");
|
|
6
5
|
const yaml = require("js-yaml");
|
|
7
6
|
const paths_cnst_1 = require("../paths.cnst");
|
|
8
7
|
const backendCfgSchema = nodejs_lib_1.AjvSchema.readJsonSync(`${paths_cnst_1.resourcesDir}/backendCfg.schema.json`, {
|
|
@@ -13,7 +12,7 @@ function getBackendCfg(projectDir = '.') {
|
|
|
13
12
|
(0, nodejs_lib_1.requireFileToExist)(backendCfgYamlPath);
|
|
14
13
|
const backendCfg = {
|
|
15
14
|
serviceWithBranchName: true,
|
|
16
|
-
...yaml.load(
|
|
15
|
+
...yaml.load((0, nodejs_lib_1._readFileSync)(backendCfgYamlPath)),
|
|
17
16
|
};
|
|
18
17
|
backendCfgSchema.validate(backendCfg);
|
|
19
18
|
return backendCfg;
|
|
@@ -83,7 +83,7 @@ async function deployHealthCheck(url, opt = {}) {
|
|
|
83
83
|
attempt++;
|
|
84
84
|
console.log([`>>`, (0, colors_1.dimGrey)(url), (0, node_util_1.inspect)({ attempt }, inspectOpt)].join(' '));
|
|
85
85
|
const started = Date.now();
|
|
86
|
-
const { err,
|
|
86
|
+
const { err, statusCode = 0 } = await fetcher.doFetch({
|
|
87
87
|
url,
|
|
88
88
|
mode: 'json',
|
|
89
89
|
timeoutSeconds: timeoutSec,
|
|
@@ -95,7 +95,6 @@ async function deployHealthCheck(url, opt = {}) {
|
|
|
95
95
|
if (err) {
|
|
96
96
|
console.log(err);
|
|
97
97
|
}
|
|
98
|
-
const statusCode = fetchResponse?.status || 0;
|
|
99
98
|
if (statusCode === 200) {
|
|
100
99
|
countHealthy++;
|
|
101
100
|
countUnhealthy = 0;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.deployPrepare = exports.deployPrepareYargsOptions = void 0;
|
|
4
|
+
const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
|
|
4
5
|
const colors_1 = require("@naturalcycles/nodejs-lib/dist/colors");
|
|
5
6
|
const fs_1 = require("@naturalcycles/nodejs-lib/dist/fs");
|
|
6
|
-
const fs = require("fs-extra");
|
|
7
7
|
const paths_cnst_1 = require("../paths.cnst");
|
|
8
8
|
const backend_cfg_util_1 = require("./backend.cfg.util");
|
|
9
9
|
const deploy_util_1 = require("./deploy.util");
|
|
@@ -60,7 +60,7 @@ async function deployPrepare(opt = {}) {
|
|
|
60
60
|
const appYamlPassEnv = opt.appYamlPassEnv || backendCfg.appYamlPassEnv;
|
|
61
61
|
console.log(`1. Copy files to ${(0, colors_1.dimGrey)(targetDir)}`);
|
|
62
62
|
// Clean targetDir
|
|
63
|
-
|
|
63
|
+
(0, nodejs_lib_1._emptyDirSync)(targetDir);
|
|
64
64
|
(0, fs_1.kpySync)({
|
|
65
65
|
baseDir: defaultFilesDir,
|
|
66
66
|
outputDir: targetDir,
|
|
@@ -76,7 +76,7 @@ async function deployPrepare(opt = {}) {
|
|
|
76
76
|
if (NPM_TOKEN && createNpmrc) {
|
|
77
77
|
const npmrcPath = `${targetDir}/.npmrc`;
|
|
78
78
|
const npmrc = `//registry.npmjs.org/:_authToken=${NPM_TOKEN}`;
|
|
79
|
-
|
|
79
|
+
(0, nodejs_lib_1._writeFileSync)(npmrcPath, npmrc);
|
|
80
80
|
}
|
|
81
81
|
console.log(`2. Generate ${(0, colors_1.dimGrey)('deployInfo.json')} and ${(0, colors_1.dimGrey)('app.yaml')} in targetDir`);
|
|
82
82
|
const deployInfo = await (0, deploy_util_1.createAndSaveDeployInfo)(backendCfg, targetDir);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/backend-lib",
|
|
3
|
-
"version": "4.17.
|
|
3
|
+
"version": "4.17.11",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"prepare": "husky install",
|
|
6
6
|
"serve": "APP_ENV=dev nodemon",
|
|
@@ -30,7 +30,6 @@
|
|
|
30
30
|
"express": "^4.16.4",
|
|
31
31
|
"express-promise-router": "^4.0.0",
|
|
32
32
|
"firebase-admin": "^11.0.0",
|
|
33
|
-
"fs-extra": "^11.0.0",
|
|
34
33
|
"helmet": "^7.0.0",
|
|
35
34
|
"js-yaml": "^4.0.0",
|
|
36
35
|
"on-finished": "^2.3.0",
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { StringMap } from '@naturalcycles/js-lib'
|
|
2
|
-
import { AjvSchema, requireFileToExist } from '@naturalcycles/nodejs-lib'
|
|
3
|
-
import * as fs from 'fs-extra'
|
|
2
|
+
import { _readFileSync, AjvSchema, requireFileToExist } from '@naturalcycles/nodejs-lib'
|
|
4
3
|
import * as yaml from 'js-yaml'
|
|
5
4
|
import { resourcesDir } from '../paths.cnst'
|
|
6
5
|
|
|
@@ -64,7 +63,7 @@ export function getBackendCfg(projectDir: string = '.'): BackendCfg {
|
|
|
64
63
|
|
|
65
64
|
const backendCfg: BackendCfg = {
|
|
66
65
|
serviceWithBranchName: true,
|
|
67
|
-
...(yaml.load(
|
|
66
|
+
...(yaml.load(_readFileSync(backendCfgYamlPath)) as any),
|
|
68
67
|
}
|
|
69
68
|
|
|
70
69
|
backendCfgSchema.validate(backendCfg)
|
|
@@ -125,7 +125,7 @@ export async function deployHealthCheck(
|
|
|
125
125
|
|
|
126
126
|
const started = Date.now()
|
|
127
127
|
|
|
128
|
-
const { err,
|
|
128
|
+
const { err, statusCode = 0 } = await fetcher.doFetch({
|
|
129
129
|
url,
|
|
130
130
|
mode: 'json',
|
|
131
131
|
timeoutSeconds: timeoutSec,
|
|
@@ -139,8 +139,6 @@ export async function deployHealthCheck(
|
|
|
139
139
|
console.log(err)
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
const statusCode = fetchResponse?.status || 0
|
|
143
|
-
|
|
144
142
|
if (statusCode === 200) {
|
|
145
143
|
countHealthy++
|
|
146
144
|
countUnhealthy = 0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { _emptyDirSync, _writeFileSync } from '@naturalcycles/nodejs-lib'
|
|
1
2
|
import { dimGrey } from '@naturalcycles/nodejs-lib/dist/colors'
|
|
2
3
|
import { kpySync } from '@naturalcycles/nodejs-lib/dist/fs'
|
|
3
|
-
import * as fs from 'fs-extra'
|
|
4
4
|
import { srcDir } from '../paths.cnst'
|
|
5
5
|
import { getBackendCfg } from './backend.cfg.util'
|
|
6
6
|
import { DeployInfo } from './deploy.model'
|
|
@@ -77,7 +77,7 @@ export async function deployPrepare(opt: DeployPrepareOptions = {}): Promise<Dep
|
|
|
77
77
|
console.log(`1. Copy files to ${dimGrey(targetDir)}`)
|
|
78
78
|
|
|
79
79
|
// Clean targetDir
|
|
80
|
-
|
|
80
|
+
_emptyDirSync(targetDir)
|
|
81
81
|
|
|
82
82
|
kpySync({
|
|
83
83
|
baseDir: defaultFilesDir,
|
|
@@ -96,7 +96,7 @@ export async function deployPrepare(opt: DeployPrepareOptions = {}): Promise<Dep
|
|
|
96
96
|
if (NPM_TOKEN && createNpmrc) {
|
|
97
97
|
const npmrcPath = `${targetDir}/.npmrc`
|
|
98
98
|
const npmrc = `//registry.npmjs.org/:_authToken=${NPM_TOKEN}`
|
|
99
|
-
|
|
99
|
+
_writeFileSync(npmrcPath, npmrc)
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
console.log(`2. Generate ${dimGrey('deployInfo.json')} and ${dimGrey('app.yaml')} in targetDir`)
|