ember-try 3.0.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.release-plan.json +26 -0
- package/CHANGELOG.md +87 -0
- package/README.md +25 -24
- package/lib/commands/config.js +4 -2
- package/lib/commands/reset.js +3 -3
- package/lib/commands/try-each.js +3 -3
- package/lib/commands/try-ember.js +3 -3
- package/lib/commands/try-one.js +6 -7
- package/lib/dependency-manager-adapters/base.js +175 -0
- package/lib/dependency-manager-adapters/npm.js +9 -293
- package/lib/dependency-manager-adapters/pnpm.js +114 -134
- package/lib/dependency-manager-adapters/workspace.js +23 -28
- package/lib/dependency-manager-adapters/yarn.js +11 -0
- package/lib/tasks/reset.js +13 -8
- package/lib/tasks/try-each.js +37 -31
- package/lib/utils/backup.js +95 -0
- package/lib/utils/config.js +40 -18
- package/lib/utils/console.js +51 -0
- package/lib/utils/dependency-manager-adapter-factory.js +18 -18
- package/lib/utils/package-managers.js +9 -0
- package/lib/utils/result-summary.js +27 -23
- package/lib/utils/run.js +22 -2
- package/lib/utils/scenario-manager.js +11 -10
- package/package.json +36 -48
- package/lib/utils/find-by-name.js +0 -10
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const CoreObject = require('core-object');
|
|
4
3
|
const fs = require('fs-extra');
|
|
5
4
|
const path = require('path');
|
|
6
5
|
const debug = require('debug')('ember-try:dependency-manager-adapter:workspaces');
|
|
7
6
|
const walkSync = require('walk-sync');
|
|
7
|
+
const { PACKAGE_JSON } = require('../utils/package-managers');
|
|
8
|
+
const YarnAdapter = require('./yarn');
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
module.exports = class {
|
|
11
|
+
constructor(options) {
|
|
12
|
+
this.buildManagerOptions = options.buildManagerOptions;
|
|
13
|
+
this.cwd = options.cwd;
|
|
14
|
+
this.managerOptions = options.managerOptions;
|
|
15
|
+
this.run = options.run || require('../utils/run');
|
|
10
16
|
|
|
11
|
-
|
|
12
|
-
init() {
|
|
13
|
-
this._super.apply(this, arguments);
|
|
14
|
-
this.run = this.run || require('../utils/run');
|
|
15
|
-
|
|
16
|
-
if (!this.useYarnCommand) {
|
|
17
|
+
if (options.packageManager !== 'yarn') {
|
|
17
18
|
throw new Error(
|
|
18
|
-
'workspaces are currently only supported by Yarn, you must set `
|
|
19
|
+
'workspaces are currently only supported by Yarn, you must set `packageManager` to `yarn`',
|
|
19
20
|
);
|
|
20
21
|
}
|
|
21
|
-
|
|
22
|
+
|
|
23
|
+
let packageJSON = JSON.parse(fs.readFileSync(PACKAGE_JSON));
|
|
22
24
|
let workspaceGlobs;
|
|
23
25
|
|
|
24
26
|
if (Array.isArray(packageJSON.workspaces)) {
|
|
@@ -31,7 +33,7 @@ module.exports = CoreObject.extend({
|
|
|
31
33
|
|
|
32
34
|
if (!workspaceGlobs || !workspaceGlobs.length) {
|
|
33
35
|
throw new Error(
|
|
34
|
-
'you must define the `workspaces` property in package.json with at least one workspace to use workspaces with ember-try'
|
|
36
|
+
'you must define the `workspaces` property in package.json with at least one workspace to use workspaces with ember-try',
|
|
35
37
|
);
|
|
36
38
|
}
|
|
37
39
|
|
|
@@ -43,25 +45,18 @@ module.exports = CoreObject.extend({
|
|
|
43
45
|
});
|
|
44
46
|
|
|
45
47
|
this._packageAdapters = workspacePaths.map((workspacePath) => {
|
|
46
|
-
return new
|
|
48
|
+
return new YarnAdapter({
|
|
47
49
|
cwd: workspacePath,
|
|
48
50
|
run: this.run,
|
|
49
51
|
managerOptions: this.managerOptions,
|
|
50
|
-
useYarnCommand: true,
|
|
51
52
|
buildManagerOptions: this.buildManagerOptions,
|
|
52
53
|
});
|
|
53
54
|
});
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
packageJSON: 'package.json',
|
|
57
|
-
|
|
58
|
-
setup(options) {
|
|
59
|
-
if (!options) {
|
|
60
|
-
options = {};
|
|
61
|
-
}
|
|
55
|
+
}
|
|
62
56
|
|
|
63
|
-
|
|
64
|
-
|
|
57
|
+
setup() {
|
|
58
|
+
return Promise.all(this._packageAdapters.map((adapter) => adapter.setup()));
|
|
59
|
+
}
|
|
65
60
|
|
|
66
61
|
async changeToDependencySet(depSet) {
|
|
67
62
|
// TODO: What should this do for tables? Nesting? Needs different output
|
|
@@ -83,11 +78,11 @@ module.exports = CoreObject.extend({
|
|
|
83
78
|
debug('Switched to dependencies: \n', currentDeps);
|
|
84
79
|
|
|
85
80
|
return currentDeps;
|
|
86
|
-
}
|
|
81
|
+
}
|
|
87
82
|
|
|
88
83
|
cleanup() {
|
|
89
84
|
return Promise.all(this._packageAdapters.map((adapter) => adapter.cleanup()));
|
|
90
|
-
}
|
|
85
|
+
}
|
|
91
86
|
|
|
92
87
|
_install(depSet) {
|
|
93
88
|
let mgrOptions = this.managerOptions || [];
|
|
@@ -113,9 +108,9 @@ module.exports = CoreObject.extend({
|
|
|
113
108
|
debug('Run yarn install with options %s', mgrOptions);
|
|
114
109
|
|
|
115
110
|
return this.run('yarn', ['install', ...mgrOptions], { cwd: this.cwd });
|
|
116
|
-
}
|
|
111
|
+
}
|
|
117
112
|
|
|
118
113
|
_findCurrentVersionOf(dep) {
|
|
119
114
|
return this._packageAdapters[0]._findCurrentVersionOf(dep);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
115
|
+
}
|
|
116
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { LOCKFILE } = require('../utils/package-managers');
|
|
4
|
+
const { BaseAdapter } = require('./base');
|
|
5
|
+
|
|
6
|
+
module.exports = class YarnAdapter extends BaseAdapter {
|
|
7
|
+
defaultInstallOptions = ['--no-lockfile', '--ignore-engines'];
|
|
8
|
+
lockfile = LOCKFILE.yarn;
|
|
9
|
+
name = 'yarn';
|
|
10
|
+
overridesKey = 'resolutions';
|
|
11
|
+
};
|
package/lib/tasks/reset.js
CHANGED
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const CoreObject = require('core-object');
|
|
4
3
|
const debug = require('debug')('ember-try:commands:reset');
|
|
5
4
|
const ScenarioManager = require('../utils/scenario-manager');
|
|
6
5
|
const DependencyManagerAdapterFactory = require('./../utils/dependency-manager-adapter-factory');
|
|
7
6
|
|
|
8
|
-
module.exports =
|
|
7
|
+
module.exports = class ResetTask {
|
|
8
|
+
constructor(options) {
|
|
9
|
+
this.config = options.config;
|
|
10
|
+
this.cwd = options.cwd;
|
|
11
|
+
}
|
|
12
|
+
|
|
9
13
|
run() {
|
|
10
|
-
let dependencyAdapters =
|
|
11
|
-
this.
|
|
12
|
-
|
|
14
|
+
let dependencyAdapters = DependencyManagerAdapterFactory.generateFromConfig(
|
|
15
|
+
this.config,
|
|
16
|
+
this.cwd,
|
|
17
|
+
);
|
|
13
18
|
debug(
|
|
14
19
|
'DependencyManagerAdapters: %s',
|
|
15
20
|
dependencyAdapters.map((item) => {
|
|
16
21
|
return item.configKey;
|
|
17
|
-
})
|
|
22
|
+
}),
|
|
18
23
|
);
|
|
19
24
|
return new ScenarioManager({ dependencyManagerAdapters: dependencyAdapters }).cleanup();
|
|
20
|
-
}
|
|
21
|
-
}
|
|
25
|
+
}
|
|
26
|
+
};
|
package/lib/tasks/try-each.js
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const CoreObject = require('core-object');
|
|
4
|
-
const chalk = require('chalk');
|
|
5
3
|
const debug = require('debug')('ember-try:task:try-each');
|
|
6
|
-
const
|
|
4
|
+
const { error, info, log } = require('../utils/console');
|
|
5
|
+
const runCommand = require('../utils/run-command');
|
|
6
|
+
|
|
7
|
+
module.exports = class TryEachTask {
|
|
8
|
+
constructor(options) {
|
|
9
|
+
this.commandArgs = options.commandArgs;
|
|
10
|
+
this.commandOptions = options.commandOptions;
|
|
11
|
+
this.config = options.config;
|
|
12
|
+
this.cwd = options.cwd;
|
|
13
|
+
this.dependencyManagerAdapters = options.dependencyManagerAdapters;
|
|
14
|
+
}
|
|
7
15
|
|
|
8
|
-
module.exports = CoreObject.extend({
|
|
9
16
|
async run(scenarios, options) {
|
|
10
17
|
// Required lazily to improve startup speed.
|
|
11
18
|
let ScenarioManager = require('./../utils/scenario-manager');
|
|
@@ -14,22 +21,21 @@ module.exports = CoreObject.extend({
|
|
|
14
21
|
|
|
15
22
|
let dependencyManagerAdapters =
|
|
16
23
|
this.dependencyManagerAdapters ||
|
|
17
|
-
DependencyManagerAdapterFactory.generateFromConfig(this.config, this.
|
|
24
|
+
DependencyManagerAdapterFactory.generateFromConfig(this.config, this.cwd);
|
|
18
25
|
debug(
|
|
19
26
|
'DependencyManagerAdapters: %s',
|
|
20
27
|
dependencyManagerAdapters.map((item) => {
|
|
21
28
|
return item.configKey;
|
|
22
|
-
})
|
|
29
|
+
}),
|
|
23
30
|
);
|
|
24
31
|
this.ScenarioManager = new ScenarioManager({
|
|
25
|
-
ui: this.ui,
|
|
26
32
|
dependencyManagerAdapters,
|
|
27
33
|
});
|
|
28
34
|
|
|
29
35
|
this._canceling = false;
|
|
30
36
|
this._on('SIGINT', () => {
|
|
31
37
|
this._canceling = true;
|
|
32
|
-
|
|
38
|
+
log('\nGracefully shutting down from SIGINT (Ctrl-C)');
|
|
33
39
|
return this.ScenarioManager.cleanup();
|
|
34
40
|
});
|
|
35
41
|
|
|
@@ -49,16 +55,16 @@ module.exports = CoreObject.extend({
|
|
|
49
55
|
|
|
50
56
|
return this._exitAsAppropriate(results);
|
|
51
57
|
} catch (err) {
|
|
52
|
-
|
|
58
|
+
error('Error!');
|
|
53
59
|
|
|
54
60
|
if (err) {
|
|
55
|
-
|
|
56
|
-
|
|
61
|
+
error(err);
|
|
62
|
+
error(err.stack);
|
|
57
63
|
}
|
|
58
64
|
|
|
59
65
|
return 1; // Signifies exit code
|
|
60
66
|
}
|
|
61
|
-
}
|
|
67
|
+
}
|
|
62
68
|
|
|
63
69
|
async _runCommandForThisScenario(scenario) {
|
|
64
70
|
if (this._canceling) {
|
|
@@ -98,18 +104,18 @@ module.exports = CoreObject.extend({
|
|
|
98
104
|
this._writeFooter(`Result: ${result}`);
|
|
99
105
|
|
|
100
106
|
return runResults;
|
|
101
|
-
}
|
|
107
|
+
}
|
|
102
108
|
|
|
103
109
|
_writeHeader(text) {
|
|
104
110
|
let count = 75 - text.length;
|
|
105
111
|
let separator = new Array(count + 1).join('=');
|
|
106
|
-
|
|
107
|
-
}
|
|
112
|
+
info(`\n=== ${text} ${separator}\n`);
|
|
113
|
+
}
|
|
108
114
|
|
|
109
115
|
_writeFooter(text) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
116
|
+
info(`\n${text}`);
|
|
117
|
+
info('---\n');
|
|
118
|
+
}
|
|
113
119
|
|
|
114
120
|
_determineCommandFor(scenario) {
|
|
115
121
|
if (this.commandArgs && this.commandArgs.length) {
|
|
@@ -125,11 +131,11 @@ module.exports = CoreObject.extend({
|
|
|
125
131
|
}
|
|
126
132
|
|
|
127
133
|
return this._defaultCommandArgs();
|
|
128
|
-
}
|
|
134
|
+
}
|
|
129
135
|
|
|
130
136
|
_runCommand(options) {
|
|
131
|
-
return runCommand(this.
|
|
132
|
-
}
|
|
137
|
+
return runCommand(this.cwd, options.commandArgs, options.commandOptions);
|
|
138
|
+
}
|
|
133
139
|
|
|
134
140
|
_commandOptions(env) {
|
|
135
141
|
let options = this.commandOptions || {};
|
|
@@ -137,15 +143,15 @@ module.exports = CoreObject.extend({
|
|
|
137
143
|
options.env = Object.assign({}, process.env, env);
|
|
138
144
|
}
|
|
139
145
|
return options;
|
|
140
|
-
}
|
|
146
|
+
}
|
|
141
147
|
|
|
142
148
|
_defaultCommandArgs() {
|
|
143
149
|
return ['ember', 'test'];
|
|
144
|
-
}
|
|
150
|
+
}
|
|
145
151
|
|
|
146
152
|
_printResults(results) {
|
|
147
|
-
new this.ResultSummary({
|
|
148
|
-
}
|
|
153
|
+
new this.ResultSummary({ results }).print();
|
|
154
|
+
}
|
|
149
155
|
|
|
150
156
|
_exitAsAppropriate(results) {
|
|
151
157
|
let outcomes = results.map((result) => {
|
|
@@ -153,7 +159,7 @@ module.exports = CoreObject.extend({
|
|
|
153
159
|
});
|
|
154
160
|
|
|
155
161
|
return this._exitBasedOnCondition(outcomes.indexOf(false) > -1);
|
|
156
|
-
}
|
|
162
|
+
}
|
|
157
163
|
|
|
158
164
|
async _optionallyCleanup(options) {
|
|
159
165
|
debug('Cleanup');
|
|
@@ -166,20 +172,20 @@ module.exports = CoreObject.extend({
|
|
|
166
172
|
debug('Cleanup ScenarioManager');
|
|
167
173
|
return await this.ScenarioManager.cleanup();
|
|
168
174
|
}
|
|
169
|
-
}
|
|
175
|
+
}
|
|
170
176
|
|
|
171
177
|
_exitBasedOnCondition(condition) {
|
|
172
178
|
let exitCode = condition ? 1 : 0;
|
|
173
179
|
debug('Exit %s', exitCode);
|
|
174
180
|
return exitCode;
|
|
175
|
-
}
|
|
181
|
+
}
|
|
176
182
|
|
|
177
183
|
_exit(code) {
|
|
178
184
|
debug('Exit %s', code);
|
|
179
185
|
process.exit(code);
|
|
180
|
-
}
|
|
186
|
+
}
|
|
181
187
|
|
|
182
188
|
_on(signal, fn) {
|
|
183
189
|
process.on(signal, fn);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
190
|
+
}
|
|
191
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const debug = require('debug')('ember-try:backup');
|
|
4
|
+
const { copy, existsSync } = require('fs-extra');
|
|
5
|
+
const { createHash } = require('node:crypto');
|
|
6
|
+
const { join } = require('node:path');
|
|
7
|
+
const { promisify } = require('node:util');
|
|
8
|
+
const remove = promisify(require('rimraf'));
|
|
9
|
+
const tempDir = require('temp-dir');
|
|
10
|
+
|
|
11
|
+
module.exports = class Backup {
|
|
12
|
+
constructor({ cwd }) {
|
|
13
|
+
this.cwd = cwd;
|
|
14
|
+
this.dir = join(tempDir, 'ember-try', createHash('sha256').update(cwd).digest('hex'));
|
|
15
|
+
|
|
16
|
+
debug(`Created backup directory ${this.dir}`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Adds a file to the backup directory.
|
|
21
|
+
*
|
|
22
|
+
* @param {String} filename Filename relative to the current working directory.
|
|
23
|
+
* @returns {Promise<void>}
|
|
24
|
+
*/
|
|
25
|
+
addFile(filename) {
|
|
26
|
+
let originalFile = join(this.cwd, filename);
|
|
27
|
+
|
|
28
|
+
if (existsSync(originalFile)) {
|
|
29
|
+
debug(`Adding ${originalFile} to backup directory`);
|
|
30
|
+
|
|
31
|
+
return copy(originalFile, this.pathForFile(filename));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return Promise.resolve();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Adds multiple files to the backup directory.
|
|
39
|
+
*
|
|
40
|
+
* @param {Array<String>} filenames Filenames relative to the current working directory.
|
|
41
|
+
* @returns {Promise<void>}
|
|
42
|
+
*/
|
|
43
|
+
addFiles(filenames) {
|
|
44
|
+
return Promise.all(filenames.map((filename) => this.addFile(filename)));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Cleans up the backup directory.
|
|
49
|
+
*
|
|
50
|
+
* @returns {Promise<void>}
|
|
51
|
+
*/
|
|
52
|
+
cleanUp() {
|
|
53
|
+
debug(`Cleaning up backup directory ${this.dir}`);
|
|
54
|
+
|
|
55
|
+
return remove(this.dir);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Returns the absolute path for a file in the backup directory.
|
|
60
|
+
*
|
|
61
|
+
* @param {String} filename Filename relative to the current working directory.
|
|
62
|
+
* @returns {String}
|
|
63
|
+
*/
|
|
64
|
+
pathForFile(filename) {
|
|
65
|
+
return join(this.dir, filename);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Restores a file from the backup directory.
|
|
70
|
+
*
|
|
71
|
+
* @param {String} filename Filename relative to the current working directory.
|
|
72
|
+
* @returns {Promise<void>}
|
|
73
|
+
*/
|
|
74
|
+
restoreFile(filename) {
|
|
75
|
+
let backupFile = this.pathForFile(filename);
|
|
76
|
+
|
|
77
|
+
if (existsSync(backupFile)) {
|
|
78
|
+
debug(`Restoring ${backupFile} from backup directory`);
|
|
79
|
+
|
|
80
|
+
return copy(backupFile, join(this.cwd, filename));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return Promise.resolve();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Restores multiple files from the backup directory.
|
|
88
|
+
*
|
|
89
|
+
* @param {Array<String>} filenames Filenames relative to the current working directory.
|
|
90
|
+
* @returns {Promise<void>}
|
|
91
|
+
*/
|
|
92
|
+
restoreFiles(filenames) {
|
|
93
|
+
return Promise.all(filenames.map((filename) => this.restoreFile(filename)));
|
|
94
|
+
}
|
|
95
|
+
};
|
package/lib/utils/config.js
CHANGED
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const fs = require('fs');
|
|
5
|
-
const
|
|
5
|
+
const { prefix, warn } = require('./console');
|
|
6
6
|
const debug = require('debug')('ember-try:utils:config');
|
|
7
7
|
|
|
8
|
-
function getConfigPath(
|
|
8
|
+
function getConfigPath(cwd) {
|
|
9
|
+
let packageFile = readPackageFile(cwd);
|
|
9
10
|
let possibleConfigPath;
|
|
10
|
-
if (project.pkg && project.pkg['ember-addon'] && project.pkg['ember-addon']['configPath']) {
|
|
11
|
-
let configDir = project.pkg['ember-addon']['configPath'];
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
if (packageFile['ember-addon']?.['configPath']) {
|
|
13
|
+
possibleConfigPath = path.join(packageFile['ember-addon']['configPath'], 'ember-try.js');
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
if (fs.existsSync(possibleConfigPath)) {
|
|
@@ -25,14 +25,14 @@ function getConfigPath(project) {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
async function getBaseConfig(options) {
|
|
28
|
-
let relativeConfigPath = options.configPath || getConfigPath(options.
|
|
29
|
-
let configPath = path.join(options.
|
|
28
|
+
let relativeConfigPath = options.configPath || getConfigPath(options.cwd);
|
|
29
|
+
let configPath = path.join(options.cwd, relativeConfigPath);
|
|
30
30
|
let data;
|
|
31
31
|
|
|
32
32
|
if (fs.existsSync(configPath)) {
|
|
33
33
|
let configData = await require(configPath);
|
|
34
34
|
|
|
35
|
-
data = typeof configData === 'function' ? await configData(
|
|
35
|
+
data = typeof configData === 'function' ? await configData() : configData;
|
|
36
36
|
} else {
|
|
37
37
|
debug('Config file does not exist %s', configPath);
|
|
38
38
|
}
|
|
@@ -42,19 +42,18 @@ async function getBaseConfig(options) {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
let versionCompatibility =
|
|
45
|
-
options.versionCompatibility || versionCompatibilityFromPackageJSON(options.
|
|
45
|
+
options.versionCompatibility || versionCompatibilityFromPackageJSON(options.cwd);
|
|
46
46
|
if (versionCompatibility) {
|
|
47
47
|
// Required lazily to improve startup speed.
|
|
48
48
|
let autoScenarioConfigForEmber = require('ember-try-config');
|
|
49
49
|
|
|
50
50
|
let autoConfig = await autoScenarioConfigForEmber({
|
|
51
51
|
versionCompatibility,
|
|
52
|
-
project: options.project,
|
|
53
52
|
});
|
|
54
53
|
return await mergeAutoConfigAndConfigFileData(autoConfig, data);
|
|
55
54
|
} else {
|
|
56
55
|
throw new Error(
|
|
57
|
-
'No ember-try configuration found. Please see the README for configuration options'
|
|
56
|
+
'No ember-try configuration found. Please see the README for configuration options',
|
|
58
57
|
);
|
|
59
58
|
}
|
|
60
59
|
}
|
|
@@ -62,6 +61,22 @@ async function getBaseConfig(options) {
|
|
|
62
61
|
async function config(options) {
|
|
63
62
|
const configData = await getBaseConfig(options);
|
|
64
63
|
|
|
64
|
+
for (const packageManager of [
|
|
65
|
+
['pnpm', 'usePnpm'],
|
|
66
|
+
['yarn', 'useYarn'],
|
|
67
|
+
]) {
|
|
68
|
+
const [name, oldOption] = packageManager;
|
|
69
|
+
|
|
70
|
+
if (typeof configData[oldOption] === 'boolean') {
|
|
71
|
+
warn(
|
|
72
|
+
`${prefix('ember-try DEPRECATION')} The \`${oldOption}\` config option is deprecated. Please use \`packageManager: '${name}'\` instead.`,
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
delete configData[oldOption];
|
|
76
|
+
configData.packageManager = name;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
65
80
|
return configData;
|
|
66
81
|
}
|
|
67
82
|
|
|
@@ -74,12 +89,12 @@ function mergeAutoConfigAndConfigFileData(autoConfig, configData) {
|
|
|
74
89
|
let conf = Object.assign({}, autoConfig, configData);
|
|
75
90
|
|
|
76
91
|
let overriddenScenarios = autoConfig.scenarios.map((scenario) => {
|
|
77
|
-
let overriddenScenario =
|
|
92
|
+
let overriddenScenario = configData.scenarios.find((s) => s.name === scenario.name);
|
|
78
93
|
return Object.assign({}, scenario, overriddenScenario);
|
|
79
94
|
});
|
|
80
95
|
|
|
81
96
|
let additionalScenarios = configData.scenarios.filter((scenario) => {
|
|
82
|
-
return !
|
|
97
|
+
return !autoConfig.scenarios.find((s) => s.name === scenario.name);
|
|
83
98
|
});
|
|
84
99
|
|
|
85
100
|
conf.scenarios = [...overriddenScenarios, ...additionalScenarios];
|
|
@@ -87,11 +102,18 @@ function mergeAutoConfigAndConfigFileData(autoConfig, configData) {
|
|
|
87
102
|
return conf;
|
|
88
103
|
}
|
|
89
104
|
|
|
90
|
-
function versionCompatibilityFromPackageJSON(
|
|
91
|
-
let
|
|
92
|
-
if (fs.existsSync(packageJSONFile)) {
|
|
93
|
-
let packageJSON = JSON.parse(fs.readFileSync(packageJSONFile));
|
|
105
|
+
function versionCompatibilityFromPackageJSON(cwd) {
|
|
106
|
+
let packageFile = readPackageFile(cwd);
|
|
94
107
|
|
|
95
|
-
|
|
108
|
+
return packageFile['ember-addon']?.versionCompatibility ?? null;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function readPackageFile(cwd) {
|
|
112
|
+
let packageFile = path.join(cwd, 'package.json');
|
|
113
|
+
|
|
114
|
+
if (fs.existsSync(packageFile)) {
|
|
115
|
+
return JSON.parse(fs.readFileSync(packageFile));
|
|
116
|
+
} else {
|
|
117
|
+
return {};
|
|
96
118
|
}
|
|
97
119
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const chalk = require('chalk');
|
|
2
|
+
|
|
3
|
+
let logFunction = originalLogFunction;
|
|
4
|
+
|
|
5
|
+
function error(message) {
|
|
6
|
+
logFunction(message, console.error, chalk.red);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function info(message) {
|
|
10
|
+
logFunction(message, console.info, chalk.blue);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function log(message) {
|
|
14
|
+
logFunction(message, console.log);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function prefix(string) {
|
|
18
|
+
return chalk.inverse(` ${string} `);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function success(message) {
|
|
22
|
+
logFunction(message, console.log, chalk.green);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function warn(message) {
|
|
26
|
+
logFunction(message, console.warn, chalk.yellow);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function originalLogFunction(message, consoleLogFunction, chalkColorFunction) {
|
|
30
|
+
consoleLogFunction(chalkColorFunction ? chalkColorFunction(message) : message);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function mockLog(mockedLogFunction) {
|
|
34
|
+
logFunction = mockedLogFunction;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function restoreLog() {
|
|
38
|
+
logFunction = originalLogFunction;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
module.exports = {
|
|
42
|
+
error,
|
|
43
|
+
info,
|
|
44
|
+
log,
|
|
45
|
+
prefix,
|
|
46
|
+
success,
|
|
47
|
+
warn,
|
|
48
|
+
|
|
49
|
+
_mockLog: mockLog,
|
|
50
|
+
_restoreLog: restoreLog,
|
|
51
|
+
};
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
const NpmAdapter = require('../dependency-manager-adapters/npm');
|
|
4
4
|
const PnpmAdapter = require('../dependency-manager-adapters/pnpm');
|
|
5
5
|
const WorkspaceAdapter = require('../dependency-manager-adapters/workspace');
|
|
6
|
+
const YarnAdapter = require('../dependency-manager-adapters/yarn');
|
|
6
7
|
|
|
7
8
|
module.exports = {
|
|
8
|
-
generateFromConfig(config,
|
|
9
|
+
generateFromConfig(config, cwd) {
|
|
9
10
|
let hasNpm = false;
|
|
10
|
-
let hasBower = false;
|
|
11
11
|
let adapters = [];
|
|
12
12
|
if (!config || !config.scenarios) {
|
|
13
13
|
return [];
|
|
@@ -17,40 +17,40 @@ module.exports = {
|
|
|
17
17
|
if (scenario.npm) {
|
|
18
18
|
hasNpm = true;
|
|
19
19
|
}
|
|
20
|
-
if (scenario.bower || scenario.dependencies || scenario.devDependencies) {
|
|
21
|
-
hasBower = true;
|
|
22
|
-
}
|
|
23
20
|
});
|
|
24
21
|
|
|
25
|
-
if (hasBower) {
|
|
26
|
-
throw new Error('[ember-try] bower configuration is no longer supported');
|
|
27
|
-
}
|
|
28
|
-
|
|
29
22
|
if (config.useWorkspaces) {
|
|
30
23
|
adapters.push(
|
|
31
24
|
new WorkspaceAdapter({
|
|
32
|
-
cwd
|
|
25
|
+
cwd,
|
|
33
26
|
managerOptions: config.npmOptions,
|
|
34
|
-
|
|
27
|
+
packageManager: config.packageManager,
|
|
35
28
|
buildManagerOptions: config.buildManagerOptions,
|
|
36
|
-
})
|
|
29
|
+
}),
|
|
37
30
|
);
|
|
38
|
-
} else if (config.
|
|
31
|
+
} else if (config.packageManager === 'pnpm') {
|
|
39
32
|
adapters.push(
|
|
40
33
|
new PnpmAdapter({
|
|
41
|
-
cwd
|
|
34
|
+
cwd,
|
|
35
|
+
managerOptions: config.npmOptions,
|
|
36
|
+
buildManagerOptions: config.buildManagerOptions,
|
|
37
|
+
}),
|
|
38
|
+
);
|
|
39
|
+
} else if (config.packageManager === 'yarn') {
|
|
40
|
+
adapters.push(
|
|
41
|
+
new YarnAdapter({
|
|
42
|
+
cwd,
|
|
42
43
|
managerOptions: config.npmOptions,
|
|
43
44
|
buildManagerOptions: config.buildManagerOptions,
|
|
44
|
-
})
|
|
45
|
+
}),
|
|
45
46
|
);
|
|
46
47
|
} else if (hasNpm) {
|
|
47
48
|
adapters.push(
|
|
48
49
|
new NpmAdapter({
|
|
49
|
-
cwd
|
|
50
|
+
cwd,
|
|
50
51
|
managerOptions: config.npmOptions,
|
|
51
|
-
useYarnCommand: config.useYarn,
|
|
52
52
|
buildManagerOptions: config.buildManagerOptions,
|
|
53
|
-
})
|
|
53
|
+
}),
|
|
54
54
|
);
|
|
55
55
|
}
|
|
56
56
|
|