Merge branch 'release/15.0'
This commit is contained in:
25
src/Umbraco.Web.UI.Client/devops/build/global-types.js
Normal file
25
src/Umbraco.Web.UI.Client/devops/build/global-types.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import { createImportMap } from '../importmap/index.js';
|
||||
import { writeFileWithDir } from '../utils/index.js';
|
||||
|
||||
const tsPath = './dist-cms/packages/extension-types/index.d.ts';
|
||||
|
||||
const importmap = createImportMap({
|
||||
rootDir: './src',
|
||||
replaceModuleExtensions: true,
|
||||
});
|
||||
|
||||
const paths = Object.keys(importmap.imports);
|
||||
|
||||
const content = `
|
||||
${paths.map((path) => `import '${path}';`).join('\n')}
|
||||
`;
|
||||
|
||||
writeFileWithDir(tsPath, content, (err) => {
|
||||
if (err) {
|
||||
// eslint-disable-next-line no-undef
|
||||
console.log(err);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-undef
|
||||
console.log(`global-types file generated`);
|
||||
});
|
||||
@@ -8,14 +8,14 @@ export const createImportMap = (args) => {
|
||||
// Iterate over the exports in package.json
|
||||
for (const [key, value] of Object.entries(packageJsonExports || {})) {
|
||||
// remove leading ./
|
||||
if (value) {
|
||||
if (value && value.endsWith('.js')) {
|
||||
const moduleName = key.replace(/^\.\//, '');
|
||||
|
||||
// replace ./dist-cms with src and remove /index.js
|
||||
let modulePath = value;
|
||||
if (typeof args.rootDir !== 'undefined') modulePath = modulePath.replace(/^\.\/dist-cms/, args.rootDir);
|
||||
if (args.replaceModuleExtensions) modulePath = modulePath.replace('.js', '.ts');
|
||||
console.log('replacing', value, 'with', modulePath)
|
||||
console.log('replacing', value, 'with', modulePath);
|
||||
const importAlias = `${packageJsonName}/${moduleName}`;
|
||||
|
||||
imports[importAlias] = modulePath;
|
||||
|
||||
13
src/Umbraco.Web.UI.Client/devops/utils/index.js
Normal file
13
src/Umbraco.Web.UI.Client/devops/utils/index.js
Normal file
@@ -0,0 +1,13 @@
|
||||
import { writeFile, mkdir } from 'fs';
|
||||
import * as pathModule from 'path';
|
||||
|
||||
const path = pathModule.default;
|
||||
const getDirName = path.dirname;
|
||||
|
||||
export const writeFileWithDir = (path, contents, cb) => {
|
||||
mkdir(getDirName(path), { recursive: true }, function (err) {
|
||||
if (err) return cb(err);
|
||||
|
||||
writeFile(path, contents, cb);
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user