@nstudio/schematics
Version:
Cross-platform (xplat) tools for Nx workspaces.
78 lines • 3.17 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const schematics_1 = require("@angular-devkit/schematics");
const utils_1 = require("../utils");
let name;
function default_1(options) {
if (!options.name) {
name = "fullstack";
console.warn(`Using 'fullstack' since no mode was specified. Currently supported: fullstack,${utils_1.supportedPlatforms}. Example: ng g mode nativescript`);
}
else {
name = options.name;
}
return schematics_1.chain([
// init xplat settings
utils_1.prerun(),
// update tsconfig based on mode
(tree) => updateExcludes(name)(tree),
// update IDE settings
(tree) => {
const appsDir = tree.getDir("apps");
const appFolders = appsDir.subdirs;
const allApps = [];
for (const dir of appFolders) {
allApps.push(`**${appsDir.path}/${dir}`);
}
// project handling
let focusOnApps = [];
if (name !== "fullstack" && options.projects) {
focusOnApps = options.projects.split(",");
for (let i = 0; i < focusOnApps.length; i++) {
const projectName = focusOnApps[i];
const nameParts = projectName.split("-");
let containsPlatform = false;
for (const n of nameParts) {
if (utils_1.supportedPlatforms.includes(n)) {
containsPlatform = true;
}
}
if (!containsPlatform) {
// allows for shorthand project/app names omitting platform
// just add platform to the name
const appName = utils_1.getGroupByName() ? `${nameParts.join("-")}-${name}` : `${name}-${nameParts.join("-")}`;
focusOnApps[i] = `**/apps/${appName}`;
}
}
}
// targets and mode should be the same
return utils_1.updateIDESettings(tree, name, name, allApps, focusOnApps);
}
]);
}
exports.default = default_1;
function updateExcludes(devMode) {
return (tree) => {
return utils_1.updateTsConfig(tree, (tsConfig) => {
if (tsConfig) {
if (!tsConfig.exclude) {
tsConfig.exclude = [];
}
const tnsRefs = "references.d.ts";
if (devMode === "nativescript" || devMode === "fullstack") {
const index = tsConfig.exclude.findIndex(entry => entry === tnsRefs);
if (index > -1) {
tsConfig.exclude.splice(index, 1);
}
}
else {
// when not doing {N} development, alleviate pressue on TS resolution
if (!tsConfig.exclude.includes(tnsRefs)) {
tsConfig.exclude.push("references.d.ts");
}
}
}
});
};
}
//# sourceMappingURL=index.js.map