@naturalcycles/backend-lib 4.17.8 → 4.17.10

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(fs.readFileSync(backendCfgYamlPath, 'utf8')),
15
+ ...yaml.load((0, nodejs_lib_1._readFileSync)(backendCfgYamlPath)),
17
16
  };
18
17
  backendCfgSchema.validate(backendCfg);
19
18
  return backendCfg;
@@ -90,7 +90,7 @@ async function deployHealthCheck(url, opt = {}) {
90
90
  retry: {
91
91
  count: 0,
92
92
  },
93
- followRedirects: false,
93
+ redirect: 'error',
94
94
  });
95
95
  if (err) {
96
96
  console.log(err);
@@ -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
- fs.emptyDirSync(targetDir);
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
- fs.writeFileSync(npmrcPath, npmrc);
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);
@@ -48,7 +48,7 @@ function respondWithError(req, res, err) {
48
48
  }
49
49
  if (res.headersSent)
50
50
  return;
51
- const httpError = (0, js_lib_1._errorToErrorObject)(originalError);
51
+ const httpError = (0, js_lib_1._errorLikeToErrorObject)(originalError);
52
52
  if (!includeErrorStack)
53
53
  delete httpError.stack;
54
54
  httpError.data.errorId = errorId;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/backend-lib",
3
- "version": "4.17.8",
3
+ "version": "4.17.10",
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(fs.readFileSync(backendCfgYamlPath, 'utf8')) as any),
66
+ ...(yaml.load(_readFileSync(backendCfgYamlPath)) as any),
68
67
  }
69
68
 
70
69
  backendCfgSchema.validate(backendCfg)
@@ -132,7 +132,7 @@ export async function deployHealthCheck(
132
132
  retry: {
133
133
  count: 0,
134
134
  },
135
- followRedirects: false,
135
+ redirect: 'error',
136
136
  })
137
137
 
138
138
  if (err) {
@@ -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
- fs.emptyDirSync(targetDir)
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
- fs.writeFileSync(npmrcPath, npmrc)
99
+ _writeFileSync(npmrcPath, npmrc)
100
100
  }
101
101
 
102
102
  console.log(`2. Generate ${dimGrey('deployInfo.json')} and ${dimGrey('app.yaml')} in targetDir`)
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  _anyToError,
3
- _errorToErrorObject,
3
+ _errorLikeToErrorObject,
4
4
  _filterUndefinedValues,
5
5
  AppError,
6
6
  BackendErrorResponseObject,
@@ -81,7 +81,7 @@ export function respondWithError(req: BackendRequest, res: BackendResponse, err:
81
81
 
82
82
  if (res.headersSent) return
83
83
 
84
- const httpError = _errorToErrorObject(originalError)
84
+ const httpError = _errorLikeToErrorObject(originalError)
85
85
  if (!includeErrorStack) delete httpError.stack
86
86
 
87
87
  httpError.data.errorId = errorId