mirror of
https://github.com/lowdefy/lowdefy.git
synced 2025-04-06 15:30:30 +08:00
fix: move file helpers to new node-utils package
This commit is contained in:
parent
1159ac71e7
commit
0a6ef8d09b
27
.pnp.js
generated
27
.pnp.js
generated
@ -58,6 +58,10 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
|
||||
"name": "@lowdefy/layout",
|
||||
"reference": "workspace:packages/layout"
|
||||
},
|
||||
{
|
||||
"name": "@lowdefy/node-utils",
|
||||
"reference": "workspace:packages/nodeUtils"
|
||||
},
|
||||
{
|
||||
"name": "@lowdefy/nunjucks",
|
||||
"reference": "workspace:packages/nunjucks"
|
||||
@ -84,6 +88,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
|
||||
["@lowdefy/helpers", ["workspace:packages/helpers"]],
|
||||
["@lowdefy/layout", ["workspace:packages/layout"]],
|
||||
["@lowdefy/lowdefy", ["workspace:."]],
|
||||
["@lowdefy/node-utils", ["workspace:packages/nodeUtils"]],
|
||||
["@lowdefy/nunjucks", ["workspace:packages/nunjucks"]],
|
||||
["@lowdefy/operators", ["workspace:packages/operators"]],
|
||||
["@lowdefy/renderer", ["workspace:packages/renderer"]]
|
||||
@ -3670,6 +3675,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
|
||||
["@babel/core", "npm:7.12.3"],
|
||||
["@babel/preset-env", "virtual:4a7337632ff6e9ee5a1c45a62a9ff4cc325a9367b21424babda93e269fe01b671e885bc41bdeebafb83c81f2a8eebbf0102043354a4e58905f61c8c3387cda1e#npm:7.12.1"],
|
||||
["@lowdefy/helpers", "workspace:packages/helpers"],
|
||||
["@lowdefy/node-utils", "workspace:packages/nodeUtils"],
|
||||
["@lowdefy/nunjucks", "workspace:packages/nunjucks"],
|
||||
["ajv", "npm:6.12.6"],
|
||||
["axios", "npm:0.20.0"],
|
||||
@ -3771,6 +3777,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
|
||||
["@babel/core", "npm:7.12.3"],
|
||||
["@babel/preset-env", "virtual:4a7337632ff6e9ee5a1c45a62a9ff4cc325a9367b21424babda93e269fe01b671e885bc41bdeebafb83c81f2a8eebbf0102043354a4e58905f61c8c3387cda1e#npm:7.12.1"],
|
||||
["@lowdefy/helpers", "workspace:packages/helpers"],
|
||||
["@lowdefy/node-utils", "workspace:packages/nodeUtils"],
|
||||
["apollo-server", "virtual:7fa6405098723f150ab741c1e73c906de11a676b4cc641bac8b3397ea2dd6efbb913e72a780932220533241b442cc586b41b26c7b5ac786de486992cd2db054c#npm:2.18.2"],
|
||||
["apollo-server-testing", "virtual:7fa6405098723f150ab741c1e73c906de11a676b4cc641bac8b3397ea2dd6efbb913e72a780932220533241b442cc586b41b26c7b5ac786de486992cd2db054c#npm:2.18.2"],
|
||||
["babel-jest", "virtual:4a7337632ff6e9ee5a1c45a62a9ff4cc325a9367b21424babda93e269fe01b671e885bc41bdeebafb83c81f2a8eebbf0102043354a4e58905f61c8c3387cda1e#npm:26.5.2"],
|
||||
@ -3797,8 +3804,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
|
||||
["jest", "npm:26.5.3"],
|
||||
["jest-diff", "npm:26.5.2"],
|
||||
["lodash.merge", "npm:4.6.2"],
|
||||
["query-string", "npm:6.13.6"],
|
||||
["rimraf", "npm:3.0.2"]
|
||||
["query-string", "npm:6.13.6"]
|
||||
],
|
||||
"linkType": "SOFT",
|
||||
}]
|
||||
@ -3863,6 +3869,23 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
|
||||
"linkType": "SOFT",
|
||||
}]
|
||||
]],
|
||||
["@lowdefy/node-utils", [
|
||||
["workspace:packages/nodeUtils", {
|
||||
"packageLocation": "./packages/nodeUtils/",
|
||||
"packageDependencies": [
|
||||
["@lowdefy/node-utils", "workspace:packages/nodeUtils"],
|
||||
["@babel/cli", "virtual:4a7337632ff6e9ee5a1c45a62a9ff4cc325a9367b21424babda93e269fe01b671e885bc41bdeebafb83c81f2a8eebbf0102043354a4e58905f61c8c3387cda1e#npm:7.12.1"],
|
||||
["@babel/core", "npm:7.12.3"],
|
||||
["@babel/preset-env", "virtual:4a7337632ff6e9ee5a1c45a62a9ff4cc325a9367b21424babda93e269fe01b671e885bc41bdeebafb83c81f2a8eebbf0102043354a4e58905f61c8c3387cda1e#npm:7.12.1"],
|
||||
["@lowdefy/helpers", "workspace:packages/helpers"],
|
||||
["babel-jest", "virtual:4a7337632ff6e9ee5a1c45a62a9ff4cc325a9367b21424babda93e269fe01b671e885bc41bdeebafb83c81f2a8eebbf0102043354a4e58905f61c8c3387cda1e#npm:26.5.2"],
|
||||
["jest", "npm:26.5.3"],
|
||||
["jest-diff", "npm:26.5.2"],
|
||||
["rimraf", "npm:3.0.2"]
|
||||
],
|
||||
"linkType": "SOFT",
|
||||
}]
|
||||
]],
|
||||
["@lowdefy/nunjucks", [
|
||||
["workspace:packages/nunjucks", {
|
||||
"packageLocation": "./packages/nunjucks/",
|
||||
|
@ -29,6 +29,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@lowdefy/helpers": "1.1.0",
|
||||
"@lowdefy/node-utils": "1.0.0",
|
||||
"@lowdefy/nunjucks": "1.0.0",
|
||||
"ajv": "6.12.6",
|
||||
"axios": "0.20.0",
|
||||
|
@ -14,7 +14,8 @@
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { get, getFileExtension, getFileSubExtension, type } from '@lowdefy/helpers';
|
||||
import { get, type } from '@lowdefy/helpers';
|
||||
import { getFileExtension, getFileSubExtension } from '@lowdefy/node-utils';
|
||||
import { nunjucksFunction } from '@lowdefy/nunjucks';
|
||||
import JSON5 from 'json5';
|
||||
import YAML from 'js-yaml';
|
||||
|
@ -14,7 +14,7 @@
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { cleanDirectory } from '@lowdefy/helpers';
|
||||
import { cleanDirectory } from '@lowdefy/node-utils';
|
||||
|
||||
async function cleanOutputDirectory({ context }) {
|
||||
return cleanDirectory(context.outputDirectory);
|
||||
|
@ -14,10 +14,10 @@
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { cleanDirectory } from '@lowdefy/helpers';
|
||||
import { cleanDirectory } from '@lowdefy/node-utils';
|
||||
import cleanOutputDirectory from './cleanOutputDirectory';
|
||||
|
||||
jest.mock('@lowdefy/helpers', () => {
|
||||
jest.mock('@lowdefy/node-utils', () => {
|
||||
return {
|
||||
cleanDirectory: jest.fn(),
|
||||
};
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
import path from 'path';
|
||||
import { writeFile } from '@lowdefy/helpers';
|
||||
import { writeFile } from '@lowdefy/node-utils';
|
||||
|
||||
class FileSetter {
|
||||
constructor({ baseDirectory }) {
|
||||
|
@ -16,7 +16,8 @@
|
||||
|
||||
import JSON5 from 'json5';
|
||||
import YAML from 'js-yaml';
|
||||
import { getFileExtension, readFile, type } from '@lowdefy/helpers';
|
||||
import { type } from '@lowdefy/helpers';
|
||||
import { getFileExtension, readFile } from '@lowdefy/node-utils';
|
||||
|
||||
async function getJsonFile(filePath) {
|
||||
const file = await readFile(filePath);
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
import path from 'path';
|
||||
import { readFile } from '@lowdefy/helpers';
|
||||
import { readFile } from '@lowdefy/node-utils';
|
||||
import createCacheKey from './createCacheKey';
|
||||
|
||||
function createFetchMetaCache({ cacheDirectory }) {
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
import path from 'path';
|
||||
import { writeFile } from '@lowdefy/helpers';
|
||||
import { writeFile } from '@lowdefy/node-utils';
|
||||
import createCacheKey from './createCacheKey';
|
||||
|
||||
function createWriteMetaCache({ cacheDirectory }) {
|
||||
|
@ -29,6 +29,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@lowdefy/helpers": "1.1.0",
|
||||
"@lowdefy/node-utils": "1.0.0",
|
||||
"apollo-server": "2.18.2",
|
||||
"dataloader": "2.0.0",
|
||||
"graphql": "15.3.0",
|
||||
|
@ -14,7 +14,7 @@
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { readFile } from '@lowdefy/helpers';
|
||||
import { readFile } from '@lowdefy/node-utils';
|
||||
import { ConfigurationError } from '../context/errors';
|
||||
|
||||
async function readJsonFile({ filePath }) {
|
||||
|
@ -31,8 +31,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"lodash.merge": "4.6.2",
|
||||
"query-string": "6.13.6",
|
||||
"rimraf": "3.0.2"
|
||||
"query-string": "6.13.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "7.12.1",
|
||||
|
@ -15,12 +15,9 @@
|
||||
*/
|
||||
|
||||
import applyArrayIndices from './applyArrayIndices';
|
||||
import cleanDirectory from './cleanDirectory';
|
||||
import get from './get';
|
||||
import getFileExtension, { getFileSubExtension } from './getFileExtension';
|
||||
import mergeObjects from './mergeObjects';
|
||||
import omit from './omit';
|
||||
import readFile from './readFile';
|
||||
import serializer from './serializer';
|
||||
import set from './set';
|
||||
import stableStringify from './stableStringify';
|
||||
@ -28,17 +25,12 @@ import swap from './swap';
|
||||
import type from './type';
|
||||
import unset from './unset';
|
||||
import urlQuery from './urlQuery';
|
||||
import writeFile from './writeFile';
|
||||
|
||||
export {
|
||||
applyArrayIndices,
|
||||
cleanDirectory,
|
||||
get,
|
||||
getFileExtension,
|
||||
getFileSubExtension,
|
||||
mergeObjects,
|
||||
omit,
|
||||
readFile,
|
||||
serializer,
|
||||
set,
|
||||
stableStringify,
|
||||
@ -46,5 +38,4 @@ export {
|
||||
type,
|
||||
unset,
|
||||
urlQuery,
|
||||
writeFile,
|
||||
};
|
||||
|
13
packages/nodeUtils/.babelrc
Normal file
13
packages/nodeUtils/.babelrc
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"presets": [
|
||||
[
|
||||
"@babel/preset-env",
|
||||
{
|
||||
"targets": {
|
||||
"node": "12",
|
||||
"esmodules": true
|
||||
}
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
11
packages/nodeUtils/jest.config.js
Normal file
11
packages/nodeUtils/jest.config.js
Normal file
@ -0,0 +1,11 @@
|
||||
module.exports = {
|
||||
clearMocks: true,
|
||||
collectCoverage: true,
|
||||
collectCoverageFrom: ['src/**/*.js'],
|
||||
coverageDirectory: 'coverage',
|
||||
coveragePathIgnorePatterns: ['<rootDir>/dist/', '<rootDir>/test/'],
|
||||
coverageReporters: ['lcov', 'text', 'clover'],
|
||||
errorOnDeprecated: true,
|
||||
testEnvironment: 'node',
|
||||
testPathIgnorePatterns: ['<rootDir>/dist/'],
|
||||
};
|
44
packages/nodeUtils/package.json
Normal file
44
packages/nodeUtils/package.json
Normal file
@ -0,0 +1,44 @@
|
||||
{
|
||||
"name": "@lowdefy/node-utils",
|
||||
"version": "1.0.0",
|
||||
"licence": "Apache-2.0",
|
||||
"description": "",
|
||||
"homepage": "https://lowdefy.com",
|
||||
"bugs": {
|
||||
"url": "https://github.com/lowdefy/lowdefy/issues"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Sam Tolmay",
|
||||
"url": "https://github.com/SamTolmay"
|
||||
},
|
||||
{
|
||||
"name": "Gerrie van Wyk",
|
||||
"url": "https://github.com/Gervwyk"
|
||||
}
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/lowdefy/lowdefy.git"
|
||||
},
|
||||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
"build": "babel src --out-dir dist",
|
||||
"test": "jest --coverage",
|
||||
"prepare": "yarn build",
|
||||
"prepublishOnly": "yarn build",
|
||||
"npm-publish": "npm publish --access public"
|
||||
},
|
||||
"dependencies": {
|
||||
"@lowdefy/helpers": "1.1.0",
|
||||
"rimraf": "3.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "7.12.1",
|
||||
"@babel/core": "7.12.3",
|
||||
"@babel/preset-env": "7.12.1",
|
||||
"babel-jest": "26.5.2",
|
||||
"jest": "26.5.3",
|
||||
"jest-diff": "26.5.2"
|
||||
}
|
||||
}
|
22
packages/nodeUtils/src/index.js
Normal file
22
packages/nodeUtils/src/index.js
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
Copyright 2020 Lowdefy, Inc
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import cleanDirectory from './cleanDirectory';
|
||||
import getFileExtension, { getFileSubExtension } from './getFileExtension';
|
||||
import readFile from './readFile';
|
||||
import writeFile from './writeFile';
|
||||
|
||||
export { cleanDirectory, getFileExtension, getFileSubExtension, readFile, writeFile };
|
@ -17,7 +17,7 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { promisify } from 'util';
|
||||
import type from './type';
|
||||
import { type } from '@lowdefy/helpers';
|
||||
|
||||
const readFilePromise = promisify(fs.readFile);
|
||||
|
@ -37,7 +37,7 @@ test('readFile error id filepath is not a string', async () => {
|
||||
});
|
||||
|
||||
test('readFile errors if path is not already resolved', async () => {
|
||||
await expect(readFile('./omit.test.js')).rejects.toThrow(
|
||||
'Could not read file, file path was not resolved, received "./omit.test.js".'
|
||||
await expect(readFile('./readFile/readFile.txt')).rejects.toThrow(
|
||||
'Could not read file, file path was not resolved, received "./readFile/readFile.txt".'
|
||||
);
|
||||
});
|
18
yarn.lock
18
yarn.lock
@ -2841,6 +2841,7 @@ __metadata:
|
||||
"@babel/core": 7.12.3
|
||||
"@babel/preset-env": 7.12.1
|
||||
"@lowdefy/helpers": 1.1.0
|
||||
"@lowdefy/node-utils": 1.0.0
|
||||
"@lowdefy/nunjucks": 1.0.0
|
||||
ajv: 6.12.6
|
||||
axios: 0.20.0
|
||||
@ -2932,6 +2933,7 @@ __metadata:
|
||||
"@babel/core": 7.12.3
|
||||
"@babel/preset-env": 7.12.1
|
||||
"@lowdefy/helpers": 1.1.0
|
||||
"@lowdefy/node-utils": 1.0.0
|
||||
apollo-server: 2.18.2
|
||||
apollo-server-testing: 2.18.2
|
||||
babel-jest: 26.5.2
|
||||
@ -2957,7 +2959,6 @@ __metadata:
|
||||
jest-diff: 26.5.2
|
||||
lodash.merge: 4.6.2
|
||||
query-string: 6.13.6
|
||||
rimraf: 3.0.2
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
@ -3017,6 +3018,21 @@ __metadata:
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@lowdefy/node-utils@1.0.0, @lowdefy/node-utils@workspace:packages/nodeUtils":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@lowdefy/node-utils@workspace:packages/nodeUtils"
|
||||
dependencies:
|
||||
"@babel/cli": 7.12.1
|
||||
"@babel/core": 7.12.3
|
||||
"@babel/preset-env": 7.12.1
|
||||
"@lowdefy/helpers": 1.1.0
|
||||
babel-jest: 26.5.2
|
||||
jest: 26.5.3
|
||||
jest-diff: 26.5.2
|
||||
rimraf: 3.0.2
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@lowdefy/nunjucks@1.0.0, @lowdefy/nunjucks@workspace:packages/nunjucks":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@lowdefy/nunjucks@workspace:packages/nunjucks"
|
||||
|
Loading…
x
Reference in New Issue
Block a user