@doku-dev/doku-fragment
Version:
A new Angular UI library that moving away from Bootstrap and built from scratch.
45 lines • 2.29 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const schematics_1 = require("@angular-devkit/schematics");
const tasks_1 = require("@angular-devkit/schematics/tasks");
const utility_1 = require("@schematics/angular/utility");
const messages = require("../messages");
const util_1 = require("../util");
const VERSIONS = {
FLOATING_UI: '^1.4.0',
};
function ngAdd(options) {
return (tree, context) => __awaiter(this, void 0, void 0, function* () {
if (!tree.exists('package.json')) {
throw new schematics_1.SchematicsException(messages.noPackageJson());
}
const workspace = yield (0, utility_1.readWorkspace)(tree);
// Check that specified project name exists
// Example command: `ng add @doku-dev/doku-fragment --project projectName`
if (options.project) {
const project = workspace.projects.get(options.project);
if (!project) {
throw new schematics_1.SchematicsException(messages.noProject(options.project));
}
}
if (!options.project && workspace.projects.size > 1) {
throw new schematics_1.SchematicsException(messages.noSelectedProject());
}
// Add peer dependencies to package.json
(0, util_1.addPackageToPackageJson)(tree, '@floating-ui/dom', VERSIONS.FLOATING_UI);
context.addTask(new tasks_1.RunSchematicTask('ng-add-setup-project', options), [
context.addTask(new tasks_1.NodePackageInstallTask()),
]);
});
}
exports.default = ngAdd;
//# sourceMappingURL=index.js.map