@beemo/config-constants
Advanced tools
Comparing version 1.1.0 to 2.0.0
@@ -5,8 +5,9 @@ export declare const ROOT: string; | ||
export declare const CASE_SENSITIVE = false; | ||
export declare const ECMA_VERSION = 2020; | ||
export declare const ECMA_VERSION = 2022; | ||
export declare const IGNORE_LIST: string[]; | ||
export declare const ALL_FILES_GLOB = "**/{src,tests,__tests__}/**/*.{ts,tsx}"; | ||
export declare const SOURCE_FILES_GLOB = "**/src/**/*.{ts,tsx}"; | ||
export declare const TEST_FILES_GLOB = "**/{tests,__tests__}/**/*.test.{ts,tsx}"; | ||
export declare const TEST_UTILS_GLOB = "**/{tests,__tests__}/**/*.{ts,tsx}"; | ||
export declare const TS_EXT_PATTERN = "{ts,tsx,cts,mts}"; | ||
export declare const ALL_FILES_GLOB: string; | ||
export declare const SOURCE_FILES_GLOB: string; | ||
export declare const TEST_FILES_GLOB: string; | ||
export declare const TEST_UTILS_GLOB: string; | ||
export declare const TESTS_LIST: string[]; | ||
@@ -13,0 +14,0 @@ export declare const NON_TS_REGEX = "\\.{css,sass,scss,less,gif,png,jpg,jpeg,svg,gql,graphql,yml,yaml}$"; |
@@ -7,44 +7,18 @@ 'use strict'; | ||
const path = require('path'); | ||
const constants = require('./constants2.js'); | ||
const _interopDefault = e => e && e.__esModule ? e : { | ||
default: e | ||
}; | ||
const path__default = /*#__PURE__*/_interopDefault(path); | ||
const ROOT = process.env.BEEMO_ROOT || process.cwd(); | ||
const PACKAGE_JSON_PATH = path__default.default.join(ROOT, 'package.json'); | ||
const TSCONFIG_JSON_PATH = path__default.default.join(ROOT, 'tsconfig.json'); // Support consistent sorting across the board | ||
// Its off since simple-import-sort doesnt support it! | ||
const CASE_SENSITIVE = false; // Latest ECMA version and syntax to support | ||
const ECMA_VERSION = 2020; // Files and folders to always ignore | ||
const IGNORE_LIST = ['node_modules/', 'build/', 'cjs/', 'coverage/', 'dist/', 'dts/', 'esm/', 'lib/', 'mjs/', 'umd/']; // Globs for finding source files, test files, and test utility files | ||
const ALL_FILES_GLOB = '**/{src,tests,__tests__}/**/*.{ts,tsx}'; | ||
const SOURCE_FILES_GLOB = '**/src/**/*.{ts,tsx}'; | ||
const TEST_FILES_GLOB = '**/{tests,__tests__}/**/*.test.{ts,tsx}'; | ||
const TEST_UTILS_GLOB = '**/{tests,__tests__}/**/*.{ts,tsx}'; // List of globs to find all test related files | ||
const TESTS_LIST = [TEST_FILES_GLOB, TEST_UTILS_GLOB, 'test.{ts,tsx}']; // Pattern of non-JS/TS file extensions | ||
const NON_TS_REGEX = '\\.{css,sass,scss,less,gif,png,jpg,jpeg,svg,gql,graphql,yml,yaml}$'; // Pattern to find all custom TypeScript paths | ||
const TS_PATH_PREFIX_REGEX = '^:[a-z]'; | ||
exports.ALL_FILES_GLOB = ALL_FILES_GLOB; | ||
exports.CASE_SENSITIVE = CASE_SENSITIVE; | ||
exports.ECMA_VERSION = ECMA_VERSION; | ||
exports.IGNORE_LIST = IGNORE_LIST; | ||
exports.NON_TS_REGEX = NON_TS_REGEX; | ||
exports.PACKAGE_JSON_PATH = PACKAGE_JSON_PATH; | ||
exports.ROOT = ROOT; | ||
exports.SOURCE_FILES_GLOB = SOURCE_FILES_GLOB; | ||
exports.TESTS_LIST = TESTS_LIST; | ||
exports.TEST_FILES_GLOB = TEST_FILES_GLOB; | ||
exports.TEST_UTILS_GLOB = TEST_UTILS_GLOB; | ||
exports.TSCONFIG_JSON_PATH = TSCONFIG_JSON_PATH; | ||
exports.TS_PATH_PREFIX_REGEX = TS_PATH_PREFIX_REGEX; | ||
exports.ALL_FILES_GLOB = constants.ALL_FILES_GLOB; | ||
exports.CASE_SENSITIVE = constants.CASE_SENSITIVE; | ||
exports.ECMA_VERSION = constants.ECMA_VERSION; | ||
exports.IGNORE_LIST = constants.IGNORE_LIST; | ||
exports.NON_TS_REGEX = constants.NON_TS_REGEX; | ||
exports.PACKAGE_JSON_PATH = constants.PACKAGE_JSON_PATH; | ||
exports.ROOT = constants.ROOT; | ||
exports.SOURCE_FILES_GLOB = constants.SOURCE_FILES_GLOB; | ||
exports.TESTS_LIST = constants.TESTS_LIST; | ||
exports.TEST_FILES_GLOB = constants.TEST_FILES_GLOB; | ||
exports.TEST_UTILS_GLOB = constants.TEST_UTILS_GLOB; | ||
exports.TSCONFIG_JSON_PATH = constants.TSCONFIG_JSON_PATH; | ||
exports.TS_EXT_PATTERN = constants.TS_EXT_PATTERN; | ||
exports.TS_PATH_PREFIX_REGEX = constants.TS_PATH_PREFIX_REGEX; | ||
//# sourceMappingURL=constants.js.map |
@@ -7,108 +7,10 @@ 'use strict'; | ||
const fs = require('fs'); | ||
const helpers = require('./helpers2.js'); | ||
const constants = require('./constants.js'); | ||
const _interopDefault = e => e && e.__esModule ? e : { | ||
default: e | ||
}; | ||
const fs__default = /*#__PURE__*/_interopDefault(fs); | ||
function parseJSON(filePath) { | ||
const content = fs__default.default.readFileSync(filePath, 'utf8').split('\n') // Remove comments from JSON files | ||
.filter(line => !/^\s*(#|\/)/.test(line)).join('\n'); | ||
return JSON.parse(content); | ||
} // PACKAGE.JSON | ||
let packageJson; | ||
function getRootPackageJSON() { | ||
if (packageJson === undefined) { | ||
packageJson = parseJSON(constants.PACKAGE_JSON_PATH); | ||
} | ||
return packageJson; | ||
} // NODE.JS | ||
let nodeVersion; | ||
function getTargetNodeRuntime() { | ||
if (nodeVersion !== undefined) { | ||
return nodeVersion; | ||
} | ||
try { | ||
var _pkg$engines; | ||
const pkg = getRootPackageJSON(); | ||
const version = (_pkg$engines = pkg.engines) === null || _pkg$engines === void 0 ? void 0 : _pkg$engines.node; | ||
if (version) { | ||
nodeVersion = Number.parseFloat(version.replace(/[^\d.]+/g, '')); | ||
} | ||
} catch { | ||
nodeVersion = 0; | ||
} | ||
return nodeVersion; | ||
} // PACKAGES | ||
const versionCache = {}; | ||
function getPackageVersion(pkgName) { | ||
if (versionCache[pkgName] !== undefined) { | ||
return versionCache[pkgName]; | ||
} | ||
try { | ||
const pkg = parseJSON(require.resolve(`${pkgName}/package.json`)); | ||
versionCache[pkgName] = Number.parseFloat(pkg.version); | ||
return versionCache[pkgName]; | ||
} catch { | ||
versionCache[pkgName] = 0; | ||
} | ||
try { | ||
var _ref, _pkg$dependencies$pkg, _pkg$dependencies, _pkg$devDependencies, _pkg$peerDependencies; | ||
const pkg = getRootPackageJSON(); | ||
const version = (_ref = (_pkg$dependencies$pkg = (_pkg$dependencies = pkg.dependencies) === null || _pkg$dependencies === void 0 ? void 0 : _pkg$dependencies[pkgName]) !== null && _pkg$dependencies$pkg !== void 0 ? _pkg$dependencies$pkg : (_pkg$devDependencies = pkg.devDependencies) === null || _pkg$devDependencies === void 0 ? void 0 : _pkg$devDependencies[pkgName]) !== null && _ref !== void 0 ? _ref : (_pkg$peerDependencies = pkg.peerDependencies) === null || _pkg$peerDependencies === void 0 ? void 0 : _pkg$peerDependencies[pkgName]; | ||
if (version) { | ||
versionCache[pkgName] = Number.parseFloat(version.replace(/[^\d.]+/g, '')); | ||
return versionCache[pkgName]; | ||
} | ||
} catch { | ||
versionCache[pkgName] = 0; | ||
} | ||
return versionCache[pkgName]; | ||
} // TSCONFIG.JSON | ||
let tsconfigJson; | ||
function getRootTSConfig() { | ||
if (tsconfigJson === undefined) { | ||
tsconfigJson = parseJSON(constants.TSCONFIG_JSON_PATH); | ||
} | ||
return tsconfigJson; | ||
} // TYPESCRIPT | ||
function getRootProjectReferences() { | ||
return getRootTSConfig().references; | ||
} | ||
exports.getPackageVersion = getPackageVersion; | ||
exports.getRootPackageJSON = getRootPackageJSON; | ||
exports.getRootProjectReferences = getRootProjectReferences; | ||
exports.getRootTSConfig = getRootTSConfig; | ||
exports.getTargetNodeRuntime = getTargetNodeRuntime; | ||
exports.parseJSON = parseJSON; | ||
exports.getPackageVersion = helpers.getPackageVersion; | ||
exports.getRootPackageJSON = helpers.getRootPackageJSON; | ||
exports.getRootProjectReferences = helpers.getRootProjectReferences; | ||
exports.getRootTSConfig = helpers.getRootTSConfig; | ||
exports.getTargetNodeRuntime = helpers.getTargetNodeRuntime; | ||
exports.parseJSON = helpers.parseJSON; | ||
//# sourceMappingURL=helpers.js.map |
@@ -7,6 +7,8 @@ 'use strict'; | ||
const constants = require('./constants.js'); | ||
require('./index2.js'); | ||
const helpers = require('./helpers.js'); | ||
const constants = require('./constants2.js'); | ||
const helpers = require('./helpers2.js'); | ||
exports.ALL_FILES_GLOB = constants.ALL_FILES_GLOB; | ||
@@ -24,2 +26,3 @@ exports.CASE_SENSITIVE = constants.CASE_SENSITIVE; | ||
exports.TSCONFIG_JSON_PATH = constants.TSCONFIG_JSON_PATH; | ||
exports.TS_EXT_PATTERN = constants.TS_EXT_PATTERN; | ||
exports.TS_PATH_PREFIX_REGEX = constants.TS_PATH_PREFIX_REGEX; | ||
@@ -26,0 +29,0 @@ exports.getPackageVersion = helpers.getPackageVersion; |
{ | ||
"name": "@beemo/config-constants", | ||
"version": "1.1.0", | ||
"version": "2.0.0", | ||
"release": "1624590167003", | ||
@@ -28,4 +28,4 @@ "description": "Reusable constants for Beemo configurations.", | ||
"engines": { | ||
"node": ">=12.17.0", | ||
"npm": ">=6.13.0" | ||
"node": ">=14.15.0", | ||
"npm": ">=6.14.0" | ||
}, | ||
@@ -40,3 +40,3 @@ "funding": { | ||
}, | ||
"gitHead": "615ebc898bd0312f4b6f82ddbb9e874a07b884d0" | ||
"gitHead": "ee97e740c3829fac112151ce2f28da5a5e0e26c8" | ||
} |
@@ -13,3 +13,3 @@ import path from 'path'; | ||
// Latest ECMA version and syntax to support | ||
export const ECMA_VERSION = 2020; | ||
export const ECMA_VERSION = 2022; | ||
@@ -31,9 +31,10 @@ // Files and folders to always ignore | ||
// Globs for finding source files, test files, and test utility files | ||
export const ALL_FILES_GLOB = '**/{src,tests,__tests__}/**/*.{ts,tsx}'; | ||
export const SOURCE_FILES_GLOB = '**/src/**/*.{ts,tsx}'; | ||
export const TEST_FILES_GLOB = '**/{tests,__tests__}/**/*.test.{ts,tsx}'; | ||
export const TEST_UTILS_GLOB = '**/{tests,__tests__}/**/*.{ts,tsx}'; | ||
export const TS_EXT_PATTERN = '{ts,tsx,cts,mts}'; | ||
export const ALL_FILES_GLOB = `**/{src,tests,__tests__}/**/*.${TS_EXT_PATTERN}`; | ||
export const SOURCE_FILES_GLOB = `**/src/**/*.${TS_EXT_PATTERN}`; | ||
export const TEST_FILES_GLOB = `**/{tests,__tests__}/**/*.test.${TS_EXT_PATTERN}`; | ||
export const TEST_UTILS_GLOB = `**/{tests,__tests__}/**/*.${TS_EXT_PATTERN}`; | ||
// List of globs to find all test related files | ||
export const TESTS_LIST = [TEST_FILES_GLOB, TEST_UTILS_GLOB, 'test.{ts,tsx}']; | ||
export const TESTS_LIST = [TEST_FILES_GLOB, TEST_UTILS_GLOB, `test.${TS_EXT_PATTERN}`]; | ||
@@ -40,0 +41,0 @@ // Pattern of non-JS/TS file extensions |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21090
21
367