@storm-software/build-tools
Version:
A comprehensive set of tools for building and managing projects within a Storm workspace. Includes builders such as rollup, rolldown, tsup, and unbuild, along with various utilities.
81 lines (70 loc) • 2.55 kB
JavaScript
;Object.defineProperty(exports, "__esModule", {value: true});
var _chunkBPRPYAQSjs = require('./chunk-BPRPYAQS.js');
var _chunkI2YBUOU3js = require('./chunk-I2YBUOU3.js');
var _chunk6BOTIXBIjs = require('./chunk-6BOTIXBI.js');
// src/utilities/get-entry-points.ts
var _glob = require('glob');
var getEntryPoints = async (config, projectRoot, sourceRoot, entry, emitOnAll = false) => {
const workspaceRoot = config.workspaceRoot || _chunkBPRPYAQSjs.findWorkspaceRoot.call(void 0, );
const entryPoints = [];
if (entry) {
if (typeof entry === "string") {
entryPoints.push(entry);
} else if (Array.isArray(entry)) {
entryPoints.push(...entry);
} else {
entryPoints.push(...Object.values(entry));
}
}
if (emitOnAll) {
entryPoints.push(
_chunkI2YBUOU3js.joinPaths.call(void 0, workspaceRoot, sourceRoot || projectRoot, "**/*.{ts,tsx}")
);
}
const results = await Promise.all(
entryPoints.map(async (entryPoint) => {
const paths = [];
if (entryPoint.includes("*")) {
const files = await _glob.glob.call(void 0, entryPoint, {
withFileTypes: true,
ignore: ["**/node_modules/**"]
});
paths.push(
...files.reduce((ret, filePath) => {
const result = _chunkI2YBUOU3js.correctPaths.call(void 0,
_chunkI2YBUOU3js.joinPaths.call(void 0, filePath.path, filePath.name).replaceAll(_chunkI2YBUOU3js.correctPaths.call(void 0, workspaceRoot), "").replaceAll(_chunkI2YBUOU3js.correctPaths.call(void 0, projectRoot), "")
);
if (result) {
_chunk6BOTIXBIjs.writeDebug.call(void 0,
`Trying to add entry point ${result} at "${_chunkI2YBUOU3js.joinPaths.call(void 0,
filePath.path,
filePath.name
)}"`,
config
);
if (!paths.includes(result)) {
paths.push(result);
}
}
return ret;
}, [])
);
} else {
_chunk6BOTIXBIjs.writeDebug.call(void 0, `Trying to add entry point ${entryPoint}"`, config);
if (!paths.includes(entryPoint)) {
paths.push(entryPoint);
}
}
return paths;
})
);
return results.filter(Boolean).reduce((ret, result) => {
result.forEach((res) => {
if (res && !ret.includes(res)) {
ret.push(res);
}
});
return ret;
}, []);
};
exports.getEntryPoints = getEntryPoints;