mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-28 11:10:12 +08:00
ci: add configuration for legacy projects
In some cases, there are still legacy projects, prior to migrations and we should not use `webdriverUpdate` and we should use headless chrome.
This commit is contained in:
parent
0a4c86bac5
commit
a30ca72074
@ -48,27 +48,82 @@ export async function createProject(name: string, ...args: string[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function prepareProjectForE2e(name) {
|
export async function prepareProjectForE2e(name) {
|
||||||
const argv: string[] = getGlobalVariable('argv');
|
const argv: string[] = getGlobalVariable(
|
||||||
|
'argv',
|
||||||
|
);
|
||||||
|
|
||||||
await git('config', 'user.email', 'angular-core+e2e@google.com');
|
await git(
|
||||||
await git('config', 'user.name', 'Angular CLI E2e');
|
'config',
|
||||||
await git('config', 'commit.gpgSign', 'false');
|
'user.email',
|
||||||
await useBuiltPackages();
|
'angular-core+e2e@google.com',
|
||||||
await useCIChrome('e2e');
|
);
|
||||||
await useCIChrome('');
|
await git(
|
||||||
await useDevKitSnapshots();
|
'config',
|
||||||
await argv['ng2'] ? useNg2() : Promise.resolve();
|
'user.name',
|
||||||
await argv['ng4'] ? useNg4() : Promise.resolve();
|
'Angular CLI E2e',
|
||||||
await argv['ng-snapshots'] || argv['ng-tag'] ? useSha() : Promise.resolve();
|
);
|
||||||
await console.log(`Project ${name} created... Installing npm.`);
|
await git(
|
||||||
await silentNpm('install');
|
'config',
|
||||||
await useCIDefaults(name);
|
'commit.gpgSign',
|
||||||
// Force sourcemaps to be from the root of the filesystem.
|
'false',
|
||||||
await updateJsonFile('tsconfig.json', json => {
|
);
|
||||||
json['compilerOptions']['sourceRoot'] = '/';
|
await useBuiltPackages();
|
||||||
});
|
await useCIChrome(
|
||||||
await gitCommit('prepare-project-for-e2e');
|
'e2e',
|
||||||
}
|
);
|
||||||
|
await useCIChrome(
|
||||||
|
'',
|
||||||
|
);
|
||||||
|
|
||||||
|
// legacy projects
|
||||||
|
await useCIChrome(
|
||||||
|
'src',
|
||||||
|
);
|
||||||
|
|
||||||
|
await useDevKitSnapshots();
|
||||||
|
(await argv[
|
||||||
|
'ng2'
|
||||||
|
])
|
||||||
|
? useNg2()
|
||||||
|
: Promise.resolve();
|
||||||
|
(await argv[
|
||||||
|
'ng4'
|
||||||
|
])
|
||||||
|
? useNg4()
|
||||||
|
: Promise.resolve();
|
||||||
|
(await argv[
|
||||||
|
'ng-snapshots'
|
||||||
|
]) ||
|
||||||
|
argv[
|
||||||
|
'ng-tag'
|
||||||
|
]
|
||||||
|
? useSha()
|
||||||
|
: Promise.resolve();
|
||||||
|
await console.log(
|
||||||
|
`Project ${name} created... Installing npm.`,
|
||||||
|
);
|
||||||
|
await silentNpm(
|
||||||
|
'install',
|
||||||
|
);
|
||||||
|
await useCIDefaults(
|
||||||
|
name,
|
||||||
|
);
|
||||||
|
// Force sourcemaps to be from the root of the filesystem.
|
||||||
|
await updateJsonFile(
|
||||||
|
'tsconfig.json',
|
||||||
|
json => {
|
||||||
|
json[
|
||||||
|
'compilerOptions'
|
||||||
|
][
|
||||||
|
'sourceRoot'
|
||||||
|
] =
|
||||||
|
'/';
|
||||||
|
},
|
||||||
|
);
|
||||||
|
await gitCommit(
|
||||||
|
'prepare-project-for-e2e',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export function useDevKit(devkitRoot: string) {
|
export function useDevKit(devkitRoot: string) {
|
||||||
@ -99,7 +154,7 @@ export function useDevKit(devkitRoot: string) {
|
|||||||
export function useDevKitSnapshots() {
|
export function useDevKitSnapshots() {
|
||||||
return updateJsonFile('package.json', json => {
|
return updateJsonFile('package.json', json => {
|
||||||
// TODO: actually add these.
|
// TODO: actually add these.
|
||||||
// These were not working on any test that ran `npm i`.
|
// These were not working on any test that ran `npm i`.
|
||||||
// json['devDependencies']['@angular-devkit/build-angular'] =
|
// json['devDependencies']['@angular-devkit/build-angular'] =
|
||||||
// 'github:angular/angular-devkit-build-angular-builds';
|
// 'github:angular/angular-devkit-build-angular-builds';
|
||||||
// // By adding build-ng-packagr preemptively, adding a lib will not update it.
|
// // By adding build-ng-packagr preemptively, adding a lib will not update it.
|
||||||
@ -119,8 +174,9 @@ export function useBuiltPackages() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const packageName of Object.keys(packages)) {
|
for (const packageName of Object.keys(packages)) {
|
||||||
if (json['dependencies'].hasOwnProperty(packageName)) {
|
if (json['dependencies'].hasOwnProperty(packageName)
|
||||||
json['dependencies'][packageName] = packages[packageName].tar;
|
) {
|
||||||
|
json['dependencies'][packageName] = packages[packageName].tar;
|
||||||
} else if (json['devDependencies'].hasOwnProperty(packageName)) {
|
} else if (json['devDependencies'].hasOwnProperty(packageName)) {
|
||||||
json['devDependencies'][packageName] = packages[packageName].tar;
|
json['devDependencies'][packageName] = packages[packageName].tar;
|
||||||
}
|
}
|
||||||
@ -212,6 +268,13 @@ export function useCIDefaults(projectName = 'test-project') {
|
|||||||
if (appTargets.e2e) {
|
if (appTargets.e2e) {
|
||||||
appTargets.e2e.options.webdriverUpdate = false;
|
appTargets.e2e.options.webdriverUpdate = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// legacy project structure
|
||||||
|
const e2eProject = workspaceJson.projects[projectName + '-e2e'];
|
||||||
|
if (e2eProject){
|
||||||
|
const e2eTargets = e2eProject.targets || e2eProject.architect;
|
||||||
|
e2eTargets.e2e.options.webdriverUpdate = false;
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.then(() => updateJsonFile('package.json', json => {
|
.then(() => updateJsonFile('package.json', json => {
|
||||||
// Use matching versions of Chrome and Webdriver.
|
// Use matching versions of Chrome and Webdriver.
|
||||||
@ -223,8 +286,9 @@ export function useCIDefaults(projectName = 'test-project') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function useCIChrome(projectDir: string) {
|
export function useCIChrome(projectDir: string) {
|
||||||
const protractorConf = `${projectDir}/protractor.conf.js`;
|
const dir = projectDir ? projectDir + '/' : '';
|
||||||
const karmaConf = `${projectDir ? projectDir + '/' : ''}karma.conf.js`;
|
const protractorConf = `${dir}protractor.conf.js`;
|
||||||
|
const karmaConf = `${dir}karma.conf.js`;
|
||||||
|
|
||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
.then(() => updateJsonFile('package.json', json => {
|
.then(() => updateJsonFile('package.json', json => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user