ui5-tooling-transpile
Advanced tools
Comparing version 3.0.5 to 3.1.0
@@ -6,2 +6,13 @@ # Change Log | ||
# [3.1.0](https://github.com/ui5-community/ui5-ecosystem-showcase/compare/ui5-tooling-transpile@3.0.5...ui5-tooling-transpile@3.1.0) (2023-08-25) | ||
### Features | ||
* **ui5-tooling-transpile:** integrate ts-interface-generator ([#787](https://github.com/ui5-community/ui5-ecosystem-showcase/issues/787)) ([7dfa15d](https://github.com/ui5-community/ui5-ecosystem-showcase/commit/7dfa15dfe34aac201a9ff5c501b61716460f05c5)) | ||
## [3.0.5](https://github.com/ui5-community/ui5-ecosystem-showcase/compare/ui5-tooling-transpile@3.0.4...ui5-tooling-transpile@3.0.5) (2023-08-25) | ||
@@ -8,0 +19,0 @@ |
/* eslint-disable jsdoc/check-param-names */ | ||
const path = require("path"); | ||
const parseurl = require("parseurl"); | ||
@@ -20,3 +21,3 @@ | ||
* @param {string} [parameters.options.configuration] Custom server middleware configuration if given in ui5.yaml | ||
* @returns {function} Middleware function to use | ||
* @returns {Function} Middleware function to use | ||
*/ | ||
@@ -30,3 +31,4 @@ module.exports = async function ({ log, resources, options, middlewareUtil }) { | ||
transformAsync, | ||
shouldHandlePath | ||
shouldHandlePath, | ||
resolveNodeModule | ||
} = require("./util")(log); | ||
@@ -91,2 +93,28 @@ | ||
// if the TypeScript interfaces should be created, launch the ts-interface-generator in watch mode | ||
if (config.generateTsInterfaces) { | ||
const generateTSInterfacesAPI = resolveNodeModule( | ||
"@ui5/ts-interface-generator/dist/generateTSInterfacesAPI", | ||
cwd | ||
); | ||
if (generateTSInterfacesAPI) { | ||
const { main } = require(generateTSInterfacesAPI); | ||
try { | ||
config.debug && log.info(`Starting "@ui5/ts-interface-generator" in watch mode...`); | ||
main({ | ||
watch: true, | ||
logLevel: config.debug ? log.constructor.getLevel() : "error", | ||
config: path.join(cwd, "tsconfig.json") | ||
}); | ||
} catch (e) { | ||
log.error(e); | ||
} | ||
} else { | ||
config.debug && | ||
log.warn( | ||
`Missing dependency "@ui5/ts-interface-generator"! TypeScript interfaces will not be generated until dependency has been added...` | ||
); | ||
} | ||
} | ||
return async (req, res, next) => { | ||
@@ -93,0 +121,0 @@ const pathname = parseurl(req)?.pathname; |
@@ -293,3 +293,3 @@ /* eslint-disable jsdoc/check-param-names */ | ||
if (fs.existsSync(pckgJsonFile)) { | ||
const pckgJson = require(pckgJsonFile); | ||
const pckgJson = JSON.parse(fs.readFileSync(pckgJsonFile, { encoding: "utf8" })); | ||
if (!pckgJson.types) { | ||
@@ -296,0 +296,0 @@ log.warn( |
@@ -201,4 +201,4 @@ const os = require("os"); | ||
// read package.json and tsconfig.json to determine whether to transpile dependencies or not | ||
if (isTypeScriptProject && !config.transpileDependencies) { | ||
// read tsconfig.json to determine whether to transpile dependencies or not | ||
if (isTypeScriptProject && !config.transpileDependencies && fs.existsSync(tscJsonPath)) { | ||
const tscJson = JSONC.parse(fs.readFileSync(tscJsonPath, { encoding: "utf8" })); | ||
@@ -225,2 +225,17 @@ const tsDeps = tscJson?.compilerOptions?.types?.filter((typePkgName) => { | ||
// load the pkgJson to determine the existence of the @ui5/ts-interface-generator | ||
// to automatically set the config option generateTsInterfaces (if this is a ts project) | ||
let generateTsInterfaces = config.generateTsInterfaces; | ||
const pkgJsonPath = path.join(cwd, "package.json"); | ||
if (transformTypeScript && generateTsInterfaces === undefined && fs.existsSync(pkgJsonPath)) { | ||
const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, { encoding: "utf8" })); | ||
const deps = [ | ||
...Object.keys(pkgJson?.dependencies || {}), | ||
...Object.keys(pkgJson?.devDependencies || {}) | ||
]; | ||
if (deps.indexOf("@ui5/ts-interface-generator") !== -1) { | ||
generateTsInterfaces = true; | ||
} | ||
} | ||
// derive the includes/excludes from the configuration | ||
@@ -249,2 +264,3 @@ const includes = config.includes || config.includePatterns || []; | ||
omitTSFromBuildResult: config.omitTSFromBuildResult, | ||
generateTsInterfaces, | ||
generateDts: config.generateDts, | ||
@@ -454,3 +470,3 @@ transpileDependencies: config.transpileDependencies, | ||
* @param {Array<string>} includes include paths | ||
* @returns true, if the path should be handled | ||
* @returns {boolean} true, if the path should be handled | ||
*/ | ||
@@ -457,0 +473,0 @@ shouldHandlePath: function shouldHandlePath(pathname, excludes = [], includes = []) { |
{ | ||
"name": "ui5-tooling-transpile", | ||
"version": "3.0.5", | ||
"version": "3.1.0", | ||
"description": "UI5 tooling extensions to transpile code", | ||
@@ -26,2 +26,10 @@ "author": "Jorge Martins, Peter Muessig", | ||
}, | ||
"peerDependencies": { | ||
"@ui5/ts-interface-generator": ">=0.8.0" | ||
}, | ||
"peerDependenciesMeta": { | ||
"@ui5/ts-interface-generator": { | ||
"optional": true | ||
} | ||
}, | ||
"scripts": { | ||
@@ -39,3 +47,3 @@ "lint": "eslint lib", | ||
}, | ||
"gitHead": "4a6a4401cc13120cb5f91bba8c116dce78c3812b" | ||
"gitHead": "9127d611a58bd7677bff96480f652f4eeea53172" | ||
} |
@@ -44,2 +44,5 @@ # UI5 Tooling Extension for Transpiling JS/TS | ||
- generateTsInterfaces: `boolean|undefined` (*experimental feature*) | ||
option requires a dependency to the `@ui5/ts-interface-generator` when either the value of the option is `true` or `undefined` and the project is a TypeScript-based project or the `transformTypeScript` option is set to `true` - can be forced to be inactive by setting the option to `false` (only relevant for the middleware) | ||
- generateDts: `boolean` | ||
@@ -46,0 +49,0 @@ if enabled, the tooling extension will generate type definitions (`.d.ts`) files; by default for projects of type `library` this option is considered as `true` and for other projects such as `application` this option is considered as `false` by default (is only relevant in case of transformTypeScript is `true`) |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
88880
947
178
10