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.
@@ -1,10 +1,14 @@
1
1
  'use strict';
2
2
 
3
- const CoreObject = require('core-object');
4
3
  const chalk = require('chalk');
5
4
  const Table = require('cli-table3');
5
+ const { error, info, log, success } = require('./console');
6
+
7
+ module.exports = class ResultSummary {
8
+ constructor(options) {
9
+ this.results = options.results;
10
+ }
6
11
 
7
- module.exports = CoreObject.extend({
8
12
  print() {
9
13
  let task = this;
10
14
  let colorAndMessage;
@@ -29,28 +33,28 @@ module.exports = CoreObject.extend({
29
33
  colorAndMessage = chalk.red(failMessage);
30
34
  countFailed++;
31
35
  }
32
- task.ui.writeLine(colorAndMessage);
33
- task.ui.writeLine(`Command run: ${scenario.command}`);
36
+ log(colorAndMessage);
37
+ log(`Command run: ${scenario.command}`);
34
38
  if (scenario.envState) {
35
- task.ui.writeLine(`with env: ${JSON.stringify(scenario.envState, null, 2)}`);
39
+ log(`with env: ${JSON.stringify(scenario.envState, null, 2)}`);
36
40
  }
37
41
  task._printDependencyTable(scenario.dependencyState);
38
42
  });
39
43
 
40
- task.ui.writeLine('');
44
+ log('');
41
45
  task._printResultsSummary(countFailed, countPassed, allowedFailCount, this.results.length);
42
- },
46
+ }
47
+
43
48
  _printResultHeader() {
44
- let task = this;
45
- task.ui.writeLine('');
46
- task.ui.writeLine('------ RESULTS ------');
47
- task.ui.writeLine('');
48
- },
49
+ log('');
50
+ log('------ RESULTS ------');
51
+ log('');
52
+ }
53
+
49
54
  _printDependencyTable(dependencyStatus) {
50
55
  if (!dependencyStatus.length) {
51
56
  return;
52
57
  }
53
- let task = this;
54
58
  let colorForDepFn;
55
59
  let tableRow;
56
60
  let table = new Table({
@@ -78,21 +82,21 @@ module.exports = CoreObject.extend({
78
82
  });
79
83
  table.push(tableRow);
80
84
  });
81
- task.ui.writeLine(table);
82
- task.ui.writeLine('');
83
- },
85
+ log(table);
86
+ log('');
87
+ }
88
+
84
89
  _printResultsSummary(countFailed, countPassed, allowedFailCount, total) {
85
- let task = this;
86
90
  if (countFailed) {
87
91
  let failMessage = `${countFailed} scenarios failed`;
88
92
  if (allowedFailCount) {
89
93
  failMessage = `${failMessage} (${allowedFailCount} allowed)`;
90
94
  }
91
- task.ui.writeLine(chalk.red(failMessage));
92
- task.ui.writeLine(chalk.green(`${countPassed} scenarios succeeded`));
93
- task.ui.writeLine(chalk.gray(`${total} scenarios run`));
95
+ error(failMessage);
96
+ success(`${countPassed} scenarios succeeded`);
97
+ info(`${total} scenarios run`);
94
98
  } else {
95
- task.ui.writeLine(chalk.green(`All ${countPassed} scenarios succeeded`));
99
+ success(`All ${countPassed} scenarios succeeded`);
96
100
  }
97
- },
98
- });
101
+ }
102
+ };
package/lib/utils/run.js CHANGED
@@ -3,7 +3,9 @@
3
3
  const execa = require('execa');
4
4
  const debug = require('debug')('ember-try:utils:run');
5
5
 
6
- module.exports = async function run(command, args, _options) {
6
+ let runFunction = originalRunFunction;
7
+
8
+ async function originalRunFunction(command, args, _options) {
7
9
  let options = Object.assign({ stdio: 'inherit', shell: true }, _options);
8
10
 
9
11
  if (process.env.SHUT_UP) {
@@ -21,4 +23,22 @@ module.exports = async function run(command, args, _options) {
21
23
  // TODO: should refactor this to throw an error (easier to track down stack traces)
22
24
  throw error.exitCode;
23
25
  }
24
- };
26
+ }
27
+
28
+ function run(command, args, options) {
29
+ return runFunction(command, args, options);
30
+ }
31
+
32
+ function mockRun(mockedRunFunction) {
33
+ runFunction = mockedRunFunction;
34
+ }
35
+
36
+ function restoreRun() {
37
+ runFunction = originalRunFunction;
38
+ }
39
+
40
+ module.exports = run;
41
+
42
+ module.exports._originalRunFunction = originalRunFunction;
43
+ module.exports._mockRun = mockRun;
44
+ module.exports._restoreRun = restoreRun;
@@ -1,33 +1,34 @@
1
1
  'use strict';
2
2
 
3
- const CoreObject = require('core-object');
3
+ module.exports = class ScenarioManager {
4
+ constructor(options) {
5
+ this.dependencyManagerAdapters = options.dependencyManagerAdapters;
6
+ }
4
7
 
5
- module.exports = CoreObject.extend({
6
8
  async setup() {
7
- let { ui } = this;
8
-
9
9
  for (let depManager of this.dependencyManagerAdapters) {
10
- await depManager.setup({ ui });
10
+ await depManager.setup();
11
11
  }
12
- },
12
+ }
13
13
 
14
14
  async changeTo(scenario) {
15
15
  let results = [];
16
+
16
17
  for (let depManager of this.dependencyManagerAdapters) {
17
18
  if (scenario[depManager.configKey]) {
18
19
  let depManagerResults = await depManager.changeToDependencySet(
19
- scenario[depManager.configKey]
20
+ scenario[depManager.configKey],
20
21
  );
21
22
  results.push(...depManagerResults);
22
23
  }
23
24
  }
24
25
 
25
26
  return results;
26
- },
27
+ }
27
28
 
28
29
  async cleanup() {
29
30
  for (let depManager of this.dependencyManagerAdapters) {
30
31
  await depManager.cleanup();
31
32
  }
32
- },
33
- });
33
+ }
34
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-try",
3
- "version": "3.0.0",
3
+ "version": "5.0.0",
4
4
  "description": "An ember-cli addon to test against multiple dependencies, such as ember and ember-data.",
5
5
  "keywords": [
6
6
  "ember-addon",
@@ -21,47 +21,41 @@
21
21
  "lib": "lib",
22
22
  "test": "tests"
23
23
  },
24
- "scripts": {
25
- "lint": "eslint .",
26
- "node-test": "mocha test/**/*.js",
27
- "node-test-with-coverage": "nyc --reporter lcov npm run-script node-test && node_modules/.bin/codecov",
28
- "start": "ember serve",
29
- "test": "npm run-script lint && npm run-script node-test"
30
- },
31
24
  "dependencies": {
32
25
  "chalk": "^4.1.2",
33
- "cli-table3": "^0.6.0",
34
- "core-object": "^3.1.5",
35
- "debug": "^4.3.2",
26
+ "cli-table3": "^0.6.5",
27
+ "debug": "^4.4.0",
36
28
  "ember-try-config": "^4.0.0",
29
+ "es-toolkit": "^1.29.0",
37
30
  "execa": "^4.1.0",
38
31
  "fs-extra": "^6.0.1",
39
- "resolve": "^1.20.0",
32
+ "resolve": "^1.22.8",
40
33
  "rimraf": "^3.0.2",
41
- "semver": "^7.5.4",
42
- "walk-sync": "^2.2.0"
34
+ "semver": "^7.6.3",
35
+ "temp-dir": "^2.0.0",
36
+ "walk-sync": "^2.2.0",
37
+ "yaml": "^2.9.1"
43
38
  },
44
39
  "devDependencies": {
45
- "chai": "^4.3.4",
40
+ "@babel/core": "^7.26.0",
41
+ "@babel/eslint-parser": "^7.25.9",
42
+ "chai": "^5.1.2",
43
+ "chai-as-promised": "^8.0.1",
46
44
  "codecov": "^3.8.3",
47
- "ember-cli": "~3.22.0",
48
- "eslint": "^7.31.0",
49
- "eslint-config-prettier": "^6.15.0",
50
- "eslint-plugin-node": "^11.1.0",
51
- "eslint-plugin-prettier": "^3.1.4",
52
- "glob": "^7.2.0",
53
- "json": "^10.0.0",
54
- "mocha": "^8.2.1",
55
- "mockery": "^2.1.0",
56
- "nyc": "^15.1.0",
57
- "prettier": "^2.4.1",
58
- "release-it": "^14.11.6",
59
- "release-it-lerna-changelog": "^3.1.0",
60
- "rsvp": "^4.7.0",
45
+ "concurrently": "^9.1.0",
46
+ "ember-cli": "~5.12.0",
47
+ "eslint": "^8.57.0",
48
+ "eslint-config-prettier": "^9.1.0",
49
+ "eslint-plugin-n": "^17.15.0",
50
+ "mocha": "^11.0.1",
51
+ "nyc": "^17.1.0",
52
+ "prettier": "^3.4.2",
53
+ "release-plan": "^0.18.0",
54
+ "sinon": "^19.0.2",
61
55
  "tmp-sync": "^1.1.0"
62
56
  },
63
57
  "engines": {
64
- "node": "16.* || >= 18.*"
58
+ "node": ">= 22.12.0"
65
59
  },
66
60
  "publishConfig": {
67
61
  "registry": "https://registry.npmjs.org"
@@ -69,22 +63,16 @@
69
63
  "ember-addon": {
70
64
  "configPath": "tests/dummy/config"
71
65
  },
72
- "release-it": {
73
- "plugins": {
74
- "release-it-lerna-changelog": {
75
- "infile": "CHANGELOG.md",
76
- "launchEditor": true
77
- }
78
- },
79
- "git": {
80
- "tagName": "v${version}"
81
- },
82
- "github": {
83
- "release": true,
84
- "tokenRef": "GITHUB_AUTH"
85
- },
86
- "npm": {
87
- "publish": false
88
- }
66
+ "scripts": {
67
+ "format": "prettier . --cache --write",
68
+ "lint": "concurrently --group --prefix-colors auto --timings \"pnpm:lint:*(!fix)\"",
69
+ "lint:fix": "concurrently --group --prefix-colors auto --timings \"pnpm:lint:*:fix\" && pnpm format",
70
+ "lint:format": "prettier . --cache --check",
71
+ "lint:js": "eslint . --cache",
72
+ "lint:js:fix": "eslint . --fix",
73
+ "node-test": "mocha test/**/*.js",
74
+ "node-test-with-coverage": "nyc --reporter lcov pnpm node-test",
75
+ "start": "ember serve",
76
+ "test": "pnpm lint && pnpm node-test"
89
77
  }
90
- }
78
+ }
@@ -1,10 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = function findByName(arr, name) {
4
- let matches = (arr || []).filter((item) => {
5
- if (item.name === name) {
6
- return item;
7
- }
8
- });
9
- return matches[0];
10
- };