-
Notifications
You must be signed in to change notification settings - Fork 137
/
scenarios.ts
171 lines (148 loc) · 7.55 KB
/
scenarios.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
import { Scenarios, Project } from 'scenario-tester';
import { dirname } from 'path';
export async function lts_3_28(project: Project) {
project.linkDevDependency('ember-source', { baseDir: __dirname, resolveName: 'ember-source' });
project.linkDevDependency('ember-cli', { baseDir: __dirname, resolveName: 'ember-cli' });
project.linkDevDependency('ember-data', { baseDir: __dirname, resolveName: 'ember-data-latest' });
project.linkDevDependency('@ember/test-helpers', { baseDir: __dirname, resolveName: 'ember-test-helpers-2' });
}
async function lts_4_4(project: Project) {
project.linkDevDependency('ember-source', { baseDir: __dirname, resolveName: 'ember-source-4.4' });
project.linkDevDependency('ember-cli', { baseDir: __dirname, resolveName: 'ember-cli-4.4' });
project.linkDevDependency('ember-data', { baseDir: __dirname, resolveName: 'ember-data-latest' });
}
async function lts_4_8(project: Project) {
project.linkDevDependency('ember-source', { baseDir: __dirname, resolveName: 'ember-source-4.8' });
project.linkDevDependency('ember-cli', { baseDir: __dirname, resolveName: 'ember-cli-4.8' });
project.linkDevDependency('ember-data', { baseDir: __dirname, resolveName: 'ember-data-4.8' });
}
async function lts_4_12(project: Project) {
project.linkDevDependency('ember-source', { baseDir: __dirname, resolveName: 'ember-source-4.12' });
project.linkDevDependency('ember-cli', { baseDir: __dirname, resolveName: 'ember-cli-4.12' });
project.linkDevDependency('ember-data', { baseDir: __dirname, resolveName: 'ember-data-4.12' });
}
async function lts_5_4(project: Project) {
project.linkDevDependency('ember-source', { baseDir: __dirname, resolveName: 'ember-source-5.4' });
project.linkDevDependency('ember-cli', { baseDir: __dirname, resolveName: 'ember-cli-5.4' });
project.linkDevDependency('ember-data', { baseDir: __dirname, resolveName: 'ember-data-5.3' });
project.linkDevDependency('ember-cli-babel', { baseDir: __dirname, resolveName: 'ember-cli-babel-latest' });
project.linkDevDependency('@ember/test-waiters', { baseDir: __dirname, resolveName: '@ember/test-waiters' });
}
async function lts_5_8(project: Project) {
project.linkDevDependency('ember-source', { baseDir: __dirname, resolveName: 'ember-source-5.8' });
project.linkDevDependency('ember-cli', { baseDir: __dirname, resolveName: 'ember-cli-5.8' });
project.linkDevDependency('ember-data', { baseDir: __dirname, resolveName: 'ember-data-5.3' });
project.linkDevDependency('ember-cli-babel', { baseDir: __dirname, resolveName: 'ember-cli-babel-latest' });
project.linkDevDependency('@ember/test-waiters', { baseDir: __dirname, resolveName: '@ember/test-waiters' });
}
async function release(project: Project) {
project.linkDevDependency('ember-source', { baseDir: __dirname, resolveName: 'ember-source-5.11' });
project.linkDevDependency('ember-cli', { baseDir: __dirname, resolveName: 'ember-cli-latest' });
project.linkDevDependency('ember-data', { baseDir: __dirname, resolveName: 'ember-data-latest' });
project.linkDevDependency('@ember/test-waiters', { baseDir: __dirname, resolveName: '@ember/test-waiters' });
project.linkDevDependency('ember-qunit', { baseDir: __dirname, resolveName: 'ember-qunit-7' });
project.linkDevDependency('ember-cli-babel', { baseDir: __dirname, resolveName: 'ember-cli-babel-latest' });
project.linkDevDependency('@babel/core', { baseDir: __dirname });
}
async function beta(project: Project) {
project.linkDevDependency('ember-source', { baseDir: __dirname, resolveName: 'ember-source-beta' });
project.linkDevDependency('ember-cli', { baseDir: __dirname, resolveName: 'ember-cli-beta' });
project.linkDevDependency('ember-data', { baseDir: __dirname, resolveName: 'ember-data-latest' });
project.linkDevDependency('ember-qunit', { baseDir: __dirname, resolveName: 'ember-qunit-7' });
project.linkDevDependency('ember-cli-babel', { baseDir: __dirname, resolveName: 'ember-cli-babel-latest' });
project.linkDevDependency('@babel/core', { baseDir: __dirname });
}
async function canary(project: Project) {
project.linkDevDependency('ember-source', { baseDir: __dirname, resolveName: 'ember-source-canary' });
project.linkDevDependency('ember-cli', { baseDir: __dirname, resolveName: 'ember-cli-beta' });
project.linkDevDependency('ember-data', { baseDir: __dirname, resolveName: 'ember-data-latest' });
project.linkDevDependency('ember-qunit', { baseDir: __dirname, resolveName: 'ember-qunit-7' });
project.linkDevDependency('ember-cli-babel', { baseDir: __dirname, resolveName: 'ember-cli-babel-latest' });
}
export function supportMatrix(scenarios: Scenarios) {
return (
scenarios
.expand({
lts_3_28,
lts_4_4,
lts_5_8,
release,
canary,
})
// we are skipping these scenarios for now and will likely add them back in one-by one once the
// new vite based system is working as we like
.skip('lts_3_28')
.skip('lts_4_4')
.skip('lts_5_8')
);
}
export function fullSupportMatrix(scenarios: Scenarios) {
return (
scenarios
.expand({
lts_3_28,
lts_4_4,
lts_4_8,
lts_4_12,
lts_5_4,
lts_5_8,
release,
beta,
canary,
})
// we are skipping these scenarios for now and will likely add them back in one-by one once the
// new vite based system is working as we like
.skip('lts_3_28')
.skip('lts_4_4')
.skip('lts_4_8')
.skip('lts_4_12')
.skip('lts_5_4')
);
}
export function baseAddon(as: 'dummy-app' | 'dependency' = 'dependency') {
return Project.fromDir(
dirname(require.resolve('../addon-template/package.json')),
as === 'dummy-app' ? { linkDevDeps: true } : { linkDeps: true }
);
}
export function baseV2Addon() {
return Project.fromDir(dirname(require.resolve('../v2-addon-template/package.json')), { linkDeps: true });
}
export function baseApp() {
return Project.fromDir(dirname(require.resolve('../app-template/package.json')), { linkDevDeps: true });
}
export function baseTSApp() {
return Project.fromDir(dirname(require.resolve('../ts-app-template/package.json')), { linkDevDeps: true });
}
export function baseTSAppClassic() {
return Project.fromDir(dirname(require.resolve('../ts-app-template-classic/package.json')), { linkDevDeps: true });
}
export function baseViteApp() {
return Project.fromDir(dirname(require.resolve('../vite-app/package.json')), { linkDevDeps: true });
}
export const appScenarios = supportMatrix(Scenarios.fromProject(baseApp));
export const wideAppScenarios = fullSupportMatrix(Scenarios.fromProject(baseApp));
// we're standardizing on Ember's native types, which become available starting
// at 4.8. So we're not going to run type tests on older releases that don't
// support them.
export const tsAppScenarios = supportMatrix(Scenarios.fromProject(baseTSApp)).skip('lts_3_28').skip('lts_4_4');
export const tsAppClassicScenarios = supportMatrix(Scenarios.fromProject(baseTSAppClassic))
.skip('lts_3_28')
.skip('lts_4_4');
export const dummyAppScenarios = supportMatrix(Scenarios.fromProject(() => baseAddon('dummy-app')));
// renames a v1 app
export function renameApp(project: Project, newName: string) {
let oldName = project.pkg.name;
let target = new RegExp('\\b' + oldName + '\\b', 'g');
function rename(files: Project['files']) {
for (let [path, content] of Object.entries(files)) {
if (typeof content === 'string') {
files[path] = content.replace(target, newName);
} else if (content) {
rename(content);
}
}
}
rename(project.files);
project.pkg.name = newName;
}