1 | 'use strict';
|
2 |
|
3 | const NpmAdapter = require('../dependency-manager-adapters/npm');
|
4 | const PnpmAdapter = require('../dependency-manager-adapters/pnpm');
|
5 | const WorkspaceAdapter = require('../dependency-manager-adapters/workspace');
|
6 |
|
7 | module.exports = {
|
8 | generateFromConfig(config, root) {
|
9 | let hasNpm = false;
|
10 | let hasBower = false;
|
11 | let adapters = [];
|
12 | if (!config || !config.scenarios) {
|
13 | return [];
|
14 | }
|
15 |
|
16 | config.scenarios.forEach((scenario) => {
|
17 | if (scenario.npm) {
|
18 | hasNpm = true;
|
19 | }
|
20 | if (scenario.bower || scenario.dependencies || scenario.devDependencies) {
|
21 | hasBower = true;
|
22 | }
|
23 | });
|
24 |
|
25 | if (hasBower) {
|
26 | throw new Error('[ember-try] bower configuration is no longer supported');
|
27 | }
|
28 |
|
29 | if (config.useWorkspaces) {
|
30 | adapters.push(
|
31 | new WorkspaceAdapter({
|
32 | cwd: root,
|
33 | managerOptions: config.npmOptions,
|
34 | useYarnCommand: config.useYarn,
|
35 | buildManagerOptions: config.buildManagerOptions,
|
36 | })
|
37 | );
|
38 | } else if (config.usePnpm) {
|
39 | adapters.push(
|
40 | new PnpmAdapter({
|
41 | cwd: root,
|
42 | managerOptions: config.npmOptions,
|
43 | buildManagerOptions: config.buildManagerOptions,
|
44 | })
|
45 | );
|
46 | } else if (hasNpm) {
|
47 | adapters.push(
|
48 | new NpmAdapter({
|
49 | cwd: root,
|
50 | managerOptions: config.npmOptions,
|
51 | useYarnCommand: config.useYarn,
|
52 | buildManagerOptions: config.buildManagerOptions,
|
53 | })
|
54 | );
|
55 | }
|
56 |
|
57 | return adapters;
|
58 | },
|
59 | };
|