ngx-deploy-npm
Version:
Publish your libraries to NPM with just one command
37 lines • 1.78 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = update;
const tslib_1 = require("tslib");
const devkit_1 = require("@nx/devkit");
const targetNeedsMigration = (target) => {
var _a;
return target.executor === 'ngx-deploy-npm:deploy' &&
((_a = target.options) === null || _a === void 0 ? void 0 : _a.distFolderPath) === undefined;
};
function update(host) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const projectToMigrate = Array.from((0, devkit_1.getProjects)(host))
// remove projects that doesn't have the our executor or already have the option distFolderPath
.filter(([, project]) => {
var _a;
const projectTargets = Object.values((_a = project.targets) !== null && _a !== void 0 ? _a : {});
return projectTargets.some(targetNeedsMigration);
});
projectToMigrate.forEach(([projectKey, project]) => {
var _a;
if (project.name === undefined) {
devkit_1.logger.warn(`Project ${projectKey} doesn't have a name\nIt was skipped, you will need to create the option distFolderPath manually`);
return;
}
// Create the distFolderPath option
Object.values((_a = project.targets) !== null && _a !== void 0 ? _a : {})
.filter(targetNeedsMigration)
.forEach(deployTarget => {
deployTarget.options.distFolderPath = `dist/${project.root}`;
});
(0, devkit_1.updateProjectConfiguration)(host, project.name, project);
});
yield (0, devkit_1.formatFiles)(host);
});
}
//# sourceMappingURL=write-dist-folder-path-on-deploy-target-options.js.map