@lowdefy/node-utils 4.0.0-alpha.6 → 4.0.0-alpha.9

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,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2021 Lowdefy, Inc
2
+ Copyright 2020-2022 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -12,9 +12,8 @@
12
12
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
- */ import rimraf from 'rimraf';
15
+ */ import fsExtra from 'fs-extra';
16
16
  async function cleanDirectory(dirPath) {
17
- await new Promise((resolve)=>rimraf(dirPath, resolve)
18
- );
17
+ await fsExtra.emptyDir(dirPath);
19
18
  }
20
19
  export default cleanDirectory;
@@ -0,0 +1,19 @@
1
+ /*
2
+ Copyright 2020-2022 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ import fsExtra from 'fs-extra';
16
+ async function copyDirectory(dirPathFrom, dirPathTo) {
17
+ await fsExtra.copy(dirPathFrom, dirPathTo);
18
+ }
19
+ export default copyDirectory;
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2021 Lowdefy, Inc
2
+ Copyright 2020-2022 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@
18
18
  logLevel: process.env.LOWDEFY_SERVER_LOG_LEVEL,
19
19
  publicDirectory: process.env.LOWDEFY_SERVER_PUBLIC_DIRECTORY,
20
20
  port: process.env.LOWDEFY_SERVER_PORT && parseInt(process.env.LOWDEFY_SERVER_PORT),
21
- serverBasePath: process.env.LOWDEFY_SERVER_BASE_PATH
21
+ basePath: process.env.LOWDEFY_BASE_PATH
22
22
  };
23
23
  }
24
24
  export default getConfigFromEnv;
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2021 Lowdefy, Inc
2
+ Copyright 2020-2022 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2021 Lowdefy, Inc
2
+ Copyright 2020-2022 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2021 Lowdefy, Inc
2
+ Copyright 2020-2022 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -13,10 +13,11 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import cleanDirectory from './cleanDirectory.js';
16
+ import copyDirectory from './copyDirectory.js';
16
17
  import getConfigFromEnv from './getConfigFromEnv.js';
17
18
  import getFileExtension, { getFileSubExtension } from './getFileExtension.js';
18
19
  import getSecretsFromEnv from './getSecretsFromEnv.js';
19
20
  import spawnProcess from './spawnProcess.js';
20
21
  import readFile from './readFile.js';
21
22
  import writeFile from './writeFile.js';
22
- export { cleanDirectory, getConfigFromEnv, getFileExtension, getFileSubExtension, getSecretsFromEnv, spawnProcess, readFile, writeFile };
23
+ export { cleanDirectory, copyDirectory, getConfigFromEnv, getFileExtension, getFileSubExtension, getSecretsFromEnv, spawnProcess, readFile, writeFile };
package/dist/readFile.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2021 Lowdefy, Inc
2
+ Copyright 2020-2022 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -21,12 +21,9 @@ async function readFile(filePath) {
21
21
  if (!type.isString(filePath)) {
22
22
  throw new Error(`Could not read file, file path should be a string, received ${JSON.stringify(filePath)}.`);
23
23
  }
24
- if (filePath !== path.resolve(filePath)) {
25
- throw new Error(`Could not read file, file path was not resolved, received ${JSON.stringify(filePath)}.`);
26
- }
27
24
  try {
28
25
  // By specifying encoding, readFile returns a string instead of a buffer.
29
- const file = await readFilePromise(filePath, 'utf8');
26
+ const file = await readFilePromise(path.resolve(filePath), 'utf8');
30
27
  return file;
31
28
  } catch (error) {
32
29
  if (error.code === 'ENOENT' || error.code === 'EISDIR') {
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2021 Lowdefy, Inc
2
+ Copyright 2020-2022 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
package/dist/writeFile.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2021 Lowdefy, Inc
2
+ Copyright 2020-2022 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@ import { promisify } from 'util';
18
18
  import { type } from '@lowdefy/helpers';
19
19
  const mkdirPromise = promisify(fs.mkdir);
20
20
  const writeFilePromise = promisify(fs.writeFile);
21
- async function writeFile({ filePath , content }) {
21
+ async function writeFile(filePath, content) {
22
22
  if (!type.isString(filePath)) {
23
23
  throw new Error(`Could not write file, file path should be a string, received ${JSON.stringify(filePath)}.`);
24
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/node-utils",
3
- "version": "4.0.0-alpha.6",
3
+ "version": "4.0.0-alpha.9",
4
4
  "licence": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -41,17 +41,17 @@
41
41
  "test": "jest --coverage"
42
42
  },
43
43
  "dependencies": {
44
- "@lowdefy/helpers": "4.0.0-alpha.6",
45
- "rimraf": "3.0.2"
44
+ "@lowdefy/helpers": "4.0.0-alpha.9",
45
+ "fs-extra": "10.0.0"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@swc/cli": "0.1.55",
49
- "@swc/core": "1.2.130",
49
+ "@swc/core": "1.2.135",
50
50
  "@swc/jest": "0.2.17",
51
- "jest": "27.3.1"
51
+ "jest": "27.5.1"
52
52
  },
53
53
  "publishConfig": {
54
54
  "access": "public"
55
55
  },
56
- "gitHead": "2530e31af795b6a3c75ac8f72c8dbe0ab5d1251b"
56
+ "gitHead": "98b544eca231bdcfca6c3a8601a891835d5ce571"
57
57
  }