@naturalcycles/backend-lib 4.23.1 → 4.23.2

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.
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getBackendCfg = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
6
- const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
7
5
  const paths_cnst_1 = require("../paths.cnst");
8
6
  const backendCfgSchema = nodejs_lib_1.AjvSchema.readJsonSync(`${paths_cnst_1.resourcesDir}/backendCfg.schema.json`, {
9
7
  objectName: 'backend.cfg.yaml',
@@ -13,7 +11,7 @@ function getBackendCfg(projectDir = '.') {
13
11
  (0, nodejs_lib_1.requireFileToExist)(backendCfgYamlPath);
14
12
  const backendCfg = {
15
13
  serviceWithBranchName: true,
16
- ...js_yaml_1.default.load((0, nodejs_lib_1._readFileSync)(backendCfgYamlPath)),
14
+ ...nodejs_lib_1.fs2.readYaml(backendCfgYamlPath),
17
15
  };
18
16
  backendCfgSchema.validate(backendCfg);
19
17
  return backendCfg;
@@ -58,7 +58,7 @@ async function deployPrepare(opt = {}) {
58
58
  const appYamlPassEnv = opt.appYamlPassEnv || backendCfg.appYamlPassEnv;
59
59
  console.log(`1. Copy files to ${(0, nodejs_lib_1.dimGrey)(targetDir)}`);
60
60
  // Clean targetDir
61
- (0, nodejs_lib_1._emptyDirSync)(targetDir);
61
+ nodejs_lib_1.fs2.emptyDir(targetDir);
62
62
  (0, nodejs_lib_1.kpySync)({
63
63
  baseDir: defaultFilesDir,
64
64
  outputDir: targetDir,
@@ -74,7 +74,7 @@ async function deployPrepare(opt = {}) {
74
74
  if (NPM_TOKEN && createNpmrc) {
75
75
  const npmrcPath = `${targetDir}/.npmrc`;
76
76
  const npmrc = `//registry.npmjs.org/:_authToken=${NPM_TOKEN}`;
77
- (0, nodejs_lib_1._writeFileSync)(npmrcPath, npmrc);
77
+ nodejs_lib_1.fs2.writeFile(npmrcPath, npmrc);
78
78
  }
79
79
  console.log(`2. Generate ${(0, nodejs_lib_1.dimGrey)('deployInfo.json')} and ${(0, nodejs_lib_1.dimGrey)('app.yaml')} in targetDir`);
80
80
  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.23.1",
3
+ "version": "4.23.2",
4
4
  "scripts": {
5
5
  "prepare": "husky install",
6
6
  "serve": "APP_ENV=dev nodemon",
@@ -31,7 +31,6 @@
31
31
  "express-promise-router": "^4.0.0",
32
32
  "firebase-admin": "^12.0.0",
33
33
  "helmet": "^7.0.0",
34
- "js-yaml": "^4.0.0",
35
34
  "on-finished": "^2.3.0",
36
35
  "simple-git": "^3.0.3",
37
36
  "yargs": "^17.0.0"
@@ -41,7 +40,6 @@
41
40
  "@naturalcycles/dev-lib": "^13.0.0",
42
41
  "@sentry/node": "^7.0.0",
43
42
  "@types/ejs": "^3.0.0",
44
- "@types/js-yaml": "^4.0.0",
45
43
  "@types/node": "^20.1.0",
46
44
  "@types/yargs": "^16.0.0",
47
45
  "fastify": "^4.0.0",
@@ -75,7 +75,7 @@ export function httpDBRequestHandler(db: CommonDB): BackendRouter {
75
75
 
76
76
  // getTableSchema
77
77
  router.get('/:table/schema', async (req, res) => {
78
- res.json(await db.getTableSchema(req.params['table']!))
78
+ res.json(await db.getTableSchema(req.params['table']))
79
79
  })
80
80
 
81
81
  // todo: createTable
@@ -1,6 +1,5 @@
1
1
  import { StringMap } from '@naturalcycles/js-lib'
2
- import { _readFileSync, AjvSchema, requireFileToExist } from '@naturalcycles/nodejs-lib'
3
- import yaml from 'js-yaml'
2
+ import { AjvSchema, fs2, requireFileToExist } from '@naturalcycles/nodejs-lib'
4
3
  import { resourcesDir } from '../paths.cnst'
5
4
 
6
5
  export interface BackendCfg {
@@ -63,7 +62,7 @@ export function getBackendCfg(projectDir: string = '.'): BackendCfg {
63
62
 
64
63
  const backendCfg: BackendCfg = {
65
64
  serviceWithBranchName: true,
66
- ...(yaml.load(_readFileSync(backendCfgYamlPath)) as any),
65
+ ...fs2.readYaml(backendCfgYamlPath),
67
66
  }
68
67
 
69
68
  backendCfgSchema.validate(backendCfg)
@@ -1,4 +1,4 @@
1
- import { _emptyDirSync, _writeFileSync, dimGrey, kpySync } from '@naturalcycles/nodejs-lib'
1
+ import { dimGrey, fs2, kpySync } from '@naturalcycles/nodejs-lib'
2
2
  import { srcDir } from '../paths.cnst'
3
3
  import { getBackendCfg } from './backend.cfg.util'
4
4
  import { DeployInfo } from './deploy.model'
@@ -75,7 +75,7 @@ export async function deployPrepare(opt: DeployPrepareOptions = {}): Promise<Dep
75
75
  console.log(`1. Copy files to ${dimGrey(targetDir)}`)
76
76
 
77
77
  // Clean targetDir
78
- _emptyDirSync(targetDir)
78
+ fs2.emptyDir(targetDir)
79
79
 
80
80
  kpySync({
81
81
  baseDir: defaultFilesDir,
@@ -94,7 +94,7 @@ export async function deployPrepare(opt: DeployPrepareOptions = {}): Promise<Dep
94
94
  if (NPM_TOKEN && createNpmrc) {
95
95
  const npmrcPath = `${targetDir}/.npmrc`
96
96
  const npmrc = `//registry.npmjs.org/:_authToken=${NPM_TOKEN}`
97
- _writeFileSync(npmrcPath, npmrc)
97
+ fs2.writeFile(npmrcPath, npmrc)
98
98
  }
99
99
 
100
100
  console.log(`2. Generate ${dimGrey('deployInfo.json')} and ${dimGrey('app.yaml')} in targetDir`)