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.
@@ -0,0 +1,26 @@
1
+ {
2
+ "solution": {
3
+ "ember-try": {
4
+ "impact": "major",
5
+ "oldVersion": "4.0.0",
6
+ "newVersion": "5.0.0",
7
+ "tagName": "latest",
8
+ "constraints": [
9
+ {
10
+ "impact": "major",
11
+ "reason": "Appears in changelog section :boom: Breaking Change"
12
+ },
13
+ {
14
+ "impact": "minor",
15
+ "reason": "Appears in changelog section :rocket: Enhancement"
16
+ },
17
+ {
18
+ "impact": "patch",
19
+ "reason": "Appears in changelog section :house: Internal"
20
+ }
21
+ ],
22
+ "pkgJSONPath": "./package.json"
23
+ }
24
+ },
25
+ "description": "## Release (2026-11-12)\n\n* ember-try 5.0.0 (major)\n\n#### :boom: Breaking Change\n* `ember-try`\n * [#1110](https://github.com/ember-cli/ember-try/pull/1110) Drop support for Node versions below 22.12 ([@NullVoxPopuli-ai-agent](https://github.com/NullVoxPopuli-ai-agent))\n\n#### :rocket: Enhancement\n* `ember-try`\n * [#1109](https://github.com/ember-cli/ember-try/pull/1109) Write pnpm overrides to pnpm-workspace.yaml on pnpm 11 and later ([@NullVoxPopuli-ai-agent](https://github.com/NullVoxPopuli-ai-agent))\n\n#### :house: Internal\n* `ember-try`\n * [#1113](https://github.com/ember-cli/ember-try/pull/1113) Update release-plan for OIDC ([@NullVoxPopuli](https://github.com/NullVoxPopuli))\n * [#1112](https://github.com/ember-cli/ember-try/pull/1112) Make the smoke test app pass on Ember 7 ([@NullVoxPopuli-ai-agent](https://github.com/NullVoxPopuli-ai-agent))\n\n#### Committers: 2\n- @NullVoxPopuli's reduced-access machine account for AI usage ([@NullVoxPopuli-ai-agent](https://github.com/NullVoxPopuli-ai-agent))\n- [@NullVoxPopuli](https://github.com/NullVoxPopuli)\n"
26
+ }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,92 @@
1
1
  # Changelog
2
2
 
3
+ ## Release (2026-11-12)
4
+
5
+ * ember-try 5.0.0 (major)
6
+
7
+ #### :boom: Breaking Change
8
+ * `ember-try`
9
+ * [#1110](https://github.com/ember-cli/ember-try/pull/1110) Drop support for Node versions below 22.12 ([@NullVoxPopuli-ai-agent](https://github.com/NullVoxPopuli-ai-agent))
10
+
11
+ #### :rocket: Enhancement
12
+ * `ember-try`
13
+ * [#1109](https://github.com/ember-cli/ember-try/pull/1109) Write pnpm overrides to pnpm-workspace.yaml on pnpm 11 and later ([@NullVoxPopuli-ai-agent](https://github.com/NullVoxPopuli-ai-agent))
14
+
15
+ #### :house: Internal
16
+ * `ember-try`
17
+ * [#1113](https://github.com/ember-cli/ember-try/pull/1113) Update release-plan for OIDC ([@NullVoxPopuli](https://github.com/NullVoxPopuli))
18
+ * [#1112](https://github.com/ember-cli/ember-try/pull/1112) Make the smoke test app pass on Ember 7 ([@NullVoxPopuli-ai-agent](https://github.com/NullVoxPopuli-ai-agent))
19
+
20
+ #### Committers: 2
21
+ - @NullVoxPopuli's reduced-access machine account for AI usage ([@NullVoxPopuli-ai-agent](https://github.com/NullVoxPopuli-ai-agent))
22
+ - [@NullVoxPopuli](https://github.com/NullVoxPopuli)
23
+
24
+ ## Release (2025-03-07)
25
+
26
+ ember-try 4.0.0 (major)
27
+
28
+ #### :boom: Breaking Change
29
+ * `ember-try`
30
+ * [#1037](https://github.com/ember-cli/ember-try/pull/1037) Remove passing an ember-cli `project` instance to the config function ([@bertdeblock](https://github.com/bertdeblock))
31
+ * [#994](https://github.com/ember-cli/ember-try/pull/994) pnpm: Ignore scripts by default ([@NullVoxPopuli](https://github.com/NullVoxPopuli))
32
+ * [#968](https://github.com/ember-cli/ember-try/pull/968) Update Node support (drop v16, test against v20 and v21) ([@bertdeblock](https://github.com/bertdeblock))
33
+ * [#965](https://github.com/ember-cli/ember-try/pull/965) Use the system's temp folder for backing up package-manager files ([@bertdeblock](https://github.com/bertdeblock))
34
+ * [#964](https://github.com/ember-cli/ember-try/pull/964) Drop support for npm v4 ([@bertdeblock](https://github.com/bertdeblock))
35
+ * [#962](https://github.com/ember-cli/ember-try/pull/962) Stop backing up the `node_modules` folder ([@bertdeblock](https://github.com/bertdeblock))
36
+
37
+ #### :rocket: Enhancement
38
+ * `ember-try`
39
+ * [#1025](https://github.com/ember-cli/ember-try/pull/1025) Support a `packageManager` option (instead of `usePnpm` and `useYarn`) ([@bertdeblock](https://github.com/bertdeblock))
40
+ * [#965](https://github.com/ember-cli/ember-try/pull/965) Use the system's temp folder for backing up package-manager files ([@bertdeblock](https://github.com/bertdeblock))
41
+
42
+ #### :bug: Bug Fix
43
+ * `ember-try`
44
+ * [#1024](https://github.com/ember-cli/ember-try/pull/1024) Update all dependencies with non-breaking changes ([@bertdeblock](https://github.com/bertdeblock))
45
+ * [#966](https://github.com/ember-cli/ember-try/pull/966) Enforce resolution-mode=highest for pnpm versions 8.0.0 to 8.6.* ([@lolmaus](https://github.com/lolmaus))
46
+ * [#962](https://github.com/ember-cli/ember-try/pull/962) Stop backing up the `node_modules` folder ([@bertdeblock](https://github.com/bertdeblock))
47
+
48
+ #### :memo: Documentation
49
+ * `ember-try`
50
+ * [#807](https://github.com/ember-cli/ember-try/pull/807) Use scenario names available in default `addon` blueprint ([@jelhan](https://github.com/jelhan))
51
+
52
+ #### :house: Internal
53
+ * `ember-try`
54
+ * [#1088](https://github.com/ember-cli/ember-try/pull/1088) Update release-plan actions, workflows via create-release-plan-setup ([@kategengler](https://github.com/kategengler))
55
+ * [#1085](https://github.com/ember-cli/ember-try/pull/1085) Update release-plan workflows. ([@kategengler](https://github.com/kategengler))
56
+ * [#1036](https://github.com/ember-cli/ember-try/pull/1036) Don't use ember-cli `project` instance outside of ember-cli commands ([@bertdeblock](https://github.com/bertdeblock))
57
+ * [#1048](https://github.com/ember-cli/ember-try/pull/1048) Use `pnpm` for running scripts ([@bertdeblock](https://github.com/bertdeblock))
58
+ * [#1050](https://github.com/ember-cli/ember-try/pull/1050) use package.json pnpm version for release-plan ([@mansona](https://github.com/mansona))
59
+ * [#1039](https://github.com/ember-cli/ember-try/pull/1039) Start using release-plan ([@mansona](https://github.com/mansona))
60
+ * [#1049](https://github.com/ember-cli/ember-try/pull/1049) Pin `pnpm` version ([@bertdeblock](https://github.com/bertdeblock))
61
+ * [#1038](https://github.com/ember-cli/ember-try/pull/1038) Switch to pnpm ([@mansona](https://github.com/mansona))
62
+ * [#1035](https://github.com/ember-cli/ember-try/pull/1035) Remove custom `findByName` util ([@bertdeblock](https://github.com/bertdeblock))
63
+ * [#1034](https://github.com/ember-cli/ember-try/pull/1034) Migrate test suite to ES modules ([@bertdeblock](https://github.com/bertdeblock))
64
+ * [#1030](https://github.com/ember-cli/ember-try/pull/1030) Remove use of ember-cli `ui` instance ([@bertdeblock](https://github.com/bertdeblock))
65
+ * [#1029](https://github.com/ember-cli/ember-try/pull/1029) Remove use of `mockery` ([@bertdeblock](https://github.com/bertdeblock))
66
+ * [#1028](https://github.com/ember-cli/ember-try/pull/1028) Remove some unused files ([@bertdeblock](https://github.com/bertdeblock))
67
+ * [#1026](https://github.com/ember-cli/ember-try/pull/1026) Use a completely separate adapter for yarn ([@bertdeblock](https://github.com/bertdeblock))
68
+ * [#1027](https://github.com/ember-cli/ember-try/pull/1027) Update lint setup ([@bertdeblock](https://github.com/bertdeblock))
69
+ * [#1022](https://github.com/ember-cli/ember-try/pull/1022) Use only one ESLint config file ([@bertdeblock](https://github.com/bertdeblock))
70
+ * [#1023](https://github.com/ember-cli/ember-try/pull/1023) Use `ember version` command to make test output more readable ([@bertdeblock](https://github.com/bertdeblock))
71
+ * [#1021](https://github.com/ember-cli/ember-try/pull/1021) Remove use of `rsvp` ([@bertdeblock](https://github.com/bertdeblock))
72
+ * [#1020](https://github.com/ember-cli/ember-try/pull/1020) Remove use of `core-object` for adapters ([@bertdeblock](https://github.com/bertdeblock))
73
+ * [#1000](https://github.com/ember-cli/ember-try/pull/1000) Remove use of `core-object` for utils ([@bertdeblock](https://github.com/bertdeblock))
74
+ * [#999](https://github.com/ember-cli/ember-try/pull/999) Remove use of `core-object` for tasks ([@bertdeblock](https://github.com/bertdeblock))
75
+ * [#1001](https://github.com/ember-cli/ember-try/pull/1001) Update ESLint config to properly support native classes ([@bertdeblock](https://github.com/bertdeblock))
76
+ * [#1002](https://github.com/ember-cli/ember-try/pull/1002) Clean up everything related to Bower ([@bertdeblock](https://github.com/bertdeblock))
77
+ * [#969](https://github.com/ember-cli/ember-try/pull/969) Update development dependencies ([@bertdeblock](https://github.com/bertdeblock))
78
+ * [#972](https://github.com/ember-cli/ember-try/pull/972) Update branch name and remove Appveyor badge from README -- it is no longer used ([@kategengler](https://github.com/kategengler))
79
+ * [#971](https://github.com/ember-cli/ember-try/pull/971) Update CodeCov upload ([@kategengler](https://github.com/kategengler))
80
+ * [#963](https://github.com/ember-cli/ember-try/pull/963) Add test to verify original node modules are installed again ([@bertdeblock](https://github.com/bertdeblock))
81
+
82
+ #### Committers: 6
83
+ - Andrey Mikhaylov (lolmaus) ([@lolmaus](https://github.com/lolmaus))
84
+ - Bert De Block ([@bertdeblock](https://github.com/bertdeblock))
85
+ - Chris Manson ([@mansona](https://github.com/mansona))
86
+ - Jeldrik Hanschke ([@jelhan](https://github.com/jelhan))
87
+ - Katie Gengler ([@kategengler](https://github.com/kategengler))
88
+ - [@NullVoxPopuli](https://github.com/NullVoxPopuli)
89
+
3
90
 
4
91
 
5
92
  ## v3.0.0 (2023-08-16)
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # ember-try
2
2
 
3
- [![npm version](https://badge.fury.io/js/ember-try.svg)](https://badge.fury.io/js/ember-try) [![GitHub Actions Build Status](https://github.com/ember-cli/ember-try/workflows/CI/badge.svg)](https://github.com/ember-cli/ember-try/actions/workflows/ci.yml?query=branch%3Amaster) [![Ember Observer Score](http://emberobserver.com/badges/ember-try.svg)](http://emberobserver.com/addons/ember-try) [![Build status](https://ci.appveyor.com/api/projects/status/9sswkni8pfuvo4dv/branch/master?svg=true)](https://ci.appveyor.com/project/kategengler/ember-try/branch/master) [![Code Climate](https://codeclimate.com/github/ember-cli/ember-try/badges/gpa.svg)](https://codeclimate.com/github/ember-cli/ember-try) [![Test Coverage](https://codecov.io/gh/ember-cli/ember-try/branch/master/graph/badge.svg)](https://codecov.io/gh/ember-cli/ember-try)
3
+ [![npm version](https://badge.fury.io/js/ember-try.svg)](https://badge.fury.io/js/ember-try) [![GitHub Actions Build Status](https://github.com/ember-cli/ember-try/workflows/CI/badge.svg)](https://github.com/ember-cli/ember-try/actions/workflows/ci.yml?query=branch%3Amain) [![Ember Observer Score](http://emberobserver.com/badges/ember-try.svg)](http://emberobserver.com/addons/ember-try) [![Code Climate](https://codeclimate.com/github/ember-cli/ember-try/badges/gpa.svg)](https://codeclimate.com/github/ember-cli/ember-try) [![Test Coverage](https://codecov.io/gh/ember-cli/ember-try/branch/main/graph/badge.svg)](https://codecov.io/gh/ember-cli/ember-try)
4
4
 
5
5
  An ember-cli addon to test against multiple dependencies, such as `ember` and `ember-data`.
6
6
 
@@ -14,7 +14,7 @@ ember install ember-try
14
14
 
15
15
  This addon provides a few commands:
16
16
 
17
- ### `ember try:each`
17
+ #### `ember try:each`
18
18
 
19
19
  This command will run `ember test` or the configured command with each scenario's specified in the config and exit appropriately.
20
20
 
@@ -37,31 +37,31 @@ This command will run any `ember-cli` command with the specified scenario. The c
37
37
  For example:
38
38
 
39
39
  ```
40
- ember try:one ember-1.11-with-ember-data-beta-16 --- ember test --reporter xunit
40
+ ember try:one ember-beta --- ember test --reporter xunit
41
41
  ```
42
42
 
43
43
  or
44
44
 
45
45
  ```
46
- ember try:one ember-1.11-with-ember-data-beta-16 --- ember serve
46
+ ember try:one ember-beta --- ember serve
47
47
  ```
48
48
 
49
49
  When running in a CI environment where changes are discarded you can skip resetting your environment back to its original state by specifying --skip-cleanup=true as an option to ember try.
50
- *Warning: If you use this option and, without cleaning up, build and deploy as the result of a passing test suite, it will build with the last set of dependencies ember try was run with.*
50
+ _Warning: If you use this option and, without cleaning up, build and deploy as the result of a passing test suite, it will build with the last set of dependencies ember try was run with._
51
51
 
52
52
  ```
53
- ember try:one ember-1.11 --skip-cleanup=true --- ember test
53
+ ember try:one ember-beta --skip-cleanup=true --- ember test
54
54
  ```
55
55
 
56
56
  In order to use an alternate config path or to group various scenarios, you can use the `--config-path` option.
57
57
 
58
58
  ```
59
- ember try:one ember-1.13 --config-path="config/legacy-scenarios.js"
59
+ ember try:one ember-beta --config-path="config/legacy-scenarios.js"
60
60
  ```
61
61
 
62
62
  #### `ember try:reset`
63
63
 
64
- This command restores the original `package.json` from `package.json.ember-try`, `rm -rf`s `node_modules` and runs `npm install`. For use if any of the other commands fail to clean up after (they run this by default on completion).
64
+ This command restores all original files, and installs the original node modules again. For use if any of the other commands fail to clean up after (they run this by default on completion) or after running with ‘—skip-cleanup’.
65
65
 
66
66
  #### `ember try:ember <semver-string>`
67
67
 
@@ -74,6 +74,7 @@ Displays the configuration that will be used. Also takes an optional `--config-p
74
74
  ### Config
75
75
 
76
76
  ##### versionCompatibility
77
+
77
78
  If you're using `ember-try` with an Ember addon, there is a short cut to test many Ember versions. In your `package.json` under the `ember-addon` key, add the following:
78
79
 
79
80
  ```json
@@ -109,22 +110,17 @@ module.exports = async function() {
109
110
  /*
110
111
  `npmOptions` - options to be passed to `npm`.
111
112
  */
112
- npmOptions: ['--loglevel=silent', '--no-shrinkwrap=true'],
113
+ npmOptions: ['--loglevel=silent'],
113
114
  /*
114
115
  If set to true, the `versionCompatibility` key under `ember-addon` in `package.json` will be used to
115
116
  automatically generate scenarios that will deep merge with any in this configuration file.
116
117
  */
117
118
  useVersionCompatibility: true,
118
119
  /*
119
- If set to true, all npm scenarios will use `yarn` for install with the `--no-lockfile` option. At cleanup, your
120
- dependencies will be restored to their prior state.
121
- */
122
- useYarn: true,
123
- /*
124
- If set to true, all npm scenarios will use `pnpm` for install with the `--no-lockfile` options. At cleanup, your
125
- dependencies will be restored to their prior state.
120
+ The package manager to use for all scenarios. By default, lockfiles will be ignored when installing dependencies.
121
+ At cleanup, all dependencies will be restored to their prior state.
126
122
  */
127
- usePnpm: true,
123
+ packageManager: 'npm' | 'pnpm' | 'yarn',
128
124
 
129
125
  /*
130
126
  buildManagerOptions allows you to opt-out of the default options such as `--ignore-engines --no-lockfile`.
@@ -149,15 +145,15 @@ module.exports = async function() {
149
145
  'ember-source': '2.11.0'
150
146
  },
151
147
  /*
152
- You can optionally define npm or pnpm overrides to enforce a specific dependency version
148
+ You can optionally define npm or pnpm overrides to enforce a specific dependency version
153
149
  to be installed. This is useful if other libraries you depend on include different
154
- versions of a package. This does nothing if `useYarn` is true;
150
+ versions of a package. This does nothing if `packageManager` is `yarn`;
155
151
  */
156
152
  overrides: {
157
153
  'lodash': '5.0.0'
158
154
  }
159
155
  /*
160
- When `useYarn` is true, you can optionally define yarn resolutions to enforce a
156
+ When `packageManager` is `yarn`, you can optionally define yarn resolutions to enforce a
161
157
  specific dependency version to be installed. This is useful if other libraries
162
158
  you depend on include different versions of a package.
163
159
  */
@@ -209,16 +205,21 @@ The `name` can be used to try just one scenario using the `ember try:one` comman
209
205
 
210
206
  ##### Yarn
211
207
 
212
- If you include `useYarn: true` in your `ember-try` config, all npm scenarios will use `yarn` for install with the `--no-lockfile` option. At cleanup, your dependencies will be restored to their prior state.
208
+ If you include `packageManager: 'yarn'` in your `ember-try` config, all npm scenarios will use `yarn` for install with the `--no-lockfile` option. At cleanup, your dependencies will be restored to their prior state.
209
+
210
+ pnpm 11 and later do not read the `pnpm` field in `package.json`. With these versions, `ember-try` writes the scenario `pnpm.overrides` to the `overrides` setting in `pnpm-workspace.yaml`, and restores that file at cleanup.
213
211
 
214
212
  ##### Pnpm
215
213
 
216
- If you include `usePnpm: true` in your `ember-try` config, all npm scenarios will use `pnpm` for install with the `--no-lockfile` options. At cleanup, your dependencies will be restored to their prior state.
214
+ If you include `packageManager: 'pnpm'` in your `ember-try` config, all npm scenarios will use `pnpm` for install with the `--no-lockfile` options. At cleanup, your dependencies will be restored to their prior state.
217
215
 
216
+ > ⚠ pnpm versions from 8.0.0 to 8.6.x have the default value of [resolution-mode](https://pnpm.io/npmrc#resolution-mode) setting changed to `lowest-direct`. This violates `ember-try` expectations as `resolution-mode` is expected to be `highest`, like in `npm` and `pnpm` versions < 8.0.0 and >= 8.7.0.
217
+ >
218
+ > If you run into this issue, we recommend to upgrade pnpm to latest version. If you are unable to upgrade, you can set `resolution-mode = highest` in the `.npmrc` file.
218
219
 
219
220
  ##### A note on npm scenarios with lockfiles
220
221
 
221
- Lockfiles are ignored by `ember-try`. (`yarn` will run with `--no-lockfile` and `npm` will be run with `--no-shrinkwrap` and `pnpm` will be run with `--no-lockfile`).
222
+ Lockfiles are ignored by `ember-try`. (`yarn` will run with `--no-lockfile` and `npm` will be run with `--no-package-lock` and `pnpm` will be run with `--no-lockfile`).
222
223
  When testing various scenarios, it's important to "float" dependencies so that the scenarios are run with the latest satisfying versions of dependencies a user of the project would get.
223
224
 
224
225
  ##### Workspaces
@@ -228,6 +229,7 @@ in `package.json`, allowing you to try scenarios in monorepo style repositories.
228
229
  [Yarn's documentation of workspaces](https://yarnpkg.com/lang/en/docs/workspaces/) for more details.
229
230
 
230
231
  ### Video
232
+
231
233
  [![How to use EmberTry](https://i.vimeocdn.com/video/559399937_500.jpg)](https://vimeo.com/157688157)
232
234
 
233
235
  See an example of using `ember-try` for CI [here](https://github.com/kategengler/ember-feature-flags/commit/aaf0226975c76630c875cf6b923fdc23b025aa79), and the resulting build [output](https://travis-ci.org/kategengler/ember-feature-flags/builds/55597086).
@@ -236,7 +238,6 @@ See an example of using `ember-try` for CI [here](https://github.com/kategengler
236
238
 
237
239
  - Much credit is due to [Edward Faulkner](https://github.com/ef4) The scripts in [liquid-fire](https://github.com/ef4/liquid-fire) that test against multiple ember versions were the inspiration for this project.
238
240
 
239
-
240
241
  ### Developing
241
242
 
242
243
  - Be sure to run `npm link` and `npm link ember-try`, otherwise any `ember try` commands you run will use the version of ember-try included by ember-cli itself.
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const debug = require('debug')('ember-try:commands:config');
4
+ const { log } = require('../utils/console');
4
5
 
5
6
  module.exports = {
6
7
  name: 'try:config',
@@ -11,11 +12,12 @@ module.exports = {
11
12
  async run(commandOptions) {
12
13
  debug('Options:\n', commandOptions);
13
14
 
15
+ let cwd = this.project.root;
14
16
  let config = await require('../utils/config')({
15
- project: this.project,
16
17
  configPath: commandOptions.configPath,
18
+ cwd,
17
19
  });
18
20
 
19
- this.ui.writeLine(JSON.stringify(config, null, 2));
21
+ log(JSON.stringify(config, null, 2));
20
22
  },
21
23
  };
@@ -6,13 +6,13 @@ module.exports = {
6
6
  works: 'insideProject',
7
7
 
8
8
  async run() {
9
- let config = await require('../utils/config')({ project: this.project });
9
+ let cwd = this.project.root;
10
+ let config = await require('../utils/config')({ cwd });
10
11
  let ResetTask = require('../tasks/reset');
11
12
 
12
13
  let resetTask = new ResetTask({
13
- ui: this.ui,
14
- project: this.project,
15
14
  config,
15
+ cwd,
16
16
  });
17
17
 
18
18
  return await resetTask.run();
@@ -18,17 +18,17 @@ module.exports = {
18
18
  async run(commandOptions) {
19
19
  debug('Options:\n', commandOptions);
20
20
 
21
+ let cwd = this.project.root;
21
22
  let config = await this._getConfig({
22
- project: this.project,
23
23
  configPath: commandOptions.configPath,
24
+ cwd,
24
25
  });
25
26
 
26
27
  debug('Config: %s', JSON.stringify(config));
27
28
 
28
29
  let tryEachTask = new this._TryEachTask({
29
- ui: this.ui,
30
- project: this.project,
31
30
  config,
31
+ cwd,
32
32
  });
33
33
 
34
34
  return await tryEachTask.run(config.scenarios, { skipCleanup: commandOptions.skipCleanup });
@@ -24,9 +24,10 @@ module.exports = {
24
24
  debug('Options:\n', commandOptions);
25
25
  debug('Ember semver statement', emberVersion);
26
26
 
27
+ let cwd = this.project.root;
27
28
  let config = await this._getConfig({
28
- project: this.project,
29
29
  configPath: commandOptions.configPath,
30
+ cwd,
30
31
  versionCompatibility: {
31
32
  ember: emberVersion,
32
33
  },
@@ -35,9 +36,8 @@ module.exports = {
35
36
  debug('Config: %s', JSON.stringify(config));
36
37
 
37
38
  let tryEachTask = new this._TryEachTask({
38
- ui: this.ui,
39
- project: this.project,
40
39
  config,
40
+ cwd,
41
41
  });
42
42
 
43
43
  return await tryEachTask.run(config.scenarios, { skipCleanup: commandOptions.skipCleanup });
@@ -1,6 +1,5 @@
1
1
  'use strict';
2
2
 
3
- const findByName = require('../utils/find-by-name');
4
3
  const debug = require('debug')('ember-try:commands:try-one');
5
4
 
6
5
  module.exports = {
@@ -43,25 +42,25 @@ module.exports = {
43
42
  throw new Error('The `ember try:one` command requires a ' + 'scenario name to be specified.');
44
43
  }
45
44
 
45
+ let cwd = this.project.root;
46
46
  let config = await this._getConfig({
47
- project: this.project,
48
47
  configPath: commandOptions.configPath,
48
+ cwd,
49
49
  });
50
50
 
51
51
  debug('Config: %s', JSON.stringify(config));
52
52
 
53
- let scenario = findByName(config.scenarios, scenarioName);
53
+ let scenario = config.scenarios.find((s) => s.name === scenarioName);
54
54
  if (!scenario) {
55
55
  throw new Error(
56
- 'The `ember try:one` command requires a scenario ' + 'specified in the config.'
56
+ 'The `ember try:one` command requires a scenario ' + 'specified in the config.',
57
57
  );
58
58
  }
59
59
 
60
60
  let tryEachTask = new this._TryEachTask({
61
- ui: this.ui,
62
- project: this.project,
63
- config,
64
61
  commandArgs,
62
+ config,
63
+ cwd,
65
64
  });
66
65
 
67
66
  return await tryEachTask.run([scenario], { skipCleanup: commandOptions.skipCleanup });
@@ -0,0 +1,175 @@
1
+ 'use strict';
2
+
3
+ const debug = require('debug');
4
+ const { get, set } = require('es-toolkit/compat');
5
+ const fs = require('fs-extra');
6
+ const path = require('node:path');
7
+ const semver = require('semver');
8
+ const Backup = require('../utils/backup');
9
+ const { warn } = require('../utils/console');
10
+ const { LOCKFILE, PACKAGE_JSON } = require('../utils/package-managers');
11
+
12
+ class BaseAdapter {
13
+ configKey = 'npm';
14
+ defaultInstallOptions = [];
15
+ lockfile = '';
16
+ name = '';
17
+ overridesKey = '';
18
+
19
+ backup = null;
20
+ debugFunction = null;
21
+
22
+ constructor(options) {
23
+ this.backup = new Backup({ cwd: options.cwd });
24
+ this.buildManagerOptions = options.buildManagerOptions;
25
+ this.cwd = options.cwd;
26
+ this.managerOptions = options.managerOptions;
27
+ this.run = options.run ?? require('../utils/run');
28
+ }
29
+
30
+ debug(...args) {
31
+ if (this.debugFunction === null) {
32
+ this.debugFunction = debug(`ember-try:dependency-manager-adapter:${this.name}`);
33
+ }
34
+
35
+ this.debugFunction(...args);
36
+ }
37
+
38
+ async setup() {
39
+ this._checkForDifferentLockfiles();
40
+
41
+ await this.backup.addFiles([PACKAGE_JSON, this.lockfile]);
42
+ }
43
+
44
+ async changeToDependencySet(dependencySet) {
45
+ await this.applyDependencySet(dependencySet);
46
+ await this._install(dependencySet);
47
+
48
+ const dependencies = {
49
+ ...dependencySet.dependencies,
50
+ ...dependencySet.devDependencies,
51
+ };
52
+
53
+ const currentDependencies = Object.keys(dependencies).map((name) => ({
54
+ name,
55
+ packageManager: this.name,
56
+ versionExpected: dependencies[name],
57
+ versionSeen: this._findCurrentVersionOf(name),
58
+ }));
59
+
60
+ this.debug('Switched to dependencies: \n', currentDependencies);
61
+
62
+ return currentDependencies;
63
+ }
64
+
65
+ async applyDependencySet(dependencySet) {
66
+ if (dependencySet === undefined) {
67
+ return;
68
+ }
69
+
70
+ this.debug('Changing to dependency set: %s', JSON.stringify(dependencySet));
71
+
72
+ const oldPackageJSON = JSON.parse(fs.readFileSync(this.backup.pathForFile(PACKAGE_JSON)));
73
+ const newPackageJSON = this._packageJSONForDependencySet(oldPackageJSON, dependencySet);
74
+
75
+ this.debug('Write package.json with: \n', JSON.stringify(newPackageJSON));
76
+
77
+ fs.writeFileSync(path.join(this.cwd, PACKAGE_JSON), JSON.stringify(newPackageJSON, null, 2));
78
+ }
79
+
80
+ async cleanup() {
81
+ try {
82
+ await this.backup.restoreFiles([PACKAGE_JSON, this.lockfile]);
83
+ await this.backup.cleanUp();
84
+ await this._install();
85
+ } catch (error) {
86
+ console.error('Error cleaning up scenario:', error);
87
+ }
88
+ }
89
+
90
+ _checkForDifferentLockfiles() {
91
+ for (const packageManager in LOCKFILE) {
92
+ const lockfile = LOCKFILE[packageManager];
93
+
94
+ if (lockfile === this.lockfile) {
95
+ continue;
96
+ }
97
+
98
+ try {
99
+ if (fs.statSync(path.join(this.cwd, lockfile)).isFile()) {
100
+ warn(
101
+ `Detected a \`${lockfile}\` file. Add \`packageManager: '${packageManager}'\` to your \`config/ember-try.js\` configuration file if you want to use ${packageManager} to install dependencies.`,
102
+ );
103
+ }
104
+ } catch {
105
+ // Move along.
106
+ }
107
+ }
108
+ }
109
+
110
+ _findCurrentVersionOf(name) {
111
+ const filename = path.join(this.cwd, 'node_modules', name, PACKAGE_JSON);
112
+
113
+ if (fs.existsSync(filename)) {
114
+ return JSON.parse(fs.readFileSync(filename)).version;
115
+ } else {
116
+ return null;
117
+ }
118
+ }
119
+
120
+ async _install(dependencySet) {
121
+ let managerOptions = this.managerOptions || [];
122
+
123
+ if (typeof this.buildManagerOptions === 'function') {
124
+ managerOptions = this.buildManagerOptions(dependencySet);
125
+
126
+ if (Array.isArray(managerOptions) === false) {
127
+ throw new Error('buildManagerOptions must return an array of options');
128
+ }
129
+ } else if (this.defaultInstallOptions.length) {
130
+ for (const option of this.defaultInstallOptions) {
131
+ if (managerOptions.includes(option) === false) {
132
+ managerOptions.push(option);
133
+ }
134
+ }
135
+ }
136
+
137
+ this.debug(`Running ${this.name} install with options %s`, managerOptions);
138
+
139
+ await this.run(this.name, ['install', ...managerOptions], { cwd: this.cwd });
140
+ }
141
+
142
+ _packageJSONForDependencySet(packageJSON, dependencySet) {
143
+ this._overridePackageJSONDependencies(packageJSON, dependencySet, 'dependencies');
144
+ this._overridePackageJSONDependencies(packageJSON, dependencySet, 'devDependencies');
145
+ this._overridePackageJSONDependencies(packageJSON, dependencySet, 'peerDependencies');
146
+ this._overridePackageJSONDependencies(packageJSON, dependencySet, 'ember');
147
+ this._overridePackageJSONDependencies(packageJSON, dependencySet, this.overridesKey);
148
+
149
+ return packageJSON;
150
+ }
151
+
152
+ _overridePackageJSONDependencies(packageJSON, dependencySet, kindOfDependency) {
153
+ if (get(dependencySet, kindOfDependency) === undefined) {
154
+ return;
155
+ }
156
+
157
+ let packageNames = Object.keys(get(dependencySet, kindOfDependency));
158
+
159
+ for (let packageName of packageNames) {
160
+ let version = get(dependencySet, `${kindOfDependency}.${packageName}`);
161
+
162
+ if (version === null) {
163
+ delete get(packageJSON, kindOfDependency)[packageName];
164
+ } else {
165
+ set(packageJSON, `${kindOfDependency}.${packageName}`, version);
166
+
167
+ if (semver.prerelease(version) || /^https*:\/\/.*\.tg*z/.test(version)) {
168
+ set(packageJSON, `${this.overridesKey}.${packageName}`, `$${packageName}`);
169
+ }
170
+ }
171
+ }
172
+ }
173
+ }
174
+
175
+ module.exports = { BaseAdapter };