Skip to content

Commit ad40b3b

Browse files
chore(scripts): normalize paths and include typeRoots for Windows (ionic-team#11933)
Short description of what this resolves: Allows our e2e tests to run on a Windows machine Changes proposed in this pull request: Normalize paths using path.join() Add typeRoots to the root tsconfig file Change the spawnedCommand based on the OS Fixes: ionic-team#11551
1 parent cb5d505 commit ad40b3b

14 files changed

Lines changed: 54 additions & 43 deletions

scripts/demos/copy.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ var path = require('path');
44
module.exports = {
55
copyAssets: {
66
src: [path.join(path.dirname(process.env.IONIC_APP_ENTRY_POINT), '..', 'assets', '**', '*')],
7-
dest: '{{WWW}}/assets'
7+
dest: path.join('{{WWW}}', 'assets')
88
},
99
copyIndexContent: {
1010
src: [path.join(process.cwd(), 'scripts', 'demos', 'index.html')],
1111
dest: '{{WWW}}'
1212
},
1313
copyFonts: {
1414
src: [`${process.cwd()}/node_modules/ionicons/dist/fonts/**/*`, `${process.cwd()}/src/fonts/**/*`],
15-
dest: '{{WWW}}/assets/fonts'
15+
dest: path.join('{{WWW}}', 'assets', 'fonts')
1616
},
1717
copyPolyfills: {
1818
src: [path.join(process.cwd(), 'dist', 'demos', 'polyfills', 'polyfills.js')],

scripts/demos/watch.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var path = require('path');
22

3-
var watch = require('../../node_modules/@ionic/app-scripts/dist/watch');
3+
var watch = require(path.join('..', '..', 'node_modules', '@ionic', 'app-scripts', 'dist', 'watch'));
44

55
var entryPointDirectory = path.dirname(process.env.IONIC_APP_ENTRY_POINT)
66

@@ -9,7 +9,7 @@ module.exports = {
99
paths: [path.join(entryPointDirectory, '..', '**', '*.(ts|html|s(c|a)ss)')],
1010
options: { ignored: [path.join(entryPointDirectory, '..', '**', '*.spec.ts'),
1111
path.join(entryPointDirectory, '..', '**', '*.e2e.ts'),
12-
'**/*.DS_Store'] },
12+
path.join('**', '*.DS_Store')] },
1313
callback: watch.buildUpdate
1414
}
1515
}

scripts/e2e/copy.config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ var path = require('path');
44
module.exports = {
55
copyAssets: {
66
src: [path.join(path.dirname(process.env.IONIC_APP_ENTRY_POINT), '..', 'assets', '**', '*')],
7-
dest: '{{WWW}}/assets'
7+
dest: path.join('{{WWW}}', 'assets')
88
},
99
copyIndexContent: {
1010
src: [path.join(process.cwd(), 'scripts', 'e2e', 'index.html')],
1111
dest: '{{WWW}}'
1212
},
1313
copyFonts: {
14-
src: [`${process.cwd()}/node_modules/ionicons/dist/fonts/**/*`, `${process.cwd()}/src/fonts/**/*`],
15-
dest: '{{WWW}}/assets/fonts'
14+
src: [path.join(process.cwd(), 'node_modules', 'ionicons', 'dist', 'fonts', '**', '*'), path.join(process.cwd(), 'src', 'fonts', '**', '*')],
15+
dest: path.join('{{WWW}}', 'assets', 'fonts')
1616
},
1717
copyPolyfills: {
1818
src: [path.join(process.cwd(), 'dist', 'e2e', 'polyfills', 'polyfills.ng.js')],

scripts/e2e/e2e-publish.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module.exports = function(options) {
44
var fs = require('fs');
55
var path = require('path');
66
var request = require('request');
7-
var inputDir = path.join(__dirname, '../../dist/e2e/tests');
7+
var inputDir = path.join(__dirname, '..', '..' , 'dist', 'e2e', 'tests');
88
var uploadQueue = [];
99

1010
var ignoreFiles = /(\/test\/|\/ts\/|\/q\/|\/ionic-site\/|\/docs\/|\/examples\/|\/inquirer\/|\/lodash\/|\/tooling\/|\/colors\/|\/bin\/|\.ts$|\.bin|\.map$|\.md$|\.git|\.scss$|\.yml$|\.yaml$|\.dart$|\.txt|\.npm|bower|DS_Store|LICENSE)/i;
@@ -13,15 +13,15 @@ module.exports = function(options) {
1313
fs.readdir(dir, function(err, list) {
1414

1515
list.forEach(function(file) {
16-
var url = urlPath + '/' + file;
16+
var url = path.join(urlPath, file);
1717

1818

19-
fs.stat(dir + '/' + file, function(err, stat) {
19+
fs.stat(path.join(dir, file), function(err, stat) {
2020
if (stat && stat.isDirectory()) {
21-
uploadFiles(dir + '/' + file, urlPath + '/' + file);
21+
uploadFiles(path.join(dir, file), path.join(urlPath, file);
2222
} else {
2323
if ( shouldProcessPath (url) ){
24-
uploadFile(url, dir + '/' + file);
24+
uploadFile(url, path.join(dir, file));
2525
}
2626
}
2727
});

scripts/gulp/constants.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const BUNDLES = 'bundles';
2020
export const SITE_NAME = 'ionic-site';
2121

2222
// File Paths
23-
export const PROJECT_ROOT = join(__dirname, '../..');
23+
export const PROJECT_ROOT = join(__dirname, '..', '..');
2424
export const DEMOS_ROOT = join(PROJECT_ROOT, DEMOS_NAME);
2525
export const DEMOS_SRC_ROOT = join(DEMOS_ROOT, SRC_NAME);
2626
export const DIST_ROOT = join(PROJECT_ROOT, DIST_NAME);
@@ -45,7 +45,7 @@ export const WORKERS_SRC = join(SCRIPTS_ROOT, 'workers');
4545

4646
// NPM
4747
export const NPM_VENDOR_FILES = [
48-
'@angular', 'core-js/client', 'rxjs', 'systemjs/dist', 'zone.js/dist'
48+
'@angular', join('core-js', 'client'), 'rxjs', join('systemjs', 'dist'), join('zone.js', 'dist')
4949
];
5050

5151

scripts/gulp/tasks/build.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { task } from 'gulp';
2+
import { join } from 'path';
23
import { DIST_BUILD_ROOT, DIST_BUILD_ES2015_ROOT, DIST_BUILD_UMD_ROOT, ES5, ES_2015, PROJECT_ROOT, UMD_MODULE } from '../constants';
34
import { copySourceToDest, createTempTsConfig, deleteFiles, runNgc, runTsc } from '../util';
45

@@ -7,8 +8,8 @@ export function buildIonicAngularUmd(excludeSpec: boolean, stripDebug: boolean,
78
const stream = copySourceToDest(DIST_BUILD_UMD_ROOT, excludeSpec, true, stripDebug);
89
stream.on('end', () => {
910
// the source files are copied, copy over a tsconfig from
10-
createTempTsConfig(['./**/*.ts'], ES5, UMD_MODULE, `${PROJECT_ROOT}/tsconfig.json`, `${DIST_BUILD_UMD_ROOT}/tsconfig.json`);
11-
runNgc(`${DIST_BUILD_UMD_ROOT}/tsconfig.json`, (err) => {
11+
createTempTsConfig([join('.', '**', '*.ts')], ES5, UMD_MODULE, join(PROJECT_ROOT, 'tsconfig.json'), join(DIST_BUILD_UMD_ROOT, 'tsconfig.json'));
12+
runNgc(join(DIST_BUILD_UMD_ROOT, 'tsconfig.json'), (err) => {
1213
if (err) {
1314
done(err);
1415
return;
@@ -27,8 +28,8 @@ export function buildIonicAngularUmdTsc(excludeSpec: boolean, stripDebug: boolea
2728
const stream = copySourceToDest(DIST_BUILD_UMD_ROOT, excludeSpec, true, stripDebug);
2829
stream.on('end', () => {
2930
// the source files are copied, copy over a tsconfig from
30-
createTempTsConfig(['./**/*.ts'], ES5, UMD_MODULE, `${PROJECT_ROOT}/tsconfig.json`, `${DIST_BUILD_UMD_ROOT}/tsconfig.json`);
31-
runTsc(`${DIST_BUILD_UMD_ROOT}/tsconfig.json`, (err) => {
31+
createTempTsConfig([join('.', '**', '*.ts')], ES5, UMD_MODULE, join(PROJECT_ROOT, 'tsconfig.json'), join(DIST_BUILD_UMD_ROOT, 'tsconfig.json'));
32+
runTsc(join(DIST_BUILD_UMD_ROOT, 'tsconfig.json'), (err) => {
3233
if (err) {
3334
done(err);
3435
return;
@@ -48,8 +49,8 @@ export function buildIonicAngularEsm(stripDebug: boolean, done: Function) {
4849
const stream = copySourceToDest(DIST_BUILD_ROOT, true, true, stripDebug);
4950
stream.on('end', () => {
5051
// the source files are copied, copy over a tsconfig from
51-
createTempTsConfig(['./**/*.ts'], ES5, ES_2015, `${PROJECT_ROOT}/tsconfig.json`, `${DIST_BUILD_ROOT}/tsconfig.json`);
52-
runNgc(`${DIST_BUILD_ROOT}/tsconfig.json`, (err) => {
52+
createTempTsConfig([join('.', '**', '*.ts')], ES5, ES_2015, join(PROJECT_ROOT, 'tsconfig.json'), join(DIST_BUILD_ROOT, 'tsconfig.json'));
53+
runNgc(join(DIST_BUILD_ROOT, 'tsconfig.json'), (err) => {
5354
if (err) {
5455
done(err);
5556
return;
@@ -67,8 +68,8 @@ export function buildIonicPureEs6(stripDebug: boolean, done: Function) {
6768
const stream = copySourceToDest(DIST_BUILD_ES2015_ROOT, true, true, stripDebug);
6869
stream.on('end', () => {
6970
// the source files are copied, copy over a tsconfig from
70-
createTempTsConfig(['./**/*.ts'], ES_2015, ES_2015, `${PROJECT_ROOT}/tsconfig.json`, `${DIST_BUILD_ES2015_ROOT}/tsconfig.json`);
71-
runNgc(`${DIST_BUILD_ES2015_ROOT}/tsconfig.json`, (err) => {
71+
createTempTsConfig([join('.', '**', '*.ts')], ES_2015, ES_2015, join(PROJECT_ROOT, 'tsconfig.json'), join(DIST_BUILD_ES2015_ROOT, 'tsconfig.json'));
72+
runNgc(join(DIST_BUILD_ES2015_ROOT, 'tsconfig.json'), (err) => {
7273
if (err) {
7374
done(err);
7475
return;

scripts/gulp/tasks/e2e.dev.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,5 @@ function serveTest(folderInfo: any) {
4747
const appNgModulePath = join(dirname(appEntryPoint), 'app.module.ts');
4848
const distDir = join(distTestRoot, 'www');
4949

50-
return runAppScriptsServe(folderInfo.componentName + '/' + folderInfo.componentTest, appEntryPoint, appNgModulePath, ionicAngularDir, distDir, pathToWriteFile, ionicAngularDir, sassConfigPath, copyConfigPath, null);
50+
return runAppScriptsServe(join(folderInfo.componentName, folderInfo.componentTest), appEntryPoint, appNgModulePath, ionicAngularDir, distDir, pathToWriteFile, ionicAngularDir, sassConfigPath, copyConfigPath, null);
5151
}

scripts/gulp/tasks/e2e.prod.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ task('e2e.prepare', (done: Function) => {
2121

2222
task('e2e.prepareSass', (done: Function) => {
2323
const version = `E2E-${createTimestamp()}`;
24-
writeFileSync(join(SRC_ROOT, 'themes/version.scss'), `$ionic-version: "${version}";`);
24+
writeFileSync(join(SRC_ROOT, 'themes', 'version.scss'), `$ionic-version: "${version}";`);
2525
done();
2626
});
2727

@@ -41,7 +41,7 @@ task('e2e.prod', ['e2e.prepare'], (done: Function) => {
4141
});
4242

4343
function e2eComponentExists(folderInfo: any): boolean {
44-
let componentPath = `${SRC_COMPONENTS_ROOT}/${folderInfo.componentName}/test/${folderInfo.componentTest}/app`;
44+
let componentPath = join(SRC_COMPONENTS_ROOT, folderInfo.componentName, 'test', folderInfo.componentTest, 'app');
4545

4646
try {
4747
accessSync(componentPath);
@@ -62,11 +62,11 @@ function filterE2eTestfiles() {
6262
const folderInfo = getFolderInfo();
6363
if (folderInfo && folderInfo.componentName && folderInfo.componentTest) {
6464
if (!e2eComponentExists(folderInfo)) {
65-
console.log(`Can't find E2E test "${folderInfo.componentName}/test/${folderInfo.componentTest}". Make sure that the test exists and you are passing the correct folder.`);
65+
console.log('Cannot find E2E test ', join(folderInfo.componentName, 'test', folderInfo.componentTest), '. Make sure that the test exists and you are passing the correct folder.');
6666
return [];
6767
}
6868
const filtered = entryPoints.filter(entryPoint => {
69-
return entryPoint.indexOf(`${folderInfo.componentName}/test/${folderInfo.componentTest}`) >= 0;
69+
return entryPoint.indexOf(join(folderInfo.componentName, 'test', folderInfo.componentTest)) >= 0;
7070
});
7171
return filtered;
7272
}
@@ -121,7 +121,7 @@ function buildTest(filePath: string) {
121121
const relativePathFromComponents = relative(dirname(SRC_COMPONENTS_ROOT), srcTestRoot);
122122
const distTestRoot = join(process.cwd(), 'dist', 'e2e', relativePathFromComponents);
123123

124-
const includeGlob = [ join(ionicAngularDir, '**', '*.ts')];
124+
const includeGlob = [join(ionicAngularDir, '**', '*.ts')];
125125
const pathToWriteFile = join(distTestRoot, 'tsconfig.json');
126126
const pathToReadFile = join(PROJECT_ROOT, 'tsconfig.json');
127127

@@ -154,7 +154,7 @@ function copyProtractorTestContent(filePaths: string[]): Promise<any> {
154154
}
155155

156156
function applyTemplate(filePathContent: Map<string, string>) {
157-
const buildConfig = require('../../build/config');
157+
const buildConfig = require(join('..', '..', 'build', 'config'));
158158
const templateFileContent = readFileSync(join(SCRIPTS_ROOT, 'e2e', 'e2e.template.js'));
159159
const templater = template(templateFileContent.toString());
160160
const modifiedMap = new Map<string, string>();
@@ -235,7 +235,7 @@ task('e2e.polyfill', (done: Function) => {
235235
return done();
236236
}
237237

238-
writePolyfills('dist/e2e/polyfills').then(() => {
238+
writePolyfills(join('dist', 'e2e', 'polyfills')).then(() => {
239239
done();
240240
}).catch(err => {
241241
done(err);
@@ -249,9 +249,8 @@ task('e2e.openProd', (done: Function) => {
249249
task('e2e.open', (done: Function) => {
250250
const folderInfo = getFolderInfo();
251251
if (folderInfo && folderInfo.componentName && folderInfo.componentTest) {
252-
const filePath = `${folderInfo.componentName}/test/${folderInfo.componentTest}/www/index.html`;
253-
const fullPath = join(DIST_E2E_COMPONENTS_ROOT, filePath);
254-
const spawnedCommand = spawn('open', [fullPath]);
252+
const filePath = join(DIST_E2E_COMPONENTS_ROOT, folderInfo.componentName, 'test', folderInfo.componentTest, 'www', 'index.html');
253+
const spawnedCommand = spawn('open', [filePath]);
255254

256255
spawnedCommand.on('close', (code: number) => {
257256
done();

scripts/gulp/tasks/polyfill.source.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { task } from 'gulp';
22
import { writePolyfills } from '../util';
3+
import { join } from 'path';
34

45

56
task('src.polyfill', (done: Function) => {
6-
writePolyfills('scripts/polyfill').then(() => {
7+
writePolyfills(join('scripts', 'polyfills')).then(() => {
78
done();
89
}).catch(err => {
910
done(err);

scripts/gulp/tasks/polyfill.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
import { task, src, dest } from 'gulp';
22
import { writePolyfills } from '../util';
3+
import { join } from 'path';
34

45
task('polyfill', ['polyfill.copy-readme', 'polyfill.write']);
56

67
task('polyfill.write', (done: Function) => {
7-
writePolyfills('dist/ionic-angular/polyfills').then(() => {
8+
writePolyfills(join('dist', 'ionic-angular', 'polyfills')).then(() => {
89
done();
910
}).catch(err => {
1011
done(err);
1112
});
1213
});
1314

1415
task('polyfill.copy-readme', (done: Function) => {
15-
return src('scripts/polyfill/readme.md')
16-
.pipe(dest('dist/ionic-angular/polyfills/'), done);
16+
return src(join('scripts', 'polyfill', 'readme.md'))
17+
.pipe(dest(join('dist', 'ionic-angular', 'polyfills')), done);
1718
});

0 commit comments

Comments
 (0)